aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Bottomley <jejb@mulgrave.il.steeleye.com>2006-11-22 13:06:44 -0500
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2006-11-22 13:06:44 -0500
commit0bd2af46839ad6262d25714a6ec0365db9d6b98f (patch)
treedcced72d230d69fd0c5816ac6dd03ab84799a93e
parente138a5d2356729b8752e88520cc1525fae9794ac (diff)
parentf26b90440cd74c78fe10c9bd5160809704a9627c (diff)
Merge ../scsi-rc-fixes-2.6
-rw-r--r--.gitignore1
-rw-r--r--CREDITS8
-rw-r--r--Documentation/ABI/testing/sysfs-power17
-rw-r--r--Documentation/DocBook/Makefile2
-rw-r--r--Documentation/DocBook/filesystems.tmpl (renamed from Documentation/DocBook/journal-api.tmpl)252
-rw-r--r--Documentation/DocBook/kernel-api.tmpl60
-rw-r--r--Documentation/HOWTO20
-rw-r--r--Documentation/MSI-HOWTO.txt63
-rw-r--r--Documentation/accounting/getdelays.c2
-rw-r--r--Documentation/cpu-hotplug.txt148
-rw-r--r--Documentation/feature-removal-schedule.txt14
-rw-r--r--Documentation/filesystems/00-INDEX2
-rw-r--r--Documentation/filesystems/ext4.txt236
-rw-r--r--Documentation/filesystems/udf.txt13
-rw-r--r--Documentation/hwmon/adm92402
-rw-r--r--Documentation/hwmon/f71805f2
-rw-r--r--Documentation/hwmon/k8temp13
-rw-r--r--Documentation/hwmon/smsc47m14
-rw-r--r--Documentation/hwmon/w83627ehf6
-rw-r--r--Documentation/ibm-acpi.txt75
-rw-r--r--Documentation/input/xpad.txt115
-rw-r--r--Documentation/kernel-doc-nano-HOWTO.txt2
-rw-r--r--Documentation/kernel-parameters.txt9
-rw-r--r--Documentation/kprobes.txt5
-rw-r--r--Documentation/lockdep-design.txt6
-rw-r--r--Documentation/memory-barriers.txt4
-rw-r--r--Documentation/mips/time.README49
-rw-r--r--Documentation/power/interface.txt13
-rw-r--r--Documentation/s390/CommonIO2
-rw-r--r--Documentation/s390/cds.txt52
-rw-r--r--Documentation/s390/driver-model.txt3
-rw-r--r--Documentation/sound/alsa/ALSA-Configuration.txt2
-rw-r--r--Documentation/sysctl/kernel.txt5
-rw-r--r--Documentation/usb/usb-serial.txt6
-rw-r--r--Documentation/video4linux/CARDLIST.cx882
-rw-r--r--Documentation/watchdog/src/watchdog-simple.c2
-rw-r--r--MAINTAINERS52
-rw-r--r--Makefile11
-rw-r--r--arch/alpha/kernel/alpha_ksyms.c95
-rw-r--r--arch/alpha/kernel/core_irongate.c2
-rw-r--r--arch/alpha/kernel/irq_alpha.c3
-rw-r--r--arch/alpha/kernel/pci-noop.c1
-rw-r--r--arch/alpha/kernel/pci_iommu.c17
-rw-r--r--arch/alpha/kernel/process.c5
-rw-r--r--arch/alpha/kernel/setup.c6
-rw-r--r--arch/alpha/kernel/smp.c8
-rw-r--r--arch/alpha/kernel/srm_env.c84
-rw-r--r--arch/alpha/kernel/time.c1
-rw-r--r--arch/alpha/kernel/vmlinux.lds.S8
-rw-r--r--arch/alpha/mm/numa.c2
-rw-r--r--arch/arm/Makefile6
-rw-r--r--arch/arm/common/dmabounce.c3
-rw-r--r--arch/arm/configs/at91rm9200dk_defconfig2
-rw-r--r--arch/arm/configs/at91rm9200ek_defconfig2
-rw-r--r--arch/arm/configs/ateb9200_defconfig2
-rw-r--r--arch/arm/configs/collie_defconfig2
-rw-r--r--arch/arm/configs/csb337_defconfig2
-rw-r--r--arch/arm/configs/csb637_defconfig2
-rw-r--r--arch/arm/configs/ixp4xx_defconfig6
-rw-r--r--arch/arm/configs/kafa_defconfig2
-rw-r--r--arch/arm/configs/omap_h2_1610_defconfig2
-rw-r--r--arch/arm/configs/onearm_defconfig2
-rw-r--r--arch/arm/configs/realview-smp_defconfig (renamed from arch/arm/configs/bast_defconfig)793
-rw-r--r--arch/arm/configs/s3c2410_defconfig114
-rw-r--r--arch/arm/configs/smdk2410_defconfig735
-rw-r--r--arch/arm/configs/versatile_defconfig2
-rw-r--r--arch/arm/kernel/armksyms.c6
-rw-r--r--arch/arm/kernel/setup.c4
-rw-r--r--arch/arm/kernel/smp.c20
-rw-r--r--arch/arm/kernel/time.c7
-rw-r--r--arch/arm/kernel/vmlinux.lds.S8
-rw-r--r--arch/arm/mach-footbridge/dc21285.c1
-rw-r--r--arch/arm/mach-iop32x/n2100.c2
-rw-r--r--arch/arm/mach-ixp2000/ixdp2400.c6
-rw-r--r--arch/arm/mach-ixp2000/ixdp2800.c6
-rw-r--r--arch/arm/mach-ixp2000/ixdp2x00.c7
-rw-r--r--arch/arm/mach-ixp4xx/common.c60
-rw-r--r--arch/arm/mach-lh7a40x/Kconfig4
-rw-r--r--arch/arm/mach-lh7a40x/common.h2
-rw-r--r--arch/arm/mach-pnx4008/core.c69
-rw-r--r--arch/arm/mach-pxa/lubbock.c2
-rw-r--r--arch/arm/mach-s3c2410/gpio.c21
-rw-r--r--arch/arm/mach-s3c2410/s3c2410-gpio.c19
-rw-r--r--arch/arm/mach-sa1100/cpu-sa1110.c10
-rw-r--r--arch/arm/mach-versatile/core.c4
-rw-r--r--arch/arm/mach-versatile/pci.c32
-rw-r--r--arch/arm/mm/init.c61
-rw-r--r--arch/arm/mm/proc-xscale.S2
-rw-r--r--arch/arm/oprofile/op_counter.h2
-rw-r--r--arch/arm/oprofile/op_model_xscale.c3
-rw-r--r--arch/arm/tools/mach-types18
-rw-r--r--arch/arm/vfp/vfpdouble.c2
-rw-r--r--arch/arm/vfp/vfpmodule.c3
-rw-r--r--arch/arm26/kernel/armksyms.c8
-rw-r--r--arch/avr32/Makefile21
-rw-r--r--arch/avr32/boards/atstk1000/setup.c9
-rw-r--r--arch/avr32/boot/images/Makefile4
-rw-r--r--arch/avr32/configs/atstk1002_defconfig253
-rw-r--r--arch/avr32/kernel/avr32_ksyms.c9
-rw-r--r--arch/avr32/kernel/head.S3
-rw-r--r--arch/avr32/kernel/kprobes.c2
-rw-r--r--arch/avr32/kernel/module.c4
-rw-r--r--arch/avr32/kernel/ptrace.c2
-rw-r--r--arch/avr32/kernel/syscall-stubs.S9
-rw-r--r--arch/avr32/kernel/syscall_table.S1
-rw-r--r--arch/avr32/kernel/time.c10
-rw-r--r--arch/avr32/kernel/vmlinux.lds.c8
-rw-r--r--arch/avr32/lib/Makefile1
-rw-r--r--arch/avr32/lib/findbit.S3
-rw-r--r--arch/avr32/lib/io-readsb.S49
-rw-r--r--arch/avr32/lib/io-writesb.S52
-rw-r--r--arch/avr32/mach-at32ap/extint.c5
-rw-r--r--arch/avr32/mach-at32ap/hsmc.h4
-rw-r--r--arch/avr32/mach-at32ap/intc.c7
-rw-r--r--arch/avr32/mach-at32ap/intc.h6
-rw-r--r--arch/avr32/mach-at32ap/pio.h6
-rw-r--r--arch/avr32/mach-at32ap/sm.h6
-rw-r--r--arch/avr32/mm/init.c2
-rw-r--r--arch/avr32/mm/ioremap.c2
-rw-r--r--arch/cris/arch-v32/drivers/cryptocop.c1
-rw-r--r--arch/frv/kernel/vmlinux.lds.S8
-rw-r--r--arch/h8300/kernel/vmlinux.lds.S8
-rw-r--r--arch/i386/Kconfig.cpu3
-rw-r--r--arch/i386/Makefile8
-rw-r--r--arch/i386/defconfig30
-rw-r--r--arch/i386/kernel/acpi/boot.c20
-rw-r--r--arch/i386/kernel/acpi/cstate.c122
-rw-r--r--arch/i386/kernel/acpi/earlyquirk.c8
-rw-r--r--arch/i386/kernel/alternative.c4
-rw-r--r--arch/i386/kernel/apm.c39
-rw-r--r--arch/i386/kernel/cpu/mcheck/therm_throt.c21
-rw-r--r--arch/i386/kernel/head.S2
-rw-r--r--arch/i386/kernel/i8253.c2
-rw-r--r--arch/i386/kernel/i8259.c7
-rw-r--r--arch/i386/kernel/io_apic.c115
-rw-r--r--arch/i386/kernel/irq.c2
-rw-r--r--arch/i386/kernel/kprobes.c22
-rw-r--r--arch/i386/kernel/microcode.c10
-rw-r--r--arch/i386/kernel/nmi.c10
-rw-r--r--arch/i386/kernel/process.c32
-rw-r--r--arch/i386/kernel/setup.c15
-rw-r--r--arch/i386/kernel/syscall_table.S1
-rw-r--r--arch/i386/kernel/traps.c10
-rw-r--r--arch/i386/kernel/tsc.c6
-rw-r--r--arch/i386/kernel/vmlinux.lds.S9
-rw-r--r--arch/i386/lib/usercopy.c5
-rw-r--r--arch/i386/mach-visws/visws_apic.c7
-rw-r--r--arch/i386/mach-voyager/voyager_basic.c6
-rw-r--r--arch/i386/mach-voyager/voyager_smp.c52
-rw-r--r--arch/i386/mm/discontig.c11
-rw-r--r--arch/i386/pci/common.c60
-rw-r--r--arch/i386/pci/fixup.c16
-rw-r--r--arch/i386/pci/i386.c9
-rw-r--r--arch/i386/pci/irq.c4
-rw-r--r--arch/i386/pci/mmconfig.c35
-rw-r--r--arch/i386/pci/pci.h8
-rw-r--r--arch/ia64/Kconfig10
-rw-r--r--arch/ia64/configs/sn2_defconfig219
-rw-r--r--arch/ia64/hp/sim/Kconfig4
-rw-r--r--arch/ia64/hp/sim/hpsim_irq.c2
-rw-r--r--arch/ia64/kernel/acpi.c9
-rw-r--r--arch/ia64/kernel/iosapic.c6
-rw-r--r--arch/ia64/kernel/irq.c4
-rw-r--r--arch/ia64/kernel/irq_ia64.c24
-rw-r--r--arch/ia64/kernel/irq_lsapic.c2
-rw-r--r--arch/ia64/kernel/mca_drv.c95
-rw-r--r--arch/ia64/kernel/pal.S58
-rw-r--r--arch/ia64/kernel/perfmon.c3
-rw-r--r--arch/ia64/kernel/sal.c11
-rw-r--r--arch/ia64/kernel/setup.c2
-rw-r--r--arch/ia64/kernel/smp.c12
-rw-r--r--arch/ia64/kernel/time.c6
-rw-r--r--arch/ia64/kernel/vmlinux.lds.S8
-rw-r--r--arch/ia64/mm/contig.c1
-rw-r--r--arch/ia64/mm/discontig.c1
-rw-r--r--arch/ia64/mm/hugetlbpage.c4
-rw-r--r--arch/ia64/pci/Makefile2
-rw-r--r--arch/ia64/pci/fixup.c69
-rw-r--r--arch/ia64/sn/kernel/bte.c9
-rw-r--r--arch/ia64/sn/kernel/irq.c2
-rw-r--r--arch/ia64/sn/kernel/setup.c12
-rw-r--r--arch/m32r/kernel/setup.c8
-rw-r--r--arch/m32r/kernel/setup_mappi.c16
-rw-r--r--arch/m32r/kernel/signal.c6
-rw-r--r--arch/m32r/kernel/smp.c2
-rw-r--r--arch/m32r/kernel/sys_m32r.c6
-rw-r--r--arch/m32r/kernel/traps.c2
-rw-r--r--arch/m32r/kernel/vmlinux.lds.S8
-rw-r--r--arch/m68k/kernel/m68k_ksyms.c51
-rw-r--r--arch/m68k/kernel/process.c11
-rw-r--r--arch/m68k/kernel/setup.c15
-rw-r--r--arch/m68k/kernel/traps.c6
-rw-r--r--arch/m68k/kernel/vmlinux-std.lds8
-rw-r--r--arch/m68k/kernel/vmlinux-sun3.lds8
-rw-r--r--arch/m68k/mm/kmap.c4
-rw-r--r--arch/m68k/mm/memory.c8
-rw-r--r--arch/m68k/mm/sun3kmap.c11
-rw-r--r--arch/m68k/sun3/Makefile2
-rw-r--r--arch/m68k/sun3/idprom.c3
-rw-r--r--arch/m68k/sun3/sun3_ksyms.c13
-rw-r--r--arch/m68k/sun3/sun3dvma.c6
-rw-r--r--arch/m68knommu/kernel/setup.c2
-rw-r--r--arch/m68knommu/kernel/syscalltable.S37
-rw-r--r--arch/m68knommu/kernel/time.c2
-rw-r--r--arch/m68knommu/kernel/vmlinux.lds.S8
-rw-r--r--arch/m68knommu/platform/5307/ints.c17
-rw-r--r--arch/mips/Kconfig8
-rw-r--r--arch/mips/Makefile17
-rw-r--r--arch/mips/au1000/common/dbdma.c2
-rw-r--r--arch/mips/au1000/common/prom.c2
-rw-r--r--arch/mips/au1000/common/setup.c2
-rw-r--r--arch/mips/au1000/common/time.c106
-rw-r--r--arch/mips/configs/bigsur_defconfig102
-rw-r--r--arch/mips/configs/pnx8550-jbs_defconfig384
-rw-r--r--arch/mips/configs/pnx8550-v2pci_defconfig441
-rw-r--r--arch/mips/configs/tb0287_defconfig182
-rw-r--r--arch/mips/dec/time.c9
-rw-r--r--arch/mips/emma2rh/common/irq_emma2rh.c2
-rw-r--r--arch/mips/emma2rh/markeins/irq_markeins.c4
-rw-r--r--arch/mips/emma2rh/markeins/platform.c88
-rw-r--r--arch/mips/gt64120/common/time.c4
-rw-r--r--arch/mips/gt64120/ev64120/setup.c2
-rw-r--r--arch/mips/gt64120/momenco_ocelot/setup.c3
-rw-r--r--arch/mips/jazz/setup.c2
-rw-r--r--arch/mips/jmr3927/rbhma3100/irq.c3
-rw-r--r--arch/mips/jmr3927/rbhma3100/setup.c40
-rw-r--r--arch/mips/kernel/asm-offsets.c2
-rw-r--r--arch/mips/kernel/entry.S3
-rw-r--r--arch/mips/kernel/head.S3
-rw-r--r--arch/mips/kernel/irq.c42
-rw-r--r--arch/mips/kernel/linux32.c4
-rw-r--r--arch/mips/kernel/process.c8
-rw-r--r--arch/mips/kernel/r4k_switch.S5
-rw-r--r--arch/mips/kernel/scall32-o32.S5
-rw-r--r--arch/mips/kernel/scall64-64.S3
-rw-r--r--arch/mips/kernel/scall64-n32.S5
-rw-r--r--arch/mips/kernel/scall64-o32.S5
-rw-r--r--arch/mips/kernel/setup.c6
-rw-r--r--arch/mips/kernel/smp-mt.c154
-rw-r--r--arch/mips/kernel/smp.c2
-rw-r--r--arch/mips/kernel/smtc-asm.S7
-rw-r--r--arch/mips/kernel/smtc.c1
-rw-r--r--arch/mips/kernel/stacktrace.c2
-rw-r--r--arch/mips/kernel/time.c319
-rw-r--r--arch/mips/kernel/traps.c2
-rw-r--r--arch/mips/kernel/vmlinux.lds.S18
-rw-r--r--arch/mips/lib-64/dump_tlb.c6
-rw-r--r--arch/mips/mips-boards/generic/memory.c2
-rw-r--r--arch/mips/mips-boards/generic/pci.c2
-rw-r--r--arch/mips/mips-boards/generic/time.c9
-rw-r--r--arch/mips/mips-boards/malta/malta_int.c3
-rw-r--r--arch/mips/mips-boards/sim/sim_time.c2
-rw-r--r--arch/mips/mm/c-sb1.c20
-rw-r--r--arch/mips/mm/init.c167
-rw-r--r--arch/mips/mm/ioremap.c2
-rw-r--r--arch/mips/mm/pg-r4k.c30
-rw-r--r--arch/mips/mm/pgtable-32.c7
-rw-r--r--arch/mips/mm/pgtable-64.c11
-rw-r--r--arch/mips/mm/tlbex.c13
-rw-r--r--arch/mips/momentum/ocelot_3/Makefile2
-rw-r--r--arch/mips/momentum/ocelot_3/ocelot_3_fpga.h6
-rw-r--r--arch/mips/momentum/ocelot_3/platform.c235
-rw-r--r--arch/mips/momentum/ocelot_3/prom.c58
-rw-r--r--arch/mips/momentum/ocelot_3/setup.c2
-rw-r--r--arch/mips/momentum/ocelot_c/Makefile2
-rw-r--r--arch/mips/momentum/ocelot_c/ocelot_c_fpga.h6
-rw-r--r--arch/mips/momentum/ocelot_c/platform.c201
-rw-r--r--arch/mips/momentum/ocelot_c/prom.c60
-rw-r--r--arch/mips/momentum/ocelot_c/setup.c23
-rw-r--r--arch/mips/momentum/ocelot_g/gt-irq.c8
-rw-r--r--arch/mips/momentum/ocelot_g/ocelot_pld.h6
-rw-r--r--arch/mips/momentum/ocelot_g/setup.c5
-rw-r--r--arch/mips/oprofile/op_impl.h2
-rw-r--r--arch/mips/oprofile/op_model_mipsxx.c12
-rw-r--r--arch/mips/oprofile/op_model_rm9000.c3
-rw-r--r--arch/mips/pci/Makefile2
-rw-r--r--arch/mips/pci/fixup-ev64120.c34
-rw-r--r--arch/mips/pci/pci-ev64120.c21
-rw-r--r--arch/mips/philips/pnx8550/common/time.c4
-rw-r--r--arch/mips/pmc-sierra/yosemite/i2c-yosemite.c2
-rw-r--r--arch/mips/pmc-sierra/yosemite/smp.c6
-rw-r--r--arch/mips/sgi-ip27/ip27-irq.c23
-rw-r--r--arch/mips/sgi-ip27/ip27-klnuma.c2
-rw-r--r--arch/mips/sgi-ip27/ip27-timer.c18
-rw-r--r--arch/mips/sgi-ip32/ip32-reset.c2
-rw-r--r--arch/mips/sibyte/bcm1480/smp.c6
-rw-r--r--arch/mips/sibyte/bcm1480/time.c33
-rw-r--r--arch/mips/sibyte/sb1250/bcm1250_tbprof.c4
-rw-r--r--arch/mips/sibyte/sb1250/bus_watcher.c2
-rw-r--r--arch/mips/sibyte/sb1250/time.c28
-rw-r--r--arch/mips/tx4927/common/smsc_fdc37m81x.c172
-rw-r--r--arch/mips/tx4927/common/tx4927_setup.c2
-rw-r--r--arch/mips/tx4938/toshiba_rbtx4938/spi_txx9.c8
-rw-r--r--arch/parisc/kernel/parisc_ksyms.c4
-rw-r--r--arch/parisc/kernel/vmlinux.lds.S8
-rw-r--r--arch/powerpc/Kconfig11
-rw-r--r--arch/powerpc/boot/Makefile2
-rwxr-xr-xarch/powerpc/boot/wrapper4
-rw-r--r--arch/powerpc/boot/zImage.lds.S5
-rw-r--r--arch/powerpc/configs/cell_defconfig19
-rw-r--r--arch/powerpc/configs/mpc834x_itx_defconfig2
-rw-r--r--arch/powerpc/configs/pseries_defconfig1
-rw-r--r--arch/powerpc/kernel/Makefile1
-rw-r--r--arch/powerpc/kernel/btext.c2
-rw-r--r--arch/powerpc/kernel/cputable.c88
-rw-r--r--arch/powerpc/kernel/head_64.S48
-rw-r--r--arch/powerpc/kernel/iommu.c77
-rw-r--r--arch/powerpc/kernel/misc_32.S74
-rw-r--r--arch/powerpc/kernel/misc_64.S124
-rw-r--r--arch/powerpc/kernel/module_32.c39
-rw-r--r--arch/powerpc/kernel/module_64.c49
-rw-r--r--arch/powerpc/kernel/pci_32.c12
-rw-r--r--arch/powerpc/kernel/pci_64.c10
-rw-r--r--arch/powerpc/kernel/perfmon_fsl_booke.c221
-rw-r--r--arch/powerpc/kernel/pmc.c2
-rw-r--r--arch/powerpc/kernel/process.c10
-rw-r--r--arch/powerpc/kernel/prom.c8
-rw-r--r--arch/powerpc/kernel/rtas_flash.c47
-rw-r--r--arch/powerpc/kernel/setup_32.c8
-rw-r--r--arch/powerpc/kernel/setup_64.c11
-rw-r--r--arch/powerpc/kernel/time.c105
-rw-r--r--arch/powerpc/kernel/traps.c21
-rw-r--r--arch/powerpc/kernel/vdso.c43
-rw-r--r--arch/powerpc/kernel/vdso32/vdso32.lds.S12
-rw-r--r--arch/powerpc/kernel/vdso64/gettimeofday.S6
-rw-r--r--arch/powerpc/kernel/vdso64/vdso64.lds.S10
-rw-r--r--arch/powerpc/kernel/vio.c4
-rw-r--r--arch/powerpc/kernel/vmlinux.lds.S8
-rw-r--r--arch/powerpc/lib/sstep.c5
-rw-r--r--arch/powerpc/mm/hugetlbpage.c11
-rw-r--r--arch/powerpc/mm/mem.c7
-rw-r--r--arch/powerpc/mm/numa.c6
-rw-r--r--arch/powerpc/oprofile/Makefile2
-rw-r--r--arch/powerpc/oprofile/common.c10
-rw-r--r--arch/powerpc/oprofile/op_model_7450.c2
-rw-r--r--arch/powerpc/oprofile/op_model_fsl_booke.c170
-rw-r--r--arch/powerpc/oprofile/op_model_power4.c4
-rw-r--r--arch/powerpc/oprofile/op_model_rs64.c2
-rw-r--r--arch/powerpc/platforms/83xx/Kconfig13
-rw-r--r--arch/powerpc/platforms/83xx/Makefile2
-rw-r--r--arch/powerpc/platforms/83xx/mpc832x_mds.c19
-rw-r--r--arch/powerpc/platforms/83xx/mpc834x_itx.c4
-rw-r--r--arch/powerpc/platforms/83xx/mpc8360e_pb.c19
-rw-r--r--arch/powerpc/platforms/cell/spu_base.c56
-rw-r--r--arch/powerpc/platforms/cell/spufs/file.c3
-rw-r--r--arch/powerpc/platforms/cell/spufs/hw_ops.c2
-rw-r--r--arch/powerpc/platforms/chrp/setup.c4
-rw-r--r--arch/powerpc/platforms/iseries/iommu.c11
-rw-r--r--arch/powerpc/platforms/iseries/setup.c5
-rw-r--r--arch/powerpc/platforms/powermac/sleep.S3
-rw-r--r--arch/powerpc/platforms/pseries/iommu.c35
-rw-r--r--arch/powerpc/sysdev/dart.h1
-rw-r--r--arch/powerpc/sysdev/dart_iommu.c8
-rw-r--r--arch/powerpc/sysdev/i8259.c5
-rw-r--r--arch/powerpc/sysdev/ipic.c4
-rw-r--r--arch/powerpc/sysdev/qe_lib/qe.c3
-rw-r--r--arch/powerpc/sysdev/qe_lib/ucc.c2
-rw-r--r--arch/powerpc/sysdev/qe_lib/ucc_fast.c2
-rw-r--r--arch/powerpc/sysdev/qe_lib/ucc_slow.c2
-rw-r--r--arch/powerpc/sysdev/tsi108_dev.c4
-rw-r--r--arch/ppc/boot/simple/relocate.S6
-rw-r--r--arch/ppc/kernel/misc.S74
-rw-r--r--arch/ppc/kernel/setup.c10
-rw-r--r--arch/ppc/kernel/time.c4
-rw-r--r--arch/ppc/kernel/traps.c18
-rw-r--r--arch/ppc/kernel/vmlinux.lds.S8
-rw-r--r--arch/ppc/mm/init.c7
-rw-r--r--arch/ppc/platforms/mpc8272ads_setup.c4
-rw-r--r--arch/ppc/platforms/mpc866ads_setup.c4
-rw-r--r--arch/ppc/platforms/mpc885ads_setup.c4
-rw-r--r--arch/s390/Kconfig3
-rw-r--r--arch/s390/appldata/appldata_base.c3
-rw-r--r--arch/s390/defconfig13
-rw-r--r--arch/s390/kernel/compat_linux.c6
-rw-r--r--arch/s390/kernel/compat_signal.c12
-rw-r--r--arch/s390/kernel/compat_wrapper.S2
-rw-r--r--arch/s390/kernel/s390_ext.c4
-rw-r--r--arch/s390/kernel/s390_ksyms.c1
-rw-r--r--arch/s390/kernel/setup.c55
-rw-r--r--arch/s390/kernel/signal.c12
-rw-r--r--arch/s390/kernel/stacktrace.c17
-rw-r--r--arch/s390/kernel/syscalls.S1
-rw-r--r--arch/s390/kernel/traps.c20
-rw-r--r--arch/s390/kernel/vmlinux.lds.S8
-rw-r--r--arch/s390/kernel/vtime.c8
-rw-r--r--arch/s390/mm/init.c32
-rw-r--r--arch/sh/Kconfig4
-rw-r--r--arch/sh/boards/hp6xx/hp6xx_apm.c6
-rw-r--r--arch/sh/boards/hp6xx/pm.c2
-rw-r--r--arch/sh/boards/hp6xx/setup.c2
-rw-r--r--arch/sh/boards/landisk/landisk_pwb.c2
-rw-r--r--arch/sh/boards/mpc1211/setup.c5
-rw-r--r--arch/sh/boards/renesas/hs7751rvoip/io.c2
-rw-r--r--arch/sh/boards/renesas/hs7751rvoip/irq.c2
-rw-r--r--arch/sh/boards/renesas/hs7751rvoip/setup.c19
-rw-r--r--arch/sh/boards/renesas/r7780rp/io.c2
-rw-r--r--arch/sh/boards/renesas/r7780rp/irq.c108
-rw-r--r--arch/sh/boards/renesas/r7780rp/setup.c2
-rw-r--r--arch/sh/boards/renesas/rts7751r2d/io.c4
-rw-r--r--arch/sh/boards/renesas/rts7751r2d/irq.c6
-rw-r--r--arch/sh/boards/renesas/rts7751r2d/led.c15
-rw-r--r--arch/sh/boards/renesas/rts7751r2d/setup.c2
-rw-r--r--arch/sh/boards/renesas/sh7710voipgw/setup.c105
-rw-r--r--arch/sh/boards/se/7300/irq.c20
-rw-r--r--arch/sh/boards/se/73180/irq.c47
-rw-r--r--arch/sh/boards/se/7343/irq.c90
-rw-r--r--arch/sh/boards/se/770x/irq.c80
-rw-r--r--arch/sh/boards/se/7751/irq.c85
-rw-r--r--arch/sh/boards/sh03/setup.c13
-rw-r--r--arch/sh/boards/shmin/setup.c2
-rw-r--r--arch/sh/boards/snapgear/setup.c14
-rw-r--r--arch/sh/boards/titan/setup.c12
-rw-r--r--arch/sh/cchips/hd6446x/hd64461/setup.c2
-rw-r--r--arch/sh/cchips/hd6446x/hd64465/gpio.c2
-rw-r--r--arch/sh/cchips/hd6446x/hd64465/setup.c2
-rw-r--r--arch/sh/cchips/voyagergx/irq.c25
-rw-r--r--arch/sh/configs/r7780rp_defconfig174
-rw-r--r--arch/sh/configs/titan_defconfig101
-rw-r--r--arch/sh/drivers/dma/dma-g2.c2
-rw-r--r--arch/sh/drivers/dma/dma-pvr2.c2
-rw-r--r--arch/sh/drivers/dma/dma-sh.c48
-rw-r--r--arch/sh/drivers/pci/ops-r7780rp.c2
-rw-r--r--arch/sh/drivers/pci/ops-rts7751r2d.c24
-rw-r--r--arch/sh/drivers/pci/pci-sh7751.c4
-rw-r--r--arch/sh/drivers/pci/pci-st40.c2
-rw-r--r--arch/sh/kernel/cpu/irq/intc2.c275
-rw-r--r--arch/sh/kernel/cpu/irq/ipr.c183
-rw-r--r--arch/sh/kernel/cpu/irq/pint.c8
-rw-r--r--arch/sh/kernel/cpu/sh3/ex.S204
-rw-r--r--arch/sh/kernel/cpu/sh4/ex.S507
-rw-r--r--arch/sh/kernel/cpu/sh4/setup-sh7760.c63
-rw-r--r--arch/sh/kernel/cpu/sh4/setup-sh7780.c27
-rw-r--r--arch/sh/kernel/entry.S43
-rw-r--r--arch/sh/kernel/irq.c42
-rw-r--r--arch/sh/kernel/process.c42
-rw-r--r--arch/sh/kernel/syscalls.S3
-rw-r--r--arch/sh/kernel/time.c9
-rw-r--r--arch/sh/kernel/timers/timer-tmu.c63
-rw-r--r--arch/sh/kernel/traps.c167
-rw-r--r--arch/sh/kernel/vmlinux.lds.S8
-rw-r--r--arch/sh/mm/consistent.c1
-rw-r--r--arch/sh64/kernel/vmlinux.lds.S8
-rw-r--r--arch/sparc/Kconfig7
-rw-r--r--arch/sparc/Makefile2
-rw-r--r--arch/sparc/kernel/ebus.c8
-rw-r--r--arch/sparc/kernel/entry.S3
-rw-r--r--arch/sparc/kernel/irq.c2
-rw-r--r--arch/sparc/kernel/of_device.c2
-rw-r--r--arch/sparc/kernel/pcic.c1
-rw-r--r--arch/sparc/kernel/setup.c12
-rw-r--r--arch/sparc/kernel/systbls.S5
-rw-r--r--arch/sparc/kernel/time.c2
-rw-r--r--arch/sparc/kernel/vmlinux.lds.S12
-rw-r--r--arch/sparc/mm/srmmu.c2
-rw-r--r--arch/sparc/oprofile/Kconfig17
-rw-r--r--arch/sparc/oprofile/Makefile9
-rw-r--r--arch/sparc/oprofile/init.c23
-rw-r--r--arch/sparc64/defconfig25
-rw-r--r--arch/sparc64/kernel/central.c4
-rw-r--r--arch/sparc64/kernel/ebus.c8
-rw-r--r--arch/sparc64/kernel/entry.S3
-rw-r--r--arch/sparc64/kernel/isa.c8
-rw-r--r--arch/sparc64/kernel/of_device.c42
-rw-r--r--arch/sparc64/kernel/pci_common.c29
-rw-r--r--arch/sparc64/kernel/pci_iommu.c2
-rw-r--r--arch/sparc64/kernel/pci_sabre.c23
-rw-r--r--arch/sparc64/kernel/prom.c51
-rw-r--r--arch/sparc64/kernel/setup.c12
-rw-r--r--arch/sparc64/kernel/systbls.S8
-rw-r--r--arch/sparc64/kernel/traps.c8
-rw-r--r--arch/sparc64/kernel/vmlinux.lds.S8
-rw-r--r--arch/um/Kconfig41
-rw-r--r--arch/um/Kconfig.char5
-rw-r--r--arch/um/Kconfig.i38649
-rw-r--r--arch/um/Makefile21
-rw-r--r--arch/um/Makefile-i3864
-rw-r--r--arch/um/Makefile-x86_648
-rw-r--r--arch/um/drivers/cow_sys.h1
-rw-r--r--arch/um/drivers/daemon_user.c1
-rw-r--r--arch/um/drivers/fd.c1
-rw-r--r--arch/um/drivers/mcast_user.c1
-rw-r--r--arch/um/drivers/mconsole_kern.c23
-rw-r--r--arch/um/drivers/mconsole_user.c1
-rw-r--r--arch/um/drivers/mmapper_kern.c3
-rw-r--r--arch/um/drivers/net_user.c1
-rw-r--r--arch/um/drivers/pcap_user.c1
-rw-r--r--arch/um/drivers/port_user.c1
-rw-r--r--arch/um/drivers/pty.c1
-rw-r--r--arch/um/drivers/slip_user.c1
-rw-r--r--arch/um/drivers/tty.c1
-rw-r--r--arch/um/drivers/ubd_kern.c319
-rw-r--r--arch/um/drivers/xterm.c2
-rw-r--r--arch/um/include/common-offsets.h11
-rw-r--r--arch/um/include/kern_util.h1
-rw-r--r--arch/um/include/longjmp.h3
-rw-r--r--arch/um/include/mconsole.h1
-rw-r--r--arch/um/include/mconsole_kern.h1
-rw-r--r--arch/um/include/os.h1
-rw-r--r--arch/um/include/sysdep-i386/barrier.h9
-rw-r--r--arch/um/include/sysdep-i386/kernel-offsets.h5
-rw-r--r--arch/um/include/sysdep-x86_64/barrier.h7
-rw-r--r--arch/um/include/sysdep-x86_64/kernel-offsets.h5
-rw-r--r--arch/um/include/um_malloc.h17
-rw-r--r--arch/um/include/user.h6
-rw-r--r--arch/um/include/user_util.h1
-rw-r--r--arch/um/kernel/dyn.lds.S1
-rw-r--r--arch/um/kernel/irq.c1
-rw-r--r--arch/um/kernel/process.c1
-rw-r--r--arch/um/kernel/skas/mmu.c5
-rw-r--r--arch/um/kernel/tt/tracer.c1
-rw-r--r--arch/um/kernel/tt/uaccess_user.c6
-rw-r--r--arch/um/kernel/uml.lds.S1
-rw-r--r--arch/um/os-Linux/drivers/ethertap_user.c1
-rw-r--r--arch/um/os-Linux/helper.c54
-rw-r--r--arch/um/os-Linux/irq.c1
-rw-r--r--arch/um/os-Linux/main.c1
-rw-r--r--arch/um/os-Linux/process.c1
-rw-r--r--arch/um/os-Linux/sigio.c1
-rw-r--r--arch/um/os-Linux/signal.c31
-rw-r--r--arch/um/os-Linux/skas/process.c2
-rw-r--r--arch/um/os-Linux/sys-i386/tls.c3
-rw-r--r--arch/um/os-Linux/time.c3
-rw-r--r--arch/um/os-Linux/tls.c1
-rw-r--r--arch/um/os-Linux/tt.c1
-rw-r--r--arch/um/os-Linux/util.c9
-rw-r--r--arch/um/sys-i386/unmap.c11
-rw-r--r--arch/um/sys-x86_64/ksyms.c3
-rw-r--r--arch/um/sys-x86_64/stub_segv.c1
-rw-r--r--arch/um/sys-x86_64/unmap.c11
-rw-r--r--arch/v850/kernel/vmlinux.lds.S8
-rw-r--r--arch/x86_64/Makefile8
-rw-r--r--arch/x86_64/boot/setup.S5
-rw-r--r--arch/x86_64/defconfig30
-rw-r--r--arch/x86_64/ia32/ia32_signal.c5
-rw-r--r--arch/x86_64/ia32/ptrace32.c2
-rw-r--r--arch/x86_64/kernel/e820.c18
-rw-r--r--arch/x86_64/kernel/early-quirks.c17
-rw-r--r--arch/x86_64/kernel/entry.S10
-rw-r--r--arch/x86_64/kernel/genapic_flat.c2
-rw-r--r--arch/x86_64/kernel/i8259.c7
-rw-r--r--arch/x86_64/kernel/io_apic.c197
-rw-r--r--arch/x86_64/kernel/irq.c2
-rw-r--r--arch/x86_64/kernel/pci-calgary.c44
-rw-r--r--arch/x86_64/kernel/process.c29
-rw-r--r--arch/x86_64/kernel/smp.c3
-rw-r--r--arch/x86_64/kernel/smpboot.c7
-rw-r--r--arch/x86_64/kernel/time.c13
-rw-r--r--arch/x86_64/kernel/traps.c6
-rw-r--r--arch/x86_64/kernel/vmlinux.lds.S12
-rw-r--r--arch/x86_64/kernel/vsmp.c1
-rw-r--r--arch/x86_64/kernel/vsyscall.c47
-rw-r--r--arch/x86_64/mm/init.c33
-rw-r--r--arch/x86_64/mm/numa.c8
-rw-r--r--arch/x86_64/mm/srat.c4
-rw-r--r--arch/x86_64/pci/Makefile2
-rw-r--r--arch/x86_64/pci/mmconfig.c37
-rw-r--r--arch/xtensa/kernel/vmlinux.lds.S8
-rw-r--r--block/cfq-iosched.c16
-rw-r--r--block/elevator.c17
-rw-r--r--block/ll_rw_blk.c108
-rw-r--r--block/scsi_ioctl.c5
-rw-r--r--crypto/Kconfig4
-rw-r--r--crypto/api.c15
-rw-r--r--drivers/Kconfig6
-rw-r--r--drivers/acpi/acpi_memhotplug.c14
-rw-r--r--drivers/acpi/asus_acpi.c67
-rw-r--r--drivers/acpi/battery.c14
-rw-r--r--drivers/acpi/ec.c1096
-rw-r--r--drivers/acpi/events/evmisc.c14
-rw-r--r--drivers/acpi/events/evrgnini.c13
-rw-r--r--drivers/acpi/ibm_acpi.c2
-rw-r--r--drivers/acpi/motherboard.c6
-rw-r--r--drivers/acpi/pci_link.c2
-rw-r--r--drivers/acpi/power.c9
-rw-r--r--drivers/acpi/processor_core.c2
-rw-r--r--drivers/acpi/processor_idle.c111
-rw-r--r--drivers/acpi/sbs.c20
-rw-r--r--drivers/acpi/tables/tbget.c2
-rw-r--r--drivers/acpi/tables/tbrsdt.c2
-rw-r--r--drivers/ata/Kconfig1
-rw-r--r--drivers/ata/ahci.c13
-rw-r--r--drivers/ata/ata_piix.c41
-rw-r--r--drivers/ata/libata-core.c9
-rw-r--r--drivers/ata/libata-scsi.c48
-rw-r--r--drivers/ata/libata-sff.c9
-rw-r--r--drivers/ata/libata.h1
-rw-r--r--drivers/ata/pata_amd.c2
-rw-r--r--drivers/ata/pata_artop.c2
-rw-r--r--drivers/ata/pata_hpt37x.c19
-rw-r--r--drivers/ata/pata_qdi.c2
-rw-r--r--drivers/ata/sata_nv.c12
-rw-r--r--drivers/ata/sata_promise.c1
-rw-r--r--drivers/ata/sata_sis.c21
-rw-r--r--drivers/ata/sata_via.c2
-rw-r--r--drivers/atm/ambassador.c4
-rw-r--r--drivers/atm/firestream.c4
-rw-r--r--drivers/atm/horizon.c6
-rw-r--r--drivers/atm/nicstar.c4
-rw-r--r--drivers/base/Kconfig4
-rw-r--r--drivers/base/bus.c108
-rw-r--r--drivers/base/class.c5
-rw-r--r--drivers/base/core.c26
-rw-r--r--drivers/base/dd.c34
-rw-r--r--drivers/base/dmapool.c13
-rw-r--r--drivers/base/topology.c3
-rw-r--r--drivers/block/DAC960.h4
-rw-r--r--drivers/block/amiflop.c13
-rw-r--r--drivers/block/aoe/aoe.h30
-rw-r--r--drivers/block/aoe/aoeblk.c45
-rw-r--r--drivers/block/aoe/aoechr.c18
-rw-r--r--drivers/block/aoe/aoecmd.c303
-rw-r--r--drivers/block/aoe/aoedev.c52
-rw-r--r--drivers/block/aoe/aoemain.c10
-rw-r--r--drivers/block/aoe/aoenet.c9
-rw-r--r--drivers/block/cciss.c36
-rw-r--r--drivers/block/cpqarray.c15
-rw-r--r--drivers/block/rd.c12
-rw-r--r--drivers/block/xd.c2
-rw-r--r--drivers/block/z2ram.c28
-rw-r--r--drivers/bluetooth/bcm203x.c17
-rw-r--r--drivers/bluetooth/bluecard_cs.c2
-rw-r--r--drivers/bluetooth/dtl1_cs.c1
-rw-r--r--drivers/bluetooth/hci_usb.c3
-rw-r--r--drivers/char/Kconfig10
-rw-r--r--drivers/char/agp/uninorth-agp.c54
-rw-r--r--drivers/char/drm/drm_bufs.c4
-rw-r--r--drivers/char/drm/drm_sysfs.c43
-rw-r--r--drivers/char/drm/mga_drv.c1
-rw-r--r--drivers/char/drm/r300_cmdbuf.c33
-rw-r--r--drivers/char/drm/radeon_state.c109
-rw-r--r--drivers/char/drm/savage_bci.c1
-rw-r--r--drivers/char/drm/savage_state.c2
-rw-r--r--drivers/char/epca.c32
-rw-r--r--drivers/char/ftape/zftape/zftape-buffers.c4
-rw-r--r--drivers/char/ip2/i2lib.c11
-rw-r--r--drivers/char/ip2/i2lib.h2
-rw-r--r--drivers/char/ip2/ip2main.c4
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c144
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c14
-rw-r--r--drivers/char/isicom.c3
-rw-r--r--drivers/char/mem.c5
-rw-r--r--drivers/char/moxa.c9
-rw-r--r--drivers/char/mspec.c8
-rw-r--r--drivers/char/random.c1
-rw-r--r--drivers/char/rio/host.h1
-rw-r--r--drivers/char/rio/rio_linux.c9
-rw-r--r--drivers/char/rio/rioctrl.c4
-rw-r--r--drivers/char/serial167.c52
-rw-r--r--drivers/char/specialix.c15
-rw-r--r--drivers/char/sx.c2
-rw-r--r--drivers/char/synclink.c4
-rw-r--r--drivers/char/tpm/tpm.c9
-rw-r--r--drivers/char/tpm/tpm_atmel.c10
-rw-r--r--drivers/char/tpm/tpm_nsc.c6
-rw-r--r--drivers/char/watchdog/Kconfig65
-rw-r--r--drivers/char/watchdog/Makefile4
-rw-r--r--drivers/char/watchdog/alim7101_wdt.c13
-rw-r--r--drivers/char/watchdog/at91rm9200_wdt.c (renamed from drivers/char/watchdog/at91_wdt.c)0
-rw-r--r--drivers/char/watchdog/iTCO_wdt.c21
-rw-r--r--drivers/char/watchdog/s3c2410_wdt.c5
-rw-r--r--drivers/char/watchdog/sc1200wdt.c9
-rw-r--r--drivers/char/watchdog/smsc37b787_wdt.c627
-rw-r--r--drivers/char/watchdog/w83627hf_wdt.c8
-rw-r--r--drivers/char/watchdog/w83697hf_wdt.c450
-rw-r--r--drivers/clocksource/acpi_pm.c6
-rw-r--r--drivers/cpufreq/Kconfig1
-rw-r--r--drivers/cpufreq/cpufreq.c2
-rw-r--r--drivers/edac/edac_mc.c45
-rw-r--r--drivers/eisa/eisa-bus.c22
-rw-r--r--drivers/fc4/fc.c28
-rw-r--r--drivers/fc4/fcp_impl.h15
-rw-r--r--drivers/firmware/dcdbas.c7
-rw-r--r--drivers/firmware/dell_rbu.c32
-rw-r--r--drivers/firmware/dmi_scan.c20
-rw-r--r--drivers/firmware/efivars.c7
-rw-r--r--drivers/hwmon/Kconfig10
-rw-r--r--drivers/hwmon/adm9240.c4
-rw-r--r--drivers/hwmon/lm78.c12
-rw-r--r--drivers/hwmon/smsc47m1.c11
-rw-r--r--drivers/hwmon/w83627ehf.c11
-rw-r--r--drivers/hwmon/w83781d.c30
-rw-r--r--drivers/hwmon/w83791d.c85
-rw-r--r--drivers/i2c/busses/i2c-isa.c2
-rw-r--r--drivers/i2c/busses/i2c-ixp4xx.c3
-rw-r--r--drivers/i2c/busses/i2c-pxa.c8
-rw-r--r--drivers/i2c/busses/scx200_acb.c7
-rw-r--r--drivers/ide/ide-cd.c9
-rw-r--r--drivers/ide/ide-taskfile.c13
-rw-r--r--drivers/ide/legacy/hd.c2
-rw-r--r--drivers/ide/pci/amd74xx.c7
-rw-r--r--drivers/ide/pci/generic.c29
-rw-r--r--drivers/ide/pci/sgiioc4.c2
-rw-r--r--drivers/ieee1394/eth1394.c20
-rw-r--r--drivers/ieee1394/ohci1394.c19
-rw-r--r--drivers/infiniband/core/addr.c28
-rw-r--r--drivers/infiniband/core/cma.c31
-rw-r--r--drivers/infiniband/core/mad.c2
-rw-r--r--drivers/infiniband/core/uverbs_cmd.c2
-rw-r--r--drivers/infiniband/hw/amso1100/c2.c5
-rw-r--r--drivers/infiniband/hw/amso1100/c2_alloc.c13
-rw-r--r--drivers/infiniband/hw/amso1100/c2_cq.c18
-rw-r--r--drivers/infiniband/hw/amso1100/c2_provider.c39
-rw-r--r--drivers/infiniband/hw/amso1100/c2_rnic.c64
-rw-r--r--drivers/infiniband/hw/ehca/Kconfig1
-rw-r--r--drivers/infiniband/hw/ehca/ehca_av.c5
-rw-r--r--drivers/infiniband/hw/ehca/ehca_hca.c17
-rw-r--r--drivers/infiniband/hw/ehca/ehca_irq.c17
-rw-r--r--drivers/infiniband/hw/ehca/ehca_iverbs.h8
-rw-r--r--drivers/infiniband/hw/ehca/ehca_main.c56
-rw-r--r--drivers/infiniband/hw/ehca/ehca_mrmw.c8
-rw-r--r--drivers/infiniband/hw/ehca/ehca_qp.c10
-rw-r--r--drivers/infiniband/hw/ehca/ehca_tools.h1
-rw-r--r--drivers/infiniband/hw/ehca/hipz_hw.h2
-rw-r--r--drivers/infiniband/hw/ipath/Kconfig2
-rw-r--r--drivers/infiniband/hw/ipath/Makefile5
-rw-r--r--drivers/infiniband/hw/ipath/ipath_diag.c65
-rw-r--r--drivers/infiniband/hw/ipath/ipath_driver.c31
-rw-r--r--drivers/infiniband/hw/ipath/ipath_iba6110.c117
-rw-r--r--drivers/infiniband/hw/ipath/ipath_iba6120.c8
-rw-r--r--drivers/infiniband/hw/ipath/ipath_intr.c10
-rw-r--r--drivers/infiniband/hw/ipath/ipath_kernel.h7
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cmd.c14
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cq.c7
-rw-r--r--drivers/infiniband/hw/mthca/mthca_qp.c19
-rw-r--r--drivers/infiniband/hw/mthca/mthca_srq.c8
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c15
-rw-r--r--drivers/infiniband/ulp/iser/iscsi_iser.c4
-rw-r--r--drivers/input/gameport/fm801-gp.c22
-rw-r--r--drivers/input/gameport/gameport.c18
-rw-r--r--drivers/input/keyboard/atkbd.c54
-rw-r--r--drivers/input/keyboard/corgikbd.c2
-rw-r--r--drivers/input/keyboard/lkkbd.c5
-rw-r--r--drivers/input/keyboard/locomokbd.c2
-rw-r--r--drivers/input/keyboard/spitzkbd.c2
-rw-r--r--drivers/input/misc/hp_sdc_rtc.c8
-rw-r--r--drivers/input/misc/wistron_btns.c2
-rw-r--r--drivers/input/serio/hil_mlc.c18
-rw-r--r--drivers/input/serio/hp_sdc.c4
-rw-r--r--drivers/input/serio/i8042.c13
-rw-r--r--drivers/input/serio/libps2.c3
-rw-r--r--drivers/input/serio/serio.c22
-rw-r--r--drivers/input/touchscreen/corgi_ts.c4
-rw-r--r--drivers/input/touchscreen/hp680_ts_input.c2
-rw-r--r--drivers/isdn/capi/capidrv.c3
-rw-r--r--drivers/isdn/gigaset/common.c2
-rw-r--r--drivers/isdn/hisax/Kconfig2
-rw-r--r--drivers/isdn/hisax/config.c6
-rw-r--r--drivers/isdn/hisax/diva.c26
-rw-r--r--drivers/isdn/hysdn/boardergo.c34
-rw-r--r--drivers/isdn/hysdn/hysdn_defs.h2
-rw-r--r--drivers/isdn/hysdn/hysdn_proclog.c17
-rw-r--r--drivers/isdn/hysdn/hysdn_sched.c20
-rw-r--r--drivers/isdn/i4l/isdn_common.c9
-rw-r--r--drivers/isdn/icn/icn.c3
-rw-r--r--drivers/isdn/isdnloop/isdnloop.c73
-rw-r--r--drivers/isdn/isdnloop/isdnloop.h1
-rw-r--r--drivers/isdn/pcbit/drv.c16
-rw-r--r--drivers/isdn/pcbit/layer2.c1
-rw-r--r--drivers/isdn/sc/init.c23
-rw-r--r--drivers/isdn/sc/packet.c14
-rw-r--r--drivers/isdn/sc/shmem.c2
-rw-r--r--drivers/leds/led-class.c26
-rw-r--r--drivers/leds/ledtrig-timer.c16
-rw-r--r--drivers/macintosh/windfarm_pm112.c11
-rw-r--r--drivers/macintosh/windfarm_pm81.c1
-rw-r--r--drivers/macintosh/windfarm_pm91.c1
-rw-r--r--drivers/mca/mca-bus.c28
-rw-r--r--drivers/md/bitmap.c12
-rw-r--r--drivers/md/dm-crypt.c14
-rw-r--r--drivers/md/dm-ioctl.c9
-rw-r--r--drivers/md/dm-raid1.c22
-rw-r--r--drivers/md/dm-round-robin.c2
-rw-r--r--drivers/md/dm.c4
-rw-r--r--drivers/md/md.c25
-rw-r--r--drivers/md/multipath.c4
-rw-r--r--drivers/md/raid1.c4
-rw-r--r--drivers/md/raid10.c6
-rw-r--r--drivers/md/raid5.c2
-rw-r--r--drivers/media/common/saa7146_i2c.c10
-rw-r--r--drivers/media/dvb/b2c2/flexcop-usb.c2
-rw-r--r--drivers/media/dvb/bt8xx/dvb-bt8xx.c4
-rw-r--r--drivers/media/dvb/dvb-core/Kconfig2
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig12
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb-common.c11
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb.h2
-rw-r--r--drivers/media/dvb/dvb-usb/nova-t-usb2.c3
-rw-r--r--drivers/media/dvb/frontends/Kconfig2
-rw-r--r--drivers/media/dvb/frontends/bcm3510.h2
-rw-r--r--drivers/media/dvb/frontends/cx22700.h2
-rw-r--r--drivers/media/dvb/frontends/cx22702.h2
-rw-r--r--drivers/media/dvb/frontends/cx24110.h2
-rw-r--r--drivers/media/dvb/frontends/cx24123.h2
-rw-r--r--drivers/media/dvb/frontends/dib3000.h2
-rw-r--r--drivers/media/dvb/frontends/dib3000mc.c2
-rw-r--r--drivers/media/dvb/frontends/dib3000mc.h5
-rw-r--r--drivers/media/dvb/frontends/isl6421.h2
-rw-r--r--drivers/media/dvb/frontends/l64781.h2
-rw-r--r--drivers/media/dvb/frontends/lgdt330x.h2
-rw-r--r--drivers/media/dvb/frontends/lnbp21.h2
-rw-r--r--drivers/media/dvb/frontends/mt2060.h8
-rw-r--r--drivers/media/dvb/frontends/mt312.h2
-rw-r--r--drivers/media/dvb/frontends/mt352.h2
-rw-r--r--drivers/media/dvb/frontends/nxt200x.h2
-rw-r--r--drivers/media/dvb/frontends/nxt6000.h2
-rw-r--r--drivers/media/dvb/frontends/or51132.h2
-rw-r--r--drivers/media/dvb/frontends/or51211.h2
-rw-r--r--drivers/media/dvb/frontends/s5h1420.h2
-rw-r--r--drivers/media/dvb/frontends/sp8870.h2
-rw-r--r--drivers/media/dvb/frontends/sp887x.h2
-rw-r--r--drivers/media/dvb/frontends/stv0297.h2
-rw-r--r--drivers/media/dvb/frontends/stv0299.h2
-rw-r--r--drivers/media/dvb/frontends/tda10021.h2
-rw-r--r--drivers/media/dvb/frontends/tda1004x.h2
-rw-r--r--drivers/media/dvb/frontends/tda10086.h9
-rw-r--r--drivers/media/dvb/frontends/tda8083.h2
-rw-r--r--drivers/media/dvb/frontends/tda826x.c2
-rw-r--r--drivers/media/dvb/frontends/tda826x.h19
-rw-r--r--drivers/media/dvb/frontends/tua6100.h2
-rw-r--r--drivers/media/dvb/frontends/ves1820.h2
-rw-r--r--drivers/media/dvb/frontends/ves1x93.h2
-rw-r--r--drivers/media/dvb/frontends/zl10353.h2
-rw-r--r--drivers/media/dvb/ttpci/budget-ci.c10
-rw-r--r--drivers/media/video/Kconfig4
-rw-r--r--drivers/media/video/bt8xx/bttv-cards.c2
-rw-r--r--drivers/media/video/cx25840/cx25840-vbi.c25
-rw-r--r--drivers/media/video/cx88/cx88-cards.c21
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c17
-rw-r--r--drivers/media/video/cx88/cx88-input.c12
-rw-r--r--drivers/media/video/et61x251/et61x251_core.c37
-rw-r--r--drivers/media/video/ov511.c58
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c2
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-v4l2.c6
-rw-r--r--drivers/media/video/pwc/pwc-if.c41
-rw-r--r--drivers/media/video/saa7115.c2
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c5
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c2
-rw-r--r--drivers/media/video/saa7134/saa7134-input.c11
-rw-r--r--drivers/media/video/saa7134/saa7134-video.c6
-rw-r--r--drivers/media/video/sn9c102/sn9c102_core.c71
-rw-r--r--drivers/media/video/stv680.c53
-rw-r--r--drivers/media/video/tuner-types.c1
-rw-r--r--drivers/media/video/tveeprom.c2
-rw-r--r--drivers/media/video/videodev.c16
-rw-r--r--drivers/media/video/vivi.c12
-rw-r--r--drivers/message/fusion/mptbase.h4
-rw-r--r--drivers/message/fusion/mptfc.c89
-rw-r--r--drivers/message/i2o/bus-osm.c12
-rw-r--r--drivers/message/i2o/exec-osm.c21
-rw-r--r--drivers/misc/Kconfig31
-rw-r--r--drivers/misc/Makefile2
-rw-r--r--drivers/misc/ioc4.c (renamed from drivers/sn/ioc4.c)48
-rw-r--r--drivers/misc/lkdtm.c32
-rw-r--r--drivers/misc/msi-laptop.c395
-rw-r--r--drivers/mmc/mmc.c19
-rw-r--r--drivers/mmc/tifm_sd.c1
-rw-r--r--drivers/mtd/nand/nand_base.c1
-rw-r--r--drivers/net/Kconfig21
-rw-r--r--drivers/net/arcnet/com20020.c7
-rw-r--r--drivers/net/arm/ep93xx_eth.c40
-rw-r--r--drivers/net/au1000_eth.c2
-rw-r--r--drivers/net/b44.c14
-rw-r--r--drivers/net/bonding/bond_alb.c4
-rw-r--r--drivers/net/bonding/bond_main.c5
-rw-r--r--drivers/net/cris/eth_v10.c2
-rw-r--r--drivers/net/e100.c54
-rw-r--r--drivers/net/e1000/e1000_ethtool.c4
-rw-r--r--drivers/net/e1000/e1000_hw.h6
-rw-r--r--drivers/net/e1000/e1000_main.c52
-rw-r--r--drivers/net/ehea/ehea.h16
-rw-r--r--drivers/net/ehea/ehea_ethtool.c2
-rw-r--r--drivers/net/ehea/ehea_main.c35
-rw-r--r--drivers/net/ehea/ehea_phyp.c575
-rw-r--r--drivers/net/ehea/ehea_phyp.h6
-rw-r--r--drivers/net/ehea/ehea_qmr.c17
-rw-r--r--drivers/net/eth16i.c2
-rw-r--r--drivers/net/forcedeth.c31
-rw-r--r--drivers/net/ibmveth.c64
-rw-r--r--drivers/net/ioc3-eth.c4
-rw-r--r--drivers/net/irda/stir4200.c3
-rw-r--r--drivers/net/loopback.c39
-rw-r--r--drivers/net/mv643xx_eth.c4
-rw-r--r--drivers/net/myri10ge/myri10ge.c1
-rw-r--r--drivers/net/myri_code.h8
-rw-r--r--drivers/net/myri_sbus.c4
-rw-r--r--drivers/net/r8169.c45
-rw-r--r--drivers/net/s2io.c11
-rw-r--r--drivers/net/sb1250-mac.c2
-rw-r--r--drivers/net/skge.c223
-rw-r--r--drivers/net/skge.h25
-rw-r--r--drivers/net/sky2.c278
-rw-r--r--drivers/net/sky2.h60
-rw-r--r--drivers/net/smc91x.h36
-rw-r--r--drivers/net/spider_net.c246
-rw-r--r--drivers/net/spider_net.h35
-rw-r--r--drivers/net/spider_net_ethtool.c6
-rw-r--r--drivers/net/sun3_82586.c2
-rw-r--r--drivers/net/sun3lance.c6
-rw-r--r--drivers/net/sunbmac.c2
-rw-r--r--drivers/net/tg3.c67
-rw-r--r--drivers/net/tokenring/proteon.c9
-rw-r--r--drivers/net/tokenring/skisa.c9
-rw-r--r--drivers/net/tulip/de2104x.c8
-rw-r--r--drivers/net/ucc_geth.c633
-rw-r--r--drivers/net/ucc_geth.h248
-rw-r--r--drivers/net/ucc_geth_phy.c26
-rw-r--r--drivers/net/ucc_geth_phy.h2
-rw-r--r--drivers/net/wan/Kconfig2
-rw-r--r--drivers/net/wan/n2.c6
-rw-r--r--drivers/net/wan/pc300_drv.c24
-rw-r--r--drivers/net/wireless/airo.c105
-rw-r--r--drivers/net/wireless/atmel.c2
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_dma.c28
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_dma.h18
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_leds.c9
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_leds.h6
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_main.c72
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_wx.c2
-rw-r--r--drivers/net/wireless/hostap/hostap_cs.c7
-rw-r--r--drivers/net/wireless/hostap/hostap_plx.c4
-rw-r--r--drivers/net/wireless/orinoco.c16
-rw-r--r--drivers/net/wireless/ray_cs.c1
-rw-r--r--drivers/net/wireless/zd1201.c6
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c2
-rw-r--r--drivers/parport/parport_ip32.c2
-rw-r--r--drivers/pci/Kconfig4
-rw-r--r--drivers/pci/hotplug/acpi_pcihp.c2
-rw-r--r--drivers/pci/hotplug/acpiphp.h2
-rw-r--r--drivers/pci/hotplug/acpiphp_core.c2
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c8
-rw-r--r--drivers/pci/hotplug/acpiphp_ibm.c1
-rw-r--r--drivers/pci/hotplug/cpci_hotplug_core.c2
-rw-r--r--drivers/pci/hotplug/cpci_hotplug_pci.c2
-rw-r--r--drivers/pci/hotplug/cpcihp_generic.c4
-rw-r--r--drivers/pci/hotplug/cpqphp.h1
-rw-r--r--drivers/pci/hotplug/cpqphp_core.c1
-rw-r--r--drivers/pci/hotplug/cpqphp_ctrl.c1
-rw-r--r--drivers/pci/hotplug/cpqphp_nvram.c1
-rw-r--r--drivers/pci/hotplug/cpqphp_pci.c1
-rw-r--r--drivers/pci/hotplug/cpqphp_sysfs.c1
-rw-r--r--drivers/pci/hotplug/fakephp.c13
-rw-r--r--drivers/pci/hotplug/ibmphp.h2
-rw-r--r--drivers/pci/hotplug/pci_hotplug_core.c11
-rw-r--r--drivers/pci/hotplug/pciehp.h11
-rw-r--r--drivers/pci/hotplug/pciehp_core.c6
-rw-r--r--drivers/pci/hotplug/pciehp_ctrl.c104
-rw-r--r--drivers/pci/hotplug/pciehp_hpc.c2
-rw-r--r--drivers/pci/hotplug/pcihp_skeleton.c2
-rw-r--r--drivers/pci/hotplug/rpadlpar_sysfs.c2
-rw-r--r--drivers/pci/hotplug/rpaphp.h2
-rw-r--r--drivers/pci/hotplug/rpaphp_core.c2
-rw-r--r--drivers/pci/hotplug/sgi_hotplug.c2
-rw-r--r--drivers/pci/hotplug/shpchp.h4
-rw-r--r--drivers/pci/hotplug/shpchp_hpc.c82
-rw-r--r--drivers/pci/htirq.c101
-rw-r--r--drivers/pci/msi.c16
-rw-r--r--drivers/pci/pci-driver.c13
-rw-r--r--drivers/pci/pci-sysfs.c3
-rw-r--r--drivers/pci/pcie/portdrv.h4
-rw-r--r--drivers/pci/pcie/portdrv_core.c3
-rw-r--r--drivers/pci/pcie/portdrv_pci.c2
-rw-r--r--drivers/pci/probe.c92
-rw-r--r--drivers/pci/quirks.c107
-rw-r--r--drivers/pci/rom.c6
-rw-r--r--drivers/pci/search.c72
-rw-r--r--drivers/pcmcia/at91_cf.c28
-rw-r--r--drivers/pcmcia/au1000_generic.c25
-rw-r--r--drivers/pcmcia/ds.c32
-rw-r--r--drivers/pcmcia/i82092.c9
-rw-r--r--drivers/pcmcia/m8xx_pcmcia.c12
-rw-r--r--drivers/pcmcia/omap_cf.c3
-rw-r--r--drivers/pcmcia/pcmcia_ioctl.c11
-rw-r--r--drivers/pcmcia/pcmcia_resource.c2
-rw-r--r--drivers/pcmcia/pd6729.c4
-rw-r--r--drivers/pcmcia/pxa2xx_base.c41
-rw-r--r--drivers/pcmcia/pxa2xx_base.h2
-rw-r--r--drivers/pcmcia/pxa2xx_lubbock.c2
-rw-r--r--drivers/pcmcia/soc_common.c1
-rw-r--r--drivers/pcmcia/yenta_socket.c22
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c41
-rw-r--r--drivers/rtc/rtc-max6902.c2
-rw-r--r--drivers/rtc/rtc-sh.c6
-rw-r--r--drivers/rtc/rtc-v3020.c4
-rw-r--r--drivers/s390/block/dasd.c1
-rw-r--r--drivers/s390/char/monwriter.c16
-rw-r--r--drivers/s390/cio/chsc.c23
-rw-r--r--drivers/s390/cio/cio.c4
-rw-r--r--drivers/s390/cio/css.c9
-rw-r--r--drivers/s390/cio/css.h7
-rw-r--r--drivers/s390/cio/device.c51
-rw-r--r--drivers/s390/cio/device.h2
-rw-r--r--drivers/s390/cio/device_fsm.c117
-rw-r--r--drivers/s390/cio/device_id.c14
-rw-r--r--drivers/s390/cio/device_ops.c6
-rw-r--r--drivers/s390/cio/device_pgid.c23
-rw-r--r--drivers/s390/cio/device_status.c7
-rw-r--r--drivers/s390/cio/qdio.c12
-rw-r--r--drivers/s390/crypto/ap_bus.c7
-rw-r--r--drivers/s390/scsi/zfcp_def.h4
-rw-r--r--drivers/s390/scsi/zfcp_scsi.c1
-rw-r--r--drivers/sbus/char/bbc_envctrl.c6
-rw-r--r--drivers/sbus/char/envctrl.c10
-rw-r--r--drivers/sbus/sbus.c4
-rw-r--r--drivers/scsi/3w-9xxx.c141
-rw-r--r--drivers/scsi/3w-9xxx.h14
-rw-r--r--drivers/scsi/BusLogic.c11
-rw-r--r--drivers/scsi/aha152x.c2
-rw-r--r--drivers/scsi/aic7xxx/aic79xx.h66
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_core.c350
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_inline.h30
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.c45
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.h5
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm_pci.c2
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_pci.c7
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_proc.c2
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx.h11
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_core.c40
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.c72
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.h13
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm_pci.c2
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_pci.c4
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_proc.c10
-rw-r--r--drivers/scsi/aic7xxx_old.c2
-rw-r--r--drivers/scsi/aic94xx/aic94xx_hwi.c18
-rw-r--r--drivers/scsi/aic94xx/aic94xx_hwi.h13
-rw-r--r--drivers/scsi/aic94xx/aic94xx_init.c4
-rw-r--r--drivers/scsi/aic94xx/aic94xx_sas.h1
-rw-r--r--drivers/scsi/aic94xx/aic94xx_scb.c72
-rw-r--r--drivers/scsi/aic94xx/aic94xx_sds.c4
-rw-r--r--drivers/scsi/aic94xx/aic94xx_seq.c5
-rw-r--r--drivers/scsi/aic94xx/aic94xx_seq.h2
-rw-r--r--drivers/scsi/dpt/dpti_i2o.h2
-rw-r--r--drivers/scsi/dtc.c2
-rw-r--r--drivers/scsi/eata_pio.c2
-rw-r--r--drivers/scsi/fdomain.c41
-rw-r--r--drivers/scsi/gdth.c4
-rw-r--r--drivers/scsi/ibmvscsi/ibmvscsi.c2
-rw-r--r--drivers/scsi/imm.c2
-rw-r--r--drivers/scsi/initio.c19
-rw-r--r--drivers/scsi/iscsi_tcp.c22
-rw-r--r--drivers/scsi/libiscsi.c78
-rw-r--r--drivers/scsi/libsas/sas_expander.c84
-rw-r--r--drivers/scsi/lpfc/lpfc_attr.c3
-rw-r--r--drivers/scsi/lpfc/lpfc_ct.c3
-rw-r--r--drivers/scsi/lpfc/lpfc_hbadisc.c2
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.c4
-rw-r--r--drivers/scsi/megaraid/megaraid_mbox.c2
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.c42
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.h46
-rw-r--r--drivers/scsi/pcmcia/nsp_debug.c4
-rw-r--r--drivers/scsi/pcmcia/nsp_message.c4
-rw-r--r--drivers/scsi/ppa.c2
-rw-r--r--drivers/scsi/psi240i.c33
-rw-r--r--drivers/scsi/psi240i.h6
-rw-r--r--drivers/scsi/qla1280.c7
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c51
-rw-r--r--drivers/scsi/qla2xxx/qla_dbg.h14
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h4
-rw-r--r--drivers/scsi/qla2xxx/qla_gbl.h4
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c23
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c91
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c35
-rw-r--r--drivers/scsi/qla2xxx/qla_version.h2
-rw-r--r--drivers/scsi/qla4xxx/Kconfig2
-rw-r--r--drivers/scsi/qla4xxx/ql4_dbg.h4
-rw-r--r--drivers/scsi/qla4xxx/ql4_glbl.h3
-rw-r--r--drivers/scsi/qla4xxx/ql4_init.c2
-rw-r--r--drivers/scsi/qla4xxx/ql4_mbx.c2
-rw-r--r--drivers/scsi/qla4xxx/ql4_os.c52
-rw-r--r--drivers/scsi/qla4xxx/ql4_version.h7
-rw-r--r--drivers/scsi/qlogicfas408.c18
-rw-r--r--drivers/scsi/qlogicfas408.h29
-rw-r--r--drivers/scsi/qlogicpti.c2
-rw-r--r--drivers/scsi/qlogicpti_asm.c4
-rw-r--r--drivers/scsi/scsi_debug.c141
-rw-r--r--drivers/scsi/scsi_lib.c3
-rw-r--r--drivers/scsi/scsi_scan.c18
-rw-r--r--drivers/scsi/scsi_sysfs.c2
-rw-r--r--drivers/scsi/scsi_transport_iscsi.c248
-rw-r--r--drivers/scsi/seagate.c2
-rw-r--r--drivers/scsi/sg.c25
-rw-r--r--drivers/scsi/st.c5
-rw-r--r--drivers/scsi/sun3_NCR5380.c109
-rw-r--r--drivers/scsi/sun3_scsi.c7
-rw-r--r--drivers/scsi/sun3_scsi.h7
-rw-r--r--drivers/scsi/sun3_scsi_vme.c7
-rw-r--r--drivers/scsi/t128.c2
-rw-r--r--drivers/scsi/tmscsim.c1
-rw-r--r--drivers/scsi/wd7000.c2
-rw-r--r--drivers/serial/Kconfig12
-rw-r--r--drivers/serial/cpm_uart/cpm_uart.h2
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_core.c16
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_cpm1.c2
-rw-r--r--drivers/serial/ioc4_serial.c6
-rw-r--r--drivers/serial/sh-sci.c4
-rw-r--r--drivers/serial/sunzilog.c6
-rw-r--r--drivers/sn/Kconfig13
-rw-r--r--drivers/sn/Makefile1
-rw-r--r--drivers/spi/spi.c1
-rw-r--r--drivers/telephony/ixj.c11
-rw-r--r--drivers/telephony/ixj.h2
-rw-r--r--drivers/usb/Makefile2
-rw-r--r--drivers/usb/atm/cxacru.c3
-rw-r--r--drivers/usb/atm/speedtch.c93
-rw-r--r--drivers/usb/atm/ueagle-atm.c83
-rw-r--r--drivers/usb/atm/usbatm.c5
-rw-r--r--drivers/usb/class/cdc-acm.c29
-rw-r--r--drivers/usb/class/usblp.c78
-rw-r--r--drivers/usb/core/devio.c8
-rw-r--r--drivers/usb/core/endpoint.c22
-rw-r--r--drivers/usb/core/hub.c3
-rw-r--r--drivers/usb/core/message.c5
-rw-r--r--drivers/usb/gadget/net2280.c24
-rw-r--r--drivers/usb/gadget/pxa2xx_udc.c2
-rw-r--r--drivers/usb/host/ehci-dbg.c4
-rw-r--r--drivers/usb/host/ehci-hcd.c70
-rw-r--r--drivers/usb/host/ehci-hub.c2
-rw-r--r--drivers/usb/host/ehci-pci.c2
-rw-r--r--drivers/usb/host/ehci-q.c6
-rw-r--r--drivers/usb/host/ehci.h22
-rw-r--r--drivers/usb/host/ohci-hcd.c25
-rw-r--r--drivers/usb/host/ohci-hub.c6
-rw-r--r--drivers/usb/host/ohci-pnx4008.c9
-rw-r--r--drivers/usb/host/uhci-hcd.c44
-rw-r--r--drivers/usb/input/Kconfig10
-rw-r--r--drivers/usb/input/Makefile3
-rw-r--r--drivers/usb/input/hid-core.c73
-rw-r--r--drivers/usb/input/hid-input.c17
-rw-r--r--drivers/usb/input/hid.h1
-rw-r--r--drivers/usb/input/usbtouchscreen.c6
-rw-r--r--drivers/usb/input/wacom.h2
-rw-r--r--drivers/usb/input/wacom_sys.c20
-rw-r--r--drivers/usb/input/wacom_wac.c121
-rw-r--r--drivers/usb/input/wacom_wac.h2
-rw-r--r--drivers/usb/input/xpad.c178
-rw-r--r--drivers/usb/misc/Kconfig10
-rw-r--r--drivers/usb/misc/Makefile1
-rw-r--r--drivers/usb/misc/adutux.c3
-rw-r--r--drivers/usb/misc/auerswald.c2
-rw-r--r--drivers/usb/misc/ftdi-elan.c36
-rw-r--r--drivers/usb/misc/trancevibrator.c (renamed from drivers/usb/input/trancevibrator.c)0
-rw-r--r--drivers/usb/net/Kconfig16
-rw-r--r--drivers/usb/net/Makefile1
-rw-r--r--drivers/usb/net/asix.c48
-rw-r--r--drivers/usb/net/cdc_ether.c2
-rw-r--r--drivers/usb/net/kaweth.c204
-rw-r--r--drivers/usb/net/mcs7830.c534
-rw-r--r--drivers/usb/net/usbnet.c81
-rw-r--r--drivers/usb/net/usbnet.h5
-rw-r--r--drivers/usb/serial/Kconfig17
-rw-r--r--drivers/usb/serial/Makefile1
-rw-r--r--drivers/usb/serial/airprime.c7
-rw-r--r--drivers/usb/serial/cp2101.c4
-rw-r--r--drivers/usb/serial/ftdi_sio.c256
-rw-r--r--drivers/usb/serial/ftdi_sio.h11
-rw-r--r--drivers/usb/serial/ipaq.c1
-rw-r--r--drivers/usb/serial/mos7720.c1683
-rw-r--r--drivers/usb/serial/mos7840.c3
-rw-r--r--drivers/usb/serial/sierra.c700
-rw-r--r--drivers/usb/storage/unusual_devs.h23
-rw-r--r--drivers/video/Kconfig1
-rw-r--r--drivers/video/aty/atyfb_base.c2
-rw-r--r--drivers/video/aty/radeon_i2c.c8
-rw-r--r--drivers/video/backlight/corgi_bl.c4
-rw-r--r--drivers/video/backlight/hp680_bl.c2
-rw-r--r--drivers/video/controlfb.c8
-rw-r--r--drivers/video/fb_ddc.c6
-rw-r--r--drivers/video/hitfb.c1
-rw-r--r--drivers/video/igafb.c7
-rw-r--r--drivers/video/intelfb/intelfbhw.c6
-rw-r--r--drivers/video/nvidia/nv_hw.c12
-rw-r--r--drivers/video/nvidia/nv_i2c.c45
-rw-r--r--drivers/video/nvidia/nv_setup.c20
-rw-r--r--drivers/video/nvidia/nv_type.h1
-rw-r--r--drivers/video/nvidia/nvidia.c24
-rw-r--r--drivers/video/offb.c36
-rw-r--r--drivers/video/platinumfb.c5
-rw-r--r--drivers/video/pnx4008/pnxrgbfb.c5
-rw-r--r--drivers/video/pnx4008/sdum.c2
-rw-r--r--drivers/video/valkyriefb.c4
-rw-r--r--drivers/w1/Kconfig1
-rw-r--r--drivers/w1/masters/matrox_w1.c2
-rw-r--r--fs/Kconfig122
-rw-r--r--fs/Makefile2
-rw-r--r--fs/afs/dir.c8
-rw-r--r--fs/autofs/autofs_i.h1
-rw-r--r--fs/autofs/dirhash.c1
-rw-r--r--fs/autofs/init.c2
-rw-r--r--fs/autofs/inode.c18
-rw-r--r--fs/autofs/waitq.c1
-rw-r--r--fs/autofs4/autofs_i.h3
-rw-r--r--fs/autofs4/init.c2
-rw-r--r--fs/autofs4/inode.c39
-rw-r--r--fs/autofs4/waitq.c7
-rw-r--r--fs/binfmt_elf.c10
-rw-r--r--fs/bio.c9
-rw-r--r--fs/block_dev.c58
-rw-r--r--fs/buffer.c34
-rw-r--r--fs/cifs/CHANGES5
-rw-r--r--fs/cifs/cifsacl.h4
-rw-r--r--fs/cifs/cifsencrypt.h2
-rw-r--r--fs/cifs/cifsfs.c27
-rw-r--r--fs/cifs/cifsfs.h2
-rw-r--r--fs/cifs/cifsglob.h15
-rw-r--r--fs/cifs/cifspdu.h12
-rw-r--r--fs/cifs/cifsproto.h12
-rw-r--r--fs/cifs/cifssmb.c102
-rw-r--r--fs/cifs/connect.c42
-rw-r--r--fs/cifs/file.c31
-rw-r--r--fs/cifs/inode.c30
-rw-r--r--fs/cifs/link.c6
-rw-r--r--fs/cifs/md5.c8
-rw-r--r--fs/cifs/md5.h8
-rw-r--r--fs/cifs/misc.c44
-rw-r--r--fs/cifs/netmisc.c58
-rw-r--r--fs/cifs/readdir.c36
-rw-r--r--fs/cifs/sess.c46
-rw-r--r--fs/cifs/smbdes.c6
-rw-r--r--fs/cifs/smbencrypt.c11
-rw-r--r--fs/compat.c20
-rw-r--r--fs/compat_ioctl.c10
-rw-r--r--fs/configfs/file.c14
-rw-r--r--fs/dcache.c282
-rw-r--r--fs/debugfs/inode.c4
-rw-r--r--fs/dlm/Kconfig3
-rw-r--r--fs/dlm/lockspace.c14
-rw-r--r--fs/dlm/lowcomms.c3
-rw-r--r--fs/ecryptfs/crypto.c206
-rw-r--r--fs/ecryptfs/dentry.c14
-rw-r--r--fs/ecryptfs/ecryptfs_kernel.h22
-rw-r--r--fs/ecryptfs/file.c44
-rw-r--r--fs/ecryptfs/inode.c100
-rw-r--r--fs/ecryptfs/keystore.c114
-rw-r--r--fs/ecryptfs/main.c20
-rw-r--r--fs/ecryptfs/super.c18
-rw-r--r--fs/eventpoll.c56
-rw-r--r--fs/ext2/super.c16
-rw-r--r--fs/ext3/super.c2
-rw-r--r--fs/ext4/Makefile12
-rw-r--r--fs/ext4/acl.c551
-rw-r--r--fs/ext4/acl.h81
-rw-r--r--fs/ext4/balloc.c1833
-rw-r--r--fs/ext4/bitmap.c32
-rw-r--r--fs/ext4/dir.c518
-rw-r--r--fs/ext4/extents.c2152
-rw-r--r--fs/ext4/file.c139
-rw-r--r--fs/ext4/fsync.c88
-rw-r--r--fs/ext4/hash.c152
-rw-r--r--fs/ext4/ialloc.c772
-rw-r--r--fs/ext4/inode.c3233
-rw-r--r--fs/ext4/ioctl.c306
-rw-r--r--fs/ext4/namei.c2395
-rw-r--r--fs/ext4/namei.h8
-rw-r--r--fs/ext4/resize.c1050
-rw-r--r--fs/ext4/super.c2829
-rw-r--r--fs/ext4/symlink.c54
-rw-r--r--fs/ext4/xattr.c1317
-rw-r--r--fs/ext4/xattr.h145
-rw-r--r--fs/ext4/xattr_security.c77
-rw-r--r--fs/ext4/xattr_trusted.c62
-rw-r--r--fs/ext4/xattr_user.c64
-rw-r--r--fs/fat/file.c13
-rw-r--r--fs/fat/inode.c2
-rw-r--r--fs/fuse/dir.c107
-rw-r--r--fs/fuse/file.c21
-rw-r--r--fs/fuse/fuse_i.h3
-rw-r--r--fs/fuse/inode.c15
-rw-r--r--fs/gfs2/bmap.c13
-rw-r--r--fs/gfs2/bmap.h2
-rw-r--r--fs/gfs2/dir.c10
-rw-r--r--fs/gfs2/inode.c3
-rw-r--r--fs/gfs2/locking/dlm/mount.c2
-rw-r--r--fs/gfs2/log.c11
-rw-r--r--fs/gfs2/lops.c4
-rw-r--r--fs/gfs2/main.c4
-rw-r--r--fs/gfs2/ops_address.c26
-rw-r--r--fs/gfs2/ops_fstype.c7
-rw-r--r--fs/gfs2/ops_super.c44
-rw-r--r--fs/gfs2/quota.c5
-rw-r--r--fs/gfs2/recovery.c5
-rw-r--r--fs/gfs2/rgrp.h2
-rw-r--r--fs/hfs/super.c2
-rw-r--r--fs/hugetlbfs/inode.c48
-rw-r--r--fs/inode.c36
-rw-r--r--fs/ioprio.c5
-rw-r--r--fs/jbd/journal.c3
-rw-r--r--fs/jbd/transaction.c20
-rw-r--r--fs/jbd2/Makefile7
-rw-r--r--fs/jbd2/checkpoint.c697
-rw-r--r--fs/jbd2/commit.c920
-rw-r--r--fs/jbd2/journal.c2084
-rw-r--r--fs/jbd2/recovery.c609
-rw-r--r--fs/jbd2/revoke.c712
-rw-r--r--fs/jbd2/transaction.c2094
-rw-r--r--fs/jffs2/super.c8
-rw-r--r--fs/jfs/file.c2
-rw-r--r--fs/jfs/jfs_imap.c4
-rw-r--r--fs/jfs/xattr.c9
-rw-r--r--fs/lockd/clntlock.c4
-rw-r--r--fs/lockd/mon.c12
-rw-r--r--fs/lockd/svc.c3
-rw-r--r--fs/lockd/svc4proc.c56
-rw-r--r--fs/lockd/svclock.c10
-rw-r--r--fs/lockd/svcproc.c62
-rw-r--r--fs/lockd/svcshare.c4
-rw-r--r--fs/lockd/svcsubs.c21
-rw-r--r--fs/lockd/xdr.c76
-rw-r--r--fs/lockd/xdr4.c80
-rw-r--r--fs/minix/inode.c8
-rw-r--r--fs/msdos/namei.c1
-rw-r--r--fs/nfs/callback.h10
-rw-r--r--fs/nfs/callback_proc.c6
-rw-r--r--fs/nfs/callback_xdr.c106
-rw-r--r--fs/nfs/client.c27
-rw-r--r--fs/nfs/dir.c29
-rw-r--r--fs/nfs/direct.c25
-rw-r--r--fs/nfs/inode.c30
-rw-r--r--fs/nfs/internal.h6
-rw-r--r--fs/nfs/mount_clnt.c6
-rw-r--r--fs/nfs/nfs2xdr.c78
-rw-r--r--fs/nfs/nfs3proc.c2
-rw-r--r--fs/nfs/nfs3xdr.c118
-rw-r--r--fs/nfs/nfs4_fs.h2
-rw-r--r--fs/nfs/nfs4proc.c16
-rw-r--r--fs/nfs/nfs4xdr.c360
-rw-r--r--fs/nfs/super.c2
-rw-r--r--fs/nfs/sysctl.c5
-rw-r--r--fs/nfs/write.c8
-rw-r--r--fs/nfs_common/nfsacl.c4
-rw-r--r--fs/nfsd/export.c4
-rw-r--r--fs/nfsd/lockd.c16
-rw-r--r--fs/nfsd/nfs2acl.c34
-rw-r--r--fs/nfsd/nfs3acl.c20
-rw-r--r--fs/nfsd/nfs3proc.c92
-rw-r--r--fs/nfsd/nfs3xdr.c126
-rw-r--r--fs/nfsd/nfs4callback.c26
-rw-r--r--fs/nfsd/nfs4proc.c134
-rw-r--r--fs/nfsd/nfs4recover.c16
-rw-r--r--fs/nfsd/nfs4state.c119
-rw-r--r--fs/nfsd/nfs4xdr.c273
-rw-r--r--fs/nfsd/nfscache.c8
-rw-r--r--fs/nfsd/nfsfh.c10
-rw-r--r--fs/nfsd/nfsproc.c79
-rw-r--r--fs/nfsd/nfssvc.c10
-rw-r--r--fs/nfsd/nfsxdr.c72
-rw-r--r--fs/nfsd/vfs.c305
-rw-r--r--fs/ocfs2/cluster/nodemanager.c10
-rw-r--r--fs/ocfs2/file.c51
-rw-r--r--fs/ocfs2/namei.c8
-rw-r--r--fs/ocfs2/super.c2
-rw-r--r--fs/partitions/check.c50
-rw-r--r--fs/proc/base.c6
-rw-r--r--fs/reiserfs/journal.c3
-rw-r--r--fs/reiserfs/super.c32
-rw-r--r--fs/splice.c146
-rw-r--r--fs/super.c12
-rw-r--r--fs/sysfs/file.c7
-rw-r--r--fs/sysv/super.c15
-rw-r--r--fs/vfat/namei.c1
-rw-r--r--fs/xattr.c13
-rw-r--r--fs/xfs/Makefile-linux-2.617
-rw-r--r--fs/xfs/linux-2.6/kmem.c5
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c7
-rw-r--r--fs/xfs/linux-2.6/xfs_dmapi_priv.h28
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl.c5
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c4
-rw-r--r--fs/xfs/support/debug.c4
-rw-r--r--fs/xfs/support/move.c2
-rw-r--r--fs/xfs/support/move.h2
-rw-r--r--fs/xfs/xfs.h23
-rw-r--r--fs/xfs/xfs_bmap.c2
-rw-r--r--fs/xfs/xfs_dir2.c2
-rw-r--r--fs/xfs/xfs_dmapi.h22
-rw-r--r--fs/xfs/xfs_iget.c51
-rw-r--r--fs/xfs/xfs_inode.c64
-rw-r--r--fs/xfs/xfs_inode.h41
-rw-r--r--fs/xfs/xfs_vnodeops.c33
-rw-r--r--include/acpi/pdc_intel.h9
-rw-r--r--include/acpi/processor.h18
-rw-r--r--include/asm-alpha/io.h13
-rw-r--r--include/asm-arm/arch-pxa/irqs.h2
-rw-r--r--include/asm-arm/arch-pxa/pxa-regs.h9
-rw-r--r--include/asm-arm/arch-sa1100/jornada720.h14
-rw-r--r--include/asm-arm/arch-versatile/hardware.h4
-rw-r--r--include/asm-arm/io.h17
-rw-r--r--include/asm-arm/uaccess.h22
-rw-r--r--include/asm-avr32/atomic.h8
-rw-r--r--include/asm-avr32/io.h33
-rw-r--r--include/asm-avr32/irq_regs.h1
-rw-r--r--include/asm-avr32/unistd.h3
-rw-r--r--include/asm-frv/highmem.h27
-rw-r--r--include/asm-frv/io.h21
-rw-r--r--include/asm-generic/bitops/sched.h2
-rw-r--r--include/asm-generic/bug.h5
-rw-r--r--include/asm-generic/vmlinux.lds.h35
-rw-r--r--include/asm-i386/acpi.h1
-rw-r--r--include/asm-i386/io.h27
-rw-r--r--include/asm-i386/io_apic.h29
-rw-r--r--include/asm-i386/mach-visws/do_timer.h53
-rw-r--r--include/asm-i386/mach-visws/mach_apic.h5
-rw-r--r--include/asm-i386/processor.h2
-rw-r--r--include/asm-i386/uaccess.h67
-rw-r--r--include/asm-i386/unistd.h3
-rw-r--r--include/asm-i386/vic.h2
-rw-r--r--include/asm-i386/voyager.h160
-rw-r--r--include/asm-ia64/io.h4
-rw-r--r--include/asm-ia64/pal.h11
-rw-r--r--include/asm-ia64/sal.h1
-rw-r--r--include/asm-ia64/sn/addrs.h6
-rw-r--r--include/asm-ia64/uaccess.h2
-rw-r--r--include/asm-m32r/io.h32
-rw-r--r--include/asm-m68k/sun3mmu.h3
-rw-r--r--include/asm-m68k/uaccess.h16
-rw-r--r--include/asm-m68knommu/irq_regs.h1
-rw-r--r--include/asm-m68knommu/irqnode.h8
-rw-r--r--include/asm-m68knommu/machdep.h2
-rw-r--r--include/asm-m68knommu/unistd.h35
-rw-r--r--include/asm-mips/asm.h2
-rw-r--r--include/asm-mips/cacheflush.h19
-rw-r--r--include/asm-mips/div64.h21
-rw-r--r--include/asm-mips/fixmap.h14
-rw-r--r--include/asm-mips/io.h30
-rw-r--r--include/asm-mips/irq.h6
-rw-r--r--include/asm-mips/mipsmtregs.h2
-rw-r--r--include/asm-mips/pgalloc.h2
-rw-r--r--include/asm-mips/pgtable-64.h2
-rw-r--r--include/asm-mips/sibyte/sb1250.h2
-rw-r--r--include/asm-mips/stackframe.h64
-rw-r--r--include/asm-mips/system.h2
-rw-r--r--include/asm-mips/termbits.h12
-rw-r--r--include/asm-mips/time.h10
-rw-r--r--include/asm-mips/unistd.h22
-rw-r--r--include/asm-mips/vr41xx/vr41xx.h2
-rw-r--r--include/asm-powerpc/asm-compat.h52
-rw-r--r--include/asm-powerpc/cputable.h37
-rw-r--r--include/asm-powerpc/current.h12
-rw-r--r--include/asm-powerpc/firmware.h17
-rw-r--r--include/asm-powerpc/i8259.h1
-rw-r--r--include/asm-powerpc/io.h33
-rw-r--r--include/asm-powerpc/iommu.h22
-rw-r--r--include/asm-powerpc/oprofile_impl.h87
-rw-r--r--include/asm-powerpc/pmc.h13
-rw-r--r--include/asm-powerpc/ppc_asm.h18
-rw-r--r--include/asm-powerpc/prom.h10
-rw-r--r--include/asm-powerpc/reg.h26
-rw-r--r--include/asm-powerpc/systbl.h3
-rw-r--r--include/asm-powerpc/system.h6
-rw-r--r--include/asm-powerpc/tce.h3
-rw-r--r--include/asm-powerpc/time.h31
-rw-r--r--include/asm-powerpc/timex.h20
-rw-r--r--include/asm-powerpc/topology.h8
-rw-r--r--include/asm-powerpc/unistd.h5
-rw-r--r--include/asm-ppc/io.h16
-rw-r--r--include/asm-s390/cio.h6
-rw-r--r--include/asm-s390/pgtable.h50
-rw-r--r--include/asm-s390/timer.h2
-rw-r--r--include/asm-s390/unistd.h3
-rw-r--r--include/asm-sh/cpu-sh4/ubc.h37
-rw-r--r--include/asm-sh/edosk7705.h (renamed from include/asm-sh/edosk7705/io.h)0
-rw-r--r--include/asm-sh/hp6xx.h (renamed from include/asm-sh/hp6xx/hp6xx.h)0
-rw-r--r--include/asm-sh/hp6xx/ide.h8
-rw-r--r--include/asm-sh/hp6xx/io.h10
-rw-r--r--include/asm-sh/hs7751rvoip.h (renamed from include/asm-sh/hs7751rvoip/hs7751rvoip.h)0
-rw-r--r--include/asm-sh/hs7751rvoip/ide.h8
-rw-r--r--include/asm-sh/hw_irq.h4
-rw-r--r--include/asm-sh/io.h16
-rw-r--r--include/asm-sh/irq-sh7780.h10
-rw-r--r--include/asm-sh/irq.h43
-rw-r--r--include/asm-sh/irq_regs.h1
-rw-r--r--include/asm-sh/landisk/ide.h14
-rw-r--r--include/asm-sh/processor.h2
-rw-r--r--include/asm-sh/r7780rp.h (renamed from include/asm-sh/r7780rp/r7780rp.h)6
-rw-r--r--include/asm-sh/r7780rp/ide.h8
-rw-r--r--include/asm-sh/rts7751r2d.h (renamed from include/asm-sh/rts7751r2d/rts7751r2d.h)0
-rw-r--r--include/asm-sh/rts7751r2d/ide.h8
-rw-r--r--include/asm-sh/sh03/ide.h7
-rw-r--r--include/asm-sh/shmin.h (renamed from include/asm-sh/shmin/shmin.h)0
-rw-r--r--include/asm-sh/system.h7
-rw-r--r--include/asm-sh/timer.h13
-rw-r--r--include/asm-sh/unistd.h5
-rw-r--r--include/asm-sh64/io.h16
-rw-r--r--include/asm-sparc/elf.h41
-rw-r--r--include/asm-sparc/unistd.h9
-rw-r--r--include/asm-sparc64/compat.h7
-rw-r--r--include/asm-sparc64/futex.h18
-rw-r--r--include/asm-sparc64/io.h15
-rw-r--r--include/asm-sparc64/unistd.h10
-rw-r--r--include/asm-um/archparam-ppc.h9
-rw-r--r--include/asm-um/common.lds.S8
-rw-r--r--include/asm-x86_64/acpi.h1
-rw-r--r--include/asm-x86_64/hw_irq.h2
-rw-r--r--include/asm-x86_64/io.h27
-rw-r--r--include/asm-x86_64/io_apic.h34
-rw-r--r--include/asm-x86_64/pda.h9
-rw-r--r--include/asm-x86_64/pgtable.h1
-rw-r--r--include/asm-x86_64/processor.h2
-rw-r--r--include/asm-x86_64/proto.h2
-rw-r--r--include/asm-x86_64/vsyscall.h2
-rw-r--r--include/linux/Kbuild1
-rw-r--r--include/linux/acpi.h3
-rw-r--r--include/linux/backing-dev.h7
-rw-r--r--include/linux/bitmap.h13
-rw-r--r--include/linux/blkdev.h23
-rw-r--r--include/linux/buffer_head.h2
-rw-r--r--include/linux/carta_random32.h29
-rw-r--r--include/linux/compat.h6
-rw-r--r--include/linux/compat_ioctl.h25
-rw-r--r--include/linux/cpumask.h14
-rw-r--r--include/linux/crypto.h2
-rw-r--r--include/linux/dcache.h1
-rw-r--r--include/linux/device.h2
-rw-r--r--include/linux/dmi.h2
-rw-r--r--include/linux/elevator.h1
-rw-r--r--include/linux/ext4_fs.h994
-rw-r--r--include/linux/ext4_fs_extents.h198
-rw-r--r--include/linux/ext4_fs_i.h158
-rw-r--r--include/linux/ext4_fs_sb.h94
-rw-r--r--include/linux/ext4_jbd2.h273
-rw-r--r--include/linux/fs.h13
-rw-r--r--include/linux/htirq.h16
-rw-r--r--include/linux/hugetlb.h11
-rw-r--r--include/linux/igmp.h2
-rw-r--r--include/linux/in6.h12
-rw-r--r--include/linux/init.h36
-rw-r--r--include/linux/io.h27
-rw-r--r--include/linux/ipmi_msgdefs.h2
-rw-r--r--include/linux/ipx.h14
-rw-r--r--include/linux/irq.h21
-rw-r--r--include/linux/jbd2.h1107
-rw-r--r--include/linux/kernel.h2
-rw-r--r--include/linux/libata.h3
-rw-r--r--include/linux/lockd/bind.h5
-rw-r--r--include/linux/lockd/lockd.h12
-rw-r--r--include/linux/lockd/share.h4
-rw-r--r--include/linux/lockd/xdr.h30
-rw-r--r--include/linux/lockd/xdr4.h26
-rw-r--r--include/linux/lockdep.h17
-rw-r--r--include/linux/magic.h1
-rw-r--r--include/linux/mempolicy.h2
-rw-r--r--include/linux/mm.h10
-rw-r--r--include/linux/mmzone.h12
-rw-r--r--include/linux/module.h3
-rw-r--r--include/linux/msdos_fs.h2
-rw-r--r--include/linux/mtd/nand.h2
-rw-r--r--include/linux/nbd.h2
-rw-r--r--include/linux/net.h7
-rw-r--r--include/linux/netfilter/x_tables.h16
-rw-r--r--include/linux/netfilter_arp/arp_tables.h25
-rw-r--r--include/linux/netfilter_ipv4/ip_tables.h27
-rw-r--r--include/linux/netfilter_ipv6/ip6_tables.h27
-rw-r--r--include/linux/nfs_fs.h3
-rw-r--r--include/linux/nfs_xdr.h10
-rw-r--r--include/linux/nfsd/cache.h6
-rw-r--r--include/linux/nfsd/export.h4
-rw-r--r--include/linux/nfsd/nfsd.h45
-rw-r--r--include/linux/nfsd/nfsfh.h8
-rw-r--r--include/linux/nfsd/state.h12
-rw-r--r--include/linux/nfsd/xdr.h50
-rw-r--r--include/linux/nfsd/xdr3.h114
-rw-r--r--include/linux/nfsd/xdr4.h54
-rw-r--r--include/linux/nodemask.h14
-rw-r--r--include/linux/oom.h10
-rw-r--r--include/linux/pagemap.h14
-rw-r--r--include/linux/pci.h17
-rw-r--r--include/linux/pci_hotplug.h (renamed from drivers/pci/hotplug/pci_hotplug.h)2
-rw-r--r--include/linux/pci_ids.h3
-rw-r--r--include/linux/pci_regs.h1
-rw-r--r--include/linux/personality.h9
-rw-r--r--include/linux/pm.h4
-rw-r--r--include/linux/raid/bitmap.h20
-rw-r--r--include/linux/raid/md_p.h56
-rw-r--r--include/linux/random.h3
-rw-r--r--include/linux/sched.h1
-rw-r--r--include/linux/security.h24
-rw-r--r--include/linux/serio.h1
-rw-r--r--include/linux/sunrpc/msg_prot.h4
-rw-r--r--include/linux/sunrpc/svc.h2
-rw-r--r--include/linux/sunrpc/xdr.h1
-rw-r--r--include/linux/syscalls.h4
-rw-r--r--include/linux/sysctl.h23
-rw-r--r--include/linux/taskstats_kern.h31
-rw-r--r--include/linux/tcp.h2
-rw-r--r--include/linux/tipc.h1
-rw-r--r--include/linux/ufs_fs.h2
-rw-r--r--include/linux/unwind.h2
-rw-r--r--include/linux/videodev2.h2
-rw-r--r--include/linux/vmalloc.h6
-rw-r--r--include/linux/wait.h9
-rw-r--r--include/linux/writeback.h1
-rw-r--r--include/net/bluetooth/hci_core.h17
-rw-r--r--include/net/dn.h5
-rw-r--r--include/net/flow.h5
-rw-r--r--include/net/ieee80211softmac.h35
-rw-r--r--include/net/inet_ecn.h2
-rw-r--r--include/net/inet_timewait_sock.h1
-rw-r--r--include/net/inetpeer.h24
-rw-r--r--include/net/ip6_route.h7
-rw-r--r--include/net/ip_fib.h5
-rw-r--r--include/net/ip_vs.h1
-rw-r--r--include/net/ipx.h26
-rw-r--r--include/net/netlabel.h62
-rw-r--r--include/net/sctp/sctp.h14
-rw-r--r--include/net/sctp/ulpevent.h1
-rw-r--r--include/net/sock.h3
-rw-r--r--include/net/timewait_sock.h7
-rw-r--r--include/net/xfrm.h3
-rw-r--r--include/rdma/ib_addr.h20
-rw-r--r--include/rdma/ib_user_verbs.h2
-rw-r--r--include/scsi/libiscsi.h3
-rw-r--r--include/scsi/scsi.h5
-rw-r--r--include/scsi/scsi_transport_iscsi.h4
-rw-r--r--include/sound/version.h2
-rw-r--r--init/Kconfig20
-rw-r--r--init/main.c1
-rw-r--r--ipc/msg.c3
-rw-r--r--ipc/sem.c1
-rw-r--r--ipc/shm.c1
-rw-r--r--ipc/util.c2
-rw-r--r--ipc/util.h12
-rw-r--r--kernel/compat.c35
-rw-r--r--kernel/cpu.c38
-rw-r--r--kernel/delayacct.c15
-rw-r--r--kernel/exit.c1
-rw-r--r--kernel/fork.c7
-rw-r--r--kernel/futex.c7
-rw-r--r--kernel/irq/chip.c35
-rw-r--r--kernel/irq/manage.c9
-rw-r--r--kernel/irq/proc.c2
-rw-r--r--kernel/irq/spurious.c6
-rw-r--r--kernel/lockdep.c26
-rw-r--r--kernel/module.c92
-rw-r--r--kernel/mutex-debug.c2
-rw-r--r--kernel/nsproxy.c6
-rw-r--r--kernel/posix-cpu-timers.c27
-rw-r--r--kernel/power/disk.c45
-rw-r--r--kernel/power/swap.c3
-rw-r--r--kernel/power/user.c8
-rw-r--r--kernel/printk.c32
-rw-r--r--kernel/profile.c2
-rw-r--r--kernel/sched.c24
-rw-r--r--kernel/signal.c15
-rw-r--r--kernel/sys_ni.c2
-rw-r--r--kernel/sysctl.c34
-rw-r--r--kernel/taskstats.c87
-rw-r--r--kernel/time/jiffies.c2
-rw-r--r--kernel/time/ntp.c2
-rw-r--r--kernel/tsacct.c17
-rw-r--r--kernel/unwind.c318
-rw-r--r--kernel/user.c11
-rw-r--r--kernel/workqueue.c13
-rw-r--r--lib/Kconfig.debug18
-rw-r--r--lib/Makefile2
-rw-r--r--lib/bitmap.c54
-rw-r--r--lib/cpumask.c16
-rw-r--r--lib/kobject.c1
-rw-r--r--lib/random32.c142
-rw-r--r--lib/rwsem-spinlock.c2
-rw-r--r--lib/rwsem.c2
-rw-r--r--lib/spinlock_debug.c4
-rw-r--r--lib/string.c2
-rw-r--r--mm/Makefile3
-rw-r--r--mm/backing-dev.c69
-rw-r--r--mm/filemap.c109
-rw-r--r--mm/hugetlb.c25
-rw-r--r--mm/memory.c1
-rw-r--r--mm/mempolicy.c2
-rw-r--r--mm/migrate.c3
-rw-r--r--mm/mmap.c26
-rw-r--r--mm/oom_kill.c1
-rw-r--r--mm/page-writeback.c17
-rw-r--r--mm/page_alloc.c60
-rw-r--r--mm/readahead.c2
-rw-r--r--mm/rmap.c41
-rw-r--r--mm/shmem.c84
-rw-r--r--mm/shmem_acl.c2
-rw-r--r--mm/slab.c13
-rw-r--r--mm/sparse.c2
-rw-r--r--mm/truncate.c4
-rw-r--r--mm/vmalloc.c54
-rw-r--r--mm/vmscan.c75
-rw-r--r--mm/vmstat.c2
-rw-r--r--net/Kconfig3
-rw-r--r--net/appletalk/ddp.c2
-rw-r--r--net/atm/atm_sysfs.c15
-rw-r--r--net/bluetooth/af_bluetooth.c38
-rw-r--r--net/bluetooth/bnep/core.c4
-rw-r--r--net/bluetooth/bnep/sock.c69
-rw-r--r--net/bluetooth/cmtp/sock.c35
-rw-r--r--net/bluetooth/hci_conn.c6
-rw-r--r--net/bluetooth/hci_event.c34
-rw-r--r--net/bluetooth/hci_sock.c13
-rw-r--r--net/bluetooth/hci_sysfs.c21
-rw-r--r--net/bluetooth/hidp/core.c14
-rw-r--r--net/bluetooth/hidp/sock.c80
-rw-r--r--net/bluetooth/l2cap.c16
-rw-r--r--net/bluetooth/rfcomm/core.c3
-rw-r--r--net/bluetooth/rfcomm/sock.c6
-rw-r--r--net/bluetooth/rfcomm/tty.c7
-rw-r--r--net/bluetooth/sco.c6
-rw-r--r--net/bridge/br_fdb.c7
-rw-r--r--net/bridge/br_if.c4
-rw-r--r--net/bridge/br_private.h2
-rw-r--r--net/bridge/br_stp_if.c2
-rw-r--r--net/bridge/br_sysfs_br.c2
-rw-r--r--net/bridge/netfilter/ebtables.c2
-rw-r--r--net/compat.c3
-rw-r--r--net/core/dev.c2
-rw-r--r--net/core/flow.c42
-rw-r--r--net/core/netpoll.c14
-rw-r--r--net/core/pktgen.c30
-rw-r--r--net/core/rtnetlink.c2
-rw-r--r--net/core/scm.c3
-rw-r--r--net/core/skbuff.c10
-rw-r--r--net/core/sock.c4
-rw-r--r--net/core/utils.c116
-rw-r--r--net/core/wireless.c33
-rw-r--r--net/dccp/Kconfig6
-rw-r--r--net/dccp/ackvec.c12
-rw-r--r--net/dccp/ackvec.h3
-rw-r--r--net/dccp/ccids/Kconfig17
-rw-r--r--net/dccp/ccids/ccid2.c20
-rw-r--r--net/dccp/ccids/ccid3.c3
-rw-r--r--net/dccp/dccp.h2
-rw-r--r--net/dccp/input.c4
-rw-r--r--net/dccp/ipv4.c14
-rw-r--r--net/dccp/ipv6.c22
-rw-r--r--net/dccp/options.c2
-rw-r--r--net/decnet/af_decnet.c29
-rw-r--r--net/decnet/dn_nsp_in.c8
-rw-r--r--net/decnet/dn_nsp_out.c2
-rw-r--r--net/decnet/dn_route.c14
-rw-r--r--net/decnet/dn_rules.c4
-rw-r--r--net/ieee80211/Kconfig2
-rw-r--r--net/ieee80211/ieee80211_rx.c12
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_assoc.c56
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_io.c11
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_module.c1
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_wx.c71
-rw-r--r--net/ipv4/cipso_ipv4.c47
-rw-r--r--net/ipv4/fib_frontend.c5
-rw-r--r--net/ipv4/inetpeer.c29
-rw-r--r--net/ipv4/ip_gre.c4
-rw-r--r--net/ipv4/ip_options.c2
-rw-r--r--net/ipv4/ipconfig.c2
-rw-r--r--net/ipv4/ipvs/ip_vs_ftp.c2
-rw-r--r--net/ipv4/ipvs/ip_vs_proto_tcp.c2
-rw-r--r--net/ipv4/ipvs/ip_vs_proto_udp.c8
-rw-r--r--net/ipv4/netfilter/arp_tables.c27
-rw-r--r--net/ipv4/netfilter/ip_conntrack_netlink.c72
-rw-r--r--net/ipv4/netfilter/ip_queue.c7
-rw-r--r--net/ipv4/netfilter/ip_tables.c70
-rw-r--r--net/ipv4/netfilter/ipt_ECN.c6
-rw-r--r--net/ipv4/netfilter/ipt_TOS.c6
-rw-r--r--net/ipv4/raw.c17
-rw-r--r--net/ipv4/route.c12
-rw-r--r--net/ipv4/sysctl_net_ipv4.c7
-rw-r--r--net/ipv4/tcp.c11
-rw-r--r--net/ipv4/tcp_cong.c8
-rw-r--r--net/ipv4/tcp_cubic.c6
-rw-r--r--net/ipv4/tcp_htcp.c2
-rw-r--r--net/ipv4/tcp_ipv4.c20
-rw-r--r--net/ipv4/tcp_output.c51
-rw-r--r--net/ipv4/xfrm4_policy.c2
-rw-r--r--net/ipv6/Kconfig29
-rw-r--r--net/ipv6/Makefile3
-rw-r--r--net/ipv6/addrconf.c18
-rw-r--r--net/ipv6/af_inet6.c2
-rw-r--r--net/ipv6/fib6_rules.c11
-rw-r--r--net/ipv6/ip6_fib.c9
-rw-r--r--net/ipv6/ip6_flowlabel.c24
-rw-r--r--net/ipv6/ip6_tunnel.c19
-rw-r--r--net/ipv6/ndisc.c3
-rw-r--r--net/ipv6/netfilter/Kconfig2
-rw-r--r--net/ipv6/netfilter/ip6_queue.c7
-rw-r--r--net/ipv6/netfilter/ip6_tables.c47
-rw-r--r--net/ipv6/netfilter/ip6t_ah.c7
-rw-r--r--net/ipv6/netfilter/ip6t_frag.c7
-rw-r--r--net/ipv6/netfilter/ip6t_hbh.c7
-rw-r--r--net/ipv6/netfilter/ip6t_rt.c7
-rw-r--r--net/ipv6/raw.c17
-rw-r--r--net/ipv6/route.c81
-rw-r--r--net/ipv6/sit.c5
-rw-r--r--net/ipv6/tcp_ipv6.c13
-rw-r--r--net/ipv6/udp.c7
-rw-r--r--net/ipv6/xfrm6_policy.c14
-rw-r--r--net/ipv6/xfrm6_tunnel.c4
-rw-r--r--net/ipx/af_ipx.c85
-rw-r--r--net/ipx/ipx_proc.c12
-rw-r--r--net/ipx/ipx_route.c14
-rw-r--r--net/irda/irlmp.c3
-rw-r--r--net/key/af_key.c5
-rw-r--r--net/netfilter/Kconfig4
-rw-r--r--net/netfilter/nf_conntrack_core.c3
-rw-r--r--net/netfilter/nf_conntrack_netlink.c72
-rw-r--r--net/netfilter/nfnetlink_log.c10
-rw-r--r--net/netfilter/nfnetlink_queue.c9
-rw-r--r--net/netfilter/xt_NFQUEUE.c2
-rw-r--r--net/netfilter/xt_connmark.c2
-rw-r--r--net/netlabel/Kconfig2
-rw-r--r--net/netlabel/netlabel_kapi.c2
-rw-r--r--net/netlink/af_netlink.c5
-rw-r--r--net/sched/sch_htb.c11
-rw-r--r--net/sched/sch_netem.c4
-rw-r--r--net/sctp/associola.c15
-rw-r--r--net/sctp/endpointola.c7
-rw-r--r--net/sctp/input.c9
-rw-r--r--net/sctp/ipv6.c10
-rw-r--r--net/sctp/proc.c2
-rw-r--r--net/sctp/protocol.c2
-rw-r--r--net/sctp/socket.c33
-rw-r--r--net/sctp/ulpevent.c25
-rw-r--r--net/sctp/ulpqueue.c2
-rw-r--r--net/sunrpc/pmap_clnt.c14
-rw-r--r--net/sunrpc/svc.c5
-rw-r--r--net/sunrpc/svcauth.c5
-rw-r--r--net/sunrpc/svcsock.c33
-rw-r--r--net/sunrpc/xprtsock.c2
-rw-r--r--net/tipc/bearer.c8
-rw-r--r--net/tipc/config.c5
-rw-r--r--net/tipc/core.c4
-rw-r--r--net/tipc/core.h30
-rw-r--r--net/tipc/dbg.c136
-rw-r--r--net/tipc/dbg.h15
-rw-r--r--net/tipc/discover.c39
-rw-r--r--net/tipc/link.c8
-rw-r--r--net/tipc/name_distr.c2
-rw-r--r--net/tipc/node.c2
-rw-r--r--net/tipc/port.c12
-rw-r--r--net/tipc/socket.c13
-rw-r--r--net/tipc/subscr.c99
-rw-r--r--net/xfrm/xfrm_policy.c101
-rw-r--r--net/xfrm/xfrm_state.c19
-rw-r--r--net/xfrm/xfrm_user.c26
-rw-r--r--scripts/Makefile.headersinst2
-rw-r--r--scripts/Makefile.modpost2
-rw-r--r--scripts/basic/docproc.c2
-rw-r--r--scripts/kconfig/.gitignore2
-rw-r--r--scripts/kconfig/lxdialog/dialog.h1
-rwxr-xr-xscripts/kernel-doc15
-rw-r--r--scripts/mod/modpost.c2
-rw-r--r--security/dummy.c3
-rw-r--r--security/selinux/hooks.c8
-rw-r--r--security/selinux/include/selinux_netlabel.h10
-rw-r--r--security/selinux/include/xfrm.h3
-rw-r--r--security/selinux/ss/ebitmap.c8
-rw-r--r--security/selinux/ss/mls.c17
-rw-r--r--security/selinux/ss/policydb.c2
-rw-r--r--security/selinux/ss/services.c119
-rw-r--r--security/selinux/xfrm.c53
-rw-r--r--sound/core/control.c4
-rw-r--r--sound/core/info.c5
-rw-r--r--sound/isa/Kconfig1
-rw-r--r--sound/isa/ad1816a/ad1816a.c2
-rw-r--r--sound/isa/cmi8330.c2
-rw-r--r--sound/isa/gus/interwave.c2
-rw-r--r--sound/isa/opti9xx/opti92x-ad1848.c2
-rw-r--r--sound/oss/sh_dac_audio.c2
-rw-r--r--sound/pci/ac97/ac97_codec.c8
-rw-r--r--sound/pci/ali5451/ali5451.c11
-rw-r--r--sound/pci/als300.c11
-rw-r--r--sound/pci/als4000.c11
-rw-r--r--sound/pci/atiixp.c11
-rw-r--r--sound/pci/atiixp_modem.c11
-rw-r--r--sound/pci/azt3328.c11
-rw-r--r--sound/pci/cmipci.c11
-rw-r--r--sound/pci/cs4281.c9
-rw-r--r--sound/pci/cs46xx/cs46xx_lib.c11
-rw-r--r--sound/pci/cs5535audio/cs5535audio_pm.c11
-rw-r--r--sound/pci/emu10k1/emu10k1.c13
-rw-r--r--sound/pci/ens1370.c12
-rw-r--r--sound/pci/es1938.c29
-rw-r--r--sound/pci/es1968.c71
-rw-r--r--sound/pci/fm801.c11
-rw-r--r--sound/pci/hda/hda_intel.c81
-rw-r--r--sound/pci/hda/patch_analog.c2
-rw-r--r--sound/pci/hda/patch_atihdmi.c1
-rw-r--r--sound/pci/hda/patch_realtek.c4
-rw-r--r--sound/pci/intel8x0.c29
-rw-r--r--sound/pci/intel8x0m.c23
-rw-r--r--sound/pci/maestro3.c13
-rw-r--r--sound/pci/nm256/nm256.c12
-rw-r--r--sound/pci/riptide/riptide.c11
-rw-r--r--sound/pci/trident/trident_main.c18
-rw-r--r--sound/pci/via82xx.c12
-rw-r--r--sound/pci/via82xx_modem.c12
-rw-r--r--sound/pci/vx222/vx222.c11
-rw-r--r--sound/pci/ymfpci/ymfpci_main.c9
1886 files changed, 57083 insertions, 18670 deletions
diff --git a/.gitignore b/.gitignore
index e1d5c17c12c2..9eb4b7711499 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,6 +20,7 @@
20# Top-level generic files 20# Top-level generic files
21# 21#
22tags 22tags
23TAGS
23vmlinux* 24vmlinux*
24System.map 25System.map
25Module.symvers 26Module.symvers
diff --git a/CREDITS b/CREDITS
index 5329ead9c672..ccd4f9f4dd71 100644
--- a/CREDITS
+++ b/CREDITS
@@ -45,7 +45,7 @@ S: Longford, Ireland
45S: Sydney, Australia 45S: Sydney, Australia
46 46
47N: Tigran A. Aivazian 47N: Tigran A. Aivazian
48E: tigran@veritas.com 48E: tigran@aivazian.fsnet.co.uk
49W: http://www.moses.uklinux.net/patches 49W: http://www.moses.uklinux.net/patches
50D: BFS filesystem 50D: BFS filesystem
51D: Intel IA32 CPU microcode update support 51D: Intel IA32 CPU microcode update support
@@ -3511,14 +3511,12 @@ D: The Linux Support Team Erlangen
3511 3511
3512N: David Weinehall 3512N: David Weinehall
3513E: tao@acc.umu.se 3513E: tao@acc.umu.se
3514P: 1024D/DC47CA16 7ACE 0FB0 7A74 F994 9B36 E1D1 D14E 8526 DC47 CA16
3514W: http://www.acc.umu.se/~tao/ 3515W: http://www.acc.umu.se/~tao/
3515W: http://www.acc.umu.se/~mcalinux/ 3516D: v2.0 kernel maintainer
3516D: Fixes for the NE/2-driver 3517D: Fixes for the NE/2-driver
3517D: Miscellaneous MCA-support 3518D: Miscellaneous MCA-support
3518D: Cleanup of the Config-files 3519D: Cleanup of the Config-files
3519S: Axtorpsvagen 40:20
3520S: S-903 37 UMEA
3521S: Sweden
3522 3520
3523N: Matt Welsh 3521N: Matt Welsh
3524E: mdw@metalab.unc.edu 3522E: mdw@metalab.unc.edu
diff --git a/Documentation/ABI/testing/sysfs-power b/Documentation/ABI/testing/sysfs-power
index d882f8093871..dcff4d0623ad 100644
--- a/Documentation/ABI/testing/sysfs-power
+++ b/Documentation/ABI/testing/sysfs-power
@@ -21,7 +21,7 @@ Description:
21 these states. 21 these states.
22 22
23What: /sys/power/disk 23What: /sys/power/disk
24Date: August 2006 24Date: September 2006
25Contact: Rafael J. Wysocki <rjw@sisk.pl> 25Contact: Rafael J. Wysocki <rjw@sisk.pl>
26Description: 26Description:
27 The /sys/power/disk file controls the operating mode of the 27 The /sys/power/disk file controls the operating mode of the
@@ -39,6 +39,19 @@ Description:
39 'reboot' - the memory image will be saved by the kernel and 39 'reboot' - the memory image will be saved by the kernel and
40 the system will be rebooted. 40 the system will be rebooted.
41 41
42 Additionally, /sys/power/disk can be used to turn on one of the
43 two testing modes of the suspend-to-disk mechanism: 'testproc'
44 or 'test'. If the suspend-to-disk mechanism is in the
45 'testproc' mode, writing 'disk' to /sys/power/state will cause
46 the kernel to disable nonboot CPUs and freeze tasks, wait for 5
47 seconds, unfreeze tasks and enable nonboot CPUs. If it is in
48 the 'test' mode, writing 'disk' to /sys/power/state will cause
49 the kernel to disable nonboot CPUs and freeze tasks, shrink
50 memory, suspend devices, wait for 5 seconds, resume devices,
51 unfreeze tasks and enable nonboot CPUs. Then, we are able to
52 look in the log messages and work out, for example, which code
53 is being slow and which device drivers are misbehaving.
54
42 The suspend-to-disk method may be chosen by writing to this 55 The suspend-to-disk method may be chosen by writing to this
43 file one of the accepted strings: 56 file one of the accepted strings:
44 57
@@ -46,6 +59,8 @@ Description:
46 'platform' 59 'platform'
47 'shutdown' 60 'shutdown'
48 'reboot' 61 'reboot'
62 'testproc'
63 'test'
49 64
50 It will only change to 'firmware' or 'platform' if the system 65 It will only change to 'firmware' or 'platform' if the system
51 supports that. 66 supports that.
diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile
index 66e1cf733571..db9499adbed4 100644
--- a/Documentation/DocBook/Makefile
+++ b/Documentation/DocBook/Makefile
@@ -9,7 +9,7 @@
9DOCBOOKS := wanbook.xml z8530book.xml mcabook.xml videobook.xml \ 9DOCBOOKS := wanbook.xml z8530book.xml mcabook.xml videobook.xml \
10 kernel-hacking.xml kernel-locking.xml deviceiobook.xml \ 10 kernel-hacking.xml kernel-locking.xml deviceiobook.xml \
11 procfs-guide.xml writing_usb_driver.xml \ 11 procfs-guide.xml writing_usb_driver.xml \
12 kernel-api.xml journal-api.xml lsm.xml usb.xml \ 12 kernel-api.xml filesystems.xml lsm.xml usb.xml \
13 gadget.xml libata.xml mtdnand.xml librs.xml rapidio.xml \ 13 gadget.xml libata.xml mtdnand.xml librs.xml rapidio.xml \
14 genericirq.xml 14 genericirq.xml
15 15
diff --git a/Documentation/DocBook/journal-api.tmpl b/Documentation/DocBook/filesystems.tmpl
index 2077f9a28c19..39fa2aba7f9b 100644
--- a/Documentation/DocBook/journal-api.tmpl
+++ b/Documentation/DocBook/filesystems.tmpl
@@ -2,39 +2,11 @@
2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" 2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []> 3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []>
4 4
5<book id="LinuxJBDAPI"> 5<book id="Linux-filesystems-API">
6 <bookinfo> 6 <bookinfo>
7 <title>The Linux Journalling API</title> 7 <title>Linux Filesystems API</title>
8 <authorgroup>
9 <author>
10 <firstname>Roger</firstname>
11 <surname>Gammans</surname>
12 <affiliation>
13 <address>
14 <email>rgammans@computer-surgery.co.uk</email>
15 </address>
16 </affiliation>
17 </author>
18 </authorgroup>
19
20 <authorgroup>
21 <author>
22 <firstname>Stephen</firstname>
23 <surname>Tweedie</surname>
24 <affiliation>
25 <address>
26 <email>sct@redhat.com</email>
27 </address>
28 </affiliation>
29 </author>
30 </authorgroup>
31 8
32 <copyright> 9 <legalnotice>
33 <year>2002</year>
34 <holder>Roger Gammans</holder>
35 </copyright>
36
37<legalnotice>
38 <para> 10 <para>
39 This documentation is free software; you can redistribute 11 This documentation is free software; you can redistribute
40 it and/or modify it under the terms of the GNU General Public 12 it and/or modify it under the terms of the GNU General Public
@@ -42,21 +14,21 @@
42 version 2 of the License, or (at your option) any later 14 version 2 of the License, or (at your option) any later
43 version. 15 version.
44 </para> 16 </para>
45 17
46 <para> 18 <para>
47 This program is distributed in the hope that it will be 19 This program is distributed in the hope that it will be
48 useful, but WITHOUT ANY WARRANTY; without even the implied 20 useful, but WITHOUT ANY WARRANTY; without even the implied
49 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
50 See the GNU General Public License for more details. 22 See the GNU General Public License for more details.
51 </para> 23 </para>
52 24
53 <para> 25 <para>
54 You should have received a copy of the GNU General Public 26 You should have received a copy of the GNU General Public
55 License along with this program; if not, write to the Free 27 License along with this program; if not, write to the Free
56 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 28 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
57 MA 02111-1307 USA 29 MA 02111-1307 USA
58 </para> 30 </para>
59 31
60 <para> 32 <para>
61 For more details see the file COPYING in the source 33 For more details see the file COPYING in the source
62 distribution of Linux. 34 distribution of Linux.
@@ -66,17 +38,113 @@
66 38
67<toc></toc> 39<toc></toc>
68 40
69 <chapter id="Overview"> 41 <chapter id="vfs">
42 <title>The Linux VFS</title>
43 <sect1><title>The Filesystem types</title>
44!Iinclude/linux/fs.h
45 </sect1>
46 <sect1><title>The Directory Cache</title>
47!Efs/dcache.c
48!Iinclude/linux/dcache.h
49 </sect1>
50 <sect1><title>Inode Handling</title>
51!Efs/inode.c
52!Efs/bad_inode.c
53 </sect1>
54 <sect1><title>Registration and Superblocks</title>
55!Efs/super.c
56 </sect1>
57 <sect1><title>File Locks</title>
58!Efs/locks.c
59!Ifs/locks.c
60 </sect1>
61 <sect1><title>Other Functions</title>
62!Efs/mpage.c
63!Efs/namei.c
64!Efs/buffer.c
65!Efs/bio.c
66!Efs/seq_file.c
67!Efs/filesystems.c
68!Efs/fs-writeback.c
69!Efs/block_dev.c
70 </sect1>
71 </chapter>
72
73 <chapter id="proc">
74 <title>The proc filesystem</title>
75
76 <sect1><title>sysctl interface</title>
77!Ekernel/sysctl.c
78 </sect1>
79
80 <sect1><title>proc filesystem interface</title>
81!Ifs/proc/base.c
82 </sect1>
83 </chapter>
84
85 <chapter id="sysfs">
86 <title>The Filesystem for Exporting Kernel Objects</title>
87!Efs/sysfs/file.c
88!Efs/sysfs/symlink.c
89!Efs/sysfs/bin.c
90 </chapter>
91
92 <chapter id="debugfs">
93 <title>The debugfs filesystem</title>
94
95 <sect1><title>debugfs interface</title>
96!Efs/debugfs/inode.c
97!Efs/debugfs/file.c
98 </sect1>
99 </chapter>
100
101 <chapter id="LinuxJDBAPI">
102 <chapterinfo>
103 <title>The Linux Journalling API</title>
104
105 <authorgroup>
106 <author>
107 <firstname>Roger</firstname>
108 <surname>Gammans</surname>
109 <affiliation>
110 <address>
111 <email>rgammans@computer-surgery.co.uk</email>
112 </address>
113 </affiliation>
114 </author>
115 </authorgroup>
116
117 <authorgroup>
118 <author>
119 <firstname>Stephen</firstname>
120 <surname>Tweedie</surname>
121 <affiliation>
122 <address>
123 <email>sct@redhat.com</email>
124 </address>
125 </affiliation>
126 </author>
127 </authorgroup>
128
129 <copyright>
130 <year>2002</year>
131 <holder>Roger Gammans</holder>
132 </copyright>
133 </chapterinfo>
134
135 <title>The Linux Journalling API</title>
136
137 <sect1>
70 <title>Overview</title> 138 <title>Overview</title>
71 <sect1> 139 <sect2>
72 <title>Details</title> 140 <title>Details</title>
73<para> 141<para>
74The journalling layer is easy to use. You need to 142The journalling layer is easy to use. You need to
75first of all create a journal_t data structure. There are 143first of all create a journal_t data structure. There are
76two calls to do this dependent on how you decide to allocate the physical 144two calls to do this dependent on how you decide to allocate the physical
77media on which the journal resides. The journal_init_inode() call 145media on which the journal resides. The journal_init_inode() call
78is for journals stored in filesystem inodes, or the journal_init_dev() 146is for journals stored in filesystem inodes, or the journal_init_dev()
79call can be use for journal stored on a raw device (in a continuous range 147call can be use for journal stored on a raw device (in a continuous range
80of blocks). A journal_t is a typedef for a struct pointer, so when 148of blocks). A journal_t is a typedef for a struct pointer, so when
81you are finally finished make sure you call journal_destroy() on it 149you are finally finished make sure you call journal_destroy() on it
82to free up any used kernel memory. 150to free up any used kernel memory.
@@ -91,27 +159,26 @@ need to call journal_create().
91<para> 159<para>
92Most of the time however your journal file will already have been created, but 160Most of the time however your journal file will already have been created, but
93before you load it you must call journal_wipe() to empty the journal file. 161before you load it you must call journal_wipe() to empty the journal file.
94Hang on, you say , what if the filesystem wasn't cleanly umount()'d . Well, it is the 162Hang on, you say , what if the filesystem wasn't cleanly umount()'d . Well, it is the
95job of the client file system to detect this and skip the call to journal_wipe(). 163job of the client file system to detect this and skip the call to journal_wipe().
96</para> 164</para>
97 165
98<para> 166<para>
99In either case the next call should be to journal_load() which prepares the 167In either case the next call should be to journal_load() which prepares the
100journal file for use. Note that journal_wipe(..,0) calls journal_skip_recovery() 168journal file for use. Note that journal_wipe(..,0) calls journal_skip_recovery()
101for you if it detects any outstanding transactions in the journal and similarly 169for you if it detects any outstanding transactions in the journal and similarly
102journal_load() will call journal_recover() if necessary. 170journal_load() will call journal_recover() if necessary.
103I would advise reading fs/ext3/super.c for examples on this stage. 171I would advise reading fs/ext3/super.c for examples on this stage.
104[RGG: Why is the journal_wipe() call necessary - doesn't this needlessly 172[RGG: Why is the journal_wipe() call necessary - doesn't this needlessly
105complicate the API. Or isn't a good idea for the journal layer to hide 173complicate the API. Or isn't a good idea for the journal layer to hide
106dirty mounts from the client fs] 174dirty mounts from the client fs]
107</para> 175</para>
108 176
109<para> 177<para>
110Now you can go ahead and start modifying the underlying 178Now you can go ahead and start modifying the underlying
111filesystem. Almost. 179filesystem. Almost.
112</para> 180</para>
113 181
114
115<para> 182<para>
116 183
117You still need to actually journal your filesystem changes, this 184You still need to actually journal your filesystem changes, this
@@ -138,10 +205,10 @@ individual buffers (blocks). Before you start to modify a buffer you
138need to call journal_get_{create,write,undo}_access() as appropriate, 205need to call journal_get_{create,write,undo}_access() as appropriate,
139this allows the journalling layer to copy the unmodified data if it 206this allows the journalling layer to copy the unmodified data if it
140needs to. After all the buffer may be part of a previously uncommitted 207needs to. After all the buffer may be part of a previously uncommitted
141transaction. 208transaction.
142At this point you are at last ready to modify a buffer, and once 209At this point you are at last ready to modify a buffer, and once
143you are have done so you need to call journal_dirty_{meta,}data(). 210you are have done so you need to call journal_dirty_{meta,}data().
144Or if you've asked for access to a buffer you now know is now longer 211Or if you've asked for access to a buffer you now know is now longer
145required to be pushed back on the device you can call journal_forget() 212required to be pushed back on the device you can call journal_forget()
146in much the same way as you might have used bforget() in the past. 213in much the same way as you might have used bforget() in the past.
147</para> 214</para>
@@ -156,7 +223,6 @@ Then at umount time , in your put_super() (2.4) or write_super() (2.5)
156you can then call journal_destroy() to clean up your in-core journal object. 223you can then call journal_destroy() to clean up your in-core journal object.
157</para> 224</para>
158 225
159
160<para> 226<para>
161Unfortunately there a couple of ways the journal layer can cause a deadlock. 227Unfortunately there a couple of ways the journal layer can cause a deadlock.
162The first thing to note is that each task can only have 228The first thing to note is that each task can only have
@@ -164,19 +230,19 @@ a single outstanding transaction at any one time, remember nothing
164commits until the outermost journal_stop(). This means 230commits until the outermost journal_stop(). This means
165you must complete the transaction at the end of each file/inode/address 231you must complete the transaction at the end of each file/inode/address
166etc. operation you perform, so that the journalling system isn't re-entered 232etc. operation you perform, so that the journalling system isn't re-entered
167on another journal. Since transactions can't be nested/batched 233on another journal. Since transactions can't be nested/batched
168across differing journals, and another filesystem other than 234across differing journals, and another filesystem other than
169yours (say ext3) may be modified in a later syscall. 235yours (say ext3) may be modified in a later syscall.
170</para> 236</para>
171 237
172<para> 238<para>
173The second case to bear in mind is that journal_start() can 239The second case to bear in mind is that journal_start() can
174block if there isn't enough space in the journal for your transaction 240block if there isn't enough space in the journal for your transaction
175(based on the passed nblocks param) - when it blocks it merely(!) needs to 241(based on the passed nblocks param) - when it blocks it merely(!) needs to
176wait for transactions to complete and be committed from other tasks, 242wait for transactions to complete and be committed from other tasks,
177so essentially we are waiting for journal_stop(). So to avoid 243so essentially we are waiting for journal_stop(). So to avoid
178deadlocks you must treat journal_start/stop() as if they 244deadlocks you must treat journal_start/stop() as if they
179were semaphores and include them in your semaphore ordering rules to prevent 245were semaphores and include them in your semaphore ordering rules to prevent
180deadlocks. Note that journal_extend() has similar blocking behaviour to 246deadlocks. Note that journal_extend() has similar blocking behaviour to
181journal_start() so you can deadlock here just as easily as on journal_start(). 247journal_start() so you can deadlock here just as easily as on journal_start().
182</para> 248</para>
@@ -184,7 +250,7 @@ journal_start() so you can deadlock here just as easily as on journal_start().
184<para> 250<para>
185Try to reserve the right number of blocks the first time. ;-). This will 251Try to reserve the right number of blocks the first time. ;-). This will
186be the maximum number of blocks you are going to touch in this transaction. 252be the maximum number of blocks you are going to touch in this transaction.
187I advise having a look at at least ext3_jbd.h to see the basis on which 253I advise having a look at at least ext3_jbd.h to see the basis on which
188ext3 uses to make these decisions. 254ext3 uses to make these decisions.
189</para> 255</para>
190 256
@@ -193,13 +259,13 @@ Another wriggle to watch out for is your on-disk block allocation strategy.
193why? Because, if you undo a delete, you need to ensure you haven't reused any 259why? Because, if you undo a delete, you need to ensure you haven't reused any
194of the freed blocks in a later transaction. One simple way of doing this 260of the freed blocks in a later transaction. One simple way of doing this
195is make sure any blocks you allocate only have checkpointed transactions 261is make sure any blocks you allocate only have checkpointed transactions
196listed against them. Ext3 does this in ext3_test_allocatable(). 262listed against them. Ext3 does this in ext3_test_allocatable().
197</para> 263</para>
198 264
199<para> 265<para>
200Lock is also providing through journal_{un,}lock_updates(), 266Lock is also providing through journal_{un,}lock_updates(),
201ext3 uses this when it wants a window with a clean and stable fs for a moment. 267ext3 uses this when it wants a window with a clean and stable fs for a moment.
202eg. 268eg.
203</para> 269</para>
204 270
205<programlisting> 271<programlisting>
@@ -230,19 +296,19 @@ extend it like this:-
230 struct journal_callback for_jbd; 296 struct journal_callback for_jbd;
231 // Stuff for myfs allocated together. 297 // Stuff for myfs allocated together.
232 myfs_inode* i_commited; 298 myfs_inode* i_commited;
233 299
234 } 300 }
235</programlisting> 301</programlisting>
236 302
237<para> 303<para>
238this would be useful if you needed to know when data was committed to a 304this would be useful if you needed to know when data was committed to a
239particular inode. 305particular inode.
240</para> 306</para>
241 307
242</sect1> 308 </sect2>
243 309
244<sect1> 310 <sect2>
245<title>Summary</title> 311 <title>Summary</title>
246<para> 312<para>
247Using the journal is a matter of wrapping the different context changes, 313Using the journal is a matter of wrapping the different context changes,
248being each mount, each modification (transaction) and each changed buffer 314being each mount, each modification (transaction) and each changed buffer
@@ -260,15 +326,15 @@ an example.
260 if (clean) journal_wipe(); 326 if (clean) journal_wipe();
261 journal_load(); 327 journal_load();
262 328
263 foreach(transaction) { /*transactions must be 329 foreach(transaction) { /*transactions must be
264 completed before 330 completed before
265 a syscall returns to 331 a syscall returns to
266 userspace*/ 332 userspace*/
267 333
268 handle_t * xct=journal_start(my_jnrl); 334 handle_t * xct=journal_start(my_jnrl);
269 foreach(bh) { 335 foreach(bh) {
270 journal_get_{create,write,undo}_access(xact,bh); 336 journal_get_{create,write,undo}_access(xact,bh);
271 if ( myfs_modify(bh) ) { /* returns true 337 if ( myfs_modify(bh) ) { /* returns true
272 if makes changes */ 338 if makes changes */
273 journal_dirty_{meta,}data(xact,bh); 339 journal_dirty_{meta,}data(xact,bh);
274 } else { 340 } else {
@@ -279,55 +345,57 @@ an example.
279 } 345 }
280 journal_destroy(my_jrnl); 346 journal_destroy(my_jrnl);
281</programlisting> 347</programlisting>
282</sect1> 348 </sect2>
283 349
284</chapter> 350 </sect1>
285 351
286 <chapter id="adt"> 352 <sect1>
287 <title>Data Types</title> 353 <title>Data Types</title>
288 <para> 354 <para>
289 The journalling layer uses typedefs to 'hide' the concrete definitions 355 The journalling layer uses typedefs to 'hide' the concrete definitions
290 of the structures used. As a client of the JBD layer you can 356 of the structures used. As a client of the JBD layer you can
291 just rely on the using the pointer as a magic cookie of some sort. 357 just rely on the using the pointer as a magic cookie of some sort.
292 358
293 Obviously the hiding is not enforced as this is 'C'. 359 Obviously the hiding is not enforced as this is 'C'.
294 </para> 360 </para>
295 <sect1><title>Structures</title> 361 <sect2><title>Structures</title>
296!Iinclude/linux/jbd.h 362!Iinclude/linux/jbd.h
297 </sect1> 363 </sect2>
298</chapter> 364 </sect1>
299 365
300 <chapter id="calls"> 366 <sect1>
301 <title>Functions</title> 367 <title>Functions</title>
302 <para> 368 <para>
303 The functions here are split into two groups those that 369 The functions here are split into two groups those that
304 affect a journal as a whole, and those which are used to 370 affect a journal as a whole, and those which are used to
305 manage transactions 371 manage transactions
306</para> 372 </para>
307 <sect1><title>Journal Level</title> 373 <sect2><title>Journal Level</title>
308!Efs/jbd/journal.c 374!Efs/jbd/journal.c
309!Ifs/jbd/recovery.c 375!Ifs/jbd/recovery.c
310 </sect1> 376 </sect2>
311 <sect1><title>Transasction Level</title> 377 <sect2><title>Transasction Level</title>
312!Efs/jbd/transaction.c 378!Efs/jbd/transaction.c
313 </sect1> 379 </sect2>
314</chapter> 380 </sect1>
315<chapter> 381 <sect1>
316 <title>See also</title> 382 <title>See also</title>
317 <para> 383 <para>
318 <citation> 384 <citation>
319 <ulink url="ftp://ftp.uk.linux.org/pub/linux/sct/fs/jfs/journal-design.ps.gz"> 385 <ulink url="ftp://ftp.uk.linux.org/pub/linux/sct/fs/jfs/journal-design.ps.gz">
320 Journaling the Linux ext2fs Filesystem,LinuxExpo 98, Stephen Tweedie 386 Journaling the Linux ext2fs Filesystem, LinuxExpo 98, Stephen Tweedie
321 </ulink> 387 </ulink>
322 </citation> 388 </citation>
323 </para> 389 </para>
324 <para> 390 <para>
325 <citation> 391 <citation>
326 <ulink url="http://olstrans.sourceforge.net/release/OLS2000-ext3/OLS2000-ext3.html"> 392 <ulink url="http://olstrans.sourceforge.net/release/OLS2000-ext3/OLS2000-ext3.html">
327 Ext3 Journalling FileSystem , OLS 2000, Dr. Stephen Tweedie 393 Ext3 Journalling FileSystem, OLS 2000, Dr. Stephen Tweedie
328 </ulink> 394 </ulink>
329 </citation> 395 </citation>
330 </para> 396 </para>
331</chapter> 397 </sect1>
398
399 </chapter>
332 400
333</book> 401</book>
diff --git a/Documentation/DocBook/kernel-api.tmpl b/Documentation/DocBook/kernel-api.tmpl
index 2b5ac604948c..a166675c4303 100644
--- a/Documentation/DocBook/kernel-api.tmpl
+++ b/Documentation/DocBook/kernel-api.tmpl
@@ -182,66 +182,6 @@ X!Ilib/string.c
182 </sect1> 182 </sect1>
183 </chapter> 183 </chapter>
184 184
185 <chapter id="vfs">
186 <title>The Linux VFS</title>
187 <sect1><title>The Filesystem types</title>
188!Iinclude/linux/fs.h
189 </sect1>
190 <sect1><title>The Directory Cache</title>
191!Efs/dcache.c
192!Iinclude/linux/dcache.h
193 </sect1>
194 <sect1><title>Inode Handling</title>
195!Efs/inode.c
196!Efs/bad_inode.c
197 </sect1>
198 <sect1><title>Registration and Superblocks</title>
199!Efs/super.c
200 </sect1>
201 <sect1><title>File Locks</title>
202!Efs/locks.c
203!Ifs/locks.c
204 </sect1>
205 <sect1><title>Other Functions</title>
206!Efs/mpage.c
207!Efs/namei.c
208!Efs/buffer.c
209!Efs/bio.c
210!Efs/seq_file.c
211!Efs/filesystems.c
212!Efs/fs-writeback.c
213!Efs/block_dev.c
214 </sect1>
215 </chapter>
216
217 <chapter id="proc">
218 <title>The proc filesystem</title>
219
220 <sect1><title>sysctl interface</title>
221!Ekernel/sysctl.c
222 </sect1>
223
224 <sect1><title>proc filesystem interface</title>
225!Ifs/proc/base.c
226 </sect1>
227 </chapter>
228
229 <chapter id="sysfs">
230 <title>The Filesystem for Exporting Kernel Objects</title>
231!Efs/sysfs/file.c
232!Efs/sysfs/symlink.c
233!Efs/sysfs/bin.c
234 </chapter>
235
236 <chapter id="debugfs">
237 <title>The debugfs filesystem</title>
238
239 <sect1><title>debugfs interface</title>
240!Efs/debugfs/inode.c
241!Efs/debugfs/file.c
242 </sect1>
243 </chapter>
244
245 <chapter id="relayfs"> 185 <chapter id="relayfs">
246 <title>relay interface support</title> 186 <title>relay interface support</title>
247 187
diff --git a/Documentation/HOWTO b/Documentation/HOWTO
index d6f3dd1a3464..8d51c148f721 100644
--- a/Documentation/HOWTO
+++ b/Documentation/HOWTO
@@ -395,6 +395,26 @@ bugme-janitor mailing list (every change in the bugzilla is mailed here)
395 395
396 396
397 397
398Managing bug reports
399--------------------
400
401One of the best ways to put into practice your hacking skills is by fixing
402bugs reported by other people. Not only you will help to make the kernel
403more stable, you'll learn to fix real world problems and you will improve
404your skills, and other developers will be aware of your presence. Fixing
405bugs is one of the best ways to get merits among other developers, because
406not many people like wasting time fixing other people's bugs.
407
408To work in the already reported bug reports, go to http://bugzilla.kernel.org.
409If you want to be advised of the future bug reports, you can subscribe to the
410bugme-new mailing list (only new bug reports are mailed here) or to the
411bugme-janitor mailing list (every change in the bugzilla is mailed here)
412
413 http://lists.osdl.org/mailman/listinfo/bugme-new
414 http://lists.osdl.org/mailman/listinfo/bugme-janitors
415
416
417
398Mailing lists 418Mailing lists
399------------- 419-------------
400 420
diff --git a/Documentation/MSI-HOWTO.txt b/Documentation/MSI-HOWTO.txt
index c70306abb7b2..5c34910665d1 100644
--- a/Documentation/MSI-HOWTO.txt
+++ b/Documentation/MSI-HOWTO.txt
@@ -470,7 +470,68 @@ LOC: 324553 325068
470ERR: 0 470ERR: 0
471MIS: 0 471MIS: 0
472 472
4736. FAQ 4736. MSI quirks
474
475Several PCI chipsets or devices are known to not support MSI.
476The PCI stack provides 3 possible levels of MSI disabling:
477* on a single device
478* on all devices behind a specific bridge
479* globally
480
4816.1. Disabling MSI on a single device
482
483Under some circumstances, it might be required to disable MSI on a
484single device, It may be achived by either not calling pci_enable_msi()
485or all, or setting the pci_dev->no_msi flag before (most of the time
486in a quirk).
487
4886.2. Disabling MSI below a bridge
489
490The vast majority of MSI quirks are required by PCI bridges not
491being able to route MSI between busses. In this case, MSI have to be
492disabled on all devices behind this bridge. It is achieves by setting
493the PCI_BUS_FLAGS_NO_MSI flag in the pci_bus->bus_flags of the bridge
494subordinate bus. There is no need to set the same flag on bridges that
495are below the broken brigde. When pci_enable_msi() is called to enable
496MSI on a device, pci_msi_supported() takes care of checking the NO_MSI
497flag in all parent busses of the device.
498
499Some bridges actually support dynamic MSI support enabling/disabling
500by changing some bits in their PCI configuration space (especially
501the Hypertransport chipsets such as the nVidia nForce and Serverworks
502HT2000). It may then be required to update the NO_MSI flag on the
503corresponding devices in the sysfs hierarchy. To enable MSI support
504on device "0000:00:0e", do:
505
506 echo 1 > /sys/bus/pci/devices/0000:00:0e/msi_bus
507
508To disable MSI support, echo 0 instead of 1. Note that it should be
509used with caution since changing this value might break interrupts.
510
5116.3. Disabling MSI globally
512
513Some extreme cases may require to disable MSI globally on the system.
514For now, the only known case is a Serverworks PCI-X chipsets (MSI are
515not supported on several busses that are not all connected to the
516chipset in the Linux PCI hierarchy). In the vast majority of other
517cases, disabling only behind a specific bridge is enough.
518
519For debugging purpose, the user may also pass pci=nomsi on the kernel
520command-line to explicitly disable MSI globally. But, once the appro-
521priate quirks are added to the kernel, this option should not be
522required anymore.
523
5246.4. Finding why MSI cannot be enabled on a device
525
526Assuming that MSI are not enabled on a device, you should look at
527dmesg to find messages that quirks may output when disabling MSI
528on some devices, some bridges or even globally.
529Then, lspci -t gives the list of bridges above a device. Reading
530/sys/bus/pci/devices/0000:00:0e/msi_bus will tell you whether MSI
531are enabled (1) or disabled (0). In 0 is found in a single bridge
532msi_bus file above the device, MSI cannot be enabled.
533
5347. FAQ
474 535
475Q1. Are there any limitations on using the MSI? 536Q1. Are there any limitations on using the MSI?
476 537
diff --git a/Documentation/accounting/getdelays.c b/Documentation/accounting/getdelays.c
index b11792abd6b6..bf2b0e2f87e1 100644
--- a/Documentation/accounting/getdelays.c
+++ b/Documentation/accounting/getdelays.c
@@ -49,7 +49,7 @@ __u64 stime, utime;
49 } 49 }
50 50
51/* Maximum size of response requested or message sent */ 51/* Maximum size of response requested or message sent */
52#define MAX_MSG_SIZE 256 52#define MAX_MSG_SIZE 1024
53/* Maximum number of cpus expected to be specified in a cpumask */ 53/* Maximum number of cpus expected to be specified in a cpumask */
54#define MAX_CPUS 32 54#define MAX_CPUS 32
55/* Maximum length of pathname to log file */ 55/* Maximum length of pathname to log file */
diff --git a/Documentation/cpu-hotplug.txt b/Documentation/cpu-hotplug.txt
index bc107cb157a8..4868c34f7509 100644
--- a/Documentation/cpu-hotplug.txt
+++ b/Documentation/cpu-hotplug.txt
@@ -46,7 +46,7 @@ maxcpus=n Restrict boot time cpus to n. Say if you have 4 cpus, using
46 maxcpus=2 will only boot 2. You can choose to bring the 46 maxcpus=2 will only boot 2. You can choose to bring the
47 other cpus later online, read FAQ's for more info. 47 other cpus later online, read FAQ's for more info.
48 48
49additional_cpus*=n Use this to limit hotpluggable cpus. This option sets 49additional_cpus=n (*) Use this to limit hotpluggable cpus. This option sets
50 cpu_possible_map = cpu_present_map + additional_cpus 50 cpu_possible_map = cpu_present_map + additional_cpus
51 51
52(*) Option valid only for following architectures 52(*) Option valid only for following architectures
@@ -101,15 +101,15 @@ cpu_possible_map/for_each_possible_cpu() to iterate.
101 101
102Never use anything other than cpumask_t to represent bitmap of CPUs. 102Never use anything other than cpumask_t to represent bitmap of CPUs.
103 103
104#include <linux/cpumask.h> 104 #include <linux/cpumask.h>
105 105
106for_each_possible_cpu - Iterate over cpu_possible_map 106 for_each_possible_cpu - Iterate over cpu_possible_map
107for_each_online_cpu - Iterate over cpu_online_map 107 for_each_online_cpu - Iterate over cpu_online_map
108for_each_present_cpu - Iterate over cpu_present_map 108 for_each_present_cpu - Iterate over cpu_present_map
109for_each_cpu_mask(x,mask) - Iterate over some random collection of cpu mask. 109 for_each_cpu_mask(x,mask) - Iterate over some random collection of cpu mask.
110 110
111#include <linux/cpu.h> 111 #include <linux/cpu.h>
112lock_cpu_hotplug() and unlock_cpu_hotplug(): 112 lock_cpu_hotplug() and unlock_cpu_hotplug():
113 113
114The above calls are used to inhibit cpu hotplug operations. While holding the 114The above calls are used to inhibit cpu hotplug operations. While holding the
115cpucontrol mutex, cpu_online_map will not change. If you merely need to avoid 115cpucontrol mutex, cpu_online_map will not change. If you merely need to avoid
@@ -120,7 +120,7 @@ will work as long as stop_machine_run() is used to take a cpu down.
120 120
121CPU Hotplug - Frequently Asked Questions. 121CPU Hotplug - Frequently Asked Questions.
122 122
123Q: How to i enable my kernel to support CPU hotplug? 123Q: How to enable my kernel to support CPU hotplug?
124A: When doing make defconfig, Enable CPU hotplug support 124A: When doing make defconfig, Enable CPU hotplug support
125 125
126 "Processor type and Features" -> Support for Hotpluggable CPUs 126 "Processor type and Features" -> Support for Hotpluggable CPUs
@@ -141,39 +141,39 @@ A: You should now notice an entry in sysfs.
141Check if sysfs is mounted, using the "mount" command. You should notice 141Check if sysfs is mounted, using the "mount" command. You should notice
142an entry as shown below in the output. 142an entry as shown below in the output.
143 143
144.... 144 ....
145none on /sys type sysfs (rw) 145 none on /sys type sysfs (rw)
146.... 146 ....
147 147
148if this is not mounted, do the following. 148If this is not mounted, do the following.
149 149
150#mkdir /sysfs 150 #mkdir /sysfs
151#mount -t sysfs sys /sys 151 #mount -t sysfs sys /sys
152 152
153now you should see entries for all present cpu, the following is an example 153Now you should see entries for all present cpu, the following is an example
154in a 8-way system. 154in a 8-way system.
155 155
156#pwd 156 #pwd
157#/sys/devices/system/cpu 157 #/sys/devices/system/cpu
158#ls -l 158 #ls -l
159total 0 159 total 0
160drwxr-xr-x 10 root root 0 Sep 19 07:44 . 160 drwxr-xr-x 10 root root 0 Sep 19 07:44 .
161drwxr-xr-x 13 root root 0 Sep 19 07:45 .. 161 drwxr-xr-x 13 root root 0 Sep 19 07:45 ..
162drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu0 162 drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu0
163drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu1 163 drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu1
164drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu2 164 drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu2
165drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu3 165 drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu3
166drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu4 166 drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu4
167drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu5 167 drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu5
168drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu6 168 drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu6
169drwxr-xr-x 3 root root 0 Sep 19 07:48 cpu7 169 drwxr-xr-x 3 root root 0 Sep 19 07:48 cpu7
170 170
171Under each directory you would find an "online" file which is the control 171Under each directory you would find an "online" file which is the control
172file to logically online/offline a processor. 172file to logically online/offline a processor.
173 173
174Q: Does hot-add/hot-remove refer to physical add/remove of cpus? 174Q: Does hot-add/hot-remove refer to physical add/remove of cpus?
175A: The usage of hot-add/remove may not be very consistently used in the code. 175A: The usage of hot-add/remove may not be very consistently used in the code.
176CONFIG_CPU_HOTPLUG enables logical online/offline capability in the kernel. 176CONFIG_HOTPLUG_CPU enables logical online/offline capability in the kernel.
177To support physical addition/removal, one would need some BIOS hooks and 177To support physical addition/removal, one would need some BIOS hooks and
178the platform should have something like an attention button in PCI hotplug. 178the platform should have something like an attention button in PCI hotplug.
179CONFIG_ACPI_HOTPLUG_CPU enables ACPI support for physical add/remove of CPUs. 179CONFIG_ACPI_HOTPLUG_CPU enables ACPI support for physical add/remove of CPUs.
@@ -181,17 +181,17 @@ CONFIG_ACPI_HOTPLUG_CPU enables ACPI support for physical add/remove of CPUs.
181Q: How do i logically offline a CPU? 181Q: How do i logically offline a CPU?
182A: Do the following. 182A: Do the following.
183 183
184#echo 0 > /sys/devices/system/cpu/cpuX/online 184 #echo 0 > /sys/devices/system/cpu/cpuX/online
185 185
186once the logical offline is successful, check 186Once the logical offline is successful, check
187 187
188#cat /proc/interrupts 188 #cat /proc/interrupts
189 189
190you should now not see the CPU that you removed. Also online file will report 190You should now not see the CPU that you removed. Also online file will report
191the state as 0 when a cpu if offline and 1 when its online. 191the state as 0 when a cpu if offline and 1 when its online.
192 192
193#To display the current cpu state. 193 #To display the current cpu state.
194#cat /sys/devices/system/cpu/cpuX/online 194 #cat /sys/devices/system/cpu/cpuX/online
195 195
196Q: Why cant i remove CPU0 on some systems? 196Q: Why cant i remove CPU0 on some systems?
197A: Some architectures may have some special dependency on a certain CPU. 197A: Some architectures may have some special dependency on a certain CPU.
@@ -234,8 +234,8 @@ Q: If i have some kernel code that needs to be aware of CPU arrival and
234 departure, how to i arrange for proper notification? 234 departure, how to i arrange for proper notification?
235A: This is what you would need in your kernel code to receive notifications. 235A: This is what you would need in your kernel code to receive notifications.
236 236
237 #include <linux/cpu.h> 237 #include <linux/cpu.h>
238 static int __cpuinit foobar_cpu_callback(struct notifier_block *nfb, 238 static int __cpuinit foobar_cpu_callback(struct notifier_block *nfb,
239 unsigned long action, void *hcpu) 239 unsigned long action, void *hcpu)
240 { 240 {
241 unsigned int cpu = (unsigned long)hcpu; 241 unsigned int cpu = (unsigned long)hcpu;
@@ -279,10 +279,10 @@ Q: I don't see my action being called for all CPUs already up and running?
279A: Yes, CPU notifiers are called only when new CPUs are on-lined or offlined. 279A: Yes, CPU notifiers are called only when new CPUs are on-lined or offlined.
280 If you need to perform some action for each cpu already in the system, then 280 If you need to perform some action for each cpu already in the system, then
281 281
282 for_each_online_cpu(i) { 282 for_each_online_cpu(i) {
283 foobar_cpu_callback(&foobar_cpu_notifier, CPU_UP_PREPARE, i); 283 foobar_cpu_callback(&foobar_cpu_notifier, CPU_UP_PREPARE, i);
284 foobar_cpu_callback(&foobar-cpu_notifier, CPU_ONLINE, i); 284 foobar_cpu_callback(&foobar_cpu_notifier, CPU_ONLINE, i);
285 } 285 }
286 286
287Q: If i would like to develop cpu hotplug support for a new architecture, 287Q: If i would like to develop cpu hotplug support for a new architecture,
288 what do i need at a minimum? 288 what do i need at a minimum?
@@ -307,38 +307,38 @@ Q: I need to ensure that a particular cpu is not removed when there is some
307 work specific to this cpu is in progress. 307 work specific to this cpu is in progress.
308A: First switch the current thread context to preferred cpu 308A: First switch the current thread context to preferred cpu
309 309
310 int my_func_on_cpu(int cpu) 310 int my_func_on_cpu(int cpu)
311 { 311 {
312 cpumask_t saved_mask, new_mask = CPU_MASK_NONE; 312 cpumask_t saved_mask, new_mask = CPU_MASK_NONE;
313 int curr_cpu, err = 0; 313 int curr_cpu, err = 0;
314 314
315 saved_mask = current->cpus_allowed; 315 saved_mask = current->cpus_allowed;
316 cpu_set(cpu, new_mask); 316 cpu_set(cpu, new_mask);
317 err = set_cpus_allowed(current, new_mask); 317 err = set_cpus_allowed(current, new_mask);
318 318
319 if (err) 319 if (err)
320 return err; 320 return err;
321 321
322 /* 322 /*
323 * If we got scheduled out just after the return from 323 * If we got scheduled out just after the return from
324 * set_cpus_allowed() before running the work, this ensures 324 * set_cpus_allowed() before running the work, this ensures
325 * we stay locked. 325 * we stay locked.
326 */ 326 */
327 curr_cpu = get_cpu(); 327 curr_cpu = get_cpu();
328 328
329 if (curr_cpu != cpu) { 329 if (curr_cpu != cpu) {
330 err = -EAGAIN; 330 err = -EAGAIN;
331 goto ret; 331 goto ret;
332 } else { 332 } else {
333 /* 333 /*
334 * Do work : But cant sleep, since get_cpu() disables preempt 334 * Do work : But cant sleep, since get_cpu() disables preempt
335 */ 335 */
336 } 336 }
337 ret: 337 ret:
338 put_cpu(); 338 put_cpu();
339 set_cpus_allowed(current, saved_mask); 339 set_cpus_allowed(current, saved_mask);
340 return err; 340 return err;
341 } 341 }
342 342
343 343
344Q: How do we determine how many CPUs are available for hotplug. 344Q: How do we determine how many CPUs are available for hotplug.
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 24f3c63b3017..d52c4aaaf17f 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -53,18 +53,6 @@ Who: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
53 53
54--------------------------- 54---------------------------
55 55
56What: sys_sysctl
57When: January 2007
58Why: The same information is available through /proc/sys and that is the
59 interface user space prefers to use. And there do not appear to be
60 any existing user in user space of sys_sysctl. The additional
61 maintenance overhead of keeping a set of binary names gets
62 in the way of doing a good job of maintaining this interface.
63
64Who: Eric Biederman <ebiederm@xmission.com>
65
66---------------------------
67
68What: PCMCIA control ioctl (needed for pcmcia-cs [cardmgr, cardctl]) 56What: PCMCIA control ioctl (needed for pcmcia-cs [cardmgr, cardctl])
69When: November 2005 57When: November 2005
70Files: drivers/pcmcia/: pcmcia_ioctl.c 58Files: drivers/pcmcia/: pcmcia_ioctl.c
@@ -255,7 +243,7 @@ Who: Stephen Hemminger <shemminger@osdl.org>
255 243
256 244
257What: PHYSDEVPATH, PHYSDEVBUS, PHYSDEVDRIVER in the uevent environment 245What: PHYSDEVPATH, PHYSDEVBUS, PHYSDEVDRIVER in the uevent environment
258When: Oktober 2008 246When: October 2008
259Why: The stacking of class devices makes these values misleading and 247Why: The stacking of class devices makes these values misleading and
260 inconsistent. 248 inconsistent.
261 Class devices should not carry any of these properties, and bus 249 Class devices should not carry any of these properties, and bus
diff --git a/Documentation/filesystems/00-INDEX b/Documentation/filesystems/00-INDEX
index 3c384c0cf86e..4dc28cc93503 100644
--- a/Documentation/filesystems/00-INDEX
+++ b/Documentation/filesystems/00-INDEX
@@ -34,6 +34,8 @@ ext2.txt
34 - info, mount options and specifications for the Ext2 filesystem. 34 - info, mount options and specifications for the Ext2 filesystem.
35ext3.txt 35ext3.txt
36 - info, mount options and specifications for the Ext3 filesystem. 36 - info, mount options and specifications for the Ext3 filesystem.
37ext4.txt
38 - info, mount options and specifications for the Ext4 filesystem.
37files.txt 39files.txt
38 - info on file management in the Linux kernel. 40 - info on file management in the Linux kernel.
39fuse.txt 41fuse.txt
diff --git a/Documentation/filesystems/ext4.txt b/Documentation/filesystems/ext4.txt
new file mode 100644
index 000000000000..6a4adcae9f9a
--- /dev/null
+++ b/Documentation/filesystems/ext4.txt
@@ -0,0 +1,236 @@
1
2Ext4 Filesystem
3===============
4
5This is a development version of the ext4 filesystem, an advanced level
6of the ext3 filesystem which incorporates scalability and reliability
7enhancements for supporting large filesystems (64 bit) in keeping with
8increasing disk capacities and state-of-the-art feature requirements.
9
10Mailing list: linux-ext4@vger.kernel.org
11
12
131. Quick usage instructions:
14===========================
15
16 - Grab updated e2fsprogs from
17 ftp://ftp.kernel.org/pub/linux/kernel/people/tytso/e2fsprogs-interim/
18 This is a patchset on top of e2fsprogs-1.39, which can be found at
19 ftp://ftp.kernel.org/pub/linux/kernel/people/tytso/e2fsprogs/
20
21 - It's still mke2fs -j /dev/hda1
22
23 - mount /dev/hda1 /wherever -t ext4dev
24
25 - To enable extents,
26
27 mount /dev/hda1 /wherever -t ext4dev -o extents
28
29 - The filesystem is compatible with the ext3 driver until you add a file
30 which has extents (ie: `mount -o extents', then create a file).
31
32 NOTE: The "extents" mount flag is temporary. It will soon go away and
33 extents will be enabled by the "-o extents" flag to mke2fs or tune2fs
34
35 - When comparing performance with other filesystems, remember that
36 ext3/4 by default offers higher data integrity guarantees than most. So
37 when comparing with a metadata-only journalling filesystem, use `mount -o
38 data=writeback'. And you might as well use `mount -o nobh' too along
39 with it. Making the journal larger than the mke2fs default often helps
40 performance with metadata-intensive workloads.
41
422. Features
43===========
44
452.1 Currently available
46
47* ability to use filesystems > 16TB
48* extent format reduces metadata overhead (RAM, IO for access, transactions)
49* extent format more robust in face of on-disk corruption due to magics,
50* internal redunancy in tree
51
522.1 Previously available, soon to be enabled by default by "mkefs.ext4":
53
54* dir_index and resize inode will be on by default
55* large inodes will be used by default for fast EAs, nsec timestamps, etc
56
572.2 Candidate features for future inclusion
58
59There are several under discussion, whether they all make it in is
60partly a function of how much time everyone has to work on them:
61
62* improved file allocation (multi-block alloc, delayed alloc; basically done)
63* fix 32000 subdirectory limit (patch exists, needs some e2fsck work)
64* nsec timestamps for mtime, atime, ctime, create time (patch exists,
65 needs some e2fsck work)
66* inode version field on disk (NFSv4, Lustre; prototype exists)
67* reduced mke2fs/e2fsck time via uninitialized groups (prototype exists)
68* journal checksumming for robustness, performance (prototype exists)
69* persistent file preallocation (e.g for streaming media, databases)
70
71Features like metadata checksumming have been discussed and planned for
72a bit but no patches exist yet so I'm not sure they're in the near-term
73roadmap.
74
75The big performance win will come with mballoc and delalloc. CFS has
76been using mballoc for a few years already with Lustre, and IBM + Bull
77did a lot of benchmarking on it. The reason it isn't in the first set of
78patches is partly a manageability issue, and partly because it doesn't
79directly affect the on-disk format (outside of much better allocation)
80so it isn't critical to get into the first round of changes. I believe
81Alex is working on a new set of patches right now.
82
833. Options
84==========
85
86When mounting an ext4 filesystem, the following option are accepted:
87(*) == default
88
89extents ext4 will use extents to address file data. The
90 file system will no longer be mountable by ext3.
91
92journal=update Update the ext4 file system's journal to the current
93 format.
94
95journal=inum When a journal already exists, this option is ignored.
96 Otherwise, it specifies the number of the inode which
97 will represent the ext4 file system's journal file.
98
99journal_dev=devnum When the external journal device's major/minor numbers
100 have changed, this option allows the user to specify
101 the new journal location. The journal device is
102 identified through its new major/minor numbers encoded
103 in devnum.
104
105noload Don't load the journal on mounting.
106
107data=journal All data are committed into the journal prior to being
108 written into the main file system.
109
110data=ordered (*) All data are forced directly out to the main file
111 system prior to its metadata being committed to the
112 journal.
113
114data=writeback Data ordering is not preserved, data may be written
115 into the main file system after its metadata has been
116 committed to the journal.
117
118commit=nrsec (*) Ext4 can be told to sync all its data and metadata
119 every 'nrsec' seconds. The default value is 5 seconds.
120 This means that if you lose your power, you will lose
121 as much as the latest 5 seconds of work (your
122 filesystem will not be damaged though, thanks to the
123 journaling). This default value (or any low value)
124 will hurt performance, but it's good for data-safety.
125 Setting it to 0 will have the same effect as leaving
126 it at the default (5 seconds).
127 Setting it to very large values will improve
128 performance.
129
130barrier=1 This enables/disables barriers. barrier=0 disables
131 it, barrier=1 enables it.
132
133orlov (*) This enables the new Orlov block allocator. It is
134 enabled by default.
135
136oldalloc This disables the Orlov block allocator and enables
137 the old block allocator. Orlov should have better
138 performance - we'd like to get some feedback if it's
139 the contrary for you.
140
141user_xattr Enables Extended User Attributes. Additionally, you
142 need to have extended attribute support enabled in the
143 kernel configuration (CONFIG_EXT4_FS_XATTR). See the
144 attr(5) manual page and http://acl.bestbits.at/ to
145 learn more about extended attributes.
146
147nouser_xattr Disables Extended User Attributes.
148
149acl Enables POSIX Access Control Lists support.
150 Additionally, you need to have ACL support enabled in
151 the kernel configuration (CONFIG_EXT4_FS_POSIX_ACL).
152 See the acl(5) manual page and http://acl.bestbits.at/
153 for more information.
154
155noacl This option disables POSIX Access Control List
156 support.
157
158reservation
159
160noreservation
161
162bsddf (*) Make 'df' act like BSD.
163minixdf Make 'df' act like Minix.
164
165check=none Don't do extra checking of bitmaps on mount.
166nocheck
167
168debug Extra debugging information is sent to syslog.
169
170errors=remount-ro(*) Remount the filesystem read-only on an error.
171errors=continue Keep going on a filesystem error.
172errors=panic Panic and halt the machine if an error occurs.
173
174grpid Give objects the same group ID as their creator.
175bsdgroups
176
177nogrpid (*) New objects have the group ID of their creator.
178sysvgroups
179
180resgid=n The group ID which may use the reserved blocks.
181
182resuid=n The user ID which may use the reserved blocks.
183
184sb=n Use alternate superblock at this location.
185
186quota
187noquota
188grpquota
189usrquota
190
191bh (*) ext4 associates buffer heads to data pages to
192nobh (a) cache disk block mapping information
193 (b) link pages into transaction to provide
194 ordering guarantees.
195 "bh" option forces use of buffer heads.
196 "nobh" option tries to avoid associating buffer
197 heads (supported only for "writeback" mode).
198
199
200Data Mode
201---------
202There are 3 different data modes:
203
204* writeback mode
205In data=writeback mode, ext4 does not journal data at all. This mode provides
206a similar level of journaling as that of XFS, JFS, and ReiserFS in its default
207mode - metadata journaling. A crash+recovery can cause incorrect data to
208appear in files which were written shortly before the crash. This mode will
209typically provide the best ext4 performance.
210
211* ordered mode
212In data=ordered mode, ext4 only officially journals metadata, but it logically
213groups metadata and data blocks into a single unit called a transaction. When
214it's time to write the new metadata out to disk, the associated data blocks
215are written first. In general, this mode performs slightly slower than
216writeback but significantly faster than journal mode.
217
218* journal mode
219data=journal mode provides full data and metadata journaling. All new data is
220written to the journal first, and then to its final location.
221In the event of a crash, the journal can be replayed, bringing both data and
222metadata into a consistent state. This mode is the slowest except when data
223needs to be read from and written to disk at the same time where it
224outperforms all others modes.
225
226References
227==========
228
229kernel source: <file:fs/ext4/>
230 <file:fs/jbd2/>
231
232programs: http://e2fsprogs.sourceforge.net/
233 http://ext2resize.sourceforge.net
234
235useful links: http://fedoraproject.org/wiki/ext3-devel
236 http://www.bullopensource.org/ext4/
diff --git a/Documentation/filesystems/udf.txt b/Documentation/filesystems/udf.txt
index 511b4230c053..fde829a756e6 100644
--- a/Documentation/filesystems/udf.txt
+++ b/Documentation/filesystems/udf.txt
@@ -7,8 +7,17 @@ If you encounter problems with reading UDF discs using this driver,
7please report them to linux_udf@hpesjro.fc.hp.com, which is the 7please report them to linux_udf@hpesjro.fc.hp.com, which is the
8developer's list. 8developer's list.
9 9
10Write support requires a block driver which supports writing. The current 10Write support requires a block driver which supports writing. Currently
11scsi and ide cdrom drivers do not support writing. 11dvd+rw drives and media support true random sector writes, and so a udf
12filesystem on such devices can be directly mounted read/write. CD-RW
13media however, does not support this. Instead the media can be formatted
14for packet mode using the utility cdrwtool, then the pktcdvd driver can
15be bound to the underlying cd device to provide the required buffering
16and read-modify-write cycles to allow the filesystem random sector writes
17while providing the hardware with only full packet writes. While not
18required for dvd+rw media, use of the pktcdvd driver often enhances
19performance due to very poor read-modify-write support supplied internally
20by drive firmware.
12 21
13------------------------------------------------------------------------------- 22-------------------------------------------------------------------------------
14The following mount options are supported: 23The following mount options are supported:
diff --git a/Documentation/hwmon/adm9240 b/Documentation/hwmon/adm9240
index 35f618f32896..2c6f1fed4618 100644
--- a/Documentation/hwmon/adm9240
+++ b/Documentation/hwmon/adm9240
@@ -24,7 +24,7 @@ Authors:
24 Frodo Looijaard <frodol@dds.nl>, 24 Frodo Looijaard <frodol@dds.nl>,
25 Philip Edelbrock <phil@netroedge.com>, 25 Philip Edelbrock <phil@netroedge.com>,
26 Michiel Rook <michiel@grendelproject.nl>, 26 Michiel Rook <michiel@grendelproject.nl>,
27 Grant Coady <gcoady@gmail.com> with guidance 27 Grant Coady <gcoady.lk@gmail.com> with guidance
28 from Jean Delvare <khali@linux-fr.org> 28 from Jean Delvare <khali@linux-fr.org>
29 29
30Interface 30Interface
diff --git a/Documentation/hwmon/f71805f b/Documentation/hwmon/f71805f
index 28c5b7d1eb90..2ca69df669c3 100644
--- a/Documentation/hwmon/f71805f
+++ b/Documentation/hwmon/f71805f
@@ -17,7 +17,7 @@ Thanks to Kris Chen from Fintek for answering technical questions and
17providing additional documentation. 17providing additional documentation.
18 18
19Thanks to Chris Lin from Jetway for providing wiring schematics and 19Thanks to Chris Lin from Jetway for providing wiring schematics and
20anwsering technical questions. 20answering technical questions.
21 21
22 22
23Description 23Description
diff --git a/Documentation/hwmon/k8temp b/Documentation/hwmon/k8temp
index bab445ab0f52..30d123b8d920 100644
--- a/Documentation/hwmon/k8temp
+++ b/Documentation/hwmon/k8temp
@@ -2,7 +2,7 @@ Kernel driver k8temp
2==================== 2====================
3 3
4Supported chips: 4Supported chips:
5 * AMD K8 CPU 5 * AMD Athlon64/FX or Opteron CPUs
6 Prefix: 'k8temp' 6 Prefix: 'k8temp'
7 Addresses scanned: PCI space 7 Addresses scanned: PCI space
8 Datasheet: http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/32559.pdf 8 Datasheet: http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/32559.pdf
@@ -13,10 +13,13 @@ Contact: Rudolf Marek <r.marek@sh.cvut.cz>
13Description 13Description
14----------- 14-----------
15 15
16This driver permits reading temperature sensor(s) embedded inside AMD K8 CPUs. 16This driver permits reading temperature sensor(s) embedded inside AMD K8
17Official documentation says that it works from revision F of K8 core, but 17family CPUs (Athlon64/FX, Opteron). Official documentation says that it works
18in fact it seems to be implemented for all revisions of K8 except the first 18from revision F of K8 core, but in fact it seems to be implemented for all
19two revisions (SH-B0 and SH-B3). 19revisions of K8 except the first two revisions (SH-B0 and SH-B3).
20
21Please note that you will need at least lm-sensors 2.10.1 for proper userspace
22support.
20 23
21There can be up to four temperature sensors inside single CPU. The driver 24There can be up to four temperature sensors inside single CPU. The driver
22will auto-detect the sensors and will display only temperatures from 25will auto-detect the sensors and will display only temperatures from
diff --git a/Documentation/hwmon/smsc47m1 b/Documentation/hwmon/smsc47m1
index c15bbe68264e..04a11124f667 100644
--- a/Documentation/hwmon/smsc47m1
+++ b/Documentation/hwmon/smsc47m1
@@ -2,12 +2,14 @@ Kernel driver smsc47m1
2====================== 2======================
3 3
4Supported chips: 4Supported chips:
5 * SMSC LPC47B27x, LPC47M10x, LPC47M13x, LPC47M14x, LPC47M15x and LPC47M192 5 * SMSC LPC47B27x, LPC47M112, LPC47M10x, LPC47M13x, LPC47M14x,
6 LPC47M15x and LPC47M192
6 Addresses scanned: none, address read from Super I/O config space 7 Addresses scanned: none, address read from Super I/O config space
7 Prefix: 'smsc47m1' 8 Prefix: 'smsc47m1'
8 Datasheets: 9 Datasheets:
9 http://www.smsc.com/main/datasheets/47b27x.pdf 10 http://www.smsc.com/main/datasheets/47b27x.pdf
10 http://www.smsc.com/main/datasheets/47m10x.pdf 11 http://www.smsc.com/main/datasheets/47m10x.pdf
12 http://www.smsc.com/main/datasheets/47m112.pdf
11 http://www.smsc.com/main/tools/discontinued/47m13x.pdf 13 http://www.smsc.com/main/tools/discontinued/47m13x.pdf
12 http://www.smsc.com/main/datasheets/47m14x.pdf 14 http://www.smsc.com/main/datasheets/47m14x.pdf
13 http://www.smsc.com/main/tools/discontinued/47m15x.pdf 15 http://www.smsc.com/main/tools/discontinued/47m15x.pdf
diff --git a/Documentation/hwmon/w83627ehf b/Documentation/hwmon/w83627ehf
index fae3b781d82d..caa610a297e8 100644
--- a/Documentation/hwmon/w83627ehf
+++ b/Documentation/hwmon/w83627ehf
@@ -26,7 +26,7 @@ fan control mode).
26Temperatures are measured in degrees Celsius and measurement resolution is 1 26Temperatures are measured in degrees Celsius and measurement resolution is 1
27degC for temp1 and 0.5 degC for temp2 and temp3. An alarm is triggered when 27degC for temp1 and 0.5 degC for temp2 and temp3. An alarm is triggered when
28the temperature gets higher than high limit; it stays on until the temperature 28the temperature gets higher than high limit; it stays on until the temperature
29falls below the Hysteresis value. 29falls below the hysteresis value.
30 30
31Fan rotation speeds are reported in RPM (rotations per minute). An alarm is 31Fan rotation speeds are reported in RPM (rotations per minute). An alarm is
32triggered if the rotation speed has dropped below a programmable limit. Fan 32triggered if the rotation speed has dropped below a programmable limit. Fan
@@ -67,9 +67,9 @@ Thermal Cruise mode
67 67
68If the temperature is in the range defined by: 68If the temperature is in the range defined by:
69 69
70pwm[1-4]_target - set target temperature, unit millidegree Celcius 70pwm[1-4]_target - set target temperature, unit millidegree Celsius
71 (range 0 - 127000) 71 (range 0 - 127000)
72pwm[1-4]_tolerance - tolerance, unit millidegree Celcius (range 0 - 15000) 72pwm[1-4]_tolerance - tolerance, unit millidegree Celsius (range 0 - 15000)
73 73
74there are no changes to fan speed. Once the temperature leaves the interval, 74there are no changes to fan speed. Once the temperature leaves the interval,
75fan speed increases (temp is higher) or decreases if lower than desired. 75fan speed increases (temp is higher) or decreases if lower than desired.
diff --git a/Documentation/ibm-acpi.txt b/Documentation/ibm-acpi.txt
index 71aa40345272..e50595bfd8ea 100644
--- a/Documentation/ibm-acpi.txt
+++ b/Documentation/ibm-acpi.txt
@@ -30,9 +30,10 @@ detailed description):
30 - ACPI sounds 30 - ACPI sounds
31 - temperature sensors 31 - temperature sensors
32 - Experimental: embedded controller register dump 32 - Experimental: embedded controller register dump
33 - Experimental: LCD brightness control 33 - LCD brightness control
34 - Experimental: volume control 34 - Volume control
35 - Experimental: fan speed, fan enable/disable 35 - Experimental: fan speed, fan enable/disable
36 - Experimental: WAN enable and disable
36 37
37A compatibility table by model and feature is maintained on the web 38A compatibility table by model and feature is maintained on the web
38site, http://ibm-acpi.sf.net/. I appreciate any success or failure 39site, http://ibm-acpi.sf.net/. I appreciate any success or failure
@@ -52,40 +53,7 @@ Installation
52 53
53If you are compiling this driver as included in the Linux kernel 54If you are compiling this driver as included in the Linux kernel
54sources, simply enable the CONFIG_ACPI_IBM option (Power Management / 55sources, simply enable the CONFIG_ACPI_IBM option (Power Management /
55ACPI / IBM ThinkPad Laptop Extras). The rest of this section describes 56ACPI / IBM ThinkPad Laptop Extras).
56how to install this driver when downloaded from the web site.
57
58First, you need to get a kernel with ACPI support up and running.
59Please refer to http://acpi.sourceforge.net/ for help with this
60step. How successful you will be depends a lot on you ThinkPad model,
61the kernel you are using and any additional patches applied. The
62kernel provided with your distribution may not be good enough. I
63needed to compile a 2.6.7 kernel with the 20040715 ACPI patch to get
64ACPI working reliably on my ThinkPad X40. Old ThinkPad models may not
65be supported at all.
66
67Assuming you have the basic ACPI support working (e.g. you can see the
68/proc/acpi directory), follow the following steps to install this
69driver:
70
71 - unpack the archive:
72
73 tar xzvf ibm-acpi-x.y.tar.gz; cd ibm-acpi-x.y
74
75 - compile the driver:
76
77 make
78
79 - install the module in your kernel modules directory:
80
81 make install
82
83 - load the module:
84
85 modprobe ibm_acpi
86
87After loading the module, check the "dmesg" output for any error messages.
88
89 57
90Features 58Features
91-------- 59--------
@@ -523,13 +491,8 @@ registers contain the current battery capacity, etc. If you experiment
523with this, do send me your results (including some complete dumps with 491with this, do send me your results (including some complete dumps with
524a description of the conditions when they were taken.) 492a description of the conditions when they were taken.)
525 493
526EXPERIMENTAL: LCD brightness control -- /proc/acpi/ibm/brightness 494LCD brightness control -- /proc/acpi/ibm/brightness
527----------------------------------------------------------------- 495---------------------------------------------------
528
529This feature is marked EXPERIMENTAL because the implementation
530directly accesses hardware registers and may not work as expected. USE
531WITH CAUTION! To use this feature, you need to supply the
532experimental=1 parameter when loading the module.
533 496
534This feature allows software control of the LCD brightness on ThinkPad 497This feature allows software control of the LCD brightness on ThinkPad
535models which don't have a hardware brightness slider. The available 498models which don't have a hardware brightness slider. The available
@@ -542,13 +505,8 @@ commands are:
542The <level> number range is 0 to 7, although not all of them may be 505The <level> number range is 0 to 7, although not all of them may be
543distinct. The current brightness level is shown in the file. 506distinct. The current brightness level is shown in the file.
544 507
545EXPERIMENTAL: Volume control -- /proc/acpi/ibm/volume 508Volume control -- /proc/acpi/ibm/volume
546----------------------------------------------------- 509---------------------------------------
547
548This feature is marked EXPERIMENTAL because the implementation
549directly accesses hardware registers and may not work as expected. USE
550WITH CAUTION! To use this feature, you need to supply the
551experimental=1 parameter when loading the module.
552 510
553This feature allows volume control on ThinkPad models which don't have 511This feature allows volume control on ThinkPad models which don't have
554a hardware volume knob. The available commands are: 512a hardware volume knob. The available commands are:
@@ -611,6 +569,23 @@ with the following command:
611 569
612 echo 'level <level>' > /proc/acpi/ibm/thermal 570 echo 'level <level>' > /proc/acpi/ibm/thermal
613 571
572EXPERIMENTAL: WAN -- /proc/acpi/ibm/wan
573---------------------------------------
574
575This feature is marked EXPERIMENTAL because the implementation
576directly accesses hardware registers and may not work as expected. USE
577WITH CAUTION! To use this feature, you need to supply the
578experimental=1 parameter when loading the module.
579
580This feature shows the presence and current state of a WAN (Sierra
581Wireless EV-DO) device. If WAN is installed, the following commands can
582be used:
583
584 echo enable > /proc/acpi/ibm/wan
585 echo disable > /proc/acpi/ibm/wan
586
587It was tested on a Lenovo Thinkpad X60. It should probably work on other
588Thinkpad models which come with this module installed.
614 589
615Multiple Commands, Module Parameters 590Multiple Commands, Module Parameters
616------------------------------------ 591------------------------------------
diff --git a/Documentation/input/xpad.txt b/Documentation/input/xpad.txt
index b9111a703ce0..5427bdf225ed 100644
--- a/Documentation/input/xpad.txt
+++ b/Documentation/input/xpad.txt
@@ -3,20 +3,37 @@ xpad - Linux USB driver for X-Box gamepads
3This is the very first release of a driver for X-Box gamepads. 3This is the very first release of a driver for X-Box gamepads.
4Basically, this was hacked away in just a few hours, so don't expect 4Basically, this was hacked away in just a few hours, so don't expect
5miracles. 5miracles.
6
6In particular, there is currently NO support for the rumble pack. 7In particular, there is currently NO support for the rumble pack.
7You won't find many ff-aware linux applications anyway. 8You won't find many ff-aware linux applications anyway.
8 9
9 10
100. Status 110. Notes
11--------- 12--------
13
14Driver updated for kernel 2.6.17.11. (Based on a patch for 2.6.11.4.)
12 15
13For now, this driver has only been tested on just one Linux-Box. 16The number of buttons/axes reported varies based on 3 things:
14This one is running a 2.4.18 kernel with usb-uhci on an amd athlon 600. 17- if you are using a known controller
18- if you are using a known dance pad
19- if using an unknown device (one not listed below), what you set in the
20 module configuration for "Map D-PAD to buttons rather than axes for unknown
21 pads" (module option dpad_to_buttons)
15 22
16The jstest-program from joystick-1.2.15 (jstest-version 2.1.0) reports 23If you set dpad_to_buttons to 0 and you are using an unknown device (one
178 axes and 10 buttons. 24not listed below), the driver will map the directional pad to axes (X/Y),
25if you said N it will map the d-pad to buttons, which is needed for dance
26style games to function correctly. The default is Y.
27
28dpad_to_buttons has no effect for known pads.
29
300.1 Normal Controllers
31----------------------
32With a normal controller, the directional pad is mapped to its own X/Y axes.
33The jstest-program from joystick-1.2.15 (jstest-version 2.1.0) will report 8
34axes and 10 buttons.
18 35
19Alls 8 axes work, though they all have the same range (-32768..32767) 36All 8 axes work, though they all have the same range (-32768..32767)
20and the zero-setting is not correct for the triggers (I don't know if that 37and the zero-setting is not correct for the triggers (I don't know if that
21is some limitation of jstest, since the input device setup should be fine. I 38is some limitation of jstest, since the input device setup should be fine. I
22didn't have a look at jstest itself yet). 39didn't have a look at jstest itself yet).
@@ -30,16 +47,50 @@ in game functionality were OK. However, I find it rather difficult to
30play first person shooters with a pad. Your mileage may vary. 47play first person shooters with a pad. Your mileage may vary.
31 48
32 49
500.2 Xbox Dance Pads
51-------------------
52When using a known dance pad, jstest will report 6 axes and 14 buttons.
53
54For dance style pads (like the redoctane pad) several changes
55have been made. The old driver would map the d-pad to axes, resulting
56in the driver being unable to report when the user was pressing both
57left+right or up+down, making DDR style games unplayable.
58
59Known dance pads automatically map the d-pad to buttons and will work
60correctly out of the box.
61
62If your dance pad is recognized by the driver but is using axes instead
63of buttons, see section 0.3 - Unknown Controllers
64
65I've tested this with Stepmania, and it works quite well.
66
67
680.3 Unkown Controllers
69----------------------
70If you have an unkown xbox controller, it should work just fine with
71the default settings.
72
73HOWEVER if you have an unknown dance pad not listed below, it will not
74work UNLESS you set "dpad_to_buttons" to 1 in the module configuration.
75
76PLEASE if you have an unkown controller, email Dom <binary1230@yahoo.com> with
77a dump from /proc/bus/usb and a description of the pad (manufacturer, country,
78whether it is a dance pad or normal controller) so that we can add your pad
79to the list of supported devices, ensuring that it will work out of the
80box in the future.
81
82
331. USB adapter 831. USB adapter
34-------------- 84--------------
35 85
36Before you can actually use the driver, you need to get yourself an 86Before you can actually use the driver, you need to get yourself an
37adapter cable to connect the X-Box controller to your Linux-Box. 87adapter cable to connect the X-Box controller to your Linux-Box. You
88can buy these online fairly cheap, or build your own.
38 89
39Such a cable is pretty easy to build. The Controller itself is a USB compound 90Such a cable is pretty easy to build. The Controller itself is a USB
40device (a hub with three ports for two expansion slots and the controller 91compound device (a hub with three ports for two expansion slots and
41device) with the only difference in a nonstandard connector (5 pins vs. 4 on 92the controller device) with the only difference in a nonstandard connector
42standard USB connector). 93(5 pins vs. 4 on standard USB connector).
43 94
44You just need to solder a USB connector onto the cable and keep the 95You just need to solder a USB connector onto the cable and keep the
45yellow wire unconnected. The other pins have the same order on both 96yellow wire unconnected. The other pins have the same order on both
@@ -51,36 +102,36 @@ original one. You can buy an extension cable and cut that instead. That way,
51you can still use the controller with your X-Box, if you have one ;) 102you can still use the controller with your X-Box, if you have one ;)
52 103
53 104
542. driver installation 1052. Driver Installation
55---------------------- 106----------------------
56 107
57Once you have the adapter cable and the controller is connected, you need 108Once you have the adapter cable and the controller is connected, you need
58to load your USB subsystem and should cat /proc/bus/usb/devices. 109to load your USB subsystem and should cat /proc/bus/usb/devices.
59There should be an entry like the one at the end [4]. 110There should be an entry like the one at the end [4].
60 111
61Currently (as of version 0.0.4), the following three devices are included: 112Currently (as of version 0.0.6), the following devices are included:
62 original Microsoft XBOX controller (US), vendor=0x045e, product=0x0202 113 original Microsoft XBOX controller (US), vendor=0x045e, product=0x0202
114 smaller Microsoft XBOX controller (US), vendor=0x045e, product=0x0289
63 original Microsoft XBOX controller (Japan), vendor=0x045e, product=0x0285 115 original Microsoft XBOX controller (Japan), vendor=0x045e, product=0x0285
64 InterAct PowerPad Pro (Germany), vendor=0x05fd, product=0x107a 116 InterAct PowerPad Pro (Germany), vendor=0x05fd, product=0x107a
117 RedOctane Xbox Dance Pad (US), vendor=0x0c12, product=0x8809
65 118
66If you have another controller that is not listed above and is not recognized 119The driver should work with xbox pads not listed above as well, however
67by the driver, please drop me a line with the appropriate info (that is, include 120you will need to do something extra for dance pads to work.
68the name, vendor and product ID, as well as the country where you bought it;
69sending the whole dump out of /proc/bus/usb/devices along would be even better).
70 121
71In theory, the driver should work with other controllers than mine 122If you have a controller not listed above, see 0.3 - Unknown Controllers
72(InterAct PowerPad pro, bought in Germany) just fine, but I cannot test this
73for I only have this one controller.
74 123
75If you compiled and installed the driver, test the functionality: 124If you compiled and installed the driver, test the functionality:
76> modprobe xpad 125> modprobe xpad
77> modprobe joydev 126> modprobe joydev
78> jstest /dev/js0 127> jstest /dev/js0
79 128
80There should be a single line showing 18 inputs (8 axes, 10 buttons), and 129If you're using a normal controller, there should be a single line showing
81it's values should change if you move the sticks and push the buttons. 13018 inputs (8 axes, 10 buttons), and its values should change if you move
131the sticks and push the buttons. If you're using a dance pad, it should
132show 20 inputs (6 axes, 14 buttons).
82 133
83It works? Voila, your done ;) 134It works? Voila, you're done ;)
84 135
85 136
863. Thanks 1373. Thanks
@@ -111,6 +162,22 @@ I: If#= 0 Alt= 0 #EPs= 2 Cls=58(unk. ) Sub=42 Prot=00 Driver=(none)
111E: Ad=81(I) Atr=03(Int.) MxPS= 32 Ivl= 10ms 162E: Ad=81(I) Atr=03(Int.) MxPS= 32 Ivl= 10ms
112E: Ad=02(O) Atr=03(Int.) MxPS= 32 Ivl= 10ms 163E: Ad=02(O) Atr=03(Int.) MxPS= 32 Ivl= 10ms
113 164
1655. /proc/bus/usb/devices - dump from Redoctane Xbox Dance Pad (US):
166
167T: Bus=01 Lev=02 Prnt=09 Port=00 Cnt=01 Dev#= 10 Spd=12 MxCh= 0
168D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
169P: Vendor=0c12 ProdID=8809 Rev= 0.01
170S: Product=XBOX DDR
171C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
172I: If#= 0 Alt= 0 #EPs= 2 Cls=58(unk. ) Sub=42 Prot=00 Driver=xpad
173E: Ad=82(I) Atr=03(Int.) MxPS= 32 Ivl=4ms
174E: Ad=02(O) Atr=03(Int.) MxPS= 32 Ivl=4ms
175
114-- 176--
115Marko Friedemann <mfr@bmx-chemnitz.de> 177Marko Friedemann <mfr@bmx-chemnitz.de>
1162002-07-16 1782002-07-16
179 - original doc
180
181Dominic Cerquetti <binary1230@yahoo.com>
1822005-03-19
183 - added stuff for dance pads, new d-pad->axes mappings
diff --git a/Documentation/kernel-doc-nano-HOWTO.txt b/Documentation/kernel-doc-nano-HOWTO.txt
index c65233d430f0..284e7e198e93 100644
--- a/Documentation/kernel-doc-nano-HOWTO.txt
+++ b/Documentation/kernel-doc-nano-HOWTO.txt
@@ -17,7 +17,7 @@ are:
17 special place-holders for where the extracted documentation should 17 special place-holders for where the extracted documentation should
18 go. 18 go.
19 19
20- scripts/docproc.c 20- scripts/basic/docproc.c
21 21
22 This is a program for converting SGML template files into SGML 22 This is a program for converting SGML template files into SGML
23 files. When a file is referenced it is searched for symbols 23 files. When a file is referenced it is searched for symbols
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 5a92ac085969..9913f0676643 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -164,6 +164,10 @@ and is between 256 and 4096 characters. It is defined in the file
164 acpi_skip_timer_override [HW,ACPI] 164 acpi_skip_timer_override [HW,ACPI]
165 Recognize and ignore IRQ0/pin2 Interrupt Override. 165 Recognize and ignore IRQ0/pin2 Interrupt Override.
166 For broken nForce2 BIOS resulting in XT-PIC timer. 166 For broken nForce2 BIOS resulting in XT-PIC timer.
167 acpi_use_timer_override [HW,ACPI}
168 Use timer override. For some broken Nvidia NF5 boards
169 that require a timer override, but don't have
170 HPET
167 171
168 acpi_dbg_layer= [HW,ACPI] 172 acpi_dbg_layer= [HW,ACPI]
169 Format: <int> 173 Format: <int>
@@ -1231,6 +1235,11 @@ and is between 256 and 4096 characters. It is defined in the file
1231 machine check when some devices' config space 1235 machine check when some devices' config space
1232 is read. But various workarounds are disabled 1236 is read. But various workarounds are disabled
1233 and some IOMMU drivers will not work. 1237 and some IOMMU drivers will not work.
1238 bfsort Sort PCI devices into breadth-first order.
1239 This sorting is done to get a device
1240 order compatible with older (<= 2.4) kernels.
1241 nobfsort Don't sort PCI devices into breadth-first order.
1242
1234 pcmv= [HW,PCMCIA] BadgePAD 4 1243 pcmv= [HW,PCMCIA] BadgePAD 4
1235 1244
1236 pd. [PARIDE] 1245 pd. [PARIDE]
diff --git a/Documentation/kprobes.txt b/Documentation/kprobes.txt
index ba26201d5023..d71fafffce90 100644
--- a/Documentation/kprobes.txt
+++ b/Documentation/kprobes.txt
@@ -442,9 +442,10 @@ static int __init kprobe_init(void)
442 kp.fault_handler = handler_fault; 442 kp.fault_handler = handler_fault;
443 kp.symbol_name = "do_fork"; 443 kp.symbol_name = "do_fork";
444 444
445 if ((ret = register_kprobe(&kp) < 0)) { 445 ret = register_kprobe(&kp);
446 if (ret < 0) {
446 printk("register_kprobe failed, returned %d\n", ret); 447 printk("register_kprobe failed, returned %d\n", ret);
447 return -1; 448 return ret;
448 } 449 }
449 printk("kprobe registered\n"); 450 printk("kprobe registered\n");
450 return 0; 451 return 0;
diff --git a/Documentation/lockdep-design.txt b/Documentation/lockdep-design.txt
index dab123db5a4f..488773018152 100644
--- a/Documentation/lockdep-design.txt
+++ b/Documentation/lockdep-design.txt
@@ -50,10 +50,10 @@ The bit position indicates hardirq, softirq, hardirq-read,
50softirq-read respectively, and the character displayed in each 50softirq-read respectively, and the character displayed in each
51indicates: 51indicates:
52 52
53 '.' acquired while irqs enabled 53 '.' acquired while irqs disabled
54 '+' acquired in irq context 54 '+' acquired in irq context
55 '-' acquired in process context with irqs disabled 55 '-' acquired with irqs enabled
56 '?' read-acquired both with irqs enabled and in irq context 56 '?' read acquired in irq context with irqs enabled.
57 57
58Unused mutexes cannot be part of the cause of an error. 58Unused mutexes cannot be part of the cause of an error.
59 59
diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt
index 994355b0cd19..7751704b6db1 100644
--- a/Documentation/memory-barriers.txt
+++ b/Documentation/memory-barriers.txt
@@ -1016,7 +1016,7 @@ There are some more advanced barrier functions:
1016 1016
1017 (*) set_mb(var, value) 1017 (*) set_mb(var, value)
1018 1018
1019 This assigns the value to the variable and then inserts at least a write 1019 This assigns the value to the variable and then inserts a full memory
1020 barrier after it, depending on the function. It isn't guaranteed to 1020 barrier after it, depending on the function. It isn't guaranteed to
1021 insert anything more than a compiler barrier in a UP compilation. 1021 insert anything more than a compiler barrier in a UP compilation.
1022 1022
@@ -1898,7 +1898,7 @@ queue before processing any further requests:
1898 smp_wmb(); 1898 smp_wmb();
1899 <A:modify v=2> <C:busy> 1899 <A:modify v=2> <C:busy>
1900 <C:queue v=2> 1900 <C:queue v=2>
1901 p = &b; q = p; 1901 p = &v; q = p;
1902 <D:request p> 1902 <D:request p>
1903 <B:modify p=&v> <D:commit p=&v> 1903 <B:modify p=&v> <D:commit p=&v>
1904 <D:read p> 1904 <D:read p>
diff --git a/Documentation/mips/time.README b/Documentation/mips/time.README
index 69ddc5c14b79..a4ce603ed3b3 100644
--- a/Documentation/mips/time.README
+++ b/Documentation/mips/time.README
@@ -38,19 +38,14 @@ The new time code provide the following services:
38 38
39 a) Implements functions required by Linux common code: 39 a) Implements functions required by Linux common code:
40 time_init 40 time_init
41 do_gettimeofday
42 do_settimeofday
43 41
44 b) provides an abstraction of RTC and null RTC implementation as default. 42 b) provides an abstraction of RTC and null RTC implementation as default.
45 extern unsigned long (*rtc_get_time)(void); 43 extern unsigned long (*rtc_get_time)(void);
46 extern int (*rtc_set_time)(unsigned long); 44 extern int (*rtc_set_time)(unsigned long);
47 45
48 c) a set of gettimeoffset functions for different CPUs and different 46 c) high-level and low-level timer interrupt routines where the timer
49 needs. 47 interrupt source may or may not be the CPU timer. The high-level
50 48 routine is dispatched through do_IRQ() while the low-level is
51 d) high-level and low-level timer interrupt routines where the timer
52 interrupt source may or may not be the CPU timer. The high-level
53 routine is dispatched through do_IRQ() while the low-level is
54 dispatched in assemably code (usually int-handler.S) 49 dispatched in assemably code (usually int-handler.S)
55 50
56 51
@@ -63,7 +58,7 @@ the following functions or values:
63 a) board_time_init - a function pointer. Invoked at the beginnig of 58 a) board_time_init - a function pointer. Invoked at the beginnig of
64 time_init(). It is optional. 59 time_init(). It is optional.
65 1. (optional) set up RTC routines 60 1. (optional) set up RTC routines
66 2. (optional) calibrate and set the mips_counter_frequency 61 2. (optional) calibrate and set the mips_hpt_frequency
67 62
68 b) plat_timer_setup - a function pointer. Invoked at the end of time_init() 63 b) plat_timer_setup - a function pointer. Invoked at the end of time_init()
69 1. (optional) over-ride any decisions made in time_init() 64 1. (optional) over-ride any decisions made in time_init()
@@ -72,9 +67,8 @@ the following functions or values:
72 67
73 c) (optional) board-specific RTC routines. 68 c) (optional) board-specific RTC routines.
74 69
75 d) (optional) mips_counter_frequency - It must be definied if the board 70 d) (optional) mips_hpt_frequency - It must be definied if the board
76 is using CPU counter for timer interrupt or it is using fixed rate 71 is using CPU counter for timer interrupt.
77 gettimeoffset().
78 72
79 73
80PORTING GUIDE 74PORTING GUIDE
@@ -89,22 +83,12 @@ Step 1: decide how you like to implement the time services.
89 If the answer is no, you need a timer to provide the timer interrupt 83 If the answer is no, you need a timer to provide the timer interrupt
90 at 100 HZ speed. 84 at 100 HZ speed.
91 85
92 You cannot use the fast gettimeoffset functions, i.e.,
93
94 unsigned long fixed_rate_gettimeoffset(void);
95 unsigned long calibrate_div32_gettimeoffset(void);
96 unsigned long calibrate_div64_gettimeoffset(void);
97
98 You can use null_gettimeoffset() will gives the same time resolution as
99 jiffy. Or you can implement your own gettimeoffset (probably based on
100 some ad hoc hardware on your machine.)
101
102 c) The following sub steps assume your CPU has counter register. 86 c) The following sub steps assume your CPU has counter register.
103 Do you plan to use the CPU counter register as the timer interrupt 87 Do you plan to use the CPU counter register as the timer interrupt
104 or use an exnternal timer? 88 or use an exnternal timer?
105 89
106 In order to use CPU counter register as the timer interrupt source, you 90 In order to use CPU counter register as the timer interrupt source, you
107 must know the counter speed (mips_counter_frequency). It is usually the 91 must know the counter speed (mips_hpt_frequency). It is usually the
108 same as the CPU speed or an integral divisor of it. 92 same as the CPU speed or an integral divisor of it.
109 93
110 d) decide on whether you want to use high-level or low-level timer 94 d) decide on whether you want to use high-level or low-level timer
@@ -121,10 +105,10 @@ Step 3: implement rtc routines, board_time_init() and plat_timer_setup()
121 if needed. 105 if needed.
122 106
123 board_time_init() - 107 board_time_init() -
124 a) (optional) set up RTC routines, 108 a) (optional) set up RTC routines,
125 b) (optional) calibrate and set the mips_counter_frequency 109 b) (optional) calibrate and set the mips_hpt_frequency
126 (only needed if you intended to use fixed_rate_gettimeoffset 110 (only needed if you intended to use cpu counter as timer interrupt
127 or use cpu counter as timer interrupt source) 111 source)
128 112
129 plat_timer_setup() - 113 plat_timer_setup() -
130 a) (optional) over-write any choices made above by time_init(). 114 a) (optional) over-write any choices made above by time_init().
@@ -154,8 +138,8 @@ for some of the functions in time.c.
154For example, you may define your own timer interrupt routine, which does 138For example, you may define your own timer interrupt routine, which does
155some of its own processing and then calls timer_interrupt(). 139some of its own processing and then calls timer_interrupt().
156 140
157You can also over-ride any of the built-in functions (gettimeoffset, 141You can also over-ride any of the built-in functions (RTC routines
158RTC routines and/or timer interrupt routine). 142and/or timer interrupt routine).
159 143
160 144
161PORTING NOTES FOR SMP 145PORTING NOTES FOR SMP
@@ -187,10 +171,3 @@ You need to decide on your timer interrupt sources.
187 171
188 You can also do the low-level version of those interrupt routines, 172 You can also do the low-level version of those interrupt routines,
189 following similar dispatching routes described above. 173 following similar dispatching routes described above.
190
191Note about do_gettimeoffset():
192
193 It is very likely the CPU counter registers are not sync'ed up in a SMP box.
194 Therefore you cannot really use the many of the existing routines that
195 are based on CPU counter. You should wirte your own gettimeoffset rouinte
196 if you want intra-jiffy resolution.
diff --git a/Documentation/power/interface.txt b/Documentation/power/interface.txt
index a66bec222b16..74311d7e0f3c 100644
--- a/Documentation/power/interface.txt
+++ b/Documentation/power/interface.txt
@@ -30,6 +30,17 @@ testing). The system will support either 'firmware' or 'platform', and
30that is known a priori. But, the user may choose 'shutdown' or 30that is known a priori. But, the user may choose 'shutdown' or
31'reboot' as alternatives. 31'reboot' as alternatives.
32 32
33Additionally, /sys/power/disk can be used to turn on one of the two testing
34modes of the suspend-to-disk mechanism: 'testproc' or 'test'. If the
35suspend-to-disk mechanism is in the 'testproc' mode, writing 'disk' to
36/sys/power/state will cause the kernel to disable nonboot CPUs and freeze
37tasks, wait for 5 seconds, unfreeze tasks and enable nonboot CPUs. If it is
38in the 'test' mode, writing 'disk' to /sys/power/state will cause the kernel
39to disable nonboot CPUs and freeze tasks, shrink memory, suspend devices, wait
40for 5 seconds, resume devices, unfreeze tasks and enable nonboot CPUs. Then,
41we are able to look in the log messages and work out, for example, which code
42is being slow and which device drivers are misbehaving.
43
33Reading from this file will display what the mode is currently set 44Reading from this file will display what the mode is currently set
34to. Writing to this file will accept one of 45to. Writing to this file will accept one of
35 46
@@ -37,6 +48,8 @@ to. Writing to this file will accept one of
37 'platform' 48 'platform'
38 'shutdown' 49 'shutdown'
39 'reboot' 50 'reboot'
51 'testproc'
52 'test'
40 53
41It will only change to 'firmware' or 'platform' if the system supports 54It will only change to 'firmware' or 'platform' if the system supports
42it. 55it.
diff --git a/Documentation/s390/CommonIO b/Documentation/s390/CommonIO
index 59d1166d41ee..d684a6ac69a8 100644
--- a/Documentation/s390/CommonIO
+++ b/Documentation/s390/CommonIO
@@ -66,7 +66,7 @@ Command line parameters
66 66
67 When a device is un-ignored, device recognition and sensing is performed and 67 When a device is un-ignored, device recognition and sensing is performed and
68 the device driver will be notified if possible, so the device will become 68 the device driver will be notified if possible, so the device will become
69 available to the system. 69 available to the system. Note that un-ignoring is performed asynchronously.
70 70
71 You can also add ranges of devices to be ignored by piping to 71 You can also add ranges of devices to be ignored by piping to
72 /proc/cio_ignore; "add <device range>, <device range>, ..." will ignore the 72 /proc/cio_ignore; "add <device range>, <device range>, ..." will ignore the
diff --git a/Documentation/s390/cds.txt b/Documentation/s390/cds.txt
index d80e5733827d..32a96cc39215 100644
--- a/Documentation/s390/cds.txt
+++ b/Documentation/s390/cds.txt
@@ -174,14 +174,10 @@ read_dev_chars() - Read Device Characteristics
174 174
175This routine returns the characteristics for the device specified. 175This routine returns the characteristics for the device specified.
176 176
177The function is meant to be called with an irq handler in place; that is, 177The function is meant to be called with the device already enabled; that is,
178at earliest during set_online() processing. 178at earliest during set_online() processing.
179 179
180While the request is processed synchronously, the device interrupt 180The ccw_device must not be locked prior to calling read_dev_chars().
181handler is called for final ending status. In case of error situations the
182interrupt handler may recover appropriately. The device irq handler can
183recognize the corresponding interrupts by the interruption parameter be
1840x00524443. The ccw_device must not be locked prior to calling read_dev_chars().
185 181
186The function may be called enabled or disabled. 182The function may be called enabled or disabled.
187 183
@@ -410,26 +406,7 @@ individual flag meanings.
410 406
411Usage Notes : 407Usage Notes :
412 408
413Prior to call ccw_device_start() the device driver must assure disabled state, 409ccw_device_start() must be called disabled and with the ccw device lock held.
414i.e. the I/O mask value in the PSW must be disabled. This can be accomplished
415by calling local_save_flags( flags). The current PSW flags are preserved and
416can be restored by local_irq_restore( flags) at a later time.
417
418If the device driver violates this rule while running in a uni-processor
419environment an interrupt might be presented prior to the ccw_device_start()
420routine returning to the device driver main path. In this case we will end in a
421deadlock situation as the interrupt handler will try to obtain the irq
422lock the device driver still owns (see below) !
423
424The driver must assure to hold the device specific lock. This can be
425accomplished by
426
427(i) spin_lock(get_ccwdev_lock(cdev)), or
428(ii) spin_lock_irqsave(get_ccwdev_lock(cdev), flags)
429
430Option (i) should be used if the calling routine is running disabled for
431I/O interrupts (see above) already. Option (ii) obtains the device gate und
432puts the CPU into I/O disabled state by preserving the current PSW flags.
433 410
434The device driver is allowed to issue the next ccw_device_start() call from 411The device driver is allowed to issue the next ccw_device_start() call from
435within its interrupt handler already. It is not required to schedule a 412within its interrupt handler already. It is not required to schedule a
@@ -488,7 +465,7 @@ int ccw_device_resume(struct ccw_device *cdev);
488 465
489cdev - ccw_device the resume operation is requested for 466cdev - ccw_device the resume operation is requested for
490 467
491The resume_IO() function returns: 468The ccw_device_resume() function returns:
492 469
493 0 - suspended channel program is resumed 470 0 - suspended channel program is resumed
494-EBUSY - status pending 471-EBUSY - status pending
@@ -507,6 +484,8 @@ a long-running channel program or the device might require to initially issue
507a halt subchannel (HSCH) I/O command. For those purposes the ccw_device_halt() 484a halt subchannel (HSCH) I/O command. For those purposes the ccw_device_halt()
508command is provided. 485command is provided.
509 486
487ccw_device_halt() must be called disabled and with the ccw device lock held.
488
510int ccw_device_halt(struct ccw_device *cdev, 489int ccw_device_halt(struct ccw_device *cdev,
511 unsigned long intparm); 490 unsigned long intparm);
512 491
@@ -517,7 +496,7 @@ intparm : interruption parameter; value is only used if no I/O
517 496
518The ccw_device_halt() function returns : 497The ccw_device_halt() function returns :
519 498
520 0 - successful completion or request successfully initiated 499 0 - request successfully initiated
521-EBUSY - the device is currently busy, or status pending. 500-EBUSY - the device is currently busy, or status pending.
522-ENODEV - cdev invalid. 501-ENODEV - cdev invalid.
523-EINVAL - The device is not operational or the ccw device is not online. 502-EINVAL - The device is not operational or the ccw device is not online.
@@ -533,6 +512,23 @@ can then perform an appropriate action. Prior to interrupt of an outstanding
533read to a network device (with or without PCI flag) a ccw_device_halt() 512read to a network device (with or without PCI flag) a ccw_device_halt()
534is required to end the pending operation. 513is required to end the pending operation.
535 514
515ccw_device_clear() - Terminage I/O Request Processing
516
517In order to terminate all I/O processing at the subchannel, the clear subchannel
518(CSCH) command is used. It can be issued via ccw_device_clear().
519
520ccw_device_clear() must be called disabled and with the ccw device lock held.
521
522int ccw_device_clear(struct ccw_device *cdev, unsigned long intparm);
523
524cdev: ccw_device the clear operation is requested for
525intparm: interruption parameter (see ccw_device_halt())
526
527The ccw_device_clear() function returns:
528
529 0 - request successfully initiated
530-ENODEV - cdev invalid
531-EINVAL - The device is not operational or the ccw device is not online.
536 532
537Miscellaneous Support Routines 533Miscellaneous Support Routines
538 534
diff --git a/Documentation/s390/driver-model.txt b/Documentation/s390/driver-model.txt
index 62c082387aea..77bf450ec39b 100644
--- a/Documentation/s390/driver-model.txt
+++ b/Documentation/s390/driver-model.txt
@@ -239,6 +239,9 @@ status - Can be 'online' or 'offline'.
239 239
240type - The physical type of the channel path. 240type - The physical type of the channel path.
241 241
242shared - Whether the channel path is shared.
243
244cmg - The channel measurement group.
242 245
2433. System devices 2463. System devices
244----------------- 247-----------------
diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt
index 138673a907f5..3472d9c4ef1b 100644
--- a/Documentation/sound/alsa/ALSA-Configuration.txt
+++ b/Documentation/sound/alsa/ALSA-Configuration.txt
@@ -753,7 +753,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
753 position_fix - Fix DMA pointer (0 = auto, 1 = none, 2 = POSBUF, 3 = FIFO size) 753 position_fix - Fix DMA pointer (0 = auto, 1 = none, 2 = POSBUF, 3 = FIFO size)
754 single_cmd - Use single immediate commands to communicate with 754 single_cmd - Use single immediate commands to communicate with
755 codecs (for debugging only) 755 codecs (for debugging only)
756 disable_msi - Disable Message Signaled Interrupt (MSI) 756 enable_msi - Enable Message Signaled Interrupt (MSI) (default = off)
757 757
758 This module supports one card and autoprobe. 758 This module supports one card and autoprobe.
759 759
diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt
index 89bf8c20a586..0bc7f1e3c9e6 100644
--- a/Documentation/sysctl/kernel.txt
+++ b/Documentation/sysctl/kernel.txt
@@ -86,7 +86,7 @@ valid for 30 seconds.
86core_pattern: 86core_pattern:
87 87
88core_pattern is used to specify a core dumpfile pattern name. 88core_pattern is used to specify a core dumpfile pattern name.
89. max length 64 characters; default value is "core" 89. max length 128 characters; default value is "core"
90. core_pattern is used as a pattern template for the output filename; 90. core_pattern is used as a pattern template for the output filename;
91 certain string patterns (beginning with '%') are substituted with 91 certain string patterns (beginning with '%') are substituted with
92 their actual values. 92 their actual values.
@@ -105,6 +105,9 @@ core_pattern is used to specify a core dumpfile pattern name.
105 %h hostname 105 %h hostname
106 %e executable filename 106 %e executable filename
107 %<OTHER> both are dropped 107 %<OTHER> both are dropped
108. If the first character of the pattern is a '|', the kernel will treat
109 the rest of the pattern as a command to run. The core dump will be
110 written to the standard input of that program instead of to a file.
108 111
109============================================================== 112==============================================================
110 113
diff --git a/Documentation/usb/usb-serial.txt b/Documentation/usb/usb-serial.txt
index 8dc2bacc8f1f..50436e1663ea 100644
--- a/Documentation/usb/usb-serial.txt
+++ b/Documentation/usb/usb-serial.txt
@@ -428,12 +428,6 @@ Options supported:
428 See http://www.uuhaus.de/linux/palmconnect.html for up-to-date 428 See http://www.uuhaus.de/linux/palmconnect.html for up-to-date
429 information on this driver. 429 information on this driver.
430 430
431AIRcable USB Dongle Bluetooth driver
432 If there is the cdc_acm driver loaded in the system, you will find that the
433 cdc_acm claims the device before AIRcable can. This is simply corrected
434 by unloading both modules and then loading the aircable module before
435 cdc_acm module
436
437Generic Serial driver 431Generic Serial driver
438 432
439 If your device is not one of the above listed devices, compatible with 433 If your device is not one of the above listed devices, compatible with
diff --git a/Documentation/video4linux/CARDLIST.cx88 b/Documentation/video4linux/CARDLIST.cx88
index 126e59d935cd..8755b3e7b09e 100644
--- a/Documentation/video4linux/CARDLIST.cx88
+++ b/Documentation/video4linux/CARDLIST.cx88
@@ -51,7 +51,7 @@
51 50 -> NPG Tech Real TV FM Top 10 [14f1:0842] 51 50 -> NPG Tech Real TV FM Top 10 [14f1:0842]
52 51 -> WinFast DTV2000 H [107d:665e] 52 51 -> WinFast DTV2000 H [107d:665e]
53 52 -> Geniatech DVB-S [14f1:0084] 53 52 -> Geniatech DVB-S [14f1:0084]
54 53 -> Hauppauge WinTV-HVR3000 TriMode Analog/DVB-S/DVB-T [0070:1404] 54 53 -> Hauppauge WinTV-HVR3000 TriMode Analog/DVB-S/DVB-T [0070:1404,0070:1400,0070:1401,0070:1402]
55 54 -> Norwood Micro TV Tuner 55 54 -> Norwood Micro TV Tuner
56 55 -> Shenzhen Tungsten Ages Tech TE-DTV-250 / Swann OEM [c180:c980] 56 55 -> Shenzhen Tungsten Ages Tech TE-DTV-250 / Swann OEM [c180:c980]
57 56 -> Hauppauge WinTV-HVR1300 DVB-T/Hybrid MPEG Encoder [0070:9600,0070:9601,0070:9602] 57 56 -> Hauppauge WinTV-HVR1300 DVB-T/Hybrid MPEG Encoder [0070:9600,0070:9601,0070:9602]
diff --git a/Documentation/watchdog/src/watchdog-simple.c b/Documentation/watchdog/src/watchdog-simple.c
index 85cf17c48669..47801bc7e742 100644
--- a/Documentation/watchdog/src/watchdog-simple.c
+++ b/Documentation/watchdog/src/watchdog-simple.c
@@ -1,4 +1,6 @@
1#include <stdio.h>
1#include <stdlib.h> 2#include <stdlib.h>
3#include <unistd.h>
2#include <fcntl.h> 4#include <fcntl.h>
3 5
4int main(int argc, const char *argv[]) { 6int main(int argc, const char *argv[]) {
diff --git a/MAINTAINERS b/MAINTAINERS
index 931e6e40c08b..a5508f930ed9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -493,7 +493,7 @@ S: Maintained
493 493
494BFS FILE SYSTEM 494BFS FILE SYSTEM
495P: Tigran A. Aivazian 495P: Tigran A. Aivazian
496M: tigran@veritas.com 496M: tigran@aivazian.fsnet.co.uk
497L: linux-kernel@vger.kernel.org 497L: linux-kernel@vger.kernel.org
498S: Maintained 498S: Maintained
499 499
@@ -905,7 +905,8 @@ P: David Teigland
905M: teigland@redhat.com 905M: teigland@redhat.com
906L: cluster-devel@redhat.com 906L: cluster-devel@redhat.com
907W: http://sources.redhat.com/cluster/ 907W: http://sources.redhat.com/cluster/
908T: git kernel.org:/pub/scm/linux/kernel/git/steve/gfs-2.6.git 908T: git kernel.org:/pub/scm/linux/kernel/git/steve/gfs2-2.6-fixes.git
909T: git kernel.org:/pub/scm/linux/kernel/git/steve/gfs2-2.6-nmw.git
909S: Supported 910S: Supported
910 911
911DAVICOM FAST ETHERNET (DMFE) NETWORK DRIVER 912DAVICOM FAST ETHERNET (DMFE) NETWORK DRIVER
@@ -1188,7 +1189,8 @@ P: Steven Whitehouse
1188M: swhiteho@redhat.com 1189M: swhiteho@redhat.com
1189L: cluster-devel@redhat.com 1190L: cluster-devel@redhat.com
1190W: http://sources.redhat.com/cluster/ 1191W: http://sources.redhat.com/cluster/
1191T: git kernel.org:/pub/scm/linux/kernel/git/steve/gfs-2.6.git 1192T: git kernel.org:/pub/scm/linux/kernel/git/steve/gfs2-2.6-fixes.git
1193T: git kernel.org:/pub/scm/linux/kernel/git/steve/gfs2-2.6-nmw.git
1192S: Supported 1194S: Supported
1193 1195
1194GIGASET ISDN DRIVERS 1196GIGASET ISDN DRIVERS
@@ -1511,7 +1513,7 @@ S: Maintained
1511 1513
1512INTEL IA32 MICROCODE UPDATE SUPPORT 1514INTEL IA32 MICROCODE UPDATE SUPPORT
1513P: Tigran Aivazian 1515P: Tigran Aivazian
1514M: tigran@veritas.com 1516M: tigran@aivazian.fsnet.co.uk
1515S: Maintained 1517S: Maintained
1516 1518
1517INTEL IXP4XX RANDOM NUMBER GENERATOR SUPPORT 1519INTEL IXP4XX RANDOM NUMBER GENERATOR SUPPORT
@@ -1666,6 +1668,12 @@ M: sct@redhat.com, akpm@osdl.org
1666L: ext2-devel@lists.sourceforge.net 1668L: ext2-devel@lists.sourceforge.net
1667S: Maintained 1669S: Maintained
1668 1670
1671K8TEMP HARDWARE MONITORING DRIVER
1672P: Rudolf Marek
1673M: r.marek@assembler.cz
1674L: lm-sensors@lm-sensors.org
1675S: Maintained
1676
1669KCONFIG 1677KCONFIG
1670P: Roman Zippel 1678P: Roman Zippel
1671M: zippel@linux-m68k.org 1679M: zippel@linux-m68k.org
@@ -1996,6 +2004,13 @@ M: rubini@ipvvis.unipv.it
1996L: linux-kernel@vger.kernel.org 2004L: linux-kernel@vger.kernel.org
1997S: Maintained 2005S: Maintained
1998 2006
2007MSI LAPTOP SUPPORT
2008P: Lennart Poettering
2009M: mzxreary@0pointer.de
2010L: https://tango.0pointer.de/mailman/listinfo/s270-linux
2011W: http://0pointer.de/lennart/tchibo.html
2012S: Maintained
2013
1999MTRR AND SIMILAR SUPPORT [i386] 2014MTRR AND SIMILAR SUPPORT [i386]
2000P: Richard Gooch 2015P: Richard Gooch
2001M: rgooch@atnf.csiro.au 2016M: rgooch@atnf.csiro.au
@@ -2003,8 +2018,11 @@ L: linux-kernel@vger.kernel.org
2003W: http://www.atnf.csiro.au/~rgooch/linux/kernel-patches.html 2018W: http://www.atnf.csiro.au/~rgooch/linux/kernel-patches.html
2004S: Maintained 2019S: Maintained
2005 2020
2006MULTIMEDIA CARD (MMC) SUBSYSTEM 2021MULTIMEDIA CARD (MMC) AND SECURE DIGITAL (SD) SUBSYSTEM
2007S: Orphan 2022P: Pierre Ossman
2023M: drzeus-mmc@drzeus.cx
2024L: linux-kernel@vger.kernel.org
2025S: Maintained
2008 2026
2009MULTISOUND SOUND DRIVER 2027MULTISOUND SOUND DRIVER
2010P: Andrew Veliath 2028P: Andrew Veliath
@@ -2040,11 +2058,13 @@ P: Marc Boucher
2040P: James Morris 2058P: James Morris
2041P: Harald Welte 2059P: Harald Welte
2042P: Jozsef Kadlecsik 2060P: Jozsef Kadlecsik
2043M: coreteam@netfilter.org 2061P: Patrick McHardy
2062M: kaber@trash.net
2063L: netfilter-devel@lists.netfilter.org
2064L: netfilter@lists.netfilter.org
2065L: coreteam@netfilter.org
2044W: http://www.netfilter.org/ 2066W: http://www.netfilter.org/
2045W: http://www.iptables.org/ 2067W: http://www.iptables.org/
2046L: netfilter@lists.netfilter.org
2047L: netfilter-devel@lists.netfilter.org
2048S: Supported 2068S: Supported
2049 2069
2050NETLABEL 2070NETLABEL
@@ -2295,8 +2315,8 @@ T: quilt kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/
2295S: Supported 2315S: Supported
2296 2316
2297PCI HOTPLUG CORE 2317PCI HOTPLUG CORE
2298P: Greg Kroah-Hartman 2318P: Kristen Carlson Accardi
2299M: gregkh@suse.de 2319M: kristen.c.accardi@intel.com
2300S: Supported 2320S: Supported
2301 2321
2302PCI HOTPLUG COMPAQ DRIVER 2322PCI HOTPLUG COMPAQ DRIVER
@@ -3052,6 +3072,13 @@ L: video4linux-list@redhat.com
3052W: http://www.linux-projects.org 3072W: http://www.linux-projects.org
3053S: Maintained 3073S: Maintained
3054 3074
3075USB GADGET/PERIPHERAL SUBSYSTEM
3076P: David Brownell
3077M: dbrownell@users.sourceforge.net
3078L: linux-usb-devel@lists.sourceforge.net
3079W: http://www.linux-usb.org/gadget
3080S: Maintained
3081
3055USB HID/HIDBP DRIVERS 3082USB HID/HIDBP DRIVERS
3056P: Vojtech Pavlik 3083P: Vojtech Pavlik
3057M: vojtech@suse.cz 3084M: vojtech@suse.cz
@@ -3235,10 +3262,11 @@ L: linux-usb-users@lists.sourceforge.net
3235L: linux-usb-devel@lists.sourceforge.net 3262L: linux-usb-devel@lists.sourceforge.net
3236S: Maintained 3263S: Maintained
3237 3264
3238USB "USBNET" DRIVER 3265USB "USBNET" DRIVER FRAMEWORK
3239P: David Brownell 3266P: David Brownell
3240M: dbrownell@users.sourceforge.net 3267M: dbrownell@users.sourceforge.net
3241L: linux-usb-devel@lists.sourceforge.net 3268L: linux-usb-devel@lists.sourceforge.net
3269W: http://www.linux-usb.org/usbnet
3242S: Maintained 3270S: Maintained
3243 3271
3244USB W996[87]CF DRIVER 3272USB W996[87]CF DRIVER
diff --git a/Makefile b/Makefile
index 274b780029b1..958fad6739b3 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 2 1VERSION = 2
2PATCHLEVEL = 6 2PATCHLEVEL = 6
3SUBLEVEL = 19 3SUBLEVEL = 19
4EXTRAVERSION =-rc1 4EXTRAVERSION =-rc6
5NAME=Avast! A bilge rat! 5NAME=Avast! A bilge rat!
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
@@ -499,6 +499,7 @@ endif
499 499
500ifdef CONFIG_UNWIND_INFO 500ifdef CONFIG_UNWIND_INFO
501CFLAGS += -fasynchronous-unwind-tables 501CFLAGS += -fasynchronous-unwind-tables
502LDFLAGS_vmlinux += --eh-frame-hdr
502endif 503endif
503 504
504ifdef CONFIG_DEBUG_INFO 505ifdef CONFIG_DEBUG_INFO
@@ -741,6 +742,9 @@ endif # ifdef CONFIG_KALLSYMS
741 742
742# vmlinux image - including updated kernel symbols 743# vmlinux image - including updated kernel symbols
743vmlinux: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) $(kallsyms.o) FORCE 744vmlinux: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) $(kallsyms.o) FORCE
745ifdef CONFIG_HEADERS_CHECK
746 $(Q)$(MAKE) -f $(srctree)/Makefile headers_check
747endif
744 $(call if_changed_rule,vmlinux__) 748 $(call if_changed_rule,vmlinux__)
745 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost $@ 749 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost $@
746 $(Q)rm -f .old_version 750 $(Q)rm -f .old_version
@@ -932,7 +936,7 @@ headers_install_all: include/linux/version.h scripts_basic FORCE
932 936
933PHONY += headers_install 937PHONY += headers_install
934headers_install: include/linux/version.h scripts_basic FORCE 938headers_install: include/linux/version.h scripts_basic FORCE
935 @if [ ! -r include/asm-$(ARCH)/Kbuild ]; then \ 939 @if [ ! -r $(srctree)/include/asm-$(ARCH)/Kbuild ]; then \
936 echo '*** Error: Headers not exportable for this architecture ($(ARCH))'; \ 940 echo '*** Error: Headers not exportable for this architecture ($(ARCH))'; \
937 exit 1 ; fi 941 exit 1 ; fi
938 $(Q)$(MAKE) $(build)=scripts scripts/unifdef 942 $(Q)$(MAKE) $(build)=scripts scripts/unifdef
@@ -1316,7 +1320,8 @@ define xtags
1316 $(all-sources) | xargs $1 -a \ 1320 $(all-sources) | xargs $1 -a \
1317 -I __initdata,__exitdata,__acquires,__releases \ 1321 -I __initdata,__exitdata,__acquires,__releases \
1318 -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ 1322 -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \
1319 --extra=+f --c-kinds=+px; \ 1323 --extra=+f --c-kinds=+px \
1324 --regex-asm='/ENTRY\(([^)]*)\).*/\1/'; \
1320 $(all-kconfigs) | xargs $1 -a \ 1325 $(all-kconfigs) | xargs $1 -a \
1321 --langdef=kconfig \ 1326 --langdef=kconfig \
1322 --language-force=kconfig \ 1327 --language-force=kconfig \
diff --git a/arch/alpha/kernel/alpha_ksyms.c b/arch/alpha/kernel/alpha_ksyms.c
index 8b02420f732e..e9762a33b043 100644
--- a/arch/alpha/kernel/alpha_ksyms.c
+++ b/arch/alpha/kernel/alpha_ksyms.c
@@ -6,40 +6,13 @@
6 */ 6 */
7 7
8#include <linux/module.h> 8#include <linux/module.h>
9#include <linux/string.h>
10#include <linux/user.h>
11#include <linux/elfcore.h>
12#include <linux/socket.h>
13#include <linux/syscalls.h>
14#include <linux/in.h>
15#include <linux/in6.h>
16#include <linux/pci.h>
17#include <linux/screen_info.h>
18#include <linux/tty.h>
19#include <linux/mm.h>
20#include <linux/delay.h>
21#include <linux/dma-mapping.h>
22
23#include <asm/io.h>
24#include <asm/console.h> 9#include <asm/console.h>
25#include <asm/hwrpb.h>
26#include <asm/uaccess.h> 10#include <asm/uaccess.h>
27#include <asm/processor.h>
28#include <asm/checksum.h> 11#include <asm/checksum.h>
29#include <linux/interrupt.h>
30#include <asm/fpu.h> 12#include <asm/fpu.h>
31#include <asm/irq.h>
32#include <asm/machvec.h> 13#include <asm/machvec.h>
33#include <asm/pgalloc.h>
34#include <asm/semaphore.h>
35#include <asm/tlbflush.h>
36#include <asm/cacheflush.h>
37#include <asm/vga.h>
38 14
39#include <asm/unistd.h> 15#include <linux/syscalls.h>
40
41extern struct hwrpb_struct *hwrpb;
42extern spinlock_t rtc_lock;
43 16
44/* these are C runtime functions with special calling conventions: */ 17/* these are C runtime functions with special calling conventions: */
45extern void __divl (void); 18extern void __divl (void);
@@ -52,14 +25,9 @@ extern void __divqu (void);
52extern void __remqu (void); 25extern void __remqu (void);
53 26
54EXPORT_SYMBOL(alpha_mv); 27EXPORT_SYMBOL(alpha_mv);
55EXPORT_SYMBOL(screen_info);
56EXPORT_SYMBOL(perf_irq);
57EXPORT_SYMBOL(callback_getenv); 28EXPORT_SYMBOL(callback_getenv);
58EXPORT_SYMBOL(callback_setenv); 29EXPORT_SYMBOL(callback_setenv);
59EXPORT_SYMBOL(callback_save_env); 30EXPORT_SYMBOL(callback_save_env);
60#ifdef CONFIG_ALPHA_GENERIC
61EXPORT_SYMBOL(alpha_using_srm);
62#endif /* CONFIG_ALPHA_GENERIC */
63 31
64/* platform dependent support */ 32/* platform dependent support */
65EXPORT_SYMBOL(strcat); 33EXPORT_SYMBOL(strcat);
@@ -77,47 +45,14 @@ EXPORT_SYMBOL(__constant_c_memset);
77EXPORT_SYMBOL(copy_page); 45EXPORT_SYMBOL(copy_page);
78EXPORT_SYMBOL(clear_page); 46EXPORT_SYMBOL(clear_page);
79 47
80EXPORT_SYMBOL(__direct_map_base);
81EXPORT_SYMBOL(__direct_map_size);
82
83#ifdef CONFIG_PCI
84EXPORT_SYMBOL(pci_alloc_consistent);
85EXPORT_SYMBOL(pci_free_consistent);
86EXPORT_SYMBOL(pci_map_single);
87EXPORT_SYMBOL(pci_map_page);
88EXPORT_SYMBOL(pci_unmap_single);
89EXPORT_SYMBOL(pci_unmap_page);
90EXPORT_SYMBOL(pci_map_sg);
91EXPORT_SYMBOL(pci_unmap_sg);
92EXPORT_SYMBOL(pci_dma_supported);
93EXPORT_SYMBOL(pci_dac_dma_supported);
94EXPORT_SYMBOL(pci_dac_page_to_dma);
95EXPORT_SYMBOL(pci_dac_dma_to_page);
96EXPORT_SYMBOL(pci_dac_dma_to_offset);
97EXPORT_SYMBOL(alpha_gendev_to_pci);
98#endif
99EXPORT_SYMBOL(dma_set_mask);
100
101EXPORT_SYMBOL(dump_thread);
102EXPORT_SYMBOL(dump_elf_thread);
103EXPORT_SYMBOL(dump_elf_task);
104EXPORT_SYMBOL(dump_elf_task_fp);
105EXPORT_SYMBOL(hwrpb);
106EXPORT_SYMBOL(start_thread);
107EXPORT_SYMBOL(alpha_read_fp_reg); 48EXPORT_SYMBOL(alpha_read_fp_reg);
108EXPORT_SYMBOL(alpha_read_fp_reg_s); 49EXPORT_SYMBOL(alpha_read_fp_reg_s);
109EXPORT_SYMBOL(alpha_write_fp_reg); 50EXPORT_SYMBOL(alpha_write_fp_reg);
110EXPORT_SYMBOL(alpha_write_fp_reg_s); 51EXPORT_SYMBOL(alpha_write_fp_reg_s);
111 52
112/* In-kernel system calls. */ 53/* entry.S */
113EXPORT_SYMBOL(kernel_thread); 54EXPORT_SYMBOL(kernel_thread);
114EXPORT_SYMBOL(sys_dup);
115EXPORT_SYMBOL(sys_exit);
116EXPORT_SYMBOL(sys_write);
117EXPORT_SYMBOL(sys_lseek);
118EXPORT_SYMBOL(kernel_execve); 55EXPORT_SYMBOL(kernel_execve);
119EXPORT_SYMBOL(sys_setsid);
120EXPORT_SYMBOL(sys_wait4);
121 56
122/* Networking helper routines. */ 57/* Networking helper routines. */
123EXPORT_SYMBOL(csum_tcpudp_magic); 58EXPORT_SYMBOL(csum_tcpudp_magic);
@@ -134,10 +69,6 @@ EXPORT_SYMBOL(alpha_fp_emul_imprecise);
134EXPORT_SYMBOL(alpha_fp_emul); 69EXPORT_SYMBOL(alpha_fp_emul);
135#endif 70#endif
136 71
137#ifdef CONFIG_ALPHA_BROKEN_IRQ_MASK
138EXPORT_SYMBOL(__min_ipl);
139#endif
140
141/* 72/*
142 * The following are specially called from the uaccess assembly stubs. 73 * The following are specially called from the uaccess assembly stubs.
143 */ 74 */
@@ -160,27 +91,10 @@ EXPORT_SYMBOL(up);
160 */ 91 */
161 92
162#ifdef CONFIG_SMP 93#ifdef CONFIG_SMP
163EXPORT_SYMBOL(flush_tlb_mm);
164EXPORT_SYMBOL(flush_tlb_range);
165EXPORT_SYMBOL(flush_tlb_page);
166EXPORT_SYMBOL(smp_imb);
167EXPORT_SYMBOL(cpu_data);
168EXPORT_SYMBOL(smp_num_cpus);
169EXPORT_SYMBOL(smp_call_function);
170EXPORT_SYMBOL(smp_call_function_on_cpu);
171EXPORT_SYMBOL(_atomic_dec_and_lock); 94EXPORT_SYMBOL(_atomic_dec_and_lock);
172#endif /* CONFIG_SMP */ 95#endif /* CONFIG_SMP */
173 96
174/* 97/*
175 * NUMA specific symbols
176 */
177#ifdef CONFIG_DISCONTIGMEM
178EXPORT_SYMBOL(node_data);
179#endif /* CONFIG_DISCONTIGMEM */
180
181EXPORT_SYMBOL(rtc_lock);
182
183/*
184 * The following are special because they're not called 98 * The following are special because they're not called
185 * explicitly (the C compiler or assembler generates them in 99 * explicitly (the C compiler or assembler generates them in
186 * response to division operations). Fortunately, their 100 * response to division operations). Fortunately, their
@@ -200,8 +114,3 @@ EXPORT_SYMBOL(__remqu);
200EXPORT_SYMBOL(memcpy); 114EXPORT_SYMBOL(memcpy);
201EXPORT_SYMBOL(memset); 115EXPORT_SYMBOL(memset);
202EXPORT_SYMBOL(memchr); 116EXPORT_SYMBOL(memchr);
203
204#ifdef CONFIG_ALPHA_IRONGATE
205EXPORT_SYMBOL(irongate_ioremap);
206EXPORT_SYMBOL(irongate_iounmap);
207#endif
diff --git a/arch/alpha/kernel/core_irongate.c b/arch/alpha/kernel/core_irongate.c
index 138d497d1cca..e4a0bcf1d28b 100644
--- a/arch/alpha/kernel/core_irongate.c
+++ b/arch/alpha/kernel/core_irongate.c
@@ -404,6 +404,7 @@ irongate_ioremap(unsigned long addr, unsigned long size)
404#endif 404#endif
405 return (void __iomem *)vaddr; 405 return (void __iomem *)vaddr;
406} 406}
407EXPORT_SYMBOL(irongate_ioremap);
407 408
408void 409void
409irongate_iounmap(volatile void __iomem *xaddr) 410irongate_iounmap(volatile void __iomem *xaddr)
@@ -414,3 +415,4 @@ irongate_iounmap(volatile void __iomem *xaddr)
414 if (addr) 415 if (addr)
415 return vfree((void *)(PAGE_MASK & addr)); 416 return vfree((void *)(PAGE_MASK & addr));
416} 417}
418EXPORT_SYMBOL(irongate_iounmap);
diff --git a/arch/alpha/kernel/irq_alpha.c b/arch/alpha/kernel/irq_alpha.c
index 6dd126b8be85..e16aeb6e79ef 100644
--- a/arch/alpha/kernel/irq_alpha.c
+++ b/arch/alpha/kernel/irq_alpha.c
@@ -6,6 +6,7 @@
6#include <linux/sched.h> 6#include <linux/sched.h>
7#include <linux/irq.h> 7#include <linux/irq.h>
8#include <linux/kernel_stat.h> 8#include <linux/kernel_stat.h>
9#include <linux/module.h>
9 10
10#include <asm/machvec.h> 11#include <asm/machvec.h>
11#include <asm/dma.h> 12#include <asm/dma.h>
@@ -16,6 +17,7 @@
16/* Hack minimum IPL during interrupt processing for broken hardware. */ 17/* Hack minimum IPL during interrupt processing for broken hardware. */
17#ifdef CONFIG_ALPHA_BROKEN_IRQ_MASK 18#ifdef CONFIG_ALPHA_BROKEN_IRQ_MASK
18int __min_ipl; 19int __min_ipl;
20EXPORT_SYMBOL(__min_ipl);
19#endif 21#endif
20 22
21/* 23/*
@@ -30,6 +32,7 @@ dummy_perf(unsigned long vector, struct pt_regs *regs)
30} 32}
31 33
32void (*perf_irq)(unsigned long, struct pt_regs *) = dummy_perf; 34void (*perf_irq)(unsigned long, struct pt_regs *) = dummy_perf;
35EXPORT_SYMBOL(perf_irq);
33 36
34/* 37/*
35 * The main interrupt entry point. 38 * The main interrupt entry point.
diff --git a/arch/alpha/kernel/pci-noop.c b/arch/alpha/kernel/pci-noop.c
index fff5cf93e816..174b729c504b 100644
--- a/arch/alpha/kernel/pci-noop.c
+++ b/arch/alpha/kernel/pci-noop.c
@@ -201,6 +201,7 @@ dma_set_mask(struct device *dev, u64 mask)
201 201
202 return 0; 202 return 0;
203} 203}
204EXPORT_SYMBOL(dma_set_mask);
204 205
205void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen) 206void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
206{ 207{
diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c
index c468e312e5f8..6e7d1fe6e935 100644
--- a/arch/alpha/kernel/pci_iommu.c
+++ b/arch/alpha/kernel/pci_iommu.c
@@ -300,6 +300,7 @@ pci_map_single(struct pci_dev *pdev, void *cpu_addr, size_t size, int dir)
300 dac_allowed = pdev ? pci_dac_dma_supported(pdev, pdev->dma_mask) : 0; 300 dac_allowed = pdev ? pci_dac_dma_supported(pdev, pdev->dma_mask) : 0;
301 return pci_map_single_1(pdev, cpu_addr, size, dac_allowed); 301 return pci_map_single_1(pdev, cpu_addr, size, dac_allowed);
302} 302}
303EXPORT_SYMBOL(pci_map_single);
303 304
304dma_addr_t 305dma_addr_t
305pci_map_page(struct pci_dev *pdev, struct page *page, unsigned long offset, 306pci_map_page(struct pci_dev *pdev, struct page *page, unsigned long offset,
@@ -314,6 +315,7 @@ pci_map_page(struct pci_dev *pdev, struct page *page, unsigned long offset,
314 return pci_map_single_1(pdev, (char *)page_address(page) + offset, 315 return pci_map_single_1(pdev, (char *)page_address(page) + offset,
315 size, dac_allowed); 316 size, dac_allowed);
316} 317}
318EXPORT_SYMBOL(pci_map_page);
317 319
318/* Unmap a single streaming mode DMA translation. The DMA_ADDR and 320/* Unmap a single streaming mode DMA translation. The DMA_ADDR and
319 SIZE must match what was provided for in a previous pci_map_single 321 SIZE must match what was provided for in a previous pci_map_single
@@ -379,6 +381,7 @@ pci_unmap_single(struct pci_dev *pdev, dma_addr_t dma_addr, size_t size,
379 DBGA2("pci_unmap_single: sg [%lx,%lx] np %ld from %p\n", 381 DBGA2("pci_unmap_single: sg [%lx,%lx] np %ld from %p\n",
380 dma_addr, size, npages, __builtin_return_address(0)); 382 dma_addr, size, npages, __builtin_return_address(0));
381} 383}
384EXPORT_SYMBOL(pci_unmap_single);
382 385
383void 386void
384pci_unmap_page(struct pci_dev *pdev, dma_addr_t dma_addr, 387pci_unmap_page(struct pci_dev *pdev, dma_addr_t dma_addr,
@@ -386,6 +389,7 @@ pci_unmap_page(struct pci_dev *pdev, dma_addr_t dma_addr,
386{ 389{
387 pci_unmap_single(pdev, dma_addr, size, direction); 390 pci_unmap_single(pdev, dma_addr, size, direction);
388} 391}
392EXPORT_SYMBOL(pci_unmap_page);
389 393
390/* Allocate and map kernel buffer using consistent mode DMA for PCI 394/* Allocate and map kernel buffer using consistent mode DMA for PCI
391 device. Returns non-NULL cpu-view pointer to the buffer if 395 device. Returns non-NULL cpu-view pointer to the buffer if
@@ -427,6 +431,7 @@ try_again:
427 431
428 return cpu_addr; 432 return cpu_addr;
429} 433}
434EXPORT_SYMBOL(pci_alloc_consistent);
430 435
431/* Free and unmap a consistent DMA buffer. CPU_ADDR and DMA_ADDR must 436/* Free and unmap a consistent DMA buffer. CPU_ADDR and DMA_ADDR must
432 be values that were returned from pci_alloc_consistent. SIZE must 437 be values that were returned from pci_alloc_consistent. SIZE must
@@ -444,7 +449,7 @@ pci_free_consistent(struct pci_dev *pdev, size_t size, void *cpu_addr,
444 DBGA2("pci_free_consistent: [%x,%lx] from %p\n", 449 DBGA2("pci_free_consistent: [%x,%lx] from %p\n",
445 dma_addr, size, __builtin_return_address(0)); 450 dma_addr, size, __builtin_return_address(0));
446} 451}
447 452EXPORT_SYMBOL(pci_free_consistent);
448 453
449/* Classify the elements of the scatterlist. Write dma_address 454/* Classify the elements of the scatterlist. Write dma_address
450 of each element with: 455 of each element with:
@@ -672,6 +677,7 @@ pci_map_sg(struct pci_dev *pdev, struct scatterlist *sg, int nents,
672 pci_unmap_sg(pdev, start, out - start, direction); 677 pci_unmap_sg(pdev, start, out - start, direction);
673 return 0; 678 return 0;
674} 679}
680EXPORT_SYMBOL(pci_map_sg);
675 681
676/* Unmap a set of streaming mode DMA translations. Again, cpu read 682/* Unmap a set of streaming mode DMA translations. Again, cpu read
677 rules concerning calls here are the same as for pci_unmap_single() 683 rules concerning calls here are the same as for pci_unmap_single()
@@ -752,6 +758,7 @@ pci_unmap_sg(struct pci_dev *pdev, struct scatterlist *sg, int nents,
752 758
753 DBGA("pci_unmap_sg: %ld entries\n", nents - (end - sg)); 759 DBGA("pci_unmap_sg: %ld entries\n", nents - (end - sg));
754} 760}
761EXPORT_SYMBOL(pci_unmap_sg);
755 762
756 763
757/* Return whether the given PCI device DMA address mask can be 764/* Return whether the given PCI device DMA address mask can be
@@ -786,6 +793,7 @@ pci_dma_supported(struct pci_dev *pdev, u64 mask)
786 793
787 return 0; 794 return 0;
788} 795}
796EXPORT_SYMBOL(pci_dma_supported);
789 797
790 798
791/* 799/*
@@ -908,6 +916,7 @@ pci_dac_dma_supported(struct pci_dev *dev, u64 mask)
908 916
909 return ok; 917 return ok;
910} 918}
919EXPORT_SYMBOL(pci_dac_dma_supported);
911 920
912dma64_addr_t 921dma64_addr_t
913pci_dac_page_to_dma(struct pci_dev *pdev, struct page *page, 922pci_dac_page_to_dma(struct pci_dev *pdev, struct page *page,
@@ -917,6 +926,7 @@ pci_dac_page_to_dma(struct pci_dev *pdev, struct page *page,
917 + __pa(page_address(page)) 926 + __pa(page_address(page))
918 + (dma64_addr_t) offset); 927 + (dma64_addr_t) offset);
919} 928}
929EXPORT_SYMBOL(pci_dac_page_to_dma);
920 930
921struct page * 931struct page *
922pci_dac_dma_to_page(struct pci_dev *pdev, dma64_addr_t dma_addr) 932pci_dac_dma_to_page(struct pci_dev *pdev, dma64_addr_t dma_addr)
@@ -924,13 +934,14 @@ pci_dac_dma_to_page(struct pci_dev *pdev, dma64_addr_t dma_addr)
924 unsigned long paddr = (dma_addr & PAGE_MASK) - alpha_mv.pci_dac_offset; 934 unsigned long paddr = (dma_addr & PAGE_MASK) - alpha_mv.pci_dac_offset;
925 return virt_to_page(__va(paddr)); 935 return virt_to_page(__va(paddr));
926} 936}
937EXPORT_SYMBOL(pci_dac_dma_to_page);
927 938
928unsigned long 939unsigned long
929pci_dac_dma_to_offset(struct pci_dev *pdev, dma64_addr_t dma_addr) 940pci_dac_dma_to_offset(struct pci_dev *pdev, dma64_addr_t dma_addr)
930{ 941{
931 return (dma_addr & ~PAGE_MASK); 942 return (dma_addr & ~PAGE_MASK);
932} 943}
933 944EXPORT_SYMBOL(pci_dac_dma_to_offset);
934 945
935/* Helper for generic DMA-mapping functions. */ 946/* Helper for generic DMA-mapping functions. */
936 947
@@ -957,6 +968,7 @@ alpha_gendev_to_pci(struct device *dev)
957 /* This assumes ISA bus master with dma_mask 0xffffff. */ 968 /* This assumes ISA bus master with dma_mask 0xffffff. */
958 return NULL; 969 return NULL;
959} 970}
971EXPORT_SYMBOL(alpha_gendev_to_pci);
960 972
961int 973int
962dma_set_mask(struct device *dev, u64 mask) 974dma_set_mask(struct device *dev, u64 mask)
@@ -969,3 +981,4 @@ dma_set_mask(struct device *dev, u64 mask)
969 981
970 return 0; 982 return 0;
971} 983}
984EXPORT_SYMBOL(dma_set_mask);
diff --git a/arch/alpha/kernel/process.c b/arch/alpha/kernel/process.c
index b3a8a2980365..3370e6faeae0 100644
--- a/arch/alpha/kernel/process.c
+++ b/arch/alpha/kernel/process.c
@@ -205,6 +205,7 @@ start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp)
205 regs->ps = 8; 205 regs->ps = 8;
206 wrusp(sp); 206 wrusp(sp);
207} 207}
208EXPORT_SYMBOL(start_thread);
208 209
209/* 210/*
210 * Free current thread data structures etc.. 211 * Free current thread data structures etc..
@@ -376,6 +377,7 @@ dump_thread(struct pt_regs * pt, struct user * dump)
376 dump->regs[EF_A2] = pt->r18; 377 dump->regs[EF_A2] = pt->r18;
377 memcpy((char *)dump->regs + EF_SIZE, sw->fp, 32 * 8); 378 memcpy((char *)dump->regs + EF_SIZE, sw->fp, 32 * 8);
378} 379}
380EXPORT_SYMBOL(dump_thread);
379 381
380/* 382/*
381 * Fill in the user structure for a ELF core dump. 383 * Fill in the user structure for a ELF core dump.
@@ -424,6 +426,7 @@ dump_elf_thread(elf_greg_t *dest, struct pt_regs *pt, struct thread_info *ti)
424 useful value of the thread's UNIQUE field. */ 426 useful value of the thread's UNIQUE field. */
425 dest[32] = ti->pcb.unique; 427 dest[32] = ti->pcb.unique;
426} 428}
429EXPORT_SYMBOL(dump_elf_thread);
427 430
428int 431int
429dump_elf_task(elf_greg_t *dest, struct task_struct *task) 432dump_elf_task(elf_greg_t *dest, struct task_struct *task)
@@ -431,6 +434,7 @@ dump_elf_task(elf_greg_t *dest, struct task_struct *task)
431 dump_elf_thread(dest, task_pt_regs(task), task_thread_info(task)); 434 dump_elf_thread(dest, task_pt_regs(task), task_thread_info(task));
432 return 1; 435 return 1;
433} 436}
437EXPORT_SYMBOL(dump_elf_task);
434 438
435int 439int
436dump_elf_task_fp(elf_fpreg_t *dest, struct task_struct *task) 440dump_elf_task_fp(elf_fpreg_t *dest, struct task_struct *task)
@@ -439,6 +443,7 @@ dump_elf_task_fp(elf_fpreg_t *dest, struct task_struct *task)
439 memcpy(dest, sw->fp, 32 * 8); 443 memcpy(dest, sw->fp, 32 * 8);
440 return 1; 444 return 1;
441} 445}
446EXPORT_SYMBOL(dump_elf_task_fp);
442 447
443/* 448/*
444 * sys_execve() executes a new program. 449 * sys_execve() executes a new program.
diff --git a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c
index a94e6d93e2ee..1aea7c7c683c 100644
--- a/arch/alpha/kernel/setup.c
+++ b/arch/alpha/kernel/setup.c
@@ -66,6 +66,7 @@ static struct notifier_block alpha_panic_block = {
66 66
67 67
68struct hwrpb_struct *hwrpb; 68struct hwrpb_struct *hwrpb;
69EXPORT_SYMBOL(hwrpb);
69unsigned long srm_hae; 70unsigned long srm_hae;
70 71
71int alpha_l1i_cacheshape; 72int alpha_l1i_cacheshape;
@@ -111,6 +112,7 @@ unsigned long alpha_agpgart_size = DEFAULT_AGP_APER_SIZE;
111#ifdef CONFIG_ALPHA_GENERIC 112#ifdef CONFIG_ALPHA_GENERIC
112struct alpha_machine_vector alpha_mv; 113struct alpha_machine_vector alpha_mv;
113int alpha_using_srm; 114int alpha_using_srm;
115EXPORT_SYMBOL(alpha_using_srm);
114#endif 116#endif
115 117
116static struct alpha_machine_vector *get_sysvec(unsigned long, unsigned long, 118static struct alpha_machine_vector *get_sysvec(unsigned long, unsigned long,
@@ -137,6 +139,8 @@ struct screen_info screen_info = {
137 .orig_video_points = 16 139 .orig_video_points = 16
138}; 140};
139 141
142EXPORT_SYMBOL(screen_info);
143
140/* 144/*
141 * The direct map I/O window, if any. This should be the same 145 * The direct map I/O window, if any. This should be the same
142 * for all busses, since it's used by virt_to_bus. 146 * for all busses, since it's used by virt_to_bus.
@@ -144,6 +148,8 @@ struct screen_info screen_info = {
144 148
145unsigned long __direct_map_base; 149unsigned long __direct_map_base;
146unsigned long __direct_map_size; 150unsigned long __direct_map_size;
151EXPORT_SYMBOL(__direct_map_base);
152EXPORT_SYMBOL(__direct_map_size);
147 153
148/* 154/*
149 * Declare all of the machine vectors. 155 * Declare all of the machine vectors.
diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c
index 596780e2c7da..d1ec4f51df1a 100644
--- a/arch/alpha/kernel/smp.c
+++ b/arch/alpha/kernel/smp.c
@@ -52,6 +52,7 @@
52 52
53/* A collection of per-processor data. */ 53/* A collection of per-processor data. */
54struct cpuinfo_alpha cpu_data[NR_CPUS]; 54struct cpuinfo_alpha cpu_data[NR_CPUS];
55EXPORT_SYMBOL(cpu_data);
55 56
56/* A collection of single bit ipi messages. */ 57/* A collection of single bit ipi messages. */
57static struct { 58static struct {
@@ -74,6 +75,7 @@ EXPORT_SYMBOL(cpu_online_map);
74 75
75int smp_num_probed; /* Internal processor count */ 76int smp_num_probed; /* Internal processor count */
76int smp_num_cpus = 1; /* Number that came online. */ 77int smp_num_cpus = 1; /* Number that came online. */
78EXPORT_SYMBOL(smp_num_cpus);
77 79
78extern void calibrate_delay(void); 80extern void calibrate_delay(void);
79 81
@@ -790,6 +792,7 @@ smp_call_function_on_cpu (void (*func) (void *info), void *info, int retry,
790 792
791 return 0; 793 return 0;
792} 794}
795EXPORT_SYMBOL(smp_call_function_on_cpu);
793 796
794int 797int
795smp_call_function (void (*func) (void *info), void *info, int retry, int wait) 798smp_call_function (void (*func) (void *info), void *info, int retry, int wait)
@@ -797,6 +800,7 @@ smp_call_function (void (*func) (void *info), void *info, int retry, int wait)
797 return smp_call_function_on_cpu (func, info, retry, wait, 800 return smp_call_function_on_cpu (func, info, retry, wait,
798 cpu_online_map); 801 cpu_online_map);
799} 802}
803EXPORT_SYMBOL(smp_call_function);
800 804
801static void 805static void
802ipi_imb(void *ignored) 806ipi_imb(void *ignored)
@@ -811,6 +815,7 @@ smp_imb(void)
811 if (on_each_cpu(ipi_imb, NULL, 1, 1)) 815 if (on_each_cpu(ipi_imb, NULL, 1, 1))
812 printk(KERN_CRIT "smp_imb: timed out\n"); 816 printk(KERN_CRIT "smp_imb: timed out\n");
813} 817}
818EXPORT_SYMBOL(smp_imb);
814 819
815static void 820static void
816ipi_flush_tlb_all(void *ignored) 821ipi_flush_tlb_all(void *ignored)
@@ -866,6 +871,7 @@ flush_tlb_mm(struct mm_struct *mm)
866 871
867 preempt_enable(); 872 preempt_enable();
868} 873}
874EXPORT_SYMBOL(flush_tlb_mm);
869 875
870struct flush_tlb_page_struct { 876struct flush_tlb_page_struct {
871 struct vm_area_struct *vma; 877 struct vm_area_struct *vma;
@@ -918,6 +924,7 @@ flush_tlb_page(struct vm_area_struct *vma, unsigned long addr)
918 924
919 preempt_enable(); 925 preempt_enable();
920} 926}
927EXPORT_SYMBOL(flush_tlb_page);
921 928
922void 929void
923flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned long end) 930flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned long end)
@@ -925,6 +932,7 @@ flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned long e
925 /* On the Alpha we always flush the whole user tlb. */ 932 /* On the Alpha we always flush the whole user tlb. */
926 flush_tlb_mm(vma->vm_mm); 933 flush_tlb_mm(vma->vm_mm);
927} 934}
935EXPORT_SYMBOL(flush_tlb_range);
928 936
929static void 937static void
930ipi_flush_icache_page(void *x) 938ipi_flush_icache_page(void *x)
diff --git a/arch/alpha/kernel/srm_env.c b/arch/alpha/kernel/srm_env.c
index 990ac61028f8..f7dd081d57ff 100644
--- a/arch/alpha/kernel/srm_env.c
+++ b/arch/alpha/kernel/srm_env.c
@@ -2,7 +2,7 @@
2 * srm_env.c - Access to SRM environment 2 * srm_env.c - Access to SRM environment
3 * variables through linux' procfs 3 * variables through linux' procfs
4 * 4 *
5 * Copyright (C) 2001-2002 Jan-Benedict Glaw <jbglaw@lug-owl.de> 5 * (C) 2001,2002,2006 by Jan-Benedict Glaw <jbglaw@lug-owl.de>
6 * 6 *
7 * This driver is at all a modified version of Erik Mouw's 7 * This driver is at all a modified version of Erik Mouw's
8 * Documentation/DocBook/procfs_example.c, so: thank 8 * Documentation/DocBook/procfs_example.c, so: thank
@@ -21,7 +21,7 @@
21 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 21 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
22 * PURPOSE. See the GNU General Public License for more 22 * PURPOSE. See the GNU General Public License for more
23 * details. 23 * details.
24 * 24 *
25 * You should have received a copy of the GNU General Public 25 * You should have received a copy of the GNU General Public
26 * License along with this program; if not, write to the 26 * License along with this program; if not, write to the
27 * Free Software Foundation, Inc., 59 Temple Place, 27 * Free Software Foundation, Inc., 59 Temple Place,
@@ -29,33 +29,6 @@
29 * 29 *
30 */ 30 */
31 31
32/*
33 * Changelog
34 * ~~~~~~~~~
35 *
36 * Thu, 22 Aug 2002 15:10:43 +0200
37 * - Update Config.help entry. I got a number of emails asking
38 * me to tell their senders if they could make use of this
39 * piece of code... So: "SRM is something like BIOS for your
40 * Alpha"
41 * - Update code formatting a bit to better conform CodingStyle
42 * rules.
43 * - So this is v0.0.5, with no changes (except formatting)
44 *
45 * Wed, 22 May 2002 00:11:21 +0200
46 * - Fix typo on comment (SRC -> SRM)
47 * - Call this "Version 0.0.4"
48 *
49 * Tue, 9 Apr 2002 18:44:40 +0200
50 * - Implement access by variable name and additionally
51 * by number. This is done by creating two subdirectories
52 * where one holds all names (like the old directory
53 * did) and the other holding 256 files named like "0",
54 * "1" and so on.
55 * - Call this "Version 0.0.3"
56 *
57 */
58
59#include <linux/kernel.h> 32#include <linux/kernel.h>
60#include <linux/module.h> 33#include <linux/module.h>
61#include <linux/init.h> 34#include <linux/init.h>
@@ -67,7 +40,7 @@
67#define BASE_DIR "srm_environment" /* Subdir in /proc/ */ 40#define BASE_DIR "srm_environment" /* Subdir in /proc/ */
68#define NAMED_DIR "named_variables" /* Subdir for known variables */ 41#define NAMED_DIR "named_variables" /* Subdir for known variables */
69#define NUMBERED_DIR "numbered_variables" /* Subdir for all variables */ 42#define NUMBERED_DIR "numbered_variables" /* Subdir for all variables */
70#define VERSION "0.0.5" /* Module version */ 43#define VERSION "0.0.6" /* Module version */
71#define NAME "srm_env" /* Module name */ 44#define NAME "srm_env" /* Module name */
72 45
73MODULE_AUTHOR("Jan-Benedict Glaw <jbglaw@lug-owl.de>"); 46MODULE_AUTHOR("Jan-Benedict Glaw <jbglaw@lug-owl.de>");
@@ -106,7 +79,6 @@ static srm_env_t srm_named_entries[] = {
106static srm_env_t srm_numbered_entries[256]; 79static srm_env_t srm_numbered_entries[256];
107 80
108 81
109
110static int 82static int
111srm_env_read(char *page, char **start, off_t off, int count, int *eof, 83srm_env_read(char *page, char **start, off_t off, int count, int *eof,
112 void *data) 84 void *data)
@@ -115,21 +87,23 @@ srm_env_read(char *page, char **start, off_t off, int count, int *eof,
115 unsigned long ret; 87 unsigned long ret;
116 srm_env_t *entry; 88 srm_env_t *entry;
117 89
118 if(off != 0) 90 if (off != 0) {
119 return -EFAULT; 91 *eof = 1;
92 return 0;
93 }
120 94
121 entry = (srm_env_t *) data; 95 entry = (srm_env_t *) data;
122 ret = callback_getenv(entry->id, page, count); 96 ret = callback_getenv(entry->id, page, count);
123 97
124 if((ret >> 61) == 0) 98 if ((ret >> 61) == 0) {
125 nbytes = (int) ret; 99 nbytes = (int) ret;
126 else 100 *eof = 1;
101 } else
127 nbytes = -EFAULT; 102 nbytes = -EFAULT;
128 103
129 return nbytes; 104 return nbytes;
130} 105}
131 106
132
133static int 107static int
134srm_env_write(struct file *file, const char __user *buffer, unsigned long count, 108srm_env_write(struct file *file, const char __user *buffer, unsigned long count,
135 void *data) 109 void *data)
@@ -155,7 +129,7 @@ srm_env_write(struct file *file, const char __user *buffer, unsigned long count,
155 129
156 ret1 = callback_setenv(entry->id, buf, count); 130 ret1 = callback_setenv(entry->id, buf, count);
157 if ((ret1 >> 61) == 0) { 131 if ((ret1 >> 61) == 0) {
158 do 132 do
159 ret2 = callback_save_env(); 133 ret2 = callback_save_env();
160 while((ret2 >> 61) == 1); 134 while((ret2 >> 61) == 1);
161 res = (int) ret1; 135 res = (int) ret1;
@@ -172,14 +146,14 @@ srm_env_cleanup(void)
172 srm_env_t *entry; 146 srm_env_t *entry;
173 unsigned long var_num; 147 unsigned long var_num;
174 148
175 if(base_dir) { 149 if (base_dir) {
176 /* 150 /*
177 * Remove named entries 151 * Remove named entries
178 */ 152 */
179 if(named_dir) { 153 if (named_dir) {
180 entry = srm_named_entries; 154 entry = srm_named_entries;
181 while(entry->name != NULL && entry->id != 0) { 155 while (entry->name != NULL && entry->id != 0) {
182 if(entry->proc_entry) { 156 if (entry->proc_entry) {
183 remove_proc_entry(entry->name, 157 remove_proc_entry(entry->name,
184 named_dir); 158 named_dir);
185 entry->proc_entry = NULL; 159 entry->proc_entry = NULL;
@@ -192,11 +166,11 @@ srm_env_cleanup(void)
192 /* 166 /*
193 * Remove numbered entries 167 * Remove numbered entries
194 */ 168 */
195 if(numbered_dir) { 169 if (numbered_dir) {
196 for(var_num = 0; var_num <= 255; var_num++) { 170 for (var_num = 0; var_num <= 255; var_num++) {
197 entry = &srm_numbered_entries[var_num]; 171 entry = &srm_numbered_entries[var_num];
198 172
199 if(entry->proc_entry) { 173 if (entry->proc_entry) {
200 remove_proc_entry(entry->name, 174 remove_proc_entry(entry->name,
201 numbered_dir); 175 numbered_dir);
202 entry->proc_entry = NULL; 176 entry->proc_entry = NULL;
@@ -212,7 +186,6 @@ srm_env_cleanup(void)
212 return; 186 return;
213} 187}
214 188
215
216static int __init 189static int __init
217srm_env_init(void) 190srm_env_init(void)
218{ 191{
@@ -222,7 +195,7 @@ srm_env_init(void)
222 /* 195 /*
223 * Check system 196 * Check system
224 */ 197 */
225 if(!alpha_using_srm) { 198 if (!alpha_using_srm) {
226 printk(KERN_INFO "%s: This Alpha system doesn't " 199 printk(KERN_INFO "%s: This Alpha system doesn't "
227 "know about SRM (or you've booted " 200 "know about SRM (or you've booted "
228 "SRM->MILO->Linux, which gets " 201 "SRM->MILO->Linux, which gets "
@@ -233,14 +206,14 @@ srm_env_init(void)
233 /* 206 /*
234 * Init numbers 207 * Init numbers
235 */ 208 */
236 for(var_num = 0; var_num <= 255; var_num++) 209 for (var_num = 0; var_num <= 255; var_num++)
237 sprintf(number[var_num], "%ld", var_num); 210 sprintf(number[var_num], "%ld", var_num);
238 211
239 /* 212 /*
240 * Create base directory 213 * Create base directory
241 */ 214 */
242 base_dir = proc_mkdir(BASE_DIR, NULL); 215 base_dir = proc_mkdir(BASE_DIR, NULL);
243 if(base_dir == NULL) { 216 if (!base_dir) {
244 printk(KERN_ERR "Couldn't create base dir /proc/%s\n", 217 printk(KERN_ERR "Couldn't create base dir /proc/%s\n",
245 BASE_DIR); 218 BASE_DIR);
246 goto cleanup; 219 goto cleanup;
@@ -251,7 +224,7 @@ srm_env_init(void)
251 * Create per-name subdirectory 224 * Create per-name subdirectory
252 */ 225 */
253 named_dir = proc_mkdir(NAMED_DIR, base_dir); 226 named_dir = proc_mkdir(NAMED_DIR, base_dir);
254 if(named_dir == NULL) { 227 if (!named_dir) {
255 printk(KERN_ERR "Couldn't create dir /proc/%s/%s\n", 228 printk(KERN_ERR "Couldn't create dir /proc/%s/%s\n",
256 BASE_DIR, NAMED_DIR); 229 BASE_DIR, NAMED_DIR);
257 goto cleanup; 230 goto cleanup;
@@ -262,7 +235,7 @@ srm_env_init(void)
262 * Create per-number subdirectory 235 * Create per-number subdirectory
263 */ 236 */
264 numbered_dir = proc_mkdir(NUMBERED_DIR, base_dir); 237 numbered_dir = proc_mkdir(NUMBERED_DIR, base_dir);
265 if(numbered_dir == NULL) { 238 if (!numbered_dir) {
266 printk(KERN_ERR "Couldn't create dir /proc/%s/%s\n", 239 printk(KERN_ERR "Couldn't create dir /proc/%s/%s\n",
267 BASE_DIR, NUMBERED_DIR); 240 BASE_DIR, NUMBERED_DIR);
268 goto cleanup; 241 goto cleanup;
@@ -274,10 +247,10 @@ srm_env_init(void)
274 * Create all named nodes 247 * Create all named nodes
275 */ 248 */
276 entry = srm_named_entries; 249 entry = srm_named_entries;
277 while(entry->name != NULL && entry->id != 0) { 250 while (entry->name && entry->id) {
278 entry->proc_entry = create_proc_entry(entry->name, 251 entry->proc_entry = create_proc_entry(entry->name,
279 0644, named_dir); 252 0644, named_dir);
280 if(entry->proc_entry == NULL) 253 if (!entry->proc_entry)
281 goto cleanup; 254 goto cleanup;
282 255
283 entry->proc_entry->data = (void *) entry; 256 entry->proc_entry->data = (void *) entry;
@@ -291,13 +264,13 @@ srm_env_init(void)
291 /* 264 /*
292 * Create all numbered nodes 265 * Create all numbered nodes
293 */ 266 */
294 for(var_num = 0; var_num <= 255; var_num++) { 267 for (var_num = 0; var_num <= 255; var_num++) {
295 entry = &srm_numbered_entries[var_num]; 268 entry = &srm_numbered_entries[var_num];
296 entry->name = number[var_num]; 269 entry->name = number[var_num];
297 270
298 entry->proc_entry = create_proc_entry(entry->name, 271 entry->proc_entry = create_proc_entry(entry->name,
299 0644, numbered_dir); 272 0644, numbered_dir);
300 if(entry->proc_entry == NULL) 273 if (!entry->proc_entry)
301 goto cleanup; 274 goto cleanup;
302 275
303 entry->id = var_num; 276 entry->id = var_num;
@@ -318,7 +291,6 @@ cleanup:
318 return -ENOMEM; 291 return -ENOMEM;
319} 292}
320 293
321
322static void __exit 294static void __exit
323srm_env_exit(void) 295srm_env_exit(void)
324{ 296{
@@ -328,7 +300,5 @@ srm_env_exit(void)
328 return; 300 return;
329} 301}
330 302
331
332module_init(srm_env_init); 303module_init(srm_env_init);
333module_exit(srm_env_exit); 304module_exit(srm_env_exit);
334
diff --git a/arch/alpha/kernel/time.c b/arch/alpha/kernel/time.c
index cf0666523989..d7053eb4ffcf 100644
--- a/arch/alpha/kernel/time.c
+++ b/arch/alpha/kernel/time.c
@@ -57,6 +57,7 @@
57static int set_rtc_mmss(unsigned long); 57static int set_rtc_mmss(unsigned long);
58 58
59DEFINE_SPINLOCK(rtc_lock); 59DEFINE_SPINLOCK(rtc_lock);
60EXPORT_SYMBOL(rtc_lock);
60 61
61#define TICK_SIZE (tick_nsec / 1000) 62#define TICK_SIZE (tick_nsec / 1000)
62 63
diff --git a/arch/alpha/kernel/vmlinux.lds.S b/arch/alpha/kernel/vmlinux.lds.S
index 71470e9d93ba..76bf071e376c 100644
--- a/arch/alpha/kernel/vmlinux.lds.S
+++ b/arch/alpha/kernel/vmlinux.lds.S
@@ -48,13 +48,7 @@ SECTIONS
48 . = ALIGN(8); 48 . = ALIGN(8);
49 __initcall_start = .; 49 __initcall_start = .;
50 .initcall.init : { 50 .initcall.init : {
51 *(.initcall1.init) 51 INITCALLS
52 *(.initcall2.init)
53 *(.initcall3.init)
54 *(.initcall4.init)
55 *(.initcall5.init)
56 *(.initcall6.init)
57 *(.initcall7.init)
58 } 52 }
59 __initcall_end = .; 53 __initcall_end = .;
60 54
diff --git a/arch/alpha/mm/numa.c b/arch/alpha/mm/numa.c
index b826f58c6e72..e3e3806a6f25 100644
--- a/arch/alpha/mm/numa.c
+++ b/arch/alpha/mm/numa.c
@@ -13,12 +13,14 @@
13#include <linux/swap.h> 13#include <linux/swap.h>
14#include <linux/initrd.h> 14#include <linux/initrd.h>
15#include <linux/pfn.h> 15#include <linux/pfn.h>
16#include <linux/module.h>
16 17
17#include <asm/hwrpb.h> 18#include <asm/hwrpb.h>
18#include <asm/pgalloc.h> 19#include <asm/pgalloc.h>
19 20
20pg_data_t node_data[MAX_NUMNODES]; 21pg_data_t node_data[MAX_NUMNODES];
21bootmem_data_t node_bdata[MAX_NUMNODES]; 22bootmem_data_t node_bdata[MAX_NUMNODES];
23EXPORT_SYMBOL(node_data);
22 24
23#undef DEBUG_DISCONTIG 25#undef DEBUG_DISCONTIG
24#ifdef DEBUG_DISCONTIG 26#ifdef DEBUG_DISCONTIG
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 2a0b2c8a1fe0..6f4f8bf36071 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -174,11 +174,13 @@ libs-y := arch/arm/lib/ $(libs-y)
174 174
175# Default target when executing plain make 175# Default target when executing plain make
176ifeq ($(CONFIG_XIP_KERNEL),y) 176ifeq ($(CONFIG_XIP_KERNEL),y)
177all: xipImage 177KBUILD_IMAGE := xipImage
178else 178else
179all: zImage 179KBUILD_IMAGE := zImage
180endif 180endif
181 181
182all: $(KBUILD_IMAGE)
183
182boot := arch/arm/boot 184boot := arch/arm/boot
183 185
184# Update machine arch and proc symlinks if something which affects 186# Update machine arch and proc symlinks if something which affects
diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c
index 028bdc9228fb..2e635b814c14 100644
--- a/arch/arm/common/dmabounce.c
+++ b/arch/arm/common/dmabounce.c
@@ -662,7 +662,8 @@ EXPORT_SYMBOL(dma_map_single);
662EXPORT_SYMBOL(dma_unmap_single); 662EXPORT_SYMBOL(dma_unmap_single);
663EXPORT_SYMBOL(dma_map_sg); 663EXPORT_SYMBOL(dma_map_sg);
664EXPORT_SYMBOL(dma_unmap_sg); 664EXPORT_SYMBOL(dma_unmap_sg);
665EXPORT_SYMBOL(dma_sync_single); 665EXPORT_SYMBOL(dma_sync_single_for_cpu);
666EXPORT_SYMBOL(dma_sync_single_for_device);
666EXPORT_SYMBOL(dma_sync_sg); 667EXPORT_SYMBOL(dma_sync_sg);
667EXPORT_SYMBOL(dmabounce_register_dev); 668EXPORT_SYMBOL(dmabounce_register_dev);
668EXPORT_SYMBOL(dmabounce_unregister_dev); 669EXPORT_SYMBOL(dmabounce_unregister_dev);
diff --git a/arch/arm/configs/at91rm9200dk_defconfig b/arch/arm/configs/at91rm9200dk_defconfig
index c82e4667f45e..b43041476e02 100644
--- a/arch/arm/configs/at91rm9200dk_defconfig
+++ b/arch/arm/configs/at91rm9200dk_defconfig
@@ -577,7 +577,7 @@ CONFIG_WATCHDOG_NOWAYOUT=y
577# Watchdog Device Drivers 577# Watchdog Device Drivers
578# 578#
579# CONFIG_SOFT_WATCHDOG is not set 579# CONFIG_SOFT_WATCHDOG is not set
580CONFIG_AT91_WATCHDOG=y 580CONFIG_AT91RM9200_WATCHDOG=y
581 581
582# 582#
583# USB-based Watchdog Cards 583# USB-based Watchdog Cards
diff --git a/arch/arm/configs/at91rm9200ek_defconfig b/arch/arm/configs/at91rm9200ek_defconfig
index b983fc59aa42..d96fc8386e2f 100644
--- a/arch/arm/configs/at91rm9200ek_defconfig
+++ b/arch/arm/configs/at91rm9200ek_defconfig
@@ -558,7 +558,7 @@ CONFIG_WATCHDOG_NOWAYOUT=y
558# Watchdog Device Drivers 558# Watchdog Device Drivers
559# 559#
560# CONFIG_SOFT_WATCHDOG is not set 560# CONFIG_SOFT_WATCHDOG is not set
561CONFIG_AT91_WATCHDOG=y 561CONFIG_AT91RM9200_WATCHDOG=y
562 562
563# 563#
564# USB-based Watchdog Cards 564# USB-based Watchdog Cards
diff --git a/arch/arm/configs/ateb9200_defconfig b/arch/arm/configs/ateb9200_defconfig
index 15e6b0bbbde8..3de5c643848c 100644
--- a/arch/arm/configs/ateb9200_defconfig
+++ b/arch/arm/configs/ateb9200_defconfig
@@ -217,7 +217,7 @@ CONFIG_BINFMT_ELF=y
217# Power management options 217# Power management options
218# 218#
219CONFIG_PM=y 219CONFIG_PM=y
220CONFIG_PM_LEGACY=y 220# CONFIG_PM_LEGACY is not set
221# CONFIG_PM_DEBUG is not set 221# CONFIG_PM_DEBUG is not set
222# CONFIG_APM is not set 222# CONFIG_APM is not set
223 223
diff --git a/arch/arm/configs/collie_defconfig b/arch/arm/configs/collie_defconfig
index 074c47a4fb2e..a3758913c0bb 100644
--- a/arch/arm/configs/collie_defconfig
+++ b/arch/arm/configs/collie_defconfig
@@ -219,7 +219,7 @@ CONFIG_BINFMT_ELF=y
219# Power management options 219# Power management options
220# 220#
221CONFIG_PM=y 221CONFIG_PM=y
222CONFIG_PM_LEGACY=y 222# CONFIG_PM_LEGACY is not set
223# CONFIG_PM_DEBUG is not set 223# CONFIG_PM_DEBUG is not set
224CONFIG_APM=y 224CONFIG_APM=y
225 225
diff --git a/arch/arm/configs/csb337_defconfig b/arch/arm/configs/csb337_defconfig
index a2d6fd398f16..20e68250d835 100644
--- a/arch/arm/configs/csb337_defconfig
+++ b/arch/arm/configs/csb337_defconfig
@@ -615,7 +615,7 @@ CONFIG_WATCHDOG_NOWAYOUT=y
615# Watchdog Device Drivers 615# Watchdog Device Drivers
616# 616#
617# CONFIG_SOFT_WATCHDOG is not set 617# CONFIG_SOFT_WATCHDOG is not set
618CONFIG_AT91_WATCHDOG=y 618CONFIG_AT91RM9200_WATCHDOG=y
619 619
620# 620#
621# USB-based Watchdog Cards 621# USB-based Watchdog Cards
diff --git a/arch/arm/configs/csb637_defconfig b/arch/arm/configs/csb637_defconfig
index 2a1ac6c60abc..df8595ac031f 100644
--- a/arch/arm/configs/csb637_defconfig
+++ b/arch/arm/configs/csb637_defconfig
@@ -615,7 +615,7 @@ CONFIG_WATCHDOG_NOWAYOUT=y
615# Watchdog Device Drivers 615# Watchdog Device Drivers
616# 616#
617# CONFIG_SOFT_WATCHDOG is not set 617# CONFIG_SOFT_WATCHDOG is not set
618CONFIG_AT91_WATCHDOG=y 618CONFIG_AT91RM9200_WATCHDOG=y
619 619
620# 620#
621# USB-based Watchdog Cards 621# USB-based Watchdog Cards
diff --git a/arch/arm/configs/ixp4xx_defconfig b/arch/arm/configs/ixp4xx_defconfig
index 4975b914f923..fac7c3b240c0 100644
--- a/arch/arm/configs/ixp4xx_defconfig
+++ b/arch/arm/configs/ixp4xx_defconfig
@@ -206,10 +206,8 @@ CONFIG_BINFMT_ELF=y
206# 206#
207# Power management options 207# Power management options
208# 208#
209CONFIG_PM=y 209# CONFIG_PM is not set
210CONFIG_PM_LEGACY=y 210# CONFIG_APM is not set
211# CONFIG_PM_DEBUG is not set
212CONFIG_APM=y
213 211
214# 212#
215# Networking 213# Networking
diff --git a/arch/arm/configs/kafa_defconfig b/arch/arm/configs/kafa_defconfig
index 54fcd75779da..a4cdafc1548a 100644
--- a/arch/arm/configs/kafa_defconfig
+++ b/arch/arm/configs/kafa_defconfig
@@ -560,7 +560,7 @@ CONFIG_WATCHDOG_NOWAYOUT=y
560# Watchdog Device Drivers 560# Watchdog Device Drivers
561# 561#
562# CONFIG_SOFT_WATCHDOG is not set 562# CONFIG_SOFT_WATCHDOG is not set
563CONFIG_AT91_WATCHDOG=y 563CONFIG_AT91RM9200_WATCHDOG=y
564# CONFIG_NVRAM is not set 564# CONFIG_NVRAM is not set
565# CONFIG_DTLK is not set 565# CONFIG_DTLK is not set
566# CONFIG_R3964 is not set 566# CONFIG_R3964 is not set
diff --git a/arch/arm/configs/omap_h2_1610_defconfig b/arch/arm/configs/omap_h2_1610_defconfig
index 05adb0b34e72..b0efd4ca9935 100644
--- a/arch/arm/configs/omap_h2_1610_defconfig
+++ b/arch/arm/configs/omap_h2_1610_defconfig
@@ -257,7 +257,7 @@ CONFIG_BINFMT_AOUT=y
257# Power management options 257# Power management options
258# 258#
259CONFIG_PM=y 259CONFIG_PM=y
260CONFIG_PM_LEGACY=y 260# CONFIG_PM_LEGACY is not set
261# CONFIG_PM_DEBUG is not set 261# CONFIG_PM_DEBUG is not set
262# CONFIG_APM is not set 262# CONFIG_APM is not set
263 263
diff --git a/arch/arm/configs/onearm_defconfig b/arch/arm/configs/onearm_defconfig
index cb1d94f9049e..9b9f2155af35 100644
--- a/arch/arm/configs/onearm_defconfig
+++ b/arch/arm/configs/onearm_defconfig
@@ -607,7 +607,7 @@ CONFIG_WATCHDOG_NOWAYOUT=y
607# Watchdog Device Drivers 607# Watchdog Device Drivers
608# 608#
609# CONFIG_SOFT_WATCHDOG is not set 609# CONFIG_SOFT_WATCHDOG is not set
610CONFIG_AT91_WATCHDOG=y 610CONFIG_AT91RM9200_WATCHDOG=y
611 611
612# 612#
613# USB-based Watchdog Cards 613# USB-based Watchdog Cards
diff --git a/arch/arm/configs/bast_defconfig b/arch/arm/configs/realview-smp_defconfig
index 4a8564f386af..ffd905ff19f1 100644
--- a/arch/arm/configs/bast_defconfig
+++ b/arch/arm/configs/realview-smp_defconfig
@@ -1,136 +1,168 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.12-rc1-bk2 3# Linux kernel version: 2.6.19-rc3
4# Sun Mar 27 02:24:16 2005 4# Wed Oct 25 14:12:00 2006
5# 5#
6CONFIG_ARM=y 6CONFIG_ARM=y
7# CONFIG_GENERIC_TIME is not set
7CONFIG_MMU=y 8CONFIG_MMU=y
8CONFIG_UID16=y 9CONFIG_GENERIC_HARDIRQS=y
10CONFIG_TRACE_IRQFLAGS_SUPPORT=y
11CONFIG_HARDIRQS_SW_RESEND=y
12CONFIG_GENERIC_IRQ_PROBE=y
9CONFIG_RWSEM_GENERIC_SPINLOCK=y 13CONFIG_RWSEM_GENERIC_SPINLOCK=y
14CONFIG_GENERIC_HWEIGHT=y
10CONFIG_GENERIC_CALIBRATE_DELAY=y 15CONFIG_GENERIC_CALIBRATE_DELAY=y
11CONFIG_GENERIC_IOMAP=y 16CONFIG_VECTORS_BASE=0xffff0000
17CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
12 18
13# 19#
14# Code maturity level options 20# Code maturity level options
15# 21#
16CONFIG_EXPERIMENTAL=y 22CONFIG_EXPERIMENTAL=y
17CONFIG_CLEAN_COMPILE=y 23CONFIG_LOCK_KERNEL=y
18CONFIG_BROKEN_ON_SMP=y 24CONFIG_INIT_ENV_ARG_LIMIT=32
19 25
20# 26#
21# General setup 27# General setup
22# 28#
23CONFIG_LOCALVERSION="" 29CONFIG_LOCALVERSION=""
24CONFIG_SWAP=y 30CONFIG_LOCALVERSION_AUTO=y
31# CONFIG_SWAP is not set
25CONFIG_SYSVIPC=y 32CONFIG_SYSVIPC=y
33# CONFIG_IPC_NS is not set
26# CONFIG_POSIX_MQUEUE is not set 34# CONFIG_POSIX_MQUEUE is not set
27# CONFIG_BSD_PROCESS_ACCT is not set 35# CONFIG_BSD_PROCESS_ACCT is not set
28CONFIG_SYSCTL=y 36# CONFIG_TASKSTATS is not set
37# CONFIG_UTS_NS is not set
29# CONFIG_AUDIT is not set 38# CONFIG_AUDIT is not set
30# CONFIG_HOTPLUG is not set
31CONFIG_KOBJECT_UEVENT=y
32# CONFIG_IKCONFIG is not set 39# CONFIG_IKCONFIG is not set
40# CONFIG_CPUSETS is not set
41# CONFIG_RELAY is not set
42CONFIG_INITRAMFS_SOURCE=""
43CONFIG_CC_OPTIMIZE_FOR_SIZE=y
44CONFIG_SYSCTL=y
33# CONFIG_EMBEDDED is not set 45# CONFIG_EMBEDDED is not set
46CONFIG_UID16=y
47# CONFIG_SYSCTL_SYSCALL is not set
34CONFIG_KALLSYMS=y 48CONFIG_KALLSYMS=y
35# CONFIG_KALLSYMS_ALL is not set 49CONFIG_KALLSYMS_ALL=y
36# CONFIG_KALLSYMS_EXTRA_PASS is not set 50# CONFIG_KALLSYMS_EXTRA_PASS is not set
51CONFIG_HOTPLUG=y
52CONFIG_PRINTK=y
53CONFIG_BUG=y
54CONFIG_ELF_CORE=y
37CONFIG_BASE_FULL=y 55CONFIG_BASE_FULL=y
38CONFIG_FUTEX=y 56CONFIG_FUTEX=y
39CONFIG_EPOLL=y 57CONFIG_EPOLL=y
40CONFIG_CC_OPTIMIZE_FOR_SIZE=y
41CONFIG_SHMEM=y 58CONFIG_SHMEM=y
42CONFIG_CC_ALIGN_FUNCTIONS=0 59CONFIG_SLAB=y
43CONFIG_CC_ALIGN_LABELS=0 60CONFIG_VM_EVENT_COUNTERS=y
44CONFIG_CC_ALIGN_LOOPS=0 61CONFIG_RT_MUTEXES=y
45CONFIG_CC_ALIGN_JUMPS=0
46# CONFIG_TINY_SHMEM is not set 62# CONFIG_TINY_SHMEM is not set
47CONFIG_BASE_SMALL=0 63CONFIG_BASE_SMALL=0
64# CONFIG_SLOB is not set
48 65
49# 66#
50# Loadable module support 67# Loadable module support
51# 68#
52CONFIG_MODULES=y 69CONFIG_MODULES=y
53# CONFIG_MODULE_UNLOAD is not set 70CONFIG_MODULE_UNLOAD=y
54CONFIG_OBSOLETE_MODPARM=y 71# CONFIG_MODULE_FORCE_UNLOAD is not set
55# CONFIG_MODVERSIONS is not set 72# CONFIG_MODVERSIONS is not set
56# CONFIG_MODULE_SRCVERSION_ALL is not set 73# CONFIG_MODULE_SRCVERSION_ALL is not set
57CONFIG_KMOD=y 74# CONFIG_KMOD is not set
75CONFIG_STOP_MACHINE=y
76
77#
78# Block layer
79#
80CONFIG_BLOCK=y
81# CONFIG_BLK_DEV_IO_TRACE is not set
82
83#
84# IO Schedulers
85#
86CONFIG_IOSCHED_NOOP=y
87# CONFIG_IOSCHED_AS is not set
88CONFIG_IOSCHED_DEADLINE=y
89# CONFIG_IOSCHED_CFQ is not set
90# CONFIG_DEFAULT_AS is not set
91CONFIG_DEFAULT_DEADLINE=y
92# CONFIG_DEFAULT_CFQ is not set
93# CONFIG_DEFAULT_NOOP is not set
94CONFIG_DEFAULT_IOSCHED="deadline"
58 95
59# 96#
60# System Type 97# System Type
61# 98#
99# CONFIG_ARCH_AAEC2000 is not set
100# CONFIG_ARCH_INTEGRATOR is not set
101CONFIG_ARCH_REALVIEW=y
102# CONFIG_ARCH_VERSATILE is not set
103# CONFIG_ARCH_AT91 is not set
62# CONFIG_ARCH_CLPS7500 is not set 104# CONFIG_ARCH_CLPS7500 is not set
63# CONFIG_ARCH_CLPS711X is not set 105# CONFIG_ARCH_CLPS711X is not set
64# CONFIG_ARCH_CO285 is not set 106# CONFIG_ARCH_CO285 is not set
65# CONFIG_ARCH_EBSA110 is not set 107# CONFIG_ARCH_EBSA110 is not set
108# CONFIG_ARCH_EP93XX is not set
66# CONFIG_ARCH_FOOTBRIDGE is not set 109# CONFIG_ARCH_FOOTBRIDGE is not set
67# CONFIG_ARCH_INTEGRATOR is not set 110# CONFIG_ARCH_NETX is not set
68# CONFIG_ARCH_IOP3XX is not set 111# CONFIG_ARCH_H720X is not set
112# CONFIG_ARCH_IMX is not set
113# CONFIG_ARCH_IOP32X is not set
114# CONFIG_ARCH_IOP33X is not set
69# CONFIG_ARCH_IXP4XX is not set 115# CONFIG_ARCH_IXP4XX is not set
70# CONFIG_ARCH_IXP2000 is not set 116# CONFIG_ARCH_IXP2000 is not set
117# CONFIG_ARCH_IXP23XX is not set
71# CONFIG_ARCH_L7200 is not set 118# CONFIG_ARCH_L7200 is not set
119# CONFIG_ARCH_PNX4008 is not set
72# CONFIG_ARCH_PXA is not set 120# CONFIG_ARCH_PXA is not set
73# CONFIG_ARCH_RPC is not set 121# CONFIG_ARCH_RPC is not set
74# CONFIG_ARCH_SA1100 is not set 122# CONFIG_ARCH_SA1100 is not set
75CONFIG_ARCH_S3C2410=y 123# CONFIG_ARCH_S3C2410 is not set
76# CONFIG_ARCH_SHARK is not set 124# CONFIG_ARCH_SHARK is not set
77# CONFIG_ARCH_LH7A40X is not set 125# CONFIG_ARCH_LH7A40X is not set
78# CONFIG_ARCH_OMAP is not set 126# CONFIG_ARCH_OMAP is not set
79# CONFIG_ARCH_VERSATILE is not set
80# CONFIG_ARCH_IMX is not set
81# CONFIG_ARCH_H720X is not set
82
83#
84# S3C24XX Implementations
85#
86CONFIG_ARCH_BAST=y
87# CONFIG_ARCH_H1940 is not set
88# CONFIG_MACH_N30 is not set
89# CONFIG_ARCH_SMDK2410 is not set
90# CONFIG_ARCH_S3C2440 is not set
91CONFIG_MACH_VR1000=y
92# CONFIG_MACH_RX3715 is not set
93# CONFIG_MACH_OTOM is not set
94# CONFIG_MACH_NEXCODER_2440 is not set
95CONFIG_CPU_S3C2410=y
96
97#
98# S3C2410 Boot
99#
100# CONFIG_S3C2410_BOOT_WATCHDOG is not set
101 127
102# 128#
103# S3C2410 Setup 129# RealView platform type
104# 130#
105CONFIG_S3C2410_DMA=y 131CONFIG_MACH_REALVIEW_EB=y
106# CONFIG_S3C2410_DMA_DEBUG is not set 132CONFIG_REALVIEW_MPCORE=y
107# CONFIG_S3C2410_PM_DEBUG is not set
108# CONFIG_S3C2410_PM_CHECK is not set
109CONFIG_S3C2410_LOWLEVEL_UART_PORT=0
110 133
111# 134#
112# Processor Type 135# Processor Type
113# 136#
114CONFIG_CPU_32=y 137CONFIG_CPU_32=y
115CONFIG_CPU_ARM920T=y 138# CONFIG_CPU_ARM926T is not set
116CONFIG_CPU_32v4=y 139CONFIG_CPU_V6=y
117CONFIG_CPU_ABRT_EV4T=y 140CONFIG_CPU_32v6K=y
118CONFIG_CPU_CACHE_V4WT=y 141CONFIG_CPU_32v6=y
119CONFIG_CPU_CACHE_VIVT=y 142CONFIG_CPU_ABRT_EV6=y
120CONFIG_CPU_COPY_V4WB=y 143CONFIG_CPU_CACHE_V6=y
121CONFIG_CPU_TLB_V4WBI=y 144CONFIG_CPU_CACHE_VIPT=y
145CONFIG_CPU_COPY_V6=y
146CONFIG_CPU_TLB_V6=y
147CONFIG_CPU_CP15=y
148CONFIG_CPU_CP15_MMU=y
122 149
123# 150#
124# Processor Features 151# Processor Features
125# 152#
126# CONFIG_ARM_THUMB is not set 153CONFIG_ARM_THUMB=y
127# CONFIG_CPU_ICACHE_DISABLE is not set 154# CONFIG_CPU_ICACHE_DISABLE is not set
128# CONFIG_CPU_DCACHE_DISABLE is not set 155# CONFIG_CPU_DCACHE_DISABLE is not set
129# CONFIG_CPU_DCACHE_WRITETHROUGH is not set 156# CONFIG_CPU_DCACHE_WRITETHROUGH is not set
157# CONFIG_CPU_BPREDICT_DISABLE is not set
158CONFIG_HAS_TLS_REG=y
159CONFIG_ARM_GIC=y
160CONFIG_ICST307=y
130 161
131# 162#
132# Bus support 163# Bus support
133# 164#
165CONFIG_ARM_AMBA=y
134 166
135# 167#
136# PCCARD (PCMCIA/CardBus) support 168# PCCARD (PCMCIA/CardBus) support
@@ -140,7 +172,24 @@ CONFIG_CPU_TLB_V4WBI=y
140# 172#
141# Kernel Features 173# Kernel Features
142# 174#
175CONFIG_SMP=y
176CONFIG_NR_CPUS=4
177CONFIG_HOTPLUG_CPU=y
178CONFIG_LOCAL_TIMERS=y
143# CONFIG_PREEMPT is not set 179# CONFIG_PREEMPT is not set
180# CONFIG_NO_IDLE_HZ is not set
181CONFIG_HZ=100
182# CONFIG_AEABI is not set
183# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
184CONFIG_SELECT_MEMORY_MODEL=y
185CONFIG_FLATMEM_MANUAL=y
186# CONFIG_DISCONTIGMEM_MANUAL is not set
187# CONFIG_SPARSEMEM_MANUAL is not set
188CONFIG_FLATMEM=y
189CONFIG_FLAT_NODE_MEM_MAP=y
190# CONFIG_SPARSEMEM_STATIC is not set
191CONFIG_SPLIT_PTLOCK_CPUS=4
192# CONFIG_RESOURCES_64BIT is not set
144CONFIG_ALIGNMENT_TRAP=y 193CONFIG_ALIGNMENT_TRAP=y
145 194
146# 195#
@@ -148,7 +197,7 @@ CONFIG_ALIGNMENT_TRAP=y
148# 197#
149CONFIG_ZBOOT_ROM_TEXT=0x0 198CONFIG_ZBOOT_ROM_TEXT=0x0
150CONFIG_ZBOOT_ROM_BSS=0x0 199CONFIG_ZBOOT_ROM_BSS=0x0
151CONFIG_CMDLINE="root=/dev/hda1 ro init=/bin/bash console=ttySAC0" 200CONFIG_CMDLINE="root=/dev/nfs nfsroot=10.1.69.3:/work/nfsroot ip=dhcp console=ttyAMA0 mem=128M"
152# CONFIG_XIP_KERNEL is not set 201# CONFIG_XIP_KERNEL is not set
153 202
154# 203#
@@ -161,20 +210,105 @@ CONFIG_CMDLINE="root=/dev/hda1 ro init=/bin/bash console=ttySAC0"
161CONFIG_FPE_NWFPE=y 210CONFIG_FPE_NWFPE=y
162# CONFIG_FPE_NWFPE_XP is not set 211# CONFIG_FPE_NWFPE_XP is not set
163# CONFIG_FPE_FASTFPE is not set 212# CONFIG_FPE_FASTFPE is not set
213CONFIG_VFP=y
164 214
165# 215#
166# Userspace binary formats 216# Userspace binary formats
167# 217#
168CONFIG_BINFMT_ELF=y 218CONFIG_BINFMT_ELF=y
169CONFIG_BINFMT_AOUT=y 219# CONFIG_BINFMT_AOUT is not set
170# CONFIG_BINFMT_MISC is not set 220# CONFIG_BINFMT_MISC is not set
171# CONFIG_ARTHUR is not set 221# CONFIG_ARTHUR is not set
172 222
173# 223#
174# Power management options 224# Power management options
175# 225#
176CONFIG_PM=y 226# CONFIG_PM is not set
177CONFIG_APM=y 227# CONFIG_APM is not set
228
229#
230# Networking
231#
232CONFIG_NET=y
233
234#
235# Networking options
236#
237# CONFIG_NETDEBUG is not set
238CONFIG_PACKET=y
239# CONFIG_PACKET_MMAP is not set
240CONFIG_UNIX=y
241# CONFIG_NET_KEY is not set
242CONFIG_INET=y
243# CONFIG_IP_MULTICAST is not set
244# CONFIG_IP_ADVANCED_ROUTER is not set
245CONFIG_IP_FIB_HASH=y
246CONFIG_IP_PNP=y
247CONFIG_IP_PNP_DHCP=y
248CONFIG_IP_PNP_BOOTP=y
249# CONFIG_IP_PNP_RARP is not set
250# CONFIG_NET_IPIP is not set
251# CONFIG_NET_IPGRE is not set
252# CONFIG_ARPD is not set
253# CONFIG_SYN_COOKIES is not set
254# CONFIG_INET_AH is not set
255# CONFIG_INET_ESP is not set
256# CONFIG_INET_IPCOMP is not set
257# CONFIG_INET_XFRM_TUNNEL is not set
258# CONFIG_INET_TUNNEL is not set
259# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
260# CONFIG_INET_XFRM_MODE_TUNNEL is not set
261# CONFIG_INET_XFRM_MODE_BEET is not set
262CONFIG_INET_DIAG=y
263CONFIG_INET_TCP_DIAG=y
264# CONFIG_TCP_CONG_ADVANCED is not set
265CONFIG_TCP_CONG_CUBIC=y
266CONFIG_DEFAULT_TCP_CONG="cubic"
267# CONFIG_IPV6 is not set
268# CONFIG_INET6_XFRM_TUNNEL is not set
269# CONFIG_INET6_TUNNEL is not set
270# CONFIG_NETWORK_SECMARK is not set
271# CONFIG_NETFILTER is not set
272
273#
274# DCCP Configuration (EXPERIMENTAL)
275#
276# CONFIG_IP_DCCP is not set
277
278#
279# SCTP Configuration (EXPERIMENTAL)
280#
281# CONFIG_IP_SCTP is not set
282
283#
284# TIPC Configuration (EXPERIMENTAL)
285#
286# CONFIG_TIPC is not set
287# CONFIG_ATM is not set
288# CONFIG_BRIDGE is not set
289# CONFIG_VLAN_8021Q is not set
290# CONFIG_DECNET is not set
291# CONFIG_LLC2 is not set
292# CONFIG_IPX is not set
293# CONFIG_ATALK is not set
294# CONFIG_X25 is not set
295# CONFIG_LAPB is not set
296# CONFIG_ECONET is not set
297# CONFIG_WAN_ROUTER is not set
298
299#
300# QoS and/or fair queueing
301#
302# CONFIG_NET_SCHED is not set
303
304#
305# Network testing
306#
307# CONFIG_NET_PKTGEN is not set
308# CONFIG_HAMRADIO is not set
309# CONFIG_IRDA is not set
310# CONFIG_BT is not set
311# CONFIG_IEEE80211 is not set
178 312
179# 313#
180# Device Drivers 314# Device Drivers
@@ -187,6 +321,12 @@ CONFIG_STANDALONE=y
187CONFIG_PREVENT_FIRMWARE_BUILD=y 321CONFIG_PREVENT_FIRMWARE_BUILD=y
188# CONFIG_FW_LOADER is not set 322# CONFIG_FW_LOADER is not set
189# CONFIG_DEBUG_DRIVER is not set 323# CONFIG_DEBUG_DRIVER is not set
324# CONFIG_SYS_HYPERVISOR is not set
325
326#
327# Connector - unified userspace <-> kernelspace linker
328#
329# CONFIG_CONNECTOR is not set
190 330
191# 331#
192# Memory Technology Devices (MTD) 332# Memory Technology Devices (MTD)
@@ -195,10 +335,7 @@ CONFIG_MTD=y
195# CONFIG_MTD_DEBUG is not set 335# CONFIG_MTD_DEBUG is not set
196# CONFIG_MTD_CONCAT is not set 336# CONFIG_MTD_CONCAT is not set
197CONFIG_MTD_PARTITIONS=y 337CONFIG_MTD_PARTITIONS=y
198CONFIG_MTD_REDBOOT_PARTS=y 338# CONFIG_MTD_REDBOOT_PARTS is not set
199CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
200CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED=y
201# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
202CONFIG_MTD_CMDLINE_PARTS=y 339CONFIG_MTD_CMDLINE_PARTS=y
203# CONFIG_MTD_AFS_PARTS is not set 340# CONFIG_MTD_AFS_PARTS is not set
204 341
@@ -210,44 +347,42 @@ CONFIG_MTD_BLOCK=y
210# CONFIG_FTL is not set 347# CONFIG_FTL is not set
211# CONFIG_NFTL is not set 348# CONFIG_NFTL is not set
212# CONFIG_INFTL is not set 349# CONFIG_INFTL is not set
350# CONFIG_RFD_FTL is not set
351# CONFIG_SSFDC is not set
213 352
214# 353#
215# RAM/ROM/Flash chip drivers 354# RAM/ROM/Flash chip drivers
216# 355#
217CONFIG_MTD_CFI=y 356CONFIG_MTD_CFI=y
218CONFIG_MTD_JEDECPROBE=y 357# CONFIG_MTD_JEDECPROBE is not set
219CONFIG_MTD_GEN_PROBE=y 358CONFIG_MTD_GEN_PROBE=y
220# CONFIG_MTD_CFI_ADV_OPTIONS is not set 359# CONFIG_MTD_CFI_ADV_OPTIONS is not set
221CONFIG_MTD_MAP_BANK_WIDTH_1=y 360CONFIG_MTD_MAP_BANK_WIDTH_1=y
222CONFIG_MTD_MAP_BANK_WIDTH_2=y 361CONFIG_MTD_MAP_BANK_WIDTH_2=y
223CONFIG_MTD_MAP_BANK_WIDTH_4=y 362CONFIG_MTD_MAP_BANK_WIDTH_4=y
224# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set 363# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
225CONFIG_MTD_MAP_BANK_WIDTH_16=y 364# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
226# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set 365# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
227CONFIG_MTD_CFI_I1=y 366CONFIG_MTD_CFI_I1=y
228CONFIG_MTD_CFI_I2=y 367CONFIG_MTD_CFI_I2=y
229# CONFIG_MTD_CFI_I4 is not set 368# CONFIG_MTD_CFI_I4 is not set
230# CONFIG_MTD_CFI_I8 is not set 369# CONFIG_MTD_CFI_I8 is not set
231CONFIG_MTD_CFI_INTELEXT=y 370CONFIG_MTD_CFI_INTELEXT=y
232# CONFIG_MTD_CFI_AMDSTD is not set 371CONFIG_MTD_CFI_AMDSTD=y
233# CONFIG_MTD_CFI_STAA is not set 372# CONFIG_MTD_CFI_STAA is not set
234CONFIG_MTD_CFI_UTIL=y 373CONFIG_MTD_CFI_UTIL=y
235# CONFIG_MTD_RAM is not set 374# CONFIG_MTD_RAM is not set
236# CONFIG_MTD_ROM is not set 375# CONFIG_MTD_ROM is not set
237# CONFIG_MTD_ABSENT is not set 376# CONFIG_MTD_ABSENT is not set
238# CONFIG_MTD_OBSOLETE_CHIPS is not set 377# CONFIG_MTD_OBSOLETE_CHIPS is not set
239# CONFIG_MTD_XIP is not set
240 378
241# 379#
242# Mapping drivers for chip access 380# Mapping drivers for chip access
243# 381#
244# CONFIG_MTD_COMPLEX_MAPPINGS is not set 382# CONFIG_MTD_COMPLEX_MAPPINGS is not set
245# CONFIG_MTD_PHYSMAP is not set 383# CONFIG_MTD_PHYSMAP is not set
246# CONFIG_MTD_ARM_INTEGRATOR is not set 384CONFIG_MTD_ARM_INTEGRATOR=y
247# CONFIG_MTD_EDB7312 is not set 385# CONFIG_MTD_PLATRAM is not set
248# CONFIG_MTD_IMPA7 is not set
249CONFIG_MTD_BAST=y
250CONFIG_MTD_BAST_MAXSIZE=4
251 386
252# 387#
253# Self-contained MTD device drivers 388# Self-contained MTD device drivers
@@ -255,7 +390,6 @@ CONFIG_MTD_BAST_MAXSIZE=4
255# CONFIG_MTD_SLRAM is not set 390# CONFIG_MTD_SLRAM is not set
256# CONFIG_MTD_PHRAM is not set 391# CONFIG_MTD_PHRAM is not set
257# CONFIG_MTD_MTDRAM is not set 392# CONFIG_MTD_MTDRAM is not set
258# CONFIG_MTD_BLKMTD is not set
259# CONFIG_MTD_BLOCK2MTD is not set 393# CONFIG_MTD_BLOCK2MTD is not set
260 394
261# 395#
@@ -268,23 +402,17 @@ CONFIG_MTD_BAST_MAXSIZE=4
268# 402#
269# NAND Flash Device Drivers 403# NAND Flash Device Drivers
270# 404#
271CONFIG_MTD_NAND=y 405# CONFIG_MTD_NAND is not set
272# CONFIG_MTD_NAND_VERIFY_WRITE is not set 406
273CONFIG_MTD_NAND_IDS=y 407#
274CONFIG_MTD_NAND_S3C2410=y 408# OneNAND Flash Device Drivers
275# CONFIG_MTD_NAND_S3C2410_DEBUG is not set 409#
276# CONFIG_MTD_NAND_S3C2410_HWECC is not set 410# CONFIG_MTD_ONENAND is not set
277# CONFIG_MTD_NAND_DISKONCHIP is not set
278# CONFIG_MTD_NAND_NANDSIM is not set
279 411
280# 412#
281# Parallel port support 413# Parallel port support
282# 414#
283CONFIG_PARPORT=y 415# CONFIG_PARPORT is not set
284# CONFIG_PARPORT_PC is not set
285# CONFIG_PARPORT_ARC is not set
286# CONFIG_PARPORT_GSC is not set
287CONFIG_PARPORT_1284=y
288 416
289# 417#
290# Plug and Play support 418# Plug and Play support
@@ -293,59 +421,20 @@ CONFIG_PARPORT_1284=y
293# 421#
294# Block devices 422# Block devices
295# 423#
296# CONFIG_BLK_DEV_FD is not set
297# CONFIG_PARIDE is not set
298# CONFIG_BLK_DEV_COW_COMMON is not set 424# CONFIG_BLK_DEV_COW_COMMON is not set
299CONFIG_BLK_DEV_LOOP=y 425# CONFIG_BLK_DEV_LOOP is not set
300# CONFIG_BLK_DEV_CRYPTOLOOP is not set 426# CONFIG_BLK_DEV_NBD is not set
301CONFIG_BLK_DEV_NBD=m 427# CONFIG_BLK_DEV_RAM is not set
302CONFIG_BLK_DEV_RAM=y
303CONFIG_BLK_DEV_RAM_COUNT=16
304CONFIG_BLK_DEV_RAM_SIZE=4096
305CONFIG_BLK_DEV_INITRD=y 428CONFIG_BLK_DEV_INITRD=y
306CONFIG_INITRAMFS_SOURCE=""
307# CONFIG_CDROM_PKTCDVD is not set 429# CONFIG_CDROM_PKTCDVD is not set
308
309#
310# IO Schedulers
311#
312CONFIG_IOSCHED_NOOP=y
313CONFIG_IOSCHED_AS=y
314CONFIG_IOSCHED_DEADLINE=y
315CONFIG_IOSCHED_CFQ=y
316# CONFIG_ATA_OVER_ETH is not set 430# CONFIG_ATA_OVER_ETH is not set
317 431
318# 432#
319# ATA/ATAPI/MFM/RLL support
320#
321CONFIG_IDE=y
322CONFIG_BLK_DEV_IDE=y
323
324#
325# Please see Documentation/ide.txt for help/info on IDE drives
326#
327# CONFIG_BLK_DEV_IDE_SATA is not set
328CONFIG_BLK_DEV_IDEDISK=y
329# CONFIG_IDEDISK_MULTI_MODE is not set
330CONFIG_BLK_DEV_IDECD=y
331CONFIG_BLK_DEV_IDETAPE=m
332CONFIG_BLK_DEV_IDEFLOPPY=m
333# CONFIG_IDE_TASK_IOCTL is not set
334
335#
336# IDE chipset support/bugfixes
337#
338CONFIG_IDE_GENERIC=y
339# CONFIG_IDE_ARM is not set
340CONFIG_BLK_DEV_IDE_BAST=y
341# CONFIG_BLK_DEV_IDEDMA is not set
342# CONFIG_IDEDMA_AUTO is not set
343# CONFIG_BLK_DEV_HD is not set
344
345#
346# SCSI device support 433# SCSI device support
347# 434#
435# CONFIG_RAID_ATTRS is not set
348# CONFIG_SCSI is not set 436# CONFIG_SCSI is not set
437# CONFIG_SCSI_NETLINK is not set
349 438
350# 439#
351# Multi-device support (RAID and LVM) 440# Multi-device support (RAID and LVM)
@@ -355,6 +444,7 @@ CONFIG_BLK_DEV_IDE_BAST=y
355# 444#
356# Fusion MPT device support 445# Fusion MPT device support
357# 446#
447# CONFIG_FUSION is not set
358 448
359# 449#
360# IEEE 1394 (FireWire) support 450# IEEE 1394 (FireWire) support
@@ -365,69 +455,8 @@ CONFIG_BLK_DEV_IDE_BAST=y
365# 455#
366 456
367# 457#
368# Networking support 458# Network device support
369#
370CONFIG_NET=y
371
372#
373# Networking options
374#
375# CONFIG_PACKET is not set
376# CONFIG_NETLINK_DEV is not set
377CONFIG_UNIX=y
378# CONFIG_NET_KEY is not set
379CONFIG_INET=y
380# CONFIG_IP_MULTICAST is not set
381# CONFIG_IP_ADVANCED_ROUTER is not set
382CONFIG_IP_PNP=y
383# CONFIG_IP_PNP_DHCP is not set
384CONFIG_IP_PNP_BOOTP=y
385# CONFIG_IP_PNP_RARP is not set
386# CONFIG_NET_IPIP is not set
387# CONFIG_NET_IPGRE is not set
388# CONFIG_ARPD is not set
389# CONFIG_SYN_COOKIES is not set
390# CONFIG_INET_AH is not set
391# CONFIG_INET_ESP is not set
392# CONFIG_INET_IPCOMP is not set
393# CONFIG_INET_TUNNEL is not set
394CONFIG_IP_TCPDIAG=y
395# CONFIG_IP_TCPDIAG_IPV6 is not set
396# CONFIG_IPV6 is not set
397# CONFIG_NETFILTER is not set
398
399#
400# SCTP Configuration (EXPERIMENTAL)
401#
402# CONFIG_IP_SCTP is not set
403# CONFIG_ATM is not set
404# CONFIG_BRIDGE is not set
405# CONFIG_VLAN_8021Q is not set
406# CONFIG_DECNET is not set
407# CONFIG_LLC2 is not set
408# CONFIG_IPX is not set
409# CONFIG_ATALK is not set
410# CONFIG_X25 is not set
411# CONFIG_LAPB is not set
412# CONFIG_NET_DIVERT is not set
413# CONFIG_ECONET is not set
414# CONFIG_WAN_ROUTER is not set
415
416#
417# QoS and/or fair queueing
418#
419# CONFIG_NET_SCHED is not set
420# CONFIG_NET_CLS_ROUTE is not set
421
422#
423# Network testing
424# 459#
425# CONFIG_NET_PKTGEN is not set
426# CONFIG_NETPOLL is not set
427# CONFIG_NET_POLL_CONTROLLER is not set
428# CONFIG_HAMRADIO is not set
429# CONFIG_IRDA is not set
430# CONFIG_BT is not set
431CONFIG_NETDEVICES=y 460CONFIG_NETDEVICES=y
432# CONFIG_DUMMY is not set 461# CONFIG_DUMMY is not set
433# CONFIG_BONDING is not set 462# CONFIG_BONDING is not set
@@ -435,11 +464,17 @@ CONFIG_NETDEVICES=y
435# CONFIG_TUN is not set 464# CONFIG_TUN is not set
436 465
437# 466#
467# PHY device support
468#
469# CONFIG_PHYLIB is not set
470
471#
438# Ethernet (10 or 100Mbit) 472# Ethernet (10 or 100Mbit)
439# 473#
440CONFIG_NET_ETHERNET=y 474CONFIG_NET_ETHERNET=y
441# CONFIG_MII is not set 475CONFIG_MII=y
442# CONFIG_SMC91X is not set 476CONFIG_SMC91X=y
477# CONFIG_DM9000 is not set
443 478
444# 479#
445# Ethernet (1000 Mbit) 480# Ethernet (1000 Mbit)
@@ -462,11 +497,12 @@ CONFIG_NET_ETHERNET=y
462# Wan interfaces 497# Wan interfaces
463# 498#
464# CONFIG_WAN is not set 499# CONFIG_WAN is not set
465# CONFIG_PLIP is not set
466# CONFIG_PPP is not set 500# CONFIG_PPP is not set
467# CONFIG_SLIP is not set 501# CONFIG_SLIP is not set
468# CONFIG_SHAPER is not set 502# CONFIG_SHAPER is not set
469# CONFIG_NETCONSOLE is not set 503# CONFIG_NETCONSOLE is not set
504# CONFIG_NETPOLL is not set
505# CONFIG_NET_POLL_CONTROLLER is not set
470 506
471# 507#
472# ISDN subsystem 508# ISDN subsystem
@@ -477,6 +513,7 @@ CONFIG_NET_ETHERNET=y
477# Input device support 513# Input device support
478# 514#
479CONFIG_INPUT=y 515CONFIG_INPUT=y
516# CONFIG_INPUT_FF_MEMLESS is not set
480 517
481# 518#
482# Userland interfaces 519# Userland interfaces
@@ -499,6 +536,7 @@ CONFIG_KEYBOARD_ATKBD=y
499# CONFIG_KEYBOARD_LKKBD is not set 536# CONFIG_KEYBOARD_LKKBD is not set
500# CONFIG_KEYBOARD_XTKBD is not set 537# CONFIG_KEYBOARD_XTKBD is not set
501# CONFIG_KEYBOARD_NEWTON is not set 538# CONFIG_KEYBOARD_NEWTON is not set
539# CONFIG_KEYBOARD_STOWAWAY is not set
502CONFIG_INPUT_MOUSE=y 540CONFIG_INPUT_MOUSE=y
503CONFIG_MOUSE_PS2=y 541CONFIG_MOUSE_PS2=y
504# CONFIG_MOUSE_SERIAL is not set 542# CONFIG_MOUSE_SERIAL is not set
@@ -511,12 +549,11 @@ CONFIG_MOUSE_PS2=y
511# Hardware I/O ports 549# Hardware I/O ports
512# 550#
513CONFIG_SERIO=y 551CONFIG_SERIO=y
514CONFIG_SERIO_SERPORT=y 552# CONFIG_SERIO_SERPORT is not set
515# CONFIG_SERIO_PARKBD is not set 553CONFIG_SERIO_AMBAKMI=y
516CONFIG_SERIO_LIBPS2=y 554CONFIG_SERIO_LIBPS2=y
517# CONFIG_SERIO_RAW is not set 555# CONFIG_SERIO_RAW is not set
518# CONFIG_GAMEPORT is not set 556# CONFIG_GAMEPORT is not set
519CONFIG_SOUND_GAMEPORT=y
520 557
521# 558#
522# Character devices 559# Character devices
@@ -524,49 +561,25 @@ CONFIG_SOUND_GAMEPORT=y
524CONFIG_VT=y 561CONFIG_VT=y
525CONFIG_VT_CONSOLE=y 562CONFIG_VT_CONSOLE=y
526CONFIG_HW_CONSOLE=y 563CONFIG_HW_CONSOLE=y
527CONFIG_SERIAL_NONSTANDARD=y 564# CONFIG_VT_HW_CONSOLE_BINDING is not set
528# CONFIG_COMPUTONE is not set 565# CONFIG_SERIAL_NONSTANDARD is not set
529# CONFIG_ROCKETPORT is not set
530# CONFIG_CYCLADES is not set
531# CONFIG_DIGIEPCA is not set
532# CONFIG_MOXA_INTELLIO is not set
533# CONFIG_MOXA_SMARTIO is not set
534# CONFIG_ISI is not set
535# CONFIG_SYNCLINKMP is not set
536# CONFIG_N_HDLC is not set
537# CONFIG_RISCOM8 is not set
538# CONFIG_SPECIALIX is not set
539# CONFIG_SX is not set
540# CONFIG_RIO is not set
541# CONFIG_STALDRV is not set
542 566
543# 567#
544# Serial drivers 568# Serial drivers
545# 569#
546CONFIG_SERIAL_8250=y 570# CONFIG_SERIAL_8250 is not set
547CONFIG_SERIAL_8250_CONSOLE=y
548CONFIG_SERIAL_8250_NR_UARTS=8
549CONFIG_SERIAL_8250_EXTENDED=y
550CONFIG_SERIAL_8250_MANY_PORTS=y
551CONFIG_SERIAL_8250_SHARE_IRQ=y
552# CONFIG_SERIAL_8250_DETECT_IRQ is not set
553# CONFIG_SERIAL_8250_MULTIPORT is not set
554# CONFIG_SERIAL_8250_RSA is not set
555 571
556# 572#
557# Non-8250 serial port support 573# Non-8250 serial port support
558# 574#
559CONFIG_SERIAL_S3C2410=y 575# CONFIG_SERIAL_AMBA_PL010 is not set
560CONFIG_SERIAL_S3C2410_CONSOLE=y 576CONFIG_SERIAL_AMBA_PL011=y
577CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
561CONFIG_SERIAL_CORE=y 578CONFIG_SERIAL_CORE=y
562CONFIG_SERIAL_CORE_CONSOLE=y 579CONFIG_SERIAL_CORE_CONSOLE=y
563CONFIG_UNIX98_PTYS=y 580CONFIG_UNIX98_PTYS=y
564CONFIG_LEGACY_PTYS=y 581CONFIG_LEGACY_PTYS=y
565CONFIG_LEGACY_PTY_COUNT=256 582CONFIG_LEGACY_PTY_COUNT=16
566CONFIG_PRINTER=y
567# CONFIG_LP_CONSOLE is not set
568CONFIG_PPDEV=y
569# CONFIG_TIPAR is not set
570 583
571# 584#
572# IPMI 585# IPMI
@@ -576,24 +589,15 @@ CONFIG_PPDEV=y
576# 589#
577# Watchdog Cards 590# Watchdog Cards
578# 591#
579CONFIG_WATCHDOG=y 592# CONFIG_WATCHDOG is not set
580# CONFIG_WATCHDOG_NOWAYOUT is not set 593# CONFIG_HW_RANDOM is not set
581
582#
583# Watchdog Device Drivers
584#
585# CONFIG_SOFT_WATCHDOG is not set
586CONFIG_S3C2410_WATCHDOG=y
587# CONFIG_NVRAM is not set 594# CONFIG_NVRAM is not set
588# CONFIG_RTC is not set
589CONFIG_S3C2410_RTC=y
590# CONFIG_DTLK is not set 595# CONFIG_DTLK is not set
591# CONFIG_R3964 is not set 596# CONFIG_R3964 is not set
592 597
593# 598#
594# Ftape, the floppy tape device driver 599# Ftape, the floppy tape device driver
595# 600#
596# CONFIG_DRM is not set
597# CONFIG_RAW_DRIVER is not set 601# CONFIG_RAW_DRIVER is not set
598 602
599# 603#
@@ -604,73 +608,43 @@ CONFIG_S3C2410_RTC=y
604# 608#
605# I2C support 609# I2C support
606# 610#
607CONFIG_I2C=y 611# CONFIG_I2C is not set
608CONFIG_I2C_CHARDEV=m 612
609 613#
610# 614# SPI support
611# I2C Algorithms 615#
612# 616# CONFIG_SPI is not set
613CONFIG_I2C_ALGOBIT=m 617# CONFIG_SPI_MASTER is not set
614# CONFIG_I2C_ALGOPCF is not set 618
615# CONFIG_I2C_ALGOPCA is not set 619#
616 620# Dallas's 1-wire bus
617# 621#
618# I2C Hardware Bus support 622# CONFIG_W1 is not set
619# 623
620# CONFIG_I2C_ISA is not set 624#
621# CONFIG_I2C_PARPORT is not set 625# Hardware Monitoring support
622# CONFIG_I2C_PARPORT_LIGHT is not set 626#
623CONFIG_I2C_S3C2410=y 627# CONFIG_HWMON is not set
624# CONFIG_I2C_STUB is not set 628# CONFIG_HWMON_VID is not set
625# CONFIG_I2C_PCA_ISA is not set
626
627#
628# Hardware Sensors Chip support
629#
630CONFIG_I2C_SENSOR=m
631# CONFIG_SENSORS_ADM1021 is not set
632# CONFIG_SENSORS_ADM1025 is not set
633# CONFIG_SENSORS_ADM1026 is not set
634# CONFIG_SENSORS_ADM1031 is not set
635# CONFIG_SENSORS_ASB100 is not set
636# CONFIG_SENSORS_DS1621 is not set
637# CONFIG_SENSORS_FSCHER is not set
638# CONFIG_SENSORS_FSCPOS is not set
639# CONFIG_SENSORS_GL518SM is not set
640# CONFIG_SENSORS_GL520SM is not set
641# CONFIG_SENSORS_IT87 is not set
642# CONFIG_SENSORS_LM63 is not set
643CONFIG_SENSORS_LM75=m
644# CONFIG_SENSORS_LM77 is not set
645CONFIG_SENSORS_LM78=m
646# CONFIG_SENSORS_LM80 is not set
647# CONFIG_SENSORS_LM83 is not set
648CONFIG_SENSORS_LM85=m
649# CONFIG_SENSORS_LM87 is not set
650# CONFIG_SENSORS_LM90 is not set
651# CONFIG_SENSORS_MAX1619 is not set
652# CONFIG_SENSORS_PC87360 is not set
653# CONFIG_SENSORS_SMSC47B397 is not set
654# CONFIG_SENSORS_SMSC47M1 is not set
655# CONFIG_SENSORS_W83781D is not set
656# CONFIG_SENSORS_W83L785TS is not set
657# CONFIG_SENSORS_W83627HF is not set
658
659#
660# Other I2C Chip support
661#
662CONFIG_SENSORS_EEPROM=m
663# CONFIG_SENSORS_PCF8574 is not set
664# CONFIG_SENSORS_PCF8591 is not set
665# CONFIG_SENSORS_RTC8564 is not set
666# CONFIG_I2C_DEBUG_CORE is not set
667# CONFIG_I2C_DEBUG_ALGO is not set
668# CONFIG_I2C_DEBUG_BUS is not set
669# CONFIG_I2C_DEBUG_CHIP is not set
670 629
671# 630#
672# Misc devices 631# Misc devices
673# 632#
633# CONFIG_SGI_IOC4 is not set
634# CONFIG_TIFM_CORE is not set
635
636#
637# LED devices
638#
639# CONFIG_NEW_LEDS is not set
640
641#
642# LED drivers
643#
644
645#
646# LED Triggers
647#
674 648
675# 649#
676# Multimedia devices 650# Multimedia devices
@@ -685,13 +659,17 @@ CONFIG_SENSORS_EEPROM=m
685# 659#
686# Graphics support 660# Graphics support
687# 661#
662# CONFIG_FIRMWARE_EDID is not set
688CONFIG_FB=y 663CONFIG_FB=y
689# CONFIG_FB_CFB_FILLRECT is not set 664CONFIG_FB_CFB_FILLRECT=y
690# CONFIG_FB_CFB_COPYAREA is not set 665CONFIG_FB_CFB_COPYAREA=y
691# CONFIG_FB_CFB_IMAGEBLIT is not set 666CONFIG_FB_CFB_IMAGEBLIT=y
692# CONFIG_FB_SOFT_CURSOR is not set 667# CONFIG_FB_MACMODES is not set
693CONFIG_FB_MODE_HELPERS=y 668# CONFIG_FB_BACKLIGHT is not set
669# CONFIG_FB_MODE_HELPERS is not set
694# CONFIG_FB_TILEBLITTING is not set 670# CONFIG_FB_TILEBLITTING is not set
671CONFIG_FB_ARMCLCD=y
672# CONFIG_FB_S1D13XXX is not set
695# CONFIG_FB_VIRTUAL is not set 673# CONFIG_FB_VIRTUAL is not set
696 674
697# 675#
@@ -699,27 +677,76 @@ CONFIG_FB_MODE_HELPERS=y
699# 677#
700# CONFIG_VGA_CONSOLE is not set 678# CONFIG_VGA_CONSOLE is not set
701CONFIG_DUMMY_CONSOLE=y 679CONFIG_DUMMY_CONSOLE=y
702# CONFIG_FRAMEBUFFER_CONSOLE is not set 680CONFIG_FRAMEBUFFER_CONSOLE=y
681# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
682# CONFIG_FONTS is not set
683CONFIG_FONT_8x8=y
684CONFIG_FONT_8x16=y
703 685
704# 686#
705# Logo configuration 687# Logo configuration
706# 688#
707# CONFIG_LOGO is not set 689CONFIG_LOGO=y
690# CONFIG_LOGO_LINUX_MONO is not set
691# CONFIG_LOGO_LINUX_VGA16 is not set
692CONFIG_LOGO_LINUX_CLUT224=y
708# CONFIG_BACKLIGHT_LCD_SUPPORT is not set 693# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
709 694
710# 695#
711# Sound 696# Sound
712# 697#
713# CONFIG_SOUND is not set 698CONFIG_SOUND=y
699
700#
701# Advanced Linux Sound Architecture
702#
703CONFIG_SND=y
704CONFIG_SND_TIMER=y
705CONFIG_SND_PCM=y
706# CONFIG_SND_SEQUENCER is not set
707CONFIG_SND_OSSEMUL=y
708CONFIG_SND_MIXER_OSS=y
709CONFIG_SND_PCM_OSS=y
710CONFIG_SND_PCM_OSS_PLUGINS=y
711# CONFIG_SND_DYNAMIC_MINORS is not set
712CONFIG_SND_SUPPORT_OLD_API=y
713CONFIG_SND_VERBOSE_PROCFS=y
714# CONFIG_SND_VERBOSE_PRINTK is not set
715# CONFIG_SND_DEBUG is not set
716
717#
718# Generic devices
719#
720CONFIG_SND_AC97_CODEC=m
721CONFIG_SND_AC97_BUS=m
722# CONFIG_SND_DUMMY is not set
723# CONFIG_SND_MTPAV is not set
724# CONFIG_SND_SERIAL_U16550 is not set
725# CONFIG_SND_MPU401 is not set
726
727#
728# ALSA ARM devices
729#
730CONFIG_SND_ARMAACI=m
731
732#
733# Open Sound System
734#
735# CONFIG_SOUND_PRIME is not set
714 736
715# 737#
716# USB support 738# USB support
717# 739#
718CONFIG_USB_ARCH_HAS_HCD=y 740CONFIG_USB_ARCH_HAS_HCD=y
719# CONFIG_USB_ARCH_HAS_OHCI is not set 741# CONFIG_USB_ARCH_HAS_OHCI is not set
742# CONFIG_USB_ARCH_HAS_EHCI is not set
720# CONFIG_USB is not set 743# CONFIG_USB is not set
721 744
722# 745#
746# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
747#
748
749#
723# USB Gadget Support 750# USB Gadget Support
724# 751#
725# CONFIG_USB_GADGET is not set 752# CONFIG_USB_GADGET is not set
@@ -727,33 +754,62 @@ CONFIG_USB_ARCH_HAS_HCD=y
727# 754#
728# MMC/SD Card support 755# MMC/SD Card support
729# 756#
730# CONFIG_MMC is not set 757CONFIG_MMC=y
758# CONFIG_MMC_DEBUG is not set
759CONFIG_MMC_BLOCK=y
760CONFIG_MMC_ARMMMCI=y
761# CONFIG_MMC_TIFM_SD is not set
762
763#
764# Real Time Clock
765#
766CONFIG_RTC_LIB=y
767CONFIG_RTC_CLASS=y
768CONFIG_RTC_HCTOSYS=y
769CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
770# CONFIG_RTC_DEBUG is not set
771
772#
773# RTC interfaces
774#
775CONFIG_RTC_INTF_SYSFS=y
776CONFIG_RTC_INTF_PROC=y
777CONFIG_RTC_INTF_DEV=y
778CONFIG_RTC_INTF_DEV_UIE_EMUL=y
779
780#
781# RTC drivers
782#
783# CONFIG_RTC_DRV_DS1553 is not set
784# CONFIG_RTC_DRV_DS1742 is not set
785# CONFIG_RTC_DRV_M48T86 is not set
786CONFIG_RTC_DRV_PL031=y
787# CONFIG_RTC_DRV_TEST is not set
788# CONFIG_RTC_DRV_V3020 is not set
731 789
732# 790#
733# File systems 791# File systems
734# 792#
735CONFIG_EXT2_FS=y 793CONFIG_EXT2_FS=y
736# CONFIG_EXT2_FS_XATTR is not set 794# CONFIG_EXT2_FS_XATTR is not set
737CONFIG_EXT3_FS=y 795# CONFIG_EXT2_FS_XIP is not set
738CONFIG_EXT3_FS_XATTR=y 796# CONFIG_EXT3_FS is not set
739# CONFIG_EXT3_FS_POSIX_ACL is not set 797# CONFIG_EXT4DEV_FS is not set
740# CONFIG_EXT3_FS_SECURITY is not set
741CONFIG_JBD=y
742# CONFIG_JBD_DEBUG is not set
743CONFIG_FS_MBCACHE=y
744# CONFIG_REISERFS_FS is not set 798# CONFIG_REISERFS_FS is not set
745# CONFIG_JFS_FS is not set 799# CONFIG_JFS_FS is not set
746 800# CONFIG_FS_POSIX_ACL is not set
747#
748# XFS support
749#
750# CONFIG_XFS_FS is not set 801# CONFIG_XFS_FS is not set
802# CONFIG_GFS2_FS is not set
803# CONFIG_OCFS2_FS is not set
751# CONFIG_MINIX_FS is not set 804# CONFIG_MINIX_FS is not set
752CONFIG_ROMFS_FS=y 805# CONFIG_ROMFS_FS is not set
806CONFIG_INOTIFY=y
807# CONFIG_INOTIFY_USER is not set
753# CONFIG_QUOTA is not set 808# CONFIG_QUOTA is not set
754CONFIG_DNOTIFY=y 809CONFIG_DNOTIFY=y
755# CONFIG_AUTOFS_FS is not set 810# CONFIG_AUTOFS_FS is not set
756# CONFIG_AUTOFS4_FS is not set 811# CONFIG_AUTOFS4_FS is not set
812# CONFIG_FUSE_FS is not set
757 813
758# 814#
759# CD-ROM/DVD Filesystems 815# CD-ROM/DVD Filesystems
@@ -765,7 +821,7 @@ CONFIG_DNOTIFY=y
765# DOS/FAT/NT Filesystems 821# DOS/FAT/NT Filesystems
766# 822#
767CONFIG_FAT_FS=y 823CONFIG_FAT_FS=y
768CONFIG_MSDOS_FS=y 824# CONFIG_MSDOS_FS is not set
769CONFIG_VFAT_FS=y 825CONFIG_VFAT_FS=y
770CONFIG_FAT_DEFAULT_CODEPAGE=437 826CONFIG_FAT_DEFAULT_CODEPAGE=437
771CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1" 827CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
@@ -775,12 +831,13 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
775# Pseudo filesystems 831# Pseudo filesystems
776# 832#
777CONFIG_PROC_FS=y 833CONFIG_PROC_FS=y
834CONFIG_PROC_SYSCTL=y
778CONFIG_SYSFS=y 835CONFIG_SYSFS=y
779# CONFIG_DEVFS_FS is not set 836CONFIG_TMPFS=y
780# CONFIG_DEVPTS_FS_XATTR is not set 837# CONFIG_TMPFS_POSIX_ACL is not set
781# CONFIG_TMPFS is not set
782# CONFIG_HUGETLB_PAGE is not set 838# CONFIG_HUGETLB_PAGE is not set
783CONFIG_RAMFS=y 839CONFIG_RAMFS=y
840# CONFIG_CONFIGFS_FS is not set
784 841
785# 842#
786# Miscellaneous filesystems 843# Miscellaneous filesystems
@@ -792,18 +849,9 @@ CONFIG_RAMFS=y
792# CONFIG_BEFS_FS is not set 849# CONFIG_BEFS_FS is not set
793# CONFIG_BFS_FS is not set 850# CONFIG_BFS_FS is not set
794# CONFIG_EFS_FS is not set 851# CONFIG_EFS_FS is not set
795CONFIG_JFFS_FS=y 852# CONFIG_JFFS_FS is not set
796CONFIG_JFFS_FS_VERBOSE=0 853# CONFIG_JFFS2_FS is not set
797# CONFIG_JFFS_PROC_FS is not set 854CONFIG_CRAMFS=y
798CONFIG_JFFS2_FS=y
799CONFIG_JFFS2_FS_DEBUG=0
800# CONFIG_JFFS2_FS_NAND is not set
801# CONFIG_JFFS2_FS_NOR_ECC is not set
802# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
803CONFIG_JFFS2_ZLIB=y
804CONFIG_JFFS2_RTIME=y
805# CONFIG_JFFS2_RUBIN is not set
806# CONFIG_CRAMFS is not set
807# CONFIG_VXFS_FS is not set 855# CONFIG_VXFS_FS is not set
808# CONFIG_HPFS_FS is not set 856# CONFIG_HPFS_FS is not set
809# CONFIG_QNX4FS_FS is not set 857# CONFIG_QNX4FS_FS is not set
@@ -814,12 +862,15 @@ CONFIG_JFFS2_RTIME=y
814# Network File Systems 862# Network File Systems
815# 863#
816CONFIG_NFS_FS=y 864CONFIG_NFS_FS=y
817# CONFIG_NFS_V3 is not set 865CONFIG_NFS_V3=y
866# CONFIG_NFS_V3_ACL is not set
818# CONFIG_NFS_V4 is not set 867# CONFIG_NFS_V4 is not set
819# CONFIG_NFS_DIRECTIO is not set 868# CONFIG_NFS_DIRECTIO is not set
820# CONFIG_NFSD is not set 869# CONFIG_NFSD is not set
821CONFIG_ROOT_NFS=y 870CONFIG_ROOT_NFS=y
822CONFIG_LOCKD=y 871CONFIG_LOCKD=y
872CONFIG_LOCKD_V4=y
873CONFIG_NFS_COMMON=y
823CONFIG_SUNRPC=y 874CONFIG_SUNRPC=y
824# CONFIG_RPCSEC_GSS_KRB5 is not set 875# CONFIG_RPCSEC_GSS_KRB5 is not set
825# CONFIG_RPCSEC_GSS_SPKM3 is not set 876# CONFIG_RPCSEC_GSS_SPKM3 is not set
@@ -828,33 +879,20 @@ CONFIG_SUNRPC=y
828# CONFIG_NCP_FS is not set 879# CONFIG_NCP_FS is not set
829# CONFIG_CODA_FS is not set 880# CONFIG_CODA_FS is not set
830# CONFIG_AFS_FS is not set 881# CONFIG_AFS_FS is not set
882# CONFIG_9P_FS is not set
831 883
832# 884#
833# Partition Types 885# Partition Types
834# 886#
835CONFIG_PARTITION_ADVANCED=y 887# CONFIG_PARTITION_ADVANCED is not set
836# CONFIG_ACORN_PARTITION is not set
837# CONFIG_OSF_PARTITION is not set
838# CONFIG_AMIGA_PARTITION is not set
839# CONFIG_ATARI_PARTITION is not set
840# CONFIG_MAC_PARTITION is not set
841CONFIG_MSDOS_PARTITION=y 888CONFIG_MSDOS_PARTITION=y
842CONFIG_BSD_DISKLABEL=y
843# CONFIG_MINIX_SUBPARTITION is not set
844CONFIG_SOLARIS_X86_PARTITION=y
845# CONFIG_UNIXWARE_DISKLABEL is not set
846# CONFIG_LDM_PARTITION is not set
847# CONFIG_SGI_PARTITION is not set
848# CONFIG_ULTRIX_PARTITION is not set
849# CONFIG_SUN_PARTITION is not set
850# CONFIG_EFI_PARTITION is not set
851 889
852# 890#
853# Native Language Support 891# Native Language Support
854# 892#
855CONFIG_NLS=y 893CONFIG_NLS=y
856CONFIG_NLS_DEFAULT="iso8859-1" 894CONFIG_NLS_DEFAULT="iso8859-1"
857# CONFIG_NLS_CODEPAGE_437 is not set 895CONFIG_NLS_CODEPAGE_437=y
858# CONFIG_NLS_CODEPAGE_737 is not set 896# CONFIG_NLS_CODEPAGE_737 is not set
859# CONFIG_NLS_CODEPAGE_775 is not set 897# CONFIG_NLS_CODEPAGE_775 is not set
860# CONFIG_NLS_CODEPAGE_850 is not set 898# CONFIG_NLS_CODEPAGE_850 is not set
@@ -878,7 +916,7 @@ CONFIG_NLS_DEFAULT="iso8859-1"
878# CONFIG_NLS_CODEPAGE_1250 is not set 916# CONFIG_NLS_CODEPAGE_1250 is not set
879# CONFIG_NLS_CODEPAGE_1251 is not set 917# CONFIG_NLS_CODEPAGE_1251 is not set
880# CONFIG_NLS_ASCII is not set 918# CONFIG_NLS_ASCII is not set
881# CONFIG_NLS_ISO8859_1 is not set 919CONFIG_NLS_ISO8859_1=y
882# CONFIG_NLS_ISO8859_2 is not set 920# CONFIG_NLS_ISO8859_2 is not set
883# CONFIG_NLS_ISO8859_3 is not set 921# CONFIG_NLS_ISO8859_3 is not set
884# CONFIG_NLS_ISO8859_4 is not set 922# CONFIG_NLS_ISO8859_4 is not set
@@ -902,25 +940,37 @@ CONFIG_NLS_DEFAULT="iso8859-1"
902# Kernel hacking 940# Kernel hacking
903# 941#
904# CONFIG_PRINTK_TIME is not set 942# CONFIG_PRINTK_TIME is not set
943# CONFIG_ENABLE_MUST_CHECK is not set
944CONFIG_MAGIC_SYSRQ=y
945# CONFIG_UNUSED_SYMBOLS is not set
905CONFIG_DEBUG_KERNEL=y 946CONFIG_DEBUG_KERNEL=y
906# CONFIG_MAGIC_SYSRQ is not set 947CONFIG_LOG_BUF_SHIFT=14
907CONFIG_LOG_BUF_SHIFT=16 948CONFIG_DETECT_SOFTLOCKUP=y
908# CONFIG_SCHEDSTATS is not set 949# CONFIG_SCHEDSTATS is not set
909# CONFIG_DEBUG_SLAB is not set 950# CONFIG_DEBUG_SLAB is not set
910# CONFIG_DEBUG_SPINLOCK is not set 951# CONFIG_DEBUG_RT_MUTEXES is not set
952# CONFIG_RT_MUTEX_TESTER is not set
953CONFIG_DEBUG_SPINLOCK=y
954CONFIG_DEBUG_MUTEXES=y
955CONFIG_DEBUG_RWSEMS=y
911# CONFIG_DEBUG_SPINLOCK_SLEEP is not set 956# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
957# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
912# CONFIG_DEBUG_KOBJECT is not set 958# CONFIG_DEBUG_KOBJECT is not set
913CONFIG_DEBUG_BUGVERBOSE=y 959CONFIG_DEBUG_BUGVERBOSE=y
914CONFIG_DEBUG_INFO=y 960# CONFIG_DEBUG_INFO is not set
915# CONFIG_DEBUG_FS is not set 961# CONFIG_DEBUG_FS is not set
962# CONFIG_DEBUG_VM is not set
963# CONFIG_DEBUG_LIST is not set
916CONFIG_FRAME_POINTER=y 964CONFIG_FRAME_POINTER=y
965# CONFIG_UNWIND_INFO is not set
966CONFIG_FORCED_INLINING=y
967# CONFIG_HEADERS_CHECK is not set
968# CONFIG_RCU_TORTURE_TEST is not set
917CONFIG_DEBUG_USER=y 969CONFIG_DEBUG_USER=y
918# CONFIG_DEBUG_WAITQ is not set 970# CONFIG_DEBUG_WAITQ is not set
919# CONFIG_DEBUG_ERRORS is not set 971CONFIG_DEBUG_ERRORS=y
920CONFIG_DEBUG_LL=y 972CONFIG_DEBUG_LL=y
921# CONFIG_DEBUG_ICEDCC is not set 973# CONFIG_DEBUG_ICEDCC is not set
922CONFIG_DEBUG_S3C2410_PORT=y
923CONFIG_DEBUG_S3C2410_UART=0
924 974
925# 975#
926# Security options 976# Security options
@@ -934,14 +984,11 @@ CONFIG_DEBUG_S3C2410_UART=0
934# CONFIG_CRYPTO is not set 984# CONFIG_CRYPTO is not set
935 985
936# 986#
937# Hardware crypto devices
938#
939
940#
941# Library routines 987# Library routines
942# 988#
943# CONFIG_CRC_CCITT is not set 989# CONFIG_CRC_CCITT is not set
990# CONFIG_CRC16 is not set
944CONFIG_CRC32=y 991CONFIG_CRC32=y
945# CONFIG_LIBCRC32C is not set 992# CONFIG_LIBCRC32C is not set
946CONFIG_ZLIB_INFLATE=y 993CONFIG_ZLIB_INFLATE=y
947CONFIG_ZLIB_DEFLATE=y 994CONFIG_PLIST=y
diff --git a/arch/arm/configs/s3c2410_defconfig b/arch/arm/configs/s3c2410_defconfig
index a83222641045..c0152393e494 100644
--- a/arch/arm/configs/s3c2410_defconfig
+++ b/arch/arm/configs/s3c2410_defconfig
@@ -1,9 +1,10 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.18 3# Linux kernel version: 2.6.19-rc4
4# Wed Sep 20 20:27:31 2006 4# Fri Nov 3 17:41:31 2006
5# 5#
6CONFIG_ARM=y 6CONFIG_ARM=y
7# CONFIG_GENERIC_TIME is not set
7CONFIG_MMU=y 8CONFIG_MMU=y
8CONFIG_GENERIC_HARDIRQS=y 9CONFIG_GENERIC_HARDIRQS=y
9CONFIG_TRACE_IRQFLAGS_SUPPORT=y 10CONFIG_TRACE_IRQFLAGS_SUPPORT=y
@@ -29,17 +30,20 @@ CONFIG_LOCALVERSION=""
29CONFIG_LOCALVERSION_AUTO=y 30CONFIG_LOCALVERSION_AUTO=y
30CONFIG_SWAP=y 31CONFIG_SWAP=y
31CONFIG_SYSVIPC=y 32CONFIG_SYSVIPC=y
33# CONFIG_IPC_NS is not set
32# CONFIG_POSIX_MQUEUE is not set 34# CONFIG_POSIX_MQUEUE is not set
33# CONFIG_BSD_PROCESS_ACCT is not set 35# CONFIG_BSD_PROCESS_ACCT is not set
34# CONFIG_TASKSTATS is not set 36# CONFIG_TASKSTATS is not set
37# CONFIG_UTS_NS is not set
35# CONFIG_AUDIT is not set 38# CONFIG_AUDIT is not set
36# CONFIG_IKCONFIG is not set 39# CONFIG_IKCONFIG is not set
37# CONFIG_RELAY is not set 40# CONFIG_RELAY is not set
38CONFIG_INITRAMFS_SOURCE="" 41CONFIG_INITRAMFS_SOURCE=""
39CONFIG_CC_OPTIMIZE_FOR_SIZE=y 42CONFIG_CC_OPTIMIZE_FOR_SIZE=y
43CONFIG_SYSCTL=y
40# CONFIG_EMBEDDED is not set 44# CONFIG_EMBEDDED is not set
41CONFIG_UID16=y 45CONFIG_UID16=y
42CONFIG_SYSCTL=y 46# CONFIG_SYSCTL_SYSCALL is not set
43CONFIG_KALLSYMS=y 47CONFIG_KALLSYMS=y
44# CONFIG_KALLSYMS_ALL is not set 48# CONFIG_KALLSYMS_ALL is not set
45# CONFIG_KALLSYMS_EXTRA_PASS is not set 49# CONFIG_KALLSYMS_EXTRA_PASS is not set
@@ -62,7 +66,8 @@ CONFIG_BASE_SMALL=0
62# Loadable module support 66# Loadable module support
63# 67#
64CONFIG_MODULES=y 68CONFIG_MODULES=y
65# CONFIG_MODULE_UNLOAD is not set 69CONFIG_MODULE_UNLOAD=y
70# CONFIG_MODULE_FORCE_UNLOAD is not set
66# CONFIG_MODVERSIONS is not set 71# CONFIG_MODVERSIONS is not set
67# CONFIG_MODULE_SRCVERSION_ALL is not set 72# CONFIG_MODULE_SRCVERSION_ALL is not set
68CONFIG_KMOD=y 73CONFIG_KMOD=y
@@ -70,6 +75,7 @@ CONFIG_KMOD=y
70# 75#
71# Block layer 76# Block layer
72# 77#
78CONFIG_BLOCK=y
73# CONFIG_BLK_DEV_IO_TRACE is not set 79# CONFIG_BLK_DEV_IO_TRACE is not set
74 80
75# 81#
@@ -120,6 +126,7 @@ CONFIG_ARCH_S3C2410=y
120# 126#
121# S3C24XX Implementations 127# S3C24XX Implementations
122# 128#
129# CONFIG_MACH_AML_M5900 is not set
123CONFIG_MACH_ANUBIS=y 130CONFIG_MACH_ANUBIS=y
124CONFIG_MACH_OSIRIS=y 131CONFIG_MACH_OSIRIS=y
125CONFIG_ARCH_BAST=y 132CONFIG_ARCH_BAST=y
@@ -178,6 +185,8 @@ CONFIG_CPU_CACHE_V4WT=y
178CONFIG_CPU_CACHE_VIVT=y 185CONFIG_CPU_CACHE_VIVT=y
179CONFIG_CPU_COPY_V4WB=y 186CONFIG_CPU_COPY_V4WB=y
180CONFIG_CPU_TLB_V4WBI=y 187CONFIG_CPU_TLB_V4WBI=y
188CONFIG_CPU_CP15=y
189CONFIG_CPU_CP15_MMU=y
181 190
182# 191#
183# Processor Features 192# Processor Features
@@ -249,8 +258,9 @@ CONFIG_BINFMT_AOUT=y
249# Power management options 258# Power management options
250# 259#
251CONFIG_PM=y 260CONFIG_PM=y
252CONFIG_PM_LEGACY=y 261# CONFIG_PM_LEGACY is not set
253# CONFIG_PM_DEBUG is not set 262# CONFIG_PM_DEBUG is not set
263# CONFIG_PM_SYSFS_DEPRECATED is not set
254CONFIG_APM=y 264CONFIG_APM=y
255 265
256# 266#
@@ -266,6 +276,7 @@ CONFIG_NET=y
266CONFIG_UNIX=y 276CONFIG_UNIX=y
267CONFIG_XFRM=y 277CONFIG_XFRM=y
268# CONFIG_XFRM_USER is not set 278# CONFIG_XFRM_USER is not set
279# CONFIG_XFRM_SUB_POLICY is not set
269# CONFIG_NET_KEY is not set 280# CONFIG_NET_KEY is not set
270CONFIG_INET=y 281CONFIG_INET=y
271# CONFIG_IP_MULTICAST is not set 282# CONFIG_IP_MULTICAST is not set
@@ -286,10 +297,12 @@ CONFIG_IP_PNP_BOOTP=y
286# CONFIG_INET_TUNNEL is not set 297# CONFIG_INET_TUNNEL is not set
287CONFIG_INET_XFRM_MODE_TRANSPORT=y 298CONFIG_INET_XFRM_MODE_TRANSPORT=y
288CONFIG_INET_XFRM_MODE_TUNNEL=y 299CONFIG_INET_XFRM_MODE_TUNNEL=y
300CONFIG_INET_XFRM_MODE_BEET=y
289CONFIG_INET_DIAG=y 301CONFIG_INET_DIAG=y
290CONFIG_INET_TCP_DIAG=y 302CONFIG_INET_TCP_DIAG=y
291# CONFIG_TCP_CONG_ADVANCED is not set 303# CONFIG_TCP_CONG_ADVANCED is not set
292CONFIG_TCP_CONG_BIC=y 304CONFIG_TCP_CONG_CUBIC=y
305CONFIG_DEFAULT_TCP_CONG="cubic"
293# CONFIG_IPV6 is not set 306# CONFIG_IPV6 is not set
294# CONFIG_INET6_XFRM_TUNNEL is not set 307# CONFIG_INET6_XFRM_TUNNEL is not set
295# CONFIG_INET6_TUNNEL is not set 308# CONFIG_INET6_TUNNEL is not set
@@ -377,6 +390,7 @@ CONFIG_MTD_BLOCK=y
377# CONFIG_NFTL is not set 390# CONFIG_NFTL is not set
378# CONFIG_INFTL is not set 391# CONFIG_INFTL is not set
379# CONFIG_RFD_FTL is not set 392# CONFIG_RFD_FTL is not set
393# CONFIG_SSFDC is not set
380 394
381# 395#
382# RAM/ROM/Flash chip drivers 396# RAM/ROM/Flash chip drivers
@@ -418,6 +432,8 @@ CONFIG_MTD_BAST_MAXSIZE=4
418# 432#
419# Self-contained MTD device drivers 433# Self-contained MTD device drivers
420# 434#
435# CONFIG_MTD_DATAFLASH is not set
436# CONFIG_MTD_M25P80 is not set
421# CONFIG_MTD_SLRAM is not set 437# CONFIG_MTD_SLRAM is not set
422# CONFIG_MTD_PHRAM is not set 438# CONFIG_MTD_PHRAM is not set
423# CONFIG_MTD_MTDRAM is not set 439# CONFIG_MTD_MTDRAM is not set
@@ -512,6 +528,7 @@ CONFIG_BLK_DEV_IDE_BAST=y
512# 528#
513# CONFIG_RAID_ATTRS is not set 529# CONFIG_RAID_ATTRS is not set
514# CONFIG_SCSI is not set 530# CONFIG_SCSI is not set
531# CONFIG_SCSI_NETLINK is not set
515 532
516# 533#
517# Multi-device support (RAID and LVM) 534# Multi-device support (RAID and LVM)
@@ -606,6 +623,7 @@ CONFIG_DM9000=y
606# Input device support 623# Input device support
607# 624#
608CONFIG_INPUT=y 625CONFIG_INPUT=y
626# CONFIG_INPUT_FF_MEMLESS is not set
609 627
610# 628#
611# Userland interfaces 629# Userland interfaces
@@ -628,6 +646,7 @@ CONFIG_KEYBOARD_ATKBD=y
628# CONFIG_KEYBOARD_LKKBD is not set 646# CONFIG_KEYBOARD_LKKBD is not set
629# CONFIG_KEYBOARD_XTKBD is not set 647# CONFIG_KEYBOARD_XTKBD is not set
630# CONFIG_KEYBOARD_NEWTON is not set 648# CONFIG_KEYBOARD_NEWTON is not set
649# CONFIG_KEYBOARD_STOWAWAY is not set
631CONFIG_INPUT_MOUSE=y 650CONFIG_INPUT_MOUSE=y
632CONFIG_MOUSE_PS2=y 651CONFIG_MOUSE_PS2=y
633# CONFIG_MOUSE_SERIAL is not set 652# CONFIG_MOUSE_SERIAL is not set
@@ -734,7 +753,6 @@ CONFIG_S3C2410_WATCHDOG=y
734# CONFIG_USBPCWATCHDOG is not set 753# CONFIG_USBPCWATCHDOG is not set
735CONFIG_HW_RANDOM=y 754CONFIG_HW_RANDOM=y
736# CONFIG_NVRAM is not set 755# CONFIG_NVRAM is not set
737CONFIG_S3C2410_RTC=y
738# CONFIG_DTLK is not set 756# CONFIG_DTLK is not set
739# CONFIG_R3964 is not set 757# CONFIG_R3964 is not set
740 758
@@ -747,7 +765,6 @@ CONFIG_S3C2410_RTC=y
747# TPM devices 765# TPM devices
748# 766#
749# CONFIG_TCG_TPM is not set 767# CONFIG_TCG_TPM is not set
750# CONFIG_TELCLOCK is not set
751 768
752# 769#
753# I2C support 770# I2C support
@@ -792,12 +809,26 @@ CONFIG_SENSORS_EEPROM=m
792# 809#
793# SPI support 810# SPI support
794# 811#
795# CONFIG_SPI is not set 812CONFIG_SPI=y
796# CONFIG_SPI_MASTER is not set 813# CONFIG_SPI_DEBUG is not set
814CONFIG_SPI_MASTER=y
815
816#
817# SPI Master Controller Drivers
818#
819CONFIG_SPI_BITBANG=m
820# CONFIG_SPI_BUTTERFLY is not set
821CONFIG_SPI_S3C24XX_GPIO=m
822CONFIG_SPI_S3C24XX=m
823
824#
825# SPI Protocol Masters
826#
797 827
798# 828#
799# Dallas's 1-wire bus 829# Dallas's 1-wire bus
800# 830#
831# CONFIG_W1 is not set
801 832
802# 833#
803# Hardware Monitoring support 834# Hardware Monitoring support
@@ -820,6 +851,7 @@ CONFIG_HWMON_VID=m
820# CONFIG_SENSORS_GL520SM is not set 851# CONFIG_SENSORS_GL520SM is not set
821# CONFIG_SENSORS_IT87 is not set 852# CONFIG_SENSORS_IT87 is not set
822# CONFIG_SENSORS_LM63 is not set 853# CONFIG_SENSORS_LM63 is not set
854# CONFIG_SENSORS_LM70 is not set
823CONFIG_SENSORS_LM75=m 855CONFIG_SENSORS_LM75=m
824# CONFIG_SENSORS_LM77 is not set 856# CONFIG_SENSORS_LM77 is not set
825CONFIG_SENSORS_LM78=m 857CONFIG_SENSORS_LM78=m
@@ -834,6 +866,7 @@ CONFIG_SENSORS_LM85=m
834# CONFIG_SENSORS_SMSC47M1 is not set 866# CONFIG_SENSORS_SMSC47M1 is not set
835# CONFIG_SENSORS_SMSC47M192 is not set 867# CONFIG_SENSORS_SMSC47M192 is not set
836# CONFIG_SENSORS_SMSC47B397 is not set 868# CONFIG_SENSORS_SMSC47B397 is not set
869# CONFIG_SENSORS_VT1211 is not set
837# CONFIG_SENSORS_W83781D is not set 870# CONFIG_SENSORS_W83781D is not set
838# CONFIG_SENSORS_W83791D is not set 871# CONFIG_SENSORS_W83791D is not set
839# CONFIG_SENSORS_W83792D is not set 872# CONFIG_SENSORS_W83792D is not set
@@ -845,25 +878,31 @@ CONFIG_SENSORS_LM85=m
845# 878#
846# Misc devices 879# Misc devices
847# 880#
881# CONFIG_TIFM_CORE is not set
848 882
849# 883#
850# LED devices 884# LED devices
851# 885#
852# CONFIG_NEW_LEDS is not set 886CONFIG_NEW_LEDS=y
887CONFIG_LEDS_CLASS=m
853 888
854# 889#
855# LED drivers 890# LED drivers
856# 891#
892CONFIG_LEDS_S3C24XX=m
857 893
858# 894#
859# LED Triggers 895# LED Triggers
860# 896#
897CONFIG_LEDS_TRIGGERS=y
898CONFIG_LEDS_TRIGGER_TIMER=m
899# CONFIG_LEDS_TRIGGER_IDE_DISK is not set
900CONFIG_LEDS_TRIGGER_HEARTBEAT=m
861 901
862# 902#
863# Multimedia devices 903# Multimedia devices
864# 904#
865# CONFIG_VIDEO_DEV is not set 905# CONFIG_VIDEO_DEV is not set
866CONFIG_VIDEO_V4L2=y
867 906
868# 907#
869# Digital Video Broadcasting Devices 908# Digital Video Broadcasting Devices
@@ -876,6 +915,7 @@ CONFIG_VIDEO_V4L2=y
876# 915#
877CONFIG_FIRMWARE_EDID=y 916CONFIG_FIRMWARE_EDID=y
878CONFIG_FB=y 917CONFIG_FB=y
918# CONFIG_FB_DDC is not set
879CONFIG_FB_CFB_FILLRECT=y 919CONFIG_FB_CFB_FILLRECT=y
880CONFIG_FB_CFB_COPYAREA=y 920CONFIG_FB_CFB_COPYAREA=y
881CONFIG_FB_CFB_IMAGEBLIT=y 921CONFIG_FB_CFB_IMAGEBLIT=y
@@ -951,7 +991,6 @@ CONFIG_USB_OHCI_LITTLE_ENDIAN=y
951# 991#
952# may also be needed; see USB_STORAGE Help for more information 992# may also be needed; see USB_STORAGE Help for more information
953# 993#
954# CONFIG_USB_STORAGE is not set
955# CONFIG_USB_LIBUSUAL is not set 994# CONFIG_USB_LIBUSUAL is not set
956 995
957# 996#
@@ -1007,6 +1046,7 @@ CONFIG_USB_MON=y
1007# 1046#
1008# CONFIG_USB_EMI62 is not set 1047# CONFIG_USB_EMI62 is not set
1009# CONFIG_USB_EMI26 is not set 1048# CONFIG_USB_EMI26 is not set
1049# CONFIG_USB_ADUTUX is not set
1010# CONFIG_USB_AUERSWALD is not set 1050# CONFIG_USB_AUERSWALD is not set
1011# CONFIG_USB_RIO500 is not set 1051# CONFIG_USB_RIO500 is not set
1012# CONFIG_USB_LEGOTOWER is not set 1052# CONFIG_USB_LEGOTOWER is not set
@@ -1014,11 +1054,12 @@ CONFIG_USB_MON=y
1014# CONFIG_USB_LED is not set 1054# CONFIG_USB_LED is not set
1015# CONFIG_USB_CYPRESS_CY7C63 is not set 1055# CONFIG_USB_CYPRESS_CY7C63 is not set
1016# CONFIG_USB_CYTHERM is not set 1056# CONFIG_USB_CYTHERM is not set
1017# CONFIG_USB_PHIDGETKIT is not set 1057# CONFIG_USB_PHIDGET is not set
1018# CONFIG_USB_PHIDGETSERVO is not set
1019# CONFIG_USB_IDMOUSE is not set 1058# CONFIG_USB_IDMOUSE is not set
1059# CONFIG_USB_FTDI_ELAN is not set
1020# CONFIG_USB_APPLEDISPLAY is not set 1060# CONFIG_USB_APPLEDISPLAY is not set
1021# CONFIG_USB_LD is not set 1061# CONFIG_USB_LD is not set
1062# CONFIG_USB_TRANCEVIBRATOR is not set
1022# CONFIG_USB_TEST is not set 1063# CONFIG_USB_TEST is not set
1023 1064
1024# 1065#
@@ -1039,7 +1080,37 @@ CONFIG_USB_MON=y
1039# Real Time Clock 1080# Real Time Clock
1040# 1081#
1041CONFIG_RTC_LIB=y 1082CONFIG_RTC_LIB=y
1042# CONFIG_RTC_CLASS is not set 1083CONFIG_RTC_CLASS=y
1084CONFIG_RTC_HCTOSYS=y
1085CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
1086# CONFIG_RTC_DEBUG is not set
1087
1088#
1089# RTC interfaces
1090#
1091CONFIG_RTC_INTF_SYSFS=y
1092CONFIG_RTC_INTF_PROC=y
1093CONFIG_RTC_INTF_DEV=y
1094# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
1095
1096#
1097# RTC drivers
1098#
1099# CONFIG_RTC_DRV_X1205 is not set
1100# CONFIG_RTC_DRV_DS1307 is not set
1101# CONFIG_RTC_DRV_DS1553 is not set
1102# CONFIG_RTC_DRV_ISL1208 is not set
1103# CONFIG_RTC_DRV_DS1672 is not set
1104# CONFIG_RTC_DRV_DS1742 is not set
1105# CONFIG_RTC_DRV_PCF8563 is not set
1106# CONFIG_RTC_DRV_PCF8583 is not set
1107# CONFIG_RTC_DRV_RS5C348 is not set
1108# CONFIG_RTC_DRV_RS5C372 is not set
1109CONFIG_RTC_DRV_S3C=y
1110# CONFIG_RTC_DRV_M48T86 is not set
1111# CONFIG_RTC_DRV_TEST is not set
1112# CONFIG_RTC_DRV_MAX6902 is not set
1113# CONFIG_RTC_DRV_V3020 is not set
1043 1114
1044# 1115#
1045# File systems 1116# File systems
@@ -1051,6 +1122,7 @@ CONFIG_EXT3_FS=y
1051CONFIG_EXT3_FS_XATTR=y 1122CONFIG_EXT3_FS_XATTR=y
1052# CONFIG_EXT3_FS_POSIX_ACL is not set 1123# CONFIG_EXT3_FS_POSIX_ACL is not set
1053# CONFIG_EXT3_FS_SECURITY is not set 1124# CONFIG_EXT3_FS_SECURITY is not set
1125# CONFIG_EXT4DEV_FS is not set
1054CONFIG_JBD=y 1126CONFIG_JBD=y
1055# CONFIG_JBD_DEBUG is not set 1127# CONFIG_JBD_DEBUG is not set
1056CONFIG_FS_MBCACHE=y 1128CONFIG_FS_MBCACHE=y
@@ -1058,6 +1130,7 @@ CONFIG_FS_MBCACHE=y
1058# CONFIG_JFS_FS is not set 1130# CONFIG_JFS_FS is not set
1059# CONFIG_FS_POSIX_ACL is not set 1131# CONFIG_FS_POSIX_ACL is not set
1060# CONFIG_XFS_FS is not set 1132# CONFIG_XFS_FS is not set
1133# CONFIG_GFS2_FS is not set
1061# CONFIG_OCFS2_FS is not set 1134# CONFIG_OCFS2_FS is not set
1062# CONFIG_MINIX_FS is not set 1135# CONFIG_MINIX_FS is not set
1063CONFIG_ROMFS_FS=y 1136CONFIG_ROMFS_FS=y
@@ -1089,6 +1162,7 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1089# Pseudo filesystems 1162# Pseudo filesystems
1090# 1163#
1091CONFIG_PROC_FS=y 1164CONFIG_PROC_FS=y
1165CONFIG_PROC_SYSCTL=y
1092CONFIG_SYSFS=y 1166CONFIG_SYSFS=y
1093# CONFIG_TMPFS is not set 1167# CONFIG_TMPFS is not set
1094# CONFIG_HUGETLB_PAGE is not set 1168# CONFIG_HUGETLB_PAGE is not set
@@ -1219,6 +1293,7 @@ CONFIG_NLS_DEFAULT="iso8859-1"
1219# Kernel hacking 1293# Kernel hacking
1220# 1294#
1221# CONFIG_PRINTK_TIME is not set 1295# CONFIG_PRINTK_TIME is not set
1296CONFIG_ENABLE_MUST_CHECK=y
1222CONFIG_MAGIC_SYSRQ=y 1297CONFIG_MAGIC_SYSRQ=y
1223# CONFIG_UNUSED_SYMBOLS is not set 1298# CONFIG_UNUSED_SYMBOLS is not set
1224CONFIG_DEBUG_KERNEL=y 1299CONFIG_DEBUG_KERNEL=y
@@ -1238,9 +1313,10 @@ CONFIG_DEBUG_BUGVERBOSE=y
1238CONFIG_DEBUG_INFO=y 1313CONFIG_DEBUG_INFO=y
1239# CONFIG_DEBUG_FS is not set 1314# CONFIG_DEBUG_FS is not set
1240# CONFIG_DEBUG_VM is not set 1315# CONFIG_DEBUG_VM is not set
1316# CONFIG_DEBUG_LIST is not set
1241CONFIG_FRAME_POINTER=y 1317CONFIG_FRAME_POINTER=y
1242# CONFIG_UNWIND_INFO is not set
1243CONFIG_FORCED_INLINING=y 1318CONFIG_FORCED_INLINING=y
1319# CONFIG_HEADERS_CHECK is not set
1244# CONFIG_RCU_TORTURE_TEST is not set 1320# CONFIG_RCU_TORTURE_TEST is not set
1245CONFIG_DEBUG_USER=y 1321CONFIG_DEBUG_USER=y
1246# CONFIG_DEBUG_WAITQ is not set 1322# CONFIG_DEBUG_WAITQ is not set
@@ -1262,10 +1338,6 @@ CONFIG_DEBUG_S3C2410_UART=0
1262# CONFIG_CRYPTO is not set 1338# CONFIG_CRYPTO is not set
1263 1339
1264# 1340#
1265# Hardware crypto devices
1266#
1267
1268#
1269# Library routines 1341# Library routines
1270# 1342#
1271# CONFIG_CRC_CCITT is not set 1343# CONFIG_CRC_CCITT is not set
diff --git a/arch/arm/configs/smdk2410_defconfig b/arch/arm/configs/smdk2410_defconfig
deleted file mode 100644
index 4d123d33c7df..000000000000
--- a/arch/arm/configs/smdk2410_defconfig
+++ /dev/null
@@ -1,735 +0,0 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.12-rc1-bk2
4# Sun Mar 27 22:42:40 2005
5#
6CONFIG_ARM=y
7CONFIG_MMU=y
8CONFIG_UID16=y
9CONFIG_RWSEM_GENERIC_SPINLOCK=y
10CONFIG_GENERIC_CALIBRATE_DELAY=y
11CONFIG_GENERIC_IOMAP=y
12
13#
14# Code maturity level options
15#
16CONFIG_EXPERIMENTAL=y
17CONFIG_CLEAN_COMPILE=y
18CONFIG_BROKEN_ON_SMP=y
19
20#
21# General setup
22#
23CONFIG_LOCALVERSION=""
24CONFIG_SWAP=y
25CONFIG_SYSVIPC=y
26# CONFIG_POSIX_MQUEUE is not set
27# CONFIG_BSD_PROCESS_ACCT is not set
28CONFIG_SYSCTL=y
29# CONFIG_AUDIT is not set
30# CONFIG_HOTPLUG is not set
31CONFIG_KOBJECT_UEVENT=y
32# CONFIG_IKCONFIG is not set
33# CONFIG_EMBEDDED is not set
34CONFIG_KALLSYMS=y
35# CONFIG_KALLSYMS_ALL is not set
36# CONFIG_KALLSYMS_EXTRA_PASS is not set
37CONFIG_BASE_FULL=y
38CONFIG_FUTEX=y
39CONFIG_EPOLL=y
40CONFIG_CC_OPTIMIZE_FOR_SIZE=y
41CONFIG_SHMEM=y
42CONFIG_CC_ALIGN_FUNCTIONS=0
43CONFIG_CC_ALIGN_LABELS=0
44CONFIG_CC_ALIGN_LOOPS=0
45CONFIG_CC_ALIGN_JUMPS=0
46# CONFIG_TINY_SHMEM is not set
47CONFIG_BASE_SMALL=0
48
49#
50# Loadable module support
51#
52# CONFIG_MODULES is not set
53
54#
55# System Type
56#
57# CONFIG_ARCH_CLPS7500 is not set
58# CONFIG_ARCH_CLPS711X is not set
59# CONFIG_ARCH_CO285 is not set
60# CONFIG_ARCH_EBSA110 is not set
61# CONFIG_ARCH_FOOTBRIDGE is not set
62# CONFIG_ARCH_INTEGRATOR is not set
63# CONFIG_ARCH_IOP3XX is not set
64# CONFIG_ARCH_IXP4XX is not set
65# CONFIG_ARCH_IXP2000 is not set
66# CONFIG_ARCH_L7200 is not set
67# CONFIG_ARCH_PXA is not set
68# CONFIG_ARCH_RPC is not set
69# CONFIG_ARCH_SA1100 is not set
70CONFIG_ARCH_S3C2410=y
71# CONFIG_ARCH_SHARK is not set
72# CONFIG_ARCH_LH7A40X is not set
73# CONFIG_ARCH_OMAP is not set
74# CONFIG_ARCH_VERSATILE is not set
75# CONFIG_ARCH_IMX is not set
76# CONFIG_ARCH_H720X is not set
77
78#
79# S3C24XX Implementations
80#
81# CONFIG_ARCH_BAST is not set
82# CONFIG_ARCH_H1940 is not set
83# CONFIG_MACH_N30 is not set
84CONFIG_ARCH_SMDK2410=y
85# CONFIG_ARCH_S3C2440 is not set
86# CONFIG_MACH_VR1000 is not set
87# CONFIG_MACH_RX3715 is not set
88# CONFIG_MACH_OTOM is not set
89# CONFIG_MACH_NEXCODER_2440 is not set
90CONFIG_CPU_S3C2410=y
91
92#
93# S3C2410 Boot
94#
95
96#
97# S3C2410 Setup
98#
99# CONFIG_S3C2410_DMA is not set
100CONFIG_S3C2410_LOWLEVEL_UART_PORT=0
101
102#
103# Processor Type
104#
105CONFIG_CPU_32=y
106CONFIG_CPU_ARM920T=y
107CONFIG_CPU_32v4=y
108CONFIG_CPU_ABRT_EV4T=y
109CONFIG_CPU_CACHE_V4WT=y
110CONFIG_CPU_CACHE_VIVT=y
111CONFIG_CPU_COPY_V4WB=y
112CONFIG_CPU_TLB_V4WBI=y
113
114#
115# Processor Features
116#
117CONFIG_ARM_THUMB=y
118# CONFIG_CPU_ICACHE_DISABLE is not set
119# CONFIG_CPU_DCACHE_DISABLE is not set
120# CONFIG_CPU_DCACHE_WRITETHROUGH is not set
121
122#
123# Bus support
124#
125
126#
127# PCCARD (PCMCIA/CardBus) support
128#
129# CONFIG_PCCARD is not set
130
131#
132# Kernel Features
133#
134# CONFIG_PREEMPT is not set
135CONFIG_ALIGNMENT_TRAP=y
136
137#
138# Boot options
139#
140CONFIG_ZBOOT_ROM_TEXT=0x0
141CONFIG_ZBOOT_ROM_BSS=0x0
142CONFIG_CMDLINE="root=1f04 mem=32M"
143# CONFIG_XIP_KERNEL is not set
144
145#
146# Floating point emulation
147#
148
149#
150# At least one emulation must be selected
151#
152# CONFIG_FPE_NWFPE is not set
153# CONFIG_FPE_FASTFPE is not set
154
155#
156# Userspace binary formats
157#
158CONFIG_BINFMT_ELF=y
159CONFIG_BINFMT_AOUT=y
160# CONFIG_BINFMT_MISC is not set
161# CONFIG_ARTHUR is not set
162
163#
164# Power management options
165#
166# CONFIG_PM is not set
167
168#
169# Device Drivers
170#
171
172#
173# Generic Driver Options
174#
175CONFIG_STANDALONE=y
176CONFIG_PREVENT_FIRMWARE_BUILD=y
177# CONFIG_FW_LOADER is not set
178# CONFIG_DEBUG_DRIVER is not set
179
180#
181# Memory Technology Devices (MTD)
182#
183CONFIG_MTD=y
184# CONFIG_MTD_DEBUG is not set
185# CONFIG_MTD_CONCAT is not set
186# CONFIG_MTD_PARTITIONS is not set
187
188#
189# User Modules And Translation Layers
190#
191CONFIG_MTD_CHAR=y
192CONFIG_MTD_BLOCK=y
193# CONFIG_FTL is not set
194# CONFIG_NFTL is not set
195# CONFIG_INFTL is not set
196
197#
198# RAM/ROM/Flash chip drivers
199#
200CONFIG_MTD_CFI=y
201# CONFIG_MTD_JEDECPROBE is not set
202CONFIG_MTD_GEN_PROBE=y
203# CONFIG_MTD_CFI_ADV_OPTIONS is not set
204CONFIG_MTD_MAP_BANK_WIDTH_1=y
205CONFIG_MTD_MAP_BANK_WIDTH_2=y
206CONFIG_MTD_MAP_BANK_WIDTH_4=y
207# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
208# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
209# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
210CONFIG_MTD_CFI_I1=y
211CONFIG_MTD_CFI_I2=y
212# CONFIG_MTD_CFI_I4 is not set
213# CONFIG_MTD_CFI_I8 is not set
214CONFIG_MTD_CFI_INTELEXT=y
215# CONFIG_MTD_CFI_AMDSTD is not set
216# CONFIG_MTD_CFI_STAA is not set
217CONFIG_MTD_CFI_UTIL=y
218# CONFIG_MTD_RAM is not set
219# CONFIG_MTD_ROM is not set
220# CONFIG_MTD_ABSENT is not set
221# CONFIG_MTD_XIP is not set
222
223#
224# Mapping drivers for chip access
225#
226# CONFIG_MTD_COMPLEX_MAPPINGS is not set
227# CONFIG_MTD_PHYSMAP is not set
228# CONFIG_MTD_ARM_INTEGRATOR is not set
229# CONFIG_MTD_EDB7312 is not set
230
231#
232# Self-contained MTD device drivers
233#
234# CONFIG_MTD_SLRAM is not set
235# CONFIG_MTD_PHRAM is not set
236# CONFIG_MTD_MTDRAM is not set
237# CONFIG_MTD_BLKMTD is not set
238# CONFIG_MTD_BLOCK2MTD is not set
239
240#
241# Disk-On-Chip Device Drivers
242#
243# CONFIG_MTD_DOC2000 is not set
244# CONFIG_MTD_DOC2001 is not set
245# CONFIG_MTD_DOC2001PLUS is not set
246
247#
248# NAND Flash Device Drivers
249#
250# CONFIG_MTD_NAND is not set
251
252#
253# Parallel port support
254#
255# CONFIG_PARPORT is not set
256
257#
258# Plug and Play support
259#
260
261#
262# Block devices
263#
264# CONFIG_BLK_DEV_FD is not set
265# CONFIG_BLK_DEV_COW_COMMON is not set
266# CONFIG_BLK_DEV_LOOP is not set
267# CONFIG_BLK_DEV_NBD is not set
268CONFIG_BLK_DEV_RAM=y
269CONFIG_BLK_DEV_RAM_COUNT=16
270CONFIG_BLK_DEV_RAM_SIZE=4096
271# CONFIG_BLK_DEV_INITRD is not set
272CONFIG_INITRAMFS_SOURCE=""
273# CONFIG_CDROM_PKTCDVD is not set
274
275#
276# IO Schedulers
277#
278CONFIG_IOSCHED_NOOP=y
279CONFIG_IOSCHED_AS=y
280CONFIG_IOSCHED_DEADLINE=y
281CONFIG_IOSCHED_CFQ=y
282# CONFIG_ATA_OVER_ETH is not set
283
284#
285# ATA/ATAPI/MFM/RLL support
286#
287# CONFIG_IDE is not set
288
289#
290# SCSI device support
291#
292# CONFIG_SCSI is not set
293
294#
295# Multi-device support (RAID and LVM)
296#
297# CONFIG_MD is not set
298
299#
300# Fusion MPT device support
301#
302
303#
304# IEEE 1394 (FireWire) support
305#
306
307#
308# I2O device support
309#
310
311#
312# Networking support
313#
314CONFIG_NET=y
315
316#
317# Networking options
318#
319# CONFIG_PACKET is not set
320# CONFIG_NETLINK_DEV is not set
321CONFIG_UNIX=y
322# CONFIG_NET_KEY is not set
323CONFIG_INET=y
324# CONFIG_IP_MULTICAST is not set
325# CONFIG_IP_ADVANCED_ROUTER is not set
326CONFIG_IP_PNP=y
327# CONFIG_IP_PNP_DHCP is not set
328CONFIG_IP_PNP_BOOTP=y
329# CONFIG_IP_PNP_RARP is not set
330# CONFIG_NET_IPIP is not set
331# CONFIG_NET_IPGRE is not set
332# CONFIG_ARPD is not set
333# CONFIG_SYN_COOKIES is not set
334# CONFIG_INET_AH is not set
335# CONFIG_INET_ESP is not set
336# CONFIG_INET_IPCOMP is not set
337# CONFIG_INET_TUNNEL is not set
338# CONFIG_IP_TCPDIAG is not set
339# CONFIG_IP_TCPDIAG_IPV6 is not set
340# CONFIG_IPV6 is not set
341# CONFIG_NETFILTER is not set
342
343#
344# SCTP Configuration (EXPERIMENTAL)
345#
346# CONFIG_IP_SCTP is not set
347# CONFIG_ATM is not set
348# CONFIG_BRIDGE is not set
349# CONFIG_VLAN_8021Q is not set
350# CONFIG_DECNET is not set
351# CONFIG_LLC2 is not set
352# CONFIG_IPX is not set
353# CONFIG_ATALK is not set
354# CONFIG_X25 is not set
355# CONFIG_LAPB is not set
356# CONFIG_NET_DIVERT is not set
357# CONFIG_ECONET is not set
358# CONFIG_WAN_ROUTER is not set
359
360#
361# QoS and/or fair queueing
362#
363# CONFIG_NET_SCHED is not set
364# CONFIG_NET_CLS_ROUTE is not set
365
366#
367# Network testing
368#
369# CONFIG_NET_PKTGEN is not set
370# CONFIG_NETPOLL is not set
371# CONFIG_NET_POLL_CONTROLLER is not set
372# CONFIG_HAMRADIO is not set
373# CONFIG_IRDA is not set
374# CONFIG_BT is not set
375CONFIG_NETDEVICES=y
376# CONFIG_DUMMY is not set
377# CONFIG_BONDING is not set
378# CONFIG_EQUALIZER is not set
379# CONFIG_TUN is not set
380
381#
382# Ethernet (10 or 100Mbit)
383#
384CONFIG_NET_ETHERNET=y
385# CONFIG_MII is not set
386# CONFIG_SMC91X is not set
387
388#
389# Ethernet (1000 Mbit)
390#
391
392#
393# Ethernet (10000 Mbit)
394#
395
396#
397# Token Ring devices
398#
399
400#
401# Wireless LAN (non-hamradio)
402#
403# CONFIG_NET_RADIO is not set
404
405#
406# Wan interfaces
407#
408# CONFIG_WAN is not set
409# CONFIG_PPP is not set
410# CONFIG_SLIP is not set
411# CONFIG_SHAPER is not set
412# CONFIG_NETCONSOLE is not set
413
414#
415# ISDN subsystem
416#
417# CONFIG_ISDN is not set
418
419#
420# Input device support
421#
422CONFIG_INPUT=y
423
424#
425# Userland interfaces
426#
427CONFIG_INPUT_MOUSEDEV=y
428CONFIG_INPUT_MOUSEDEV_PSAUX=y
429CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
430CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
431# CONFIG_INPUT_JOYDEV is not set
432# CONFIG_INPUT_TSDEV is not set
433# CONFIG_INPUT_EVDEV is not set
434# CONFIG_INPUT_EVBUG is not set
435
436#
437# Input Device Drivers
438#
439CONFIG_INPUT_KEYBOARD=y
440CONFIG_KEYBOARD_ATKBD=y
441# CONFIG_KEYBOARD_SUNKBD is not set
442# CONFIG_KEYBOARD_LKKBD is not set
443# CONFIG_KEYBOARD_XTKBD is not set
444# CONFIG_KEYBOARD_NEWTON is not set
445CONFIG_INPUT_MOUSE=y
446CONFIG_MOUSE_PS2=y
447# CONFIG_MOUSE_SERIAL is not set
448# CONFIG_MOUSE_VSXXXAA is not set
449# CONFIG_INPUT_JOYSTICK is not set
450# CONFIG_INPUT_TOUCHSCREEN is not set
451# CONFIG_INPUT_MISC is not set
452
453#
454# Hardware I/O ports
455#
456CONFIG_SERIO=y
457CONFIG_SERIO_SERPORT=y
458CONFIG_SERIO_LIBPS2=y
459# CONFIG_SERIO_RAW is not set
460# CONFIG_GAMEPORT is not set
461CONFIG_SOUND_GAMEPORT=y
462
463#
464# Character devices
465#
466CONFIG_VT=y
467CONFIG_VT_CONSOLE=y
468CONFIG_HW_CONSOLE=y
469# CONFIG_SERIAL_NONSTANDARD is not set
470
471#
472# Serial drivers
473#
474# CONFIG_SERIAL_8250 is not set
475
476#
477# Non-8250 serial port support
478#
479CONFIG_SERIAL_S3C2410=y
480CONFIG_SERIAL_S3C2410_CONSOLE=y
481CONFIG_SERIAL_CORE=y
482CONFIG_SERIAL_CORE_CONSOLE=y
483CONFIG_UNIX98_PTYS=y
484CONFIG_LEGACY_PTYS=y
485CONFIG_LEGACY_PTY_COUNT=256
486
487#
488# IPMI
489#
490# CONFIG_IPMI_HANDLER is not set
491
492#
493# Watchdog Cards
494#
495# CONFIG_WATCHDOG is not set
496# CONFIG_NVRAM is not set
497# CONFIG_RTC is not set
498# CONFIG_S3C2410_RTC is not set
499# CONFIG_DTLK is not set
500# CONFIG_R3964 is not set
501
502#
503# Ftape, the floppy tape device driver
504#
505# CONFIG_DRM is not set
506# CONFIG_RAW_DRIVER is not set
507
508#
509# TPM devices
510#
511# CONFIG_TCG_TPM is not set
512
513#
514# I2C support
515#
516# CONFIG_I2C is not set
517
518#
519# Misc devices
520#
521
522#
523# Multimedia devices
524#
525# CONFIG_VIDEO_DEV is not set
526
527#
528# Digital Video Broadcasting Devices
529#
530# CONFIG_DVB is not set
531
532#
533# Graphics support
534#
535CONFIG_FB=y
536CONFIG_FB_CFB_FILLRECT=y
537CONFIG_FB_CFB_COPYAREA=y
538CONFIG_FB_CFB_IMAGEBLIT=y
539CONFIG_FB_SOFT_CURSOR=y
540# CONFIG_FB_MODE_HELPERS is not set
541# CONFIG_FB_TILEBLITTING is not set
542CONFIG_FB_VIRTUAL=y
543
544#
545# Console display driver support
546#
547# CONFIG_VGA_CONSOLE is not set
548CONFIG_DUMMY_CONSOLE=y
549CONFIG_FRAMEBUFFER_CONSOLE=y
550# CONFIG_FONTS is not set
551CONFIG_FONT_8x8=y
552CONFIG_FONT_8x16=y
553
554#
555# Logo configuration
556#
557# CONFIG_LOGO is not set
558# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
559
560#
561# Sound
562#
563# CONFIG_SOUND is not set
564
565#
566# USB support
567#
568CONFIG_USB_ARCH_HAS_HCD=y
569# CONFIG_USB_ARCH_HAS_OHCI is not set
570# CONFIG_USB is not set
571
572#
573# USB Gadget Support
574#
575# CONFIG_USB_GADGET is not set
576
577#
578# MMC/SD Card support
579#
580# CONFIG_MMC is not set
581
582#
583# File systems
584#
585CONFIG_EXT2_FS=y
586# CONFIG_EXT2_FS_XATTR is not set
587# CONFIG_EXT3_FS is not set
588# CONFIG_JBD is not set
589# CONFIG_REISERFS_FS is not set
590# CONFIG_JFS_FS is not set
591
592#
593# XFS support
594#
595# CONFIG_XFS_FS is not set
596# CONFIG_MINIX_FS is not set
597CONFIG_ROMFS_FS=y
598# CONFIG_QUOTA is not set
599CONFIG_DNOTIFY=y
600# CONFIG_AUTOFS_FS is not set
601# CONFIG_AUTOFS4_FS is not set
602
603#
604# CD-ROM/DVD Filesystems
605#
606# CONFIG_ISO9660_FS is not set
607# CONFIG_UDF_FS is not set
608
609#
610# DOS/FAT/NT Filesystems
611#
612# CONFIG_MSDOS_FS is not set
613# CONFIG_VFAT_FS is not set
614# CONFIG_NTFS_FS is not set
615
616#
617# Pseudo filesystems
618#
619CONFIG_PROC_FS=y
620CONFIG_SYSFS=y
621# CONFIG_DEVFS_FS is not set
622# CONFIG_DEVPTS_FS_XATTR is not set
623# CONFIG_TMPFS is not set
624# CONFIG_HUGETLB_PAGE is not set
625CONFIG_RAMFS=y
626
627#
628# Miscellaneous filesystems
629#
630# CONFIG_ADFS_FS is not set
631# CONFIG_AFFS_FS is not set
632# CONFIG_HFS_FS is not set
633# CONFIG_HFSPLUS_FS is not set
634# CONFIG_BEFS_FS is not set
635# CONFIG_BFS_FS is not set
636# CONFIG_EFS_FS is not set
637# CONFIG_JFFS_FS is not set
638# CONFIG_JFFS2_FS is not set
639# CONFIG_CRAMFS is not set
640# CONFIG_VXFS_FS is not set
641# CONFIG_HPFS_FS is not set
642# CONFIG_QNX4FS_FS is not set
643# CONFIG_SYSV_FS is not set
644# CONFIG_UFS_FS is not set
645
646#
647# Network File Systems
648#
649CONFIG_NFS_FS=y
650# CONFIG_NFS_V3 is not set
651# CONFIG_NFS_V4 is not set
652# CONFIG_NFS_DIRECTIO is not set
653# CONFIG_NFSD is not set
654CONFIG_ROOT_NFS=y
655CONFIG_LOCKD=y
656CONFIG_SUNRPC=y
657# CONFIG_RPCSEC_GSS_KRB5 is not set
658# CONFIG_RPCSEC_GSS_SPKM3 is not set
659# CONFIG_SMB_FS is not set
660# CONFIG_CIFS is not set
661# CONFIG_NCP_FS is not set
662# CONFIG_CODA_FS is not set
663# CONFIG_AFS_FS is not set
664
665#
666# Partition Types
667#
668CONFIG_PARTITION_ADVANCED=y
669# CONFIG_ACORN_PARTITION is not set
670# CONFIG_OSF_PARTITION is not set
671# CONFIG_AMIGA_PARTITION is not set
672# CONFIG_ATARI_PARTITION is not set
673# CONFIG_MAC_PARTITION is not set
674# CONFIG_MSDOS_PARTITION is not set
675# CONFIG_LDM_PARTITION is not set
676# CONFIG_SGI_PARTITION is not set
677# CONFIG_ULTRIX_PARTITION is not set
678# CONFIG_SUN_PARTITION is not set
679# CONFIG_EFI_PARTITION is not set
680
681#
682# Native Language Support
683#
684# CONFIG_NLS is not set
685
686#
687# Profiling support
688#
689# CONFIG_PROFILING is not set
690
691#
692# Kernel hacking
693#
694# CONFIG_PRINTK_TIME is not set
695CONFIG_DEBUG_KERNEL=y
696# CONFIG_MAGIC_SYSRQ is not set
697CONFIG_LOG_BUF_SHIFT=14
698# CONFIG_SCHEDSTATS is not set
699# CONFIG_DEBUG_SLAB is not set
700# CONFIG_DEBUG_SPINLOCK is not set
701# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
702# CONFIG_DEBUG_KOBJECT is not set
703CONFIG_DEBUG_BUGVERBOSE=y
704# CONFIG_DEBUG_INFO is not set
705# CONFIG_DEBUG_FS is not set
706CONFIG_FRAME_POINTER=y
707CONFIG_DEBUG_USER=y
708# CONFIG_DEBUG_WAITQ is not set
709# CONFIG_DEBUG_ERRORS is not set
710CONFIG_DEBUG_LL=y
711# CONFIG_DEBUG_ICEDCC is not set
712CONFIG_DEBUG_S3C2410_PORT=y
713CONFIG_DEBUG_S3C2410_UART=0
714
715#
716# Security options
717#
718# CONFIG_KEYS is not set
719# CONFIG_SECURITY is not set
720
721#
722# Cryptographic options
723#
724# CONFIG_CRYPTO is not set
725
726#
727# Hardware crypto devices
728#
729
730#
731# Library routines
732#
733# CONFIG_CRC_CCITT is not set
734CONFIG_CRC32=y
735CONFIG_LIBCRC32C=y
diff --git a/arch/arm/configs/versatile_defconfig b/arch/arm/configs/versatile_defconfig
index 96b7a7762426..f7bf6ef27d19 100644
--- a/arch/arm/configs/versatile_defconfig
+++ b/arch/arm/configs/versatile_defconfig
@@ -200,7 +200,7 @@ CONFIG_BINFMT_ELF=y
200# Power management options 200# Power management options
201# 201#
202CONFIG_PM=y 202CONFIG_PM=y
203CONFIG_PM_LEGACY=y 203# CONFIG_PM_LEGACY is not set
204# CONFIG_PM_DEBUG is not set 204# CONFIG_PM_DEBUG is not set
205# CONFIG_APM is not set 205# CONFIG_APM is not set
206 206
diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
index da69e660574b..4779f474f911 100644
--- a/arch/arm/kernel/armksyms.c
+++ b/arch/arm/kernel/armksyms.c
@@ -178,9 +178,3 @@ EXPORT_SYMBOL(_find_next_zero_bit_be);
178EXPORT_SYMBOL(_find_first_bit_be); 178EXPORT_SYMBOL(_find_first_bit_be);
179EXPORT_SYMBOL(_find_next_bit_be); 179EXPORT_SYMBOL(_find_next_bit_be);
180#endif 180#endif
181
182 /* syscalls */
183EXPORT_SYMBOL(sys_write);
184EXPORT_SYMBOL(sys_lseek);
185EXPORT_SYMBOL(sys_exit);
186EXPORT_SYMBOL(sys_wait4);
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 6bbd93dd186a..29efc9f82057 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -357,6 +357,9 @@ static void __init setup_processor(void)
357#ifndef CONFIG_VFP 357#ifndef CONFIG_VFP
358 elf_hwcap &= ~HWCAP_VFP; 358 elf_hwcap &= ~HWCAP_VFP;
359#endif 359#endif
360#ifndef CONFIG_IWMMXT
361 elf_hwcap &= ~HWCAP_IWMMXT;
362#endif
360 363
361 cpu_proc_init(); 364 cpu_proc_init();
362} 365}
@@ -854,6 +857,7 @@ static const char *hwcap_str[] = {
854 "vfp", 857 "vfp",
855 "edsp", 858 "edsp",
856 "java", 859 "java",
860 "iwmmxt",
857 NULL 861 NULL
858}; 862};
859 863
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 421329f5e18e..a07d202143c3 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -7,6 +7,7 @@
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 */ 9 */
10#include <linux/module.h>
10#include <linux/delay.h> 11#include <linux/delay.h>
11#include <linux/init.h> 12#include <linux/init.h>
12#include <linux/spinlock.h> 13#include <linux/spinlock.h>
@@ -19,6 +20,7 @@
19#include <linux/cpu.h> 20#include <linux/cpu.h>
20#include <linux/smp.h> 21#include <linux/smp.h>
21#include <linux/seq_file.h> 22#include <linux/seq_file.h>
23#include <linux/irq.h>
22 24
23#include <asm/atomic.h> 25#include <asm/atomic.h>
24#include <asm/cacheflush.h> 26#include <asm/cacheflush.h>
@@ -474,25 +476,26 @@ void show_local_irqs(struct seq_file *p)
474 seq_putc(p, '\n'); 476 seq_putc(p, '\n');
475} 477}
476 478
477static void ipi_timer(struct pt_regs *regs) 479static void ipi_timer(void)
478{ 480{
479 int user = user_mode(regs);
480
481 irq_enter(); 481 irq_enter();
482 profile_tick(CPU_PROFILING, regs); 482 profile_tick(CPU_PROFILING);
483 update_process_times(user); 483 update_process_times(user_mode(get_irq_regs()));
484 irq_exit(); 484 irq_exit();
485} 485}
486 486
487#ifdef CONFIG_LOCAL_TIMERS 487#ifdef CONFIG_LOCAL_TIMERS
488asmlinkage void do_local_timer(struct pt_regs *regs) 488asmlinkage void do_local_timer(struct pt_regs *regs)
489{ 489{
490 struct pt_regs *old_regs = set_irq_regs(regs);
490 int cpu = smp_processor_id(); 491 int cpu = smp_processor_id();
491 492
492 if (local_timer_ack()) { 493 if (local_timer_ack()) {
493 irq_stat[cpu].local_timer_irqs++; 494 irq_stat[cpu].local_timer_irqs++;
494 ipi_timer(regs); 495 ipi_timer();
495 } 496 }
497
498 set_irq_regs(old_regs);
496} 499}
497#endif 500#endif
498 501
@@ -551,6 +554,7 @@ asmlinkage void do_IPI(struct pt_regs *regs)
551{ 554{
552 unsigned int cpu = smp_processor_id(); 555 unsigned int cpu = smp_processor_id();
553 struct ipi_data *ipi = &per_cpu(ipi_data, cpu); 556 struct ipi_data *ipi = &per_cpu(ipi_data, cpu);
557 struct pt_regs *old_regs = set_irq_regs(regs);
554 558
555 ipi->ipi_count++; 559 ipi->ipi_count++;
556 560
@@ -574,7 +578,7 @@ asmlinkage void do_IPI(struct pt_regs *regs)
574 578
575 switch (nextmsg) { 579 switch (nextmsg) {
576 case IPI_TIMER: 580 case IPI_TIMER:
577 ipi_timer(regs); 581 ipi_timer();
578 break; 582 break;
579 583
580 case IPI_RESCHEDULE: 584 case IPI_RESCHEDULE:
@@ -599,6 +603,8 @@ asmlinkage void do_IPI(struct pt_regs *regs)
599 } 603 }
600 } while (msgs); 604 } while (msgs);
601 } 605 }
606
607 set_irq_regs(old_regs);
602} 608}
603 609
604void smp_send_reschedule(int cpu) 610void smp_send_reschedule(int cpu)
diff --git a/arch/arm/kernel/time.c b/arch/arm/kernel/time.c
index c03cab5c4c79..6ff5e3ff6cb5 100644
--- a/arch/arm/kernel/time.c
+++ b/arch/arm/kernel/time.c
@@ -220,10 +220,10 @@ EXPORT_SYMBOL(leds_event);
220#ifdef CONFIG_LEDS_TIMER 220#ifdef CONFIG_LEDS_TIMER
221static inline void do_leds(void) 221static inline void do_leds(void)
222{ 222{
223 static unsigned int count = 50; 223 static unsigned int count = HZ/2;
224 224
225 if (--count == 0) { 225 if (--count == 0) {
226 count = 50; 226 count = HZ/2;
227 leds_event(led_timer); 227 leds_event(led_timer);
228 } 228 }
229} 229}
@@ -327,13 +327,12 @@ EXPORT_SYMBOL(restore_time_delta);
327 */ 327 */
328void timer_tick(void) 328void timer_tick(void)
329{ 329{
330 struct pt_regs *regs = get_irq_regs();
331 profile_tick(CPU_PROFILING); 330 profile_tick(CPU_PROFILING);
332 do_leds(); 331 do_leds();
333 do_set_rtc(); 332 do_set_rtc();
334 do_timer(1); 333 do_timer(1);
335#ifndef CONFIG_SMP 334#ifndef CONFIG_SMP
336 update_process_times(user_mode(regs)); 335 update_process_times(user_mode(get_irq_regs()));
337#endif 336#endif
338} 337}
339 338
diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
index 3ca574ee2772..a8fa75ea07a9 100644
--- a/arch/arm/kernel/vmlinux.lds.S
+++ b/arch/arm/kernel/vmlinux.lds.S
@@ -45,13 +45,7 @@ SECTIONS
45 *(.early_param.init) 45 *(.early_param.init)
46 __early_end = .; 46 __early_end = .;
47 __initcall_start = .; 47 __initcall_start = .;
48 *(.initcall1.init) 48 INITCALLS
49 *(.initcall2.init)
50 *(.initcall3.init)
51 *(.initcall4.init)
52 *(.initcall5.init)
53 *(.initcall6.init)
54 *(.initcall7.init)
55 __initcall_end = .; 49 __initcall_end = .;
56 __con_initcall_start = .; 50 __con_initcall_start = .;
57 *(.con_initcall.init) 51 *(.con_initcall.init)
diff --git a/arch/arm/mach-footbridge/dc21285.c b/arch/arm/mach-footbridge/dc21285.c
index fa5d4976f514..1463330ed8ee 100644
--- a/arch/arm/mach-footbridge/dc21285.c
+++ b/arch/arm/mach-footbridge/dc21285.c
@@ -16,6 +16,7 @@
16#include <linux/slab.h> 16#include <linux/slab.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/ioport.h> 18#include <linux/ioport.h>
19#include <linux/irq.h>
19 20
20#include <asm/io.h> 21#include <asm/io.h>
21#include <asm/irq.h> 22#include <asm/irq.h>
diff --git a/arch/arm/mach-iop32x/n2100.c b/arch/arm/mach-iop32x/n2100.c
index a2c94a47b2b2..2499a7707e3c 100644
--- a/arch/arm/mach-iop32x/n2100.c
+++ b/arch/arm/mach-iop32x/n2100.c
@@ -85,7 +85,7 @@ n2100_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
85 irq = IRQ_IOP32X_XINT0; 85 irq = IRQ_IOP32X_XINT0;
86 } else if (PCI_SLOT(dev->devfn) == 2) { 86 } else if (PCI_SLOT(dev->devfn) == 2) {
87 /* RTL8110SB #2 */ 87 /* RTL8110SB #2 */
88 irq = IRQ_IOP32X_XINT1; 88 irq = IRQ_IOP32X_XINT3;
89 } else if (PCI_SLOT(dev->devfn) == 3) { 89 } else if (PCI_SLOT(dev->devfn) == 3) {
90 /* Sil3512 */ 90 /* Sil3512 */
91 irq = IRQ_IOP32X_XINT2; 91 irq = IRQ_IOP32X_XINT2;
diff --git a/arch/arm/mach-ixp2000/ixdp2400.c b/arch/arm/mach-ixp2000/ixdp2400.c
index a6f14801872d..0fdd03ab36e6 100644
--- a/arch/arm/mach-ixp2000/ixdp2400.c
+++ b/arch/arm/mach-ixp2000/ixdp2400.c
@@ -133,11 +133,13 @@ static void ixdp2400_pci_postinit(void)
133 struct pci_dev *dev; 133 struct pci_dev *dev;
134 134
135 if (ixdp2x00_master_npu()) { 135 if (ixdp2x00_master_npu()) {
136 dev = pci_find_slot(1, IXDP2400_SLAVE_ENET_DEVFN); 136 dev = pci_get_bus_and_slot(1, IXDP2400_SLAVE_ENET_DEVFN);
137 pci_remove_bus_device(dev); 137 pci_remove_bus_device(dev);
138 pci_dev_put(dev);
138 } else { 139 } else {
139 dev = pci_find_slot(1, IXDP2400_MASTER_ENET_DEVFN); 140 dev = pci_get_bus_and_slot(1, IXDP2400_MASTER_ENET_DEVFN);
140 pci_remove_bus_device(dev); 141 pci_remove_bus_device(dev);
142 pci_dev_put(dev);
141 143
142 ixdp2x00_slave_pci_postinit(); 144 ixdp2x00_slave_pci_postinit();
143 } 145 }
diff --git a/arch/arm/mach-ixp2000/ixdp2800.c b/arch/arm/mach-ixp2000/ixdp2800.c
index 91d36d91dac0..70d247f09a7e 100644
--- a/arch/arm/mach-ixp2000/ixdp2800.c
+++ b/arch/arm/mach-ixp2000/ixdp2800.c
@@ -261,14 +261,16 @@ int __init ixdp2800_pci_init(void)
261 261
262 pci_common_init(&ixdp2800_pci); 262 pci_common_init(&ixdp2800_pci);
263 if (ixdp2x00_master_npu()) { 263 if (ixdp2x00_master_npu()) {
264 dev = pci_find_slot(1, IXDP2800_SLAVE_ENET_DEVFN); 264 dev = pci_get_bus_and_slot(1, IXDP2800_SLAVE_ENET_DEVFN);
265 pci_remove_bus_device(dev); 265 pci_remove_bus_device(dev);
266 pci_dev_put(dev);
266 267
267 ixdp2800_master_enable_slave(); 268 ixdp2800_master_enable_slave();
268 ixdp2800_master_wait_for_slave_bus_scan(); 269 ixdp2800_master_wait_for_slave_bus_scan();
269 } else { 270 } else {
270 dev = pci_find_slot(1, IXDP2800_MASTER_ENET_DEVFN); 271 dev = pci_get_bus_and_slot(1, IXDP2800_MASTER_ENET_DEVFN);
271 pci_remove_bus_device(dev); 272 pci_remove_bus_device(dev);
273 pci_dev_put(dev);
272 } 274 }
273 } 275 }
274 276
diff --git a/arch/arm/mach-ixp2000/ixdp2x00.c b/arch/arm/mach-ixp2000/ixdp2x00.c
index af48cb52dfc4..aa2655092d2d 100644
--- a/arch/arm/mach-ixp2000/ixdp2x00.c
+++ b/arch/arm/mach-ixp2000/ixdp2x00.c
@@ -241,11 +241,14 @@ void ixdp2x00_slave_pci_postinit(void)
241 /* 241 /*
242 * Remove PMC device is there is one 242 * Remove PMC device is there is one
243 */ 243 */
244 if((dev = pci_find_slot(1, IXDP2X00_PMC_DEVFN))) 244 if((dev = pci_get_bus_and_slot(1, IXDP2X00_PMC_DEVFN))) {
245 pci_remove_bus_device(dev); 245 pci_remove_bus_device(dev);
246 pci_dev_put(dev);
247 }
246 248
247 dev = pci_find_slot(0, IXDP2X00_21555_DEVFN); 249 dev = pci_get_bus_and_slot(0, IXDP2X00_21555_DEVFN);
248 pci_remove_bus_device(dev); 250 pci_remove_bus_device(dev);
251 pci_dev_put(dev);
249} 252}
250 253
251/************************************************************************** 254/**************************************************************************
diff --git a/arch/arm/mach-ixp4xx/common.c b/arch/arm/mach-ixp4xx/common.c
index c7513f6eb50c..fbe288a8da65 100644
--- a/arch/arm/mach-ixp4xx/common.c
+++ b/arch/arm/mach-ixp4xx/common.c
@@ -86,7 +86,8 @@ enum ixp4xx_irq_type {
86 IXP4XX_IRQ_LEVEL, IXP4XX_IRQ_EDGE 86 IXP4XX_IRQ_LEVEL, IXP4XX_IRQ_EDGE
87}; 87};
88 88
89static void ixp4xx_config_irq(unsigned irq, enum ixp4xx_irq_type type); 89/* Each bit represents an IRQ: 1: edge-triggered, 0: level triggered */
90static unsigned long long ixp4xx_irq_edge = 0;
90 91
91/* 92/*
92 * IRQ -> GPIO mapping table 93 * IRQ -> GPIO mapping table
@@ -135,7 +136,11 @@ static int ixp4xx_set_irq_type(unsigned int irq, unsigned int type)
135 default: 136 default:
136 return -EINVAL; 137 return -EINVAL;
137 } 138 }
138 ixp4xx_config_irq(irq, irq_type); 139
140 if (irq_type == IXP4XX_IRQ_EDGE)
141 ixp4xx_irq_edge |= (1 << irq);
142 else
143 ixp4xx_irq_edge &= ~(1 << irq);
139 144
140 if (line >= 8) { /* pins 8-15 */ 145 if (line >= 8) { /* pins 8-15 */
141 line -= 8; 146 line -= 8;
@@ -167,14 +172,6 @@ static void ixp4xx_irq_mask(unsigned int irq)
167 *IXP4XX_ICMR &= ~(1 << irq); 172 *IXP4XX_ICMR &= ~(1 << irq);
168} 173}
169 174
170static void ixp4xx_irq_unmask(unsigned int irq)
171{
172 if (cpu_is_ixp46x() && irq >= 32)
173 *IXP4XX_ICMR2 |= (1 << (irq - 32));
174 else
175 *IXP4XX_ICMR |= (1 << irq);
176}
177
178static void ixp4xx_irq_ack(unsigned int irq) 175static void ixp4xx_irq_ack(unsigned int irq)
179{ 176{
180 int line = (irq < 32) ? irq2gpio[irq] : -1; 177 int line = (irq < 32) ? irq2gpio[irq] : -1;
@@ -187,41 +184,25 @@ static void ixp4xx_irq_ack(unsigned int irq)
187 * Level triggered interrupts on GPIO lines can only be cleared when the 184 * Level triggered interrupts on GPIO lines can only be cleared when the
188 * interrupt condition disappears. 185 * interrupt condition disappears.
189 */ 186 */
190static void ixp4xx_irq_level_unmask(unsigned int irq) 187static void ixp4xx_irq_unmask(unsigned int irq)
191{ 188{
192 ixp4xx_irq_ack(irq); 189 if (!(ixp4xx_irq_edge & (1 << irq)))
193 ixp4xx_irq_unmask(irq); 190 ixp4xx_irq_ack(irq);
194}
195 191
196static struct irqchip ixp4xx_irq_level_chip = { 192 if (cpu_is_ixp46x() && irq >= 32)
197 .ack = ixp4xx_irq_mask, 193 *IXP4XX_ICMR2 |= (1 << (irq - 32));
198 .mask = ixp4xx_irq_mask, 194 else
199 .unmask = ixp4xx_irq_level_unmask, 195 *IXP4XX_ICMR |= (1 << irq);
200 .set_type = ixp4xx_set_irq_type, 196}
201};
202 197
203static struct irqchip ixp4xx_irq_edge_chip = { 198static struct irqchip ixp4xx_irq_chip = {
199 .name = "IXP4xx",
204 .ack = ixp4xx_irq_ack, 200 .ack = ixp4xx_irq_ack,
205 .mask = ixp4xx_irq_mask, 201 .mask = ixp4xx_irq_mask,
206 .unmask = ixp4xx_irq_unmask, 202 .unmask = ixp4xx_irq_unmask,
207 .set_type = ixp4xx_set_irq_type, 203 .set_type = ixp4xx_set_irq_type,
208}; 204};
209 205
210static void ixp4xx_config_irq(unsigned irq, enum ixp4xx_irq_type type)
211{
212 switch (type) {
213 case IXP4XX_IRQ_LEVEL:
214 set_irq_chip(irq, &ixp4xx_irq_level_chip);
215 set_irq_handler(irq, do_level_IRQ);
216 break;
217 case IXP4XX_IRQ_EDGE:
218 set_irq_chip(irq, &ixp4xx_irq_edge_chip);
219 set_irq_handler(irq, do_edge_IRQ);
220 break;
221 }
222 set_irq_flags(irq, IRQF_VALID);
223}
224
225void __init ixp4xx_init_irq(void) 206void __init ixp4xx_init_irq(void)
226{ 207{
227 int i = 0; 208 int i = 0;
@@ -241,8 +222,11 @@ void __init ixp4xx_init_irq(void)
241 } 222 }
242 223
243 /* Default to all level triggered */ 224 /* Default to all level triggered */
244 for(i = 0; i < NR_IRQS; i++) 225 for(i = 0; i < NR_IRQS; i++) {
245 ixp4xx_config_irq(i, IXP4XX_IRQ_LEVEL); 226 set_irq_chip(i, &ixp4xx_irq_chip);
227 set_irq_handler(i, do_level_IRQ);
228 set_irq_flags(i, IRQF_VALID);
229 }
246} 230}
247 231
248 232
diff --git a/arch/arm/mach-lh7a40x/Kconfig b/arch/arm/mach-lh7a40x/Kconfig
index 558a34f53b1c..147b01928a9b 100644
--- a/arch/arm/mach-lh7a40x/Kconfig
+++ b/arch/arm/mach-lh7a40x/Kconfig
@@ -14,7 +14,7 @@ config MACH_LPD7A400
14 bool "LPD7A400 Card Engine" 14 bool "LPD7A400 Card Engine"
15 select ARCH_LH7A400 15 select ARCH_LH7A400
16# select IDE_POLL 16# select IDE_POLL
17 select HAS_TOUCHSCREEN_ADS7843_LH7 17# select HAS_TOUCHSCREEN_ADS7843_LH7
18 help 18 help
19 Say Y here if you are using Logic Product Development's 19 Say Y here if you are using Logic Product Development's
20 LPD7A400 CardEngine. For the time being, the LPD7A400 and 20 LPD7A400 CardEngine. For the time being, the LPD7A400 and
@@ -24,7 +24,7 @@ config MACH_LPD7A404
24 bool "LPD7A404 Card Engine" 24 bool "LPD7A404 Card Engine"
25 select ARCH_LH7A404 25 select ARCH_LH7A404
26# select IDE_POLL 26# select IDE_POLL
27 select HAS_TOUCHSCREEN_ADC_LH7 27# select HAS_TOUCHSCREEN_ADC_LH7
28 help 28 help
29 Say Y here if you are using Logic Product Development's 29 Say Y here if you are using Logic Product Development's
30 LPD7A404 CardEngine. For the time being, the LPD7A400 and 30 LPD7A404 CardEngine. For the time being, the LPD7A400 and
diff --git a/arch/arm/mach-lh7a40x/common.h b/arch/arm/mach-lh7a40x/common.h
index 18e8bb4eb202..0ca20c6c83b7 100644
--- a/arch/arm/mach-lh7a40x/common.h
+++ b/arch/arm/mach-lh7a40x/common.h
@@ -15,4 +15,4 @@ extern void lh7a404_init_irq (void);
15extern void lh7a40x_clcd_init (void); 15extern void lh7a40x_clcd_init (void);
16extern void lh7a40x_init_board_irq (void); 16extern void lh7a40x_init_board_irq (void);
17 17
18#define IRQ_DISPATCH(irq) desc_handle_irq((irq),(irq_desc + irq), regs) 18#define IRQ_DISPATCH(irq) desc_handle_irq((irq),(irq_desc + irq))
diff --git a/arch/arm/mach-pnx4008/core.c b/arch/arm/mach-pnx4008/core.c
index 3d73c1e93752..429c796938be 100644
--- a/arch/arm/mach-pnx4008/core.c
+++ b/arch/arm/mach-pnx4008/core.c
@@ -133,10 +133,79 @@ static struct platform_device serial_device = {
133 }, 133 },
134}; 134};
135 135
136static struct platform_device nand_flash_device = {
137 .name = "pnx4008-flash",
138 .id = -1,
139 .dev = {
140 .coherent_dma_mask = 0xFFFFFFFF,
141 },
142};
143
144/* The dmamask must be set for OHCI to work */
145static u64 ohci_dmamask = ~(u32) 0;
146
147static struct resource ohci_resources[] = {
148 {
149 .start = IO_ADDRESS(PNX4008_USB_CONFIG_BASE),
150 .end = IO_ADDRESS(PNX4008_USB_CONFIG_BASE + 0x100),
151 .flags = IORESOURCE_MEM,
152 }, {
153 .start = USB_HOST_INT,
154 .flags = IORESOURCE_IRQ,
155 },
156};
157
158static struct platform_device ohci_device = {
159 .name = "pnx4008-usb-ohci",
160 .id = -1,
161 .dev = {
162 .dma_mask = &ohci_dmamask,
163 .coherent_dma_mask = 0xffffffff,
164 },
165 .num_resources = ARRAY_SIZE(ohci_resources),
166 .resource = ohci_resources,
167};
168
169static struct platform_device sdum_device = {
170 .name = "pnx4008-sdum",
171 .id = 0,
172 .dev = {
173 .coherent_dma_mask = 0xffffffff,
174 },
175};
176
177static struct platform_device rgbfb_device = {
178 .name = "pnx4008-rgbfb",
179 .id = 0,
180 .dev = {
181 .coherent_dma_mask = 0xffffffff,
182 }
183};
184
185struct resource watchdog_resources[] = {
186 {
187 .start = PNX4008_WDOG_BASE,
188 .end = PNX4008_WDOG_BASE + SZ_4K - 1,
189 .flags = IORESOURCE_MEM,
190 },
191};
192
193static struct platform_device watchdog_device = {
194 .name = "pnx4008-watchdog",
195 .id = -1,
196 .num_resources = ARRAY_SIZE(watchdog_resources),
197 .resource = watchdog_resources,
198};
199
136static struct platform_device *devices[] __initdata = { 200static struct platform_device *devices[] __initdata = {
137 &spipnx_1, 201 &spipnx_1,
138 &spipnx_2, 202 &spipnx_2,
139 &serial_device, 203 &serial_device,
204 &ohci_device,
205 &nand_flash_device,
206 &sdum_device,
207 &rgbfb_device,
208 &watchdog_device,
140}; 209};
141 210
142 211
diff --git a/arch/arm/mach-pxa/lubbock.c b/arch/arm/mach-pxa/lubbock.c
index ee80d62119d3..142c33c3dff5 100644
--- a/arch/arm/mach-pxa/lubbock.c
+++ b/arch/arm/mach-pxa/lubbock.c
@@ -397,7 +397,7 @@ static void lubbock_mmc_poll(unsigned long data)
397 if (LUB_IRQ_SET_CLR & (1 << 0)) 397 if (LUB_IRQ_SET_CLR & (1 << 0))
398 mod_timer(&mmc_timer, jiffies + MMC_POLL_RATE); 398 mod_timer(&mmc_timer, jiffies + MMC_POLL_RATE);
399 else { 399 else {
400 (void) mmc_detect_int(LUBBOCK_SD_IRQ, (void *)data, NULL); 400 (void) mmc_detect_int(LUBBOCK_SD_IRQ, (void *)data);
401 enable_irq(LUBBOCK_SD_IRQ); 401 enable_irq(LUBBOCK_SD_IRQ);
402 } 402 }
403} 403}
diff --git a/arch/arm/mach-s3c2410/gpio.c b/arch/arm/mach-s3c2410/gpio.c
index db6393c99860..ba346546150b 100644
--- a/arch/arm/mach-s3c2410/gpio.c
+++ b/arch/arm/mach-s3c2410/gpio.c
@@ -3,7 +3,7 @@
3 * Copyright (c) 2004-2005 Simtec Electronics 3 * Copyright (c) 2004-2005 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk> 4 * Ben Dooks <ben@simtec.co.uk>
5 * 5 *
6 * S3C2410 GPIO support 6 * S3C24XX GPIO support
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
@@ -163,3 +163,22 @@ unsigned int s3c2410_modify_misccr(unsigned int clear, unsigned int change)
163} 163}
164 164
165EXPORT_SYMBOL(s3c2410_modify_misccr); 165EXPORT_SYMBOL(s3c2410_modify_misccr);
166
167int s3c2410_gpio_getirq(unsigned int pin)
168{
169 if (pin < S3C2410_GPF0 || pin > S3C2410_GPG15)
170 return -1; /* not valid interrupts */
171
172 if (pin < S3C2410_GPG0 && pin > S3C2410_GPF7)
173 return -1; /* not valid pin */
174
175 if (pin < S3C2410_GPF4)
176 return (pin - S3C2410_GPF0) + IRQ_EINT0;
177
178 if (pin < S3C2410_GPG0)
179 return (pin - S3C2410_GPF4) + IRQ_EINT4;
180
181 return (pin - S3C2410_GPG0) + IRQ_EINT8;
182}
183
184EXPORT_SYMBOL(s3c2410_gpio_getirq);
diff --git a/arch/arm/mach-s3c2410/s3c2410-gpio.c b/arch/arm/mach-s3c2410/s3c2410-gpio.c
index a2098f692d83..ec3a276cc3cf 100644
--- a/arch/arm/mach-s3c2410/s3c2410-gpio.c
+++ b/arch/arm/mach-s3c2410/s3c2410-gpio.c
@@ -69,22 +69,3 @@ int s3c2410_gpio_irqfilter(unsigned int pin, unsigned int on,
69} 69}
70 70
71EXPORT_SYMBOL(s3c2410_gpio_irqfilter); 71EXPORT_SYMBOL(s3c2410_gpio_irqfilter);
72
73int s3c2410_gpio_getirq(unsigned int pin)
74{
75 if (pin < S3C2410_GPF0 || pin > S3C2410_GPG15)
76 return -1; /* not valid interrupts */
77
78 if (pin < S3C2410_GPG0 && pin > S3C2410_GPF7)
79 return -1; /* not valid pin */
80
81 if (pin < S3C2410_GPF4)
82 return (pin - S3C2410_GPF0) + IRQ_EINT0;
83
84 if (pin < S3C2410_GPG0)
85 return (pin - S3C2410_GPF4) + IRQ_EINT4;
86
87 return (pin - S3C2410_GPG0) + IRQ_EINT8;
88}
89
90EXPORT_SYMBOL(s3c2410_gpio_getirq);
diff --git a/arch/arm/mach-sa1100/cpu-sa1110.c b/arch/arm/mach-sa1100/cpu-sa1110.c
index 639597729932..78f4c1346044 100644
--- a/arch/arm/mach-sa1100/cpu-sa1110.c
+++ b/arch/arm/mach-sa1100/cpu-sa1110.c
@@ -82,6 +82,14 @@ static struct sdram_params sdram_tbl[] __initdata = {
82 .twr = 9, 82 .twr = 9,
83 .refresh = 64000, 83 .refresh = 64000,
84 .cas_latency = 3, 84 .cas_latency = 3,
85 }, { /* Samsung K4S281632B-1H */
86 .name = "K4S281632B-1H",
87 .rows = 12,
88 .tck = 10,
89 .trp = 20,
90 .twr = 10,
91 .refresh = 64000,
92 .cas_latency = 3,
85 }, { /* Samsung KM416S4030CT */ 93 }, { /* Samsung KM416S4030CT */
86 .name = "KM416S4030CT", 94 .name = "KM416S4030CT",
87 .rows = 13, 95 .rows = 13,
@@ -366,6 +374,8 @@ static int __init sa1110_clk_init(void)
366 374
367 if (machine_is_h3100()) 375 if (machine_is_h3100())
368 name = "KM416S4030CT"; 376 name = "KM416S4030CT";
377 if (machine_is_jornada720())
378 name = "K4S281632B-1H";
369 } 379 }
370 380
371 sdram = sa1110_find_sdram(name); 381 sdram = sa1110_find_sdram(name);
diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
index 2aa150b57ba1..3b8576111c16 100644
--- a/arch/arm/mach-versatile/core.c
+++ b/arch/arm/mach-versatile/core.c
@@ -188,12 +188,12 @@ static struct map_desc versatile_io_desc[] __initdata = {
188 .length = SZ_4K, 188 .length = SZ_4K,
189 .type = MT_DEVICE 189 .type = MT_DEVICE
190 }, { 190 }, {
191 .virtual = VERSATILE_PCI_VIRT_BASE, 191 .virtual = (unsigned long)VERSATILE_PCI_VIRT_BASE,
192 .pfn = __phys_to_pfn(VERSATILE_PCI_BASE), 192 .pfn = __phys_to_pfn(VERSATILE_PCI_BASE),
193 .length = VERSATILE_PCI_BASE_SIZE, 193 .length = VERSATILE_PCI_BASE_SIZE,
194 .type = MT_DEVICE 194 .type = MT_DEVICE
195 }, { 195 }, {
196 .virtual = VERSATILE_PCI_CFG_VIRT_BASE, 196 .virtual = (unsigned long)VERSATILE_PCI_CFG_VIRT_BASE,
197 .pfn = __phys_to_pfn(VERSATILE_PCI_CFG_BASE), 197 .pfn = __phys_to_pfn(VERSATILE_PCI_CFG_BASE),
198 .length = VERSATILE_PCI_CFG_BASE_SIZE, 198 .length = VERSATILE_PCI_CFG_BASE_SIZE,
199 .type = MT_DEVICE 199 .type = MT_DEVICE
diff --git a/arch/arm/mach-versatile/pci.c b/arch/arm/mach-versatile/pci.c
index 13bbd08ff841..5cd0b5d9e7eb 100644
--- a/arch/arm/mach-versatile/pci.c
+++ b/arch/arm/mach-versatile/pci.c
@@ -40,14 +40,15 @@
40 * Cfg 42000000 - 42FFFFFF PCI config 40 * Cfg 42000000 - 42FFFFFF PCI config
41 * 41 *
42 */ 42 */
43#define SYS_PCICTL IO_ADDRESS(VERSATILE_SYS_PCICTL) 43#define __IO_ADDRESS(n) ((void __iomem *)(unsigned long)IO_ADDRESS(n))
44#define PCI_IMAP0 IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x0) 44#define SYS_PCICTL __IO_ADDRESS(VERSATILE_SYS_PCICTL)
45#define PCI_IMAP1 IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x4) 45#define PCI_IMAP0 __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x0)
46#define PCI_IMAP2 IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x8) 46#define PCI_IMAP1 __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x4)
47#define PCI_SMAP0 IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x10) 47#define PCI_IMAP2 __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x8)
48#define PCI_SMAP1 IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x14) 48#define PCI_SMAP0 __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x10)
49#define PCI_SMAP2 IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x18) 49#define PCI_SMAP1 __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x14)
50#define PCI_SELFID IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0xc) 50#define PCI_SMAP2 __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x18)
51#define PCI_SELFID __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0xc)
51 52
52#define DEVICE_ID_OFFSET 0x00 53#define DEVICE_ID_OFFSET 0x00
53#define CSR_OFFSET 0x04 54#define CSR_OFFSET 0x04
@@ -76,7 +77,7 @@ static int __init versatile_pci_slot_ignore(char *str)
76__setup("pci_slot_ignore=", versatile_pci_slot_ignore); 77__setup("pci_slot_ignore=", versatile_pci_slot_ignore);
77 78
78 79
79static unsigned long __pci_addr(struct pci_bus *bus, 80static void __iomem *__pci_addr(struct pci_bus *bus,
80 unsigned int devfn, int offset) 81 unsigned int devfn, int offset)
81{ 82{
82 unsigned int busnr = bus->number; 83 unsigned int busnr = bus->number;
@@ -91,14 +92,14 @@ static unsigned long __pci_addr(struct pci_bus *bus,
91 if (devfn > 255) 92 if (devfn > 255)
92 BUG(); 93 BUG();
93 94
94 return (VERSATILE_PCI_CFG_VIRT_BASE | (busnr << 16) | 95 return VERSATILE_PCI_CFG_VIRT_BASE + ((busnr << 16) |
95 (PCI_SLOT(devfn) << 11) | (PCI_FUNC(devfn) << 8) | offset); 96 (PCI_SLOT(devfn) << 11) | (PCI_FUNC(devfn) << 8) | offset);
96} 97}
97 98
98static int versatile_read_config(struct pci_bus *bus, unsigned int devfn, int where, 99static int versatile_read_config(struct pci_bus *bus, unsigned int devfn, int where,
99 int size, u32 *val) 100 int size, u32 *val)
100{ 101{
101 unsigned long addr = __pci_addr(bus, devfn, where); 102 void __iomem *addr = __pci_addr(bus, devfn, where & ~3);
102 u32 v; 103 u32 v;
103 int slot = PCI_SLOT(devfn); 104 int slot = PCI_SLOT(devfn);
104 105
@@ -121,13 +122,12 @@ static int versatile_read_config(struct pci_bus *bus, unsigned int devfn, int wh
121 break; 122 break;
122 123
123 case 2: 124 case 2:
124 v = __raw_readl(addr & ~3); 125 v = __raw_readl(addr);
125 if (addr & 2) v >>= 16; 126 if (where & 2) v >>= 16;
126 v &= 0xffff; 127 v &= 0xffff;
127 break; 128 break;
128 129
129 default: 130 default:
130 addr &= ~3;
131 v = __raw_readl(addr); 131 v = __raw_readl(addr);
132 break; 132 break;
133 } 133 }
@@ -140,7 +140,7 @@ static int versatile_read_config(struct pci_bus *bus, unsigned int devfn, int wh
140static int versatile_write_config(struct pci_bus *bus, unsigned int devfn, int where, 140static int versatile_write_config(struct pci_bus *bus, unsigned int devfn, int where,
141 int size, u32 val) 141 int size, u32 val)
142{ 142{
143 unsigned long addr = __pci_addr(bus, devfn, where); 143 void __iomem *addr = __pci_addr(bus, devfn, where);
144 int slot = PCI_SLOT(devfn); 144 int slot = PCI_SLOT(devfn);
145 145
146 if (pci_slot_ignore & (1 << slot)) { 146 if (pci_slot_ignore & (1 << slot)) {
@@ -279,7 +279,7 @@ int __init pci_versatile_setup(int nr, struct pci_sys_data *sys)
279 printk("PCI core found (slot %d)\n",myslot); 279 printk("PCI core found (slot %d)\n",myslot);
280 280
281 __raw_writel(myslot, PCI_SELFID); 281 __raw_writel(myslot, PCI_SELFID);
282 local_pci_cfg_base = (void *) VERSATILE_PCI_CFG_VIRT_BASE + (myslot << 11); 282 local_pci_cfg_base = VERSATILE_PCI_CFG_VIRT_BASE + (myslot << 11);
283 283
284 val = __raw_readl(local_pci_cfg_base + CSR_OFFSET); 284 val = __raw_readl(local_pci_cfg_base + CSR_OFFSET);
285 val |= PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE; 285 val |= PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE;
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 22217fe2650b..b5814b4b6f35 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -32,40 +32,51 @@ extern unsigned long phys_initrd_start;
32extern unsigned long phys_initrd_size; 32extern unsigned long phys_initrd_size;
33 33
34/* 34/*
35 * The sole use of this is to pass memory configuration 35 * This is used to pass memory configuration data from paging_init
36 * data from paging_init to mem_init. 36 * to mem_init, and by show_mem() to skip holes in the memory map.
37 */ 37 */
38static struct meminfo meminfo __initdata = { 0, }; 38static struct meminfo meminfo = { 0, };
39
40#define for_each_nodebank(iter,mi,no) \
41 for (iter = 0; iter < mi->nr_banks; iter++) \
42 if (mi->bank[iter].node == no)
39 43
40void show_mem(void) 44void show_mem(void)
41{ 45{
42 int free = 0, total = 0, reserved = 0; 46 int free = 0, total = 0, reserved = 0;
43 int shared = 0, cached = 0, slab = 0, node; 47 int shared = 0, cached = 0, slab = 0, node, i;
48 struct meminfo * mi = &meminfo;
44 49
45 printk("Mem-info:\n"); 50 printk("Mem-info:\n");
46 show_free_areas(); 51 show_free_areas();
47 printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10)); 52 printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
48 53
49 for_each_online_node(node) { 54 for_each_online_node(node) {
50 struct page *page, *end; 55 for_each_nodebank (i,mi,node) {
51 56 unsigned int pfn1, pfn2;
52 page = NODE_MEM_MAP(node); 57 struct page *page, *end;
53 end = page + NODE_DATA(node)->node_spanned_pages; 58
54 59 pfn1 = mi->bank[i].start >> PAGE_SHIFT;
55 do { 60 pfn2 = (mi->bank[i].size + mi->bank[i].start) >> PAGE_SHIFT;
56 total++; 61
57 if (PageReserved(page)) 62 page = NODE_MEM_MAP(node) + pfn1;
58 reserved++; 63 end = NODE_MEM_MAP(node) + pfn2;
59 else if (PageSwapCache(page)) 64
60 cached++; 65 do {
61 else if (PageSlab(page)) 66 total++;
62 slab++; 67 if (PageReserved(page))
63 else if (!page_count(page)) 68 reserved++;
64 free++; 69 else if (PageSwapCache(page))
65 else 70 cached++;
66 shared += page_count(page) - 1; 71 else if (PageSlab(page))
67 page++; 72 slab++;
68 } while (page < end); 73 else if (!page_count(page))
74 free++;
75 else
76 shared += page_count(page) - 1;
77 page++;
78 } while (page < end);
79 }
69 } 80 }
70 81
71 printk("%d pages of RAM\n", total); 82 printk("%d pages of RAM\n", total);
@@ -76,10 +87,6 @@ void show_mem(void)
76 printk("%d pages swap cached\n", cached); 87 printk("%d pages swap cached\n", cached);
77} 88}
78 89
79#define for_each_nodebank(iter,mi,no) \
80 for (iter = 0; iter < mi->nr_banks; iter++) \
81 if (mi->bank[iter].node == no)
82
83/* 90/*
84 * FIXME: We really want to avoid allocating the bootmap bitmap 91 * FIXME: We really want to avoid allocating the bootmap bitmap
85 * over the top of the initrd. Hopefully, this is located towards 92 * over the top of the initrd. Hopefully, this is located towards
diff --git a/arch/arm/mm/proc-xscale.S b/arch/arm/mm/proc-xscale.S
index e8b377d637f6..2749c1f88d7d 100644
--- a/arch/arm/mm/proc-xscale.S
+++ b/arch/arm/mm/proc-xscale.S
@@ -909,7 +909,7 @@ __pxa270_proc_info:
909 b __xscale_setup 909 b __xscale_setup
910 .long cpu_arch_name 910 .long cpu_arch_name
911 .long cpu_elf_name 911 .long cpu_elf_name
912 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP 912 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP|HWCAP_IWMMXT
913 .long cpu_pxa270_name 913 .long cpu_pxa270_name
914 .long xscale_processor_functions 914 .long xscale_processor_functions
915 .long v4wbi_tlb_fns 915 .long v4wbi_tlb_fns
diff --git a/arch/arm/oprofile/op_counter.h b/arch/arm/oprofile/op_counter.h
index 8c5351d751cf..ca942a63b52f 100644
--- a/arch/arm/oprofile/op_counter.h
+++ b/arch/arm/oprofile/op_counter.h
@@ -10,8 +10,6 @@
10#ifndef OP_COUNTER_H 10#ifndef OP_COUNTER_H
11#define OP_COUNTER_H 11#define OP_COUNTER_H
12 12
13#define OP_MAX_COUNTER 5
14
15/* Per performance monitor configuration as set via 13/* Per performance monitor configuration as set via
16 * oprofilefs. 14 * oprofilefs.
17 */ 15 */
diff --git a/arch/arm/oprofile/op_model_xscale.c b/arch/arm/oprofile/op_model_xscale.c
index 7899d3ca75a3..7c3289c2acd7 100644
--- a/arch/arm/oprofile/op_model_xscale.c
+++ b/arch/arm/oprofile/op_model_xscale.c
@@ -20,7 +20,8 @@
20#include <linux/sched.h> 20#include <linux/sched.h>
21#include <linux/oprofile.h> 21#include <linux/oprofile.h>
22#include <linux/interrupt.h> 22#include <linux/interrupt.h>
23#include <asm/irq.h> 23#include <linux/irq.h>
24
24#include <asm/system.h> 25#include <asm/system.h>
25 26
26#include "op_counter.h" 27#include "op_counter.h"
diff --git a/arch/arm/tools/mach-types b/arch/arm/tools/mach-types
index b02af1d740fa..579c69ae9ff7 100644
--- a/arch/arm/tools/mach-types
+++ b/arch/arm/tools/mach-types
@@ -4,7 +4,7 @@
4# 4#
5# Up to date versions of this file can be obtained from: 5# Up to date versions of this file can be obtained from:
6# 6#
7# http://www.arm.linux.org.uk/developer/machines/?action=download 7# http://www.arm.linux.org.uk/developer/machines/download.php
8# 8#
9# Please do not send patches to this file; it is automatically generated! 9# Please do not send patches to this file; it is automatically generated!
10# To add an entry into this database, please see Documentation/arm/README, 10# To add an entry into this database, please see Documentation/arm/README,
@@ -12,7 +12,7 @@
12# 12#
13# http://www.arm.linux.org.uk/developer/machines/?action=new 13# http://www.arm.linux.org.uk/developer/machines/?action=new
14# 14#
15# Last update: Sat Sep 23 13:20:43 2006 15# Last update: Mon Oct 16 21:13:36 2006
16# 16#
17# machine_is_xxx CONFIG_xxxx MACH_TYPE_xxx number 17# machine_is_xxx CONFIG_xxxx MACH_TYPE_xxx number
18# 18#
@@ -1157,3 +1157,17 @@ adsturboxb MACH_ADSTURBOXB ADSTURBOXB 1143
1157oti4110 MACH_OTI4110 OTI4110 1144 1157oti4110 MACH_OTI4110 OTI4110 1144
1158hme_pxa MACH_HME_PXA HME_PXA 1145 1158hme_pxa MACH_HME_PXA HME_PXA 1145
1159deisterdca MACH_DEISTERDCA DEISTERDCA 1146 1159deisterdca MACH_DEISTERDCA DEISTERDCA 1146
1160ces_ssem2 MACH_CES_SSEM2 CES_SSEM2 1147
1161ces_mtr MACH_CES_MTR CES_MTR 1148
1162tds_avng_sbc MACH_TDS_AVNG_SBC TDS_AVNG_SBC 1149
1163everest MACH_EVEREST EVEREST 1150
1164pnx4010 MACH_PNX4010 PNX4010 1151
1165oxnas MACH_OXNAS OXNAS 1152
1166fiori MACH_FIORI FIORI 1153
1167ml1200 MACH_ML1200 ML1200 1154
1168cactus MACH_CACTUS CACTUS 1155
1169nb2xxx MACH_NB2XXX NB2XXX 1156
1170hw6900 MACH_HW6900 HW6900 1157
1171cdcs_quoll MACH_CDCS_QUOLL CDCS_QUOLL 1158
1172quicksilver MACH_QUICKSILVER QUICKSILVER 1159
1173uplat926 MACH_UPLAT926 UPLAT926 1160
diff --git a/arch/arm/vfp/vfpdouble.c b/arch/arm/vfp/vfpdouble.c
index 4fc05ee0a2ef..e44b9ed0f81f 100644
--- a/arch/arm/vfp/vfpdouble.c
+++ b/arch/arm/vfp/vfpdouble.c
@@ -56,7 +56,7 @@ static void vfp_double_normalise_denormal(struct vfp_double *vd)
56{ 56{
57 int bits = 31 - fls(vd->significand >> 32); 57 int bits = 31 - fls(vd->significand >> 32);
58 if (bits == 31) 58 if (bits == 31)
59 bits = 62 - fls(vd->significand); 59 bits = 63 - fls(vd->significand);
60 60
61 vfp_double_dump("normalise_denormal: in", vd); 61 vfp_double_dump("normalise_denormal: in", vd);
62 62
diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c
index dedbb449632e..f08eafbddcc1 100644
--- a/arch/arm/vfp/vfpmodule.c
+++ b/arch/arm/vfp/vfpmodule.c
@@ -90,7 +90,7 @@ void vfp_raise_sigfpe(unsigned int sicode, struct pt_regs *regs)
90 90
91 info.si_signo = SIGFPE; 91 info.si_signo = SIGFPE;
92 info.si_code = sicode; 92 info.si_code = sicode;
93 info.si_addr = (void *)(instruction_pointer(regs) - 4); 93 info.si_addr = (void __user *)(instruction_pointer(regs) - 4);
94 94
95 /* 95 /*
96 * This is the same as NWFPE, because it's not clear what 96 * This is the same as NWFPE, because it's not clear what
@@ -148,6 +148,7 @@ static void vfp_raise_exceptions(u32 exceptions, u32 inst, u32 fpscr, struct pt_
148 /* 148 /*
149 * These are arranged in priority order, least to highest. 149 * These are arranged in priority order, least to highest.
150 */ 150 */
151 RAISE(FPSCR_DZC, FPSCR_DZE, FPE_FLTDIV);
151 RAISE(FPSCR_IXC, FPSCR_IXE, FPE_FLTRES); 152 RAISE(FPSCR_IXC, FPSCR_IXE, FPE_FLTRES);
152 RAISE(FPSCR_UFC, FPSCR_UFE, FPE_FLTUND); 153 RAISE(FPSCR_UFC, FPSCR_UFE, FPE_FLTUND);
153 RAISE(FPSCR_OFC, FPSCR_OFE, FPE_FLTOVF); 154 RAISE(FPSCR_OFC, FPSCR_OFE, FPE_FLTOVF);
diff --git a/arch/arm26/kernel/armksyms.c b/arch/arm26/kernel/armksyms.c
index 07907b6ecb63..93293d04b303 100644
--- a/arch/arm26/kernel/armksyms.c
+++ b/arch/arm26/kernel/armksyms.c
@@ -202,14 +202,6 @@ EXPORT_SYMBOL(_find_next_zero_bit_le);
202EXPORT_SYMBOL(elf_platform); 202EXPORT_SYMBOL(elf_platform);
203EXPORT_SYMBOL(elf_hwcap); 203EXPORT_SYMBOL(elf_hwcap);
204 204
205 /* syscalls */
206EXPORT_SYMBOL(sys_write);
207EXPORT_SYMBOL(sys_read);
208EXPORT_SYMBOL(sys_lseek);
209EXPORT_SYMBOL(sys_open);
210EXPORT_SYMBOL(sys_exit);
211EXPORT_SYMBOL(sys_wait4);
212
213#ifdef CONFIG_PREEMPT 205#ifdef CONFIG_PREEMPT
214EXPORT_SYMBOL(kernel_flag); 206EXPORT_SYMBOL(kernel_flag);
215#endif 207#endif
diff --git a/arch/avr32/Makefile b/arch/avr32/Makefile
index cefc95a73980..7b842e98efed 100644
--- a/arch/avr32/Makefile
+++ b/arch/avr32/Makefile
@@ -7,7 +7,7 @@
7 7
8# Default target when executing plain make 8# Default target when executing plain make
9.PHONY: all 9.PHONY: all
10all: uImage vmlinux.elf linux.lst 10all: uImage vmlinux.elf
11 11
12KBUILD_DEFCONFIG := atstk1002_defconfig 12KBUILD_DEFCONFIG := atstk1002_defconfig
13 13
@@ -21,9 +21,7 @@ cpuflags-$(CONFIG_CPU_AP7000) += -mcpu=ap7000
21CFLAGS += $(cpuflags-y) 21CFLAGS += $(cpuflags-y)
22AFLAGS += $(cpuflags-y) 22AFLAGS += $(cpuflags-y)
23 23
24CHECKFLAGS += -D__avr32__ 24CHECKFLAGS += -D__avr32__ -D__BIG_ENDIAN
25
26LIBGCC := $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
27 25
28head-$(CONFIG_LOADER_U_BOOT) += arch/avr32/boot/u-boot/head.o 26head-$(CONFIG_LOADER_U_BOOT) += arch/avr32/boot/u-boot/head.o
29head-y += arch/avr32/kernel/head.o 27head-y += arch/avr32/kernel/head.o
@@ -32,7 +30,7 @@ core-$(CONFIG_BOARD_ATSTK1000) += arch/avr32/boards/atstk1000/
32core-$(CONFIG_LOADER_U_BOOT) += arch/avr32/boot/u-boot/ 30core-$(CONFIG_LOADER_U_BOOT) += arch/avr32/boot/u-boot/
33core-y += arch/avr32/kernel/ 31core-y += arch/avr32/kernel/
34core-y += arch/avr32/mm/ 32core-y += arch/avr32/mm/
35libs-y += arch/avr32/lib/ #$(LIBGCC) 33libs-y += arch/avr32/lib/
36 34
37archincdir-$(CONFIG_PLATFORM_AT32AP) := arch-at32ap 35archincdir-$(CONFIG_PLATFORM_AT32AP) := arch-at32ap
38 36
@@ -48,6 +46,8 @@ endif
48 46
49archprepare: include/asm-avr32/.arch 47archprepare: include/asm-avr32/.arch
50 48
49CLEAN_FILES += include/asm-avr32/.arch include/asm-avr32/arch
50
51BOOT_TARGETS := vmlinux.elf vmlinux.bin uImage uImage.srec 51BOOT_TARGETS := vmlinux.elf vmlinux.bin uImage uImage.srec
52 52
53.PHONY: $(BOOT_TARGETS) install 53.PHONY: $(BOOT_TARGETS) install
@@ -71,14 +71,19 @@ vmlinux.elf vmlinux.bin uImage.srec uImage vmlinux.cso: vmlinux
71install: vmlinux 71install: vmlinux
72 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) $@ 72 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) $@
73 73
74linux.s: vmlinux 74vmlinux.s: vmlinux
75 $(call if_changed,disasm) 75 $(call if_changed,disasm)
76 76
77linux.lst: vmlinux 77vmlinux.lst: vmlinux
78 $(call if_changed,listing) 78 $(call if_changed,listing)
79 79
80CLEAN_FILES += vmlinux.s vmlinux.lst
81
82archclean:
83 $(Q)$(MAKE) $(clean)=$(boot)
84
80define archhelp 85define archhelp
81 @echo '* vmlinux.elf - ELF image with load address 0' 86 @echo '* vmlinux.elf - ELF image with load address 0'
82 @echo ' vmlinux.cso - PathFinder CSO image' 87 @echo ' vmlinux.cso - PathFinder CSO image'
83 @echo ' uImage - Create a bootable image for U-Boot' 88 @echo '* uImage - Create a bootable image for U-Boot'
84endef 89endef
diff --git a/arch/avr32/boards/atstk1000/setup.c b/arch/avr32/boards/atstk1000/setup.c
index 191ab85de9a3..272c011802a7 100644
--- a/arch/avr32/boards/atstk1000/setup.c
+++ b/arch/avr32/boards/atstk1000/setup.c
@@ -21,15 +21,6 @@ struct tag *bootloader_tags __initdata;
21 21
22struct lcdc_platform_data __initdata atstk1000_fb0_data; 22struct lcdc_platform_data __initdata atstk1000_fb0_data;
23 23
24asmlinkage void __init board_early_init(void)
25{
26 extern void sdram_init(void);
27
28#ifdef CONFIG_LOADER_STANDALONE
29 sdram_init();
30#endif
31}
32
33void __init board_setup_fbmem(unsigned long fbmem_start, 24void __init board_setup_fbmem(unsigned long fbmem_start,
34 unsigned long fbmem_size) 25 unsigned long fbmem_size)
35{ 26{
diff --git a/arch/avr32/boot/images/Makefile b/arch/avr32/boot/images/Makefile
index ccd74eeecec3..219720a47bf9 100644
--- a/arch/avr32/boot/images/Makefile
+++ b/arch/avr32/boot/images/Makefile
@@ -37,14 +37,12 @@ OBJCOPYFLAGS_vmlinux.elf := --change-section-lma .text-0x80000000 \
37 --change-section-lma .data-0x80000000 \ 37 --change-section-lma .data-0x80000000 \
38 --change-section-lma .init-0x80000000 \ 38 --change-section-lma .init-0x80000000 \
39 --change-section-lma .bss-0x80000000 \ 39 --change-section-lma .bss-0x80000000 \
40 --change-section-lma .initrd-0x80000000 \
41 --change-section-lma __param-0x80000000 \ 40 --change-section-lma __param-0x80000000 \
42 --change-section-lma __ksymtab-0x80000000 \ 41 --change-section-lma __ksymtab-0x80000000 \
43 --change-section-lma __ksymtab_gpl-0x80000000 \ 42 --change-section-lma __ksymtab_gpl-0x80000000 \
44 --change-section-lma __kcrctab-0x80000000 \ 43 --change-section-lma __kcrctab-0x80000000 \
45 --change-section-lma __kcrctab_gpl-0x80000000 \ 44 --change-section-lma __kcrctab_gpl-0x80000000 \
46 --change-section-lma __ksymtab_strings-0x80000000 \ 45 --change-section-lma __ksymtab_strings-0x80000000 \
47 --change-section-lma .got-0x80000000 \
48 --set-start 0xa0000000 46 --set-start 0xa0000000
49$(obj)/vmlinux.elf: vmlinux FORCE 47$(obj)/vmlinux.elf: vmlinux FORCE
50 $(call if_changed,objcopy) 48 $(call if_changed,objcopy)
@@ -59,4 +57,4 @@ install: $(BOOTIMAGE)
59 sh $(srctree)/install-kernel.sh $< 57 sh $(srctree)/install-kernel.sh $<
60 58
61# Generated files to be removed upon make clean 59# Generated files to be removed upon make clean
62clean-files := vmlinux* uImage uImage.srec 60clean-files := vmlinux.elf vmlinux.bin vmlinux.gz uImage uImage.srec
diff --git a/arch/avr32/configs/atstk1002_defconfig b/arch/avr32/configs/atstk1002_defconfig
index 6c2c5e00dfc7..ae92a14ef9a0 100644
--- a/arch/avr32/configs/atstk1002_defconfig
+++ b/arch/avr32/configs/atstk1002_defconfig
@@ -1,13 +1,14 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.18-rc1 3# Linux kernel version: 2.6.19-rc2
4# Tue Jul 11 12:41:36 2006 4# Fri Oct 20 11:52:37 2006
5# 5#
6CONFIG_AVR32=y 6CONFIG_AVR32=y
7CONFIG_GENERIC_HARDIRQS=y 7CONFIG_GENERIC_HARDIRQS=y
8CONFIG_HARDIRQS_SW_RESEND=y 8CONFIG_HARDIRQS_SW_RESEND=y
9CONFIG_GENERIC_IRQ_PROBE=y 9CONFIG_GENERIC_IRQ_PROBE=y
10CONFIG_RWSEM_GENERIC_SPINLOCK=y 10CONFIG_RWSEM_GENERIC_SPINLOCK=y
11CONFIG_GENERIC_TIME=y
11CONFIG_GENERIC_HWEIGHT=y 12CONFIG_GENERIC_HWEIGHT=y
12CONFIG_GENERIC_CALIBRATE_DELAY=y 13CONFIG_GENERIC_CALIBRATE_DELAY=y
13CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 14CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
@@ -25,16 +26,23 @@ CONFIG_INIT_ENV_ARG_LIMIT=32
25CONFIG_LOCALVERSION="" 26CONFIG_LOCALVERSION=""
26# CONFIG_LOCALVERSION_AUTO is not set 27# CONFIG_LOCALVERSION_AUTO is not set
27CONFIG_SWAP=y 28CONFIG_SWAP=y
28# CONFIG_SYSVIPC is not set 29CONFIG_SYSVIPC=y
29# CONFIG_POSIX_MQUEUE is not set 30# CONFIG_IPC_NS is not set
30# CONFIG_BSD_PROCESS_ACCT is not set 31CONFIG_POSIX_MQUEUE=y
31CONFIG_SYSCTL=y 32CONFIG_BSD_PROCESS_ACCT=y
32# CONFIG_AUDIT is not set 33CONFIG_BSD_PROCESS_ACCT_V3=y
34CONFIG_TASKSTATS=y
35CONFIG_TASK_DELAY_ACCT=y
36# CONFIG_UTS_NS is not set
37CONFIG_AUDIT=y
33# CONFIG_IKCONFIG is not set 38# CONFIG_IKCONFIG is not set
34# CONFIG_RELAY is not set 39CONFIG_RELAY=y
35CONFIG_INITRAMFS_SOURCE="" 40CONFIG_INITRAMFS_SOURCE=""
36CONFIG_CC_OPTIMIZE_FOR_SIZE=y 41CONFIG_CC_OPTIMIZE_FOR_SIZE=y
42# CONFIG_TASK_XACCT is not set
43CONFIG_SYSCTL=y
37CONFIG_EMBEDDED=y 44CONFIG_EMBEDDED=y
45# CONFIG_SYSCTL_SYSCALL is not set
38CONFIG_KALLSYMS=y 46CONFIG_KALLSYMS=y
39# CONFIG_KALLSYMS_ALL is not set 47# CONFIG_KALLSYMS_ALL is not set
40# CONFIG_KALLSYMS_EXTRA_PASS is not set 48# CONFIG_KALLSYMS_EXTRA_PASS is not set
@@ -43,14 +51,15 @@ CONFIG_PRINTK=y
43CONFIG_BUG=y 51CONFIG_BUG=y
44CONFIG_ELF_CORE=y 52CONFIG_ELF_CORE=y
45# CONFIG_BASE_FULL is not set 53# CONFIG_BASE_FULL is not set
46# CONFIG_FUTEX is not set 54CONFIG_FUTEX=y
47# CONFIG_EPOLL is not set 55CONFIG_EPOLL=y
48CONFIG_SHMEM=y 56CONFIG_SHMEM=y
49# CONFIG_SLAB is not set 57CONFIG_SLAB=y
50# CONFIG_VM_EVENT_COUNTERS is not set 58CONFIG_VM_EVENT_COUNTERS=y
59CONFIG_RT_MUTEXES=y
51# CONFIG_TINY_SHMEM is not set 60# CONFIG_TINY_SHMEM is not set
52CONFIG_BASE_SMALL=1 61CONFIG_BASE_SMALL=1
53CONFIG_SLOB=y 62# CONFIG_SLOB is not set
54 63
55# 64#
56# Loadable module support 65# Loadable module support
@@ -65,6 +74,7 @@ CONFIG_MODULE_UNLOAD=y
65# 74#
66# Block layer 75# Block layer
67# 76#
77CONFIG_BLOCK=y
68# CONFIG_BLK_DEV_IO_TRACE is not set 78# CONFIG_BLK_DEV_IO_TRACE is not set
69 79
70# 80#
@@ -166,10 +176,12 @@ CONFIG_IP_PNP_DHCP=y
166# CONFIG_INET_TUNNEL is not set 176# CONFIG_INET_TUNNEL is not set
167# CONFIG_INET_XFRM_MODE_TRANSPORT is not set 177# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
168# CONFIG_INET_XFRM_MODE_TUNNEL is not set 178# CONFIG_INET_XFRM_MODE_TUNNEL is not set
179# CONFIG_INET_XFRM_MODE_BEET is not set
169CONFIG_INET_DIAG=y 180CONFIG_INET_DIAG=y
170CONFIG_INET_TCP_DIAG=y 181CONFIG_INET_TCP_DIAG=y
171# CONFIG_TCP_CONG_ADVANCED is not set 182# CONFIG_TCP_CONG_ADVANCED is not set
172CONFIG_TCP_CONG_BIC=y 183CONFIG_TCP_CONG_CUBIC=y
184CONFIG_DEFAULT_TCP_CONG="cubic"
173# CONFIG_IPV6 is not set 185# CONFIG_IPV6 is not set
174# CONFIG_INET6_XFRM_TUNNEL is not set 186# CONFIG_INET6_XFRM_TUNNEL is not set
175# CONFIG_INET6_TUNNEL is not set 187# CONFIG_INET6_TUNNEL is not set
@@ -199,7 +211,6 @@ CONFIG_TCP_CONG_BIC=y
199# CONFIG_ATALK is not set 211# CONFIG_ATALK is not set
200# CONFIG_X25 is not set 212# CONFIG_X25 is not set
201# CONFIG_LAPB is not set 213# CONFIG_LAPB is not set
202# CONFIG_NET_DIVERT is not set
203# CONFIG_ECONET is not set 214# CONFIG_ECONET is not set
204# CONFIG_WAN_ROUTER is not set 215# CONFIG_WAN_ROUTER is not set
205 216
@@ -212,7 +223,6 @@ CONFIG_TCP_CONG_BIC=y
212# Network testing 223# Network testing
213# 224#
214# CONFIG_NET_PKTGEN is not set 225# CONFIG_NET_PKTGEN is not set
215# CONFIG_NET_TCPPROBE is not set
216# CONFIG_HAMRADIO is not set 226# CONFIG_HAMRADIO is not set
217# CONFIG_IRDA is not set 227# CONFIG_IRDA is not set
218# CONFIG_BT is not set 228# CONFIG_BT is not set
@@ -239,7 +249,84 @@ CONFIG_STANDALONE=y
239# 249#
240# Memory Technology Devices (MTD) 250# Memory Technology Devices (MTD)
241# 251#
242# CONFIG_MTD is not set 252CONFIG_MTD=y
253# CONFIG_MTD_DEBUG is not set
254# CONFIG_MTD_CONCAT is not set
255CONFIG_MTD_PARTITIONS=y
256# CONFIG_MTD_REDBOOT_PARTS is not set
257CONFIG_MTD_CMDLINE_PARTS=y
258
259#
260# User Modules And Translation Layers
261#
262CONFIG_MTD_CHAR=y
263CONFIG_MTD_BLOCK=y
264# CONFIG_FTL is not set
265# CONFIG_NFTL is not set
266# CONFIG_INFTL is not set
267# CONFIG_RFD_FTL is not set
268# CONFIG_SSFDC is not set
269
270#
271# RAM/ROM/Flash chip drivers
272#
273CONFIG_MTD_CFI=y
274# CONFIG_MTD_JEDECPROBE is not set
275CONFIG_MTD_GEN_PROBE=y
276# CONFIG_MTD_CFI_ADV_OPTIONS is not set
277CONFIG_MTD_MAP_BANK_WIDTH_1=y
278CONFIG_MTD_MAP_BANK_WIDTH_2=y
279CONFIG_MTD_MAP_BANK_WIDTH_4=y
280# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
281# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
282# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
283CONFIG_MTD_CFI_I1=y
284CONFIG_MTD_CFI_I2=y
285# CONFIG_MTD_CFI_I4 is not set
286# CONFIG_MTD_CFI_I8 is not set
287# CONFIG_MTD_CFI_INTELEXT is not set
288CONFIG_MTD_CFI_AMDSTD=y
289# CONFIG_MTD_CFI_STAA is not set
290CONFIG_MTD_CFI_UTIL=y
291# CONFIG_MTD_RAM is not set
292# CONFIG_MTD_ROM is not set
293# CONFIG_MTD_ABSENT is not set
294# CONFIG_MTD_OBSOLETE_CHIPS is not set
295
296#
297# Mapping drivers for chip access
298#
299# CONFIG_MTD_COMPLEX_MAPPINGS is not set
300CONFIG_MTD_PHYSMAP=y
301CONFIG_MTD_PHYSMAP_START=0x8000000
302CONFIG_MTD_PHYSMAP_LEN=0x0
303CONFIG_MTD_PHYSMAP_BANKWIDTH=2
304# CONFIG_MTD_PLATRAM is not set
305
306#
307# Self-contained MTD device drivers
308#
309# CONFIG_MTD_SLRAM is not set
310# CONFIG_MTD_PHRAM is not set
311# CONFIG_MTD_MTDRAM is not set
312# CONFIG_MTD_BLOCK2MTD is not set
313
314#
315# Disk-On-Chip Device Drivers
316#
317# CONFIG_MTD_DOC2000 is not set
318# CONFIG_MTD_DOC2001 is not set
319# CONFIG_MTD_DOC2001PLUS is not set
320
321#
322# NAND Flash Device Drivers
323#
324# CONFIG_MTD_NAND is not set
325
326#
327# OneNAND Flash Device Drivers
328#
329# CONFIG_MTD_ONENAND is not set
243 330
244# 331#
245# Parallel port support 332# Parallel port support
@@ -260,11 +347,18 @@ CONFIG_BLK_DEV_NBD=m
260CONFIG_BLK_DEV_RAM=m 347CONFIG_BLK_DEV_RAM=m
261CONFIG_BLK_DEV_RAM_COUNT=16 348CONFIG_BLK_DEV_RAM_COUNT=16
262CONFIG_BLK_DEV_RAM_SIZE=4096 349CONFIG_BLK_DEV_RAM_SIZE=4096
350CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
263CONFIG_BLK_DEV_INITRD=y 351CONFIG_BLK_DEV_INITRD=y
264# CONFIG_CDROM_PKTCDVD is not set 352# CONFIG_CDROM_PKTCDVD is not set
265# CONFIG_ATA_OVER_ETH is not set 353# CONFIG_ATA_OVER_ETH is not set
266 354
267# 355#
356# Misc devices
357#
358# CONFIG_SGI_IOC4 is not set
359# CONFIG_TIFM_CORE is not set
360
361#
268# ATA/ATAPI/MFM/RLL support 362# ATA/ATAPI/MFM/RLL support
269# 363#
270# CONFIG_IDE is not set 364# CONFIG_IDE is not set
@@ -274,6 +368,12 @@ CONFIG_BLK_DEV_INITRD=y
274# 368#
275# CONFIG_RAID_ATTRS is not set 369# CONFIG_RAID_ATTRS is not set
276# CONFIG_SCSI is not set 370# CONFIG_SCSI is not set
371# CONFIG_SCSI_NETLINK is not set
372
373#
374# Serial ATA (prod) and Parallel ATA (experimental) drivers
375#
376# CONFIG_ATA is not set
277 377
278# 378#
279# Multi-device support (RAID and LVM) 379# Multi-device support (RAID and LVM)
@@ -305,14 +405,11 @@ CONFIG_TUN=m
305# 405#
306# PHY device support 406# PHY device support
307# 407#
308# CONFIG_PHYLIB is not set
309 408
310# 409#
311# Ethernet (10 or 100Mbit) 410# Ethernet (10 or 100Mbit)
312# 411#
313CONFIG_NET_ETHERNET=y 412# CONFIG_NET_ETHERNET is not set
314CONFIG_MII=y
315CONFIG_MACB=y
316 413
317# 414#
318# Ethernet (1000 Mbit) 415# Ethernet (1000 Mbit)
@@ -341,10 +438,11 @@ CONFIG_PPP=m
341CONFIG_PPP_ASYNC=m 438CONFIG_PPP_ASYNC=m
342# CONFIG_PPP_SYNC_TTY is not set 439# CONFIG_PPP_SYNC_TTY is not set
343CONFIG_PPP_DEFLATE=m 440CONFIG_PPP_DEFLATE=m
344# CONFIG_PPP_BSDCOMP is not set 441CONFIG_PPP_BSDCOMP=m
345# CONFIG_PPP_MPPE is not set 442# CONFIG_PPP_MPPE is not set
346# CONFIG_PPPOE is not set 443# CONFIG_PPPOE is not set
347# CONFIG_SLIP is not set 444# CONFIG_SLIP is not set
445CONFIG_SLHC=m
348# CONFIG_SHAPER is not set 446# CONFIG_SHAPER is not set
349# CONFIG_NETCONSOLE is not set 447# CONFIG_NETCONSOLE is not set
350# CONFIG_NETPOLL is not set 448# CONFIG_NETPOLL is not set
@@ -417,7 +515,6 @@ CONFIG_UNIX98_PTYS=y
417# TPM devices 515# TPM devices
418# 516#
419# CONFIG_TCG_TPM is not set 517# CONFIG_TCG_TPM is not set
420# CONFIG_TELCLOCK is not set
421 518
422# 519#
423# I2C support 520# I2C support
@@ -427,23 +524,13 @@ CONFIG_UNIX98_PTYS=y
427# 524#
428# SPI support 525# SPI support
429# 526#
430CONFIG_SPI=y 527# CONFIG_SPI is not set
431# CONFIG_SPI_DEBUG is not set 528# CONFIG_SPI_MASTER is not set
432CONFIG_SPI_MASTER=y
433
434#
435# SPI Master Controller Drivers
436#
437CONFIG_SPI_ATMEL=m
438# CONFIG_SPI_BITBANG is not set
439
440#
441# SPI Protocol Masters
442#
443 529
444# 530#
445# Dallas's 1-wire bus 531# Dallas's 1-wire bus
446# 532#
533# CONFIG_W1 is not set
447 534
448# 535#
449# Hardware Monitoring support 536# Hardware Monitoring support
@@ -452,14 +539,9 @@ CONFIG_SPI_ATMEL=m
452# CONFIG_HWMON_VID is not set 539# CONFIG_HWMON_VID is not set
453 540
454# 541#
455# Misc devices
456#
457
458#
459# Multimedia devices 542# Multimedia devices
460# 543#
461# CONFIG_VIDEO_DEV is not set 544# CONFIG_VIDEO_DEV is not set
462CONFIG_VIDEO_V4L2=y
463 545
464# 546#
465# Digital Video Broadcasting Devices 547# Digital Video Broadcasting Devices
@@ -470,28 +552,8 @@ CONFIG_VIDEO_V4L2=y
470# Graphics support 552# Graphics support
471# 553#
472# CONFIG_FIRMWARE_EDID is not set 554# CONFIG_FIRMWARE_EDID is not set
473CONFIG_FB=m 555# CONFIG_FB is not set
474CONFIG_FB_CFB_FILLRECT=m 556# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
475CONFIG_FB_CFB_COPYAREA=m
476CONFIG_FB_CFB_IMAGEBLIT=m
477# CONFIG_FB_MACMODES is not set
478# CONFIG_FB_BACKLIGHT is not set
479# CONFIG_FB_MODE_HELPERS is not set
480# CONFIG_FB_TILEBLITTING is not set
481CONFIG_FB_SIDSA=m
482CONFIG_FB_SIDSA_DEFAULT_BPP=24
483# CONFIG_FB_S1D13XXX is not set
484# CONFIG_FB_VIRTUAL is not set
485
486#
487# Logo configuration
488#
489# CONFIG_LOGO is not set
490CONFIG_BACKLIGHT_LCD_SUPPORT=y
491# CONFIG_BACKLIGHT_CLASS_DEVICE is not set
492CONFIG_LCD_CLASS_DEVICE=m
493CONFIG_LCD_DEVICE=y
494CONFIG_LCD_LTV350QV=m
495 557
496# 558#
497# Sound 559# Sound
@@ -561,18 +623,21 @@ CONFIG_LCD_LTV350QV=m
561# 623#
562# File systems 624# File systems
563# 625#
564CONFIG_EXT2_FS=y 626CONFIG_EXT2_FS=m
565# CONFIG_EXT2_FS_XATTR is not set 627# CONFIG_EXT2_FS_XATTR is not set
566# CONFIG_EXT2_FS_XIP is not set 628# CONFIG_EXT2_FS_XIP is not set
567# CONFIG_EXT3_FS is not set 629# CONFIG_EXT3_FS is not set
630# CONFIG_EXT4DEV_FS is not set
568# CONFIG_REISERFS_FS is not set 631# CONFIG_REISERFS_FS is not set
569# CONFIG_JFS_FS is not set 632# CONFIG_JFS_FS is not set
570# CONFIG_FS_POSIX_ACL is not set 633# CONFIG_FS_POSIX_ACL is not set
571# CONFIG_XFS_FS is not set 634# CONFIG_XFS_FS is not set
635# CONFIG_GFS2_FS is not set
572# CONFIG_OCFS2_FS is not set 636# CONFIG_OCFS2_FS is not set
573CONFIG_MINIX_FS=m 637CONFIG_MINIX_FS=m
574CONFIG_ROMFS_FS=m 638# CONFIG_ROMFS_FS is not set
575# CONFIG_INOTIFY is not set 639CONFIG_INOTIFY=y
640CONFIG_INOTIFY_USER=y
576# CONFIG_QUOTA is not set 641# CONFIG_QUOTA is not set
577# CONFIG_DNOTIFY is not set 642# CONFIG_DNOTIFY is not set
578# CONFIG_AUTOFS_FS is not set 643# CONFIG_AUTOFS_FS is not set
@@ -600,8 +665,10 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
600# 665#
601CONFIG_PROC_FS=y 666CONFIG_PROC_FS=y
602CONFIG_PROC_KCORE=y 667CONFIG_PROC_KCORE=y
668CONFIG_PROC_SYSCTL=y
603CONFIG_SYSFS=y 669CONFIG_SYSFS=y
604CONFIG_TMPFS=y 670CONFIG_TMPFS=y
671# CONFIG_TMPFS_POSIX_ACL is not set
605# CONFIG_HUGETLB_PAGE is not set 672# CONFIG_HUGETLB_PAGE is not set
606CONFIG_RAMFS=y 673CONFIG_RAMFS=y
607CONFIG_CONFIGFS_FS=m 674CONFIG_CONFIGFS_FS=m
@@ -616,6 +683,16 @@ CONFIG_CONFIGFS_FS=m
616# CONFIG_BEFS_FS is not set 683# CONFIG_BEFS_FS is not set
617# CONFIG_BFS_FS is not set 684# CONFIG_BFS_FS is not set
618# CONFIG_EFS_FS is not set 685# CONFIG_EFS_FS is not set
686# CONFIG_JFFS_FS is not set
687CONFIG_JFFS2_FS=y
688CONFIG_JFFS2_FS_DEBUG=0
689CONFIG_JFFS2_FS_WRITEBUFFER=y
690# CONFIG_JFFS2_SUMMARY is not set
691# CONFIG_JFFS2_FS_XATTR is not set
692# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
693CONFIG_JFFS2_ZLIB=y
694CONFIG_JFFS2_RTIME=y
695# CONFIG_JFFS2_RUBIN is not set
619# CONFIG_CRAMFS is not set 696# CONFIG_CRAMFS is not set
620# CONFIG_VXFS_FS is not set 697# CONFIG_VXFS_FS is not set
621# CONFIG_HPFS_FS is not set 698# CONFIG_HPFS_FS is not set
@@ -626,26 +703,10 @@ CONFIG_CONFIGFS_FS=m
626# 703#
627# Network File Systems 704# Network File Systems
628# 705#
629CONFIG_NFS_FS=y 706# CONFIG_NFS_FS is not set
630CONFIG_NFS_V3=y
631# CONFIG_NFS_V3_ACL is not set
632# CONFIG_NFS_V4 is not set
633# CONFIG_NFS_DIRECTIO is not set
634# CONFIG_NFSD is not set 707# CONFIG_NFSD is not set
635CONFIG_ROOT_NFS=y
636CONFIG_LOCKD=y
637CONFIG_LOCKD_V4=y
638CONFIG_NFS_COMMON=y
639CONFIG_SUNRPC=y
640# CONFIG_RPCSEC_GSS_KRB5 is not set
641# CONFIG_RPCSEC_GSS_SPKM3 is not set
642# CONFIG_SMB_FS is not set 708# CONFIG_SMB_FS is not set
643CONFIG_CIFS=m 709# CONFIG_CIFS is not set
644# CONFIG_CIFS_STATS is not set
645# CONFIG_CIFS_WEAK_PW_HASH is not set
646# CONFIG_CIFS_XATTR is not set
647# CONFIG_CIFS_DEBUG2 is not set
648# CONFIG_CIFS_EXPERIMENTAL is not set
649# CONFIG_NCP_FS is not set 710# CONFIG_NCP_FS is not set
650# CONFIG_CODA_FS is not set 711# CONFIG_CODA_FS is not set
651# CONFIG_AFS_FS is not set 712# CONFIG_AFS_FS is not set
@@ -665,7 +726,7 @@ CONFIG_NLS_DEFAULT="iso8859-1"
665CONFIG_NLS_CODEPAGE_437=m 726CONFIG_NLS_CODEPAGE_437=m
666# CONFIG_NLS_CODEPAGE_737 is not set 727# CONFIG_NLS_CODEPAGE_737 is not set
667# CONFIG_NLS_CODEPAGE_775 is not set 728# CONFIG_NLS_CODEPAGE_775 is not set
668CONFIG_NLS_CODEPAGE_850=m 729# CONFIG_NLS_CODEPAGE_850 is not set
669# CONFIG_NLS_CODEPAGE_852 is not set 730# CONFIG_NLS_CODEPAGE_852 is not set
670# CONFIG_NLS_CODEPAGE_855 is not set 731# CONFIG_NLS_CODEPAGE_855 is not set
671# CONFIG_NLS_CODEPAGE_857 is not set 732# CONFIG_NLS_CODEPAGE_857 is not set
@@ -705,13 +766,17 @@ CONFIG_NLS_UTF8=m
705# Kernel hacking 766# Kernel hacking
706# 767#
707CONFIG_TRACE_IRQFLAGS_SUPPORT=y 768CONFIG_TRACE_IRQFLAGS_SUPPORT=y
708CONFIG_PRINTK_TIME=y 769# CONFIG_PRINTK_TIME is not set
770CONFIG_ENABLE_MUST_CHECK=y
709CONFIG_MAGIC_SYSRQ=y 771CONFIG_MAGIC_SYSRQ=y
710# CONFIG_UNUSED_SYMBOLS is not set 772# CONFIG_UNUSED_SYMBOLS is not set
711CONFIG_DEBUG_KERNEL=y 773CONFIG_DEBUG_KERNEL=y
712CONFIG_LOG_BUF_SHIFT=14 774CONFIG_LOG_BUF_SHIFT=14
713CONFIG_DETECT_SOFTLOCKUP=y 775CONFIG_DETECT_SOFTLOCKUP=y
714# CONFIG_SCHEDSTATS is not set 776# CONFIG_SCHEDSTATS is not set
777# CONFIG_DEBUG_SLAB is not set
778# CONFIG_DEBUG_RT_MUTEXES is not set
779# CONFIG_RT_MUTEX_TESTER is not set
715# CONFIG_DEBUG_SPINLOCK is not set 780# CONFIG_DEBUG_SPINLOCK is not set
716# CONFIG_DEBUG_MUTEXES is not set 781# CONFIG_DEBUG_MUTEXES is not set
717# CONFIG_DEBUG_RWSEMS is not set 782# CONFIG_DEBUG_RWSEMS is not set
@@ -722,11 +787,13 @@ CONFIG_DEBUG_BUGVERBOSE=y
722# CONFIG_DEBUG_INFO is not set 787# CONFIG_DEBUG_INFO is not set
723CONFIG_DEBUG_FS=y 788CONFIG_DEBUG_FS=y
724# CONFIG_DEBUG_VM is not set 789# CONFIG_DEBUG_VM is not set
790# CONFIG_DEBUG_LIST is not set
725CONFIG_FRAME_POINTER=y 791CONFIG_FRAME_POINTER=y
726# CONFIG_UNWIND_INFO is not set 792# CONFIG_UNWIND_INFO is not set
727CONFIG_FORCED_INLINING=y 793CONFIG_FORCED_INLINING=y
794# CONFIG_HEADERS_CHECK is not set
728# CONFIG_RCU_TORTURE_TEST is not set 795# CONFIG_RCU_TORTURE_TEST is not set
729CONFIG_KPROBES=y 796# CONFIG_KPROBES is not set
730 797
731# 798#
732# Security options 799# Security options
@@ -740,15 +807,13 @@ CONFIG_KPROBES=y
740# CONFIG_CRYPTO is not set 807# CONFIG_CRYPTO is not set
741 808
742# 809#
743# Hardware crypto devices
744#
745
746#
747# Library routines 810# Library routines
748# 811#
749CONFIG_CRC_CCITT=m 812CONFIG_CRC_CCITT=m
750# CONFIG_CRC16 is not set 813# CONFIG_CRC16 is not set
751CONFIG_CRC32=m 814CONFIG_CRC32=y
752# CONFIG_LIBCRC32C is not set 815# CONFIG_LIBCRC32C is not set
753CONFIG_ZLIB_INFLATE=m 816CONFIG_AUDIT_GENERIC=y
754CONFIG_ZLIB_DEFLATE=m 817CONFIG_ZLIB_INFLATE=y
818CONFIG_ZLIB_DEFLATE=y
819CONFIG_PLIST=y
diff --git a/arch/avr32/kernel/avr32_ksyms.c b/arch/avr32/kernel/avr32_ksyms.c
index 04f767a272b7..372e3f8b2417 100644
--- a/arch/avr32/kernel/avr32_ksyms.c
+++ b/arch/avr32/kernel/avr32_ksyms.c
@@ -7,6 +7,7 @@
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 */ 9 */
10#include <linux/io.h>
10#include <linux/module.h> 11#include <linux/module.h>
11 12
12#include <asm/checksum.h> 13#include <asm/checksum.h>
@@ -53,3 +54,11 @@ EXPORT_SYMBOL(find_next_zero_bit);
53EXPORT_SYMBOL(find_first_bit); 54EXPORT_SYMBOL(find_first_bit);
54EXPORT_SYMBOL(find_next_bit); 55EXPORT_SYMBOL(find_next_bit);
55EXPORT_SYMBOL(generic_find_next_zero_le_bit); 56EXPORT_SYMBOL(generic_find_next_zero_le_bit);
57
58/* I/O primitives (lib/io-*.S) */
59EXPORT_SYMBOL(__raw_readsb);
60EXPORT_SYMBOL(__raw_readsw);
61EXPORT_SYMBOL(__raw_readsl);
62EXPORT_SYMBOL(__raw_writesb);
63EXPORT_SYMBOL(__raw_writesw);
64EXPORT_SYMBOL(__raw_writesl);
diff --git a/arch/avr32/kernel/head.S b/arch/avr32/kernel/head.S
index 773b7ad87be9..6163bd0acb95 100644
--- a/arch/avr32/kernel/head.S
+++ b/arch/avr32/kernel/head.S
@@ -30,9 +30,6 @@ kernel_entry:
30 mov r7, 0 30 mov r7, 0
31#endif 31#endif
32 32
33 /* Set up the PIO, SDRAM controller, early printk, etc. */
34 rcall board_early_init
35
36 /* Start the show */ 33 /* Start the show */
37 lddpc pc, kernel_start_addr 34 lddpc pc, kernel_start_addr
38 35
diff --git a/arch/avr32/kernel/kprobes.c b/arch/avr32/kernel/kprobes.c
index 6caf9e8d8080..ca41fc1edbe1 100644
--- a/arch/avr32/kernel/kprobes.c
+++ b/arch/avr32/kernel/kprobes.c
@@ -109,7 +109,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
109 void *addr = (void *)regs->pc; 109 void *addr = (void *)regs->pc;
110 int ret = 0; 110 int ret = 0;
111 111
112 pr_debug("kprobe_handler: kprobe_running=%d\n", 112 pr_debug("kprobe_handler: kprobe_running=%p\n",
113 kprobe_running()); 113 kprobe_running());
114 114
115 /* 115 /*
diff --git a/arch/avr32/kernel/module.c b/arch/avr32/kernel/module.c
index dfc32f2817b6..b599eae64576 100644
--- a/arch/avr32/kernel/module.c
+++ b/arch/avr32/kernel/module.c
@@ -263,7 +263,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab,
263 * value of PC. Just subtract the value of 263 * value of PC. Just subtract the value of
264 * GOT, and we're done. 264 * GOT, and we're done.
265 */ 265 */
266 pr_debug("GOTPC: PC=0x%lx, got_offset=0x%lx, core=0x%p\n", 266 pr_debug("GOTPC: PC=0x%x, got_offset=0x%lx, core=0x%p\n",
267 relocation, module->arch.got_offset, 267 relocation, module->arch.got_offset,
268 module->module_core); 268 module->module_core);
269 relocation -= ((unsigned long)module->module_core 269 relocation -= ((unsigned long)module->module_core
@@ -282,7 +282,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab,
282 && (relocation & 0xffff0000) != 0xffff0000) 282 && (relocation & 0xffff0000) != 0xffff0000)
283 return reloc_overflow(module, "R_AVR32_GOT16S", 283 return reloc_overflow(module, "R_AVR32_GOT16S",
284 relocation); 284 relocation);
285 pr_debug("GOT reloc @ 0x%lx -> %lu\n", 285 pr_debug("GOT reloc @ 0x%x -> %u\n",
286 rel->r_offset, relocation); 286 rel->r_offset, relocation);
287 value = *location; 287 value = *location;
288 value = ((value & 0xffff0000) 288 value = ((value & 0xffff0000)
diff --git a/arch/avr32/kernel/ptrace.c b/arch/avr32/kernel/ptrace.c
index 3c89e59029ab..f2e81cd79002 100644
--- a/arch/avr32/kernel/ptrace.c
+++ b/arch/avr32/kernel/ptrace.c
@@ -157,7 +157,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
157 unsigned long tmp; 157 unsigned long tmp;
158 int ret; 158 int ret;
159 159
160 pr_debug("arch_ptrace(%ld, %ld, %#lx, %#lx)\n", 160 pr_debug("arch_ptrace(%ld, %d, %#lx, %#lx)\n",
161 request, child->pid, addr, data); 161 request, child->pid, addr, data);
162 162
163 pr_debug("ptrace: Enabling monitor mode...\n"); 163 pr_debug("ptrace: Enabling monitor mode...\n");
diff --git a/arch/avr32/kernel/syscall-stubs.S b/arch/avr32/kernel/syscall-stubs.S
index 7589a9b426cb..890286a1e62b 100644
--- a/arch/avr32/kernel/syscall-stubs.S
+++ b/arch/avr32/kernel/syscall-stubs.S
@@ -100,3 +100,12 @@ __sys_splice:
100 rcall sys_splice 100 rcall sys_splice
101 sub sp, -4 101 sub sp, -4
102 popm pc 102 popm pc
103
104 .global __sys_epoll_pwait
105 .type __sys_epoll_pwait,@function
106__sys_epoll_pwait:
107 pushm lr
108 st.w --sp, ARG6
109 rcall sys_epoll_pwait
110 sub sp, -4
111 popm pc
diff --git a/arch/avr32/kernel/syscall_table.S b/arch/avr32/kernel/syscall_table.S
index 63b206965d05..db8f8b55ffdf 100644
--- a/arch/avr32/kernel/syscall_table.S
+++ b/arch/avr32/kernel/syscall_table.S
@@ -286,4 +286,5 @@ sys_call_table:
286 .long sys_sync_file_range 286 .long sys_sync_file_range
287 .long sys_tee 287 .long sys_tee
288 .long sys_vmsplice 288 .long sys_vmsplice
289 .long __sys_epoll_pwait /* 265 */
289 .long sys_ni_syscall /* r8 is saturated at nr_syscalls */ 290 .long sys_ni_syscall /* r8 is saturated at nr_syscalls */
diff --git a/arch/avr32/kernel/time.c b/arch/avr32/kernel/time.c
index 3e56b9f4358a..5a247ba71a72 100644
--- a/arch/avr32/kernel/time.c
+++ b/arch/avr32/kernel/time.c
@@ -124,15 +124,15 @@ unsigned long long sched_clock(void)
124 * 124 *
125 * In UP mode, it is invoked from the (global) timer_interrupt. 125 * In UP mode, it is invoked from the (global) timer_interrupt.
126 */ 126 */
127static void local_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs) 127static void local_timer_interrupt(int irq, void *dev_id)
128{ 128{
129 if (current->pid) 129 if (current->pid)
130 profile_tick(CPU_PROFILING, regs); 130 profile_tick(CPU_PROFILING);
131 update_process_times(user_mode(regs)); 131 update_process_times(user_mode(get_irq_regs()));
132} 132}
133 133
134static irqreturn_t 134static irqreturn_t
135timer_interrupt(int irq, void *dev_id, struct pt_regs *regs) 135timer_interrupt(int irq, void *dev_id)
136{ 136{
137 unsigned int count; 137 unsigned int count;
138 138
@@ -157,7 +157,7 @@ timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
157 * 157 *
158 * SMP is not supported yet. 158 * SMP is not supported yet.
159 */ 159 */
160 local_timer_interrupt(irq, dev_id, regs); 160 local_timer_interrupt(irq, dev_id);
161 161
162 return IRQ_HANDLED; 162 return IRQ_HANDLED;
163} 163}
diff --git a/arch/avr32/kernel/vmlinux.lds.c b/arch/avr32/kernel/vmlinux.lds.c
index cdd627c6b7dc..5c4424e362b5 100644
--- a/arch/avr32/kernel/vmlinux.lds.c
+++ b/arch/avr32/kernel/vmlinux.lds.c
@@ -38,13 +38,7 @@ SECTIONS
38 __setup_end = .; 38 __setup_end = .;
39 . = ALIGN(4); 39 . = ALIGN(4);
40 __initcall_start = .; 40 __initcall_start = .;
41 *(.initcall1.init) 41 INITCALLS
42 *(.initcall2.init)
43 *(.initcall3.init)
44 *(.initcall4.init)
45 *(.initcall5.init)
46 *(.initcall6.init)
47 *(.initcall7.init)
48 __initcall_end = .; 42 __initcall_end = .;
49 __con_initcall_start = .; 43 __con_initcall_start = .;
50 *(.con_initcall.init) 44 *(.con_initcall.init)
diff --git a/arch/avr32/lib/Makefile b/arch/avr32/lib/Makefile
index 09ac43e40522..084d95bac5e7 100644
--- a/arch/avr32/lib/Makefile
+++ b/arch/avr32/lib/Makefile
@@ -7,4 +7,5 @@ lib-y += strncpy_from_user.o strnlen_user.o
7lib-y += delay.o memset.o memcpy.o findbit.o 7lib-y += delay.o memset.o memcpy.o findbit.o
8lib-y += csum_partial.o csum_partial_copy_generic.o 8lib-y += csum_partial.o csum_partial_copy_generic.o
9lib-y += io-readsw.o io-readsl.o io-writesw.o io-writesl.o 9lib-y += io-readsw.o io-readsl.o io-writesw.o io-writesl.o
10lib-y += io-readsb.o io-writesb.o
10lib-y += __avr32_lsl64.o __avr32_lsr64.o __avr32_asr64.o 11lib-y += __avr32_lsl64.o __avr32_lsr64.o __avr32_asr64.o
diff --git a/arch/avr32/lib/findbit.S b/arch/avr32/lib/findbit.S
index 2b4856f4bf7c..c6b91dee857c 100644
--- a/arch/avr32/lib/findbit.S
+++ b/arch/avr32/lib/findbit.S
@@ -136,6 +136,7 @@ ENTRY(generic_find_next_zero_le_bit)
136 /* offset is not word-aligned. Handle the first (32 - r10) bits */ 136 /* offset is not word-aligned. Handle the first (32 - r10) bits */
137 ldswp.w r8, r12[0] 137 ldswp.w r8, r12[0]
138 sub r12, -4 138 sub r12, -4
139 com r8
139 lsr r8, r8, r10 140 lsr r8, r8, r10
140 brne .L_found 141 brne .L_found
141 142
@@ -146,7 +147,7 @@ ENTRY(generic_find_next_zero_le_bit)
146 147
147 /* Main loop. offset must be word-aligned */ 148 /* Main loop. offset must be word-aligned */
1481: ldswp.w r8, r12[0] 1491: ldswp.w r8, r12[0]
149 cp.w r8, 0 150 com r8
150 brne .L_found 151 brne .L_found
151 sub r12, -4 152 sub r12, -4
152 sub r9, 32 153 sub r9, 32
diff --git a/arch/avr32/lib/io-readsb.S b/arch/avr32/lib/io-readsb.S
new file mode 100644
index 000000000000..2be5da7ed26b
--- /dev/null
+++ b/arch/avr32/lib/io-readsb.S
@@ -0,0 +1,49 @@
1/*
2 * Copyright (C) 2004-2006 Atmel Corporation
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9 .text
10.Lnot_word_aligned:
111: ld.ub r8, r12[0]
12 sub r10, 1
13 st.b r11++, r8
14 reteq r12
15 tst r11, r9
16 brne 1b
17
18 /* fall through */
19
20 .global __raw_readsb
21 .type __raw_readsb,@function
22__raw_readsb:
23 cp.w r10, 0
24 mov r9, 3
25 reteq r12
26
27 tst r11, r9
28 brne .Lnot_word_aligned
29
30 sub r10, 4
31 brlt 2f
32
331: ldins.b r8:t, r12[0]
34 ldins.b r8:u, r12[0]
35 ldins.b r8:l, r12[0]
36 ldins.b r8:b, r12[0]
37 st.w r11++, r8
38 sub r10, 4
39 brge 1b
40
412: sub r10, -4
42 reteq r12
43
443: ld.uh r8, r12[0]
45 sub r10, 1
46 st.b r11++, r8
47 brne 3b
48
49 retal r12
diff --git a/arch/avr32/lib/io-writesb.S b/arch/avr32/lib/io-writesb.S
new file mode 100644
index 000000000000..b4ebaacccf68
--- /dev/null
+++ b/arch/avr32/lib/io-writesb.S
@@ -0,0 +1,52 @@
1/*
2 * Copyright (C) 2004-2006 Atmel Corporation
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9 .text
10.Lnot_word_aligned:
111: ld.ub r8, r11++
12 sub r10, 1
13 st.b r12[0], r8
14 reteq r12
15 tst r11, r9
16 brne 1b
17
18 /* fall through */
19
20 .global __raw_writesb
21 .type __raw_writesb,@function
22__raw_writesb:
23 cp.w r10, 0
24 mov r9, 3
25 reteq r12
26
27 tst r11, r9
28 brne .Lnot_word_aligned
29
30 sub r10, 4
31 brlt 2f
32
331: ld.w r8, r11++
34 bfextu r9, r8, 24, 8
35 st.b r12[0], r9
36 bfextu r9, r8, 16, 8
37 st.b r12[0], r9
38 bfextu r9, r8, 8, 8
39 st.b r12[0], r9
40 st.b r12[0], r8
41 sub r10, 4
42 brge 1b
43
442: sub r10, -4
45 reteq r12
46
473: ld.ub r8, r11++
48 sub r10, 1
49 st.b r12[0], r8
50 brne 3b
51
52 retal r12
diff --git a/arch/avr32/mach-at32ap/extint.c b/arch/avr32/mach-at32ap/extint.c
index 7da9c5f7a0eb..4dff1f988900 100644
--- a/arch/avr32/mach-at32ap/extint.c
+++ b/arch/avr32/mach-at32ap/extint.c
@@ -102,8 +102,7 @@ struct irq_chip eim_chip = {
102 .set_type = eim_set_irq_type, 102 .set_type = eim_set_irq_type,
103}; 103};
104 104
105static void demux_eim_irq(unsigned int irq, struct irq_desc *desc, 105static void demux_eim_irq(unsigned int irq, struct irq_desc *desc)
106 struct pt_regs *regs)
107{ 106{
108 struct at32_sm *sm = desc->handler_data; 107 struct at32_sm *sm = desc->handler_data;
109 struct irq_desc *ext_desc; 108 struct irq_desc *ext_desc;
@@ -121,7 +120,7 @@ static void demux_eim_irq(unsigned int irq, struct irq_desc *desc,
121 120
122 ext_irq = i + sm->eim_first_irq; 121 ext_irq = i + sm->eim_first_irq;
123 ext_desc = irq_desc + ext_irq; 122 ext_desc = irq_desc + ext_irq;
124 ext_desc->handle_irq(ext_irq, ext_desc, regs); 123 ext_desc->handle_irq(ext_irq, ext_desc);
125 } 124 }
126 125
127 spin_unlock(&sm->lock); 126 spin_unlock(&sm->lock);
diff --git a/arch/avr32/mach-at32ap/hsmc.h b/arch/avr32/mach-at32ap/hsmc.h
index 5681276fafdb..d1d48e26e393 100644
--- a/arch/avr32/mach-at32ap/hsmc.h
+++ b/arch/avr32/mach-at32ap/hsmc.h
@@ -120,8 +120,8 @@
120 120
121/* Register access macros */ 121/* Register access macros */
122#define hsmc_readl(port,reg) \ 122#define hsmc_readl(port,reg) \
123 readl((port)->regs + HSMC_##reg) 123 __raw_readl((port)->regs + HSMC_##reg)
124#define hsmc_writel(port,reg,value) \ 124#define hsmc_writel(port,reg,value) \
125 writel((value), (port)->regs + HSMC_##reg) 125 __raw_writel((value), (port)->regs + HSMC_##reg)
126 126
127#endif /* __ASM_AVR32_HSMC_H__ */ 127#endif /* __ASM_AVR32_HSMC_H__ */
diff --git a/arch/avr32/mach-at32ap/intc.c b/arch/avr32/mach-at32ap/intc.c
index 74f8c9f2f03d..eb87a18ad7b2 100644
--- a/arch/avr32/mach-at32ap/intc.c
+++ b/arch/avr32/mach-at32ap/intc.c
@@ -52,16 +52,19 @@ static struct intc intc0 = {
52asmlinkage void do_IRQ(int level, struct pt_regs *regs) 52asmlinkage void do_IRQ(int level, struct pt_regs *regs)
53{ 53{
54 struct irq_desc *desc; 54 struct irq_desc *desc;
55 struct pt_regs *old_regs;
55 unsigned int irq; 56 unsigned int irq;
56 unsigned long status_reg; 57 unsigned long status_reg;
57 58
58 local_irq_disable(); 59 local_irq_disable();
59 60
61 old_regs = set_irq_regs(regs);
62
60 irq_enter(); 63 irq_enter();
61 64
62 irq = intc_readl(&intc0, INTCAUSE0 - 4 * level); 65 irq = intc_readl(&intc0, INTCAUSE0 - 4 * level);
63 desc = irq_desc + irq; 66 desc = irq_desc + irq;
64 desc->handle_irq(irq, desc, regs); 67 desc->handle_irq(irq, desc);
65 68
66 /* 69 /*
67 * Clear all interrupt level masks so that we may handle 70 * Clear all interrupt level masks so that we may handle
@@ -75,6 +78,8 @@ asmlinkage void do_IRQ(int level, struct pt_regs *regs)
75 sysreg_write(SR, status_reg); 78 sysreg_write(SR, status_reg);
76 79
77 irq_exit(); 80 irq_exit();
81
82 set_irq_regs(old_regs);
78} 83}
79 84
80void __init init_IRQ(void) 85void __init init_IRQ(void)
diff --git a/arch/avr32/mach-at32ap/intc.h b/arch/avr32/mach-at32ap/intc.h
index d289ca2fff13..4d3664e43a8e 100644
--- a/arch/avr32/mach-at32ap/intc.h
+++ b/arch/avr32/mach-at32ap/intc.h
@@ -321,7 +321,9 @@
321#define INTC_MKBF(name, value) (((value) & ((1 << INTC_##name##_SIZE) - 1)) << INTC_##name##_OFFSET) 321#define INTC_MKBF(name, value) (((value) & ((1 << INTC_##name##_SIZE) - 1)) << INTC_##name##_OFFSET)
322#define INTC_GETBF(name, value) (((value) >> INTC_##name##_OFFSET) & ((1 << INTC_##name##_SIZE) - 1)) 322#define INTC_GETBF(name, value) (((value) >> INTC_##name##_OFFSET) & ((1 << INTC_##name##_SIZE) - 1))
323 323
324#define intc_readl(port,reg) readl((port)->regs + INTC_##reg) 324#define intc_readl(port,reg) \
325#define intc_writel(port,reg,value) writel((value), (port)->regs + INTC_##reg) 325 __raw_readl((port)->regs + INTC_##reg)
326#define intc_writel(port,reg,value) \
327 __raw_writel((value), (port)->regs + INTC_##reg)
326 328
327#endif /* __ASM_AVR32_PERIHP_INTC_H__ */ 329#endif /* __ASM_AVR32_PERIHP_INTC_H__ */
diff --git a/arch/avr32/mach-at32ap/pio.h b/arch/avr32/mach-at32ap/pio.h
index cfea12351599..50fa3aca32c5 100644
--- a/arch/avr32/mach-at32ap/pio.h
+++ b/arch/avr32/mach-at32ap/pio.h
@@ -170,8 +170,10 @@
170#define PIO_BFINS(name,value,old) (((old) & ~(((1 << PIO_##name##_SIZE) - 1) << PIO_##name##_OFFSET)) | PIO_BF(name,value)) 170#define PIO_BFINS(name,value,old) (((old) & ~(((1 << PIO_##name##_SIZE) - 1) << PIO_##name##_OFFSET)) | PIO_BF(name,value))
171 171
172/* Register access macros */ 172/* Register access macros */
173#define pio_readl(port,reg) readl((port)->regs + PIO_##reg) 173#define pio_readl(port,reg) \
174#define pio_writel(port,reg,value) writel((value), (port)->regs + PIO_##reg) 174 __raw_readl((port)->regs + PIO_##reg)
175#define pio_writel(port,reg,value) \
176 __raw_writel((value), (port)->regs + PIO_##reg)
175 177
176void at32_init_pio(struct platform_device *pdev); 178void at32_init_pio(struct platform_device *pdev);
177 179
diff --git a/arch/avr32/mach-at32ap/sm.h b/arch/avr32/mach-at32ap/sm.h
index 27565822ae2a..cad02b512bcb 100644
--- a/arch/avr32/mach-at32ap/sm.h
+++ b/arch/avr32/mach-at32ap/sm.h
@@ -234,7 +234,9 @@
234#define SM_BFINS(name,value,old) (((old) & ~(((1 << SM_##name##_SIZE) - 1) << SM_##name##_OFFSET)) | SM_BF(name,value)) 234#define SM_BFINS(name,value,old) (((old) & ~(((1 << SM_##name##_SIZE) - 1) << SM_##name##_OFFSET)) | SM_BF(name,value))
235 235
236/* Register access macros */ 236/* Register access macros */
237#define sm_readl(port,reg) readl((port)->regs + SM_##reg) 237#define sm_readl(port,reg) \
238#define sm_writel(port,reg,value) writel((value), (port)->regs + SM_##reg) 238 __raw_readl((port)->regs + SM_##reg)
239#define sm_writel(port,reg,value) \
240 __raw_writel((value), (port)->regs + SM_##reg)
239 241
240#endif /* __ASM_AVR32_SM_H__ */ 242#endif /* __ASM_AVR32_SM_H__ */
diff --git a/arch/avr32/mm/init.c b/arch/avr32/mm/init.c
index 3e6c41039808..70da6894acc1 100644
--- a/arch/avr32/mm/init.c
+++ b/arch/avr32/mm/init.c
@@ -206,7 +206,7 @@ void __init setup_bootmem(void)
206 206
207 if (mem_ramdisk) { 207 if (mem_ramdisk) {
208#ifdef CONFIG_BLK_DEV_INITRD 208#ifdef CONFIG_BLK_DEV_INITRD
209 initrd_start = __va(mem_ramdisk->addr); 209 initrd_start = (unsigned long)__va(mem_ramdisk->addr);
210 initrd_end = initrd_start + mem_ramdisk->size; 210 initrd_end = initrd_start + mem_ramdisk->size;
211 211
212 print_memory_map("RAMDISK images", mem_ramdisk); 212 print_memory_map("RAMDISK images", mem_ramdisk);
diff --git a/arch/avr32/mm/ioremap.c b/arch/avr32/mm/ioremap.c
index 8cfec65e37f7..3437c82434ac 100644
--- a/arch/avr32/mm/ioremap.c
+++ b/arch/avr32/mm/ioremap.c
@@ -77,6 +77,8 @@ void __iounmap(void __iomem *addr)
77 77
78 if ((unsigned long)addr >= P4SEG) 78 if ((unsigned long)addr >= P4SEG)
79 return; 79 return;
80 if (PXSEG(addr) == P2SEG)
81 return;
80 82
81 p = remove_vm_area((void *)(PAGE_MASK & (unsigned long __force)addr)); 83 p = remove_vm_area((void *)(PAGE_MASK & (unsigned long __force)addr));
82 if (unlikely(!p)) { 84 if (unlikely(!p)) {
diff --git a/arch/cris/arch-v32/drivers/cryptocop.c b/arch/cris/arch-v32/drivers/cryptocop.c
index ba096ebb0b15..2449637e6fc0 100644
--- a/arch/cris/arch-v32/drivers/cryptocop.c
+++ b/arch/cris/arch-v32/drivers/cryptocop.c
@@ -2051,7 +2051,6 @@ static void cryptocop_job_queue_close(void)
2051 spin_lock_irqsave(&cryptocop_process_lock, process_flags); 2051 spin_lock_irqsave(&cryptocop_process_lock, process_flags);
2052 2052
2053 /* Empty the job queue. */ 2053 /* Empty the job queue. */
2054 spin_lock_irqsave(&cryptocop_process_lock, process_flags);
2055 for (i = 0; i < cryptocop_prio_no_prios; i++){ 2054 for (i = 0; i < cryptocop_prio_no_prios; i++){
2056 if (!list_empty(&(cryptocop_job_queues[i].jobs))){ 2055 if (!list_empty(&(cryptocop_job_queues[i].jobs))){
2057 list_for_each_safe(node, tmp, &(cryptocop_job_queues[i].jobs)) { 2056 list_for_each_safe(node, tmp, &(cryptocop_job_queues[i].jobs)) {
diff --git a/arch/frv/kernel/vmlinux.lds.S b/arch/frv/kernel/vmlinux.lds.S
index f474534ba78a..9c1fb12367fa 100644
--- a/arch/frv/kernel/vmlinux.lds.S
+++ b/arch/frv/kernel/vmlinux.lds.S
@@ -44,13 +44,7 @@ SECTIONS
44 44
45 __initcall_start = .; 45 __initcall_start = .;
46 .initcall.init : { 46 .initcall.init : {
47 *(.initcall1.init) 47 INITCALLS
48 *(.initcall2.init)
49 *(.initcall3.init)
50 *(.initcall4.init)
51 *(.initcall5.init)
52 *(.initcall6.init)
53 *(.initcall7.init)
54 } 48 }
55 __initcall_end = .; 49 __initcall_end = .;
56 __con_initcall_start = .; 50 __con_initcall_start = .;
diff --git a/arch/h8300/kernel/vmlinux.lds.S b/arch/h8300/kernel/vmlinux.lds.S
index 6406c388f88a..756325dd480e 100644
--- a/arch/h8300/kernel/vmlinux.lds.S
+++ b/arch/h8300/kernel/vmlinux.lds.S
@@ -118,13 +118,7 @@ SECTIONS
118 . = ALIGN(0x4) ; 118 . = ALIGN(0x4) ;
119 ___setup_end = .; 119 ___setup_end = .;
120 ___initcall_start = .; 120 ___initcall_start = .;
121 *(.initcall1.init) 121 INITCALLS
122 *(.initcall2.init)
123 *(.initcall3.init)
124 *(.initcall4.init)
125 *(.initcall5.init)
126 *(.initcall6.init)
127 *(.initcall7.init)
128 ___initcall_end = .; 122 ___initcall_end = .;
129 ___con_initcall_start = .; 123 ___con_initcall_start = .;
130 *(.con_initcall.init) 124 *(.con_initcall.init)
diff --git a/arch/i386/Kconfig.cpu b/arch/i386/Kconfig.cpu
index 21c9a4e71104..fc4f2abccf06 100644
--- a/arch/i386/Kconfig.cpu
+++ b/arch/i386/Kconfig.cpu
@@ -7,6 +7,7 @@ choice
7 7
8config M386 8config M386
9 bool "386" 9 bool "386"
10 depends on !UML
10 ---help--- 11 ---help---
11 This is the processor type of your CPU. This information is used for 12 This is the processor type of your CPU. This information is used for
12 optimizing purposes. In order to compile a kernel that can run on 13 optimizing purposes. In order to compile a kernel that can run on
@@ -301,7 +302,7 @@ config X86_USE_PPRO_CHECKSUM
301 302
302config X86_USE_3DNOW 303config X86_USE_3DNOW
303 bool 304 bool
304 depends on MCYRIXIII || MK7 || MGEODE_LX 305 depends on (MCYRIXIII || MK7 || MGEODE_LX) && !UML
305 default y 306 default y
306 307
307config X86_OOSTORE 308config X86_OOSTORE
diff --git a/arch/i386/Makefile b/arch/i386/Makefile
index 7cc0b189b82b..0677908dfa06 100644
--- a/arch/i386/Makefile
+++ b/arch/i386/Makefile
@@ -42,6 +42,10 @@ cflags-$(CONFIG_REGPARM) += -mregparm=3
42# temporary until string.h is fixed 42# temporary until string.h is fixed
43cflags-y += -ffreestanding 43cflags-y += -ffreestanding
44 44
45# this works around some issues with generating unwind tables in older gccs
46# newer gccs do it by default
47cflags-y += -maccumulate-outgoing-args
48
45# Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use 49# Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use
46# a lot more stack due to the lack of sharing of stacklots: 50# a lot more stack due to the lack of sharing of stacklots:
47CFLAGS += $(shell if [ $(call cc-version) -lt 0400 ] ; then echo $(call cc-option,-fno-unit-at-a-time); fi ;) 51CFLAGS += $(shell if [ $(call cc-version) -lt 0400 ] ; then echo $(call cc-option,-fno-unit-at-a-time); fi ;)
@@ -51,8 +55,8 @@ cflags-y += $(call as-instr,.cfi_startproc\n.cfi_endproc,-DCONFIG_AS_CFI=1,)
51AFLAGS += $(call as-instr,.cfi_startproc\n.cfi_endproc,-DCONFIG_AS_CFI=1,) 55AFLAGS += $(call as-instr,.cfi_startproc\n.cfi_endproc,-DCONFIG_AS_CFI=1,)
52 56
53# is .cfi_signal_frame supported too? 57# is .cfi_signal_frame supported too?
54cflags-y += $(call as-instr,.cfi_startproc\n.cfi_endproc,-DCONFIG_AS_CFI=1,) 58cflags-y += $(call as-instr,.cfi_startproc\n.cfi_signal_frame\n.cfi_endproc,-DCONFIG_AS_CFI_SIGNAL_FRAME=1,)
55AFLAGS += $(call as-instr,.cfi_startproc\n.cfi_endproc,-DCONFIG_AS_CFI=1,) 59AFLAGS += $(call as-instr,.cfi_startproc\n.cfi_signal_frame\n.cfi_endproc,-DCONFIG_AS_CFI_SIGNAL_FRAME=1,)
56 60
57CFLAGS += $(cflags-y) 61CFLAGS += $(cflags-y)
58 62
diff --git a/arch/i386/defconfig b/arch/i386/defconfig
index 60c0c02574f0..97aacd6bd7d8 100644
--- a/arch/i386/defconfig
+++ b/arch/i386/defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.19-rc1 3# Linux kernel version: 2.6.19-rc2-git4
4# Thu Oct 5 13:04:53 2006 4# Sat Oct 21 03:38:56 2006
5# 5#
6CONFIG_X86_32=y 6CONFIG_X86_32=y
7CONFIG_GENERIC_TIME=y 7CONFIG_GENERIC_TIME=y
@@ -380,8 +380,8 @@ CONFIG_INET6_XFRM_MODE_TRANSPORT=y
380CONFIG_INET6_XFRM_MODE_TUNNEL=y 380CONFIG_INET6_XFRM_MODE_TUNNEL=y
381# CONFIG_INET6_XFRM_MODE_BEET is not set 381# CONFIG_INET6_XFRM_MODE_BEET is not set
382# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set 382# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
383CONFIG_IPV6_SIT=y
383# CONFIG_IPV6_TUNNEL is not set 384# CONFIG_IPV6_TUNNEL is not set
384# CONFIG_IPV6_SUBTREES is not set
385# CONFIG_IPV6_MULTIPLE_TABLES is not set 385# CONFIG_IPV6_MULTIPLE_TABLES is not set
386# CONFIG_NETWORK_SECMARK is not set 386# CONFIG_NETWORK_SECMARK is not set
387# CONFIG_NETFILTER is not set 387# CONFIG_NETFILTER is not set
@@ -483,6 +483,13 @@ CONFIG_BLK_DEV_INITRD=y
483# CONFIG_ATA_OVER_ETH is not set 483# CONFIG_ATA_OVER_ETH is not set
484 484
485# 485#
486# Misc devices
487#
488# CONFIG_IBM_ASM is not set
489# CONFIG_SGI_IOC4 is not set
490# CONFIG_TIFM_CORE is not set
491
492#
486# ATA/ATAPI/MFM/RLL support 493# ATA/ATAPI/MFM/RLL support
487# 494#
488CONFIG_IDE=y 495CONFIG_IDE=y
@@ -1024,6 +1031,7 @@ CONFIG_HANGCHECK_TIMER=y
1024# 1031#
1025# Dallas's 1-wire bus 1032# Dallas's 1-wire bus
1026# 1033#
1034# CONFIG_W1 is not set
1027 1035
1028# 1036#
1029# Hardware Monitoring support 1037# Hardware Monitoring support
@@ -1032,12 +1040,6 @@ CONFIG_HANGCHECK_TIMER=y
1032# CONFIG_HWMON_VID is not set 1040# CONFIG_HWMON_VID is not set
1033 1041
1034# 1042#
1035# Misc devices
1036#
1037# CONFIG_IBM_ASM is not set
1038# CONFIG_TIFM_CORE is not set
1039
1040#
1041# Multimedia devices 1043# Multimedia devices
1042# 1044#
1043# CONFIG_VIDEO_DEV is not set 1045# CONFIG_VIDEO_DEV is not set
@@ -1169,7 +1171,6 @@ CONFIG_USB_HIDINPUT=y
1169# CONFIG_USB_ATI_REMOTE2 is not set 1171# CONFIG_USB_ATI_REMOTE2 is not set
1170# CONFIG_USB_KEYSPAN_REMOTE is not set 1172# CONFIG_USB_KEYSPAN_REMOTE is not set
1171# CONFIG_USB_APPLETOUCH is not set 1173# CONFIG_USB_APPLETOUCH is not set
1172# CONFIG_USB_TRANCEVIBRATOR is not set
1173 1174
1174# 1175#
1175# USB Imaging devices 1176# USB Imaging devices
@@ -1215,6 +1216,7 @@ CONFIG_USB_MON=y
1215# CONFIG_USB_APPLEDISPLAY is not set 1216# CONFIG_USB_APPLEDISPLAY is not set
1216# CONFIG_USB_SISUSBVGA is not set 1217# CONFIG_USB_SISUSBVGA is not set
1217# CONFIG_USB_LD is not set 1218# CONFIG_USB_LD is not set
1219# CONFIG_USB_TRANCEVIBRATOR is not set
1218# CONFIG_USB_TEST is not set 1220# CONFIG_USB_TEST is not set
1219 1221
1220# 1222#
@@ -1284,6 +1286,7 @@ CONFIG_EXT3_FS=y
1284CONFIG_EXT3_FS_XATTR=y 1286CONFIG_EXT3_FS_XATTR=y
1285CONFIG_EXT3_FS_POSIX_ACL=y 1287CONFIG_EXT3_FS_POSIX_ACL=y
1286# CONFIG_EXT3_FS_SECURITY is not set 1288# CONFIG_EXT3_FS_SECURITY is not set
1289# CONFIG_EXT4DEV_FS is not set
1287CONFIG_JBD=y 1290CONFIG_JBD=y
1288# CONFIG_JBD_DEBUG is not set 1291# CONFIG_JBD_DEBUG is not set
1289CONFIG_FS_MBCACHE=y 1292CONFIG_FS_MBCACHE=y
@@ -1307,6 +1310,7 @@ CONFIG_DNOTIFY=y
1307# CONFIG_AUTOFS_FS is not set 1310# CONFIG_AUTOFS_FS is not set
1308CONFIG_AUTOFS4_FS=y 1311CONFIG_AUTOFS4_FS=y
1309# CONFIG_FUSE_FS is not set 1312# CONFIG_FUSE_FS is not set
1313CONFIG_GENERIC_ACL=y
1310 1314
1311# 1315#
1312# CD-ROM/DVD Filesystems 1316# CD-ROM/DVD Filesystems
@@ -1384,7 +1388,6 @@ CONFIG_SUNRPC=y
1384# CONFIG_CODA_FS is not set 1388# CONFIG_CODA_FS is not set
1385# CONFIG_AFS_FS is not set 1389# CONFIG_AFS_FS is not set
1386# CONFIG_9P_FS is not set 1390# CONFIG_9P_FS is not set
1387CONFIG_GENERIC_ACL=y
1388 1391
1389# 1392#
1390# Partition Types 1393# Partition Types
@@ -1437,10 +1440,6 @@ CONFIG_NLS_ISO8859_15=y
1437CONFIG_NLS_UTF8=y 1440CONFIG_NLS_UTF8=y
1438 1441
1439# 1442#
1440# Distributed Lock Manager
1441#
1442
1443#
1444# Instrumentation Support 1443# Instrumentation Support
1445# 1444#
1446CONFIG_PROFILING=y 1445CONFIG_PROFILING=y
@@ -1480,6 +1479,7 @@ CONFIG_DEBUG_BUGVERBOSE=y
1480CONFIG_UNWIND_INFO=y 1479CONFIG_UNWIND_INFO=y
1481CONFIG_STACK_UNWIND=y 1480CONFIG_STACK_UNWIND=y
1482# CONFIG_FORCED_INLINING is not set 1481# CONFIG_FORCED_INLINING is not set
1482# CONFIG_HEADERS_CHECK is not set
1483# CONFIG_RCU_TORTURE_TEST is not set 1483# CONFIG_RCU_TORTURE_TEST is not set
1484# CONFIG_LKDTM is not set 1484# CONFIG_LKDTM is not set
1485CONFIG_EARLY_PRINTK=y 1485CONFIG_EARLY_PRINTK=y
diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c
index 92f79cdd9a48..d12fb97a5337 100644
--- a/arch/i386/kernel/acpi/boot.c
+++ b/arch/i386/kernel/acpi/boot.c
@@ -70,7 +70,7 @@ static inline int acpi_madt_oem_check(char *oem_id, char *oem_table_id) { return
70 70
71#define PREFIX "ACPI: " 71#define PREFIX "ACPI: "
72 72
73int acpi_noirq __initdata; /* skip ACPI IRQ initialization */ 73int acpi_noirq; /* skip ACPI IRQ initialization */
74int acpi_pci_disabled __initdata; /* skip ACPI PCI scan and IRQ initialization */ 74int acpi_pci_disabled __initdata; /* skip ACPI PCI scan and IRQ initialization */
75int acpi_ht __initdata = 1; /* enable HT */ 75int acpi_ht __initdata = 1; /* enable HT */
76 76
@@ -82,6 +82,7 @@ EXPORT_SYMBOL(acpi_strict);
82acpi_interrupt_flags acpi_sci_flags __initdata; 82acpi_interrupt_flags acpi_sci_flags __initdata;
83int acpi_sci_override_gsi __initdata; 83int acpi_sci_override_gsi __initdata;
84int acpi_skip_timer_override __initdata; 84int acpi_skip_timer_override __initdata;
85int acpi_use_timer_override __initdata;
85 86
86#ifdef CONFIG_X86_LOCAL_APIC 87#ifdef CONFIG_X86_LOCAL_APIC
87static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE; 88static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
@@ -332,7 +333,7 @@ acpi_parse_ioapic(acpi_table_entry_header * header, const unsigned long end)
332/* 333/*
333 * Parse Interrupt Source Override for the ACPI SCI 334 * Parse Interrupt Source Override for the ACPI SCI
334 */ 335 */
335static void acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger) 336static void acpi_sci_ioapic_setup(u32 bus_irq, u32 gsi, u16 polarity, u16 trigger)
336{ 337{
337 if (trigger == 0) /* compatible SCI trigger is level */ 338 if (trigger == 0) /* compatible SCI trigger is level */
338 trigger = 3; 339 trigger = 3;
@@ -352,13 +353,13 @@ static void acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
352 * If GSI is < 16, this will update its flags, 353 * If GSI is < 16, this will update its flags,
353 * else it will create a new mp_irqs[] entry. 354 * else it will create a new mp_irqs[] entry.
354 */ 355 */
355 mp_override_legacy_irq(gsi, polarity, trigger, gsi); 356 mp_override_legacy_irq(bus_irq, polarity, trigger, gsi);
356 357
357 /* 358 /*
358 * stash over-ride to indicate we've been here 359 * stash over-ride to indicate we've been here
359 * and for later update of acpi_fadt 360 * and for later update of acpi_fadt
360 */ 361 */
361 acpi_sci_override_gsi = gsi; 362 acpi_sci_override_gsi = bus_irq;
362 return; 363 return;
363} 364}
364 365
@@ -376,7 +377,7 @@ acpi_parse_int_src_ovr(acpi_table_entry_header * header,
376 acpi_table_print_madt_entry(header); 377 acpi_table_print_madt_entry(header);
377 378
378 if (intsrc->bus_irq == acpi_fadt.sci_int) { 379 if (intsrc->bus_irq == acpi_fadt.sci_int) {
379 acpi_sci_ioapic_setup(intsrc->global_irq, 380 acpi_sci_ioapic_setup(intsrc->bus_irq, intsrc->global_irq,
380 intsrc->flags.polarity, 381 intsrc->flags.polarity,
381 intsrc->flags.trigger); 382 intsrc->flags.trigger);
382 return 0; 383 return 0;
@@ -879,7 +880,7 @@ static int __init acpi_parse_madt_ioapic_entries(void)
879 * pretend we got one so we can set the SCI flags. 880 * pretend we got one so we can set the SCI flags.
880 */ 881 */
881 if (!acpi_sci_override_gsi) 882 if (!acpi_sci_override_gsi)
882 acpi_sci_ioapic_setup(acpi_fadt.sci_int, 0, 0); 883 acpi_sci_ioapic_setup(acpi_fadt.sci_int, acpi_fadt.sci_int, 0, 0);
883 884
884 /* Fill in identity legacy mapings where no override */ 885 /* Fill in identity legacy mapings where no override */
885 mp_config_acpi_legacy_irqs(); 886 mp_config_acpi_legacy_irqs();
@@ -1300,6 +1301,13 @@ static int __init parse_acpi_skip_timer_override(char *arg)
1300 return 0; 1301 return 0;
1301} 1302}
1302early_param("acpi_skip_timer_override", parse_acpi_skip_timer_override); 1303early_param("acpi_skip_timer_override", parse_acpi_skip_timer_override);
1304
1305static int __init parse_acpi_use_timer_override(char *arg)
1306{
1307 acpi_use_timer_override = 1;
1308 return 0;
1309}
1310early_param("acpi_use_timer_override", parse_acpi_use_timer_override);
1303#endif /* CONFIG_X86_IO_APIC */ 1311#endif /* CONFIG_X86_IO_APIC */
1304 1312
1305static int __init setup_acpi_sci(char *s) 1313static int __init setup_acpi_sci(char *s)
diff --git a/arch/i386/kernel/acpi/cstate.c b/arch/i386/kernel/acpi/cstate.c
index 25db49ef1770..20563e52c622 100644
--- a/arch/i386/kernel/acpi/cstate.c
+++ b/arch/i386/kernel/acpi/cstate.c
@@ -10,6 +10,7 @@
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/acpi.h> 12#include <linux/acpi.h>
13#include <linux/cpu.h>
13 14
14#include <acpi/processor.h> 15#include <acpi/processor.h>
15#include <asm/acpi.h> 16#include <asm/acpi.h>
@@ -41,5 +42,124 @@ void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
41 flags->bm_check = 1; 42 flags->bm_check = 1;
42 } 43 }
43} 44}
44
45EXPORT_SYMBOL(acpi_processor_power_init_bm_check); 45EXPORT_SYMBOL(acpi_processor_power_init_bm_check);
46
47/* The code below handles cstate entry with monitor-mwait pair on Intel*/
48
49struct cstate_entry_s {
50 struct {
51 unsigned int eax;
52 unsigned int ecx;
53 } states[ACPI_PROCESSOR_MAX_POWER];
54};
55static struct cstate_entry_s *cpu_cstate_entry; /* per CPU ptr */
56
57static short mwait_supported[ACPI_PROCESSOR_MAX_POWER];
58
59#define MWAIT_SUBSTATE_MASK (0xf)
60#define MWAIT_SUBSTATE_SIZE (4)
61
62#define CPUID_MWAIT_LEAF (5)
63#define CPUID5_ECX_EXTENSIONS_SUPPORTED (0x1)
64#define CPUID5_ECX_INTERRUPT_BREAK (0x2)
65
66#define MWAIT_ECX_INTERRUPT_BREAK (0x1)
67
68#define NATIVE_CSTATE_BEYOND_HALT (2)
69
70int acpi_processor_ffh_cstate_probe(unsigned int cpu,
71 struct acpi_processor_cx *cx, struct acpi_power_register *reg)
72{
73 struct cstate_entry_s *percpu_entry;
74 struct cpuinfo_x86 *c = cpu_data + cpu;
75
76 cpumask_t saved_mask;
77 int retval;
78 unsigned int eax, ebx, ecx, edx;
79 unsigned int edx_part;
80 unsigned int cstate_type; /* C-state type and not ACPI C-state type */
81 unsigned int num_cstate_subtype;
82
83 if (!cpu_cstate_entry || c->cpuid_level < CPUID_MWAIT_LEAF )
84 return -1;
85
86 if (reg->bit_offset != NATIVE_CSTATE_BEYOND_HALT)
87 return -1;
88
89 percpu_entry = per_cpu_ptr(cpu_cstate_entry, cpu);
90 percpu_entry->states[cx->index].eax = 0;
91 percpu_entry->states[cx->index].ecx = 0;
92
93 /* Make sure we are running on right CPU */
94 saved_mask = current->cpus_allowed;
95 retval = set_cpus_allowed(current, cpumask_of_cpu(cpu));
96 if (retval)
97 return -1;
98
99 cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &edx);
100
101 /* Check whether this particular cx_type (in CST) is supported or not */
102 cstate_type = (cx->address >> MWAIT_SUBSTATE_SIZE) + 1;
103 edx_part = edx >> (cstate_type * MWAIT_SUBSTATE_SIZE);
104 num_cstate_subtype = edx_part & MWAIT_SUBSTATE_MASK;
105
106 retval = 0;
107 if (num_cstate_subtype < (cx->address & MWAIT_SUBSTATE_MASK)) {
108 retval = -1;
109 goto out;
110 }
111
112 /* mwait ecx extensions INTERRUPT_BREAK should be supported for C2/C3 */
113 if (!(ecx & CPUID5_ECX_EXTENSIONS_SUPPORTED) ||
114 !(ecx & CPUID5_ECX_INTERRUPT_BREAK)) {
115 retval = -1;
116 goto out;
117 }
118 percpu_entry->states[cx->index].ecx = MWAIT_ECX_INTERRUPT_BREAK;
119
120 /* Use the hint in CST */
121 percpu_entry->states[cx->index].eax = cx->address;
122
123 if (!mwait_supported[cstate_type]) {
124 mwait_supported[cstate_type] = 1;
125 printk(KERN_DEBUG "Monitor-Mwait will be used to enter C-%d "
126 "state\n", cx->type);
127 }
128
129out:
130 set_cpus_allowed(current, saved_mask);
131 return retval;
132}
133EXPORT_SYMBOL_GPL(acpi_processor_ffh_cstate_probe);
134
135void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx *cx)
136{
137 unsigned int cpu = smp_processor_id();
138 struct cstate_entry_s *percpu_entry;
139
140 percpu_entry = per_cpu_ptr(cpu_cstate_entry, cpu);
141 mwait_idle_with_hints(percpu_entry->states[cx->index].eax,
142 percpu_entry->states[cx->index].ecx);
143}
144EXPORT_SYMBOL_GPL(acpi_processor_ffh_cstate_enter);
145
146static int __init ffh_cstate_init(void)
147{
148 struct cpuinfo_x86 *c = &boot_cpu_data;
149 if (c->x86_vendor != X86_VENDOR_INTEL)
150 return -1;
151
152 cpu_cstate_entry = alloc_percpu(struct cstate_entry_s);
153 return 0;
154}
155
156static void __exit ffh_cstate_exit(void)
157{
158 if (cpu_cstate_entry) {
159 free_percpu(cpu_cstate_entry);
160 cpu_cstate_entry = NULL;
161 }
162}
163
164arch_initcall(ffh_cstate_init);
165__exitcall(ffh_cstate_exit);
diff --git a/arch/i386/kernel/acpi/earlyquirk.c b/arch/i386/kernel/acpi/earlyquirk.c
index fe799b11ac0a..c9841692bb7c 100644
--- a/arch/i386/kernel/acpi/earlyquirk.c
+++ b/arch/i386/kernel/acpi/earlyquirk.c
@@ -27,11 +27,17 @@ static int __init check_bridge(int vendor, int device)
27#ifdef CONFIG_ACPI 27#ifdef CONFIG_ACPI
28 /* According to Nvidia all timer overrides are bogus unless HPET 28 /* According to Nvidia all timer overrides are bogus unless HPET
29 is enabled. */ 29 is enabled. */
30 if (vendor == PCI_VENDOR_ID_NVIDIA) { 30 if (!acpi_use_timer_override && vendor == PCI_VENDOR_ID_NVIDIA) {
31 nvidia_hpet_detected = 0; 31 nvidia_hpet_detected = 0;
32 acpi_table_parse(ACPI_HPET, nvidia_hpet_check); 32 acpi_table_parse(ACPI_HPET, nvidia_hpet_check);
33 if (nvidia_hpet_detected == 0) { 33 if (nvidia_hpet_detected == 0) {
34 acpi_skip_timer_override = 1; 34 acpi_skip_timer_override = 1;
35 printk(KERN_INFO "Nvidia board "
36 "detected. Ignoring ACPI "
37 "timer override.\n");
38 printk(KERN_INFO "If you got timer trouble "
39 "try acpi_use_timer_override\n");
40
35 } 41 }
36 } 42 }
37#endif 43#endif
diff --git a/arch/i386/kernel/alternative.c b/arch/i386/kernel/alternative.c
index 28ab80649764..583c238e17fb 100644
--- a/arch/i386/kernel/alternative.c
+++ b/arch/i386/kernel/alternative.c
@@ -344,6 +344,7 @@ void alternatives_smp_switch(int smp)
344 344
345void __init alternative_instructions(void) 345void __init alternative_instructions(void)
346{ 346{
347 unsigned long flags;
347 if (no_replacement) { 348 if (no_replacement) {
348 printk(KERN_INFO "(SMP-)alternatives turned off\n"); 349 printk(KERN_INFO "(SMP-)alternatives turned off\n");
349 free_init_pages("SMP alternatives", 350 free_init_pages("SMP alternatives",
@@ -351,6 +352,8 @@ void __init alternative_instructions(void)
351 (unsigned long)__smp_alt_end); 352 (unsigned long)__smp_alt_end);
352 return; 353 return;
353 } 354 }
355
356 local_irq_save(flags);
354 apply_alternatives(__alt_instructions, __alt_instructions_end); 357 apply_alternatives(__alt_instructions, __alt_instructions_end);
355 358
356 /* switch to patch-once-at-boottime-only mode and free the 359 /* switch to patch-once-at-boottime-only mode and free the
@@ -386,4 +389,5 @@ void __init alternative_instructions(void)
386 alternatives_smp_switch(0); 389 alternatives_smp_switch(0);
387 } 390 }
388#endif 391#endif
392 local_irq_restore(flags);
389} 393}
diff --git a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c
index b42f2d914af3..a60358fe9a49 100644
--- a/arch/i386/kernel/apm.c
+++ b/arch/i386/kernel/apm.c
@@ -198,7 +198,7 @@
198 * (APM) BIOS Interface Specification, Revision 1.2, February 1996. 198 * (APM) BIOS Interface Specification, Revision 1.2, February 1996.
199 * 199 *
200 * [This document is available from Microsoft at: 200 * [This document is available from Microsoft at:
201 * http://www.microsoft.com/hwdev/busbios/amp_12.htm] 201 * http://www.microsoft.com/whdc/archive/amp_12.mspx]
202 */ 202 */
203 203
204#include <linux/module.h> 204#include <linux/module.h>
@@ -540,11 +540,30 @@ static inline void apm_restore_cpus(cpumask_t mask)
540 * Also, we KNOW that for the non error case of apm_bios_call, there 540 * Also, we KNOW that for the non error case of apm_bios_call, there
541 * is no useful data returned in the low order 8 bits of eax. 541 * is no useful data returned in the low order 8 bits of eax.
542 */ 542 */
543#define APM_DO_CLI \ 543
544 if (apm_info.allow_ints) \ 544static inline unsigned long __apm_irq_save(void)
545 local_irq_enable(); \ 545{
546 else \ 546 unsigned long flags;
547 local_save_flags(flags);
548 if (apm_info.allow_ints) {
549 if (irqs_disabled_flags(flags))
550 local_irq_enable();
551 } else
552 local_irq_disable();
553
554 return flags;
555}
556
557#define apm_irq_save(flags) \
558 do { flags = __apm_irq_save(); } while (0)
559
560static inline void apm_irq_restore(unsigned long flags)
561{
562 if (irqs_disabled_flags(flags))
547 local_irq_disable(); 563 local_irq_disable();
564 else if (irqs_disabled())
565 local_irq_enable();
566}
548 567
549#ifdef APM_ZERO_SEGS 568#ifdef APM_ZERO_SEGS
550# define APM_DECL_SEGS \ 569# define APM_DECL_SEGS \
@@ -596,12 +615,11 @@ static u8 apm_bios_call(u32 func, u32 ebx_in, u32 ecx_in,
596 save_desc_40 = gdt[0x40 / 8]; 615 save_desc_40 = gdt[0x40 / 8];
597 gdt[0x40 / 8] = bad_bios_desc; 616 gdt[0x40 / 8] = bad_bios_desc;
598 617
599 local_save_flags(flags); 618 apm_irq_save(flags);
600 APM_DO_CLI;
601 APM_DO_SAVE_SEGS; 619 APM_DO_SAVE_SEGS;
602 apm_bios_call_asm(func, ebx_in, ecx_in, eax, ebx, ecx, edx, esi); 620 apm_bios_call_asm(func, ebx_in, ecx_in, eax, ebx, ecx, edx, esi);
603 APM_DO_RESTORE_SEGS; 621 APM_DO_RESTORE_SEGS;
604 local_irq_restore(flags); 622 apm_irq_restore(flags);
605 gdt[0x40 / 8] = save_desc_40; 623 gdt[0x40 / 8] = save_desc_40;
606 put_cpu(); 624 put_cpu();
607 apm_restore_cpus(cpus); 625 apm_restore_cpus(cpus);
@@ -640,12 +658,11 @@ static u8 apm_bios_call_simple(u32 func, u32 ebx_in, u32 ecx_in, u32 *eax)
640 save_desc_40 = gdt[0x40 / 8]; 658 save_desc_40 = gdt[0x40 / 8];
641 gdt[0x40 / 8] = bad_bios_desc; 659 gdt[0x40 / 8] = bad_bios_desc;
642 660
643 local_save_flags(flags); 661 apm_irq_save(flags);
644 APM_DO_CLI;
645 APM_DO_SAVE_SEGS; 662 APM_DO_SAVE_SEGS;
646 error = apm_bios_call_simple_asm(func, ebx_in, ecx_in, eax); 663 error = apm_bios_call_simple_asm(func, ebx_in, ecx_in, eax);
647 APM_DO_RESTORE_SEGS; 664 APM_DO_RESTORE_SEGS;
648 local_irq_restore(flags); 665 apm_irq_restore(flags);
649 gdt[0x40 / 8] = save_desc_40; 666 gdt[0x40 / 8] = save_desc_40;
650 put_cpu(); 667 put_cpu();
651 apm_restore_cpus(cpus); 668 apm_restore_cpus(cpus);
diff --git a/arch/i386/kernel/cpu/mcheck/therm_throt.c b/arch/i386/kernel/cpu/mcheck/therm_throt.c
index 4f43047de406..2d8703b7ce65 100644
--- a/arch/i386/kernel/cpu/mcheck/therm_throt.c
+++ b/arch/i386/kernel/cpu/mcheck/therm_throt.c
@@ -110,17 +110,15 @@ int therm_throt_process(int curr)
110 110
111#ifdef CONFIG_SYSFS 111#ifdef CONFIG_SYSFS
112/* Add/Remove thermal_throttle interface for CPU device */ 112/* Add/Remove thermal_throttle interface for CPU device */
113static __cpuinit int thermal_throttle_add_dev(struct sys_device * sys_dev) 113static __cpuinit int thermal_throttle_add_dev(struct sys_device *sys_dev)
114{ 114{
115 sysfs_create_group(&sys_dev->kobj, &thermal_throttle_attr_group); 115 return sysfs_create_group(&sys_dev->kobj, &thermal_throttle_attr_group);
116 return 0;
117} 116}
118 117
119#ifdef CONFIG_HOTPLUG_CPU 118#ifdef CONFIG_HOTPLUG_CPU
120static __cpuinit int thermal_throttle_remove_dev(struct sys_device * sys_dev) 119static __cpuinit void thermal_throttle_remove_dev(struct sys_device *sys_dev)
121{ 120{
122 sysfs_remove_group(&sys_dev->kobj, &thermal_throttle_attr_group); 121 return sysfs_remove_group(&sys_dev->kobj, &thermal_throttle_attr_group);
123 return 0;
124} 122}
125 123
126/* Mutex protecting device creation against CPU hotplug */ 124/* Mutex protecting device creation against CPU hotplug */
@@ -133,12 +131,14 @@ static __cpuinit int thermal_throttle_cpu_callback(struct notifier_block *nfb,
133{ 131{
134 unsigned int cpu = (unsigned long)hcpu; 132 unsigned int cpu = (unsigned long)hcpu;
135 struct sys_device *sys_dev; 133 struct sys_device *sys_dev;
134 int err;
136 135
137 sys_dev = get_cpu_sysdev(cpu); 136 sys_dev = get_cpu_sysdev(cpu);
138 mutex_lock(&therm_cpu_lock); 137 mutex_lock(&therm_cpu_lock);
139 switch (action) { 138 switch (action) {
140 case CPU_ONLINE: 139 case CPU_ONLINE:
141 thermal_throttle_add_dev(sys_dev); 140 err = thermal_throttle_add_dev(sys_dev);
141 WARN_ON(err);
142 break; 142 break;
143 case CPU_DEAD: 143 case CPU_DEAD:
144 thermal_throttle_remove_dev(sys_dev); 144 thermal_throttle_remove_dev(sys_dev);
@@ -157,6 +157,7 @@ static struct notifier_block thermal_throttle_cpu_notifier =
157static __init int thermal_throttle_init_device(void) 157static __init int thermal_throttle_init_device(void)
158{ 158{
159 unsigned int cpu = 0; 159 unsigned int cpu = 0;
160 int err;
160 161
161 if (!atomic_read(&therm_throt_en)) 162 if (!atomic_read(&therm_throt_en))
162 return 0; 163 return 0;
@@ -167,8 +168,10 @@ static __init int thermal_throttle_init_device(void)
167 mutex_lock(&therm_cpu_lock); 168 mutex_lock(&therm_cpu_lock);
168#endif 169#endif
169 /* connect live CPUs to sysfs */ 170 /* connect live CPUs to sysfs */
170 for_each_online_cpu(cpu) 171 for_each_online_cpu(cpu) {
171 thermal_throttle_add_dev(get_cpu_sysdev(cpu)); 172 err = thermal_throttle_add_dev(get_cpu_sysdev(cpu));
173 WARN_ON(err);
174 }
172#ifdef CONFIG_HOTPLUG_CPU 175#ifdef CONFIG_HOTPLUG_CPU
173 mutex_unlock(&therm_cpu_lock); 176 mutex_unlock(&therm_cpu_lock);
174#endif 177#endif
diff --git a/arch/i386/kernel/head.S b/arch/i386/kernel/head.S
index be9d883c62ce..ca31f18d277c 100644
--- a/arch/i386/kernel/head.S
+++ b/arch/i386/kernel/head.S
@@ -317,7 +317,7 @@ is386: movl $2,%ecx # set MP
317 movl %eax,%gs 317 movl %eax,%gs
318 lldt %ax 318 lldt %ax
319 cld # gcc2 wants the direction flag cleared at all times 319 cld # gcc2 wants the direction flag cleared at all times
320 pushl %eax # fake return address 320 pushl $0 # fake return address for unwinder
321#ifdef CONFIG_SMP 321#ifdef CONFIG_SMP
322 movb ready, %cl 322 movb ready, %cl
323 movb $1, ready 323 movb $1, ready
diff --git a/arch/i386/kernel/i8253.c b/arch/i386/kernel/i8253.c
index 477b24daff53..9a0060b92e32 100644
--- a/arch/i386/kernel/i8253.c
+++ b/arch/i386/kernel/i8253.c
@@ -109,7 +109,7 @@ static struct clocksource clocksource_pit = {
109 109
110static int __init init_pit_clocksource(void) 110static int __init init_pit_clocksource(void)
111{ 111{
112 if (num_possible_cpus() > 4) /* PIT does not scale! */ 112 if (num_possible_cpus() > 1) /* PIT does not scale! */
113 return 0; 113 return 0;
114 114
115 clocksource_pit.mult = clocksource_hz2mult(CLOCK_TICK_RATE, 20); 115 clocksource_pit.mult = clocksource_hz2mult(CLOCK_TICK_RATE, 20);
diff --git a/arch/i386/kernel/i8259.c b/arch/i386/kernel/i8259.c
index d53eafb6daa7..62996cd17084 100644
--- a/arch/i386/kernel/i8259.c
+++ b/arch/i386/kernel/i8259.c
@@ -113,7 +113,8 @@ void make_8259A_irq(unsigned int irq)
113{ 113{
114 disable_irq_nosync(irq); 114 disable_irq_nosync(irq);
115 io_apic_irqs &= ~(1<<irq); 115 io_apic_irqs &= ~(1<<irq);
116 set_irq_chip_and_handler(irq, &i8259A_chip, handle_level_irq); 116 set_irq_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
117 "XT");
117 enable_irq(irq); 118 enable_irq(irq);
118} 119}
119 120
@@ -369,8 +370,8 @@ void __init init_ISA_irqs (void)
369 /* 370 /*
370 * 16 old-style INTA-cycle interrupts: 371 * 16 old-style INTA-cycle interrupts:
371 */ 372 */
372 set_irq_chip_and_handler(i, &i8259A_chip, 373 set_irq_chip_and_handler_name(i, &i8259A_chip,
373 handle_level_irq); 374 handle_level_irq, "XT");
374 } else { 375 } else {
375 /* 376 /*
376 * 'high' PCI IRQs filled in on demand 377 * 'high' PCI IRQs filled in on demand
diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c
index cd082c36ca03..3b7a63e0ed1a 100644
--- a/arch/i386/kernel/io_apic.c
+++ b/arch/i386/kernel/io_apic.c
@@ -91,6 +91,46 @@ static struct irq_pin_list {
91 int apic, pin, next; 91 int apic, pin, next;
92} irq_2_pin[PIN_MAP_SIZE]; 92} irq_2_pin[PIN_MAP_SIZE];
93 93
94struct io_apic {
95 unsigned int index;
96 unsigned int unused[3];
97 unsigned int data;
98};
99
100static __attribute_const__ struct io_apic __iomem *io_apic_base(int idx)
101{
102 return (void __iomem *) __fix_to_virt(FIX_IO_APIC_BASE_0 + idx)
103 + (mp_ioapics[idx].mpc_apicaddr & ~PAGE_MASK);
104}
105
106static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg)
107{
108 struct io_apic __iomem *io_apic = io_apic_base(apic);
109 writel(reg, &io_apic->index);
110 return readl(&io_apic->data);
111}
112
113static inline void io_apic_write(unsigned int apic, unsigned int reg, unsigned int value)
114{
115 struct io_apic __iomem *io_apic = io_apic_base(apic);
116 writel(reg, &io_apic->index);
117 writel(value, &io_apic->data);
118}
119
120/*
121 * Re-write a value: to be used for read-modify-write
122 * cycles where the read already set up the index register.
123 *
124 * Older SiS APIC requires we rewrite the index register
125 */
126static inline void io_apic_modify(unsigned int apic, unsigned int reg, unsigned int value)
127{
128 volatile struct io_apic *io_apic = io_apic_base(apic);
129 if (sis_apic_bug)
130 writel(reg, &io_apic->index);
131 writel(value, &io_apic->data);
132}
133
94union entry_union { 134union entry_union {
95 struct { u32 w1, w2; }; 135 struct { u32 w1, w2; };
96 struct IO_APIC_route_entry entry; 136 struct IO_APIC_route_entry entry;
@@ -107,12 +147,34 @@ static struct IO_APIC_route_entry ioapic_read_entry(int apic, int pin)
107 return eu.entry; 147 return eu.entry;
108} 148}
109 149
150/*
151 * When we write a new IO APIC routing entry, we need to write the high
152 * word first! If the mask bit in the low word is clear, we will enable
153 * the interrupt, and we need to make sure the entry is fully populated
154 * before that happens.
155 */
110static void ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e) 156static void ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e)
111{ 157{
112 unsigned long flags; 158 unsigned long flags;
113 union entry_union eu; 159 union entry_union eu;
114 eu.entry = e; 160 eu.entry = e;
115 spin_lock_irqsave(&ioapic_lock, flags); 161 spin_lock_irqsave(&ioapic_lock, flags);
162 io_apic_write(apic, 0x11 + 2*pin, eu.w2);
163 io_apic_write(apic, 0x10 + 2*pin, eu.w1);
164 spin_unlock_irqrestore(&ioapic_lock, flags);
165}
166
167/*
168 * When we mask an IO APIC routing entry, we need to write the low
169 * word first, in order to set the mask bit before we change the
170 * high bits!
171 */
172static void ioapic_mask_entry(int apic, int pin)
173{
174 unsigned long flags;
175 union entry_union eu = { .entry.mask = 1 };
176
177 spin_lock_irqsave(&ioapic_lock, flags);
116 io_apic_write(apic, 0x10 + 2*pin, eu.w1); 178 io_apic_write(apic, 0x10 + 2*pin, eu.w1);
117 io_apic_write(apic, 0x11 + 2*pin, eu.w2); 179 io_apic_write(apic, 0x11 + 2*pin, eu.w2);
118 spin_unlock_irqrestore(&ioapic_lock, flags); 180 spin_unlock_irqrestore(&ioapic_lock, flags);
@@ -234,9 +296,7 @@ static void clear_IO_APIC_pin(unsigned int apic, unsigned int pin)
234 /* 296 /*
235 * Disable it in the IO-APIC irq-routing table: 297 * Disable it in the IO-APIC irq-routing table:
236 */ 298 */
237 memset(&entry, 0, sizeof(entry)); 299 ioapic_mask_entry(apic, pin);
238 entry.mask = 1;
239 ioapic_write_entry(apic, pin, entry);
240} 300}
241 301
242static void clear_IO_APIC (void) 302static void clear_IO_APIC (void)
@@ -1225,11 +1285,13 @@ static void ioapic_register_intr(int irq, int vector, unsigned long trigger)
1225{ 1285{
1226 if ((trigger == IOAPIC_AUTO && IO_APIC_irq_trigger(irq)) || 1286 if ((trigger == IOAPIC_AUTO && IO_APIC_irq_trigger(irq)) ||
1227 trigger == IOAPIC_LEVEL) 1287 trigger == IOAPIC_LEVEL)
1228 set_irq_chip_and_handler(irq, &ioapic_chip, 1288 set_irq_chip_and_handler_name(irq, &ioapic_chip,
1229 handle_fasteoi_irq); 1289 handle_fasteoi_irq, "fasteoi");
1230 else 1290 else {
1231 set_irq_chip_and_handler(irq, &ioapic_chip, 1291 irq_desc[irq].status |= IRQ_DELAYED_DISABLE;
1232 handle_edge_irq); 1292 set_irq_chip_and_handler_name(irq, &ioapic_chip,
1293 handle_edge_irq, "edge");
1294 }
1233 set_intr_gate(vector, interrupt[irq]); 1295 set_intr_gate(vector, interrupt[irq]);
1234} 1296}
1235 1297
@@ -2235,7 +2297,8 @@ static inline void check_timer(void)
2235 printk(KERN_INFO "...trying to set up timer as Virtual Wire IRQ..."); 2297 printk(KERN_INFO "...trying to set up timer as Virtual Wire IRQ...");
2236 2298
2237 disable_8259A_irq(0); 2299 disable_8259A_irq(0);
2238 set_irq_chip_and_handler(0, &lapic_chip, handle_fasteoi_irq); 2300 set_irq_chip_and_handler_name(0, &lapic_chip, handle_fasteoi_irq,
2301 "fasteio");
2239 apic_write_around(APIC_LVT0, APIC_DM_FIXED | vector); /* Fixed mode */ 2302 apic_write_around(APIC_LVT0, APIC_DM_FIXED | vector); /* Fixed mode */
2240 enable_8259A_irq(0); 2303 enable_8259A_irq(0);
2241 2304
@@ -2541,7 +2604,8 @@ int arch_setup_msi_irq(unsigned int irq, struct pci_dev *dev)
2541 2604
2542 write_msi_msg(irq, &msg); 2605 write_msi_msg(irq, &msg);
2543 2606
2544 set_irq_chip_and_handler(irq, &msi_chip, handle_edge_irq); 2607 set_irq_chip_and_handler_name(irq, &msi_chip, handle_edge_irq,
2608 "edge");
2545 2609
2546 return 0; 2610 return 0;
2547} 2611}
@@ -2562,18 +2626,16 @@ void arch_teardown_msi_irq(unsigned int irq)
2562 2626
2563static void target_ht_irq(unsigned int irq, unsigned int dest) 2627static void target_ht_irq(unsigned int irq, unsigned int dest)
2564{ 2628{
2565 u32 low, high; 2629 struct ht_irq_msg msg;
2566 low = read_ht_irq_low(irq); 2630 fetch_ht_irq_msg(irq, &msg);
2567 high = read_ht_irq_high(irq);
2568 2631
2569 low &= ~(HT_IRQ_LOW_DEST_ID_MASK); 2632 msg.address_lo &= ~(HT_IRQ_LOW_DEST_ID_MASK);
2570 high &= ~(HT_IRQ_HIGH_DEST_ID_MASK); 2633 msg.address_hi &= ~(HT_IRQ_HIGH_DEST_ID_MASK);
2571 2634
2572 low |= HT_IRQ_LOW_DEST_ID(dest); 2635 msg.address_lo |= HT_IRQ_LOW_DEST_ID(dest);
2573 high |= HT_IRQ_HIGH_DEST_ID(dest); 2636 msg.address_hi |= HT_IRQ_HIGH_DEST_ID(dest);
2574 2637
2575 write_ht_irq_low(irq, low); 2638 write_ht_irq_msg(irq, &msg);
2576 write_ht_irq_high(irq, high);
2577} 2639}
2578 2640
2579static void set_ht_irq_affinity(unsigned int irq, cpumask_t mask) 2641static void set_ht_irq_affinity(unsigned int irq, cpumask_t mask)
@@ -2594,7 +2656,7 @@ static void set_ht_irq_affinity(unsigned int irq, cpumask_t mask)
2594} 2656}
2595#endif 2657#endif
2596 2658
2597static struct hw_interrupt_type ht_irq_chip = { 2659static struct irq_chip ht_irq_chip = {
2598 .name = "PCI-HT", 2660 .name = "PCI-HT",
2599 .mask = mask_ht_irq, 2661 .mask = mask_ht_irq,
2600 .unmask = unmask_ht_irq, 2662 .unmask = unmask_ht_irq,
@@ -2611,7 +2673,7 @@ int arch_setup_ht_irq(unsigned int irq, struct pci_dev *dev)
2611 2673
2612 vector = assign_irq_vector(irq); 2674 vector = assign_irq_vector(irq);
2613 if (vector >= 0) { 2675 if (vector >= 0) {
2614 u32 low, high; 2676 struct ht_irq_msg msg;
2615 unsigned dest; 2677 unsigned dest;
2616 cpumask_t tmp; 2678 cpumask_t tmp;
2617 2679
@@ -2619,9 +2681,10 @@ int arch_setup_ht_irq(unsigned int irq, struct pci_dev *dev)
2619 cpu_set(vector >> 8, tmp); 2681 cpu_set(vector >> 8, tmp);
2620 dest = cpu_mask_to_apicid(tmp); 2682 dest = cpu_mask_to_apicid(tmp);
2621 2683
2622 high = HT_IRQ_HIGH_DEST_ID(dest); 2684 msg.address_hi = HT_IRQ_HIGH_DEST_ID(dest);
2623 2685
2624 low = HT_IRQ_LOW_BASE | 2686 msg.address_lo =
2687 HT_IRQ_LOW_BASE |
2625 HT_IRQ_LOW_DEST_ID(dest) | 2688 HT_IRQ_LOW_DEST_ID(dest) |
2626 HT_IRQ_LOW_VECTOR(vector) | 2689 HT_IRQ_LOW_VECTOR(vector) |
2627 ((INT_DEST_MODE == 0) ? 2690 ((INT_DEST_MODE == 0) ?
@@ -2633,10 +2696,10 @@ int arch_setup_ht_irq(unsigned int irq, struct pci_dev *dev)
2633 HT_IRQ_LOW_MT_ARBITRATED) | 2696 HT_IRQ_LOW_MT_ARBITRATED) |
2634 HT_IRQ_LOW_IRQ_MASKED; 2697 HT_IRQ_LOW_IRQ_MASKED;
2635 2698
2636 write_ht_irq_low(irq, low); 2699 write_ht_irq_msg(irq, &msg);
2637 write_ht_irq_high(irq, high);
2638 2700
2639 set_irq_chip_and_handler(irq, &ht_irq_chip, handle_edge_irq); 2701 set_irq_chip_and_handler_name(irq, &ht_irq_chip,
2702 handle_edge_irq, "edge");
2640 } 2703 }
2641 return vector; 2704 return vector;
2642} 2705}
diff --git a/arch/i386/kernel/irq.c b/arch/i386/kernel/irq.c
index 8cfc7dbec7b9..3201d421090a 100644
--- a/arch/i386/kernel/irq.c
+++ b/arch/i386/kernel/irq.c
@@ -258,7 +258,7 @@ int show_interrupts(struct seq_file *p, void *v)
258 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]); 258 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
259#endif 259#endif
260 seq_printf(p, " %8s", irq_desc[i].chip->name); 260 seq_printf(p, " %8s", irq_desc[i].chip->name);
261 seq_printf(p, "-%s", handle_irq_name(irq_desc[i].handle_irq)); 261 seq_printf(p, "-%-8s", irq_desc[i].name);
262 seq_printf(p, " %s", action->name); 262 seq_printf(p, " %s", action->name);
263 263
264 for (action=action->next; action; action = action->next) 264 for (action=action->next; action; action = action->next)
diff --git a/arch/i386/kernel/kprobes.c b/arch/i386/kernel/kprobes.c
index d98e44b16fe2..fc79e1e859c4 100644
--- a/arch/i386/kernel/kprobes.c
+++ b/arch/i386/kernel/kprobes.c
@@ -361,8 +361,11 @@ no_kprobe:
361 asm volatile ( ".global kretprobe_trampoline\n" 361 asm volatile ( ".global kretprobe_trampoline\n"
362 "kretprobe_trampoline: \n" 362 "kretprobe_trampoline: \n"
363 " pushf\n" 363 " pushf\n"
364 /* skip cs, eip, orig_eax, es, ds */ 364 /* skip cs, eip, orig_eax */
365 " subl $20, %esp\n" 365 " subl $12, %esp\n"
366 " pushl %gs\n"
367 " pushl %ds\n"
368 " pushl %es\n"
366 " pushl %eax\n" 369 " pushl %eax\n"
367 " pushl %ebp\n" 370 " pushl %ebp\n"
368 " pushl %edi\n" 371 " pushl %edi\n"
@@ -373,10 +376,10 @@ no_kprobe:
373 " movl %esp, %eax\n" 376 " movl %esp, %eax\n"
374 " call trampoline_handler\n" 377 " call trampoline_handler\n"
375 /* move eflags to cs */ 378 /* move eflags to cs */
376 " movl 48(%esp), %edx\n" 379 " movl 52(%esp), %edx\n"
377 " movl %edx, 44(%esp)\n" 380 " movl %edx, 48(%esp)\n"
378 /* save true return address on eflags */ 381 /* save true return address on eflags */
379 " movl %eax, 48(%esp)\n" 382 " movl %eax, 52(%esp)\n"
380 " popl %ebx\n" 383 " popl %ebx\n"
381 " popl %ecx\n" 384 " popl %ecx\n"
382 " popl %edx\n" 385 " popl %edx\n"
@@ -384,8 +387,8 @@ no_kprobe:
384 " popl %edi\n" 387 " popl %edi\n"
385 " popl %ebp\n" 388 " popl %ebp\n"
386 " popl %eax\n" 389 " popl %eax\n"
387 /* skip eip, orig_eax, es, ds */ 390 /* skip eip, orig_eax, es, ds, gs */
388 " addl $16, %esp\n" 391 " addl $20, %esp\n"
389 " popf\n" 392 " popf\n"
390 " ret\n"); 393 " ret\n");
391} 394}
@@ -404,6 +407,10 @@ fastcall void *__kprobes trampoline_handler(struct pt_regs *regs)
404 INIT_HLIST_HEAD(&empty_rp); 407 INIT_HLIST_HEAD(&empty_rp);
405 spin_lock_irqsave(&kretprobe_lock, flags); 408 spin_lock_irqsave(&kretprobe_lock, flags);
406 head = kretprobe_inst_table_head(current); 409 head = kretprobe_inst_table_head(current);
410 /* fixup registers */
411 regs->xcs = __KERNEL_CS;
412 regs->eip = trampoline_address;
413 regs->orig_eax = 0xffffffff;
407 414
408 /* 415 /*
409 * It is possible to have multiple instances associated with a given 416 * It is possible to have multiple instances associated with a given
@@ -425,6 +432,7 @@ fastcall void *__kprobes trampoline_handler(struct pt_regs *regs)
425 432
426 if (ri->rp && ri->rp->handler){ 433 if (ri->rp && ri->rp->handler){
427 __get_cpu_var(current_kprobe) = &ri->rp->kp; 434 __get_cpu_var(current_kprobe) = &ri->rp->kp;
435 get_kprobe_ctlblk()->kprobe_status = KPROBE_HIT_ACTIVE;
428 ri->rp->handler(ri, regs); 436 ri->rp->handler(ri, regs);
429 __get_cpu_var(current_kprobe) = NULL; 437 __get_cpu_var(current_kprobe) = NULL;
430 } 438 }
diff --git a/arch/i386/kernel/microcode.c b/arch/i386/kernel/microcode.c
index 9b9479768d5e..23f5984d0654 100644
--- a/arch/i386/kernel/microcode.c
+++ b/arch/i386/kernel/microcode.c
@@ -577,7 +577,7 @@ static void microcode_init_cpu(int cpu)
577 set_cpus_allowed(current, cpumask_of_cpu(cpu)); 577 set_cpus_allowed(current, cpumask_of_cpu(cpu));
578 mutex_lock(&microcode_mutex); 578 mutex_lock(&microcode_mutex);
579 collect_cpu_info(cpu); 579 collect_cpu_info(cpu);
580 if (uci->valid) 580 if (uci->valid && system_state == SYSTEM_RUNNING)
581 cpu_request_microcode(cpu); 581 cpu_request_microcode(cpu);
582 mutex_unlock(&microcode_mutex); 582 mutex_unlock(&microcode_mutex);
583 set_cpus_allowed(current, old); 583 set_cpus_allowed(current, old);
@@ -656,14 +656,18 @@ static struct attribute_group mc_attr_group = {
656 656
657static int mc_sysdev_add(struct sys_device *sys_dev) 657static int mc_sysdev_add(struct sys_device *sys_dev)
658{ 658{
659 int cpu = sys_dev->id; 659 int err, cpu = sys_dev->id;
660 struct ucode_cpu_info *uci = ucode_cpu_info + cpu; 660 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
661 661
662 if (!cpu_online(cpu)) 662 if (!cpu_online(cpu))
663 return 0; 663 return 0;
664
664 pr_debug("Microcode:CPU %d added\n", cpu); 665 pr_debug("Microcode:CPU %d added\n", cpu);
665 memset(uci, 0, sizeof(*uci)); 666 memset(uci, 0, sizeof(*uci));
666 sysfs_create_group(&sys_dev->kobj, &mc_attr_group); 667
668 err = sysfs_create_group(&sys_dev->kobj, &mc_attr_group);
669 if (err)
670 return err;
667 671
668 microcode_init_cpu(cpu); 672 microcode_init_cpu(cpu);
669 return 0; 673 return 0;
diff --git a/arch/i386/kernel/nmi.c b/arch/i386/kernel/nmi.c
index 3e8e3adb0489..eaafe233a5da 100644
--- a/arch/i386/kernel/nmi.c
+++ b/arch/i386/kernel/nmi.c
@@ -219,11 +219,11 @@ static int __init check_nmi_watchdog(void)
219 int cpu; 219 int cpu;
220 220
221 /* Enable NMI watchdog for newer systems. 221 /* Enable NMI watchdog for newer systems.
222 Actually it should be safe for most systems before 2004 too except 222 Probably safe on most older systems too, but let's be careful.
223 for some IBM systems that corrupt registers when NMI happens 223 IBM ThinkPads use INT10 inside SMM and that allows early NMI inside SMM
224 during SMM. Unfortunately we don't have more exact information 224 which hangs the system. Disable watchdog for all thinkpads */
225 on these and use this coarse check. */ 225 if (nmi_watchdog == NMI_DEFAULT && dmi_get_year(DMI_BIOS_DATE) >= 2004 &&
226 if (nmi_watchdog == NMI_DEFAULT && dmi_get_year(DMI_BIOS_DATE) >= 2004) 226 !dmi_name_in_vendors("ThinkPad"))
227 nmi_watchdog = NMI_LOCAL_APIC; 227 nmi_watchdog = NMI_LOCAL_APIC;
228 228
229 if ((nmi_watchdog == NMI_NONE) || (nmi_watchdog == NMI_DEFAULT)) 229 if ((nmi_watchdog == NMI_NONE) || (nmi_watchdog == NMI_DEFAULT))
diff --git a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c
index b0a07801d9df..dd53c58f64f1 100644
--- a/arch/i386/kernel/process.c
+++ b/arch/i386/kernel/process.c
@@ -205,7 +205,7 @@ void cpu_idle(void)
205void cpu_idle_wait(void) 205void cpu_idle_wait(void)
206{ 206{
207 unsigned int cpu, this_cpu = get_cpu(); 207 unsigned int cpu, this_cpu = get_cpu();
208 cpumask_t map; 208 cpumask_t map, tmp = current->cpus_allowed;
209 209
210 set_cpus_allowed(current, cpumask_of_cpu(this_cpu)); 210 set_cpus_allowed(current, cpumask_of_cpu(this_cpu));
211 put_cpu(); 211 put_cpu();
@@ -227,6 +227,8 @@ void cpu_idle_wait(void)
227 } 227 }
228 cpus_and(map, map, cpu_online_map); 228 cpus_and(map, map, cpu_online_map);
229 } while (!cpus_empty(map)); 229 } while (!cpus_empty(map));
230
231 set_cpus_allowed(current, tmp);
230} 232}
231EXPORT_SYMBOL_GPL(cpu_idle_wait); 233EXPORT_SYMBOL_GPL(cpu_idle_wait);
232 234
@@ -236,20 +238,28 @@ EXPORT_SYMBOL_GPL(cpu_idle_wait);
236 * We execute MONITOR against need_resched and enter optimized wait state 238 * We execute MONITOR against need_resched and enter optimized wait state
237 * through MWAIT. Whenever someone changes need_resched, we would be woken 239 * through MWAIT. Whenever someone changes need_resched, we would be woken
238 * up from MWAIT (without an IPI). 240 * up from MWAIT (without an IPI).
241 *
242 * New with Core Duo processors, MWAIT can take some hints based on CPU
243 * capability.
239 */ 244 */
240static void mwait_idle(void) 245void mwait_idle_with_hints(unsigned long eax, unsigned long ecx)
241{ 246{
242 local_irq_enable(); 247 if (!need_resched()) {
243
244 while (!need_resched()) {
245 __monitor((void *)&current_thread_info()->flags, 0, 0); 248 __monitor((void *)&current_thread_info()->flags, 0, 0);
246 smp_mb(); 249 smp_mb();
247 if (need_resched()) 250 if (!need_resched())
248 break; 251 __mwait(eax, ecx);
249 __mwait(0, 0);
250 } 252 }
251} 253}
252 254
255/* Default MONITOR/MWAIT with no hints, used for default C1 state */
256static void mwait_idle(void)
257{
258 local_irq_enable();
259 while (!need_resched())
260 mwait_idle_with_hints(0, 0);
261}
262
253void __devinit select_idle_routine(const struct cpuinfo_x86 *c) 263void __devinit select_idle_routine(const struct cpuinfo_x86 *c)
254{ 264{
255 if (cpu_has(c, X86_FEATURE_MWAIT)) { 265 if (cpu_has(c, X86_FEATURE_MWAIT)) {
@@ -328,7 +338,6 @@ extern void kernel_thread_helper(void);
328int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags) 338int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
329{ 339{
330 struct pt_regs regs; 340 struct pt_regs regs;
331 int err;
332 341
333 memset(&regs, 0, sizeof(regs)); 342 memset(&regs, 0, sizeof(regs));
334 343
@@ -343,10 +352,7 @@ int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
343 regs.eflags = X86_EFLAGS_IF | X86_EFLAGS_SF | X86_EFLAGS_PF | 0x2; 352 regs.eflags = X86_EFLAGS_IF | X86_EFLAGS_SF | X86_EFLAGS_PF | 0x2;
344 353
345 /* Ok, create the new process.. */ 354 /* Ok, create the new process.. */
346 err = do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, &regs, 0, NULL, NULL); 355 return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, &regs, 0, NULL, NULL);
347 if (err == 0) /* terminate kernel stack */
348 task_pt_regs(current)->eip = 0;
349 return err;
350} 356}
351EXPORT_SYMBOL(kernel_thread); 357EXPORT_SYMBOL(kernel_thread);
352 358
diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
index 000cf03751fe..141041dde74d 100644
--- a/arch/i386/kernel/setup.c
+++ b/arch/i386/kernel/setup.c
@@ -846,7 +846,7 @@ efi_find_max_pfn(unsigned long start, unsigned long end, void *arg)
846static int __init 846static int __init
847efi_memory_present_wrapper(unsigned long start, unsigned long end, void *arg) 847efi_memory_present_wrapper(unsigned long start, unsigned long end, void *arg)
848{ 848{
849 memory_present(0, start, end); 849 memory_present(0, PFN_UP(start), PFN_DOWN(end));
850 return 0; 850 return 0;
851} 851}
852 852
@@ -1083,16 +1083,15 @@ static unsigned long __init setup_memory(void)
1083 1083
1084void __init zone_sizes_init(void) 1084void __init zone_sizes_init(void)
1085{ 1085{
1086 unsigned long max_zone_pfns[MAX_NR_ZONES];
1087 memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
1088 max_zone_pfns[ZONE_DMA] =
1089 virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
1090 max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
1086#ifdef CONFIG_HIGHMEM 1091#ifdef CONFIG_HIGHMEM
1087 unsigned long max_zone_pfns[MAX_NR_ZONES] = { 1092 max_zone_pfns[ZONE_HIGHMEM] = highend_pfn;
1088 virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT,
1089 max_low_pfn,
1090 highend_pfn};
1091 add_active_range(0, 0, highend_pfn); 1093 add_active_range(0, 0, highend_pfn);
1092#else 1094#else
1093 unsigned long max_zone_pfns[MAX_NR_ZONES] = {
1094 virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT,
1095 max_low_pfn};
1096 add_active_range(0, 0, max_low_pfn); 1095 add_active_range(0, 0, max_low_pfn);
1097#endif 1096#endif
1098 1097
diff --git a/arch/i386/kernel/syscall_table.S b/arch/i386/kernel/syscall_table.S
index 7e639f78b0b9..2697e9210e92 100644
--- a/arch/i386/kernel/syscall_table.S
+++ b/arch/i386/kernel/syscall_table.S
@@ -318,3 +318,4 @@ ENTRY(sys_call_table)
318 .long sys_vmsplice 318 .long sys_vmsplice
319 .long sys_move_pages 319 .long sys_move_pages
320 .long sys_getcpu 320 .long sys_getcpu
321 .long sys_epoll_pwait
diff --git a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c
index 00489b706d27..fe9c5e8e7e6f 100644
--- a/arch/i386/kernel/traps.c
+++ b/arch/i386/kernel/traps.c
@@ -129,15 +129,19 @@ static inline unsigned long print_context_stack(struct thread_info *tinfo,
129 129
130#ifdef CONFIG_FRAME_POINTER 130#ifdef CONFIG_FRAME_POINTER
131 while (valid_stack_ptr(tinfo, (void *)ebp)) { 131 while (valid_stack_ptr(tinfo, (void *)ebp)) {
132 unsigned long new_ebp;
132 addr = *(unsigned long *)(ebp + 4); 133 addr = *(unsigned long *)(ebp + 4);
133 ops->address(data, addr); 134 ops->address(data, addr);
134 /* 135 /*
135 * break out of recursive entries (such as 136 * break out of recursive entries (such as
136 * end_of_stack_stop_unwind_function): 137 * end_of_stack_stop_unwind_function). Also,
138 * we can never allow a frame pointer to
139 * move downwards!
137 */ 140 */
138 if (ebp == *(unsigned long *)ebp) 141 new_ebp = *(unsigned long *)ebp;
142 if (new_ebp <= ebp)
139 break; 143 break;
140 ebp = *(unsigned long *)ebp; 144 ebp = new_ebp;
141 } 145 }
142#else 146#else
143 while (valid_stack_ptr(tinfo, stack)) { 147 while (valid_stack_ptr(tinfo, stack)) {
diff --git a/arch/i386/kernel/tsc.c b/arch/i386/kernel/tsc.c
index b8fa0a8b2e47..fbc95828cd74 100644
--- a/arch/i386/kernel/tsc.c
+++ b/arch/i386/kernel/tsc.c
@@ -349,8 +349,8 @@ static int tsc_update_callback(void)
349 int change = 0; 349 int change = 0;
350 350
351 /* check to see if we should switch to the safe clocksource: */ 351 /* check to see if we should switch to the safe clocksource: */
352 if (clocksource_tsc.rating != 50 && check_tsc_unstable()) { 352 if (clocksource_tsc.rating != 0 && check_tsc_unstable()) {
353 clocksource_tsc.rating = 50; 353 clocksource_tsc.rating = 0;
354 clocksource_reselect(); 354 clocksource_reselect();
355 change = 1; 355 change = 1;
356 } 356 }
@@ -461,7 +461,7 @@ static int __init init_tsc_clocksource(void)
461 clocksource_tsc.shift); 461 clocksource_tsc.shift);
462 /* lower the rating if we already know its unstable: */ 462 /* lower the rating if we already know its unstable: */
463 if (check_tsc_unstable()) 463 if (check_tsc_unstable())
464 clocksource_tsc.rating = 50; 464 clocksource_tsc.rating = 0;
465 465
466 init_timer(&verify_tsc_freq_timer); 466 init_timer(&verify_tsc_freq_timer);
467 verify_tsc_freq_timer.function = verify_tsc_freq; 467 verify_tsc_freq_timer.function = verify_tsc_freq;
diff --git a/arch/i386/kernel/vmlinux.lds.S b/arch/i386/kernel/vmlinux.lds.S
index 1e7ac1c44ddc..c6f84a0322ba 100644
--- a/arch/i386/kernel/vmlinux.lds.S
+++ b/arch/i386/kernel/vmlinux.lds.S
@@ -51,6 +51,7 @@ SECTIONS
51 __tracedata_end = .; 51 __tracedata_end = .;
52 52
53 /* writeable */ 53 /* writeable */
54 . = ALIGN(4096);
54 .data : AT(ADDR(.data) - LOAD_OFFSET) { /* Data */ 55 .data : AT(ADDR(.data) - LOAD_OFFSET) { /* Data */
55 *(.data) 56 *(.data)
56 CONSTRUCTORS 57 CONSTRUCTORS
@@ -126,13 +127,7 @@ SECTIONS
126 __setup_end = .; 127 __setup_end = .;
127 __initcall_start = .; 128 __initcall_start = .;
128 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) { 129 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
129 *(.initcall1.init) 130 INITCALLS
130 *(.initcall2.init)
131 *(.initcall3.init)
132 *(.initcall4.init)
133 *(.initcall5.init)
134 *(.initcall6.init)
135 *(.initcall7.init)
136 } 131 }
137 __initcall_end = .; 132 __initcall_end = .;
138 __con_initcall_start = .; 133 __con_initcall_start = .;
diff --git a/arch/i386/lib/usercopy.c b/arch/i386/lib/usercopy.c
index 08502fc6d0cb..d22cfc9d656c 100644
--- a/arch/i386/lib/usercopy.c
+++ b/arch/i386/lib/usercopy.c
@@ -9,6 +9,7 @@
9#include <linux/highmem.h> 9#include <linux/highmem.h>
10#include <linux/blkdev.h> 10#include <linux/blkdev.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/backing-dev.h>
12#include <asm/uaccess.h> 13#include <asm/uaccess.h>
13#include <asm/mmx.h> 14#include <asm/mmx.h>
14 15
@@ -179,7 +180,7 @@ __clear_user(void __user *to, unsigned long n)
179EXPORT_SYMBOL(__clear_user); 180EXPORT_SYMBOL(__clear_user);
180 181
181/** 182/**
182 * strlen_user: - Get the size of a string in user space. 183 * strnlen_user: - Get the size of a string in user space.
183 * @s: The string to measure. 184 * @s: The string to measure.
184 * @n: The maximum valid length 185 * @n: The maximum valid length
185 * 186 *
@@ -741,7 +742,7 @@ survive:
741 742
742 if (retval == -ENOMEM && is_init(current)) { 743 if (retval == -ENOMEM && is_init(current)) {
743 up_read(&current->mm->mmap_sem); 744 up_read(&current->mm->mmap_sem);
744 blk_congestion_wait(WRITE, HZ/50); 745 congestion_wait(WRITE, HZ/50);
745 goto survive; 746 goto survive;
746 } 747 }
747 748
diff --git a/arch/i386/mach-visws/visws_apic.c b/arch/i386/mach-visws/visws_apic.c
index 07097ed48890..38c2b13124d9 100644
--- a/arch/i386/mach-visws/visws_apic.c
+++ b/arch/i386/mach-visws/visws_apic.c
@@ -122,7 +122,7 @@ static void end_cobalt_irq(unsigned int irq)
122 spin_unlock_irqrestore(&cobalt_lock, flags); 122 spin_unlock_irqrestore(&cobalt_lock, flags);
123} 123}
124 124
125static struct hw_interrupt_type cobalt_irq_type = { 125static struct irq_chip cobalt_irq_type = {
126 .typename = "Cobalt-APIC", 126 .typename = "Cobalt-APIC",
127 .startup = startup_cobalt_irq, 127 .startup = startup_cobalt_irq,
128 .shutdown = disable_cobalt_irq, 128 .shutdown = disable_cobalt_irq,
@@ -159,7 +159,7 @@ static void end_piix4_master_irq(unsigned int irq)
159 spin_unlock_irqrestore(&cobalt_lock, flags); 159 spin_unlock_irqrestore(&cobalt_lock, flags);
160} 160}
161 161
162static struct hw_interrupt_type piix4_master_irq_type = { 162static struct irq_chip piix4_master_irq_type = {
163 .typename = "PIIX4-master", 163 .typename = "PIIX4-master",
164 .startup = startup_piix4_master_irq, 164 .startup = startup_piix4_master_irq,
165 .ack = ack_cobalt_irq, 165 .ack = ack_cobalt_irq,
@@ -167,9 +167,8 @@ static struct hw_interrupt_type piix4_master_irq_type = {
167}; 167};
168 168
169 169
170static struct hw_interrupt_type piix4_virtual_irq_type = { 170static struct irq_chip piix4_virtual_irq_type = {
171 .typename = "PIIX4-virtual", 171 .typename = "PIIX4-virtual",
172 .startup = startup_8259A_irq,
173 .shutdown = disable_8259A_irq, 172 .shutdown = disable_8259A_irq,
174 .enable = enable_8259A_irq, 173 .enable = enable_8259A_irq,
175 .disable = disable_8259A_irq, 174 .disable = disable_8259A_irq,
diff --git a/arch/i386/mach-voyager/voyager_basic.c b/arch/i386/mach-voyager/voyager_basic.c
index c639d30d8bdc..8fe7e4593d5f 100644
--- a/arch/i386/mach-voyager/voyager_basic.c
+++ b/arch/i386/mach-voyager/voyager_basic.c
@@ -44,7 +44,7 @@ struct voyager_SUS *voyager_SUS = NULL;
44 44
45#ifdef CONFIG_SMP 45#ifdef CONFIG_SMP
46static void 46static void
47voyager_dump(int dummy1, struct pt_regs *dummy2, struct tty_struct *dummy3) 47voyager_dump(int dummy1, struct tty_struct *dummy3)
48{ 48{
49 /* get here via a sysrq */ 49 /* get here via a sysrq */
50 voyager_smp_dump(); 50 voyager_smp_dump();
@@ -166,7 +166,7 @@ voyager_memory_detect(int region, __u32 *start, __u32 *length)
166 * off the timer tick to the SMP code, since the VIC doesn't have an 166 * off the timer tick to the SMP code, since the VIC doesn't have an
167 * internal timer (The QIC does, but that's another story). */ 167 * internal timer (The QIC does, but that's another story). */
168void 168void
169voyager_timer_interrupt(struct pt_regs *regs) 169voyager_timer_interrupt(void)
170{ 170{
171 if((jiffies & 0x3ff) == 0) { 171 if((jiffies & 0x3ff) == 0) {
172 172
@@ -202,7 +202,7 @@ voyager_timer_interrupt(struct pt_regs *regs)
202 } 202 }
203 } 203 }
204#ifdef CONFIG_SMP 204#ifdef CONFIG_SMP
205 smp_vic_timer_interrupt(regs); 205 smp_vic_timer_interrupt();
206#endif 206#endif
207} 207}
208 208
diff --git a/arch/i386/mach-voyager/voyager_smp.c b/arch/i386/mach-voyager/voyager_smp.c
index d42422fc4af3..f3fea2ad50fe 100644
--- a/arch/i386/mach-voyager/voyager_smp.c
+++ b/arch/i386/mach-voyager/voyager_smp.c
@@ -85,8 +85,8 @@ static int ack_QIC_CPI(__u8 cpi);
85static void ack_special_QIC_CPI(__u8 cpi); 85static void ack_special_QIC_CPI(__u8 cpi);
86static void ack_VIC_CPI(__u8 cpi); 86static void ack_VIC_CPI(__u8 cpi);
87static void send_CPI_allbutself(__u8 cpi); 87static void send_CPI_allbutself(__u8 cpi);
88static void enable_vic_irq(unsigned int irq); 88static void mask_vic_irq(unsigned int irq);
89static void disable_vic_irq(unsigned int irq); 89static void unmask_vic_irq(unsigned int irq);
90static unsigned int startup_vic_irq(unsigned int irq); 90static unsigned int startup_vic_irq(unsigned int irq);
91static void enable_local_vic_irq(unsigned int irq); 91static void enable_local_vic_irq(unsigned int irq);
92static void disable_local_vic_irq(unsigned int irq); 92static void disable_local_vic_irq(unsigned int irq);
@@ -205,15 +205,12 @@ ack_CPI(__u8 cpi)
205/* The VIC IRQ descriptors -- these look almost identical to the 205/* The VIC IRQ descriptors -- these look almost identical to the
206 * 8259 IRQs except that masks and things must be kept per processor 206 * 8259 IRQs except that masks and things must be kept per processor
207 */ 207 */
208static struct hw_interrupt_type vic_irq_type = { 208static struct irq_chip vic_chip = {
209 .typename = "VIC-level", 209 .name = "VIC",
210 .startup = startup_vic_irq, 210 .startup = startup_vic_irq,
211 .shutdown = disable_vic_irq, 211 .mask = mask_vic_irq,
212 .enable = enable_vic_irq, 212 .unmask = unmask_vic_irq,
213 .disable = disable_vic_irq, 213 .set_affinity = set_vic_irq_affinity,
214 .ack = before_handle_vic_irq,
215 .end = after_handle_vic_irq,
216 .set_affinity = set_vic_irq_affinity,
217}; 214};
218 215
219/* used to count up as CPUs are brought on line (starts at 0) */ 216/* used to count up as CPUs are brought on line (starts at 0) */
@@ -1144,9 +1141,9 @@ smp_apic_timer_interrupt(struct pt_regs *regs)
1144fastcall void 1141fastcall void
1145smp_qic_timer_interrupt(struct pt_regs *regs) 1142smp_qic_timer_interrupt(struct pt_regs *regs)
1146{ 1143{
1147 ack_QIC_CPI(QIC_TIMER_CPI);
1148 struct pt_regs *old_regs = set_irq_regs(regs); 1144 struct pt_regs *old_regs = set_irq_regs(regs);
1149 wrapper_smp_local_timer_interrupt(void); 1145 ack_QIC_CPI(QIC_TIMER_CPI);
1146 wrapper_smp_local_timer_interrupt();
1150 set_irq_regs(old_regs); 1147 set_irq_regs(old_regs);
1151} 1148}
1152 1149
@@ -1270,12 +1267,10 @@ smp_send_stop(void)
1270/* this function is triggered in time.c when a clock tick fires 1267/* this function is triggered in time.c when a clock tick fires
1271 * we need to re-broadcast the tick to all CPUs */ 1268 * we need to re-broadcast the tick to all CPUs */
1272void 1269void
1273smp_vic_timer_interrupt(struct pt_regs *regs) 1270smp_vic_timer_interrupt(void)
1274{ 1271{
1275 struct pt_regs *old_regs = set_irq_regs(regs);
1276 send_CPI_allbutself(VIC_TIMER_CPI); 1272 send_CPI_allbutself(VIC_TIMER_CPI);
1277 smp_local_timer_interrupt(); 1273 smp_local_timer_interrupt();
1278 set_irq_regs(old_regs);
1279} 1274}
1280 1275
1281/* local (per CPU) timer interrupt. It does both profiling and 1276/* local (per CPU) timer interrupt. It does both profiling and
@@ -1310,7 +1305,7 @@ smp_local_timer_interrupt(void)
1310 per_cpu(prof_counter, cpu); 1305 per_cpu(prof_counter, cpu);
1311 } 1306 }
1312 1307
1313 update_process_times(user_mode_vm(irq_regs)); 1308 update_process_times(user_mode_vm(get_irq_regs()));
1314 } 1309 }
1315 1310
1316 if( ((1<<cpu) & voyager_extended_vic_processors) == 0) 1311 if( ((1<<cpu) & voyager_extended_vic_processors) == 0)
@@ -1397,6 +1392,17 @@ setup_profiling_timer(unsigned int multiplier)
1397 return 0; 1392 return 0;
1398} 1393}
1399 1394
1395/* This is a bit of a mess, but forced on us by the genirq changes
1396 * there's no genirq handler that really does what voyager wants
1397 * so hack it up with the simple IRQ handler */
1398static void fastcall
1399handle_vic_irq(unsigned int irq, struct irq_desc *desc)
1400{
1401 before_handle_vic_irq(irq);
1402 handle_simple_irq(irq, desc);
1403 after_handle_vic_irq(irq);
1404}
1405
1400 1406
1401/* The CPIs are handled in the per cpu 8259s, so they must be 1407/* The CPIs are handled in the per cpu 8259s, so they must be
1402 * enabled to be received: FIX: enabling the CPIs in the early 1408 * enabled to be received: FIX: enabling the CPIs in the early
@@ -1433,7 +1439,7 @@ smp_intr_init(void)
1433 * This is for later: first 16 correspond to PC IRQs; next 16 1439 * This is for later: first 16 correspond to PC IRQs; next 16
1434 * are Primary MC IRQs and final 16 are Secondary MC IRQs */ 1440 * are Primary MC IRQs and final 16 are Secondary MC IRQs */
1435 for(i = 0; i < 48; i++) 1441 for(i = 0; i < 48; i++)
1436 irq_desc[i].chip = &vic_irq_type; 1442 set_irq_chip_and_handler(i, &vic_chip, handle_vic_irq);
1437} 1443}
1438 1444
1439/* send a CPI at level cpi to a set of cpus in cpuset (set 1 bit per 1445/* send a CPI at level cpi to a set of cpus in cpuset (set 1 bit per
@@ -1531,7 +1537,7 @@ ack_VIC_CPI(__u8 cpi)
1531static unsigned int 1537static unsigned int
1532startup_vic_irq(unsigned int irq) 1538startup_vic_irq(unsigned int irq)
1533{ 1539{
1534 enable_vic_irq(irq); 1540 unmask_vic_irq(irq);
1535 1541
1536 return 0; 1542 return 0;
1537} 1543}
@@ -1558,7 +1564,7 @@ startup_vic_irq(unsigned int irq)
1558 * adjust their masks accordingly. */ 1564 * adjust their masks accordingly. */
1559 1565
1560static void 1566static void
1561enable_vic_irq(unsigned int irq) 1567unmask_vic_irq(unsigned int irq)
1562{ 1568{
1563 /* linux doesn't to processor-irq affinity, so enable on 1569 /* linux doesn't to processor-irq affinity, so enable on
1564 * all CPUs we know about */ 1570 * all CPUs we know about */
@@ -1567,7 +1573,7 @@ enable_vic_irq(unsigned int irq)
1567 __u32 processorList = 0; 1573 __u32 processorList = 0;
1568 unsigned long flags; 1574 unsigned long flags;
1569 1575
1570 VDEBUG(("VOYAGER: enable_vic_irq(%d) CPU%d affinity 0x%lx\n", 1576 VDEBUG(("VOYAGER: unmask_vic_irq(%d) CPU%d affinity 0x%lx\n",
1571 irq, cpu, cpu_irq_affinity[cpu])); 1577 irq, cpu, cpu_irq_affinity[cpu]));
1572 spin_lock_irqsave(&vic_irq_lock, flags); 1578 spin_lock_irqsave(&vic_irq_lock, flags);
1573 for_each_online_cpu(real_cpu) { 1579 for_each_online_cpu(real_cpu) {
@@ -1591,7 +1597,7 @@ enable_vic_irq(unsigned int irq)
1591} 1597}
1592 1598
1593static void 1599static void
1594disable_vic_irq(unsigned int irq) 1600mask_vic_irq(unsigned int irq)
1595{ 1601{
1596 /* lazy disable, do nothing */ 1602 /* lazy disable, do nothing */
1597} 1603}
@@ -1819,7 +1825,7 @@ set_vic_irq_affinity(unsigned int irq, cpumask_t mask)
1819 * disabled again as it comes in (voyager lazy disable). If 1825 * disabled again as it comes in (voyager lazy disable). If
1820 * the affinity map is tightened to disable the interrupt on a 1826 * the affinity map is tightened to disable the interrupt on a
1821 * cpu, it will be pushed off when it comes in */ 1827 * cpu, it will be pushed off when it comes in */
1822 enable_vic_irq(irq); 1828 unmask_vic_irq(irq);
1823} 1829}
1824 1830
1825static void 1831static void
diff --git a/arch/i386/mm/discontig.c b/arch/i386/mm/discontig.c
index 455597db84df..ddbdb0336f28 100644
--- a/arch/i386/mm/discontig.c
+++ b/arch/i386/mm/discontig.c
@@ -356,11 +356,12 @@ void __init numa_kva_reserve(void)
356void __init zone_sizes_init(void) 356void __init zone_sizes_init(void)
357{ 357{
358 int nid; 358 int nid;
359 unsigned long max_zone_pfns[MAX_NR_ZONES] = { 359 unsigned long max_zone_pfns[MAX_NR_ZONES];
360 virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT, 360 memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
361 max_low_pfn, 361 max_zone_pfns[ZONE_DMA] =
362 highend_pfn 362 virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
363 }; 363 max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
364 max_zone_pfns[ZONE_HIGHMEM] = highend_pfn;
364 365
365 /* If SRAT has not registered memory, register it now */ 366 /* If SRAT has not registered memory, register it now */
366 if (find_max_pfn_with_active_regions() == 0) { 367 if (find_max_pfn_with_active_regions() == 0) {
diff --git a/arch/i386/pci/common.c b/arch/i386/pci/common.c
index 68bce194e688..cdfcf971098b 100644
--- a/arch/i386/pci/common.c
+++ b/arch/i386/pci/common.c
@@ -20,6 +20,7 @@
20unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2 | 20unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2 |
21 PCI_PROBE_MMCONF; 21 PCI_PROBE_MMCONF;
22 22
23int pci_bf_sort;
23int pci_routeirq; 24int pci_routeirq;
24int pcibios_last_bus = -1; 25int pcibios_last_bus = -1;
25unsigned long pirq_table_addr; 26unsigned long pirq_table_addr;
@@ -118,6 +119,20 @@ void __devinit pcibios_fixup_bus(struct pci_bus *b)
118} 119}
119 120
120/* 121/*
122 * Only use DMI information to set this if nothing was passed
123 * on the kernel command line (which was parsed earlier).
124 */
125
126static int __devinit set_bf_sort(struct dmi_system_id *d)
127{
128 if (pci_bf_sort == pci_bf_sort_default) {
129 pci_bf_sort = pci_dmi_bf;
130 printk(KERN_INFO "PCI: %s detected, enabling pci=bfsort.\n", d->ident);
131 }
132 return 0;
133}
134
135/*
121 * Enable renumbering of PCI bus# ranges to reach all PCI busses (Cardbus) 136 * Enable renumbering of PCI bus# ranges to reach all PCI busses (Cardbus)
122 */ 137 */
123#ifdef __i386__ 138#ifdef __i386__
@@ -130,11 +145,11 @@ static int __devinit assign_all_busses(struct dmi_system_id *d)
130} 145}
131#endif 146#endif
132 147
148static struct dmi_system_id __devinitdata pciprobe_dmi_table[] = {
149#ifdef __i386__
133/* 150/*
134 * Laptops which need pci=assign-busses to see Cardbus cards 151 * Laptops which need pci=assign-busses to see Cardbus cards
135 */ 152 */
136static struct dmi_system_id __devinitdata pciprobe_dmi_table[] = {
137#ifdef __i386__
138 { 153 {
139 .callback = assign_all_busses, 154 .callback = assign_all_busses,
140 .ident = "Samsung X20 Laptop", 155 .ident = "Samsung X20 Laptop",
@@ -144,6 +159,38 @@ static struct dmi_system_id __devinitdata pciprobe_dmi_table[] = {
144 }, 159 },
145 }, 160 },
146#endif /* __i386__ */ 161#endif /* __i386__ */
162 {
163 .callback = set_bf_sort,
164 .ident = "Dell PowerEdge 1950",
165 .matches = {
166 DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
167 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1950"),
168 },
169 },
170 {
171 .callback = set_bf_sort,
172 .ident = "Dell PowerEdge 1955",
173 .matches = {
174 DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
175 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1955"),
176 },
177 },
178 {
179 .callback = set_bf_sort,
180 .ident = "Dell PowerEdge 2900",
181 .matches = {
182 DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
183 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 2900"),
184 },
185 },
186 {
187 .callback = set_bf_sort,
188 .ident = "Dell PowerEdge 2950",
189 .matches = {
190 DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
191 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 2950"),
192 },
193 },
147 {} 194 {}
148}; 195};
149 196
@@ -189,6 +236,8 @@ static int __init pcibios_init(void)
189 236
190 pcibios_resource_survey(); 237 pcibios_resource_survey();
191 238
239 if (pci_bf_sort >= pci_force_bf)
240 pci_sort_breadthfirst();
192#ifdef CONFIG_PCI_BIOS 241#ifdef CONFIG_PCI_BIOS
193 if ((pci_probe & PCI_BIOS_SORT) && !(pci_probe & PCI_NO_SORT)) 242 if ((pci_probe & PCI_BIOS_SORT) && !(pci_probe & PCI_NO_SORT))
194 pcibios_sort(); 243 pcibios_sort();
@@ -203,6 +252,12 @@ char * __devinit pcibios_setup(char *str)
203 if (!strcmp(str, "off")) { 252 if (!strcmp(str, "off")) {
204 pci_probe = 0; 253 pci_probe = 0;
205 return NULL; 254 return NULL;
255 } else if (!strcmp(str, "bfsort")) {
256 pci_bf_sort = pci_force_bf;
257 return NULL;
258 } else if (!strcmp(str, "nobfsort")) {
259 pci_bf_sort = pci_force_nobf;
260 return NULL;
206 } 261 }
207#ifdef CONFIG_PCI_BIOS 262#ifdef CONFIG_PCI_BIOS
208 else if (!strcmp(str, "bios")) { 263 else if (!strcmp(str, "bios")) {
@@ -288,7 +343,6 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
288 343
289void pcibios_disable_device (struct pci_dev *dev) 344void pcibios_disable_device (struct pci_dev *dev)
290{ 345{
291 pcibios_disable_resources(dev);
292 if (pcibios_disable_irq) 346 if (pcibios_disable_irq)
293 pcibios_disable_irq(dev); 347 pcibios_disable_irq(dev);
294} 348}
diff --git a/arch/i386/pci/fixup.c b/arch/i386/pci/fixup.c
index b60d7e8689ed..c1949ff38d61 100644
--- a/arch/i386/pci/fixup.c
+++ b/arch/i386/pci/fixup.c
@@ -348,8 +348,8 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_MCH_PC1, pcie_r
348 * From information provided by "Jon Smirl" <jonsmirl@gmail.com> 348 * From information provided by "Jon Smirl" <jonsmirl@gmail.com>
349 * 349 *
350 * The standard boot ROM sequence for an x86 machine uses the BIOS 350 * The standard boot ROM sequence for an x86 machine uses the BIOS
351 * to select an initial video card for boot display. This boot video 351 * to select an initial video card for boot display. This boot video
352 * card will have it's BIOS copied to C0000 in system RAM. 352 * card will have it's BIOS copied to C0000 in system RAM.
353 * IORESOURCE_ROM_SHADOW is used to associate the boot video 353 * IORESOURCE_ROM_SHADOW is used to associate the boot video
354 * card with this copy. On laptops this copy has to be used since 354 * card with this copy. On laptops this copy has to be used since
355 * the main ROM may be compressed or combined with another image. 355 * the main ROM may be compressed or combined with another image.
@@ -371,7 +371,17 @@ static void __devinit pci_fixup_video(struct pci_dev *pdev)
371 bus = pdev->bus; 371 bus = pdev->bus;
372 while (bus) { 372 while (bus) {
373 bridge = bus->self; 373 bridge = bus->self;
374 if (bridge) { 374
375 /*
376 * From information provided by
377 * "David Miller" <davem@davemloft.net>
378 * The bridge control register is valid for PCI header
379 * type BRIDGE, or CARDBUS. Host to PCI controllers use
380 * PCI header type NORMAL.
381 */
382 if (bridge
383 &&((bridge->hdr_type == PCI_HEADER_TYPE_BRIDGE)
384 ||(bridge->hdr_type == PCI_HEADER_TYPE_CARDBUS))) {
375 pci_read_config_word(bridge, PCI_BRIDGE_CONTROL, 385 pci_read_config_word(bridge, PCI_BRIDGE_CONTROL,
376 &config); 386 &config);
377 if (!(config & PCI_BRIDGE_CTL_VGA)) 387 if (!(config & PCI_BRIDGE_CTL_VGA))
diff --git a/arch/i386/pci/i386.c b/arch/i386/pci/i386.c
index 10154a2cac68..98580292f0d4 100644
--- a/arch/i386/pci/i386.c
+++ b/arch/i386/pci/i386.c
@@ -242,15 +242,6 @@ int pcibios_enable_resources(struct pci_dev *dev, int mask)
242 return 0; 242 return 0;
243} 243}
244 244
245void pcibios_disable_resources(struct pci_dev *dev)
246{
247 u16 cmd;
248
249 pci_read_config_word(dev, PCI_COMMAND, &cmd);
250 cmd &= ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY);
251 pci_write_config_word(dev, PCI_COMMAND, cmd);
252}
253
254/* 245/*
255 * If we set up a device for bus mastering, we need to check the latency 246 * If we set up a device for bus mastering, we need to check the latency
256 * timer as certain crappy BIOSes forget to set it properly. 247 * timer as certain crappy BIOSes forget to set it properly.
diff --git a/arch/i386/pci/irq.c b/arch/i386/pci/irq.c
index dbc4aae91959..69163998adeb 100644
--- a/arch/i386/pci/irq.c
+++ b/arch/i386/pci/irq.c
@@ -255,13 +255,13 @@ static int pirq_via_set(struct pci_dev *router, struct pci_dev *dev, int pirq, i
255 */ 255 */
256static int pirq_via586_get(struct pci_dev *router, struct pci_dev *dev, int pirq) 256static int pirq_via586_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
257{ 257{
258 static const unsigned int pirqmap[4] = { 3, 2, 5, 1 }; 258 static const unsigned int pirqmap[5] = { 3, 2, 5, 1, 1 };
259 return read_config_nybble(router, 0x55, pirqmap[pirq-1]); 259 return read_config_nybble(router, 0x55, pirqmap[pirq-1]);
260} 260}
261 261
262static int pirq_via586_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq) 262static int pirq_via586_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
263{ 263{
264 static const unsigned int pirqmap[4] = { 3, 2, 5, 1 }; 264 static const unsigned int pirqmap[5] = { 3, 2, 5, 1, 1 };
265 write_config_nybble(router, 0x55, pirqmap[pirq-1], irq); 265 write_config_nybble(router, 0x55, pirqmap[pirq-1], irq);
266 return 1; 266 return 1;
267} 267}
diff --git a/arch/i386/pci/mmconfig.c b/arch/i386/pci/mmconfig.c
index d0c3da3aa2aa..c6b6d9bbc453 100644
--- a/arch/i386/pci/mmconfig.c
+++ b/arch/i386/pci/mmconfig.c
@@ -154,38 +154,6 @@ static struct pci_raw_ops pci_mmcfg = {
154 .write = pci_mmcfg_write, 154 .write = pci_mmcfg_write,
155}; 155};
156 156
157
158static __init void pci_mmcfg_insert_resources(void)
159{
160#define PCI_MMCFG_RESOURCE_NAME_LEN 19
161 int i;
162 struct resource *res;
163 char *names;
164 unsigned num_buses;
165
166 res = kcalloc(PCI_MMCFG_RESOURCE_NAME_LEN + sizeof(*res),
167 pci_mmcfg_config_num, GFP_KERNEL);
168
169 if (!res) {
170 printk(KERN_ERR "PCI: Unable to allocate MMCONFIG resources\n");
171 return;
172 }
173
174 names = (void *)&res[pci_mmcfg_config_num];
175 for (i = 0; i < pci_mmcfg_config_num; i++, res++) {
176 num_buses = pci_mmcfg_config[i].end_bus_number -
177 pci_mmcfg_config[i].start_bus_number + 1;
178 res->name = names;
179 snprintf(names, PCI_MMCFG_RESOURCE_NAME_LEN, "PCI MMCONFIG %u",
180 pci_mmcfg_config[i].pci_segment_group_number);
181 res->start = pci_mmcfg_config[i].base_address;
182 res->end = res->start + (num_buses << 20) - 1;
183 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
184 insert_resource(&iomem_resource, res);
185 names += PCI_MMCFG_RESOURCE_NAME_LEN;
186 }
187}
188
189/* K8 systems have some devices (typically in the builtin northbridge) 157/* K8 systems have some devices (typically in the builtin northbridge)
190 that are only accessible using type1 158 that are only accessible using type1
191 Normally this can be expressed in the MCFG by not listing them 159 Normally this can be expressed in the MCFG by not listing them
@@ -222,8 +190,6 @@ static __init void unreachable_devices(void)
222 } 190 }
223} 191}
224 192
225
226
227void __init pci_mmcfg_init(int type) 193void __init pci_mmcfg_init(int type)
228{ 194{
229 if ((pci_probe & PCI_PROBE_MMCONF) == 0) 195 if ((pci_probe & PCI_PROBE_MMCONF) == 0)
@@ -251,5 +217,4 @@ void __init pci_mmcfg_init(int type)
251 pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF; 217 pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF;
252 218
253 unreachable_devices(); 219 unreachable_devices();
254 pci_mmcfg_insert_resources();
255} 220}
diff --git a/arch/i386/pci/pci.h b/arch/i386/pci/pci.h
index 1814f74569c6..a0a25180b61a 100644
--- a/arch/i386/pci/pci.h
+++ b/arch/i386/pci/pci.h
@@ -30,13 +30,19 @@
30extern unsigned int pci_probe; 30extern unsigned int pci_probe;
31extern unsigned long pirq_table_addr; 31extern unsigned long pirq_table_addr;
32 32
33enum pci_bf_sort_state {
34 pci_bf_sort_default,
35 pci_force_nobf,
36 pci_force_bf,
37 pci_dmi_bf,
38};
39
33/* pci-i386.c */ 40/* pci-i386.c */
34 41
35extern unsigned int pcibios_max_latency; 42extern unsigned int pcibios_max_latency;
36 43
37void pcibios_resource_survey(void); 44void pcibios_resource_survey(void);
38int pcibios_enable_resources(struct pci_dev *, int); 45int pcibios_enable_resources(struct pci_dev *, int);
39void pcibios_disable_resources(struct pci_dev *);
40 46
41/* pci-pc.c */ 47/* pci-pc.c */
42 48
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 70f7eb9fed35..683b12c6f76c 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -341,6 +341,7 @@ config NUMA
341 bool "NUMA support" 341 bool "NUMA support"
342 depends on !IA64_HP_SIM && !FLATMEM 342 depends on !IA64_HP_SIM && !FLATMEM
343 default y if IA64_SGI_SN2 343 default y if IA64_SGI_SN2
344 select ACPI_NUMA if ACPI
344 help 345 help
345 Say Y to compile the kernel to support NUMA (Non-Uniform Memory 346 Say Y to compile the kernel to support NUMA (Non-Uniform Memory
346 Access). This option is for configuring high-end multiprocessor 347 Access). This option is for configuring high-end multiprocessor
@@ -483,6 +484,15 @@ source "net/Kconfig"
483 484
484source "drivers/Kconfig" 485source "drivers/Kconfig"
485 486
487config MSPEC
488 tristate "Memory special operations driver"
489 depends on IA64
490 select IA64_UNCACHED_ALLOCATOR
491 help
492 If you have an ia64 and you want to enable memory special
493 operations support (formerly known as fetchop), say Y here,
494 otherwise say N.
495
486source "fs/Kconfig" 496source "fs/Kconfig"
487 497
488source "lib/Kconfig" 498source "lib/Kconfig"
diff --git a/arch/ia64/configs/sn2_defconfig b/arch/ia64/configs/sn2_defconfig
index 0f14a82b856e..64e951de4e57 100644
--- a/arch/ia64/configs/sn2_defconfig
+++ b/arch/ia64/configs/sn2_defconfig
@@ -1,8 +1,9 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.17-rc3 3# Linux kernel version: 2.6.19-rc1
4# Thu Apr 27 11:48:23 2006 4# Mon Oct 9 10:53:59 2006
5# 5#
6CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
6 7
7# 8#
8# Code maturity level options 9# Code maturity level options
@@ -18,16 +19,22 @@ CONFIG_LOCALVERSION=""
18# CONFIG_LOCALVERSION_AUTO is not set 19# CONFIG_LOCALVERSION_AUTO is not set
19CONFIG_SWAP=y 20CONFIG_SWAP=y
20CONFIG_SYSVIPC=y 21CONFIG_SYSVIPC=y
22# CONFIG_IPC_NS is not set
21CONFIG_POSIX_MQUEUE=y 23CONFIG_POSIX_MQUEUE=y
22# CONFIG_BSD_PROCESS_ACCT is not set 24# CONFIG_BSD_PROCESS_ACCT is not set
23CONFIG_SYSCTL=y 25CONFIG_TASKSTATS=y
26# CONFIG_TASK_DELAY_ACCT is not set
27# CONFIG_UTS_NS is not set
24# CONFIG_AUDIT is not set 28# CONFIG_AUDIT is not set
25# CONFIG_IKCONFIG is not set 29# CONFIG_IKCONFIG is not set
26CONFIG_CPUSETS=y 30CONFIG_CPUSETS=y
27CONFIG_RELAY=y 31CONFIG_RELAY=y
28CONFIG_INITRAMFS_SOURCE="" 32CONFIG_INITRAMFS_SOURCE=""
29CONFIG_CC_OPTIMIZE_FOR_SIZE=y 33CONFIG_CC_OPTIMIZE_FOR_SIZE=y
34CONFIG_TASK_XACCT=y
35CONFIG_SYSCTL=y
30# CONFIG_EMBEDDED is not set 36# CONFIG_EMBEDDED is not set
37# CONFIG_SYSCTL_SYSCALL is not set
31CONFIG_KALLSYMS=y 38CONFIG_KALLSYMS=y
32CONFIG_KALLSYMS_ALL=y 39CONFIG_KALLSYMS_ALL=y
33# CONFIG_KALLSYMS_EXTRA_PASS is not set 40# CONFIG_KALLSYMS_EXTRA_PASS is not set
@@ -40,6 +47,8 @@ CONFIG_FUTEX=y
40CONFIG_EPOLL=y 47CONFIG_EPOLL=y
41CONFIG_SHMEM=y 48CONFIG_SHMEM=y
42CONFIG_SLAB=y 49CONFIG_SLAB=y
50CONFIG_VM_EVENT_COUNTERS=y
51CONFIG_RT_MUTEXES=y
43# CONFIG_TINY_SHMEM is not set 52# CONFIG_TINY_SHMEM is not set
44CONFIG_BASE_SMALL=0 53CONFIG_BASE_SMALL=0
45# CONFIG_SLOB is not set 54# CONFIG_SLOB is not set
@@ -58,6 +67,7 @@ CONFIG_STOP_MACHINE=y
58# 67#
59# Block layer 68# Block layer
60# 69#
70CONFIG_BLOCK=y
61# CONFIG_BLK_DEV_IO_TRACE is not set 71# CONFIG_BLK_DEV_IO_TRACE is not set
62 72
63# 73#
@@ -89,7 +99,7 @@ CONFIG_EFI=y
89CONFIG_GENERIC_IOMAP=y 99CONFIG_GENERIC_IOMAP=y
90CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y 100CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
91CONFIG_IA64_UNCACHED_ALLOCATOR=y 101CONFIG_IA64_UNCACHED_ALLOCATOR=y
92CONFIG_DMA_IS_DMA32=y 102CONFIG_AUDIT_ARCH=y
93# CONFIG_IA64_GENERIC is not set 103# CONFIG_IA64_GENERIC is not set
94# CONFIG_IA64_DIG is not set 104# CONFIG_IA64_DIG is not set
95# CONFIG_IA64_HP_ZX1 is not set 105# CONFIG_IA64_HP_ZX1 is not set
@@ -116,6 +126,7 @@ CONFIG_FORCE_MAX_ZONEORDER=17
116CONFIG_SMP=y 126CONFIG_SMP=y
117CONFIG_NR_CPUS=1024 127CONFIG_NR_CPUS=1024
118# CONFIG_HOTPLUG_CPU is not set 128# CONFIG_HOTPLUG_CPU is not set
129CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
119CONFIG_SCHED_SMT=y 130CONFIG_SCHED_SMT=y
120CONFIG_PREEMPT=y 131CONFIG_PREEMPT=y
121CONFIG_SELECT_MEMORY_MODEL=y 132CONFIG_SELECT_MEMORY_MODEL=y
@@ -128,6 +139,7 @@ CONFIG_NEED_MULTIPLE_NODES=y
128# CONFIG_SPARSEMEM_STATIC is not set 139# CONFIG_SPARSEMEM_STATIC is not set
129CONFIG_SPLIT_PTLOCK_CPUS=4 140CONFIG_SPLIT_PTLOCK_CPUS=4
130CONFIG_MIGRATION=y 141CONFIG_MIGRATION=y
142CONFIG_RESOURCES_64BIT=y
131CONFIG_ARCH_SELECT_MEMORY_MODEL=y 143CONFIG_ARCH_SELECT_MEMORY_MODEL=y
132CONFIG_ARCH_DISCONTIGMEM_ENABLE=y 144CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
133CONFIG_ARCH_FLATMEM_ENABLE=y 145CONFIG_ARCH_FLATMEM_ENABLE=y
@@ -135,15 +147,24 @@ CONFIG_ARCH_SPARSEMEM_ENABLE=y
135CONFIG_ARCH_DISCONTIGMEM_DEFAULT=y 147CONFIG_ARCH_DISCONTIGMEM_DEFAULT=y
136CONFIG_NUMA=y 148CONFIG_NUMA=y
137CONFIG_NODES_SHIFT=10 149CONFIG_NODES_SHIFT=10
150CONFIG_ARCH_POPULATES_NODE_MAP=y
138CONFIG_VIRTUAL_MEM_MAP=y 151CONFIG_VIRTUAL_MEM_MAP=y
139CONFIG_HOLES_IN_ZONE=y 152CONFIG_HOLES_IN_ZONE=y
140CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y 153CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y
154CONFIG_HAVE_ARCH_NODEDATA_EXTENSION=y
141CONFIG_IA32_SUPPORT=y 155CONFIG_IA32_SUPPORT=y
142CONFIG_COMPAT=y 156CONFIG_COMPAT=y
143CONFIG_IA64_MCA_RECOVERY=y 157CONFIG_IA64_MCA_RECOVERY=y
144CONFIG_PERFMON=y 158CONFIG_PERFMON=y
145CONFIG_IA64_PALINFO=y 159CONFIG_IA64_PALINFO=y
146CONFIG_SGI_SN=y 160CONFIG_SGI_SN=y
161# CONFIG_IA64_ESI is not set
162
163#
164# SN Devices
165#
166CONFIG_SGI_IOC4=y
167CONFIG_SGI_IOC3=y
147 168
148# 169#
149# Firmware Drivers 170# Firmware Drivers
@@ -159,6 +180,7 @@ CONFIG_BINFMT_ELF=y
159CONFIG_PM=y 180CONFIG_PM=y
160# CONFIG_PM_LEGACY is not set 181# CONFIG_PM_LEGACY is not set
161# CONFIG_PM_DEBUG is not set 182# CONFIG_PM_DEBUG is not set
183# CONFIG_PM_SYSFS_DEPRECATED is not set
162 184
163# 185#
164# ACPI (Advanced Configuration and Power Interface) Support 186# ACPI (Advanced Configuration and Power Interface) Support
@@ -166,6 +188,7 @@ CONFIG_PM=y
166CONFIG_ACPI=y 188CONFIG_ACPI=y
167# CONFIG_ACPI_BUTTON is not set 189# CONFIG_ACPI_BUTTON is not set
168# CONFIG_ACPI_FAN is not set 190# CONFIG_ACPI_FAN is not set
191# CONFIG_ACPI_DOCK is not set
169# CONFIG_ACPI_PROCESSOR is not set 192# CONFIG_ACPI_PROCESSOR is not set
170CONFIG_ACPI_NUMA=y 193CONFIG_ACPI_NUMA=y
171CONFIG_ACPI_BLACKLIST_YEAR=0 194CONFIG_ACPI_BLACKLIST_YEAR=0
@@ -185,7 +208,12 @@ CONFIG_ACPI_SYSTEM=y
185# 208#
186CONFIG_PCI=y 209CONFIG_PCI=y
187CONFIG_PCI_DOMAINS=y 210CONFIG_PCI_DOMAINS=y
211CONFIG_PCIEPORTBUS=y
212CONFIG_HOTPLUG_PCI_PCIE=y
213# CONFIG_HOTPLUG_PCI_PCIE_POLL_EVENT_MODE is not set
214CONFIG_PCIEAER=y
188# CONFIG_PCI_MSI is not set 215# CONFIG_PCI_MSI is not set
216# CONFIG_PCI_MULTITHREAD_PROBE is not set
189# CONFIG_PCI_DEBUG is not set 217# CONFIG_PCI_DEBUG is not set
190 218
191# 219#
@@ -215,6 +243,9 @@ CONFIG_NET=y
215CONFIG_PACKET=y 243CONFIG_PACKET=y
216CONFIG_PACKET_MMAP=y 244CONFIG_PACKET_MMAP=y
217CONFIG_UNIX=y 245CONFIG_UNIX=y
246CONFIG_XFRM=y
247# CONFIG_XFRM_USER is not set
248# CONFIG_XFRM_SUB_POLICY is not set
218# CONFIG_NET_KEY is not set 249# CONFIG_NET_KEY is not set
219CONFIG_INET=y 250CONFIG_INET=y
220CONFIG_IP_MULTICAST=y 251CONFIG_IP_MULTICAST=y
@@ -231,19 +262,31 @@ CONFIG_SYN_COOKIES=y
231# CONFIG_INET_IPCOMP is not set 262# CONFIG_INET_IPCOMP is not set
232# CONFIG_INET_XFRM_TUNNEL is not set 263# CONFIG_INET_XFRM_TUNNEL is not set
233# CONFIG_INET_TUNNEL is not set 264# CONFIG_INET_TUNNEL is not set
265CONFIG_INET_XFRM_MODE_TRANSPORT=y
266CONFIG_INET_XFRM_MODE_TUNNEL=y
267CONFIG_INET_XFRM_MODE_BEET=y
234CONFIG_INET_DIAG=m 268CONFIG_INET_DIAG=m
235CONFIG_INET_TCP_DIAG=m 269CONFIG_INET_TCP_DIAG=m
236# CONFIG_TCP_CONG_ADVANCED is not set 270# CONFIG_TCP_CONG_ADVANCED is not set
237CONFIG_TCP_CONG_BIC=y 271CONFIG_TCP_CONG_CUBIC=y
272CONFIG_DEFAULT_TCP_CONG="cubic"
238CONFIG_IPV6=m 273CONFIG_IPV6=m
239# CONFIG_IPV6_PRIVACY is not set 274# CONFIG_IPV6_PRIVACY is not set
240# CONFIG_IPV6_ROUTER_PREF is not set 275# CONFIG_IPV6_ROUTER_PREF is not set
241# CONFIG_INET6_AH is not set 276# CONFIG_INET6_AH is not set
242# CONFIG_INET6_ESP is not set 277# CONFIG_INET6_ESP is not set
243# CONFIG_INET6_IPCOMP is not set 278# CONFIG_INET6_IPCOMP is not set
279# CONFIG_IPV6_MIP6 is not set
244# CONFIG_INET6_XFRM_TUNNEL is not set 280# CONFIG_INET6_XFRM_TUNNEL is not set
245# CONFIG_INET6_TUNNEL is not set 281# CONFIG_INET6_TUNNEL is not set
282CONFIG_INET6_XFRM_MODE_TRANSPORT=m
283CONFIG_INET6_XFRM_MODE_TUNNEL=m
284CONFIG_INET6_XFRM_MODE_BEET=m
285# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
246# CONFIG_IPV6_TUNNEL is not set 286# CONFIG_IPV6_TUNNEL is not set
287# CONFIG_IPV6_SUBTREES is not set
288# CONFIG_IPV6_MULTIPLE_TABLES is not set
289# CONFIG_NETWORK_SECMARK is not set
247# CONFIG_NETFILTER is not set 290# CONFIG_NETFILTER is not set
248 291
249# 292#
@@ -269,7 +312,6 @@ CONFIG_IPV6=m
269# CONFIG_ATALK is not set 312# CONFIG_ATALK is not set
270# CONFIG_X25 is not set 313# CONFIG_X25 is not set
271# CONFIG_LAPB is not set 314# CONFIG_LAPB is not set
272# CONFIG_NET_DIVERT is not set
273# CONFIG_ECONET is not set 315# CONFIG_ECONET is not set
274# CONFIG_WAN_ROUTER is not set 316# CONFIG_WAN_ROUTER is not set
275 317
@@ -298,6 +340,7 @@ CONFIG_STANDALONE=y
298CONFIG_PREVENT_FIRMWARE_BUILD=y 340CONFIG_PREVENT_FIRMWARE_BUILD=y
299CONFIG_FW_LOADER=y 341CONFIG_FW_LOADER=y
300# CONFIG_DEBUG_DRIVER is not set 342# CONFIG_DEBUG_DRIVER is not set
343# CONFIG_SYS_HYPERVISOR is not set
301 344
302# 345#
303# Connector - unified userspace <-> kernelspace linker 346# Connector - unified userspace <-> kernelspace linker
@@ -335,6 +378,7 @@ CONFIG_BLK_DEV_NBD=m
335CONFIG_BLK_DEV_RAM=y 378CONFIG_BLK_DEV_RAM=y
336CONFIG_BLK_DEV_RAM_COUNT=16 379CONFIG_BLK_DEV_RAM_COUNT=16
337CONFIG_BLK_DEV_RAM_SIZE=4096 380CONFIG_BLK_DEV_RAM_SIZE=4096
381CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
338CONFIG_BLK_DEV_INITRD=y 382CONFIG_BLK_DEV_INITRD=y
339# CONFIG_CDROM_PKTCDVD is not set 383# CONFIG_CDROM_PKTCDVD is not set
340CONFIG_ATA_OVER_ETH=m 384CONFIG_ATA_OVER_ETH=m
@@ -381,6 +425,7 @@ CONFIG_IDEDMA_PCI_AUTO=y
381# CONFIG_BLK_DEV_CS5530 is not set 425# CONFIG_BLK_DEV_CS5530 is not set
382# CONFIG_BLK_DEV_HPT34X is not set 426# CONFIG_BLK_DEV_HPT34X is not set
383# CONFIG_BLK_DEV_HPT366 is not set 427# CONFIG_BLK_DEV_HPT366 is not set
428# CONFIG_BLK_DEV_JMICRON is not set
384# CONFIG_BLK_DEV_SC1200 is not set 429# CONFIG_BLK_DEV_SC1200 is not set
385# CONFIG_BLK_DEV_PIIX is not set 430# CONFIG_BLK_DEV_PIIX is not set
386# CONFIG_BLK_DEV_IT821X is not set 431# CONFIG_BLK_DEV_IT821X is not set
@@ -404,6 +449,7 @@ CONFIG_IDEDMA_AUTO=y
404# 449#
405# CONFIG_RAID_ATTRS is not set 450# CONFIG_RAID_ATTRS is not set
406CONFIG_SCSI=y 451CONFIG_SCSI=y
452CONFIG_SCSI_NETLINK=y
407CONFIG_SCSI_PROC_FS=y 453CONFIG_SCSI_PROC_FS=y
408 454
409# 455#
@@ -425,12 +471,14 @@ CONFIG_SCSI_CONSTANTS=y
425# CONFIG_SCSI_LOGGING is not set 471# CONFIG_SCSI_LOGGING is not set
426 472
427# 473#
428# SCSI Transport Attributes 474# SCSI Transports
429# 475#
430CONFIG_SCSI_SPI_ATTRS=y 476CONFIG_SCSI_SPI_ATTRS=y
431CONFIG_SCSI_FC_ATTRS=y 477CONFIG_SCSI_FC_ATTRS=y
432CONFIG_SCSI_ISCSI_ATTRS=m 478CONFIG_SCSI_ISCSI_ATTRS=m
433CONFIG_SCSI_SAS_ATTRS=y 479CONFIG_SCSI_SAS_ATTRS=y
480CONFIG_SCSI_SAS_LIBSAS=y
481# CONFIG_SCSI_SAS_LIBSAS_DEBUG is not set
434 482
435# 483#
436# SCSI low-level drivers 484# SCSI low-level drivers
@@ -443,46 +491,82 @@ CONFIG_ISCSI_TCP=m
443# CONFIG_SCSI_AIC7XXX is not set 491# CONFIG_SCSI_AIC7XXX is not set
444# CONFIG_SCSI_AIC7XXX_OLD is not set 492# CONFIG_SCSI_AIC7XXX_OLD is not set
445# CONFIG_SCSI_AIC79XX is not set 493# CONFIG_SCSI_AIC79XX is not set
494# CONFIG_SCSI_AIC94XX is not set
495# CONFIG_SCSI_ARCMSR is not set
446# CONFIG_MEGARAID_NEWGEN is not set 496# CONFIG_MEGARAID_NEWGEN is not set
447# CONFIG_MEGARAID_LEGACY is not set 497# CONFIG_MEGARAID_LEGACY is not set
448# CONFIG_MEGARAID_SAS is not set 498# CONFIG_MEGARAID_SAS is not set
449CONFIG_SCSI_SATA=y 499# CONFIG_SCSI_HPTIOP is not set
450# CONFIG_SCSI_SATA_AHCI is not set
451# CONFIG_SCSI_SATA_SVW is not set
452# CONFIG_SCSI_ATA_PIIX is not set
453# CONFIG_SCSI_SATA_MV is not set
454# CONFIG_SCSI_SATA_NV is not set
455# CONFIG_SCSI_PDC_ADMA is not set
456# CONFIG_SCSI_SATA_QSTOR is not set
457# CONFIG_SCSI_SATA_PROMISE is not set
458# CONFIG_SCSI_SATA_SX4 is not set
459# CONFIG_SCSI_SATA_SIL is not set
460# CONFIG_SCSI_SATA_SIL24 is not set
461# CONFIG_SCSI_SATA_SIS is not set
462# CONFIG_SCSI_SATA_ULI is not set
463# CONFIG_SCSI_SATA_VIA is not set
464CONFIG_SCSI_SATA_VITESSE=y
465# CONFIG_SCSI_DMX3191D is not set 500# CONFIG_SCSI_DMX3191D is not set
466# CONFIG_SCSI_FUTURE_DOMAIN is not set 501# CONFIG_SCSI_FUTURE_DOMAIN is not set
467# CONFIG_SCSI_IPS is not set 502# CONFIG_SCSI_IPS is not set
468# CONFIG_SCSI_INITIO is not set 503# CONFIG_SCSI_INITIO is not set
469# CONFIG_SCSI_INIA100 is not set 504# CONFIG_SCSI_INIA100 is not set
505# CONFIG_SCSI_STEX is not set
470# CONFIG_SCSI_SYM53C8XX_2 is not set 506# CONFIG_SCSI_SYM53C8XX_2 is not set
471# CONFIG_SCSI_IPR is not set 507# CONFIG_SCSI_IPR is not set
472CONFIG_SCSI_QLOGIC_1280=y 508CONFIG_SCSI_QLOGIC_1280=y
473CONFIG_SCSI_QLA_FC=y 509CONFIG_SCSI_QLA_FC=y
474CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE=y 510# CONFIG_SCSI_QLA_ISCSI is not set
475# CONFIG_SCSI_QLA21XX is not set
476CONFIG_SCSI_QLA22XX=y
477CONFIG_SCSI_QLA2300=y
478CONFIG_SCSI_QLA2322=y
479# CONFIG_SCSI_QLA24XX is not set
480# CONFIG_SCSI_LPFC is not set 511# CONFIG_SCSI_LPFC is not set
481# CONFIG_SCSI_DC395x is not set 512# CONFIG_SCSI_DC395x is not set
482# CONFIG_SCSI_DC390T is not set 513# CONFIG_SCSI_DC390T is not set
483# CONFIG_SCSI_DEBUG is not set 514# CONFIG_SCSI_DEBUG is not set
484 515
485# 516#
517# Serial ATA (prod) and Parallel ATA (experimental) drivers
518#
519CONFIG_ATA=y
520# CONFIG_SATA_AHCI is not set
521# CONFIG_SATA_SVW is not set
522# CONFIG_ATA_PIIX is not set
523# CONFIG_SATA_MV is not set
524# CONFIG_SATA_NV is not set
525# CONFIG_PDC_ADMA is not set
526# CONFIG_SATA_QSTOR is not set
527# CONFIG_SATA_PROMISE is not set
528# CONFIG_SATA_SX4 is not set
529# CONFIG_SATA_SIL is not set
530# CONFIG_SATA_SIL24 is not set
531# CONFIG_SATA_SIS is not set
532# CONFIG_SATA_ULI is not set
533# CONFIG_SATA_VIA is not set
534CONFIG_SATA_VITESSE=y
535# CONFIG_PATA_ALI is not set
536# CONFIG_PATA_AMD is not set
537# CONFIG_PATA_ARTOP is not set
538# CONFIG_PATA_ATIIXP is not set
539# CONFIG_PATA_CMD64X is not set
540# CONFIG_PATA_CS5520 is not set
541# CONFIG_PATA_CS5530 is not set
542# CONFIG_PATA_CYPRESS is not set
543# CONFIG_PATA_EFAR is not set
544# CONFIG_ATA_GENERIC is not set
545# CONFIG_PATA_HPT366 is not set
546# CONFIG_PATA_HPT37X is not set
547# CONFIG_PATA_HPT3X2N is not set
548# CONFIG_PATA_HPT3X3 is not set
549# CONFIG_PATA_IT821X is not set
550# CONFIG_PATA_JMICRON is not set
551# CONFIG_PATA_TRIFLEX is not set
552# CONFIG_PATA_MPIIX is not set
553# CONFIG_PATA_OLDPIIX is not set
554# CONFIG_PATA_NETCELL is not set
555# CONFIG_PATA_NS87410 is not set
556# CONFIG_PATA_OPTI is not set
557# CONFIG_PATA_OPTIDMA is not set
558# CONFIG_PATA_PDC_OLD is not set
559# CONFIG_PATA_RADISYS is not set
560# CONFIG_PATA_RZ1000 is not set
561# CONFIG_PATA_SC1200 is not set
562# CONFIG_PATA_SERVERWORKS is not set
563# CONFIG_PATA_PDC2027X is not set
564# CONFIG_PATA_SIL680 is not set
565# CONFIG_PATA_SIS is not set
566# CONFIG_PATA_VIA is not set
567# CONFIG_PATA_WINBOND is not set
568
569#
486# Multi-device support (RAID and LVM) 570# Multi-device support (RAID and LVM)
487# 571#
488CONFIG_MD=y 572CONFIG_MD=y
@@ -491,12 +575,12 @@ CONFIG_MD_LINEAR=y
491CONFIG_MD_RAID0=y 575CONFIG_MD_RAID0=y
492CONFIG_MD_RAID1=y 576CONFIG_MD_RAID1=y
493# CONFIG_MD_RAID10 is not set 577# CONFIG_MD_RAID10 is not set
494CONFIG_MD_RAID5=y 578CONFIG_MD_RAID456=y
495# CONFIG_MD_RAID5_RESHAPE is not set 579# CONFIG_MD_RAID5_RESHAPE is not set
496# CONFIG_MD_RAID6 is not set
497CONFIG_MD_MULTIPATH=y 580CONFIG_MD_MULTIPATH=y
498# CONFIG_MD_FAULTY is not set 581# CONFIG_MD_FAULTY is not set
499CONFIG_BLK_DEV_DM=y 582CONFIG_BLK_DEV_DM=y
583# CONFIG_DM_DEBUG is not set
500CONFIG_DM_CRYPT=m 584CONFIG_DM_CRYPT=m
501CONFIG_DM_SNAPSHOT=m 585CONFIG_DM_SNAPSHOT=m
502CONFIG_DM_MIRROR=m 586CONFIG_DM_MIRROR=m
@@ -563,6 +647,7 @@ CONFIG_NETDEVICES=y
563# CONFIG_SK98LIN is not set 647# CONFIG_SK98LIN is not set
564CONFIG_TIGON3=y 648CONFIG_TIGON3=y
565# CONFIG_BNX2 is not set 649# CONFIG_BNX2 is not set
650# CONFIG_QLA3XXX is not set
566 651
567# 652#
568# Ethernet (10000 Mbit) 653# Ethernet (10000 Mbit)
@@ -571,6 +656,7 @@ CONFIG_CHELSIO_T1=m
571# CONFIG_IXGB is not set 656# CONFIG_IXGB is not set
572CONFIG_S2IO=m 657CONFIG_S2IO=m
573# CONFIG_S2IO_NAPI is not set 658# CONFIG_S2IO_NAPI is not set
659# CONFIG_MYRI10GE is not set
574 660
575# 661#
576# Token Ring devices 662# Token Ring devices
@@ -612,6 +698,7 @@ CONFIG_NET_POLL_CONTROLLER=y
612# Input device support 698# Input device support
613# 699#
614CONFIG_INPUT=y 700CONFIG_INPUT=y
701# CONFIG_INPUT_FF_MEMLESS is not set
615 702
616# 703#
617# Userland interfaces 704# Userland interfaces
@@ -646,6 +733,7 @@ CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
646CONFIG_VT=y 733CONFIG_VT=y
647CONFIG_VT_CONSOLE=y 734CONFIG_VT_CONSOLE=y
648CONFIG_HW_CONSOLE=y 735CONFIG_HW_CONSOLE=y
736# CONFIG_VT_HW_CONSOLE_BINDING is not set
649CONFIG_SERIAL_NONSTANDARD=y 737CONFIG_SERIAL_NONSTANDARD=y
650# CONFIG_COMPUTONE is not set 738# CONFIG_COMPUTONE is not set
651# CONFIG_ROCKETPORT is not set 739# CONFIG_ROCKETPORT is not set
@@ -659,10 +747,12 @@ CONFIG_SERIAL_NONSTANDARD=y
659# CONFIG_N_HDLC is not set 747# CONFIG_N_HDLC is not set
660# CONFIG_SPECIALIX is not set 748# CONFIG_SPECIALIX is not set
661# CONFIG_SX is not set 749# CONFIG_SX is not set
750# CONFIG_RIO is not set
662# CONFIG_STALDRV is not set 751# CONFIG_STALDRV is not set
663CONFIG_SGI_SNSC=y 752CONFIG_SGI_SNSC=y
664CONFIG_SGI_TIOCX=y 753CONFIG_SGI_TIOCX=y
665CONFIG_SGI_MBCS=m 754CONFIG_SGI_MBCS=m
755CONFIG_MSPEC=y
666 756
667# 757#
668# Serial drivers 758# Serial drivers
@@ -701,6 +791,7 @@ CONFIG_EFI_RTC=y
701# Ftape, the floppy tape device driver 791# Ftape, the floppy tape device driver
702# 792#
703CONFIG_AGP=y 793CONFIG_AGP=y
794# CONFIG_AGP_SIS is not set
704# CONFIG_AGP_VIA is not set 795# CONFIG_AGP_VIA is not set
705CONFIG_AGP_SGI_TIOCA=y 796CONFIG_AGP_SGI_TIOCA=y
706# CONFIG_DRM is not set 797# CONFIG_DRM is not set
@@ -730,7 +821,6 @@ CONFIG_MMTIMER=y
730# 821#
731# Dallas's 1-wire bus 822# Dallas's 1-wire bus
732# 823#
733# CONFIG_W1 is not set
734 824
735# 825#
736# Hardware Monitoring support 826# Hardware Monitoring support
@@ -741,6 +831,7 @@ CONFIG_MMTIMER=y
741# 831#
742# Misc devices 832# Misc devices
743# 833#
834# CONFIG_TIFM_CORE is not set
744 835
745# 836#
746# Multimedia devices 837# Multimedia devices
@@ -756,6 +847,7 @@ CONFIG_MMTIMER=y
756# 847#
757# Graphics support 848# Graphics support
758# 849#
850CONFIG_FIRMWARE_EDID=y
759# CONFIG_FB is not set 851# CONFIG_FB is not set
760 852
761# 853#
@@ -764,6 +856,7 @@ CONFIG_MMTIMER=y
764CONFIG_VGA_CONSOLE=y 856CONFIG_VGA_CONSOLE=y
765# CONFIG_VGACON_SOFT_SCROLLBACK is not set 857# CONFIG_VGACON_SOFT_SCROLLBACK is not set
766CONFIG_DUMMY_CONSOLE=y 858CONFIG_DUMMY_CONSOLE=y
859# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
767 860
768# 861#
769# Sound 862# Sound
@@ -794,6 +887,7 @@ CONFIG_USB=m
794CONFIG_USB_EHCI_HCD=m 887CONFIG_USB_EHCI_HCD=m
795# CONFIG_USB_EHCI_SPLIT_ISO is not set 888# CONFIG_USB_EHCI_SPLIT_ISO is not set
796# CONFIG_USB_EHCI_ROOT_HUB_TT is not set 889# CONFIG_USB_EHCI_ROOT_HUB_TT is not set
890# CONFIG_USB_EHCI_TT_NEWSCHED is not set
797# CONFIG_USB_ISP116X_HCD is not set 891# CONFIG_USB_ISP116X_HCD is not set
798CONFIG_USB_OHCI_HCD=m 892CONFIG_USB_OHCI_HCD=m
799# CONFIG_USB_OHCI_BIG_ENDIAN is not set 893# CONFIG_USB_OHCI_BIG_ENDIAN is not set
@@ -843,6 +937,7 @@ CONFIG_USB_HIDINPUT=y
843# CONFIG_USB_ATI_REMOTE2 is not set 937# CONFIG_USB_ATI_REMOTE2 is not set
844# CONFIG_USB_KEYSPAN_REMOTE is not set 938# CONFIG_USB_KEYSPAN_REMOTE is not set
845# CONFIG_USB_APPLETOUCH is not set 939# CONFIG_USB_APPLETOUCH is not set
940# CONFIG_USB_TRANCEVIBRATOR is not set
846 941
847# 942#
848# USB Imaging devices 943# USB Imaging devices
@@ -874,15 +969,18 @@ CONFIG_USB_MON=y
874# 969#
875# CONFIG_USB_EMI62 is not set 970# CONFIG_USB_EMI62 is not set
876# CONFIG_USB_EMI26 is not set 971# CONFIG_USB_EMI26 is not set
972# CONFIG_USB_ADUTUX is not set
877# CONFIG_USB_AUERSWALD is not set 973# CONFIG_USB_AUERSWALD is not set
878# CONFIG_USB_RIO500 is not set 974# CONFIG_USB_RIO500 is not set
879# CONFIG_USB_LEGOTOWER is not set 975# CONFIG_USB_LEGOTOWER is not set
880# CONFIG_USB_LCD is not set 976# CONFIG_USB_LCD is not set
881# CONFIG_USB_LED is not set 977# CONFIG_USB_LED is not set
978# CONFIG_USB_CYPRESS_CY7C63 is not set
882# CONFIG_USB_CYTHERM is not set 979# CONFIG_USB_CYTHERM is not set
883# CONFIG_USB_PHIDGETKIT is not set 980# CONFIG_USB_PHIDGET is not set
884# CONFIG_USB_PHIDGETSERVO is not set
885# CONFIG_USB_IDMOUSE is not set 981# CONFIG_USB_IDMOUSE is not set
982# CONFIG_USB_FTDI_ELAN is not set
983# CONFIG_USB_APPLEDISPLAY is not set
886# CONFIG_USB_SISUSBVGA is not set 984# CONFIG_USB_SISUSBVGA is not set
887# CONFIG_USB_LD is not set 985# CONFIG_USB_LD is not set
888 986
@@ -919,18 +1017,15 @@ CONFIG_USB_MON=y
919CONFIG_INFINIBAND=m 1017CONFIG_INFINIBAND=m
920# CONFIG_INFINIBAND_USER_MAD is not set 1018# CONFIG_INFINIBAND_USER_MAD is not set
921CONFIG_INFINIBAND_USER_ACCESS=m 1019CONFIG_INFINIBAND_USER_ACCESS=m
1020CONFIG_INFINIBAND_ADDR_TRANS=y
922CONFIG_INFINIBAND_MTHCA=m 1021CONFIG_INFINIBAND_MTHCA=m
923CONFIG_INFINIBAND_MTHCA_DEBUG=y 1022CONFIG_INFINIBAND_MTHCA_DEBUG=y
1023# CONFIG_INFINIBAND_AMSO1100 is not set
924CONFIG_INFINIBAND_IPOIB=m 1024CONFIG_INFINIBAND_IPOIB=m
925CONFIG_INFINIBAND_IPOIB_DEBUG=y 1025CONFIG_INFINIBAND_IPOIB_DEBUG=y
926# CONFIG_INFINIBAND_IPOIB_DEBUG_DATA is not set 1026# CONFIG_INFINIBAND_IPOIB_DEBUG_DATA is not set
927CONFIG_INFINIBAND_SRP=m 1027CONFIG_INFINIBAND_SRP=m
928 1028# CONFIG_INFINIBAND_ISER is not set
929#
930# SN Devices
931#
932CONFIG_SGI_IOC4=y
933CONFIG_SGI_IOC3=y
934 1029
935# 1030#
936# EDAC - error detection and reporting (RAS) (EXPERIMENTAL) 1031# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
@@ -942,6 +1037,19 @@ CONFIG_SGI_IOC3=y
942# CONFIG_RTC_CLASS is not set 1037# CONFIG_RTC_CLASS is not set
943 1038
944# 1039#
1040# DMA Engine support
1041#
1042# CONFIG_DMA_ENGINE is not set
1043
1044#
1045# DMA Clients
1046#
1047
1048#
1049# DMA Devices
1050#
1051
1052#
945# File systems 1053# File systems
946# 1054#
947CONFIG_EXT2_FS=y 1055CONFIG_EXT2_FS=y
@@ -965,15 +1073,16 @@ CONFIG_REISERFS_FS_SECURITY=y
965# CONFIG_JFS_FS is not set 1073# CONFIG_JFS_FS is not set
966CONFIG_FS_POSIX_ACL=y 1074CONFIG_FS_POSIX_ACL=y
967CONFIG_XFS_FS=y 1075CONFIG_XFS_FS=y
968CONFIG_XFS_EXPORT=y
969CONFIG_XFS_QUOTA=y 1076CONFIG_XFS_QUOTA=y
970# CONFIG_XFS_SECURITY is not set 1077# CONFIG_XFS_SECURITY is not set
971CONFIG_XFS_POSIX_ACL=y 1078CONFIG_XFS_POSIX_ACL=y
972CONFIG_XFS_RT=y 1079CONFIG_XFS_RT=y
1080# CONFIG_GFS2_FS is not set
973# CONFIG_OCFS2_FS is not set 1081# CONFIG_OCFS2_FS is not set
974# CONFIG_MINIX_FS is not set 1082# CONFIG_MINIX_FS is not set
975# CONFIG_ROMFS_FS is not set 1083# CONFIG_ROMFS_FS is not set
976CONFIG_INOTIFY=y 1084CONFIG_INOTIFY=y
1085CONFIG_INOTIFY_USER=y
977CONFIG_QUOTA=y 1086CONFIG_QUOTA=y
978# CONFIG_QFMT_V1 is not set 1087# CONFIG_QFMT_V1 is not set
979# CONFIG_QFMT_V2 is not set 1088# CONFIG_QFMT_V2 is not set
@@ -1007,8 +1116,10 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1007# 1116#
1008CONFIG_PROC_FS=y 1117CONFIG_PROC_FS=y
1009CONFIG_PROC_KCORE=y 1118CONFIG_PROC_KCORE=y
1119CONFIG_PROC_SYSCTL=y
1010CONFIG_SYSFS=y 1120CONFIG_SYSFS=y
1011CONFIG_TMPFS=y 1121CONFIG_TMPFS=y
1122# CONFIG_TMPFS_POSIX_ACL is not set
1012CONFIG_HUGETLBFS=y 1123CONFIG_HUGETLBFS=y
1013CONFIG_HUGETLB_PAGE=y 1124CONFIG_HUGETLB_PAGE=y
1014CONFIG_RAMFS=y 1125CONFIG_RAMFS=y
@@ -1046,7 +1157,7 @@ CONFIG_NFSD_V4=y
1046CONFIG_NFSD_TCP=y 1157CONFIG_NFSD_TCP=y
1047CONFIG_LOCKD=m 1158CONFIG_LOCKD=m
1048CONFIG_LOCKD_V4=y 1159CONFIG_LOCKD_V4=y
1049CONFIG_EXPORTFS=y 1160CONFIG_EXPORTFS=m
1050CONFIG_NFS_COMMON=y 1161CONFIG_NFS_COMMON=y
1051CONFIG_SUNRPC=m 1162CONFIG_SUNRPC=m
1052CONFIG_SUNRPC_GSS=m 1163CONFIG_SUNRPC_GSS=m
@@ -1056,7 +1167,9 @@ CONFIG_SMB_FS=m
1056# CONFIG_SMB_NLS_DEFAULT is not set 1167# CONFIG_SMB_NLS_DEFAULT is not set
1057CONFIG_CIFS=m 1168CONFIG_CIFS=m
1058# CONFIG_CIFS_STATS is not set 1169# CONFIG_CIFS_STATS is not set
1170# CONFIG_CIFS_WEAK_PW_HASH is not set
1059# CONFIG_CIFS_XATTR is not set 1171# CONFIG_CIFS_XATTR is not set
1172# CONFIG_CIFS_DEBUG2 is not set
1060# CONFIG_CIFS_EXPERIMENTAL is not set 1173# CONFIG_CIFS_EXPERIMENTAL is not set
1061# CONFIG_NCP_FS is not set 1174# CONFIG_NCP_FS is not set
1062# CONFIG_CODA_FS is not set 1175# CONFIG_CODA_FS is not set
@@ -1129,6 +1242,10 @@ CONFIG_NLS_ISO8859_1=y
1129CONFIG_NLS_UTF8=y 1242CONFIG_NLS_UTF8=y
1130 1243
1131# 1244#
1245# Distributed Lock Manager
1246#
1247
1248#
1132# Library routines 1249# Library routines
1133# 1250#
1134# CONFIG_CRC_CCITT is not set 1251# CONFIG_CRC_CCITT is not set
@@ -1138,9 +1255,11 @@ CONFIG_LIBCRC32C=m
1138CONFIG_ZLIB_INFLATE=m 1255CONFIG_ZLIB_INFLATE=m
1139CONFIG_ZLIB_DEFLATE=m 1256CONFIG_ZLIB_DEFLATE=m
1140CONFIG_GENERIC_ALLOCATOR=y 1257CONFIG_GENERIC_ALLOCATOR=y
1258CONFIG_PLIST=y
1141CONFIG_GENERIC_HARDIRQS=y 1259CONFIG_GENERIC_HARDIRQS=y
1142CONFIG_GENERIC_IRQ_PROBE=y 1260CONFIG_GENERIC_IRQ_PROBE=y
1143CONFIG_GENERIC_PENDING_IRQ=y 1261CONFIG_GENERIC_PENDING_IRQ=y
1262CONFIG_IRQ_PER_CPU=y
1144 1263
1145# 1264#
1146# Instrumentation Support 1265# Instrumentation Support
@@ -1152,20 +1271,26 @@ CONFIG_GENERIC_PENDING_IRQ=y
1152# Kernel hacking 1271# Kernel hacking
1153# 1272#
1154# CONFIG_PRINTK_TIME is not set 1273# CONFIG_PRINTK_TIME is not set
1274CONFIG_ENABLE_MUST_CHECK=y
1155CONFIG_MAGIC_SYSRQ=y 1275CONFIG_MAGIC_SYSRQ=y
1276# CONFIG_UNUSED_SYMBOLS is not set
1156CONFIG_DEBUG_KERNEL=y 1277CONFIG_DEBUG_KERNEL=y
1157CONFIG_LOG_BUF_SHIFT=20 1278CONFIG_LOG_BUF_SHIFT=20
1158CONFIG_DETECT_SOFTLOCKUP=y 1279CONFIG_DETECT_SOFTLOCKUP=y
1159# CONFIG_SCHEDSTATS is not set 1280# CONFIG_SCHEDSTATS is not set
1160# CONFIG_DEBUG_SLAB is not set 1281# CONFIG_DEBUG_SLAB is not set
1161CONFIG_DEBUG_PREEMPT=y 1282# CONFIG_DEBUG_RT_MUTEXES is not set
1162# CONFIG_DEBUG_MUTEXES is not set 1283# CONFIG_RT_MUTEX_TESTER is not set
1163# CONFIG_DEBUG_SPINLOCK is not set 1284# CONFIG_DEBUG_SPINLOCK is not set
1285# CONFIG_DEBUG_MUTEXES is not set
1286# CONFIG_DEBUG_RWSEMS is not set
1164# CONFIG_DEBUG_SPINLOCK_SLEEP is not set 1287# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1288# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1165# CONFIG_DEBUG_KOBJECT is not set 1289# CONFIG_DEBUG_KOBJECT is not set
1166CONFIG_DEBUG_INFO=y 1290CONFIG_DEBUG_INFO=y
1167# CONFIG_DEBUG_FS is not set 1291# CONFIG_DEBUG_FS is not set
1168# CONFIG_DEBUG_VM is not set 1292# CONFIG_DEBUG_VM is not set
1293# CONFIG_DEBUG_LIST is not set
1169CONFIG_FORCED_INLINING=y 1294CONFIG_FORCED_INLINING=y
1170# CONFIG_RCU_TORTURE_TEST is not set 1295# CONFIG_RCU_TORTURE_TEST is not set
1171CONFIG_IA64_GRANULE_16MB=y 1296CONFIG_IA64_GRANULE_16MB=y
@@ -1186,6 +1311,10 @@ CONFIG_SYSVIPC_COMPAT=y
1186# Cryptographic options 1311# Cryptographic options
1187# 1312#
1188CONFIG_CRYPTO=y 1313CONFIG_CRYPTO=y
1314CONFIG_CRYPTO_ALGAPI=y
1315CONFIG_CRYPTO_BLKCIPHER=m
1316CONFIG_CRYPTO_HASH=y
1317CONFIG_CRYPTO_MANAGER=m
1189CONFIG_CRYPTO_HMAC=y 1318CONFIG_CRYPTO_HMAC=y
1190# CONFIG_CRYPTO_NULL is not set 1319# CONFIG_CRYPTO_NULL is not set
1191# CONFIG_CRYPTO_MD4 is not set 1320# CONFIG_CRYPTO_MD4 is not set
@@ -1195,6 +1324,8 @@ CONFIG_CRYPTO_SHA1=m
1195# CONFIG_CRYPTO_SHA512 is not set 1324# CONFIG_CRYPTO_SHA512 is not set
1196# CONFIG_CRYPTO_WP512 is not set 1325# CONFIG_CRYPTO_WP512 is not set
1197# CONFIG_CRYPTO_TGR192 is not set 1326# CONFIG_CRYPTO_TGR192 is not set
1327CONFIG_CRYPTO_ECB=m
1328CONFIG_CRYPTO_CBC=m
1198CONFIG_CRYPTO_DES=m 1329CONFIG_CRYPTO_DES=m
1199# CONFIG_CRYPTO_BLOWFISH is not set 1330# CONFIG_CRYPTO_BLOWFISH is not set
1200# CONFIG_CRYPTO_TWOFISH is not set 1331# CONFIG_CRYPTO_TWOFISH is not set
diff --git a/arch/ia64/hp/sim/Kconfig b/arch/ia64/hp/sim/Kconfig
index 18ccb1266e18..f92306bbedb8 100644
--- a/arch/ia64/hp/sim/Kconfig
+++ b/arch/ia64/hp/sim/Kconfig
@@ -13,8 +13,8 @@ config HP_SIMSERIAL_CONSOLE
13 depends on HP_SIMSERIAL 13 depends on HP_SIMSERIAL
14 14
15config HP_SIMSCSI 15config HP_SIMSCSI
16 tristate "Simulated SCSI disk" 16 bool "Simulated SCSI disk"
17 depends on SCSI 17 depends on SCSI=y
18 18
19endmenu 19endmenu
20 20
diff --git a/arch/ia64/hp/sim/hpsim_irq.c b/arch/ia64/hp/sim/hpsim_irq.c
index 8145547bb52d..c2f58ff364e7 100644
--- a/arch/ia64/hp/sim/hpsim_irq.c
+++ b/arch/ia64/hp/sim/hpsim_irq.c
@@ -27,7 +27,7 @@ hpsim_set_affinity_noop (unsigned int a, cpumask_t b)
27} 27}
28 28
29static struct hw_interrupt_type irq_type_hp_sim = { 29static struct hw_interrupt_type irq_type_hp_sim = {
30 .typename = "hpsim", 30 .name = "hpsim",
31 .startup = hpsim_irq_startup, 31 .startup = hpsim_irq_startup,
32 .shutdown = hpsim_irq_noop, 32 .shutdown = hpsim_irq_noop,
33 .enable = hpsim_irq_noop, 33 .enable = hpsim_irq_noop,
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
index 32c3abededc6..73ef4a85b861 100644
--- a/arch/ia64/kernel/acpi.c
+++ b/arch/ia64/kernel/acpi.c
@@ -64,9 +64,6 @@ EXPORT_SYMBOL(pm_idle);
64void (*pm_power_off) (void); 64void (*pm_power_off) (void);
65EXPORT_SYMBOL(pm_power_off); 65EXPORT_SYMBOL(pm_power_off);
66 66
67unsigned char acpi_kbd_controller_present = 1;
68unsigned char acpi_legacy_devices;
69
70unsigned int acpi_cpei_override; 67unsigned int acpi_cpei_override;
71unsigned int acpi_cpei_phys_cpuid; 68unsigned int acpi_cpei_phys_cpuid;
72 69
@@ -628,12 +625,6 @@ static int __init acpi_parse_fadt(unsigned long phys_addr, unsigned long size)
628 625
629 fadt = (struct fadt_descriptor *)fadt_header; 626 fadt = (struct fadt_descriptor *)fadt_header;
630 627
631 if (!(fadt->iapc_boot_arch & BAF_8042_KEYBOARD_CONTROLLER))
632 acpi_kbd_controller_present = 0;
633
634 if (fadt->iapc_boot_arch & BAF_LEGACY_DEVICES)
635 acpi_legacy_devices = 1;
636
637 acpi_register_gsi(fadt->sci_int, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW); 628 acpi_register_gsi(fadt->sci_int, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW);
638 return 0; 629 return 0;
639} 630}
diff --git a/arch/ia64/kernel/iosapic.c b/arch/ia64/kernel/iosapic.c
index 9bf15fefa7e4..60d64950e3c2 100644
--- a/arch/ia64/kernel/iosapic.c
+++ b/arch/ia64/kernel/iosapic.c
@@ -426,7 +426,7 @@ iosapic_end_level_irq (unsigned int irq)
426#define iosapic_ack_level_irq nop 426#define iosapic_ack_level_irq nop
427 427
428struct hw_interrupt_type irq_type_iosapic_level = { 428struct hw_interrupt_type irq_type_iosapic_level = {
429 .typename = "IO-SAPIC-level", 429 .name = "IO-SAPIC-level",
430 .startup = iosapic_startup_level_irq, 430 .startup = iosapic_startup_level_irq,
431 .shutdown = iosapic_shutdown_level_irq, 431 .shutdown = iosapic_shutdown_level_irq,
432 .enable = iosapic_enable_level_irq, 432 .enable = iosapic_enable_level_irq,
@@ -473,7 +473,7 @@ iosapic_ack_edge_irq (unsigned int irq)
473#define iosapic_end_edge_irq nop 473#define iosapic_end_edge_irq nop
474 474
475struct hw_interrupt_type irq_type_iosapic_edge = { 475struct hw_interrupt_type irq_type_iosapic_edge = {
476 .typename = "IO-SAPIC-edge", 476 .name = "IO-SAPIC-edge",
477 .startup = iosapic_startup_edge_irq, 477 .startup = iosapic_startup_edge_irq,
478 .shutdown = iosapic_disable_edge_irq, 478 .shutdown = iosapic_disable_edge_irq,
479 .enable = iosapic_enable_edge_irq, 479 .enable = iosapic_enable_edge_irq,
@@ -664,7 +664,7 @@ register_intr (unsigned int gsi, int vector, unsigned char delivery,
664 printk(KERN_WARNING 664 printk(KERN_WARNING
665 "%s: changing vector %d from %s to %s\n", 665 "%s: changing vector %d from %s to %s\n",
666 __FUNCTION__, vector, 666 __FUNCTION__, vector,
667 idesc->chip->typename, irq_type->typename); 667 idesc->chip->name, irq_type->name);
668 idesc->chip = irq_type; 668 idesc->chip = irq_type;
669 } 669 }
670 return 0; 670 return 0;
diff --git a/arch/ia64/kernel/irq.c b/arch/ia64/kernel/irq.c
index f07c0864b0b4..54d55e4d64f7 100644
--- a/arch/ia64/kernel/irq.c
+++ b/arch/ia64/kernel/irq.c
@@ -76,7 +76,7 @@ int show_interrupts(struct seq_file *p, void *v)
76 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]); 76 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
77 } 77 }
78#endif 78#endif
79 seq_printf(p, " %14s", irq_desc[i].chip->typename); 79 seq_printf(p, " %14s", irq_desc[i].chip->name);
80 seq_printf(p, " %s", action->name); 80 seq_printf(p, " %s", action->name);
81 81
82 for (action=action->next; action; action = action->next) 82 for (action=action->next; action; action = action->next)
@@ -197,7 +197,7 @@ void fixup_irqs(void)
197 struct pt_regs *old_regs = set_irq_regs(NULL); 197 struct pt_regs *old_regs = set_irq_regs(NULL);
198 198
199 vectors_in_migration[irq]=0; 199 vectors_in_migration[irq]=0;
200 __do_IRQ(irq); 200 generic_handle_irq(irq);
201 set_irq_regs(old_regs); 201 set_irq_regs(old_regs);
202 } 202 }
203 } 203 }
diff --git a/arch/ia64/kernel/irq_ia64.c b/arch/ia64/kernel/irq_ia64.c
index 68339dd0c9e2..ba3ba8bc50be 100644
--- a/arch/ia64/kernel/irq_ia64.c
+++ b/arch/ia64/kernel/irq_ia64.c
@@ -180,11 +180,13 @@ ia64_handle_irq (ia64_vector vector, struct pt_regs *regs)
180 saved_tpr = ia64_getreg(_IA64_REG_CR_TPR); 180 saved_tpr = ia64_getreg(_IA64_REG_CR_TPR);
181 ia64_srlz_d(); 181 ia64_srlz_d();
182 while (vector != IA64_SPURIOUS_INT_VECTOR) { 182 while (vector != IA64_SPURIOUS_INT_VECTOR) {
183 if (!IS_RESCHEDULE(vector)) { 183 if (unlikely(IS_RESCHEDULE(vector)))
184 kstat_this_cpu.irqs[vector]++;
185 else {
184 ia64_setreg(_IA64_REG_CR_TPR, vector); 186 ia64_setreg(_IA64_REG_CR_TPR, vector);
185 ia64_srlz_d(); 187 ia64_srlz_d();
186 188
187 __do_IRQ(local_vector_to_irq(vector)); 189 generic_handle_irq(local_vector_to_irq(vector));
188 190
189 /* 191 /*
190 * Disable interrupts and send EOI: 192 * Disable interrupts and send EOI:
@@ -225,7 +227,9 @@ void ia64_process_pending_intr(void)
225 * Perform normal interrupt style processing 227 * Perform normal interrupt style processing
226 */ 228 */
227 while (vector != IA64_SPURIOUS_INT_VECTOR) { 229 while (vector != IA64_SPURIOUS_INT_VECTOR) {
228 if (!IS_RESCHEDULE(vector)) { 230 if (unlikely(IS_RESCHEDULE(vector)))
231 kstat_this_cpu.irqs[vector]++;
232 else {
229 struct pt_regs *old_regs = set_irq_regs(NULL); 233 struct pt_regs *old_regs = set_irq_regs(NULL);
230 234
231 ia64_setreg(_IA64_REG_CR_TPR, vector); 235 ia64_setreg(_IA64_REG_CR_TPR, vector);
@@ -238,7 +242,7 @@ void ia64_process_pending_intr(void)
238 * Probably could shared code. 242 * Probably could shared code.
239 */ 243 */
240 vectors_in_migration[local_vector_to_irq(vector)]=0; 244 vectors_in_migration[local_vector_to_irq(vector)]=0;
241 __do_IRQ(local_vector_to_irq(vector)); 245 generic_handle_irq(local_vector_to_irq(vector));
242 set_irq_regs(old_regs); 246 set_irq_regs(old_regs);
243 247
244 /* 248 /*
@@ -258,11 +262,22 @@ void ia64_process_pending_intr(void)
258#ifdef CONFIG_SMP 262#ifdef CONFIG_SMP
259extern irqreturn_t handle_IPI (int irq, void *dev_id); 263extern irqreturn_t handle_IPI (int irq, void *dev_id);
260 264
265static irqreturn_t dummy_handler (int irq, void *dev_id)
266{
267 BUG();
268}
269
261static struct irqaction ipi_irqaction = { 270static struct irqaction ipi_irqaction = {
262 .handler = handle_IPI, 271 .handler = handle_IPI,
263 .flags = IRQF_DISABLED, 272 .flags = IRQF_DISABLED,
264 .name = "IPI" 273 .name = "IPI"
265}; 274};
275
276static struct irqaction resched_irqaction = {
277 .handler = dummy_handler,
278 .flags = SA_INTERRUPT,
279 .name = "resched"
280};
266#endif 281#endif
267 282
268void 283void
@@ -287,6 +302,7 @@ init_IRQ (void)
287 register_percpu_irq(IA64_SPURIOUS_INT_VECTOR, NULL); 302 register_percpu_irq(IA64_SPURIOUS_INT_VECTOR, NULL);
288#ifdef CONFIG_SMP 303#ifdef CONFIG_SMP
289 register_percpu_irq(IA64_IPI_VECTOR, &ipi_irqaction); 304 register_percpu_irq(IA64_IPI_VECTOR, &ipi_irqaction);
305 register_percpu_irq(IA64_IPI_RESCHEDULE, &resched_irqaction);
290#endif 306#endif
291#ifdef CONFIG_PERFMON 307#ifdef CONFIG_PERFMON
292 pfm_init_percpu(); 308 pfm_init_percpu();
diff --git a/arch/ia64/kernel/irq_lsapic.c b/arch/ia64/kernel/irq_lsapic.c
index 1ab58b09f3d7..c2f07beb1759 100644
--- a/arch/ia64/kernel/irq_lsapic.c
+++ b/arch/ia64/kernel/irq_lsapic.c
@@ -34,7 +34,7 @@ static int lsapic_retrigger(unsigned int irq)
34} 34}
35 35
36struct hw_interrupt_type irq_type_ia64_lsapic = { 36struct hw_interrupt_type irq_type_ia64_lsapic = {
37 .typename = "LSAPIC", 37 .name = "LSAPIC",
38 .startup = lsapic_noop_startup, 38 .startup = lsapic_noop_startup,
39 .shutdown = lsapic_noop, 39 .shutdown = lsapic_noop,
40 .enable = lsapic_noop, 40 .enable = lsapic_noop,
diff --git a/arch/ia64/kernel/mca_drv.c b/arch/ia64/kernel/mca_drv.c
index a45009d2bc90..afc1403799c9 100644
--- a/arch/ia64/kernel/mca_drv.c
+++ b/arch/ia64/kernel/mca_drv.c
@@ -435,6 +435,50 @@ is_mca_global(peidx_table_t *peidx, pal_bus_check_info_t *pbci,
435} 435}
436 436
437/** 437/**
438 * get_target_identifier - Get the valid Cache or Bus check target identifier.
439 * @peidx: pointer of index of processor error section
440 *
441 * Return value:
442 * target address on Success / 0 on Failue
443 */
444static u64
445get_target_identifier(peidx_table_t *peidx)
446{
447 u64 target_address = 0;
448 sal_log_mod_error_info_t *smei;
449 pal_cache_check_info_t *pcci;
450 int i, level = 9;
451
452 /*
453 * Look through the cache checks for a valid target identifier
454 * If more than one valid target identifier, return the one
455 * with the lowest cache level.
456 */
457 for (i = 0; i < peidx_cache_check_num(peidx); i++) {
458 smei = (sal_log_mod_error_info_t *)peidx_cache_check(peidx, i);
459 if (smei->valid.target_identifier && smei->target_identifier) {
460 pcci = (pal_cache_check_info_t *)&(smei->check_info);
461 if (!target_address || (pcci->level < level)) {
462 target_address = smei->target_identifier;
463 level = pcci->level;
464 continue;
465 }
466 }
467 }
468 if (target_address)
469 return target_address;
470
471 /*
472 * Look at the bus check for a valid target identifier
473 */
474 smei = peidx_bus_check(peidx, 0);
475 if (smei && smei->valid.target_identifier)
476 return smei->target_identifier;
477
478 return 0;
479}
480
481/**
438 * recover_from_read_error - Try to recover the errors which type are "read"s. 482 * recover_from_read_error - Try to recover the errors which type are "read"s.
439 * @slidx: pointer of index of SAL error record 483 * @slidx: pointer of index of SAL error record
440 * @peidx: pointer of index of processor error section 484 * @peidx: pointer of index of processor error section
@@ -450,13 +494,14 @@ recover_from_read_error(slidx_table_t *slidx,
450 peidx_table_t *peidx, pal_bus_check_info_t *pbci, 494 peidx_table_t *peidx, pal_bus_check_info_t *pbci,
451 struct ia64_sal_os_state *sos) 495 struct ia64_sal_os_state *sos)
452{ 496{
453 sal_log_mod_error_info_t *smei; 497 u64 target_identifier;
454 pal_min_state_area_t *pmsa; 498 pal_min_state_area_t *pmsa;
455 struct ia64_psr *psr1, *psr2; 499 struct ia64_psr *psr1, *psr2;
456 ia64_fptr_t *mca_hdlr_bh = (ia64_fptr_t*)mca_handler_bhhook; 500 ia64_fptr_t *mca_hdlr_bh = (ia64_fptr_t*)mca_handler_bhhook;
457 501
458 /* Is target address valid? */ 502 /* Is target address valid? */
459 if (!pbci->tv) 503 target_identifier = get_target_identifier(peidx);
504 if (!target_identifier)
460 return fatal_mca("target address not valid"); 505 return fatal_mca("target address not valid");
461 506
462 /* 507 /*
@@ -487,32 +532,28 @@ recover_from_read_error(slidx_table_t *slidx,
487 pmsa = sos->pal_min_state; 532 pmsa = sos->pal_min_state;
488 if (psr1->cpl != 0 || 533 if (psr1->cpl != 0 ||
489 ((psr2->cpl != 0) && mca_recover_range(pmsa->pmsa_iip))) { 534 ((psr2->cpl != 0) && mca_recover_range(pmsa->pmsa_iip))) {
490 smei = peidx_bus_check(peidx, 0); 535 /*
491 if (smei->valid.target_identifier) { 536 * setup for resume to bottom half of MCA,
492 /* 537 * "mca_handler_bhhook"
493 * setup for resume to bottom half of MCA, 538 */
494 * "mca_handler_bhhook" 539 /* pass to bhhook as argument (gr8, ...) */
495 */ 540 pmsa->pmsa_gr[8-1] = target_identifier;
496 /* pass to bhhook as argument (gr8, ...) */ 541 pmsa->pmsa_gr[9-1] = pmsa->pmsa_iip;
497 pmsa->pmsa_gr[8-1] = smei->target_identifier; 542 pmsa->pmsa_gr[10-1] = pmsa->pmsa_ipsr;
498 pmsa->pmsa_gr[9-1] = pmsa->pmsa_iip; 543 /* set interrupted return address (but no use) */
499 pmsa->pmsa_gr[10-1] = pmsa->pmsa_ipsr; 544 pmsa->pmsa_br0 = pmsa->pmsa_iip;
500 /* set interrupted return address (but no use) */ 545 /* change resume address to bottom half */
501 pmsa->pmsa_br0 = pmsa->pmsa_iip; 546 pmsa->pmsa_iip = mca_hdlr_bh->fp;
502 /* change resume address to bottom half */ 547 pmsa->pmsa_gr[1-1] = mca_hdlr_bh->gp;
503 pmsa->pmsa_iip = mca_hdlr_bh->fp; 548 /* set cpl with kernel mode */
504 pmsa->pmsa_gr[1-1] = mca_hdlr_bh->gp; 549 psr2 = (struct ia64_psr *)&pmsa->pmsa_ipsr;
505 /* set cpl with kernel mode */ 550 psr2->cpl = 0;
506 psr2 = (struct ia64_psr *)&pmsa->pmsa_ipsr; 551 psr2->ri = 0;
507 psr2->cpl = 0; 552 psr2->bn = 1;
508 psr2->ri = 0; 553 psr2->i = 0;
509 psr2->bn = 1; 554
510 psr2->i = 0; 555 return mca_recovered("user memory corruption. "
511
512 return mca_recovered("user memory corruption. "
513 "kill affected process - recovered."); 556 "kill affected process - recovered.");
514 }
515
516 } 557 }
517 558
518 return fatal_mca("kernel context not recovered, iip 0x%lx\n", 559 return fatal_mca("kernel context not recovered, iip 0x%lx\n",
diff --git a/arch/ia64/kernel/pal.S b/arch/ia64/kernel/pal.S
index ebaf1e685f5e..0b533441c3c9 100644
--- a/arch/ia64/kernel/pal.S
+++ b/arch/ia64/kernel/pal.S
@@ -21,11 +21,12 @@ pal_entry_point:
21 .text 21 .text
22 22
23/* 23/*
24 * Set the PAL entry point address. This could be written in C code, but we do it here 24 * Set the PAL entry point address. This could be written in C code, but we
25 * to keep it all in one module (besides, it's so trivial that it's 25 * do it here to keep it all in one module (besides, it's so trivial that it's
26 * not a big deal). 26 * not a big deal).
27 * 27 *
28 * in0 Address of the PAL entry point (text address, NOT a function descriptor). 28 * in0 Address of the PAL entry point (text address, NOT a function
29 * descriptor).
29 */ 30 */
30GLOBAL_ENTRY(ia64_pal_handler_init) 31GLOBAL_ENTRY(ia64_pal_handler_init)
31 alloc r3=ar.pfs,1,0,0,0 32 alloc r3=ar.pfs,1,0,0,0
@@ -36,9 +37,9 @@ GLOBAL_ENTRY(ia64_pal_handler_init)
36END(ia64_pal_handler_init) 37END(ia64_pal_handler_init)
37 38
38/* 39/*
39 * Default PAL call handler. This needs to be coded in assembly because it uses 40 * Default PAL call handler. This needs to be coded in assembly because it
40 * the static calling convention, i.e., the RSE may not be used and calls are 41 * uses the static calling convention, i.e., the RSE may not be used and
41 * done via "br.cond" (not "br.call"). 42 * calls are done via "br.cond" (not "br.call").
42 */ 43 */
43GLOBAL_ENTRY(ia64_pal_default_handler) 44GLOBAL_ENTRY(ia64_pal_default_handler)
44 mov r8=-1 45 mov r8=-1
@@ -50,12 +51,10 @@ END(ia64_pal_default_handler)
50 * 51 *
51 * in0 Index of PAL service 52 * in0 Index of PAL service
52 * in1 - in3 Remaining PAL arguments 53 * in1 - in3 Remaining PAL arguments
53 * in4 1 ==> clear psr.ic, 0 ==> don't clear psr.ic
54 *
55 */ 54 */
56GLOBAL_ENTRY(ia64_pal_call_static) 55GLOBAL_ENTRY(ia64_pal_call_static)
57 .prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(5) 56 .prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(4)
58 alloc loc1 = ar.pfs,5,5,0,0 57 alloc loc1 = ar.pfs,4,5,0,0
59 movl loc2 = pal_entry_point 58 movl loc2 = pal_entry_point
601: { 591: {
61 mov r28 = in0 60 mov r28 = in0
@@ -64,7 +63,6 @@ GLOBAL_ENTRY(ia64_pal_call_static)
64 } 63 }
65 ;; 64 ;;
66 ld8 loc2 = [loc2] // loc2 <- entry point 65 ld8 loc2 = [loc2] // loc2 <- entry point
67 tbit.nz p6,p7 = in4, 0
68 adds r8 = 1f-1b,r8 66 adds r8 = 1f-1b,r8
69 mov loc4=ar.rsc // save RSE configuration 67 mov loc4=ar.rsc // save RSE configuration
70 ;; 68 ;;
@@ -74,13 +72,11 @@ GLOBAL_ENTRY(ia64_pal_call_static)
74 .body 72 .body
75 mov r30 = in2 73 mov r30 = in2
76 74
77(p6) rsm psr.i | psr.ic
78 mov r31 = in3 75 mov r31 = in3
79 mov b7 = loc2 76 mov b7 = loc2
80 77
81(p7) rsm psr.i 78 rsm psr.i
82 ;; 79 ;;
83(p6) srlz.i
84 mov rp = r8 80 mov rp = r8
85 br.cond.sptk.many b7 81 br.cond.sptk.many b7
861: mov psr.l = loc3 821: mov psr.l = loc3
@@ -96,8 +92,8 @@ END(ia64_pal_call_static)
96 * Make a PAL call using the stacked registers calling convention. 92 * Make a PAL call using the stacked registers calling convention.
97 * 93 *
98 * Inputs: 94 * Inputs:
99 * in0 Index of PAL service 95 * in0 Index of PAL service
100 * in2 - in3 Remaning PAL arguments 96 * in2 - in3 Remaining PAL arguments
101 */ 97 */
102GLOBAL_ENTRY(ia64_pal_call_stacked) 98GLOBAL_ENTRY(ia64_pal_call_stacked)
103 .prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(4) 99 .prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(4)
@@ -131,18 +127,18 @@ END(ia64_pal_call_stacked)
131 * Make a physical mode PAL call using the static registers calling convention. 127 * Make a physical mode PAL call using the static registers calling convention.
132 * 128 *
133 * Inputs: 129 * Inputs:
134 * in0 Index of PAL service 130 * in0 Index of PAL service
135 * in2 - in3 Remaning PAL arguments 131 * in2 - in3 Remaining PAL arguments
136 * 132 *
137 * PSR_LP, PSR_TB, PSR_ID, PSR_DA are never set by the kernel. 133 * PSR_LP, PSR_TB, PSR_ID, PSR_DA are never set by the kernel.
138 * So we don't need to clear them. 134 * So we don't need to clear them.
139 */ 135 */
140#define PAL_PSR_BITS_TO_CLEAR \ 136#define PAL_PSR_BITS_TO_CLEAR \
141 (IA64_PSR_I | IA64_PSR_IT | IA64_PSR_DT | IA64_PSR_DB | IA64_PSR_RT | \ 137 (IA64_PSR_I | IA64_PSR_IT | IA64_PSR_DT | IA64_PSR_DB | IA64_PSR_RT |\
142 IA64_PSR_DD | IA64_PSR_SS | IA64_PSR_RI | IA64_PSR_ED | \ 138 IA64_PSR_DD | IA64_PSR_SS | IA64_PSR_RI | IA64_PSR_ED | \
143 IA64_PSR_DFL | IA64_PSR_DFH) 139 IA64_PSR_DFL | IA64_PSR_DFH)
144 140
145#define PAL_PSR_BITS_TO_SET \ 141#define PAL_PSR_BITS_TO_SET \
146 (IA64_PSR_BN) 142 (IA64_PSR_BN)
147 143
148 144
@@ -178,7 +174,7 @@ GLOBAL_ENTRY(ia64_pal_call_phys_static)
178 ;; 174 ;;
179 andcm r16=loc3,r16 // removes bits to clear from psr 175 andcm r16=loc3,r16 // removes bits to clear from psr
180 br.call.sptk.many rp=ia64_switch_mode_phys 176 br.call.sptk.many rp=ia64_switch_mode_phys
181.ret1: mov rp = r8 // install return address (physical) 177 mov rp = r8 // install return address (physical)
182 mov loc5 = r19 178 mov loc5 = r19
183 mov loc6 = r20 179 mov loc6 = r20
184 br.cond.sptk.many b7 180 br.cond.sptk.many b7
@@ -188,7 +184,6 @@ GLOBAL_ENTRY(ia64_pal_call_phys_static)
188 mov r19=loc5 184 mov r19=loc5
189 mov r20=loc6 185 mov r20=loc6
190 br.call.sptk.many rp=ia64_switch_mode_virt // return to virtual mode 186 br.call.sptk.many rp=ia64_switch_mode_virt // return to virtual mode
191.ret2:
192 mov psr.l = loc3 // restore init PSR 187 mov psr.l = loc3 // restore init PSR
193 188
194 mov ar.pfs = loc1 189 mov ar.pfs = loc1
@@ -203,8 +198,8 @@ END(ia64_pal_call_phys_static)
203 * Make a PAL call using the stacked registers in physical mode. 198 * Make a PAL call using the stacked registers in physical mode.
204 * 199 *
205 * Inputs: 200 * Inputs:
206 * in0 Index of PAL service 201 * in0 Index of PAL service
207 * in2 - in3 Remaning PAL arguments 202 * in2 - in3 Remaining PAL arguments
208 */ 203 */
209GLOBAL_ENTRY(ia64_pal_call_phys_stacked) 204GLOBAL_ENTRY(ia64_pal_call_phys_stacked)
210 .prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(5) 205 .prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(5)
@@ -212,7 +207,7 @@ GLOBAL_ENTRY(ia64_pal_call_phys_stacked)
212 movl loc2 = pal_entry_point 207 movl loc2 = pal_entry_point
2131: { 2081: {
214 mov r28 = in0 // copy procedure index 209 mov r28 = in0 // copy procedure index
215 mov loc0 = rp // save rp 210 mov loc0 = rp // save rp
216 } 211 }
217 .body 212 .body
218 ;; 213 ;;
@@ -245,7 +240,7 @@ GLOBAL_ENTRY(ia64_pal_call_phys_stacked)
245 mov r16=loc3 // r16= original psr 240 mov r16=loc3 // r16= original psr
246 mov r19=loc5 241 mov r19=loc5
247 mov r20=loc6 242 mov r20=loc6
248 br.call.sptk.many rp=ia64_switch_mode_virt // return to virtual mode 243 br.call.sptk.many rp=ia64_switch_mode_virt // return to virtual mode
249 244
250 mov psr.l = loc3 // restore init PSR 245 mov psr.l = loc3 // restore init PSR
251 mov ar.pfs = loc1 246 mov ar.pfs = loc1
@@ -257,10 +252,11 @@ GLOBAL_ENTRY(ia64_pal_call_phys_stacked)
257END(ia64_pal_call_phys_stacked) 252END(ia64_pal_call_phys_stacked)
258 253
259/* 254/*
260 * Save scratch fp scratch regs which aren't saved in pt_regs already (fp10-fp15). 255 * Save scratch fp scratch regs which aren't saved in pt_regs already
256 * (fp10-fp15).
261 * 257 *
262 * NOTE: We need to do this since firmware (SAL and PAL) may use any of the scratch 258 * NOTE: We need to do this since firmware (SAL and PAL) may use any of the
263 * regs fp-low partition. 259 * scratch regs fp-low partition.
264 * 260 *
265 * Inputs: 261 * Inputs:
266 * in0 Address of stack storage for fp regs 262 * in0 Address of stack storage for fp regs
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index 281004ff7b00..3aaede0d6981 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -5558,12 +5558,13 @@ report_spurious2:
5558} 5558}
5559 5559
5560static irqreturn_t 5560static irqreturn_t
5561pfm_interrupt_handler(int irq, void *arg, struct pt_regs *regs) 5561pfm_interrupt_handler(int irq, void *arg)
5562{ 5562{
5563 unsigned long start_cycles, total_cycles; 5563 unsigned long start_cycles, total_cycles;
5564 unsigned long min, max; 5564 unsigned long min, max;
5565 int this_cpu; 5565 int this_cpu;
5566 int ret; 5566 int ret;
5567 struct pt_regs *regs = get_irq_regs();
5567 5568
5568 this_cpu = get_cpu(); 5569 this_cpu = get_cpu();
5569 if (likely(!pfm_alt_intr_handler)) { 5570 if (likely(!pfm_alt_intr_handler)) {
diff --git a/arch/ia64/kernel/sal.c b/arch/ia64/kernel/sal.c
index 642fdc7b969d..20bad78b5073 100644
--- a/arch/ia64/kernel/sal.c
+++ b/arch/ia64/kernel/sal.c
@@ -223,12 +223,13 @@ static void __init sal_desc_ap_wakeup(void *p) { }
223 */ 223 */
224static int sal_cache_flush_drops_interrupts; 224static int sal_cache_flush_drops_interrupts;
225 225
226static void __init 226void __init
227check_sal_cache_flush (void) 227check_sal_cache_flush (void)
228{ 228{
229 unsigned long flags; 229 unsigned long flags;
230 int cpu; 230 int cpu;
231 u64 vector; 231 u64 vector, cache_type = 3;
232 struct ia64_sal_retval isrv;
232 233
233 cpu = get_cpu(); 234 cpu = get_cpu();
234 local_irq_save(flags); 235 local_irq_save(flags);
@@ -243,7 +244,10 @@ check_sal_cache_flush (void)
243 while (!ia64_get_irr(IA64_TIMER_VECTOR)) 244 while (!ia64_get_irr(IA64_TIMER_VECTOR))
244 cpu_relax(); 245 cpu_relax();
245 246
246 ia64_sal_cache_flush(3); 247 SAL_CALL(isrv, SAL_CACHE_FLUSH, cache_type, 0, 0, 0, 0, 0, 0);
248
249 if (isrv.status)
250 printk(KERN_ERR "SAL_CAL_FLUSH failed with %ld\n", isrv.status);
247 251
248 if (ia64_get_irr(IA64_TIMER_VECTOR)) { 252 if (ia64_get_irr(IA64_TIMER_VECTOR)) {
249 vector = ia64_get_ivr(); 253 vector = ia64_get_ivr();
@@ -331,7 +335,6 @@ ia64_sal_init (struct ia64_sal_systab *systab)
331 p += SAL_DESC_SIZE(*p); 335 p += SAL_DESC_SIZE(*p);
332 } 336 }
333 337
334 check_sal_cache_flush();
335} 338}
336 339
337int 340int
diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c
index c4caa8003492..d10404a41756 100644
--- a/arch/ia64/kernel/setup.c
+++ b/arch/ia64/kernel/setup.c
@@ -457,6 +457,8 @@ setup_arch (char **cmdline_p)
457 cpu_init(); /* initialize the bootstrap CPU */ 457 cpu_init(); /* initialize the bootstrap CPU */
458 mmu_context_init(); /* initialize context_id bitmap */ 458 mmu_context_init(); /* initialize context_id bitmap */
459 459
460 check_sal_cache_flush();
461
460#ifdef CONFIG_ACPI 462#ifdef CONFIG_ACPI
461 acpi_boot_init(); 463 acpi_boot_init();
462#endif 464#endif
diff --git a/arch/ia64/kernel/smp.c b/arch/ia64/kernel/smp.c
index 657ac99a451c..6ab95ceaf9d4 100644
--- a/arch/ia64/kernel/smp.c
+++ b/arch/ia64/kernel/smp.c
@@ -108,7 +108,7 @@ cpu_die(void)
108} 108}
109 109
110irqreturn_t 110irqreturn_t
111handle_IPI (int irq, void *dev_id, struct pt_regs *regs) 111handle_IPI (int irq, void *dev_id)
112{ 112{
113 int this_cpu = get_cpu(); 113 int this_cpu = get_cpu();
114 unsigned long *pending_ipis = &__ia64_per_cpu_var(ipi_operation); 114 unsigned long *pending_ipis = &__ia64_per_cpu_var(ipi_operation);
@@ -328,10 +328,14 @@ int
328smp_call_function (void (*func) (void *info), void *info, int nonatomic, int wait) 328smp_call_function (void (*func) (void *info), void *info, int nonatomic, int wait)
329{ 329{
330 struct call_data_struct data; 330 struct call_data_struct data;
331 int cpus = num_online_cpus()-1; 331 int cpus;
332 332
333 if (!cpus) 333 spin_lock(&call_lock);
334 cpus = num_online_cpus() - 1;
335 if (!cpus) {
336 spin_unlock(&call_lock);
334 return 0; 337 return 0;
338 }
335 339
336 /* Can deadlock when called with interrupts disabled */ 340 /* Can deadlock when called with interrupts disabled */
337 WARN_ON(irqs_disabled()); 341 WARN_ON(irqs_disabled());
@@ -343,8 +347,6 @@ smp_call_function (void (*func) (void *info), void *info, int nonatomic, int wai
343 if (wait) 347 if (wait)
344 atomic_set(&data.finished, 0); 348 atomic_set(&data.finished, 0);
345 349
346 spin_lock(&call_lock);
347
348 call_data = &data; 350 call_data = &data;
349 mb(); /* ensure store to call_data precedes setting of IPI_CALL_FUNC */ 351 mb(); /* ensure store to call_data precedes setting of IPI_CALL_FUNC */
350 send_IPI_allbutself(IPI_CALL_FUNC); 352 send_IPI_allbutself(IPI_CALL_FUNC);
diff --git a/arch/ia64/kernel/time.c b/arch/ia64/kernel/time.c
index 41169a9bc301..39e0cd3a0884 100644
--- a/arch/ia64/kernel/time.c
+++ b/arch/ia64/kernel/time.c
@@ -84,6 +84,12 @@ timer_interrupt (int irq, void *dev_id)
84 84
85 if (time_after(new_itm, ia64_get_itc())) 85 if (time_after(new_itm, ia64_get_itc()))
86 break; 86 break;
87
88 /*
89 * Allow IPIs to interrupt the timer loop.
90 */
91 local_irq_enable();
92 local_irq_disable();
87 } 93 }
88 94
89 do { 95 do {
diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
index b3b2e389d6b2..d6083a0936f4 100644
--- a/arch/ia64/kernel/vmlinux.lds.S
+++ b/arch/ia64/kernel/vmlinux.lds.S
@@ -128,13 +128,7 @@ SECTIONS
128 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) 128 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET)
129 { 129 {
130 __initcall_start = .; 130 __initcall_start = .;
131 *(.initcall1.init) 131 INITCALLS
132 *(.initcall2.init)
133 *(.initcall3.init)
134 *(.initcall4.init)
135 *(.initcall5.init)
136 *(.initcall6.init)
137 *(.initcall7.init)
138 __initcall_end = .; 132 __initcall_end = .;
139 } 133 }
140 134
diff --git a/arch/ia64/mm/contig.c b/arch/ia64/mm/contig.c
index daf977ff2920..82deaa3a7c48 100644
--- a/arch/ia64/mm/contig.c
+++ b/arch/ia64/mm/contig.c
@@ -233,6 +233,7 @@ paging_init (void)
233 efi_memmap_walk(count_pages, &num_physpages); 233 efi_memmap_walk(count_pages, &num_physpages);
234 234
235 max_dma = virt_to_phys((void *) MAX_DMA_ADDRESS) >> PAGE_SHIFT; 235 max_dma = virt_to_phys((void *) MAX_DMA_ADDRESS) >> PAGE_SHIFT;
236 memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
236 max_zone_pfns[ZONE_DMA] = max_dma; 237 max_zone_pfns[ZONE_DMA] = max_dma;
237 max_zone_pfns[ZONE_NORMAL] = max_low_pfn; 238 max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
238 239
diff --git a/arch/ia64/mm/discontig.c b/arch/ia64/mm/discontig.c
index d497b6b0f5b2..96722cb1b49d 100644
--- a/arch/ia64/mm/discontig.c
+++ b/arch/ia64/mm/discontig.c
@@ -709,6 +709,7 @@ void __init paging_init(void)
709 max_pfn = mem_data[node].max_pfn; 709 max_pfn = mem_data[node].max_pfn;
710 } 710 }
711 711
712 memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
712 max_zone_pfns[ZONE_DMA] = max_dma; 713 max_zone_pfns[ZONE_DMA] = max_dma;
713 max_zone_pfns[ZONE_NORMAL] = max_pfn; 714 max_zone_pfns[ZONE_NORMAL] = max_pfn;
714 free_area_init_nodes(max_zone_pfns); 715 free_area_init_nodes(max_zone_pfns);
diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
index eee5c1cfbe32..f3a9585e98a8 100644
--- a/arch/ia64/mm/hugetlbpage.c
+++ b/arch/ia64/mm/hugetlbpage.c
@@ -70,8 +70,10 @@ huge_pte_offset (struct mm_struct *mm, unsigned long addr)
70 * Don't actually need to do any preparation, but need to make sure 70 * Don't actually need to do any preparation, but need to make sure
71 * the address is in the right region. 71 * the address is in the right region.
72 */ 72 */
73int prepare_hugepage_range(unsigned long addr, unsigned long len) 73int prepare_hugepage_range(unsigned long addr, unsigned long len, pgoff_t pgoff)
74{ 74{
75 if (pgoff & (~HPAGE_MASK >> PAGE_SHIFT))
76 return -EINVAL;
75 if (len & ~HPAGE_MASK) 77 if (len & ~HPAGE_MASK)
76 return -EINVAL; 78 return -EINVAL;
77 if (addr & ~HPAGE_MASK) 79 if (addr & ~HPAGE_MASK)
diff --git a/arch/ia64/pci/Makefile b/arch/ia64/pci/Makefile
index e66889e6922a..fb14dc520d2d 100644
--- a/arch/ia64/pci/Makefile
+++ b/arch/ia64/pci/Makefile
@@ -1,4 +1,4 @@
1# 1#
2# Makefile for the ia64-specific parts of the pci bus 2# Makefile for the ia64-specific parts of the pci bus
3# 3#
4obj-y := pci.o 4obj-y := pci.o fixup.o
diff --git a/arch/ia64/pci/fixup.c b/arch/ia64/pci/fixup.c
new file mode 100644
index 000000000000..245dc1fedc24
--- /dev/null
+++ b/arch/ia64/pci/fixup.c
@@ -0,0 +1,69 @@
1/*
2 * Exceptions for specific devices. Usually work-arounds for fatal design flaws.
3 * Derived from fixup.c of i386 tree.
4 */
5
6#include <linux/pci.h>
7#include <linux/init.h>
8
9#include <asm/machvec.h>
10
11/*
12 * Fixup to mark boot BIOS video selected by BIOS before it changes
13 *
14 * From information provided by "Jon Smirl" <jonsmirl@gmail.com>
15 *
16 * The standard boot ROM sequence for an x86 machine uses the BIOS
17 * to select an initial video card for boot display. This boot video
18 * card will have it's BIOS copied to C0000 in system RAM.
19 * IORESOURCE_ROM_SHADOW is used to associate the boot video
20 * card with this copy. On laptops this copy has to be used since
21 * the main ROM may be compressed or combined with another image.
22 * See pci_map_rom() for use of this flag. IORESOURCE_ROM_SHADOW
23 * is marked here since the boot video device will be the only enabled
24 * video device at this point.
25 */
26
27static void __devinit pci_fixup_video(struct pci_dev *pdev)
28{
29 struct pci_dev *bridge;
30 struct pci_bus *bus;
31 u16 config;
32
33 if ((strcmp(platform_name, "dig") != 0)
34 && (strcmp(platform_name, "hpzx1") != 0))
35 return;
36 /* Maybe, this machine supports legacy memory map. */
37
38 if ((pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA)
39 return;
40
41 /* Is VGA routed to us? */
42 bus = pdev->bus;
43 while (bus) {
44 bridge = bus->self;
45
46 /*
47 * From information provided by
48 * "David Miller" <davem@davemloft.net>
49 * The bridge control register is valid for PCI header
50 * type BRIDGE, or CARDBUS. Host to PCI controllers use
51 * PCI header type NORMAL.
52 */
53 if (bridge
54 &&((bridge->hdr_type == PCI_HEADER_TYPE_BRIDGE)
55 ||(bridge->hdr_type == PCI_HEADER_TYPE_CARDBUS))) {
56 pci_read_config_word(bridge, PCI_BRIDGE_CONTROL,
57 &config);
58 if (!(config & PCI_BRIDGE_CTL_VGA))
59 return;
60 }
61 bus = bus->parent;
62 }
63 pci_read_config_word(pdev, PCI_COMMAND, &config);
64 if (config & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) {
65 pdev->resource[PCI_ROM_RESOURCE].flags |= IORESOURCE_ROM_SHADOW;
66 printk(KERN_DEBUG "Boot video device is %s\n", pci_name(pdev));
67 }
68}
69DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pci_fixup_video);
diff --git a/arch/ia64/sn/kernel/bte.c b/arch/ia64/sn/kernel/bte.c
index 7f73ad4408aa..ff1c55601178 100644
--- a/arch/ia64/sn/kernel/bte.c
+++ b/arch/ia64/sn/kernel/bte.c
@@ -381,14 +381,13 @@ bte_result_t bte_unaligned_copy(u64 src, u64 dest, u64 len, u64 mode)
381 * bcopy to the destination. 381 * bcopy to the destination.
382 */ 382 */
383 383
384 /* Add the leader from source */
385 headBteLen = len + (src & L1_CACHE_MASK);
386 /* Add the trailing bytes from footer. */
387 headBteLen += L1_CACHE_BYTES - (headBteLen & L1_CACHE_MASK);
388 headBteSource = src & ~L1_CACHE_MASK;
389 headBcopySrcOffset = src & L1_CACHE_MASK; 384 headBcopySrcOffset = src & L1_CACHE_MASK;
390 headBcopyDest = dest; 385 headBcopyDest = dest;
391 headBcopyLen = len; 386 headBcopyLen = len;
387
388 headBteSource = src - headBcopySrcOffset;
389 /* Add the leading and trailing bytes from source */
390 headBteLen = L1_CACHE_ALIGN(len + headBcopySrcOffset);
392 } 391 }
393 392
394 if (headBcopyLen > 0) { 393 if (headBcopyLen > 0) {
diff --git a/arch/ia64/sn/kernel/irq.c b/arch/ia64/sn/kernel/irq.c
index 7bb6ad188ba3..0b49459a878a 100644
--- a/arch/ia64/sn/kernel/irq.c
+++ b/arch/ia64/sn/kernel/irq.c
@@ -201,7 +201,7 @@ static void sn_set_affinity_irq(unsigned int irq, cpumask_t mask)
201} 201}
202 202
203struct hw_interrupt_type irq_type_sn = { 203struct hw_interrupt_type irq_type_sn = {
204 .typename = "SN hub", 204 .name = "SN hub",
205 .startup = sn_startup_irq, 205 .startup = sn_startup_irq,
206 .shutdown = sn_shutdown_irq, 206 .shutdown = sn_shutdown_irq,
207 .enable = sn_enable_irq, 207 .enable = sn_enable_irq,
diff --git a/arch/ia64/sn/kernel/setup.c b/arch/ia64/sn/kernel/setup.c
index 5f2dcba7fa8d..7a2d824c5ce3 100644
--- a/arch/ia64/sn/kernel/setup.c
+++ b/arch/ia64/sn/kernel/setup.c
@@ -65,7 +65,6 @@ extern void sn_timer_init(void);
65extern unsigned long last_time_offset; 65extern unsigned long last_time_offset;
66extern void (*ia64_mark_idle) (int); 66extern void (*ia64_mark_idle) (int);
67extern void snidle(int); 67extern void snidle(int);
68extern unsigned char acpi_kbd_controller_present;
69extern unsigned long long (*ia64_printk_clock)(void); 68extern unsigned long long (*ia64_printk_clock)(void);
70 69
71unsigned long sn_rtc_cycles_per_second; 70unsigned long sn_rtc_cycles_per_second;
@@ -452,17 +451,6 @@ void __init sn_setup(char **cmdline_p)
452 451
453 ia64_printk_clock = ia64_sn2_printk_clock; 452 ia64_printk_clock = ia64_sn2_printk_clock;
454 453
455 /*
456 * Old PROMs do not provide an ACPI FADT. Disable legacy keyboard
457 * support here so we don't have to listen to failed keyboard probe
458 * messages.
459 */
460 if (is_shub1() && version <= 0x0209 && acpi_kbd_controller_present) {
461 printk(KERN_INFO "Disabling legacy keyboard support as prom "
462 "is too old and doesn't provide FADT\n");
463 acpi_kbd_controller_present = 0;
464 }
465
466 printk("SGI SAL version %x.%02x\n", version >> 8, version & 0x00FF); 454 printk("SGI SAL version %x.%02x\n", version >> 8, version & 0x00FF);
467 455
468 /* 456 /*
diff --git a/arch/m32r/kernel/setup.c b/arch/m32r/kernel/setup.c
index 3f35ab3d2dc2..0e7778be33cc 100644
--- a/arch/m32r/kernel/setup.c
+++ b/arch/m32r/kernel/setup.c
@@ -369,10 +369,10 @@ static void c_stop(struct seq_file *m, void *v)
369} 369}
370 370
371struct seq_operations cpuinfo_op = { 371struct seq_operations cpuinfo_op = {
372 start: c_start, 372 .start = c_start,
373 next: c_next, 373 .next = c_next,
374 stop: c_stop, 374 .stop = c_stop,
375 show: show_cpuinfo, 375 .show = show_cpuinfo,
376}; 376};
377#endif /* CONFIG_PROC_FS */ 377#endif /* CONFIG_PROC_FS */
378 378
diff --git a/arch/m32r/kernel/setup_mappi.c b/arch/m32r/kernel/setup_mappi.c
index 67dbbdc9d111..6b2d77da0683 100644
--- a/arch/m32r/kernel/setup_mappi.c
+++ b/arch/m32r/kernel/setup_mappi.c
@@ -86,7 +86,7 @@ void __init init_IRQ(void)
86 /* INT0 : LAN controller (RTL8019AS) */ 86 /* INT0 : LAN controller (RTL8019AS) */
87 irq_desc[M32R_IRQ_INT0].status = IRQ_DISABLED; 87 irq_desc[M32R_IRQ_INT0].status = IRQ_DISABLED;
88 irq_desc[M32R_IRQ_INT0].chip = &mappi_irq_type; 88 irq_desc[M32R_IRQ_INT0].chip = &mappi_irq_type;
89 irq_desc[M32R_IRQ_INT0].action = 0; 89 irq_desc[M32R_IRQ_INT0].action = NULL;
90 irq_desc[M32R_IRQ_INT0].depth = 1; 90 irq_desc[M32R_IRQ_INT0].depth = 1;
91 icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10; 91 icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10;
92 disable_mappi_irq(M32R_IRQ_INT0); 92 disable_mappi_irq(M32R_IRQ_INT0);
@@ -95,7 +95,7 @@ void __init init_IRQ(void)
95 /* MFT2 : system timer */ 95 /* MFT2 : system timer */
96 irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED; 96 irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED;
97 irq_desc[M32R_IRQ_MFT2].chip = &mappi_irq_type; 97 irq_desc[M32R_IRQ_MFT2].chip = &mappi_irq_type;
98 irq_desc[M32R_IRQ_MFT2].action = 0; 98 irq_desc[M32R_IRQ_MFT2].action = NULL;
99 irq_desc[M32R_IRQ_MFT2].depth = 1; 99 irq_desc[M32R_IRQ_MFT2].depth = 1;
100 icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN; 100 icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN;
101 disable_mappi_irq(M32R_IRQ_MFT2); 101 disable_mappi_irq(M32R_IRQ_MFT2);
@@ -104,7 +104,7 @@ void __init init_IRQ(void)
104 /* SIO0_R : uart receive data */ 104 /* SIO0_R : uart receive data */
105 irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED; 105 irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED;
106 irq_desc[M32R_IRQ_SIO0_R].chip = &mappi_irq_type; 106 irq_desc[M32R_IRQ_SIO0_R].chip = &mappi_irq_type;
107 irq_desc[M32R_IRQ_SIO0_R].action = 0; 107 irq_desc[M32R_IRQ_SIO0_R].action = NULL;
108 irq_desc[M32R_IRQ_SIO0_R].depth = 1; 108 irq_desc[M32R_IRQ_SIO0_R].depth = 1;
109 icu_data[M32R_IRQ_SIO0_R].icucr = 0; 109 icu_data[M32R_IRQ_SIO0_R].icucr = 0;
110 disable_mappi_irq(M32R_IRQ_SIO0_R); 110 disable_mappi_irq(M32R_IRQ_SIO0_R);
@@ -112,7 +112,7 @@ void __init init_IRQ(void)
112 /* SIO0_S : uart send data */ 112 /* SIO0_S : uart send data */
113 irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED; 113 irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED;
114 irq_desc[M32R_IRQ_SIO0_S].chip = &mappi_irq_type; 114 irq_desc[M32R_IRQ_SIO0_S].chip = &mappi_irq_type;
115 irq_desc[M32R_IRQ_SIO0_S].action = 0; 115 irq_desc[M32R_IRQ_SIO0_S].action = NULL;
116 irq_desc[M32R_IRQ_SIO0_S].depth = 1; 116 irq_desc[M32R_IRQ_SIO0_S].depth = 1;
117 icu_data[M32R_IRQ_SIO0_S].icucr = 0; 117 icu_data[M32R_IRQ_SIO0_S].icucr = 0;
118 disable_mappi_irq(M32R_IRQ_SIO0_S); 118 disable_mappi_irq(M32R_IRQ_SIO0_S);
@@ -120,7 +120,7 @@ void __init init_IRQ(void)
120 /* SIO1_R : uart receive data */ 120 /* SIO1_R : uart receive data */
121 irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED; 121 irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED;
122 irq_desc[M32R_IRQ_SIO1_R].chip = &mappi_irq_type; 122 irq_desc[M32R_IRQ_SIO1_R].chip = &mappi_irq_type;
123 irq_desc[M32R_IRQ_SIO1_R].action = 0; 123 irq_desc[M32R_IRQ_SIO1_R].action = NULL;
124 irq_desc[M32R_IRQ_SIO1_R].depth = 1; 124 irq_desc[M32R_IRQ_SIO1_R].depth = 1;
125 icu_data[M32R_IRQ_SIO1_R].icucr = 0; 125 icu_data[M32R_IRQ_SIO1_R].icucr = 0;
126 disable_mappi_irq(M32R_IRQ_SIO1_R); 126 disable_mappi_irq(M32R_IRQ_SIO1_R);
@@ -128,7 +128,7 @@ void __init init_IRQ(void)
128 /* SIO1_S : uart send data */ 128 /* SIO1_S : uart send data */
129 irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED; 129 irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED;
130 irq_desc[M32R_IRQ_SIO1_S].chip = &mappi_irq_type; 130 irq_desc[M32R_IRQ_SIO1_S].chip = &mappi_irq_type;
131 irq_desc[M32R_IRQ_SIO1_S].action = 0; 131 irq_desc[M32R_IRQ_SIO1_S].action = NULL;
132 irq_desc[M32R_IRQ_SIO1_S].depth = 1; 132 irq_desc[M32R_IRQ_SIO1_S].depth = 1;
133 icu_data[M32R_IRQ_SIO1_S].icucr = 0; 133 icu_data[M32R_IRQ_SIO1_S].icucr = 0;
134 disable_mappi_irq(M32R_IRQ_SIO1_S); 134 disable_mappi_irq(M32R_IRQ_SIO1_S);
@@ -138,7 +138,7 @@ void __init init_IRQ(void)
138 /* INT1 : pccard0 interrupt */ 138 /* INT1 : pccard0 interrupt */
139 irq_desc[M32R_IRQ_INT1].status = IRQ_DISABLED; 139 irq_desc[M32R_IRQ_INT1].status = IRQ_DISABLED;
140 irq_desc[M32R_IRQ_INT1].chip = &mappi_irq_type; 140 irq_desc[M32R_IRQ_INT1].chip = &mappi_irq_type;
141 irq_desc[M32R_IRQ_INT1].action = 0; 141 irq_desc[M32R_IRQ_INT1].action = NULL;
142 irq_desc[M32R_IRQ_INT1].depth = 1; 142 irq_desc[M32R_IRQ_INT1].depth = 1;
143 icu_data[M32R_IRQ_INT1].icucr = M32R_ICUCR_IEN | M32R_ICUCR_ISMOD00; 143 icu_data[M32R_IRQ_INT1].icucr = M32R_ICUCR_IEN | M32R_ICUCR_ISMOD00;
144 disable_mappi_irq(M32R_IRQ_INT1); 144 disable_mappi_irq(M32R_IRQ_INT1);
@@ -146,7 +146,7 @@ void __init init_IRQ(void)
146 /* INT2 : pccard1 interrupt */ 146 /* INT2 : pccard1 interrupt */
147 irq_desc[M32R_IRQ_INT2].status = IRQ_DISABLED; 147 irq_desc[M32R_IRQ_INT2].status = IRQ_DISABLED;
148 irq_desc[M32R_IRQ_INT2].chip = &mappi_irq_type; 148 irq_desc[M32R_IRQ_INT2].chip = &mappi_irq_type;
149 irq_desc[M32R_IRQ_INT2].action = 0; 149 irq_desc[M32R_IRQ_INT2].action = NULL;
150 irq_desc[M32R_IRQ_INT2].depth = 1; 150 irq_desc[M32R_IRQ_INT2].depth = 1;
151 icu_data[M32R_IRQ_INT2].icucr = M32R_ICUCR_IEN | M32R_ICUCR_ISMOD00; 151 icu_data[M32R_IRQ_INT2].icucr = M32R_ICUCR_IEN | M32R_ICUCR_ISMOD00;
152 disable_mappi_irq(M32R_IRQ_INT2); 152 disable_mappi_irq(M32R_IRQ_INT2);
diff --git a/arch/m32r/kernel/signal.c b/arch/m32r/kernel/signal.c
index a9174efe80cb..b60cea4aebaa 100644
--- a/arch/m32r/kernel/signal.c
+++ b/arch/m32r/kernel/signal.c
@@ -33,7 +33,7 @@
33int do_signal(struct pt_regs *, sigset_t *); 33int do_signal(struct pt_regs *, sigset_t *);
34 34
35asmlinkage int 35asmlinkage int
36sys_rt_sigsuspend(sigset_t *unewset, size_t sigsetsize, 36sys_rt_sigsuspend(sigset_t __user *unewset, size_t sigsetsize,
37 unsigned long r2, unsigned long r3, unsigned long r4, 37 unsigned long r2, unsigned long r3, unsigned long r4,
38 unsigned long r5, unsigned long r6, struct pt_regs *regs) 38 unsigned long r5, unsigned long r6, struct pt_regs *regs)
39{ 39{
@@ -78,8 +78,8 @@ sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
78struct rt_sigframe 78struct rt_sigframe
79{ 79{
80 int sig; 80 int sig;
81 struct siginfo *pinfo; 81 struct siginfo __user *pinfo;
82 void *puc; 82 void __user *puc;
83 struct siginfo info; 83 struct siginfo info;
84 struct ucontext uc; 84 struct ucontext uc;
85// struct _fpstate fpstate; 85// struct _fpstate fpstate;
diff --git a/arch/m32r/kernel/smp.c b/arch/m32r/kernel/smp.c
index 722e21f556dc..360129174b2b 100644
--- a/arch/m32r/kernel/smp.c
+++ b/arch/m32r/kernel/smp.c
@@ -231,7 +231,7 @@ void smp_flush_tlb_all(void)
231 local_irq_save(flags); 231 local_irq_save(flags);
232 __flush_tlb_all(); 232 __flush_tlb_all();
233 local_irq_restore(flags); 233 local_irq_restore(flags);
234 smp_call_function(flush_tlb_all_ipi, 0, 1, 1); 234 smp_call_function(flush_tlb_all_ipi, NULL, 1, 1);
235 preempt_enable(); 235 preempt_enable();
236} 236}
237 237
diff --git a/arch/m32r/kernel/sys_m32r.c b/arch/m32r/kernel/sys_m32r.c
index b567351f3c52..b4e7bcb43540 100644
--- a/arch/m32r/kernel/sys_m32r.c
+++ b/arch/m32r/kernel/sys_m32r.c
@@ -31,7 +31,7 @@
31/* 31/*
32 * sys_tas() - test-and-set 32 * sys_tas() - test-and-set
33 */ 33 */
34asmlinkage int sys_tas(int *addr) 34asmlinkage int sys_tas(int __user *addr)
35{ 35{
36 int oldval; 36 int oldval;
37 37
@@ -90,7 +90,7 @@ sys_pipe(unsigned long r0, unsigned long r1, unsigned long r2,
90 90
91 error = do_pipe(fd); 91 error = do_pipe(fd);
92 if (!error) { 92 if (!error) {
93 if (copy_to_user((void *)r0, (void *)fd, 2*sizeof(int))) 93 if (copy_to_user((void __user *)r0, fd, 2*sizeof(int)))
94 error = -EFAULT; 94 error = -EFAULT;
95 } 95 }
96 return error; 96 return error;
@@ -201,7 +201,7 @@ asmlinkage int sys_ipc(uint call, int first, int second,
201 } 201 }
202} 202}
203 203
204asmlinkage int sys_uname(struct old_utsname * name) 204asmlinkage int sys_uname(struct old_utsname __user * name)
205{ 205{
206 int err; 206 int err;
207 if (!name) 207 if (!name)
diff --git a/arch/m32r/kernel/traps.c b/arch/m32r/kernel/traps.c
index c1daf2c40c7c..97e0b1c0830e 100644
--- a/arch/m32r/kernel/traps.c
+++ b/arch/m32r/kernel/traps.c
@@ -268,7 +268,7 @@ static __inline__ void do_trap(int trapnr, int signr, const char * str,
268#define DO_ERROR(trapnr, signr, str, name) \ 268#define DO_ERROR(trapnr, signr, str, name) \
269asmlinkage void do_##name(struct pt_regs * regs, long error_code) \ 269asmlinkage void do_##name(struct pt_regs * regs, long error_code) \
270{ \ 270{ \
271 do_trap(trapnr, signr, 0, regs, error_code, NULL); \ 271 do_trap(trapnr, signr, NULL, regs, error_code, NULL); \
272} 272}
273 273
274#define DO_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr) \ 274#define DO_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr) \
diff --git a/arch/m32r/kernel/vmlinux.lds.S b/arch/m32r/kernel/vmlinux.lds.S
index 13c7bb698e37..358b9cee2c65 100644
--- a/arch/m32r/kernel/vmlinux.lds.S
+++ b/arch/m32r/kernel/vmlinux.lds.S
@@ -83,13 +83,7 @@ SECTIONS
83 __setup_end = .; 83 __setup_end = .;
84 __initcall_start = .; 84 __initcall_start = .;
85 .initcall.init : { 85 .initcall.init : {
86 *(.initcall1.init) 86 INITCALLS
87 *(.initcall2.init)
88 *(.initcall3.init)
89 *(.initcall4.init)
90 *(.initcall5.init)
91 *(.initcall6.init)
92 *(.initcall7.init)
93 } 87 }
94 __initcall_end = .; 88 __initcall_end = .;
95 __con_initcall_start = .; 89 __con_initcall_start = .;
diff --git a/arch/m68k/kernel/m68k_ksyms.c b/arch/m68k/kernel/m68k_ksyms.c
index f9636e84e6a4..6fc69c74fe2e 100644
--- a/arch/m68k/kernel/m68k_ksyms.c
+++ b/arch/m68k/kernel/m68k_ksyms.c
@@ -1,61 +1,10 @@
1#include <linux/module.h> 1#include <linux/module.h>
2#include <linux/linkage.h>
3#include <linux/sched.h>
4#include <linux/mm.h>
5#include <linux/user.h>
6#include <linux/elfcore.h>
7#include <linux/in6.h>
8#include <linux/interrupt.h>
9
10#include <asm/setup.h>
11#include <asm/machdep.h>
12#include <asm/pgalloc.h>
13#include <asm/irq.h>
14#include <asm/io.h>
15#include <asm/semaphore.h> 2#include <asm/semaphore.h>
16#include <asm/checksum.h>
17 3
18asmlinkage long long __ashldi3 (long long, int); 4asmlinkage long long __ashldi3 (long long, int);
19asmlinkage long long __ashrdi3 (long long, int); 5asmlinkage long long __ashrdi3 (long long, int);
20asmlinkage long long __lshrdi3 (long long, int); 6asmlinkage long long __lshrdi3 (long long, int);
21asmlinkage long long __muldi3 (long long, long long); 7asmlinkage long long __muldi3 (long long, long long);
22extern char m68k_debug_device[];
23
24/* platform dependent support */
25
26EXPORT_SYMBOL(m68k_machtype);
27EXPORT_SYMBOL(m68k_cputype);
28EXPORT_SYMBOL(m68k_is040or060);
29EXPORT_SYMBOL(m68k_realnum_memory);
30EXPORT_SYMBOL(m68k_memory);
31#ifndef CONFIG_SUN3
32EXPORT_SYMBOL(cache_push);
33EXPORT_SYMBOL(cache_clear);
34#ifndef CONFIG_SINGLE_MEMORY_CHUNK
35EXPORT_SYMBOL(mm_vtop);
36EXPORT_SYMBOL(mm_ptov);
37EXPORT_SYMBOL(mm_end_of_chunk);
38#else
39EXPORT_SYMBOL(m68k_memoffset);
40#endif /* !CONFIG_SINGLE_MEMORY_CHUNK */
41EXPORT_SYMBOL(__ioremap);
42EXPORT_SYMBOL(iounmap);
43EXPORT_SYMBOL(kernel_set_cachemode);
44#endif /* !CONFIG_SUN3 */
45EXPORT_SYMBOL(m68k_debug_device);
46EXPORT_SYMBOL(mach_hwclk);
47EXPORT_SYMBOL(mach_get_ss);
48EXPORT_SYMBOL(mach_get_rtc_pll);
49EXPORT_SYMBOL(mach_set_rtc_pll);
50#ifdef CONFIG_INPUT_M68K_BEEP_MODULE
51EXPORT_SYMBOL(mach_beep);
52#endif
53EXPORT_SYMBOL(dump_fpu);
54EXPORT_SYMBOL(dump_thread);
55EXPORT_SYMBOL(kernel_thread);
56#ifdef CONFIG_VME
57EXPORT_SYMBOL(vme_brdtype);
58#endif
59 8
60/* The following are special because they're not called 9/* The following are special because they're not called
61 explicitly (the C compiler generates them). Fortunately, 10 explicitly (the C compiler generates them). Fortunately,
diff --git a/arch/m68k/kernel/process.c b/arch/m68k/kernel/process.c
index 45a46646c1b3..99fc1226f7f8 100644
--- a/arch/m68k/kernel/process.c
+++ b/arch/m68k/kernel/process.c
@@ -187,6 +187,7 @@ int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
187 set_fs (fs); 187 set_fs (fs);
188 return pid; 188 return pid;
189} 189}
190EXPORT_SYMBOL(kernel_thread);
190 191
191void flush_thread(void) 192void flush_thread(void)
192{ 193{
@@ -221,13 +222,13 @@ asmlinkage int m68k_clone(struct pt_regs *regs)
221{ 222{
222 unsigned long clone_flags; 223 unsigned long clone_flags;
223 unsigned long newsp; 224 unsigned long newsp;
224 int *parent_tidptr, *child_tidptr; 225 int __user *parent_tidptr, *child_tidptr;
225 226
226 /* syscall2 puts clone_flags in d1 and usp in d2 */ 227 /* syscall2 puts clone_flags in d1 and usp in d2 */
227 clone_flags = regs->d1; 228 clone_flags = regs->d1;
228 newsp = regs->d2; 229 newsp = regs->d2;
229 parent_tidptr = (int *)regs->d3; 230 parent_tidptr = (int __user *)regs->d3;
230 child_tidptr = (int *)regs->d4; 231 child_tidptr = (int __user *)regs->d4;
231 if (!newsp) 232 if (!newsp)
232 newsp = rdusp(); 233 newsp = rdusp();
233 return do_fork(clone_flags, newsp, regs, 0, 234 return do_fork(clone_flags, newsp, regs, 0,
@@ -311,6 +312,7 @@ int dump_fpu (struct pt_regs *regs, struct user_m68kfp_struct *fpu)
311 : "memory"); 312 : "memory");
312 return 1; 313 return 1;
313} 314}
315EXPORT_SYMBOL(dump_fpu);
314 316
315/* 317/*
316 * fill in the user structure for a core dump.. 318 * fill in the user structure for a core dump..
@@ -357,11 +359,12 @@ void dump_thread(struct pt_regs * regs, struct user * dump)
357 /* dump floating point stuff */ 359 /* dump floating point stuff */
358 dump->u_fpvalid = dump_fpu (regs, &dump->m68kfp); 360 dump->u_fpvalid = dump_fpu (regs, &dump->m68kfp);
359} 361}
362EXPORT_SYMBOL(dump_thread);
360 363
361/* 364/*
362 * sys_execve() executes a new program. 365 * sys_execve() executes a new program.
363 */ 366 */
364asmlinkage int sys_execve(char *name, char **argv, char **envp) 367asmlinkage int sys_execve(char __user *name, char __user * __user *argv, char __user * __user *envp)
365{ 368{
366 int error; 369 int error;
367 char * filename; 370 char * filename;
diff --git a/arch/m68k/kernel/setup.c b/arch/m68k/kernel/setup.c
index 42d5b85f3350..9af3ee0e555d 100644
--- a/arch/m68k/kernel/setup.c
+++ b/arch/m68k/kernel/setup.c
@@ -42,27 +42,37 @@
42 42
43unsigned long m68k_machtype; 43unsigned long m68k_machtype;
44unsigned long m68k_cputype; 44unsigned long m68k_cputype;
45EXPORT_SYMBOL(m68k_machtype);
46EXPORT_SYMBOL(m68k_cputype);
45unsigned long m68k_fputype; 47unsigned long m68k_fputype;
46unsigned long m68k_mmutype; 48unsigned long m68k_mmutype;
47#ifdef CONFIG_VME 49#ifdef CONFIG_VME
48unsigned long vme_brdtype; 50unsigned long vme_brdtype;
51EXPORT_SYMBOL(vme_brdtype);
49#endif 52#endif
50 53
51int m68k_is040or060; 54int m68k_is040or060;
55EXPORT_SYMBOL(m68k_is040or060);
52 56
53extern int end; 57extern int end;
54extern unsigned long availmem; 58extern unsigned long availmem;
55 59
56int m68k_num_memory; 60int m68k_num_memory;
57int m68k_realnum_memory; 61int m68k_realnum_memory;
62EXPORT_SYMBOL(m68k_realnum_memory);
63#ifdef CONFIG_SINGLE_MEMORY_CHUNK
58unsigned long m68k_memoffset; 64unsigned long m68k_memoffset;
65EXPORT_SYMBOL(m68k_memoffset);
66#endif
59struct mem_info m68k_memory[NUM_MEMINFO]; 67struct mem_info m68k_memory[NUM_MEMINFO];
68EXPORT_SYMBOL(m68k_memory);
60 69
61static struct mem_info m68k_ramdisk; 70static struct mem_info m68k_ramdisk;
62 71
63static char m68k_command_line[CL_SIZE]; 72static char m68k_command_line[CL_SIZE];
64 73
65char m68k_debug_device[6] = ""; 74char m68k_debug_device[6] = "";
75EXPORT_SYMBOL(m68k_debug_device);
66 76
67void (*mach_sched_init) (irq_handler_t handler) __initdata = NULL; 77void (*mach_sched_init) (irq_handler_t handler) __initdata = NULL;
68/* machine dependent irq functions */ 78/* machine dependent irq functions */
@@ -72,10 +82,14 @@ int (*mach_get_hardware_list) (char *buffer);
72/* machine dependent timer functions */ 82/* machine dependent timer functions */
73unsigned long (*mach_gettimeoffset) (void); 83unsigned long (*mach_gettimeoffset) (void);
74int (*mach_hwclk) (int, struct rtc_time*); 84int (*mach_hwclk) (int, struct rtc_time*);
85EXPORT_SYMBOL(mach_hwclk);
75int (*mach_set_clock_mmss) (unsigned long); 86int (*mach_set_clock_mmss) (unsigned long);
76unsigned int (*mach_get_ss)(void); 87unsigned int (*mach_get_ss)(void);
77int (*mach_get_rtc_pll)(struct rtc_pll_info *); 88int (*mach_get_rtc_pll)(struct rtc_pll_info *);
78int (*mach_set_rtc_pll)(struct rtc_pll_info *); 89int (*mach_set_rtc_pll)(struct rtc_pll_info *);
90EXPORT_SYMBOL(mach_get_ss);
91EXPORT_SYMBOL(mach_get_rtc_pll);
92EXPORT_SYMBOL(mach_set_rtc_pll);
79void (*mach_reset)( void ); 93void (*mach_reset)( void );
80void (*mach_halt)( void ); 94void (*mach_halt)( void );
81void (*mach_power_off)( void ); 95void (*mach_power_off)( void );
@@ -89,6 +103,7 @@ void (*mach_l2_flush) (int);
89#endif 103#endif
90#if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE) 104#if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE)
91void (*mach_beep)(unsigned int, unsigned int); 105void (*mach_beep)(unsigned int, unsigned int);
106EXPORT_SYMBOL(mach_beep);
92#endif 107#endif
93#if defined(CONFIG_ISA) && defined(MULTI_ISA) 108#if defined(CONFIG_ISA) && defined(MULTI_ISA)
94int isa_type; 109int isa_type;
diff --git a/arch/m68k/kernel/traps.c b/arch/m68k/kernel/traps.c
index 4569406a2e1f..759fa244e6cd 100644
--- a/arch/m68k/kernel/traps.c
+++ b/arch/m68k/kernel/traps.c
@@ -326,13 +326,13 @@ static inline int do_040writeback1(unsigned short wbs, unsigned long wba,
326 326
327 switch (wbs & WBSIZ_040) { 327 switch (wbs & WBSIZ_040) {
328 case BA_SIZE_BYTE: 328 case BA_SIZE_BYTE:
329 res = put_user(wbd & 0xff, (char *)wba); 329 res = put_user(wbd & 0xff, (char __user *)wba);
330 break; 330 break;
331 case BA_SIZE_WORD: 331 case BA_SIZE_WORD:
332 res = put_user(wbd & 0xffff, (short *)wba); 332 res = put_user(wbd & 0xffff, (short __user *)wba);
333 break; 333 break;
334 case BA_SIZE_LONG: 334 case BA_SIZE_LONG:
335 res = put_user(wbd, (int *)wba); 335 res = put_user(wbd, (int __user *)wba);
336 break; 336 break;
337 } 337 }
338 338
diff --git a/arch/m68k/kernel/vmlinux-std.lds b/arch/m68k/kernel/vmlinux-std.lds
index 69d1d3d30c78..d2794452b195 100644
--- a/arch/m68k/kernel/vmlinux-std.lds
+++ b/arch/m68k/kernel/vmlinux-std.lds
@@ -54,13 +54,7 @@ SECTIONS
54 __setup_end = .; 54 __setup_end = .;
55 __initcall_start = .; 55 __initcall_start = .;
56 .initcall.init : { 56 .initcall.init : {
57 *(.initcall1.init) 57 INITCALLS
58 *(.initcall2.init)
59 *(.initcall3.init)
60 *(.initcall4.init)
61 *(.initcall5.init)
62 *(.initcall6.init)
63 *(.initcall7.init)
64 } 58 }
65 __initcall_end = .; 59 __initcall_end = .;
66 __con_initcall_start = .; 60 __con_initcall_start = .;
diff --git a/arch/m68k/kernel/vmlinux-sun3.lds b/arch/m68k/kernel/vmlinux-sun3.lds
index 65cc39c24185..2550b4ae2732 100644
--- a/arch/m68k/kernel/vmlinux-sun3.lds
+++ b/arch/m68k/kernel/vmlinux-sun3.lds
@@ -48,13 +48,7 @@ __init_begin = .;
48 __setup_end = .; 48 __setup_end = .;
49 __initcall_start = .; 49 __initcall_start = .;
50 .initcall.init : { 50 .initcall.init : {
51 *(.initcall1.init) 51 INITCALLS
52 *(.initcall2.init)
53 *(.initcall3.init)
54 *(.initcall4.init)
55 *(.initcall5.init)
56 *(.initcall6.init)
57 *(.initcall7.init)
58 } 52 }
59 __initcall_end = .; 53 __initcall_end = .;
60 __con_initcall_start = .; 54 __con_initcall_start = .;
diff --git a/arch/m68k/mm/kmap.c b/arch/m68k/mm/kmap.c
index f46f049d29ff..b54ef1726c55 100644
--- a/arch/m68k/mm/kmap.c
+++ b/arch/m68k/mm/kmap.c
@@ -7,6 +7,7 @@
7 * used by other architectures /Roman Zippel 7 * used by other architectures /Roman Zippel
8 */ 8 */
9 9
10#include <linux/module.h>
10#include <linux/mm.h> 11#include <linux/mm.h>
11#include <linux/kernel.h> 12#include <linux/kernel.h>
12#include <linux/string.h> 13#include <linux/string.h>
@@ -219,6 +220,7 @@ void __iomem *__ioremap(unsigned long physaddr, unsigned long size, int cachefla
219 220
220 return (void __iomem *)retaddr; 221 return (void __iomem *)retaddr;
221} 222}
223EXPORT_SYMBOL(__ioremap);
222 224
223/* 225/*
224 * Unmap a ioremap()ed region again 226 * Unmap a ioremap()ed region again
@@ -234,6 +236,7 @@ void iounmap(void __iomem *addr)
234 free_io_area((__force void *)addr); 236 free_io_area((__force void *)addr);
235#endif 237#endif
236} 238}
239EXPORT_SYMBOL(iounmap);
237 240
238/* 241/*
239 * __iounmap unmaps nearly everything, so be careful 242 * __iounmap unmaps nearly everything, so be careful
@@ -360,3 +363,4 @@ void kernel_set_cachemode(void *addr, unsigned long size, int cmode)
360 363
361 flush_tlb_all(); 364 flush_tlb_all();
362} 365}
366EXPORT_SYMBOL(kernel_set_cachemode);
diff --git a/arch/m68k/mm/memory.c b/arch/m68k/mm/memory.c
index a0c095e17222..0f88812822b1 100644
--- a/arch/m68k/mm/memory.c
+++ b/arch/m68k/mm/memory.c
@@ -4,6 +4,7 @@
4 * Copyright (C) 1995 Hamish Macdonald 4 * Copyright (C) 1995 Hamish Macdonald
5 */ 5 */
6 6
7#include <linux/module.h>
7#include <linux/mm.h> 8#include <linux/mm.h>
8#include <linux/kernel.h> 9#include <linux/kernel.h>
9#include <linux/string.h> 10#include <linux/string.h>
@@ -157,9 +158,8 @@ unsigned long mm_vtop(unsigned long vaddr)
157 158
158 return -1; 159 return -1;
159} 160}
160#endif 161EXPORT_SYMBOL(mm_vtop);
161 162
162#ifndef CONFIG_SINGLE_MEMORY_CHUNK
163unsigned long mm_ptov (unsigned long paddr) 163unsigned long mm_ptov (unsigned long paddr)
164{ 164{
165 int i = 0; 165 int i = 0;
@@ -185,6 +185,7 @@ unsigned long mm_ptov (unsigned long paddr)
185#endif 185#endif
186 return -1; 186 return -1;
187} 187}
188EXPORT_SYMBOL(mm_ptov);
188#endif 189#endif
189 190
190/* invalidate page in both caches */ 191/* invalidate page in both caches */
@@ -298,6 +299,7 @@ void cache_clear (unsigned long paddr, int len)
298 mach_l2_flush(0); 299 mach_l2_flush(0);
299#endif 300#endif
300} 301}
302EXPORT_SYMBOL(cache_clear); /* probably can be unexported */
301 303
302 304
303/* 305/*
@@ -350,6 +352,7 @@ void cache_push (unsigned long paddr, int len)
350 mach_l2_flush(1); 352 mach_l2_flush(1);
351#endif 353#endif
352} 354}
355EXPORT_SYMBOL(cache_push); /* probably can be unexported */
353 356
354#ifndef CONFIG_SINGLE_MEMORY_CHUNK 357#ifndef CONFIG_SINGLE_MEMORY_CHUNK
355int mm_end_of_chunk (unsigned long addr, int len) 358int mm_end_of_chunk (unsigned long addr, int len)
@@ -361,4 +364,5 @@ int mm_end_of_chunk (unsigned long addr, int len)
361 return 1; 364 return 1;
362 return 0; 365 return 0;
363} 366}
367EXPORT_SYMBOL(mm_end_of_chunk);
364#endif 368#endif
diff --git a/arch/m68k/mm/sun3kmap.c b/arch/m68k/mm/sun3kmap.c
index 7f0d86f3fe73..1af24cb5bfe1 100644
--- a/arch/m68k/mm/sun3kmap.c
+++ b/arch/m68k/mm/sun3kmap.c
@@ -8,6 +8,7 @@
8 * for more details. 8 * for more details.
9 */ 9 */
10 10
11#include <linux/module.h>
11#include <linux/types.h> 12#include <linux/types.h>
12#include <linux/kernel.h> 13#include <linux/kernel.h>
13#include <linux/mm.h> 14#include <linux/mm.h>
@@ -59,7 +60,7 @@ static inline void do_pmeg_mapin(unsigned long phys, unsigned long virt,
59 } 60 }
60} 61}
61 62
62void *sun3_ioremap(unsigned long phys, unsigned long size, 63void __iomem *sun3_ioremap(unsigned long phys, unsigned long size,
63 unsigned long type) 64 unsigned long type)
64{ 65{
65 struct vm_struct *area; 66 struct vm_struct *area;
@@ -101,22 +102,24 @@ void *sun3_ioremap(unsigned long phys, unsigned long size,
101 virt += seg_pages * PAGE_SIZE; 102 virt += seg_pages * PAGE_SIZE;
102 } 103 }
103 104
104 return (void *)ret; 105 return (void __iomem *)ret;
105 106
106} 107}
107 108
108 109
109void *__ioremap(unsigned long phys, unsigned long size, int cache) 110void __iomem *__ioremap(unsigned long phys, unsigned long size, int cache)
110{ 111{
111 112
112 return sun3_ioremap(phys, size, SUN3_PAGE_TYPE_IO); 113 return sun3_ioremap(phys, size, SUN3_PAGE_TYPE_IO);
113 114
114} 115}
116EXPORT_SYMBOL(__ioremap);
115 117
116void iounmap(void *addr) 118void iounmap(void __iomem *addr)
117{ 119{
118 vfree((void *)(PAGE_MASK & (unsigned long)addr)); 120 vfree((void *)(PAGE_MASK & (unsigned long)addr));
119} 121}
122EXPORT_SYMBOL(iounmap);
120 123
121/* sun3_map_test(addr, val) -- Reads a byte from addr, storing to val, 124/* sun3_map_test(addr, val) -- Reads a byte from addr, storing to val,
122 * trapping the potential read fault. Returns 0 if the access faulted, 125 * trapping the potential read fault. Returns 0 if the access faulted,
diff --git a/arch/m68k/sun3/Makefile b/arch/m68k/sun3/Makefile
index 4d4f0695d985..be1a8470d636 100644
--- a/arch/m68k/sun3/Makefile
+++ b/arch/m68k/sun3/Makefile
@@ -2,6 +2,6 @@
2# Makefile for Linux arch/m68k/sun3 source directory 2# Makefile for Linux arch/m68k/sun3 source directory
3# 3#
4 4
5obj-y := sun3_ksyms.o sun3ints.o sun3dvma.o sbus.o idprom.o 5obj-y := sun3ints.o sun3dvma.o sbus.o idprom.o
6 6
7obj-$(CONFIG_SUN3) += config.o mmu_emu.o leds.o dvma.o intersil.o 7obj-$(CONFIG_SUN3) += config.o mmu_emu.o leds.o dvma.o intersil.o
diff --git a/arch/m68k/sun3/idprom.c b/arch/m68k/sun3/idprom.c
index 02c1fee6fe74..dca6ab6a4ede 100644
--- a/arch/m68k/sun3/idprom.c
+++ b/arch/m68k/sun3/idprom.c
@@ -6,6 +6,7 @@
6 * Sun3/3x models added by David Monro (davidm@psrg.cs.usyd.edu.au) 6 * Sun3/3x models added by David Monro (davidm@psrg.cs.usyd.edu.au)
7 */ 7 */
8 8
9#include <linux/module.h>
9#include <linux/kernel.h> 10#include <linux/kernel.h>
10#include <linux/types.h> 11#include <linux/types.h>
11#include <linux/init.h> 12#include <linux/init.h>
@@ -16,6 +17,8 @@
16#include <asm/machines.h> /* Fun with Sun released architectures. */ 17#include <asm/machines.h> /* Fun with Sun released architectures. */
17 18
18struct idprom *idprom; 19struct idprom *idprom;
20EXPORT_SYMBOL(idprom);
21
19static struct idprom idprom_buffer; 22static struct idprom idprom_buffer;
20 23
21/* Here is the master table of Sun machines which use some implementation 24/* Here is the master table of Sun machines which use some implementation
diff --git a/arch/m68k/sun3/sun3_ksyms.c b/arch/m68k/sun3/sun3_ksyms.c
deleted file mode 100644
index 43e5a9af8abd..000000000000
--- a/arch/m68k/sun3/sun3_ksyms.c
+++ /dev/null
@@ -1,13 +0,0 @@
1#include <linux/module.h>
2#include <linux/types.h>
3#include <asm/dvma.h>
4#include <asm/idprom.h>
5
6/*
7 * Add things here when you find the need for it.
8 */
9EXPORT_SYMBOL(dvma_map_align);
10EXPORT_SYMBOL(dvma_unmap);
11EXPORT_SYMBOL(dvma_malloc_align);
12EXPORT_SYMBOL(dvma_free);
13EXPORT_SYMBOL(idprom);
diff --git a/arch/m68k/sun3/sun3dvma.c b/arch/m68k/sun3/sun3dvma.c
index a2bc2da7f8f0..8709677fa025 100644
--- a/arch/m68k/sun3/sun3dvma.c
+++ b/arch/m68k/sun3/sun3dvma.c
@@ -6,6 +6,7 @@
6 * Contains common routines for sun3/sun3x DVMA management. 6 * Contains common routines for sun3/sun3x DVMA management.
7 */ 7 */
8 8
9#include <linux/module.h>
9#include <linux/kernel.h> 10#include <linux/kernel.h>
10#include <linux/mm.h> 11#include <linux/mm.h>
11#include <linux/list.h> 12#include <linux/list.h>
@@ -312,6 +313,7 @@ inline unsigned long dvma_map_align(unsigned long kaddr, int len, int align)
312 BUG(); 313 BUG();
313 return 0; 314 return 0;
314} 315}
316EXPORT_SYMBOL(dvma_map_align);
315 317
316void dvma_unmap(void *baddr) 318void dvma_unmap(void *baddr)
317{ 319{
@@ -327,7 +329,7 @@ void dvma_unmap(void *baddr)
327 return; 329 return;
328 330
329} 331}
330 332EXPORT_SYMBOL(dvma_unmap);
331 333
332void *dvma_malloc_align(unsigned long len, unsigned long align) 334void *dvma_malloc_align(unsigned long len, unsigned long align)
333{ 335{
@@ -367,6 +369,7 @@ void *dvma_malloc_align(unsigned long len, unsigned long align)
367 return (void *)vaddr; 369 return (void *)vaddr;
368 370
369} 371}
372EXPORT_SYMBOL(dvma_malloc_align);
370 373
371void dvma_free(void *vaddr) 374void dvma_free(void *vaddr)
372{ 375{
@@ -374,3 +377,4 @@ void dvma_free(void *vaddr)
374 return; 377 return;
375 378
376} 379}
380EXPORT_SYMBOL(dvma_free);
diff --git a/arch/m68knommu/kernel/setup.c b/arch/m68knommu/kernel/setup.c
index bde9811cf98c..7b21959eaeae 100644
--- a/arch/m68knommu/kernel/setup.c
+++ b/arch/m68knommu/kernel/setup.c
@@ -62,7 +62,7 @@ int (*mach_kbdrate) (struct kbd_repeat *);
62void (*mach_kbd_leds) (unsigned int); 62void (*mach_kbd_leds) (unsigned int);
63/* machine dependent irq functions */ 63/* machine dependent irq functions */
64void (*mach_init_IRQ) (void); 64void (*mach_init_IRQ) (void);
65irqreturn_t (*(*mach_default_handler)[]) (int, void *, struct pt_regs *); 65irq_handler_t mach_default_handler;
66int (*mach_get_irq_list) (struct seq_file *, void *); 66int (*mach_get_irq_list) (struct seq_file *, void *);
67void (*mach_process_int) (int irq, struct pt_regs *fp); 67void (*mach_process_int) (int irq, struct pt_regs *fp);
68void (*mach_trap_init) (void); 68void (*mach_trap_init) (void);
diff --git a/arch/m68knommu/kernel/syscalltable.S b/arch/m68knommu/kernel/syscalltable.S
index 617e43ec95ae..4603f4f3c935 100644
--- a/arch/m68knommu/kernel/syscalltable.S
+++ b/arch/m68knommu/kernel/syscalltable.S
@@ -296,10 +296,39 @@ ENTRY(sys_call_table)
296 .long sys_mq_notify /* 275 */ 296 .long sys_mq_notify /* 275 */
297 .long sys_mq_getsetattr 297 .long sys_mq_getsetattr
298 .long sys_waitid 298 .long sys_waitid
299 .long sys_ni_syscall /* sys_setaltroot */ 299 .long sys_ni_syscall /* for sys_vserver */
300 .long sys_ni_syscall /* sys_add_key */ 300 .long sys_add_key
301 .long sys_ni_syscall /* 280 */ /* sys_request_key */ 301 .long sys_request_key /* 280 */
302 .long sys_ni_syscall /* sys_keyctl */ 302 .long sys_keyctl
303 .long sys_ioprio_set
304 .long sys_ioprio_get
305 .long sys_inotify_init
306 .long sys_inotify_add_watch /* 285 */
307 .long sys_inotify_rm_watch
308 .long sys_migrate_pages
309 .long sys_openat
310 .long sys_mkdirat
311 .long sys_mknodat /* 290 */
312 .long sys_fchownat
313 .long sys_futimesat
314 .long sys_fstatat64
315 .long sys_unlinkat
316 .long sys_renameat /* 295 */
317 .long sys_linkat
318 .long sys_symlinkat
319 .long sys_readlinkat
320 .long sys_fchmodat
321 .long sys_faccessat /* 300 */
322 .long sys_ni_syscall /* Reserved for pselect6 */
323 .long sys_ni_syscall /* Reserved for ppoll */
324 .long sys_unshare
325 .long sys_set_robust_list
326 .long sys_get_robust_list /* 305 */
327 .long sys_splice
328 .long sys_sync_file_range
329 .long sys_tee
330 .long sys_vmsplice
331 .long sys_move_pages /* 310 */
303 332
304 .rept NR_syscalls-(.-sys_call_table)/4 333 .rept NR_syscalls-(.-sys_call_table)/4
305 .long sys_ni_syscall 334 .long sys_ni_syscall
diff --git a/arch/m68knommu/kernel/time.c b/arch/m68knommu/kernel/time.c
index c5667bdddd5e..9226264abf1a 100644
--- a/arch/m68knommu/kernel/time.c
+++ b/arch/m68knommu/kernel/time.c
@@ -54,7 +54,7 @@ static irqreturn_t timer_interrupt(int irq, void *dummy, struct pt_regs * regs)
54 update_process_times(user_mode(regs)); 54 update_process_times(user_mode(regs));
55#endif 55#endif
56 if (current->pid) 56 if (current->pid)
57 profile_tick(CPU_PROFILING, regs); 57 profile_tick(CPU_PROFILING);
58 58
59 /* 59 /*
60 * If we have an externally synchronized Linux clock, then update 60 * If we have an externally synchronized Linux clock, then update
diff --git a/arch/m68knommu/kernel/vmlinux.lds.S b/arch/m68knommu/kernel/vmlinux.lds.S
index ccd2ceb05cfb..58afa8be604e 100644
--- a/arch/m68knommu/kernel/vmlinux.lds.S
+++ b/arch/m68knommu/kernel/vmlinux.lds.S
@@ -140,13 +140,7 @@ SECTIONS {
140 *(.init.setup) 140 *(.init.setup)
141 __setup_end = .; 141 __setup_end = .;
142 __initcall_start = .; 142 __initcall_start = .;
143 *(.initcall1.init) 143 INITCALLS
144 *(.initcall2.init)
145 *(.initcall3.init)
146 *(.initcall4.init)
147 *(.initcall5.init)
148 *(.initcall6.init)
149 *(.initcall7.init)
150 __initcall_end = .; 144 __initcall_end = .;
151 __con_initcall_start = .; 145 __con_initcall_start = .;
152 *(.con_initcall.init) 146 *(.con_initcall.init)
diff --git a/arch/m68knommu/platform/5307/ints.c b/arch/m68knommu/platform/5307/ints.c
index b4b55093ae7e..a57239ec6c8c 100644
--- a/arch/m68knommu/platform/5307/ints.c
+++ b/arch/m68knommu/platform/5307/ints.c
@@ -33,7 +33,7 @@
33/* 33/*
34 * This table stores the address info for each vector handler. 34 * This table stores the address info for each vector handler.
35 */ 35 */
36irq_handler_t irq_list[SYS_IRQS]; 36struct irq_entry irq_list[SYS_IRQS];
37 37
38#define NUM_IRQ_NODES 16 38#define NUM_IRQ_NODES 16
39static irq_node_t nodes[NUM_IRQ_NODES]; 39static irq_node_t nodes[NUM_IRQ_NODES];
@@ -44,7 +44,7 @@ volatile unsigned int num_spurious;
44unsigned int local_bh_count[NR_CPUS]; 44unsigned int local_bh_count[NR_CPUS];
45unsigned int local_irq_count[NR_CPUS]; 45unsigned int local_irq_count[NR_CPUS];
46 46
47static irqreturn_t default_irq_handler(int irq, void *ptr, struct pt_regs *regs) 47static irqreturn_t default_irq_handler(int irq, void *ptr)
48{ 48{
49#if 1 49#if 1
50 printk(KERN_INFO "%s(%d): default irq handler vec=%d [0x%x]\n", 50 printk(KERN_INFO "%s(%d): default irq handler vec=%d [0x%x]\n",
@@ -70,7 +70,7 @@ void __init init_IRQ(void)
70 70
71 for (i = 0; i < SYS_IRQS; i++) { 71 for (i = 0; i < SYS_IRQS; i++) {
72 if (mach_default_handler) 72 if (mach_default_handler)
73 irq_list[i].handler = (*mach_default_handler)[i]; 73 irq_list[i].handler = mach_default_handler;
74 else 74 else
75 irq_list[i].handler = default_irq_handler; 75 irq_list[i].handler = default_irq_handler;
76 irq_list[i].flags = IRQ_FLG_STD; 76 irq_list[i].flags = IRQ_FLG_STD;
@@ -100,7 +100,7 @@ irq_node_t *new_irq_node(void)
100 100
101int request_irq( 101int request_irq(
102 unsigned int irq, 102 unsigned int irq,
103 irqreturn_t (*handler)(int, void *, struct pt_regs *), 103 irq_handler_t handler,
104 unsigned long flags, 104 unsigned long flags,
105 const char *devname, 105 const char *devname,
106 void *dev_id) 106 void *dev_id)
@@ -157,7 +157,7 @@ void free_irq(unsigned int irq, void *dev_id)
157 } 157 }
158 158
159 if (mach_default_handler) 159 if (mach_default_handler)
160 irq_list[irq].handler = (*mach_default_handler)[irq]; 160 irq_list[irq].handler = mach_default_handler;
161 else 161 else
162 irq_list[irq].handler = default_irq_handler; 162 irq_list[irq].handler = default_irq_handler;
163 irq_list[irq].flags = IRQ_FLG_STD; 163 irq_list[irq].flags = IRQ_FLG_STD;
@@ -168,8 +168,7 @@ void free_irq(unsigned int irq, void *dev_id)
168EXPORT_SYMBOL(free_irq); 168EXPORT_SYMBOL(free_irq);
169 169
170 170
171int sys_request_irq(unsigned int irq, 171int sys_request_irq(unsigned int irq, irq_handler_t handler,
172 irqreturn_t (*handler)(int, void *, struct pt_regs *),
173 unsigned long flags, const char *devname, void *dev_id) 172 unsigned long flags, const char *devname, void *dev_id)
174{ 173{
175 if (irq > IRQ7) { 174 if (irq > IRQ7) {
@@ -211,7 +210,7 @@ void sys_free_irq(unsigned int irq, void *dev_id)
211 printk(KERN_WARNING "%s: Removing probably wrong IRQ %d from %s\n", 210 printk(KERN_WARNING "%s: Removing probably wrong IRQ %d from %s\n",
212 __FUNCTION__, irq, irq_list[irq].devname); 211 __FUNCTION__, irq, irq_list[irq].devname);
213 212
214 irq_list[irq].handler = (*mach_default_handler)[irq]; 213 irq_list[irq].handler = mach_default_handler;
215 irq_list[irq].flags = 0; 214 irq_list[irq].flags = 0;
216 irq_list[irq].dev_id = NULL; 215 irq_list[irq].dev_id = NULL;
217 irq_list[irq].devname = NULL; 216 irq_list[irq].devname = NULL;
@@ -241,7 +240,7 @@ asmlinkage void process_int(unsigned long vec, struct pt_regs *fp)
241 if (vec >= VEC_INT1 && vec <= VEC_INT7) { 240 if (vec >= VEC_INT1 && vec <= VEC_INT7) {
242 vec -= VEC_SPUR; 241 vec -= VEC_SPUR;
243 kstat_cpu(0).irqs[vec]++; 242 kstat_cpu(0).irqs[vec]++;
244 irq_list[vec].handler(vec, irq_list[vec].dev_id, fp); 243 irq_list[vec].handler(vec, irq_list[vec].dev_id);
245 } else { 244 } else {
246 if (mach_process_int) 245 if (mach_process_int)
247 mach_process_int(vec, fp); 246 mach_process_int(vec, fp);
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 14af6cce2fa2..1443024b1c7c 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -425,9 +425,8 @@ config MOMENCO_OCELOT_G
425 select SWAP_IO_SPACE 425 select SWAP_IO_SPACE
426 select SYS_HAS_CPU_RM7000 426 select SYS_HAS_CPU_RM7000
427 select SYS_SUPPORTS_32BIT_KERNEL 427 select SYS_SUPPORTS_32BIT_KERNEL
428 select SYS_SUPPORTS_64BIT_KERNEL 428 select SYS_SUPPORTS_64BIT_KERNEL if BROKEN
429 select SYS_SUPPORTS_BIG_ENDIAN 429 select SYS_SUPPORTS_BIG_ENDIAN
430 select ARCH_SPARSEMEM_ENABLE
431 help 430 help
432 The Ocelot is a MIPS-based Single Board Computer (SBC) made by 431 The Ocelot is a MIPS-based Single Board Computer (SBC) made by
433 Momentum Computer <http://www.momenco.com/>. 432 Momentum Computer <http://www.momenco.com/>.
@@ -560,6 +559,7 @@ config SGI_IP27
560 select SYS_SUPPORTS_64BIT_KERNEL 559 select SYS_SUPPORTS_64BIT_KERNEL
561 select SYS_SUPPORTS_BIG_ENDIAN 560 select SYS_SUPPORTS_BIG_ENDIAN
562 select SYS_SUPPORTS_NUMA 561 select SYS_SUPPORTS_NUMA
562 select SYS_SUPPORTS_SMP
563 help 563 help
564 This are the SGI Origin 200, Origin 2000 and Onyx 2 Graphics 564 This are the SGI Origin 200, Origin 2000 and Onyx 2 Graphics
565 workstations. To compile a Linux kernel that runs on these, say Y 565 workstations. To compile a Linux kernel that runs on these, say Y
@@ -1633,9 +1633,6 @@ config ARCH_DISCONTIGMEM_ENABLE
1633 1633
1634config ARCH_SPARSEMEM_ENABLE 1634config ARCH_SPARSEMEM_ENABLE
1635 bool 1635 bool
1636
1637config ARCH_SPARSEMEM_ENABLE
1638 bool
1639 select SPARSEMEM_STATIC 1636 select SPARSEMEM_STATIC
1640 1637
1641config NUMA 1638config NUMA
@@ -1690,6 +1687,7 @@ config NR_CPUS
1690 depends on SMP 1687 depends on SMP
1691 default "64" if SGI_IP27 1688 default "64" if SGI_IP27
1692 default "2" 1689 default "2"
1690 default "8" if MIPS_MT_SMTC
1693 help 1691 help
1694 This allows you to specify the maximum number of CPUs which this 1692 This allows you to specify the maximum number of CPUs which this
1695 kernel will support. The maximum supported value is 32 for 32-bit 1693 kernel will support. The maximum supported value is 32 for 32-bit
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 2124350ab94d..d580d46f967b 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -63,7 +63,9 @@ cflags-y += -mabi=64
63ifdef CONFIG_BUILD_ELF64 63ifdef CONFIG_BUILD_ELF64
64cflags-y += $(call cc-option,-mno-explicit-relocs) 64cflags-y += $(call cc-option,-mno-explicit-relocs)
65else 65else
66cflags-y += $(call cc-option,-msym32) 66# -msym32 can not be used for modules since they are loaded into XKSEG
67CFLAGS_MODULE += $(call cc-option,-mno-explicit-relocs)
68CFLAGS_KERNEL += $(call cc-option,-msym32)
67endif 69endif
68endif 70endif
69 71
@@ -91,8 +93,17 @@ cflags-y += -ffreestanding
91# carefully avoid to add it redundantly because gcc 3.3/3.4 complains 93# carefully avoid to add it redundantly because gcc 3.3/3.4 complains
92# when fed the toolchain default! 94# when fed the toolchain default!
93# 95#
94cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' && echo -EB -D__MIPSEB__) 96# Certain gcc versions upto gcc 4.1.1 (probably 4.2-subversion as of
95cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' || echo -EL -D__MIPSEL__) 97# 2006-10-10 don't properly change the the predefined symbols if -EB / -EL
98# are used, so we kludge that here. A bug has been filed at
99# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29413.
100#
101undef-all += -UMIPSEB -U_MIPSEB -U__MIPSEB -U__MIPSEB__
102undef-all += -UMIPSEL -U_MIPSEL -U__MIPSEL -U__MIPSEL__
103predef-be += -DMIPSEB -D_MIPSEB -D__MIPSEB -D__MIPSEB__
104predef-le += -DMIPSEL -D_MIPSEL -D__MIPSEL -D__MIPSEL__
105cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' && echo -EB $(undef-all) $(predef-be))
106cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' || echo -EL $(undef-all) $(predef-le))
96 107
97cflags-$(CONFIG_SB1XXX_CORELIS) += $(call cc-option,-mno-sched-prolog) \ 108cflags-$(CONFIG_SB1XXX_CORELIS) += $(call cc-option,-mno-sched-prolog) \
98 -fno-omit-frame-pointer 109 -fno-omit-frame-pointer
diff --git a/arch/mips/au1000/common/dbdma.c b/arch/mips/au1000/common/dbdma.c
index c4fae8ff4671..626de44bd888 100644
--- a/arch/mips/au1000/common/dbdma.c
+++ b/arch/mips/au1000/common/dbdma.c
@@ -849,7 +849,7 @@ au1xxx_dbdma_chan_free(u32 chanid)
849EXPORT_SYMBOL(au1xxx_dbdma_chan_free); 849EXPORT_SYMBOL(au1xxx_dbdma_chan_free);
850 850
851static irqreturn_t 851static irqreturn_t
852dbdma_interrupt(int irq, void *dev_id, struct pt_regs *regs) 852dbdma_interrupt(int irq, void *dev_id)
853{ 853{
854 u32 intstat; 854 u32 intstat;
855 u32 chan_index; 855 u32 chan_index;
diff --git a/arch/mips/au1000/common/prom.c b/arch/mips/au1000/common/prom.c
index b4b010a2fe36..6fce60af005d 100644
--- a/arch/mips/au1000/common/prom.c
+++ b/arch/mips/au1000/common/prom.c
@@ -47,7 +47,7 @@ extern int prom_argc;
47extern char **prom_argv, **prom_envp; 47extern char **prom_argv, **prom_envp;
48 48
49 49
50char * prom_getcmdline(void) 50char * __init_or_module prom_getcmdline(void)
51{ 51{
52 return &(arcs_cmdline[0]); 52 return &(arcs_cmdline[0]);
53} 53}
diff --git a/arch/mips/au1000/common/setup.c b/arch/mips/au1000/common/setup.c
index 377ae0d8ff00..919172db560c 100644
--- a/arch/mips/au1000/common/setup.c
+++ b/arch/mips/au1000/common/setup.c
@@ -43,7 +43,7 @@
43#include <asm/mach-au1x00/au1000.h> 43#include <asm/mach-au1x00/au1000.h>
44#include <asm/time.h> 44#include <asm/time.h>
45 45
46extern char * __init prom_getcmdline(void); 46extern char * prom_getcmdline(void);
47extern void __init board_setup(void); 47extern void __init board_setup(void);
48extern void au1000_restart(char *); 48extern void au1000_restart(char *);
49extern void au1000_halt(void); 49extern void au1000_halt(void);
diff --git a/arch/mips/au1000/common/time.c b/arch/mips/au1000/common/time.c
index 94f09194d63d..fa1c62f05515 100644
--- a/arch/mips/au1000/common/time.c
+++ b/arch/mips/au1000/common/time.c
@@ -53,9 +53,6 @@ static unsigned long r4k_cur; /* What counter should be at next timer irq */
53int no_au1xxx_32khz; 53int no_au1xxx_32khz;
54extern int allow_au1k_wait; /* default off for CP0 Counter */ 54extern int allow_au1k_wait; /* default off for CP0 Counter */
55 55
56/* Cycle counter value at the previous timer interrupt.. */
57static unsigned int timerhi = 0, timerlo = 0;
58
59#ifdef CONFIG_PM 56#ifdef CONFIG_PM
60#if HZ < 100 || HZ > 1000 57#if HZ < 100 || HZ > 1000
61#error "unsupported HZ value! Must be in [100,1000]" 58#error "unsupported HZ value! Must be in [100,1000]"
@@ -82,7 +79,6 @@ unsigned long wtimer;
82void mips_timer_interrupt(void) 79void mips_timer_interrupt(void)
83{ 80{
84 int irq = 63; 81 int irq = 63;
85 unsigned long count;
86 82
87 irq_enter(); 83 irq_enter();
88 kstat_this_cpu.irqs[irq]++; 84 kstat_this_cpu.irqs[irq]++;
@@ -91,10 +87,6 @@ void mips_timer_interrupt(void)
91 goto null; 87 goto null;
92 88
93 do { 89 do {
94 count = read_c0_count();
95 timerhi += (count < timerlo); /* Wrap around */
96 timerlo = count;
97
98 kstat_this_cpu.irqs[irq]++; 90 kstat_this_cpu.irqs[irq]++;
99 do_timer(1); 91 do_timer(1);
100#ifndef CONFIG_SMP 92#ifndef CONFIG_SMP
@@ -231,7 +223,6 @@ wakeup_counter0_set(int ticks)
231 */ 223 */
232unsigned long cal_r4koff(void) 224unsigned long cal_r4koff(void)
233{ 225{
234 unsigned long count;
235 unsigned long cpu_speed; 226 unsigned long cpu_speed;
236 unsigned long flags; 227 unsigned long flags;
237 unsigned long counter; 228 unsigned long counter;
@@ -258,7 +249,7 @@ unsigned long cal_r4koff(void)
258 249
259#if defined(CONFIG_AU1000_USE32K) 250#if defined(CONFIG_AU1000_USE32K)
260 { 251 {
261 unsigned long start, end; 252 unsigned long start, end, count;
262 253
263 start = au_readl(SYS_RTCREAD); 254 start = au_readl(SYS_RTCREAD);
264 start += 2; 255 start += 2;
@@ -282,7 +273,6 @@ unsigned long cal_r4koff(void)
282#else 273#else
283 cpu_speed = (au_readl(SYS_CPUPLL) & 0x0000003f) * 274 cpu_speed = (au_readl(SYS_CPUPLL) & 0x0000003f) *
284 AU1000_SRC_CLK; 275 AU1000_SRC_CLK;
285 count = cpu_speed / 2;
286#endif 276#endif
287 } 277 }
288 else { 278 else {
@@ -291,98 +281,15 @@ unsigned long cal_r4koff(void)
291 * NOTE: some old silicon doesn't allow reading the PLL. 281 * NOTE: some old silicon doesn't allow reading the PLL.
292 */ 282 */
293 cpu_speed = (au_readl(SYS_CPUPLL) & 0x0000003f) * AU1000_SRC_CLK; 283 cpu_speed = (au_readl(SYS_CPUPLL) & 0x0000003f) * AU1000_SRC_CLK;
294 count = cpu_speed / 2;
295 no_au1xxx_32khz = 1; 284 no_au1xxx_32khz = 1;
296 } 285 }
297 mips_hpt_frequency = count; 286 mips_hpt_frequency = cpu_speed;
298 // Equation: Baudrate = CPU / (SD * 2 * CLKDIV * 16) 287 // Equation: Baudrate = CPU / (SD * 2 * CLKDIV * 16)
299 set_au1x00_uart_baud_base(cpu_speed / (2 * ((int)(au_readl(SYS_POWERCTRL)&0x03) + 2) * 16)); 288 set_au1x00_uart_baud_base(cpu_speed / (2 * ((int)(au_readl(SYS_POWERCTRL)&0x03) + 2) * 16));
300 spin_unlock_irqrestore(&time_lock, flags); 289 spin_unlock_irqrestore(&time_lock, flags);
301 return (cpu_speed / HZ); 290 return (cpu_speed / HZ);
302} 291}
303 292
304/* This is for machines which generate the exact clock. */
305#define USECS_PER_JIFFY (1000000/HZ)
306#define USECS_PER_JIFFY_FRAC (0x100000000LL*1000000/HZ&0xffffffff)
307
308static unsigned long
309div64_32(unsigned long v1, unsigned long v2, unsigned long v3)
310{
311 unsigned long r0;
312 do_div64_32(r0, v1, v2, v3);
313 return r0;
314}
315
316static unsigned long do_fast_cp0_gettimeoffset(void)
317{
318 u32 count;
319 unsigned long res, tmp;
320 unsigned long r0;
321
322 /* Last jiffy when do_fast_gettimeoffset() was called. */
323 static unsigned long last_jiffies=0;
324 unsigned long quotient;
325
326 /*
327 * Cached "1/(clocks per usec)*2^32" value.
328 * It has to be recalculated once each jiffy.
329 */
330 static unsigned long cached_quotient=0;
331
332 tmp = jiffies;
333
334 quotient = cached_quotient;
335
336 if (tmp && last_jiffies != tmp) {
337 last_jiffies = tmp;
338 if (last_jiffies != 0) {
339 r0 = div64_32(timerhi, timerlo, tmp);
340 quotient = div64_32(USECS_PER_JIFFY, USECS_PER_JIFFY_FRAC, r0);
341 cached_quotient = quotient;
342 }
343 }
344
345 /* Get last timer tick in absolute kernel time */
346 count = read_c0_count();
347
348 /* .. relative to previous jiffy (32 bits is enough) */
349 count -= timerlo;
350
351 __asm__("multu\t%1,%2\n\t"
352 "mfhi\t%0"
353 : "=r" (res)
354 : "r" (count), "r" (quotient)
355 : "hi", "lo", GCC_REG_ACCUM);
356
357 /*
358 * Due to possible jiffies inconsistencies, we need to check
359 * the result so that we'll get a timer that is monotonic.
360 */
361 if (res >= USECS_PER_JIFFY)
362 res = USECS_PER_JIFFY-1;
363
364 return res;
365}
366
367#ifdef CONFIG_PM
368static unsigned long do_fast_pm_gettimeoffset(void)
369{
370 unsigned long pc0;
371 unsigned long offset;
372
373 pc0 = au_readl(SYS_TOYREAD);
374 au_sync();
375 offset = pc0 - last_pc0;
376 if (offset > 2*MATCH20_INC) {
377 printk("huge offset %x, last_pc0 %x last_match20 %x pc0 %x\n",
378 (unsigned)offset, (unsigned)last_pc0,
379 (unsigned)last_match20, (unsigned)pc0);
380 }
381 offset = (unsigned long)((offset * 305) / 10);
382 return offset;
383}
384#endif
385
386void __init plat_timer_setup(struct irqaction *irq) 293void __init plat_timer_setup(struct irqaction *irq)
387{ 294{
388 unsigned int est_freq; 295 unsigned int est_freq;
@@ -420,7 +327,6 @@ void __init plat_timer_setup(struct irqaction *irq)
420 unsigned int c0_status; 327 unsigned int c0_status;
421 328
422 printk("WARNING: no 32KHz clock found.\n"); 329 printk("WARNING: no 32KHz clock found.\n");
423 do_gettimeoffset = do_fast_cp0_gettimeoffset;
424 330
425 /* Ensure we get CPO_COUNTER interrupts. 331 /* Ensure we get CPO_COUNTER interrupts.
426 */ 332 */
@@ -445,19 +351,11 @@ void __init plat_timer_setup(struct irqaction *irq)
445 while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_M20); 351 while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_M20);
446 startup_match20_interrupt(counter0_irq); 352 startup_match20_interrupt(counter0_irq);
447 353
448 do_gettimeoffset = do_fast_pm_gettimeoffset;
449
450 /* We can use the real 'wait' instruction. 354 /* We can use the real 'wait' instruction.
451 */ 355 */
452 allow_au1k_wait = 1; 356 allow_au1k_wait = 1;
453 } 357 }
454 358
455#else
456 /* We have to do this here instead of in timer_init because
457 * the generic code in arch/mips/kernel/time.c will write
458 * over our function pointer.
459 */
460 do_gettimeoffset = do_fast_cp0_gettimeoffset;
461#endif 359#endif
462} 360}
463 361
diff --git a/arch/mips/configs/bigsur_defconfig b/arch/mips/configs/bigsur_defconfig
index c6a015940b41..ba3bf733d27d 100644
--- a/arch/mips/configs/bigsur_defconfig
+++ b/arch/mips/configs/bigsur_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.18-rc1 3# Linux kernel version: 2.6.19-rc1
4# Thu Jul 6 10:02:58 2006 4# Wed Oct 11 01:41:41 2006
5# 5#
6CONFIG_MIPS=y 6CONFIG_MIPS=y
7 7
@@ -25,8 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_IVR is not set
29# CONFIG_MIPS_ITE8172 is not set
30# CONFIG_MACH_JAZZ is not set 28# CONFIG_MACH_JAZZ is not set
31# CONFIG_LASAT is not set 29# CONFIG_LASAT is not set
32# CONFIG_MIPS_ATLAS is not set 30# CONFIG_MIPS_ATLAS is not set
@@ -83,6 +81,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
83CONFIG_GENERIC_FIND_NEXT_BIT=y 81CONFIG_GENERIC_FIND_NEXT_BIT=y
84CONFIG_GENERIC_HWEIGHT=y 82CONFIG_GENERIC_HWEIGHT=y
85CONFIG_GENERIC_CALIBRATE_DELAY=y 83CONFIG_GENERIC_CALIBRATE_DELAY=y
84CONFIG_GENERIC_TIME=y
86CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y 85CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
87CONFIG_DMA_COHERENT=y 86CONFIG_DMA_COHERENT=y
88CONFIG_CPU_BIG_ENDIAN=y 87CONFIG_CPU_BIG_ENDIAN=y
@@ -132,8 +131,8 @@ CONFIG_PAGE_SIZE_4KB=y
132# CONFIG_PAGE_SIZE_64KB is not set 131# CONFIG_PAGE_SIZE_64KB is not set
133# CONFIG_SIBYTE_DMA_PAGEOPS is not set 132# CONFIG_SIBYTE_DMA_PAGEOPS is not set
134CONFIG_MIPS_MT_DISABLED=y 133CONFIG_MIPS_MT_DISABLED=y
135# CONFIG_MIPS_MT_SMTC is not set
136# CONFIG_MIPS_MT_SMP is not set 134# CONFIG_MIPS_MT_SMP is not set
135# CONFIG_MIPS_MT_SMTC is not set
137# CONFIG_MIPS_VPE_LOADER is not set 136# CONFIG_MIPS_VPE_LOADER is not set
138CONFIG_CPU_HAS_LLSC=y 137CONFIG_CPU_HAS_LLSC=y
139CONFIG_CPU_HAS_SYNC=y 138CONFIG_CPU_HAS_SYNC=y
@@ -185,9 +184,11 @@ CONFIG_LOCALVERSION=""
185CONFIG_LOCALVERSION_AUTO=y 184CONFIG_LOCALVERSION_AUTO=y
186CONFIG_SWAP=y 185CONFIG_SWAP=y
187CONFIG_SYSVIPC=y 186CONFIG_SYSVIPC=y
187# CONFIG_IPC_NS is not set
188# CONFIG_POSIX_MQUEUE is not set 188# CONFIG_POSIX_MQUEUE is not set
189# CONFIG_BSD_PROCESS_ACCT is not set 189# CONFIG_BSD_PROCESS_ACCT is not set
190CONFIG_SYSCTL=y 190# CONFIG_TASKSTATS is not set
191# CONFIG_UTS_NS is not set
191# CONFIG_AUDIT is not set 192# CONFIG_AUDIT is not set
192CONFIG_IKCONFIG=y 193CONFIG_IKCONFIG=y
193CONFIG_IKCONFIG_PROC=y 194CONFIG_IKCONFIG_PROC=y
@@ -195,7 +196,9 @@ CONFIG_IKCONFIG_PROC=y
195# CONFIG_RELAY is not set 196# CONFIG_RELAY is not set
196CONFIG_INITRAMFS_SOURCE="" 197CONFIG_INITRAMFS_SOURCE=""
197# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 198# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
199CONFIG_SYSCTL=y
198CONFIG_EMBEDDED=y 200CONFIG_EMBEDDED=y
201# CONFIG_SYSCTL_SYSCALL is not set
199CONFIG_KALLSYMS=y 202CONFIG_KALLSYMS=y
200# CONFIG_KALLSYMS_ALL is not set 203# CONFIG_KALLSYMS_ALL is not set
201# CONFIG_KALLSYMS_EXTRA_PASS is not set 204# CONFIG_KALLSYMS_EXTRA_PASS is not set
@@ -204,12 +207,12 @@ CONFIG_PRINTK=y
204CONFIG_BUG=y 207CONFIG_BUG=y
205CONFIG_ELF_CORE=y 208CONFIG_ELF_CORE=y
206CONFIG_BASE_FULL=y 209CONFIG_BASE_FULL=y
207CONFIG_RT_MUTEXES=y
208CONFIG_FUTEX=y 210CONFIG_FUTEX=y
209CONFIG_EPOLL=y 211CONFIG_EPOLL=y
210CONFIG_SHMEM=y 212CONFIG_SHMEM=y
211CONFIG_SLAB=y 213CONFIG_SLAB=y
212CONFIG_VM_EVENT_COUNTERS=y 214CONFIG_VM_EVENT_COUNTERS=y
215CONFIG_RT_MUTEXES=y
213# CONFIG_TINY_SHMEM is not set 216# CONFIG_TINY_SHMEM is not set
214CONFIG_BASE_SMALL=0 217CONFIG_BASE_SMALL=0
215# CONFIG_SLOB is not set 218# CONFIG_SLOB is not set
@@ -228,6 +231,7 @@ CONFIG_STOP_MACHINE=y
228# 231#
229# Block layer 232# Block layer
230# 233#
234CONFIG_BLOCK=y
231# CONFIG_BLK_DEV_IO_TRACE is not set 235# CONFIG_BLK_DEV_IO_TRACE is not set
232 236
233# 237#
@@ -249,18 +253,17 @@ CONFIG_DEFAULT_IOSCHED="anticipatory"
249CONFIG_HW_HAS_PCI=y 253CONFIG_HW_HAS_PCI=y
250CONFIG_PCI=y 254CONFIG_PCI=y
251CONFIG_PCI_DOMAINS=y 255CONFIG_PCI_DOMAINS=y
256# CONFIG_PCI_MULTITHREAD_PROBE is not set
252CONFIG_PCI_DEBUG=y 257CONFIG_PCI_DEBUG=y
253CONFIG_MMU=y 258CONFIG_MMU=y
254 259
255# 260#
256# PCCARD (PCMCIA/CardBus) support 261# PCCARD (PCMCIA/CardBus) support
257# 262#
258# CONFIG_PCCARD is not set
259 263
260# 264#
261# PCI Hotplug Support 265# PCI Hotplug Support
262# 266#
263# CONFIG_HOTPLUG_PCI is not set
264 267
265# 268#
266# Executable file formats 269# Executable file formats
@@ -271,7 +274,7 @@ CONFIG_BINFMT_ELF=y
271CONFIG_MIPS32_COMPAT=y 274CONFIG_MIPS32_COMPAT=y
272CONFIG_COMPAT=y 275CONFIG_COMPAT=y
273CONFIG_MIPS32_O32=y 276CONFIG_MIPS32_O32=y
274# CONFIG_MIPS32_N32 is not set 277CONFIG_MIPS32_N32=y
275CONFIG_BINFMT_ELF32=y 278CONFIG_BINFMT_ELF32=y
276 279
277# 280#
@@ -288,6 +291,7 @@ CONFIG_PACKET_MMAP=y
288CONFIG_UNIX=y 291CONFIG_UNIX=y
289CONFIG_XFRM=y 292CONFIG_XFRM=y
290CONFIG_XFRM_USER=m 293CONFIG_XFRM_USER=m
294# CONFIG_XFRM_SUB_POLICY is not set
291CONFIG_NET_KEY=y 295CONFIG_NET_KEY=y
292CONFIG_INET=y 296CONFIG_INET=y
293# CONFIG_IP_MULTICAST is not set 297# CONFIG_IP_MULTICAST is not set
@@ -308,10 +312,12 @@ CONFIG_IP_PNP_BOOTP=y
308# CONFIG_INET_TUNNEL is not set 312# CONFIG_INET_TUNNEL is not set
309CONFIG_INET_XFRM_MODE_TRANSPORT=m 313CONFIG_INET_XFRM_MODE_TRANSPORT=m
310CONFIG_INET_XFRM_MODE_TUNNEL=m 314CONFIG_INET_XFRM_MODE_TUNNEL=m
315CONFIG_INET_XFRM_MODE_BEET=y
311CONFIG_INET_DIAG=y 316CONFIG_INET_DIAG=y
312CONFIG_INET_TCP_DIAG=y 317CONFIG_INET_TCP_DIAG=y
313# CONFIG_TCP_CONG_ADVANCED is not set 318# CONFIG_TCP_CONG_ADVANCED is not set
314CONFIG_TCP_CONG_BIC=y 319CONFIG_TCP_CONG_CUBIC=y
320CONFIG_DEFAULT_TCP_CONG="cubic"
315# CONFIG_IPV6 is not set 321# CONFIG_IPV6 is not set
316# CONFIG_INET6_XFRM_TUNNEL is not set 322# CONFIG_INET6_XFRM_TUNNEL is not set
317# CONFIG_INET6_TUNNEL is not set 323# CONFIG_INET6_TUNNEL is not set
@@ -341,7 +347,6 @@ CONFIG_NETWORK_SECMARK=y
341# CONFIG_ATALK is not set 347# CONFIG_ATALK is not set
342# CONFIG_X25 is not set 348# CONFIG_X25 is not set
343# CONFIG_LAPB is not set 349# CONFIG_LAPB is not set
344# CONFIG_NET_DIVERT is not set
345# CONFIG_ECONET is not set 350# CONFIG_ECONET is not set
346# CONFIG_WAN_ROUTER is not set 351# CONFIG_WAN_ROUTER is not set
347 352
@@ -368,7 +373,6 @@ CONFIG_NETWORK_SECMARK=y
368# 373#
369CONFIG_STANDALONE=y 374CONFIG_STANDALONE=y
370CONFIG_PREVENT_FIRMWARE_BUILD=y 375CONFIG_PREVENT_FIRMWARE_BUILD=y
371# CONFIG_FW_LOADER is not set
372# CONFIG_DEBUG_DRIVER is not set 376# CONFIG_DEBUG_DRIVER is not set
373# CONFIG_SYS_HYPERVISOR is not set 377# CONFIG_SYS_HYPERVISOR is not set
374 378
@@ -404,7 +408,7 @@ CONFIG_BLK_DEV_LOOP=m
404CONFIG_BLK_DEV_NBD=m 408CONFIG_BLK_DEV_NBD=m
405# CONFIG_BLK_DEV_SX8 is not set 409# CONFIG_BLK_DEV_SX8 is not set
406# CONFIG_BLK_DEV_RAM is not set 410# CONFIG_BLK_DEV_RAM is not set
407# CONFIG_BLK_DEV_INITRD is not set 411CONFIG_BLK_DEV_INITRD=y
408# CONFIG_CDROM_PKTCDVD is not set 412# CONFIG_CDROM_PKTCDVD is not set
409# CONFIG_ATA_OVER_ETH is not set 413# CONFIG_ATA_OVER_ETH is not set
410 414
@@ -412,6 +416,7 @@ CONFIG_BLK_DEV_NBD=m
412# ATA/ATAPI/MFM/RLL support 416# ATA/ATAPI/MFM/RLL support
413# 417#
414CONFIG_IDE=y 418CONFIG_IDE=y
419CONFIG_IDE_MAX_HWIFS=4
415CONFIG_BLK_DEV_IDE=y 420CONFIG_BLK_DEV_IDE=y
416 421
417# 422#
@@ -429,10 +434,40 @@ CONFIG_BLK_DEV_IDEFLOPPY=y
429# IDE chipset support/bugfixes 434# IDE chipset support/bugfixes
430# 435#
431CONFIG_IDE_GENERIC=y 436CONFIG_IDE_GENERIC=y
432# CONFIG_BLK_DEV_IDEPCI is not set 437CONFIG_BLK_DEV_IDEPCI=y
438# CONFIG_IDEPCI_SHARE_IRQ is not set
439# CONFIG_BLK_DEV_OFFBOARD is not set
440CONFIG_BLK_DEV_GENERIC=y
441# CONFIG_BLK_DEV_OPTI621 is not set
442CONFIG_BLK_DEV_IDEDMA_PCI=y
443# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
444# CONFIG_IDEDMA_PCI_AUTO is not set
445# CONFIG_BLK_DEV_AEC62XX is not set
446# CONFIG_BLK_DEV_ALI15X3 is not set
447# CONFIG_BLK_DEV_AMD74XX is not set
448CONFIG_BLK_DEV_CMD64X=y
449# CONFIG_BLK_DEV_TRIFLEX is not set
450# CONFIG_BLK_DEV_CY82C693 is not set
451# CONFIG_BLK_DEV_CS5520 is not set
452# CONFIG_BLK_DEV_CS5530 is not set
453# CONFIG_BLK_DEV_HPT34X is not set
454# CONFIG_BLK_DEV_HPT366 is not set
455# CONFIG_BLK_DEV_JMICRON is not set
456# CONFIG_BLK_DEV_SC1200 is not set
457# CONFIG_BLK_DEV_PIIX is not set
458# CONFIG_BLK_DEV_IT821X is not set
459# CONFIG_BLK_DEV_NS87415 is not set
460# CONFIG_BLK_DEV_PDC202XX_OLD is not set
461# CONFIG_BLK_DEV_PDC202XX_NEW is not set
462# CONFIG_BLK_DEV_SVWKS is not set
463# CONFIG_BLK_DEV_SIIMAGE is not set
464# CONFIG_BLK_DEV_SLC90E66 is not set
465# CONFIG_BLK_DEV_TRM290 is not set
466# CONFIG_BLK_DEV_VIA82CXXX is not set
433# CONFIG_BLK_DEV_IDE_SWARM is not set 467# CONFIG_BLK_DEV_IDE_SWARM is not set
434# CONFIG_IDE_ARM is not set 468# CONFIG_IDE_ARM is not set
435# CONFIG_BLK_DEV_IDEDMA is not set 469CONFIG_BLK_DEV_IDEDMA=y
470# CONFIG_IDEDMA_IVB is not set
436# CONFIG_IDEDMA_AUTO is not set 471# CONFIG_IDEDMA_AUTO is not set
437# CONFIG_BLK_DEV_HD is not set 472# CONFIG_BLK_DEV_HD is not set
438 473
@@ -441,6 +476,12 @@ CONFIG_IDE_GENERIC=y
441# 476#
442# CONFIG_RAID_ATTRS is not set 477# CONFIG_RAID_ATTRS is not set
443# CONFIG_SCSI is not set 478# CONFIG_SCSI is not set
479# CONFIG_SCSI_NETLINK is not set
480
481#
482# Serial ATA (prod) and Parallel ATA (experimental) drivers
483#
484# CONFIG_ATA is not set
444 485
445# 486#
446# Multi-device support (RAID and LVM) 487# Multi-device support (RAID and LVM)
@@ -516,6 +557,7 @@ CONFIG_NET_SB1250_MAC=y
516# CONFIG_SK98LIN is not set 557# CONFIG_SK98LIN is not set
517# CONFIG_TIGON3 is not set 558# CONFIG_TIGON3 is not set
518# CONFIG_BNX2 is not set 559# CONFIG_BNX2 is not set
560# CONFIG_QLA3XXX is not set
519 561
520# 562#
521# Ethernet (10000 Mbit) 563# Ethernet (10000 Mbit)
@@ -650,7 +692,6 @@ CONFIG_I2C_CHARDEV=y
650# CONFIG_I2C_ALGOBIT is not set 692# CONFIG_I2C_ALGOBIT is not set
651# CONFIG_I2C_ALGOPCF is not set 693# CONFIG_I2C_ALGOPCF is not set
652# CONFIG_I2C_ALGOPCA is not set 694# CONFIG_I2C_ALGOPCA is not set
653CONFIG_I2C_ALGO_SIBYTE=y
654 695
655# 696#
656# I2C Hardware Bus support 697# I2C Hardware Bus support
@@ -712,12 +753,12 @@ CONFIG_I2C_DEBUG_CHIP=y
712# 753#
713# Misc devices 754# Misc devices
714# 755#
756# CONFIG_TIFM_CORE is not set
715 757
716# 758#
717# Multimedia devices 759# Multimedia devices
718# 760#
719# CONFIG_VIDEO_DEV is not set 761# CONFIG_VIDEO_DEV is not set
720CONFIG_VIDEO_V4L2=y
721 762
722# 763#
723# Digital Video Broadcasting Devices 764# Digital Video Broadcasting Devices
@@ -729,6 +770,7 @@ CONFIG_VIDEO_V4L2=y
729# 770#
730# CONFIG_FIRMWARE_EDID is not set 771# CONFIG_FIRMWARE_EDID is not set
731# CONFIG_FB is not set 772# CONFIG_FB is not set
773# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
732 774
733# 775#
734# Sound 776# Sound
@@ -811,6 +853,7 @@ CONFIG_FS_MBCACHE=y
811# CONFIG_JFS_FS is not set 853# CONFIG_JFS_FS is not set
812CONFIG_FS_POSIX_ACL=y 854CONFIG_FS_POSIX_ACL=y
813# CONFIG_XFS_FS is not set 855# CONFIG_XFS_FS is not set
856# CONFIG_GFS2_FS is not set
814# CONFIG_OCFS2_FS is not set 857# CONFIG_OCFS2_FS is not set
815# CONFIG_MINIX_FS is not set 858# CONFIG_MINIX_FS is not set
816# CONFIG_ROMFS_FS is not set 859# CONFIG_ROMFS_FS is not set
@@ -840,8 +883,10 @@ CONFIG_DNOTIFY=y
840# 883#
841CONFIG_PROC_FS=y 884CONFIG_PROC_FS=y
842CONFIG_PROC_KCORE=y 885CONFIG_PROC_KCORE=y
886CONFIG_PROC_SYSCTL=y
843CONFIG_SYSFS=y 887CONFIG_SYSFS=y
844# CONFIG_TMPFS is not set 888CONFIG_TMPFS=y
889# CONFIG_TMPFS_POSIX_ACL is not set
845# CONFIG_HUGETLB_PAGE is not set 890# CONFIG_HUGETLB_PAGE is not set
846CONFIG_RAMFS=y 891CONFIG_RAMFS=y
847# CONFIG_CONFIGFS_FS is not set 892# CONFIG_CONFIGFS_FS is not set
@@ -851,6 +896,7 @@ CONFIG_RAMFS=y
851# 896#
852# CONFIG_ADFS_FS is not set 897# CONFIG_ADFS_FS is not set
853# CONFIG_AFFS_FS is not set 898# CONFIG_AFFS_FS is not set
899# CONFIG_ECRYPT_FS is not set
854# CONFIG_HFS_FS is not set 900# CONFIG_HFS_FS is not set
855# CONFIG_HFSPLUS_FS is not set 901# CONFIG_HFSPLUS_FS is not set
856# CONFIG_BEFS_FS is not set 902# CONFIG_BEFS_FS is not set
@@ -881,7 +927,6 @@ CONFIG_SUNRPC=y
881# CONFIG_RPCSEC_GSS_SPKM3 is not set 927# CONFIG_RPCSEC_GSS_SPKM3 is not set
882# CONFIG_SMB_FS is not set 928# CONFIG_SMB_FS is not set
883# CONFIG_CIFS is not set 929# CONFIG_CIFS is not set
884# CONFIG_CIFS_DEBUG2 is not set
885# CONFIG_NCP_FS is not set 930# CONFIG_NCP_FS is not set
886# CONFIG_CODA_FS is not set 931# CONFIG_CODA_FS is not set
887# CONFIG_AFS_FS is not set 932# CONFIG_AFS_FS is not set
@@ -899,6 +944,10 @@ CONFIG_MSDOS_PARTITION=y
899# CONFIG_NLS is not set 944# CONFIG_NLS is not set
900 945
901# 946#
947# Distributed Lock Manager
948#
949
950#
902# Profiling support 951# Profiling support
903# 952#
904# CONFIG_PROFILING is not set 953# CONFIG_PROFILING is not set
@@ -907,7 +956,8 @@ CONFIG_MSDOS_PARTITION=y
907# Kernel hacking 956# Kernel hacking
908# 957#
909CONFIG_TRACE_IRQFLAGS_SUPPORT=y 958CONFIG_TRACE_IRQFLAGS_SUPPORT=y
910CONFIG_PRINTK_TIME=y 959# CONFIG_PRINTK_TIME is not set
960CONFIG_ENABLE_MUST_CHECK=y
911CONFIG_MAGIC_SYSRQ=y 961CONFIG_MAGIC_SYSRQ=y
912# CONFIG_UNUSED_SYMBOLS is not set 962# CONFIG_UNUSED_SYMBOLS is not set
913CONFIG_DEBUG_KERNEL=y 963CONFIG_DEBUG_KERNEL=y
@@ -920,12 +970,15 @@ CONFIG_DETECT_SOFTLOCKUP=y
920# CONFIG_DEBUG_SPINLOCK is not set 970# CONFIG_DEBUG_SPINLOCK is not set
921CONFIG_DEBUG_MUTEXES=y 971CONFIG_DEBUG_MUTEXES=y
922# CONFIG_DEBUG_RWSEMS is not set 972# CONFIG_DEBUG_RWSEMS is not set
973# CONFIG_DEBUG_LOCK_ALLOC is not set
974# CONFIG_PROVE_LOCKING is not set
923# CONFIG_DEBUG_SPINLOCK_SLEEP is not set 975# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
924# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set 976# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
925# CONFIG_DEBUG_KOBJECT is not set 977# CONFIG_DEBUG_KOBJECT is not set
926# CONFIG_DEBUG_INFO is not set 978# CONFIG_DEBUG_INFO is not set
927# CONFIG_DEBUG_FS is not set 979# CONFIG_DEBUG_FS is not set
928# CONFIG_DEBUG_VM is not set 980# CONFIG_DEBUG_VM is not set
981# CONFIG_DEBUG_LIST is not set
929CONFIG_FORCED_INLINING=y 982CONFIG_FORCED_INLINING=y
930# CONFIG_RCU_TORTURE_TEST is not set 983# CONFIG_RCU_TORTURE_TEST is not set
931CONFIG_CROSSCOMPILE=y 984CONFIG_CROSSCOMPILE=y
@@ -946,6 +999,10 @@ CONFIG_KEYS_DEBUG_PROC_KEYS=y
946# Cryptographic options 999# Cryptographic options
947# 1000#
948CONFIG_CRYPTO=y 1001CONFIG_CRYPTO=y
1002CONFIG_CRYPTO_ALGAPI=y
1003CONFIG_CRYPTO_BLKCIPHER=m
1004CONFIG_CRYPTO_HASH=y
1005CONFIG_CRYPTO_MANAGER=m
949CONFIG_CRYPTO_HMAC=y 1006CONFIG_CRYPTO_HMAC=y
950CONFIG_CRYPTO_NULL=y 1007CONFIG_CRYPTO_NULL=y
951CONFIG_CRYPTO_MD4=y 1008CONFIG_CRYPTO_MD4=y
@@ -955,9 +1012,12 @@ CONFIG_CRYPTO_SHA256=y
955CONFIG_CRYPTO_SHA512=y 1012CONFIG_CRYPTO_SHA512=y
956CONFIG_CRYPTO_WP512=m 1013CONFIG_CRYPTO_WP512=m
957CONFIG_CRYPTO_TGR192=m 1014CONFIG_CRYPTO_TGR192=m
1015CONFIG_CRYPTO_ECB=m
1016CONFIG_CRYPTO_CBC=m
958CONFIG_CRYPTO_DES=y 1017CONFIG_CRYPTO_DES=y
959CONFIG_CRYPTO_BLOWFISH=y 1018CONFIG_CRYPTO_BLOWFISH=y
960CONFIG_CRYPTO_TWOFISH=y 1019CONFIG_CRYPTO_TWOFISH=y
1020CONFIG_CRYPTO_TWOFISH_COMMON=y
961CONFIG_CRYPTO_SERPENT=y 1021CONFIG_CRYPTO_SERPENT=y
962CONFIG_CRYPTO_AES=m 1022CONFIG_CRYPTO_AES=m
963# CONFIG_CRYPTO_CAST5 is not set 1023# CONFIG_CRYPTO_CAST5 is not set
diff --git a/arch/mips/configs/pnx8550-jbs_defconfig b/arch/mips/configs/pnx8550-jbs_defconfig
index 26b0b9883496..280a8001eacf 100644
--- a/arch/mips/configs/pnx8550-jbs_defconfig
+++ b/arch/mips/configs/pnx8550-jbs_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.18-rc1 3# Linux kernel version: 2.6.19-rc2
4# Thu Jul 6 10:04:18 2006 4# Sat Oct 14 23:01:16 2006
5# 5#
6CONFIG_MIPS=y 6CONFIG_MIPS=y
7 7
@@ -25,8 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_IVR is not set
29# CONFIG_MIPS_ITE8172 is not set
30# CONFIG_MACH_JAZZ is not set 28# CONFIG_MACH_JAZZ is not set
31# CONFIG_LASAT is not set 29# CONFIG_LASAT is not set
32# CONFIG_MIPS_ATLAS is not set 30# CONFIG_MIPS_ATLAS is not set
@@ -41,13 +39,13 @@ CONFIG_MIPS=y
41# CONFIG_MOMENCO_OCELOT_G is not set 39# CONFIG_MOMENCO_OCELOT_G is not set
42# CONFIG_MIPS_XXS1500 is not set 40# CONFIG_MIPS_XXS1500 is not set
43# CONFIG_PNX8550_V2PCI is not set 41# CONFIG_PNX8550_V2PCI is not set
44# CONFIG_PNX8550_JBS is not set 42CONFIG_PNX8550_JBS=y
45# CONFIG_DDB5477 is not set 43# CONFIG_DDB5477 is not set
46# CONFIG_MACH_VR41XX is not set 44# CONFIG_MACH_VR41XX is not set
47# CONFIG_PMC_YOSEMITE is not set 45# CONFIG_PMC_YOSEMITE is not set
48# CONFIG_QEMU is not set 46# CONFIG_QEMU is not set
49# CONFIG_MARKEINS is not set 47# CONFIG_MARKEINS is not set
50CONFIG_SGI_IP22=y 48# CONFIG_SGI_IP22 is not set
51# CONFIG_SGI_IP27 is not set 49# CONFIG_SGI_IP27 is not set
52# CONFIG_SGI_IP32 is not set 50# CONFIG_SGI_IP32 is not set
53# CONFIG_SIBYTE_BIGSUR is not set 51# CONFIG_SIBYTE_BIGSUR is not set
@@ -67,25 +65,21 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
67CONFIG_GENERIC_FIND_NEXT_BIT=y 65CONFIG_GENERIC_FIND_NEXT_BIT=y
68CONFIG_GENERIC_HWEIGHT=y 66CONFIG_GENERIC_HWEIGHT=y
69CONFIG_GENERIC_CALIBRATE_DELAY=y 67CONFIG_GENERIC_CALIBRATE_DELAY=y
68CONFIG_GENERIC_TIME=y
70CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y 69CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
71CONFIG_ARC=y
72CONFIG_DMA_NONCOHERENT=y 70CONFIG_DMA_NONCOHERENT=y
73CONFIG_DMA_NEED_PCI_MAP_STATE=y 71CONFIG_DMA_NEED_PCI_MAP_STATE=y
74CONFIG_CPU_BIG_ENDIAN=y 72# CONFIG_CPU_BIG_ENDIAN is not set
75# CONFIG_CPU_LITTLE_ENDIAN is not set 73CONFIG_CPU_LITTLE_ENDIAN=y
76CONFIG_SYS_SUPPORTS_BIG_ENDIAN=y 74CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y
77CONFIG_IRQ_CPU=y 75CONFIG_PNX8550=y
78CONFIG_SWAP_IO_SPACE=y 76CONFIG_SOC_PNX8550=y
79CONFIG_ARC32=y
80CONFIG_BOOT_ELF32=y
81CONFIG_MIPS_L1_CACHE_SHIFT=5 77CONFIG_MIPS_L1_CACHE_SHIFT=5
82# CONFIG_ARC_CONSOLE is not set
83CONFIG_ARC_PROMLIB=y
84 78
85# 79#
86# CPU selection 80# CPU selection
87# 81#
88# CONFIG_CPU_MIPS32_R1 is not set 82CONFIG_CPU_MIPS32_R1=y
89# CONFIG_CPU_MIPS32_R2 is not set 83# CONFIG_CPU_MIPS32_R2 is not set
90# CONFIG_CPU_MIPS64_R1 is not set 84# CONFIG_CPU_MIPS64_R1 is not set
91# CONFIG_CPU_MIPS64_R2 is not set 85# CONFIG_CPU_MIPS64_R2 is not set
@@ -93,7 +87,7 @@ CONFIG_ARC_PROMLIB=y
93# CONFIG_CPU_TX39XX is not set 87# CONFIG_CPU_TX39XX is not set
94# CONFIG_CPU_VR41XX is not set 88# CONFIG_CPU_VR41XX is not set
95# CONFIG_CPU_R4300 is not set 89# CONFIG_CPU_R4300 is not set
96CONFIG_CPU_R4X00=y 90# CONFIG_CPU_R4X00 is not set
97# CONFIG_CPU_TX49XX is not set 91# CONFIG_CPU_TX49XX is not set
98# CONFIG_CPU_R5000 is not set 92# CONFIG_CPU_R5000 is not set
99# CONFIG_CPU_R5432 is not set 93# CONFIG_CPU_R5432 is not set
@@ -104,12 +98,11 @@ CONFIG_CPU_R4X00=y
104# CONFIG_CPU_RM7000 is not set 98# CONFIG_CPU_RM7000 is not set
105# CONFIG_CPU_RM9000 is not set 99# CONFIG_CPU_RM9000 is not set
106# CONFIG_CPU_SB1 is not set 100# CONFIG_CPU_SB1 is not set
107CONFIG_SYS_HAS_CPU_R4X00=y 101CONFIG_SYS_HAS_CPU_MIPS32_R1=y
108CONFIG_SYS_HAS_CPU_R5000=y 102CONFIG_CPU_MIPS32=y
103CONFIG_CPU_MIPSR1=y
109CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y 104CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
110CONFIG_SYS_SUPPORTS_64BIT_KERNEL=y
111CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y 105CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
112CONFIG_CPU_SUPPORTS_64BIT_KERNEL=y
113 106
114# 107#
115# Kernel type 108# Kernel type
@@ -120,17 +113,17 @@ CONFIG_PAGE_SIZE_4KB=y
120# CONFIG_PAGE_SIZE_8KB is not set 113# CONFIG_PAGE_SIZE_8KB is not set
121# CONFIG_PAGE_SIZE_16KB is not set 114# CONFIG_PAGE_SIZE_16KB is not set
122# CONFIG_PAGE_SIZE_64KB is not set 115# CONFIG_PAGE_SIZE_64KB is not set
123CONFIG_BOARD_SCACHE=y 116CONFIG_CPU_HAS_PREFETCH=y
124CONFIG_IP22_CPU_SCACHE=y
125CONFIG_MIPS_MT_DISABLED=y 117CONFIG_MIPS_MT_DISABLED=y
126# CONFIG_MIPS_MT_SMTC is not set
127# CONFIG_MIPS_MT_SMP is not set 118# CONFIG_MIPS_MT_SMP is not set
119# CONFIG_MIPS_MT_SMTC is not set
128# CONFIG_MIPS_VPE_LOADER is not set 120# CONFIG_MIPS_VPE_LOADER is not set
129# CONFIG_64BIT_PHYS_ADDR is not set 121# CONFIG_64BIT_PHYS_ADDR is not set
130CONFIG_CPU_HAS_LLSC=y 122CONFIG_CPU_HAS_LLSC=y
131CONFIG_CPU_HAS_SYNC=y 123CONFIG_CPU_HAS_SYNC=y
132CONFIG_GENERIC_HARDIRQS=y 124CONFIG_GENERIC_HARDIRQS=y
133CONFIG_GENERIC_IRQ_PROBE=y 125CONFIG_GENERIC_IRQ_PROBE=y
126CONFIG_CPU_SUPPORTS_HIGHMEM=y
134CONFIG_ARCH_FLATMEM_ENABLE=y 127CONFIG_ARCH_FLATMEM_ENABLE=y
135CONFIG_SELECT_MEMORY_MODEL=y 128CONFIG_SELECT_MEMORY_MODEL=y
136CONFIG_FLATMEM_MANUAL=y 129CONFIG_FLATMEM_MANUAL=y
@@ -144,12 +137,12 @@ CONFIG_SPLIT_PTLOCK_CPUS=4
144# CONFIG_HZ_48 is not set 137# CONFIG_HZ_48 is not set
145# CONFIG_HZ_100 is not set 138# CONFIG_HZ_100 is not set
146# CONFIG_HZ_128 is not set 139# CONFIG_HZ_128 is not set
147# CONFIG_HZ_250 is not set 140CONFIG_HZ_250=y
148# CONFIG_HZ_256 is not set 141# CONFIG_HZ_256 is not set
149CONFIG_HZ_1000=y 142# CONFIG_HZ_1000 is not set
150# CONFIG_HZ_1024 is not set 143# CONFIG_HZ_1024 is not set
151CONFIG_SYS_SUPPORTS_ARBIT_HZ=y 144CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
152CONFIG_HZ=1000 145CONFIG_HZ=250
153CONFIG_PREEMPT_NONE=y 146CONFIG_PREEMPT_NONE=y
154# CONFIG_PREEMPT_VOLUNTARY is not set 147# CONFIG_PREEMPT_VOLUNTARY is not set
155# CONFIG_PREEMPT is not set 148# CONFIG_PREEMPT is not set
@@ -171,16 +164,20 @@ CONFIG_LOCALVERSION=""
171CONFIG_LOCALVERSION_AUTO=y 164CONFIG_LOCALVERSION_AUTO=y
172CONFIG_SWAP=y 165CONFIG_SWAP=y
173CONFIG_SYSVIPC=y 166CONFIG_SYSVIPC=y
167# CONFIG_IPC_NS is not set
174# CONFIG_POSIX_MQUEUE is not set 168# CONFIG_POSIX_MQUEUE is not set
175# CONFIG_BSD_PROCESS_ACCT is not set 169# CONFIG_BSD_PROCESS_ACCT is not set
176CONFIG_SYSCTL=y 170# CONFIG_TASKSTATS is not set
171# CONFIG_UTS_NS is not set
177# CONFIG_AUDIT is not set 172# CONFIG_AUDIT is not set
178CONFIG_IKCONFIG=y 173CONFIG_IKCONFIG=y
179CONFIG_IKCONFIG_PROC=y 174CONFIG_IKCONFIG_PROC=y
180# CONFIG_RELAY is not set 175# CONFIG_RELAY is not set
181CONFIG_INITRAMFS_SOURCE="" 176CONFIG_INITRAMFS_SOURCE=""
182# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 177# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
178CONFIG_SYSCTL=y
183CONFIG_EMBEDDED=y 179CONFIG_EMBEDDED=y
180# CONFIG_SYSCTL_SYSCALL is not set
184CONFIG_KALLSYMS=y 181CONFIG_KALLSYMS=y
185# CONFIG_KALLSYMS_ALL is not set 182# CONFIG_KALLSYMS_ALL is not set
186# CONFIG_KALLSYMS_EXTRA_PASS is not set 183# CONFIG_KALLSYMS_EXTRA_PASS is not set
@@ -189,12 +186,12 @@ CONFIG_PRINTK=y
189CONFIG_BUG=y 186CONFIG_BUG=y
190CONFIG_ELF_CORE=y 187CONFIG_ELF_CORE=y
191CONFIG_BASE_FULL=y 188CONFIG_BASE_FULL=y
192CONFIG_RT_MUTEXES=y
193CONFIG_FUTEX=y 189CONFIG_FUTEX=y
194CONFIG_EPOLL=y 190CONFIG_EPOLL=y
195CONFIG_SHMEM=y 191CONFIG_SHMEM=y
196CONFIG_SLAB=y 192CONFIG_SLAB=y
197CONFIG_VM_EVENT_COUNTERS=y 193CONFIG_VM_EVENT_COUNTERS=y
194CONFIG_RT_MUTEXES=y
198# CONFIG_TINY_SHMEM is not set 195# CONFIG_TINY_SHMEM is not set
199CONFIG_BASE_SMALL=0 196CONFIG_BASE_SMALL=0
200# CONFIG_SLOB is not set 197# CONFIG_SLOB is not set
@@ -211,6 +208,7 @@ CONFIG_KMOD=y
211# 208#
212# Block layer 209# Block layer
213# 210#
211CONFIG_BLOCK=y
214# CONFIG_LBD is not set 212# CONFIG_LBD is not set
215# CONFIG_BLK_DEV_IO_TRACE is not set 213# CONFIG_BLK_DEV_IO_TRACE is not set
216# CONFIG_LSF is not set 214# CONFIG_LSF is not set
@@ -231,8 +229,10 @@ CONFIG_DEFAULT_IOSCHED="anticipatory"
231# 229#
232# Bus options (PCI, PCMCIA, EISA, ISA, TC) 230# Bus options (PCI, PCMCIA, EISA, ISA, TC)
233# 231#
234CONFIG_HW_HAS_EISA=y 232CONFIG_HW_HAS_PCI=y
235# CONFIG_EISA is not set 233CONFIG_PCI=y
234# CONFIG_PCI_MULTITHREAD_PROBE is not set
235# CONFIG_PCI_DEBUG is not set
236CONFIG_MMU=y 236CONFIG_MMU=y
237 237
238# 238#
@@ -243,6 +243,7 @@ CONFIG_MMU=y
243# 243#
244# PCI Hotplug Support 244# PCI Hotplug Support
245# 245#
246# CONFIG_HOTPLUG_PCI is not set
246 247
247# 248#
248# Executable file formats 249# Executable file formats
@@ -265,6 +266,7 @@ CONFIG_PACKET=y
265CONFIG_UNIX=y 266CONFIG_UNIX=y
266CONFIG_XFRM=y 267CONFIG_XFRM=y
267# CONFIG_XFRM_USER is not set 268# CONFIG_XFRM_USER is not set
269# CONFIG_XFRM_SUB_POLICY is not set
268# CONFIG_NET_KEY is not set 270# CONFIG_NET_KEY is not set
269CONFIG_INET=y 271CONFIG_INET=y
270# CONFIG_IP_MULTICAST is not set 272# CONFIG_IP_MULTICAST is not set
@@ -283,16 +285,18 @@ CONFIG_IP_PNP_BOOTP=y
283# CONFIG_INET_IPCOMP is not set 285# CONFIG_INET_IPCOMP is not set
284# CONFIG_INET_XFRM_TUNNEL is not set 286# CONFIG_INET_XFRM_TUNNEL is not set
285# CONFIG_INET_TUNNEL is not set 287# CONFIG_INET_TUNNEL is not set
286CONFIG_INET_XFRM_MODE_TRANSPORT=m 288CONFIG_INET_XFRM_MODE_TRANSPORT=y
287CONFIG_INET_XFRM_MODE_TUNNEL=m 289CONFIG_INET_XFRM_MODE_TUNNEL=y
290CONFIG_INET_XFRM_MODE_BEET=y
288CONFIG_INET_DIAG=y 291CONFIG_INET_DIAG=y
289CONFIG_INET_TCP_DIAG=y 292CONFIG_INET_TCP_DIAG=y
290# CONFIG_TCP_CONG_ADVANCED is not set 293# CONFIG_TCP_CONG_ADVANCED is not set
291CONFIG_TCP_CONG_BIC=y 294CONFIG_TCP_CONG_CUBIC=y
295CONFIG_DEFAULT_TCP_CONG="cubic"
292# CONFIG_IPV6 is not set 296# CONFIG_IPV6 is not set
293# CONFIG_INET6_XFRM_TUNNEL is not set 297# CONFIG_INET6_XFRM_TUNNEL is not set
294# CONFIG_INET6_TUNNEL is not set 298# CONFIG_INET6_TUNNEL is not set
295CONFIG_NETWORK_SECMARK=y 299# CONFIG_NETWORK_SECMARK is not set
296# CONFIG_NETFILTER is not set 300# CONFIG_NETFILTER is not set
297 301
298# 302#
@@ -318,7 +322,6 @@ CONFIG_NETWORK_SECMARK=y
318# CONFIG_ATALK is not set 322# CONFIG_ATALK is not set
319# CONFIG_X25 is not set 323# CONFIG_X25 is not set
320# CONFIG_LAPB is not set 324# CONFIG_LAPB is not set
321# CONFIG_NET_DIVERT is not set
322# CONFIG_ECONET is not set 325# CONFIG_ECONET is not set
323# CONFIG_WAN_ROUTER is not set 326# CONFIG_WAN_ROUTER is not set
324 327
@@ -371,13 +374,20 @@ CONFIG_FW_LOADER=y
371# 374#
372# Block devices 375# Block devices
373# 376#
377# CONFIG_BLK_CPQ_DA is not set
378# CONFIG_BLK_CPQ_CISS_DA is not set
379# CONFIG_BLK_DEV_DAC960 is not set
380# CONFIG_BLK_DEV_UMEM is not set
374# CONFIG_BLK_DEV_COW_COMMON is not set 381# CONFIG_BLK_DEV_COW_COMMON is not set
375CONFIG_BLK_DEV_LOOP=y 382CONFIG_BLK_DEV_LOOP=y
376# CONFIG_BLK_DEV_CRYPTOLOOP is not set 383# CONFIG_BLK_DEV_CRYPTOLOOP is not set
377# CONFIG_BLK_DEV_NBD is not set 384# CONFIG_BLK_DEV_NBD is not set
385# CONFIG_BLK_DEV_SX8 is not set
386# CONFIG_BLK_DEV_UB is not set
378CONFIG_BLK_DEV_RAM=y 387CONFIG_BLK_DEV_RAM=y
379CONFIG_BLK_DEV_RAM_COUNT=16 388CONFIG_BLK_DEV_RAM_COUNT=16
380CONFIG_BLK_DEV_RAM_SIZE=8192 389CONFIG_BLK_DEV_RAM_SIZE=8192
390CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
381CONFIG_BLK_DEV_INITRD=y 391CONFIG_BLK_DEV_INITRD=y
382# CONFIG_CDROM_PKTCDVD is not set 392# CONFIG_CDROM_PKTCDVD is not set
383# CONFIG_ATA_OVER_ETH is not set 393# CONFIG_ATA_OVER_ETH is not set
@@ -386,6 +396,7 @@ CONFIG_BLK_DEV_INITRD=y
386# ATA/ATAPI/MFM/RLL support 396# ATA/ATAPI/MFM/RLL support
387# 397#
388CONFIG_IDE=y 398CONFIG_IDE=y
399CONFIG_IDE_MAX_HWIFS=4
389CONFIG_BLK_DEV_IDE=y 400CONFIG_BLK_DEV_IDE=y
390 401
391# 402#
@@ -404,8 +415,39 @@ CONFIG_BLK_DEV_IDESCSI=y
404# IDE chipset support/bugfixes 415# IDE chipset support/bugfixes
405# 416#
406CONFIG_IDE_GENERIC=y 417CONFIG_IDE_GENERIC=y
418CONFIG_BLK_DEV_IDEPCI=y
419CONFIG_IDEPCI_SHARE_IRQ=y
420CONFIG_BLK_DEV_OFFBOARD=y
421CONFIG_BLK_DEV_GENERIC=y
422# CONFIG_BLK_DEV_OPTI621 is not set
423CONFIG_BLK_DEV_IDEDMA_PCI=y
424# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
425# CONFIG_IDEDMA_PCI_AUTO is not set
426# CONFIG_BLK_DEV_AEC62XX is not set
427# CONFIG_BLK_DEV_ALI15X3 is not set
428# CONFIG_BLK_DEV_AMD74XX is not set
429# CONFIG_BLK_DEV_CMD64X is not set
430# CONFIG_BLK_DEV_TRIFLEX is not set
431# CONFIG_BLK_DEV_CY82C693 is not set
432# CONFIG_BLK_DEV_CS5520 is not set
433# CONFIG_BLK_DEV_CS5530 is not set
434# CONFIG_BLK_DEV_HPT34X is not set
435CONFIG_BLK_DEV_HPT366=y
436# CONFIG_BLK_DEV_JMICRON is not set
437# CONFIG_BLK_DEV_SC1200 is not set
438# CONFIG_BLK_DEV_PIIX is not set
439# CONFIG_BLK_DEV_IT821X is not set
440# CONFIG_BLK_DEV_NS87415 is not set
441# CONFIG_BLK_DEV_PDC202XX_OLD is not set
442# CONFIG_BLK_DEV_PDC202XX_NEW is not set
443# CONFIG_BLK_DEV_SVWKS is not set
444# CONFIG_BLK_DEV_SIIMAGE is not set
445# CONFIG_BLK_DEV_SLC90E66 is not set
446# CONFIG_BLK_DEV_TRM290 is not set
447# CONFIG_BLK_DEV_VIA82CXXX is not set
407# CONFIG_IDE_ARM is not set 448# CONFIG_IDE_ARM is not set
408# CONFIG_BLK_DEV_IDEDMA is not set 449CONFIG_BLK_DEV_IDEDMA=y
450# CONFIG_IDEDMA_IVB is not set
409# CONFIG_IDEDMA_AUTO is not set 451# CONFIG_IDEDMA_AUTO is not set
410# CONFIG_BLK_DEV_HD is not set 452# CONFIG_BLK_DEV_HD is not set
411 453
@@ -414,6 +456,7 @@ CONFIG_IDE_GENERIC=y
414# 456#
415# CONFIG_RAID_ATTRS is not set 457# CONFIG_RAID_ATTRS is not set
416CONFIG_SCSI=y 458CONFIG_SCSI=y
459CONFIG_SCSI_NETLINK=y
417CONFIG_SCSI_PROC_FS=y 460CONFIG_SCSI_PROC_FS=y
418 461
419# 462#
@@ -434,22 +477,54 @@ CONFIG_SCSI_CONSTANTS=y
434# CONFIG_SCSI_LOGGING is not set 477# CONFIG_SCSI_LOGGING is not set
435 478
436# 479#
437# SCSI Transport Attributes 480# SCSI Transports
438# 481#
439# CONFIG_SCSI_SPI_ATTRS is not set 482# CONFIG_SCSI_SPI_ATTRS is not set
440CONFIG_SCSI_FC_ATTRS=y 483CONFIG_SCSI_FC_ATTRS=y
441CONFIG_SCSI_ISCSI_ATTRS=m 484CONFIG_SCSI_ISCSI_ATTRS=m
442# CONFIG_SCSI_SAS_ATTRS is not set 485# CONFIG_SCSI_SAS_ATTRS is not set
486# CONFIG_SCSI_SAS_LIBSAS is not set
443 487
444# 488#
445# SCSI low-level drivers 489# SCSI low-level drivers
446# 490#
447CONFIG_ISCSI_TCP=m 491CONFIG_ISCSI_TCP=m
448# CONFIG_SGIWD93_SCSI is not set 492# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
449# CONFIG_SCSI_SATA is not set 493# CONFIG_SCSI_3W_9XXX is not set
494# CONFIG_SCSI_ACARD is not set
495# CONFIG_SCSI_AACRAID is not set
496# CONFIG_SCSI_AIC7XXX is not set
497# CONFIG_SCSI_AIC7XXX_OLD is not set
498# CONFIG_SCSI_AIC79XX is not set
499# CONFIG_SCSI_AIC94XX is not set
500# CONFIG_SCSI_DPT_I2O is not set
501# CONFIG_SCSI_ARCMSR is not set
502# CONFIG_MEGARAID_NEWGEN is not set
503# CONFIG_MEGARAID_LEGACY is not set
504# CONFIG_MEGARAID_SAS is not set
505# CONFIG_SCSI_HPTIOP is not set
506# CONFIG_SCSI_DMX3191D is not set
507# CONFIG_SCSI_FUTURE_DOMAIN is not set
508# CONFIG_SCSI_IPS is not set
509# CONFIG_SCSI_INITIO is not set
510# CONFIG_SCSI_INIA100 is not set
511# CONFIG_SCSI_STEX is not set
512# CONFIG_SCSI_SYM53C8XX_2 is not set
513# CONFIG_SCSI_QLOGIC_1280 is not set
514# CONFIG_SCSI_QLA_FC is not set
515# CONFIG_SCSI_QLA_ISCSI is not set
516# CONFIG_SCSI_LPFC is not set
517# CONFIG_SCSI_DC395x is not set
518# CONFIG_SCSI_DC390T is not set
519# CONFIG_SCSI_NSP32 is not set
450# CONFIG_SCSI_DEBUG is not set 520# CONFIG_SCSI_DEBUG is not set
451 521
452# 522#
523# Serial ATA (prod) and Parallel ATA (experimental) drivers
524#
525# CONFIG_ATA is not set
526
527#
453# Multi-device support (RAID and LVM) 528# Multi-device support (RAID and LVM)
454# 529#
455# CONFIG_MD is not set 530# CONFIG_MD is not set
@@ -458,14 +533,19 @@ CONFIG_ISCSI_TCP=m
458# Fusion MPT device support 533# Fusion MPT device support
459# 534#
460# CONFIG_FUSION is not set 535# CONFIG_FUSION is not set
536# CONFIG_FUSION_SPI is not set
537# CONFIG_FUSION_FC is not set
538# CONFIG_FUSION_SAS is not set
461 539
462# 540#
463# IEEE 1394 (FireWire) support 541# IEEE 1394 (FireWire) support
464# 542#
543# CONFIG_IEEE1394 is not set
465 544
466# 545#
467# I2O device support 546# I2O device support
468# 547#
548# CONFIG_I2O is not set
469 549
470# 550#
471# Network device support 551# Network device support
@@ -477,6 +557,11 @@ CONFIG_NETDEVICES=y
477# CONFIG_TUN is not set 557# CONFIG_TUN is not set
478 558
479# 559#
560# ARCnet devices
561#
562# CONFIG_ARCNET is not set
563
564#
480# PHY device support 565# PHY device support
481# 566#
482# CONFIG_PHYLIB is not set 567# CONFIG_PHYLIB is not set
@@ -486,20 +571,73 @@ CONFIG_NETDEVICES=y
486# 571#
487CONFIG_NET_ETHERNET=y 572CONFIG_NET_ETHERNET=y
488CONFIG_MII=y 573CONFIG_MII=y
574# CONFIG_HAPPYMEAL is not set
575# CONFIG_SUNGEM is not set
576# CONFIG_CASSINI is not set
577# CONFIG_NET_VENDOR_3COM is not set
489# CONFIG_DM9000 is not set 578# CONFIG_DM9000 is not set
490# CONFIG_SGISEEQ is not set 579
580#
581# Tulip family network device support
582#
583# CONFIG_NET_TULIP is not set
584# CONFIG_HP100 is not set
585CONFIG_NET_PCI=y
586# CONFIG_PCNET32 is not set
587# CONFIG_AMD8111_ETH is not set
588# CONFIG_ADAPTEC_STARFIRE is not set
589# CONFIG_B44 is not set
590# CONFIG_FORCEDETH is not set
591# CONFIG_DGRS is not set
592# CONFIG_EEPRO100 is not set
593# CONFIG_E100 is not set
594# CONFIG_FEALNX is not set
595# CONFIG_NATSEMI is not set
596# CONFIG_NE2K_PCI is not set
597# CONFIG_8139CP is not set
598CONFIG_8139TOO=y
599# CONFIG_8139TOO_PIO is not set
600CONFIG_8139TOO_TUNE_TWISTER=y
601CONFIG_8139TOO_8129=y
602# CONFIG_8139_OLD_RX_RESET is not set
603# CONFIG_SIS900 is not set
604# CONFIG_EPIC100 is not set
605# CONFIG_SUNDANCE is not set
606# CONFIG_TLAN is not set
607# CONFIG_VIA_RHINE is not set
608# CONFIG_LAN_SAA9730 is not set
491 609
492# 610#
493# Ethernet (1000 Mbit) 611# Ethernet (1000 Mbit)
494# 612#
613# CONFIG_ACENIC is not set
614# CONFIG_DL2K is not set
615# CONFIG_E1000 is not set
616# CONFIG_NS83820 is not set
617# CONFIG_HAMACHI is not set
618# CONFIG_YELLOWFIN is not set
619# CONFIG_R8169 is not set
620# CONFIG_SIS190 is not set
621# CONFIG_SKGE is not set
622# CONFIG_SKY2 is not set
623# CONFIG_SK98LIN is not set
624# CONFIG_VIA_VELOCITY is not set
625# CONFIG_TIGON3 is not set
626# CONFIG_BNX2 is not set
627# CONFIG_QLA3XXX is not set
495 628
496# 629#
497# Ethernet (10000 Mbit) 630# Ethernet (10000 Mbit)
498# 631#
632# CONFIG_CHELSIO_T1 is not set
633# CONFIG_IXGB is not set
634# CONFIG_S2IO is not set
635# CONFIG_MYRI10GE is not set
499 636
500# 637#
501# Token Ring devices 638# Token Ring devices
502# 639#
640# CONFIG_TR is not set
503 641
504# 642#
505# Wireless LAN (non-hamradio) 643# Wireless LAN (non-hamradio)
@@ -510,8 +648,11 @@ CONFIG_MII=y
510# Wan interfaces 648# Wan interfaces
511# 649#
512# CONFIG_WAN is not set 650# CONFIG_WAN is not set
651# CONFIG_FDDI is not set
652# CONFIG_HIPPI is not set
513# CONFIG_PPP is not set 653# CONFIG_PPP is not set
514# CONFIG_SLIP is not set 654# CONFIG_SLIP is not set
655# CONFIG_NET_FC is not set
515# CONFIG_SHAPER is not set 656# CONFIG_SHAPER is not set
516# CONFIG_NETCONSOLE is not set 657# CONFIG_NETCONSOLE is not set
517# CONFIG_NETPOLL is not set 658# CONFIG_NETPOLL is not set
@@ -531,6 +672,7 @@ CONFIG_MII=y
531# Input device support 672# Input device support
532# 673#
533CONFIG_INPUT=y 674CONFIG_INPUT=y
675# CONFIG_INPUT_FF_MEMLESS is not set
534 676
535# 677#
536# Userland interfaces 678# Userland interfaces
@@ -556,6 +698,7 @@ CONFIG_INPUT=y
556CONFIG_SERIO=y 698CONFIG_SERIO=y
557# CONFIG_SERIO_I8042 is not set 699# CONFIG_SERIO_I8042 is not set
558# CONFIG_SERIO_SERPORT is not set 700# CONFIG_SERIO_SERPORT is not set
701# CONFIG_SERIO_PCIPS2 is not set
559CONFIG_SERIO_LIBPS2=y 702CONFIG_SERIO_LIBPS2=y
560# CONFIG_SERIO_RAW is not set 703# CONFIG_SERIO_RAW is not set
561# CONFIG_GAMEPORT is not set 704# CONFIG_GAMEPORT is not set
@@ -566,7 +709,7 @@ CONFIG_SERIO_LIBPS2=y
566CONFIG_VT=y 709CONFIG_VT=y
567CONFIG_VT_CONSOLE=y 710CONFIG_VT_CONSOLE=y
568CONFIG_HW_CONSOLE=y 711CONFIG_HW_CONSOLE=y
569CONFIG_VT_HW_CONSOLE_BINDING=y 712# CONFIG_VT_HW_CONSOLE_BINDING is not set
570# CONFIG_SERIAL_NONSTANDARD is not set 713# CONFIG_SERIAL_NONSTANDARD is not set
571 714
572# 715#
@@ -577,7 +720,8 @@ CONFIG_VT_HW_CONSOLE_BINDING=y
577# 720#
578# Non-8250 serial port support 721# Non-8250 serial port support
579# 722#
580# CONFIG_SERIAL_IP22_ZILOG is not set 723# CONFIG_SERIAL_IP3106 is not set
724# CONFIG_SERIAL_JSM is not set
581CONFIG_UNIX98_PTYS=y 725CONFIG_UNIX98_PTYS=y
582CONFIG_LEGACY_PTYS=y 726CONFIG_LEGACY_PTYS=y
583CONFIG_LEGACY_PTY_COUNT=256 727CONFIG_LEGACY_PTY_COUNT=256
@@ -591,16 +735,17 @@ CONFIG_LEGACY_PTY_COUNT=256
591# Watchdog Cards 735# Watchdog Cards
592# 736#
593# CONFIG_WATCHDOG is not set 737# CONFIG_WATCHDOG is not set
594# CONFIG_HW_RANDOM is not set 738CONFIG_HW_RANDOM=y
595# CONFIG_RTC is not set 739# CONFIG_RTC is not set
596# CONFIG_SGI_DS1286 is not set
597# CONFIG_GEN_RTC is not set 740# CONFIG_GEN_RTC is not set
598# CONFIG_DTLK is not set 741# CONFIG_DTLK is not set
599# CONFIG_R3964 is not set 742# CONFIG_R3964 is not set
743# CONFIG_APPLICOM is not set
600 744
601# 745#
602# Ftape, the floppy tape device driver 746# Ftape, the floppy tape device driver
603# 747#
748# CONFIG_DRM is not set
604# CONFIG_RAW_DRIVER is not set 749# CONFIG_RAW_DRIVER is not set
605 750
606# 751#
@@ -631,35 +776,37 @@ CONFIG_HWMON=y
631# CONFIG_HWMON_VID is not set 776# CONFIG_HWMON_VID is not set
632# CONFIG_SENSORS_ABITUGURU is not set 777# CONFIG_SENSORS_ABITUGURU is not set
633# CONFIG_SENSORS_F71805F is not set 778# CONFIG_SENSORS_F71805F is not set
779# CONFIG_SENSORS_VT1211 is not set
634# CONFIG_HWMON_DEBUG_CHIP is not set 780# CONFIG_HWMON_DEBUG_CHIP is not set
635 781
636# 782#
637# Misc devices 783# Misc devices
638# 784#
785# CONFIG_TIFM_CORE is not set
639 786
640# 787#
641# Multimedia devices 788# Multimedia devices
642# 789#
643# CONFIG_VIDEO_DEV is not set 790# CONFIG_VIDEO_DEV is not set
644CONFIG_VIDEO_V4L2=y
645 791
646# 792#
647# Digital Video Broadcasting Devices 793# Digital Video Broadcasting Devices
648# 794#
649# CONFIG_DVB is not set 795# CONFIG_DVB is not set
796# CONFIG_USB_DABUSB is not set
650 797
651# 798#
652# Graphics support 799# Graphics support
653# 800#
654# CONFIG_FIRMWARE_EDID is not set 801CONFIG_FIRMWARE_EDID=y
655# CONFIG_FB is not set 802# CONFIG_FB is not set
656 803
657# 804#
658# Console display driver support 805# Console display driver support
659# 806#
660# CONFIG_VGA_CONSOLE is not set 807# CONFIG_VGA_CONSOLE is not set
661# CONFIG_SGI_NEWPORT_CONSOLE is not set
662CONFIG_DUMMY_CONSOLE=y 808CONFIG_DUMMY_CONSOLE=y
809# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
663 810
664# 811#
665# Sound 812# Sound
@@ -669,15 +816,131 @@ CONFIG_DUMMY_CONSOLE=y
669# 816#
670# USB support 817# USB support
671# 818#
672# CONFIG_USB_ARCH_HAS_HCD is not set 819CONFIG_USB_ARCH_HAS_HCD=y
673# CONFIG_USB_ARCH_HAS_OHCI is not set 820CONFIG_USB_ARCH_HAS_OHCI=y
674# CONFIG_USB_ARCH_HAS_EHCI is not set 821CONFIG_USB_ARCH_HAS_EHCI=y
822CONFIG_USB=y
823# CONFIG_USB_DEBUG is not set
824
825#
826# Miscellaneous USB options
827#
828# CONFIG_USB_DEVICEFS is not set
829# CONFIG_USB_BANDWIDTH is not set
830# CONFIG_USB_DYNAMIC_MINORS is not set
831# CONFIG_USB_OTG is not set
832
833#
834# USB Host Controller Drivers
835#
836# CONFIG_USB_EHCI_HCD is not set
837# CONFIG_USB_ISP116X_HCD is not set
838CONFIG_USB_OHCI_HCD=y
839# CONFIG_USB_OHCI_BIG_ENDIAN is not set
840CONFIG_USB_OHCI_LITTLE_ENDIAN=y
841# CONFIG_USB_UHCI_HCD is not set
842# CONFIG_USB_SL811_HCD is not set
843
844#
845# USB Device Class drivers
846#
847# CONFIG_USB_ACM is not set
848# CONFIG_USB_PRINTER is not set
675 849
676# 850#
677# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' 851# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
678# 852#
679 853
680# 854#
855# may also be needed; see USB_STORAGE Help for more information
856#
857CONFIG_USB_STORAGE=y
858# CONFIG_USB_STORAGE_DEBUG is not set
859CONFIG_USB_STORAGE_DATAFAB=y
860CONFIG_USB_STORAGE_FREECOM=y
861CONFIG_USB_STORAGE_ISD200=y
862CONFIG_USB_STORAGE_DPCM=y
863CONFIG_USB_STORAGE_USBAT=y
864CONFIG_USB_STORAGE_SDDR09=y
865CONFIG_USB_STORAGE_SDDR55=y
866CONFIG_USB_STORAGE_JUMPSHOT=y
867# CONFIG_USB_STORAGE_ALAUDA is not set
868# CONFIG_USB_STORAGE_KARMA is not set
869# CONFIG_USB_LIBUSUAL is not set
870
871#
872# USB Input Devices
873#
874# CONFIG_USB_HID is not set
875
876#
877# USB HID Boot Protocol drivers
878#
879# CONFIG_USB_KBD is not set
880# CONFIG_USB_MOUSE is not set
881# CONFIG_USB_AIPTEK is not set
882# CONFIG_USB_WACOM is not set
883# CONFIG_USB_ACECAD is not set
884# CONFIG_USB_KBTAB is not set
885# CONFIG_USB_POWERMATE is not set
886# CONFIG_USB_TOUCHSCREEN is not set
887# CONFIG_USB_YEALINK is not set
888# CONFIG_USB_XPAD is not set
889# CONFIG_USB_ATI_REMOTE is not set
890# CONFIG_USB_ATI_REMOTE2 is not set
891# CONFIG_USB_KEYSPAN_REMOTE is not set
892# CONFIG_USB_APPLETOUCH is not set
893# CONFIG_USB_TRANCEVIBRATOR is not set
894
895#
896# USB Imaging devices
897#
898# CONFIG_USB_MDC800 is not set
899# CONFIG_USB_MICROTEK is not set
900
901#
902# USB Network Adapters
903#
904# CONFIG_USB_CATC is not set
905# CONFIG_USB_KAWETH is not set
906# CONFIG_USB_PEGASUS is not set
907# CONFIG_USB_RTL8150 is not set
908# CONFIG_USB_USBNET is not set
909CONFIG_USB_MON=y
910
911#
912# USB port drivers
913#
914
915#
916# USB Serial Converter support
917#
918# CONFIG_USB_SERIAL is not set
919
920#
921# USB Miscellaneous drivers
922#
923# CONFIG_USB_EMI62 is not set
924# CONFIG_USB_EMI26 is not set
925# CONFIG_USB_ADUTUX is not set
926# CONFIG_USB_AUERSWALD is not set
927# CONFIG_USB_RIO500 is not set
928# CONFIG_USB_LEGOTOWER is not set
929# CONFIG_USB_LCD is not set
930# CONFIG_USB_LED is not set
931# CONFIG_USB_CYPRESS_CY7C63 is not set
932# CONFIG_USB_CYTHERM is not set
933# CONFIG_USB_PHIDGET is not set
934# CONFIG_USB_IDMOUSE is not set
935# CONFIG_USB_FTDI_ELAN is not set
936# CONFIG_USB_APPLEDISPLAY is not set
937# CONFIG_USB_LD is not set
938
939#
940# USB DSL modem support
941#
942
943#
681# USB Gadget Support 944# USB Gadget Support
682# 945#
683# CONFIG_USB_GADGET is not set 946# CONFIG_USB_GADGET is not set
@@ -703,6 +966,7 @@ CONFIG_DUMMY_CONSOLE=y
703# 966#
704# InfiniBand support 967# InfiniBand support
705# 968#
969# CONFIG_INFINIBAND is not set
706 970
707# 971#
708# EDAC - error detection and reporting (RAS) (EXPERIMENTAL) 972# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
@@ -733,10 +997,12 @@ CONFIG_EXT2_FS=y
733# CONFIG_EXT2_FS_XATTR is not set 997# CONFIG_EXT2_FS_XATTR is not set
734# CONFIG_EXT2_FS_XIP is not set 998# CONFIG_EXT2_FS_XIP is not set
735# CONFIG_EXT3_FS is not set 999# CONFIG_EXT3_FS is not set
1000# CONFIG_EXT4DEV_FS is not set
736# CONFIG_REISERFS_FS is not set 1001# CONFIG_REISERFS_FS is not set
737# CONFIG_JFS_FS is not set 1002# CONFIG_JFS_FS is not set
738# CONFIG_FS_POSIX_ACL is not set 1003# CONFIG_FS_POSIX_ACL is not set
739# CONFIG_XFS_FS is not set 1004# CONFIG_XFS_FS is not set
1005# CONFIG_GFS2_FS is not set
740# CONFIG_OCFS2_FS is not set 1006# CONFIG_OCFS2_FS is not set
741# CONFIG_MINIX_FS is not set 1007# CONFIG_MINIX_FS is not set
742# CONFIG_ROMFS_FS is not set 1008# CONFIG_ROMFS_FS is not set
@@ -769,8 +1035,10 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
769# 1035#
770CONFIG_PROC_FS=y 1036CONFIG_PROC_FS=y
771# CONFIG_PROC_KCORE is not set 1037# CONFIG_PROC_KCORE is not set
1038CONFIG_PROC_SYSCTL=y
772CONFIG_SYSFS=y 1039CONFIG_SYSFS=y
773CONFIG_TMPFS=y 1040CONFIG_TMPFS=y
1041# CONFIG_TMPFS_POSIX_ACL is not set
774# CONFIG_HUGETLB_PAGE is not set 1042# CONFIG_HUGETLB_PAGE is not set
775CONFIG_RAMFS=y 1043CONFIG_RAMFS=y
776# CONFIG_CONFIGFS_FS is not set 1044# CONFIG_CONFIGFS_FS is not set
@@ -813,7 +1081,6 @@ CONFIG_SUNRPC=y
813# CONFIG_RPCSEC_GSS_SPKM3 is not set 1081# CONFIG_RPCSEC_GSS_SPKM3 is not set
814# CONFIG_SMB_FS is not set 1082# CONFIG_SMB_FS is not set
815# CONFIG_CIFS is not set 1083# CONFIG_CIFS is not set
816# CONFIG_CIFS_DEBUG2 is not set
817# CONFIG_NCP_FS is not set 1084# CONFIG_NCP_FS is not set
818# CONFIG_CODA_FS is not set 1085# CONFIG_CODA_FS is not set
819# CONFIG_AFS_FS is not set 1086# CONFIG_AFS_FS is not set
@@ -824,7 +1091,6 @@ CONFIG_SUNRPC=y
824# 1091#
825# CONFIG_PARTITION_ADVANCED is not set 1092# CONFIG_PARTITION_ADVANCED is not set
826CONFIG_MSDOS_PARTITION=y 1093CONFIG_MSDOS_PARTITION=y
827CONFIG_SGI_PARTITION=y
828 1094
829# 1095#
830# Native Language Support 1096# Native Language Support
@@ -880,6 +1146,7 @@ CONFIG_NLS_DEFAULT="iso8859-1"
880# 1146#
881CONFIG_TRACE_IRQFLAGS_SUPPORT=y 1147CONFIG_TRACE_IRQFLAGS_SUPPORT=y
882# CONFIG_PRINTK_TIME is not set 1148# CONFIG_PRINTK_TIME is not set
1149CONFIG_ENABLE_MUST_CHECK=y
883CONFIG_MAGIC_SYSRQ=y 1150CONFIG_MAGIC_SYSRQ=y
884# CONFIG_UNUSED_SYMBOLS is not set 1151# CONFIG_UNUSED_SYMBOLS is not set
885CONFIG_DEBUG_KERNEL=y 1152CONFIG_DEBUG_KERNEL=y
@@ -893,13 +1160,17 @@ CONFIG_DEBUG_SLAB=y
893# CONFIG_DEBUG_SPINLOCK is not set 1160# CONFIG_DEBUG_SPINLOCK is not set
894CONFIG_DEBUG_MUTEXES=y 1161CONFIG_DEBUG_MUTEXES=y
895# CONFIG_DEBUG_RWSEMS is not set 1162# CONFIG_DEBUG_RWSEMS is not set
1163# CONFIG_DEBUG_LOCK_ALLOC is not set
1164# CONFIG_PROVE_LOCKING is not set
896# CONFIG_DEBUG_SPINLOCK_SLEEP is not set 1165# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
897# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set 1166# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
898# CONFIG_DEBUG_KOBJECT is not set 1167# CONFIG_DEBUG_KOBJECT is not set
899# CONFIG_DEBUG_INFO is not set 1168# CONFIG_DEBUG_INFO is not set
900# CONFIG_DEBUG_FS is not set 1169# CONFIG_DEBUG_FS is not set
901# CONFIG_DEBUG_VM is not set 1170# CONFIG_DEBUG_VM is not set
1171# CONFIG_DEBUG_LIST is not set
902CONFIG_FORCED_INLINING=y 1172CONFIG_FORCED_INLINING=y
1173# CONFIG_HEADERS_CHECK is not set
903# CONFIG_RCU_TORTURE_TEST is not set 1174# CONFIG_RCU_TORTURE_TEST is not set
904CONFIG_CROSSCOMPILE=y 1175CONFIG_CROSSCOMPILE=y
905CONFIG_CMDLINE="console=ttyS1,38400n8 kgdb=ttyS0 root=/dev/nfs ip=bootp" 1176CONFIG_CMDLINE="console=ttyS1,38400n8 kgdb=ttyS0 root=/dev/nfs ip=bootp"
@@ -918,6 +1189,9 @@ CONFIG_CMDLINE="console=ttyS1,38400n8 kgdb=ttyS0 root=/dev/nfs ip=bootp"
918# Cryptographic options 1189# Cryptographic options
919# 1190#
920CONFIG_CRYPTO=y 1191CONFIG_CRYPTO=y
1192CONFIG_CRYPTO_ALGAPI=m
1193CONFIG_CRYPTO_BLKCIPHER=m
1194CONFIG_CRYPTO_MANAGER=m
921# CONFIG_CRYPTO_HMAC is not set 1195# CONFIG_CRYPTO_HMAC is not set
922# CONFIG_CRYPTO_NULL is not set 1196# CONFIG_CRYPTO_NULL is not set
923# CONFIG_CRYPTO_MD4 is not set 1197# CONFIG_CRYPTO_MD4 is not set
@@ -927,6 +1201,8 @@ CONFIG_CRYPTO_MD5=m
927# CONFIG_CRYPTO_SHA512 is not set 1201# CONFIG_CRYPTO_SHA512 is not set
928# CONFIG_CRYPTO_WP512 is not set 1202# CONFIG_CRYPTO_WP512 is not set
929# CONFIG_CRYPTO_TGR192 is not set 1203# CONFIG_CRYPTO_TGR192 is not set
1204CONFIG_CRYPTO_ECB=m
1205CONFIG_CRYPTO_CBC=m
930# CONFIG_CRYPTO_DES is not set 1206# CONFIG_CRYPTO_DES is not set
931# CONFIG_CRYPTO_BLOWFISH is not set 1207# CONFIG_CRYPTO_BLOWFISH is not set
932# CONFIG_CRYPTO_TWOFISH is not set 1208# CONFIG_CRYPTO_TWOFISH is not set
diff --git a/arch/mips/configs/pnx8550-v2pci_defconfig b/arch/mips/configs/pnx8550-v2pci_defconfig
index e93266b37dd9..64b9fbf44a64 100644
--- a/arch/mips/configs/pnx8550-v2pci_defconfig
+++ b/arch/mips/configs/pnx8550-v2pci_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.18-rc1 3# Linux kernel version: 2.6.19-rc2
4# Thu Jul 6 10:04:18 2006 4# Sat Oct 14 23:12:15 2006
5# 5#
6CONFIG_MIPS=y 6CONFIG_MIPS=y
7 7
@@ -25,8 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_IVR is not set
29# CONFIG_MIPS_ITE8172 is not set
30# CONFIG_MACH_JAZZ is not set 28# CONFIG_MACH_JAZZ is not set
31# CONFIG_LASAT is not set 29# CONFIG_LASAT is not set
32# CONFIG_MIPS_ATLAS is not set 30# CONFIG_MIPS_ATLAS is not set
@@ -40,14 +38,14 @@ CONFIG_MIPS=y
40# CONFIG_MOMENCO_OCELOT_C is not set 38# CONFIG_MOMENCO_OCELOT_C is not set
41# CONFIG_MOMENCO_OCELOT_G is not set 39# CONFIG_MOMENCO_OCELOT_G is not set
42# CONFIG_MIPS_XXS1500 is not set 40# CONFIG_MIPS_XXS1500 is not set
43# CONFIG_PNX8550_V2PCI is not set 41CONFIG_PNX8550_V2PCI=y
44# CONFIG_PNX8550_JBS is not set 42# CONFIG_PNX8550_JBS is not set
45# CONFIG_DDB5477 is not set 43# CONFIG_DDB5477 is not set
46# CONFIG_MACH_VR41XX is not set 44# CONFIG_MACH_VR41XX is not set
47# CONFIG_PMC_YOSEMITE is not set 45# CONFIG_PMC_YOSEMITE is not set
48# CONFIG_QEMU is not set 46# CONFIG_QEMU is not set
49# CONFIG_MARKEINS is not set 47# CONFIG_MARKEINS is not set
50CONFIG_SGI_IP22=y 48# CONFIG_SGI_IP22 is not set
51# CONFIG_SGI_IP27 is not set 49# CONFIG_SGI_IP27 is not set
52# CONFIG_SGI_IP32 is not set 50# CONFIG_SGI_IP32 is not set
53# CONFIG_SIBYTE_BIGSUR is not set 51# CONFIG_SIBYTE_BIGSUR is not set
@@ -67,25 +65,21 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
67CONFIG_GENERIC_FIND_NEXT_BIT=y 65CONFIG_GENERIC_FIND_NEXT_BIT=y
68CONFIG_GENERIC_HWEIGHT=y 66CONFIG_GENERIC_HWEIGHT=y
69CONFIG_GENERIC_CALIBRATE_DELAY=y 67CONFIG_GENERIC_CALIBRATE_DELAY=y
68CONFIG_GENERIC_TIME=y
70CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y 69CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
71CONFIG_ARC=y
72CONFIG_DMA_NONCOHERENT=y 70CONFIG_DMA_NONCOHERENT=y
73CONFIG_DMA_NEED_PCI_MAP_STATE=y 71CONFIG_DMA_NEED_PCI_MAP_STATE=y
74CONFIG_CPU_BIG_ENDIAN=y 72# CONFIG_CPU_BIG_ENDIAN is not set
75# CONFIG_CPU_LITTLE_ENDIAN is not set 73CONFIG_CPU_LITTLE_ENDIAN=y
76CONFIG_SYS_SUPPORTS_BIG_ENDIAN=y 74CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y
77CONFIG_IRQ_CPU=y 75CONFIG_PNX8550=y
78CONFIG_SWAP_IO_SPACE=y 76CONFIG_SOC_PNX8550=y
79CONFIG_ARC32=y
80CONFIG_BOOT_ELF32=y
81CONFIG_MIPS_L1_CACHE_SHIFT=5 77CONFIG_MIPS_L1_CACHE_SHIFT=5
82# CONFIG_ARC_CONSOLE is not set
83CONFIG_ARC_PROMLIB=y
84 78
85# 79#
86# CPU selection 80# CPU selection
87# 81#
88# CONFIG_CPU_MIPS32_R1 is not set 82CONFIG_CPU_MIPS32_R1=y
89# CONFIG_CPU_MIPS32_R2 is not set 83# CONFIG_CPU_MIPS32_R2 is not set
90# CONFIG_CPU_MIPS64_R1 is not set 84# CONFIG_CPU_MIPS64_R1 is not set
91# CONFIG_CPU_MIPS64_R2 is not set 85# CONFIG_CPU_MIPS64_R2 is not set
@@ -93,7 +87,7 @@ CONFIG_ARC_PROMLIB=y
93# CONFIG_CPU_TX39XX is not set 87# CONFIG_CPU_TX39XX is not set
94# CONFIG_CPU_VR41XX is not set 88# CONFIG_CPU_VR41XX is not set
95# CONFIG_CPU_R4300 is not set 89# CONFIG_CPU_R4300 is not set
96CONFIG_CPU_R4X00=y 90# CONFIG_CPU_R4X00 is not set
97# CONFIG_CPU_TX49XX is not set 91# CONFIG_CPU_TX49XX is not set
98# CONFIG_CPU_R5000 is not set 92# CONFIG_CPU_R5000 is not set
99# CONFIG_CPU_R5432 is not set 93# CONFIG_CPU_R5432 is not set
@@ -104,12 +98,11 @@ CONFIG_CPU_R4X00=y
104# CONFIG_CPU_RM7000 is not set 98# CONFIG_CPU_RM7000 is not set
105# CONFIG_CPU_RM9000 is not set 99# CONFIG_CPU_RM9000 is not set
106# CONFIG_CPU_SB1 is not set 100# CONFIG_CPU_SB1 is not set
107CONFIG_SYS_HAS_CPU_R4X00=y 101CONFIG_SYS_HAS_CPU_MIPS32_R1=y
108CONFIG_SYS_HAS_CPU_R5000=y 102CONFIG_CPU_MIPS32=y
103CONFIG_CPU_MIPSR1=y
109CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y 104CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
110CONFIG_SYS_SUPPORTS_64BIT_KERNEL=y
111CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y 105CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
112CONFIG_CPU_SUPPORTS_64BIT_KERNEL=y
113 106
114# 107#
115# Kernel type 108# Kernel type
@@ -120,17 +113,17 @@ CONFIG_PAGE_SIZE_4KB=y
120# CONFIG_PAGE_SIZE_8KB is not set 113# CONFIG_PAGE_SIZE_8KB is not set
121# CONFIG_PAGE_SIZE_16KB is not set 114# CONFIG_PAGE_SIZE_16KB is not set
122# CONFIG_PAGE_SIZE_64KB is not set 115# CONFIG_PAGE_SIZE_64KB is not set
123CONFIG_BOARD_SCACHE=y 116CONFIG_CPU_HAS_PREFETCH=y
124CONFIG_IP22_CPU_SCACHE=y
125CONFIG_MIPS_MT_DISABLED=y 117CONFIG_MIPS_MT_DISABLED=y
126# CONFIG_MIPS_MT_SMTC is not set
127# CONFIG_MIPS_MT_SMP is not set 118# CONFIG_MIPS_MT_SMP is not set
119# CONFIG_MIPS_MT_SMTC is not set
128# CONFIG_MIPS_VPE_LOADER is not set 120# CONFIG_MIPS_VPE_LOADER is not set
129# CONFIG_64BIT_PHYS_ADDR is not set 121# CONFIG_64BIT_PHYS_ADDR is not set
130CONFIG_CPU_HAS_LLSC=y 122CONFIG_CPU_HAS_LLSC=y
131CONFIG_CPU_HAS_SYNC=y 123CONFIG_CPU_HAS_SYNC=y
132CONFIG_GENERIC_HARDIRQS=y 124CONFIG_GENERIC_HARDIRQS=y
133CONFIG_GENERIC_IRQ_PROBE=y 125CONFIG_GENERIC_IRQ_PROBE=y
126CONFIG_CPU_SUPPORTS_HIGHMEM=y
134CONFIG_ARCH_FLATMEM_ENABLE=y 127CONFIG_ARCH_FLATMEM_ENABLE=y
135CONFIG_SELECT_MEMORY_MODEL=y 128CONFIG_SELECT_MEMORY_MODEL=y
136CONFIG_FLATMEM_MANUAL=y 129CONFIG_FLATMEM_MANUAL=y
@@ -144,12 +137,12 @@ CONFIG_SPLIT_PTLOCK_CPUS=4
144# CONFIG_HZ_48 is not set 137# CONFIG_HZ_48 is not set
145# CONFIG_HZ_100 is not set 138# CONFIG_HZ_100 is not set
146# CONFIG_HZ_128 is not set 139# CONFIG_HZ_128 is not set
147# CONFIG_HZ_250 is not set 140CONFIG_HZ_250=y
148# CONFIG_HZ_256 is not set 141# CONFIG_HZ_256 is not set
149CONFIG_HZ_1000=y 142# CONFIG_HZ_1000 is not set
150# CONFIG_HZ_1024 is not set 143# CONFIG_HZ_1024 is not set
151CONFIG_SYS_SUPPORTS_ARBIT_HZ=y 144CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
152CONFIG_HZ=1000 145CONFIG_HZ=250
153CONFIG_PREEMPT_NONE=y 146CONFIG_PREEMPT_NONE=y
154# CONFIG_PREEMPT_VOLUNTARY is not set 147# CONFIG_PREEMPT_VOLUNTARY is not set
155# CONFIG_PREEMPT is not set 148# CONFIG_PREEMPT is not set
@@ -171,16 +164,20 @@ CONFIG_LOCALVERSION=""
171CONFIG_LOCALVERSION_AUTO=y 164CONFIG_LOCALVERSION_AUTO=y
172CONFIG_SWAP=y 165CONFIG_SWAP=y
173CONFIG_SYSVIPC=y 166CONFIG_SYSVIPC=y
167# CONFIG_IPC_NS is not set
174# CONFIG_POSIX_MQUEUE is not set 168# CONFIG_POSIX_MQUEUE is not set
175# CONFIG_BSD_PROCESS_ACCT is not set 169# CONFIG_BSD_PROCESS_ACCT is not set
176CONFIG_SYSCTL=y 170# CONFIG_TASKSTATS is not set
171# CONFIG_UTS_NS is not set
177# CONFIG_AUDIT is not set 172# CONFIG_AUDIT is not set
178CONFIG_IKCONFIG=y 173CONFIG_IKCONFIG=y
179CONFIG_IKCONFIG_PROC=y 174CONFIG_IKCONFIG_PROC=y
180# CONFIG_RELAY is not set 175# CONFIG_RELAY is not set
181CONFIG_INITRAMFS_SOURCE="" 176CONFIG_INITRAMFS_SOURCE=""
182# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 177# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
178CONFIG_SYSCTL=y
183CONFIG_EMBEDDED=y 179CONFIG_EMBEDDED=y
180# CONFIG_SYSCTL_SYSCALL is not set
184CONFIG_KALLSYMS=y 181CONFIG_KALLSYMS=y
185# CONFIG_KALLSYMS_EXTRA_PASS is not set 182# CONFIG_KALLSYMS_EXTRA_PASS is not set
186CONFIG_HOTPLUG=y 183CONFIG_HOTPLUG=y
@@ -188,12 +185,12 @@ CONFIG_PRINTK=y
188CONFIG_BUG=y 185CONFIG_BUG=y
189CONFIG_ELF_CORE=y 186CONFIG_ELF_CORE=y
190CONFIG_BASE_FULL=y 187CONFIG_BASE_FULL=y
191CONFIG_RT_MUTEXES=y
192CONFIG_FUTEX=y 188CONFIG_FUTEX=y
193CONFIG_EPOLL=y 189CONFIG_EPOLL=y
194CONFIG_SHMEM=y 190CONFIG_SHMEM=y
195CONFIG_SLAB=y 191CONFIG_SLAB=y
196CONFIG_VM_EVENT_COUNTERS=y 192CONFIG_VM_EVENT_COUNTERS=y
193CONFIG_RT_MUTEXES=y
197# CONFIG_TINY_SHMEM is not set 194# CONFIG_TINY_SHMEM is not set
198CONFIG_BASE_SMALL=0 195CONFIG_BASE_SMALL=0
199# CONFIG_SLOB is not set 196# CONFIG_SLOB is not set
@@ -210,6 +207,7 @@ CONFIG_KMOD=y
210# 207#
211# Block layer 208# Block layer
212# 209#
210CONFIG_BLOCK=y
213# CONFIG_LBD is not set 211# CONFIG_LBD is not set
214# CONFIG_BLK_DEV_IO_TRACE is not set 212# CONFIG_BLK_DEV_IO_TRACE is not set
215# CONFIG_LSF is not set 213# CONFIG_LSF is not set
@@ -230,8 +228,9 @@ CONFIG_DEFAULT_IOSCHED="anticipatory"
230# 228#
231# Bus options (PCI, PCMCIA, EISA, ISA, TC) 229# Bus options (PCI, PCMCIA, EISA, ISA, TC)
232# 230#
233CONFIG_HW_HAS_EISA=y 231CONFIG_HW_HAS_PCI=y
234# CONFIG_EISA is not set 232CONFIG_PCI=y
233# CONFIG_PCI_MULTITHREAD_PROBE is not set
235CONFIG_MMU=y 234CONFIG_MMU=y
236 235
237# 236#
@@ -242,6 +241,7 @@ CONFIG_MMU=y
242# 241#
243# PCI Hotplug Support 242# PCI Hotplug Support
244# 243#
244# CONFIG_HOTPLUG_PCI is not set
245 245
246# 246#
247# Executable file formats 247# Executable file formats
@@ -264,6 +264,7 @@ CONFIG_PACKET=y
264CONFIG_UNIX=y 264CONFIG_UNIX=y
265CONFIG_XFRM=y 265CONFIG_XFRM=y
266# CONFIG_XFRM_USER is not set 266# CONFIG_XFRM_USER is not set
267# CONFIG_XFRM_SUB_POLICY is not set
267# CONFIG_NET_KEY is not set 268# CONFIG_NET_KEY is not set
268CONFIG_INET=y 269CONFIG_INET=y
269# CONFIG_IP_MULTICAST is not set 270# CONFIG_IP_MULTICAST is not set
@@ -282,12 +283,14 @@ CONFIG_IP_PNP=y
282# CONFIG_INET_IPCOMP is not set 283# CONFIG_INET_IPCOMP is not set
283# CONFIG_INET_XFRM_TUNNEL is not set 284# CONFIG_INET_XFRM_TUNNEL is not set
284# CONFIG_INET_TUNNEL is not set 285# CONFIG_INET_TUNNEL is not set
285CONFIG_INET_XFRM_MODE_TRANSPORT=m 286CONFIG_INET_XFRM_MODE_TRANSPORT=y
286CONFIG_INET_XFRM_MODE_TUNNEL=m 287CONFIG_INET_XFRM_MODE_TUNNEL=y
288CONFIG_INET_XFRM_MODE_BEET=y
287CONFIG_INET_DIAG=y 289CONFIG_INET_DIAG=y
288CONFIG_INET_TCP_DIAG=y 290CONFIG_INET_TCP_DIAG=y
289# CONFIG_TCP_CONG_ADVANCED is not set 291# CONFIG_TCP_CONG_ADVANCED is not set
290CONFIG_TCP_CONG_BIC=y 292CONFIG_TCP_CONG_CUBIC=y
293CONFIG_DEFAULT_TCP_CONG="cubic"
291 294
292# 295#
293# IP: Virtual Server Configuration 296# IP: Virtual Server Configuration
@@ -300,12 +303,18 @@ CONFIG_IPV6_ROUTE_INFO=y
300# CONFIG_INET6_AH is not set 303# CONFIG_INET6_AH is not set
301# CONFIG_INET6_ESP is not set 304# CONFIG_INET6_ESP is not set
302# CONFIG_INET6_IPCOMP is not set 305# CONFIG_INET6_IPCOMP is not set
306# CONFIG_IPV6_MIP6 is not set
303# CONFIG_INET6_XFRM_TUNNEL is not set 307# CONFIG_INET6_XFRM_TUNNEL is not set
304# CONFIG_INET6_TUNNEL is not set 308# CONFIG_INET6_TUNNEL is not set
305CONFIG_INET6_XFRM_MODE_TRANSPORT=m 309CONFIG_INET6_XFRM_MODE_TRANSPORT=m
306CONFIG_INET6_XFRM_MODE_TUNNEL=m 310CONFIG_INET6_XFRM_MODE_TUNNEL=m
311CONFIG_INET6_XFRM_MODE_BEET=m
312# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
313CONFIG_IPV6_SIT=m
307# CONFIG_IPV6_TUNNEL is not set 314# CONFIG_IPV6_TUNNEL is not set
308CONFIG_NETWORK_SECMARK=y 315# CONFIG_IPV6_SUBTREES is not set
316# CONFIG_IPV6_MULTIPLE_TABLES is not set
317# CONFIG_NETWORK_SECMARK is not set
309CONFIG_NETFILTER=y 318CONFIG_NETFILTER=y
310# CONFIG_NETFILTER_DEBUG is not set 319# CONFIG_NETFILTER_DEBUG is not set
311 320
@@ -318,9 +327,9 @@ CONFIG_NETFILTER_XTABLES=m
318CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m 327CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
319CONFIG_NETFILTER_XT_TARGET_MARK=m 328CONFIG_NETFILTER_XT_TARGET_MARK=m
320CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m 329CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m
321CONFIG_NETFILTER_XT_TARGET_SECMARK=m
322CONFIG_NETFILTER_XT_MATCH_COMMENT=m 330CONFIG_NETFILTER_XT_MATCH_COMMENT=m
323CONFIG_NETFILTER_XT_MATCH_DCCP=m 331CONFIG_NETFILTER_XT_MATCH_DCCP=m
332# CONFIG_NETFILTER_XT_MATCH_DSCP is not set
324CONFIG_NETFILTER_XT_MATCH_ESP=m 333CONFIG_NETFILTER_XT_MATCH_ESP=m
325CONFIG_NETFILTER_XT_MATCH_LENGTH=m 334CONFIG_NETFILTER_XT_MATCH_LENGTH=m
326CONFIG_NETFILTER_XT_MATCH_LIMIT=m 335CONFIG_NETFILTER_XT_MATCH_LIMIT=m
@@ -329,10 +338,10 @@ CONFIG_NETFILTER_XT_MATCH_MARK=m
329# CONFIG_NETFILTER_XT_MATCH_POLICY is not set 338# CONFIG_NETFILTER_XT_MATCH_POLICY is not set
330CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m 339CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m
331CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m 340CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m
332CONFIG_NETFILTER_XT_MATCH_QUOTA=m 341# CONFIG_NETFILTER_XT_MATCH_QUOTA is not set
333CONFIG_NETFILTER_XT_MATCH_REALM=m 342CONFIG_NETFILTER_XT_MATCH_REALM=m
334CONFIG_NETFILTER_XT_MATCH_SCTP=m 343CONFIG_NETFILTER_XT_MATCH_SCTP=m
335CONFIG_NETFILTER_XT_MATCH_STATISTIC=m 344# CONFIG_NETFILTER_XT_MATCH_STATISTIC is not set
336CONFIG_NETFILTER_XT_MATCH_STRING=m 345CONFIG_NETFILTER_XT_MATCH_STRING=m
337CONFIG_NETFILTER_XT_MATCH_TCPMSS=m 346CONFIG_NETFILTER_XT_MATCH_TCPMSS=m
338 347
@@ -373,7 +382,6 @@ CONFIG_NETFILTER_XT_MATCH_TCPMSS=m
373# CONFIG_ATALK is not set 382# CONFIG_ATALK is not set
374# CONFIG_X25 is not set 383# CONFIG_X25 is not set
375# CONFIG_LAPB is not set 384# CONFIG_LAPB is not set
376# CONFIG_NET_DIVERT is not set
377# CONFIG_ECONET is not set 385# CONFIG_ECONET is not set
378# CONFIG_WAN_ROUTER is not set 386# CONFIG_WAN_ROUTER is not set
379 387
@@ -426,13 +434,20 @@ CONFIG_FW_LOADER=y
426# 434#
427# Block devices 435# Block devices
428# 436#
437# CONFIG_BLK_CPQ_DA is not set
438# CONFIG_BLK_CPQ_CISS_DA is not set
439# CONFIG_BLK_DEV_DAC960 is not set
440# CONFIG_BLK_DEV_UMEM is not set
429# CONFIG_BLK_DEV_COW_COMMON is not set 441# CONFIG_BLK_DEV_COW_COMMON is not set
430CONFIG_BLK_DEV_LOOP=y 442CONFIG_BLK_DEV_LOOP=y
431# CONFIG_BLK_DEV_CRYPTOLOOP is not set 443# CONFIG_BLK_DEV_CRYPTOLOOP is not set
432# CONFIG_BLK_DEV_NBD is not set 444# CONFIG_BLK_DEV_NBD is not set
445# CONFIG_BLK_DEV_SX8 is not set
446# CONFIG_BLK_DEV_UB is not set
433CONFIG_BLK_DEV_RAM=y 447CONFIG_BLK_DEV_RAM=y
434CONFIG_BLK_DEV_RAM_COUNT=16 448CONFIG_BLK_DEV_RAM_COUNT=16
435CONFIG_BLK_DEV_RAM_SIZE=8192 449CONFIG_BLK_DEV_RAM_SIZE=8192
450CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
436CONFIG_BLK_DEV_INITRD=y 451CONFIG_BLK_DEV_INITRD=y
437# CONFIG_CDROM_PKTCDVD is not set 452# CONFIG_CDROM_PKTCDVD is not set
438# CONFIG_ATA_OVER_ETH is not set 453# CONFIG_ATA_OVER_ETH is not set
@@ -441,6 +456,7 @@ CONFIG_BLK_DEV_INITRD=y
441# ATA/ATAPI/MFM/RLL support 456# ATA/ATAPI/MFM/RLL support
442# 457#
443CONFIG_IDE=y 458CONFIG_IDE=y
459CONFIG_IDE_MAX_HWIFS=4
444CONFIG_BLK_DEV_IDE=y 460CONFIG_BLK_DEV_IDE=y
445 461
446# 462#
@@ -459,9 +475,41 @@ CONFIG_IDEDISK_MULTI_MODE=y
459# IDE chipset support/bugfixes 475# IDE chipset support/bugfixes
460# 476#
461CONFIG_IDE_GENERIC=y 477CONFIG_IDE_GENERIC=y
478CONFIG_BLK_DEV_IDEPCI=y
479CONFIG_IDEPCI_SHARE_IRQ=y
480# CONFIG_BLK_DEV_OFFBOARD is not set
481# CONFIG_BLK_DEV_GENERIC is not set
482# CONFIG_BLK_DEV_OPTI621 is not set
483CONFIG_BLK_DEV_IDEDMA_PCI=y
484# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
485CONFIG_IDEDMA_PCI_AUTO=y
486# CONFIG_IDEDMA_ONLYDISK is not set
487# CONFIG_BLK_DEV_AEC62XX is not set
488# CONFIG_BLK_DEV_ALI15X3 is not set
489# CONFIG_BLK_DEV_AMD74XX is not set
490CONFIG_BLK_DEV_CMD64X=y
491# CONFIG_BLK_DEV_TRIFLEX is not set
492# CONFIG_BLK_DEV_CY82C693 is not set
493# CONFIG_BLK_DEV_CS5520 is not set
494# CONFIG_BLK_DEV_CS5530 is not set
495# CONFIG_BLK_DEV_HPT34X is not set
496# CONFIG_BLK_DEV_HPT366 is not set
497# CONFIG_BLK_DEV_JMICRON is not set
498# CONFIG_BLK_DEV_SC1200 is not set
499# CONFIG_BLK_DEV_PIIX is not set
500# CONFIG_BLK_DEV_IT821X is not set
501# CONFIG_BLK_DEV_NS87415 is not set
502# CONFIG_BLK_DEV_PDC202XX_OLD is not set
503# CONFIG_BLK_DEV_PDC202XX_NEW is not set
504# CONFIG_BLK_DEV_SVWKS is not set
505# CONFIG_BLK_DEV_SIIMAGE is not set
506# CONFIG_BLK_DEV_SLC90E66 is not set
507# CONFIG_BLK_DEV_TRM290 is not set
508# CONFIG_BLK_DEV_VIA82CXXX is not set
462# CONFIG_IDE_ARM is not set 509# CONFIG_IDE_ARM is not set
463# CONFIG_BLK_DEV_IDEDMA is not set 510CONFIG_BLK_DEV_IDEDMA=y
464# CONFIG_IDEDMA_AUTO is not set 511# CONFIG_IDEDMA_IVB is not set
512CONFIG_IDEDMA_AUTO=y
465# CONFIG_BLK_DEV_HD is not set 513# CONFIG_BLK_DEV_HD is not set
466 514
467# 515#
@@ -469,6 +517,7 @@ CONFIG_IDE_GENERIC=y
469# 517#
470# CONFIG_RAID_ATTRS is not set 518# CONFIG_RAID_ATTRS is not set
471CONFIG_SCSI=y 519CONFIG_SCSI=y
520CONFIG_SCSI_NETLINK=y
472CONFIG_SCSI_PROC_FS=y 521CONFIG_SCSI_PROC_FS=y
473 522
474# 523#
@@ -489,22 +538,59 @@ CONFIG_BLK_DEV_SD=y
489# CONFIG_SCSI_LOGGING is not set 538# CONFIG_SCSI_LOGGING is not set
490 539
491# 540#
492# SCSI Transport Attributes 541# SCSI Transports
493# 542#
494CONFIG_SCSI_SPI_ATTRS=m 543CONFIG_SCSI_SPI_ATTRS=m
495CONFIG_SCSI_FC_ATTRS=y 544CONFIG_SCSI_FC_ATTRS=y
496CONFIG_SCSI_ISCSI_ATTRS=m 545CONFIG_SCSI_ISCSI_ATTRS=m
497# CONFIG_SCSI_SAS_ATTRS is not set 546# CONFIG_SCSI_SAS_ATTRS is not set
547# CONFIG_SCSI_SAS_LIBSAS is not set
498 548
499# 549#
500# SCSI low-level drivers 550# SCSI low-level drivers
501# 551#
502CONFIG_ISCSI_TCP=m 552CONFIG_ISCSI_TCP=m
503# CONFIG_SGIWD93_SCSI is not set 553# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
504# CONFIG_SCSI_SATA is not set 554# CONFIG_SCSI_3W_9XXX is not set
555# CONFIG_SCSI_ACARD is not set
556# CONFIG_SCSI_AACRAID is not set
557CONFIG_SCSI_AIC7XXX=m
558CONFIG_AIC7XXX_CMDS_PER_DEVICE=32
559CONFIG_AIC7XXX_RESET_DELAY_MS=15000
560# CONFIG_AIC7XXX_DEBUG_ENABLE is not set
561CONFIG_AIC7XXX_DEBUG_MASK=0
562# CONFIG_AIC7XXX_REG_PRETTY_PRINT is not set
563# CONFIG_SCSI_AIC7XXX_OLD is not set
564# CONFIG_SCSI_AIC79XX is not set
565# CONFIG_SCSI_AIC94XX is not set
566# CONFIG_SCSI_DPT_I2O is not set
567# CONFIG_SCSI_ARCMSR is not set
568# CONFIG_MEGARAID_NEWGEN is not set
569# CONFIG_MEGARAID_LEGACY is not set
570# CONFIG_MEGARAID_SAS is not set
571# CONFIG_SCSI_HPTIOP is not set
572# CONFIG_SCSI_DMX3191D is not set
573# CONFIG_SCSI_FUTURE_DOMAIN is not set
574# CONFIG_SCSI_IPS is not set
575# CONFIG_SCSI_INITIO is not set
576# CONFIG_SCSI_INIA100 is not set
577# CONFIG_SCSI_STEX is not set
578# CONFIG_SCSI_SYM53C8XX_2 is not set
579# CONFIG_SCSI_QLOGIC_1280 is not set
580# CONFIG_SCSI_QLA_FC is not set
581# CONFIG_SCSI_QLA_ISCSI is not set
582# CONFIG_SCSI_LPFC is not set
583# CONFIG_SCSI_DC395x is not set
584# CONFIG_SCSI_DC390T is not set
585# CONFIG_SCSI_NSP32 is not set
505# CONFIG_SCSI_DEBUG is not set 586# CONFIG_SCSI_DEBUG is not set
506 587
507# 588#
589# Serial ATA (prod) and Parallel ATA (experimental) drivers
590#
591# CONFIG_ATA is not set
592
593#
508# Multi-device support (RAID and LVM) 594# Multi-device support (RAID and LVM)
509# 595#
510# CONFIG_MD is not set 596# CONFIG_MD is not set
@@ -513,14 +599,19 @@ CONFIG_ISCSI_TCP=m
513# Fusion MPT device support 599# Fusion MPT device support
514# 600#
515# CONFIG_FUSION is not set 601# CONFIG_FUSION is not set
602# CONFIG_FUSION_SPI is not set
603# CONFIG_FUSION_FC is not set
604# CONFIG_FUSION_SAS is not set
516 605
517# 606#
518# IEEE 1394 (FireWire) support 607# IEEE 1394 (FireWire) support
519# 608#
609# CONFIG_IEEE1394 is not set
520 610
521# 611#
522# I2O device support 612# I2O device support
523# 613#
614# CONFIG_I2O is not set
524 615
525# 616#
526# Network device support 617# Network device support
@@ -532,6 +623,11 @@ CONFIG_NETDEVICES=y
532CONFIG_TUN=m 623CONFIG_TUN=m
533 624
534# 625#
626# ARCnet devices
627#
628# CONFIG_ARCNET is not set
629
630#
535# PHY device support 631# PHY device support
536# 632#
537# CONFIG_PHYLIB is not set 633# CONFIG_PHYLIB is not set
@@ -541,20 +637,73 @@ CONFIG_TUN=m
541# 637#
542CONFIG_NET_ETHERNET=y 638CONFIG_NET_ETHERNET=y
543CONFIG_MII=y 639CONFIG_MII=y
640# CONFIG_HAPPYMEAL is not set
641# CONFIG_SUNGEM is not set
642# CONFIG_CASSINI is not set
643# CONFIG_NET_VENDOR_3COM is not set
544# CONFIG_DM9000 is not set 644# CONFIG_DM9000 is not set
545# CONFIG_SGISEEQ is not set 645
646#
647# Tulip family network device support
648#
649# CONFIG_NET_TULIP is not set
650# CONFIG_HP100 is not set
651CONFIG_NET_PCI=y
652# CONFIG_PCNET32 is not set
653# CONFIG_AMD8111_ETH is not set
654# CONFIG_ADAPTEC_STARFIRE is not set
655# CONFIG_B44 is not set
656# CONFIG_FORCEDETH is not set
657# CONFIG_DGRS is not set
658# CONFIG_EEPRO100 is not set
659# CONFIG_E100 is not set
660# CONFIG_FEALNX is not set
661CONFIG_NATSEMI=y
662# CONFIG_NE2K_PCI is not set
663# CONFIG_8139CP is not set
664CONFIG_8139TOO=y
665# CONFIG_8139TOO_PIO is not set
666# CONFIG_8139TOO_TUNE_TWISTER is not set
667# CONFIG_8139TOO_8129 is not set
668# CONFIG_8139_OLD_RX_RESET is not set
669# CONFIG_SIS900 is not set
670# CONFIG_EPIC100 is not set
671# CONFIG_SUNDANCE is not set
672# CONFIG_TLAN is not set
673# CONFIG_VIA_RHINE is not set
674# CONFIG_LAN_SAA9730 is not set
546 675
547# 676#
548# Ethernet (1000 Mbit) 677# Ethernet (1000 Mbit)
549# 678#
679# CONFIG_ACENIC is not set
680# CONFIG_DL2K is not set
681# CONFIG_E1000 is not set
682# CONFIG_NS83820 is not set
683# CONFIG_HAMACHI is not set
684# CONFIG_YELLOWFIN is not set
685# CONFIG_R8169 is not set
686# CONFIG_SIS190 is not set
687# CONFIG_SKGE is not set
688# CONFIG_SKY2 is not set
689# CONFIG_SK98LIN is not set
690# CONFIG_VIA_VELOCITY is not set
691# CONFIG_TIGON3 is not set
692# CONFIG_BNX2 is not set
693# CONFIG_QLA3XXX is not set
550 694
551# 695#
552# Ethernet (10000 Mbit) 696# Ethernet (10000 Mbit)
553# 697#
698# CONFIG_CHELSIO_T1 is not set
699# CONFIG_IXGB is not set
700# CONFIG_S2IO is not set
701# CONFIG_MYRI10GE is not set
554 702
555# 703#
556# Token Ring devices 704# Token Ring devices
557# 705#
706# CONFIG_TR is not set
558 707
559# 708#
560# Wireless LAN (non-hamradio) 709# Wireless LAN (non-hamradio)
@@ -565,6 +714,8 @@ CONFIG_MII=y
565# Wan interfaces 714# Wan interfaces
566# 715#
567# CONFIG_WAN is not set 716# CONFIG_WAN is not set
717# CONFIG_FDDI is not set
718# CONFIG_HIPPI is not set
568CONFIG_PPP=m 719CONFIG_PPP=m
569# CONFIG_PPP_MULTILINK is not set 720# CONFIG_PPP_MULTILINK is not set
570# CONFIG_PPP_FILTER is not set 721# CONFIG_PPP_FILTER is not set
@@ -575,6 +726,8 @@ CONFIG_PPP_DEFLATE=m
575CONFIG_PPP_MPPE=m 726CONFIG_PPP_MPPE=m
576# CONFIG_PPPOE is not set 727# CONFIG_PPPOE is not set
577# CONFIG_SLIP is not set 728# CONFIG_SLIP is not set
729CONFIG_SLHC=m
730# CONFIG_NET_FC is not set
578# CONFIG_SHAPER is not set 731# CONFIG_SHAPER is not set
579# CONFIG_NETCONSOLE is not set 732# CONFIG_NETCONSOLE is not set
580# CONFIG_NETPOLL is not set 733# CONFIG_NETPOLL is not set
@@ -594,6 +747,7 @@ CONFIG_PPP_MPPE=m
594# Input device support 747# Input device support
595# 748#
596CONFIG_INPUT=y 749CONFIG_INPUT=y
750# CONFIG_INPUT_FF_MEMLESS is not set
597 751
598# 752#
599# Userland interfaces 753# Userland interfaces
@@ -616,6 +770,7 @@ CONFIG_KEYBOARD_ATKBD=y
616# CONFIG_KEYBOARD_LKKBD is not set 770# CONFIG_KEYBOARD_LKKBD is not set
617# CONFIG_KEYBOARD_XTKBD is not set 771# CONFIG_KEYBOARD_XTKBD is not set
618# CONFIG_KEYBOARD_NEWTON is not set 772# CONFIG_KEYBOARD_NEWTON is not set
773# CONFIG_KEYBOARD_STOWAWAY is not set
619CONFIG_INPUT_MOUSE=y 774CONFIG_INPUT_MOUSE=y
620CONFIG_MOUSE_PS2=y 775CONFIG_MOUSE_PS2=y
621# CONFIG_MOUSE_SERIAL is not set 776# CONFIG_MOUSE_SERIAL is not set
@@ -630,6 +785,7 @@ CONFIG_MOUSE_PS2=y
630CONFIG_SERIO=y 785CONFIG_SERIO=y
631CONFIG_SERIO_I8042=y 786CONFIG_SERIO_I8042=y
632CONFIG_SERIO_SERPORT=y 787CONFIG_SERIO_SERPORT=y
788# CONFIG_SERIO_PCIPS2 is not set
633CONFIG_SERIO_LIBPS2=y 789CONFIG_SERIO_LIBPS2=y
634# CONFIG_SERIO_RAW is not set 790# CONFIG_SERIO_RAW is not set
635# CONFIG_GAMEPORT is not set 791# CONFIG_GAMEPORT is not set
@@ -640,7 +796,7 @@ CONFIG_SERIO_LIBPS2=y
640CONFIG_VT=y 796CONFIG_VT=y
641# CONFIG_VT_CONSOLE is not set 797# CONFIG_VT_CONSOLE is not set
642CONFIG_HW_CONSOLE=y 798CONFIG_HW_CONSOLE=y
643CONFIG_VT_HW_CONSOLE_BINDING=y 799# CONFIG_VT_HW_CONSOLE_BINDING is not set
644CONFIG_SERIAL_NONSTANDARD=y 800CONFIG_SERIAL_NONSTANDARD=y
645# CONFIG_COMPUTONE is not set 801# CONFIG_COMPUTONE is not set
646# CONFIG_ROCKETPORT is not set 802# CONFIG_ROCKETPORT is not set
@@ -650,6 +806,7 @@ CONFIG_SERIAL_NONSTANDARD=y
650# CONFIG_MOXA_SMARTIO is not set 806# CONFIG_MOXA_SMARTIO is not set
651# CONFIG_ISI is not set 807# CONFIG_ISI is not set
652# CONFIG_SYNCLINKMP is not set 808# CONFIG_SYNCLINKMP is not set
809# CONFIG_SYNCLINK_GT is not set
653# CONFIG_N_HDLC is not set 810# CONFIG_N_HDLC is not set
654# CONFIG_RISCOM8 is not set 811# CONFIG_RISCOM8 is not set
655# CONFIG_SPECIALIX is not set 812# CONFIG_SPECIALIX is not set
@@ -665,7 +822,8 @@ CONFIG_SERIAL_NONSTANDARD=y
665# 822#
666# Non-8250 serial port support 823# Non-8250 serial port support
667# 824#
668# CONFIG_SERIAL_IP22_ZILOG is not set 825# CONFIG_SERIAL_IP3106 is not set
826# CONFIG_SERIAL_JSM is not set
669CONFIG_UNIX98_PTYS=y 827CONFIG_UNIX98_PTYS=y
670CONFIG_LEGACY_PTYS=y 828CONFIG_LEGACY_PTYS=y
671CONFIG_LEGACY_PTY_COUNT=256 829CONFIG_LEGACY_PTY_COUNT=256
@@ -679,16 +837,17 @@ CONFIG_LEGACY_PTY_COUNT=256
679# Watchdog Cards 837# Watchdog Cards
680# 838#
681# CONFIG_WATCHDOG is not set 839# CONFIG_WATCHDOG is not set
682# CONFIG_HW_RANDOM is not set 840CONFIG_HW_RANDOM=y
683# CONFIG_RTC is not set 841# CONFIG_RTC is not set
684# CONFIG_SGI_DS1286 is not set
685# CONFIG_GEN_RTC is not set 842# CONFIG_GEN_RTC is not set
686# CONFIG_DTLK is not set 843# CONFIG_DTLK is not set
687# CONFIG_R3964 is not set 844# CONFIG_R3964 is not set
845# CONFIG_APPLICOM is not set
688 846
689# 847#
690# Ftape, the floppy tape device driver 848# Ftape, the floppy tape device driver
691# 849#
850# CONFIG_DRM is not set
692# CONFIG_RAW_DRIVER is not set 851# CONFIG_RAW_DRIVER is not set
693 852
694# 853#
@@ -709,14 +868,30 @@ CONFIG_I2C_CHARDEV=m
709CONFIG_I2C_ALGOBIT=m 868CONFIG_I2C_ALGOBIT=m
710# CONFIG_I2C_ALGOPCF is not set 869# CONFIG_I2C_ALGOPCF is not set
711# CONFIG_I2C_ALGOPCA is not set 870# CONFIG_I2C_ALGOPCA is not set
712# CONFIG_I2C_ALGO_SGI is not set
713 871
714# 872#
715# I2C Hardware Bus support 873# I2C Hardware Bus support
716# 874#
875# CONFIG_I2C_ALI1535 is not set
876# CONFIG_I2C_ALI1563 is not set
877# CONFIG_I2C_ALI15X3 is not set
878# CONFIG_I2C_AMD756 is not set
879# CONFIG_I2C_AMD8111 is not set
880# CONFIG_I2C_I801 is not set
881# CONFIG_I2C_I810 is not set
882# CONFIG_I2C_PIIX4 is not set
883# CONFIG_I2C_NFORCE2 is not set
717# CONFIG_I2C_OCORES is not set 884# CONFIG_I2C_OCORES is not set
718# CONFIG_I2C_PARPORT_LIGHT is not set 885# CONFIG_I2C_PARPORT_LIGHT is not set
886# CONFIG_I2C_PROSAVAGE is not set
887# CONFIG_I2C_SAVAGE4 is not set
888# CONFIG_I2C_SIS5595 is not set
889# CONFIG_I2C_SIS630 is not set
890# CONFIG_I2C_SIS96X is not set
719# CONFIG_I2C_STUB is not set 891# CONFIG_I2C_STUB is not set
892# CONFIG_I2C_VIA is not set
893# CONFIG_I2C_VIAPRO is not set
894# CONFIG_I2C_VOODOO3 is not set
720# CONFIG_I2C_PCA_ISA is not set 895# CONFIG_I2C_PCA_ISA is not set
721 896
722# 897#
@@ -776,9 +951,13 @@ CONFIG_HWMON=y
776# CONFIG_SENSORS_LM92 is not set 951# CONFIG_SENSORS_LM92 is not set
777# CONFIG_SENSORS_MAX1619 is not set 952# CONFIG_SENSORS_MAX1619 is not set
778# CONFIG_SENSORS_PC87360 is not set 953# CONFIG_SENSORS_PC87360 is not set
954# CONFIG_SENSORS_SIS5595 is not set
779# CONFIG_SENSORS_SMSC47M1 is not set 955# CONFIG_SENSORS_SMSC47M1 is not set
780# CONFIG_SENSORS_SMSC47M192 is not set 956# CONFIG_SENSORS_SMSC47M192 is not set
781# CONFIG_SENSORS_SMSC47B397 is not set 957# CONFIG_SENSORS_SMSC47B397 is not set
958# CONFIG_SENSORS_VIA686A is not set
959# CONFIG_SENSORS_VT1211 is not set
960# CONFIG_SENSORS_VT8231 is not set
782# CONFIG_SENSORS_W83781D is not set 961# CONFIG_SENSORS_W83781D is not set
783# CONFIG_SENSORS_W83791D is not set 962# CONFIG_SENSORS_W83791D is not set
784# CONFIG_SENSORS_W83792D is not set 963# CONFIG_SENSORS_W83792D is not set
@@ -790,23 +969,25 @@ CONFIG_HWMON=y
790# 969#
791# Misc devices 970# Misc devices
792# 971#
972# CONFIG_TIFM_CORE is not set
793 973
794# 974#
795# Multimedia devices 975# Multimedia devices
796# 976#
797# CONFIG_VIDEO_DEV is not set 977# CONFIG_VIDEO_DEV is not set
798CONFIG_VIDEO_V4L2=y
799 978
800# 979#
801# Digital Video Broadcasting Devices 980# Digital Video Broadcasting Devices
802# 981#
803# CONFIG_DVB is not set 982# CONFIG_DVB is not set
983# CONFIG_USB_DABUSB is not set
804 984
805# 985#
806# Graphics support 986# Graphics support
807# 987#
808# CONFIG_FIRMWARE_EDID is not set 988CONFIG_FIRMWARE_EDID=y
809CONFIG_FB=y 989CONFIG_FB=y
990# CONFIG_FB_DDC is not set
810# CONFIG_FB_CFB_FILLRECT is not set 991# CONFIG_FB_CFB_FILLRECT is not set
811# CONFIG_FB_CFB_COPYAREA is not set 992# CONFIG_FB_CFB_COPYAREA is not set
812# CONFIG_FB_CFB_IMAGEBLIT is not set 993# CONFIG_FB_CFB_IMAGEBLIT is not set
@@ -814,14 +995,32 @@ CONFIG_FB=y
814# CONFIG_FB_BACKLIGHT is not set 995# CONFIG_FB_BACKLIGHT is not set
815# CONFIG_FB_MODE_HELPERS is not set 996# CONFIG_FB_MODE_HELPERS is not set
816# CONFIG_FB_TILEBLITTING is not set 997# CONFIG_FB_TILEBLITTING is not set
998# CONFIG_FB_CIRRUS is not set
999# CONFIG_FB_PM2 is not set
1000# CONFIG_FB_CYBER2000 is not set
1001# CONFIG_FB_ASILIANT is not set
1002# CONFIG_FB_IMSTT is not set
817# CONFIG_FB_S1D13XXX is not set 1003# CONFIG_FB_S1D13XXX is not set
1004# CONFIG_FB_NVIDIA is not set
1005# CONFIG_FB_RIVA is not set
1006# CONFIG_FB_MATROX is not set
1007# CONFIG_FB_RADEON is not set
1008# CONFIG_FB_ATY128 is not set
1009# CONFIG_FB_ATY is not set
1010# CONFIG_FB_SAVAGE is not set
1011# CONFIG_FB_SIS is not set
1012# CONFIG_FB_NEOMAGIC is not set
1013# CONFIG_FB_KYRO is not set
1014# CONFIG_FB_3DFX is not set
1015# CONFIG_FB_VOODOO1 is not set
1016# CONFIG_FB_SMIVGX is not set
1017# CONFIG_FB_TRIDENT is not set
818# CONFIG_FB_VIRTUAL is not set 1018# CONFIG_FB_VIRTUAL is not set
819 1019
820# 1020#
821# Console display driver support 1021# Console display driver support
822# 1022#
823# CONFIG_VGA_CONSOLE is not set 1023# CONFIG_VGA_CONSOLE is not set
824# CONFIG_SGI_NEWPORT_CONSOLE is not set
825CONFIG_DUMMY_CONSOLE=y 1024CONFIG_DUMMY_CONSOLE=y
826# CONFIG_FRAMEBUFFER_CONSOLE is not set 1025# CONFIG_FRAMEBUFFER_CONSOLE is not set
827 1026
@@ -839,15 +1038,129 @@ CONFIG_DUMMY_CONSOLE=y
839# 1038#
840# USB support 1039# USB support
841# 1040#
842# CONFIG_USB_ARCH_HAS_HCD is not set 1041CONFIG_USB_ARCH_HAS_HCD=y
843# CONFIG_USB_ARCH_HAS_OHCI is not set 1042CONFIG_USB_ARCH_HAS_OHCI=y
844# CONFIG_USB_ARCH_HAS_EHCI is not set 1043CONFIG_USB_ARCH_HAS_EHCI=y
1044CONFIG_USB=y
1045# CONFIG_USB_DEBUG is not set
1046
1047#
1048# Miscellaneous USB options
1049#
1050CONFIG_USB_DEVICEFS=y
1051# CONFIG_USB_BANDWIDTH is not set
1052# CONFIG_USB_DYNAMIC_MINORS is not set
1053# CONFIG_USB_OTG is not set
1054
1055#
1056# USB Host Controller Drivers
1057#
1058# CONFIG_USB_EHCI_HCD is not set
1059# CONFIG_USB_ISP116X_HCD is not set
1060# CONFIG_USB_OHCI_HCD is not set
1061# CONFIG_USB_UHCI_HCD is not set
1062# CONFIG_USB_SL811_HCD is not set
1063
1064#
1065# USB Device Class drivers
1066#
1067# CONFIG_USB_ACM is not set
1068# CONFIG_USB_PRINTER is not set
845 1069
846# 1070#
847# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' 1071# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
848# 1072#
849 1073
850# 1074#
1075# may also be needed; see USB_STORAGE Help for more information
1076#
1077CONFIG_USB_STORAGE=y
1078# CONFIG_USB_STORAGE_DEBUG is not set
1079# CONFIG_USB_STORAGE_DATAFAB is not set
1080# CONFIG_USB_STORAGE_FREECOM is not set
1081# CONFIG_USB_STORAGE_ISD200 is not set
1082# CONFIG_USB_STORAGE_DPCM is not set
1083# CONFIG_USB_STORAGE_USBAT is not set
1084# CONFIG_USB_STORAGE_SDDR09 is not set
1085# CONFIG_USB_STORAGE_SDDR55 is not set
1086# CONFIG_USB_STORAGE_JUMPSHOT is not set
1087# CONFIG_USB_STORAGE_ALAUDA is not set
1088# CONFIG_USB_STORAGE_ONETOUCH is not set
1089# CONFIG_USB_STORAGE_KARMA is not set
1090# CONFIG_USB_LIBUSUAL is not set
1091
1092#
1093# USB Input Devices
1094#
1095CONFIG_USB_HID=y
1096CONFIG_USB_HIDINPUT=y
1097# CONFIG_USB_HIDINPUT_POWERBOOK is not set
1098# CONFIG_HID_FF is not set
1099CONFIG_USB_HIDDEV=y
1100# CONFIG_USB_AIPTEK is not set
1101# CONFIG_USB_WACOM is not set
1102# CONFIG_USB_ACECAD is not set
1103# CONFIG_USB_KBTAB is not set
1104# CONFIG_USB_POWERMATE is not set
1105# CONFIG_USB_TOUCHSCREEN is not set
1106# CONFIG_USB_YEALINK is not set
1107# CONFIG_USB_XPAD is not set
1108# CONFIG_USB_ATI_REMOTE is not set
1109# CONFIG_USB_ATI_REMOTE2 is not set
1110# CONFIG_USB_KEYSPAN_REMOTE is not set
1111# CONFIG_USB_APPLETOUCH is not set
1112# CONFIG_USB_TRANCEVIBRATOR is not set
1113
1114#
1115# USB Imaging devices
1116#
1117# CONFIG_USB_MDC800 is not set
1118# CONFIG_USB_MICROTEK is not set
1119
1120#
1121# USB Network Adapters
1122#
1123# CONFIG_USB_CATC is not set
1124# CONFIG_USB_KAWETH is not set
1125# CONFIG_USB_PEGASUS is not set
1126# CONFIG_USB_RTL8150 is not set
1127# CONFIG_USB_USBNET is not set
1128CONFIG_USB_MON=y
1129
1130#
1131# USB port drivers
1132#
1133
1134#
1135# USB Serial Converter support
1136#
1137# CONFIG_USB_SERIAL is not set
1138
1139#
1140# USB Miscellaneous drivers
1141#
1142# CONFIG_USB_EMI62 is not set
1143# CONFIG_USB_EMI26 is not set
1144# CONFIG_USB_ADUTUX is not set
1145# CONFIG_USB_AUERSWALD is not set
1146# CONFIG_USB_RIO500 is not set
1147# CONFIG_USB_LEGOTOWER is not set
1148# CONFIG_USB_LCD is not set
1149# CONFIG_USB_LED is not set
1150# CONFIG_USB_CYPRESS_CY7C63 is not set
1151# CONFIG_USB_CYTHERM is not set
1152# CONFIG_USB_PHIDGET is not set
1153# CONFIG_USB_IDMOUSE is not set
1154# CONFIG_USB_FTDI_ELAN is not set
1155# CONFIG_USB_APPLEDISPLAY is not set
1156# CONFIG_USB_LD is not set
1157# CONFIG_USB_TEST is not set
1158
1159#
1160# USB DSL modem support
1161#
1162
1163#
851# USB Gadget Support 1164# USB Gadget Support
852# 1165#
853# CONFIG_USB_GADGET is not set 1166# CONFIG_USB_GADGET is not set
@@ -873,6 +1186,7 @@ CONFIG_DUMMY_CONSOLE=y
873# 1186#
874# InfiniBand support 1187# InfiniBand support
875# 1188#
1189# CONFIG_INFINIBAND is not set
876 1190
877# 1191#
878# EDAC - error detection and reporting (RAS) (EXPERIMENTAL) 1192# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
@@ -906,6 +1220,7 @@ CONFIG_EXT3_FS=y
906CONFIG_EXT3_FS_XATTR=y 1220CONFIG_EXT3_FS_XATTR=y
907# CONFIG_EXT3_FS_POSIX_ACL is not set 1221# CONFIG_EXT3_FS_POSIX_ACL is not set
908# CONFIG_EXT3_FS_SECURITY is not set 1222# CONFIG_EXT3_FS_SECURITY is not set
1223# CONFIG_EXT4DEV_FS is not set
909CONFIG_JBD=y 1224CONFIG_JBD=y
910# CONFIG_JBD_DEBUG is not set 1225# CONFIG_JBD_DEBUG is not set
911CONFIG_FS_MBCACHE=y 1226CONFIG_FS_MBCACHE=y
@@ -917,6 +1232,7 @@ CONFIG_XFS_FS=m
917# CONFIG_XFS_SECURITY is not set 1232# CONFIG_XFS_SECURITY is not set
918# CONFIG_XFS_POSIX_ACL is not set 1233# CONFIG_XFS_POSIX_ACL is not set
919# CONFIG_XFS_RT is not set 1234# CONFIG_XFS_RT is not set
1235# CONFIG_GFS2_FS is not set
920# CONFIG_OCFS2_FS is not set 1236# CONFIG_OCFS2_FS is not set
921# CONFIG_MINIX_FS is not set 1237# CONFIG_MINIX_FS is not set
922# CONFIG_ROMFS_FS is not set 1238# CONFIG_ROMFS_FS is not set
@@ -949,8 +1265,10 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
949# 1265#
950CONFIG_PROC_FS=y 1266CONFIG_PROC_FS=y
951# CONFIG_PROC_KCORE is not set 1267# CONFIG_PROC_KCORE is not set
1268CONFIG_PROC_SYSCTL=y
952CONFIG_SYSFS=y 1269CONFIG_SYSFS=y
953CONFIG_TMPFS=y 1270CONFIG_TMPFS=y
1271# CONFIG_TMPFS_POSIX_ACL is not set
954# CONFIG_HUGETLB_PAGE is not set 1272# CONFIG_HUGETLB_PAGE is not set
955CONFIG_RAMFS=y 1273CONFIG_RAMFS=y
956# CONFIG_CONFIGFS_FS is not set 1274# CONFIG_CONFIGFS_FS is not set
@@ -994,7 +1312,6 @@ CONFIG_SUNRPC=y
994CONFIG_SMB_FS=m 1312CONFIG_SMB_FS=m
995# CONFIG_SMB_NLS_DEFAULT is not set 1313# CONFIG_SMB_NLS_DEFAULT is not set
996# CONFIG_CIFS is not set 1314# CONFIG_CIFS is not set
997# CONFIG_CIFS_DEBUG2 is not set
998# CONFIG_NCP_FS is not set 1315# CONFIG_NCP_FS is not set
999# CONFIG_CODA_FS is not set 1316# CONFIG_CODA_FS is not set
1000# CONFIG_AFS_FS is not set 1317# CONFIG_AFS_FS is not set
@@ -1005,7 +1322,6 @@ CONFIG_SMB_FS=m
1005# 1322#
1006# CONFIG_PARTITION_ADVANCED is not set 1323# CONFIG_PARTITION_ADVANCED is not set
1007CONFIG_MSDOS_PARTITION=y 1324CONFIG_MSDOS_PARTITION=y
1008CONFIG_SGI_PARTITION=y
1009 1325
1010# 1326#
1011# Native Language Support 1327# Native Language Support
@@ -1061,11 +1377,13 @@ CONFIG_NLS_DEFAULT="iso8859-1"
1061# 1377#
1062CONFIG_TRACE_IRQFLAGS_SUPPORT=y 1378CONFIG_TRACE_IRQFLAGS_SUPPORT=y
1063# CONFIG_PRINTK_TIME is not set 1379# CONFIG_PRINTK_TIME is not set
1380CONFIG_ENABLE_MUST_CHECK=y
1064# CONFIG_MAGIC_SYSRQ is not set 1381# CONFIG_MAGIC_SYSRQ is not set
1065# CONFIG_UNUSED_SYMBOLS is not set 1382# CONFIG_UNUSED_SYMBOLS is not set
1066# CONFIG_DEBUG_KERNEL is not set 1383# CONFIG_DEBUG_KERNEL is not set
1067CONFIG_LOG_BUF_SHIFT=14 1384CONFIG_LOG_BUF_SHIFT=14
1068# CONFIG_DEBUG_FS is not set 1385# CONFIG_DEBUG_FS is not set
1386# CONFIG_HEADERS_CHECK is not set
1069CONFIG_CROSSCOMPILE=y 1387CONFIG_CROSSCOMPILE=y
1070CONFIG_CMDLINE="" 1388CONFIG_CMDLINE=""
1071 1389
@@ -1079,6 +1397,9 @@ CONFIG_CMDLINE=""
1079# Cryptographic options 1397# Cryptographic options
1080# 1398#
1081CONFIG_CRYPTO=y 1399CONFIG_CRYPTO=y
1400CONFIG_CRYPTO_ALGAPI=m
1401CONFIG_CRYPTO_BLKCIPHER=m
1402CONFIG_CRYPTO_MANAGER=m
1082# CONFIG_CRYPTO_HMAC is not set 1403# CONFIG_CRYPTO_HMAC is not set
1083# CONFIG_CRYPTO_NULL is not set 1404# CONFIG_CRYPTO_NULL is not set
1084# CONFIG_CRYPTO_MD4 is not set 1405# CONFIG_CRYPTO_MD4 is not set
@@ -1088,6 +1409,8 @@ CONFIG_CRYPTO_SHA1=m
1088# CONFIG_CRYPTO_SHA512 is not set 1409# CONFIG_CRYPTO_SHA512 is not set
1089# CONFIG_CRYPTO_WP512 is not set 1410# CONFIG_CRYPTO_WP512 is not set
1090# CONFIG_CRYPTO_TGR192 is not set 1411# CONFIG_CRYPTO_TGR192 is not set
1412CONFIG_CRYPTO_ECB=m
1413CONFIG_CRYPTO_CBC=m
1091# CONFIG_CRYPTO_DES is not set 1414# CONFIG_CRYPTO_DES is not set
1092# CONFIG_CRYPTO_BLOWFISH is not set 1415# CONFIG_CRYPTO_BLOWFISH is not set
1093# CONFIG_CRYPTO_TWOFISH is not set 1416# CONFIG_CRYPTO_TWOFISH is not set
diff --git a/arch/mips/configs/tb0287_defconfig b/arch/mips/configs/tb0287_defconfig
index ad7271b3f266..f7e8194809a1 100644
--- a/arch/mips/configs/tb0287_defconfig
+++ b/arch/mips/configs/tb0287_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.18-rc1 3# Linux kernel version: 2.6.19-rc2
4# Thu Jul 6 10:04:21 2006 4# Wed Oct 18 12:57:11 2006
5# 5#
6CONFIG_MIPS=y 6CONFIG_MIPS=y
7 7
@@ -25,8 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_IVR is not set
29# CONFIG_MIPS_ITE8172 is not set
30# CONFIG_MACH_JAZZ is not set 28# CONFIG_MACH_JAZZ is not set
31# CONFIG_LASAT is not set 29# CONFIG_LASAT is not set
32# CONFIG_MIPS_ATLAS is not set 30# CONFIG_MIPS_ATLAS is not set
@@ -72,11 +70,11 @@ CONFIG_TANBAC_TB0287=y
72# CONFIG_VICTOR_MPC30X is not set 70# CONFIG_VICTOR_MPC30X is not set
73# CONFIG_ZAO_CAPCELLA is not set 71# CONFIG_ZAO_CAPCELLA is not set
74CONFIG_PCI_VR41XX=y 72CONFIG_PCI_VR41XX=y
75# CONFIG_VRC4173 is not set
76CONFIG_RWSEM_GENERIC_SPINLOCK=y 73CONFIG_RWSEM_GENERIC_SPINLOCK=y
77CONFIG_GENERIC_FIND_NEXT_BIT=y 74CONFIG_GENERIC_FIND_NEXT_BIT=y
78CONFIG_GENERIC_HWEIGHT=y 75CONFIG_GENERIC_HWEIGHT=y
79CONFIG_GENERIC_CALIBRATE_DELAY=y 76CONFIG_GENERIC_CALIBRATE_DELAY=y
77CONFIG_GENERIC_TIME=y
80CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y 78CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
81CONFIG_DMA_NONCOHERENT=y 79CONFIG_DMA_NONCOHERENT=y
82CONFIG_DMA_NEED_PCI_MAP_STATE=y 80CONFIG_DMA_NEED_PCI_MAP_STATE=y
@@ -123,8 +121,8 @@ CONFIG_PAGE_SIZE_4KB=y
123# CONFIG_PAGE_SIZE_16KB is not set 121# CONFIG_PAGE_SIZE_16KB is not set
124# CONFIG_PAGE_SIZE_64KB is not set 122# CONFIG_PAGE_SIZE_64KB is not set
125CONFIG_MIPS_MT_DISABLED=y 123CONFIG_MIPS_MT_DISABLED=y
126# CONFIG_MIPS_MT_SMTC is not set
127# CONFIG_MIPS_MT_SMP is not set 124# CONFIG_MIPS_MT_SMP is not set
125# CONFIG_MIPS_MT_SMTC is not set
128# CONFIG_MIPS_VPE_LOADER is not set 126# CONFIG_MIPS_VPE_LOADER is not set
129CONFIG_CPU_HAS_SYNC=y 127CONFIG_CPU_HAS_SYNC=y
130CONFIG_GENERIC_HARDIRQS=y 128CONFIG_GENERIC_HARDIRQS=y
@@ -169,15 +167,19 @@ CONFIG_LOCALVERSION=""
169CONFIG_LOCALVERSION_AUTO=y 167CONFIG_LOCALVERSION_AUTO=y
170CONFIG_SWAP=y 168CONFIG_SWAP=y
171CONFIG_SYSVIPC=y 169CONFIG_SYSVIPC=y
170# CONFIG_IPC_NS is not set
172# CONFIG_POSIX_MQUEUE is not set 171# CONFIG_POSIX_MQUEUE is not set
173# CONFIG_BSD_PROCESS_ACCT is not set 172# CONFIG_BSD_PROCESS_ACCT is not set
174CONFIG_SYSCTL=y 173# CONFIG_TASKSTATS is not set
174# CONFIG_UTS_NS is not set
175# CONFIG_AUDIT is not set 175# CONFIG_AUDIT is not set
176# CONFIG_IKCONFIG is not set 176# CONFIG_IKCONFIG is not set
177# CONFIG_RELAY is not set 177# CONFIG_RELAY is not set
178CONFIG_INITRAMFS_SOURCE="" 178CONFIG_INITRAMFS_SOURCE=""
179# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 179# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
180CONFIG_SYSCTL=y
180CONFIG_EMBEDDED=y 181CONFIG_EMBEDDED=y
182# CONFIG_SYSCTL_SYSCALL is not set
181CONFIG_KALLSYMS=y 183CONFIG_KALLSYMS=y
182# CONFIG_KALLSYMS_EXTRA_PASS is not set 184# CONFIG_KALLSYMS_EXTRA_PASS is not set
183# CONFIG_HOTPLUG is not set 185# CONFIG_HOTPLUG is not set
@@ -185,12 +187,12 @@ CONFIG_PRINTK=y
185CONFIG_BUG=y 187CONFIG_BUG=y
186CONFIG_ELF_CORE=y 188CONFIG_ELF_CORE=y
187CONFIG_BASE_FULL=y 189CONFIG_BASE_FULL=y
188CONFIG_RT_MUTEXES=y
189CONFIG_FUTEX=y 190CONFIG_FUTEX=y
190CONFIG_EPOLL=y 191CONFIG_EPOLL=y
191CONFIG_SHMEM=y 192CONFIG_SHMEM=y
192CONFIG_SLAB=y 193CONFIG_SLAB=y
193CONFIG_VM_EVENT_COUNTERS=y 194CONFIG_VM_EVENT_COUNTERS=y
195CONFIG_RT_MUTEXES=y
194# CONFIG_TINY_SHMEM is not set 196# CONFIG_TINY_SHMEM is not set
195CONFIG_BASE_SMALL=0 197CONFIG_BASE_SMALL=0
196# CONFIG_SLOB is not set 198# CONFIG_SLOB is not set
@@ -208,6 +210,7 @@ CONFIG_KMOD=y
208# 210#
209# Block layer 211# Block layer
210# 212#
213CONFIG_BLOCK=y
211# CONFIG_LBD is not set 214# CONFIG_LBD is not set
212# CONFIG_BLK_DEV_IO_TRACE is not set 215# CONFIG_BLK_DEV_IO_TRACE is not set
213# CONFIG_LSF is not set 216# CONFIG_LSF is not set
@@ -230,17 +233,16 @@ CONFIG_DEFAULT_IOSCHED="anticipatory"
230# 233#
231CONFIG_HW_HAS_PCI=y 234CONFIG_HW_HAS_PCI=y
232CONFIG_PCI=y 235CONFIG_PCI=y
236# CONFIG_PCI_MULTITHREAD_PROBE is not set
233CONFIG_MMU=y 237CONFIG_MMU=y
234 238
235# 239#
236# PCCARD (PCMCIA/CardBus) support 240# PCCARD (PCMCIA/CardBus) support
237# 241#
238# CONFIG_PCCARD is not set
239 242
240# 243#
241# PCI Hotplug Support 244# PCI Hotplug Support
242# 245#
243# CONFIG_HOTPLUG_PCI is not set
244 246
245# 247#
246# Executable file formats 248# Executable file formats
@@ -263,6 +265,7 @@ CONFIG_PACKET=y
263CONFIG_UNIX=y 265CONFIG_UNIX=y
264CONFIG_XFRM=y 266CONFIG_XFRM=y
265# CONFIG_XFRM_USER is not set 267# CONFIG_XFRM_USER is not set
268# CONFIG_XFRM_SUB_POLICY is not set
266# CONFIG_NET_KEY is not set 269# CONFIG_NET_KEY is not set
267CONFIG_INET=y 270CONFIG_INET=y
268CONFIG_IP_MULTICAST=y 271CONFIG_IP_MULTICAST=y
@@ -291,13 +294,10 @@ CONFIG_SYN_COOKIES=y
291CONFIG_INET_TUNNEL=m 294CONFIG_INET_TUNNEL=m
292CONFIG_INET_XFRM_MODE_TRANSPORT=m 295CONFIG_INET_XFRM_MODE_TRANSPORT=m
293CONFIG_INET_XFRM_MODE_TUNNEL=m 296CONFIG_INET_XFRM_MODE_TUNNEL=m
297CONFIG_INET_XFRM_MODE_BEET=y
294CONFIG_INET_DIAG=y 298CONFIG_INET_DIAG=y
295CONFIG_INET_TCP_DIAG=y 299CONFIG_INET_TCP_DIAG=y
296CONFIG_TCP_CONG_ADVANCED=y 300CONFIG_TCP_CONG_ADVANCED=y
297
298#
299# TCP congestion control
300#
301CONFIG_TCP_CONG_BIC=y 301CONFIG_TCP_CONG_BIC=y
302CONFIG_TCP_CONG_CUBIC=m 302CONFIG_TCP_CONG_CUBIC=m
303CONFIG_TCP_CONG_WESTWOOD=m 303CONFIG_TCP_CONG_WESTWOOD=m
@@ -308,7 +308,13 @@ CONFIG_TCP_CONG_HTCP=m
308# CONFIG_TCP_CONG_SCALABLE is not set 308# CONFIG_TCP_CONG_SCALABLE is not set
309# CONFIG_TCP_CONG_LP is not set 309# CONFIG_TCP_CONG_LP is not set
310# CONFIG_TCP_CONG_VENO is not set 310# CONFIG_TCP_CONG_VENO is not set
311# CONFIG_TCP_CONG_COMPOUND is not set 311CONFIG_DEFAULT_BIC=y
312# CONFIG_DEFAULT_CUBIC is not set
313# CONFIG_DEFAULT_HTCP is not set
314# CONFIG_DEFAULT_VEGAS is not set
315# CONFIG_DEFAULT_WESTWOOD is not set
316# CONFIG_DEFAULT_RENO is not set
317CONFIG_DEFAULT_TCP_CONG="bic"
312# CONFIG_IPV6 is not set 318# CONFIG_IPV6 is not set
313# CONFIG_INET6_XFRM_TUNNEL is not set 319# CONFIG_INET6_XFRM_TUNNEL is not set
314# CONFIG_INET6_TUNNEL is not set 320# CONFIG_INET6_TUNNEL is not set
@@ -338,7 +344,6 @@ CONFIG_NETWORK_SECMARK=y
338# CONFIG_ATALK is not set 344# CONFIG_ATALK is not set
339# CONFIG_X25 is not set 345# CONFIG_X25 is not set
340# CONFIG_LAPB is not set 346# CONFIG_LAPB is not set
341# CONFIG_NET_DIVERT is not set
342# CONFIG_ECONET is not set 347# CONFIG_ECONET is not set
343# CONFIG_WAN_ROUTER is not set 348# CONFIG_WAN_ROUTER is not set
344 349
@@ -355,6 +360,7 @@ CONFIG_NETWORK_SECMARK=y
355# CONFIG_IRDA is not set 360# CONFIG_IRDA is not set
356# CONFIG_BT is not set 361# CONFIG_BT is not set
357# CONFIG_IEEE80211 is not set 362# CONFIG_IEEE80211 is not set
363CONFIG_FIB_RULES=y
358 364
359# 365#
360# Device Drivers 366# Device Drivers
@@ -365,7 +371,6 @@ CONFIG_NETWORK_SECMARK=y
365# 371#
366CONFIG_STANDALONE=y 372CONFIG_STANDALONE=y
367CONFIG_PREVENT_FIRMWARE_BUILD=y 373CONFIG_PREVENT_FIRMWARE_BUILD=y
368# CONFIG_FW_LOADER is not set
369# CONFIG_SYS_HYPERVISOR is not set 374# CONFIG_SYS_HYPERVISOR is not set
370 375
371# 376#
@@ -403,6 +408,7 @@ CONFIG_BLK_DEV_NBD=m
403CONFIG_BLK_DEV_RAM=y 408CONFIG_BLK_DEV_RAM=y
404CONFIG_BLK_DEV_RAM_COUNT=16 409CONFIG_BLK_DEV_RAM_COUNT=16
405CONFIG_BLK_DEV_RAM_SIZE=4096 410CONFIG_BLK_DEV_RAM_SIZE=4096
411CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
406# CONFIG_BLK_DEV_INITRD is not set 412# CONFIG_BLK_DEV_INITRD is not set
407# CONFIG_CDROM_PKTCDVD is not set 413# CONFIG_CDROM_PKTCDVD is not set
408# CONFIG_ATA_OVER_ETH is not set 414# CONFIG_ATA_OVER_ETH is not set
@@ -410,65 +416,14 @@ CONFIG_BLK_DEV_RAM_SIZE=4096
410# 416#
411# ATA/ATAPI/MFM/RLL support 417# ATA/ATAPI/MFM/RLL support
412# 418#
413CONFIG_IDE=y 419# CONFIG_IDE is not set
414CONFIG_BLK_DEV_IDE=y
415
416#
417# Please see Documentation/ide.txt for help/info on IDE drives
418#
419# CONFIG_BLK_DEV_IDE_SATA is not set
420CONFIG_BLK_DEV_IDEDISK=y
421# CONFIG_IDEDISK_MULTI_MODE is not set
422# CONFIG_BLK_DEV_IDECD is not set
423# CONFIG_BLK_DEV_IDETAPE is not set
424# CONFIG_BLK_DEV_IDEFLOPPY is not set
425# CONFIG_BLK_DEV_IDESCSI is not set
426# CONFIG_IDE_TASK_IOCTL is not set
427
428#
429# IDE chipset support/bugfixes
430#
431CONFIG_IDE_GENERIC=y
432CONFIG_BLK_DEV_IDEPCI=y
433# CONFIG_IDEPCI_SHARE_IRQ is not set
434# CONFIG_BLK_DEV_OFFBOARD is not set
435# CONFIG_BLK_DEV_GENERIC is not set
436# CONFIG_BLK_DEV_OPTI621 is not set
437CONFIG_BLK_DEV_IDEDMA_PCI=y
438# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
439# CONFIG_IDEDMA_PCI_AUTO is not set
440# CONFIG_BLK_DEV_AEC62XX is not set
441# CONFIG_BLK_DEV_ALI15X3 is not set
442# CONFIG_BLK_DEV_AMD74XX is not set
443# CONFIG_BLK_DEV_CMD64X is not set
444# CONFIG_BLK_DEV_TRIFLEX is not set
445# CONFIG_BLK_DEV_CY82C693 is not set
446# CONFIG_BLK_DEV_CS5520 is not set
447# CONFIG_BLK_DEV_CS5530 is not set
448# CONFIG_BLK_DEV_HPT34X is not set
449# CONFIG_BLK_DEV_HPT366 is not set
450# CONFIG_BLK_DEV_SC1200 is not set
451# CONFIG_BLK_DEV_PIIX is not set
452# CONFIG_BLK_DEV_IT821X is not set
453# CONFIG_BLK_DEV_NS87415 is not set
454# CONFIG_BLK_DEV_PDC202XX_OLD is not set
455# CONFIG_BLK_DEV_PDC202XX_NEW is not set
456# CONFIG_BLK_DEV_SVWKS is not set
457CONFIG_BLK_DEV_SIIMAGE=y
458# CONFIG_BLK_DEV_SLC90E66 is not set
459# CONFIG_BLK_DEV_TRM290 is not set
460# CONFIG_BLK_DEV_VIA82CXXX is not set
461# CONFIG_IDE_ARM is not set
462CONFIG_BLK_DEV_IDEDMA=y
463# CONFIG_IDEDMA_IVB is not set
464# CONFIG_IDEDMA_AUTO is not set
465# CONFIG_BLK_DEV_HD is not set
466 420
467# 421#
468# SCSI device support 422# SCSI device support
469# 423#
470# CONFIG_RAID_ATTRS is not set 424# CONFIG_RAID_ATTRS is not set
471CONFIG_SCSI=y 425CONFIG_SCSI=y
426# CONFIG_SCSI_NETLINK is not set
472CONFIG_SCSI_PROC_FS=y 427CONFIG_SCSI_PROC_FS=y
473 428
474# 429#
@@ -489,12 +444,13 @@ CONFIG_BLK_DEV_SD=y
489# CONFIG_SCSI_LOGGING is not set 444# CONFIG_SCSI_LOGGING is not set
490 445
491# 446#
492# SCSI Transport Attributes 447# SCSI Transports
493# 448#
494# CONFIG_SCSI_SPI_ATTRS is not set 449# CONFIG_SCSI_SPI_ATTRS is not set
495# CONFIG_SCSI_FC_ATTRS is not set 450# CONFIG_SCSI_FC_ATTRS is not set
496# CONFIG_SCSI_ISCSI_ATTRS is not set 451# CONFIG_SCSI_ISCSI_ATTRS is not set
497# CONFIG_SCSI_SAS_ATTRS is not set 452# CONFIG_SCSI_SAS_ATTRS is not set
453# CONFIG_SCSI_SAS_LIBSAS is not set
498 454
499# 455#
500# SCSI low-level drivers 456# SCSI low-level drivers
@@ -507,21 +463,24 @@ CONFIG_BLK_DEV_SD=y
507# CONFIG_SCSI_AIC7XXX is not set 463# CONFIG_SCSI_AIC7XXX is not set
508# CONFIG_SCSI_AIC7XXX_OLD is not set 464# CONFIG_SCSI_AIC7XXX_OLD is not set
509# CONFIG_SCSI_AIC79XX is not set 465# CONFIG_SCSI_AIC79XX is not set
466# CONFIG_SCSI_AIC94XX is not set
510# CONFIG_SCSI_DPT_I2O is not set 467# CONFIG_SCSI_DPT_I2O is not set
468# CONFIG_SCSI_ARCMSR is not set
511# CONFIG_MEGARAID_NEWGEN is not set 469# CONFIG_MEGARAID_NEWGEN is not set
512# CONFIG_MEGARAID_LEGACY is not set 470# CONFIG_MEGARAID_LEGACY is not set
513# CONFIG_MEGARAID_SAS is not set 471# CONFIG_MEGARAID_SAS is not set
514# CONFIG_SCSI_SATA is not set
515# CONFIG_SCSI_HPTIOP is not set 472# CONFIG_SCSI_HPTIOP is not set
516# CONFIG_SCSI_DMX3191D is not set 473# CONFIG_SCSI_DMX3191D is not set
517# CONFIG_SCSI_FUTURE_DOMAIN is not set 474# CONFIG_SCSI_FUTURE_DOMAIN is not set
518# CONFIG_SCSI_IPS is not set 475# CONFIG_SCSI_IPS is not set
519# CONFIG_SCSI_INITIO is not set 476# CONFIG_SCSI_INITIO is not set
520# CONFIG_SCSI_INIA100 is not set 477# CONFIG_SCSI_INIA100 is not set
478# CONFIG_SCSI_STEX is not set
521# CONFIG_SCSI_SYM53C8XX_2 is not set 479# CONFIG_SCSI_SYM53C8XX_2 is not set
522# CONFIG_SCSI_IPR is not set 480# CONFIG_SCSI_IPR is not set
523# CONFIG_SCSI_QLOGIC_1280 is not set 481# CONFIG_SCSI_QLOGIC_1280 is not set
524# CONFIG_SCSI_QLA_FC is not set 482# CONFIG_SCSI_QLA_FC is not set
483# CONFIG_SCSI_QLA_ISCSI is not set
525# CONFIG_SCSI_LPFC is not set 484# CONFIG_SCSI_LPFC is not set
526# CONFIG_SCSI_DC395x is not set 485# CONFIG_SCSI_DC395x is not set
527# CONFIG_SCSI_DC390T is not set 486# CONFIG_SCSI_DC390T is not set
@@ -529,6 +488,59 @@ CONFIG_BLK_DEV_SD=y
529# CONFIG_SCSI_DEBUG is not set 488# CONFIG_SCSI_DEBUG is not set
530 489
531# 490#
491# Serial ATA (prod) and Parallel ATA (experimental) drivers
492#
493CONFIG_ATA=y
494# CONFIG_SATA_AHCI is not set
495# CONFIG_SATA_SVW is not set
496# CONFIG_ATA_PIIX is not set
497# CONFIG_SATA_MV is not set
498# CONFIG_SATA_NV is not set
499# CONFIG_PDC_ADMA is not set
500# CONFIG_SATA_QSTOR is not set
501# CONFIG_SATA_PROMISE is not set
502# CONFIG_SATA_SX4 is not set
503# CONFIG_SATA_SIL is not set
504# CONFIG_SATA_SIL24 is not set
505# CONFIG_SATA_SIS is not set
506# CONFIG_SATA_ULI is not set
507# CONFIG_SATA_VIA is not set
508# CONFIG_SATA_VITESSE is not set
509# CONFIG_PATA_ALI is not set
510# CONFIG_PATA_AMD is not set
511# CONFIG_PATA_ARTOP is not set
512# CONFIG_PATA_ATIIXP is not set
513# CONFIG_PATA_CMD64X is not set
514# CONFIG_PATA_CS5520 is not set
515# CONFIG_PATA_CS5530 is not set
516# CONFIG_PATA_CYPRESS is not set
517# CONFIG_PATA_EFAR is not set
518# CONFIG_ATA_GENERIC is not set
519# CONFIG_PATA_HPT366 is not set
520# CONFIG_PATA_HPT37X is not set
521# CONFIG_PATA_HPT3X2N is not set
522# CONFIG_PATA_HPT3X3 is not set
523# CONFIG_PATA_IT821X is not set
524# CONFIG_PATA_JMICRON is not set
525# CONFIG_PATA_TRIFLEX is not set
526# CONFIG_PATA_MPIIX is not set
527# CONFIG_PATA_OLDPIIX is not set
528# CONFIG_PATA_NETCELL is not set
529# CONFIG_PATA_NS87410 is not set
530# CONFIG_PATA_OPTI is not set
531# CONFIG_PATA_OPTIDMA is not set
532# CONFIG_PATA_PDC_OLD is not set
533# CONFIG_PATA_RADISYS is not set
534# CONFIG_PATA_RZ1000 is not set
535# CONFIG_PATA_SC1200 is not set
536# CONFIG_PATA_SERVERWORKS is not set
537# CONFIG_PATA_PDC2027X is not set
538CONFIG_PATA_SIL680=y
539# CONFIG_PATA_SIS is not set
540# CONFIG_PATA_VIA is not set
541# CONFIG_PATA_WINBOND is not set
542
543#
532# Multi-device support (RAID and LVM) 544# Multi-device support (RAID and LVM)
533# 545#
534# CONFIG_MD is not set 546# CONFIG_MD is not set
@@ -632,6 +644,7 @@ CONFIG_R8169=y
632# CONFIG_SK98LIN is not set 644# CONFIG_SK98LIN is not set
633# CONFIG_TIGON3 is not set 645# CONFIG_TIGON3 is not set
634# CONFIG_BNX2 is not set 646# CONFIG_BNX2 is not set
647# CONFIG_QLA3XXX is not set
635 648
636# 649#
637# Ethernet (10000 Mbit) 650# Ethernet (10000 Mbit)
@@ -679,6 +692,7 @@ CONFIG_R8169=y
679# Input device support 692# Input device support
680# 693#
681CONFIG_INPUT=y 694CONFIG_INPUT=y
695# CONFIG_INPUT_FF_MEMLESS is not set
682 696
683# 697#
684# Userland interfaces 698# Userland interfaces
@@ -758,7 +772,6 @@ CONFIG_GPIO_VR41XX=y
758# TPM devices 772# TPM devices
759# 773#
760# CONFIG_TCG_TPM is not set 774# CONFIG_TCG_TPM is not set
761# CONFIG_TELCLOCK is not set
762 775
763# 776#
764# I2C support 777# I2C support
@@ -784,12 +797,12 @@ CONFIG_GPIO_VR41XX=y
784# 797#
785# Misc devices 798# Misc devices
786# 799#
800# CONFIG_TIFM_CORE is not set
787 801
788# 802#
789# Multimedia devices 803# Multimedia devices
790# 804#
791# CONFIG_VIDEO_DEV is not set 805# CONFIG_VIDEO_DEV is not set
792CONFIG_VIDEO_V4L2=y
793 806
794# 807#
795# Digital Video Broadcasting Devices 808# Digital Video Broadcasting Devices
@@ -897,13 +910,13 @@ CONFIG_USB_STORAGE=m
897# CONFIG_USB_STORAGE_DEBUG is not set 910# CONFIG_USB_STORAGE_DEBUG is not set
898# CONFIG_USB_STORAGE_DATAFAB is not set 911# CONFIG_USB_STORAGE_DATAFAB is not set
899# CONFIG_USB_STORAGE_FREECOM is not set 912# CONFIG_USB_STORAGE_FREECOM is not set
900# CONFIG_USB_STORAGE_ISD200 is not set
901# CONFIG_USB_STORAGE_DPCM is not set 913# CONFIG_USB_STORAGE_DPCM is not set
902# CONFIG_USB_STORAGE_USBAT is not set 914# CONFIG_USB_STORAGE_USBAT is not set
903# CONFIG_USB_STORAGE_SDDR09 is not set 915# CONFIG_USB_STORAGE_SDDR09 is not set
904# CONFIG_USB_STORAGE_SDDR55 is not set 916# CONFIG_USB_STORAGE_SDDR55 is not set
905# CONFIG_USB_STORAGE_JUMPSHOT is not set 917# CONFIG_USB_STORAGE_JUMPSHOT is not set
906# CONFIG_USB_STORAGE_ALAUDA is not set 918# CONFIG_USB_STORAGE_ALAUDA is not set
919# CONFIG_USB_STORAGE_KARMA is not set
907# CONFIG_USB_LIBUSUAL is not set 920# CONFIG_USB_LIBUSUAL is not set
908 921
909# 922#
@@ -932,6 +945,7 @@ CONFIG_USB_HIDINPUT=y
932# CONFIG_USB_ATI_REMOTE2 is not set 945# CONFIG_USB_ATI_REMOTE2 is not set
933# CONFIG_USB_KEYSPAN_REMOTE is not set 946# CONFIG_USB_KEYSPAN_REMOTE is not set
934# CONFIG_USB_APPLETOUCH is not set 947# CONFIG_USB_APPLETOUCH is not set
948# CONFIG_USB_TRANCEVIBRATOR is not set
935 949
936# 950#
937# USB Imaging devices 951# USB Imaging devices
@@ -963,16 +977,17 @@ CONFIG_USB_MON=y
963# 977#
964# CONFIG_USB_EMI62 is not set 978# CONFIG_USB_EMI62 is not set
965# CONFIG_USB_EMI26 is not set 979# CONFIG_USB_EMI26 is not set
980# CONFIG_USB_ADUTUX is not set
966# CONFIG_USB_AUERSWALD is not set 981# CONFIG_USB_AUERSWALD is not set
967# CONFIG_USB_RIO500 is not set 982# CONFIG_USB_RIO500 is not set
968# CONFIG_USB_LEGOTOWER is not set 983# CONFIG_USB_LEGOTOWER is not set
969# CONFIG_USB_LCD is not set 984# CONFIG_USB_LCD is not set
970# CONFIG_USB_LED is not set 985# CONFIG_USB_LED is not set
971# CONFIG_USB_CY7C63 is not set 986# CONFIG_USB_CYPRESS_CY7C63 is not set
972# CONFIG_USB_CYTHERM is not set 987# CONFIG_USB_CYTHERM is not set
973# CONFIG_USB_PHIDGETKIT is not set 988# CONFIG_USB_PHIDGET is not set
974# CONFIG_USB_PHIDGETSERVO is not set
975# CONFIG_USB_IDMOUSE is not set 989# CONFIG_USB_IDMOUSE is not set
990# CONFIG_USB_FTDI_ELAN is not set
976# CONFIG_USB_APPLEDISPLAY is not set 991# CONFIG_USB_APPLEDISPLAY is not set
977# CONFIG_USB_SISUSBVGA is not set 992# CONFIG_USB_SISUSBVGA is not set
978# CONFIG_USB_LD is not set 993# CONFIG_USB_LD is not set
@@ -1041,6 +1056,7 @@ CONFIG_EXT3_FS=y
1041CONFIG_EXT3_FS_XATTR=y 1056CONFIG_EXT3_FS_XATTR=y
1042# CONFIG_EXT3_FS_POSIX_ACL is not set 1057# CONFIG_EXT3_FS_POSIX_ACL is not set
1043# CONFIG_EXT3_FS_SECURITY is not set 1058# CONFIG_EXT3_FS_SECURITY is not set
1059# CONFIG_EXT4DEV_FS is not set
1044CONFIG_JBD=y 1060CONFIG_JBD=y
1045# CONFIG_JBD_DEBUG is not set 1061# CONFIG_JBD_DEBUG is not set
1046CONFIG_FS_MBCACHE=y 1062CONFIG_FS_MBCACHE=y
@@ -1052,6 +1068,7 @@ CONFIG_XFS_QUOTA=y
1052# CONFIG_XFS_SECURITY is not set 1068# CONFIG_XFS_SECURITY is not set
1053CONFIG_XFS_POSIX_ACL=y 1069CONFIG_XFS_POSIX_ACL=y
1054# CONFIG_XFS_RT is not set 1070# CONFIG_XFS_RT is not set
1071# CONFIG_GFS2_FS is not set
1055# CONFIG_OCFS2_FS is not set 1072# CONFIG_OCFS2_FS is not set
1056# CONFIG_MINIX_FS is not set 1073# CONFIG_MINIX_FS is not set
1057CONFIG_ROMFS_FS=m 1074CONFIG_ROMFS_FS=m
@@ -1082,8 +1099,10 @@ CONFIG_AUTOFS4_FS=y
1082# 1099#
1083CONFIG_PROC_FS=y 1100CONFIG_PROC_FS=y
1084CONFIG_PROC_KCORE=y 1101CONFIG_PROC_KCORE=y
1102CONFIG_PROC_SYSCTL=y
1085CONFIG_SYSFS=y 1103CONFIG_SYSFS=y
1086CONFIG_TMPFS=y 1104CONFIG_TMPFS=y
1105# CONFIG_TMPFS_POSIX_ACL is not set
1087# CONFIG_HUGETLB_PAGE is not set 1106# CONFIG_HUGETLB_PAGE is not set
1088CONFIG_RAMFS=y 1107CONFIG_RAMFS=y
1089# CONFIG_CONFIGFS_FS is not set 1108# CONFIG_CONFIGFS_FS is not set
@@ -1123,7 +1142,6 @@ CONFIG_SUNRPC=y
1123# CONFIG_RPCSEC_GSS_SPKM3 is not set 1142# CONFIG_RPCSEC_GSS_SPKM3 is not set
1124# CONFIG_SMB_FS is not set 1143# CONFIG_SMB_FS is not set
1125# CONFIG_CIFS is not set 1144# CONFIG_CIFS is not set
1126# CONFIG_CIFS_DEBUG2 is not set
1127# CONFIG_NCP_FS is not set 1145# CONFIG_NCP_FS is not set
1128# CONFIG_CODA_FS is not set 1146# CONFIG_CODA_FS is not set
1129# CONFIG_AFS_FS is not set 1147# CONFIG_AFS_FS is not set
@@ -1150,11 +1168,13 @@ CONFIG_MSDOS_PARTITION=y
1150# 1168#
1151CONFIG_TRACE_IRQFLAGS_SUPPORT=y 1169CONFIG_TRACE_IRQFLAGS_SUPPORT=y
1152# CONFIG_PRINTK_TIME is not set 1170# CONFIG_PRINTK_TIME is not set
1171CONFIG_ENABLE_MUST_CHECK=y
1153# CONFIG_MAGIC_SYSRQ is not set 1172# CONFIG_MAGIC_SYSRQ is not set
1154# CONFIG_UNUSED_SYMBOLS is not set 1173# CONFIG_UNUSED_SYMBOLS is not set
1155# CONFIG_DEBUG_KERNEL is not set 1174# CONFIG_DEBUG_KERNEL is not set
1156CONFIG_LOG_BUF_SHIFT=14 1175CONFIG_LOG_BUF_SHIFT=14
1157# CONFIG_DEBUG_FS is not set 1176# CONFIG_DEBUG_FS is not set
1177# CONFIG_HEADERS_CHECK is not set
1158CONFIG_CROSSCOMPILE=y 1178CONFIG_CROSSCOMPILE=y
1159CONFIG_CMDLINE="mem=64M console=ttyVR0,115200 ip=any root=/dev/nfs" 1179CONFIG_CMDLINE="mem=64M console=ttyVR0,115200 ip=any root=/dev/nfs"
1160 1180
@@ -1170,10 +1190,6 @@ CONFIG_CMDLINE="mem=64M console=ttyVR0,115200 ip=any root=/dev/nfs"
1170# CONFIG_CRYPTO is not set 1190# CONFIG_CRYPTO is not set
1171 1191
1172# 1192#
1173# Hardware crypto devices
1174#
1175
1176#
1177# Library routines 1193# Library routines
1178# 1194#
1179# CONFIG_CRC_CCITT is not set 1195# CONFIG_CRC_CCITT is not set
diff --git a/arch/mips/dec/time.c b/arch/mips/dec/time.c
index 4cf0c06e2414..69e424e9ab6f 100644
--- a/arch/mips/dec/time.c
+++ b/arch/mips/dec/time.c
@@ -160,11 +160,6 @@ static unsigned int dec_ioasic_hpt_read(void)
160 return ioasic_read(IO_REG_FCTR); 160 return ioasic_read(IO_REG_FCTR);
161} 161}
162 162
163static void dec_ioasic_hpt_init(unsigned int count)
164{
165 ioasic_write(IO_REG_FCTR, ioasic_read(IO_REG_FCTR) - count);
166}
167
168 163
169void __init dec_time_init(void) 164void __init dec_time_init(void)
170{ 165{
@@ -174,11 +169,9 @@ void __init dec_time_init(void)
174 mips_timer_state = dec_timer_state; 169 mips_timer_state = dec_timer_state;
175 mips_timer_ack = dec_timer_ack; 170 mips_timer_ack = dec_timer_ack;
176 171
177 if (!cpu_has_counter && IOASIC) { 172 if (!cpu_has_counter && IOASIC)
178 /* For pre-R4k systems we use the I/O ASIC's counter. */ 173 /* For pre-R4k systems we use the I/O ASIC's counter. */
179 mips_hpt_read = dec_ioasic_hpt_read; 174 mips_hpt_read = dec_ioasic_hpt_read;
180 mips_hpt_init = dec_ioasic_hpt_init;
181 }
182 175
183 /* Set up the rate of periodic DS1287 interrupts. */ 176 /* Set up the rate of periodic DS1287 interrupts. */
184 CMOS_WRITE(RTC_REF_CLCK_32KHZ | (16 - __ffs(HZ)), RTC_REG_A); 177 CMOS_WRITE(RTC_REF_CLCK_32KHZ | (16 - __ffs(HZ)), RTC_REG_A);
diff --git a/arch/mips/emma2rh/common/irq_emma2rh.c b/arch/mips/emma2rh/common/irq_emma2rh.c
index 7c930860c921..197ed4c2ba04 100644
--- a/arch/mips/emma2rh/common/irq_emma2rh.c
+++ b/arch/mips/emma2rh/common/irq_emma2rh.c
@@ -97,7 +97,7 @@ void emma2rh_irq_init(u32 irq_base)
97 irq_desc[i].status = IRQ_DISABLED; 97 irq_desc[i].status = IRQ_DISABLED;
98 irq_desc[i].action = NULL; 98 irq_desc[i].action = NULL;
99 irq_desc[i].depth = 1; 99 irq_desc[i].depth = 1;
100 irq_desc[i].handler = &emma2rh_irq_controller; 100 irq_desc[i].chip = &emma2rh_irq_controller;
101 } 101 }
102 102
103 emma2rh_irq_base = irq_base; 103 emma2rh_irq_base = irq_base;
diff --git a/arch/mips/emma2rh/markeins/irq_markeins.c b/arch/mips/emma2rh/markeins/irq_markeins.c
index f23ae9fcffa0..0b36eb001e62 100644
--- a/arch/mips/emma2rh/markeins/irq_markeins.c
+++ b/arch/mips/emma2rh/markeins/irq_markeins.c
@@ -86,7 +86,7 @@ void emma2rh_sw_irq_init(u32 irq_base)
86 irq_desc[i].status = IRQ_DISABLED; 86 irq_desc[i].status = IRQ_DISABLED;
87 irq_desc[i].action = NULL; 87 irq_desc[i].action = NULL;
88 irq_desc[i].depth = 2; 88 irq_desc[i].depth = 2;
89 irq_desc[i].handler = &emma2rh_sw_irq_controller; 89 irq_desc[i].chip = &emma2rh_sw_irq_controller;
90 } 90 }
91 91
92 emma2rh_sw_irq_base = irq_base; 92 emma2rh_sw_irq_base = irq_base;
@@ -166,7 +166,7 @@ void emma2rh_gpio_irq_init(u32 irq_base)
166 irq_desc[i].status = IRQ_DISABLED; 166 irq_desc[i].status = IRQ_DISABLED;
167 irq_desc[i].action = NULL; 167 irq_desc[i].action = NULL;
168 irq_desc[i].depth = 2; 168 irq_desc[i].depth = 2;
169 irq_desc[i].handler = &emma2rh_gpio_irq_controller; 169 irq_desc[i].chip = &emma2rh_gpio_irq_controller;
170 } 170 }
171 171
172 emma2rh_gpio_irq_base = irq_base; 172 emma2rh_gpio_irq_base = irq_base;
diff --git a/arch/mips/emma2rh/markeins/platform.c b/arch/mips/emma2rh/markeins/platform.c
index 15cc61df3622..11567702b155 100644
--- a/arch/mips/emma2rh/markeins/platform.c
+++ b/arch/mips/emma2rh/markeins/platform.c
@@ -44,18 +44,45 @@
44#define I2C_EMMA2RH "emma2rh-iic" /* must be in sync with IIC driver */ 44#define I2C_EMMA2RH "emma2rh-iic" /* must be in sync with IIC driver */
45 45
46static struct resource i2c_emma_resources_0[] = { 46static struct resource i2c_emma_resources_0[] = {
47 { NULL, EMMA2RH_IRQ_PIIC0, EMMA2RH_IRQ_PIIC0, IORESOURCE_IRQ }, 47 {
48 { NULL, KSEG1ADDR(EMMA2RH_PIIC0_BASE), KSEG1ADDR(EMMA2RH_PIIC0_BASE + 0x1000), 0 }, 48 .name = NULL,
49 .start = EMMA2RH_IRQ_PIIC0,
50 .end = EMMA2RH_IRQ_PIIC0,
51 .flags = IORESOURCE_IRQ
52 }, {
53 .name = NULL,
54 .start = EMMA2RH_PIIC0_BASE,
55 .end = EMMA2RH_PIIC0_BASE + 0x1000,
56 .flags = 0
57 },
49}; 58};
50 59
51struct resource i2c_emma_resources_1[] = { 60struct resource i2c_emma_resources_1[] = {
52 { NULL, EMMA2RH_IRQ_PIIC1, EMMA2RH_IRQ_PIIC1, IORESOURCE_IRQ }, 61 {
53 { NULL, KSEG1ADDR(EMMA2RH_PIIC1_BASE), KSEG1ADDR(EMMA2RH_PIIC1_BASE + 0x1000), 0 }, 62 .name = NULL,
63 .start = EMMA2RH_IRQ_PIIC1,
64 .end = EMMA2RH_IRQ_PIIC1,
65 .flags = IORESOURCE_IRQ
66 }, {
67 .name = NULL,
68 .start = EMMA2RH_PIIC1_BASE,
69 .end = EMMA2RH_PIIC1_BASE + 0x1000,
70 .flags = 0
71 },
54}; 72};
55 73
56struct resource i2c_emma_resources_2[] = { 74struct resource i2c_emma_resources_2[] = {
57 { NULL, EMMA2RH_IRQ_PIIC2, EMMA2RH_IRQ_PIIC2, IORESOURCE_IRQ }, 75 {
58 { NULL, KSEG1ADDR(EMMA2RH_PIIC2_BASE), KSEG1ADDR(EMMA2RH_PIIC2_BASE + 0x1000), 0 }, 76 .name = NULL,
77 .start = EMMA2RH_IRQ_PIIC2,
78 .end = EMMA2RH_IRQ_PIIC2,
79 .flags = IORESOURCE_IRQ
80 }, {
81 .name = NULL,
82 .start = EMMA2RH_PIIC2_BASE,
83 .end = EMMA2RH_PIIC2_BASE + 0x1000,
84 .flags = 0
85 },
59}; 86};
60 87
61struct platform_device i2c_emma_devices[] = { 88struct platform_device i2c_emma_devices[] = {
@@ -83,32 +110,29 @@ struct platform_device i2c_emma_devices[] = {
83#define EMMA2RH_SERIAL_FLAGS UPF_BOOT_AUTOCONF | UPF_SKIP_TEST 110#define EMMA2RH_SERIAL_FLAGS UPF_BOOT_AUTOCONF | UPF_SKIP_TEST
84 111
85static struct plat_serial8250_port platform_serial_ports[] = { 112static struct plat_serial8250_port platform_serial_ports[] = {
86 [0] = { 113 [0] = {
87 .membase = (void __iomem*)KSEG1ADDR(EMMA2RH_PFUR0_BASE + 3), 114 .membase= (void __iomem*)KSEG1ADDR(EMMA2RH_PFUR0_BASE + 3),
88 .irq = EMMA2RH_IRQ_PFUR0, 115 .irq = EMMA2RH_IRQ_PFUR0,
89 .uartclk = EMMA2RH_SERIAL_CLOCK, 116 .uartclk = EMMA2RH_SERIAL_CLOCK,
90 .regshift = 4, 117 .regshift = 4,
91 .iotype = UPIO_MEM, 118 .iotype = UPIO_MEM,
92 .flags = EMMA2RH_SERIAL_FLAGS, 119 .flags = EMMA2RH_SERIAL_FLAGS,
93 }, 120 }, [1] = {
94 [1] = { 121 .membase = (void __iomem*)KSEG1ADDR(EMMA2RH_PFUR1_BASE + 3),
95 .membase = (void __iomem*)KSEG1ADDR(EMMA2RH_PFUR1_BASE + 3), 122 .irq = EMMA2RH_IRQ_PFUR1,
96 .irq = EMMA2RH_IRQ_PFUR1, 123 .uartclk = EMMA2RH_SERIAL_CLOCK,
97 .uartclk = EMMA2RH_SERIAL_CLOCK, 124 .regshift = 4,
98 .regshift = 4, 125 .iotype = UPIO_MEM,
99 .iotype = UPIO_MEM, 126 .flags = EMMA2RH_SERIAL_FLAGS,
100 .flags = EMMA2RH_SERIAL_FLAGS, 127 }, [2] = {
101 }, 128 .membase = (void __iomem*)KSEG1ADDR(EMMA2RH_PFUR2_BASE + 3),
102 [2] = { 129 .irq = EMMA2RH_IRQ_PFUR2,
103 .membase = (void __iomem*)KSEG1ADDR(EMMA2RH_PFUR2_BASE + 3), 130 .uartclk = EMMA2RH_SERIAL_CLOCK,
104 .irq = EMMA2RH_IRQ_PFUR2, 131 .regshift = 4,
105 .uartclk = EMMA2RH_SERIAL_CLOCK, 132 .iotype = UPIO_MEM,
106 .regshift = 4, 133 .flags = EMMA2RH_SERIAL_FLAGS,
107 .iotype = UPIO_MEM, 134 }, [3] = {
108 .flags = EMMA2RH_SERIAL_FLAGS, 135 .flags = 0,
109 },
110 [3] = {
111 .flags = 0,
112 }, 136 },
113}; 137};
114 138
diff --git a/arch/mips/gt64120/common/time.c b/arch/mips/gt64120/common/time.c
index c83ae6acd601..c47eeb768192 100644
--- a/arch/mips/gt64120/common/time.c
+++ b/arch/mips/gt64120/common/time.c
@@ -64,14 +64,14 @@ static irqreturn_t gt64120_irq(int irq, void *dev_id)
64 * as *irq (=irq0 in ../kernel/time.c). We will do our own timer interrupt 64 * as *irq (=irq0 in ../kernel/time.c). We will do our own timer interrupt
65 * handling. 65 * handling.
66 */ 66 */
67void gt64120_time_init(void) 67void __init plat_timer_setup(struct irqaction *irq)
68{ 68{
69 static struct irqaction timer; 69 static struct irqaction timer;
70 70
71 /* Disable timer first */ 71 /* Disable timer first */
72 GT_WRITE(GT_TC_CONTROL_OFS, 0); 72 GT_WRITE(GT_TC_CONTROL_OFS, 0);
73 /* Load timer value for 100 Hz */ 73 /* Load timer value for 100 Hz */
74 GT_WRITE(GT_TC3_OFS, Sys_clock / 100); 74 GT_WRITE(GT_TC3_OFS, Sys_clock / HZ);
75 75
76 /* 76 /*
77 * Create the IRQ structure entry for the timer. Since we're too early 77 * Create the IRQ structure entry for the timer. Since we're too early
diff --git a/arch/mips/gt64120/ev64120/setup.c b/arch/mips/gt64120/ev64120/setup.c
index 91c2d3f41617..99c8d42212e2 100644
--- a/arch/mips/gt64120/ev64120/setup.c
+++ b/arch/mips/gt64120/ev64120/setup.c
@@ -68,7 +68,6 @@ unsigned long __init prom_free_prom_memory(void)
68 * Initializes basic routines and structures pointers, memory size (as 68 * Initializes basic routines and structures pointers, memory size (as
69 * given by the bios and saves the command line. 69 * given by the bios and saves the command line.
70 */ 70 */
71extern void gt64120_time_init(void);
72 71
73void __init plat_mem_setup(void) 72void __init plat_mem_setup(void)
74{ 73{
@@ -76,7 +75,6 @@ void __init plat_mem_setup(void)
76 _machine_halt = galileo_machine_halt; 75 _machine_halt = galileo_machine_halt;
77 pm_power_off = galileo_machine_power_off; 76 pm_power_off = galileo_machine_power_off;
78 77
79 board_time_init = gt64120_time_init;
80 set_io_port_base(KSEG1); 78 set_io_port_base(KSEG1);
81} 79}
82 80
diff --git a/arch/mips/gt64120/momenco_ocelot/setup.c b/arch/mips/gt64120/momenco_ocelot/setup.c
index 0e5bbee2d5b7..94f94ebbda6c 100644
--- a/arch/mips/gt64120/momenco_ocelot/setup.c
+++ b/arch/mips/gt64120/momenco_ocelot/setup.c
@@ -70,7 +70,6 @@ extern void momenco_ocelot_restart(char *command);
70extern void momenco_ocelot_halt(void); 70extern void momenco_ocelot_halt(void);
71extern void momenco_ocelot_power_off(void); 71extern void momenco_ocelot_power_off(void);
72 72
73extern void gt64120_time_init(void);
74extern void momenco_ocelot_irq_setup(void); 73extern void momenco_ocelot_irq_setup(void);
75 74
76static char reset_reason; 75static char reset_reason;
@@ -156,8 +155,6 @@ void __init plat_mem_setup(void)
156 void (*l3func)(unsigned long)=KSEG1ADDR(&setup_l3cache); 155 void (*l3func)(unsigned long)=KSEG1ADDR(&setup_l3cache);
157 unsigned int tmpword; 156 unsigned int tmpword;
158 157
159 board_time_init = gt64120_time_init;
160
161 _machine_restart = momenco_ocelot_restart; 158 _machine_restart = momenco_ocelot_restart;
162 _machine_halt = momenco_ocelot_halt; 159 _machine_halt = momenco_ocelot_halt;
163 pm_power_off = momenco_ocelot_power_off; 160 pm_power_off = momenco_ocelot_power_off;
diff --git a/arch/mips/jazz/setup.c b/arch/mips/jazz/setup.c
index 6dc4135d6e11..d848f1a07786 100644
--- a/arch/mips/jazz/setup.c
+++ b/arch/mips/jazz/setup.c
@@ -37,7 +37,7 @@ extern void jazz_machine_restart(char *command);
37extern void jazz_machine_halt(void); 37extern void jazz_machine_halt(void);
38extern void jazz_machine_power_off(void); 38extern void jazz_machine_power_off(void);
39 39
40void __init plat_time_init(struct irqaction *irq) 40void __init plat_timer_setup(struct irqaction *irq)
41{ 41{
42 /* set the clock to 100 Hz */ 42 /* set the clock to 100 Hz */
43 r4030_write_reg32(JAZZ_TIMER_INTERVAL, 9); 43 r4030_write_reg32(JAZZ_TIMER_INTERVAL, 9);
diff --git a/arch/mips/jmr3927/rbhma3100/irq.c b/arch/mips/jmr3927/rbhma3100/irq.c
index 39a0243bed9a..de4a238c28be 100644
--- a/arch/mips/jmr3927/rbhma3100/irq.c
+++ b/arch/mips/jmr3927/rbhma3100/irq.c
@@ -288,6 +288,8 @@ static void tx_branch_likely_bug_fixup(void)
288 288
289static void jmr3927_spurious(void) 289static void jmr3927_spurious(void)
290{ 290{
291 struct pt_regs * regs = get_irq_regs();
292
291#ifdef CONFIG_TX_BRANCH_LIKELY_BUG_WORKAROUND 293#ifdef CONFIG_TX_BRANCH_LIKELY_BUG_WORKAROUND
292 tx_branch_likely_bug_fixup(); 294 tx_branch_likely_bug_fixup();
293#endif 295#endif
@@ -297,6 +299,7 @@ static void jmr3927_spurious(void)
297 299
298asmlinkage void plat_irq_dispatch(void) 300asmlinkage void plat_irq_dispatch(void)
299{ 301{
302 struct pt_regs * regs = get_irq_regs();
300 int irq; 303 int irq;
301 304
302#ifdef CONFIG_TX_BRANCH_LIKELY_BUG_WORKAROUND 305#ifdef CONFIG_TX_BRANCH_LIKELY_BUG_WORKAROUND
diff --git a/arch/mips/jmr3927/rbhma3100/setup.c b/arch/mips/jmr3927/rbhma3100/setup.c
index 025434054ed0..16e5dfe7aa8a 100644
--- a/arch/mips/jmr3927/rbhma3100/setup.c
+++ b/arch/mips/jmr3927/rbhma3100/setup.c
@@ -170,12 +170,20 @@ static void jmr3927_machine_power_off(void)
170 while (1); 170 while (1);
171} 171}
172 172
173static unsigned int jmr3927_hpt_read(void)
174{
175 /* We assume this function is called xtime_lock held. */
176 return jiffies * (JMR3927_TIMER_CLK / HZ) + jmr3927_tmrptr->trr;
177}
178
173#define USE_RTC_DS1742 179#define USE_RTC_DS1742
174#ifdef USE_RTC_DS1742 180#ifdef USE_RTC_DS1742
175extern void rtc_ds1742_init(unsigned long base); 181extern void rtc_ds1742_init(unsigned long base);
176#endif 182#endif
177static void __init jmr3927_time_init(void) 183static void __init jmr3927_time_init(void)
178{ 184{
185 mips_hpt_read = jmr3927_hpt_read;
186 mips_hpt_frequency = JMR3927_TIMER_CLK;
179#ifdef USE_RTC_DS1742 187#ifdef USE_RTC_DS1742
180 if (jmr3927_have_nvram()) { 188 if (jmr3927_have_nvram()) {
181 rtc_ds1742_init(JMR3927_IOC_NVRAMB_ADDR); 189 rtc_ds1742_init(JMR3927_IOC_NVRAMB_ADDR);
@@ -183,12 +191,8 @@ static void __init jmr3927_time_init(void)
183#endif 191#endif
184} 192}
185 193
186unsigned long jmr3927_do_gettimeoffset(void);
187
188void __init plat_timer_setup(struct irqaction *irq) 194void __init plat_timer_setup(struct irqaction *irq)
189{ 195{
190 do_gettimeoffset = jmr3927_do_gettimeoffset;
191
192 jmr3927_tmrptr->cpra = JMR3927_TIMER_CLK / HZ; 196 jmr3927_tmrptr->cpra = JMR3927_TIMER_CLK / HZ;
193 jmr3927_tmrptr->itmr = TXx927_TMTITMR_TIIE | TXx927_TMTITMR_TZCE; 197 jmr3927_tmrptr->itmr = TXx927_TMTITMR_TIIE | TXx927_TMTITMR_TZCE;
194 jmr3927_tmrptr->ccdr = JMR3927_TIMER_CCD; 198 jmr3927_tmrptr->ccdr = JMR3927_TIMER_CCD;
@@ -200,34 +204,6 @@ void __init plat_timer_setup(struct irqaction *irq)
200 204
201#define USECS_PER_JIFFY (1000000/HZ) 205#define USECS_PER_JIFFY (1000000/HZ)
202 206
203unsigned long jmr3927_do_gettimeoffset(void)
204{
205 unsigned long count;
206 unsigned long res = 0;
207
208 /* MUST read TRR before TISR. */
209 count = jmr3927_tmrptr->trr;
210
211 if (jmr3927_tmrptr->tisr & TXx927_TMTISR_TIIS) {
212 /* timer interrupt is pending. use Max value. */
213 res = USECS_PER_JIFFY - 1;
214 } else {
215 /* convert to usec */
216 /* res = count / (JMR3927_TIMER_CLK / 1000000); */
217 res = (count << 7) / ((JMR3927_TIMER_CLK << 7) / 1000000);
218
219 /*
220 * Due to possible jiffies inconsistencies, we need to check
221 * the result so that we'll get a timer that is monotonic.
222 */
223 if (res >= USECS_PER_JIFFY)
224 res = USECS_PER_JIFFY-1;
225 }
226
227 return res;
228}
229
230
231//#undef DO_WRITE_THROUGH 207//#undef DO_WRITE_THROUGH
232#define DO_WRITE_THROUGH 208#define DO_WRITE_THROUGH
233#define DO_ENABLE_CACHE 209#define DO_ENABLE_CACHE
diff --git a/arch/mips/kernel/asm-offsets.c b/arch/mips/kernel/asm-offsets.c
index e9ce5b3721af..ff88b06f89df 100644
--- a/arch/mips/kernel/asm-offsets.c
+++ b/arch/mips/kernel/asm-offsets.c
@@ -22,7 +22,7 @@
22#define offset(string, ptr, member) \ 22#define offset(string, ptr, member) \
23 __asm__("\n@@@" string "%0" : : "i" (_offset(ptr, member))) 23 __asm__("\n@@@" string "%0" : : "i" (_offset(ptr, member)))
24#define constant(string, member) \ 24#define constant(string, member) \
25 __asm__("\n@@@" string "%x0" : : "ri" (member)) 25 __asm__("\n@@@" string "%X0" : : "ri" (member))
26#define size(string, size) \ 26#define size(string, size) \
27 __asm__("\n@@@" string "%0" : : "i" (sizeof(size))) 27 __asm__("\n@@@" string "%0" : : "i" (sizeof(size)))
28#define linefeed text("") 28#define linefeed text("")
diff --git a/arch/mips/kernel/entry.S b/arch/mips/kernel/entry.S
index 417c08ac76eb..f10b6a19f8bf 100644
--- a/arch/mips/kernel/entry.S
+++ b/arch/mips/kernel/entry.S
@@ -83,7 +83,10 @@ FEXPORT(syscall_exit)
83FEXPORT(restore_all) # restore full frame 83FEXPORT(restore_all) # restore full frame
84#ifdef CONFIG_MIPS_MT_SMTC 84#ifdef CONFIG_MIPS_MT_SMTC
85/* Detect and execute deferred IPI "interrupts" */ 85/* Detect and execute deferred IPI "interrupts" */
86 LONG_L s0, TI_REGS($28)
87 LONG_S sp, TI_REGS($28)
86 jal deferred_smtc_ipi 88 jal deferred_smtc_ipi
89 LONG_S s0, TI_REGS($28)
87/* Re-arm any temporarily masked interrupts not explicitly "acked" */ 90/* Re-arm any temporarily masked interrupts not explicitly "acked" */
88 mfc0 v0, CP0_TCSTATUS 91 mfc0 v0, CP0_TCSTATUS
89 ori v1, v0, TCSTATUS_IXMT 92 ori v1, v0, TCSTATUS_IXMT
diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S
index 8c6db0fc72f0..ddc1b71c9378 100644
--- a/arch/mips/kernel/head.S
+++ b/arch/mips/kernel/head.S
@@ -189,7 +189,8 @@ NESTED(kernel_entry, 16, sp) # kernel entry point
189 189
190 MTC0 zero, CP0_CONTEXT # clear context register 190 MTC0 zero, CP0_CONTEXT # clear context register
191 PTR_LA $28, init_thread_union 191 PTR_LA $28, init_thread_union
192 PTR_ADDIU sp, $28, _THREAD_SIZE - 32 192 PTR_LI sp, _THREAD_SIZE - 32
193 PTR_ADDU sp, $28
193 set_saved_sp sp, t0, t1 194 set_saved_sp sp, t0, t1
194 PTR_SUBU sp, 4 * SZREG # init stack pointer 195 PTR_SUBU sp, 4 * SZREG # init stack pointer
195 196
diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
index dd24434392b6..9b0e49d63d7b 100644
--- a/arch/mips/kernel/irq.c
+++ b/arch/mips/kernel/irq.c
@@ -26,6 +26,48 @@
26#include <asm/system.h> 26#include <asm/system.h>
27#include <asm/uaccess.h> 27#include <asm/uaccess.h>
28 28
29static unsigned long irq_map[NR_IRQS / BITS_PER_LONG];
30
31int __devinit allocate_irqno(void)
32{
33 int irq;
34
35again:
36 irq = find_first_zero_bit(irq_map, NR_IRQS);
37
38 if (irq >= NR_IRQS)
39 return -ENOSPC;
40
41 if (test_and_set_bit(irq, irq_map))
42 goto again;
43
44 return irq;
45}
46
47EXPORT_SYMBOL_GPL(allocate_irqno);
48
49/*
50 * Allocate the 16 legacy interrupts for i8259 devices. This happens early
51 * in the kernel initialization so treating allocation failure as BUG() is
52 * ok.
53 */
54void __init alloc_legacy_irqno(void)
55{
56 int i;
57
58 for (i = 0; i <= 16; i++)
59 BUG_ON(test_and_set_bit(i, irq_map));
60}
61
62void __devinit free_irqno(unsigned int irq)
63{
64 smp_mb__before_clear_bit();
65 clear_bit(irq, irq_map);
66 smp_mb__after_clear_bit();
67}
68
69EXPORT_SYMBOL_GPL(free_irqno);
70
29/* 71/*
30 * 'what should we do if we get a hw irq event on an illegal vector'. 72 * 'what should we do if we get a hw irq event on an illegal vector'.
31 * each architecture has to answer this themselves. 73 * each architecture has to answer this themselves.
diff --git a/arch/mips/kernel/linux32.c b/arch/mips/kernel/linux32.c
index 53f4171fc188..7a3ebbeba1f3 100644
--- a/arch/mips/kernel/linux32.c
+++ b/arch/mips/kernel/linux32.c
@@ -1055,7 +1055,9 @@ asmlinkage long sys32_newuname(struct new_utsname __user * name)
1055asmlinkage int sys32_personality(unsigned long personality) 1055asmlinkage int sys32_personality(unsigned long personality)
1056{ 1056{
1057 int ret; 1057 int ret;
1058 if (current->personality == PER_LINUX32 && personality == PER_LINUX) 1058 personality &= 0xffffffff;
1059 if (personality(current->personality) == PER_LINUX32 &&
1060 personality == PER_LINUX)
1059 personality = PER_LINUX32; 1061 personality = PER_LINUX32;
1060 ret = sys_personality(personality); 1062 ret = sys_personality(personality);
1061 if (ret == PER_LINUX32) 1063 if (ret == PER_LINUX32)
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index 9f307eb1a31e..ec8209f3a0c6 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -358,10 +358,8 @@ static int __init frame_info_init(void)
358 unsigned long size = 0; 358 unsigned long size = 0;
359#ifdef CONFIG_KALLSYMS 359#ifdef CONFIG_KALLSYMS
360 unsigned long ofs; 360 unsigned long ofs;
361 char *modname;
362 char namebuf[KSYM_NAME_LEN + 1];
363 361
364 kallsyms_lookup((unsigned long)schedule, &size, &ofs, &modname, namebuf); 362 kallsyms_lookup_size_offset((unsigned long)schedule, &size, &ofs);
365#endif 363#endif
366 schedule_mfi.func = schedule; 364 schedule_mfi.func = schedule;
367 schedule_mfi.func_size = size; 365 schedule_mfi.func_size = size;
@@ -403,8 +401,6 @@ unsigned long unwind_stack(struct task_struct *task, unsigned long *sp,
403{ 401{
404 unsigned long stack_page; 402 unsigned long stack_page;
405 struct mips_frame_info info; 403 struct mips_frame_info info;
406 char *modname;
407 char namebuf[KSYM_NAME_LEN + 1];
408 unsigned long size, ofs; 404 unsigned long size, ofs;
409 int leaf; 405 int leaf;
410 extern void ret_from_irq(void); 406 extern void ret_from_irq(void);
@@ -433,7 +429,7 @@ unsigned long unwind_stack(struct task_struct *task, unsigned long *sp,
433 } 429 }
434 return 0; 430 return 0;
435 } 431 }
436 if (!kallsyms_lookup(pc, &size, &ofs, &modname, namebuf)) 432 if (!kallsyms_lookup_size_offset(pc, &size, &ofs))
437 return 0; 433 return 0;
438 /* 434 /*
439 * Return ra if an exception occured at the first instruction 435 * Return ra if an exception occured at the first instruction
diff --git a/arch/mips/kernel/r4k_switch.S b/arch/mips/kernel/r4k_switch.S
index d5c8b82fed72..cc566cf12246 100644
--- a/arch/mips/kernel/r4k_switch.S
+++ b/arch/mips/kernel/r4k_switch.S
@@ -85,7 +85,12 @@
85 move $28, a2 85 move $28, a2
86 cpu_restore_nonscratch a1 86 cpu_restore_nonscratch a1
87 87
88#if (_THREAD_SIZE - 32) < 0x10000
88 PTR_ADDIU t0, $28, _THREAD_SIZE - 32 89 PTR_ADDIU t0, $28, _THREAD_SIZE - 32
90#else
91 PTR_LI t0, _THREAD_SIZE - 32
92 PTR_ADDU t0, $28
93#endif
89 set_saved_sp t0, t1, t2 94 set_saved_sp t0, t1, t2
90#ifdef CONFIG_MIPS_MT_SMTC 95#ifdef CONFIG_MIPS_MT_SMTC
91 /* Read-modify-writes of Status must be atomic on a VPE */ 96 /* Read-modify-writes of Status must be atomic on a VPE */
diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
index 61362e6fa9ec..a95f37de080e 100644
--- a/arch/mips/kernel/scall32-o32.S
+++ b/arch/mips/kernel/scall32-o32.S
@@ -652,7 +652,10 @@ einval: li v0, -EINVAL
652 sys sys_vmsplice 4 652 sys sys_vmsplice 4
653 sys sys_move_pages 6 653 sys sys_move_pages 6
654 sys sys_set_robust_list 2 654 sys sys_set_robust_list 2
655 sys sys_get_robust_list 3 655 sys sys_get_robust_list 3 /* 4310 */
656 sys sys_ni_syscall 0
657 sys sys_getcpu 3
658 sys sys_epoll_pwait 6
656 .endm 659 .endm
657 660
658 /* We pre-compute the number of _instruction_ bytes needed to 661 /* We pre-compute the number of _instruction_ bytes needed to
diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
index 6c7b5ed0ea6e..8fb0f60f657b 100644
--- a/arch/mips/kernel/scall64-64.S
+++ b/arch/mips/kernel/scall64-64.S
@@ -468,3 +468,6 @@ sys_call_table:
468 PTR sys_move_pages 468 PTR sys_move_pages
469 PTR sys_set_robust_list 469 PTR sys_set_robust_list
470 PTR sys_get_robust_list 470 PTR sys_get_robust_list
471 PTR sys_ni_syscall /* 5270 */
472 PTR sys_getcpu
473 PTR sys_epoll_pwait
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
index 6d9f18727ac5..0da5ca2040ff 100644
--- a/arch/mips/kernel/scall64-n32.S
+++ b/arch/mips/kernel/scall64-n32.S
@@ -280,7 +280,7 @@ EXPORT(sysn32_call_table)
280 PTR sys_sync 280 PTR sys_sync
281 PTR sys_acct 281 PTR sys_acct
282 PTR sys32_settimeofday 282 PTR sys32_settimeofday
283 PTR sys_mount /* 6160 */ 283 PTR compat_sys_mount /* 6160 */
284 PTR sys_umount 284 PTR sys_umount
285 PTR sys_swapon 285 PTR sys_swapon
286 PTR sys_swapoff 286 PTR sys_swapoff
@@ -394,3 +394,6 @@ EXPORT(sysn32_call_table)
394 PTR sys_move_pages 394 PTR sys_move_pages
395 PTR compat_sys_set_robust_list 395 PTR compat_sys_set_robust_list
396 PTR compat_sys_get_robust_list 396 PTR compat_sys_get_robust_list
397 PTR sys_ni_syscall
398 PTR sys_getcpu
399 PTR sys_epoll_pwait
diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
index 2e6d0673163e..b9d00cae8b5f 100644
--- a/arch/mips/kernel/scall64-o32.S
+++ b/arch/mips/kernel/scall64-o32.S
@@ -226,7 +226,7 @@ sys_call_table:
226 PTR sys_ni_syscall /* was sys_stat */ 226 PTR sys_ni_syscall /* was sys_stat */
227 PTR sys_lseek 227 PTR sys_lseek
228 PTR sys_getpid /* 4020 */ 228 PTR sys_getpid /* 4020 */
229 PTR sys_mount 229 PTR compat_sys_mount
230 PTR sys_oldumount 230 PTR sys_oldumount
231 PTR sys_setuid 231 PTR sys_setuid
232 PTR sys_getuid 232 PTR sys_getuid
@@ -516,4 +516,7 @@ sys_call_table:
516 PTR compat_sys_move_pages 516 PTR compat_sys_move_pages
517 PTR compat_sys_set_robust_list 517 PTR compat_sys_set_robust_list
518 PTR compat_sys_get_robust_list /* 4310 */ 518 PTR compat_sys_get_robust_list /* 4310 */
519 PTR sys_ni_syscall
520 PTR sys_getcpu
521 PTR sys_epoll_pwait
519 .size sys_call_table,.-sys_call_table 522 .size sys_call_table,.-sys_call_table
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index fdbb508661c5..8f6e89697ccf 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -223,7 +223,11 @@ disable:
223 223
224#else /* !CONFIG_BLK_DEV_INITRD */ 224#else /* !CONFIG_BLK_DEV_INITRD */
225 225
226#define init_initrd() 0 226static unsigned long __init init_initrd(void)
227{
228 return 0;
229}
230
227#define finalize_initrd() do {} while (0) 231#define finalize_initrd() do {} while (0)
228 232
229#endif 233#endif
diff --git a/arch/mips/kernel/smp-mt.c b/arch/mips/kernel/smp-mt.c
index 3b5f3b632622..2ac19a6cbf68 100644
--- a/arch/mips/kernel/smp-mt.c
+++ b/arch/mips/kernel/smp-mt.c
@@ -140,15 +140,90 @@ static struct irqaction irq_call = {
140 .name = "IPI_call" 140 .name = "IPI_call"
141}; 141};
142 142
143static void __init smp_copy_vpe_config(void)
144{
145 write_vpe_c0_status(
146 (read_c0_status() & ~(ST0_IM | ST0_IE | ST0_KSU)) | ST0_CU0);
147
148 /* set config to be the same as vpe0, particularly kseg0 coherency alg */
149 write_vpe_c0_config( read_c0_config());
150
151 /* make sure there are no software interrupts pending */
152 write_vpe_c0_cause(0);
153
154 /* Propagate Config7 */
155 write_vpe_c0_config7(read_c0_config7());
156
157 write_vpe_c0_count(read_c0_count());
158}
159
160static unsigned int __init smp_vpe_init(unsigned int tc, unsigned int mvpconf0,
161 unsigned int ncpu)
162{
163 if (tc > ((mvpconf0 & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT))
164 return ncpu;
165
166 /* Deactivate all but VPE 0 */
167 if (tc != 0) {
168 unsigned long tmp = read_vpe_c0_vpeconf0();
169
170 tmp &= ~VPECONF0_VPA;
171
172 /* master VPE */
173 tmp |= VPECONF0_MVP;
174 write_vpe_c0_vpeconf0(tmp);
175
176 /* Record this as available CPU */
177 cpu_set(tc, phys_cpu_present_map);
178 __cpu_number_map[tc] = ++ncpu;
179 __cpu_logical_map[ncpu] = tc;
180 }
181
182 /* Disable multi-threading with TC's */
183 write_vpe_c0_vpecontrol(read_vpe_c0_vpecontrol() & ~VPECONTROL_TE);
184
185 if (tc != 0)
186 smp_copy_vpe_config();
187
188 return ncpu;
189}
190
191static void __init smp_tc_init(unsigned int tc, unsigned int mvpconf0)
192{
193 unsigned long tmp;
194
195 if (!tc)
196 return;
197
198 /* bind a TC to each VPE, May as well put all excess TC's
199 on the last VPE */
200 if (tc >= (((mvpconf0 & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT)+1))
201 write_tc_c0_tcbind(read_tc_c0_tcbind() | ((mvpconf0 & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT));
202 else {
203 write_tc_c0_tcbind(read_tc_c0_tcbind() | tc);
204
205 /* and set XTC */
206 write_vpe_c0_vpeconf0(read_vpe_c0_vpeconf0() | (tc << VPECONF0_XTC_SHIFT));
207 }
208
209 tmp = read_tc_c0_tcstatus();
210
211 /* mark not allocated and not dynamically allocatable */
212 tmp &= ~(TCSTATUS_A | TCSTATUS_DA);
213 tmp |= TCSTATUS_IXMT; /* interrupt exempt */
214 write_tc_c0_tcstatus(tmp);
215
216 write_tc_c0_tchalt(TCHALT_H);
217}
218
143/* 219/*
144 * Common setup before any secondaries are started 220 * Common setup before any secondaries are started
145 * Make sure all CPU's are in a sensible state before we boot any of the 221 * Make sure all CPU's are in a sensible state before we boot any of the
146 * secondarys 222 * secondarys
147 */ 223 */
148void plat_smp_setup(void) 224void __init plat_smp_setup(void)
149{ 225{
150 unsigned long val; 226 unsigned int mvpconf0, ntc, tc, ncpu = 0;
151 int i, num;
152 227
153#ifdef CONFIG_MIPS_MT_FPAFF 228#ifdef CONFIG_MIPS_MT_FPAFF
154 /* If we have an FPU, enroll ourselves in the FPU-full mask */ 229 /* If we have an FPU, enroll ourselves in the FPU-full mask */
@@ -167,75 +242,16 @@ void plat_smp_setup(void)
167 /* Put MVPE's into 'configuration state' */ 242 /* Put MVPE's into 'configuration state' */
168 set_c0_mvpcontrol(MVPCONTROL_VPC); 243 set_c0_mvpcontrol(MVPCONTROL_VPC);
169 244
170 val = read_c0_mvpconf0(); 245 mvpconf0 = read_c0_mvpconf0();
246 ntc = (mvpconf0 & MVPCONF0_PTC) >> MVPCONF0_PTC_SHIFT;
171 247
172 /* we'll always have more TC's than VPE's, so loop setting everything 248 /* we'll always have more TC's than VPE's, so loop setting everything
173 to a sensible state */ 249 to a sensible state */
174 for (i = 0, num = 0; i <= ((val & MVPCONF0_PTC) >> MVPCONF0_PTC_SHIFT); i++) { 250 for (tc = 0; tc <= ntc; tc++) {
175 settc(i); 251 settc(tc);
176
177 /* VPE's */
178 if (i <= ((val & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT)) {
179
180 /* deactivate all but vpe0 */
181 if (i != 0) {
182 unsigned long tmp = read_vpe_c0_vpeconf0();
183
184 tmp &= ~VPECONF0_VPA;
185
186 /* master VPE */
187 tmp |= VPECONF0_MVP;
188 write_vpe_c0_vpeconf0(tmp);
189
190 /* Record this as available CPU */
191 cpu_set(i, phys_cpu_present_map);
192 __cpu_number_map[i] = ++num;
193 __cpu_logical_map[num] = i;
194 }
195
196 /* disable multi-threading with TC's */
197 write_vpe_c0_vpecontrol(read_vpe_c0_vpecontrol() & ~VPECONTROL_TE);
198
199 if (i != 0) {
200 write_vpe_c0_status((read_c0_status() & ~(ST0_IM | ST0_IE | ST0_KSU)) | ST0_CU0);
201 252
202 /* set config to be the same as vpe0, particularly kseg0 coherency alg */ 253 smp_tc_init(tc, mvpconf0);
203 write_vpe_c0_config( read_c0_config()); 254 ncpu = smp_vpe_init(tc, mvpconf0, ncpu);
204
205 /* make sure there are no software interrupts pending */
206 write_vpe_c0_cause(0);
207
208 /* Propagate Config7 */
209 write_vpe_c0_config7(read_c0_config7());
210 }
211
212 }
213
214 /* TC's */
215
216 if (i != 0) {
217 unsigned long tmp;
218
219 /* bind a TC to each VPE, May as well put all excess TC's
220 on the last VPE */
221 if ( i >= (((val & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT)+1) )
222 write_tc_c0_tcbind(read_tc_c0_tcbind() | ((val & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT) );
223 else {
224 write_tc_c0_tcbind( read_tc_c0_tcbind() | i);
225
226 /* and set XTC */
227 write_vpe_c0_vpeconf0( read_vpe_c0_vpeconf0() | (i << VPECONF0_XTC_SHIFT));
228 }
229
230 tmp = read_tc_c0_tcstatus();
231
232 /* mark not allocated and not dynamically allocatable */
233 tmp &= ~(TCSTATUS_A | TCSTATUS_DA);
234 tmp |= TCSTATUS_IXMT; /* interrupt exempt */
235 write_tc_c0_tcstatus(tmp);
236
237 write_tc_c0_tchalt(TCHALT_H);
238 }
239 } 255 }
240 256
241 /* Release config state */ 257 /* Release config state */
@@ -243,7 +259,7 @@ void plat_smp_setup(void)
243 259
244 /* We'll wait until starting the secondaries before starting MVPE */ 260 /* We'll wait until starting the secondaries before starting MVPE */
245 261
246 printk(KERN_INFO "Detected %i available secondary CPU(s)\n", num); 262 printk(KERN_INFO "Detected %i available secondary CPU(s)\n", ncpu);
247} 263}
248 264
249void __init plat_prepare_cpus(unsigned int max_cpus) 265void __init plat_prepare_cpus(unsigned int max_cpus)
diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index 1af3612a1ce8..db80957ada89 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -310,7 +310,7 @@ static void flush_tlb_all_ipi(void *info)
310 310
311void flush_tlb_all(void) 311void flush_tlb_all(void)
312{ 312{
313 on_each_cpu(flush_tlb_all_ipi, 0, 1, 1); 313 on_each_cpu(flush_tlb_all_ipi, NULL, 1, 1);
314} 314}
315 315
316static void flush_tlb_mm_ipi(void *mm) 316static void flush_tlb_mm_ipi(void *mm)
diff --git a/arch/mips/kernel/smtc-asm.S b/arch/mips/kernel/smtc-asm.S
index 1cb9441f1474..921207c4a83c 100644
--- a/arch/mips/kernel/smtc-asm.S
+++ b/arch/mips/kernel/smtc-asm.S
@@ -101,7 +101,9 @@ FEXPORT(__smtc_ipi_vector)
101 lw t0,PT_PADSLOT5(sp) 101 lw t0,PT_PADSLOT5(sp)
102 /* Argument from sender passed in stack pad slot 4 */ 102 /* Argument from sender passed in stack pad slot 4 */
103 lw a0,PT_PADSLOT4(sp) 103 lw a0,PT_PADSLOT4(sp)
104 PTR_LA ra, _ret_from_irq 104 LONG_L s0, TI_REGS($28)
105 LONG_S sp, TI_REGS($28)
106 PTR_LA ra, ret_from_irq
105 jr t0 107 jr t0
106 108
107/* 109/*
@@ -119,7 +121,10 @@ LEAF(self_ipi)
119 subu t1,sp,PT_SIZE 121 subu t1,sp,PT_SIZE
120 sw ra,PT_EPC(t1) 122 sw ra,PT_EPC(t1)
121 sw a0,PT_PADSLOT4(t1) 123 sw a0,PT_PADSLOT4(t1)
124 LONG_L s0, TI_REGS($28)
125 LONG_S sp, TI_REGS($28)
122 la t2,ipi_decode 126 la t2,ipi_decode
127 LONG_S s0, TI_REGS($28)
123 sw t2,PT_PADSLOT5(t1) 128 sw t2,PT_PADSLOT5(t1)
124 /* Save pre-disable value of TCStatus */ 129 /* Save pre-disable value of TCStatus */
125 sw t0,PT_TCSTATUS(t1) 130 sw t0,PT_TCSTATUS(t1)
diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
index cc1f7474f7d7..3b78caf112f5 100644
--- a/arch/mips/kernel/smtc.c
+++ b/arch/mips/kernel/smtc.c
@@ -476,6 +476,7 @@ void mipsmt_prepare_cpus(void)
476 write_vpe_c0_compare(0); 476 write_vpe_c0_compare(0);
477 /* Propagate Config7 */ 477 /* Propagate Config7 */
478 write_vpe_c0_config7(read_c0_config7()); 478 write_vpe_c0_config7(read_c0_config7());
479 write_vpe_c0_count(read_c0_count());
479 } 480 }
480 /* enable multi-threading within VPE */ 481 /* enable multi-threading within VPE */
481 write_vpe_c0_vpecontrol(read_vpe_c0_vpecontrol() | VPECONTROL_TE); 482 write_vpe_c0_vpecontrol(read_vpe_c0_vpecontrol() | VPECONTROL_TE);
diff --git a/arch/mips/kernel/stacktrace.c b/arch/mips/kernel/stacktrace.c
index 4aabe526a68e..a586aba337a7 100644
--- a/arch/mips/kernel/stacktrace.c
+++ b/arch/mips/kernel/stacktrace.c
@@ -57,7 +57,7 @@ static void save_context_stack(struct stack_trace *trace,
57 pc = unwind_stack(task, &sp, pc, &ra); 57 pc = unwind_stack(task, &sp, pc, &ra);
58 } while (pc); 58 } while (pc);
59#else 59#else
60 save_raw_context_stack(sp); 60 save_raw_context_stack(trace, sp);
61#endif 61#endif
62} 62}
63 63
diff --git a/arch/mips/kernel/time.c b/arch/mips/kernel/time.c
index debe86c2f691..e535f86efa2f 100644
--- a/arch/mips/kernel/time.c
+++ b/arch/mips/kernel/time.c
@@ -11,6 +11,7 @@
11 * Free Software Foundation; either version 2 of the License, or (at your 11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version. 12 * option) any later version.
13 */ 13 */
14#include <linux/clocksource.h>
14#include <linux/types.h> 15#include <linux/types.h>
15#include <linux/kernel.h> 16#include <linux/kernel.h>
16#include <linux/init.h> 17#include <linux/init.h>
@@ -67,15 +68,9 @@ int (*rtc_mips_set_time)(unsigned long) = null_rtc_set_time;
67int (*rtc_mips_set_mmss)(unsigned long); 68int (*rtc_mips_set_mmss)(unsigned long);
68 69
69 70
70/* usecs per counter cycle, shifted to left by 32 bits */
71static unsigned int sll32_usecs_per_cycle;
72
73/* how many counter cycles in a jiffy */ 71/* how many counter cycles in a jiffy */
74static unsigned long cycles_per_jiffy __read_mostly; 72static unsigned long cycles_per_jiffy __read_mostly;
75 73
76/* Cycle counter value at the previous timer interrupt.. */
77static unsigned int timerhi, timerlo;
78
79/* expirelo is the count value for next CPU timer interrupt */ 74/* expirelo is the count value for next CPU timer interrupt */
80static unsigned int expirelo; 75static unsigned int expirelo;
81 76
@@ -93,7 +88,7 @@ static unsigned int null_hpt_read(void)
93 return 0; 88 return 0;
94} 89}
95 90
96static void null_hpt_init(unsigned int count) 91static void __init null_hpt_init(void)
97{ 92{
98 /* nothing */ 93 /* nothing */
99} 94}
@@ -128,186 +123,18 @@ static unsigned int c0_hpt_read(void)
128 return read_c0_count(); 123 return read_c0_count();
129} 124}
130 125
131/* For use solely as a high precision timer. */
132static void c0_hpt_init(unsigned int count)
133{
134 write_c0_count(read_c0_count() - count);
135}
136
137/* For use both as a high precision timer and an interrupt source. */ 126/* For use both as a high precision timer and an interrupt source. */
138static void c0_hpt_timer_init(unsigned int count) 127static void __init c0_hpt_timer_init(void)
139{ 128{
140 count = read_c0_count() - count; 129 expirelo = read_c0_count() + cycles_per_jiffy;
141 expirelo = (count / cycles_per_jiffy + 1) * cycles_per_jiffy;
142 write_c0_count(expirelo - cycles_per_jiffy);
143 write_c0_compare(expirelo); 130 write_c0_compare(expirelo);
144 write_c0_count(count);
145} 131}
146 132
147int (*mips_timer_state)(void); 133int (*mips_timer_state)(void);
148void (*mips_timer_ack)(void); 134void (*mips_timer_ack)(void);
149unsigned int (*mips_hpt_read)(void); 135unsigned int (*mips_hpt_read)(void);
150void (*mips_hpt_init)(unsigned int); 136void (*mips_hpt_init)(void) __initdata = null_hpt_init;
151 137unsigned int mips_hpt_mask = 0xffffffff;
152/*
153 * Gettimeoffset routines. These routines returns the time duration
154 * since last timer interrupt in usecs.
155 *
156 * If the exact CPU counter frequency is known, use fixed_rate_gettimeoffset.
157 * Otherwise use calibrate_gettimeoffset()
158 *
159 * If the CPU does not have the counter register, you can either supply
160 * your own gettimeoffset() routine, or use null_gettimeoffset(), which
161 * gives the same resolution as HZ.
162 */
163
164static unsigned long null_gettimeoffset(void)
165{
166 return 0;
167}
168
169
170/* The function pointer to one of the gettimeoffset funcs. */
171unsigned long (*do_gettimeoffset)(void) = null_gettimeoffset;
172
173
174static unsigned long fixed_rate_gettimeoffset(void)
175{
176 u32 count;
177 unsigned long res;
178
179 /* Get last timer tick in absolute kernel time */
180 count = mips_hpt_read();
181
182 /* .. relative to previous jiffy (32 bits is enough) */
183 count -= timerlo;
184
185 __asm__("multu %1,%2"
186 : "=h" (res)
187 : "r" (count), "r" (sll32_usecs_per_cycle)
188 : "lo", GCC_REG_ACCUM);
189
190 /*
191 * Due to possible jiffies inconsistencies, we need to check
192 * the result so that we'll get a timer that is monotonic.
193 */
194 if (res >= USECS_PER_JIFFY)
195 res = USECS_PER_JIFFY - 1;
196
197 return res;
198}
199
200
201/*
202 * Cached "1/(clocks per usec) * 2^32" value.
203 * It has to be recalculated once each jiffy.
204 */
205static unsigned long cached_quotient;
206
207/* Last jiffy when calibrate_divXX_gettimeoffset() was called. */
208static unsigned long last_jiffies;
209
210/*
211 * This is moved from dec/time.c:do_ioasic_gettimeoffset() by Maciej.
212 */
213static unsigned long calibrate_div32_gettimeoffset(void)
214{
215 u32 count;
216 unsigned long res, tmp;
217 unsigned long quotient;
218
219 tmp = jiffies;
220
221 quotient = cached_quotient;
222
223 if (last_jiffies != tmp) {
224 last_jiffies = tmp;
225 if (last_jiffies != 0) {
226 unsigned long r0;
227 do_div64_32(r0, timerhi, timerlo, tmp);
228 do_div64_32(quotient, USECS_PER_JIFFY,
229 USECS_PER_JIFFY_FRAC, r0);
230 cached_quotient = quotient;
231 }
232 }
233
234 /* Get last timer tick in absolute kernel time */
235 count = mips_hpt_read();
236
237 /* .. relative to previous jiffy (32 bits is enough) */
238 count -= timerlo;
239
240 __asm__("multu %1,%2"
241 : "=h" (res)
242 : "r" (count), "r" (quotient)
243 : "lo", GCC_REG_ACCUM);
244
245 /*
246 * Due to possible jiffies inconsistencies, we need to check
247 * the result so that we'll get a timer that is monotonic.
248 */
249 if (res >= USECS_PER_JIFFY)
250 res = USECS_PER_JIFFY - 1;
251
252 return res;
253}
254
255static unsigned long calibrate_div64_gettimeoffset(void)
256{
257 u32 count;
258 unsigned long res, tmp;
259 unsigned long quotient;
260
261 tmp = jiffies;
262
263 quotient = cached_quotient;
264
265 if (last_jiffies != tmp) {
266 last_jiffies = tmp;
267 if (last_jiffies) {
268 unsigned long r0;
269 __asm__(".set push\n\t"
270 ".set mips3\n\t"
271 "lwu %0,%3\n\t"
272 "dsll32 %1,%2,0\n\t"
273 "or %1,%1,%0\n\t"
274 "ddivu $0,%1,%4\n\t"
275 "mflo %1\n\t"
276 "dsll32 %0,%5,0\n\t"
277 "or %0,%0,%6\n\t"
278 "ddivu $0,%0,%1\n\t"
279 "mflo %0\n\t"
280 ".set pop"
281 : "=&r" (quotient), "=&r" (r0)
282 : "r" (timerhi), "m" (timerlo),
283 "r" (tmp), "r" (USECS_PER_JIFFY),
284 "r" (USECS_PER_JIFFY_FRAC)
285 : "hi", "lo", GCC_REG_ACCUM);
286 cached_quotient = quotient;
287 }
288 }
289
290 /* Get last timer tick in absolute kernel time */
291 count = mips_hpt_read();
292
293 /* .. relative to previous jiffy (32 bits is enough) */
294 count -= timerlo;
295
296 __asm__("multu %1,%2"
297 : "=h" (res)
298 : "r" (count), "r" (quotient)
299 : "lo", GCC_REG_ACCUM);
300
301 /*
302 * Due to possible jiffies inconsistencies, we need to check
303 * the result so that we'll get a timer that is monotonic.
304 */
305 if (res >= USECS_PER_JIFFY)
306 res = USECS_PER_JIFFY - 1;
307
308 return res;
309}
310
311 138
312/* last time when xtime and rtc are sync'ed up */ 139/* last time when xtime and rtc are sync'ed up */
313static long last_rtc_update; 140static long last_rtc_update;
@@ -334,18 +161,10 @@ void local_timer_interrupt(int irq, void *dev_id)
334 */ 161 */
335irqreturn_t timer_interrupt(int irq, void *dev_id) 162irqreturn_t timer_interrupt(int irq, void *dev_id)
336{ 163{
337 unsigned long j;
338 unsigned int count;
339
340 write_seqlock(&xtime_lock); 164 write_seqlock(&xtime_lock);
341 165
342 count = mips_hpt_read();
343 mips_timer_ack(); 166 mips_timer_ack();
344 167
345 /* Update timerhi/timerlo for intra-jiffy calibration. */
346 timerhi += count < timerlo; /* Wrap around */
347 timerlo = count;
348
349 /* 168 /*
350 * call the generic timer interrupt handling 169 * call the generic timer interrupt handling
351 */ 170 */
@@ -368,47 +187,6 @@ irqreturn_t timer_interrupt(int irq, void *dev_id)
368 } 187 }
369 } 188 }
370 189
371 /*
372 * If jiffies has overflown in this timer_interrupt, we must
373 * update the timer[hi]/[lo] to make fast gettimeoffset funcs
374 * quotient calc still valid. -arca
375 *
376 * The first timer interrupt comes late as interrupts are
377 * enabled long after timers are initialized. Therefore the
378 * high precision timer is fast, leading to wrong gettimeoffset()
379 * calculations. We deal with it by setting it based on the
380 * number of its ticks between the second and the third interrupt.
381 * That is still somewhat imprecise, but it's a good estimate.
382 * --macro
383 */
384 j = jiffies;
385 if (j < 4) {
386 static unsigned int prev_count;
387 static int hpt_initialized;
388
389 switch (j) {
390 case 0:
391 timerhi = timerlo = 0;
392 mips_hpt_init(count);
393 break;
394 case 2:
395 prev_count = count;
396 break;
397 case 3:
398 if (!hpt_initialized) {
399 unsigned int c3 = 3 * (count - prev_count);
400
401 timerhi = 0;
402 timerlo = c3;
403 mips_hpt_init(count - c3);
404 hpt_initialized = 1;
405 }
406 break;
407 default:
408 break;
409 }
410 }
411
412 write_sequnlock(&xtime_lock); 190 write_sequnlock(&xtime_lock);
413 191
414 /* 192 /*
@@ -476,12 +254,11 @@ asmlinkage void ll_local_timer_interrupt(int irq)
476 * 1) board_time_init() - 254 * 1) board_time_init() -
477 * a) (optional) set up RTC routines, 255 * a) (optional) set up RTC routines,
478 * b) (optional) calibrate and set the mips_hpt_frequency 256 * b) (optional) calibrate and set the mips_hpt_frequency
479 * (only needed if you intended to use fixed_rate_gettimeoffset 257 * (only needed if you intended to use cpu counter as timer interrupt
480 * or use cpu counter as timer interrupt source) 258 * source)
481 * 2) setup xtime based on rtc_mips_get_time(). 259 * 2) setup xtime based on rtc_mips_get_time().
482 * 3) choose a appropriate gettimeoffset routine. 260 * 3) calculate a couple of cached variables for later usage
483 * 4) calculate a couple of cached variables for later usage 261 * 4) plat_timer_setup() -
484 * 5) plat_timer_setup() -
485 * a) (optional) over-write any choices made above by time_init(). 262 * a) (optional) over-write any choices made above by time_init().
486 * b) machine specific code should setup the timer irqaction. 263 * b) machine specific code should setup the timer irqaction.
487 * c) enable the timer interrupt 264 * c) enable the timer interrupt
@@ -533,13 +310,48 @@ static unsigned int __init calibrate_hpt(void)
533 } while (--i); 310 } while (--i);
534 hpt_end = mips_hpt_read(); 311 hpt_end = mips_hpt_read();
535 312
536 hpt_count = hpt_end - hpt_start; 313 hpt_count = (hpt_end - hpt_start) & mips_hpt_mask;
537 hz = HZ; 314 hz = HZ;
538 frequency = (u64)hpt_count * (u64)hz; 315 frequency = (u64)hpt_count * (u64)hz;
539 316
540 return frequency >> log_2_loops; 317 return frequency >> log_2_loops;
541} 318}
542 319
320static cycle_t read_mips_hpt(void)
321{
322 return (cycle_t)mips_hpt_read();
323}
324
325static struct clocksource clocksource_mips = {
326 .name = "MIPS",
327 .read = read_mips_hpt,
328 .is_continuous = 1,
329};
330
331static void __init init_mips_clocksource(void)
332{
333 u64 temp;
334 u32 shift;
335
336 if (!mips_hpt_frequency || mips_hpt_read == null_hpt_read)
337 return;
338
339 /* Calclate a somewhat reasonable rating value */
340 clocksource_mips.rating = 200 + mips_hpt_frequency / 10000000;
341 /* Find a shift value */
342 for (shift = 32; shift > 0; shift--) {
343 temp = (u64) NSEC_PER_SEC << shift;
344 do_div(temp, mips_hpt_frequency);
345 if ((temp >> 32) == 0)
346 break;
347 }
348 clocksource_mips.shift = shift;
349 clocksource_mips.mult = (u32)temp;
350 clocksource_mips.mask = mips_hpt_mask;
351
352 clocksource_register(&clocksource_mips);
353}
354
543void __init time_init(void) 355void __init time_init(void)
544{ 356{
545 if (board_time_init) 357 if (board_time_init)
@@ -555,41 +367,21 @@ void __init time_init(void)
555 -xtime.tv_sec, -xtime.tv_nsec); 367 -xtime.tv_sec, -xtime.tv_nsec);
556 368
557 /* Choose appropriate high precision timer routines. */ 369 /* Choose appropriate high precision timer routines. */
558 if (!cpu_has_counter && !mips_hpt_read) { 370 if (!cpu_has_counter && !mips_hpt_read)
559 /* No high precision timer -- sorry. */ 371 /* No high precision timer -- sorry. */
560 mips_hpt_read = null_hpt_read; 372 mips_hpt_read = null_hpt_read;
561 mips_hpt_init = null_hpt_init; 373 else if (!mips_hpt_frequency && !mips_timer_state) {
562 } else if (!mips_hpt_frequency && !mips_timer_state) {
563 /* A high precision timer of unknown frequency. */ 374 /* A high precision timer of unknown frequency. */
564 if (!mips_hpt_read) { 375 if (!mips_hpt_read)
565 /* No external high precision timer -- use R4k. */ 376 /* No external high precision timer -- use R4k. */
566 mips_hpt_read = c0_hpt_read; 377 mips_hpt_read = c0_hpt_read;
567 mips_hpt_init = c0_hpt_init;
568 }
569
570 if (cpu_has_mips32r1 || cpu_has_mips32r2 ||
571 (current_cpu_data.isa_level == MIPS_CPU_ISA_I) ||
572 (current_cpu_data.isa_level == MIPS_CPU_ISA_II))
573 /*
574 * We need to calibrate the counter but we don't have
575 * 64-bit division.
576 */
577 do_gettimeoffset = calibrate_div32_gettimeoffset;
578 else
579 /*
580 * We need to calibrate the counter but we *do* have
581 * 64-bit division.
582 */
583 do_gettimeoffset = calibrate_div64_gettimeoffset;
584 } else { 378 } else {
585 /* We know counter frequency. Or we can get it. */ 379 /* We know counter frequency. Or we can get it. */
586 if (!mips_hpt_read) { 380 if (!mips_hpt_read) {
587 /* No external high precision timer -- use R4k. */ 381 /* No external high precision timer -- use R4k. */
588 mips_hpt_read = c0_hpt_read; 382 mips_hpt_read = c0_hpt_read;
589 383
590 if (mips_timer_state) 384 if (!mips_timer_state) {
591 mips_hpt_init = c0_hpt_init;
592 else {
593 /* No external timer interrupt -- use R4k. */ 385 /* No external timer interrupt -- use R4k. */
594 mips_hpt_init = c0_hpt_timer_init; 386 mips_hpt_init = c0_hpt_timer_init;
595 mips_timer_ack = c0_timer_ack; 387 mips_timer_ack = c0_timer_ack;
@@ -598,16 +390,9 @@ void __init time_init(void)
598 if (!mips_hpt_frequency) 390 if (!mips_hpt_frequency)
599 mips_hpt_frequency = calibrate_hpt(); 391 mips_hpt_frequency = calibrate_hpt();
600 392
601 do_gettimeoffset = fixed_rate_gettimeoffset;
602
603 /* Calculate cache parameters. */ 393 /* Calculate cache parameters. */
604 cycles_per_jiffy = (mips_hpt_frequency + HZ / 2) / HZ; 394 cycles_per_jiffy = (mips_hpt_frequency + HZ / 2) / HZ;
605 395
606 /* sll32_usecs_per_cycle = 10^6 * 2^32 / mips_counter_freq */
607 do_div64_32(sll32_usecs_per_cycle,
608 1000000, mips_hpt_frequency / 2,
609 mips_hpt_frequency);
610
611 /* Report the high precision timer rate for a reference. */ 396 /* Report the high precision timer rate for a reference. */
612 printk("Using %u.%03u MHz high precision timer.\n", 397 printk("Using %u.%03u MHz high precision timer.\n",
613 ((mips_hpt_frequency + 500) / 1000) / 1000, 398 ((mips_hpt_frequency + 500) / 1000) / 1000,
@@ -619,7 +404,7 @@ void __init time_init(void)
619 mips_timer_ack = null_timer_ack; 404 mips_timer_ack = null_timer_ack;
620 405
621 /* This sets up the high precision timer for the first interrupt. */ 406 /* This sets up the high precision timer for the first interrupt. */
622 mips_hpt_init(mips_hpt_read()); 407 mips_hpt_init();
623 408
624 /* 409 /*
625 * Call board specific timer interrupt setup. 410 * Call board specific timer interrupt setup.
@@ -633,6 +418,8 @@ void __init time_init(void)
633 * is not invoked accidentally. 418 * is not invoked accidentally.
634 */ 419 */
635 plat_timer_setup(&timer_irqaction); 420 plat_timer_setup(&timer_irqaction);
421
422 init_mips_clocksource();
636} 423}
637 424
638#define FEBRUARY 2 425#define FEBRUARY 2
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index cce8313ec27d..9fda1b8be3a7 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -1111,7 +1111,7 @@ static struct shadow_registers {
1111static void mips_srs_init(void) 1111static void mips_srs_init(void)
1112{ 1112{
1113 shadow_registers.sr_supported = ((read_c0_srsctl() >> 26) & 0x0f) + 1; 1113 shadow_registers.sr_supported = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
1114 printk(KERN_INFO "%d MIPSR2 register sets available\n", 1114 printk(KERN_INFO "%ld MIPSR2 register sets available\n",
1115 shadow_registers.sr_supported); 1115 shadow_registers.sr_supported);
1116 shadow_registers.sr_allocated = 1; /* Set 0 used by kernel */ 1116 shadow_registers.sr_allocated = 1; /* Set 0 used by kernel */
1117} 1117}
diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S
index 0bb9cd889456..79f0317d84ac 100644
--- a/arch/mips/kernel/vmlinux.lds.S
+++ b/arch/mips/kernel/vmlinux.lds.S
@@ -50,6 +50,16 @@ SECTIONS
50 /* writeable */ 50 /* writeable */
51 .data : { /* Data */ 51 .data : { /* Data */
52 . = . + DATAOFFSET; /* for CONFIG_MAPPED_KERNEL */ 52 . = . + DATAOFFSET; /* for CONFIG_MAPPED_KERNEL */
53 /*
54 * This ALIGN is needed as a workaround for a bug a gcc bug upto 4.1 which
55 * limits the maximum alignment to at most 32kB and results in the following
56 * warning:
57 *
58 * CC arch/mips/kernel/init_task.o
59 * arch/mips/kernel/init_task.c:30: warning: alignment of ‘init_thread_union’
60 * is greater than maximum object file alignment. Using 32768
61 */
62 . = ALIGN(_PAGE_SIZE);
53 *(.data.init_task) 63 *(.data.init_task)
54 64
55 *(.data) 65 *(.data)
@@ -91,13 +101,7 @@ SECTIONS
91 101
92 __initcall_start = .; 102 __initcall_start = .;
93 .initcall.init : { 103 .initcall.init : {
94 *(.initcall1.init) 104 INITCALLS
95 *(.initcall2.init)
96 *(.initcall3.init)
97 *(.initcall4.init)
98 *(.initcall5.init)
99 *(.initcall6.init)
100 *(.initcall7.init)
101 } 105 }
102 __initcall_end = .; 106 __initcall_end = .;
103 107
diff --git a/arch/mips/lib-64/dump_tlb.c b/arch/mips/lib-64/dump_tlb.c
index be8261be679b..594df1a05ecc 100644
--- a/arch/mips/lib-64/dump_tlb.c
+++ b/arch/mips/lib-64/dump_tlb.c
@@ -149,7 +149,7 @@ void dump_list_process(struct task_struct *t, void *address)
149 printk("Addr == %08lx\n", addr); 149 printk("Addr == %08lx\n", addr);
150 printk("tasks->mm.pgd == %08lx\n", (unsigned long) t->mm->pgd); 150 printk("tasks->mm.pgd == %08lx\n", (unsigned long) t->mm->pgd);
151 151
152 page_dir = pgd_offset(t->mm, 0); 152 page_dir = pgd_offset(t->mm, 0UL);
153 printk("page_dir == %016lx\n", (unsigned long) page_dir); 153 printk("page_dir == %016lx\n", (unsigned long) page_dir);
154 154
155 pgd = pgd_offset(t->mm, addr); 155 pgd = pgd_offset(t->mm, addr);
@@ -184,13 +184,13 @@ void dump_list_current(void *address)
184 dump_list_process(current, address); 184 dump_list_process(current, address);
185} 185}
186 186
187unsigned int vtop(void *address) 187unsigned long vtop(void *address)
188{ 188{
189 pgd_t *pgd; 189 pgd_t *pgd;
190 pud_t *pud; 190 pud_t *pud;
191 pmd_t *pmd; 191 pmd_t *pmd;
192 pte_t *pte; 192 pte_t *pte;
193 unsigned int addr, paddr; 193 unsigned long addr, paddr;
194 194
195 addr = (unsigned long) address; 195 addr = (unsigned long) address;
196 pgd = pgd_offset(current->mm, addr); 196 pgd = pgd_offset(current->mm, addr);
diff --git a/arch/mips/mips-boards/generic/memory.c b/arch/mips/mips-boards/generic/memory.c
index be80c5dd4a0c..eeed944e0f83 100644
--- a/arch/mips/mips-boards/generic/memory.c
+++ b/arch/mips/mips-boards/generic/memory.c
@@ -176,7 +176,7 @@ unsigned long __init prom_free_prom_memory(void)
176 if (boot_mem_map.map[i].type != BOOT_MEM_ROM_DATA) 176 if (boot_mem_map.map[i].type != BOOT_MEM_ROM_DATA)
177 continue; 177 continue;
178 178
179 addr = boot_mem_map.map[i].addr; 179 addr = PAGE_ALIGN(boot_mem_map.map[i].addr);
180 while (addr < boot_mem_map.map[i].addr 180 while (addr < boot_mem_map.map[i].addr
181 + boot_mem_map.map[i].size) { 181 + boot_mem_map.map[i].size) {
182 ClearPageReserved(virt_to_page(__va(addr))); 182 ClearPageReserved(virt_to_page(__va(addr)));
diff --git a/arch/mips/mips-boards/generic/pci.c b/arch/mips/mips-boards/generic/pci.c
index 9337f6c8873a..3192a14698c8 100644
--- a/arch/mips/mips-boards/generic/pci.c
+++ b/arch/mips/mips-boards/generic/pci.c
@@ -90,7 +90,7 @@ static struct pci_controller msc_controller = {
90void __init mips_pcibios_init(void) 90void __init mips_pcibios_init(void)
91{ 91{
92 struct pci_controller *controller; 92 struct pci_controller *controller;
93 unsigned long start, end, map, start1, end1, map1, map2, map3, mask; 93 resource_size_t start, end, map, start1, end1, map1, map2, map3, mask;
94 94
95 switch (mips_revision_corid) { 95 switch (mips_revision_corid) {
96 case MIPS_REVISION_CORID_QED_RM5261: 96 case MIPS_REVISION_CORID_QED_RM5261:
diff --git a/arch/mips/mips-boards/generic/time.c b/arch/mips/mips-boards/generic/time.c
index 6f8a9fe7c1e3..d817c60c5ca5 100644
--- a/arch/mips/mips-boards/generic/time.c
+++ b/arch/mips/mips-boards/generic/time.c
@@ -187,7 +187,7 @@ out:
187} 187}
188 188
189/* 189/*
190 * Estimate CPU frequency. Sets mips_counter_frequency as a side-effect 190 * Estimate CPU frequency. Sets mips_hpt_frequency as a side-effect
191 */ 191 */
192static unsigned int __init estimate_cpu_frequency(void) 192static unsigned int __init estimate_cpu_frequency(void)
193{ 193{
@@ -208,7 +208,8 @@ static unsigned int __init estimate_cpu_frequency(void)
208 count = 6000000; 208 count = 6000000;
209#endif 209#endif
210#if defined(CONFIG_MIPS_ATLAS) || defined(CONFIG_MIPS_MALTA) 210#if defined(CONFIG_MIPS_ATLAS) || defined(CONFIG_MIPS_MALTA)
211 unsigned int flags; 211 unsigned long flags;
212 unsigned int start;
212 213
213 local_irq_save(flags); 214 local_irq_save(flags);
214 215
@@ -217,13 +218,13 @@ static unsigned int __init estimate_cpu_frequency(void)
217 while (!(CMOS_READ(RTC_REG_A) & RTC_UIP)); 218 while (!(CMOS_READ(RTC_REG_A) & RTC_UIP));
218 219
219 /* Start r4k counter. */ 220 /* Start r4k counter. */
220 write_c0_count(0); 221 start = read_c0_count();
221 222
222 /* Read counter exactly on falling edge of update flag */ 223 /* Read counter exactly on falling edge of update flag */
223 while (CMOS_READ(RTC_REG_A) & RTC_UIP); 224 while (CMOS_READ(RTC_REG_A) & RTC_UIP);
224 while (!(CMOS_READ(RTC_REG_A) & RTC_UIP)); 225 while (!(CMOS_READ(RTC_REG_A) & RTC_UIP));
225 226
226 count = read_c0_count(); 227 count = read_c0_count() - start;
227 228
228 /* restore interrupts */ 229 /* restore interrupts */
229 local_irq_restore(flags); 230 local_irq_restore(flags);
diff --git a/arch/mips/mips-boards/malta/malta_int.c b/arch/mips/mips-boards/malta/malta_int.c
index 6244d0e2c7de..90ad5bf3e2f1 100644
--- a/arch/mips/mips-boards/malta/malta_int.c
+++ b/arch/mips/mips-boards/malta/malta_int.c
@@ -32,6 +32,7 @@
32#include <asm/i8259.h> 32#include <asm/i8259.h>
33#include <asm/irq_cpu.h> 33#include <asm/irq_cpu.h>
34#include <asm/io.h> 34#include <asm/io.h>
35#include <asm/irq_regs.h>
35#include <asm/mips-boards/malta.h> 36#include <asm/mips-boards/malta.h>
36#include <asm/mips-boards/maltaint.h> 37#include <asm/mips-boards/maltaint.h>
37#include <asm/mips-boards/piix4.h> 38#include <asm/mips-boards/piix4.h>
@@ -131,7 +132,7 @@ static void corehi_irqdispatch(void)
131 unsigned int intedge, intsteer, pcicmd, pcibadaddr; 132 unsigned int intedge, intsteer, pcicmd, pcibadaddr;
132 unsigned int pcimstat, intisr, inten, intpol; 133 unsigned int pcimstat, intisr, inten, intpol;
133 unsigned int intrcause,datalo,datahi; 134 unsigned int intrcause,datalo,datahi;
134 struct pt_regs *regs; 135 struct pt_regs *regs = get_irq_regs();
135 136
136 printk("CoreHI interrupt, shouldn't happen, so we die here!!!\n"); 137 printk("CoreHI interrupt, shouldn't happen, so we die here!!!\n");
137 printk("epc : %08lx\nStatus: %08lx\n" 138 printk("epc : %08lx\nStatus: %08lx\n"
diff --git a/arch/mips/mips-boards/sim/sim_time.c b/arch/mips/mips-boards/sim/sim_time.c
index c566b9bd0427..24a4ed00cc0a 100644
--- a/arch/mips/mips-boards/sim/sim_time.c
+++ b/arch/mips/mips-boards/sim/sim_time.c
@@ -102,7 +102,7 @@ irqreturn_t sim_timer_interrupt(int irq, void *dev_id)
102 102
103 103
104/* 104/*
105 * Estimate CPU frequency. Sets mips_counter_frequency as a side-effect 105 * Estimate CPU frequency. Sets mips_hpt_frequency as a side-effect
106 */ 106 */
107static unsigned int __init estimate_cpu_frequency(void) 107static unsigned int __init estimate_cpu_frequency(void)
108{ 108{
diff --git a/arch/mips/mm/c-sb1.c b/arch/mips/mm/c-sb1.c
index 5537558f19f7..d0ddb4a768a5 100644
--- a/arch/mips/mm/c-sb1.c
+++ b/arch/mips/mm/c-sb1.c
@@ -49,6 +49,15 @@ static unsigned short dcache_sets;
49static unsigned int icache_range_cutoff; 49static unsigned int icache_range_cutoff;
50static unsigned int dcache_range_cutoff; 50static unsigned int dcache_range_cutoff;
51 51
52static inline void sb1_on_each_cpu(void (*func) (void *info), void *info,
53 int retry, int wait)
54{
55 preempt_disable();
56 smp_call_function(func, info, retry, wait);
57 func(info);
58 preempt_enable();
59}
60
52/* 61/*
53 * The dcache is fully coherent to the system, with one 62 * The dcache is fully coherent to the system, with one
54 * big caveat: the instruction stream. In other words, 63 * big caveat: the instruction stream. In other words,
@@ -226,7 +235,7 @@ static void sb1_flush_cache_page(struct vm_area_struct *vma, unsigned long addr,
226 args.vma = vma; 235 args.vma = vma;
227 args.addr = addr; 236 args.addr = addr;
228 args.pfn = pfn; 237 args.pfn = pfn;
229 on_each_cpu(sb1_flush_cache_page_ipi, (void *) &args, 1, 1); 238 sb1_on_each_cpu(sb1_flush_cache_page_ipi, (void *) &args, 1, 1);
230} 239}
231#else 240#else
232void sb1_flush_cache_page(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn) 241void sb1_flush_cache_page(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn)
@@ -249,7 +258,7 @@ void sb1___flush_cache_all_ipi(void *ignored)
249 258
250static void sb1___flush_cache_all(void) 259static void sb1___flush_cache_all(void)
251{ 260{
252 on_each_cpu(sb1___flush_cache_all_ipi, 0, 1, 1); 261 sb1_on_each_cpu(sb1___flush_cache_all_ipi, 0, 1, 1);
253} 262}
254#else 263#else
255void sb1___flush_cache_all(void) 264void sb1___flush_cache_all(void)
@@ -299,7 +308,7 @@ void sb1_flush_icache_range(unsigned long start, unsigned long end)
299 308
300 args.start = start; 309 args.start = start;
301 args.end = end; 310 args.end = end;
302 on_each_cpu(sb1_flush_icache_range_ipi, &args, 1, 1); 311 sb1_on_each_cpu(sb1_flush_icache_range_ipi, &args, 1, 1);
303} 312}
304#else 313#else
305void sb1_flush_icache_range(unsigned long start, unsigned long end) 314void sb1_flush_icache_range(unsigned long start, unsigned long end)
@@ -326,7 +335,7 @@ static void sb1_flush_cache_sigtramp_ipi(void *info)
326 335
327static void sb1_flush_cache_sigtramp(unsigned long addr) 336static void sb1_flush_cache_sigtramp(unsigned long addr)
328{ 337{
329 on_each_cpu(sb1_flush_cache_sigtramp_ipi, (void *) addr, 1, 1); 338 sb1_on_each_cpu(sb1_flush_cache_sigtramp_ipi, (void *) addr, 1, 1);
330} 339}
331#else 340#else
332void sb1_flush_cache_sigtramp(unsigned long addr) 341void sb1_flush_cache_sigtramp(unsigned long addr)
@@ -444,7 +453,6 @@ static __init void probe_cache_sizes(void)
444void sb1_cache_init(void) 453void sb1_cache_init(void)
445{ 454{
446 extern char except_vec2_sb1; 455 extern char except_vec2_sb1;
447 extern char handle_vec2_sb1;
448 456
449 /* Special cache error handler for SB1 */ 457 /* Special cache error handler for SB1 */
450 set_uncached_handler (0x100, &except_vec2_sb1, 0x80); 458 set_uncached_handler (0x100, &except_vec2_sb1, 0x80);
@@ -497,5 +505,5 @@ void sb1_cache_init(void)
497 : 505 :
498 : "memory"); 506 : "memory");
499 507
500 flush_cache_all(); 508 local_sb1___flush_cache_all();
501} 509}
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index 88b72c9a8495..2de4d3c367a2 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -30,11 +30,34 @@
30#include <asm/cachectl.h> 30#include <asm/cachectl.h>
31#include <asm/cpu.h> 31#include <asm/cpu.h>
32#include <asm/dma.h> 32#include <asm/dma.h>
33#include <asm/kmap_types.h>
33#include <asm/mmu_context.h> 34#include <asm/mmu_context.h>
34#include <asm/sections.h> 35#include <asm/sections.h>
35#include <asm/pgtable.h> 36#include <asm/pgtable.h>
36#include <asm/pgalloc.h> 37#include <asm/pgalloc.h>
37#include <asm/tlb.h> 38#include <asm/tlb.h>
39#include <asm/fixmap.h>
40
41/* Atomicity and interruptability */
42#ifdef CONFIG_MIPS_MT_SMTC
43
44#include <asm/mipsmtregs.h>
45
46#define ENTER_CRITICAL(flags) \
47 { \
48 unsigned int mvpflags; \
49 local_irq_save(flags);\
50 mvpflags = dvpe()
51#define EXIT_CRITICAL(flags) \
52 evpe(mvpflags); \
53 local_irq_restore(flags); \
54 }
55#else
56
57#define ENTER_CRITICAL(flags) local_irq_save(flags)
58#define EXIT_CRITICAL(flags) local_irq_restore(flags)
59
60#endif /* CONFIG_MIPS_MT_SMTC */
38 61
39DEFINE_PER_CPU(struct mmu_gather, mmu_gathers); 62DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
40 63
@@ -80,13 +103,142 @@ unsigned long setup_zero_pages(void)
80 return 1UL << order; 103 return 1UL << order;
81} 104}
82 105
83#ifdef CONFIG_HIGHMEM 106/*
84pte_t *kmap_pte; 107 * These are almost like kmap_atomic / kunmap_atmic except they take an
85pgprot_t kmap_prot; 108 * additional address argument as the hint.
109 */
86 110
87#define kmap_get_fixmap_pte(vaddr) \ 111#define kmap_get_fixmap_pte(vaddr) \
88 pte_offset_kernel(pmd_offset(pud_offset(pgd_offset_k(vaddr), (vaddr)), (vaddr)), (vaddr)) 112 pte_offset_kernel(pmd_offset(pud_offset(pgd_offset_k(vaddr), (vaddr)), (vaddr)), (vaddr))
89 113
114#ifdef CONFIG_MIPS_MT_SMTC
115static pte_t *kmap_coherent_pte;
116static void __init kmap_coherent_init(void)
117{
118 unsigned long vaddr;
119
120 /* cache the first coherent kmap pte */
121 vaddr = __fix_to_virt(FIX_CMAP_BEGIN);
122 kmap_coherent_pte = kmap_get_fixmap_pte(vaddr);
123}
124#else
125static inline void kmap_coherent_init(void) {}
126#endif
127
128static inline void *kmap_coherent(struct page *page, unsigned long addr)
129{
130 enum fixed_addresses idx;
131 unsigned long vaddr, flags, entrylo;
132 unsigned long old_ctx;
133 pte_t pte;
134 int tlbidx;
135
136 inc_preempt_count();
137 idx = (addr >> PAGE_SHIFT) & (FIX_N_COLOURS - 1);
138#ifdef CONFIG_MIPS_MT_SMTC
139 idx += FIX_N_COLOURS * smp_processor_id();
140#endif
141 vaddr = __fix_to_virt(FIX_CMAP_END - idx);
142 pte = mk_pte(page, PAGE_KERNEL);
143#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32_R1)
144 entrylo = pte.pte_high;
145#else
146 entrylo = pte_val(pte) >> 6;
147#endif
148
149 ENTER_CRITICAL(flags);
150 old_ctx = read_c0_entryhi();
151 write_c0_entryhi(vaddr & (PAGE_MASK << 1));
152 write_c0_entrylo0(entrylo);
153 write_c0_entrylo1(entrylo);
154#ifdef CONFIG_MIPS_MT_SMTC
155 set_pte(kmap_coherent_pte - (FIX_CMAP_END - idx), pte);
156 /* preload TLB instead of local_flush_tlb_one() */
157 mtc0_tlbw_hazard();
158 tlb_probe();
159 tlb_probe_hazard();
160 tlbidx = read_c0_index();
161 mtc0_tlbw_hazard();
162 if (tlbidx < 0)
163 tlb_write_random();
164 else
165 tlb_write_indexed();
166#else
167 tlbidx = read_c0_wired();
168 write_c0_wired(tlbidx + 1);
169 write_c0_index(tlbidx);
170 mtc0_tlbw_hazard();
171 tlb_write_indexed();
172#endif
173 tlbw_use_hazard();
174 write_c0_entryhi(old_ctx);
175 EXIT_CRITICAL(flags);
176
177 return (void*) vaddr;
178}
179
180#define UNIQUE_ENTRYHI(idx) (CKSEG0 + ((idx) << (PAGE_SHIFT + 1)))
181
182static inline void kunmap_coherent(struct page *page)
183{
184#ifndef CONFIG_MIPS_MT_SMTC
185 unsigned int wired;
186 unsigned long flags, old_ctx;
187
188 ENTER_CRITICAL(flags);
189 old_ctx = read_c0_entryhi();
190 wired = read_c0_wired() - 1;
191 write_c0_wired(wired);
192 write_c0_index(wired);
193 write_c0_entryhi(UNIQUE_ENTRYHI(wired));
194 write_c0_entrylo0(0);
195 write_c0_entrylo1(0);
196 mtc0_tlbw_hazard();
197 tlb_write_indexed();
198 tlbw_use_hazard();
199 write_c0_entryhi(old_ctx);
200 EXIT_CRITICAL(flags);
201#endif
202 dec_preempt_count();
203 preempt_check_resched();
204}
205
206void copy_to_user_page(struct vm_area_struct *vma,
207 struct page *page, unsigned long vaddr, void *dst, const void *src,
208 unsigned long len)
209{
210 if (cpu_has_dc_aliases) {
211 void *vto = kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK);
212 memcpy(vto, src, len);
213 kunmap_coherent(page);
214 } else
215 memcpy(dst, src, len);
216 if ((vma->vm_flags & VM_EXEC) && !cpu_has_ic_fills_f_dc)
217 flush_cache_page(vma, vaddr, page_to_pfn(page));
218}
219
220EXPORT_SYMBOL(copy_to_user_page);
221
222void copy_from_user_page(struct vm_area_struct *vma,
223 struct page *page, unsigned long vaddr, void *dst, const void *src,
224 unsigned long len)
225{
226 if (cpu_has_dc_aliases) {
227 void *vfrom =
228 kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK);
229 memcpy(dst, vfrom, len);
230 kunmap_coherent(page);
231 } else
232 memcpy(dst, src, len);
233}
234
235EXPORT_SYMBOL(copy_from_user_page);
236
237
238#ifdef CONFIG_HIGHMEM
239pte_t *kmap_pte;
240pgprot_t kmap_prot;
241
90static void __init kmap_init(void) 242static void __init kmap_init(void)
91{ 243{
92 unsigned long kmap_vstart; 244 unsigned long kmap_vstart;
@@ -97,11 +249,12 @@ static void __init kmap_init(void)
97 249
98 kmap_prot = PAGE_KERNEL; 250 kmap_prot = PAGE_KERNEL;
99} 251}
252#endif /* CONFIG_HIGHMEM */
100 253
101#ifdef CONFIG_32BIT
102void __init fixrange_init(unsigned long start, unsigned long end, 254void __init fixrange_init(unsigned long start, unsigned long end,
103 pgd_t *pgd_base) 255 pgd_t *pgd_base)
104{ 256{
257#if defined(CONFIG_HIGHMEM) || defined(CONFIG_MIPS_MT_SMTC)
105 pgd_t *pgd; 258 pgd_t *pgd;
106 pud_t *pud; 259 pud_t *pud;
107 pmd_t *pmd; 260 pmd_t *pmd;
@@ -122,7 +275,7 @@ void __init fixrange_init(unsigned long start, unsigned long end,
122 for (; (k < PTRS_PER_PMD) && (vaddr != end); pmd++, k++) { 275 for (; (k < PTRS_PER_PMD) && (vaddr != end); pmd++, k++) {
123 if (pmd_none(*pmd)) { 276 if (pmd_none(*pmd)) {
124 pte = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE); 277 pte = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE);
125 set_pmd(pmd, __pmd(pte)); 278 set_pmd(pmd, __pmd((unsigned long)pte));
126 if (pte != pte_offset_kernel(pmd, 0)) 279 if (pte != pte_offset_kernel(pmd, 0))
127 BUG(); 280 BUG();
128 } 281 }
@@ -132,9 +285,8 @@ void __init fixrange_init(unsigned long start, unsigned long end,
132 } 285 }
133 j = 0; 286 j = 0;
134 } 287 }
288#endif
135} 289}
136#endif /* CONFIG_32BIT */
137#endif /* CONFIG_HIGHMEM */
138 290
139#ifndef CONFIG_NEED_MULTIPLE_NODES 291#ifndef CONFIG_NEED_MULTIPLE_NODES
140extern void pagetable_init(void); 292extern void pagetable_init(void);
@@ -175,6 +327,7 @@ void __init paging_init(void)
175#ifdef CONFIG_HIGHMEM 327#ifdef CONFIG_HIGHMEM
176 kmap_init(); 328 kmap_init();
177#endif 329#endif
330 kmap_coherent_init();
178 331
179 max_dma = virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT; 332 max_dma = virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
180 low = max_low_pfn; 333 low = max_low_pfn;
diff --git a/arch/mips/mm/ioremap.c b/arch/mips/mm/ioremap.c
index 3101d1db5592..cea7d0ea36e4 100644
--- a/arch/mips/mm/ioremap.c
+++ b/arch/mips/mm/ioremap.c
@@ -176,7 +176,7 @@ void __iomem * __ioremap(phys_t phys_addr, phys_t size, unsigned long flags)
176 176
177#define IS_KSEG1(addr) (((unsigned long)(addr) & ~0x1fffffffUL) == CKSEG1) 177#define IS_KSEG1(addr) (((unsigned long)(addr) & ~0x1fffffffUL) == CKSEG1)
178 178
179void __iounmap(volatile void __iomem *addr) 179void __iounmap(const volatile void __iomem *addr)
180{ 180{
181 struct vm_struct *p; 181 struct vm_struct *p;
182 182
diff --git a/arch/mips/mm/pg-r4k.c b/arch/mips/mm/pg-r4k.c
index b7c749232ffe..d41fc5885e87 100644
--- a/arch/mips/mm/pg-r4k.c
+++ b/arch/mips/mm/pg-r4k.c
@@ -270,6 +270,20 @@ static inline void build_addiu_a2_a0(unsigned long offset)
270 emit_instruction(mi); 270 emit_instruction(mi);
271} 271}
272 272
273static inline void build_addiu_a2(unsigned long offset)
274{
275 union mips_instruction mi;
276
277 BUG_ON(offset > 0x7fff);
278
279 mi.i_format.opcode = cpu_has_64bit_gp_regs ? daddiu_op : addiu_op;
280 mi.i_format.rs = 6; /* $a2 */
281 mi.i_format.rt = 6; /* $a2 */
282 mi.i_format.simmediate = offset;
283
284 emit_instruction(mi);
285}
286
273static inline void build_addiu_a1(unsigned long offset) 287static inline void build_addiu_a1(unsigned long offset)
274{ 288{
275 union mips_instruction mi; 289 union mips_instruction mi;
@@ -333,6 +347,7 @@ static inline void build_jr_ra(void)
333void __init build_clear_page(void) 347void __init build_clear_page(void)
334{ 348{
335 unsigned int loop_start; 349 unsigned int loop_start;
350 unsigned long off;
336 351
337 epc = (unsigned int *) &clear_page_array; 352 epc = (unsigned int *) &clear_page_array;
338 instruction_pending = 0; 353 instruction_pending = 0;
@@ -369,7 +384,12 @@ void __init build_clear_page(void)
369 } 384 }
370 } 385 }
371 386
372 build_addiu_a2_a0(PAGE_SIZE - (cpu_has_prefetch ? pref_offset_clear : 0)); 387 off = PAGE_SIZE - (cpu_has_prefetch ? pref_offset_clear : 0);
388 if (off > 0x7fff) {
389 build_addiu_a2_a0(off >> 1);
390 build_addiu_a2(off >> 1);
391 } else
392 build_addiu_a2_a0(off);
373 393
374 if (R4600_V2_HIT_CACHEOP_WAR && cpu_is_r4600_v2_x()) 394 if (R4600_V2_HIT_CACHEOP_WAR && cpu_is_r4600_v2_x())
375 build_insn_word(0x3c01a000); /* lui $at, 0xa000 */ 395 build_insn_word(0x3c01a000); /* lui $at, 0xa000 */
@@ -420,12 +440,18 @@ dest = label();
420void __init build_copy_page(void) 440void __init build_copy_page(void)
421{ 441{
422 unsigned int loop_start; 442 unsigned int loop_start;
443 unsigned long off;
423 444
424 epc = (unsigned int *) &copy_page_array; 445 epc = (unsigned int *) &copy_page_array;
425 store_offset = load_offset = 0; 446 store_offset = load_offset = 0;
426 instruction_pending = 0; 447 instruction_pending = 0;
427 448
428 build_addiu_a2_a0(PAGE_SIZE - (cpu_has_prefetch ? pref_offset_copy : 0)); 449 off = PAGE_SIZE - (cpu_has_prefetch ? pref_offset_copy : 0);
450 if (off > 0x7fff) {
451 build_addiu_a2_a0(off >> 1);
452 build_addiu_a2(off >> 1);
453 } else
454 build_addiu_a2_a0(off);
429 455
430 if (R4600_V2_HIT_CACHEOP_WAR && cpu_is_r4600_v2_x()) 456 if (R4600_V2_HIT_CACHEOP_WAR && cpu_is_r4600_v2_x())
431 build_insn_word(0x3c01a000); /* lui $at, 0xa000 */ 457 build_insn_word(0x3c01a000); /* lui $at, 0xa000 */
diff --git a/arch/mips/mm/pgtable-32.c b/arch/mips/mm/pgtable-32.c
index 4bdaa05f485b..4a61e624b0ec 100644
--- a/arch/mips/mm/pgtable-32.c
+++ b/arch/mips/mm/pgtable-32.c
@@ -31,9 +31,10 @@ void pgd_init(unsigned long page)
31 31
32void __init pagetable_init(void) 32void __init pagetable_init(void)
33{ 33{
34#ifdef CONFIG_HIGHMEM
35 unsigned long vaddr; 34 unsigned long vaddr;
36 pgd_t *pgd, *pgd_base; 35 pgd_t *pgd_base;
36#ifdef CONFIG_HIGHMEM
37 pgd_t *pgd;
37 pud_t *pud; 38 pud_t *pud;
38 pmd_t *pmd; 39 pmd_t *pmd;
39 pte_t *pte; 40 pte_t *pte;
@@ -44,7 +45,6 @@ void __init pagetable_init(void)
44 pgd_init((unsigned long)swapper_pg_dir 45 pgd_init((unsigned long)swapper_pg_dir
45 + sizeof(pgd_t) * USER_PTRS_PER_PGD); 46 + sizeof(pgd_t) * USER_PTRS_PER_PGD);
46 47
47#ifdef CONFIG_HIGHMEM
48 pgd_base = swapper_pg_dir; 48 pgd_base = swapper_pg_dir;
49 49
50 /* 50 /*
@@ -53,6 +53,7 @@ void __init pagetable_init(void)
53 vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK; 53 vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK;
54 fixrange_init(vaddr, 0, pgd_base); 54 fixrange_init(vaddr, 0, pgd_base);
55 55
56#ifdef CONFIG_HIGHMEM
56 /* 57 /*
57 * Permanent kmaps: 58 * Permanent kmaps:
58 */ 59 */
diff --git a/arch/mips/mm/pgtable-64.c b/arch/mips/mm/pgtable-64.c
index 44b5e97fff65..8d600d307d5d 100644
--- a/arch/mips/mm/pgtable-64.c
+++ b/arch/mips/mm/pgtable-64.c
@@ -8,6 +8,7 @@
8 */ 8 */
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/mm.h> 10#include <linux/mm.h>
11#include <asm/fixmap.h>
11#include <asm/pgtable.h> 12#include <asm/pgtable.h>
12 13
13void pgd_init(unsigned long page) 14void pgd_init(unsigned long page)
@@ -52,7 +53,17 @@ void pmd_init(unsigned long addr, unsigned long pagetable)
52 53
53void __init pagetable_init(void) 54void __init pagetable_init(void)
54{ 55{
56 unsigned long vaddr;
57 pgd_t *pgd_base;
58
55 /* Initialize the entire pgd. */ 59 /* Initialize the entire pgd. */
56 pgd_init((unsigned long)swapper_pg_dir); 60 pgd_init((unsigned long)swapper_pg_dir);
57 pmd_init((unsigned long)invalid_pmd_table, (unsigned long)invalid_pte_table); 61 pmd_init((unsigned long)invalid_pmd_table, (unsigned long)invalid_pte_table);
62
63 pgd_base = swapper_pg_dir;
64 /*
65 * Fixed mappings:
66 */
67 vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK;
68 fixrange_init(vaddr, 0, pgd_base);
58} 69}
diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
index 6f8b25cfa6f0..fec318a1c8c5 100644
--- a/arch/mips/mm/tlbex.c
+++ b/arch/mips/mm/tlbex.c
@@ -102,7 +102,7 @@ enum opcode {
102 insn_addu, insn_addiu, insn_and, insn_andi, insn_beq, 102 insn_addu, insn_addiu, insn_and, insn_andi, insn_beq,
103 insn_beql, insn_bgez, insn_bgezl, insn_bltz, insn_bltzl, 103 insn_beql, insn_bgez, insn_bgezl, insn_bltz, insn_bltzl,
104 insn_bne, insn_daddu, insn_daddiu, insn_dmfc0, insn_dmtc0, 104 insn_bne, insn_daddu, insn_daddiu, insn_dmfc0, insn_dmtc0,
105 insn_dsll, insn_dsll32, insn_dsra, insn_dsrl, 105 insn_dsll, insn_dsll32, insn_dsra, insn_dsrl, insn_dsrl32,
106 insn_dsubu, insn_eret, insn_j, insn_jal, insn_jr, insn_ld, 106 insn_dsubu, insn_eret, insn_j, insn_jal, insn_jr, insn_ld,
107 insn_ll, insn_lld, insn_lui, insn_lw, insn_mfc0, insn_mtc0, 107 insn_ll, insn_lld, insn_lui, insn_lw, insn_mfc0, insn_mtc0,
108 insn_ori, insn_rfe, insn_sc, insn_scd, insn_sd, insn_sll, 108 insn_ori, insn_rfe, insn_sc, insn_scd, insn_sd, insn_sll,
@@ -145,6 +145,7 @@ static __initdata struct insn insn_table[] = {
145 { insn_dsll32, M(spec_op,0,0,0,0,dsll32_op), RT | RD | RE }, 145 { insn_dsll32, M(spec_op,0,0,0,0,dsll32_op), RT | RD | RE },
146 { insn_dsra, M(spec_op,0,0,0,0,dsra_op), RT | RD | RE }, 146 { insn_dsra, M(spec_op,0,0,0,0,dsra_op), RT | RD | RE },
147 { insn_dsrl, M(spec_op,0,0,0,0,dsrl_op), RT | RD | RE }, 147 { insn_dsrl, M(spec_op,0,0,0,0,dsrl_op), RT | RD | RE },
148 { insn_dsrl32, M(spec_op,0,0,0,0,dsrl32_op), RT | RD | RE },
148 { insn_dsubu, M(spec_op,0,0,0,0,dsubu_op), RS | RT | RD }, 149 { insn_dsubu, M(spec_op,0,0,0,0,dsubu_op), RS | RT | RD },
149 { insn_eret, M(cop0_op,cop_op,0,0,0,eret_op), 0 }, 150 { insn_eret, M(cop0_op,cop_op,0,0,0,eret_op), 0 },
150 { insn_j, M(j_op,0,0,0,0,0), JIMM }, 151 { insn_j, M(j_op,0,0,0,0,0), JIMM },
@@ -385,6 +386,7 @@ I_u2u1u3(_dsll);
385I_u2u1u3(_dsll32); 386I_u2u1u3(_dsll32);
386I_u2u1u3(_dsra); 387I_u2u1u3(_dsra);
387I_u2u1u3(_dsrl); 388I_u2u1u3(_dsrl);
389I_u2u1u3(_dsrl32);
388I_u3u1u2(_dsubu); 390I_u3u1u2(_dsubu);
389I_0(_eret); 391I_0(_eret);
390I_u1(_j); 392I_u1(_j);
@@ -996,7 +998,12 @@ build_get_pmde64(u32 **p, struct label **l, struct reloc **r,
996#endif 998#endif
997 999
998 l_vmalloc_done(l, *p); 1000 l_vmalloc_done(l, *p);
999 i_dsrl(p, tmp, tmp, PGDIR_SHIFT-3); /* get pgd offset in bytes */ 1001
1002 if (PGDIR_SHIFT - 3 < 32) /* get pgd offset in bytes */
1003 i_dsrl(p, tmp, tmp, PGDIR_SHIFT-3);
1004 else
1005 i_dsrl32(p, tmp, tmp, PGDIR_SHIFT - 3 - 32);
1006
1000 i_andi(p, tmp, tmp, (PTRS_PER_PGD - 1)<<3); 1007 i_andi(p, tmp, tmp, (PTRS_PER_PGD - 1)<<3);
1001 i_daddu(p, ptr, ptr, tmp); /* add in pgd offset */ 1008 i_daddu(p, ptr, ptr, tmp); /* add in pgd offset */
1002 i_dmfc0(p, tmp, C0_BADVADDR); /* get faulting address */ 1009 i_dmfc0(p, tmp, C0_BADVADDR); /* get faulting address */
@@ -1073,7 +1080,7 @@ build_get_pgde32(u32 **p, unsigned int tmp, unsigned int ptr)
1073 1080
1074static __init void build_adjust_context(u32 **p, unsigned int ctx) 1081static __init void build_adjust_context(u32 **p, unsigned int ctx)
1075{ 1082{
1076 unsigned int shift = 4 - (PTE_T_LOG2 + 1); 1083 unsigned int shift = 4 - (PTE_T_LOG2 + 1) + PAGE_SHIFT - 12;
1077 unsigned int mask = (PTRS_PER_PTE / 2 - 1) << (PTE_T_LOG2 + 1); 1084 unsigned int mask = (PTRS_PER_PTE / 2 - 1) << (PTE_T_LOG2 + 1);
1078 1085
1079 switch (current_cpu_data.cputype) { 1086 switch (current_cpu_data.cputype) {
diff --git a/arch/mips/momentum/ocelot_3/Makefile b/arch/mips/momentum/ocelot_3/Makefile
index 8bcea64dd27b..d5a090a85a15 100644
--- a/arch/mips/momentum/ocelot_3/Makefile
+++ b/arch/mips/momentum/ocelot_3/Makefile
@@ -5,4 +5,4 @@
5# removes any old dependencies. DON'T put your own dependencies here 5# removes any old dependencies. DON'T put your own dependencies here
6# unless it's something special (ie not a .c file). 6# unless it's something special (ie not a .c file).
7# 7#
8obj-y += irq.o prom.o reset.o setup.o 8obj-y += irq.o platform.o prom.o reset.o setup.o
diff --git a/arch/mips/momentum/ocelot_3/ocelot_3_fpga.h b/arch/mips/momentum/ocelot_3/ocelot_3_fpga.h
index 227e429fe720..5710a9029f1c 100644
--- a/arch/mips/momentum/ocelot_3/ocelot_3_fpga.h
+++ b/arch/mips/momentum/ocelot_3/ocelot_3_fpga.h
@@ -51,7 +51,9 @@
51 51
52extern unsigned long ocelot_fpga_base; 52extern unsigned long ocelot_fpga_base;
53 53
54#define OCELOT_FPGA_WRITE(x, y) writeb(x, ocelot_fpga_base + OCELOT_3_REG_##y) 54#define __FPGA_REG_TO_ADDR(reg) \
55#define OCELOT_FPGA_READ(x) readb(ocelot_fpga_base + OCELOT_3_REG_##x) 55 ((void *) ocelot_fpga_base + OCELOT_3_REG_##reg)
56#define OCELOT_FPGA_WRITE(x, reg) writeb(x, __FPGA_REG_TO_ADDR(reg))
57#define OCELOT_FPGA_READ(reg) readb(__FPGA_REG_TO_ADDR(reg))
56 58
57#endif 59#endif
diff --git a/arch/mips/momentum/ocelot_3/platform.c b/arch/mips/momentum/ocelot_3/platform.c
new file mode 100644
index 000000000000..eefe5841fbb2
--- /dev/null
+++ b/arch/mips/momentum/ocelot_3/platform.c
@@ -0,0 +1,235 @@
1#include <linux/delay.h>
2#include <linux/if_ether.h>
3#include <linux/ioport.h>
4#include <linux/mv643xx.h>
5#include <linux/platform_device.h>
6
7#include "ocelot_3_fpga.h"
8
9#if defined(CONFIG_MV643XX_ETH) || defined(CONFIG_MV643XX_ETH_MODULE)
10
11static struct resource mv643xx_eth_shared_resources[] = {
12 [0] = {
13 .name = "ethernet shared base",
14 .start = 0xf1000000 + MV643XX_ETH_SHARED_REGS,
15 .end = 0xf1000000 + MV643XX_ETH_SHARED_REGS +
16 MV643XX_ETH_SHARED_REGS_SIZE - 1,
17 .flags = IORESOURCE_MEM,
18 },
19};
20
21static struct platform_device mv643xx_eth_shared_device = {
22 .name = MV643XX_ETH_SHARED_NAME,
23 .id = 0,
24 .num_resources = ARRAY_SIZE(mv643xx_eth_shared_resources),
25 .resource = mv643xx_eth_shared_resources,
26};
27
28#define MV_SRAM_BASE 0xfe000000UL
29#define MV_SRAM_SIZE (256 * 1024)
30
31#define MV_SRAM_RXRING_SIZE (MV_SRAM_SIZE / 4)
32#define MV_SRAM_TXRING_SIZE (MV_SRAM_SIZE / 4)
33
34#define MV_SRAM_BASE_ETH0 MV_SRAM_BASE
35#define MV_SRAM_BASE_ETH1 (MV_SRAM_BASE + (MV_SRAM_SIZE / 2))
36
37#define MV64x60_IRQ_ETH_0 48
38#define MV64x60_IRQ_ETH_1 49
39#define MV64x60_IRQ_ETH_2 50
40
41#ifdef CONFIG_MV643XX_ETH_0
42
43static struct resource mv64x60_eth0_resources[] = {
44 [0] = {
45 .name = "eth0 irq",
46 .start = MV64x60_IRQ_ETH_0,
47 .end = MV64x60_IRQ_ETH_0,
48 .flags = IORESOURCE_IRQ,
49 },
50};
51
52static char eth0_mac_addr[ETH_ALEN];
53
54static struct mv643xx_eth_platform_data eth0_pd = {
55 .mac_addr = eth0_mac_addr,
56
57 .tx_sram_addr = MV_SRAM_BASE_ETH0,
58 .tx_sram_size = MV_SRAM_TXRING_SIZE,
59 .tx_queue_size = MV_SRAM_TXRING_SIZE / 16,
60
61 .rx_sram_addr = MV_SRAM_BASE_ETH0 + MV_SRAM_TXRING_SIZE,
62 .rx_sram_size = MV_SRAM_RXRING_SIZE,
63 .rx_queue_size = MV_SRAM_RXRING_SIZE / 16,
64};
65
66static struct platform_device eth0_device = {
67 .name = MV643XX_ETH_NAME,
68 .id = 0,
69 .num_resources = ARRAY_SIZE(mv64x60_eth0_resources),
70 .resource = mv64x60_eth0_resources,
71 .dev = {
72 .platform_data = &eth0_pd,
73 },
74};
75#endif /* CONFIG_MV643XX_ETH_0 */
76
77#ifdef CONFIG_MV643XX_ETH_1
78
79static struct resource mv64x60_eth1_resources[] = {
80 [0] = {
81 .name = "eth1 irq",
82 .start = MV64x60_IRQ_ETH_1,
83 .end = MV64x60_IRQ_ETH_1,
84 .flags = IORESOURCE_IRQ,
85 },
86};
87
88static char eth1_mac_addr[ETH_ALEN];
89
90static struct mv643xx_eth_platform_data eth1_pd = {
91 .mac_addr = eth1_mac_addr,
92
93 .tx_sram_addr = MV_SRAM_BASE_ETH1,
94 .tx_sram_size = MV_SRAM_TXRING_SIZE,
95 .tx_queue_size = MV_SRAM_TXRING_SIZE / 16,
96
97 .rx_sram_addr = MV_SRAM_BASE_ETH1 + MV_SRAM_TXRING_SIZE,
98 .rx_sram_size = MV_SRAM_RXRING_SIZE,
99 .rx_queue_size = MV_SRAM_RXRING_SIZE / 16,
100};
101
102static struct platform_device eth1_device = {
103 .name = MV643XX_ETH_NAME,
104 .id = 1,
105 .num_resources = ARRAY_SIZE(mv64x60_eth1_resources),
106 .resource = mv64x60_eth1_resources,
107 .dev = {
108 .platform_data = &eth1_pd,
109 },
110};
111#endif /* CONFIG_MV643XX_ETH_1 */
112
113#ifdef CONFIG_MV643XX_ETH_2
114
115static struct resource mv64x60_eth2_resources[] = {
116 [0] = {
117 .name = "eth2 irq",
118 .start = MV64x60_IRQ_ETH_2,
119 .end = MV64x60_IRQ_ETH_2,
120 .flags = IORESOURCE_IRQ,
121 },
122};
123
124static char eth2_mac_addr[ETH_ALEN];
125
126static struct mv643xx_eth_platform_data eth2_pd = {
127 .mac_addr = eth2_mac_addr,
128};
129
130static struct platform_device eth2_device = {
131 .name = MV643XX_ETH_NAME,
132 .id = 1,
133 .num_resources = ARRAY_SIZE(mv64x60_eth2_resources),
134 .resource = mv64x60_eth2_resources,
135 .dev = {
136 .platform_data = &eth2_pd,
137 },
138};
139#endif /* CONFIG_MV643XX_ETH_2 */
140
141static struct platform_device *mv643xx_eth_pd_devs[] __initdata = {
142 &mv643xx_eth_shared_device,
143#ifdef CONFIG_MV643XX_ETH_0
144 &eth0_device,
145#endif
146#ifdef CONFIG_MV643XX_ETH_1
147 &eth1_device,
148#endif
149#ifdef CONFIG_MV643XX_ETH_2
150 &eth2_device,
151#endif
152};
153
154static u8 __init exchange_bit(u8 val, u8 cs)
155{
156 /* place the data */
157 OCELOT_FPGA_WRITE((val << 2) | cs, EEPROM_MODE);
158 udelay(1);
159
160 /* turn the clock on */
161 OCELOT_FPGA_WRITE((val << 2) | cs | 0x2, EEPROM_MODE);
162 udelay(1);
163
164 /* turn the clock off and read-strobe */
165 OCELOT_FPGA_WRITE((val << 2) | cs | 0x10, EEPROM_MODE);
166
167 /* return the data */
168 return (OCELOT_FPGA_READ(EEPROM_MODE) >> 3) & 0x1;
169}
170
171static void __init get_mac(char dest[6])
172{
173 u8 read_opcode[12] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
174 int i,j;
175
176 for (i = 0; i < 12; i++)
177 exchange_bit(read_opcode[i], 1);
178
179 for (j = 0; j < 6; j++) {
180 dest[j] = 0;
181 for (i = 0; i < 8; i++) {
182 dest[j] <<= 1;
183 dest[j] |= exchange_bit(0, 1);
184 }
185 }
186
187 /* turn off CS */
188 exchange_bit(0,0);
189}
190
191/*
192 * Copy and increment ethernet MAC address by a small value.
193 *
194 * This is useful for systems where the only one MAC address is stored in
195 * non-volatile memory for multiple ports.
196 */
197static inline void eth_mac_add(unsigned char *dst, unsigned char *src,
198 unsigned int add)
199{
200 int i;
201
202 BUG_ON(add >= 256);
203
204 for (i = ETH_ALEN; i >= 0; i--) {
205 dst[i] = src[i] + add;
206 add = dst[i] < src[i]; /* compute carry */
207 }
208
209 WARN_ON(add);
210}
211
212static int __init mv643xx_eth_add_pds(void)
213{
214 unsigned char mac[ETH_ALEN];
215 int ret;
216
217 get_mac(mac);
218#ifdef CONFIG_MV643XX_ETH_0
219 eth_mac_add(eth1_mac_addr, mac, 0);
220#endif
221#ifdef CONFIG_MV643XX_ETH_1
222 eth_mac_add(eth1_mac_addr, mac, 1);
223#endif
224#ifdef CONFIG_MV643XX_ETH_2
225 eth_mac_add(eth2_mac_addr, mac, 2);
226#endif
227 ret = platform_add_devices(mv643xx_eth_pd_devs,
228 ARRAY_SIZE(mv643xx_eth_pd_devs));
229
230 return ret;
231}
232
233device_initcall(mv643xx_eth_add_pds);
234
235#endif /* defined(CONFIG_MV643XX_ETH) || defined(CONFIG_MV643XX_ETH_MODULE) */
diff --git a/arch/mips/momentum/ocelot_3/prom.c b/arch/mips/momentum/ocelot_3/prom.c
index 296d945bc248..6ce9b7fdb824 100644
--- a/arch/mips/momentum/ocelot_3/prom.c
+++ b/arch/mips/momentum/ocelot_3/prom.c
@@ -34,64 +34,11 @@ struct callvectors* debug_vectors;
34extern unsigned long marvell_base; 34extern unsigned long marvell_base;
35extern unsigned long cpu_clock; 35extern unsigned long cpu_clock;
36 36
37#ifdef CONFIG_MV643XX_ETH
38extern unsigned char prom_mac_addr_base[6];
39#endif
40
41const char *get_system_type(void) 37const char *get_system_type(void)
42{ 38{
43 return "Momentum Ocelot-3"; 39 return "Momentum Ocelot-3";
44} 40}
45 41
46#ifdef CONFIG_MV643XX_ETH
47void burn_clocks(void)
48{
49 int i;
50
51 /* this loop should burn at least 1us -- this should be plenty */
52 for (i = 0; i < 0x10000; i++)
53 ;
54}
55
56u8 exchange_bit(u8 val, u8 cs)
57{
58 /* place the data */
59 OCELOT_FPGA_WRITE((val << 2) | cs, EEPROM_MODE);
60 burn_clocks();
61
62 /* turn the clock on */
63 OCELOT_FPGA_WRITE((val << 2) | cs | 0x2, EEPROM_MODE);
64 burn_clocks();
65
66 /* turn the clock off and read-strobe */
67 OCELOT_FPGA_WRITE((val << 2) | cs | 0x10, EEPROM_MODE);
68
69 /* return the data */
70 return ((OCELOT_FPGA_READ(EEPROM_MODE) >> 3) & 0x1);
71}
72
73void get_mac(char dest[6])
74{
75 u8 read_opcode[12] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
76 int i,j;
77
78 for (i = 0; i < 12; i++)
79 exchange_bit(read_opcode[i], 1);
80
81 for (j = 0; j < 6; j++) {
82 dest[j] = 0;
83 for (i = 0; i < 8; i++) {
84 dest[j] <<= 1;
85 dest[j] |= exchange_bit(0, 1);
86 }
87 }
88
89 /* turn off CS */
90 exchange_bit(0,0);
91}
92#endif
93
94
95#ifdef CONFIG_64BIT 42#ifdef CONFIG_64BIT
96 43
97unsigned long signext(unsigned long addr) 44unsigned long signext(unsigned long addr)
@@ -228,11 +175,6 @@ void __init prom_init(void)
228 mips_machgroup = MACH_GROUP_MOMENCO; 175 mips_machgroup = MACH_GROUP_MOMENCO;
229 mips_machtype = MACH_MOMENCO_OCELOT_3; 176 mips_machtype = MACH_MOMENCO_OCELOT_3;
230 177
231#ifdef CONFIG_MV643XX_ETH
232 /* get the base MAC address for on-board ethernet ports */
233 get_mac(prom_mac_addr_base);
234#endif
235
236#ifndef CONFIG_64BIT 178#ifndef CONFIG_64BIT
237 debug_vectors->printf("Booting Linux kernel...\n"); 179 debug_vectors->printf("Booting Linux kernel...\n");
238#endif 180#endif
diff --git a/arch/mips/momentum/ocelot_3/setup.c b/arch/mips/momentum/ocelot_3/setup.c
index 7d74f8c54129..ff0829f81116 100644
--- a/arch/mips/momentum/ocelot_3/setup.c
+++ b/arch/mips/momentum/ocelot_3/setup.c
@@ -4,7 +4,7 @@
4 * BRIEF MODULE DESCRIPTION 4 * BRIEF MODULE DESCRIPTION
5 * Momentum Computer Ocelot-3 board dependent boot routines 5 * Momentum Computer Ocelot-3 board dependent boot routines
6 * 6 *
7 * Copyright (C) 1996, 1997, 01, 05 Ralf Baechle 7 * Copyright (C) 1996, 1997, 01, 05 - 06 Ralf Baechle
8 * Copyright (C) 2000 RidgeRun, Inc. 8 * Copyright (C) 2000 RidgeRun, Inc.
9 * Copyright (C) 2001 Red Hat, Inc. 9 * Copyright (C) 2001 Red Hat, Inc.
10 * Copyright (C) 2002 Momentum Computer 10 * Copyright (C) 2002 Momentum Computer
diff --git a/arch/mips/momentum/ocelot_c/Makefile b/arch/mips/momentum/ocelot_c/Makefile
index 94802b4db472..d69161aa1675 100644
--- a/arch/mips/momentum/ocelot_c/Makefile
+++ b/arch/mips/momentum/ocelot_c/Makefile
@@ -2,7 +2,7 @@
2# Makefile for Momentum Computer's Ocelot-C and -CS boards. 2# Makefile for Momentum Computer's Ocelot-C and -CS boards.
3# 3#
4 4
5obj-y += cpci-irq.o irq.o prom.o reset.o \ 5obj-y += cpci-irq.o irq.o platform.o prom.o reset.o \
6 setup.o uart-irq.o 6 setup.o uart-irq.o
7 7
8obj-$(CONFIG_KGDB) += dbg_io.o 8obj-$(CONFIG_KGDB) += dbg_io.o
diff --git a/arch/mips/momentum/ocelot_c/ocelot_c_fpga.h b/arch/mips/momentum/ocelot_c/ocelot_c_fpga.h
index 7228cd19e5ea..f0f5581dcb50 100644
--- a/arch/mips/momentum/ocelot_c/ocelot_c_fpga.h
+++ b/arch/mips/momentum/ocelot_c/ocelot_c_fpga.h
@@ -53,7 +53,9 @@
53#define OCELOT_C_REG_INTSET 0xe 53#define OCELOT_C_REG_INTSET 0xe
54#define OCELOT_C_REG_INTCLR 0xf 54#define OCELOT_C_REG_INTCLR 0xf
55 55
56#define OCELOT_FPGA_WRITE(x, y) writeb(x, OCELOT_C_CS0_ADDR + OCELOT_C_REG_##y) 56#define __FPGA_REG_TO_ADDR(reg) \
57#define OCELOT_FPGA_READ(x) readb(OCELOT_C_CS0_ADDR + OCELOT_C_REG_##x) 57 ((void *) OCELOT_C_CS0_ADDR + OCELOT_C_REG_##reg)
58#define OCELOT_FPGA_WRITE(x, reg) writeb(x, __FPGA_REG_TO_ADDR(reg))
59#define OCELOT_FPGA_READ(reg) readb(__FPGA_REG_TO_ADDR(reg))
58 60
59#endif 61#endif
diff --git a/arch/mips/momentum/ocelot_c/platform.c b/arch/mips/momentum/ocelot_c/platform.c
new file mode 100644
index 000000000000..6c495b2f1560
--- /dev/null
+++ b/arch/mips/momentum/ocelot_c/platform.c
@@ -0,0 +1,201 @@
1#include <linux/delay.h>
2#include <linux/if_ether.h>
3#include <linux/ioport.h>
4#include <linux/mv643xx.h>
5#include <linux/platform_device.h>
6
7#include "ocelot_c_fpga.h"
8
9#if defined(CONFIG_MV643XX_ETH) || defined(CONFIG_MV643XX_ETH_MODULE)
10
11static struct resource mv643xx_eth_shared_resources[] = {
12 [0] = {
13 .name = "ethernet shared base",
14 .start = 0xf1000000 + MV643XX_ETH_SHARED_REGS,
15 .end = 0xf1000000 + MV643XX_ETH_SHARED_REGS +
16 MV643XX_ETH_SHARED_REGS_SIZE - 1,
17 .flags = IORESOURCE_MEM,
18 },
19};
20
21static struct platform_device mv643xx_eth_shared_device = {
22 .name = MV643XX_ETH_SHARED_NAME,
23 .id = 0,
24 .num_resources = ARRAY_SIZE(mv643xx_eth_shared_resources),
25 .resource = mv643xx_eth_shared_resources,
26};
27
28#define MV_SRAM_BASE 0xfe000000UL
29#define MV_SRAM_SIZE (256 * 1024)
30
31#define MV_SRAM_RXRING_SIZE (MV_SRAM_SIZE / 4)
32#define MV_SRAM_TXRING_SIZE (MV_SRAM_SIZE / 4)
33
34#define MV_SRAM_BASE_ETH0 MV_SRAM_BASE
35#define MV_SRAM_BASE_ETH1 (MV_SRAM_BASE + (MV_SRAM_SIZE / 2))
36
37#define MV64x60_IRQ_ETH_0 48
38#define MV64x60_IRQ_ETH_1 49
39
40#ifdef CONFIG_MV643XX_ETH_0
41
42static struct resource mv64x60_eth0_resources[] = {
43 [0] = {
44 .name = "eth0 irq",
45 .start = MV64x60_IRQ_ETH_0,
46 .end = MV64x60_IRQ_ETH_0,
47 .flags = IORESOURCE_IRQ,
48 },
49};
50
51static char eth0_mac_addr[ETH_ALEN];
52
53static struct mv643xx_eth_platform_data eth0_pd = {
54 .mac_addr = eth0_mac_addr,
55
56 .tx_sram_addr = MV_SRAM_BASE_ETH0,
57 .tx_sram_size = MV_SRAM_TXRING_SIZE,
58 .tx_queue_size = MV_SRAM_TXRING_SIZE / 16,
59
60 .rx_sram_addr = MV_SRAM_BASE_ETH0 + MV_SRAM_TXRING_SIZE,
61 .rx_sram_size = MV_SRAM_RXRING_SIZE,
62 .rx_queue_size = MV_SRAM_RXRING_SIZE / 16,
63};
64
65static struct platform_device eth0_device = {
66 .name = MV643XX_ETH_NAME,
67 .id = 0,
68 .num_resources = ARRAY_SIZE(mv64x60_eth0_resources),
69 .resource = mv64x60_eth0_resources,
70 .dev = {
71 .platform_data = &eth0_pd,
72 },
73};
74#endif /* CONFIG_MV643XX_ETH_0 */
75
76#ifdef CONFIG_MV643XX_ETH_1
77
78static struct resource mv64x60_eth1_resources[] = {
79 [0] = {
80 .name = "eth1 irq",
81 .start = MV64x60_IRQ_ETH_1,
82 .end = MV64x60_IRQ_ETH_1,
83 .flags = IORESOURCE_IRQ,
84 },
85};
86
87static char eth1_mac_addr[ETH_ALEN];
88
89static struct mv643xx_eth_platform_data eth1_pd = {
90 .mac_addr = eth1_mac_addr,
91
92 .tx_sram_addr = MV_SRAM_BASE_ETH1,
93 .tx_sram_size = MV_SRAM_TXRING_SIZE,
94 .tx_queue_size = MV_SRAM_TXRING_SIZE / 16,
95
96 .rx_sram_addr = MV_SRAM_BASE_ETH1 + MV_SRAM_TXRING_SIZE,
97 .rx_sram_size = MV_SRAM_RXRING_SIZE,
98 .rx_queue_size = MV_SRAM_RXRING_SIZE / 16,
99};
100
101static struct platform_device eth1_device = {
102 .name = MV643XX_ETH_NAME,
103 .id = 1,
104 .num_resources = ARRAY_SIZE(mv64x60_eth1_resources),
105 .resource = mv64x60_eth1_resources,
106 .dev = {
107 .platform_data = &eth1_pd,
108 },
109};
110#endif /* CONFIG_MV643XX_ETH_1 */
111
112static struct platform_device *mv643xx_eth_pd_devs[] __initdata = {
113 &mv643xx_eth_shared_device,
114#ifdef CONFIG_MV643XX_ETH_0
115 &eth0_device,
116#endif
117#ifdef CONFIG_MV643XX_ETH_1
118 &eth1_device,
119#endif
120 /* The third port is not wired up on the Ocelot C */
121};
122
123static u8 __init exchange_bit(u8 val, u8 cs)
124{
125 /* place the data */
126 OCELOT_FPGA_WRITE((val << 2) | cs, EEPROM_MODE);
127 udelay(1);
128
129 /* turn the clock on */
130 OCELOT_FPGA_WRITE((val << 2) | cs | 0x2, EEPROM_MODE);
131 udelay(1);
132
133 /* turn the clock off and read-strobe */
134 OCELOT_FPGA_WRITE((val << 2) | cs | 0x10, EEPROM_MODE);
135
136 /* return the data */
137 return (OCELOT_FPGA_READ(EEPROM_MODE) >> 3) & 0x1;
138}
139
140static void __init get_mac(char dest[6])
141{
142 u8 read_opcode[12] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
143 int i,j;
144
145 for (i = 0; i < 12; i++)
146 exchange_bit(read_opcode[i], 1);
147
148 for (j = 0; j < 6; j++) {
149 dest[j] = 0;
150 for (i = 0; i < 8; i++) {
151 dest[j] <<= 1;
152 dest[j] |= exchange_bit(0, 1);
153 }
154 }
155
156 /* turn off CS */
157 exchange_bit(0,0);
158}
159
160/*
161 * Copy and increment ethernet MAC address by a small value.
162 *
163 * This is useful for systems where the only one MAC address is stored in
164 * non-volatile memory for multiple ports.
165 */
166static inline void eth_mac_add(unsigned char *dst, unsigned char *src,
167 unsigned int add)
168{
169 int i;
170
171 BUG_ON(add >= 256);
172
173 for (i = ETH_ALEN; i >= 0; i--) {
174 dst[i] = src[i] + add;
175 add = dst[i] < src[i]; /* compute carry */
176 }
177
178 WARN_ON(add);
179}
180
181static int __init mv643xx_eth_add_pds(void)
182{
183 unsigned char mac[ETH_ALEN];
184 int ret;
185
186 get_mac(mac);
187#ifdef CONFIG_MV643XX_ETH_0
188 eth_mac_add(eth1_mac_addr, mac, 0);
189#endif
190#ifdef CONFIG_MV643XX_ETH_1
191 eth_mac_add(eth1_mac_addr, mac, 1);
192#endif
193 ret = platform_add_devices(mv643xx_eth_pd_devs,
194 ARRAY_SIZE(mv643xx_eth_pd_devs));
195
196 return ret;
197}
198
199device_initcall(mv643xx_eth_add_pds);
200
201#endif /* defined(CONFIG_MV643XX_ETH) || defined(CONFIG_MV643XX_ETH_MODULE) */
diff --git a/arch/mips/momentum/ocelot_c/prom.c b/arch/mips/momentum/ocelot_c/prom.c
index 4c50a147f429..d0b77e101d74 100644
--- a/arch/mips/momentum/ocelot_c/prom.c
+++ b/arch/mips/momentum/ocelot_c/prom.c
@@ -29,11 +29,7 @@
29struct callvectors* debug_vectors; 29struct callvectors* debug_vectors;
30 30
31extern unsigned long marvell_base; 31extern unsigned long marvell_base;
32extern unsigned long cpu_clock; 32extern unsigned int cpu_clock;
33
34#ifdef CONFIG_MV643XX_ETH
35extern unsigned char prom_mac_addr_base[6];
36#endif
37 33
38const char *get_system_type(void) 34const char *get_system_type(void)
39{ 35{
@@ -44,55 +40,6 @@ const char *get_system_type(void)
44#endif 40#endif
45} 41}
46 42
47#ifdef CONFIG_MV643XX_ETH
48static void burn_clocks(void)
49{
50 int i;
51
52 /* this loop should burn at least 1us -- this should be plenty */
53 for (i = 0; i < 0x10000; i++)
54 ;
55}
56
57static u8 exchange_bit(u8 val, u8 cs)
58{
59 /* place the data */
60 OCELOT_FPGA_WRITE((val << 2) | cs, EEPROM_MODE);
61 burn_clocks();
62
63 /* turn the clock on */
64 OCELOT_FPGA_WRITE((val << 2) | cs | 0x2, EEPROM_MODE);
65 burn_clocks();
66
67 /* turn the clock off and read-strobe */
68 OCELOT_FPGA_WRITE((val << 2) | cs | 0x10, EEPROM_MODE);
69
70 /* return the data */
71 return ((OCELOT_FPGA_READ(EEPROM_MODE) >> 3) & 0x1);
72}
73
74void get_mac(char dest[6])
75{
76 u8 read_opcode[12] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
77 int i,j;
78
79 for (i = 0; i < 12; i++)
80 exchange_bit(read_opcode[i], 1);
81
82 for (j = 0; j < 6; j++) {
83 dest[j] = 0;
84 for (i = 0; i < 8; i++) {
85 dest[j] <<= 1;
86 dest[j] |= exchange_bit(0, 1);
87 }
88 }
89
90 /* turn off CS */
91 exchange_bit(0,0);
92}
93#endif
94
95
96#ifdef CONFIG_64BIT 43#ifdef CONFIG_64BIT
97 44
98unsigned long signext(unsigned long addr) 45unsigned long signext(unsigned long addr)
@@ -226,11 +173,6 @@ void __init prom_init(void)
226 mips_machgroup = MACH_GROUP_MOMENCO; 173 mips_machgroup = MACH_GROUP_MOMENCO;
227 mips_machtype = MACH_MOMENCO_OCELOT_C; 174 mips_machtype = MACH_MOMENCO_OCELOT_C;
228 175
229#ifdef CONFIG_MV643XX_ETH
230 /* get the base MAC address for on-board ethernet ports */
231 get_mac(prom_mac_addr_base);
232#endif
233
234#ifndef CONFIG_64BIT 176#ifndef CONFIG_64BIT
235 debug_vectors->printf("Booting Linux kernel...\n"); 177 debug_vectors->printf("Booting Linux kernel...\n");
236#endif 178#endif
diff --git a/arch/mips/momentum/ocelot_c/setup.c b/arch/mips/momentum/ocelot_c/setup.c
index 9c0c462af650..0b6b2338cfb4 100644
--- a/arch/mips/momentum/ocelot_c/setup.c
+++ b/arch/mips/momentum/ocelot_c/setup.c
@@ -69,8 +69,7 @@
69#include "ocelot_c_fpga.h" 69#include "ocelot_c_fpga.h"
70 70
71unsigned long marvell_base; 71unsigned long marvell_base;
72extern unsigned long mv64340_sram_base; 72unsigned int cpu_clock;
73unsigned long cpu_clock;
74 73
75/* These functions are used for rebooting or halting the machine*/ 74/* These functions are used for rebooting or halting the machine*/
76extern void momenco_ocelot_restart(char *command); 75extern void momenco_ocelot_restart(char *command);
@@ -119,7 +118,6 @@ void PMON_v2_setup(void)
119 add_wired_entry(ENTRYLO(0xfe000000), ENTRYLO(0xff000000), 0xfffffffffe000000, PM_16M); 118 add_wired_entry(ENTRYLO(0xfe000000), ENTRYLO(0xff000000), 0xfffffffffe000000, PM_16M);
120 119
121 marvell_base = 0xfffffffff4000000; 120 marvell_base = 0xfffffffff4000000;
122 mv64340_sram_base = 0xfffffffffe000000;
123#else 121#else
124 /* marvell and extra space */ 122 /* marvell and extra space */
125 add_wired_entry(ENTRYLO(0xf4000000), ENTRYLO(0xf4010000), 0xf4000000, PM_64K); 123 add_wired_entry(ENTRYLO(0xf4000000), ENTRYLO(0xf4010000), 0xf4000000, PM_64K);
@@ -129,7 +127,6 @@ void PMON_v2_setup(void)
129 add_wired_entry(ENTRYLO(0xfe000000), ENTRYLO(0xff000000), 0xfe000000, PM_16M); 127 add_wired_entry(ENTRYLO(0xfe000000), ENTRYLO(0xff000000), 0xfe000000, PM_16M);
130 128
131 marvell_base = 0xf4000000; 129 marvell_base = 0xf4000000;
132 mv64340_sram_base = 0xfe000000;
133#endif 130#endif
134} 131}
135 132
@@ -346,22 +343,20 @@ void __init plat_mem_setup(void)
346 } 343 }
347} 344}
348 345
349#ifndef CONFIG_64BIT 346/*
350/* This needs to be one of the first initcalls, because no I/O port access 347 * This needs to be one of the first initcalls, because no I/O port access
351 can work before this */ 348 * can work before this
349 */
352static int io_base_ioremap(void) 350static int io_base_ioremap(void)
353{ 351{
354 /* we're mapping PCI accesses from 0xc0000000 to 0xf0000000 */ 352 void __iomem * io_remap_range = ioremap(0xc0000000UL, 0x10000);
355 void *io_remap_range = ioremap(0xc0000000, 0x30000000);
356 353
357 if (!io_remap_range) { 354 if (!io_remap_range)
358 panic("Could not ioremap I/O port range"); 355 panic("Could not ioremap I/O port range");
359 } 356
360 printk("io_remap_range set at 0x%08x\n", (uint32_t)io_remap_range); 357 set_io_port_base((unsigned long) io_remap_range);
361 set_io_port_base(io_remap_range - 0xc0000000);
362 358
363 return 0; 359 return 0;
364} 360}
365 361
366module_init(io_base_ioremap); 362module_init(io_base_ioremap);
367#endif
diff --git a/arch/mips/momentum/ocelot_g/gt-irq.c b/arch/mips/momentum/ocelot_g/gt-irq.c
index 7b5cc6648f7e..e5576bd50fa9 100644
--- a/arch/mips/momentum/ocelot_g/gt-irq.c
+++ b/arch/mips/momentum/ocelot_g/gt-irq.c
@@ -27,7 +27,7 @@ unsigned long bus_clock;
27 * be handled and ack'ed differently than other MIPS interrupts. 27 * be handled and ack'ed differently than other MIPS interrupts.
28 */ 28 */
29 29
30#if CURRENTLY_UNUSED 30#if 0
31 31
32struct tq_struct irq_handlers[MAX_CAUSE_REGS][MAX_CAUSE_REG_WIDTH]; 32struct tq_struct irq_handlers[MAX_CAUSE_REGS][MAX_CAUSE_REG_WIDTH];
33void hook_irq_handler(int int_cause, int bit_num, void *isr_ptr); 33void hook_irq_handler(int int_cause, int bit_num, void *isr_ptr);
@@ -95,7 +95,7 @@ int disable_galileo_irq(int int_cause, int bit_num)
95 return 0; 95 return 0;
96 return 1; 96 return 1;
97} 97}
98#endif /* UNUSED */ 98#endif /* 0 */
99 99
100/* 100/*
101 * Interrupt handler for interrupts coming from the Galileo chip via P0_INT#. 101 * Interrupt handler for interrupts coming from the Galileo chip via P0_INT#.
@@ -196,7 +196,7 @@ void gt64240_time_init(void)
196 196
197void gt64240_irq_init(void) 197void gt64240_irq_init(void)
198{ 198{
199#if CURRENTLY_UNUSED 199#if 0
200 int i, j; 200 int i, j;
201 201
202 /* Reset irq handlers pointers to NULL */ 202 /* Reset irq handlers pointers to NULL */
@@ -208,5 +208,5 @@ void gt64240_irq_init(void)
208 irq_handlers[i][j].data = NULL; 208 irq_handlers[i][j].data = NULL;
209 } 209 }
210 } 210 }
211#endif 211#endif /* 0 */
212} 212}
diff --git a/arch/mips/momentum/ocelot_g/ocelot_pld.h b/arch/mips/momentum/ocelot_g/ocelot_pld.h
index fcb8275e219d..95e0534026d0 100644
--- a/arch/mips/momentum/ocelot_g/ocelot_pld.h
+++ b/arch/mips/momentum/ocelot_g/ocelot_pld.h
@@ -23,8 +23,8 @@
23#define OCELOT_REG_INTSET (12) 23#define OCELOT_REG_INTSET (12)
24#define OCELOT_REG_INTCLR (13) 24#define OCELOT_REG_INTCLR (13)
25 25
26#define OCELOT_PLD_WRITE(x, y) writeb(x, OCELOT_CS0_ADDR + OCELOT_REG_##y) 26#define __PLD_REG_TO_ADDR(reg) ((void *) OCELOT_CS0_ADDR + OCELOT_REG_##reg)
27#define OCELOT_PLD_READ(x) readb(OCELOT_CS0_ADDR + OCELOT_REG_##x) 27#define OCELOT_PLD_WRITE(x, reg) writeb(x, __PLD_REG_TO_ADDR(reg))
28 28#define OCELOT_PLD_READ(reg) readb(__PLD_REG_TO_ADDR(reg))
29 29
30#endif /* __MOMENCO_OCELOT_PLD_H__ */ 30#endif /* __MOMENCO_OCELOT_PLD_H__ */
diff --git a/arch/mips/momentum/ocelot_g/setup.c b/arch/mips/momentum/ocelot_g/setup.c
index 56ec47039c16..d288f7b01842 100644
--- a/arch/mips/momentum/ocelot_g/setup.c
+++ b/arch/mips/momentum/ocelot_g/setup.c
@@ -57,6 +57,7 @@
57#include <asm/gt64240.h> 57#include <asm/gt64240.h>
58#include <asm/irq.h> 58#include <asm/irq.h>
59#include <asm/pci.h> 59#include <asm/pci.h>
60#include <asm/pgtable.h>
60#include <asm/processor.h> 61#include <asm/processor.h>
61#include <asm/reboot.h> 62#include <asm/reboot.h>
62#include <linux/bootmem.h> 63#include <linux/bootmem.h>
@@ -160,6 +161,10 @@ static void __init setup_l3cache(unsigned long size)
160 printk("Done\n"); 161 printk("Done\n");
161} 162}
162 163
164void __init plat_timer_setup(struct irqaction *irq)
165{
166}
167
163void __init plat_mem_setup(void) 168void __init plat_mem_setup(void)
164{ 169{
165 void (*l3func)(unsigned long) = (void *) KSEG1ADDR(setup_l3cache); 170 void (*l3func)(unsigned long) = (void *) KSEG1ADDR(setup_l3cache);
diff --git a/arch/mips/oprofile/op_impl.h b/arch/mips/oprofile/op_impl.h
index 354e54496406..fa6b4aae7523 100644
--- a/arch/mips/oprofile/op_impl.h
+++ b/arch/mips/oprofile/op_impl.h
@@ -10,8 +10,6 @@
10#ifndef OP_IMPL_H 10#ifndef OP_IMPL_H
11#define OP_IMPL_H 1 11#define OP_IMPL_H 1
12 12
13struct pt_regs;
14
15extern int null_perf_irq(void); 13extern int null_perf_irq(void);
16extern int (*perf_irq)(void); 14extern int (*perf_irq)(void);
17 15
diff --git a/arch/mips/oprofile/op_model_mipsxx.c b/arch/mips/oprofile/op_model_mipsxx.c
index dd0aec9c3ce1..1fb240c57bac 100644
--- a/arch/mips/oprofile/op_model_mipsxx.c
+++ b/arch/mips/oprofile/op_model_mipsxx.c
@@ -31,16 +31,18 @@
31#define M_COUNTER_OVERFLOW (1UL << 31) 31#define M_COUNTER_OVERFLOW (1UL << 31)
32 32
33#ifdef CONFIG_MIPS_MT_SMP 33#ifdef CONFIG_MIPS_MT_SMP
34#define WHAT (M_TC_EN_VPE | M_PERFCTL_VPEID(smp_processor_id())) 34#define WHAT (M_TC_EN_VPE | M_PERFCTL_VPEID(smp_processor_id()))
35#define vpe_id() smp_processor_id()
35#else 36#else
36#define WHAT 0 37#define WHAT 0
38#define vpe_id() smp_processor_id()
37#endif 39#endif
38 40
39#define __define_perf_accessors(r, n, np) \ 41#define __define_perf_accessors(r, n, np) \
40 \ 42 \
41static inline unsigned int r_c0_ ## r ## n(void) \ 43static inline unsigned int r_c0_ ## r ## n(void) \
42{ \ 44{ \
43 unsigned int cpu = smp_processor_id(); \ 45 unsigned int cpu = vpe_id(); \
44 \ 46 \
45 switch (cpu) { \ 47 switch (cpu) { \
46 case 0: \ 48 case 0: \
@@ -55,7 +57,7 @@ static inline unsigned int r_c0_ ## r ## n(void) \
55 \ 57 \
56static inline void w_c0_ ## r ## n(unsigned int value) \ 58static inline void w_c0_ ## r ## n(unsigned int value) \
57{ \ 59{ \
58 unsigned int cpu = smp_processor_id(); \ 60 unsigned int cpu = vpe_id(); \
59 \ 61 \
60 switch (cpu) { \ 62 switch (cpu) { \
61 case 0: \ 63 case 0: \
@@ -218,7 +220,7 @@ static inline int n_counters(void)
218{ 220{
219 int counters = __n_counters(); 221 int counters = __n_counters();
220 222
221#ifndef CONFIG_SMP 223#ifdef CONFIG_MIPS_MT_SMP
222 if (current_cpu_data.cputype == CPU_34K) 224 if (current_cpu_data.cputype == CPU_34K)
223 return counters >> 1; 225 return counters >> 1;
224#endif 226#endif
diff --git a/arch/mips/oprofile/op_model_rm9000.c b/arch/mips/oprofile/op_model_rm9000.c
index b7063fefa65b..7dc9bf6f1321 100644
--- a/arch/mips/oprofile/op_model_rm9000.c
+++ b/arch/mips/oprofile/op_model_rm9000.c
@@ -80,8 +80,7 @@ static void rm9000_cpu_stop(void *args)
80 write_c0_perfcontrol(0); 80 write_c0_perfcontrol(0);
81} 81}
82 82
83static irqreturn_t rm9000_perfcount_handler(int irq, void * dev_id, 83static irqreturn_t rm9000_perfcount_handler(int irq, void * dev_id)
84 struct pt_regs *regs)
85{ 84{
86 unsigned int control = read_c0_perfcontrol(); 85 unsigned int control = read_c0_perfcontrol();
87 uint32_t counter1, counter2; 86 uint32_t counter1, counter2;
diff --git a/arch/mips/pci/Makefile b/arch/mips/pci/Makefile
index 3cf0dd4ba548..70cb55b89df6 100644
--- a/arch/mips/pci/Makefile
+++ b/arch/mips/pci/Makefile
@@ -26,7 +26,7 @@ obj-$(CONFIG_DDB5477) += fixup-ddb5477.o pci-ddb5477.o ops-ddb5477.o
26obj-$(CONFIG_LASAT) += pci-lasat.o 26obj-$(CONFIG_LASAT) += pci-lasat.o
27obj-$(CONFIG_MIPS_ATLAS) += fixup-atlas.o 27obj-$(CONFIG_MIPS_ATLAS) += fixup-atlas.o
28obj-$(CONFIG_MIPS_COBALT) += fixup-cobalt.o 28obj-$(CONFIG_MIPS_COBALT) += fixup-cobalt.o
29obj-$(CONFIG_MIPS_EV64120) += fixup-ev64120.o 29obj-$(CONFIG_MIPS_EV64120) += pci-ev64120.o
30obj-$(CONFIG_SOC_AU1500) += fixup-au1000.o ops-au1000.o 30obj-$(CONFIG_SOC_AU1500) += fixup-au1000.o ops-au1000.o
31obj-$(CONFIG_SOC_AU1550) += fixup-au1000.o ops-au1000.o 31obj-$(CONFIG_SOC_AU1550) += fixup-au1000.o ops-au1000.o
32obj-$(CONFIG_SOC_PNX8550) += fixup-pnx8550.o ops-pnx8550.o 32obj-$(CONFIG_SOC_PNX8550) += fixup-pnx8550.o ops-pnx8550.o
diff --git a/arch/mips/pci/fixup-ev64120.c b/arch/mips/pci/fixup-ev64120.c
deleted file mode 100644
index 8dbb90d63f0a..000000000000
--- a/arch/mips/pci/fixup-ev64120.c
+++ /dev/null
@@ -1,34 +0,0 @@
1#include <linux/pci.h>
2#include <linux/init.h>
3
4int pci_range_ck(unsigned char bus, unsigned char dev)
5{
6 if (((bus == 0) || (bus == 1)) && (dev >= 6) && (dev <= 8))
7 return 0;
8
9 return -1;
10}
11
12/*
13 * After detecting all agents over the PCI , this function is called
14 * in order to give an interrupt number for each PCI device starting
15 * from IRQ 20. It does also enables master for each device.
16 */
17void __devinit pcibios_fixup_bus(struct pci_bus *bus)
18{
19 unsigned int irq = 20;
20 struct pci_bus *current_bus = bus;
21 struct pci_dev *dev;
22 struct list_head *devices_link;
23
24 list_for_each(devices_link, &(current_bus->devices)) {
25 dev = pci_dev_b(devices_link);
26 if (dev != NULL) {
27 dev->irq = irq++;
28
29 /* Assign an interrupt number for the device */
30 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
31 pcibios_set_master(dev);
32 }
33 }
34}
diff --git a/arch/mips/pci/pci-ev64120.c b/arch/mips/pci/pci-ev64120.c
new file mode 100644
index 000000000000..9cd859ef1842
--- /dev/null
+++ b/arch/mips/pci/pci-ev64120.c
@@ -0,0 +1,21 @@
1#include <linux/pci.h>
2
3int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
4{
5 int irq;
6
7 if (!pin)
8 return 0;
9
10 irq = allocate_irqno();
11 if (irq < 0)
12 return 0;
13
14 return irq;
15}
16
17/* Do platform specific device initialization at pci_enable_device() time */
18int pcibios_plat_dev_init(struct pci_dev *dev)
19{
20 return 0;
21}
diff --git a/arch/mips/philips/pnx8550/common/time.c b/arch/mips/philips/pnx8550/common/time.c
index 0af655b1f330..65c440e8480b 100644
--- a/arch/mips/philips/pnx8550/common/time.c
+++ b/arch/mips/philips/pnx8550/common/time.c
@@ -41,8 +41,8 @@ extern unsigned int mips_hpt_frequency;
41 * 1) board_time_init() - 41 * 1) board_time_init() -
42 * a) (optional) set up RTC routines, 42 * a) (optional) set up RTC routines,
43 * b) (optional) calibrate and set the mips_hpt_frequency 43 * b) (optional) calibrate and set the mips_hpt_frequency
44 * (only needed if you intended to use fixed_rate_gettimeoffset 44 * (only needed if you intended to use cpu counter as timer interrupt
45 * or use cpu counter as timer interrupt source) 45 * source)
46 */ 46 */
47 47
48void pnx8550_time_init(void) 48void pnx8550_time_init(void)
diff --git a/arch/mips/pmc-sierra/yosemite/i2c-yosemite.c b/arch/mips/pmc-sierra/yosemite/i2c-yosemite.c
index 416da22b3bf4..85b14c73c226 100644
--- a/arch/mips/pmc-sierra/yosemite/i2c-yosemite.c
+++ b/arch/mips/pmc-sierra/yosemite/i2c-yosemite.c
@@ -74,7 +74,7 @@ static int titan_i2c_poll(void)
74int titan_i2c_xfer(unsigned int slave_addr, titan_i2c_command * cmd, 74int titan_i2c_xfer(unsigned int slave_addr, titan_i2c_command * cmd,
75 int size, unsigned int *addr) 75 int size, unsigned int *addr)
76{ 76{
77 int loop = 0, bytes, i; 77 int loop, bytes = 0, i;
78 unsigned int *write_data, data, *read_data; 78 unsigned int *write_data, data, *read_data;
79 unsigned long reg_val, val; 79 unsigned long reg_val, val;
80 80
diff --git a/arch/mips/pmc-sierra/yosemite/smp.c b/arch/mips/pmc-sierra/yosemite/smp.c
index 65fa3a23ea5e..3cc0436db6cf 100644
--- a/arch/mips/pmc-sierra/yosemite/smp.c
+++ b/arch/mips/pmc-sierra/yosemite/smp.c
@@ -3,9 +3,7 @@
3 3
4#include <asm/pmon.h> 4#include <asm/pmon.h>
5#include <asm/titan_dep.h> 5#include <asm/titan_dep.h>
6 6#include <asm/time.h>
7extern unsigned int (*mips_hpt_read)(void);
8extern void (*mips_hpt_init)(unsigned int);
9 7
10#define LAUNCHSTACK_SIZE 256 8#define LAUNCHSTACK_SIZE 256
11 9
@@ -101,7 +99,7 @@ void prom_cpus_done(void)
101 */ 99 */
102void prom_init_secondary(void) 100void prom_init_secondary(void)
103{ 101{
104 mips_hpt_init(mips_hpt_read()); 102 mips_hpt_init();
105 103
106 set_c0_status(ST0_CO | ST0_IE | ST0_IM); 104 set_c0_status(ST0_CO | ST0_IE | ST0_IM);
107} 105}
diff --git a/arch/mips/sgi-ip27/ip27-irq.c b/arch/mips/sgi-ip27/ip27-irq.c
index f01ba1f90770..270ecd3e6b4a 100644
--- a/arch/mips/sgi-ip27/ip27-irq.c
+++ b/arch/mips/sgi-ip27/ip27-irq.c
@@ -354,29 +354,6 @@ static struct irq_chip bridge_irq_type = {
354 .end = end_bridge_irq, 354 .end = end_bridge_irq,
355}; 355};
356 356
357static unsigned long irq_map[NR_IRQS / BITS_PER_LONG];
358
359int allocate_irqno(void)
360{
361 int irq;
362
363again:
364 irq = find_first_zero_bit(irq_map, NR_IRQS);
365
366 if (irq >= NR_IRQS)
367 return -ENOSPC;
368
369 if (test_and_set_bit(irq, irq_map))
370 goto again;
371
372 return irq;
373}
374
375void free_irqno(unsigned int irq)
376{
377 clear_bit(irq, irq_map);
378}
379
380void __devinit register_bridge_irq(unsigned int irq) 357void __devinit register_bridge_irq(unsigned int irq)
381{ 358{
382 irq_desc[irq].status = IRQ_DISABLED; 359 irq_desc[irq].status = IRQ_DISABLED;
diff --git a/arch/mips/sgi-ip27/ip27-klnuma.c b/arch/mips/sgi-ip27/ip27-klnuma.c
index d777b7d1a9fe..f9f404a8ddad 100644
--- a/arch/mips/sgi-ip27/ip27-klnuma.c
+++ b/arch/mips/sgi-ip27/ip27-klnuma.c
@@ -26,7 +26,7 @@ static cpumask_t ktext_repmask;
26 * kernel. For example, we should never put a copy on a headless node, 26 * kernel. For example, we should never put a copy on a headless node,
27 * and we should respect the topology of the machine. 27 * and we should respect the topology of the machine.
28 */ 28 */
29void __init setup_replication_mask() 29void __init setup_replication_mask(void)
30{ 30{
31 cnodeid_t cnode; 31 cnodeid_t cnode;
32 32
diff --git a/arch/mips/sgi-ip27/ip27-timer.c b/arch/mips/sgi-ip27/ip27-timer.c
index 4e870fc4469b..5e82a268e3c9 100644
--- a/arch/mips/sgi-ip27/ip27-timer.c
+++ b/arch/mips/sgi-ip27/ip27-timer.c
@@ -134,13 +134,6 @@ again:
134 irq_exit(); 134 irq_exit();
135} 135}
136 136
137unsigned long ip27_do_gettimeoffset(void)
138{
139 unsigned long ct_cur1;
140 ct_cur1 = REMOTE_HUB_L(cputonasid(0), PI_RT_COUNT) + CYCLES_PER_JIFFY;
141 return (ct_cur1 - ct_cur[0]) * NSEC_PER_CYCLE / 1000;
142}
143
144/* Includes for ioc3_init(). */ 137/* Includes for ioc3_init(). */
145#include <asm/sn/types.h> 138#include <asm/sn/types.h>
146#include <asm/sn/sn0/addrs.h> 139#include <asm/sn/sn0/addrs.h>
@@ -221,8 +214,6 @@ static struct irqaction rt_irqaction = {
221 .name = "timer" 214 .name = "timer"
222}; 215};
223 216
224extern int allocate_irqno(void);
225
226void __init plat_timer_setup(struct irqaction *irq) 217void __init plat_timer_setup(struct irqaction *irq)
227{ 218{
228 int irqno = allocate_irqno(); 219 int irqno = allocate_irqno();
@@ -248,12 +239,17 @@ void __init plat_timer_setup(struct irqaction *irq)
248 setup_irq(irqno, &rt_irqaction); 239 setup_irq(irqno, &rt_irqaction);
249} 240}
250 241
242static unsigned int ip27_hpt_read(void)
243{
244 return REMOTE_HUB_L(cputonasid(0), PI_RT_COUNT);
245}
246
251void __init ip27_time_init(void) 247void __init ip27_time_init(void)
252{ 248{
249 mips_hpt_read = ip27_hpt_read;
250 mips_hpt_frequency = CYCLES_PER_SEC;
253 xtime.tv_sec = get_m48t35_time(); 251 xtime.tv_sec = get_m48t35_time();
254 xtime.tv_nsec = 0; 252 xtime.tv_nsec = 0;
255
256 do_gettimeoffset = ip27_do_gettimeoffset;
257} 253}
258 254
259void __init cpu_time_init(void) 255void __init cpu_time_init(void)
diff --git a/arch/mips/sgi-ip32/ip32-reset.c b/arch/mips/sgi-ip32/ip32-reset.c
index fd0932b2d521..db8084411538 100644
--- a/arch/mips/sgi-ip32/ip32-reset.c
+++ b/arch/mips/sgi-ip32/ip32-reset.c
@@ -135,7 +135,7 @@ static inline void ip32_power_button(void)
135 add_timer(&power_timer); 135 add_timer(&power_timer);
136} 136}
137 137
138static irqreturn_t ip32_rtc_int(int irq, void *dev_id, struct pt_regs *regs) 138static irqreturn_t ip32_rtc_int(int irq, void *dev_id)
139{ 139{
140 volatile unsigned char reg_c; 140 volatile unsigned char reg_c;
141 141
diff --git a/arch/mips/sibyte/bcm1480/smp.c b/arch/mips/sibyte/bcm1480/smp.c
index 6eac36d1b8c8..bf328277c775 100644
--- a/arch/mips/sibyte/bcm1480/smp.c
+++ b/arch/mips/sibyte/bcm1480/smp.c
@@ -34,21 +34,21 @@ extern void smp_call_function_interrupt(void);
34 * independent of board/firmware 34 * independent of board/firmware
35 */ 35 */
36 36
37static void *mailbox_0_set_regs[] = { 37static volatile void *mailbox_0_set_regs[] = {
38 IOADDR(A_BCM1480_IMR_CPU0_BASE + R_BCM1480_IMR_MAILBOX_0_SET_CPU), 38 IOADDR(A_BCM1480_IMR_CPU0_BASE + R_BCM1480_IMR_MAILBOX_0_SET_CPU),
39 IOADDR(A_BCM1480_IMR_CPU1_BASE + R_BCM1480_IMR_MAILBOX_0_SET_CPU), 39 IOADDR(A_BCM1480_IMR_CPU1_BASE + R_BCM1480_IMR_MAILBOX_0_SET_CPU),
40 IOADDR(A_BCM1480_IMR_CPU2_BASE + R_BCM1480_IMR_MAILBOX_0_SET_CPU), 40 IOADDR(A_BCM1480_IMR_CPU2_BASE + R_BCM1480_IMR_MAILBOX_0_SET_CPU),
41 IOADDR(A_BCM1480_IMR_CPU3_BASE + R_BCM1480_IMR_MAILBOX_0_SET_CPU), 41 IOADDR(A_BCM1480_IMR_CPU3_BASE + R_BCM1480_IMR_MAILBOX_0_SET_CPU),
42}; 42};
43 43
44static void *mailbox_0_clear_regs[] = { 44static volatile void *mailbox_0_clear_regs[] = {
45 IOADDR(A_BCM1480_IMR_CPU0_BASE + R_BCM1480_IMR_MAILBOX_0_CLR_CPU), 45 IOADDR(A_BCM1480_IMR_CPU0_BASE + R_BCM1480_IMR_MAILBOX_0_CLR_CPU),
46 IOADDR(A_BCM1480_IMR_CPU1_BASE + R_BCM1480_IMR_MAILBOX_0_CLR_CPU), 46 IOADDR(A_BCM1480_IMR_CPU1_BASE + R_BCM1480_IMR_MAILBOX_0_CLR_CPU),
47 IOADDR(A_BCM1480_IMR_CPU2_BASE + R_BCM1480_IMR_MAILBOX_0_CLR_CPU), 47 IOADDR(A_BCM1480_IMR_CPU2_BASE + R_BCM1480_IMR_MAILBOX_0_CLR_CPU),
48 IOADDR(A_BCM1480_IMR_CPU3_BASE + R_BCM1480_IMR_MAILBOX_0_CLR_CPU), 48 IOADDR(A_BCM1480_IMR_CPU3_BASE + R_BCM1480_IMR_MAILBOX_0_CLR_CPU),
49}; 49};
50 50
51static void *mailbox_0_regs[] = { 51static volatile void *mailbox_0_regs[] = {
52 IOADDR(A_BCM1480_IMR_CPU0_BASE + R_BCM1480_IMR_MAILBOX_0_CPU), 52 IOADDR(A_BCM1480_IMR_CPU0_BASE + R_BCM1480_IMR_MAILBOX_0_CPU),
53 IOADDR(A_BCM1480_IMR_CPU1_BASE + R_BCM1480_IMR_MAILBOX_0_CPU), 53 IOADDR(A_BCM1480_IMR_CPU1_BASE + R_BCM1480_IMR_MAILBOX_0_CPU),
54 IOADDR(A_BCM1480_IMR_CPU2_BASE + R_BCM1480_IMR_MAILBOX_0_CPU), 54 IOADDR(A_BCM1480_IMR_CPU2_BASE + R_BCM1480_IMR_MAILBOX_0_CPU),
diff --git a/arch/mips/sibyte/bcm1480/time.c b/arch/mips/sibyte/bcm1480/time.c
index bf12af46132e..e136bde5248e 100644
--- a/arch/mips/sibyte/bcm1480/time.c
+++ b/arch/mips/sibyte/bcm1480/time.c
@@ -47,6 +47,12 @@
47#define IMR_IP3_VAL K_BCM1480_INT_MAP_I1 47#define IMR_IP3_VAL K_BCM1480_INT_MAP_I1
48#define IMR_IP4_VAL K_BCM1480_INT_MAP_I2 48#define IMR_IP4_VAL K_BCM1480_INT_MAP_I2
49 49
50#ifdef CONFIG_SIMULATION
51#define BCM1480_HPT_VALUE 50000
52#else
53#define BCM1480_HPT_VALUE 1000000
54#endif
55
50extern int bcm1480_steal_irq(int irq); 56extern int bcm1480_steal_irq(int irq);
51 57
52void bcm1480_time_init(void) 58void bcm1480_time_init(void)
@@ -59,11 +65,6 @@ void bcm1480_time_init(void)
59 BUG(); 65 BUG();
60 } 66 }
61 67
62 if (!cpu) {
63 /* Use our own gettimeoffset() routine */
64 do_gettimeoffset = bcm1480_gettimeoffset;
65 }
66
67 bcm1480_mask_irq(cpu, irq); 68 bcm1480_mask_irq(cpu, irq);
68 69
69 /* Map the timer interrupt to ip[4] of this cpu */ 70 /* Map the timer interrupt to ip[4] of this cpu */
@@ -74,11 +75,7 @@ void bcm1480_time_init(void)
74 /* Disable the timer and set up the count */ 75 /* Disable the timer and set up the count */
75 __raw_writeq(0, IOADDR(A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_CFG))); 76 __raw_writeq(0, IOADDR(A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_CFG)));
76 __raw_writeq( 77 __raw_writeq(
77#ifndef CONFIG_SIMULATION 78 BCM1480_HPT_VALUE/HZ
78 1000000/HZ
79#else
80 50000/HZ
81#endif
82 , IOADDR(A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_INIT))); 79 , IOADDR(A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_INIT)));
83 80
84 /* Set the timer running */ 81 /* Set the timer running */
@@ -122,16 +119,16 @@ void bcm1480_timer_interrupt(void)
122 } 119 }
123} 120}
124 121
125/* 122static unsigned int bcm1480_hpt_read(void)
126 * We use our own do_gettimeoffset() instead of the generic one,
127 * because the generic one does not work for SMP case.
128 * In addition, since we use general timer 0 for system time,
129 * we can get accurate intra-jiffy offset without calibration.
130 */
131unsigned long bcm1480_gettimeoffset(void)
132{ 123{
124 /* We assume this function is called xtime_lock held. */
133 unsigned long count = 125 unsigned long count =
134 __raw_readq(IOADDR(A_SCD_TIMER_REGISTER(0, R_SCD_TIMER_CNT))); 126 __raw_readq(IOADDR(A_SCD_TIMER_REGISTER(0, R_SCD_TIMER_CNT)));
127 return (jiffies + 1) * (BCM1480_HPT_VALUE / HZ) - count;
128}
135 129
136 return 1000000/HZ - count; 130void __init bcm1480_hpt_setup(void)
131{
132 mips_hpt_read = bcm1480_hpt_read;
133 mips_hpt_frequency = BCM1480_HPT_VALUE;
137} 134}
diff --git a/arch/mips/sibyte/sb1250/bcm1250_tbprof.c b/arch/mips/sibyte/sb1250/bcm1250_tbprof.c
index 992e0d8dbb67..d1a906e683b2 100644
--- a/arch/mips/sibyte/sb1250/bcm1250_tbprof.c
+++ b/arch/mips/sibyte/sb1250/bcm1250_tbprof.c
@@ -88,7 +88,7 @@ static void arm_tb(void)
88 sbp.tb_armed = 1; 88 sbp.tb_armed = 1;
89} 89}
90 90
91static irqreturn_t sbprof_tb_intr(int irq, void *dev_id, struct pt_regs *regs) 91static irqreturn_t sbprof_tb_intr(int irq, void *dev_id)
92{ 92{
93 int i; 93 int i;
94 DBG(printk(DEVNAME ": tb_intr\n")); 94 DBG(printk(DEVNAME ": tb_intr\n"));
@@ -138,7 +138,7 @@ static irqreturn_t sbprof_tb_intr(int irq, void *dev_id, struct pt_regs *regs)
138 return IRQ_HANDLED; 138 return IRQ_HANDLED;
139} 139}
140 140
141static irqreturn_t sbprof_pc_intr(int irq, void *dev_id, struct pt_regs *regs) 141static irqreturn_t sbprof_pc_intr(int irq, void *dev_id)
142{ 142{
143 printk(DEVNAME ": unexpected pc_intr"); 143 printk(DEVNAME ": unexpected pc_intr");
144 return IRQ_NONE; 144 return IRQ_NONE;
diff --git a/arch/mips/sibyte/sb1250/bus_watcher.c b/arch/mips/sibyte/sb1250/bus_watcher.c
index bb90649fbc48..45274bd3cd8b 100644
--- a/arch/mips/sibyte/sb1250/bus_watcher.c
+++ b/arch/mips/sibyte/sb1250/bus_watcher.c
@@ -171,7 +171,7 @@ static void create_proc_decoder(struct bw_stats_struct *stats)
171 * notes: possible re-entry due to multiple sources 171 * notes: possible re-entry due to multiple sources
172 * should check/indicate saturation 172 * should check/indicate saturation
173 */ 173 */
174static irqreturn_t sibyte_bw_int(int irq, void *data, struct pt_regs *regs) 174static irqreturn_t sibyte_bw_int(int irq, void *data)
175{ 175{
176 struct bw_stats_struct *stats = data; 176 struct bw_stats_struct *stats = data;
177 unsigned long cntr; 177 unsigned long cntr;
diff --git a/arch/mips/sibyte/sb1250/time.c b/arch/mips/sibyte/sb1250/time.c
index 0ccf1796dd78..bcb74f2c1948 100644
--- a/arch/mips/sibyte/sb1250/time.c
+++ b/arch/mips/sibyte/sb1250/time.c
@@ -47,15 +47,11 @@
47 47
48#define SB1250_HPT_NUM 3 48#define SB1250_HPT_NUM 3
49#define SB1250_HPT_VALUE M_SCD_TIMER_CNT /* max value */ 49#define SB1250_HPT_VALUE M_SCD_TIMER_CNT /* max value */
50#define SB1250_HPT_SHIFT ((sizeof(unsigned int)*8)-V_SCD_TIMER_WIDTH)
51 50
52 51
53extern int sb1250_steal_irq(int irq); 52extern int sb1250_steal_irq(int irq);
54 53
55static unsigned int sb1250_hpt_read(void); 54static unsigned int sb1250_hpt_read(void);
56static void sb1250_hpt_init(unsigned int);
57
58static unsigned int hpt_offset;
59 55
60void __init sb1250_hpt_setup(void) 56void __init sb1250_hpt_setup(void)
61{ 57{
@@ -69,13 +65,9 @@ void __init sb1250_hpt_setup(void)
69 __raw_writeq(M_SCD_TIMER_ENABLE | M_SCD_TIMER_MODE_CONTINUOUS, 65 __raw_writeq(M_SCD_TIMER_ENABLE | M_SCD_TIMER_MODE_CONTINUOUS,
70 IOADDR(A_SCD_TIMER_REGISTER(SB1250_HPT_NUM, R_SCD_TIMER_CFG))); 66 IOADDR(A_SCD_TIMER_REGISTER(SB1250_HPT_NUM, R_SCD_TIMER_CFG)));
71 67
72 /* 68 mips_hpt_frequency = V_SCD_TIMER_FREQ;
73 * we need to fill 32 bits, so just use the upper 23 bits and pretend
74 * the timer is going 512Mhz instead of 1Mhz
75 */
76 mips_hpt_frequency = V_SCD_TIMER_FREQ << SB1250_HPT_SHIFT;
77 mips_hpt_init = sb1250_hpt_init;
78 mips_hpt_read = sb1250_hpt_read; 69 mips_hpt_read = sb1250_hpt_read;
70 mips_hpt_mask = M_SCD_TIMER_INIT;
79 } 71 }
80} 72}
81 73
@@ -149,11 +141,7 @@ void sb1250_timer_interrupt(void)
149 141
150/* 142/*
151 * The HPT is free running from SB1250_HPT_VALUE down to 0 then starts over 143 * The HPT is free running from SB1250_HPT_VALUE down to 0 then starts over
152 * again. There's no easy way to set to a specific value so store init value 144 * again.
153 * in hpt_offset and subtract each time.
154 *
155 * Note: Timer isn't full 32bits so shift it into the upper part making
156 * it appear to run at a higher frequency.
157 */ 145 */
158static unsigned int sb1250_hpt_read(void) 146static unsigned int sb1250_hpt_read(void)
159{ 147{
@@ -161,13 +149,5 @@ static unsigned int sb1250_hpt_read(void)
161 149
162 count = G_SCD_TIMER_CNT(__raw_readq(IOADDR(A_SCD_TIMER_REGISTER(SB1250_HPT_NUM, R_SCD_TIMER_CNT)))); 150 count = G_SCD_TIMER_CNT(__raw_readq(IOADDR(A_SCD_TIMER_REGISTER(SB1250_HPT_NUM, R_SCD_TIMER_CNT))));
163 151
164 count = (SB1250_HPT_VALUE - count) << SB1250_HPT_SHIFT; 152 return SB1250_HPT_VALUE - count;
165
166 return count - hpt_offset;
167}
168
169static void sb1250_hpt_init(unsigned int count)
170{
171 hpt_offset = count;
172 return;
173} 153}
diff --git a/arch/mips/tx4927/common/smsc_fdc37m81x.c b/arch/mips/tx4927/common/smsc_fdc37m81x.c
new file mode 100644
index 000000000000..33f517bc9a08
--- /dev/null
+++ b/arch/mips/tx4927/common/smsc_fdc37m81x.c
@@ -0,0 +1,172 @@
1/*
2 * Interface for smsc fdc48m81x Super IO chip
3 *
4 * Author: MontaVista Software, Inc. source@mvista.com
5 *
6 * 2001-2003 (c) MontaVista Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 *
11 * Copyright 2004 (c) MontaVista Software, Inc.
12 */
13#include <linux/init.h>
14#include <linux/types.h>
15#include <asm/io.h>
16#include <asm/tx4927/smsc_fdc37m81x.h>
17
18#define DEBUG
19
20/* Common Registers */
21#define SMSC_FDC37M81X_CONFIG_INDEX 0x00
22#define SMSC_FDC37M81X_CONFIG_DATA 0x01
23#define SMSC_FDC37M81X_CONF 0x02
24#define SMSC_FDC37M81X_INDEX 0x03
25#define SMSC_FDC37M81X_DNUM 0x07
26#define SMSC_FDC37M81X_DID 0x20
27#define SMSC_FDC37M81X_DREV 0x21
28#define SMSC_FDC37M81X_PCNT 0x22
29#define SMSC_FDC37M81X_PMGT 0x23
30#define SMSC_FDC37M81X_OSC 0x24
31#define SMSC_FDC37M81X_CONFPA0 0x26
32#define SMSC_FDC37M81X_CONFPA1 0x27
33#define SMSC_FDC37M81X_TEST4 0x2B
34#define SMSC_FDC37M81X_TEST5 0x2C
35#define SMSC_FDC37M81X_TEST1 0x2D
36#define SMSC_FDC37M81X_TEST2 0x2E
37#define SMSC_FDC37M81X_TEST3 0x2F
38
39/* Logical device numbers */
40#define SMSC_FDC37M81X_FDD 0x00
41#define SMSC_FDC37M81X_SERIAL1 0x04
42#define SMSC_FDC37M81X_SERIAL2 0x05
43#define SMSC_FDC37M81X_KBD 0x07
44
45/* Logical device Config Registers */
46#define SMSC_FDC37M81X_ACTIVE 0x30
47#define SMSC_FDC37M81X_BASEADDR0 0x60
48#define SMSC_FDC37M81X_BASEADDR1 0x61
49#define SMSC_FDC37M81X_INT 0x70
50#define SMSC_FDC37M81X_INT2 0x72
51#define SMSC_FDC37M81X_MODE 0xF0
52
53/* Chip Config Values */
54#define SMSC_FDC37M81X_CONFIG_ENTER 0x55
55#define SMSC_FDC37M81X_CONFIG_EXIT 0xaa
56#define SMSC_FDC37M81X_CHIP_ID 0x4d
57
58static unsigned long g_smsc_fdc37m81x_base = 0;
59
60static inline unsigned char smsc_fdc37m81x_rd(unsigned char index)
61{
62 outb(index, g_smsc_fdc37m81x_base + SMSC_FDC37M81X_CONFIG_INDEX);
63
64 return inb(g_smsc_fdc37m81x_base + SMSC_FDC37M81X_CONFIG_DATA);
65}
66
67static inline void smsc_dc37m81x_wr(unsigned char index, unsigned char data)
68{
69 outb(index, g_smsc_fdc37m81x_base + SMSC_FDC37M81X_CONFIG_INDEX);
70 outb(data, g_smsc_fdc37m81x_base + SMSC_FDC37M81X_CONFIG_DATA);
71}
72
73void smsc_fdc37m81x_config_beg(void)
74{
75 if (g_smsc_fdc37m81x_base) {
76 outb(SMSC_FDC37M81X_CONFIG_ENTER,
77 g_smsc_fdc37m81x_base + SMSC_FDC37M81X_CONFIG_INDEX);
78 }
79}
80
81void smsc_fdc37m81x_config_end(void)
82{
83 if (g_smsc_fdc37m81x_base)
84 outb(SMSC_FDC37M81X_CONFIG_EXIT,
85 g_smsc_fdc37m81x_base + SMSC_FDC37M81X_CONFIG_INDEX);
86}
87
88u8 smsc_fdc37m81x_config_get(u8 reg)
89{
90 u8 val = 0;
91
92 if (g_smsc_fdc37m81x_base)
93 val = smsc_fdc37m81x_rd(reg);
94
95 return val;
96}
97
98void smsc_fdc37m81x_config_set(u8 reg, u8 val)
99{
100 if (g_smsc_fdc37m81x_base)
101 smsc_dc37m81x_wr(reg, val);
102}
103
104unsigned long __init smsc_fdc37m81x_init(unsigned long port)
105{
106 const int field = sizeof(unsigned long) * 2;
107 u8 chip_id;
108
109 if (g_smsc_fdc37m81x_base)
110 printk("smsc_fdc37m81x_init() stepping on old base=0x%0*lx\n",
111 field, g_smsc_fdc37m81x_base);
112
113 g_smsc_fdc37m81x_base = port;
114
115 smsc_fdc37m81x_config_beg();
116
117 chip_id = smsc_fdc37m81x_rd(SMSC_FDC37M81X_DID);
118 if (chip_id == SMSC_FDC37M81X_CHIP_ID)
119 smsc_fdc37m81x_config_end();
120 else {
121 printk("smsc_fdc37m81x_init() unknow chip id 0x%02x\n",
122 chip_id);
123 g_smsc_fdc37m81x_base = 0;
124 }
125
126 return g_smsc_fdc37m81x_base;
127}
128
129#ifdef DEBUG
130void smsc_fdc37m81x_config_dump_one(char *key, u8 dev, u8 reg)
131{
132 printk("%s: dev=0x%02x reg=0x%02x val=0x%02x\n", key, dev, reg,
133 smsc_fdc37m81x_rd(reg));
134}
135
136void smsc_fdc37m81x_config_dump(void)
137{
138 u8 orig;
139 char *fname = "smsc_fdc37m81x_config_dump()";
140
141 smsc_fdc37m81x_config_beg();
142
143 orig = smsc_fdc37m81x_rd(SMSC_FDC37M81X_DNUM);
144
145 printk("%s: common\n", fname);
146 smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_NONE,
147 SMSC_FDC37M81X_DNUM);
148 smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_NONE,
149 SMSC_FDC37M81X_DID);
150 smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_NONE,
151 SMSC_FDC37M81X_DREV);
152 smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_NONE,
153 SMSC_FDC37M81X_PCNT);
154 smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_NONE,
155 SMSC_FDC37M81X_PMGT);
156
157 printk("%s: keyboard\n", fname);
158 smsc_dc37m81x_wr(SMSC_FDC37M81X_DNUM, SMSC_FDC37M81X_KBD);
159 smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_KBD,
160 SMSC_FDC37M81X_ACTIVE);
161 smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_KBD,
162 SMSC_FDC37M81X_INT);
163 smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_KBD,
164 SMSC_FDC37M81X_INT2);
165 smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_KBD,
166 SMSC_FDC37M81X_LDCR_F0);
167
168 smsc_dc37m81x_wr(SMSC_FDC37M81X_DNUM, orig);
169
170 smsc_fdc37m81x_config_end();
171}
172#endif
diff --git a/arch/mips/tx4927/common/tx4927_setup.c b/arch/mips/tx4927/common/tx4927_setup.c
index 4658b2ae4833..941c441729b0 100644
--- a/arch/mips/tx4927/common/tx4927_setup.c
+++ b/arch/mips/tx4927/common/tx4927_setup.c
@@ -112,8 +112,6 @@ void print_cp0(char *key, int num, char *name, u32 val)
112 return; 112 return;
113} 113}
114 114
115indent: Standard input:25: Error:Unexpected end of file
116
117void 115void
118dump_cp0(char *key) 116dump_cp0(char *key)
119{ 117{
diff --git a/arch/mips/tx4938/toshiba_rbtx4938/spi_txx9.c b/arch/mips/tx4938/toshiba_rbtx4938/spi_txx9.c
index b926e6a75c29..08b20cdfd7b3 100644
--- a/arch/mips/tx4938/toshiba_rbtx4938/spi_txx9.c
+++ b/arch/mips/tx4938/toshiba_rbtx4938/spi_txx9.c
@@ -36,14 +36,18 @@ void __init txx9_spi_init(unsigned long base, int (*cs_func)(int chipid, int on)
36 36
37static DECLARE_WAIT_QUEUE_HEAD(txx9_spi_wait); 37static DECLARE_WAIT_QUEUE_HEAD(txx9_spi_wait);
38 38
39static void txx9_spi_interrupt(int irq, void *dev_id) 39static irqreturn_t txx9_spi_interrupt(int irq, void *dev_id)
40{ 40{
41 /* disable rx intr */ 41 /* disable rx intr */
42 tx4938_spiptr->cr0 &= ~TXx9_SPCR0_RBSIE; 42 tx4938_spiptr->cr0 &= ~TXx9_SPCR0_RBSIE;
43 wake_up(&txx9_spi_wait); 43 wake_up(&txx9_spi_wait);
44
45 return IRQ_HANDLED;
44} 46}
47
45static struct irqaction txx9_spi_action = { 48static struct irqaction txx9_spi_action = {
46 txx9_spi_interrupt, 0, 0, "spi", NULL, NULL, 49 .handler = txx9_spi_interrupt,
50 .name = "spi",
47}; 51};
48 52
49void __init txx9_spi_irqinit(int irc_irq) 53void __init txx9_spi_irqinit(int irc_irq)
diff --git a/arch/parisc/kernel/parisc_ksyms.c b/arch/parisc/kernel/parisc_ksyms.c
index 6d57553d8ef8..8f6a0b312f7a 100644
--- a/arch/parisc/kernel/parisc_ksyms.c
+++ b/arch/parisc/kernel/parisc_ksyms.c
@@ -69,10 +69,6 @@ EXPORT_SYMBOL(memcpy_toio);
69EXPORT_SYMBOL(memcpy_fromio); 69EXPORT_SYMBOL(memcpy_fromio);
70EXPORT_SYMBOL(memset_io); 70EXPORT_SYMBOL(memset_io);
71 71
72#include <asm/unistd.h>
73EXPORT_SYMBOL(sys_lseek);
74EXPORT_SYMBOL(sys_write);
75
76#include <asm/semaphore.h> 72#include <asm/semaphore.h>
77EXPORT_SYMBOL(__up); 73EXPORT_SYMBOL(__up);
78EXPORT_SYMBOL(__down_interruptible); 74EXPORT_SYMBOL(__down_interruptible);
diff --git a/arch/parisc/kernel/vmlinux.lds.S b/arch/parisc/kernel/vmlinux.lds.S
index b3677fc8eef5..7b943b45f7cd 100644
--- a/arch/parisc/kernel/vmlinux.lds.S
+++ b/arch/parisc/kernel/vmlinux.lds.S
@@ -153,13 +153,7 @@ SECTIONS
153 __setup_end = .; 153 __setup_end = .;
154 __initcall_start = .; 154 __initcall_start = .;
155 .initcall.init : { 155 .initcall.init : {
156 *(.initcall1.init) 156 INITCALLS
157 *(.initcall2.init)
158 *(.initcall3.init)
159 *(.initcall4.init)
160 *(.initcall5.init)
161 *(.initcall6.init)
162 *(.initcall7.init)
163 } 157 }
164 __initcall_end = .; 158 __initcall_end = .;
165 __con_initcall_start = .; 159 __con_initcall_start = .;
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 8b6910465578..0673dbedb241 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -740,7 +740,7 @@ config ARCH_SPARSEMEM_ENABLE
740 740
741config ARCH_SPARSEMEM_DEFAULT 741config ARCH_SPARSEMEM_DEFAULT
742 def_bool y 742 def_bool y
743 depends on SMP && PPC_PSERIES 743 depends on (SMP && PPC_PSERIES) || PPC_CELL
744 744
745config ARCH_POPULATES_NODE_MAP 745config ARCH_POPULATES_NODE_MAP
746 def_bool y 746 def_bool y
@@ -751,6 +751,15 @@ config ARCH_MEMORY_PROBE
751 def_bool y 751 def_bool y
752 depends on MEMORY_HOTPLUG 752 depends on MEMORY_HOTPLUG
753 753
754# Some NUMA nodes have memory ranges that span
755# other nodes. Even though a pfn is valid and
756# between a node's start and end pfns, it may not
757# reside on that node. See memmap_init_zone()
758# for details.
759config NODES_SPAN_OTHER_NODES
760 def_bool y
761 depends on NEED_MULTIPLE_NODES
762
754config PPC_64K_PAGES 763config PPC_64K_PAGES
755 bool "64k page size" 764 bool "64k page size"
756 depends on PPC64 765 depends on PPC64
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 37ddfcab0003..4b2be611f77f 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -115,7 +115,7 @@ endif
115quiet_cmd_wrap = WRAP $@ 115quiet_cmd_wrap = WRAP $@
116 cmd_wrap =$(CONFIG_SHELL) $(wrapper) -c -o $@ -p $2 $(CROSSWRAP) vmlinux 116 cmd_wrap =$(CONFIG_SHELL) $(wrapper) -c -o $@ -p $2 $(CROSSWRAP) vmlinux
117quiet_cmd_wrap_initrd = WRAP $@ 117quiet_cmd_wrap_initrd = WRAP $@
118 cmd_wrap_initrd =$(wrapper) -c -o $@ -p $2 $(CROSSWRAP) \ 118 cmd_wrap_initrd =$(CONFIG_SHELL) $(wrapper) -c -o $@ -p $2 $(CROSSWRAP) \
119 -i $(obj)/ramdisk.image.gz vmlinux 119 -i $(obj)/ramdisk.image.gz vmlinux
120 120
121$(obj)/zImage.chrp: vmlinux $(wrapperbits) 121$(obj)/zImage.chrp: vmlinux $(wrapperbits)
diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
index eab7318729e9..b5fb1fee76f8 100755
--- a/arch/powerpc/boot/wrapper
+++ b/arch/powerpc/boot/wrapper
@@ -179,11 +179,11 @@ if [ -z "$cacheit" ]; then
179fi 179fi
180 180
181if [ -n "$initrd" ]; then 181if [ -n "$initrd" ]; then
182 addsec $tmp "$initrd" initrd 182 addsec $tmp "$initrd" $isection
183fi 183fi
184 184
185if [ -n "$dtb" ]; then 185if [ -n "$dtb" ]; then
186 addsec $tmp "$dtb" dtb 186 addsec $tmp "$dtb" .kernel:dtb
187fi 187fi
188 188
189if [ "$platform" != "miboot" ]; then 189if [ "$platform" != "miboot" ]; then
diff --git a/arch/powerpc/boot/zImage.lds.S b/arch/powerpc/boot/zImage.lds.S
index 4b6bb3ffe3dc..4be3c6414b04 100644
--- a/arch/powerpc/boot/zImage.lds.S
+++ b/arch/powerpc/boot/zImage.lds.S
@@ -21,6 +21,11 @@ SECTIONS
21 __got2_end = .; 21 __got2_end = .;
22 } 22 }
23 23
24 . = ALIGN(8);
25 _dtb_start = .;
26 .kernel:dtb : { *(.kernel:dtb) }
27 _dtb_end = .;
28
24 . = ALIGN(4096); 29 . = ALIGN(4096);
25 _vmlinux_start = .; 30 _vmlinux_start = .;
26 .kernel:vmlinux.strip : { *(.kernel:vmlinux.strip) } 31 .kernel:vmlinux.strip : { *(.kernel:vmlinux.strip) }
diff --git a/arch/powerpc/configs/cell_defconfig b/arch/powerpc/configs/cell_defconfig
index 892d5dd3254e..0aba06d7d2ec 100644
--- a/arch/powerpc/configs/cell_defconfig
+++ b/arch/powerpc/configs/cell_defconfig
@@ -254,6 +254,7 @@ CONFIG_SYN_COOKIES=y
254CONFIG_INET_TUNNEL=y 254CONFIG_INET_TUNNEL=y
255CONFIG_INET_XFRM_MODE_TRANSPORT=y 255CONFIG_INET_XFRM_MODE_TRANSPORT=y
256CONFIG_INET_XFRM_MODE_TUNNEL=y 256CONFIG_INET_XFRM_MODE_TUNNEL=y
257# CONFIG_INET_XFRM_MODE_BEET is not set
257CONFIG_INET_DIAG=y 258CONFIG_INET_DIAG=y
258CONFIG_INET_TCP_DIAG=y 259CONFIG_INET_TCP_DIAG=y
259# CONFIG_TCP_CONG_ADVANCED is not set 260# CONFIG_TCP_CONG_ADVANCED is not set
@@ -275,7 +276,9 @@ CONFIG_INET6_XFRM_TUNNEL=m
275CONFIG_INET6_TUNNEL=m 276CONFIG_INET6_TUNNEL=m
276CONFIG_INET6_XFRM_MODE_TRANSPORT=y 277CONFIG_INET6_XFRM_MODE_TRANSPORT=y
277CONFIG_INET6_XFRM_MODE_TUNNEL=y 278CONFIG_INET6_XFRM_MODE_TUNNEL=y
279# CONFIG_INET6_XFRM_MODE_BEET is not set
278# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set 280# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
281# CONFIG_IPV6_SIT is not set
279CONFIG_IPV6_TUNNEL=m 282CONFIG_IPV6_TUNNEL=m
280# CONFIG_IPV6_SUBTREES is not set 283# CONFIG_IPV6_SUBTREES is not set
281# CONFIG_IPV6_MULTIPLE_TABLES is not set 284# CONFIG_IPV6_MULTIPLE_TABLES is not set
@@ -406,6 +409,12 @@ CONFIG_BLK_DEV_INITRD=y
406# CONFIG_ATA_OVER_ETH is not set 409# CONFIG_ATA_OVER_ETH is not set
407 410
408# 411#
412# Misc devices
413#
414# CONFIG_SGI_IOC4 is not set
415# CONFIG_TIFM_CORE is not set
416
417#
409# ATA/ATAPI/MFM/RLL support 418# ATA/ATAPI/MFM/RLL support
410# 419#
411CONFIG_IDE=y 420CONFIG_IDE=y
@@ -738,7 +747,6 @@ CONFIG_GEN_RTC=y
738# TPM devices 747# TPM devices
739# 748#
740# CONFIG_TCG_TPM is not set 749# CONFIG_TCG_TPM is not set
741# CONFIG_TELCLOCK is not set
742 750
743# 751#
744# I2C support 752# I2C support
@@ -802,6 +810,7 @@ CONFIG_I2C_ALGOBIT=y
802# 810#
803# Dallas's 1-wire bus 811# Dallas's 1-wire bus
804# 812#
813# CONFIG_W1 is not set
805 814
806# 815#
807# Hardware Monitoring support 816# Hardware Monitoring support
@@ -810,14 +819,9 @@ CONFIG_I2C_ALGOBIT=y
810# CONFIG_HWMON_VID is not set 819# CONFIG_HWMON_VID is not set
811 820
812# 821#
813# Misc devices
814#
815
816#
817# Multimedia devices 822# Multimedia devices
818# 823#
819# CONFIG_VIDEO_DEV is not set 824# CONFIG_VIDEO_DEV is not set
820CONFIG_VIDEO_V4L2=y
821 825
822# 826#
823# Digital Video Broadcasting Devices 827# Digital Video Broadcasting Devices
@@ -923,6 +927,7 @@ CONFIG_EXT3_FS=y
923CONFIG_EXT3_FS_XATTR=y 927CONFIG_EXT3_FS_XATTR=y
924# CONFIG_EXT3_FS_POSIX_ACL is not set 928# CONFIG_EXT3_FS_POSIX_ACL is not set
925# CONFIG_EXT3_FS_SECURITY is not set 929# CONFIG_EXT3_FS_SECURITY is not set
930# CONFIG_EXT4DEV_FS is not set
926CONFIG_JBD=y 931CONFIG_JBD=y
927# CONFIG_JBD_DEBUG is not set 932# CONFIG_JBD_DEBUG is not set
928CONFIG_FS_MBCACHE=y 933CONFIG_FS_MBCACHE=y
@@ -930,6 +935,7 @@ CONFIG_FS_MBCACHE=y
930# CONFIG_JFS_FS is not set 935# CONFIG_JFS_FS is not set
931CONFIG_FS_POSIX_ACL=y 936CONFIG_FS_POSIX_ACL=y
932# CONFIG_XFS_FS is not set 937# CONFIG_XFS_FS is not set
938# CONFIG_GFS2_FS is not set
933# CONFIG_OCFS2_FS is not set 939# CONFIG_OCFS2_FS is not set
934# CONFIG_MINIX_FS is not set 940# CONFIG_MINIX_FS is not set
935# CONFIG_ROMFS_FS is not set 941# CONFIG_ROMFS_FS is not set
@@ -1129,6 +1135,7 @@ CONFIG_DEBUG_FS=y
1129# CONFIG_DEBUG_VM is not set 1135# CONFIG_DEBUG_VM is not set
1130# CONFIG_DEBUG_LIST is not set 1136# CONFIG_DEBUG_LIST is not set
1131# CONFIG_FORCED_INLINING is not set 1137# CONFIG_FORCED_INLINING is not set
1138# CONFIG_HEADERS_CHECK is not set
1132# CONFIG_RCU_TORTURE_TEST is not set 1139# CONFIG_RCU_TORTURE_TEST is not set
1133# CONFIG_DEBUG_STACKOVERFLOW is not set 1140# CONFIG_DEBUG_STACKOVERFLOW is not set
1134# CONFIG_DEBUG_STACK_USAGE is not set 1141# CONFIG_DEBUG_STACK_USAGE is not set
diff --git a/arch/powerpc/configs/mpc834x_itx_defconfig b/arch/powerpc/configs/mpc834x_itx_defconfig
index cd3535e1a095..0561b73a918f 100644
--- a/arch/powerpc/configs/mpc834x_itx_defconfig
+++ b/arch/powerpc/configs/mpc834x_itx_defconfig
@@ -1248,7 +1248,7 @@ CONFIG_PARTITION_ADVANCED=y
1248# CONFIG_AMIGA_PARTITION is not set 1248# CONFIG_AMIGA_PARTITION is not set
1249# CONFIG_ATARI_PARTITION is not set 1249# CONFIG_ATARI_PARTITION is not set
1250# CONFIG_MAC_PARTITION is not set 1250# CONFIG_MAC_PARTITION is not set
1251# CONFIG_MSDOS_PARTITION is not set 1251CONFIG_MSDOS_PARTITION=y
1252# CONFIG_LDM_PARTITION is not set 1252# CONFIG_LDM_PARTITION is not set
1253# CONFIG_SGI_PARTITION is not set 1253# CONFIG_SGI_PARTITION is not set
1254# CONFIG_ULTRIX_PARTITION is not set 1254# CONFIG_ULTRIX_PARTITION is not set
diff --git a/arch/powerpc/configs/pseries_defconfig b/arch/powerpc/configs/pseries_defconfig
index 9828663652e9..d2833c1a1f3d 100644
--- a/arch/powerpc/configs/pseries_defconfig
+++ b/arch/powerpc/configs/pseries_defconfig
@@ -184,6 +184,7 @@ CONFIG_SPLIT_PTLOCK_CPUS=4
184CONFIG_MIGRATION=y 184CONFIG_MIGRATION=y
185CONFIG_RESOURCES_64BIT=y 185CONFIG_RESOURCES_64BIT=y
186CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y 186CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y
187CONFIG_NODES_SPAN_OTHER_NODES=y
187# CONFIG_PPC_64K_PAGES is not set 188# CONFIG_PPC_64K_PAGES is not set
188CONFIG_SCHED_SMT=y 189CONFIG_SCHED_SMT=y
189CONFIG_PROC_DEVICETREE=y 190CONFIG_PROC_DEVICETREE=y
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 8b133afbdc20..7af23c43fd4b 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -38,7 +38,6 @@ obj-$(CONFIG_6xx) += idle_6xx.o l2cr_6xx.o cpu_setup_6xx.o
38obj-$(CONFIG_TAU) += tau_6xx.o 38obj-$(CONFIG_TAU) += tau_6xx.o
39obj32-$(CONFIG_SOFTWARE_SUSPEND) += swsusp_32.o 39obj32-$(CONFIG_SOFTWARE_SUSPEND) += swsusp_32.o
40obj32-$(CONFIG_MODULES) += module_32.o 40obj32-$(CONFIG_MODULES) += module_32.o
41obj-$(CONFIG_E500) += perfmon_fsl_booke.o
42 41
43ifeq ($(CONFIG_PPC_MERGE),y) 42ifeq ($(CONFIG_PPC_MERGE),y)
44 43
diff --git a/arch/powerpc/kernel/btext.c b/arch/powerpc/kernel/btext.c
index 995fcef156fd..93f21aaf7c8e 100644
--- a/arch/powerpc/kernel/btext.c
+++ b/arch/powerpc/kernel/btext.c
@@ -182,7 +182,7 @@ int btext_initialize(struct device_node *np)
182 prop = get_property(np, "linux,bootx-linebytes", NULL); 182 prop = get_property(np, "linux,bootx-linebytes", NULL);
183 if (prop == NULL) 183 if (prop == NULL)
184 prop = get_property(np, "linebytes", NULL); 184 prop = get_property(np, "linebytes", NULL);
185 if (prop) 185 if (prop && *prop != 0xffffffffu)
186 pitch = *prop; 186 pitch = *prop;
187 if (pitch == 1) 187 if (pitch == 1)
188 pitch = 0x1000; 188 pitch = 0x1000;
diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
index 47a613cdd775..bfd499ee3753 100644
--- a/arch/powerpc/kernel/cputable.c
+++ b/arch/powerpc/kernel/cputable.c
@@ -18,6 +18,7 @@
18 18
19#include <asm/oprofile_impl.h> 19#include <asm/oprofile_impl.h>
20#include <asm/cputable.h> 20#include <asm/cputable.h>
21#include <asm/prom.h> /* for PTRRELOC on ARCH=ppc */
21 22
22struct cpu_spec* cur_cpu_spec = NULL; 23struct cpu_spec* cur_cpu_spec = NULL;
23EXPORT_SYMBOL(cur_cpu_spec); 24EXPORT_SYMBOL(cur_cpu_spec);
@@ -73,7 +74,7 @@ extern void __restore_cpu_ppc970(void);
73#define PPC_FEATURE_SPE_COMP 0 74#define PPC_FEATURE_SPE_COMP 0
74#endif 75#endif
75 76
76struct cpu_spec cpu_specs[] = { 77static struct cpu_spec cpu_specs[] = {
77#ifdef CONFIG_PPC64 78#ifdef CONFIG_PPC64
78 { /* Power3 */ 79 { /* Power3 */
79 .pvr_mask = 0xffff0000, 80 .pvr_mask = 0xffff0000,
@@ -227,6 +228,21 @@ struct cpu_spec cpu_specs[] = {
227 .oprofile_type = PPC_OPROFILE_POWER4, 228 .oprofile_type = PPC_OPROFILE_POWER4,
228 .platform = "ppc970", 229 .platform = "ppc970",
229 }, 230 },
231 { /* PPC970GX */
232 .pvr_mask = 0xffff0000,
233 .pvr_value = 0x00450000,
234 .cpu_name = "PPC970GX",
235 .cpu_features = CPU_FTRS_PPC970,
236 .cpu_user_features = COMMON_USER_POWER4 |
237 PPC_FEATURE_HAS_ALTIVEC_COMP,
238 .icache_bsize = 128,
239 .dcache_bsize = 128,
240 .num_pmcs = 8,
241 .cpu_setup = __setup_cpu_ppc970,
242 .oprofile_cpu_type = "ppc64/970",
243 .oprofile_type = PPC_OPROFILE_POWER4,
244 .platform = "ppc970",
245 },
230 { /* Power5 GR */ 246 { /* Power5 GR */
231 .pvr_mask = 0xffff0000, 247 .pvr_mask = 0xffff0000,
232 .pvr_value = 0x003a0000, 248 .pvr_value = 0x003a0000,
@@ -268,7 +284,7 @@ struct cpu_spec cpu_specs[] = {
268 .cpu_user_features = COMMON_USER_POWER6, 284 .cpu_user_features = COMMON_USER_POWER6,
269 .icache_bsize = 128, 285 .icache_bsize = 128,
270 .dcache_bsize = 128, 286 .dcache_bsize = 128,
271 .num_pmcs = 8, 287 .num_pmcs = 6,
272 .oprofile_cpu_type = "ppc64/power6", 288 .oprofile_cpu_type = "ppc64/power6",
273 .oprofile_type = PPC_OPROFILE_POWER4, 289 .oprofile_type = PPC_OPROFILE_POWER4,
274 .oprofile_mmcra_sihv = POWER6_MMCRA_SIHV, 290 .oprofile_mmcra_sihv = POWER6_MMCRA_SIHV,
@@ -1152,3 +1168,71 @@ struct cpu_spec cpu_specs[] = {
1152#endif /* !CLASSIC_PPC */ 1168#endif /* !CLASSIC_PPC */
1153#endif /* CONFIG_PPC32 */ 1169#endif /* CONFIG_PPC32 */
1154}; 1170};
1171
1172struct cpu_spec *identify_cpu(unsigned long offset)
1173{
1174 struct cpu_spec *s = cpu_specs;
1175 struct cpu_spec **cur = &cur_cpu_spec;
1176 unsigned int pvr = mfspr(SPRN_PVR);
1177 int i;
1178
1179 s = PTRRELOC(s);
1180 cur = PTRRELOC(cur);
1181
1182 if (*cur != NULL)
1183 return PTRRELOC(*cur);
1184
1185 for (i = 0; i < ARRAY_SIZE(cpu_specs); i++,s++)
1186 if ((pvr & s->pvr_mask) == s->pvr_value) {
1187 *cur = cpu_specs + i;
1188#ifdef CONFIG_PPC64
1189 /* ppc64 expects identify_cpu to also call setup_cpu
1190 * for that processor. I will consolidate that at a
1191 * later time, for now, just use our friend #ifdef.
1192 * we also don't need to PTRRELOC the function pointer
1193 * on ppc64 as we are running at 0 in real mode.
1194 */
1195 if (s->cpu_setup) {
1196 s->cpu_setup(offset, s);
1197 }
1198#endif /* CONFIG_PPC64 */
1199 return s;
1200 }
1201 BUG();
1202 return NULL;
1203}
1204
1205void do_feature_fixups(unsigned long value, void *fixup_start, void *fixup_end)
1206{
1207 struct fixup_entry {
1208 unsigned long mask;
1209 unsigned long value;
1210 long start_off;
1211 long end_off;
1212 } *fcur, *fend;
1213
1214 fcur = fixup_start;
1215 fend = fixup_end;
1216
1217 for (; fcur < fend; fcur++) {
1218 unsigned int *pstart, *pend, *p;
1219
1220 if ((value & fcur->mask) == fcur->value)
1221 continue;
1222
1223 /* These PTRRELOCs will disappear once the new scheme for
1224 * modules and vdso is implemented
1225 */
1226 pstart = ((unsigned int *)fcur) + (fcur->start_off / 4);
1227 pend = ((unsigned int *)fcur) + (fcur->end_off / 4);
1228
1229 for (p = pstart; p < pend; p++) {
1230 *p = 0x60000000u;
1231 asm volatile ("dcbst 0, %0" : : "r" (p));
1232 }
1233 asm volatile ("sync" : : : "memory");
1234 for (p = pstart; p < pend; p++)
1235 asm volatile ("icbi 0,%0" : : "r" (p));
1236 asm volatile ("sync; isync" : : : "memory");
1237 }
1238}
diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index 645c7f10fb28..e720729f3e55 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -487,7 +487,7 @@ BEGIN_FTR_SECTION
487 rlwimi r13,r12,16,0x20 487 rlwimi r13,r12,16,0x20
488 mfcr r12 488 mfcr r12
489 cmpwi r13,0x2c 489 cmpwi r13,0x2c
490 beq .do_stab_bolted_pSeries 490 beq do_stab_bolted_pSeries
491 mtcrf 0x80,r12 491 mtcrf 0x80,r12
492 mfspr r12,SPRN_SPRG2 492 mfspr r12,SPRN_SPRG2
493END_FTR_SECTION_IFCLR(CPU_FTR_SLB) 493END_FTR_SECTION_IFCLR(CPU_FTR_SLB)
@@ -600,7 +600,7 @@ system_call_pSeries:
600 STD_EXCEPTION_PSERIES(., performance_monitor) 600 STD_EXCEPTION_PSERIES(., performance_monitor)
601 601
602 .align 7 602 .align 7
603_GLOBAL(do_stab_bolted_pSeries) 603do_stab_bolted_pSeries:
604 mtcrf 0x80,r12 604 mtcrf 0x80,r12
605 mfspr r12,SPRN_SPRG2 605 mfspr r12,SPRN_SPRG2
606 EXCEPTION_PROLOG_PSERIES(PACA_EXSLB, .do_stab_bolted) 606 EXCEPTION_PROLOG_PSERIES(PACA_EXSLB, .do_stab_bolted)
@@ -1046,7 +1046,7 @@ slb_miss_fault:
1046 li r5,0 1046 li r5,0
1047 std r4,_DAR(r1) 1047 std r4,_DAR(r1)
1048 std r5,_DSISR(r1) 1048 std r5,_DSISR(r1)
1049 b .handle_page_fault 1049 b handle_page_fault
1050 1050
1051unrecov_user_slb: 1051unrecov_user_slb:
1052 EXCEPTION_PROLOG_COMMON(0x4200, PACA_EXGEN) 1052 EXCEPTION_PROLOG_COMMON(0x4200, PACA_EXGEN)
@@ -1174,12 +1174,13 @@ program_check_common:
1174 .globl fp_unavailable_common 1174 .globl fp_unavailable_common
1175fp_unavailable_common: 1175fp_unavailable_common:
1176 EXCEPTION_PROLOG_COMMON(0x800, PACA_EXGEN) 1176 EXCEPTION_PROLOG_COMMON(0x800, PACA_EXGEN)
1177 bne .load_up_fpu /* if from user, just load it up */ 1177 bne 1f /* if from user, just load it up */
1178 bl .save_nvgprs 1178 bl .save_nvgprs
1179 addi r3,r1,STACK_FRAME_OVERHEAD 1179 addi r3,r1,STACK_FRAME_OVERHEAD
1180 ENABLE_INTS 1180 ENABLE_INTS
1181 bl .kernel_fp_unavailable_exception 1181 bl .kernel_fp_unavailable_exception
1182 BUG_OPCODE 1182 BUG_OPCODE
11831: b .load_up_fpu
1183 1184
1184 .align 7 1185 .align 7
1185 .globl altivec_unavailable_common 1186 .globl altivec_unavailable_common
@@ -1279,10 +1280,10 @@ _GLOBAL(do_hash_page)
1279 std r4,_DSISR(r1) 1280 std r4,_DSISR(r1)
1280 1281
1281 andis. r0,r4,0xa450 /* weird error? */ 1282 andis. r0,r4,0xa450 /* weird error? */
1282 bne- .handle_page_fault /* if not, try to insert a HPTE */ 1283 bne- handle_page_fault /* if not, try to insert a HPTE */
1283BEGIN_FTR_SECTION 1284BEGIN_FTR_SECTION
1284 andis. r0,r4,0x0020 /* Is it a segment table fault? */ 1285 andis. r0,r4,0x0020 /* Is it a segment table fault? */
1285 bne- .do_ste_alloc /* If so handle it */ 1286 bne- do_ste_alloc /* If so handle it */
1286END_FTR_SECTION_IFCLR(CPU_FTR_SLB) 1287END_FTR_SECTION_IFCLR(CPU_FTR_SLB)
1287 1288
1288 /* 1289 /*
@@ -1324,7 +1325,7 @@ BEGIN_FW_FTR_SECTION
1324 * because ret_from_except_lite will check for and handle pending 1325 * because ret_from_except_lite will check for and handle pending
1325 * interrupts if necessary. 1326 * interrupts if necessary.
1326 */ 1327 */
1327 beq .ret_from_except_lite 1328 beq 13f
1328 /* For a hash failure, we don't bother re-enabling interrupts */ 1329 /* For a hash failure, we don't bother re-enabling interrupts */
1329 ble- 12f 1330 ble- 12f
1330 1331
@@ -1346,14 +1347,14 @@ BEGIN_FW_FTR_SECTION
1346END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISERIES) 1347END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISERIES)
1347 1348
1348/* Here we have a page fault that hash_page can't handle. */ 1349/* Here we have a page fault that hash_page can't handle. */
1349_GLOBAL(handle_page_fault) 1350handle_page_fault:
1350 ENABLE_INTS 1351 ENABLE_INTS
135111: ld r4,_DAR(r1) 135211: ld r4,_DAR(r1)
1352 ld r5,_DSISR(r1) 1353 ld r5,_DSISR(r1)
1353 addi r3,r1,STACK_FRAME_OVERHEAD 1354 addi r3,r1,STACK_FRAME_OVERHEAD
1354 bl .do_page_fault 1355 bl .do_page_fault
1355 cmpdi r3,0 1356 cmpdi r3,0
1356 beq+ .ret_from_except_lite 1357 beq+ 13f
1357 bl .save_nvgprs 1358 bl .save_nvgprs
1358 mr r5,r3 1359 mr r5,r3
1359 addi r3,r1,STACK_FRAME_OVERHEAD 1360 addi r3,r1,STACK_FRAME_OVERHEAD
@@ -1370,12 +1371,14 @@ _GLOBAL(handle_page_fault)
1370 bl .low_hash_fault 1371 bl .low_hash_fault
1371 b .ret_from_except 1372 b .ret_from_except
1372 1373
137413: b .ret_from_except_lite
1375
1373 /* here we have a segment miss */ 1376 /* here we have a segment miss */
1374_GLOBAL(do_ste_alloc) 1377do_ste_alloc:
1375 bl .ste_allocate /* try to insert stab entry */ 1378 bl .ste_allocate /* try to insert stab entry */
1376 cmpdi r3,0 1379 cmpdi r3,0
1377 beq+ fast_exception_return 1380 bne- handle_page_fault
1378 b .handle_page_fault 1381 b fast_exception_return
1379 1382
1380/* 1383/*
1381 * r13 points to the PACA, r9 contains the saved CR, 1384 * r13 points to the PACA, r9 contains the saved CR,
@@ -1580,11 +1583,6 @@ _STATIC(__start_initialization_iSeries)
1580 li r0,0 1583 li r0,0
1581 stdu r0,-STACK_FRAME_OVERHEAD(r1) 1584 stdu r0,-STACK_FRAME_OVERHEAD(r1)
1582 1585
1583 LOAD_REG_IMMEDIATE(r3,cpu_specs)
1584 LOAD_REG_IMMEDIATE(r4,cur_cpu_spec)
1585 li r5,0
1586 bl .identify_cpu
1587
1588 LOAD_REG_IMMEDIATE(r2,__toc_start) 1586 LOAD_REG_IMMEDIATE(r2,__toc_start)
1589 addi r2,r2,0x4000 1587 addi r2,r2,0x4000
1590 addi r2,r2,0x4000 1588 addi r2,r2,0x4000
@@ -1646,6 +1644,8 @@ _GLOBAL(__start_initialization_multiplatform)
1646 cmpwi r0,0x3c /* 970FX */ 1644 cmpwi r0,0x3c /* 970FX */
1647 beq 1f 1645 beq 1f
1648 cmpwi r0,0x44 /* 970MP */ 1646 cmpwi r0,0x44 /* 970MP */
1647 beq 1f
1648 cmpwi r0,0x45 /* 970GX */
1649 bne 2f 1649 bne 2f
16501: bl .__cpu_preinit_ppc970 16501: bl .__cpu_preinit_ppc970
16512: 16512:
@@ -1964,13 +1964,6 @@ _STATIC(start_here_multiplatform)
1964 addi r2,r2,0x4000 1964 addi r2,r2,0x4000
1965 add r2,r2,r26 1965 add r2,r2,r26
1966 1966
1967 LOAD_REG_IMMEDIATE(r3, cpu_specs)
1968 add r3,r3,r26
1969 LOAD_REG_IMMEDIATE(r4,cur_cpu_spec)
1970 add r4,r4,r26
1971 mr r5,r26
1972 bl .identify_cpu
1973
1974 /* Do very early kernel initializations, including initial hash table, 1967 /* Do very early kernel initializations, including initial hash table,
1975 * stab and slb setup before we turn on relocation. */ 1968 * stab and slb setup before we turn on relocation. */
1976 1969
@@ -2000,13 +1993,6 @@ _STATIC(start_here_common)
2000 li r0,0 1993 li r0,0
2001 stdu r0,-STACK_FRAME_OVERHEAD(r1) 1994 stdu r0,-STACK_FRAME_OVERHEAD(r1)
2002 1995
2003 /* Apply the CPUs-specific fixups (nop out sections not relevant
2004 * to this CPU
2005 */
2006 li r3,0
2007 bl .do_cpu_ftr_fixups
2008 bl .do_fw_ftr_fixups
2009
2010 /* ptr to current */ 1996 /* ptr to current */
2011 LOAD_REG_IMMEDIATE(r4, init_task) 1997 LOAD_REG_IMMEDIATE(r4, init_task)
2012 std r4,PACACURRENT(r13) 1998 std r4,PACACURRENT(r13)
diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
index f88a2a675d90..ba6b7256084b 100644
--- a/arch/powerpc/kernel/iommu.c
+++ b/arch/powerpc/kernel/iommu.c
@@ -47,6 +47,17 @@ static int novmerge = 0;
47static int novmerge = 1; 47static int novmerge = 1;
48#endif 48#endif
49 49
50static inline unsigned long iommu_num_pages(unsigned long vaddr,
51 unsigned long slen)
52{
53 unsigned long npages;
54
55 npages = IOMMU_PAGE_ALIGN(vaddr + slen) - (vaddr & IOMMU_PAGE_MASK);
56 npages >>= IOMMU_PAGE_SHIFT;
57
58 return npages;
59}
60
50static int __init setup_iommu(char *str) 61static int __init setup_iommu(char *str)
51{ 62{
52 if (!strcmp(str, "novmerge")) 63 if (!strcmp(str, "novmerge"))
@@ -178,10 +189,10 @@ static dma_addr_t iommu_alloc(struct iommu_table *tbl, void *page,
178 } 189 }
179 190
180 entry += tbl->it_offset; /* Offset into real TCE table */ 191 entry += tbl->it_offset; /* Offset into real TCE table */
181 ret = entry << PAGE_SHIFT; /* Set the return dma address */ 192 ret = entry << IOMMU_PAGE_SHIFT; /* Set the return dma address */
182 193
183 /* Put the TCEs in the HW table */ 194 /* Put the TCEs in the HW table */
184 ppc_md.tce_build(tbl, entry, npages, (unsigned long)page & PAGE_MASK, 195 ppc_md.tce_build(tbl, entry, npages, (unsigned long)page & IOMMU_PAGE_MASK,
185 direction); 196 direction);
186 197
187 198
@@ -203,7 +214,7 @@ static void __iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
203 unsigned long entry, free_entry; 214 unsigned long entry, free_entry;
204 unsigned long i; 215 unsigned long i;
205 216
206 entry = dma_addr >> PAGE_SHIFT; 217 entry = dma_addr >> IOMMU_PAGE_SHIFT;
207 free_entry = entry - tbl->it_offset; 218 free_entry = entry - tbl->it_offset;
208 219
209 if (((free_entry + npages) > tbl->it_size) || 220 if (((free_entry + npages) > tbl->it_size) ||
@@ -270,7 +281,7 @@ int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
270 /* Init first segment length for backout at failure */ 281 /* Init first segment length for backout at failure */
271 outs->dma_length = 0; 282 outs->dma_length = 0;
272 283
273 DBG("mapping %d elements:\n", nelems); 284 DBG("sg mapping %d elements:\n", nelems);
274 285
275 spin_lock_irqsave(&(tbl->it_lock), flags); 286 spin_lock_irqsave(&(tbl->it_lock), flags);
276 287
@@ -285,9 +296,8 @@ int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
285 } 296 }
286 /* Allocate iommu entries for that segment */ 297 /* Allocate iommu entries for that segment */
287 vaddr = (unsigned long)page_address(s->page) + s->offset; 298 vaddr = (unsigned long)page_address(s->page) + s->offset;
288 npages = PAGE_ALIGN(vaddr + slen) - (vaddr & PAGE_MASK); 299 npages = iommu_num_pages(vaddr, slen);
289 npages >>= PAGE_SHIFT; 300 entry = iommu_range_alloc(tbl, npages, &handle, mask >> IOMMU_PAGE_SHIFT, 0);
290 entry = iommu_range_alloc(tbl, npages, &handle, mask >> PAGE_SHIFT, 0);
291 301
292 DBG(" - vaddr: %lx, size: %lx\n", vaddr, slen); 302 DBG(" - vaddr: %lx, size: %lx\n", vaddr, slen);
293 303
@@ -301,14 +311,14 @@ int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
301 311
302 /* Convert entry to a dma_addr_t */ 312 /* Convert entry to a dma_addr_t */
303 entry += tbl->it_offset; 313 entry += tbl->it_offset;
304 dma_addr = entry << PAGE_SHIFT; 314 dma_addr = entry << IOMMU_PAGE_SHIFT;
305 dma_addr |= s->offset; 315 dma_addr |= (s->offset & ~IOMMU_PAGE_MASK);
306 316
307 DBG(" - %lx pages, entry: %lx, dma_addr: %lx\n", 317 DBG(" - %lu pages, entry: %lx, dma_addr: %lx\n",
308 npages, entry, dma_addr); 318 npages, entry, dma_addr);
309 319
310 /* Insert into HW table */ 320 /* Insert into HW table */
311 ppc_md.tce_build(tbl, entry, npages, vaddr & PAGE_MASK, direction); 321 ppc_md.tce_build(tbl, entry, npages, vaddr & IOMMU_PAGE_MASK, direction);
312 322
313 /* If we are in an open segment, try merging */ 323 /* If we are in an open segment, try merging */
314 if (segstart != s) { 324 if (segstart != s) {
@@ -323,7 +333,7 @@ int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
323 DBG(" can't merge, new segment.\n"); 333 DBG(" can't merge, new segment.\n");
324 } else { 334 } else {
325 outs->dma_length += s->length; 335 outs->dma_length += s->length;
326 DBG(" merged, new len: %lx\n", outs->dma_length); 336 DBG(" merged, new len: %ux\n", outs->dma_length);
327 } 337 }
328 } 338 }
329 339
@@ -367,9 +377,8 @@ int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
367 if (s->dma_length != 0) { 377 if (s->dma_length != 0) {
368 unsigned long vaddr, npages; 378 unsigned long vaddr, npages;
369 379
370 vaddr = s->dma_address & PAGE_MASK; 380 vaddr = s->dma_address & IOMMU_PAGE_MASK;
371 npages = (PAGE_ALIGN(s->dma_address + s->dma_length) - vaddr) 381 npages = iommu_num_pages(s->dma_address, s->dma_length);
372 >> PAGE_SHIFT;
373 __iommu_free(tbl, vaddr, npages); 382 __iommu_free(tbl, vaddr, npages);
374 s->dma_address = DMA_ERROR_CODE; 383 s->dma_address = DMA_ERROR_CODE;
375 s->dma_length = 0; 384 s->dma_length = 0;
@@ -398,8 +407,7 @@ void iommu_unmap_sg(struct iommu_table *tbl, struct scatterlist *sglist,
398 407
399 if (sglist->dma_length == 0) 408 if (sglist->dma_length == 0)
400 break; 409 break;
401 npages = (PAGE_ALIGN(dma_handle + sglist->dma_length) 410 npages = iommu_num_pages(dma_handle,sglist->dma_length);
402 - (dma_handle & PAGE_MASK)) >> PAGE_SHIFT;
403 __iommu_free(tbl, dma_handle, npages); 411 __iommu_free(tbl, dma_handle, npages);
404 sglist++; 412 sglist++;
405 } 413 }
@@ -532,12 +540,11 @@ dma_addr_t iommu_map_single(struct iommu_table *tbl, void *vaddr,
532 BUG_ON(direction == DMA_NONE); 540 BUG_ON(direction == DMA_NONE);
533 541
534 uaddr = (unsigned long)vaddr; 542 uaddr = (unsigned long)vaddr;
535 npages = PAGE_ALIGN(uaddr + size) - (uaddr & PAGE_MASK); 543 npages = iommu_num_pages(uaddr, size);
536 npages >>= PAGE_SHIFT;
537 544
538 if (tbl) { 545 if (tbl) {
539 dma_handle = iommu_alloc(tbl, vaddr, npages, direction, 546 dma_handle = iommu_alloc(tbl, vaddr, npages, direction,
540 mask >> PAGE_SHIFT, 0); 547 mask >> IOMMU_PAGE_SHIFT, 0);
541 if (dma_handle == DMA_ERROR_CODE) { 548 if (dma_handle == DMA_ERROR_CODE) {
542 if (printk_ratelimit()) { 549 if (printk_ratelimit()) {
543 printk(KERN_INFO "iommu_alloc failed, " 550 printk(KERN_INFO "iommu_alloc failed, "
@@ -545,7 +552,7 @@ dma_addr_t iommu_map_single(struct iommu_table *tbl, void *vaddr,
545 tbl, vaddr, npages); 552 tbl, vaddr, npages);
546 } 553 }
547 } else 554 } else
548 dma_handle |= (uaddr & ~PAGE_MASK); 555 dma_handle |= (uaddr & ~IOMMU_PAGE_MASK);
549 } 556 }
550 557
551 return dma_handle; 558 return dma_handle;
@@ -554,11 +561,14 @@ dma_addr_t iommu_map_single(struct iommu_table *tbl, void *vaddr,
554void iommu_unmap_single(struct iommu_table *tbl, dma_addr_t dma_handle, 561void iommu_unmap_single(struct iommu_table *tbl, dma_addr_t dma_handle,
555 size_t size, enum dma_data_direction direction) 562 size_t size, enum dma_data_direction direction)
556{ 563{
564 unsigned int npages;
565
557 BUG_ON(direction == DMA_NONE); 566 BUG_ON(direction == DMA_NONE);
558 567
559 if (tbl) 568 if (tbl) {
560 iommu_free(tbl, dma_handle, (PAGE_ALIGN(dma_handle + size) - 569 npages = iommu_num_pages(dma_handle, size);
561 (dma_handle & PAGE_MASK)) >> PAGE_SHIFT); 570 iommu_free(tbl, dma_handle, npages);
571 }
562} 572}
563 573
564/* Allocates a contiguous real buffer and creates mappings over it. 574/* Allocates a contiguous real buffer and creates mappings over it.
@@ -570,11 +580,11 @@ void *iommu_alloc_coherent(struct iommu_table *tbl, size_t size,
570{ 580{
571 void *ret = NULL; 581 void *ret = NULL;
572 dma_addr_t mapping; 582 dma_addr_t mapping;
573 unsigned int npages, order; 583 unsigned int order;
584 unsigned int nio_pages, io_order;
574 struct page *page; 585 struct page *page;
575 586
576 size = PAGE_ALIGN(size); 587 size = PAGE_ALIGN(size);
577 npages = size >> PAGE_SHIFT;
578 order = get_order(size); 588 order = get_order(size);
579 589
580 /* 590 /*
@@ -598,8 +608,10 @@ void *iommu_alloc_coherent(struct iommu_table *tbl, size_t size,
598 memset(ret, 0, size); 608 memset(ret, 0, size);
599 609
600 /* Set up tces to cover the allocated range */ 610 /* Set up tces to cover the allocated range */
601 mapping = iommu_alloc(tbl, ret, npages, DMA_BIDIRECTIONAL, 611 nio_pages = size >> IOMMU_PAGE_SHIFT;
602 mask >> PAGE_SHIFT, order); 612 io_order = get_iommu_order(size);
613 mapping = iommu_alloc(tbl, ret, nio_pages, DMA_BIDIRECTIONAL,
614 mask >> IOMMU_PAGE_SHIFT, io_order);
603 if (mapping == DMA_ERROR_CODE) { 615 if (mapping == DMA_ERROR_CODE) {
604 free_pages((unsigned long)ret, order); 616 free_pages((unsigned long)ret, order);
605 return NULL; 617 return NULL;
@@ -611,12 +623,13 @@ void *iommu_alloc_coherent(struct iommu_table *tbl, size_t size,
611void iommu_free_coherent(struct iommu_table *tbl, size_t size, 623void iommu_free_coherent(struct iommu_table *tbl, size_t size,
612 void *vaddr, dma_addr_t dma_handle) 624 void *vaddr, dma_addr_t dma_handle)
613{ 625{
614 unsigned int npages;
615
616 if (tbl) { 626 if (tbl) {
627 unsigned int nio_pages;
628
629 size = PAGE_ALIGN(size);
630 nio_pages = size >> IOMMU_PAGE_SHIFT;
631 iommu_free(tbl, dma_handle, nio_pages);
617 size = PAGE_ALIGN(size); 632 size = PAGE_ALIGN(size);
618 npages = size >> PAGE_SHIFT;
619 iommu_free(tbl, dma_handle, npages);
620 free_pages((unsigned long)vaddr, get_order(size)); 633 free_pages((unsigned long)vaddr, get_order(size));
621 } 634 }
622} 635}
diff --git a/arch/powerpc/kernel/misc_32.S b/arch/powerpc/kernel/misc_32.S
index 88fd73fdf048..412bea3cf813 100644
--- a/arch/powerpc/kernel/misc_32.S
+++ b/arch/powerpc/kernel/misc_32.S
@@ -102,80 +102,6 @@ _GLOBAL(reloc_got2)
102 blr 102 blr
103 103
104/* 104/*
105 * identify_cpu,
106 * called with r3 = data offset and r4 = CPU number
107 * doesn't change r3
108 */
109_GLOBAL(identify_cpu)
110 addis r8,r3,cpu_specs@ha
111 addi r8,r8,cpu_specs@l
112 mfpvr r7
1131:
114 lwz r5,CPU_SPEC_PVR_MASK(r8)
115 and r5,r5,r7
116 lwz r6,CPU_SPEC_PVR_VALUE(r8)
117 cmplw 0,r6,r5
118 beq 1f
119 addi r8,r8,CPU_SPEC_ENTRY_SIZE
120 b 1b
1211:
122 addis r6,r3,cur_cpu_spec@ha
123 addi r6,r6,cur_cpu_spec@l
124 sub r8,r8,r3
125 stw r8,0(r6)
126 blr
127
128/*
129 * do_cpu_ftr_fixups - goes through the list of CPU feature fixups
130 * and writes nop's over sections of code that don't apply for this cpu.
131 * r3 = data offset (not changed)
132 */
133_GLOBAL(do_cpu_ftr_fixups)
134 /* Get CPU 0 features */
135 addis r6,r3,cur_cpu_spec@ha
136 addi r6,r6,cur_cpu_spec@l
137 lwz r4,0(r6)
138 add r4,r4,r3
139 lwz r4,CPU_SPEC_FEATURES(r4)
140
141 /* Get the fixup table */
142 addis r6,r3,__start___ftr_fixup@ha
143 addi r6,r6,__start___ftr_fixup@l
144 addis r7,r3,__stop___ftr_fixup@ha
145 addi r7,r7,__stop___ftr_fixup@l
146
147 /* Do the fixup */
1481: cmplw 0,r6,r7
149 bgelr
150 addi r6,r6,16
151 lwz r8,-16(r6) /* mask */
152 and r8,r8,r4
153 lwz r9,-12(r6) /* value */
154 cmplw 0,r8,r9
155 beq 1b
156 lwz r8,-8(r6) /* section begin */
157 lwz r9,-4(r6) /* section end */
158 subf. r9,r8,r9
159 beq 1b
160 /* write nops over the section of code */
161 /* todo: if large section, add a branch at the start of it */
162 srwi r9,r9,2
163 mtctr r9
164 add r8,r8,r3
165 lis r0,0x60000000@h /* nop */
1663: stw r0,0(r8)
167 andi. r10,r4,CPU_FTR_SPLIT_ID_CACHE@l
168 beq 2f
169 dcbst 0,r8 /* suboptimal, but simpler */
170 sync
171 icbi 0,r8
1722: addi r8,r8,4
173 bdnz 3b
174 sync /* additional sync needed on g4 */
175 isync
176 b 1b
177
178/*
179 * call_setup_cpu - call the setup_cpu function for this cpu 105 * call_setup_cpu - call the setup_cpu function for this cpu
180 * r3 = data offset, r24 = cpu number 106 * r3 = data offset, r24 = cpu number
181 * 107 *
diff --git a/arch/powerpc/kernel/misc_64.S b/arch/powerpc/kernel/misc_64.S
index c70e20708a1f..21fd2c662a99 100644
--- a/arch/powerpc/kernel/misc_64.S
+++ b/arch/powerpc/kernel/misc_64.S
@@ -246,130 +246,6 @@ _GLOBAL(__flush_dcache_icache)
246 isync 246 isync
247 blr 247 blr
248 248
249/*
250 * identify_cpu and calls setup_cpu
251 * In: r3 = base of the cpu_specs array
252 * r4 = address of cur_cpu_spec
253 * r5 = relocation offset
254 */
255_GLOBAL(identify_cpu)
256 mfpvr r7
2571:
258 lwz r8,CPU_SPEC_PVR_MASK(r3)
259 and r8,r8,r7
260 lwz r9,CPU_SPEC_PVR_VALUE(r3)
261 cmplw 0,r9,r8
262 beq 1f
263 addi r3,r3,CPU_SPEC_ENTRY_SIZE
264 b 1b
2651:
266 sub r0,r3,r5
267 std r0,0(r4)
268 ld r4,CPU_SPEC_SETUP(r3)
269 cmpdi 0,r4,0
270 add r4,r4,r5
271 beqlr
272 ld r4,0(r4)
273 add r4,r4,r5
274 mtctr r4
275 /* Calling convention for cpu setup is r3=offset, r4=cur_cpu_spec */
276 mr r4,r3
277 mr r3,r5
278 bctr
279
280/*
281 * do_cpu_ftr_fixups - goes through the list of CPU feature fixups
282 * and writes nop's over sections of code that don't apply for this cpu.
283 * r3 = data offset (not changed)
284 */
285_GLOBAL(do_cpu_ftr_fixups)
286 /* Get CPU 0 features */
287 LOAD_REG_IMMEDIATE(r6,cur_cpu_spec)
288 sub r6,r6,r3
289 ld r4,0(r6)
290 sub r4,r4,r3
291 ld r4,CPU_SPEC_FEATURES(r4)
292 /* Get the fixup table */
293 LOAD_REG_IMMEDIATE(r6,__start___ftr_fixup)
294 sub r6,r6,r3
295 LOAD_REG_IMMEDIATE(r7,__stop___ftr_fixup)
296 sub r7,r7,r3
297 /* Do the fixup */
2981: cmpld r6,r7
299 bgelr
300 addi r6,r6,32
301 ld r8,-32(r6) /* mask */
302 and r8,r8,r4
303 ld r9,-24(r6) /* value */
304 cmpld r8,r9
305 beq 1b
306 ld r8,-16(r6) /* section begin */
307 ld r9,-8(r6) /* section end */
308 subf. r9,r8,r9
309 beq 1b
310 /* write nops over the section of code */
311 /* todo: if large section, add a branch at the start of it */
312 srwi r9,r9,2
313 mtctr r9
314 sub r8,r8,r3
315 lis r0,0x60000000@h /* nop */
3163: stw r0,0(r8)
317 andi. r10,r4,CPU_FTR_SPLIT_ID_CACHE@l
318 beq 2f
319 dcbst 0,r8 /* suboptimal, but simpler */
320 sync
321 icbi 0,r8
3222: addi r8,r8,4
323 bdnz 3b
324 sync /* additional sync needed on g4 */
325 isync
326 b 1b
327
328/*
329 * do_fw_ftr_fixups - goes through the list of firmware feature fixups
330 * and writes nop's over sections of code that don't apply for this firmware.
331 * r3 = data offset (not changed)
332 */
333_GLOBAL(do_fw_ftr_fixups)
334 /* Get firmware features */
335 LOAD_REG_IMMEDIATE(r6,powerpc_firmware_features)
336 sub r6,r6,r3
337 ld r4,0(r6)
338 /* Get the fixup table */
339 LOAD_REG_IMMEDIATE(r6,__start___fw_ftr_fixup)
340 sub r6,r6,r3
341 LOAD_REG_IMMEDIATE(r7,__stop___fw_ftr_fixup)
342 sub r7,r7,r3
343 /* Do the fixup */
3441: cmpld r6,r7
345 bgelr
346 addi r6,r6,32
347 ld r8,-32(r6) /* mask */
348 and r8,r8,r4
349 ld r9,-24(r6) /* value */
350 cmpld r8,r9
351 beq 1b
352 ld r8,-16(r6) /* section begin */
353 ld r9,-8(r6) /* section end */
354 subf. r9,r8,r9
355 beq 1b
356 /* write nops over the section of code */
357 /* todo: if large section, add a branch at the start of it */
358 srwi r9,r9,2
359 mtctr r9
360 sub r8,r8,r3
361 lis r0,0x60000000@h /* nop */
3623: stw r0,0(r8)
363BEGIN_FTR_SECTION
364 dcbst 0,r8 /* suboptimal, but simpler */
365 sync
366 icbi 0,r8
367END_FTR_SECTION_IFSET(CPU_FTR_SPLIT_ID_CACHE)
368 addi r8,r8,4
369 bdnz 3b
370 sync /* additional sync needed on g4 */
371 isync
372 b 1b
373 249
374#if defined(CONFIG_PPC_PMAC) || defined(CONFIG_PPC_MAPLE) 250#if defined(CONFIG_PPC_PMAC) || defined(CONFIG_PPC_MAPLE)
375/* 251/*
diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
index 92f4e5f64f02..e2c3c6a85f33 100644
--- a/arch/powerpc/kernel/module_32.c
+++ b/arch/powerpc/kernel/module_32.c
@@ -24,6 +24,8 @@
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/cache.h> 25#include <linux/cache.h>
26 26
27#include "setup.h"
28
27#if 0 29#if 0
28#define DEBUGP printk 30#define DEBUGP printk
29#else 31#else
@@ -269,33 +271,50 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
269 return 0; 271 return 0;
270} 272}
271 273
274static const Elf_Shdr *find_section(const Elf_Ehdr *hdr,
275 const Elf_Shdr *sechdrs,
276 const char *name)
277{
278 char *secstrings;
279 unsigned int i;
280
281 secstrings = (char *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
282 for (i = 1; i < hdr->e_shnum; i++)
283 if (strcmp(secstrings+sechdrs[i].sh_name, name) == 0)
284 return &sechdrs[i];
285 return NULL;
286}
287
272int module_finalize(const Elf_Ehdr *hdr, 288int module_finalize(const Elf_Ehdr *hdr,
273 const Elf_Shdr *sechdrs, 289 const Elf_Shdr *sechdrs,
274 struct module *me) 290 struct module *me)
275{ 291{
276 char *secstrings; 292 const Elf_Shdr *sect;
277 unsigned int i;
278 293
279 me->arch.bug_table = NULL; 294 me->arch.bug_table = NULL;
280 me->arch.num_bugs = 0; 295 me->arch.num_bugs = 0;
281 296
282 /* Find the __bug_table section, if present */ 297 /* Find the __bug_table section, if present */
283 secstrings = (char *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; 298 sect = find_section(hdr, sechdrs, "__bug_table");
284 for (i = 1; i < hdr->e_shnum; i++) { 299 if (sect != NULL) {
285 if (strcmp(secstrings+sechdrs[i].sh_name, "__bug_table")) 300 me->arch.bug_table = (void *) sect->sh_addr;
286 continue; 301 me->arch.num_bugs = sect->sh_size / sizeof(struct bug_entry);
287 me->arch.bug_table = (void *) sechdrs[i].sh_addr;
288 me->arch.num_bugs = sechdrs[i].sh_size / sizeof(struct bug_entry);
289 break;
290 } 302 }
291 303
292 /* 304 /*
293 * Strictly speaking this should have a spinlock to protect against 305 * Strictly speaking this should have a spinlock to protect against
294 * traversals, but since we only traverse on BUG()s, a spinlock 306 * traversals, but since we only traverse on BUG()s, a spinlock
295 * could potentially lead to deadlock and thus be counter-productive. 307 * could potentially lead to deadlock and thus be counter-productive.
296 */ 308 */
297 list_add(&me->arch.bug_list, &module_bug_list); 309 list_add(&me->arch.bug_list, &module_bug_list);
298 310
311 /* Apply feature fixups */
312 sect = find_section(hdr, sechdrs, "__ftr_fixup");
313 if (sect != NULL)
314 do_feature_fixups(cur_cpu_spec->cpu_features,
315 (void *)sect->sh_addr,
316 (void *)sect->sh_addr + sect->sh_size);
317
299 return 0; 318 return 0;
300} 319}
301 320
diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
index ba34001fca8e..8dd1f0aae5d6 100644
--- a/arch/powerpc/kernel/module_64.c
+++ b/arch/powerpc/kernel/module_64.c
@@ -22,6 +22,9 @@
22#include <linux/vmalloc.h> 22#include <linux/vmalloc.h>
23#include <asm/module.h> 23#include <asm/module.h>
24#include <asm/uaccess.h> 24#include <asm/uaccess.h>
25#include <asm/firmware.h>
26
27#include "setup.h"
25 28
26/* FIXME: We don't do .init separately. To do this, we'd need to have 29/* FIXME: We don't do .init separately. To do this, we'd need to have
27 a separate r2 value in the init and core section, and stub between 30 a separate r2 value in the init and core section, and stub between
@@ -400,6 +403,11 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
400 | (value & 0x03fffffc); 403 | (value & 0x03fffffc);
401 break; 404 break;
402 405
406 case R_PPC64_REL64:
407 /* 64 bits relative (used by features fixups) */
408 *location = value - (unsigned long)location;
409 break;
410
403 default: 411 default:
404 printk("%s: Unknown ADD relocation: %lu\n", 412 printk("%s: Unknown ADD relocation: %lu\n",
405 me->name, 413 me->name,
@@ -413,23 +421,33 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
413 421
414LIST_HEAD(module_bug_list); 422LIST_HEAD(module_bug_list);
415 423
416int module_finalize(const Elf_Ehdr *hdr, 424static const Elf_Shdr *find_section(const Elf_Ehdr *hdr,
417 const Elf_Shdr *sechdrs, struct module *me) 425 const Elf_Shdr *sechdrs,
426 const char *name)
418{ 427{
419 char *secstrings; 428 char *secstrings;
420 unsigned int i; 429 unsigned int i;
421 430
431 secstrings = (char *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
432 for (i = 1; i < hdr->e_shnum; i++)
433 if (strcmp(secstrings+sechdrs[i].sh_name, name) == 0)
434 return &sechdrs[i];
435 return NULL;
436}
437
438int module_finalize(const Elf_Ehdr *hdr,
439 const Elf_Shdr *sechdrs, struct module *me)
440{
441 const Elf_Shdr *sect;
442
422 me->arch.bug_table = NULL; 443 me->arch.bug_table = NULL;
423 me->arch.num_bugs = 0; 444 me->arch.num_bugs = 0;
424 445
425 /* Find the __bug_table section, if present */ 446 /* Find the __bug_table section, if present */
426 secstrings = (char *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; 447 sect = find_section(hdr, sechdrs, "__bug_table");
427 for (i = 1; i < hdr->e_shnum; i++) { 448 if (sect != NULL) {
428 if (strcmp(secstrings+sechdrs[i].sh_name, "__bug_table")) 449 me->arch.bug_table = (void *) sect->sh_addr;
429 continue; 450 me->arch.num_bugs = sect->sh_size / sizeof(struct bug_entry);
430 me->arch.bug_table = (void *) sechdrs[i].sh_addr;
431 me->arch.num_bugs = sechdrs[i].sh_size / sizeof(struct bug_entry);
432 break;
433 } 451 }
434 452
435 /* 453 /*
@@ -439,6 +457,19 @@ int module_finalize(const Elf_Ehdr *hdr,
439 */ 457 */
440 list_add(&me->arch.bug_list, &module_bug_list); 458 list_add(&me->arch.bug_list, &module_bug_list);
441 459
460 /* Apply feature fixups */
461 sect = find_section(hdr, sechdrs, "__ftr_fixup");
462 if (sect != NULL)
463 do_feature_fixups(cur_cpu_spec->cpu_features,
464 (void *)sect->sh_addr,
465 (void *)sect->sh_addr + sect->sh_size);
466
467 sect = find_section(hdr, sechdrs, "__fw_ftr_fixup");
468 if (sect != NULL)
469 do_feature_fixups(powerpc_firmware_features,
470 (void *)sect->sh_addr,
471 (void *)sect->sh_addr + sect->sh_size);
472
442 return 0; 473 return 0;
443} 474}
444 475
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c
index 9b49f8691d29..0d9ff72e2852 100644
--- a/arch/powerpc/kernel/pci_32.c
+++ b/arch/powerpc/kernel/pci_32.c
@@ -441,14 +441,14 @@ update_bridge_base(struct pci_bus *bus, int i)
441 end = res->end - off; 441 end = res->end - off;
442 io_base_lo = (start >> 8) & PCI_IO_RANGE_MASK; 442 io_base_lo = (start >> 8) & PCI_IO_RANGE_MASK;
443 io_limit_lo = (end >> 8) & PCI_IO_RANGE_MASK; 443 io_limit_lo = (end >> 8) & PCI_IO_RANGE_MASK;
444 if (end > 0xffff) { 444 if (end > 0xffff)
445 pci_write_config_word(dev, PCI_IO_BASE_UPPER16,
446 start >> 16);
447 pci_write_config_word(dev, PCI_IO_LIMIT_UPPER16,
448 end >> 16);
449 io_base_lo |= PCI_IO_RANGE_TYPE_32; 445 io_base_lo |= PCI_IO_RANGE_TYPE_32;
450 } else 446 else
451 io_base_lo |= PCI_IO_RANGE_TYPE_16; 447 io_base_lo |= PCI_IO_RANGE_TYPE_16;
448 pci_write_config_word(dev, PCI_IO_BASE_UPPER16,
449 start >> 16);
450 pci_write_config_word(dev, PCI_IO_LIMIT_UPPER16,
451 end >> 16);
452 pci_write_config_byte(dev, PCI_IO_BASE, io_base_lo); 452 pci_write_config_byte(dev, PCI_IO_BASE, io_base_lo);
453 pci_write_config_byte(dev, PCI_IO_LIMIT, io_limit_lo); 453 pci_write_config_byte(dev, PCI_IO_LIMIT, io_limit_lo);
454 454
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index 78d3c0fc8dfb..9bae8a5bf671 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -199,8 +199,14 @@ struct pci_controller * pcibios_alloc_controller(struct device_node *dev)
199 pci_setup_pci_controller(phb); 199 pci_setup_pci_controller(phb);
200 phb->arch_data = dev; 200 phb->arch_data = dev;
201 phb->is_dynamic = mem_init_done; 201 phb->is_dynamic = mem_init_done;
202 if (dev) 202 if (dev) {
203 PHB_SET_NODE(phb, of_node_to_nid(dev)); 203 int nid = of_node_to_nid(dev);
204
205 if (nid < 0 || !node_online(nid))
206 nid = -1;
207
208 PHB_SET_NODE(phb, nid);
209 }
204 return phb; 210 return phb;
205} 211}
206 212
diff --git a/arch/powerpc/kernel/perfmon_fsl_booke.c b/arch/powerpc/kernel/perfmon_fsl_booke.c
deleted file mode 100644
index e0dcf2b41fbe..000000000000
--- a/arch/powerpc/kernel/perfmon_fsl_booke.c
+++ /dev/null
@@ -1,221 +0,0 @@
1/* arch/powerpc/kernel/perfmon_fsl_booke.c
2 * Freescale Book-E Performance Monitor code
3 *
4 * Author: Andy Fleming
5 * Copyright (c) 2004 Freescale Semiconductor, Inc
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13#include <linux/errno.h>
14#include <linux/sched.h>
15#include <linux/kernel.h>
16#include <linux/mm.h>
17#include <linux/stddef.h>
18#include <linux/unistd.h>
19#include <linux/ptrace.h>
20#include <linux/slab.h>
21#include <linux/user.h>
22#include <linux/a.out.h>
23#include <linux/interrupt.h>
24#include <linux/init.h>
25#include <linux/module.h>
26#include <linux/prctl.h>
27
28#include <asm/pgtable.h>
29#include <asm/uaccess.h>
30#include <asm/system.h>
31#include <asm/io.h>
32#include <asm/reg.h>
33#include <asm/xmon.h>
34#include <asm/pmc.h>
35
36static inline u32 get_pmlca(int ctr);
37static inline void set_pmlca(int ctr, u32 pmlca);
38
39static inline u32 get_pmlca(int ctr)
40{
41 u32 pmlca;
42
43 switch (ctr) {
44 case 0:
45 pmlca = mfpmr(PMRN_PMLCA0);
46 break;
47 case 1:
48 pmlca = mfpmr(PMRN_PMLCA1);
49 break;
50 case 2:
51 pmlca = mfpmr(PMRN_PMLCA2);
52 break;
53 case 3:
54 pmlca = mfpmr(PMRN_PMLCA3);
55 break;
56 default:
57 panic("Bad ctr number\n");
58 }
59
60 return pmlca;
61}
62
63static inline void set_pmlca(int ctr, u32 pmlca)
64{
65 switch (ctr) {
66 case 0:
67 mtpmr(PMRN_PMLCA0, pmlca);
68 break;
69 case 1:
70 mtpmr(PMRN_PMLCA1, pmlca);
71 break;
72 case 2:
73 mtpmr(PMRN_PMLCA2, pmlca);
74 break;
75 case 3:
76 mtpmr(PMRN_PMLCA3, pmlca);
77 break;
78 default:
79 panic("Bad ctr number\n");
80 }
81}
82
83void init_pmc_stop(int ctr)
84{
85 u32 pmlca = (PMLCA_FC | PMLCA_FCS | PMLCA_FCU |
86 PMLCA_FCM1 | PMLCA_FCM0);
87 u32 pmlcb = 0;
88
89 switch (ctr) {
90 case 0:
91 mtpmr(PMRN_PMLCA0, pmlca);
92 mtpmr(PMRN_PMLCB0, pmlcb);
93 break;
94 case 1:
95 mtpmr(PMRN_PMLCA1, pmlca);
96 mtpmr(PMRN_PMLCB1, pmlcb);
97 break;
98 case 2:
99 mtpmr(PMRN_PMLCA2, pmlca);
100 mtpmr(PMRN_PMLCB2, pmlcb);
101 break;
102 case 3:
103 mtpmr(PMRN_PMLCA3, pmlca);
104 mtpmr(PMRN_PMLCB3, pmlcb);
105 break;
106 default:
107 panic("Bad ctr number!\n");
108 }
109}
110
111void set_pmc_event(int ctr, int event)
112{
113 u32 pmlca;
114
115 pmlca = get_pmlca(ctr);
116
117 pmlca = (pmlca & ~PMLCA_EVENT_MASK) |
118 ((event << PMLCA_EVENT_SHIFT) &
119 PMLCA_EVENT_MASK);
120
121 set_pmlca(ctr, pmlca);
122}
123
124void set_pmc_user_kernel(int ctr, int user, int kernel)
125{
126 u32 pmlca;
127
128 pmlca = get_pmlca(ctr);
129
130 if(user)
131 pmlca &= ~PMLCA_FCU;
132 else
133 pmlca |= PMLCA_FCU;
134
135 if(kernel)
136 pmlca &= ~PMLCA_FCS;
137 else
138 pmlca |= PMLCA_FCS;
139
140 set_pmlca(ctr, pmlca);
141}
142
143void set_pmc_marked(int ctr, int mark0, int mark1)
144{
145 u32 pmlca = get_pmlca(ctr);
146
147 if(mark0)
148 pmlca &= ~PMLCA_FCM0;
149 else
150 pmlca |= PMLCA_FCM0;
151
152 if(mark1)
153 pmlca &= ~PMLCA_FCM1;
154 else
155 pmlca |= PMLCA_FCM1;
156
157 set_pmlca(ctr, pmlca);
158}
159
160void pmc_start_ctr(int ctr, int enable)
161{
162 u32 pmlca = get_pmlca(ctr);
163
164 pmlca &= ~PMLCA_FC;
165
166 if (enable)
167 pmlca |= PMLCA_CE;
168 else
169 pmlca &= ~PMLCA_CE;
170
171 set_pmlca(ctr, pmlca);
172}
173
174void pmc_start_ctrs(int enable)
175{
176 u32 pmgc0 = mfpmr(PMRN_PMGC0);
177
178 pmgc0 &= ~PMGC0_FAC;
179 pmgc0 |= PMGC0_FCECE;
180
181 if (enable)
182 pmgc0 |= PMGC0_PMIE;
183 else
184 pmgc0 &= ~PMGC0_PMIE;
185
186 mtpmr(PMRN_PMGC0, pmgc0);
187}
188
189void pmc_stop_ctrs(void)
190{
191 u32 pmgc0 = mfpmr(PMRN_PMGC0);
192
193 pmgc0 |= PMGC0_FAC;
194
195 pmgc0 &= ~(PMGC0_PMIE | PMGC0_FCECE);
196
197 mtpmr(PMRN_PMGC0, pmgc0);
198}
199
200void dump_pmcs(void)
201{
202 printk("pmgc0: %x\n", mfpmr(PMRN_PMGC0));
203 printk("pmc\t\tpmlca\t\tpmlcb\n");
204 printk("%8x\t%8x\t%8x\n", mfpmr(PMRN_PMC0),
205 mfpmr(PMRN_PMLCA0), mfpmr(PMRN_PMLCB0));
206 printk("%8x\t%8x\t%8x\n", mfpmr(PMRN_PMC1),
207 mfpmr(PMRN_PMLCA1), mfpmr(PMRN_PMLCB1));
208 printk("%8x\t%8x\t%8x\n", mfpmr(PMRN_PMC2),
209 mfpmr(PMRN_PMLCA2), mfpmr(PMRN_PMLCB2));
210 printk("%8x\t%8x\t%8x\n", mfpmr(PMRN_PMC3),
211 mfpmr(PMRN_PMLCA3), mfpmr(PMRN_PMLCB3));
212}
213
214EXPORT_SYMBOL(init_pmc_stop);
215EXPORT_SYMBOL(set_pmc_event);
216EXPORT_SYMBOL(set_pmc_user_kernel);
217EXPORT_SYMBOL(set_pmc_marked);
218EXPORT_SYMBOL(pmc_start_ctr);
219EXPORT_SYMBOL(pmc_start_ctrs);
220EXPORT_SYMBOL(pmc_stop_ctrs);
221EXPORT_SYMBOL(dump_pmcs);
diff --git a/arch/powerpc/kernel/pmc.c b/arch/powerpc/kernel/pmc.c
index a0a2efadeabf..3d8f6f44641e 100644
--- a/arch/powerpc/kernel/pmc.c
+++ b/arch/powerpc/kernel/pmc.c
@@ -71,7 +71,7 @@ int reserve_pmc_hardware(perf_irq_t new_perf_irq)
71 } 71 }
72 72
73 pmc_owner_caller = __builtin_return_address(0); 73 pmc_owner_caller = __builtin_return_address(0);
74 perf_irq = new_perf_irq ? : dummy_perf; 74 perf_irq = new_perf_irq ? new_perf_irq : dummy_perf;
75 75
76 out: 76 out:
77 spin_unlock(&pmc_owner_lock); 77 spin_unlock(&pmc_owner_lock);
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 7b2f6452ba72..f3d4dd580dd6 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -341,13 +341,6 @@ struct task_struct *__switch_to(struct task_struct *prev,
341 341
342static int instructions_to_print = 16; 342static int instructions_to_print = 16;
343 343
344#ifdef CONFIG_PPC64
345#define BAD_PC(pc) ((REGION_ID(pc) != KERNEL_REGION_ID) && \
346 (REGION_ID(pc) != VMALLOC_REGION_ID))
347#else
348#define BAD_PC(pc) ((pc) < KERNELBASE)
349#endif
350
351static void show_instructions(struct pt_regs *regs) 344static void show_instructions(struct pt_regs *regs)
352{ 345{
353 int i; 346 int i;
@@ -366,7 +359,8 @@ static void show_instructions(struct pt_regs *regs)
366 * bad address because the pc *should* only be a 359 * bad address because the pc *should* only be a
367 * kernel address. 360 * kernel address.
368 */ 361 */
369 if (BAD_PC(pc) || __get_user(instr, (unsigned int __user *)pc)) { 362 if (!__kernel_text_address(pc) ||
363 __get_user(instr, (unsigned int __user *)pc)) {
370 printk("XXXXXXXX "); 364 printk("XXXXXXXX ");
371 } else { 365 } else {
372 if (regs->nip == pc) 366 if (regs->nip == pc)
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 865b9648d0d5..bdb412d4b748 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -1014,7 +1014,7 @@ EXPORT_SYMBOL(find_all_nodes);
1014/** Checks if the given "compat" string matches one of the strings in 1014/** Checks if the given "compat" string matches one of the strings in
1015 * the device's "compatible" property 1015 * the device's "compatible" property
1016 */ 1016 */
1017int device_is_compatible(struct device_node *device, const char *compat) 1017int device_is_compatible(const struct device_node *device, const char *compat)
1018{ 1018{
1019 const char* cp; 1019 const char* cp;
1020 int cplen, l; 1020 int cplen, l;
@@ -1491,7 +1491,8 @@ static int __init prom_reconfig_setup(void)
1491__initcall(prom_reconfig_setup); 1491__initcall(prom_reconfig_setup);
1492#endif 1492#endif
1493 1493
1494struct property *of_find_property(struct device_node *np, const char *name, 1494struct property *of_find_property(const struct device_node *np,
1495 const char *name,
1495 int *lenp) 1496 int *lenp)
1496{ 1497{
1497 struct property *pp; 1498 struct property *pp;
@@ -1512,7 +1513,8 @@ struct property *of_find_property(struct device_node *np, const char *name,
1512 * Find a property with a given name for a given node 1513 * Find a property with a given name for a given node
1513 * and return the value. 1514 * and return the value.
1514 */ 1515 */
1515const void *get_property(struct device_node *np, const char *name, int *lenp) 1516const void *get_property(const struct device_node *np, const char *name,
1517 int *lenp)
1516{ 1518{
1517 struct property *pp = of_find_property(np,name,lenp); 1519 struct property *pp = of_find_property(np,name,lenp);
1518 return pp ? pp->value : NULL; 1520 return pp ? pp->value : NULL;
diff --git a/arch/powerpc/kernel/rtas_flash.c b/arch/powerpc/kernel/rtas_flash.c
index 1442b63a75da..6f6fc977cb39 100644
--- a/arch/powerpc/kernel/rtas_flash.c
+++ b/arch/powerpc/kernel/rtas_flash.c
@@ -72,6 +72,10 @@
72#define VALIDATE_BUF_SIZE 4096 72#define VALIDATE_BUF_SIZE 4096
73#define RTAS_MSG_MAXLEN 64 73#define RTAS_MSG_MAXLEN 64
74 74
75/* Quirk - RTAS requires 4k list length and block size */
76#define RTAS_BLKLIST_LENGTH 4096
77#define RTAS_BLK_SIZE 4096
78
75struct flash_block { 79struct flash_block {
76 char *data; 80 char *data;
77 unsigned long length; 81 unsigned long length;
@@ -83,7 +87,7 @@ struct flash_block {
83 * into a version/length and translate the pointers 87 * into a version/length and translate the pointers
84 * to absolute. 88 * to absolute.
85 */ 89 */
86#define FLASH_BLOCKS_PER_NODE ((PAGE_SIZE - 16) / sizeof(struct flash_block)) 90#define FLASH_BLOCKS_PER_NODE ((RTAS_BLKLIST_LENGTH - 16) / sizeof(struct flash_block))
87struct flash_block_list { 91struct flash_block_list {
88 unsigned long num_blocks; 92 unsigned long num_blocks;
89 struct flash_block_list *next; 93 struct flash_block_list *next;
@@ -96,6 +100,9 @@ struct flash_block_list_header { /* just the header of flash_block_list */
96 100
97static struct flash_block_list_header rtas_firmware_flash_list = {0, NULL}; 101static struct flash_block_list_header rtas_firmware_flash_list = {0, NULL};
98 102
103/* Use slab cache to guarantee 4k alignment */
104static kmem_cache_t *flash_block_cache = NULL;
105
99#define FLASH_BLOCK_LIST_VERSION (1UL) 106#define FLASH_BLOCK_LIST_VERSION (1UL)
100 107
101/* Local copy of the flash block list. 108/* Local copy of the flash block list.
@@ -153,7 +160,7 @@ static int flash_list_valid(struct flash_block_list *flist)
153 return FLASH_IMG_NULL_DATA; 160 return FLASH_IMG_NULL_DATA;
154 } 161 }
155 block_size = f->blocks[i].length; 162 block_size = f->blocks[i].length;
156 if (block_size <= 0 || block_size > PAGE_SIZE) { 163 if (block_size <= 0 || block_size > RTAS_BLK_SIZE) {
157 return FLASH_IMG_BAD_LEN; 164 return FLASH_IMG_BAD_LEN;
158 } 165 }
159 image_size += block_size; 166 image_size += block_size;
@@ -177,9 +184,9 @@ static void free_flash_list(struct flash_block_list *f)
177 184
178 while (f) { 185 while (f) {
179 for (i = 0; i < f->num_blocks; i++) 186 for (i = 0; i < f->num_blocks; i++)
180 free_page((unsigned long)(f->blocks[i].data)); 187 kmem_cache_free(flash_block_cache, f->blocks[i].data);
181 next = f->next; 188 next = f->next;
182 free_page((unsigned long)f); 189 kmem_cache_free(flash_block_cache, f);
183 f = next; 190 f = next;
184 } 191 }
185} 192}
@@ -278,6 +285,12 @@ static ssize_t rtas_flash_read(struct file *file, char __user *buf,
278 return msglen; 285 return msglen;
279} 286}
280 287
288/* constructor for flash_block_cache */
289void rtas_block_ctor(void *ptr, kmem_cache_t *cache, unsigned long flags)
290{
291 memset(ptr, 0, RTAS_BLK_SIZE);
292}
293
281/* We could be much more efficient here. But to keep this function 294/* We could be much more efficient here. But to keep this function
282 * simple we allocate a page to the block list no matter how small the 295 * simple we allocate a page to the block list no matter how small the
283 * count is. If the system is low on memory it will be just as well 296 * count is. If the system is low on memory it will be just as well
@@ -302,7 +315,7 @@ static ssize_t rtas_flash_write(struct file *file, const char __user *buffer,
302 * proc file 315 * proc file
303 */ 316 */
304 if (uf->flist == NULL) { 317 if (uf->flist == NULL) {
305 uf->flist = (struct flash_block_list *) get_zeroed_page(GFP_KERNEL); 318 uf->flist = kmem_cache_alloc(flash_block_cache, GFP_KERNEL);
306 if (!uf->flist) 319 if (!uf->flist)
307 return -ENOMEM; 320 return -ENOMEM;
308 } 321 }
@@ -313,21 +326,21 @@ static ssize_t rtas_flash_write(struct file *file, const char __user *buffer,
313 next_free = fl->num_blocks; 326 next_free = fl->num_blocks;
314 if (next_free == FLASH_BLOCKS_PER_NODE) { 327 if (next_free == FLASH_BLOCKS_PER_NODE) {
315 /* Need to allocate another block_list */ 328 /* Need to allocate another block_list */
316 fl->next = (struct flash_block_list *)get_zeroed_page(GFP_KERNEL); 329 fl->next = kmem_cache_alloc(flash_block_cache, GFP_KERNEL);
317 if (!fl->next) 330 if (!fl->next)
318 return -ENOMEM; 331 return -ENOMEM;
319 fl = fl->next; 332 fl = fl->next;
320 next_free = 0; 333 next_free = 0;
321 } 334 }
322 335
323 if (count > PAGE_SIZE) 336 if (count > RTAS_BLK_SIZE)
324 count = PAGE_SIZE; 337 count = RTAS_BLK_SIZE;
325 p = (char *)get_zeroed_page(GFP_KERNEL); 338 p = kmem_cache_alloc(flash_block_cache, GFP_KERNEL);
326 if (!p) 339 if (!p)
327 return -ENOMEM; 340 return -ENOMEM;
328 341
329 if(copy_from_user(p, buffer, count)) { 342 if(copy_from_user(p, buffer, count)) {
330 free_page((unsigned long)p); 343 kmem_cache_free(flash_block_cache, p);
331 return -EFAULT; 344 return -EFAULT;
332 } 345 }
333 fl->blocks[next_free].data = p; 346 fl->blocks[next_free].data = p;
@@ -791,6 +804,16 @@ int __init rtas_flash_init(void)
791 goto cleanup; 804 goto cleanup;
792 805
793 rtas_flash_term_hook = rtas_flash_firmware; 806 rtas_flash_term_hook = rtas_flash_firmware;
807
808 flash_block_cache = kmem_cache_create("rtas_flash_cache",
809 RTAS_BLK_SIZE, RTAS_BLK_SIZE, 0,
810 rtas_block_ctor, NULL);
811 if (!flash_block_cache) {
812 printk(KERN_ERR "%s: failed to create block cache\n",
813 __FUNCTION__);
814 rc = -ENOMEM;
815 goto cleanup;
816 }
794 return 0; 817 return 0;
795 818
796cleanup: 819cleanup:
@@ -805,6 +828,10 @@ cleanup:
805void __exit rtas_flash_cleanup(void) 828void __exit rtas_flash_cleanup(void)
806{ 829{
807 rtas_flash_term_hook = NULL; 830 rtas_flash_term_hook = NULL;
831
832 if (flash_block_cache)
833 kmem_cache_destroy(flash_block_cache);
834
808 remove_flash_pde(firmware_flash_pde); 835 remove_flash_pde(firmware_flash_pde);
809 remove_flash_pde(firmware_update_pde); 836 remove_flash_pde(firmware_update_pde);
810 remove_flash_pde(validate_pde); 837 remove_flash_pde(validate_pde);
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index 191d0ab09222..a4c2964a3ca6 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -91,6 +91,7 @@ int ucache_bsize;
91unsigned long __init early_init(unsigned long dt_ptr) 91unsigned long __init early_init(unsigned long dt_ptr)
92{ 92{
93 unsigned long offset = reloc_offset(); 93 unsigned long offset = reloc_offset();
94 struct cpu_spec *spec;
94 95
95 /* First zero the BSS -- use memset_io, some platforms don't have 96 /* First zero the BSS -- use memset_io, some platforms don't have
96 * caches on yet */ 97 * caches on yet */
@@ -100,8 +101,11 @@ unsigned long __init early_init(unsigned long dt_ptr)
100 * Identify the CPU type and fix up code sections 101 * Identify the CPU type and fix up code sections
101 * that depend on which cpu we have. 102 * that depend on which cpu we have.
102 */ 103 */
103 identify_cpu(offset, 0); 104 spec = identify_cpu(offset);
104 do_cpu_ftr_fixups(offset); 105
106 do_feature_fixups(spec->cpu_features,
107 PTRRELOC(&__start___ftr_fixup),
108 PTRRELOC(&__stop___ftr_fixup));
105 109
106 return KERNELBASE + offset; 110 return KERNELBASE + offset;
107} 111}
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 4b2e32eab9dc..16278968dab6 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -170,6 +170,9 @@ void __init setup_paca(int cpu)
170 170
171void __init early_setup(unsigned long dt_ptr) 171void __init early_setup(unsigned long dt_ptr)
172{ 172{
173 /* Identify CPU type */
174 identify_cpu(0);
175
173 /* Assume we're on cpu 0 for now. Don't write to the paca yet! */ 176 /* Assume we're on cpu 0 for now. Don't write to the paca yet! */
174 setup_paca(0); 177 setup_paca(0);
175 178
@@ -348,6 +351,14 @@ void __init setup_system(void)
348{ 351{
349 DBG(" -> setup_system()\n"); 352 DBG(" -> setup_system()\n");
350 353
354 /* Apply the CPUs-specific and firmware specific fixups to kernel
355 * text (nop out sections not relevant to this CPU or this firmware)
356 */
357 do_feature_fixups(cur_cpu_spec->cpu_features,
358 &__start___ftr_fixup, &__stop___ftr_fixup);
359 do_feature_fixups(powerpc_firmware_features,
360 &__start___fw_ftr_fixup, &__stop___fw_ftr_fixup);
361
351 /* 362 /*
352 * Unflatten the device-tree passed by prom_init or kexec 363 * Unflatten the device-tree passed by prom_init or kexec
353 */ 364 */
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 5b59bc18dfe7..46a24de36fec 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -220,11 +220,8 @@ static void account_process_time(struct pt_regs *regs)
220 */ 220 */
221struct cpu_purr_data { 221struct cpu_purr_data {
222 int initialized; /* thread is running */ 222 int initialized; /* thread is running */
223 u64 tb0; /* timebase at origin time */
224 u64 purr0; /* PURR at origin time */
225 u64 tb; /* last TB value read */ 223 u64 tb; /* last TB value read */
226 u64 purr; /* last PURR value read */ 224 u64 purr; /* last PURR value read */
227 u64 stolen; /* stolen time so far */
228 spinlock_t lock; 225 spinlock_t lock;
229}; 226};
230 227
@@ -234,10 +231,8 @@ static void snapshot_tb_and_purr(void *data)
234{ 231{
235 struct cpu_purr_data *p = &__get_cpu_var(cpu_purr_data); 232 struct cpu_purr_data *p = &__get_cpu_var(cpu_purr_data);
236 233
237 p->tb0 = mftb(); 234 p->tb = mftb();
238 p->purr0 = mfspr(SPRN_PURR); 235 p->purr = mfspr(SPRN_PURR);
239 p->tb = p->tb0;
240 p->purr = 0;
241 wmb(); 236 wmb();
242 p->initialized = 1; 237 p->initialized = 1;
243} 238}
@@ -258,37 +253,24 @@ void snapshot_timebases(void)
258 253
259void calculate_steal_time(void) 254void calculate_steal_time(void)
260{ 255{
261 u64 tb, purr, t0; 256 u64 tb, purr;
262 s64 stolen; 257 s64 stolen;
263 struct cpu_purr_data *p0, *pme, *phim; 258 struct cpu_purr_data *pme;
264 int cpu;
265 259
266 if (!cpu_has_feature(CPU_FTR_PURR)) 260 if (!cpu_has_feature(CPU_FTR_PURR))
267 return; 261 return;
268 cpu = smp_processor_id(); 262 pme = &per_cpu(cpu_purr_data, smp_processor_id());
269 pme = &per_cpu(cpu_purr_data, cpu);
270 if (!pme->initialized) 263 if (!pme->initialized)
271 return; /* this can happen in early boot */ 264 return; /* this can happen in early boot */
272 p0 = &per_cpu(cpu_purr_data, cpu & ~1); 265 spin_lock(&pme->lock);
273 phim = &per_cpu(cpu_purr_data, cpu ^ 1);
274 spin_lock(&p0->lock);
275 tb = mftb(); 266 tb = mftb();
276 purr = mfspr(SPRN_PURR) - pme->purr0; 267 purr = mfspr(SPRN_PURR);
277 if (!phim->initialized || !cpu_online(cpu ^ 1)) { 268 stolen = (tb - pme->tb) - (purr - pme->purr);
278 stolen = (tb - pme->tb) - (purr - pme->purr); 269 if (stolen > 0)
279 } else {
280 t0 = pme->tb0;
281 if (phim->tb0 < t0)
282 t0 = phim->tb0;
283 stolen = phim->tb - t0 - phim->purr - purr - p0->stolen;
284 }
285 if (stolen > 0) {
286 account_steal_time(current, stolen); 270 account_steal_time(current, stolen);
287 p0->stolen += stolen;
288 }
289 pme->tb = tb; 271 pme->tb = tb;
290 pme->purr = purr; 272 pme->purr = purr;
291 spin_unlock(&p0->lock); 273 spin_unlock(&pme->lock);
292} 274}
293 275
294/* 276/*
@@ -297,30 +279,17 @@ void calculate_steal_time(void)
297 */ 279 */
298static void snapshot_purr(void) 280static void snapshot_purr(void)
299{ 281{
300 int cpu; 282 struct cpu_purr_data *pme;
301 u64 purr;
302 struct cpu_purr_data *p0, *pme, *phim;
303 unsigned long flags; 283 unsigned long flags;
304 284
305 if (!cpu_has_feature(CPU_FTR_PURR)) 285 if (!cpu_has_feature(CPU_FTR_PURR))
306 return; 286 return;
307 cpu = smp_processor_id(); 287 pme = &per_cpu(cpu_purr_data, smp_processor_id());
308 pme = &per_cpu(cpu_purr_data, cpu); 288 spin_lock_irqsave(&pme->lock, flags);
309 p0 = &per_cpu(cpu_purr_data, cpu & ~1); 289 pme->tb = mftb();
310 phim = &per_cpu(cpu_purr_data, cpu ^ 1); 290 pme->purr = mfspr(SPRN_PURR);
311 spin_lock_irqsave(&p0->lock, flags);
312 pme->tb = pme->tb0 = mftb();
313 purr = mfspr(SPRN_PURR);
314 if (!phim->initialized) {
315 pme->purr = 0;
316 pme->purr0 = purr;
317 } else {
318 /* set p->purr and p->purr0 for no change in p0->stolen */
319 pme->purr = phim->tb - phim->tb0 - phim->purr - p0->stolen;
320 pme->purr0 = purr - pme->purr;
321 }
322 pme->initialized = 1; 291 pme->initialized = 1;
323 spin_unlock_irqrestore(&p0->lock, flags); 292 spin_unlock_irqrestore(&pme->lock, flags);
324} 293}
325 294
326#endif /* CONFIG_PPC_SPLPAR */ 295#endif /* CONFIG_PPC_SPLPAR */
@@ -1045,48 +1014,6 @@ void __init time_init(void)
1045 set_dec(tb_ticks_per_jiffy); 1014 set_dec(tb_ticks_per_jiffy);
1046} 1015}
1047 1016
1048#ifdef CONFIG_RTC_CLASS
1049static int set_rtc_class_time(struct rtc_time *tm)
1050{
1051 int err;
1052 struct class_device *class_dev =
1053 rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
1054
1055 if (class_dev == NULL)
1056 return -ENODEV;
1057
1058 err = rtc_set_time(class_dev, tm);
1059
1060 rtc_class_close(class_dev);
1061
1062 return 0;
1063}
1064
1065static void get_rtc_class_time(struct rtc_time *tm)
1066{
1067 int err;
1068 struct class_device *class_dev =
1069 rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
1070
1071 if (class_dev == NULL)
1072 return;
1073
1074 err = rtc_read_time(class_dev, tm);
1075
1076 rtc_class_close(class_dev);
1077
1078 return;
1079}
1080
1081int __init rtc_class_hookup(void)
1082{
1083 ppc_md.get_rtc_time = get_rtc_class_time;
1084 ppc_md.set_rtc_time = set_rtc_class_time;
1085
1086 return 0;
1087}
1088#endif /* CONFIG_RTC_CLASS */
1089
1090 1017
1091#define FEBRUARY 2 1018#define FEBRUARY 2
1092#define STARTOFTIME 1970 1019#define STARTOFTIME 1970
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index d9f10f2fc372..c66b4771ef44 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -843,7 +843,7 @@ void __kprobes program_check_exception(struct pt_regs *regs)
843 843
844void alignment_exception(struct pt_regs *regs) 844void alignment_exception(struct pt_regs *regs)
845{ 845{
846 int fixed = 0; 846 int sig, code, fixed = 0;
847 847
848 /* we don't implement logging of alignment exceptions */ 848 /* we don't implement logging of alignment exceptions */
849 if (!(current->thread.align_ctl & PR_UNALIGN_SIGBUS)) 849 if (!(current->thread.align_ctl & PR_UNALIGN_SIGBUS))
@@ -857,14 +857,16 @@ void alignment_exception(struct pt_regs *regs)
857 857
858 /* Operand address was bad */ 858 /* Operand address was bad */
859 if (fixed == -EFAULT) { 859 if (fixed == -EFAULT) {
860 if (user_mode(regs)) 860 sig = SIGSEGV;
861 _exception(SIGSEGV, regs, SEGV_ACCERR, regs->dar); 861 code = SEGV_ACCERR;
862 else 862 } else {
863 /* Search exception table */ 863 sig = SIGBUS;
864 bad_page_fault(regs, regs->dar, SIGSEGV); 864 code = BUS_ADRALN;
865 return;
866 } 865 }
867 _exception(SIGBUS, regs, BUS_ADRALN, regs->dar); 866 if (user_mode(regs))
867 _exception(sig, regs, code, regs->dar);
868 else
869 bad_page_fault(regs, regs->dar, sig);
868} 870}
869 871
870void StackOverflow(struct pt_regs *regs) 872void StackOverflow(struct pt_regs *regs)
@@ -900,14 +902,13 @@ void kernel_fp_unavailable_exception(struct pt_regs *regs)
900 902
901void altivec_unavailable_exception(struct pt_regs *regs) 903void altivec_unavailable_exception(struct pt_regs *regs)
902{ 904{
903#if !defined(CONFIG_ALTIVEC)
904 if (user_mode(regs)) { 905 if (user_mode(regs)) {
905 /* A user program has executed an altivec instruction, 906 /* A user program has executed an altivec instruction,
906 but this kernel doesn't support altivec. */ 907 but this kernel doesn't support altivec. */
907 _exception(SIGILL, regs, ILL_ILLOPC, regs->nip); 908 _exception(SIGILL, regs, ILL_ILLOPC, regs->nip);
908 return; 909 return;
909 } 910 }
910#endif 911
911 printk(KERN_EMERG "Unrecoverable VMX/Altivec Unavailable Exception " 912 printk(KERN_EMERG "Unrecoverable VMX/Altivec Unavailable Exception "
912 "%lx at %lx\n", regs->trap, regs->nip); 913 "%lx at %lx\n", regs->trap, regs->nip);
913 die("Unrecoverable VMX/Altivec Unavailable Exception", regs, SIGABRT); 914 die("Unrecoverable VMX/Altivec Unavailable Exception", regs, SIGABRT);
diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
index 1a7e19cdab39..c913ad5cad29 100644
--- a/arch/powerpc/kernel/vdso.c
+++ b/arch/powerpc/kernel/vdso.c
@@ -36,6 +36,8 @@
36#include <asm/vdso.h> 36#include <asm/vdso.h>
37#include <asm/vdso_datapage.h> 37#include <asm/vdso_datapage.h>
38 38
39#include "setup.h"
40
39#undef DEBUG 41#undef DEBUG
40 42
41#ifdef DEBUG 43#ifdef DEBUG
@@ -586,6 +588,43 @@ static __init int vdso_fixup_datapage(struct lib32_elfinfo *v32,
586 return 0; 588 return 0;
587} 589}
588 590
591
592static __init int vdso_fixup_features(struct lib32_elfinfo *v32,
593 struct lib64_elfinfo *v64)
594{
595 void *start32;
596 unsigned long size32;
597
598#ifdef CONFIG_PPC64
599 void *start64;
600 unsigned long size64;
601
602 start64 = find_section64(v64->hdr, "__ftr_fixup", &size64);
603 if (start64)
604 do_feature_fixups(cur_cpu_spec->cpu_features,
605 start64, start64 + size64);
606
607 start64 = find_section64(v64->hdr, "__fw_ftr_fixup", &size64);
608 if (start64)
609 do_feature_fixups(powerpc_firmware_features,
610 start64, start64 + size64);
611#endif /* CONFIG_PPC64 */
612
613 start32 = find_section32(v32->hdr, "__ftr_fixup", &size32);
614 if (start32)
615 do_feature_fixups(cur_cpu_spec->cpu_features,
616 start32, start32 + size32);
617
618#ifdef CONFIG_PPC64
619 start32 = find_section32(v32->hdr, "__fw_ftr_fixup", &size32);
620 if (start32)
621 do_feature_fixups(powerpc_firmware_features,
622 start32, start32 + size32);
623#endif /* CONFIG_PPC64 */
624
625 return 0;
626}
627
589static __init int vdso_fixup_alt_funcs(struct lib32_elfinfo *v32, 628static __init int vdso_fixup_alt_funcs(struct lib32_elfinfo *v32,
590 struct lib64_elfinfo *v64) 629 struct lib64_elfinfo *v64)
591{ 630{
@@ -634,6 +673,9 @@ static __init int vdso_setup(void)
634 if (vdso_fixup_datapage(&v32, &v64)) 673 if (vdso_fixup_datapage(&v32, &v64))
635 return -1; 674 return -1;
636 675
676 if (vdso_fixup_features(&v32, &v64))
677 return -1;
678
637 if (vdso_fixup_alt_funcs(&v32, &v64)) 679 if (vdso_fixup_alt_funcs(&v32, &v64))
638 return -1; 680 return -1;
639 681
@@ -714,6 +756,7 @@ void __init vdso_init(void)
714 * Setup the syscall map in the vDOS 756 * Setup the syscall map in the vDOS
715 */ 757 */
716 vdso_setup_syscall_map(); 758 vdso_setup_syscall_map();
759
717 /* 760 /*
718 * Initialize the vDSO images in memory, that is do necessary 761 * Initialize the vDSO images in memory, that is do necessary
719 * fixups of vDSO symbols, locate trampolines, etc... 762 * fixups of vDSO symbols, locate trampolines, etc...
diff --git a/arch/powerpc/kernel/vdso32/vdso32.lds.S b/arch/powerpc/kernel/vdso32/vdso32.lds.S
index 6187af2d54c3..26e138c4ce17 100644
--- a/arch/powerpc/kernel/vdso32/vdso32.lds.S
+++ b/arch/powerpc/kernel/vdso32/vdso32.lds.S
@@ -32,6 +32,18 @@ SECTIONS
32 PROVIDE (_etext = .); 32 PROVIDE (_etext = .);
33 PROVIDE (etext = .); 33 PROVIDE (etext = .);
34 34
35 . = ALIGN(8);
36 __ftr_fixup : {
37 *(__ftr_fixup)
38 }
39
40#ifdef CONFIG_PPC64
41 . = ALIGN(8);
42 __fw_ftr_fixup : {
43 *(__fw_ftr_fixup)
44 }
45#endif
46
35 /* Other stuff is appended to the text segment: */ 47 /* Other stuff is appended to the text segment: */
36 .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } 48 .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
37 .rodata1 : { *(.rodata1) } 49 .rodata1 : { *(.rodata1) }
diff --git a/arch/powerpc/kernel/vdso64/gettimeofday.S b/arch/powerpc/kernel/vdso64/gettimeofday.S
index 56e76ff5498f..40ffd9b6cef7 100644
--- a/arch/powerpc/kernel/vdso64/gettimeofday.S
+++ b/arch/powerpc/kernel/vdso64/gettimeofday.S
@@ -229,8 +229,10 @@ V_FUNCTION_BEGIN(__do_get_xsec)
229 xor r0,r8,r8 /* create dependency */ 229 xor r0,r8,r8 /* create dependency */
230 add r3,r3,r0 230 add r3,r3,r0
231 231
232 /* Get TB & offset it */ 232 /* Get TB & offset it. We use the MFTB macro which will generate
233 mftb r7 233 * workaround code for Cell.
234 */
235 MFTB(r7)
234 ld r9,CFG_TB_ORIG_STAMP(r3) 236 ld r9,CFG_TB_ORIG_STAMP(r3)
235 subf r7,r9,r7 237 subf r7,r9,r7
236 238
diff --git a/arch/powerpc/kernel/vdso64/vdso64.lds.S b/arch/powerpc/kernel/vdso64/vdso64.lds.S
index 4a2b6dc0960c..2d70f35d50b5 100644
--- a/arch/powerpc/kernel/vdso64/vdso64.lds.S
+++ b/arch/powerpc/kernel/vdso64/vdso64.lds.S
@@ -31,6 +31,16 @@ SECTIONS
31 PROVIDE (_etext = .); 31 PROVIDE (_etext = .);
32 PROVIDE (etext = .); 32 PROVIDE (etext = .);
33 33
34 . = ALIGN(8);
35 __ftr_fixup : {
36 *(__ftr_fixup)
37 }
38
39 . = ALIGN(8);
40 __fw_ftr_fixup : {
41 *(__fw_ftr_fixup)
42 }
43
34 /* Other stuff is appended to the text segment: */ 44 /* Other stuff is appended to the text segment: */
35 .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } 45 .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
36 .rodata1 : { *(.rodata1) } 46 .rodata1 : { *(.rodata1) }
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index cb87e71eec66..ed007878d1bf 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -92,9 +92,9 @@ static struct iommu_table *vio_build_iommu_table(struct vio_dev *dev)
92 &tbl->it_index, &offset, &size); 92 &tbl->it_index, &offset, &size);
93 93
94 /* TCE table size - measured in tce entries */ 94 /* TCE table size - measured in tce entries */
95 tbl->it_size = size >> PAGE_SHIFT; 95 tbl->it_size = size >> IOMMU_PAGE_SHIFT;
96 /* offset for VIO should always be 0 */ 96 /* offset for VIO should always be 0 */
97 tbl->it_offset = offset >> PAGE_SHIFT; 97 tbl->it_offset = offset >> IOMMU_PAGE_SHIFT;
98 tbl->it_busno = 0; 98 tbl->it_busno = 0;
99 tbl->it_type = TCE_VB; 99 tbl->it_type = TCE_VB;
100 100
diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index cb0e8d46c3e8..e8342d867536 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -108,13 +108,7 @@ SECTIONS
108 108
109 .initcall.init : { 109 .initcall.init : {
110 __initcall_start = .; 110 __initcall_start = .;
111 *(.initcall1.init) 111 INITCALLS
112 *(.initcall2.init)
113 *(.initcall3.init)
114 *(.initcall4.init)
115 *(.initcall5.init)
116 *(.initcall6.init)
117 *(.initcall7.init)
118 __initcall_end = .; 112 __initcall_end = .;
119 } 113 }
120 114
diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index 9590ba780b98..7e8ded051b5b 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -9,6 +9,7 @@
9 * 2 of the License, or (at your option) any later version. 9 * 2 of the License, or (at your option) any later version.
10 */ 10 */
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/kprobes.h>
12#include <linux/ptrace.h> 13#include <linux/ptrace.h>
13#include <asm/sstep.h> 14#include <asm/sstep.h>
14#include <asm/processor.h> 15#include <asm/processor.h>
@@ -25,7 +26,7 @@ extern char system_call_common[];
25/* 26/*
26 * Determine whether a conditional branch instruction would branch. 27 * Determine whether a conditional branch instruction would branch.
27 */ 28 */
28static int branch_taken(unsigned int instr, struct pt_regs *regs) 29static int __kprobes branch_taken(unsigned int instr, struct pt_regs *regs)
29{ 30{
30 unsigned int bo = (instr >> 21) & 0x1f; 31 unsigned int bo = (instr >> 21) & 0x1f;
31 unsigned int bi; 32 unsigned int bi;
@@ -51,7 +52,7 @@ static int branch_taken(unsigned int instr, struct pt_regs *regs)
51 * or -1 if the instruction is one that should not be stepped, 52 * or -1 if the instruction is one that should not be stepped,
52 * such as an rfid, or a mtmsrd that would clear MSR_RI. 53 * such as an rfid, or a mtmsrd that would clear MSR_RI.
53 */ 54 */
54int emulate_step(struct pt_regs *regs, unsigned int instr) 55int __kprobes emulate_step(struct pt_regs *regs, unsigned int instr)
55{ 56{
56 unsigned int opcode, rd; 57 unsigned int opcode, rd;
57 unsigned long int imm; 58 unsigned long int imm;
diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
index 5615acc29527..506d89768d45 100644
--- a/arch/powerpc/mm/hugetlbpage.c
+++ b/arch/powerpc/mm/hugetlbpage.c
@@ -480,9 +480,6 @@ static int open_high_hpage_areas(struct mm_struct *mm, u16 newareas)
480 480
481 mm->context.high_htlb_areas |= newareas; 481 mm->context.high_htlb_areas |= newareas;
482 482
483 /* update the paca copy of the context struct */
484 get_paca()->context = mm->context;
485
486 /* the context change must make it to memory before the flush, 483 /* the context change must make it to memory before the flush,
487 * so that further SLB misses do the right thing. */ 484 * so that further SLB misses do the right thing. */
488 mb(); 485 mb();
@@ -494,11 +491,15 @@ static int open_high_hpage_areas(struct mm_struct *mm, u16 newareas)
494 return 0; 491 return 0;
495} 492}
496 493
497int prepare_hugepage_range(unsigned long addr, unsigned long len) 494int prepare_hugepage_range(unsigned long addr, unsigned long len, pgoff_t pgoff)
498{ 495{
499 int err = 0; 496 int err = 0;
500 497
501 if ( (addr+len) < addr ) 498 if (pgoff & (~HPAGE_MASK >> PAGE_SHIFT))
499 return -EINVAL;
500 if (len & ~HPAGE_MASK)
501 return -EINVAL;
502 if (addr & ~HPAGE_MASK)
502 return -EINVAL; 503 return -EINVAL;
503 504
504 if (addr < 0x100000000UL) 505 if (addr < 0x100000000UL)
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 16fe027bbc12..d1c0758c5611 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -307,11 +307,12 @@ void __init paging_init(void)
307 top_of_ram, total_ram); 307 top_of_ram, total_ram);
308 printk(KERN_DEBUG "Memory hole size: %ldMB\n", 308 printk(KERN_DEBUG "Memory hole size: %ldMB\n",
309 (top_of_ram - total_ram) >> 20); 309 (top_of_ram - total_ram) >> 20);
310 memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
310#ifdef CONFIG_HIGHMEM 311#ifdef CONFIG_HIGHMEM
311 max_zone_pfns[0] = total_lowmem >> PAGE_SHIFT; 312 max_zone_pfns[ZONE_DMA] = total_lowmem >> PAGE_SHIFT;
312 max_zone_pfns[1] = top_of_ram >> PAGE_SHIFT; 313 max_zone_pfns[ZONE_HIGHMEM] = top_of_ram >> PAGE_SHIFT;
313#else 314#else
314 max_zone_pfns[0] = top_of_ram >> PAGE_SHIFT; 315 max_zone_pfns[ZONE_DMA] = top_of_ram >> PAGE_SHIFT;
315#endif 316#endif
316 free_area_init_nodes(max_zone_pfns); 317 free_area_init_nodes(max_zone_pfns);
317} 318}
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 43c272075e1a..9da01dc8cfd9 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -617,9 +617,9 @@ void __init do_init_bootmem(void)
617 617
618void __init paging_init(void) 618void __init paging_init(void)
619{ 619{
620 unsigned long max_zone_pfns[MAX_NR_ZONES] = { 620 unsigned long max_zone_pfns[MAX_NR_ZONES];
621 lmb_end_of_DRAM() >> PAGE_SHIFT 621 memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
622 }; 622 max_zone_pfns[ZONE_DMA] = lmb_end_of_DRAM() >> PAGE_SHIFT;
623 free_area_init_nodes(max_zone_pfns); 623 free_area_init_nodes(max_zone_pfns);
624} 624}
625 625
diff --git a/arch/powerpc/oprofile/Makefile b/arch/powerpc/oprofile/Makefile
index 3145d610b5b0..0b5df9c96ae0 100644
--- a/arch/powerpc/oprofile/Makefile
+++ b/arch/powerpc/oprofile/Makefile
@@ -13,4 +13,4 @@ DRIVER_OBJS := $(addprefix ../../../drivers/oprofile/, \
13oprofile-y := $(DRIVER_OBJS) common.o backtrace.o 13oprofile-y := $(DRIVER_OBJS) common.o backtrace.o
14oprofile-$(CONFIG_PPC64) += op_model_rs64.o op_model_power4.o 14oprofile-$(CONFIG_PPC64) += op_model_rs64.o op_model_power4.o
15oprofile-$(CONFIG_FSL_BOOKE) += op_model_fsl_booke.o 15oprofile-$(CONFIG_FSL_BOOKE) += op_model_fsl_booke.o
16oprofile-$(CONFIG_PPC32) += op_model_7450.o 16oprofile-$(CONFIG_6xx) += op_model_7450.o
diff --git a/arch/powerpc/oprofile/common.c b/arch/powerpc/oprofile/common.c
index fd0bbbe7a4de..63bbef3b63f1 100644
--- a/arch/powerpc/oprofile/common.c
+++ b/arch/powerpc/oprofile/common.c
@@ -34,6 +34,11 @@ static void op_handle_interrupt(struct pt_regs *regs)
34 model->handle_interrupt(regs, ctr); 34 model->handle_interrupt(regs, ctr);
35} 35}
36 36
37static void op_powerpc_cpu_setup(void *dummy)
38{
39 model->cpu_setup(ctr);
40}
41
37static int op_powerpc_setup(void) 42static int op_powerpc_setup(void)
38{ 43{
39 int err; 44 int err;
@@ -47,7 +52,7 @@ static int op_powerpc_setup(void)
47 model->reg_setup(ctr, &sys, model->num_counters); 52 model->reg_setup(ctr, &sys, model->num_counters);
48 53
49 /* Configure the registers on all cpus. */ 54 /* Configure the registers on all cpus. */
50 on_each_cpu(model->cpu_setup, NULL, 0, 1); 55 on_each_cpu(op_powerpc_cpu_setup, NULL, 0, 1);
51 56
52 return 0; 57 return 0;
53} 58}
@@ -142,7 +147,8 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)
142 case PPC_OPROFILE_POWER4: 147 case PPC_OPROFILE_POWER4:
143 model = &op_model_power4; 148 model = &op_model_power4;
144 break; 149 break;
145#else 150#endif
151#ifdef CONFIG_6xx
146 case PPC_OPROFILE_G4: 152 case PPC_OPROFILE_G4:
147 model = &op_model_7450; 153 model = &op_model_7450;
148 break; 154 break;
diff --git a/arch/powerpc/oprofile/op_model_7450.c b/arch/powerpc/oprofile/op_model_7450.c
index d8ee3aea83f8..f481c0ed5e67 100644
--- a/arch/powerpc/oprofile/op_model_7450.c
+++ b/arch/powerpc/oprofile/op_model_7450.c
@@ -81,7 +81,7 @@ static void pmc_stop_ctrs(void)
81 81
82/* Configures the counters on this CPU based on the global 82/* Configures the counters on this CPU based on the global
83 * settings */ 83 * settings */
84static void fsl7450_cpu_setup(void *unused) 84static void fsl7450_cpu_setup(struct op_counter_config *ctr)
85{ 85{
86 /* freeze all counters */ 86 /* freeze all counters */
87 pmc_stop_ctrs(); 87 pmc_stop_ctrs();
diff --git a/arch/powerpc/oprofile/op_model_fsl_booke.c b/arch/powerpc/oprofile/op_model_fsl_booke.c
index e29dede31423..0b3c31f5209e 100644
--- a/arch/powerpc/oprofile/op_model_fsl_booke.c
+++ b/arch/powerpc/oprofile/op_model_fsl_booke.c
@@ -32,42 +32,152 @@ static unsigned long reset_value[OP_MAX_COUNTER];
32static int num_counters; 32static int num_counters;
33static int oprofile_running; 33static int oprofile_running;
34 34
35static inline unsigned int ctr_read(unsigned int i) 35static void init_pmc_stop(int ctr)
36{ 36{
37 switch(i) { 37 u32 pmlca = (PMLCA_FC | PMLCA_FCS | PMLCA_FCU |
38 case 0: 38 PMLCA_FCM1 | PMLCA_FCM0);
39 return mfpmr(PMRN_PMC0); 39 u32 pmlcb = 0;
40 case 1:
41 return mfpmr(PMRN_PMC1);
42 case 2:
43 return mfpmr(PMRN_PMC2);
44 case 3:
45 return mfpmr(PMRN_PMC3);
46 default:
47 return 0;
48 }
49}
50 40
51static inline void ctr_write(unsigned int i, unsigned int val) 41 switch (ctr) {
52{
53 switch(i) {
54 case 0: 42 case 0:
55 mtpmr(PMRN_PMC0, val); 43 mtpmr(PMRN_PMLCA0, pmlca);
44 mtpmr(PMRN_PMLCB0, pmlcb);
56 break; 45 break;
57 case 1: 46 case 1:
58 mtpmr(PMRN_PMC1, val); 47 mtpmr(PMRN_PMLCA1, pmlca);
48 mtpmr(PMRN_PMLCB1, pmlcb);
59 break; 49 break;
60 case 2: 50 case 2:
61 mtpmr(PMRN_PMC2, val); 51 mtpmr(PMRN_PMLCA2, pmlca);
52 mtpmr(PMRN_PMLCB2, pmlcb);
62 break; 53 break;
63 case 3: 54 case 3:
64 mtpmr(PMRN_PMC3, val); 55 mtpmr(PMRN_PMLCA3, pmlca);
56 mtpmr(PMRN_PMLCB3, pmlcb);
65 break; 57 break;
66 default: 58 default:
67 break; 59 panic("Bad ctr number!\n");
68 } 60 }
69} 61}
70 62
63static void set_pmc_event(int ctr, int event)
64{
65 u32 pmlca;
66
67 pmlca = get_pmlca(ctr);
68
69 pmlca = (pmlca & ~PMLCA_EVENT_MASK) |
70 ((event << PMLCA_EVENT_SHIFT) &
71 PMLCA_EVENT_MASK);
72
73 set_pmlca(ctr, pmlca);
74}
75
76static void set_pmc_user_kernel(int ctr, int user, int kernel)
77{
78 u32 pmlca;
79
80 pmlca = get_pmlca(ctr);
81
82 if(user)
83 pmlca &= ~PMLCA_FCU;
84 else
85 pmlca |= PMLCA_FCU;
86
87 if(kernel)
88 pmlca &= ~PMLCA_FCS;
89 else
90 pmlca |= PMLCA_FCS;
91
92 set_pmlca(ctr, pmlca);
93}
94
95static void set_pmc_marked(int ctr, int mark0, int mark1)
96{
97 u32 pmlca = get_pmlca(ctr);
98
99 if(mark0)
100 pmlca &= ~PMLCA_FCM0;
101 else
102 pmlca |= PMLCA_FCM0;
103
104 if(mark1)
105 pmlca &= ~PMLCA_FCM1;
106 else
107 pmlca |= PMLCA_FCM1;
108
109 set_pmlca(ctr, pmlca);
110}
111
112static void pmc_start_ctr(int ctr, int enable)
113{
114 u32 pmlca = get_pmlca(ctr);
115
116 pmlca &= ~PMLCA_FC;
117
118 if (enable)
119 pmlca |= PMLCA_CE;
120 else
121 pmlca &= ~PMLCA_CE;
122
123 set_pmlca(ctr, pmlca);
124}
125
126static void pmc_start_ctrs(int enable)
127{
128 u32 pmgc0 = mfpmr(PMRN_PMGC0);
129
130 pmgc0 &= ~PMGC0_FAC;
131 pmgc0 |= PMGC0_FCECE;
132
133 if (enable)
134 pmgc0 |= PMGC0_PMIE;
135 else
136 pmgc0 &= ~PMGC0_PMIE;
137
138 mtpmr(PMRN_PMGC0, pmgc0);
139}
140
141static void pmc_stop_ctrs(void)
142{
143 u32 pmgc0 = mfpmr(PMRN_PMGC0);
144
145 pmgc0 |= PMGC0_FAC;
146
147 pmgc0 &= ~(PMGC0_PMIE | PMGC0_FCECE);
148
149 mtpmr(PMRN_PMGC0, pmgc0);
150}
151
152static void dump_pmcs(void)
153{
154 printk("pmgc0: %x\n", mfpmr(PMRN_PMGC0));
155 printk("pmc\t\tpmlca\t\tpmlcb\n");
156 printk("%8x\t%8x\t%8x\n", mfpmr(PMRN_PMC0),
157 mfpmr(PMRN_PMLCA0), mfpmr(PMRN_PMLCB0));
158 printk("%8x\t%8x\t%8x\n", mfpmr(PMRN_PMC1),
159 mfpmr(PMRN_PMLCA1), mfpmr(PMRN_PMLCB1));
160 printk("%8x\t%8x\t%8x\n", mfpmr(PMRN_PMC2),
161 mfpmr(PMRN_PMLCA2), mfpmr(PMRN_PMLCB2));
162 printk("%8x\t%8x\t%8x\n", mfpmr(PMRN_PMC3),
163 mfpmr(PMRN_PMLCA3), mfpmr(PMRN_PMLCB3));
164}
165
166static void fsl_booke_cpu_setup(struct op_counter_config *ctr)
167{
168 int i;
169
170 /* freeze all counters */
171 pmc_stop_ctrs();
172
173 for (i = 0;i < num_counters;i++) {
174 init_pmc_stop(i);
175
176 set_pmc_event(i, ctr[i].event);
177
178 set_pmc_user_kernel(i, ctr[i].user, ctr[i].kernel);
179 }
180}
71 181
72static void fsl_booke_reg_setup(struct op_counter_config *ctr, 182static void fsl_booke_reg_setup(struct op_counter_config *ctr,
73 struct op_system_config *sys, 183 struct op_system_config *sys,
@@ -77,23 +187,14 @@ static void fsl_booke_reg_setup(struct op_counter_config *ctr,
77 187
78 num_counters = num_ctrs; 188 num_counters = num_ctrs;
79 189
80 /* freeze all counters */
81 pmc_stop_ctrs();
82
83 /* Our counters count up, and "count" refers to 190 /* Our counters count up, and "count" refers to
84 * how much before the next interrupt, and we interrupt 191 * how much before the next interrupt, and we interrupt
85 * on overflow. So we calculate the starting value 192 * on overflow. So we calculate the starting value
86 * which will give us "count" until overflow. 193 * which will give us "count" until overflow.
87 * Then we set the events on the enabled counters */ 194 * Then we set the events on the enabled counters */
88 for (i = 0; i < num_counters; ++i) { 195 for (i = 0; i < num_counters; ++i)
89 reset_value[i] = 0x80000000UL - ctr[i].count; 196 reset_value[i] = 0x80000000UL - ctr[i].count;
90 197
91 init_pmc_stop(i);
92
93 set_pmc_event(i, ctr[i].event);
94
95 set_pmc_user_kernel(i, ctr[i].user, ctr[i].kernel);
96 }
97} 198}
98 199
99static void fsl_booke_start(struct op_counter_config *ctr) 200static void fsl_booke_start(struct op_counter_config *ctr)
@@ -105,8 +206,8 @@ static void fsl_booke_start(struct op_counter_config *ctr)
105 for (i = 0; i < num_counters; ++i) { 206 for (i = 0; i < num_counters; ++i) {
106 if (ctr[i].enabled) { 207 if (ctr[i].enabled) {
107 ctr_write(i, reset_value[i]); 208 ctr_write(i, reset_value[i]);
108 /* Set Each enabled counterd to only 209 /* Set each enabled counter to only
109 * count when the Mark bit is not set */ 210 * count when the Mark bit is *not* set */
110 set_pmc_marked(i, 1, 0); 211 set_pmc_marked(i, 1, 0);
111 pmc_start_ctr(i, 1); 212 pmc_start_ctr(i, 1);
112 } else { 213 } else {
@@ -177,6 +278,7 @@ static void fsl_booke_handle_interrupt(struct pt_regs *regs,
177 278
178struct op_powerpc_model op_model_fsl_booke = { 279struct op_powerpc_model op_model_fsl_booke = {
179 .reg_setup = fsl_booke_reg_setup, 280 .reg_setup = fsl_booke_reg_setup,
281 .cpu_setup = fsl_booke_cpu_setup,
180 .start = fsl_booke_start, 282 .start = fsl_booke_start,
181 .stop = fsl_booke_stop, 283 .stop = fsl_booke_stop,
182 .handle_interrupt = fsl_booke_handle_interrupt, 284 .handle_interrupt = fsl_booke_handle_interrupt,
diff --git a/arch/powerpc/oprofile/op_model_power4.c b/arch/powerpc/oprofile/op_model_power4.c
index 506f6b79f893..356709d515b9 100644
--- a/arch/powerpc/oprofile/op_model_power4.c
+++ b/arch/powerpc/oprofile/op_model_power4.c
@@ -76,13 +76,13 @@ static inline int mmcra_must_set_sample(void)
76{ 76{
77 if (__is_processor(PV_POWER4) || __is_processor(PV_POWER4p) || 77 if (__is_processor(PV_POWER4) || __is_processor(PV_POWER4p) ||
78 __is_processor(PV_970) || __is_processor(PV_970FX) || 78 __is_processor(PV_970) || __is_processor(PV_970FX) ||
79 __is_processor(PV_970MP)) 79 __is_processor(PV_970MP) || __is_processor(PV_970GX))
80 return 1; 80 return 1;
81 81
82 return 0; 82 return 0;
83} 83}
84 84
85static void power4_cpu_setup(void *unused) 85static void power4_cpu_setup(struct op_counter_config *ctr)
86{ 86{
87 unsigned int mmcr0 = mmcr0_val; 87 unsigned int mmcr0 = mmcr0_val;
88 unsigned long mmcra = mmcra_val; 88 unsigned long mmcra = mmcra_val;
diff --git a/arch/powerpc/oprofile/op_model_rs64.c b/arch/powerpc/oprofile/op_model_rs64.c
index 042f8f4867ad..19c5ee089bc9 100644
--- a/arch/powerpc/oprofile/op_model_rs64.c
+++ b/arch/powerpc/oprofile/op_model_rs64.c
@@ -102,7 +102,7 @@ static void rs64_reg_setup(struct op_counter_config *ctr,
102 /* XXX setup user and kernel profiling */ 102 /* XXX setup user and kernel profiling */
103} 103}
104 104
105static void rs64_cpu_setup(void *unused) 105static void rs64_cpu_setup(struct op_counter_config *ctr)
106{ 106{
107 unsigned int mmcr0; 107 unsigned int mmcr0;
108 108
diff --git a/arch/powerpc/platforms/83xx/Kconfig b/arch/powerpc/platforms/83xx/Kconfig
index 0975e94ac7c4..7edb6b461382 100644
--- a/arch/powerpc/platforms/83xx/Kconfig
+++ b/arch/powerpc/platforms/83xx/Kconfig
@@ -32,6 +32,13 @@ config MPC834x_ITX
32 Be aware that PCI initialization is the bootloader's 32 Be aware that PCI initialization is the bootloader's
33 responsiblilty. 33 responsiblilty.
34 34
35config MPC8360E_PB
36 bool "Freescale MPC8360E PB"
37 select DEFAULT_UIMAGE
38 select QUICC_ENGINE
39 help
40 This option enables support for the MPC836x EMDS Processor Board.
41
35endchoice 42endchoice
36 43
37config PPC_MPC832x 44config PPC_MPC832x
@@ -46,4 +53,10 @@ config MPC834x
46 select PPC_INDIRECT_PCI 53 select PPC_INDIRECT_PCI
47 default y if MPC834x_SYS || MPC834x_ITX 54 default y if MPC834x_SYS || MPC834x_ITX
48 55
56config PPC_MPC836x
57 bool
58 select PPC_UDBG_16550
59 select PPC_INDIRECT_PCI
60 default y if MPC8360E_PB
61
49endmenu 62endmenu
diff --git a/arch/powerpc/platforms/83xx/Makefile b/arch/powerpc/platforms/83xx/Makefile
index 9387a110d28a..f1aa7e24a938 100644
--- a/arch/powerpc/platforms/83xx/Makefile
+++ b/arch/powerpc/platforms/83xx/Makefile
@@ -5,3 +5,5 @@ obj-y := misc.o
5obj-$(CONFIG_PCI) += pci.o 5obj-$(CONFIG_PCI) += pci.o
6obj-$(CONFIG_MPC834x_SYS) += mpc834x_sys.o 6obj-$(CONFIG_MPC834x_SYS) += mpc834x_sys.o
7obj-$(CONFIG_MPC834x_ITX) += mpc834x_itx.o 7obj-$(CONFIG_MPC834x_ITX) += mpc834x_itx.o
8obj-$(CONFIG_MPC8360E_PB) += mpc8360e_pb.o
9obj-$(CONFIG_MPC832x_MDS) += mpc832x_mds.o
diff --git a/arch/powerpc/platforms/83xx/mpc832x_mds.c b/arch/powerpc/platforms/83xx/mpc832x_mds.c
index 54dea9d42dc9..a43ac71ab740 100644
--- a/arch/powerpc/platforms/83xx/mpc832x_mds.c
+++ b/arch/powerpc/platforms/83xx/mpc832x_mds.c
@@ -24,6 +24,7 @@
24#include <linux/root_dev.h> 24#include <linux/root_dev.h>
25#include <linux/initrd.h> 25#include <linux/initrd.h>
26 26
27#include <asm/of_device.h>
27#include <asm/system.h> 28#include <asm/system.h>
28#include <asm/atomic.h> 29#include <asm/atomic.h>
29#include <asm/time.h> 30#include <asm/time.h>
@@ -136,6 +137,24 @@ static void __init mpc832x_sys_setup_arch(void)
136#endif 137#endif
137} 138}
138 139
140static int __init mpc832x_declare_of_platform_devices(void)
141{
142 struct device_node *np;
143
144 for (np = NULL; (np = of_find_compatible_node(np, "network",
145 "ucc_geth")) != NULL;) {
146 int ucc_num;
147 char bus_id[BUS_ID_SIZE];
148
149 ucc_num = *((uint *) get_property(np, "device-id", NULL)) - 1;
150 snprintf(bus_id, BUS_ID_SIZE, "ucc_geth.%u", ucc_num);
151 of_platform_device_create(np, bus_id, NULL);
152 }
153
154 return 0;
155}
156device_initcall(mpc832x_declare_of_platform_devices);
157
139void __init mpc832x_sys_init_IRQ(void) 158void __init mpc832x_sys_init_IRQ(void)
140{ 159{
141 160
diff --git a/arch/powerpc/platforms/83xx/mpc834x_itx.c b/arch/powerpc/platforms/83xx/mpc834x_itx.c
index 5446bab08eca..e2bcaaf6b329 100644
--- a/arch/powerpc/platforms/83xx/mpc834x_itx.c
+++ b/arch/powerpc/platforms/83xx/mpc834x_itx.c
@@ -108,10 +108,6 @@ static int __init mpc834x_itx_probe(void)
108 return 1; 108 return 1;
109} 109}
110 110
111#ifdef CONFIG_RTC_CLASS
112late_initcall(rtc_class_hookup);
113#endif
114
115define_machine(mpc834x_itx) { 111define_machine(mpc834x_itx) {
116 .name = "MPC834x ITX", 112 .name = "MPC834x ITX",
117 .probe = mpc834x_itx_probe, 113 .probe = mpc834x_itx_probe,
diff --git a/arch/powerpc/platforms/83xx/mpc8360e_pb.c b/arch/powerpc/platforms/83xx/mpc8360e_pb.c
index c0191900fc25..1a523c81c06e 100644
--- a/arch/powerpc/platforms/83xx/mpc8360e_pb.c
+++ b/arch/powerpc/platforms/83xx/mpc8360e_pb.c
@@ -30,6 +30,7 @@
30#include <linux/root_dev.h> 30#include <linux/root_dev.h>
31#include <linux/initrd.h> 31#include <linux/initrd.h>
32 32
33#include <asm/of_device.h>
33#include <asm/system.h> 34#include <asm/system.h>
34#include <asm/atomic.h> 35#include <asm/atomic.h>
35#include <asm/time.h> 36#include <asm/time.h>
@@ -141,6 +142,24 @@ static void __init mpc8360_sys_setup_arch(void)
141#endif 142#endif
142} 143}
143 144
145static int __init mpc8360_declare_of_platform_devices(void)
146{
147 struct device_node *np;
148
149 for (np = NULL; (np = of_find_compatible_node(np, "network",
150 "ucc_geth")) != NULL;) {
151 int ucc_num;
152 char bus_id[BUS_ID_SIZE];
153
154 ucc_num = *((uint *) get_property(np, "device-id", NULL)) - 1;
155 snprintf(bus_id, BUS_ID_SIZE, "ucc_geth.%u", ucc_num);
156 of_platform_device_create(np, bus_id, NULL);
157 }
158
159 return 0;
160}
161device_initcall(mpc8360_declare_of_platform_devices);
162
144void __init mpc8360_sys_init_IRQ(void) 163void __init mpc8360_sys_init_IRQ(void)
145{ 164{
146 165
diff --git a/arch/powerpc/platforms/cell/spu_base.c b/arch/powerpc/platforms/cell/spu_base.c
index ccfd0c4db874..7aa809d5a244 100644
--- a/arch/powerpc/platforms/cell/spu_base.c
+++ b/arch/powerpc/platforms/cell/spu_base.c
@@ -655,14 +655,19 @@ static int __init spu_map_interrupts(struct spu *spu, struct device_node *np)
655 655
656 for (i=0; i < 3; i++) { 656 for (i=0; i < 3; i++) {
657 ret = of_irq_map_one(np, i, &oirq); 657 ret = of_irq_map_one(np, i, &oirq);
658 if (ret) 658 if (ret) {
659 pr_debug("spu_new: failed to get irq %d\n", i);
659 goto err; 660 goto err;
660 661 }
661 ret = -EINVAL; 662 ret = -EINVAL;
663 pr_debug(" irq %d no 0x%x on %s\n", i, oirq.specifier[0],
664 oirq.controller->full_name);
662 spu->irqs[i] = irq_create_of_mapping(oirq.controller, 665 spu->irqs[i] = irq_create_of_mapping(oirq.controller,
663 oirq.specifier, oirq.size); 666 oirq.specifier, oirq.size);
664 if (spu->irqs[i] == NO_IRQ) 667 if (spu->irqs[i] == NO_IRQ) {
668 pr_debug("spu_new: failed to map it !\n");
665 goto err; 669 goto err;
670 }
666 } 671 }
667 return 0; 672 return 0;
668 673
@@ -681,7 +686,7 @@ static int spu_map_resource(struct device_node *node, int nr,
681 struct resource resource = { }; 686 struct resource resource = { };
682 int ret; 687 int ret;
683 688
684 ret = of_address_to_resource(node, 0, &resource); 689 ret = of_address_to_resource(node, nr, &resource);
685 if (ret) 690 if (ret)
686 goto out; 691 goto out;
687 692
@@ -704,22 +709,42 @@ static int __init spu_map_device(struct spu *spu, struct device_node *node)
704 709
705 ret = spu_map_resource(node, 0, (void __iomem**)&spu->local_store, 710 ret = spu_map_resource(node, 0, (void __iomem**)&spu->local_store,
706 &spu->local_store_phys); 711 &spu->local_store_phys);
707 if (ret) 712 if (ret) {
713 pr_debug("spu_new: failed to map %s resource 0\n",
714 node->full_name);
708 goto out; 715 goto out;
716 }
709 ret = spu_map_resource(node, 1, (void __iomem**)&spu->problem, 717 ret = spu_map_resource(node, 1, (void __iomem**)&spu->problem,
710 &spu->problem_phys); 718 &spu->problem_phys);
711 if (ret) 719 if (ret) {
720 pr_debug("spu_new: failed to map %s resource 1\n",
721 node->full_name);
712 goto out_unmap; 722 goto out_unmap;
723 }
713 ret = spu_map_resource(node, 2, (void __iomem**)&spu->priv2, 724 ret = spu_map_resource(node, 2, (void __iomem**)&spu->priv2,
714 NULL); 725 NULL);
715 if (ret) 726 if (ret) {
727 pr_debug("spu_new: failed to map %s resource 2\n",
728 node->full_name);
716 goto out_unmap; 729 goto out_unmap;
730 }
717 731
718 if (!firmware_has_feature(FW_FEATURE_LPAR)) 732 if (!firmware_has_feature(FW_FEATURE_LPAR))
719 ret = spu_map_resource(node, 3, (void __iomem**)&spu->priv1, 733 ret = spu_map_resource(node, 3, (void __iomem**)&spu->priv1,
720 NULL); 734 NULL);
721 if (ret) 735 if (ret) {
736 pr_debug("spu_new: failed to map %s resource 3\n",
737 node->full_name);
722 goto out_unmap; 738 goto out_unmap;
739 }
740 pr_debug("spu_new: %s maps:\n", node->full_name);
741 pr_debug(" local store : 0x%016lx -> 0x%p\n",
742 spu->local_store_phys, spu->local_store);
743 pr_debug(" problem state : 0x%016lx -> 0x%p\n",
744 spu->problem_phys, spu->problem);
745 pr_debug(" priv2 : 0x%p\n", spu->priv2);
746 pr_debug(" priv1 : 0x%p\n", spu->priv1);
747
723 return 0; 748 return 0;
724 749
725out_unmap: 750out_unmap:
@@ -781,6 +806,17 @@ static int __init create_spu(struct device_node *spe)
781 if (!spu) 806 if (!spu)
782 goto out; 807 goto out;
783 808
809 spu->node = find_spu_node_id(spe);
810 if (spu->node >= MAX_NUMNODES) {
811 printk(KERN_WARNING "SPE %s on node %d ignored,"
812 " node number too big\n", spe->full_name, spu->node);
813 printk(KERN_WARNING "Check if CONFIG_NUMA is enabled.\n");
814 return -ENODEV;
815 }
816 spu->nid = of_node_to_nid(spe);
817 if (spu->nid == -1)
818 spu->nid = 0;
819
784 ret = spu_map_device(spu, spe); 820 ret = spu_map_device(spu, spe);
785 /* try old method */ 821 /* try old method */
786 if (ret) 822 if (ret)
@@ -788,10 +824,6 @@ static int __init create_spu(struct device_node *spe)
788 if (ret) 824 if (ret)
789 goto out_free; 825 goto out_free;
790 826
791 spu->node = find_spu_node_id(spe);
792 spu->nid = of_node_to_nid(spe);
793 if (spu->nid == -1)
794 spu->nid = 0;
795 ret = spu_map_interrupts(spu, spe); 827 ret = spu_map_interrupts(spu, spe);
796 if (ret) 828 if (ret)
797 ret = spu_map_interrupts_old(spu, spe); 829 ret = spu_map_interrupts_old(spu, spe);
diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
index e0d730045260..533e2723e184 100644
--- a/arch/powerpc/platforms/cell/spufs/file.c
+++ b/arch/powerpc/platforms/cell/spufs/file.c
@@ -246,6 +246,7 @@ static int spufs_cntl_open(struct inode *inode, struct file *file)
246 246
247static struct file_operations spufs_cntl_fops = { 247static struct file_operations spufs_cntl_fops = {
248 .open = spufs_cntl_open, 248 .open = spufs_cntl_open,
249 .release = simple_attr_close,
249 .read = simple_attr_read, 250 .read = simple_attr_read,
250 .write = simple_attr_write, 251 .write = simple_attr_write,
251 .mmap = spufs_cntl_mmap, 252 .mmap = spufs_cntl_mmap,
@@ -384,7 +385,7 @@ static ssize_t spufs_mbox_read(struct file *file, char __user *buf,
384 udata = (void __user *)buf; 385 udata = (void __user *)buf;
385 386
386 spu_acquire(ctx); 387 spu_acquire(ctx);
387 for (count = 0; count <= len; count += 4, udata++) { 388 for (count = 0; (count + 4) <= len; count += 4, udata++) {
388 int ret; 389 int ret;
389 ret = ctx->ops->mbox_read(ctx, &mbox_data); 390 ret = ctx->ops->mbox_read(ctx, &mbox_data);
390 if (ret == 0) 391 if (ret == 0)
diff --git a/arch/powerpc/platforms/cell/spufs/hw_ops.c b/arch/powerpc/platforms/cell/spufs/hw_ops.c
index efc452e71ab0..d805ffed892d 100644
--- a/arch/powerpc/platforms/cell/spufs/hw_ops.c
+++ b/arch/powerpc/platforms/cell/spufs/hw_ops.c
@@ -147,7 +147,7 @@ static void spu_hw_signal1_write(struct spu_context *ctx, u32 data)
147 147
148static u32 spu_hw_signal2_read(struct spu_context *ctx) 148static u32 spu_hw_signal2_read(struct spu_context *ctx)
149{ 149{
150 return in_be32(&ctx->spu->problem->signal_notify1); 150 return in_be32(&ctx->spu->problem->signal_notify2);
151} 151}
152 152
153static void spu_hw_signal2_write(struct spu_context *ctx, u32 data) 153static void spu_hw_signal2_write(struct spu_context *ctx, u32 data)
diff --git a/arch/powerpc/platforms/chrp/setup.c b/arch/powerpc/platforms/chrp/setup.c
index cae3d13229b9..49b8dabcbc99 100644
--- a/arch/powerpc/platforms/chrp/setup.c
+++ b/arch/powerpc/platforms/chrp/setup.c
@@ -477,8 +477,10 @@ static void __init chrp_find_8259(void)
477 " address, polling\n"); 477 " address, polling\n");
478 478
479 i8259_init(pic, chrp_int_ack); 479 i8259_init(pic, chrp_int_ack);
480 if (ppc_md.get_irq == NULL) 480 if (ppc_md.get_irq == NULL) {
481 ppc_md.get_irq = i8259_irq; 481 ppc_md.get_irq = i8259_irq;
482 irq_set_default_host(i8259_get_host());
483 }
482 if (chrp_mpic != NULL) { 484 if (chrp_mpic != NULL) {
483 cascade_irq = irq_of_parse_and_map(pic, 0); 485 cascade_irq = irq_of_parse_and_map(pic, 0);
484 if (cascade_irq == NO_IRQ) 486 if (cascade_irq == NO_IRQ)
diff --git a/arch/powerpc/platforms/iseries/iommu.c b/arch/powerpc/platforms/iseries/iommu.c
index f4cbbcf8773a..218817d13c5c 100644
--- a/arch/powerpc/platforms/iseries/iommu.c
+++ b/arch/powerpc/platforms/iseries/iommu.c
@@ -43,9 +43,6 @@ static void tce_build_iSeries(struct iommu_table *tbl, long index, long npages,
43 u64 rc; 43 u64 rc;
44 u64 tce, rpn; 44 u64 tce, rpn;
45 45
46 index <<= TCE_PAGE_FACTOR;
47 npages <<= TCE_PAGE_FACTOR;
48
49 while (npages--) { 46 while (npages--) {
50 rpn = virt_to_abs(uaddr) >> TCE_SHIFT; 47 rpn = virt_to_abs(uaddr) >> TCE_SHIFT;
51 tce = (rpn & TCE_RPN_MASK) << TCE_RPN_SHIFT; 48 tce = (rpn & TCE_RPN_MASK) << TCE_RPN_SHIFT;
@@ -75,9 +72,6 @@ static void tce_free_iSeries(struct iommu_table *tbl, long index, long npages)
75{ 72{
76 u64 rc; 73 u64 rc;
77 74
78 npages <<= TCE_PAGE_FACTOR;
79 index <<= TCE_PAGE_FACTOR;
80
81 while (npages--) { 75 while (npages--) {
82 rc = HvCallXm_setTce((u64)tbl->it_index, (u64)index, 0); 76 rc = HvCallXm_setTce((u64)tbl->it_index, (u64)index, 0);
83 if (rc) 77 if (rc)
@@ -136,10 +130,9 @@ void iommu_table_getparms_iSeries(unsigned long busno,
136 panic("PCI_DMA: parms->size is zero, parms is 0x%p", parms); 130 panic("PCI_DMA: parms->size is zero, parms is 0x%p", parms);
137 131
138 /* itc_size is in pages worth of table, it_size is in # of entries */ 132 /* itc_size is in pages worth of table, it_size is in # of entries */
139 tbl->it_size = ((parms->itc_size * TCE_PAGE_SIZE) / 133 tbl->it_size = (parms->itc_size * TCE_PAGE_SIZE) / TCE_ENTRY_SIZE;
140 TCE_ENTRY_SIZE) >> TCE_PAGE_FACTOR;
141 tbl->it_busno = parms->itc_busno; 134 tbl->it_busno = parms->itc_busno;
142 tbl->it_offset = parms->itc_offset >> TCE_PAGE_FACTOR; 135 tbl->it_offset = parms->itc_offset;
143 tbl->it_index = parms->itc_index; 136 tbl->it_index = parms->itc_index;
144 tbl->it_blocksize = 1; 137 tbl->it_blocksize = 1;
145 tbl->it_type = virtbus ? TCE_VB : TCE_PCI; 138 tbl->it_type = virtbus ? TCE_VB : TCE_PCI;
diff --git a/arch/powerpc/platforms/iseries/setup.c b/arch/powerpc/platforms/iseries/setup.c
index a0ff7ba7d666..6f73469fd3b0 100644
--- a/arch/powerpc/platforms/iseries/setup.c
+++ b/arch/powerpc/platforms/iseries/setup.c
@@ -694,6 +694,11 @@ void * __init iSeries_early_setup(void)
694{ 694{
695 unsigned long phys_mem_size; 695 unsigned long phys_mem_size;
696 696
697 /* Identify CPU type. This is done again by the common code later
698 * on but calling this function multiple times is fine.
699 */
700 identify_cpu(0);
701
697 powerpc_firmware_features |= FW_FEATURE_ISERIES; 702 powerpc_firmware_features |= FW_FEATURE_ISERIES;
698 powerpc_firmware_features |= FW_FEATURE_LPAR; 703 powerpc_firmware_features |= FW_FEATURE_LPAR;
699 704
diff --git a/arch/powerpc/platforms/powermac/sleep.S b/arch/powerpc/platforms/powermac/sleep.S
index 1174ca128efa..adee28da353f 100644
--- a/arch/powerpc/platforms/powermac/sleep.S
+++ b/arch/powerpc/platforms/powermac/sleep.S
@@ -45,7 +45,8 @@
45 .section .text 45 .section .text
46 .align 5 46 .align 5
47 47
48#if defined(CONFIG_PM) || defined(CONFIG_CPU_FREQ_PMAC) 48#if defined(CONFIG_PM) || defined(CONFIG_CPU_FREQ_PMAC) || \
49 (defined(CONFIG_HOTPLUG_CPU) && defined(CONFIG_PPC32))
49 50
50/* This gets called by via-pmu.c late during the sleep process. 51/* This gets called by via-pmu.c late during the sleep process.
51 * The PMU was already send the sleep command and will shut us down 52 * The PMU was already send the sleep command and will shut us down
diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index d24ba547e53f..556c279a789d 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -57,9 +57,6 @@ static void tce_build_pSeries(struct iommu_table *tbl, long index,
57 u64 *tcep; 57 u64 *tcep;
58 u64 rpn; 58 u64 rpn;
59 59
60 index <<= TCE_PAGE_FACTOR;
61 npages <<= TCE_PAGE_FACTOR;
62
63 proto_tce = TCE_PCI_READ; // Read allowed 60 proto_tce = TCE_PCI_READ; // Read allowed
64 61
65 if (direction != DMA_TO_DEVICE) 62 if (direction != DMA_TO_DEVICE)
@@ -82,9 +79,6 @@ static void tce_free_pSeries(struct iommu_table *tbl, long index, long npages)
82{ 79{
83 u64 *tcep; 80 u64 *tcep;
84 81
85 npages <<= TCE_PAGE_FACTOR;
86 index <<= TCE_PAGE_FACTOR;
87
88 tcep = ((u64 *)tbl->it_base) + index; 82 tcep = ((u64 *)tbl->it_base) + index;
89 83
90 while (npages--) 84 while (npages--)
@@ -95,7 +89,6 @@ static unsigned long tce_get_pseries(struct iommu_table *tbl, long index)
95{ 89{
96 u64 *tcep; 90 u64 *tcep;
97 91
98 index <<= TCE_PAGE_FACTOR;
99 tcep = ((u64 *)tbl->it_base) + index; 92 tcep = ((u64 *)tbl->it_base) + index;
100 93
101 return *tcep; 94 return *tcep;
@@ -109,9 +102,6 @@ static void tce_build_pSeriesLP(struct iommu_table *tbl, long tcenum,
109 u64 proto_tce, tce; 102 u64 proto_tce, tce;
110 u64 rpn; 103 u64 rpn;
111 104
112 tcenum <<= TCE_PAGE_FACTOR;
113 npages <<= TCE_PAGE_FACTOR;
114
115 rpn = (virt_to_abs(uaddr)) >> TCE_SHIFT; 105 rpn = (virt_to_abs(uaddr)) >> TCE_SHIFT;
116 proto_tce = TCE_PCI_READ; 106 proto_tce = TCE_PCI_READ;
117 if (direction != DMA_TO_DEVICE) 107 if (direction != DMA_TO_DEVICE)
@@ -146,7 +136,7 @@ static void tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
146 u64 rpn; 136 u64 rpn;
147 long l, limit; 137 long l, limit;
148 138
149 if (TCE_PAGE_FACTOR == 0 && npages == 1) 139 if (npages == 1)
150 return tce_build_pSeriesLP(tbl, tcenum, npages, uaddr, 140 return tce_build_pSeriesLP(tbl, tcenum, npages, uaddr,
151 direction); 141 direction);
152 142
@@ -164,9 +154,6 @@ static void tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
164 __get_cpu_var(tce_page) = tcep; 154 __get_cpu_var(tce_page) = tcep;
165 } 155 }
166 156
167 tcenum <<= TCE_PAGE_FACTOR;
168 npages <<= TCE_PAGE_FACTOR;
169
170 rpn = (virt_to_abs(uaddr)) >> TCE_SHIFT; 157 rpn = (virt_to_abs(uaddr)) >> TCE_SHIFT;
171 proto_tce = TCE_PCI_READ; 158 proto_tce = TCE_PCI_READ;
172 if (direction != DMA_TO_DEVICE) 159 if (direction != DMA_TO_DEVICE)
@@ -207,9 +194,6 @@ static void tce_free_pSeriesLP(struct iommu_table *tbl, long tcenum, long npages
207{ 194{
208 u64 rc; 195 u64 rc;
209 196
210 tcenum <<= TCE_PAGE_FACTOR;
211 npages <<= TCE_PAGE_FACTOR;
212
213 while (npages--) { 197 while (npages--) {
214 rc = plpar_tce_put((u64)tbl->it_index, (u64)tcenum << 12, 0); 198 rc = plpar_tce_put((u64)tbl->it_index, (u64)tcenum << 12, 0);
215 199
@@ -229,9 +213,6 @@ static void tce_freemulti_pSeriesLP(struct iommu_table *tbl, long tcenum, long n
229{ 213{
230 u64 rc; 214 u64 rc;
231 215
232 tcenum <<= TCE_PAGE_FACTOR;
233 npages <<= TCE_PAGE_FACTOR;
234
235 rc = plpar_tce_stuff((u64)tbl->it_index, (u64)tcenum << 12, 0, npages); 216 rc = plpar_tce_stuff((u64)tbl->it_index, (u64)tcenum << 12, 0, npages);
236 217
237 if (rc && printk_ratelimit()) { 218 if (rc && printk_ratelimit()) {
@@ -248,7 +229,6 @@ static unsigned long tce_get_pSeriesLP(struct iommu_table *tbl, long tcenum)
248 u64 rc; 229 u64 rc;
249 unsigned long tce_ret; 230 unsigned long tce_ret;
250 231
251 tcenum <<= TCE_PAGE_FACTOR;
252 rc = plpar_tce_get((u64)tbl->it_index, (u64)tcenum << 12, &tce_ret); 232 rc = plpar_tce_get((u64)tbl->it_index, (u64)tcenum << 12, &tce_ret);
253 233
254 if (rc && printk_ratelimit()) { 234 if (rc && printk_ratelimit()) {
@@ -289,7 +269,7 @@ static void iommu_table_setparms(struct pci_controller *phb,
289 tbl->it_busno = phb->bus->number; 269 tbl->it_busno = phb->bus->number;
290 270
291 /* Units of tce entries */ 271 /* Units of tce entries */
292 tbl->it_offset = phb->dma_window_base_cur >> PAGE_SHIFT; 272 tbl->it_offset = phb->dma_window_base_cur >> IOMMU_PAGE_SHIFT;
293 273
294 /* Test if we are going over 2GB of DMA space */ 274 /* Test if we are going over 2GB of DMA space */
295 if (phb->dma_window_base_cur + phb->dma_window_size > 0x80000000ul) { 275 if (phb->dma_window_base_cur + phb->dma_window_size > 0x80000000ul) {
@@ -300,7 +280,7 @@ static void iommu_table_setparms(struct pci_controller *phb,
300 phb->dma_window_base_cur += phb->dma_window_size; 280 phb->dma_window_base_cur += phb->dma_window_size;
301 281
302 /* Set the tce table size - measured in entries */ 282 /* Set the tce table size - measured in entries */
303 tbl->it_size = phb->dma_window_size >> PAGE_SHIFT; 283 tbl->it_size = phb->dma_window_size >> IOMMU_PAGE_SHIFT;
304 284
305 tbl->it_index = 0; 285 tbl->it_index = 0;
306 tbl->it_blocksize = 16; 286 tbl->it_blocksize = 16;
@@ -325,8 +305,8 @@ static void iommu_table_setparms_lpar(struct pci_controller *phb,
325 tbl->it_base = 0; 305 tbl->it_base = 0;
326 tbl->it_blocksize = 16; 306 tbl->it_blocksize = 16;
327 tbl->it_type = TCE_PCI; 307 tbl->it_type = TCE_PCI;
328 tbl->it_offset = offset >> PAGE_SHIFT; 308 tbl->it_offset = offset >> IOMMU_PAGE_SHIFT;
329 tbl->it_size = size >> PAGE_SHIFT; 309 tbl->it_size = size >> IOMMU_PAGE_SHIFT;
330} 310}
331 311
332static void iommu_bus_setup_pSeries(struct pci_bus *bus) 312static void iommu_bus_setup_pSeries(struct pci_bus *bus)
@@ -522,8 +502,6 @@ static void iommu_dev_setup_pSeriesLP(struct pci_dev *dev)
522 const void *dma_window = NULL; 502 const void *dma_window = NULL;
523 struct pci_dn *pci; 503 struct pci_dn *pci;
524 504
525 DBG("iommu_dev_setup_pSeriesLP, dev %p (%s)\n", dev, pci_name(dev));
526
527 /* dev setup for LPAR is a little tricky, since the device tree might 505 /* dev setup for LPAR is a little tricky, since the device tree might
528 * contain the dma-window properties per-device and not neccesarily 506 * contain the dma-window properties per-device and not neccesarily
529 * for the bus. So we need to search upwards in the tree until we 507 * for the bus. So we need to search upwards in the tree until we
@@ -532,6 +510,9 @@ static void iommu_dev_setup_pSeriesLP(struct pci_dev *dev)
532 */ 510 */
533 dn = pci_device_to_OF_node(dev); 511 dn = pci_device_to_OF_node(dev);
534 512
513 DBG("iommu_dev_setup_pSeriesLP, dev %p (%s) %s\n",
514 dev, pci_name(dev), dn->full_name);
515
535 for (pdn = dn; pdn && PCI_DN(pdn) && !PCI_DN(pdn)->iommu_table; 516 for (pdn = dn; pdn && PCI_DN(pdn) && !PCI_DN(pdn)->iommu_table;
536 pdn = pdn->parent) { 517 pdn = pdn->parent) {
537 dma_window = get_property(pdn, "ibm,dma-window", NULL); 518 dma_window = get_property(pdn, "ibm,dma-window", NULL);
diff --git a/arch/powerpc/sysdev/dart.h b/arch/powerpc/sysdev/dart.h
index 1c8817c4835e..ff202edb0591 100644
--- a/arch/powerpc/sysdev/dart.h
+++ b/arch/powerpc/sysdev/dart.h
@@ -72,7 +72,6 @@
72 72
73#define DART_PAGE_SHIFT 12 73#define DART_PAGE_SHIFT 12
74#define DART_PAGE_SIZE (1 << DART_PAGE_SHIFT) 74#define DART_PAGE_SIZE (1 << DART_PAGE_SHIFT)
75#define DART_PAGE_FACTOR (PAGE_SHIFT - DART_PAGE_SHIFT)
76 75
77 76
78#endif /* _POWERPC_SYSDEV_DART_H */ 77#endif /* _POWERPC_SYSDEV_DART_H */
diff --git a/arch/powerpc/sysdev/dart_iommu.c b/arch/powerpc/sysdev/dart_iommu.c
index 03b4477dd7f0..572b7846cc77 100644
--- a/arch/powerpc/sysdev/dart_iommu.c
+++ b/arch/powerpc/sysdev/dart_iommu.c
@@ -156,9 +156,6 @@ static void dart_build(struct iommu_table *tbl, long index,
156 156
157 DBG("dart: build at: %lx, %lx, addr: %x\n", index, npages, uaddr); 157 DBG("dart: build at: %lx, %lx, addr: %x\n", index, npages, uaddr);
158 158
159 index <<= DART_PAGE_FACTOR;
160 npages <<= DART_PAGE_FACTOR;
161
162 dp = ((unsigned int*)tbl->it_base) + index; 159 dp = ((unsigned int*)tbl->it_base) + index;
163 160
164 /* On U3, all memory is contigous, so we can move this 161 /* On U3, all memory is contigous, so we can move this
@@ -199,9 +196,6 @@ static void dart_free(struct iommu_table *tbl, long index, long npages)
199 196
200 DBG("dart: free at: %lx, %lx\n", index, npages); 197 DBG("dart: free at: %lx, %lx\n", index, npages);
201 198
202 index <<= DART_PAGE_FACTOR;
203 npages <<= DART_PAGE_FACTOR;
204
205 dp = ((unsigned int *)tbl->it_base) + index; 199 dp = ((unsigned int *)tbl->it_base) + index;
206 200
207 while (npages--) 201 while (npages--)
@@ -281,7 +275,7 @@ static void iommu_table_dart_setup(void)
281 iommu_table_dart.it_busno = 0; 275 iommu_table_dart.it_busno = 0;
282 iommu_table_dart.it_offset = 0; 276 iommu_table_dart.it_offset = 0;
283 /* it_size is in number of entries */ 277 /* it_size is in number of entries */
284 iommu_table_dart.it_size = (dart_tablesize / sizeof(u32)) >> DART_PAGE_FACTOR; 278 iommu_table_dart.it_size = dart_tablesize / sizeof(u32);
285 279
286 /* Initialize the common IOMMU code */ 280 /* Initialize the common IOMMU code */
287 iommu_table_dart.it_base = (unsigned long)dart_vbase; 281 iommu_table_dart.it_base = (unsigned long)dart_vbase;
diff --git a/arch/powerpc/sysdev/i8259.c b/arch/powerpc/sysdev/i8259.c
index 0450265d73bb..ad87adc975bc 100644
--- a/arch/powerpc/sysdev/i8259.c
+++ b/arch/powerpc/sysdev/i8259.c
@@ -224,6 +224,11 @@ static struct irq_host_ops i8259_host_ops = {
224 .xlate = i8259_host_xlate, 224 .xlate = i8259_host_xlate,
225}; 225};
226 226
227struct irq_host *i8259_get_host(void)
228{
229 return i8259_host;
230}
231
227/** 232/**
228 * i8259_init - Initialize the legacy controller 233 * i8259_init - Initialize the legacy controller
229 * @node: device node of the legacy PIC (can be NULL, but then, it will match 234 * @node: device node of the legacy PIC (can be NULL, but then, it will match
diff --git a/arch/powerpc/sysdev/ipic.c b/arch/powerpc/sysdev/ipic.c
index bc4d4a7f9657..746f78c15375 100644
--- a/arch/powerpc/sysdev/ipic.c
+++ b/arch/powerpc/sysdev/ipic.c
@@ -473,9 +473,9 @@ static int ipic_set_irq_type(unsigned int virq, unsigned int flow_type)
473 desc->status |= flow_type & IRQ_TYPE_SENSE_MASK; 473 desc->status |= flow_type & IRQ_TYPE_SENSE_MASK;
474 if (flow_type & IRQ_TYPE_LEVEL_LOW) { 474 if (flow_type & IRQ_TYPE_LEVEL_LOW) {
475 desc->status |= IRQ_LEVEL; 475 desc->status |= IRQ_LEVEL;
476 set_irq_handler(virq, handle_level_irq); 476 desc->handle_irq = handle_level_irq;
477 } else { 477 } else {
478 set_irq_handler(virq, handle_edge_irq); 478 desc->handle_irq = handle_edge_irq;
479 } 479 }
480 480
481 /* only EXT IRQ senses are programmable on ipic 481 /* only EXT IRQ senses are programmable on ipic
diff --git a/arch/powerpc/sysdev/qe_lib/qe.c b/arch/powerpc/sysdev/qe_lib/qe.c
index 2bae632d3ad7..e4223226a7a8 100644
--- a/arch/powerpc/sysdev/qe_lib/qe.c
+++ b/arch/powerpc/sysdev/qe_lib/qe.c
@@ -122,8 +122,7 @@ int qe_issue_cmd(u32 cmd, u32 device, u8 mcn_protocol, u32 cmd_input)
122 mcn_shift = QE_CR_MCN_NORMAL_SHIFT; 122 mcn_shift = QE_CR_MCN_NORMAL_SHIFT;
123 } 123 }
124 124
125 out_be32(&qe_immr->cp.cecdr, 125 out_be32(&qe_immr->cp.cecdr, cmd_input);
126 immrbar_virt_to_phys((void *)cmd_input));
127 out_be32(&qe_immr->cp.cecr, 126 out_be32(&qe_immr->cp.cecr,
128 (cmd | QE_CR_FLG | ((u32) device << dev_shift) | (u32) 127 (cmd | QE_CR_FLG | ((u32) device << dev_shift) | (u32)
129 mcn_protocol << mcn_shift)); 128 mcn_protocol << mcn_shift));
diff --git a/arch/powerpc/sysdev/qe_lib/ucc.c b/arch/powerpc/sysdev/qe_lib/ucc.c
index 916c9e5df57f..ac12a44d516f 100644
--- a/arch/powerpc/sysdev/qe_lib/ucc.c
+++ b/arch/powerpc/sysdev/qe_lib/ucc.c
@@ -207,6 +207,7 @@ int ucc_set_qe_mux_rxtx(int ucc_num, enum qe_clock clock, enum comm_dir mode)
207 case QE_CLK18: source = 8; break; 207 case QE_CLK18: source = 8; break;
208 case QE_CLK7: source = 9; break; 208 case QE_CLK7: source = 9; break;
209 case QE_CLK8: source = 10; break; 209 case QE_CLK8: source = 10; break;
210 case QE_CLK16: source = 11; break;
210 default: source = -1; break; 211 default: source = -1; break;
211 } 212 }
212 break; 213 break;
@@ -222,6 +223,7 @@ int ucc_set_qe_mux_rxtx(int ucc_num, enum qe_clock clock, enum comm_dir mode)
222 case QE_CLK22: source = 8; break; 223 case QE_CLK22: source = 8; break;
223 case QE_CLK7: source = 9; break; 224 case QE_CLK7: source = 9; break;
224 case QE_CLK8: source = 10; break; 225 case QE_CLK8: source = 10; break;
226 case QE_CLK16: source = 11; break;
225 default: source = -1; break; 227 default: source = -1; break;
226 } 228 }
227 break; 229 break;
diff --git a/arch/powerpc/sysdev/qe_lib/ucc_fast.c b/arch/powerpc/sysdev/qe_lib/ucc_fast.c
index c2be7348fcbd..75fa3104a43a 100644
--- a/arch/powerpc/sysdev/qe_lib/ucc_fast.c
+++ b/arch/powerpc/sysdev/qe_lib/ucc_fast.c
@@ -163,7 +163,7 @@ int ucc_fast_init(struct ucc_fast_info * uf_info, struct ucc_fast_private ** ucc
163 163
164 /* check if the UCC port number is in range. */ 164 /* check if the UCC port number is in range. */
165 if ((uf_info->ucc_num < 0) || (uf_info->ucc_num > UCC_MAX_NUM - 1)) { 165 if ((uf_info->ucc_num < 0) || (uf_info->ucc_num > UCC_MAX_NUM - 1)) {
166 uccf_err("ucc_fast_init: Illagal UCC number!"); 166 uccf_err("ucc_fast_init: Illegal UCC number!");
167 return -EINVAL; 167 return -EINVAL;
168 } 168 }
169 169
diff --git a/arch/powerpc/sysdev/qe_lib/ucc_slow.c b/arch/powerpc/sysdev/qe_lib/ucc_slow.c
index 1fb88ef7cf06..a49da6b73ecf 100644
--- a/arch/powerpc/sysdev/qe_lib/ucc_slow.c
+++ b/arch/powerpc/sysdev/qe_lib/ucc_slow.c
@@ -152,7 +152,7 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc
152 152
153 /* check if the UCC port number is in range. */ 153 /* check if the UCC port number is in range. */
154 if ((us_info->ucc_num < 0) || (us_info->ucc_num > UCC_MAX_NUM - 1)) { 154 if ((us_info->ucc_num < 0) || (us_info->ucc_num > UCC_MAX_NUM - 1)) {
155 uccs_err("ucc_slow_init: Illagal UCC number!"); 155 uccs_err("ucc_slow_init: Illegal UCC number!");
156 return -EINVAL; 156 return -EINVAL;
157 } 157 }
158 158
diff --git a/arch/powerpc/sysdev/tsi108_dev.c b/arch/powerpc/sysdev/tsi108_dev.c
index 11de090eb901..97f37ef4bbbf 100644
--- a/arch/powerpc/sysdev/tsi108_dev.c
+++ b/arch/powerpc/sysdev/tsi108_dev.c
@@ -48,7 +48,7 @@ phys_addr_t get_csrbase(void)
48 tsi = of_find_node_by_type(NULL, "tsi-bridge"); 48 tsi = of_find_node_by_type(NULL, "tsi-bridge");
49 if (tsi) { 49 if (tsi) {
50 unsigned int size; 50 unsigned int size;
51 void *prop = get_property(tsi, "reg", &size); 51 const void *prop = get_property(tsi, "reg", &size);
52 tsi108_csr_base = of_translate_address(tsi, prop); 52 tsi108_csr_base = of_translate_address(tsi, prop);
53 of_node_put(tsi); 53 of_node_put(tsi);
54 }; 54 };
@@ -79,7 +79,7 @@ static int __init tsi108_eth_of_init(void)
79 hw_info tsi_eth_data; 79 hw_info tsi_eth_data;
80 unsigned int *id; 80 unsigned int *id;
81 unsigned int *phy_id; 81 unsigned int *phy_id;
82 void *mac_addr; 82 const void *mac_addr;
83 phandle *ph; 83 phandle *ph;
84 84
85 memset(r, 0, sizeof(r)); 85 memset(r, 0, sizeof(r));
diff --git a/arch/ppc/boot/simple/relocate.S b/arch/ppc/boot/simple/relocate.S
index 0c021556d78e..1bbbcd2f2bcb 100644
--- a/arch/ppc/boot/simple/relocate.S
+++ b/arch/ppc/boot/simple/relocate.S
@@ -154,8 +154,8 @@ do_relocate_out:
154 154
155start_ldr: 155start_ldr:
156/* Clear all of BSS and set up stack for C calls */ 156/* Clear all of BSS and set up stack for C calls */
157 lis r3,edata@h 157 lis r3,__bss_start@h
158 ori r3,r3,edata@l 158 ori r3,r3,__bss_start@l
159 lis r4,end@h 159 lis r4,end@h
160 ori r4,r4,end@l 160 ori r4,r4,end@l
161 subi r3,r3,4 161 subi r3,r3,4
@@ -163,7 +163,7 @@ start_ldr:
163 li r0,0 163 li r0,0
16450: stwu r0,4(r3) 16450: stwu r0,4(r3)
165 cmpw cr0,r3,r4 165 cmpw cr0,r3,r4
166 bne 50b 166 blt 50b
16790: mr r9,r1 /* Save old stack pointer (in case it matters) */ 16790: mr r9,r1 /* Save old stack pointer (in case it matters) */
168 lis r1,.stack@h 168 lis r1,.stack@h
169 ori r1,r1,.stack@l 169 ori r1,r1,.stack@l
diff --git a/arch/ppc/kernel/misc.S b/arch/ppc/kernel/misc.S
index 5f6684012ded..d319f9ba2379 100644
--- a/arch/ppc/kernel/misc.S
+++ b/arch/ppc/kernel/misc.S
@@ -110,80 +110,6 @@ _GLOBAL(reloc_got2)
110 blr 110 blr
111 111
112/* 112/*
113 * identify_cpu,
114 * called with r3 = data offset and r4 = CPU number
115 * doesn't change r3
116 */
117_GLOBAL(identify_cpu)
118 addis r8,r3,cpu_specs@ha
119 addi r8,r8,cpu_specs@l
120 mfpvr r7
1211:
122 lwz r5,CPU_SPEC_PVR_MASK(r8)
123 and r5,r5,r7
124 lwz r6,CPU_SPEC_PVR_VALUE(r8)
125 cmplw 0,r6,r5
126 beq 1f
127 addi r8,r8,CPU_SPEC_ENTRY_SIZE
128 b 1b
1291:
130 addis r6,r3,cur_cpu_spec@ha
131 addi r6,r6,cur_cpu_spec@l
132 sub r8,r8,r3
133 stw r8,0(r6)
134 blr
135
136/*
137 * do_cpu_ftr_fixups - goes through the list of CPU feature fixups
138 * and writes nop's over sections of code that don't apply for this cpu.
139 * r3 = data offset (not changed)
140 */
141_GLOBAL(do_cpu_ftr_fixups)
142 /* Get CPU 0 features */
143 addis r6,r3,cur_cpu_spec@ha
144 addi r6,r6,cur_cpu_spec@l
145 lwz r4,0(r6)
146 add r4,r4,r3
147 lwz r4,CPU_SPEC_FEATURES(r4)
148
149 /* Get the fixup table */
150 addis r6,r3,__start___ftr_fixup@ha
151 addi r6,r6,__start___ftr_fixup@l
152 addis r7,r3,__stop___ftr_fixup@ha
153 addi r7,r7,__stop___ftr_fixup@l
154
155 /* Do the fixup */
1561: cmplw 0,r6,r7
157 bgelr
158 addi r6,r6,16
159 lwz r8,-16(r6) /* mask */
160 and r8,r8,r4
161 lwz r9,-12(r6) /* value */
162 cmplw 0,r8,r9
163 beq 1b
164 lwz r8,-8(r6) /* section begin */
165 lwz r9,-4(r6) /* section end */
166 subf. r9,r8,r9
167 beq 1b
168 /* write nops over the section of code */
169 /* todo: if large section, add a branch at the start of it */
170 srwi r9,r9,2
171 mtctr r9
172 add r8,r8,r3
173 lis r0,0x60000000@h /* nop */
1743: stw r0,0(r8)
175 andi. r10,r4,CPU_FTR_SPLIT_ID_CACHE@l
176 beq 2f
177 dcbst 0,r8 /* suboptimal, but simpler */
178 sync
179 icbi 0,r8
1802: addi r8,r8,4
181 bdnz 3b
182 sync /* additional sync needed on g4 */
183 isync
184 b 1b
185
186/*
187 * call_setup_cpu - call the setup_cpu function for this cpu 113 * call_setup_cpu - call the setup_cpu function for this cpu
188 * r3 = data offset, r24 = cpu number 114 * r3 = data offset, r24 = cpu number
189 * 115 *
diff --git a/arch/ppc/kernel/setup.c b/arch/ppc/kernel/setup.c
index 75fe13815be2..27faeca2c7a2 100644
--- a/arch/ppc/kernel/setup.c
+++ b/arch/ppc/kernel/setup.c
@@ -38,6 +38,7 @@
38#include <asm/nvram.h> 38#include <asm/nvram.h>
39#include <asm/xmon.h> 39#include <asm/xmon.h>
40#include <asm/ocp.h> 40#include <asm/ocp.h>
41#include <asm/prom.h>
41 42
42#define USES_PPC_SYS (defined(CONFIG_85xx) || defined(CONFIG_83xx) || \ 43#define USES_PPC_SYS (defined(CONFIG_85xx) || defined(CONFIG_83xx) || \
43 defined(CONFIG_MPC10X_BRIDGE) || defined(CONFIG_8260) || \ 44 defined(CONFIG_MPC10X_BRIDGE) || defined(CONFIG_8260) || \
@@ -53,8 +54,6 @@
53 54
54extern void platform_init(unsigned long r3, unsigned long r4, 55extern void platform_init(unsigned long r3, unsigned long r4,
55 unsigned long r5, unsigned long r6, unsigned long r7); 56 unsigned long r5, unsigned long r6, unsigned long r7);
56extern void identify_cpu(unsigned long offset, unsigned long cpu);
57extern void do_cpu_ftr_fixups(unsigned long offset);
58extern void reloc_got2(unsigned long offset); 57extern void reloc_got2(unsigned long offset);
59 58
60extern void ppc6xx_idle(void); 59extern void ppc6xx_idle(void);
@@ -301,6 +300,7 @@ early_init(int r3, int r4, int r5)
301{ 300{
302 unsigned long phys; 301 unsigned long phys;
303 unsigned long offset = reloc_offset(); 302 unsigned long offset = reloc_offset();
303 struct cpu_spec *spec;
304 304
305 /* Default */ 305 /* Default */
306 phys = offset + KERNELBASE; 306 phys = offset + KERNELBASE;
@@ -313,8 +313,10 @@ early_init(int r3, int r4, int r5)
313 * Identify the CPU type and fix up code sections 313 * Identify the CPU type and fix up code sections
314 * that depend on which cpu we have. 314 * that depend on which cpu we have.
315 */ 315 */
316 identify_cpu(offset, 0); 316 spec = identify_cpu(offset);
317 do_cpu_ftr_fixups(offset); 317 do_feature_fixups(spec->cpu_features,
318 PTRRELOC(&__start___ftr_fixup),
319 PTRRELOC(&__stop___ftr_fixup));
318 320
319 return phys; 321 return phys;
320} 322}
diff --git a/arch/ppc/kernel/time.c b/arch/ppc/kernel/time.c
index d4b2cf74da6a..18ee851e33e3 100644
--- a/arch/ppc/kernel/time.c
+++ b/arch/ppc/kernel/time.c
@@ -62,6 +62,7 @@
62#include <asm/cache.h> 62#include <asm/cache.h>
63#include <asm/8xx_immap.h> 63#include <asm/8xx_immap.h>
64#include <asm/machdep.h> 64#include <asm/machdep.h>
65#include <asm/irq_regs.h>
65 66
66#include <asm/time.h> 67#include <asm/time.h>
67 68
@@ -129,6 +130,7 @@ void wakeup_decrementer(void)
129 */ 130 */
130void timer_interrupt(struct pt_regs * regs) 131void timer_interrupt(struct pt_regs * regs)
131{ 132{
133 struct pt_regs *old_regs;
132 int next_dec; 134 int next_dec;
133 unsigned long cpu = smp_processor_id(); 135 unsigned long cpu = smp_processor_id();
134 unsigned jiffy_stamp = last_jiffy_stamp(cpu); 136 unsigned jiffy_stamp = last_jiffy_stamp(cpu);
@@ -137,6 +139,7 @@ void timer_interrupt(struct pt_regs * regs)
137 if (atomic_read(&ppc_n_lost_interrupts) != 0) 139 if (atomic_read(&ppc_n_lost_interrupts) != 0)
138 do_IRQ(regs); 140 do_IRQ(regs);
139 141
142 old_regs = set_irq_regs(regs);
140 irq_enter(); 143 irq_enter();
141 144
142 while ((next_dec = tb_ticks_per_jiffy - tb_delta(&jiffy_stamp)) <= 0) { 145 while ((next_dec = tb_ticks_per_jiffy - tb_delta(&jiffy_stamp)) <= 0) {
@@ -188,6 +191,7 @@ void timer_interrupt(struct pt_regs * regs)
188 ppc_md.heartbeat(); 191 ppc_md.heartbeat();
189 192
190 irq_exit(); 193 irq_exit();
194 set_irq_regs(old_regs);
191} 195}
192 196
193/* 197/*
diff --git a/arch/ppc/kernel/traps.c b/arch/ppc/kernel/traps.c
index aafc8e8893d1..9661a91183b3 100644
--- a/arch/ppc/kernel/traps.c
+++ b/arch/ppc/kernel/traps.c
@@ -708,7 +708,7 @@ void single_step_exception(struct pt_regs *regs)
708 708
709void alignment_exception(struct pt_regs *regs) 709void alignment_exception(struct pt_regs *regs)
710{ 710{
711 int fixed; 711 int sig, code, fixed = 0;
712 712
713 fixed = fix_alignment(regs); 713 fixed = fix_alignment(regs);
714 if (fixed == 1) { 714 if (fixed == 1) {
@@ -717,14 +717,16 @@ void alignment_exception(struct pt_regs *regs)
717 return; 717 return;
718 } 718 }
719 if (fixed == -EFAULT) { 719 if (fixed == -EFAULT) {
720 /* fixed == -EFAULT means the operand address was bad */ 720 sig = SIGSEGV;
721 if (user_mode(regs)) 721 code = SEGV_ACCERR;
722 _exception(SIGSEGV, regs, SEGV_ACCERR, regs->dar); 722 } else {
723 else 723 sig = SIGBUS;
724 bad_page_fault(regs, regs->dar, SIGSEGV); 724 code = BUS_ADRALN;
725 return;
726 } 725 }
727 _exception(SIGBUS, regs, BUS_ADRALN, regs->dar); 726 if (user_mode(regs))
727 _exception(sig, regs, code, regs->dar);
728 else
729 bad_page_fault(regs, regs->dar, sig);
728} 730}
729 731
730void StackOverflow(struct pt_regs *regs) 732void StackOverflow(struct pt_regs *regs)
diff --git a/arch/ppc/kernel/vmlinux.lds.S b/arch/ppc/kernel/vmlinux.lds.S
index 095fd3323323..16e8661e1fec 100644
--- a/arch/ppc/kernel/vmlinux.lds.S
+++ b/arch/ppc/kernel/vmlinux.lds.S
@@ -115,13 +115,7 @@ SECTIONS
115 __setup_end = .; 115 __setup_end = .;
116 __initcall_start = .; 116 __initcall_start = .;
117 .initcall.init : { 117 .initcall.init : {
118 *(.initcall1.init) 118 INITCALLS
119 *(.initcall2.init)
120 *(.initcall3.init)
121 *(.initcall4.init)
122 *(.initcall5.init)
123 *(.initcall6.init)
124 *(.initcall7.init)
125 } 119 }
126 __initcall_end = .; 120 __initcall_end = .;
127 121
diff --git a/arch/ppc/mm/init.c b/arch/ppc/mm/init.c
index 410200046af1..c374e53ae03a 100644
--- a/arch/ppc/mm/init.c
+++ b/arch/ppc/mm/init.c
@@ -374,11 +374,12 @@ void __init paging_init(void)
374 end_pfn = start_pfn + (total_memory >> PAGE_SHIFT); 374 end_pfn = start_pfn + (total_memory >> PAGE_SHIFT);
375 add_active_range(0, start_pfn, end_pfn); 375 add_active_range(0, start_pfn, end_pfn);
376 376
377 memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
377#ifdef CONFIG_HIGHMEM 378#ifdef CONFIG_HIGHMEM
378 max_zone_pfns[0] = total_lowmem >> PAGE_SHIFT; 379 max_zone_pfns[ZONE_DMA] = total_lowmem >> PAGE_SHIFT;
379 max_zone_pfns[1] = total_memory >> PAGE_SHIFT; 380 max_zone_pfns[ZONE_HIGHMEM] = total_memory >> PAGE_SHIFT;
380#else 381#else
381 max_zone_pfns[0] = total_memory >> PAGE_SHIFT; 382 max_zone_pfns[ZONE_DMA] = total_memory >> PAGE_SHIFT;
382#endif /* CONFIG_HIGHMEM */ 383#endif /* CONFIG_HIGHMEM */
383 free_area_init_nodes(max_zone_pfns); 384 free_area_init_nodes(max_zone_pfns);
384} 385}
diff --git a/arch/ppc/platforms/mpc8272ads_setup.c b/arch/ppc/platforms/mpc8272ads_setup.c
index d7b3a6afa78f..1f9ea36837b1 100644
--- a/arch/ppc/platforms/mpc8272ads_setup.c
+++ b/arch/ppc/platforms/mpc8272ads_setup.c
@@ -196,7 +196,7 @@ static void __init mpc8272ads_fixup_enet_pdata(struct platform_device *pdev,
196 bd_t* bi = (void*)__res; 196 bd_t* bi = (void*)__res;
197 int fs_no = fsid_fcc1+pdev->id-1; 197 int fs_no = fsid_fcc1+pdev->id-1;
198 198
199 if(fs_no > ARRAY_SIZE(mpc82xx_enet_pdata)) { 199 if(fs_no >= ARRAY_SIZE(mpc82xx_enet_pdata)) {
200 return; 200 return;
201 } 201 }
202 202
@@ -222,7 +222,7 @@ static void mpc8272ads_fixup_uart_pdata(struct platform_device *pdev,
222 int id = fs_uart_id_scc2fsid(idx); 222 int id = fs_uart_id_scc2fsid(idx);
223 223
224 /* no need to alter anything if console */ 224 /* no need to alter anything if console */
225 if ((id <= num) && (!pdev->dev.platform_data)) { 225 if ((id < num) && (!pdev->dev.platform_data)) {
226 pinfo = &mpc8272_uart_pdata[id]; 226 pinfo = &mpc8272_uart_pdata[id];
227 pinfo->uart_clk = bd->bi_intfreq; 227 pinfo->uart_clk = bd->bi_intfreq;
228 pdev->dev.platform_data = pinfo; 228 pdev->dev.platform_data = pinfo;
diff --git a/arch/ppc/platforms/mpc866ads_setup.c b/arch/ppc/platforms/mpc866ads_setup.c
index 5f130dca3770..e95d2c111747 100644
--- a/arch/ppc/platforms/mpc866ads_setup.c
+++ b/arch/ppc/platforms/mpc866ads_setup.c
@@ -259,7 +259,7 @@ static void mpc866ads_fixup_enet_pdata(struct platform_device *pdev, int fs_no)
259 /* Get pointer to Communication Processor */ 259 /* Get pointer to Communication Processor */
260 cp = cpmp; 260 cp = cpmp;
261 261
262 if(fs_no > ARRAY_SIZE(mpc8xx_enet_pdata)) { 262 if(fs_no >= ARRAY_SIZE(mpc8xx_enet_pdata)) {
263 printk(KERN_ERR"No network-suitable #%d device on bus", fs_no); 263 printk(KERN_ERR"No network-suitable #%d device on bus", fs_no);
264 return; 264 return;
265 } 265 }
@@ -305,7 +305,7 @@ static void __init mpc866ads_fixup_uart_pdata(struct platform_device *pdev,
305 int id = fs_uart_id_smc2fsid(idx); 305 int id = fs_uart_id_smc2fsid(idx);
306 306
307 /* no need to alter anything if console */ 307 /* no need to alter anything if console */
308 if ((id <= num) && (!pdev->dev.platform_data)) { 308 if ((id < num) && (!pdev->dev.platform_data)) {
309 pinfo = &mpc866_uart_pdata[id]; 309 pinfo = &mpc866_uart_pdata[id];
310 pinfo->uart_clk = bd->bi_intfreq; 310 pinfo->uart_clk = bd->bi_intfreq;
311 pdev->dev.platform_data = pinfo; 311 pdev->dev.platform_data = pinfo;
diff --git a/arch/ppc/platforms/mpc885ads_setup.c b/arch/ppc/platforms/mpc885ads_setup.c
index 02293141efb5..f8161f3557f5 100644
--- a/arch/ppc/platforms/mpc885ads_setup.c
+++ b/arch/ppc/platforms/mpc885ads_setup.c
@@ -263,7 +263,7 @@ static void mpc885ads_fixup_enet_pdata(struct platform_device *pdev, int fs_no)
263 char *e; 263 char *e;
264 int i; 264 int i;
265 265
266 if(fs_no > ARRAY_SIZE(mpc8xx_enet_pdata)) { 266 if(fs_no >= ARRAY_SIZE(mpc8xx_enet_pdata)) {
267 printk(KERN_ERR"No network-suitable #%d device on bus", fs_no); 267 printk(KERN_ERR"No network-suitable #%d device on bus", fs_no);
268 return; 268 return;
269 } 269 }
@@ -371,7 +371,7 @@ static void __init mpc885ads_fixup_uart_pdata(struct platform_device *pdev,
371 int id = fs_uart_id_smc2fsid(idx); 371 int id = fs_uart_id_smc2fsid(idx);
372 372
373 /* no need to alter anything if console */ 373 /* no need to alter anything if console */
374 if ((id <= num) && (!pdev->dev.platform_data)) { 374 if ((id < num) && (!pdev->dev.platform_data)) {
375 pinfo = &mpc885_uart_pdata[id]; 375 pinfo = &mpc885_uart_pdata[id];
376 pinfo->uart_clk = bd->bi_intfreq; 376 pinfo->uart_clk = bd->bi_intfreq;
377 pdev->dev.platform_data = pinfo; 377 pdev->dev.platform_data = pinfo;
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 608193cfe43f..245b81bc7157 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -236,9 +236,6 @@ config WARN_STACK_SIZE
236 This allows you to specify the maximum frame size a function may 236 This allows you to specify the maximum frame size a function may
237 have without the compiler complaining about it. 237 have without the compiler complaining about it.
238 238
239config ARCH_POPULATES_NODE_MAP
240 def_bool y
241
242source "mm/Kconfig" 239source "mm/Kconfig"
243 240
244comment "I/O subsystem configuration" 241comment "I/O subsystem configuration"
diff --git a/arch/s390/appldata/appldata_base.c b/arch/s390/appldata/appldata_base.c
index 2b1e6c9a6e0e..af1e8fc7d985 100644
--- a/arch/s390/appldata/appldata_base.c
+++ b/arch/s390/appldata/appldata_base.c
@@ -109,7 +109,7 @@ static LIST_HEAD(appldata_ops_list);
109 * 109 *
110 * schedule work and reschedule timer 110 * schedule work and reschedule timer
111 */ 111 */
112static void appldata_timer_function(unsigned long data, struct pt_regs *regs) 112static void appldata_timer_function(unsigned long data)
113{ 113{
114 P_DEBUG(" -= Timer =-\n"); 114 P_DEBUG(" -= Timer =-\n");
115 P_DEBUG("CPU: %i, expire_count: %i\n", smp_processor_id(), 115 P_DEBUG("CPU: %i, expire_count: %i\n", smp_processor_id(),
@@ -310,6 +310,7 @@ appldata_interval_handler(ctl_table *ctl, int write, struct file *filp,
310 if (copy_from_user(buf, buffer, len > sizeof(buf) ? sizeof(buf) : len)) { 310 if (copy_from_user(buf, buffer, len > sizeof(buf) ? sizeof(buf) : len)) {
311 return -EFAULT; 311 return -EFAULT;
312 } 312 }
313 interval = 0;
313 sscanf(buf, "%i", &interval); 314 sscanf(buf, "%i", &interval);
314 if (interval <= 0) { 315 if (interval <= 0) {
315 P_ERROR("Timer CPU interval has to be > 0!\n"); 316 P_ERROR("Timer CPU interval has to be > 0!\n");
diff --git a/arch/s390/defconfig b/arch/s390/defconfig
index a3257398ea8d..7cd51e73e274 100644
--- a/arch/s390/defconfig
+++ b/arch/s390/defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.18 3# Linux kernel version: 2.6.19-rc2
4# Wed Oct 4 19:45:46 2006 4# Wed Oct 18 17:11:10 2006
5# 5#
6CONFIG_MMU=y 6CONFIG_MMU=y
7CONFIG_LOCKDEP_SUPPORT=y 7CONFIG_LOCKDEP_SUPPORT=y
@@ -119,7 +119,6 @@ CONFIG_PACK_STACK=y
119CONFIG_CHECK_STACK=y 119CONFIG_CHECK_STACK=y
120CONFIG_STACK_GUARD=256 120CONFIG_STACK_GUARD=256
121# CONFIG_WARN_STACK is not set 121# CONFIG_WARN_STACK is not set
122CONFIG_ARCH_POPULATES_NODE_MAP=y
123CONFIG_SELECT_MEMORY_MODEL=y 122CONFIG_SELECT_MEMORY_MODEL=y
124CONFIG_FLATMEM_MANUAL=y 123CONFIG_FLATMEM_MANUAL=y
125# CONFIG_DISCONTIGMEM_MANUAL is not set 124# CONFIG_DISCONTIGMEM_MANUAL is not set
@@ -211,6 +210,7 @@ CONFIG_INET6_XFRM_MODE_TRANSPORT=y
211CONFIG_INET6_XFRM_MODE_TUNNEL=y 210CONFIG_INET6_XFRM_MODE_TUNNEL=y
212CONFIG_INET6_XFRM_MODE_BEET=y 211CONFIG_INET6_XFRM_MODE_BEET=y
213# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set 212# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
213CONFIG_IPV6_SIT=y
214# CONFIG_IPV6_TUNNEL is not set 214# CONFIG_IPV6_TUNNEL is not set
215# CONFIG_IPV6_SUBTREES is not set 215# CONFIG_IPV6_SUBTREES is not set
216# CONFIG_IPV6_MULTIPLE_TABLES is not set 216# CONFIG_IPV6_MULTIPLE_TABLES is not set
@@ -528,6 +528,7 @@ CONFIG_EXT3_FS=y
528CONFIG_EXT3_FS_XATTR=y 528CONFIG_EXT3_FS_XATTR=y
529# CONFIG_EXT3_FS_POSIX_ACL is not set 529# CONFIG_EXT3_FS_POSIX_ACL is not set
530# CONFIG_EXT3_FS_SECURITY is not set 530# CONFIG_EXT3_FS_SECURITY is not set
531# CONFIG_EXT4DEV_FS is not set
531CONFIG_JBD=y 532CONFIG_JBD=y
532# CONFIG_JBD_DEBUG is not set 533# CONFIG_JBD_DEBUG is not set
533CONFIG_FS_MBCACHE=y 534CONFIG_FS_MBCACHE=y
@@ -646,10 +647,6 @@ CONFIG_MSDOS_PARTITION=y
646# CONFIG_NLS is not set 647# CONFIG_NLS is not set
647 648
648# 649#
649# Distributed Lock Manager
650#
651
652#
653# Instrumentation Support 650# Instrumentation Support
654# 651#
655 652
@@ -669,7 +666,6 @@ CONFIG_MAGIC_SYSRQ=y
669# CONFIG_UNUSED_SYMBOLS is not set 666# CONFIG_UNUSED_SYMBOLS is not set
670CONFIG_DEBUG_KERNEL=y 667CONFIG_DEBUG_KERNEL=y
671CONFIG_LOG_BUF_SHIFT=17 668CONFIG_LOG_BUF_SHIFT=17
672# CONFIG_DETECT_SOFTLOCKUP is not set
673# CONFIG_SCHEDSTATS is not set 669# CONFIG_SCHEDSTATS is not set
674# CONFIG_DEBUG_SLAB is not set 670# CONFIG_DEBUG_SLAB is not set
675CONFIG_DEBUG_PREEMPT=y 671CONFIG_DEBUG_PREEMPT=y
@@ -690,6 +686,7 @@ CONFIG_DEBUG_FS=y
690# CONFIG_FRAME_POINTER is not set 686# CONFIG_FRAME_POINTER is not set
691# CONFIG_UNWIND_INFO is not set 687# CONFIG_UNWIND_INFO is not set
692CONFIG_FORCED_INLINING=y 688CONFIG_FORCED_INLINING=y
689CONFIG_HEADERS_CHECK=y
693# CONFIG_RCU_TORTURE_TEST is not set 690# CONFIG_RCU_TORTURE_TEST is not set
694# CONFIG_LKDTM is not set 691# CONFIG_LKDTM is not set
695 692
diff --git a/arch/s390/kernel/compat_linux.c b/arch/s390/kernel/compat_linux.c
index e15e1489aef5..5b33f823863a 100644
--- a/arch/s390/kernel/compat_linux.c
+++ b/arch/s390/kernel/compat_linux.c
@@ -295,6 +295,7 @@ static inline long put_tv32(struct compat_timeval __user *o, struct timeval *i)
295 * 295 *
296 * This is really horribly ugly. 296 * This is really horribly ugly.
297 */ 297 */
298#ifdef CONFIG_SYSVIPC
298asmlinkage long sys32_ipc(u32 call, int first, int second, int third, u32 ptr) 299asmlinkage long sys32_ipc(u32 call, int first, int second, int third, u32 ptr)
299{ 300{
300 if (call >> 16) /* hack for backward compatibility */ 301 if (call >> 16) /* hack for backward compatibility */
@@ -338,6 +339,7 @@ asmlinkage long sys32_ipc(u32 call, int first, int second, int third, u32 ptr)
338 339
339 return -ENOSYS; 340 return -ENOSYS;
340} 341}
342#endif
341 343
342asmlinkage long sys32_truncate64(const char __user * path, unsigned long high, unsigned long low) 344asmlinkage long sys32_truncate64(const char __user * path, unsigned long high, unsigned long low)
343{ 345{
@@ -755,7 +757,9 @@ asmlinkage long sys32_sysctl(struct __sysctl_args32 __user *args)
755 put_user(oldlen, (u32 __user *)compat_ptr(tmp.oldlenp))) 757 put_user(oldlen, (u32 __user *)compat_ptr(tmp.oldlenp)))
756 error = -EFAULT; 758 error = -EFAULT;
757 } 759 }
758 copy_to_user(args->__unused, tmp.__unused, sizeof(tmp.__unused)); 760 if (copy_to_user(args->__unused, tmp.__unused,
761 sizeof(tmp.__unused)))
762 error = -EFAULT;
759 } 763 }
760 return error; 764 return error;
761} 765}
diff --git a/arch/s390/kernel/compat_signal.c b/arch/s390/kernel/compat_signal.c
index d49b876a83bf..861888ab8c13 100644
--- a/arch/s390/kernel/compat_signal.c
+++ b/arch/s390/kernel/compat_signal.c
@@ -169,12 +169,12 @@ sys32_sigaction(int sig, const struct old_sigaction32 __user *act,
169 compat_old_sigset_t mask; 169 compat_old_sigset_t mask;
170 if (!access_ok(VERIFY_READ, act, sizeof(*act)) || 170 if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
171 __get_user(sa_handler, &act->sa_handler) || 171 __get_user(sa_handler, &act->sa_handler) ||
172 __get_user(sa_restorer, &act->sa_restorer)) 172 __get_user(sa_restorer, &act->sa_restorer) ||
173 __get_user(new_ka.sa.sa_flags, &act->sa_flags) ||
174 __get_user(mask, &act->sa_mask))
173 return -EFAULT; 175 return -EFAULT;
174 new_ka.sa.sa_handler = (__sighandler_t) sa_handler; 176 new_ka.sa.sa_handler = (__sighandler_t) sa_handler;
175 new_ka.sa.sa_restorer = (void (*)(void)) sa_restorer; 177 new_ka.sa.sa_restorer = (void (*)(void)) sa_restorer;
176 __get_user(new_ka.sa.sa_flags, &act->sa_flags);
177 __get_user(mask, &act->sa_mask);
178 siginitset(&new_ka.sa.sa_mask, mask); 178 siginitset(&new_ka.sa.sa_mask, mask);
179 } 179 }
180 180
@@ -185,10 +185,10 @@ sys32_sigaction(int sig, const struct old_sigaction32 __user *act,
185 sa_restorer = (unsigned long) old_ka.sa.sa_restorer; 185 sa_restorer = (unsigned long) old_ka.sa.sa_restorer;
186 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) || 186 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
187 __put_user(sa_handler, &oact->sa_handler) || 187 __put_user(sa_handler, &oact->sa_handler) ||
188 __put_user(sa_restorer, &oact->sa_restorer)) 188 __put_user(sa_restorer, &oact->sa_restorer) ||
189 __put_user(old_ka.sa.sa_flags, &oact->sa_flags) ||
190 __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask))
189 return -EFAULT; 191 return -EFAULT;
190 __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
191 __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
192 } 192 }
193 193
194 return ret; 194 return ret;
diff --git a/arch/s390/kernel/compat_wrapper.S b/arch/s390/kernel/compat_wrapper.S
index cb0efae6802f..71e54ef0931e 100644
--- a/arch/s390/kernel/compat_wrapper.S
+++ b/arch/s390/kernel/compat_wrapper.S
@@ -1664,4 +1664,4 @@ sys_getcpu_wrapper:
1664 llgtr %r2,%r2 # unsigned * 1664 llgtr %r2,%r2 # unsigned *
1665 llgtr %r3,%r3 # unsigned * 1665 llgtr %r3,%r3 # unsigned *
1666 llgtr %r4,%r4 # struct getcpu_cache * 1666 llgtr %r4,%r4 # struct getcpu_cache *
1667 jg sys_tee 1667 jg sys_getcpu
diff --git a/arch/s390/kernel/s390_ext.c b/arch/s390/kernel/s390_ext.c
index c49ab8c784d2..4faf96f8a834 100644
--- a/arch/s390/kernel/s390_ext.c
+++ b/arch/s390/kernel/s390_ext.c
@@ -117,8 +117,8 @@ void do_extint(struct pt_regs *regs, unsigned short code)
117 int index; 117 int index;
118 struct pt_regs *old_regs; 118 struct pt_regs *old_regs;
119 119
120 irq_enter();
121 old_regs = set_irq_regs(regs); 120 old_regs = set_irq_regs(regs);
121 irq_enter();
122 asm volatile ("mc 0,0"); 122 asm volatile ("mc 0,0");
123 if (S390_lowcore.int_clock >= S390_lowcore.jiffy_timer) 123 if (S390_lowcore.int_clock >= S390_lowcore.jiffy_timer)
124 /** 124 /**
@@ -134,8 +134,8 @@ void do_extint(struct pt_regs *regs, unsigned short code)
134 p->handler(code); 134 p->handler(code);
135 } 135 }
136 } 136 }
137 set_irq_regs(old_regs);
138 irq_exit(); 137 irq_exit();
138 set_irq_regs(old_regs);
139} 139}
140 140
141EXPORT_SYMBOL(register_external_interrupt); 141EXPORT_SYMBOL(register_external_interrupt);
diff --git a/arch/s390/kernel/s390_ksyms.c b/arch/s390/kernel/s390_ksyms.c
index 9f19e833a562..90b5ef529eb7 100644
--- a/arch/s390/kernel/s390_ksyms.c
+++ b/arch/s390/kernel/s390_ksyms.c
@@ -51,4 +51,3 @@ EXPORT_SYMBOL(csum_fold);
51EXPORT_SYMBOL(console_mode); 51EXPORT_SYMBOL(console_mode);
52EXPORT_SYMBOL(console_devno); 52EXPORT_SYMBOL(console_devno);
53EXPORT_SYMBOL(console_irq); 53EXPORT_SYMBOL(console_irq);
54EXPORT_SYMBOL(sys_wait4);
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index 49f2b68e32b1..2aa13e8e000a 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -70,6 +70,7 @@ struct {
70#define CHUNK_READ_WRITE 0 70#define CHUNK_READ_WRITE 0
71#define CHUNK_READ_ONLY 1 71#define CHUNK_READ_ONLY 1
72volatile int __cpu_logical_map[NR_CPUS]; /* logical cpu to cpu address */ 72volatile int __cpu_logical_map[NR_CPUS]; /* logical cpu to cpu address */
73unsigned long __initdata zholes_size[MAX_NR_ZONES];
73static unsigned long __initdata memory_end; 74static unsigned long __initdata memory_end;
74 75
75/* 76/*
@@ -357,6 +358,21 @@ void machine_power_off(void)
357 */ 358 */
358void (*pm_power_off)(void) = machine_power_off; 359void (*pm_power_off)(void) = machine_power_off;
359 360
361static void __init
362add_memory_hole(unsigned long start, unsigned long end)
363{
364 unsigned long dma_pfn = MAX_DMA_ADDRESS >> PAGE_SHIFT;
365
366 if (end <= dma_pfn)
367 zholes_size[ZONE_DMA] += end - start + 1;
368 else if (start > dma_pfn)
369 zholes_size[ZONE_NORMAL] += end - start + 1;
370 else {
371 zholes_size[ZONE_DMA] += dma_pfn - start + 1;
372 zholes_size[ZONE_NORMAL] += end - dma_pfn;
373 }
374}
375
360static int __init early_parse_mem(char *p) 376static int __init early_parse_mem(char *p)
361{ 377{
362 memory_end = memparse(p, &p); 378 memory_end = memparse(p, &p);
@@ -434,7 +450,7 @@ setup_lowcore(void)
434 lc->extended_save_area_addr = (__u32) 450 lc->extended_save_area_addr = (__u32)
435 __alloc_bootmem(PAGE_SIZE, PAGE_SIZE, 0); 451 __alloc_bootmem(PAGE_SIZE, PAGE_SIZE, 0);
436 /* enable extended save area */ 452 /* enable extended save area */
437 ctl_set_bit(14, 29); 453 __ctl_set_bit(14, 29);
438 } 454 }
439#endif 455#endif
440 set_prefix((u32)(unsigned long) lc); 456 set_prefix((u32)(unsigned long) lc);
@@ -478,6 +494,7 @@ setup_memory(void)
478{ 494{
479 unsigned long bootmap_size; 495 unsigned long bootmap_size;
480 unsigned long start_pfn, end_pfn, init_pfn; 496 unsigned long start_pfn, end_pfn, init_pfn;
497 unsigned long last_rw_end;
481 int i; 498 int i;
482 499
483 /* 500 /*
@@ -533,27 +550,39 @@ setup_memory(void)
533 /* 550 /*
534 * Register RAM areas with the bootmem allocator. 551 * Register RAM areas with the bootmem allocator.
535 */ 552 */
553 last_rw_end = start_pfn;
536 554
537 for (i = 0; i < MEMORY_CHUNKS && memory_chunk[i].size > 0; i++) { 555 for (i = 0; i < MEMORY_CHUNKS && memory_chunk[i].size > 0; i++) {
538 unsigned long start_chunk, end_chunk, pfn; 556 unsigned long start_chunk, end_chunk;
539 557
540 if (memory_chunk[i].type != CHUNK_READ_WRITE) 558 if (memory_chunk[i].type != CHUNK_READ_WRITE)
541 continue; 559 continue;
542 start_chunk = PFN_DOWN(memory_chunk[i].addr); 560 start_chunk = (memory_chunk[i].addr + PAGE_SIZE - 1);
543 end_chunk = start_chunk + PFN_DOWN(memory_chunk[i].size) - 1; 561 start_chunk >>= PAGE_SHIFT;
544 end_chunk = min(end_chunk, end_pfn); 562 end_chunk = (memory_chunk[i].addr + memory_chunk[i].size);
545 if (start_chunk >= end_chunk) 563 end_chunk >>= PAGE_SHIFT;
546 continue; 564 if (start_chunk < start_pfn)
547 add_active_range(0, start_chunk, end_chunk); 565 start_chunk = start_pfn;
548 pfn = max(start_chunk, start_pfn); 566 if (end_chunk > end_pfn)
549 for (; pfn <= end_chunk; pfn++) 567 end_chunk = end_pfn;
550 page_set_storage_key(PFN_PHYS(pfn), PAGE_DEFAULT_KEY); 568 if (start_chunk < end_chunk) {
569 /* Initialize storage key for RAM pages */
570 for (init_pfn = start_chunk ; init_pfn < end_chunk;
571 init_pfn++)
572 page_set_storage_key(init_pfn << PAGE_SHIFT,
573 PAGE_DEFAULT_KEY);
574 free_bootmem(start_chunk << PAGE_SHIFT,
575 (end_chunk - start_chunk) << PAGE_SHIFT);
576 if (last_rw_end < start_chunk)
577 add_memory_hole(last_rw_end, start_chunk - 1);
578 last_rw_end = end_chunk;
579 }
551 } 580 }
552 581
553 psw_set_key(PAGE_DEFAULT_KEY); 582 psw_set_key(PAGE_DEFAULT_KEY);
554 583
555 free_bootmem_with_active_regions(0, max_pfn); 584 if (last_rw_end < end_pfn - 1)
556 reserve_bootmem(0, PFN_PHYS(start_pfn)); 585 add_memory_hole(last_rw_end, end_pfn - 1);
557 586
558 /* 587 /*
559 * Reserve the bootmem bitmap itself as well. We do this in two 588 * Reserve the bootmem bitmap itself as well. We do this in two
diff --git a/arch/s390/kernel/signal.c b/arch/s390/kernel/signal.c
index 4392a77cbae8..4c8a7954ef48 100644
--- a/arch/s390/kernel/signal.c
+++ b/arch/s390/kernel/signal.c
@@ -80,10 +80,10 @@ sys_sigaction(int sig, const struct old_sigaction __user *act,
80 old_sigset_t mask; 80 old_sigset_t mask;
81 if (!access_ok(VERIFY_READ, act, sizeof(*act)) || 81 if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
82 __get_user(new_ka.sa.sa_handler, &act->sa_handler) || 82 __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
83 __get_user(new_ka.sa.sa_restorer, &act->sa_restorer)) 83 __get_user(new_ka.sa.sa_restorer, &act->sa_restorer) ||
84 __get_user(new_ka.sa.sa_flags, &act->sa_flags) ||
85 __get_user(mask, &act->sa_mask))
84 return -EFAULT; 86 return -EFAULT;
85 __get_user(new_ka.sa.sa_flags, &act->sa_flags);
86 __get_user(mask, &act->sa_mask);
87 siginitset(&new_ka.sa.sa_mask, mask); 87 siginitset(&new_ka.sa.sa_mask, mask);
88 } 88 }
89 89
@@ -92,10 +92,10 @@ sys_sigaction(int sig, const struct old_sigaction __user *act,
92 if (!ret && oact) { 92 if (!ret && oact) {
93 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) || 93 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
94 __put_user(old_ka.sa.sa_handler, &oact->sa_handler) || 94 __put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
95 __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer)) 95 __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer) ||
96 __put_user(old_ka.sa.sa_flags, &oact->sa_flags) ||
97 __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask))
96 return -EFAULT; 98 return -EFAULT;
97 __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
98 __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
99 } 99 }
100 100
101 return ret; 101 return ret;
diff --git a/arch/s390/kernel/stacktrace.c b/arch/s390/kernel/stacktrace.c
index d9428a0fc8fb..0d14a4789bf2 100644
--- a/arch/s390/kernel/stacktrace.c
+++ b/arch/s390/kernel/stacktrace.c
@@ -62,27 +62,26 @@ static inline unsigned long save_context_stack(struct stack_trace *trace,
62void save_stack_trace(struct stack_trace *trace, struct task_struct *task) 62void save_stack_trace(struct stack_trace *trace, struct task_struct *task)
63{ 63{
64 register unsigned long sp asm ("15"); 64 register unsigned long sp asm ("15");
65 unsigned long orig_sp; 65 unsigned long orig_sp, new_sp;
66 66
67 sp &= PSW_ADDR_INSN; 67 orig_sp = sp & PSW_ADDR_INSN;
68 orig_sp = sp;
69 68
70 sp = save_context_stack(trace, &trace->skip, sp, 69 new_sp = save_context_stack(trace, &trace->skip, orig_sp,
71 S390_lowcore.panic_stack - PAGE_SIZE, 70 S390_lowcore.panic_stack - PAGE_SIZE,
72 S390_lowcore.panic_stack); 71 S390_lowcore.panic_stack);
73 if ((sp != orig_sp) && !trace->all_contexts) 72 if ((new_sp != orig_sp) && !trace->all_contexts)
74 return; 73 return;
75 sp = save_context_stack(trace, &trace->skip, sp, 74 new_sp = save_context_stack(trace, &trace->skip, new_sp,
76 S390_lowcore.async_stack - ASYNC_SIZE, 75 S390_lowcore.async_stack - ASYNC_SIZE,
77 S390_lowcore.async_stack); 76 S390_lowcore.async_stack);
78 if ((sp != orig_sp) && !trace->all_contexts) 77 if ((new_sp != orig_sp) && !trace->all_contexts)
79 return; 78 return;
80 if (task) 79 if (task)
81 save_context_stack(trace, &trace->skip, sp, 80 save_context_stack(trace, &trace->skip, new_sp,
82 (unsigned long) task_stack_page(task), 81 (unsigned long) task_stack_page(task),
83 (unsigned long) task_stack_page(task) + THREAD_SIZE); 82 (unsigned long) task_stack_page(task) + THREAD_SIZE);
84 else 83 else
85 save_context_stack(trace, &trace->skip, sp, 84 save_context_stack(trace, &trace->skip, new_sp,
86 S390_lowcore.thread_info, 85 S390_lowcore.thread_info,
87 S390_lowcore.thread_info + THREAD_SIZE); 86 S390_lowcore.thread_info + THREAD_SIZE);
88 return; 87 return;
diff --git a/arch/s390/kernel/syscalls.S b/arch/s390/kernel/syscalls.S
index e59baec56520..a4ceae3dbcf1 100644
--- a/arch/s390/kernel/syscalls.S
+++ b/arch/s390/kernel/syscalls.S
@@ -320,3 +320,4 @@ SYSCALL(sys_tee,sys_tee,sys_tee_wrapper)
320SYSCALL(sys_vmsplice,sys_vmsplice,compat_sys_vmsplice_wrapper) 320SYSCALL(sys_vmsplice,sys_vmsplice,compat_sys_vmsplice_wrapper)
321NI_SYSCALL /* 310 sys_move_pages */ 321NI_SYSCALL /* 310 sys_move_pages */
322SYSCALL(sys_getcpu,sys_getcpu,sys_getcpu_wrapper) 322SYSCALL(sys_getcpu,sys_getcpu,sys_getcpu_wrapper)
323SYSCALL(sys_epoll_pwait,sys_epoll_pwait,sys_ni_syscall)
diff --git a/arch/s390/kernel/traps.c b/arch/s390/kernel/traps.c
index 66375a5e3d12..92ecffbc8d82 100644
--- a/arch/s390/kernel/traps.c
+++ b/arch/s390/kernel/traps.c
@@ -462,7 +462,8 @@ asmlinkage void illegal_op(struct pt_regs * regs, long interruption_code)
462 local_irq_enable(); 462 local_irq_enable();
463 463
464 if (regs->psw.mask & PSW_MASK_PSTATE) { 464 if (regs->psw.mask & PSW_MASK_PSTATE) {
465 get_user(*((__u16 *) opcode), (__u16 __user *) location); 465 if (get_user(*((__u16 *) opcode), (__u16 __user *) location))
466 return;
466 if (*((__u16 *) opcode) == S390_BREAKPOINT_U16) { 467 if (*((__u16 *) opcode) == S390_BREAKPOINT_U16) {
467 if (current->ptrace & PT_PTRACED) 468 if (current->ptrace & PT_PTRACED)
468 force_sig(SIGTRAP, current); 469 force_sig(SIGTRAP, current);
@@ -470,20 +471,25 @@ asmlinkage void illegal_op(struct pt_regs * regs, long interruption_code)
470 signal = SIGILL; 471 signal = SIGILL;
471#ifdef CONFIG_MATHEMU 472#ifdef CONFIG_MATHEMU
472 } else if (opcode[0] == 0xb3) { 473 } else if (opcode[0] == 0xb3) {
473 get_user(*((__u16 *) (opcode+2)), location+1); 474 if (get_user(*((__u16 *) (opcode+2)), location+1))
475 return;
474 signal = math_emu_b3(opcode, regs); 476 signal = math_emu_b3(opcode, regs);
475 } else if (opcode[0] == 0xed) { 477 } else if (opcode[0] == 0xed) {
476 get_user(*((__u32 *) (opcode+2)), 478 if (get_user(*((__u32 *) (opcode+2)),
477 (__u32 __user *)(location+1)); 479 (__u32 __user *)(location+1)))
480 return;
478 signal = math_emu_ed(opcode, regs); 481 signal = math_emu_ed(opcode, regs);
479 } else if (*((__u16 *) opcode) == 0xb299) { 482 } else if (*((__u16 *) opcode) == 0xb299) {
480 get_user(*((__u16 *) (opcode+2)), location+1); 483 if (get_user(*((__u16 *) (opcode+2)), location+1))
484 return;
481 signal = math_emu_srnm(opcode, regs); 485 signal = math_emu_srnm(opcode, regs);
482 } else if (*((__u16 *) opcode) == 0xb29c) { 486 } else if (*((__u16 *) opcode) == 0xb29c) {
483 get_user(*((__u16 *) (opcode+2)), location+1); 487 if (get_user(*((__u16 *) (opcode+2)), location+1))
488 return;
484 signal = math_emu_stfpc(opcode, regs); 489 signal = math_emu_stfpc(opcode, regs);
485 } else if (*((__u16 *) opcode) == 0xb29d) { 490 } else if (*((__u16 *) opcode) == 0xb29d) {
486 get_user(*((__u16 *) (opcode+2)), location+1); 491 if (get_user(*((__u16 *) (opcode+2)), location+1))
492 return;
487 signal = math_emu_lfpc(opcode, regs); 493 signal = math_emu_lfpc(opcode, regs);
488#endif 494#endif
489 } else 495 } else
diff --git a/arch/s390/kernel/vmlinux.lds.S b/arch/s390/kernel/vmlinux.lds.S
index af9e69a03011..fe0f2e97ba7b 100644
--- a/arch/s390/kernel/vmlinux.lds.S
+++ b/arch/s390/kernel/vmlinux.lds.S
@@ -83,13 +83,7 @@ SECTIONS
83 __setup_end = .; 83 __setup_end = .;
84 __initcall_start = .; 84 __initcall_start = .;
85 .initcall.init : { 85 .initcall.init : {
86 *(.initcall1.init) 86 INITCALLS
87 *(.initcall2.init)
88 *(.initcall3.init)
89 *(.initcall4.init)
90 *(.initcall5.init)
91 *(.initcall6.init)
92 *(.initcall7.init)
93 } 87 }
94 __initcall_end = .; 88 __initcall_end = .;
95 __con_initcall_start = .; 89 __con_initcall_start = .;
diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c
index 1d7d3938b2b1..21baaf5496d6 100644
--- a/arch/s390/kernel/vtime.c
+++ b/arch/s390/kernel/vtime.c
@@ -209,11 +209,11 @@ static void list_add_sorted(struct vtimer_list *timer, struct list_head *head)
209 * Do the callback functions of expired vtimer events. 209 * Do the callback functions of expired vtimer events.
210 * Called from within the interrupt handler. 210 * Called from within the interrupt handler.
211 */ 211 */
212static void do_callbacks(struct list_head *cb_list, struct pt_regs *regs) 212static void do_callbacks(struct list_head *cb_list)
213{ 213{
214 struct vtimer_queue *vt_list; 214 struct vtimer_queue *vt_list;
215 struct vtimer_list *event, *tmp; 215 struct vtimer_list *event, *tmp;
216 void (*fn)(unsigned long, struct pt_regs*); 216 void (*fn)(unsigned long);
217 unsigned long data; 217 unsigned long data;
218 218
219 if (list_empty(cb_list)) 219 if (list_empty(cb_list))
@@ -224,7 +224,7 @@ static void do_callbacks(struct list_head *cb_list, struct pt_regs *regs)
224 list_for_each_entry_safe(event, tmp, cb_list, entry) { 224 list_for_each_entry_safe(event, tmp, cb_list, entry) {
225 fn = event->function; 225 fn = event->function;
226 data = event->data; 226 data = event->data;
227 fn(data, regs); 227 fn(data);
228 228
229 if (!event->interval) 229 if (!event->interval)
230 /* delete one shot timer */ 230 /* delete one shot timer */
@@ -275,7 +275,7 @@ static void do_cpu_timer_interrupt(__u16 error_code)
275 list_move_tail(&event->entry, &cb_list); 275 list_move_tail(&event->entry, &cb_list);
276 } 276 }
277 spin_unlock(&vt_list->lock); 277 spin_unlock(&vt_list->lock);
278 do_callbacks(&cb_list, get_irq_regs()); 278 do_callbacks(&cb_list);
279 279
280 /* next event is first in list */ 280 /* next event is first in list */
281 spin_lock(&vt_list->lock); 281 spin_lock(&vt_list->lock);
diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
index d99891718709..e1881c31b1cb 100644
--- a/arch/s390/mm/init.c
+++ b/arch/s390/mm/init.c
@@ -84,6 +84,7 @@ void show_mem(void)
84 printk("%d pages swap cached\n",cached); 84 printk("%d pages swap cached\n",cached);
85} 85}
86 86
87extern unsigned long __initdata zholes_size[];
87/* 88/*
88 * paging_init() sets up the page tables 89 * paging_init() sets up the page tables
89 */ 90 */
@@ -100,15 +101,16 @@ void __init paging_init(void)
100 unsigned long pgdir_k = (__pa(swapper_pg_dir) & PAGE_MASK) | _KERNSEG_TABLE; 101 unsigned long pgdir_k = (__pa(swapper_pg_dir) & PAGE_MASK) | _KERNSEG_TABLE;
101 static const int ssm_mask = 0x04000000L; 102 static const int ssm_mask = 0x04000000L;
102 unsigned long ro_start_pfn, ro_end_pfn; 103 unsigned long ro_start_pfn, ro_end_pfn;
103 unsigned long max_zone_pfns[MAX_NR_ZONES]; 104 unsigned long zones_size[MAX_NR_ZONES];
104 105
105 ro_start_pfn = PFN_DOWN((unsigned long)&__start_rodata); 106 ro_start_pfn = PFN_DOWN((unsigned long)&__start_rodata);
106 ro_end_pfn = PFN_UP((unsigned long)&__end_rodata); 107 ro_end_pfn = PFN_UP((unsigned long)&__end_rodata);
107 108
108 memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); 109 memset(zones_size, 0, sizeof(zones_size));
109 max_zone_pfns[ZONE_DMA] = max_low_pfn; 110 zones_size[ZONE_DMA] = max_low_pfn;
110 max_zone_pfns[ZONE_NORMAL] = max_low_pfn; 111 free_area_init_node(0, &contig_page_data, zones_size,
111 free_area_init_nodes(max_zone_pfns); 112 __pa(PAGE_OFFSET) >> PAGE_SHIFT,
113 zholes_size);
112 114
113 /* unmap whole virtual address space */ 115 /* unmap whole virtual address space */
114 116
@@ -168,16 +170,26 @@ void __init paging_init(void)
168 unsigned long pgdir_k = (__pa(swapper_pg_dir) & PAGE_MASK) | 170 unsigned long pgdir_k = (__pa(swapper_pg_dir) & PAGE_MASK) |
169 _KERN_REGION_TABLE; 171 _KERN_REGION_TABLE;
170 static const int ssm_mask = 0x04000000L; 172 static const int ssm_mask = 0x04000000L;
173 unsigned long zones_size[MAX_NR_ZONES];
174 unsigned long dma_pfn, high_pfn;
171 unsigned long ro_start_pfn, ro_end_pfn; 175 unsigned long ro_start_pfn, ro_end_pfn;
172 unsigned long max_zone_pfns[MAX_NR_ZONES];
173 176
177 memset(zones_size, 0, sizeof(zones_size));
178 dma_pfn = MAX_DMA_ADDRESS >> PAGE_SHIFT;
179 high_pfn = max_low_pfn;
174 ro_start_pfn = PFN_DOWN((unsigned long)&__start_rodata); 180 ro_start_pfn = PFN_DOWN((unsigned long)&__start_rodata);
175 ro_end_pfn = PFN_UP((unsigned long)&__end_rodata); 181 ro_end_pfn = PFN_UP((unsigned long)&__end_rodata);
176 182
177 memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); 183 if (dma_pfn > high_pfn)
178 max_zone_pfns[ZONE_DMA] = PFN_DOWN(MAX_DMA_ADDRESS); 184 zones_size[ZONE_DMA] = high_pfn;
179 max_zone_pfns[ZONE_NORMAL] = max_low_pfn; 185 else {
180 free_area_init_nodes(max_zone_pfns); 186 zones_size[ZONE_DMA] = dma_pfn;
187 zones_size[ZONE_NORMAL] = high_pfn - dma_pfn;
188 }
189
190 /* Initialize mem_map[]. */
191 free_area_init_node(0, &contig_page_data, zones_size,
192 __pa(PAGE_OFFSET) >> PAGE_SHIFT, zholes_size);
181 193
182 /* 194 /*
183 * map whole physical memory to virtual memory (identity mapping) 195 * map whole physical memory to virtual memory (identity mapping)
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index f6a0c4436168..6a461d4caeff 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -45,6 +45,9 @@ config GENERIC_CALIBRATE_DELAY
45config GENERIC_IOMAP 45config GENERIC_IOMAP
46 bool 46 bool
47 47
48config GENERIC_TIME
49 def_bool n
50
48config ARCH_MAY_HAVE_PC_FDC 51config ARCH_MAY_HAVE_PC_FDC
49 bool 52 bool
50 53
@@ -357,6 +360,7 @@ config CPU_HAS_SR_RB
357endmenu 360endmenu
358 361
359menu "Timer support" 362menu "Timer support"
363depends on !GENERIC_TIME
360 364
361config SH_TMU 365config SH_TMU
362 bool "TMU timer support" 366 bool "TMU timer support"
diff --git a/arch/sh/boards/hp6xx/hp6xx_apm.c b/arch/sh/boards/hp6xx/hp6xx_apm.c
index 75f91aaae077..d146cdaa0b8b 100644
--- a/arch/sh/boards/hp6xx/hp6xx_apm.c
+++ b/arch/sh/boards/hp6xx/hp6xx_apm.c
@@ -14,7 +14,7 @@
14#include <asm/io.h> 14#include <asm/io.h>
15#include <asm/apm.h> 15#include <asm/apm.h>
16#include <asm/adc.h> 16#include <asm/adc.h>
17#include <asm/hp6xx/hp6xx.h> 17#include <asm/hp6xx.h>
18 18
19#define SH7709_PGDR 0xa400012c 19#define SH7709_PGDR 0xa400012c
20 20
@@ -83,7 +83,7 @@ static int hp6x0_apm_get_info(char *buf, char **start, off_t fpos, int length)
83 return p - buf; 83 return p - buf;
84} 84}
85 85
86static irqreturn_t hp6x0_apm_interrupt(int irq, void *dev, struct pt_regs *regs) 86static irqreturn_t hp6x0_apm_interrupt(int irq, void *dev)
87{ 87{
88 if (!apm_suspended) 88 if (!apm_suspended)
89 apm_queue_event(APM_USER_SUSPEND); 89 apm_queue_event(APM_USER_SUSPEND);
@@ -96,7 +96,7 @@ static int __init hp6x0_apm_init(void)
96 int ret; 96 int ret;
97 97
98 ret = request_irq(HP680_BTN_IRQ, hp6x0_apm_interrupt, 98 ret = request_irq(HP680_BTN_IRQ, hp6x0_apm_interrupt,
99 SA_INTERRUPT, MODNAME, 0); 99 IRQF_DISABLED, MODNAME, 0);
100 if (unlikely(ret < 0)) { 100 if (unlikely(ret < 0)) {
101 printk(KERN_ERR MODNAME ": IRQ %d request failed\n", 101 printk(KERN_ERR MODNAME ": IRQ %d request failed\n",
102 HP680_BTN_IRQ); 102 HP680_BTN_IRQ);
diff --git a/arch/sh/boards/hp6xx/pm.c b/arch/sh/boards/hp6xx/pm.c
index 83d327212064..d1947732fb3e 100644
--- a/arch/sh/boards/hp6xx/pm.c
+++ b/arch/sh/boards/hp6xx/pm.c
@@ -12,7 +12,7 @@
12#include <linux/time.h> 12#include <linux/time.h>
13#include <asm/io.h> 13#include <asm/io.h>
14#include <asm/hd64461.h> 14#include <asm/hd64461.h>
15#include <asm/hp6xx/hp6xx.h> 15#include <asm/hp6xx.h>
16#include <asm/cpu/dac.h> 16#include <asm/cpu/dac.h>
17#include <asm/pm.h> 17#include <asm/pm.h>
18 18
diff --git a/arch/sh/boards/hp6xx/setup.c b/arch/sh/boards/hp6xx/setup.c
index 2d3a5b4faf58..b5a96649ed26 100644
--- a/arch/sh/boards/hp6xx/setup.c
+++ b/arch/sh/boards/hp6xx/setup.c
@@ -13,7 +13,7 @@
13#include <asm/hd64461.h> 13#include <asm/hd64461.h>
14#include <asm/io.h> 14#include <asm/io.h>
15#include <asm/irq.h> 15#include <asm/irq.h>
16#include <asm/hp6xx/hp6xx.h> 16#include <asm/hp6xx.h>
17#include <asm/cpu/dac.h> 17#include <asm/cpu/dac.h>
18 18
19#define SCPCR 0xa4000116 19#define SCPCR 0xa4000116
diff --git a/arch/sh/boards/landisk/landisk_pwb.c b/arch/sh/boards/landisk/landisk_pwb.c
index 0b7bee1a9ca5..e62524978160 100644
--- a/arch/sh/boards/landisk/landisk_pwb.c
+++ b/arch/sh/boards/landisk/landisk_pwb.c
@@ -135,7 +135,7 @@ static int swdrv_write(struct file *filp, const char *buff, size_t count,
135 return count; 135 return count;
136} 136}
137 137
138static irqreturn_t sw_interrupt(int irq, void *dev_id, struct pt_regs *regs) 138static irqreturn_t sw_interrupt(int irq, void *dev_id)
139{ 139{
140 landisk_btn = (0x0ff & (~ctrl_inb(PA_STATUS))); 140 landisk_btn = (0x0ff & (~ctrl_inb(PA_STATUS)));
141 disable_irq(IRQ_BUTTON); 141 disable_irq(IRQ_BUTTON);
diff --git a/arch/sh/boards/mpc1211/setup.c b/arch/sh/boards/mpc1211/setup.c
index 01c10fa5c058..7c3d1d304157 100644
--- a/arch/sh/boards/mpc1211/setup.c
+++ b/arch/sh/boards/mpc1211/setup.c
@@ -69,7 +69,6 @@ static void __init pci_write_config(unsigned long busNo,
69 69
70static unsigned char m_irq_mask = 0xfb; 70static unsigned char m_irq_mask = 0xfb;
71static unsigned char s_irq_mask = 0xff; 71static unsigned char s_irq_mask = 0xff;
72volatile unsigned long irq_err_count;
73 72
74static void disable_mpc1211_irq(unsigned int irq) 73static void disable_mpc1211_irq(unsigned int irq)
75{ 74{
@@ -118,7 +117,7 @@ static void mask_and_ack_mpc1211(unsigned int irq)
118 if(irq < 8) { 117 if(irq < 8) {
119 if(m_irq_mask & (1<<irq)){ 118 if(m_irq_mask & (1<<irq)){
120 if(!mpc1211_irq_real(irq)){ 119 if(!mpc1211_irq_real(irq)){
121 irq_err_count++; 120 atomic_inc(&irq_err_count)
122 printk("spurious 8259A interrupt: IRQ %x\n",irq); 121 printk("spurious 8259A interrupt: IRQ %x\n",irq);
123 } 122 }
124 } else { 123 } else {
@@ -131,7 +130,7 @@ static void mask_and_ack_mpc1211(unsigned int irq)
131 } else { 130 } else {
132 if(s_irq_mask & (1<<(irq - 8))){ 131 if(s_irq_mask & (1<<(irq - 8))){
133 if(!mpc1211_irq_real(irq)){ 132 if(!mpc1211_irq_real(irq)){
134 irq_err_count++; 133 atomic_inc(&irq_err_count);
135 printk("spurious 8259A interrupt: IRQ %x\n",irq); 134 printk("spurious 8259A interrupt: IRQ %x\n",irq);
136 } 135 }
137 } else { 136 } else {
diff --git a/arch/sh/boards/renesas/hs7751rvoip/io.c b/arch/sh/boards/renesas/hs7751rvoip/io.c
index 51f3f6574210..bb9aa0d62852 100644
--- a/arch/sh/boards/renesas/hs7751rvoip/io.c
+++ b/arch/sh/boards/renesas/hs7751rvoip/io.c
@@ -15,7 +15,7 @@
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/pci.h> 16#include <linux/pci.h>
17#include <asm/io.h> 17#include <asm/io.h>
18#include <asm/hs7751rvoip/hs7751rvoip.h> 18#include <asm/hs7751rvoip.h>
19#include <asm/addrspace.h> 19#include <asm/addrspace.h>
20 20
21extern void *area6_io8_base; /* Area 6 8bit I/O Base address */ 21extern void *area6_io8_base; /* Area 6 8bit I/O Base address */
diff --git a/arch/sh/boards/renesas/hs7751rvoip/irq.c b/arch/sh/boards/renesas/hs7751rvoip/irq.c
index c617b188258a..943f93aa6052 100644
--- a/arch/sh/boards/renesas/hs7751rvoip/irq.c
+++ b/arch/sh/boards/renesas/hs7751rvoip/irq.c
@@ -14,7 +14,7 @@
14#include <linux/irq.h> 14#include <linux/irq.h>
15#include <asm/io.h> 15#include <asm/io.h>
16#include <asm/irq.h> 16#include <asm/irq.h>
17#include <asm/hs7751rvoip/hs7751rvoip.h> 17#include <asm/hs7751rvoip.h>
18 18
19static int mask_pos[] = {8, 9, 10, 11, 12, 13, 0, 1, 2, 3, 4, 5, 6, 7}; 19static int mask_pos[] = {8, 9, 10, 11, 12, 13, 0, 1, 2, 3, 4, 5, 6, 7};
20 20
diff --git a/arch/sh/boards/renesas/hs7751rvoip/setup.c b/arch/sh/boards/renesas/hs7751rvoip/setup.c
index 0414c15c3458..f7d0e304d899 100644
--- a/arch/sh/boards/renesas/hs7751rvoip/setup.c
+++ b/arch/sh/boards/renesas/hs7751rvoip/setup.c
@@ -10,22 +10,21 @@
10#include <linux/init.h> 10#include <linux/init.h>
11#include <linux/irq.h> 11#include <linux/irq.h>
12#include <linux/mm.h> 12#include <linux/mm.h>
13#include <linux/vmalloc.h>
14#include <linux/hdreg.h>
15#include <linux/ide.h>
16#include <linux/pm.h> 13#include <linux/pm.h>
14#include <asm/hs7751rvoip.h>
17#include <asm/io.h> 15#include <asm/io.h>
18#include <asm/hs7751rvoip/hs7751rvoip.h>
19#include <asm/machvec.h> 16#include <asm/machvec.h>
20#include <asm/rtc.h>
21#include <asm/irq.h>
22 17
23static void __init hs7751rvoip_init_irq(void) 18static struct ipr_data hs77501rvoip_ipr_map[] = {
24{
25#if defined(CONFIG_HS7751RVOIP_CODEC) 19#if defined(CONFIG_HS7751RVOIP_CODEC)
26 make_ipr_irq(DMTE0_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY); 20 { DMTE0_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
27 make_ipr_irq(DMTE1_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY); 21 { DMTE1_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
28#endif 22#endif
23};
24
25static void __init hs7751rvoip_init_irq(void)
26{
27 make_ipr_irq(hs77501rvoip_ipr_map, ARRAY_SIZE(hs77501rvoip_ipr_map));
29 28
30 init_hs7751rvoip_IRQ(); 29 init_hs7751rvoip_IRQ();
31} 30}
diff --git a/arch/sh/boards/renesas/r7780rp/io.c b/arch/sh/boards/renesas/r7780rp/io.c
index db92d6e6ae99..311ccccba718 100644
--- a/arch/sh/boards/renesas/r7780rp/io.c
+++ b/arch/sh/boards/renesas/r7780rp/io.c
@@ -11,7 +11,7 @@
11#include <linux/pci.h> 11#include <linux/pci.h>
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/types.h> 13#include <linux/types.h>
14#include <asm/r7780rp/r7780rp.h> 14#include <asm/r7780rp.h>
15#include <asm/addrspace.h> 15#include <asm/addrspace.h>
16#include <asm/io.h> 16#include <asm/io.h>
17 17
diff --git a/arch/sh/boards/renesas/r7780rp/irq.c b/arch/sh/boards/renesas/r7780rp/irq.c
index 2d960e9a3143..aa15ec5bc69e 100644
--- a/arch/sh/boards/renesas/r7780rp/irq.c
+++ b/arch/sh/boards/renesas/r7780rp/irq.c
@@ -1,18 +1,17 @@
1/* 1/*
2 * linux/arch/sh/boards/renesas/r7780rp/irq.c
3 *
4 * Copyright (C) 2000 Kazumoto Kojima
5 *
6 * Renesas Solutions Highlander R7780RP-1 Support. 2 * Renesas Solutions Highlander R7780RP-1 Support.
7 * 3 *
8 * Modified for R7780RP-1 by 4 * Copyright (C) 2002 Atom Create Engineering Co., Ltd.
9 * Atom Create Engineering Co., Ltd. 2002. 5 * Copyright (C) 2006 Paul Mundt
6 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details.
10 */ 10 */
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/irq.h> 12#include <linux/irq.h>
13#include <asm/io.h> 13#include <linux/io.h>
14#include <asm/irq.h> 14#include <asm/r7780rp.h>
15#include <asm/r7780rp/r7780rp.h>
16 15
17#ifdef CONFIG_SH_R7780MP 16#ifdef CONFIG_SH_R7780MP
18static int mask_pos[] = {12, 11, 9, 14, 15, 8, 13, 6, 5, 4, 3, 2, 0, 0, 1, 0}; 17static int mask_pos[] = {12, 11, 9, 14, 15, 8, 13, 6, 5, 4, 3, 2, 0, 0, 1, 0};
@@ -20,71 +19,26 @@ static int mask_pos[] = {12, 11, 9, 14, 15, 8, 13, 6, 5, 4, 3, 2, 0, 0, 1, 0};
20static int mask_pos[] = {15, 14, 13, 12, 11, 10, 9, 8, 7, 5, 6, 4, 0, 1, 2, 0}; 19static int mask_pos[] = {15, 14, 13, 12, 11, 10, 9, 8, 7, 5, 6, 4, 0, 1, 2, 0};
21#endif 20#endif
22 21
23static void enable_r7780rp_irq(unsigned int irq);
24static void disable_r7780rp_irq(unsigned int irq);
25
26/* shutdown is same as "disable" */
27#define shutdown_r7780rp_irq disable_r7780rp_irq
28
29static void ack_r7780rp_irq(unsigned int irq);
30static void end_r7780rp_irq(unsigned int irq);
31
32static unsigned int startup_r7780rp_irq(unsigned int irq)
33{
34 enable_r7780rp_irq(irq);
35 return 0; /* never anything pending */
36}
37
38static void disable_r7780rp_irq(unsigned int irq)
39{
40 unsigned short val;
41 unsigned short mask = 0xffff ^ (0x0001 << mask_pos[irq]);
42
43 /* Set the priority in IPR to 0 */
44 val = ctrl_inw(IRLCNTR1);
45 val &= mask;
46 ctrl_outw(val, IRLCNTR1);
47}
48
49static void enable_r7780rp_irq(unsigned int irq) 22static void enable_r7780rp_irq(unsigned int irq)
50{ 23{
51 unsigned short val;
52 unsigned short value = (0x0001 << mask_pos[irq]);
53
54 /* Set priority in IPR back to original value */ 24 /* Set priority in IPR back to original value */
55 val = ctrl_inw(IRLCNTR1); 25 ctrl_outw(ctrl_inw(IRLCNTR1) | (1 << mask_pos[irq]), IRLCNTR1);
56 val |= value;
57 ctrl_outw(val, IRLCNTR1);
58}
59
60static void ack_r7780rp_irq(unsigned int irq)
61{
62 disable_r7780rp_irq(irq);
63} 26}
64 27
65static void end_r7780rp_irq(unsigned int irq) 28static void disable_r7780rp_irq(unsigned int irq)
66{ 29{
67 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) 30 /* Set the priority in IPR to 0 */
68 enable_r7780rp_irq(irq); 31 ctrl_outw(ctrl_inw(IRLCNTR1) & (0xffff ^ (1 << mask_pos[irq])),
32 IRLCNTR1);
69} 33}
70 34
71static struct hw_interrupt_type r7780rp_irq_type = { 35static struct irq_chip r7780rp_irq_chip __read_mostly = {
72 .typename = "R7780RP-IRQ", 36 .name = "R7780RP",
73 .startup = startup_r7780rp_irq, 37 .mask = disable_r7780rp_irq,
74 .shutdown = shutdown_r7780rp_irq, 38 .unmask = enable_r7780rp_irq,
75 .enable = enable_r7780rp_irq, 39 .mask_ack = disable_r7780rp_irq,
76 .disable = disable_r7780rp_irq,
77 .ack = ack_r7780rp_irq,
78 .end = end_r7780rp_irq,
79}; 40};
80 41
81static void make_r7780rp_irq(unsigned int irq)
82{
83 disable_irq_nosync(irq);
84 irq_desc[irq].chip = &r7780rp_irq_type;
85 disable_r7780rp_irq(irq);
86}
87
88/* 42/*
89 * Initialize IRQ setting 43 * Initialize IRQ setting
90 */ 44 */
@@ -92,24 +46,10 @@ void __init init_r7780rp_IRQ(void)
92{ 46{
93 int i; 47 int i;
94 48
95 /* IRL0=PCI Slot #A 49 for (i = 0; i < 15; i++) {
96 * IRL1=PCI Slot #B 50 disable_irq_nosync(i);
97 * IRL2=PCI Slot #C 51 set_irq_chip_and_handler_name(i, &r7780rp_irq_chip,
98 * IRL3=PCI Slot #D 52 handle_level_irq, "level");
99 * IRL4=CF Card 53 enable_r7780rp_irq(i);
100 * IRL5=CF Card Insert 54 }
101 * IRL6=M66596
102 * IRL7=SD Card
103 * IRL8=Touch Panel
104 * IRL9=SCI
105 * IRL10=Serial
106 * IRL11=Extention #A
107 * IRL11=Extention #B
108 * IRL12=Debug LAN
109 * IRL13=Push Switch
110 * IRL14=ZiggBee IO
111 */
112
113 for (i=0; i<15; i++)
114 make_r7780rp_irq(i);
115} 55}
diff --git a/arch/sh/boards/renesas/r7780rp/setup.c b/arch/sh/boards/renesas/r7780rp/setup.c
index b941aa0aa34e..c331caeb694b 100644
--- a/arch/sh/boards/renesas/r7780rp/setup.c
+++ b/arch/sh/boards/renesas/r7780rp/setup.c
@@ -13,7 +13,7 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <asm/machvec.h> 15#include <asm/machvec.h>
16#include <asm/r7780rp/r7780rp.h> 16#include <asm/r7780rp.h>
17#include <asm/clock.h> 17#include <asm/clock.h>
18#include <asm/io.h> 18#include <asm/io.h>
19 19
diff --git a/arch/sh/boards/renesas/rts7751r2d/io.c b/arch/sh/boards/renesas/rts7751r2d/io.c
index 135aa0b5e62d..f2507a804979 100644
--- a/arch/sh/boards/renesas/rts7751r2d/io.c
+++ b/arch/sh/boards/renesas/rts7751r2d/io.c
@@ -11,8 +11,8 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/types.h> 12#include <linux/types.h>
13#include <linux/pci.h> 13#include <linux/pci.h>
14#include <asm/rts7751r2d/rts7751r2d.h> 14#include <linux/io.h>
15#include <asm/io.h> 15#include <asm/rts7751r2d.h>
16#include <asm/addrspace.h> 16#include <asm/addrspace.h>
17 17
18/* 18/*
diff --git a/arch/sh/boards/renesas/rts7751r2d/irq.c b/arch/sh/boards/renesas/rts7751r2d/irq.c
index c915e7a3693a..cb0eb20d1b43 100644
--- a/arch/sh/boards/renesas/rts7751r2d/irq.c
+++ b/arch/sh/boards/renesas/rts7751r2d/irq.c
@@ -8,12 +8,10 @@
8 * Modified for RTS7751R2D by 8 * Modified for RTS7751R2D by
9 * Atom Create Engineering Co., Ltd. 2002. 9 * Atom Create Engineering Co., Ltd. 2002.
10 */ 10 */
11
12#include <linux/init.h> 11#include <linux/init.h>
13#include <linux/irq.h> 12#include <linux/irq.h>
14#include <asm/io.h> 13#include <linux/io.h>
15#include <asm/irq.h> 14#include <asm/rts7751r2d.h>
16#include <asm/rts7751r2d/rts7751r2d.h>
17 15
18#if defined(CONFIG_RTS7751R2D_REV11) 16#if defined(CONFIG_RTS7751R2D_REV11)
19static int mask_pos[] = {11, 9, 8, 12, 10, 6, 5, 4, 7, 14, 13, 0, 0, 0, 0}; 17static int mask_pos[] = {11, 9, 8, 12, 10, 6, 5, 4, 7, 14, 13, 0, 0, 0, 0};
diff --git a/arch/sh/boards/renesas/rts7751r2d/led.c b/arch/sh/boards/renesas/rts7751r2d/led.c
index a7ce66c1e4f0..509f548bdce0 100644
--- a/arch/sh/boards/renesas/rts7751r2d/led.c
+++ b/arch/sh/boards/renesas/rts7751r2d/led.c
@@ -8,13 +8,9 @@
8 * 8 *
9 * This file contains Renesas Technology Sales RTS7751R2D specific LED code. 9 * This file contains Renesas Technology Sales RTS7751R2D specific LED code.
10 */ 10 */
11 11#include <linux/io.h>
12#include <asm/io.h>
13#include <asm/rts7751r2d/rts7751r2d.h>
14
15#ifdef CONFIG_HEARTBEAT
16
17#include <linux/sched.h> 12#include <linux/sched.h>
13#include <asm/rts7751r2d.h>
18 14
19/* Cycle the LED's in the clasic Knightriger/Sun pattern */ 15/* Cycle the LED's in the clasic Knightriger/Sun pattern */
20void heartbeat_rts7751r2d(void) 16void heartbeat_rts7751r2d(void)
@@ -46,10 +42,3 @@ void heartbeat_rts7751r2d(void)
46 else 42 else
47 bit--; 43 bit--;
48} 44}
49#endif /* CONFIG_HEARTBEAT */
50
51void rts7751r2d_led(unsigned short value)
52{
53 ctrl_outw(value, PA_OUTPORT);
54}
55
diff --git a/arch/sh/boards/renesas/rts7751r2d/setup.c b/arch/sh/boards/renesas/rts7751r2d/setup.c
index 20597a6e6702..5c042d35ec91 100644
--- a/arch/sh/boards/renesas/rts7751r2d/setup.c
+++ b/arch/sh/boards/renesas/rts7751r2d/setup.c
@@ -12,9 +12,9 @@
12#include <linux/platform_device.h> 12#include <linux/platform_device.h>
13#include <linux/serial_8250.h> 13#include <linux/serial_8250.h>
14#include <linux/pm.h> 14#include <linux/pm.h>
15#include <asm/io.h>
16#include <asm/machvec.h> 15#include <asm/machvec.h>
17#include <asm/mach/rts7751r2d.h> 16#include <asm/mach/rts7751r2d.h>
17#include <asm/io.h>
18#include <asm/voyagergx.h> 18#include <asm/voyagergx.h>
19 19
20extern void heartbeat_rts7751r2d(void); 20extern void heartbeat_rts7751r2d(void);
diff --git a/arch/sh/boards/renesas/sh7710voipgw/setup.c b/arch/sh/boards/renesas/sh7710voipgw/setup.c
index e57e7afab8c6..180810b12107 100644
--- a/arch/sh/boards/renesas/sh7710voipgw/setup.c
+++ b/arch/sh/boards/renesas/sh7710voipgw/setup.c
@@ -13,6 +13,51 @@
13#include <asm/io.h> 13#include <asm/io.h>
14#include <asm/irq.h> 14#include <asm/irq.h>
15 15
16static struct ipr_data sh7710voipgw_ipr_map[] = {
17 { TIMER2_IRQ, TIMER2_IPR_ADDR, TIMER2_IPR_POS, TIMER2_PRIORITY },
18 { WDT_IRQ, WDT_IPR_ADDR, WDT_IPR_POS, WDT_PRIORITY },
19
20 /* SCIF0 */
21 { SCIF0_ERI_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS, SCIF0_PRIORITY },
22 { SCIF0_RXI_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS, SCIF0_PRIORITY },
23 { SCIF0_BRI_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS, SCIF0_PRIORITY },
24 { SCIF0_TXI_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS, SCIF0_PRIORITY },
25
26 /* DMAC-1 */
27 { DMTE0_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
28 { DMTE1_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
29 { DMTE2_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
30 { DMTE3_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
31
32 /* DMAC-2 */
33 { DMTE4_IRQ, DMA2_IPR_ADDR, DMA2_IPR_POS, DMA2_PRIORITY },
34 { DMTE4_IRQ, DMA2_IPR_ADDR, DMA2_IPR_POS, DMA2_PRIORITY },
35
36 /* IPSEC */
37 { IPSEC_IRQ, IPSEC_IPR_ADDR, IPSEC_IPR_POS, IPSEC_PRIORITY },
38
39 /* EDMAC */
40 { EDMAC0_IRQ, EDMAC0_IPR_ADDR, EDMAC0_IPR_POS, EDMAC0_PRIORITY },
41 { EDMAC1_IRQ, EDMAC1_IPR_ADDR, EDMAC1_IPR_POS, EDMAC1_PRIORITY },
42 { EDMAC2_IRQ, EDMAC2_IPR_ADDR, EDMAC2_IPR_POS, EDMAC2_PRIORITY },
43
44 /* SIOF0 */
45 { SIOF0_ERI_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY },
46 { SIOF0_TXI_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY },
47 { SIOF0_RXI_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY },
48 { SIOF0_CCI_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY },
49
50 /* SIOF1 */
51 { SIOF1_ERI_IRQ, SIOF1_IPR_ADDR, SIOF1_IPR_POS, SIOF1_PRIORITY },
52 { SIOF1_TXI_IRQ, SIOF1_IPR_ADDR, SIOF1_IPR_POS, SIOF1_PRIORITY },
53 { SIOF1_RXI_IRQ, SIOF1_IPR_ADDR, SIOF1_IPR_POS, SIOF1_PRIORITY },
54 { SIOF1_CCI_IRQ, SIOF1_IPR_ADDR, SIOF1_IPR_POS, SIOF1_PRIORITY },
55
56 /* SLIC IRQ's */
57 { IRQ1_IRQ, IRQ1_IPR_ADDR, IRQ1_IPR_POS, IRQ1_PRIORITY },
58 { IRQ2_IRQ, IRQ2_IPR_ADDR, IRQ2_IPR_POS, IRQ2_PRIORITY },
59};
60
16/* 61/*
17 * Initialize IRQ setting 62 * Initialize IRQ setting
18 */ 63 */
@@ -37,65 +82,7 @@ static void __init sh7710voipgw_init_irq(void)
37 */ 82 */
38 ctrl_outw(0x2aa, INTC_ICR1); 83 ctrl_outw(0x2aa, INTC_ICR1);
39 84
40 /* Now make IPR interrupts */ 85 make_ipr_irq(sh7710voipgw_ipr_map, ARRAY_SIZE(sh7710voipgw_ipr_map));
41 make_ipr_irq(TIMER2_IRQ, TIMER2_IPR_ADDR,
42 TIMER2_IPR_POS, TIMER2_PRIORITY);
43 make_ipr_irq(WDT_IRQ, WDT_IPR_ADDR, WDT_IPR_POS, WDT_PRIORITY);
44
45 /* SCIF0 */
46 make_ipr_irq(SCIF0_ERI_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS,
47 SCIF0_PRIORITY);
48 make_ipr_irq(SCIF0_RXI_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS,
49 SCIF0_PRIORITY);
50 make_ipr_irq(SCIF0_BRI_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS,
51 SCIF0_PRIORITY);
52 make_ipr_irq(SCIF0_TXI_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS,
53 SCIF0_PRIORITY);
54
55 /* DMAC-1 */
56 make_ipr_irq(DMTE0_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY);
57 make_ipr_irq(DMTE1_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY);
58 make_ipr_irq(DMTE2_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY);
59 make_ipr_irq(DMTE3_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY);
60
61 /* DMAC-2 */
62 make_ipr_irq(DMTE4_IRQ, DMA2_IPR_ADDR, DMA2_IPR_POS, DMA2_PRIORITY);
63 make_ipr_irq(DMTE4_IRQ, DMA2_IPR_ADDR, DMA2_IPR_POS, DMA2_PRIORITY);
64
65 /* IPSEC */
66 make_ipr_irq(IPSEC_IRQ, IPSEC_IPR_ADDR, IPSEC_IPR_POS, IPSEC_PRIORITY);
67
68 /* EDMAC */
69 make_ipr_irq(EDMAC0_IRQ, EDMAC0_IPR_ADDR, EDMAC0_IPR_POS,
70 EDMAC0_PRIORITY);
71 make_ipr_irq(EDMAC1_IRQ, EDMAC1_IPR_ADDR, EDMAC1_IPR_POS,
72 EDMAC1_PRIORITY);
73 make_ipr_irq(EDMAC2_IRQ, EDMAC2_IPR_ADDR, EDMAC2_IPR_POS,
74 EDMAC2_PRIORITY);
75
76 /* SIOF0 */
77 make_ipr_irq(SIOF0_ERI_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS,
78 SIOF0_PRIORITY);
79 make_ipr_irq(SIOF0_TXI_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS,
80 SIOF0_PRIORITY);
81 make_ipr_irq(SIOF0_RXI_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS,
82 SIOF0_PRIORITY);
83 make_ipr_irq(SIOF0_CCI_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS,
84 SIOF0_PRIORITY);
85
86 /* SIOF1 */
87 make_ipr_irq(SIOF1_ERI_IRQ, SIOF1_IPR_ADDR, SIOF1_IPR_POS,
88 SIOF1_PRIORITY);
89 make_ipr_irq(SIOF1_TXI_IRQ, SIOF1_IPR_ADDR, SIOF1_IPR_POS,
90 SIOF1_PRIORITY);
91 make_ipr_irq(SIOF1_RXI_IRQ, SIOF1_IPR_ADDR, SIOF1_IPR_POS,
92 SIOF1_PRIORITY);
93 make_ipr_irq(SIOF1_CCI_IRQ, SIOF1_IPR_ADDR, SIOF1_IPR_POS,
94 SIOF1_PRIORITY);
95
96 /* SLIC IRQ's */
97 make_ipr_irq(IRQ1_IRQ, IRQ1_IPR_ADDR, IRQ1_IPR_POS, IRQ1_PRIORITY);
98 make_ipr_irq(IRQ2_IRQ, IRQ2_IPR_ADDR, IRQ2_IPR_POS, IRQ2_PRIORITY);
99} 86}
100 87
101/* 88/*
diff --git a/arch/sh/boards/se/7300/irq.c b/arch/sh/boards/se/7300/irq.c
index ad1034f98a29..1279d776d60f 100644
--- a/arch/sh/boards/se/7300/irq.c
+++ b/arch/sh/boards/se/7300/irq.c
@@ -13,6 +13,17 @@
13#include <asm/io.h> 13#include <asm/io.h>
14#include <asm/se7300.h> 14#include <asm/se7300.h>
15 15
16static struct ipr_data se7300_ipr_map[] = {
17 /* PC_IRQ[0-3] -> IRQ0 (32) */
18 { IRQ0_IRQ, IRQ0_IPR_ADDR, IRQ0_IPR_POS, 0x0f - IRQ0_IRQ },
19 /* A_IRQ[0-3] -> IRQ1 (33) */
20 { IRQ1_IRQ, IRQ1_IPR_ADDR, IRQ1_IPR_POS, 0x0f - IRQ1_IRQ },
21 { SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY },
22 { DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
23 { DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
24 { VIO_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY },
25};
26
16/* 27/*
17 * Initialize IRQ setting 28 * Initialize IRQ setting
18 */ 29 */
@@ -23,14 +34,7 @@ init_7300se_IRQ(void)
23 ctrl_outw(0xa000, INTC_ICR1); /* IRQ mode; IRQ0,1 enable. */ 34 ctrl_outw(0xa000, INTC_ICR1); /* IRQ mode; IRQ0,1 enable. */
24 ctrl_outw(0x0000, PORT_PFCR); /* use F for IRQ[3:0] and SIU. */ 35 ctrl_outw(0x0000, PORT_PFCR); /* use F for IRQ[3:0] and SIU. */
25 36
26 /* PC_IRQ[0-3] -> IRQ0 (32) */ 37 make_ipr_irq(se7300_ipr_map, ARRAY_SIZE(se7300_ipr_map));
27 make_ipr_irq(IRQ0_IRQ, IRQ0_IPR_ADDR, IRQ0_IPR_POS, 0x0f - IRQ0_IRQ);
28 /* A_IRQ[0-3] -> IRQ1 (33) */
29 make_ipr_irq(IRQ1_IRQ, IRQ1_IPR_ADDR, IRQ1_IPR_POS, 0x0f - IRQ1_IRQ);
30 make_ipr_irq(SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY);
31 make_ipr_irq(DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY);
32 make_ipr_irq(DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY);
33 make_ipr_irq(VIO_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY);
34 38
35 ctrl_outw(0x2000, PA_MRSHPC + 0x0c); /* mrshpc irq enable */ 39 ctrl_outw(0x2000, PA_MRSHPC + 0x0c); /* mrshpc irq enable */
36} 40}
diff --git a/arch/sh/boards/se/73180/irq.c b/arch/sh/boards/se/73180/irq.c
index 2c62b8ea350e..e7200c56bb45 100644
--- a/arch/sh/boards/se/73180/irq.c
+++ b/arch/sh/boards/se/73180/irq.c
@@ -87,13 +87,38 @@ shmse_irq_demux(int irq)
87 return irq; 87 return irq;
88} 88}
89 89
90static struct ipr_data se73180_siof0_ipr_map[] = {
91 { SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY },
92};
93static struct ipr_data se73180_vpu_ipr_map[] = {
94 { VPU_IRQ, VPU_IPR_ADDR, VPU_IPR_POS, 8 },
95};
96static struct ipr_data se73180_other_ipr_map[] = {
97 { DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
98 { DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
99 { DMTE4_IRQ, DMA2_IPR_ADDR, DMA2_IPR_POS, DMA2_PRIORITY },
100 { IIC0_ALI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY },
101 { IIC0_TACKI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY },
102 { IIC0_WAITI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY },
103 { IIC0_DTEI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY },
104 { SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY },
105 { SIU_IRQ, SIU_IPR_ADDR, SIU_IPR_POS, SIU_PRIORITY },
106
107 /* VIO interrupt */
108 { CEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY },
109 { BEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY },
110 { VEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY },
111
112 { LCDC_IRQ, LCDC_IPR_ADDR, LCDC_IPR_POS, LCDC_PRIORITY },
113};
114
90/* 115/*
91 * Initialize IRQ setting 116 * Initialize IRQ setting
92 */ 117 */
93void __init 118void __init
94init_73180se_IRQ(void) 119init_73180se_IRQ(void)
95{ 120{
96 make_ipr_irq(SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY); 121 make_ipr_irq(se73180_siof0_ipr_map, ARRAY_SIZE(se73180_siof0_ipr_map));
97 122
98 ctrl_outw(0x2000, 0xb03fffec); /* mrshpc irq enable */ 123 ctrl_outw(0x2000, 0xb03fffec); /* mrshpc irq enable */
99 ctrl_outw(0x2000, 0xb07fffec); /* mrshpc irq enable */ 124 ctrl_outw(0x2000, 0xb07fffec); /* mrshpc irq enable */
@@ -101,27 +126,11 @@ init_73180se_IRQ(void)
101 ctrl_outw(2 << ((7 - 5) * 2), INTC_ICR1); /* low-level irq */ 126 ctrl_outw(2 << ((7 - 5) * 2), INTC_ICR1); /* low-level irq */
102 make_intreq_irq(10); 127 make_intreq_irq(10);
103 128
104 make_ipr_irq(VPU_IRQ, VPU_IPR_ADDR, VPU_IPR_POS, 8); 129 make_ipr_irq(se73180_vpu_ipr_map, ARRAY_SIZE(se73180_vpu_ipr_map));
105 130
106 ctrl_outb(0x0f, INTC_IMCR5); /* enable SCIF IRQ */ 131 ctrl_outb(0x0f, INTC_IMCR5); /* enable SCIF IRQ */
107 132
108 make_ipr_irq(DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY); 133 make_ipr_irq(se73180_other_ipr_map, ARRAY_SIZE(se73180_other_ipr_map));
109 make_ipr_irq(DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY);
110 make_ipr_irq(DMTE4_IRQ, DMA2_IPR_ADDR, DMA2_IPR_POS, DMA2_PRIORITY);
111 make_ipr_irq(IIC0_ALI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY);
112 make_ipr_irq(IIC0_TACKI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS,
113 IIC0_PRIORITY);
114 make_ipr_irq(IIC0_WAITI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS,
115 IIC0_PRIORITY);
116 make_ipr_irq(IIC0_DTEI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY);
117 make_ipr_irq(SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY);
118 make_ipr_irq(SIU_IRQ, SIU_IPR_ADDR, SIU_IPR_POS, SIU_PRIORITY);
119
120 /* VIO interrupt */
121 make_ipr_irq(CEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY);
122 make_ipr_irq(BEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY);
123 make_ipr_irq(VEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY);
124 134
125 make_ipr_irq(LCDC_IRQ, LCDC_IPR_ADDR, LCDC_IPR_POS, LCDC_PRIORITY);
126 ctrl_outw(0x2000, PA_MRSHPC + 0x0c); /* mrshpc irq enable */ 135 ctrl_outw(0x2000, PA_MRSHPC + 0x0c); /* mrshpc irq enable */
127} 136}
diff --git a/arch/sh/boards/se/7343/irq.c b/arch/sh/boards/se/7343/irq.c
index 288b62f59419..360153ecc55b 100644
--- a/arch/sh/boards/se/7343/irq.c
+++ b/arch/sh/boards/se/7343/irq.c
@@ -102,6 +102,51 @@ shmse_irq_demux(int irq)
102static struct irqaction irq5 = { no_action, 0, CPU_MASK_NONE, "IRQ5-cascade", 102static struct irqaction irq5 = { no_action, 0, CPU_MASK_NONE, "IRQ5-cascade",
103 NULL, NULL}; 103 NULL, NULL};
104 104
105static struct ipr_data se7343_irq5_ipr_map[] = {
106 { IRQ5_IRQ, IRQ5_IPR_ADDR+2, IRQ5_IPR_POS, IRQ5_PRIORITY },
107};
108static struct ipr_data se7343_siof0_vpu_ipr_map[] = {
109 { SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY },
110 { VPU_IRQ, VPU_IPR_ADDR, VPU_IPR_POS, 8 },
111};
112static struct ipr_data se7343_other_ipr_map[] = {
113 { DMTE0_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
114 { DMTE1_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
115 { DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
116 { DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
117 { DMTE4_IRQ, DMA2_IPR_ADDR, DMA2_IPR_POS, DMA2_PRIORITY },
118 { DMTE5_IRQ, DMA2_IPR_ADDR, DMA2_IPR_POS, DMA2_PRIORITY },
119
120 /* I2C block */
121 { IIC0_ALI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY },
122 { IIC0_TACKI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY },
123 { IIC0_WAITI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY },
124 { IIC0_DTEI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY },
125
126 { IIC1_ALI_IRQ, IIC1_IPR_ADDR, IIC1_IPR_POS, IIC1_PRIORITY },
127 { IIC1_TACKI_IRQ, IIC1_IPR_ADDR, IIC1_IPR_POS, IIC1_PRIORITY },
128 { IIC1_WAITI_IRQ, IIC1_IPR_ADDR, IIC1_IPR_POS, IIC1_PRIORITY },
129 { IIC1_DTEI_IRQ, IIC1_IPR_ADDR, IIC1_IPR_POS, IIC1_PRIORITY },
130
131 /* SIOF */
132 { SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY },
133
134 /* SIU */
135 { SIU_IRQ, SIU_IPR_ADDR, SIU_IPR_POS, SIU_PRIORITY },
136
137 /* VIO interrupt */
138 { CEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY },
139 { BEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY },
140 { VEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY },
141
142 /*MFI interrupt*/
143
144 { MFI_IRQ, MFI_IPR_ADDR, MFI_IPR_POS, MFI_PRIORITY },
145
146 /* LCD controller */
147 { LCDC_IRQ, LCDC_IPR_ADDR, LCDC_IPR_POS, LCDC_PRIORITY },
148};
149
105/* 150/*
106 * Initialize IRQ setting 151 * Initialize IRQ setting
107 */ 152 */
@@ -138,54 +183,17 @@ init_7343se_IRQ(void)
138 /* Setup all external interrupts to be active low */ 183 /* Setup all external interrupts to be active low */
139 ctrl_outw(0xaaaa, INTC_ICR1); 184 ctrl_outw(0xaaaa, INTC_ICR1);
140 185
141 make_ipr_irq(IRQ5_IRQ, IRQ5_IPR_ADDR+2, IRQ5_IPR_POS, IRQ5_PRIORITY); 186 make_ipr_irq(se7343_irq5_ipr_map, ARRAY_SIZE(se7343_irq5_ipr_map));
187
142 setup_irq(IRQ5_IRQ, &irq5); 188 setup_irq(IRQ5_IRQ, &irq5);
143 /* Set port control to use IRQ5 */ 189 /* Set port control to use IRQ5 */
144 *(u16 *)0xA4050108 &= ~0xc; 190 *(u16 *)0xA4050108 &= ~0xc;
145 191
146 make_ipr_irq(SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY); 192 make_ipr_irq(se7343_siof0_vpu_ipr_map, ARRAY_SIZE(se7343_siof0_vpu_ipr_map));
147 make_ipr_irq(VPU_IRQ, VPU_IPR_ADDR, VPU_IPR_POS, 8);
148 193
149 ctrl_outb(0x0f, INTC_IMCR5); /* enable SCIF IRQ */ 194 ctrl_outb(0x0f, INTC_IMCR5); /* enable SCIF IRQ */
150 195
151 make_ipr_irq(DMTE0_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY); 196 make_ipr_irq(se7343_other_ipr_map, ARRAY_SIZE(se7343_other_ipr_map));
152 make_ipr_irq(DMTE1_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY);
153 make_ipr_irq(DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY);
154 make_ipr_irq(DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY);
155 make_ipr_irq(DMTE4_IRQ, DMA2_IPR_ADDR, DMA2_IPR_POS, DMA2_PRIORITY);
156 make_ipr_irq(DMTE5_IRQ, DMA2_IPR_ADDR, DMA2_IPR_POS, DMA2_PRIORITY);
157
158 /* I2C block */
159 make_ipr_irq(IIC0_ALI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY);
160 make_ipr_irq(IIC0_TACKI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS,
161 IIC0_PRIORITY);
162 make_ipr_irq(IIC0_WAITI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS,
163 IIC0_PRIORITY);
164 make_ipr_irq(IIC0_DTEI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY);
165
166 make_ipr_irq(IIC1_ALI_IRQ, IIC1_IPR_ADDR, IIC1_IPR_POS, IIC1_PRIORITY);
167 make_ipr_irq(IIC1_TACKI_IRQ, IIC1_IPR_ADDR, IIC1_IPR_POS,
168 IIC1_PRIORITY);
169 make_ipr_irq(IIC1_WAITI_IRQ, IIC1_IPR_ADDR, IIC1_IPR_POS,
170 IIC1_PRIORITY);
171 make_ipr_irq(IIC1_DTEI_IRQ, IIC1_IPR_ADDR, IIC1_IPR_POS, IIC1_PRIORITY);
172
173 /* SIOF */
174 make_ipr_irq(SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY);
175 197
176 /* SIU */
177 make_ipr_irq(SIU_IRQ, SIU_IPR_ADDR, SIU_IPR_POS, SIU_PRIORITY);
178
179 /* VIO interrupt */
180 make_ipr_irq(CEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY);
181 make_ipr_irq(BEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY);
182 make_ipr_irq(VEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY);
183
184 /*MFI interrupt*/
185
186 make_ipr_irq(MFI_IRQ, MFI_IPR_ADDR, MFI_IPR_POS, MFI_PRIORITY);
187
188 /* LCD controller */
189 make_ipr_irq(LCDC_IRQ, LCDC_IPR_ADDR, LCDC_IPR_POS, LCDC_PRIORITY);
190 ctrl_outw(0x2000, PA_MRSHPC + 0x0c); /* mrshpc irq enable */ 198 ctrl_outw(0x2000, PA_MRSHPC + 0x0c); /* mrshpc irq enable */
191} 199}
diff --git a/arch/sh/boards/se/770x/irq.c b/arch/sh/boards/se/770x/irq.c
index cff6700bbafd..fcd7cd7fa05f 100644
--- a/arch/sh/boards/se/770x/irq.c
+++ b/arch/sh/boards/se/770x/irq.c
@@ -13,6 +13,48 @@
13#include <asm/io.h> 13#include <asm/io.h>
14#include <asm/se.h> 14#include <asm/se.h>
15 15
16static struct ipr_data se770x_ipr_map[] = {
17#if defined(CONFIG_CPU_SUBTYPE_SH7705)
18 /* This is default value */
19 { 0xf-0x2, BCR_ILCRA, 2, 0x2 },
20 { 0xf-0xa, BCR_ILCRA, 1, 0xa },
21 { 0xf-0x5, BCR_ILCRB, 0, 0x5 },
22 { 0xf-0x8, BCR_ILCRC, 1, 0x8 },
23 { 0xf-0xc, BCR_ILCRC, 0, 0xc },
24 { 0xf-0xe, BCR_ILCRD, 3, 0xe },
25 { 0xf-0x3, BCR_ILCRD, 1, 0x3 }, /* LAN */
26 { 0xf-0xd, BCR_ILCRE, 2, 0xd },
27 { 0xf-0x9, BCR_ILCRE, 1, 0x9 },
28 { 0xf-0x1, BCR_ILCRE, 0, 0x1 },
29 { 0xf-0xf, BCR_ILCRF, 3, 0xf },
30 { 0xf-0xb, BCR_ILCRF, 1, 0xb },
31 { 0xf-0x7, BCR_ILCRG, 3, 0x7 },
32 { 0xf-0x6, BCR_ILCRG, 2, 0x6 },
33 { 0xf-0x4, BCR_ILCRG, 1, 0x4 },
34#else
35 { 14, BCR_ILCRA, 2, 0x0f-14 },
36 { 12, BCR_ILCRA, 1, 0x0f-12 },
37 { 8, BCR_ILCRB, 1, 0x0f- 8 },
38 { 6, BCR_ILCRC, 3, 0x0f- 6 },
39 { 5, BCR_ILCRC, 2, 0x0f- 5 },
40 { 4, BCR_ILCRC, 1, 0x0f- 4 },
41 { 3, BCR_ILCRC, 0, 0x0f- 3 },
42 { 1, BCR_ILCRD, 3, 0x0f- 1 },
43
44 { 10, BCR_ILCRD, 1, 0x0f-10 }, /* LAN */
45
46 { 0, BCR_ILCRE, 3, 0x0f- 0 }, /* PCIRQ3 */
47 { 11, BCR_ILCRE, 2, 0x0f-11 }, /* PCIRQ2 */
48 { 9, BCR_ILCRE, 1, 0x0f- 9 }, /* PCIRQ1 */
49 { 7, BCR_ILCRE, 0, 0x0f- 7 }, /* PCIRQ0 */
50
51 /* #2, #13 are allocated for SLOT IRQ #1 and #2 (for now) */
52 /* NOTE: #2 and #13 are not used on PC */
53 { 13, BCR_ILCRG, 1, 0x0f-13 }, /* SLOTIRQ2 */
54 { 2, BCR_ILCRG, 0, 0x0f- 2 }, /* SLOTIRQ1 */
55#endif
56};
57
16/* 58/*
17 * Initialize IRQ setting 59 * Initialize IRQ setting
18 */ 60 */
@@ -38,42 +80,6 @@ void __init init_se_IRQ(void)
38 ctrl_outw(0, BCR_ILCRE); 80 ctrl_outw(0, BCR_ILCRE);
39 ctrl_outw(0, BCR_ILCRF); 81 ctrl_outw(0, BCR_ILCRF);
40 ctrl_outw(0, BCR_ILCRG); 82 ctrl_outw(0, BCR_ILCRG);
41 /* This is default value */
42 make_ipr_irq(0xf-0x2, BCR_ILCRA, 2, 0x2);
43 make_ipr_irq(0xf-0xa, BCR_ILCRA, 1, 0xa);
44 make_ipr_irq(0xf-0x5, BCR_ILCRB, 0, 0x5);
45 make_ipr_irq(0xf-0x8, BCR_ILCRC, 1, 0x8);
46 make_ipr_irq(0xf-0xc, BCR_ILCRC, 0, 0xc);
47 make_ipr_irq(0xf-0xe, BCR_ILCRD, 3, 0xe);
48 make_ipr_irq(0xf-0x3, BCR_ILCRD, 1, 0x3); /* LAN */
49 make_ipr_irq(0xf-0xd, BCR_ILCRE, 2, 0xd);
50 make_ipr_irq(0xf-0x9, BCR_ILCRE, 1, 0x9);
51 make_ipr_irq(0xf-0x1, BCR_ILCRE, 0, 0x1);
52 make_ipr_irq(0xf-0xf, BCR_ILCRF, 3, 0xf);
53 make_ipr_irq(0xf-0xb, BCR_ILCRF, 1, 0xb);
54 make_ipr_irq(0xf-0x7, BCR_ILCRG, 3, 0x7);
55 make_ipr_irq(0xf-0x6, BCR_ILCRG, 2, 0x6);
56 make_ipr_irq(0xf-0x4, BCR_ILCRG, 1, 0x4);
57#else
58 make_ipr_irq(14, BCR_ILCRA, 2, 0x0f-14);
59 make_ipr_irq(12, BCR_ILCRA, 1, 0x0f-12);
60 make_ipr_irq( 8, BCR_ILCRB, 1, 0x0f- 8);
61 make_ipr_irq( 6, BCR_ILCRC, 3, 0x0f- 6);
62 make_ipr_irq( 5, BCR_ILCRC, 2, 0x0f- 5);
63 make_ipr_irq( 4, BCR_ILCRC, 1, 0x0f- 4);
64 make_ipr_irq( 3, BCR_ILCRC, 0, 0x0f- 3);
65 make_ipr_irq( 1, BCR_ILCRD, 3, 0x0f- 1);
66
67 make_ipr_irq(10, BCR_ILCRD, 1, 0x0f-10); /* LAN */
68
69 make_ipr_irq( 0, BCR_ILCRE, 3, 0x0f- 0); /* PCIRQ3 */
70 make_ipr_irq(11, BCR_ILCRE, 2, 0x0f-11); /* PCIRQ2 */
71 make_ipr_irq( 9, BCR_ILCRE, 1, 0x0f- 9); /* PCIRQ1 */
72 make_ipr_irq( 7, BCR_ILCRE, 0, 0x0f- 7); /* PCIRQ0 */
73
74 /* #2, #13 are allocated for SLOT IRQ #1 and #2 (for now) */
75 /* NOTE: #2 and #13 are not used on PC */
76 make_ipr_irq(13, BCR_ILCRG, 1, 0x0f-13); /* SLOTIRQ2 */
77 make_ipr_irq( 2, BCR_ILCRG, 0, 0x0f- 2); /* SLOTIRQ1 */
78#endif 83#endif
84 make_ipr_irq(se770x_ipr_map, ARRAY_SIZE(se770x_ipr_map));
79} 85}
diff --git a/arch/sh/boards/se/7751/irq.c b/arch/sh/boards/se/7751/irq.c
index c607b0a48479..e4c63a48296c 100644
--- a/arch/sh/boards/se/7751/irq.c
+++ b/arch/sh/boards/se/7751/irq.c
@@ -14,53 +14,50 @@
14#include <asm/irq.h> 14#include <asm/irq.h>
15#include <asm/se7751.h> 15#include <asm/se7751.h>
16 16
17/* 17static struct ipr_data se7751_ipr_map[] = {
18 * Initialize IRQ setting
19 */
20void __init init_7751se_IRQ(void)
21{
22
23 /* Leave old Solution Engine code in for reference. */ 18 /* Leave old Solution Engine code in for reference. */
24#if defined(CONFIG_SH_SOLUTION_ENGINE) 19#if defined(CONFIG_SH_SOLUTION_ENGINE)
25 /* 20 /*
26 * Super I/O (Just mimic PC): 21 * Super I/O (Just mimic PC):
27 * 1: keyboard 22 * 1: keyboard
28 * 3: serial 0 23 * 3: serial 0
29 * 4: serial 1 24 * 4: serial 1
30 * 5: printer 25 * 5: printer
31 * 6: floppy 26 * 6: floppy
32 * 8: rtc 27 * 8: rtc
33 * 12: mouse 28 * 12: mouse
34 * 14: ide0 29 * 14: ide0
35 */ 30 */
36 make_ipr_irq(14, BCR_ILCRA, 2, 0x0f-14); 31 { 14, BCR_ILCRA, 2, 0x0f-14 },
37 make_ipr_irq(12, BCR_ILCRA, 1, 0x0f-12); 32 { 12, BCR_ILCRA, 1, 0x0f-12 },
38 make_ipr_irq( 8, BCR_ILCRB, 1, 0x0f- 8); 33 { 8, BCR_ILCRB, 1, 0x0f- 8 },
39 make_ipr_irq( 6, BCR_ILCRC, 3, 0x0f- 6); 34 { 6, BCR_ILCRC, 3, 0x0f- 6 },
40 make_ipr_irq( 5, BCR_ILCRC, 2, 0x0f- 5); 35 { 5, BCR_ILCRC, 2, 0x0f- 5 },
41 make_ipr_irq( 4, BCR_ILCRC, 1, 0x0f- 4); 36 { 4, BCR_ILCRC, 1, 0x0f- 4 },
42 make_ipr_irq( 3, BCR_ILCRC, 0, 0x0f- 3); 37 { 3, BCR_ILCRC, 0, 0x0f- 3 },
43 make_ipr_irq( 1, BCR_ILCRD, 3, 0x0f- 1); 38 { 1, BCR_ILCRD, 3, 0x0f- 1 },
44 39
45 make_ipr_irq(10, BCR_ILCRD, 1, 0x0f-10); /* LAN */ 40 { 10, BCR_ILCRD, 1, 0x0f-10 }, /* LAN */
46 41
47 make_ipr_irq( 0, BCR_ILCRE, 3, 0x0f- 0); /* PCIRQ3 */ 42 { 0, BCR_ILCRE, 3, 0x0f- 0 }, /* PCIRQ3 */
48 make_ipr_irq(11, BCR_ILCRE, 2, 0x0f-11); /* PCIRQ2 */ 43 { 11, BCR_ILCRE, 2, 0x0f-11 }, /* PCIRQ2 */
49 make_ipr_irq( 9, BCR_ILCRE, 1, 0x0f- 9); /* PCIRQ1 */ 44 { 9, BCR_ILCRE, 1, 0x0f- 9 }, /* PCIRQ1 */
50 make_ipr_irq( 7, BCR_ILCRE, 0, 0x0f- 7); /* PCIRQ0 */ 45 { 7, BCR_ILCRE, 0, 0x0f- 7 }, /* PCIRQ0 */
51 46
52 /* #2, #13 are allocated for SLOT IRQ #1 and #2 (for now) */ 47 /* #2, #13 are allocated for SLOT IRQ #1 and #2 (for now) */
53 /* NOTE: #2 and #13 are not used on PC */ 48 /* NOTE: #2 and #13 are not used on PC */
54 make_ipr_irq(13, BCR_ILCRG, 1, 0x0f-13); /* SLOTIRQ2 */ 49 { 13, BCR_ILCRG, 1, 0x0f-13 }, /* SLOTIRQ2 */
55 make_ipr_irq( 2, BCR_ILCRG, 0, 0x0f- 2); /* SLOTIRQ1 */ 50 { 2, BCR_ILCRG, 0, 0x0f- 2 }, /* SLOTIRQ1 */
56
57#elif defined(CONFIG_SH_7751_SOLUTION_ENGINE) 51#elif defined(CONFIG_SH_7751_SOLUTION_ENGINE)
58 52 { 13, BCR_ILCRD, 3, 2 },
59 make_ipr_irq(13, BCR_ILCRD, 3, 2); 53 /* Add additional entries here as drivers are added and tested. */
60
61 /* Add additional calls to make_ipr_irq() as drivers are added
62 * and tested.
63 */
64#endif 54#endif
55};
65 56
57/*
58 * Initialize IRQ setting
59 */
60void __init init_7751se_IRQ(void)
61{
62 make_ipr_irq(se7751_ipr_map, ARRAY_SIZE(se7751_ipr_map));
66} 63}
diff --git a/arch/sh/boards/sh03/setup.c b/arch/sh/boards/sh03/setup.c
index 137e2ba9243e..5ad1e19771be 100644
--- a/arch/sh/boards/sh03/setup.c
+++ b/arch/sh/boards/sh03/setup.c
@@ -14,14 +14,17 @@
14#include <asm/sh03/sh03.h> 14#include <asm/sh03/sh03.h>
15#include <asm/addrspace.h> 15#include <asm/addrspace.h>
16 16
17static struct ipr_data sh03_ipr_map[] = {
18 { IRL0_IRQ, IRL0_IPR_ADDR, IRL0_IPR_POS, IRL0_PRIORITY },
19 { IRL1_IRQ, IRL1_IPR_ADDR, IRL1_IPR_POS, IRL1_PRIORITY },
20 { IRL2_IRQ, IRL2_IPR_ADDR, IRL2_IPR_POS, IRL2_PRIORITY },
21 { IRL3_IRQ, IRL3_IPR_ADDR, IRL3_IPR_POS, IRL3_PRIORITY },
22};
23
17static void __init init_sh03_IRQ(void) 24static void __init init_sh03_IRQ(void)
18{ 25{
19 ctrl_outw(ctrl_inw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR); 26 ctrl_outw(ctrl_inw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR);
20 27 make_ipr_irq(sh03_ipr_map, ARRAY_SIZE(sh03_ipr_map));
21 make_ipr_irq(IRL0_IRQ, IRL0_IPR_ADDR, IRL0_IPR_POS, IRL0_PRIORITY);
22 make_ipr_irq(IRL1_IRQ, IRL1_IPR_ADDR, IRL1_IPR_POS, IRL1_PRIORITY);
23 make_ipr_irq(IRL2_IRQ, IRL2_IPR_ADDR, IRL2_IPR_POS, IRL2_PRIORITY);
24 make_ipr_irq(IRL3_IRQ, IRL3_IPR_ADDR, IRL3_IPR_POS, IRL3_PRIORITY);
25} 28}
26 29
27extern void *cf_io_base; 30extern void *cf_io_base;
diff --git a/arch/sh/boards/shmin/setup.c b/arch/sh/boards/shmin/setup.c
index 2f0c19706cf9..a31a1d1e2681 100644
--- a/arch/sh/boards/shmin/setup.c
+++ b/arch/sh/boards/shmin/setup.c
@@ -7,7 +7,7 @@
7 */ 7 */
8#include <linux/init.h> 8#include <linux/init.h>
9#include <asm/machvec.h> 9#include <asm/machvec.h>
10#include <asm/shmin/shmin.h> 10#include <asm/shmin.h>
11#include <asm/clock.h> 11#include <asm/clock.h>
12#include <asm/irq.h> 12#include <asm/irq.h>
13#include <asm/io.h> 13#include <asm/io.h>
diff --git a/arch/sh/boards/snapgear/setup.c b/arch/sh/boards/snapgear/setup.c
index f5e98c56b530..650fb3645947 100644
--- a/arch/sh/boards/snapgear/setup.c
+++ b/arch/sh/boards/snapgear/setup.c
@@ -33,7 +33,7 @@ extern void pcibios_init(void);
33 * EraseConfig handling functions 33 * EraseConfig handling functions
34 */ 34 */
35 35
36static irqreturn_t eraseconfig_interrupt(int irq, void *dev_id, struct pt_regs *regs) 36static irqreturn_t eraseconfig_interrupt(int irq, void *dev_id)
37{ 37{
38 volatile char dummy __attribute__((unused)) = * (volatile char *) 0xb8000000; 38 volatile char dummy __attribute__((unused)) = * (volatile char *) 0xb8000000;
39 39
@@ -68,6 +68,13 @@ module_init(eraseconfig_init);
68 * IRL3 = crypto 68 * IRL3 = crypto
69 */ 69 */
70 70
71static struct ipr_data snapgear_ipr_map[] = {
72 make_ipr_irq(IRL0_IRQ, IRL0_IPR_ADDR, IRL0_IPR_POS, IRL0_PRIORITY);
73 make_ipr_irq(IRL1_IRQ, IRL1_IPR_ADDR, IRL1_IPR_POS, IRL1_PRIORITY);
74 make_ipr_irq(IRL2_IRQ, IRL2_IPR_ADDR, IRL2_IPR_POS, IRL2_PRIORITY);
75 make_ipr_irq(IRL3_IRQ, IRL3_IPR_ADDR, IRL3_IPR_POS, IRL3_PRIORITY);
76};
77
71static void __init init_snapgear_IRQ(void) 78static void __init init_snapgear_IRQ(void)
72{ 79{
73 /* enable individual interrupt mode for externals */ 80 /* enable individual interrupt mode for externals */
@@ -75,10 +82,7 @@ static void __init init_snapgear_IRQ(void)
75 82
76 printk("Setup SnapGear IRQ/IPR ...\n"); 83 printk("Setup SnapGear IRQ/IPR ...\n");
77 84
78 make_ipr_irq(IRL0_IRQ, IRL0_IPR_ADDR, IRL0_IPR_POS, IRL0_PRIORITY); 85 make_ipr_irq(snapgear_ipr_map, ARRAY_SIZE(snapgear_ipr_map));
79 make_ipr_irq(IRL1_IRQ, IRL1_IPR_ADDR, IRL1_IPR_POS, IRL1_PRIORITY);
80 make_ipr_irq(IRL2_IRQ, IRL2_IPR_ADDR, IRL2_IPR_POS, IRL2_PRIORITY);
81 make_ipr_irq(IRL3_IRQ, IRL3_IPR_ADDR, IRL3_IPR_POS, IRL3_PRIORITY);
82} 86}
83 87
84/* 88/*
diff --git a/arch/sh/boards/titan/setup.c b/arch/sh/boards/titan/setup.c
index 52b66d8b8d2a..a6046d93758b 100644
--- a/arch/sh/boards/titan/setup.c
+++ b/arch/sh/boards/titan/setup.c
@@ -9,15 +9,19 @@
9 9
10extern void __init pcibios_init_platform(void); 10extern void __init pcibios_init_platform(void);
11 11
12static struct ipr_data titan_ipr_map[] = {
13 { TITAN_IRQ_WAN, IRL0_IPR_ADDR, IRL0_IPR_POS, IRL0_PRIORITY },
14 { TITAN_IRQ_LAN, IRL1_IPR_ADDR, IRL1_IPR_POS, IRL1_PRIORITY },
15 { TITAN_IRQ_MPCIA, IRL2_IPR_ADDR, IRL2_IPR_POS, IRL2_PRIORITY },
16 { TITAN_IRQ_USB, IRL3_IPR_ADDR, IRL3_IPR_POS, IRL3_PRIORITY },
17};
18
12static void __init init_titan_irq(void) 19static void __init init_titan_irq(void)
13{ 20{
14 /* enable individual interrupt mode for externals */ 21 /* enable individual interrupt mode for externals */
15 ctrl_outw(ctrl_inw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR); 22 ctrl_outw(ctrl_inw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR);
16 23
17 make_ipr_irq( TITAN_IRQ_WAN, IRL0_IPR_ADDR, IRL0_IPR_POS, IRL0_PRIORITY); /* PCIRQ0 */ 24 make_ipr_irq(titan_ipr_map, ARRAY_SIZE(titan_ipr_map));
18 make_ipr_irq( TITAN_IRQ_LAN, IRL1_IPR_ADDR, IRL1_IPR_POS, IRL1_PRIORITY); /* PCIRQ1 */
19 make_ipr_irq( TITAN_IRQ_MPCIA, IRL2_IPR_ADDR, IRL2_IPR_POS, IRL2_PRIORITY); /* PCIRQ2 */
20 make_ipr_irq( TITAN_IRQ_USB, IRL3_IPR_ADDR, IRL3_IPR_POS, IRL3_PRIORITY); /* PCIRQ3 */
21} 25}
22 26
23struct sh_machine_vector mv_titan __initmv = { 27struct sh_machine_vector mv_titan __initmv = {
diff --git a/arch/sh/cchips/hd6446x/hd64461/setup.c b/arch/sh/cchips/hd6446x/hd64461/setup.c
index 38f1e8171a3a..4d49b5cbcc13 100644
--- a/arch/sh/cchips/hd6446x/hd64461/setup.c
+++ b/arch/sh/cchips/hd6446x/hd64461/setup.c
@@ -71,7 +71,7 @@ static struct hw_interrupt_type hd64461_irq_type = {
71 .end = end_hd64461_irq, 71 .end = end_hd64461_irq,
72}; 72};
73 73
74static irqreturn_t hd64461_interrupt(int irq, void *dev_id, struct pt_regs *regs) 74static irqreturn_t hd64461_interrupt(int irq, void *dev_id)
75{ 75{
76 printk(KERN_INFO 76 printk(KERN_INFO
77 "HD64461: spurious interrupt, nirr: 0x%x nimr: 0x%x\n", 77 "HD64461: spurious interrupt, nirr: 0x%x nimr: 0x%x\n",
diff --git a/arch/sh/cchips/hd6446x/hd64465/gpio.c b/arch/sh/cchips/hd6446x/hd64465/gpio.c
index 72320d02d69a..43431855ec86 100644
--- a/arch/sh/cchips/hd6446x/hd64465/gpio.c
+++ b/arch/sh/cchips/hd6446x/hd64465/gpio.c
@@ -85,7 +85,7 @@ static struct {
85 void *dev; 85 void *dev;
86} handlers[GPIO_NPORTS * 8]; 86} handlers[GPIO_NPORTS * 8];
87 87
88static irqreturn_t hd64465_gpio_interrupt(int irq, void *dev, struct pt_regs *regs) 88static irqreturn_t hd64465_gpio_interrupt(int irq, void *dev)
89{ 89{
90 unsigned short port, pin, isr, mask, portpin; 90 unsigned short port, pin, isr, mask, portpin;
91 91
diff --git a/arch/sh/cchips/hd6446x/hd64465/setup.c b/arch/sh/cchips/hd6446x/hd64465/setup.c
index 30573d3e1966..d126e1f30dee 100644
--- a/arch/sh/cchips/hd6446x/hd64465/setup.c
+++ b/arch/sh/cchips/hd6446x/hd64465/setup.c
@@ -84,7 +84,7 @@ static struct hw_interrupt_type hd64465_irq_type = {
84}; 84};
85 85
86 86
87static irqreturn_t hd64465_interrupt(int irq, void *dev_id, struct pt_regs *regs) 87static irqreturn_t hd64465_interrupt(int irq, void *dev_id)
88{ 88{
89 printk(KERN_INFO 89 printk(KERN_INFO
90 "HD64465: spurious interrupt, nirr: 0x%x nimr: 0x%x\n", 90 "HD64465: spurious interrupt, nirr: 0x%x nimr: 0x%x\n",
diff --git a/arch/sh/cchips/voyagergx/irq.c b/arch/sh/cchips/voyagergx/irq.c
index 392c8b12ce36..f7ea700d05ae 100644
--- a/arch/sh/cchips/voyagergx/irq.c
+++ b/arch/sh/cchips/voyagergx/irq.c
@@ -17,29 +17,18 @@
17 17
18 Copyright 2003 (c) Lineo uSolutions,Inc. 18 Copyright 2003 (c) Lineo uSolutions,Inc.
19*/ 19*/
20/* -------------------------------------------------------------------- */
21
22#undef DEBUG
23
24#include <linux/sched.h>
25#include <linux/module.h>
26#include <linux/kernel.h>
27#include <linux/param.h>
28#include <linux/ioport.h>
29#include <linux/interrupt.h> 20#include <linux/interrupt.h>
30#include <linux/init.h> 21#include <linux/init.h>
31#include <linux/irq.h> 22#include <linux/io.h>
32
33#include <asm/io.h>
34#include <asm/irq.h>
35#include <asm/voyagergx.h> 23#include <asm/voyagergx.h>
24#include <asm/rts7751r2d.h>
36 25
37static void disable_voyagergx_irq(unsigned int irq) 26static void disable_voyagergx_irq(unsigned int irq)
38{ 27{
39 unsigned long val; 28 unsigned long val;
40 unsigned long mask = 1 << (irq - VOYAGER_IRQ_BASE); 29 unsigned long mask = 1 << (irq - VOYAGER_IRQ_BASE);
41 30
42 pr_debug("disable_voyagergx_irq(%d): mask=%x\n", irq, mask); 31 pr_debug("disable_voyagergx_irq(%d): mask=%lx\n", irq, mask);
43 val = inl(VOYAGER_INT_MASK); 32 val = inl(VOYAGER_INT_MASK);
44 val &= ~mask; 33 val &= ~mask;
45 outl(val, VOYAGER_INT_MASK); 34 outl(val, VOYAGER_INT_MASK);
@@ -50,7 +39,7 @@ static void enable_voyagergx_irq(unsigned int irq)
50 unsigned long val; 39 unsigned long val;
51 unsigned long mask = 1 << (irq - VOYAGER_IRQ_BASE); 40 unsigned long mask = 1 << (irq - VOYAGER_IRQ_BASE);
52 41
53 pr_debug("disable_voyagergx_irq(%d): mask=%x\n", irq, mask); 42 pr_debug("disable_voyagergx_irq(%d): mask=%lx\n", irq, mask);
54 val = inl(VOYAGER_INT_MASK); 43 val = inl(VOYAGER_INT_MASK);
55 val |= mask; 44 val |= mask;
56 outl(val, VOYAGER_INT_MASK); 45 outl(val, VOYAGER_INT_MASK);
@@ -88,8 +77,7 @@ static struct hw_interrupt_type voyagergx_irq_type = {
88 .end = end_voyagergx_irq, 77 .end = end_voyagergx_irq,
89}; 78};
90 79
91static irqreturn_t voyagergx_interrupt(int irq, void *dev_id, 80static irqreturn_t voyagergx_interrupt(int irq, void *dev_id)
92 struct pt_regs *regs)
93{ 81{
94 printk(KERN_INFO 82 printk(KERN_INFO
95 "VoyagerGX: spurious interrupt, status: 0x%x\n", 83 "VoyagerGX: spurious interrupt, status: 0x%x\n",
@@ -138,7 +126,7 @@ int voyagergx_irq_demux(int irq)
138 } else { 126 } else {
139 printk("Unexpected IRQ irq = %d status = 0x%08lx\n", irq, val); 127 printk("Unexpected IRQ irq = %d status = 0x%08lx\n", irq, val);
140 } 128 }
141 pr_debug("voyagergx_irq_demux %d \n", i); 129 pr_debug("voyagergx_irq_demux %ld\n", i);
142#else 130#else
143 for (bit = 1, i = 0 ; i < VOYAGER_IRQ_NUM ; bit <<= 1, i++) 131 for (bit = 1, i = 0 ; i < VOYAGER_IRQ_NUM ; bit <<= 1, i++)
144 if (val & bit) 132 if (val & bit)
@@ -186,4 +174,3 @@ void __init setup_voyagergx_irq(void)
186 174
187 setup_irq(IRQ_VOYAGER, &irq0); 175 setup_irq(IRQ_VOYAGER, &irq0);
188} 176}
189
diff --git a/arch/sh/configs/r7780rp_defconfig b/arch/sh/configs/r7780rp_defconfig
index 2470364948e7..34e2046c3213 100644
--- a/arch/sh/configs/r7780rp_defconfig
+++ b/arch/sh/configs/r7780rp_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.18 3# Linux kernel version: 2.6.19-rc3
4# Tue Oct 3 11:32:47 2006 4# Tue Oct 31 12:32:06 2006
5# 5#
6CONFIG_SUPERH=y 6CONFIG_SUPERH=y
7CONFIG_RWSEM_GENERIC_SPINLOCK=y 7CONFIG_RWSEM_GENERIC_SPINLOCK=y
@@ -10,6 +10,7 @@ CONFIG_GENERIC_HWEIGHT=y
10CONFIG_GENERIC_HARDIRQS=y 10CONFIG_GENERIC_HARDIRQS=y
11CONFIG_GENERIC_IRQ_PROBE=y 11CONFIG_GENERIC_IRQ_PROBE=y
12CONFIG_GENERIC_CALIBRATE_DELAY=y 12CONFIG_GENERIC_CALIBRATE_DELAY=y
13# CONFIG_GENERIC_TIME is not set
13CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 14CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
14 15
15# 16#
@@ -178,7 +179,7 @@ CONFIG_MMU=y
178CONFIG_PAGE_OFFSET=0x80000000 179CONFIG_PAGE_OFFSET=0x80000000
179CONFIG_MEMORY_START=0x08000000 180CONFIG_MEMORY_START=0x08000000
180CONFIG_MEMORY_SIZE=0x08000000 181CONFIG_MEMORY_SIZE=0x08000000
181CONFIG_32BIT=y 182# CONFIG_32BIT is not set
182CONFIG_VSYSCALL=y 183CONFIG_VSYSCALL=y
183CONFIG_HUGETLB_PAGE_SIZE_64K=y 184CONFIG_HUGETLB_PAGE_SIZE_64K=y
184# CONFIG_HUGETLB_PAGE_SIZE_1MB is not set 185# CONFIG_HUGETLB_PAGE_SIZE_1MB is not set
@@ -229,9 +230,7 @@ CONFIG_SH_PCLK_FREQ=32000000
229# 230#
230# DMA support 231# DMA support
231# 232#
232CONFIG_SH_DMA=y 233# CONFIG_SH_DMA is not set
233CONFIG_NR_ONCHIP_DMA_CHANNELS=6
234# CONFIG_NR_DMA_CHANNELS_BOOL is not set
235 234
236# 235#
237# Companion Chips 236# Companion Chips
@@ -259,7 +258,7 @@ CONFIG_ZERO_PAGE_OFFSET=0x00001000
259CONFIG_BOOT_LINK_OFFSET=0x00800000 258CONFIG_BOOT_LINK_OFFSET=0x00800000
260# CONFIG_UBC_WAKEUP is not set 259# CONFIG_UBC_WAKEUP is not set
261CONFIG_CMDLINE_BOOL=y 260CONFIG_CMDLINE_BOOL=y
262CONFIG_CMDLINE="mem=128M console=ttySC0,115200 root=/dev/hda1" 261CONFIG_CMDLINE="mem=128M console=ttySC0,115200 root=/dev/sda1"
263 262
264# 263#
265# Bus options 264# Bus options
@@ -336,6 +335,7 @@ CONFIG_IP_PNP_DHCP=y
336# CONFIG_INET_TUNNEL is not set 335# CONFIG_INET_TUNNEL is not set
337CONFIG_INET_XFRM_MODE_TRANSPORT=y 336CONFIG_INET_XFRM_MODE_TRANSPORT=y
338CONFIG_INET_XFRM_MODE_TUNNEL=y 337CONFIG_INET_XFRM_MODE_TUNNEL=y
338CONFIG_INET_XFRM_MODE_BEET=y
339CONFIG_INET_DIAG=y 339CONFIG_INET_DIAG=y
340CONFIG_INET_TCP_DIAG=y 340CONFIG_INET_TCP_DIAG=y
341# CONFIG_TCP_CONG_ADVANCED is not set 341# CONFIG_TCP_CONG_ADVANCED is not set
@@ -441,76 +441,28 @@ CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
441# CONFIG_ATA_OVER_ETH is not set 441# CONFIG_ATA_OVER_ETH is not set
442 442
443# 443#
444# Misc devices
445#
446# CONFIG_SGI_IOC4 is not set
447# CONFIG_TIFM_CORE is not set
448
449#
444# ATA/ATAPI/MFM/RLL support 450# ATA/ATAPI/MFM/RLL support
445# 451#
446CONFIG_IDE=m 452# CONFIG_IDE is not set
447CONFIG_IDE_MAX_HWIFS=4
448CONFIG_BLK_DEV_IDE=m
449
450#
451# Please see Documentation/ide.txt for help/info on IDE drives
452#
453CONFIG_BLK_DEV_IDE_SATA=y
454CONFIG_BLK_DEV_IDEDISK=m
455CONFIG_IDEDISK_MULTI_MODE=y
456# CONFIG_BLK_DEV_IDECD is not set
457# CONFIG_BLK_DEV_IDETAPE is not set
458# CONFIG_BLK_DEV_IDEFLOPPY is not set
459CONFIG_BLK_DEV_IDESCSI=m
460# CONFIG_IDE_TASK_IOCTL is not set
461
462#
463# IDE chipset support/bugfixes
464#
465CONFIG_IDE_GENERIC=m
466CONFIG_BLK_DEV_IDEPCI=y
467CONFIG_IDEPCI_SHARE_IRQ=y
468# CONFIG_BLK_DEV_OFFBOARD is not set
469CONFIG_BLK_DEV_GENERIC=m
470# CONFIG_BLK_DEV_OPTI621 is not set
471CONFIG_BLK_DEV_IDEDMA_PCI=y
472# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
473CONFIG_IDEDMA_PCI_AUTO=y
474# CONFIG_IDEDMA_ONLYDISK is not set
475CONFIG_BLK_DEV_AEC62XX=m
476# CONFIG_BLK_DEV_ALI15X3 is not set
477# CONFIG_BLK_DEV_AMD74XX is not set
478# CONFIG_BLK_DEV_CMD64X is not set
479# CONFIG_BLK_DEV_TRIFLEX is not set
480# CONFIG_BLK_DEV_CY82C693 is not set
481# CONFIG_BLK_DEV_CS5520 is not set
482# CONFIG_BLK_DEV_CS5530 is not set
483# CONFIG_BLK_DEV_HPT34X is not set
484# CONFIG_BLK_DEV_HPT366 is not set
485# CONFIG_BLK_DEV_SC1200 is not set
486# CONFIG_BLK_DEV_PIIX is not set
487# CONFIG_BLK_DEV_IT821X is not set
488# CONFIG_BLK_DEV_NS87415 is not set
489# CONFIG_BLK_DEV_PDC202XX_OLD is not set
490CONFIG_BLK_DEV_PDC202XX_NEW=m
491# CONFIG_BLK_DEV_SVWKS is not set
492CONFIG_BLK_DEV_SIIMAGE=m
493# CONFIG_BLK_DEV_SLC90E66 is not set
494# CONFIG_BLK_DEV_TRM290 is not set
495# CONFIG_BLK_DEV_VIA82CXXX is not set
496# CONFIG_IDE_ARM is not set
497CONFIG_BLK_DEV_IDEDMA=y
498# CONFIG_IDEDMA_IVB is not set
499CONFIG_IDEDMA_AUTO=y
500# CONFIG_BLK_DEV_HD is not set
501 453
502# 454#
503# SCSI device support 455# SCSI device support
504# 456#
505# CONFIG_RAID_ATTRS is not set 457# CONFIG_RAID_ATTRS is not set
506CONFIG_SCSI=m 458CONFIG_SCSI=y
507# CONFIG_SCSI_NETLINK is not set 459# CONFIG_SCSI_NETLINK is not set
508CONFIG_SCSI_PROC_FS=y 460CONFIG_SCSI_PROC_FS=y
509 461
510# 462#
511# SCSI support type (disk, tape, CD-ROM) 463# SCSI support type (disk, tape, CD-ROM)
512# 464#
513CONFIG_BLK_DEV_SD=m 465CONFIG_BLK_DEV_SD=y
514# CONFIG_CHR_DEV_ST is not set 466# CONFIG_CHR_DEV_ST is not set
515# CONFIG_CHR_DEV_OSST is not set 467# CONFIG_CHR_DEV_OSST is not set
516# CONFIG_BLK_DEV_SR is not set 468# CONFIG_BLK_DEV_SR is not set
@@ -561,6 +513,7 @@ CONFIG_CHR_DEV_SG=m
561# CONFIG_SCSI_IPR is not set 513# CONFIG_SCSI_IPR is not set
562# CONFIG_SCSI_QLOGIC_1280 is not set 514# CONFIG_SCSI_QLOGIC_1280 is not set
563# CONFIG_SCSI_QLA_FC is not set 515# CONFIG_SCSI_QLA_FC is not set
516# CONFIG_SCSI_QLA_ISCSI is not set
564# CONFIG_SCSI_LPFC is not set 517# CONFIG_SCSI_LPFC is not set
565# CONFIG_SCSI_DC395x is not set 518# CONFIG_SCSI_DC395x is not set
566# CONFIG_SCSI_DC390T is not set 519# CONFIG_SCSI_DC390T is not set
@@ -570,7 +523,55 @@ CONFIG_CHR_DEV_SG=m
570# 523#
571# Serial ATA (prod) and Parallel ATA (experimental) drivers 524# Serial ATA (prod) and Parallel ATA (experimental) drivers
572# 525#
573# CONFIG_ATA is not set 526CONFIG_ATA=y
527# CONFIG_SATA_AHCI is not set
528# CONFIG_SATA_SVW is not set
529# CONFIG_ATA_PIIX is not set
530# CONFIG_SATA_MV is not set
531# CONFIG_SATA_NV is not set
532# CONFIG_PDC_ADMA is not set
533# CONFIG_SATA_QSTOR is not set
534# CONFIG_SATA_PROMISE is not set
535# CONFIG_SATA_SX4 is not set
536CONFIG_SATA_SIL=y
537# CONFIG_SATA_SIL24 is not set
538# CONFIG_SATA_SIS is not set
539# CONFIG_SATA_ULI is not set
540# CONFIG_SATA_VIA is not set
541# CONFIG_SATA_VITESSE is not set
542# CONFIG_PATA_ALI is not set
543# CONFIG_PATA_AMD is not set
544# CONFIG_PATA_ARTOP is not set
545# CONFIG_PATA_ATIIXP is not set
546# CONFIG_PATA_CMD64X is not set
547# CONFIG_PATA_CS5520 is not set
548# CONFIG_PATA_CS5530 is not set
549# CONFIG_PATA_CYPRESS is not set
550# CONFIG_PATA_EFAR is not set
551# CONFIG_ATA_GENERIC is not set
552# CONFIG_PATA_HPT366 is not set
553# CONFIG_PATA_HPT37X is not set
554# CONFIG_PATA_HPT3X2N is not set
555# CONFIG_PATA_HPT3X3 is not set
556# CONFIG_PATA_IT821X is not set
557# CONFIG_PATA_JMICRON is not set
558# CONFIG_PATA_TRIFLEX is not set
559# CONFIG_PATA_MPIIX is not set
560# CONFIG_PATA_OLDPIIX is not set
561# CONFIG_PATA_NETCELL is not set
562# CONFIG_PATA_NS87410 is not set
563# CONFIG_PATA_OPTI is not set
564# CONFIG_PATA_OPTIDMA is not set
565# CONFIG_PATA_PDC_OLD is not set
566# CONFIG_PATA_RADISYS is not set
567# CONFIG_PATA_RZ1000 is not set
568# CONFIG_PATA_SC1200 is not set
569# CONFIG_PATA_SERVERWORKS is not set
570# CONFIG_PATA_PDC2027X is not set
571# CONFIG_PATA_SIL680 is not set
572# CONFIG_PATA_SIS is not set
573# CONFIG_PATA_VIA is not set
574# CONFIG_PATA_WINBOND is not set
574 575
575# 576#
576# Multi-device support (RAID and LVM) 577# Multi-device support (RAID and LVM)
@@ -840,7 +841,6 @@ CONFIG_HW_RANDOM=y
840# TPM devices 841# TPM devices
841# 842#
842# CONFIG_TCG_TPM is not set 843# CONFIG_TCG_TPM is not set
843# CONFIG_TELCLOCK is not set
844 844
845# 845#
846# I2C support 846# I2C support
@@ -856,6 +856,7 @@ CONFIG_HW_RANDOM=y
856# 856#
857# Dallas's 1-wire bus 857# Dallas's 1-wire bus
858# 858#
859# CONFIG_W1 is not set
859 860
860# 861#
861# Hardware Monitoring support 862# Hardware Monitoring support
@@ -868,14 +869,9 @@ CONFIG_HWMON=y
868# CONFIG_HWMON_DEBUG_CHIP is not set 869# CONFIG_HWMON_DEBUG_CHIP is not set
869 870
870# 871#
871# Misc devices
872#
873
874#
875# Multimedia devices 872# Multimedia devices
876# 873#
877# CONFIG_VIDEO_DEV is not set 874# CONFIG_VIDEO_DEV is not set
878CONFIG_VIDEO_V4L2=y
879 875
880# 876#
881# Digital Video Broadcasting Devices 877# Digital Video Broadcasting Devices
@@ -959,7 +955,29 @@ CONFIG_USB_ARCH_HAS_EHCI=y
959# 955#
960# Real Time Clock 956# Real Time Clock
961# 957#
962# CONFIG_RTC_CLASS is not set 958CONFIG_RTC_LIB=y
959CONFIG_RTC_CLASS=y
960CONFIG_RTC_HCTOSYS=y
961CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
962# CONFIG_RTC_DEBUG is not set
963
964#
965# RTC interfaces
966#
967CONFIG_RTC_INTF_SYSFS=y
968CONFIG_RTC_INTF_PROC=y
969CONFIG_RTC_INTF_DEV=y
970# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
971
972#
973# RTC drivers
974#
975# CONFIG_RTC_DRV_DS1553 is not set
976# CONFIG_RTC_DRV_DS1742 is not set
977# CONFIG_RTC_DRV_M48T86 is not set
978CONFIG_RTC_DRV_SH=y
979# CONFIG_RTC_DRV_TEST is not set
980# CONFIG_RTC_DRV_V3020 is not set
963 981
964# 982#
965# DMA Engine support 983# DMA Engine support
@@ -984,6 +1002,7 @@ CONFIG_EXT3_FS=y
984CONFIG_EXT3_FS_XATTR=y 1002CONFIG_EXT3_FS_XATTR=y
985# CONFIG_EXT3_FS_POSIX_ACL is not set 1003# CONFIG_EXT3_FS_POSIX_ACL is not set
986# CONFIG_EXT3_FS_SECURITY is not set 1004# CONFIG_EXT3_FS_SECURITY is not set
1005# CONFIG_EXT4DEV_FS is not set
987CONFIG_JBD=y 1006CONFIG_JBD=y
988# CONFIG_JBD_DEBUG is not set 1007# CONFIG_JBD_DEBUG is not set
989CONFIG_FS_MBCACHE=y 1008CONFIG_FS_MBCACHE=y
@@ -991,6 +1010,7 @@ CONFIG_FS_MBCACHE=y
991# CONFIG_JFS_FS is not set 1010# CONFIG_JFS_FS is not set
992CONFIG_FS_POSIX_ACL=y 1011CONFIG_FS_POSIX_ACL=y
993# CONFIG_XFS_FS is not set 1012# CONFIG_XFS_FS is not set
1013# CONFIG_GFS2_FS is not set
994# CONFIG_OCFS2_FS is not set 1014# CONFIG_OCFS2_FS is not set
995CONFIG_MINIX_FS=y 1015CONFIG_MINIX_FS=y
996# CONFIG_ROMFS_FS is not set 1016# CONFIG_ROMFS_FS is not set
@@ -1027,7 +1047,8 @@ CONFIG_PROC_FS=y
1027CONFIG_PROC_KCORE=y 1047CONFIG_PROC_KCORE=y
1028CONFIG_PROC_SYSCTL=y 1048CONFIG_PROC_SYSCTL=y
1029CONFIG_SYSFS=y 1049CONFIG_SYSFS=y
1030# CONFIG_TMPFS is not set 1050CONFIG_TMPFS=y
1051# CONFIG_TMPFS_POSIX_ACL is not set
1031CONFIG_HUGETLBFS=y 1052CONFIG_HUGETLBFS=y
1032CONFIG_HUGETLB_PAGE=y 1053CONFIG_HUGETLB_PAGE=y
1033CONFIG_RAMFS=y 1054CONFIG_RAMFS=y
@@ -1159,6 +1180,7 @@ CONFIG_DEBUG_FS=y
1159# CONFIG_DEBUG_LIST is not set 1180# CONFIG_DEBUG_LIST is not set
1160CONFIG_FRAME_POINTER=y 1181CONFIG_FRAME_POINTER=y
1161CONFIG_FORCED_INLINING=y 1182CONFIG_FORCED_INLINING=y
1183# CONFIG_HEADERS_CHECK is not set
1162# CONFIG_RCU_TORTURE_TEST is not set 1184# CONFIG_RCU_TORTURE_TEST is not set
1163# CONFIG_SH_STANDARD_BIOS is not set 1185# CONFIG_SH_STANDARD_BIOS is not set
1164# CONFIG_EARLY_SCIF_CONSOLE is not set 1186# CONFIG_EARLY_SCIF_CONSOLE is not set
@@ -1178,9 +1200,9 @@ CONFIG_FORCED_INLINING=y
1178# 1200#
1179CONFIG_CRYPTO=y 1201CONFIG_CRYPTO=y
1180CONFIG_CRYPTO_ALGAPI=y 1202CONFIG_CRYPTO_ALGAPI=y
1181CONFIG_CRYPTO_BLKCIPHER=m 1203CONFIG_CRYPTO_BLKCIPHER=y
1182CONFIG_CRYPTO_HASH=y 1204CONFIG_CRYPTO_HASH=y
1183CONFIG_CRYPTO_MANAGER=m 1205CONFIG_CRYPTO_MANAGER=y
1184CONFIG_CRYPTO_HMAC=y 1206CONFIG_CRYPTO_HMAC=y
1185# CONFIG_CRYPTO_NULL is not set 1207# CONFIG_CRYPTO_NULL is not set
1186# CONFIG_CRYPTO_MD4 is not set 1208# CONFIG_CRYPTO_MD4 is not set
@@ -1191,7 +1213,7 @@ CONFIG_CRYPTO_MD5=y
1191# CONFIG_CRYPTO_WP512 is not set 1213# CONFIG_CRYPTO_WP512 is not set
1192# CONFIG_CRYPTO_TGR192 is not set 1214# CONFIG_CRYPTO_TGR192 is not set
1193CONFIG_CRYPTO_ECB=m 1215CONFIG_CRYPTO_ECB=m
1194CONFIG_CRYPTO_CBC=m 1216CONFIG_CRYPTO_CBC=y
1195CONFIG_CRYPTO_DES=y 1217CONFIG_CRYPTO_DES=y
1196# CONFIG_CRYPTO_BLOWFISH is not set 1218# CONFIG_CRYPTO_BLOWFISH is not set
1197# CONFIG_CRYPTO_TWOFISH is not set 1219# CONFIG_CRYPTO_TWOFISH is not set
diff --git a/arch/sh/configs/titan_defconfig b/arch/sh/configs/titan_defconfig
index 5e8175461138..41049cf14b79 100644
--- a/arch/sh/configs/titan_defconfig
+++ b/arch/sh/configs/titan_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.18 3# Linux kernel version: 2.6.19-rc3
4# Tue Oct 3 12:59:14 2006 4# Mon Oct 30 18:04:49 2006
5# 5#
6CONFIG_SUPERH=y 6CONFIG_SUPERH=y
7CONFIG_RWSEM_GENERIC_SPINLOCK=y 7CONFIG_RWSEM_GENERIC_SPINLOCK=y
@@ -10,6 +10,7 @@ CONFIG_GENERIC_HWEIGHT=y
10CONFIG_GENERIC_HARDIRQS=y 10CONFIG_GENERIC_HARDIRQS=y
11CONFIG_GENERIC_IRQ_PROBE=y 11CONFIG_GENERIC_IRQ_PROBE=y
12CONFIG_GENERIC_CALIBRATE_DELAY=y 12CONFIG_GENERIC_CALIBRATE_DELAY=y
13# CONFIG_GENERIC_TIME is not set
13CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 14CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
14 15
15# 16#
@@ -23,7 +24,7 @@ CONFIG_INIT_ENV_ARG_LIMIT=32
23# General setup 24# General setup
24# 25#
25CONFIG_LOCALVERSION="" 26CONFIG_LOCALVERSION=""
26CONFIG_LOCALVERSION_AUTO=y 27# CONFIG_LOCALVERSION_AUTO is not set
27CONFIG_SWAP=y 28CONFIG_SWAP=y
28CONFIG_SYSVIPC=y 29CONFIG_SYSVIPC=y
29# CONFIG_IPC_NS is not set 30# CONFIG_IPC_NS is not set
@@ -236,8 +237,8 @@ CONFIG_HZ_250=y
236CONFIG_HZ=250 237CONFIG_HZ=250
237# CONFIG_KEXEC is not set 238# CONFIG_KEXEC is not set
238# CONFIG_SMP is not set 239# CONFIG_SMP is not set
239CONFIG_PREEMPT_NONE=y 240# CONFIG_PREEMPT_NONE is not set
240# CONFIG_PREEMPT_VOLUNTARY is not set 241CONFIG_PREEMPT_VOLUNTARY=y
241# CONFIG_PREEMPT is not set 242# CONFIG_PREEMPT is not set
242 243
243# 244#
@@ -247,7 +248,7 @@ CONFIG_ZERO_PAGE_OFFSET=0x00001000
247CONFIG_BOOT_LINK_OFFSET=0x009e0000 248CONFIG_BOOT_LINK_OFFSET=0x009e0000
248# CONFIG_UBC_WAKEUP is not set 249# CONFIG_UBC_WAKEUP is not set
249CONFIG_CMDLINE_BOOL=y 250CONFIG_CMDLINE_BOOL=y
250CONFIG_CMDLINE="console=ttySC1,38400N81 root=/dev/nfs ip=:::::eth1:autoconf" 251CONFIG_CMDLINE="console=ttySC1,38400N81 root=/dev/nfs ip=:::::eth1:autoconf rw"
251 252
252# 253#
253# Bus options 254# Bus options
@@ -334,6 +335,7 @@ CONFIG_INET_XFRM_TUNNEL=y
334CONFIG_INET_TUNNEL=y 335CONFIG_INET_TUNNEL=y
335CONFIG_INET_XFRM_MODE_TRANSPORT=y 336CONFIG_INET_XFRM_MODE_TRANSPORT=y
336CONFIG_INET_XFRM_MODE_TUNNEL=y 337CONFIG_INET_XFRM_MODE_TUNNEL=y
338CONFIG_INET_XFRM_MODE_BEET=y
337CONFIG_INET_DIAG=m 339CONFIG_INET_DIAG=m
338CONFIG_INET_TCP_DIAG=m 340CONFIG_INET_TCP_DIAG=m
339# CONFIG_TCP_CONG_ADVANCED is not set 341# CONFIG_TCP_CONG_ADVANCED is not set
@@ -355,9 +357,10 @@ CONFIG_INET6_XFRM_TUNNEL=y
355CONFIG_INET6_TUNNEL=y 357CONFIG_INET6_TUNNEL=y
356CONFIG_INET6_XFRM_MODE_TRANSPORT=y 358CONFIG_INET6_XFRM_MODE_TRANSPORT=y
357CONFIG_INET6_XFRM_MODE_TUNNEL=y 359CONFIG_INET6_XFRM_MODE_TUNNEL=y
360CONFIG_INET6_XFRM_MODE_BEET=y
358# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set 361# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
362CONFIG_IPV6_SIT=m
359CONFIG_IPV6_TUNNEL=y 363CONFIG_IPV6_TUNNEL=y
360# CONFIG_IPV6_SUBTREES is not set
361# CONFIG_IPV6_MULTIPLE_TABLES is not set 364# CONFIG_IPV6_MULTIPLE_TABLES is not set
362# CONFIG_NETWORK_SECMARK is not set 365# CONFIG_NETWORK_SECMARK is not set
363CONFIG_NETFILTER=y 366CONFIG_NETFILTER=y
@@ -714,6 +717,12 @@ CONFIG_BLK_DEV_INITRD=y
714CONFIG_ATA_OVER_ETH=m 717CONFIG_ATA_OVER_ETH=m
715 718
716# 719#
720# Misc devices
721#
722# CONFIG_SGI_IOC4 is not set
723# CONFIG_TIFM_CORE is not set
724
725#
717# ATA/ATAPI/MFM/RLL support 726# ATA/ATAPI/MFM/RLL support
718# 727#
719# CONFIG_IDE is not set 728# CONFIG_IDE is not set
@@ -778,9 +787,9 @@ CONFIG_CHR_DEV_SG=m
778# CONFIG_SCSI_INIA100 is not set 787# CONFIG_SCSI_INIA100 is not set
779# CONFIG_SCSI_STEX is not set 788# CONFIG_SCSI_STEX is not set
780# CONFIG_SCSI_SYM53C8XX_2 is not set 789# CONFIG_SCSI_SYM53C8XX_2 is not set
781# CONFIG_SCSI_IPR is not set
782# CONFIG_SCSI_QLOGIC_1280 is not set 790# CONFIG_SCSI_QLOGIC_1280 is not set
783# CONFIG_SCSI_QLA_FC is not set 791# CONFIG_SCSI_QLA_FC is not set
792# CONFIG_SCSI_QLA_ISCSI is not set
784# CONFIG_SCSI_LPFC is not set 793# CONFIG_SCSI_LPFC is not set
785# CONFIG_SCSI_DC395x is not set 794# CONFIG_SCSI_DC395x is not set
786# CONFIG_SCSI_DC390T is not set 795# CONFIG_SCSI_DC390T is not set
@@ -1095,7 +1104,6 @@ CONFIG_HW_RANDOM=y
1095# TPM devices 1104# TPM devices
1096# 1105#
1097# CONFIG_TCG_TPM is not set 1106# CONFIG_TCG_TPM is not set
1098# CONFIG_TELCLOCK is not set
1099 1107
1100# 1108#
1101# I2C support 1109# I2C support
@@ -1124,14 +1132,9 @@ CONFIG_HWMON=y
1124# CONFIG_HWMON_DEBUG_CHIP is not set 1132# CONFIG_HWMON_DEBUG_CHIP is not set
1125 1133
1126# 1134#
1127# Misc devices
1128#
1129
1130#
1131# Multimedia devices 1135# Multimedia devices
1132# 1136#
1133# CONFIG_VIDEO_DEV is not set 1137# CONFIG_VIDEO_DEV is not set
1134CONFIG_VIDEO_V4L2=y
1135 1138
1136# 1139#
1137# Digital Video Broadcasting Devices 1140# Digital Video Broadcasting Devices
@@ -1177,9 +1180,9 @@ CONFIG_USB_DEVICEFS=y
1177# USB Host Controller Drivers 1180# USB Host Controller Drivers
1178# 1181#
1179CONFIG_USB_EHCI_HCD=y 1182CONFIG_USB_EHCI_HCD=y
1180# CONFIG_USB_EHCI_SPLIT_ISO is not set 1183CONFIG_USB_EHCI_SPLIT_ISO=y
1181# CONFIG_USB_EHCI_ROOT_HUB_TT is not set 1184CONFIG_USB_EHCI_ROOT_HUB_TT=y
1182# CONFIG_USB_EHCI_TT_NEWSCHED is not set 1185CONFIG_USB_EHCI_TT_NEWSCHED=y
1183# CONFIG_USB_ISP116X_HCD is not set 1186# CONFIG_USB_ISP116X_HCD is not set
1184CONFIG_USB_OHCI_HCD=y 1187CONFIG_USB_OHCI_HCD=y
1185# CONFIG_USB_OHCI_BIG_ENDIAN is not set 1188# CONFIG_USB_OHCI_BIG_ENDIAN is not set
@@ -1235,7 +1238,6 @@ CONFIG_USB_STORAGE=y
1235# CONFIG_USB_ATI_REMOTE2 is not set 1238# CONFIG_USB_ATI_REMOTE2 is not set
1236# CONFIG_USB_KEYSPAN_REMOTE is not set 1239# CONFIG_USB_KEYSPAN_REMOTE is not set
1237# CONFIG_USB_APPLETOUCH is not set 1240# CONFIG_USB_APPLETOUCH is not set
1238# CONFIG_USB_TRANCEVIBRATOR is not set
1239 1241
1240# 1242#
1241# USB Imaging devices 1243# USB Imaging devices
@@ -1246,11 +1248,20 @@ CONFIG_USB_STORAGE=y
1246# 1248#
1247# USB Network Adapters 1249# USB Network Adapters
1248# 1250#
1249# CONFIG_USB_CATC is not set 1251CONFIG_USB_CATC=m
1250# CONFIG_USB_KAWETH is not set 1252CONFIG_USB_KAWETH=m
1251# CONFIG_USB_PEGASUS is not set 1253CONFIG_USB_PEGASUS=m
1252# CONFIG_USB_RTL8150 is not set 1254CONFIG_USB_RTL8150=m
1253# CONFIG_USB_USBNET is not set 1255CONFIG_USB_USBNET=m
1256CONFIG_USB_NET_AX8817X=m
1257CONFIG_USB_NET_CDCETHER=m
1258# CONFIG_USB_NET_GL620A is not set
1259CONFIG_USB_NET_NET1080=m
1260CONFIG_USB_NET_PLUSB=m
1261# CONFIG_USB_NET_MCS7830 is not set
1262# CONFIG_USB_NET_RNDIS_HOST is not set
1263# CONFIG_USB_NET_CDC_SUBSET is not set
1264CONFIG_USB_NET_ZAURUS=m
1254CONFIG_USB_MON=y 1265CONFIG_USB_MON=y
1255 1266
1256# 1267#
@@ -1285,6 +1296,7 @@ CONFIG_USB_SERIAL_ARK3116=m
1285# CONFIG_USB_SERIAL_KLSI is not set 1296# CONFIG_USB_SERIAL_KLSI is not set
1286# CONFIG_USB_SERIAL_KOBIL_SCT is not set 1297# CONFIG_USB_SERIAL_KOBIL_SCT is not set
1287# CONFIG_USB_SERIAL_MCT_U232 is not set 1298# CONFIG_USB_SERIAL_MCT_U232 is not set
1299# CONFIG_USB_SERIAL_MOS7720 is not set
1288# CONFIG_USB_SERIAL_MOS7840 is not set 1300# CONFIG_USB_SERIAL_MOS7840 is not set
1289# CONFIG_USB_SERIAL_NAVMAN is not set 1301# CONFIG_USB_SERIAL_NAVMAN is not set
1290CONFIG_USB_SERIAL_PL2303=m 1302CONFIG_USB_SERIAL_PL2303=m
@@ -1316,6 +1328,7 @@ CONFIG_USB_SERIAL_PL2303=m
1316# CONFIG_USB_APPLEDISPLAY is not set 1328# CONFIG_USB_APPLEDISPLAY is not set
1317# CONFIG_USB_SISUSBVGA is not set 1329# CONFIG_USB_SISUSBVGA is not set
1318# CONFIG_USB_LD is not set 1330# CONFIG_USB_LD is not set
1331# CONFIG_USB_TRANCEVIBRATOR is not set
1319# CONFIG_USB_TEST is not set 1332# CONFIG_USB_TEST is not set
1320 1333
1321# 1334#
@@ -1357,7 +1370,26 @@ CONFIG_USB_SERIAL_PL2303=m
1357# 1370#
1358# Real Time Clock 1371# Real Time Clock
1359# 1372#
1360# CONFIG_RTC_CLASS is not set 1373CONFIG_RTC_LIB=m
1374CONFIG_RTC_CLASS=m
1375
1376#
1377# RTC interfaces
1378#
1379CONFIG_RTC_INTF_SYSFS=m
1380CONFIG_RTC_INTF_PROC=m
1381CONFIG_RTC_INTF_DEV=m
1382# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
1383
1384#
1385# RTC drivers
1386#
1387# CONFIG_RTC_DRV_DS1553 is not set
1388# CONFIG_RTC_DRV_DS1742 is not set
1389# CONFIG_RTC_DRV_M48T86 is not set
1390CONFIG_RTC_DRV_SH=m
1391# CONFIG_RTC_DRV_TEST is not set
1392# CONFIG_RTC_DRV_V3020 is not set
1361 1393
1362# 1394#
1363# DMA Engine support 1395# DMA Engine support
@@ -1380,8 +1412,12 @@ CONFIG_EXT2_FS=y
1380# CONFIG_EXT2_FS_XIP is not set 1412# CONFIG_EXT2_FS_XIP is not set
1381CONFIG_EXT3_FS=y 1413CONFIG_EXT3_FS=y
1382# CONFIG_EXT3_FS_XATTR is not set 1414# CONFIG_EXT3_FS_XATTR is not set
1415CONFIG_EXT4DEV_FS=m
1416# CONFIG_EXT4DEV_FS_XATTR is not set
1383CONFIG_JBD=y 1417CONFIG_JBD=y
1384# CONFIG_JBD_DEBUG is not set 1418# CONFIG_JBD_DEBUG is not set
1419CONFIG_JBD2=m
1420# CONFIG_JBD2_DEBUG is not set
1385CONFIG_REISERFS_FS=m 1421CONFIG_REISERFS_FS=m
1386# CONFIG_REISERFS_CHECK is not set 1422# CONFIG_REISERFS_CHECK is not set
1387# CONFIG_REISERFS_PROC_INFO is not set 1423# CONFIG_REISERFS_PROC_INFO is not set
@@ -1393,9 +1429,10 @@ CONFIG_XFS_FS=m
1393# CONFIG_XFS_SECURITY is not set 1429# CONFIG_XFS_SECURITY is not set
1394# CONFIG_XFS_POSIX_ACL is not set 1430# CONFIG_XFS_POSIX_ACL is not set
1395# CONFIG_XFS_RT is not set 1431# CONFIG_XFS_RT is not set
1432# CONFIG_GFS2_FS is not set
1396# CONFIG_OCFS2_FS is not set 1433# CONFIG_OCFS2_FS is not set
1397# CONFIG_MINIX_FS is not set 1434# CONFIG_MINIX_FS is not set
1398# CONFIG_ROMFS_FS is not set 1435CONFIG_ROMFS_FS=y
1399CONFIG_INOTIFY=y 1436CONFIG_INOTIFY=y
1400CONFIG_INOTIFY_USER=y 1437CONFIG_INOTIFY_USER=y
1401# CONFIG_QUOTA is not set 1438# CONFIG_QUOTA is not set
@@ -1480,7 +1517,12 @@ CONFIG_SUNRPC=y
1480# CONFIG_RPCSEC_GSS_SPKM3 is not set 1517# CONFIG_RPCSEC_GSS_SPKM3 is not set
1481CONFIG_SMB_FS=m 1518CONFIG_SMB_FS=m
1482# CONFIG_SMB_NLS_DEFAULT is not set 1519# CONFIG_SMB_NLS_DEFAULT is not set
1483# CONFIG_CIFS is not set 1520CONFIG_CIFS=m
1521# CONFIG_CIFS_STATS is not set
1522CONFIG_CIFS_WEAK_PW_HASH=y
1523# CONFIG_CIFS_XATTR is not set
1524# CONFIG_CIFS_DEBUG2 is not set
1525# CONFIG_CIFS_EXPERIMENTAL is not set
1484# CONFIG_NCP_FS is not set 1526# CONFIG_NCP_FS is not set
1485# CONFIG_CODA_FS is not set 1527# CONFIG_CODA_FS is not set
1486# CONFIG_AFS_FS is not set 1528# CONFIG_AFS_FS is not set
@@ -1583,9 +1625,10 @@ CONFIG_LOG_BUF_SHIFT=16
1583# CONFIG_DEBUG_LIST is not set 1625# CONFIG_DEBUG_LIST is not set
1584# CONFIG_FRAME_POINTER is not set 1626# CONFIG_FRAME_POINTER is not set
1585# CONFIG_FORCED_INLINING is not set 1627# CONFIG_FORCED_INLINING is not set
1628# CONFIG_HEADERS_CHECK is not set
1586# CONFIG_RCU_TORTURE_TEST is not set 1629# CONFIG_RCU_TORTURE_TEST is not set
1587# CONFIG_SH_STANDARD_BIOS is not set 1630# CONFIG_SH_STANDARD_BIOS is not set
1588CONFIG_EARLY_SCIF_CONSOLE=y 1631# CONFIG_EARLY_SCIF_CONSOLE is not set
1589# CONFIG_EARLY_PRINTK is not set 1632# CONFIG_EARLY_PRINTK is not set
1590# CONFIG_DEBUG_STACKOVERFLOW is not set 1633# CONFIG_DEBUG_STACKOVERFLOW is not set
1591# CONFIG_DEBUG_STACK_USAGE is not set 1634# CONFIG_DEBUG_STACK_USAGE is not set
@@ -1605,7 +1648,7 @@ CONFIG_CRYPTO=y
1605CONFIG_CRYPTO_ALGAPI=y 1648CONFIG_CRYPTO_ALGAPI=y
1606CONFIG_CRYPTO_BLKCIPHER=y 1649CONFIG_CRYPTO_BLKCIPHER=y
1607CONFIG_CRYPTO_HASH=y 1650CONFIG_CRYPTO_HASH=y
1608CONFIG_CRYPTO_MANAGER=m 1651CONFIG_CRYPTO_MANAGER=y
1609CONFIG_CRYPTO_HMAC=y 1652CONFIG_CRYPTO_HMAC=y
1610CONFIG_CRYPTO_NULL=m 1653CONFIG_CRYPTO_NULL=m
1611CONFIG_CRYPTO_MD4=m 1654CONFIG_CRYPTO_MD4=m
@@ -1615,7 +1658,7 @@ CONFIG_CRYPTO_SHA256=m
1615CONFIG_CRYPTO_SHA512=m 1658CONFIG_CRYPTO_SHA512=m
1616CONFIG_CRYPTO_WP512=m 1659CONFIG_CRYPTO_WP512=m
1617CONFIG_CRYPTO_TGR192=m 1660CONFIG_CRYPTO_TGR192=m
1618CONFIG_CRYPTO_ECB=m 1661CONFIG_CRYPTO_ECB=y
1619CONFIG_CRYPTO_CBC=y 1662CONFIG_CRYPTO_CBC=y
1620CONFIG_CRYPTO_DES=y 1663CONFIG_CRYPTO_DES=y
1621CONFIG_CRYPTO_BLOWFISH=m 1664CONFIG_CRYPTO_BLOWFISH=m
diff --git a/arch/sh/drivers/dma/dma-g2.c b/arch/sh/drivers/dma/dma-g2.c
index 9cb070924180..0caf11bb7e27 100644
--- a/arch/sh/drivers/dma/dma-g2.c
+++ b/arch/sh/drivers/dma/dma-g2.c
@@ -51,7 +51,7 @@ static volatile struct g2_dma_info *g2_dma = (volatile struct g2_dma_info *)0xa0
51 ((g2_dma->channel[i].size - \ 51 ((g2_dma->channel[i].size - \
52 g2_dma->status[i].size) & 0x0fffffff) 52 g2_dma->status[i].size) & 0x0fffffff)
53 53
54static irqreturn_t g2_dma_interrupt(int irq, void *dev_id, struct pt_regs *regs) 54static irqreturn_t g2_dma_interrupt(int irq, void *dev_id)
55{ 55{
56 int i; 56 int i;
57 57
diff --git a/arch/sh/drivers/dma/dma-pvr2.c b/arch/sh/drivers/dma/dma-pvr2.c
index c1b6bc23c107..838fad566eaf 100644
--- a/arch/sh/drivers/dma/dma-pvr2.c
+++ b/arch/sh/drivers/dma/dma-pvr2.c
@@ -21,7 +21,7 @@
21static unsigned int xfer_complete; 21static unsigned int xfer_complete;
22static int count; 22static int count;
23 23
24static irqreturn_t pvr2_dma_interrupt(int irq, void *dev_id, struct pt_regs *regs) 24static irqreturn_t pvr2_dma_interrupt(int irq, void *dev_id)
25{ 25{
26 if (get_dma_residue(PVR2_CASCADE_CHAN)) { 26 if (get_dma_residue(PVR2_CASCADE_CHAN)) {
27 printk(KERN_WARNING "DMA: SH DMAC did not complete transfer " 27 printk(KERN_WARNING "DMA: SH DMAC did not complete transfer "
diff --git a/arch/sh/drivers/dma/dma-sh.c b/arch/sh/drivers/dma/dma-sh.c
index cbbe8bce3d67..660786013350 100644
--- a/arch/sh/drivers/dma/dma-sh.c
+++ b/arch/sh/drivers/dma/dma-sh.c
@@ -19,23 +19,34 @@
19#include <asm/io.h> 19#include <asm/io.h>
20#include "dma-sh.h" 20#include "dma-sh.h"
21 21
22static inline unsigned int get_dmte_irq(unsigned int chan)
23{
24 unsigned int irq = 0;
25 22
23
24#ifdef CONFIG_CPU_SH4
25static struct ipr_data dmae_ipr_map[] = {
26 { DMAE_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
27};
28#endif
29static struct ipr_data dmte_ipr_map[] = {
26 /* 30 /*
27 * Normally we could just do DMTE0_IRQ + chan outright, though in the 31 * Normally we could just do DMTE0_IRQ + chan outright, though in the
28 * case of the 7751R, the DMTE IRQs for channels > 4 start right above 32 * case of the 7751R, the DMTE IRQs for channels > 4 start right above
29 * the SCIF 33 * the SCIF
30 */ 34 */
31 if (chan < 4) { 35 { DMTE0_IRQ + 0, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
32 irq = DMTE0_IRQ + chan; 36 { DMTE0_IRQ + 1, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
33 } else { 37 { DMTE0_IRQ + 2, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
34#ifdef DMTE4_IRQ 38 { DMTE0_IRQ + 3, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
35 irq = DMTE4_IRQ + chan - 4; 39 { DMTE4_IRQ + 0, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
36#endif 40 { DMTE4_IRQ + 1, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
37 } 41 { DMTE4_IRQ + 2, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
42 { DMTE4_IRQ + 3, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
43};
38 44
45static inline unsigned int get_dmte_irq(unsigned int chan)
46{
47 unsigned int irq = 0;
48 if (chan < ARRAY_SIZE(dmte_ipr_map))
49 irq = dmte_ipr_map[chan].irq;
39 return irq; 50 return irq;
40} 51}
41 52
@@ -60,9 +71,9 @@ static inline unsigned int calc_xmit_shift(struct dma_channel *chan)
60 * Besides that it needs to waken any waiting process, which should handle 71 * Besides that it needs to waken any waiting process, which should handle
61 * setting up the next transfer. 72 * setting up the next transfer.
62 */ 73 */
63static irqreturn_t dma_tei(int irq, void *dev_id, struct pt_regs *regs) 74static irqreturn_t dma_tei(int irq, void *dev_id)
64{ 75{
65 struct dma_channel *chan = (struct dma_channel *)dev_id; 76 struct dma_channel *chan = dev_id;
66 u32 chcr; 77 u32 chcr;
67 78
68 chcr = ctrl_inl(CHCR[chan->chan]); 79 chcr = ctrl_inl(CHCR[chan->chan]);
@@ -228,7 +239,7 @@ static inline int dmaor_reset(void)
228} 239}
229 240
230#if defined(CONFIG_CPU_SH4) 241#if defined(CONFIG_CPU_SH4)
231static irqreturn_t dma_err(int irq, void *dev_id, struct pt_regs *regs) 242static irqreturn_t dma_err(int irq, void *dummy)
232{ 243{
233 dmaor_reset(); 244 dmaor_reset();
234 disable_irq(irq); 245 disable_irq(irq);
@@ -258,17 +269,16 @@ static int __init sh_dmac_init(void)
258 int i; 269 int i;
259 270
260#ifdef CONFIG_CPU_SH4 271#ifdef CONFIG_CPU_SH4
261 make_ipr_irq(DMAE_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY); 272 make_ipr_irq(dmae_ipr_map, ARRAY_SIZE(dmae_ipr_map));
262 i = request_irq(DMAE_IRQ, dma_err, IRQF_DISABLED, "DMAC Address Error", 0); 273 i = request_irq(DMAE_IRQ, dma_err, IRQF_DISABLED, "DMAC Address Error", 0);
263 if (unlikely(i < 0)) 274 if (unlikely(i < 0))
264 return i; 275 return i;
265#endif 276#endif
266 277
267 for (i = 0; i < info->nr_channels; i++) { 278 i = info->nr_channels;
268 int irq = get_dmte_irq(i); 279 if (i > ARRAY_SIZE(dmte_ipr_map))
269 280 i = ARRAY_SIZE(dmte_ipr_map);
270 make_ipr_irq(irq, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY); 281 make_ipr_irq(dmte_ipr_map, i);
271 }
272 282
273 /* 283 /*
274 * Initialize DMAOR, and clean up any error flags that may have 284 * Initialize DMAOR, and clean up any error flags that may have
diff --git a/arch/sh/drivers/pci/ops-r7780rp.c b/arch/sh/drivers/pci/ops-r7780rp.c
index 6e3ba9c65b40..eeea1577e112 100644
--- a/arch/sh/drivers/pci/ops-r7780rp.c
+++ b/arch/sh/drivers/pci/ops-r7780rp.c
@@ -13,7 +13,7 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/delay.h> 14#include <linux/delay.h>
15#include <linux/pci.h> 15#include <linux/pci.h>
16#include <asm/r7780rp/r7780rp.h> 16#include <asm/r7780rp.h>
17#include <asm/io.h> 17#include <asm/io.h>
18#include "pci-sh4.h" 18#include "pci-sh4.h"
19 19
diff --git a/arch/sh/drivers/pci/ops-rts7751r2d.c b/arch/sh/drivers/pci/ops-rts7751r2d.c
index b68824c8b81e..4a518d948049 100644
--- a/arch/sh/drivers/pci/ops-rts7751r2d.c
+++ b/arch/sh/drivers/pci/ops-rts7751r2d.c
@@ -10,28 +10,24 @@
10 * 10 *
11 * PCI initialization for the Renesas SH7751R RTS7751R2D board 11 * PCI initialization for the Renesas SH7751R RTS7751R2D board
12 */ 12 */
13
14#include <linux/kernel.h> 13#include <linux/kernel.h>
15#include <linux/types.h> 14#include <linux/types.h>
16#include <linux/init.h> 15#include <linux/init.h>
17#include <linux/delay.h>
18#include <linux/pci.h> 16#include <linux/pci.h>
19#include <linux/module.h> 17#include <linux/io.h>
20#include <asm/rts7751r2d/rts7751r2d.h> 18#include <asm/rts7751r2d.h>
21#include <asm/io.h>
22#include "pci-sh4.h" 19#include "pci-sh4.h"
23 20
21static u8 rts7751r2d_irq_tab[] __initdata = {
22 IRQ_PCISLOT1,
23 IRQ_PCISLOT2,
24 IRQ_PCMCIA,
25 IRQ_PCIETH,
26};
27
24int __init pcibios_map_platform_irq(struct pci_dev *pdev, u8 slot, u8 pin) 28int __init pcibios_map_platform_irq(struct pci_dev *pdev, u8 slot, u8 pin)
25{ 29{
26 switch (slot) { 30 return rts7751r2d_irq_tab[slot];
27 case 0: return IRQ_PCISLOT1; /* PCI Extend slot #1 */
28 case 1: return IRQ_PCISLOT2; /* PCI Extend slot #2 */
29 case 2: return IRQ_PCMCIA; /* PCI Cardbus Bridge */
30 case 3: return IRQ_PCIETH; /* Realtek Ethernet controller */
31 default:
32 printk("PCI: Bad IRQ mapping request for slot %d\n", slot);
33 return -1;
34 }
35} 31}
36 32
37static struct resource sh7751_io_resource = { 33static struct resource sh7751_io_resource = {
diff --git a/arch/sh/drivers/pci/pci-sh7751.c b/arch/sh/drivers/pci/pci-sh7751.c
index dbe837884983..85e1ee2e2e7b 100644
--- a/arch/sh/drivers/pci/pci-sh7751.c
+++ b/arch/sh/drivers/pci/pci-sh7751.c
@@ -155,7 +155,7 @@ int __init sh7751_pcic_init(struct sh4_pci_address_map *map)
155 */ 155 */
156 pr_debug("PCI: Mapping IO address 0x%x - 0x%x to base 0x%x\n", 156 pr_debug("PCI: Mapping IO address 0x%x - 0x%x to base 0x%x\n",
157 PCIBIOS_MIN_IO, (64 << 10), 157 PCIBIOS_MIN_IO, (64 << 10),
158 SH4_PCI_IO_BASE + PCIBIOS_MIN_IO); 158 SH7751_PCI_IO_BASE + PCIBIOS_MIN_IO);
159 159
160 /* 160 /*
161 * XXX: For now, leave this board-specific. In the event we have other 161 * XXX: For now, leave this board-specific. In the event we have other
@@ -163,7 +163,7 @@ int __init sh7751_pcic_init(struct sh4_pci_address_map *map)
163 */ 163 */
164#ifdef CONFIG_SH_BIGSUR 164#ifdef CONFIG_SH_BIGSUR
165 bigsur_port_map(PCIBIOS_MIN_IO, (64 << 10), 165 bigsur_port_map(PCIBIOS_MIN_IO, (64 << 10),
166 SH4_PCI_IO_BASE + PCIBIOS_MIN_IO, 0); 166 SH7751_PCI_IO_BASE + PCIBIOS_MIN_IO, 0);
167#endif 167#endif
168 168
169 /* Make sure the MSB's of IO window are set to access PCI space 169 /* Make sure the MSB's of IO window are set to access PCI space
diff --git a/arch/sh/drivers/pci/pci-st40.c b/arch/sh/drivers/pci/pci-st40.c
index 4ab5ea6b35fb..efecb3d5995c 100644
--- a/arch/sh/drivers/pci/pci-st40.c
+++ b/arch/sh/drivers/pci/pci-st40.c
@@ -161,7 +161,7 @@ static char * pci_commands[16]={
161 "Memory Write-and-Invalidate" 161 "Memory Write-and-Invalidate"
162}; 162};
163 163
164static irqreturn_t st40_pci_irq(int irq, void *dev_instance, struct pt_regs *regs) 164static irqreturn_t st40_pci_irq(int irq, void *dev_instance)
165{ 165{
166 unsigned pci_int, pci_air, pci_cir, pci_aint; 166 unsigned pci_int, pci_air, pci_cir, pci_aint;
167 static int count=0; 167 static int count=0;
diff --git a/arch/sh/kernel/cpu/irq/intc2.c b/arch/sh/kernel/cpu/irq/intc2.c
index e30e4b7aa70e..74ca576a7ce5 100644
--- a/arch/sh/kernel/cpu/irq/intc2.c
+++ b/arch/sh/kernel/cpu/irq/intc2.c
@@ -10,93 +10,31 @@
10 * These are the "new Hitachi style" interrupts, as present on the 10 * These are the "new Hitachi style" interrupts, as present on the
11 * Hitachi 7751, the STM ST40 STB1, SH7760, and SH7780. 11 * Hitachi 7751, the STM ST40 STB1, SH7760, and SH7780.
12 */ 12 */
13
14#include <linux/kernel.h> 13#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/irq.h> 14#include <linux/irq.h>
15#include <linux/io.h>
17#include <asm/system.h> 16#include <asm/system.h>
18#include <asm/io.h>
19#include <asm/machvec.h>
20
21struct intc2_data {
22 unsigned char msk_offset;
23 unsigned char msk_shift;
24
25 int (*clear_irq) (int);
26};
27
28static struct intc2_data intc2_data[NR_INTC2_IRQS];
29
30static void enable_intc2_irq(unsigned int irq);
31static void disable_intc2_irq(unsigned int irq);
32
33/* shutdown is same as "disable" */
34#define shutdown_intc2_irq disable_intc2_irq
35
36static void mask_and_ack_intc2(unsigned int);
37static void end_intc2_irq(unsigned int irq);
38
39static unsigned int startup_intc2_irq(unsigned int irq)
40{
41 enable_intc2_irq(irq);
42 return 0; /* never anything pending */
43}
44
45static struct hw_interrupt_type intc2_irq_type = {
46 .typename = "INTC2-IRQ",
47 .startup = startup_intc2_irq,
48 .shutdown = shutdown_intc2_irq,
49 .enable = enable_intc2_irq,
50 .disable = disable_intc2_irq,
51 .ack = mask_and_ack_intc2,
52 .end = end_intc2_irq
53};
54 17
55static void disable_intc2_irq(unsigned int irq) 18static void disable_intc2_irq(unsigned int irq)
56{ 19{
57 int irq_offset = irq - INTC2_FIRST_IRQ; 20 struct intc2_data *p = get_irq_chip_data(irq);
58 int msk_shift, msk_offset; 21 ctrl_outl(1 << p->msk_shift,
59 22 INTC2_BASE + INTC2_INTMSK_OFFSET + p->msk_offset);
60 /* Sanity check */
61 if (unlikely(irq_offset < 0 || irq_offset >= NR_INTC2_IRQS))
62 return;
63
64 msk_shift = intc2_data[irq_offset].msk_shift;
65 msk_offset = intc2_data[irq_offset].msk_offset;
66
67 ctrl_outl(1 << msk_shift,
68 INTC2_BASE + INTC2_INTMSK_OFFSET + msk_offset);
69} 23}
70 24
71static void enable_intc2_irq(unsigned int irq) 25static void enable_intc2_irq(unsigned int irq)
72{ 26{
73 int irq_offset = irq - INTC2_FIRST_IRQ; 27 struct intc2_data *p = get_irq_chip_data(irq);
74 int msk_shift, msk_offset; 28 ctrl_outl(1 << p->msk_shift,
75 29 INTC2_BASE + INTC2_INTMSKCLR_OFFSET + p->msk_offset);
76 /* Sanity check */
77 if (unlikely(irq_offset < 0 || irq_offset >= NR_INTC2_IRQS))
78 return;
79
80 msk_shift = intc2_data[irq_offset].msk_shift;
81 msk_offset = intc2_data[irq_offset].msk_offset;
82
83 ctrl_outl(1 << msk_shift,
84 INTC2_BASE + INTC2_INTMSKCLR_OFFSET + msk_offset);
85} 30}
86 31
87static void mask_and_ack_intc2(unsigned int irq) 32static struct irq_chip intc2_irq_chip = {
88{ 33 .name = "INTC2",
89 disable_intc2_irq(irq); 34 .mask = disable_intc2_irq,
90} 35 .unmask = enable_intc2_irq,
91 36 .mask_ack = disable_intc2_irq,
92static void end_intc2_irq(unsigned int irq) 37};
93{
94 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
95 enable_intc2_irq(irq);
96
97 if (unlikely(intc2_data[irq - INTC2_FIRST_IRQ].clear_irq))
98 intc2_data[irq - INTC2_FIRST_IRQ].clear_irq(irq);
99}
100 38
101/* 39/*
102 * Setup an INTC2 style interrupt. 40 * Setup an INTC2 style interrupt.
@@ -106,179 +44,36 @@ static void end_intc2_irq(unsigned int irq)
106 * PIO1 which is INTPRI00[19,16] and INTMSK00[13] 44 * PIO1 which is INTPRI00[19,16] and INTMSK00[13]
107 * would be: ^ ^ ^ ^ 45 * would be: ^ ^ ^ ^
108 * | | | | 46 * | | | |
109 * make_intc2_irq(84, 0, 16, 0, 13); 47 * { 84, 0, 16, 0, 13 },
48 *
49 * in the intc2_data table.
110 */ 50 */
111void make_intc2_irq(unsigned int irq, 51void make_intc2_irq(struct intc2_data *table, unsigned int nr_irqs)
112 unsigned int ipr_offset, unsigned int ipr_shift,
113 unsigned int msk_offset, unsigned int msk_shift,
114 unsigned int priority)
115{ 52{
116 int irq_offset = irq - INTC2_FIRST_IRQ; 53 int i;
117 unsigned int flags;
118 unsigned long ipr;
119
120 if (unlikely(irq_offset < 0 || irq_offset >= NR_INTC2_IRQS))
121 return;
122
123 disable_irq_nosync(irq);
124
125 /* Fill the data we need */
126 intc2_data[irq_offset].msk_offset = msk_offset;
127 intc2_data[irq_offset].msk_shift = msk_shift;
128 intc2_data[irq_offset].clear_irq = NULL;
129
130 /* Set the priority level */
131 local_irq_save(flags);
132
133 ipr = ctrl_inl(INTC2_BASE + INTC2_INTPRI_OFFSET + ipr_offset);
134 ipr &= ~(0xf << ipr_shift);
135 ipr |= priority << ipr_shift;
136 ctrl_outl(ipr, INTC2_BASE + INTC2_INTPRI_OFFSET + ipr_offset);
137
138 local_irq_restore(flags);
139 54
140 irq_desc[irq].chip = &intc2_irq_type; 55 for (i = 0; i < nr_irqs; i++) {
56 unsigned long ipr, flags;
57 struct intc2_data *p = table + i;
141 58
142 disable_intc2_irq(irq); 59 disable_irq_nosync(p->irq);
143}
144 60
145static struct intc2_init { 61 /* Set the priority level */
146 unsigned short irq; 62 local_irq_save(flags);
147 unsigned char ipr_offset, ipr_shift;
148 unsigned char msk_offset, msk_shift;
149 unsigned char priority;
150} intc2_init_data[] __initdata = {
151#if defined(CONFIG_CPU_SUBTYPE_ST40)
152 {64, 0, 0, 0, 0, 13}, /* PCI serr */
153 {65, 0, 4, 0, 1, 13}, /* PCI err */
154 {66, 0, 4, 0, 2, 13}, /* PCI ad */
155 {67, 0, 4, 0, 3, 13}, /* PCI pwd down */
156 {72, 0, 8, 0, 5, 13}, /* DMAC INT0 */
157 {73, 0, 8, 0, 6, 13}, /* DMAC INT1 */
158 {74, 0, 8, 0, 7, 13}, /* DMAC INT2 */
159 {75, 0, 8, 0, 8, 13}, /* DMAC INT3 */
160 {76, 0, 8, 0, 9, 13}, /* DMAC INT4 */
161 {78, 0, 8, 0, 11, 13}, /* DMAC ERR */
162 {80, 0, 12, 0, 12, 13}, /* PIO0 */
163 {84, 0, 16, 0, 13, 13}, /* PIO1 */
164 {88, 0, 20, 0, 14, 13}, /* PIO2 */
165 {112, 4, 0, 4, 0, 13}, /* Mailbox */
166 #ifdef CONFIG_CPU_SUBTYPE_ST40GX1
167 {116, 4, 4, 4, 4, 13}, /* SSC0 */
168 {120, 4, 8, 4, 8, 13}, /* IR Blaster */
169 {124, 4, 12, 4, 12, 13}, /* USB host */
170 {128, 4, 16, 4, 16, 13}, /* Video processor BLITTER */
171 {132, 4, 20, 4, 20, 13}, /* UART0 */
172 {134, 4, 20, 4, 22, 13}, /* UART2 */
173 {136, 4, 24, 4, 24, 13}, /* IO_PIO0 */
174 {140, 4, 28, 4, 28, 13}, /* EMPI */
175 {144, 8, 0, 8, 0, 13}, /* MAFE */
176 {148, 8, 4, 8, 4, 13}, /* PWM */
177 {152, 8, 8, 8, 8, 13}, /* SSC1 */
178 {156, 8, 12, 8, 12, 13}, /* IO_PIO1 */
179 {160, 8, 16, 8, 16, 13}, /* USB target */
180 {164, 8, 20, 8, 20, 13}, /* UART1 */
181 {168, 8, 24, 8, 24, 13}, /* Teletext */
182 {172, 8, 28, 8, 28, 13}, /* VideoSync VTG */
183 {173, 8, 28, 8, 29, 13}, /* VideoSync DVP0 */
184 {174, 8, 28, 8, 30, 13}, /* VideoSync DVP1 */
185#endif
186#elif defined(CONFIG_CPU_SUBTYPE_SH7760)
187/*
188 * SH7760 INTC2-Style interrupts, vectors IRQ48-111 INTEVT 0x800-0xFE0
189 */
190 /* INTPRIO0 | INTMSK0 */
191 {48, 0, 28, 0, 31, 3}, /* IRQ 4 */
192 {49, 0, 24, 0, 30, 3}, /* IRQ 3 */
193 {50, 0, 20, 0, 29, 3}, /* IRQ 2 */
194 {51, 0, 16, 0, 28, 3}, /* IRQ 1 */
195 /* 52-55 (INTEVT 0x880-0x8E0) unused/reserved */
196 /* INTPRIO4 | INTMSK0 */
197 {56, 4, 28, 0, 25, 3}, /* HCAN2_CHAN0 */
198 {57, 4, 24, 0, 24, 3}, /* HCAN2_CHAN1 */
199 {58, 4, 20, 0, 23, 3}, /* I2S_CHAN0 */
200 {59, 4, 16, 0, 22, 3}, /* I2S_CHAN1 */
201 {60, 4, 12, 0, 21, 3}, /* AC97_CHAN0 */
202 {61, 4, 8, 0, 20, 3}, /* AC97_CHAN1 */
203 {62, 4, 4, 0, 19, 3}, /* I2C_CHAN0 */
204 {63, 4, 0, 0, 18, 3}, /* I2C_CHAN1 */
205 /* INTPRIO8 | INTMSK0 */
206 {52, 8, 16, 0, 11, 3}, /* SCIF0_ERI_IRQ */
207 {53, 8, 16, 0, 10, 3}, /* SCIF0_RXI_IRQ */
208 {54, 8, 16, 0, 9, 3}, /* SCIF0_BRI_IRQ */
209 {55, 8, 16, 0, 8, 3}, /* SCIF0_TXI_IRQ */
210 {64, 8, 28, 0, 17, 3}, /* USBHI_IRQ */
211 {65, 8, 24, 0, 16, 3}, /* LCDC */
212 /* 66, 67 unused */
213 {68, 8, 20, 0, 14, 13}, /* DMABRGI0_IRQ */
214 {69, 8, 20, 0, 13, 13}, /* DMABRGI1_IRQ */
215 {70, 8, 20, 0, 12, 13}, /* DMABRGI2_IRQ */
216 /* 71 unused */
217 {72, 8, 12, 0, 7, 3}, /* SCIF1_ERI_IRQ */
218 {73, 8, 12, 0, 6, 3}, /* SCIF1_RXI_IRQ */
219 {74, 8, 12, 0, 5, 3}, /* SCIF1_BRI_IRQ */
220 {75, 8, 12, 0, 4, 3}, /* SCIF1_TXI_IRQ */
221 {76, 8, 8, 0, 3, 3}, /* SCIF2_ERI_IRQ */
222 {77, 8, 8, 0, 2, 3}, /* SCIF2_RXI_IRQ */
223 {78, 8, 8, 0, 1, 3}, /* SCIF2_BRI_IRQ */
224 {79, 8, 8, 0, 0, 3}, /* SCIF2_TXI_IRQ */
225 /* | INTMSK4 */
226 {80, 8, 4, 4, 23, 3}, /* SIM_ERI */
227 {81, 8, 4, 4, 22, 3}, /* SIM_RXI */
228 {82, 8, 4, 4, 21, 3}, /* SIM_TXI */
229 {83, 8, 4, 4, 20, 3}, /* SIM_TEI */
230 {84, 8, 0, 4, 19, 3}, /* HSPII */
231 /* INTPRIOC | INTMSK4 */
232 /* 85-87 unused/reserved */
233 {88, 12, 20, 4, 18, 3}, /* MMCI0 */
234 {89, 12, 20, 4, 17, 3}, /* MMCI1 */
235 {90, 12, 20, 4, 16, 3}, /* MMCI2 */
236 {91, 12, 20, 4, 15, 3}, /* MMCI3 */
237 {92, 12, 12, 4, 6, 3}, /* MFI (unsure, bug? in my 7760 manual*/
238 /* 93-107 reserved/undocumented */
239 {108,12, 4, 4, 1, 3}, /* ADC */
240 {109,12, 0, 4, 0, 3}, /* CMTI */
241 /* 110-111 reserved/unused */
242#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
243 { TIMER_IRQ, 0, 24, 0, INTC_TMU0_MSK, 2},
244 { 21, 1, 0, 0, INTC_RTC_MSK, TIMER_PRIORITY },
245 { 22, 1, 1, 0, INTC_RTC_MSK, TIMER_PRIORITY },
246 { 23, 1, 2, 0, INTC_RTC_MSK, TIMER_PRIORITY },
247 { SCIF0_ERI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY },
248 { SCIF0_RXI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY },
249 { SCIF0_BRI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY },
250 { SCIF0_TXI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY },
251 63
252 { SCIF1_ERI_IRQ, 8, 16, 0, INTC_SCIF1_MSK, SCIF1_PRIORITY }, 64 ipr = ctrl_inl(INTC2_BASE + INTC2_INTPRI_OFFSET +
253 { SCIF1_RXI_IRQ, 8, 16, 0, INTC_SCIF1_MSK, SCIF1_PRIORITY }, 65 p->ipr_offset);
254 { SCIF1_BRI_IRQ, 8, 16, 0, INTC_SCIF1_MSK, SCIF1_PRIORITY }, 66 ipr &= ~(0xf << p->ipr_shift);
255 { SCIF1_TXI_IRQ, 8, 16, 0, INTC_SCIF1_MSK, SCIF1_PRIORITY }, 67 ipr |= p->priority << p->ipr_shift;
68 ctrl_outl(ipr, INTC2_BASE + INTC2_INTPRI_OFFSET +
69 p->ipr_offset);
256 70
257 { PCIC0_IRQ, 0x10, 8, 0, INTC_PCIC0_MSK, PCIC0_PRIORITY }, 71 local_irq_restore(flags);
258 { PCIC1_IRQ, 0x10, 0, 0, INTC_PCIC1_MSK, PCIC1_PRIORITY },
259 { PCIC2_IRQ, 0x14, 24, 0, INTC_PCIC2_MSK, PCIC2_PRIORITY },
260 { PCIC3_IRQ, 0x14, 16, 0, INTC_PCIC3_MSK, PCIC3_PRIORITY },
261 { PCIC4_IRQ, 0x14, 8, 0, INTC_PCIC4_MSK, PCIC4_PRIORITY },
262#endif
263};
264 72
265void __init init_IRQ_intc2(void) 73 set_irq_chip_and_handler_name(p->irq, &intc2_irq_chip,
266{ 74 handle_level_irq, "level");
267 int i; 75 set_irq_chip_data(p->irq, p);
268 76
269 for (i = 0; i < ARRAY_SIZE(intc2_init_data); i++) { 77 enable_intc2_irq(p->irq);
270 struct intc2_init *p = intc2_init_data + i;
271 make_intc2_irq(p->irq, p->ipr_offset, p->ipr_shift,
272 p-> msk_offset, p->msk_shift, p->priority);
273 } 78 }
274} 79}
275
276/* Adds a termination callback to the interrupt */
277void intc2_add_clear_irq(int irq, int (*fn)(int))
278{
279 if (unlikely(irq < INTC2_FIRST_IRQ))
280 return;
281
282 intc2_data[irq - INTC2_FIRST_IRQ].clear_irq = fn;
283}
284
diff --git a/arch/sh/kernel/cpu/irq/ipr.c b/arch/sh/kernel/cpu/irq/ipr.c
index f785822cd5de..a0089563cbfc 100644
--- a/arch/sh/kernel/cpu/irq/ipr.c
+++ b/arch/sh/kernel/cpu/irq/ipr.c
@@ -1,11 +1,10 @@
1/* 1/*
2 * arch/sh/kernel/cpu/irq/ipr.c 2 * Interrupt handling for IPR-based IRQ.
3 * 3 *
4 * Copyright (C) 1999 Niibe Yutaka & Takeshi Yaegashi 4 * Copyright (C) 1999 Niibe Yutaka & Takeshi Yaegashi
5 * Copyright (C) 2000 Kazumoto Kojima 5 * Copyright (C) 2000 Kazumoto Kojima
6 * Copyright (C) 2003 Takashi Kusuda <kusuda-takashi@hitachi-ul.co.jp> 6 * Copyright (C) 2003 Takashi Kusuda <kusuda-takashi@hitachi-ul.co.jp>
7 * 7 * Copyright (C) 2006 Paul Mundt
8 * Interrupt handling for IPR-based IRQ.
9 * 8 *
10 * Supported system: 9 * Supported system:
11 * On-chip supporting modules (TMU, RTC, etc.). 10 * On-chip supporting modules (TMU, RTC, etc.).
@@ -13,151 +12,92 @@
13 * Hitachi SolutionEngine external I/O: 12 * Hitachi SolutionEngine external I/O:
14 * MS7709SE01, MS7709ASE01, and MS7750SE01 13 * MS7709SE01, MS7709ASE01, and MS7750SE01
15 * 14 *
15 * This file is subject to the terms and conditions of the GNU General Public
16 * License. See the file "COPYING" in the main directory of this archive
17 * for more details.
16 */ 18 */
17
18#include <linux/init.h> 19#include <linux/init.h>
19#include <linux/irq.h> 20#include <linux/irq.h>
20#include <linux/module.h> 21#include <linux/module.h>
21
22#include <asm/system.h> 22#include <asm/system.h>
23#include <asm/io.h> 23#include <asm/io.h>
24#include <asm/machvec.h> 24#include <asm/machvec.h>
25 25
26struct ipr_data {
27 unsigned int addr; /* Address of Interrupt Priority Register */
28 int shift; /* Shifts of the 16-bit data */
29 int priority; /* The priority */
30};
31static struct ipr_data ipr_data[NR_IRQS];
32
33static void enable_ipr_irq(unsigned int irq);
34static void disable_ipr_irq(unsigned int irq);
35
36/* shutdown is same as "disable" */
37#define shutdown_ipr_irq disable_ipr_irq
38
39static void mask_and_ack_ipr(unsigned int);
40static void end_ipr_irq(unsigned int irq);
41
42static unsigned int startup_ipr_irq(unsigned int irq)
43{
44 enable_ipr_irq(irq);
45 return 0; /* never anything pending */
46}
47
48static struct hw_interrupt_type ipr_irq_type = {
49 .typename = "IPR-IRQ",
50 .startup = startup_ipr_irq,
51 .shutdown = shutdown_ipr_irq,
52 .enable = enable_ipr_irq,
53 .disable = disable_ipr_irq,
54 .ack = mask_and_ack_ipr,
55 .end = end_ipr_irq
56};
57 26
58static void disable_ipr_irq(unsigned int irq) 27static void disable_ipr_irq(unsigned int irq)
59{ 28{
60 unsigned long val; 29 struct ipr_data *p = get_irq_chip_data(irq);
61 unsigned int addr = ipr_data[irq].addr; 30 int shift = p->shift*4;
62 unsigned short mask = 0xffff ^ (0x0f << ipr_data[irq].shift);
63
64 /* Set the priority in IPR to 0 */ 31 /* Set the priority in IPR to 0 */
65 val = ctrl_inw(addr); 32 ctrl_outw(ctrl_inw(p->addr) & (0xffff ^ (0xf << shift)), p->addr);
66 val &= mask;
67 ctrl_outw(val, addr);
68} 33}
69 34
70static void enable_ipr_irq(unsigned int irq) 35static void enable_ipr_irq(unsigned int irq)
71{ 36{
72 unsigned long val; 37 struct ipr_data *p = get_irq_chip_data(irq);
73 unsigned int addr = ipr_data[irq].addr; 38 int shift = p->shift*4;
74 int priority = ipr_data[irq].priority;
75 unsigned short value = (priority << ipr_data[irq].shift);
76
77 /* Set priority in IPR back to original value */ 39 /* Set priority in IPR back to original value */
78 val = ctrl_inw(addr); 40 ctrl_outw(ctrl_inw(p->addr) | (p->priority << shift), p->addr);
79 val |= value;
80 ctrl_outw(val, addr);
81} 41}
82 42
83static void mask_and_ack_ipr(unsigned int irq) 43static struct irq_chip ipr_irq_chip = {
84{ 44 .name = "IPR",
85 disable_ipr_irq(irq); 45 .mask = disable_ipr_irq,
86 46 .unmask = enable_ipr_irq,
87#if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) || \ 47 .mask_ack = disable_ipr_irq,
88 defined(CONFIG_CPU_SUBTYPE_SH7706) || \ 48};
89 defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705)
90 /* This is needed when we use edge triggered setting */
91 /* XXX: Is it really needed? */
92 if (IRQ0_IRQ <= irq && irq <= IRQ5_IRQ) {
93 /* Clear external interrupt request */
94 int a = ctrl_inb(INTC_IRR0);
95 a &= ~(1 << (irq - IRQ0_IRQ));
96 ctrl_outb(a, INTC_IRR0);
97 }
98#endif
99}
100 49
101static void end_ipr_irq(unsigned int irq) 50void make_ipr_irq(struct ipr_data *table, unsigned int nr_irqs)
102{ 51{
103 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) 52 int i;
53
54 for (i = 0; i < nr_irqs; i++) {
55 unsigned int irq = table[i].irq;
56 disable_irq_nosync(irq);
57 set_irq_chip_and_handler_name(irq, &ipr_irq_chip,
58 handle_level_irq, "level");
59 set_irq_chip_data(irq, &table[i]);
104 enable_ipr_irq(irq); 60 enable_ipr_irq(irq);
61 }
105} 62}
63EXPORT_SYMBOL(make_ipr_irq);
106 64
107void make_ipr_irq(unsigned int irq, unsigned int addr, int pos, int priority) 65static struct ipr_data sys_ipr_map[] = {
108{
109 disable_irq_nosync(irq);
110 ipr_data[irq].addr = addr;
111 ipr_data[irq].shift = pos*4; /* POSition (0-3) x 4 means shift */
112 ipr_data[irq].priority = priority;
113
114 irq_desc[irq].chip = &ipr_irq_type;
115 disable_ipr_irq(irq);
116}
117
118void __init init_IRQ(void)
119{
120#ifndef CONFIG_CPU_SUBTYPE_SH7780 66#ifndef CONFIG_CPU_SUBTYPE_SH7780
121 make_ipr_irq(TIMER_IRQ, TIMER_IPR_ADDR, TIMER_IPR_POS, TIMER_PRIORITY); 67 { TIMER_IRQ, TIMER_IPR_ADDR, TIMER_IPR_POS, TIMER_PRIORITY },
122 make_ipr_irq(TIMER1_IRQ, TIMER1_IPR_ADDR, TIMER1_IPR_POS, TIMER1_PRIORITY); 68 { TIMER1_IRQ, TIMER1_IPR_ADDR, TIMER1_IPR_POS, TIMER1_PRIORITY },
123#ifdef RTC_IRQ 69#ifdef RTC_IRQ
124 make_ipr_irq(RTC_IRQ, RTC_IPR_ADDR, RTC_IPR_POS, RTC_PRIORITY); 70 { RTC_IRQ, RTC_IPR_ADDR, RTC_IPR_POS, RTC_PRIORITY },
125#endif 71#endif
126
127#ifdef SCI_ERI_IRQ 72#ifdef SCI_ERI_IRQ
128 make_ipr_irq(SCI_ERI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY); 73 { SCI_ERI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY },
129 make_ipr_irq(SCI_RXI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY); 74 { SCI_RXI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY },
130 make_ipr_irq(SCI_TXI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY); 75 { SCI_TXI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY },
131#endif 76#endif
132
133#ifdef SCIF1_ERI_IRQ 77#ifdef SCIF1_ERI_IRQ
134 make_ipr_irq(SCIF1_ERI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY); 78 { SCIF1_ERI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY },
135 make_ipr_irq(SCIF1_RXI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY); 79 { SCIF1_RXI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY },
136 make_ipr_irq(SCIF1_BRI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY); 80 { SCIF1_BRI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY },
137 make_ipr_irq(SCIF1_TXI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY); 81 { SCIF1_TXI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY },
138#endif 82#endif
139
140#if defined(CONFIG_CPU_SUBTYPE_SH7300) 83#if defined(CONFIG_CPU_SUBTYPE_SH7300)
141 make_ipr_irq(SCIF0_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS, SCIF0_PRIORITY); 84 { SCIF0_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS, SCIF0_PRIORITY },
142 make_ipr_irq(DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY); 85 { DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
143 make_ipr_irq(DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY); 86 { DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
144 make_ipr_irq(VIO_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY); 87 { VIO_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY },
145#endif 88#endif
146
147#ifdef SCIF_ERI_IRQ 89#ifdef SCIF_ERI_IRQ
148 make_ipr_irq(SCIF_ERI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY); 90 { SCIF_ERI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY },
149 make_ipr_irq(SCIF_RXI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY); 91 { SCIF_RXI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY },
150 make_ipr_irq(SCIF_BRI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY); 92 { SCIF_BRI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY },
151 make_ipr_irq(SCIF_TXI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY); 93 { SCIF_TXI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY },
152#endif 94#endif
153
154#ifdef IRDA_ERI_IRQ 95#ifdef IRDA_ERI_IRQ
155 make_ipr_irq(IRDA_ERI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY); 96 { IRDA_ERI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY },
156 make_ipr_irq(IRDA_RXI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY); 97 { IRDA_RXI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY },
157 make_ipr_irq(IRDA_BRI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY); 98 { IRDA_BRI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY },
158 make_ipr_irq(IRDA_TXI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY); 99 { IRDA_TXI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY },
159#endif 100#endif
160
161#if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) || \ 101#if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) || \
162 defined(CONFIG_CPU_SUBTYPE_SH7706) || \ 102 defined(CONFIG_CPU_SUBTYPE_SH7706) || \
163 defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705) 103 defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705)
@@ -171,14 +111,19 @@ void __init init_IRQ(void)
171 * You should set corresponding bits of PFC to "00" 111 * You should set corresponding bits of PFC to "00"
172 * to enable these interrupts. 112 * to enable these interrupts.
173 */ 113 */
174 make_ipr_irq(IRQ0_IRQ, IRQ0_IPR_ADDR, IRQ0_IPR_POS, IRQ0_PRIORITY); 114 { IRQ0_IRQ, IRQ0_IPR_ADDR, IRQ0_IPR_POS, IRQ0_PRIORITY },
175 make_ipr_irq(IRQ1_IRQ, IRQ1_IPR_ADDR, IRQ1_IPR_POS, IRQ1_PRIORITY); 115 { IRQ1_IRQ, IRQ1_IPR_ADDR, IRQ1_IPR_POS, IRQ1_PRIORITY },
176 make_ipr_irq(IRQ2_IRQ, IRQ2_IPR_ADDR, IRQ2_IPR_POS, IRQ2_PRIORITY); 116 { IRQ2_IRQ, IRQ2_IPR_ADDR, IRQ2_IPR_POS, IRQ2_PRIORITY },
177 make_ipr_irq(IRQ3_IRQ, IRQ3_IPR_ADDR, IRQ3_IPR_POS, IRQ3_PRIORITY); 117 { IRQ3_IRQ, IRQ3_IPR_ADDR, IRQ3_IPR_POS, IRQ3_PRIORITY },
178 make_ipr_irq(IRQ4_IRQ, IRQ4_IPR_ADDR, IRQ4_IPR_POS, IRQ4_PRIORITY); 118 { IRQ4_IRQ, IRQ4_IPR_ADDR, IRQ4_IPR_POS, IRQ4_PRIORITY },
179 make_ipr_irq(IRQ5_IRQ, IRQ5_IPR_ADDR, IRQ5_IPR_POS, IRQ5_PRIORITY); 119 { IRQ5_IRQ, IRQ5_IPR_ADDR, IRQ5_IPR_POS, IRQ5_PRIORITY },
180#endif 120#endif
181#endif 121#endif
122};
123
124void __init init_IRQ(void)
125{
126 make_ipr_irq(sys_ipr_map, ARRAY_SIZE(sys_ipr_map));
182 127
183#ifdef CONFIG_CPU_HAS_PINT_IRQ 128#ifdef CONFIG_CPU_HAS_PINT_IRQ
184 init_IRQ_pint(); 129 init_IRQ_pint();
@@ -200,5 +145,3 @@ int ipr_irq_demux(int irq)
200 return irq; 145 return irq;
201} 146}
202#endif 147#endif
203
204EXPORT_SYMBOL(make_ipr_irq);
diff --git a/arch/sh/kernel/cpu/irq/pint.c b/arch/sh/kernel/cpu/irq/pint.c
index 17f47b373d6e..f60007783a21 100644
--- a/arch/sh/kernel/cpu/irq/pint.c
+++ b/arch/sh/kernel/cpu/irq/pint.c
@@ -84,12 +84,16 @@ void make_pint_irq(unsigned int irq)
84 disable_pint_irq(irq); 84 disable_pint_irq(irq);
85} 85}
86 86
87static struct ipr_data pint_ipr_map[] = {
88 { PINT0_IRQ, PINT0_IPR_ADDR, PINT0_IPR_POS, PINT0_PRIORITY },
89 { PINT8_IRQ, PINT8_IPR_ADDR, PINT8_IPR_POS, PINT8_PRIORITY },
90};
91
87void __init init_IRQ_pint(void) 92void __init init_IRQ_pint(void)
88{ 93{
89 int i; 94 int i;
90 95
91 make_ipr_irq(PINT0_IRQ, PINT0_IPR_ADDR, PINT0_IPR_POS, PINT0_PRIORITY); 96 make_ipr_irq(pint_ipr_map, ARRAY_SIZE(pint_ipr_map));
92 make_ipr_irq(PINT8_IRQ, PINT8_IPR_ADDR, PINT8_IPR_POS, PINT8_PRIORITY);
93 97
94 enable_irq(PINT0_IRQ); 98 enable_irq(PINT0_IRQ);
95 enable_irq(PINT8_IRQ); 99 enable_irq(PINT8_IRQ);
diff --git a/arch/sh/kernel/cpu/sh3/ex.S b/arch/sh/kernel/cpu/sh3/ex.S
index 44daf44833f9..ba3082d640b5 100644
--- a/arch/sh/kernel/cpu/sh3/ex.S
+++ b/arch/sh/kernel/cpu/sh3/ex.S
@@ -4,7 +4,7 @@
4 * The SH-3 exception vector table. 4 * The SH-3 exception vector table.
5 5
6 * Copyright (C) 1999, 2000, 2002 Niibe Yutaka 6 * Copyright (C) 1999, 2000, 2002 Niibe Yutaka
7 * Copyright (C) 2003 Paul Mundt 7 * Copyright (C) 2003 - 2006 Paul Mundt
8 * 8 *
9 * This file is subject to the terms and conditions of the GNU General Public 9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive 10 * License. See the file "COPYING" in the main directory of this archive
@@ -49,198 +49,10 @@ ENTRY(nmi_slot)
49#endif 49#endif
50ENTRY(user_break_point_trap) 50ENTRY(user_break_point_trap)
51 .long break_point_trap /* 1E0 */ 51 .long break_point_trap /* 1E0 */
52ENTRY(interrupt_table) 52
53 ! external hardware 53 /*
54 .long do_IRQ ! 0000 /* 200 */ 54 * Pad the remainder of the table out, exceptions residing in far
55 .long do_IRQ ! 0001 55 * away offsets can be manually inserted in to their appropriate
56 .long do_IRQ ! 0010 56 * location via set_exception_table_{evt,vec}().
57 .long do_IRQ ! 0011 57 */
58 .long do_IRQ ! 0100 58 .balign 4096,0,4096
59 .long do_IRQ ! 0101
60 .long do_IRQ ! 0110
61 .long do_IRQ ! 0111
62 .long do_IRQ ! 1000 /* 300 */
63 .long do_IRQ ! 1001
64 .long do_IRQ ! 1010
65 .long do_IRQ ! 1011
66 .long do_IRQ ! 1100
67 .long do_IRQ ! 1101
68 .long do_IRQ ! 1110
69 .long exception_error
70 ! Internal hardware
71 .long do_IRQ ! TMU0 tuni0 /* 400 */
72 .long do_IRQ ! TMU1 tuni1
73 .long do_IRQ ! TMU2 tuni2
74 .long do_IRQ ! ticpi2
75 .long do_IRQ ! RTC ati
76 .long do_IRQ ! pri
77 .long do_IRQ ! cui
78 .long do_IRQ ! SCI eri
79 .long do_IRQ ! rxi /* 500 */
80 .long do_IRQ ! txi
81 .long do_IRQ ! tei
82 .long do_IRQ ! WDT iti /* 560 */
83 .long do_IRQ ! REF rcmi
84 .long do_IRQ ! rovi
85 .long do_IRQ
86 .long do_IRQ /* 5E0 */
87#if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
88 defined(CONFIG_CPU_SUBTYPE_SH7709) || \
89 defined(CONFIG_CPU_SUBTYPE_SH7706) || \
90 defined(CONFIG_CPU_SUBTYPE_SH7300) || \
91 defined(CONFIG_CPU_SUBTYPE_SH7705) || \
92 defined(CONFIG_CPU_SUBTYPE_SH7710)
93 .long do_IRQ ! 32 IRQ irq0 /* 600 */
94 .long do_IRQ ! 33 irq1
95 .long do_IRQ ! 34 irq2
96 .long do_IRQ ! 35 irq3
97 .long do_IRQ ! 36 irq4
98 .long do_IRQ ! 37 irq5
99 .long do_IRQ ! 38
100 .long do_IRQ ! 39
101 .long do_IRQ ! 40 PINT pint0-7 /* 700 */
102 .long do_IRQ ! 41 pint8-15
103 .long do_IRQ ! 42
104 .long do_IRQ ! 43
105 .long do_IRQ ! 44
106 .long do_IRQ ! 45
107 .long do_IRQ ! 46
108 .long do_IRQ ! 47
109 .long do_IRQ ! 48 DMAC dei0 /* 800 */
110 .long do_IRQ ! 49 dei1
111 .long do_IRQ ! 50 dei2
112 .long do_IRQ ! 51 dei3
113 .long do_IRQ ! 52 IrDA eri1
114 .long do_IRQ ! 53 rxi1
115 .long do_IRQ ! 54 bri1
116 .long do_IRQ ! 55 txi1
117 .long do_IRQ ! 56 SCIF eri2
118 .long do_IRQ ! 57 rxi2
119 .long do_IRQ ! 58 bri2
120 .long do_IRQ ! 59 txi2
121 .long do_IRQ ! 60 ADC adi /* 980 */
122#if defined(CONFIG_CPU_SUBTYPE_SH7705)
123 .long exception_none ! 61 /* 9A0 */
124 .long exception_none ! 62
125 .long exception_none ! 63
126 .long exception_none ! 64 /* A00 */
127 .long do_IRQ ! 65 USB usi0
128 .long do_IRQ ! 66 usi1
129 .long exception_none ! 67
130 .long exception_none ! 68
131 .long exception_none ! 69
132 .long exception_none ! 70
133 .long exception_none ! 71
134 .long exception_none ! 72 /* B00 */
135 .long exception_none ! 73
136 .long exception_none ! 74
137 .long exception_none ! 75
138 .long exception_none ! 76
139 .long exception_none ! 77
140 .long exception_none ! 78
141 .long exception_none ! 79
142 .long do_IRQ ! 80 TPU0 tpi0 /* C00 */
143 .long do_IRQ ! 81 TPU1 tpi1
144 .long exception_none ! 82
145 .long exception_none ! 83
146 .long do_IRQ ! 84 TPU2 tpi2
147 .long do_IRQ ! 85 TPU3 tpi3 /* CA0 */
148#endif
149#if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7300)
150 .long do_IRQ ! 61 LCDC lcdi /* 9A0 */
151 .long do_IRQ ! 62 PCC pcc0i
152 .long do_IRQ ! 63 pcc1i /* 9E0 */
153#endif
154#if defined(CONFIG_CPU_SUBTYPE_SH7710)
155 .long exception_none ! 61 /* 9A0 */
156 .long exception_none ! 62
157 .long exception_none ! 63
158 .long exception_none ! 64 /* A00 */
159 .long exception_none ! 65
160 .long exception_none ! 66
161 .long exception_none ! 67
162 .long exception_none ! 68
163 .long exception_none ! 69
164 .long exception_none ! 70
165 .long exception_none ! 71
166 .long exception_none ! 72 /* B00 */
167 .long exception_none ! 73
168 .long exception_none ! 74
169 .long exception_none ! 75
170 .long do_IRQ ! 76 DMAC2 dei4 /* B80 */
171 .long do_IRQ ! 77 DMAC2 dei5
172 .long exception_none ! 78
173 .long do_IRQ ! 79 IPSEC ipseci /* BE0 */
174 .long do_IRQ ! 80 EDMAC eint0 /* C00 */
175 .long do_IRQ ! 81 EDMAC eint1
176 .long do_IRQ ! 82 EDMAC eint2
177 .long exception_none ! 83 /* C60 */
178 .long exception_none ! 84
179 .long exception_none ! 85
180 .long exception_none ! 86
181 .long exception_none ! 87
182 .long exception_none ! 88 /* D00 */
183 .long exception_none ! 89
184 .long exception_none ! 90
185 .long exception_none ! 91
186 .long exception_none ! 92
187 .long exception_none ! 93
188 .long exception_none ! 94
189 .long exception_none ! 95
190 .long do_IRQ ! 96 SIOF eri0 /* E00 */
191 .long do_IRQ ! 97 txi0
192 .long do_IRQ ! 98 rxi0
193 .long do_IRQ ! 99 cci0
194 .long do_IRQ ! 100 eri1 /* E80 */
195 .long do_IRQ ! 101 txi1
196 .long do_IRQ ! 102 rxi2
197 .long do_IRQ ! 103 cci3
198#endif
199#if defined(CONFIG_CPU_SUBTYPE_SH7300)
200 .long do_IRQ ! 64
201 .long do_IRQ ! 65
202 .long do_IRQ ! 66
203 .long do_IRQ ! 67
204 .long do_IRQ ! 68
205 .long do_IRQ ! 69
206 .long do_IRQ ! 70
207 .long do_IRQ ! 71
208 .long do_IRQ ! 72
209 .long do_IRQ ! 73
210 .long do_IRQ ! 74
211 .long do_IRQ ! 75
212 .long do_IRQ ! 76
213 .long do_IRQ ! 77
214 .long do_IRQ ! 78
215 .long do_IRQ ! 79
216 .long do_IRQ ! 80 SCIF0(SH7300)
217 .long do_IRQ ! 81
218 .long do_IRQ ! 82
219 .long do_IRQ ! 83
220 .long do_IRQ ! 84
221 .long do_IRQ ! 85
222 .long do_IRQ ! 86
223 .long do_IRQ ! 87
224 .long do_IRQ ! 88
225 .long do_IRQ ! 89
226 .long do_IRQ ! 90
227 .long do_IRQ ! 91
228 .long do_IRQ ! 92
229 .long do_IRQ ! 93
230 .long do_IRQ ! 94
231 .long do_IRQ ! 95
232 .long do_IRQ ! 96
233 .long do_IRQ ! 97
234 .long do_IRQ ! 98
235 .long do_IRQ ! 99
236 .long do_IRQ ! 100
237 .long do_IRQ ! 101
238 .long do_IRQ ! 102
239 .long do_IRQ ! 103
240 .long do_IRQ ! 104
241 .long do_IRQ ! 105
242 .long do_IRQ ! 106
243 .long do_IRQ ! 107
244 .long do_IRQ ! 108
245#endif
246#endif
diff --git a/arch/sh/kernel/cpu/sh4/ex.S b/arch/sh/kernel/cpu/sh4/ex.S
index 7146893a6cca..ac8ab57413cc 100644
--- a/arch/sh/kernel/cpu/sh4/ex.S
+++ b/arch/sh/kernel/cpu/sh4/ex.S
@@ -4,7 +4,7 @@
4 * The SH-4 exception vector table. 4 * The SH-4 exception vector table.
5 5
6 * Copyright (C) 1999, 2000, 2002 Niibe Yutaka 6 * Copyright (C) 1999, 2000, 2002 Niibe Yutaka
7 * Copyright (C) 2003 Paul Mundt 7 * Copyright (C) 2003 - 2006 Paul Mundt
8 * 8 *
9 * This file is subject to the terms and conditions of the GNU General Public 9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive 10 * License. See the file "COPYING" in the main directory of this archive
@@ -53,503 +53,10 @@ ENTRY(nmi_slot)
53#endif 53#endif
54ENTRY(user_break_point_trap) 54ENTRY(user_break_point_trap)
55 .long break_point_trap /* 1E0 */ 55 .long break_point_trap /* 1E0 */
56ENTRY(interrupt_table)
57 ! external hardware
58 .long do_IRQ ! 0000 /* 200 */
59 .long do_IRQ ! 0001
60 .long do_IRQ ! 0010
61 .long do_IRQ ! 0011
62 .long do_IRQ ! 0100
63 .long do_IRQ ! 0101
64 .long do_IRQ ! 0110
65 .long do_IRQ ! 0111
66 .long do_IRQ ! 1000 /* 300 */
67 .long do_IRQ ! 1001
68 .long do_IRQ ! 1010
69 .long do_IRQ ! 1011
70 .long do_IRQ ! 1100
71 .long do_IRQ ! 1101
72 .long do_IRQ ! 1110
73 .long exception_error
74 ! Internal hardware
75#ifndef CONFIG_CPU_SUBTYPE_SH7780
76 .long do_IRQ ! TMU0 tuni0 /* 400 */
77 .long do_IRQ ! TMU1 tuni1
78 .long do_IRQ ! TMU2 tuni2
79 .long do_IRQ ! ticpi2
80#if defined(CONFIG_CPU_SUBTYPE_SH7760)
81 .long exception_error
82 .long exception_error
83 .long exception_error
84 .long exception_error
85 .long exception_error /* 500 */
86 .long exception_error
87 .long exception_error
88#else
89 .long do_IRQ ! RTC ati
90 .long do_IRQ ! pri
91 .long do_IRQ ! cui
92 .long do_IRQ ! SCI eri
93 .long do_IRQ ! rxi /* 500 */
94 .long do_IRQ ! txi
95 .long do_IRQ ! tei
96#endif
97 .long do_IRQ ! WDT iti /* 560 */
98 .long do_IRQ ! REF rcmi
99 .long do_IRQ ! rovi
100 .long do_IRQ
101 .long do_IRQ /* 5E0 */
102 .long do_IRQ ! 32 Hitachi UDI /* 600 */
103 .long do_IRQ ! 33 GPIO
104 .long do_IRQ ! 34 DMAC dmte0
105 .long do_IRQ ! 35 dmte1
106 .long do_IRQ ! 36 dmte2
107 .long do_IRQ ! 37 dmte3
108 .long do_IRQ ! 38 dmae
109 .long exception_error ! 39 /* 6E0 */
110#if defined(CONFIG_CPU_SUBTYPE_SH7760)
111 .long exception_error /* 700 */
112 .long exception_error
113 .long exception_error
114 .long exception_error /* 760 */
115#else
116 .long do_IRQ ! 40 SCIF eri /* 700 */
117 .long do_IRQ ! 41 rxi
118 .long do_IRQ ! 42 bri
119 .long do_IRQ ! 43 txi
120#endif
121#if CONFIG_NR_ONCHIP_DMA_CHANNELS == 8
122 .long do_IRQ ! 44 DMAC dmte4 /* 780 */
123 .long do_IRQ ! 45 dmte5
124 .long do_IRQ ! 46 dmte6
125 .long do_IRQ ! 47 dmte7 /* 7E0 */
126#elif defined(CONFIG_CPU_SUBTYPE_SH7343)
127 .long do_IRQ ! 44 IIC1 ali /* 780 */
128 .long do_IRQ ! 45 tacki
129 .long do_IRQ ! 46 waiti
130 .long do_IRQ ! 47 dtei /* 7E0 */
131 .long do_IRQ ! 48 DMAC dei0 /* 800 */
132 .long do_IRQ ! 49 dei1 /* 820 */
133#else
134 .long exception_error ! 44 /* 780 */
135 .long exception_error ! 45
136 .long exception_error ! 46
137 .long exception_error ! 47
138#endif
139#if defined(CONFIG_SH_FPU)
140 .long do_fpu_state_restore ! 48 /* 800 */
141 .long do_fpu_state_restore ! 49 /* 820 */
142#elif !defined(CONFIG_CPU_SUBTYPE_SH7343) && \
143 !defined(CONFIG_CPU_SUBTYPE_SH73180)
144 .long exception_error
145 .long exception_error
146#endif
147#if defined(CONFIG_CPU_SUBTYPE_SH7751)
148 .long exception_error /* 840 */
149 .long exception_error
150 .long exception_error
151 .long exception_error
152 .long exception_error
153 .long exception_error
154 .long exception_error /* 900 */
155 .long exception_error
156 .long exception_error
157 .long exception_error
158 .long exception_error
159 .long exception_error
160 .long exception_error
161 .long exception_error
162 .long do_IRQ ! PCI serr /* A00 */
163 .long do_IRQ ! dma3
164 .long do_IRQ ! dma2
165 .long do_IRQ ! dma1
166 .long do_IRQ ! dma0
167 .long do_IRQ ! pwon
168 .long do_IRQ ! pwdwn
169 .long do_IRQ ! err
170 .long do_IRQ ! TMU3 tuni3 /* B00 */
171 .long exception_error
172 .long exception_error
173 .long exception_error
174 .long do_IRQ ! TMU4 tuni4 /* B80 */
175#elif defined(CONFIG_CPU_SUBTYPE_SH7760)
176 .long do_IRQ ! IRQ irq6 /* 840 */
177 .long do_IRQ ! irq7
178 .long do_IRQ ! SCIF eri0
179 .long do_IRQ ! rxi0
180 .long do_IRQ ! bri0
181 .long do_IRQ ! txi0
182 .long do_IRQ ! HCAN2 cani0 /* 900 */
183 .long do_IRQ ! cani1
184 .long do_IRQ ! SSI ssii0
185 .long do_IRQ ! ssii1
186 .long do_IRQ ! HAC haci0
187 .long do_IRQ ! haci1
188 .long do_IRQ ! IIC iici0
189 .long do_IRQ ! iici1
190 .long do_IRQ ! USB usbi /* A00 */
191 .long do_IRQ ! LCDC vint
192 .long exception_error
193 .long exception_error
194 .long do_IRQ ! DMABRG dmabrgi0
195 .long do_IRQ ! dmabrgi1
196 .long do_IRQ ! dmabrgi2
197 .long exception_error
198 .long do_IRQ ! SCIF eri1 /* B00 */
199 .long do_IRQ ! rxi1
200 .long do_IRQ ! bri1
201 .long do_IRQ ! txi1
202 .long do_IRQ ! eri2
203 .long do_IRQ ! rxi2
204 .long do_IRQ ! bri2
205 .long do_IRQ ! txi2
206 .long do_IRQ ! SIM simeri /* C00 */
207 .long do_IRQ ! simrxi
208 .long do_IRQ ! simtxi
209 .long do_IRQ ! simtei
210 .long do_IRQ ! HSPI spii
211 .long exception_error
212 .long exception_error
213 .long exception_error
214 .long do_IRQ ! MMCIF mmci0 /* D00 */
215 .long do_IRQ ! mmci1
216 .long do_IRQ ! mmci2
217 .long do_IRQ ! mmci3
218 .long exception_error
219 .long exception_error
220 .long exception_error
221 .long exception_error
222 .long exception_error /* E00 */
223 .long exception_error
224 .long exception_error
225 .long exception_error
226 .long do_IRQ ! MFI mfii
227 .long exception_error
228 .long exception_error
229 .long exception_error
230 .long exception_error /* F00 */
231 .long exception_error
232 .long exception_error
233 .long exception_error
234 .long do_IRQ ! ADC adi
235 .long do_IRQ ! CMT cmti /* FA0 */
236#elif defined(CONFIG_CPU_SUBTYPE_SH73180) || defined(CONFIG_CPU_SUBTYPE_SH7343)
237 .long do_IRQ ! 50 0x840
238 .long do_IRQ ! 51 0x860
239 .long do_IRQ ! 52 0x880
240 .long do_IRQ ! 53 0x8a0
241 .long do_IRQ ! 54 0x8c0
242 .long do_IRQ ! 55 0x8e0
243 .long do_IRQ ! 56 0x900
244 .long do_IRQ ! 57 0x920
245 .long do_IRQ ! 58 0x940
246 .long do_IRQ ! 59 0x960
247 .long do_IRQ ! 60 0x980
248 .long do_IRQ ! 61 0x9a0
249 .long do_IRQ ! 62 0x9c0
250 .long do_IRQ ! 63 0x9e0
251 .long do_IRQ ! 64 0xa00
252 .long do_IRQ ! 65 0xa20
253 .long do_IRQ ! 66 0xa40
254 .long do_IRQ ! 67 0xa60
255 .long do_IRQ ! 68 0xa80
256 .long do_IRQ ! 69 0xaa0
257 .long do_IRQ ! 70 0xac0
258 .long do_IRQ ! 71 0xae0
259 .long do_IRQ ! 72 0xb00
260 .long do_IRQ ! 73 0xb20
261 .long do_IRQ ! 74 0xb40
262 .long do_IRQ ! 75 0xb60
263 .long do_IRQ ! 76 0xb80
264 .long do_IRQ ! 77 0xba0
265 .long do_IRQ ! 78 0xbc0
266 .long do_IRQ ! 79 0xbe0
267 .long do_IRQ ! 80 0xc00
268 .long do_IRQ ! 81 0xc20
269 .long do_IRQ ! 82 0xc40
270 .long do_IRQ ! 83 0xc60
271 .long do_IRQ ! 84 0xc80
272 .long do_IRQ ! 85 0xca0
273 .long do_IRQ ! 86 0xcc0
274 .long do_IRQ ! 87 0xce0
275 .long do_IRQ ! 88 0xd00
276 .long do_IRQ ! 89 0xd20
277 .long do_IRQ ! 90 0xd40
278 .long do_IRQ ! 91 0xd60
279 .long do_IRQ ! 92 0xd80
280 .long do_IRQ ! 93 0xda0
281 .long do_IRQ ! 94 0xdc0
282 .long do_IRQ ! 95 0xde0
283 .long do_IRQ ! 96 0xe00
284 .long do_IRQ ! 97 0xe20
285 .long do_IRQ ! 98 0xe40
286 .long do_IRQ ! 99 0xe60
287 .long do_IRQ ! 100 0xe80
288 .long do_IRQ ! 101 0xea0
289 .long do_IRQ ! 102 0xec0
290 .long do_IRQ ! 103 0xee0
291 .long do_IRQ ! 104 0xf00
292 .long do_IRQ ! 105 0xf20
293 .long do_IRQ ! 106 0xf40
294 .long do_IRQ ! 107 0xf60
295 .long do_IRQ ! 108 0xf80
296#elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)
297 .long exception_error ! 50 0x840
298 .long exception_error ! 51 0x860
299 .long exception_error ! 52 0x880
300 .long exception_error ! 53 0x8a0
301 .long exception_error ! 54 0x8c0
302 .long exception_error ! 55 0x8e0
303 .long exception_error ! 56 0x900
304 .long exception_error ! 57 0x920
305 .long exception_error ! 58 0x940
306 .long exception_error ! 59 0x960
307 .long exception_error ! 60 0x980
308 .long exception_error ! 61 0x9a0
309 .long exception_error ! 62 0x9c0
310 .long exception_error ! 63 0x9e0
311 .long do_IRQ ! 64 0xa00 PCI serr
312 .long do_IRQ ! 65 0xa20 err
313 .long do_IRQ ! 66 0xa40 ad
314 .long do_IRQ ! 67 0xa60 pwr_dwn
315 .long exception_error ! 68 0xa80
316 .long exception_error ! 69 0xaa0
317 .long exception_error ! 70 0xac0
318 .long exception_error ! 71 0xae0
319 .long do_IRQ ! 72 0xb00 DMA INT0
320 .long do_IRQ ! 73 0xb20 INT1
321 .long do_IRQ ! 74 0xb40 INT2
322 .long do_IRQ ! 75 0xb60 INT3
323 .long do_IRQ ! 76 0xb80 INT4
324 .long exception_error ! 77 0xba0
325 .long do_IRQ ! 78 0xbc0 DMA ERR
326 .long exception_error ! 79 0xbe0
327 .long do_IRQ ! 80 0xc00 PIO0
328 .long do_IRQ ! 81 0xc20 PIO1
329 .long do_IRQ ! 82 0xc40 PIO2
330 .long exception_error ! 83 0xc60
331 .long exception_error ! 84 0xc80
332 .long exception_error ! 85 0xca0
333 .long exception_error ! 86 0xcc0
334 .long exception_error ! 87 0xce0
335 .long exception_error ! 88 0xd00
336 .long exception_error ! 89 0xd20
337 .long exception_error ! 90 0xd40
338 .long exception_error ! 91 0xd60
339 .long exception_error ! 92 0xd80
340 .long exception_error ! 93 0xda0
341 .long exception_error ! 94 0xdc0
342 .long exception_error ! 95 0xde0
343 .long exception_error ! 96 0xe00
344 .long exception_error ! 97 0xe20
345 .long exception_error ! 98 0xe40
346 .long exception_error ! 99 0xe60
347 .long exception_error ! 100 0xe80
348 .long exception_error ! 101 0xea0
349 .long exception_error ! 102 0xec0
350 .long exception_error ! 103 0xee0
351 .long exception_error ! 104 0xf00
352 .long exception_error ! 105 0xf20
353 .long exception_error ! 106 0xf40
354 .long exception_error ! 107 0xf60
355 .long exception_error ! 108 0xf80
356 .long exception_error ! 109 0xfa0
357 .long exception_error ! 110 0xfc0
358 .long exception_error ! 111 0xfe0
359 .long do_IRQ ! 112 0x1000 Mailbox
360 .long exception_error ! 113 0x1020
361 .long exception_error ! 114 0x1040
362 .long exception_error ! 115 0x1060
363 .long exception_error ! 116 0x1080
364 .long exception_error ! 117 0x10a0
365 .long exception_error ! 118 0x10c0
366 .long exception_error ! 119 0x10e0
367 .long exception_error ! 120 0x1100
368 .long exception_error ! 121 0x1120
369 .long exception_error ! 122 0x1140
370 .long exception_error ! 123 0x1160
371 .long exception_error ! 124 0x1180
372 .long exception_error ! 125 0x11a0
373 .long exception_error ! 126 0x11c0
374 .long exception_error ! 127 0x11e0
375 .long exception_error ! 128 0x1200
376 .long exception_error ! 129 0x1220
377 .long exception_error ! 130 0x1240
378 .long exception_error ! 131 0x1260
379 .long exception_error ! 132 0x1280
380 .long exception_error ! 133 0x12a0
381 .long exception_error ! 134 0x12c0
382 .long exception_error ! 135 0x12e0
383 .long exception_error ! 136 0x1300
384 .long exception_error ! 137 0x1320
385 .long exception_error ! 138 0x1340
386 .long exception_error ! 139 0x1360
387 .long do_IRQ ! 140 0x1380 EMPI INV_ADDR
388 .long exception_error ! 141 0x13a0
389 .long exception_error ! 142 0x13c0
390 .long exception_error ! 143 0x13e0
391#elif defined(CONFIG_CPU_SUBTYPE_SH7770)
392 .long do_IRQ ! 50 0x840
393 .long do_IRQ ! 51 0x860
394 .long do_IRQ ! 52 0x880
395 .long do_IRQ ! 53 0x8a0
396 .long do_IRQ ! 54 0x8c0
397 .long do_IRQ ! 55 0x8e0
398 .long do_IRQ ! 56 0x900
399 .long do_IRQ ! 57 0x920
400 .long do_IRQ ! 58 0x940
401 .long do_IRQ ! 59 0x960
402 .long do_IRQ ! 60 0x980
403 .long do_IRQ ! 61 0x9a0
404 .long do_IRQ ! 62 0x9c0
405 .long do_IRQ ! 63 0x9e0
406 .long do_IRQ ! 64 0xa00
407 .long do_IRQ ! 65 0xa20
408 .long do_IRQ ! 66 0xa4d
409 .long do_IRQ ! 67 0xa60
410 .long do_IRQ ! 68 0xa80
411 .long do_IRQ ! 69 0xaa0
412 .long do_IRQ ! 70 0xac0
413 .long do_IRQ ! 71 0xae0
414 .long do_IRQ ! 72 0xb00
415 .long do_IRQ ! 73 0xb20
416 .long do_IRQ ! 74 0xb40
417 .long do_IRQ ! 75 0xb60
418 .long do_IRQ ! 76 0xb80
419 .long do_IRQ ! 77 0xba0
420 .long do_IRQ ! 78 0xbc0
421 .long do_IRQ ! 79 0xbe0
422 .long do_IRQ ! 80 0xc00
423 .long do_IRQ ! 81 0xc20
424 .long do_IRQ ! 82 0xc40
425 .long do_IRQ ! 83 0xc60
426 .long do_IRQ ! 84 0xc80
427 .long do_IRQ ! 85 0xca0
428 .long do_IRQ ! 86 0xcc0
429 .long do_IRQ ! 87 0xce0
430 .long do_IRQ ! 88 0xd00
431 .long do_IRQ ! 89 0xd20
432 .long do_IRQ ! 90 0xd40
433 .long do_IRQ ! 91 0xd60
434 .long do_IRQ ! 92 0xd80
435 .long do_IRQ ! 93 0xda0
436 .long do_IRQ ! 94 0xdc0
437 .long do_IRQ ! 95 0xde0
438 .long do_IRQ ! 96 0xe00
439 .long do_IRQ ! 97 0xe20
440 .long do_IRQ ! 98 0xe40
441 .long do_IRQ ! 99 0xe60
442 .long do_IRQ ! 100 0xe80
443 .long do_IRQ ! 101 0xea0
444 .long do_IRQ ! 102 0xec0
445 .long do_IRQ ! 103 0xee0
446 .long do_IRQ ! 104 0xf00
447 .long do_IRQ ! 105 0xf20
448 .long do_IRQ ! 106 0xf40
449 .long do_IRQ ! 107 0xf60
450 .long do_IRQ ! 108 0xf80
451#endif
452#else
453 .long exception_error /* 400 */
454 .long exception_error
455 .long exception_error
456 .long exception_error
457 .long do_IRQ ! RTC ati
458 .long do_IRQ ! pri
459 .long do_IRQ ! cui
460 .long exception_error
461 .long exception_error /* 500 */
462 .long exception_error
463 .long exception_error
464 .long do_IRQ ! WDT iti /* 560 */
465 .long do_IRQ ! TMU-ch0
466 .long do_IRQ ! TMU-ch1
467 .long do_IRQ ! TMU-ch2
468 .long do_IRQ ! ticpi2 /* 5E0 */
469 .long do_IRQ ! 32 Hitachi UDI /* 600 */
470 .long exception_error
471 .long do_IRQ ! 34 DMAC dmte0
472 .long do_IRQ ! 35 dmte1
473 .long do_IRQ ! 36 dmte2
474 .long do_IRQ ! 37 dmte3
475 .long do_IRQ ! 38 dmae
476 .long exception_error ! 39 /* 6E0 */
477 .long do_IRQ ! 40 SCIF-ch0 eri /* 700 */
478 .long do_IRQ ! 41 rxi
479 .long do_IRQ ! 42 bri
480 .long do_IRQ ! 43 txi
481 .long do_IRQ ! 44 DMAC dmte4 /* 780 */
482 .long do_IRQ ! 45 dmte5
483 .long do_IRQ ! 46 dmte6
484 .long do_IRQ ! 47 dmte7 /* 7E0 */
485#if defined(CONFIG_SH_FPU)
486 .long do_fpu_state_restore ! 48 /* 800 */
487 .long do_fpu_state_restore ! 49 /* 820 */
488#else
489 .long exception_error
490 .long exception_error
491#endif
492 .long exception_error /* 840 */
493 .long exception_error
494 .long exception_error
495 .long exception_error
496 .long exception_error
497 .long exception_error
498 .long do_IRQ ! 56 CMT /* 900 */
499 .long exception_error
500 .long exception_error
501 .long exception_error
502 .long do_IRQ ! 60 HAC
503 .long exception_error
504 .long exception_error
505 .long exception_error
506 .long do_IRQ ! PCI serr /* A00 */
507 .long do_IRQ ! INTA
508 .long do_IRQ ! INTB
509 .long do_IRQ ! INTC
510 .long do_IRQ ! INTD
511 .long do_IRQ ! err
512 .long do_IRQ ! pwd3
513 .long do_IRQ ! pwd2
514 .long do_IRQ ! pwd1 /* B00 */
515 .long do_IRQ ! pwd0
516 .long exception_error
517 .long exception_error
518 .long do_IRQ ! SCIF-ch1 eri /* B80 */
519 .long do_IRQ ! rxi
520 .long do_IRQ ! bri
521 .long do_IRQ ! txi
522 .long do_IRQ ! SIOF /* C00 */
523 .long exception_error
524 .long exception_error
525 .long exception_error
526 .long do_IRQ ! HSPI /* C80 */
527 .long exception_error
528 .long exception_error
529 .long exception_error
530 .long do_IRQ ! MMCIF fatat /* D00 */
531 .long do_IRQ ! tran
532 .long do_IRQ ! err
533 .long do_IRQ ! frdy
534 .long do_IRQ ! DMAC dmint8 /* D80 */
535 .long do_IRQ ! dmint9
536 .long do_IRQ ! dmint10
537 .long do_IRQ ! dmint11
538 .long do_IRQ ! TMU-ch3 /* E00 */
539 .long do_IRQ ! TMU-ch4
540 .long do_IRQ ! TMU-ch5
541 .long exception_error
542 .long do_IRQ ! SSI
543 .long exception_error
544 .long exception_error
545 .long exception_error
546 .long do_IRQ ! FLCTL flste /* F00 */
547 .long do_IRQ ! fltend
548 .long do_IRQ ! fltrq0
549 .long do_IRQ ! fltrq1
550 .long do_IRQ ! GPIO gpioi0 /* F80 */
551 .long do_IRQ ! gpioi1
552 .long do_IRQ ! gpioi2
553 .long do_IRQ ! gpioi3
554#endif
555 56
57 /*
58 * Pad the remainder of the table out, exceptions residing in far
59 * away offsets can be manually inserted in to their appropriate
60 * location via set_exception_table_{evt,vec}().
61 */
62 .balign 4096,0,4096
diff --git a/arch/sh/kernel/cpu/sh4/setup-sh7760.c b/arch/sh/kernel/cpu/sh4/setup-sh7760.c
index 97f1c9af35d6..07e5377bf550 100644
--- a/arch/sh/kernel/cpu/sh4/setup-sh7760.c
+++ b/arch/sh/kernel/cpu/sh4/setup-sh7760.c
@@ -51,3 +51,66 @@ static int __init sh7760_devices_setup(void)
51 ARRAY_SIZE(sh7760_devices)); 51 ARRAY_SIZE(sh7760_devices));
52} 52}
53__initcall(sh7760_devices_setup); 53__initcall(sh7760_devices_setup);
54
55/*
56 * SH7760 INTC2-Style interrupts, vectors IRQ48-111 INTEVT 0x800-0xFE0
57 */
58static struct intc2_data intc2_irq_table[] = {
59 /* INTPRIO0 | INTMSK0 */
60 {48, 0, 28, 0, 31, 3}, /* IRQ 4 */
61 {49, 0, 24, 0, 30, 3}, /* IRQ 3 */
62 {50, 0, 20, 0, 29, 3}, /* IRQ 2 */
63 {51, 0, 16, 0, 28, 3}, /* IRQ 1 */
64 /* 52-55 (INTEVT 0x880-0x8E0) unused/reserved */
65 /* INTPRIO4 | INTMSK0 */
66 {56, 4, 28, 0, 25, 3}, /* HCAN2_CHAN0 */
67 {57, 4, 24, 0, 24, 3}, /* HCAN2_CHAN1 */
68 {58, 4, 20, 0, 23, 3}, /* I2S_CHAN0 */
69 {59, 4, 16, 0, 22, 3}, /* I2S_CHAN1 */
70 {60, 4, 12, 0, 21, 3}, /* AC97_CHAN0 */
71 {61, 4, 8, 0, 20, 3}, /* AC97_CHAN1 */
72 {62, 4, 4, 0, 19, 3}, /* I2C_CHAN0 */
73 {63, 4, 0, 0, 18, 3}, /* I2C_CHAN1 */
74 /* INTPRIO8 | INTMSK0 */
75 {52, 8, 16, 0, 11, 3}, /* SCIF0_ERI_IRQ */
76 {53, 8, 16, 0, 10, 3}, /* SCIF0_RXI_IRQ */
77 {54, 8, 16, 0, 9, 3}, /* SCIF0_BRI_IRQ */
78 {55, 8, 16, 0, 8, 3}, /* SCIF0_TXI_IRQ */
79 {64, 8, 28, 0, 17, 3}, /* USBHI_IRQ */
80 {65, 8, 24, 0, 16, 3}, /* LCDC */
81 /* 66, 67 unused */
82 {68, 8, 20, 0, 14, 13}, /* DMABRGI0_IRQ */
83 {69, 8, 20, 0, 13, 13}, /* DMABRGI1_IRQ */
84 {70, 8, 20, 0, 12, 13}, /* DMABRGI2_IRQ */
85 /* 71 unused */
86 {72, 8, 12, 0, 7, 3}, /* SCIF1_ERI_IRQ */
87 {73, 8, 12, 0, 6, 3}, /* SCIF1_RXI_IRQ */
88 {74, 8, 12, 0, 5, 3}, /* SCIF1_BRI_IRQ */
89 {75, 8, 12, 0, 4, 3}, /* SCIF1_TXI_IRQ */
90 {76, 8, 8, 0, 3, 3}, /* SCIF2_ERI_IRQ */
91 {77, 8, 8, 0, 2, 3}, /* SCIF2_RXI_IRQ */
92 {78, 8, 8, 0, 1, 3}, /* SCIF2_BRI_IRQ */
93 {79, 8, 8, 0, 0, 3}, /* SCIF2_TXI_IRQ */
94 /* | INTMSK4 */
95 {80, 8, 4, 4, 23, 3}, /* SIM_ERI */
96 {81, 8, 4, 4, 22, 3}, /* SIM_RXI */
97 {82, 8, 4, 4, 21, 3}, /* SIM_TXI */
98 {83, 8, 4, 4, 20, 3}, /* SIM_TEI */
99 {84, 8, 0, 4, 19, 3}, /* HSPII */
100 /* INTPRIOC | INTMSK4 */
101 /* 85-87 unused/reserved */
102 {88, 12, 20, 4, 18, 3}, /* MMCI0 */
103 {89, 12, 20, 4, 17, 3}, /* MMCI1 */
104 {90, 12, 20, 4, 16, 3}, /* MMCI2 */
105 {91, 12, 20, 4, 15, 3}, /* MMCI3 */
106 {92, 12, 12, 4, 6, 3}, /* MFI (unsure, bug? in my 7760 manual*/
107 /* 93-107 reserved/undocumented */
108 {108,12, 4, 4, 1, 3}, /* ADC */
109 {109,12, 0, 4, 0, 3}, /* CMTI */
110 /* 110-111 reserved/unused */
111};
112
113void __init init_IRQ_intc2(void)
114{
115 make_intc2_irq(intc2_irq_table, ARRAY_SIZE(intc2_irq_table));
116}
diff --git a/arch/sh/kernel/cpu/sh4/setup-sh7780.c b/arch/sh/kernel/cpu/sh4/setup-sh7780.c
index 72493f259edc..814ddb226531 100644
--- a/arch/sh/kernel/cpu/sh4/setup-sh7780.c
+++ b/arch/sh/kernel/cpu/sh4/setup-sh7780.c
@@ -77,3 +77,30 @@ static int __init sh7780_devices_setup(void)
77 ARRAY_SIZE(sh7780_devices)); 77 ARRAY_SIZE(sh7780_devices));
78} 78}
79__initcall(sh7780_devices_setup); 79__initcall(sh7780_devices_setup);
80
81static struct intc2_data intc2_irq_table[] = {
82 { TIMER_IRQ, 0, 24, 0, INTC_TMU0_MSK, 2 },
83 { 21, 1, 0, 0, INTC_RTC_MSK, TIMER_PRIORITY },
84 { 22, 1, 1, 0, INTC_RTC_MSK, TIMER_PRIORITY },
85 { 23, 1, 2, 0, INTC_RTC_MSK, TIMER_PRIORITY },
86 { SCIF0_ERI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY },
87 { SCIF0_RXI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY },
88 { SCIF0_BRI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY },
89 { SCIF0_TXI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY },
90
91 { SCIF1_ERI_IRQ, 8, 16, 0, INTC_SCIF1_MSK, SCIF1_PRIORITY },
92 { SCIF1_RXI_IRQ, 8, 16, 0, INTC_SCIF1_MSK, SCIF1_PRIORITY },
93 { SCIF1_BRI_IRQ, 8, 16, 0, INTC_SCIF1_MSK, SCIF1_PRIORITY },
94 { SCIF1_TXI_IRQ, 8, 16, 0, INTC_SCIF1_MSK, SCIF1_PRIORITY },
95
96 { PCIC0_IRQ, 0x10, 8, 0, INTC_PCIC0_MSK, PCIC0_PRIORITY },
97 { PCIC1_IRQ, 0x10, 0, 0, INTC_PCIC1_MSK, PCIC1_PRIORITY },
98 { PCIC2_IRQ, 0x14, 24, 0, INTC_PCIC2_MSK, PCIC2_PRIORITY },
99 { PCIC3_IRQ, 0x14, 16, 0, INTC_PCIC3_MSK, PCIC3_PRIORITY },
100 { PCIC4_IRQ, 0x14, 8, 0, INTC_PCIC4_MSK, PCIC4_PRIORITY },
101};
102
103void __init init_IRQ_intc2(void)
104{
105 make_intc2_irq(intc2_irq_table, ARRAY_SIZE(intc2_irq_table));
106}
diff --git a/arch/sh/kernel/entry.S b/arch/sh/kernel/entry.S
index 97c571fbcdf1..39aaefb2d83f 100644
--- a/arch/sh/kernel/entry.S
+++ b/arch/sh/kernel/entry.S
@@ -1,9 +1,8 @@
1/* $Id: entry.S,v 1.37 2004/06/11 13:02:46 doyu Exp $ 1/*
2 *
3 * linux/arch/sh/entry.S 2 * linux/arch/sh/entry.S
4 * 3 *
5 * Copyright (C) 1999, 2000, 2002 Niibe Yutaka 4 * Copyright (C) 1999, 2000, 2002 Niibe Yutaka
6 * Copyright (C) 2003 Paul Mundt 5 * Copyright (C) 2003 - 2006 Paul Mundt
7 * 6 *
8 * This file is subject to the terms and conditions of the GNU General Public 7 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive 8 * License. See the file "COPYING" in the main directory of this archive
@@ -78,7 +77,6 @@ OFF_TRA = (16*4+6*4)
78#define k3 r3 77#define k3 r3
79#define k4 r4 78#define k4 r4
80 79
81#define k_ex_code r2_bank /* r2_bank1 */
82#define g_imask r6 /* r6_bank1 */ 80#define g_imask r6 /* r6_bank1 */
83#define k_g_imask r6_bank /* r6_bank1 */ 81#define k_g_imask r6_bank /* r6_bank1 */
84#define current r7 /* r7_bank1 */ 82#define current r7 /* r7_bank1 */
@@ -691,7 +689,7 @@ interrupt:
6910: 6890:
692#endif /* defined(CONFIG_KGDB_NMI) */ 690#endif /* defined(CONFIG_KGDB_NMI) */
693 bra handle_exception 691 bra handle_exception
694 mov.l @k2, k2 692 mov #-1, k2 ! interrupt exception marker
695 693
696 .align 2 694 .align 2
6971: .long EXPEVT 6951: .long EXPEVT
@@ -717,8 +715,7 @@ ENTRY(handle_exception)
717 add current, k1 715 add current, k1
718 mov k1, r15 ! change to kernel stack 716 mov k1, r15 ! change to kernel stack
719 ! 717 !
7201: mov #-1, k4 7181: mov.l 2f, k1
721 mov.l 2f, k1
722 ! 719 !
723#ifdef CONFIG_SH_DSP 720#ifdef CONFIG_SH_DSP
724 mov.l r2, @-r15 ! Save r2, we need another reg 721 mov.l r2, @-r15 ! Save r2, we need another reg
@@ -763,6 +760,8 @@ skip_save:
763#endif 760#endif
764 ! Save the user registers on the stack. 761 ! Save the user registers on the stack.
765 mov.l k2, @-r15 ! EXPEVT 762 mov.l k2, @-r15 ! EXPEVT
763
764 mov #-1, k4
766 mov.l k4, @-r15 ! set TRA (default: -1) 765 mov.l k4, @-r15 ! set TRA (default: -1)
767 ! 766 !
768 sts.l macl, @-r15 767 sts.l macl, @-r15
@@ -797,8 +796,21 @@ skip_save:
797 mov.l r2, @-r15 796 mov.l r2, @-r15
798 mov.l r1, @-r15 797 mov.l r1, @-r15
799 mov.l r0, @-r15 798 mov.l r0, @-r15
800 ! Then, dispatch to the handler, according to the exception code. 799
801 stc k_ex_code, r8 800 /*
801 * This gets a bit tricky.. in the INTEVT case we don't want to use
802 * the VBR offset as a destination in the jump call table, since all
803 * of the destinations are the same. In this case, (interrupt) sets
804 * a marker in r2 (now r2_bank since SR.RB changed), which we check
805 * to determine the exception type. For all other exceptions, we
806 * forcibly read EXPEVT from memory and fix up the jump address, in
807 * the interrupt exception case we jump to do_IRQ() and defer the
808 * INTEVT read until there. As a bonus, we can also clean up the SR.RB
809 * checks that do_IRQ() was doing..
810 */
811 stc r2_bank, r8
812 cmp/pz r8
813 bf interrupt_exception
802 shlr2 r8 814 shlr2 r8
803 shlr r8 815 shlr r8
804 mov.l 4f, r9 816 mov.l 4f, r9
@@ -806,6 +818,8 @@ skip_save:
806 mov.l @r9, r9 818 mov.l @r9, r9
807 jmp @r9 819 jmp @r9
808 nop 820 nop
821 rts
822 nop
809 823
810 .align 2 824 .align 2
8111: .long 0x00001000 ! DSP=1 8251: .long 0x00001000 ! DSP=1
@@ -813,8 +827,17 @@ skip_save:
8133: .long 0xcfffffff ! RB=0, BL=0 8273: .long 0xcfffffff ! RB=0, BL=0
8144: .long exception_handling_table 8284: .long exception_handling_table
815 829
830interrupt_exception:
831 mov.l 1f, r9
832 jmp @r9
833 nop
834 rts
835 nop
836
837 .align 2
8381: .long do_IRQ
839
816 .align 2 840 .align 2
817ENTRY(exception_none) 841ENTRY(exception_none)
818 rts 842 rts
819 nop 843 nop
820
diff --git a/arch/sh/kernel/irq.c b/arch/sh/kernel/irq.c
index c7ebd6aec951..944128ce9706 100644
--- a/arch/sh/kernel/irq.c
+++ b/arch/sh/kernel/irq.c
@@ -11,12 +11,15 @@
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/kernel_stat.h> 12#include <linux/kernel_stat.h>
13#include <linux/seq_file.h> 13#include <linux/seq_file.h>
14#include <linux/io.h>
14#include <asm/irq.h> 15#include <asm/irq.h>
15#include <asm/processor.h> 16#include <asm/processor.h>
16#include <asm/uaccess.h> 17#include <asm/uaccess.h>
17#include <asm/thread_info.h> 18#include <asm/thread_info.h>
18#include <asm/cpu/mmu_context.h> 19#include <asm/cpu/mmu_context.h>
19 20
21atomic_t irq_err_count;
22
20/* 23/*
21 * 'what should we do if we get a hw irq event on an illegal vector'. 24 * 'what should we do if we get a hw irq event on an illegal vector'.
22 * each architecture has to answer this themselves, it doesn't deserve 25 * each architecture has to answer this themselves, it doesn't deserve
@@ -24,6 +27,7 @@
24 */ 27 */
25void ack_bad_irq(unsigned int irq) 28void ack_bad_irq(unsigned int irq)
26{ 29{
30 atomic_inc(&irq_err_count);
27 printk("unexpected IRQ trap at vector %02x\n", irq); 31 printk("unexpected IRQ trap at vector %02x\n", irq);
28} 32}
29 33
@@ -47,8 +51,10 @@ int show_interrupts(struct seq_file *p, void *v)
47 if (!action) 51 if (!action)
48 goto unlock; 52 goto unlock;
49 seq_printf(p, "%3d: ",i); 53 seq_printf(p, "%3d: ",i);
50 seq_printf(p, "%10u ", kstat_irqs(i)); 54 for_each_online_cpu(j)
51 seq_printf(p, " %14s", irq_desc[i].chip->typename); 55 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
56 seq_printf(p, " %14s", irq_desc[i].chip->name);
57 seq_printf(p, "-%-8s", irq_desc[i].name);
52 seq_printf(p, " %s", action->name); 58 seq_printf(p, " %s", action->name);
53 59
54 for (action=action->next; action; action = action->next) 60 for (action=action->next; action; action = action->next)
@@ -56,7 +62,9 @@ int show_interrupts(struct seq_file *p, void *v)
56 seq_putc(p, '\n'); 62 seq_putc(p, '\n');
57unlock: 63unlock:
58 spin_unlock_irqrestore(&irq_desc[i].lock, flags); 64 spin_unlock_irqrestore(&irq_desc[i].lock, flags);
59 } 65 } else if (i == NR_IRQS)
66 seq_printf(p, "Err: %10u\n", atomic_read(&irq_err_count));
67
60 return 0; 68 return 0;
61} 69}
62#endif 70#endif
@@ -78,7 +86,8 @@ asmlinkage int do_IRQ(unsigned long r4, unsigned long r5,
78 unsigned long r6, unsigned long r7, 86 unsigned long r6, unsigned long r7,
79 struct pt_regs regs) 87 struct pt_regs regs)
80{ 88{
81 int irq = r4; 89 struct pt_regs *old_regs = set_irq_regs(&regs);
90 int irq;
82#ifdef CONFIG_4KSTACKS 91#ifdef CONFIG_4KSTACKS
83 union irq_ctx *curctx, *irqctx; 92 union irq_ctx *curctx, *irqctx;
84#endif 93#endif
@@ -102,20 +111,9 @@ asmlinkage int do_IRQ(unsigned long r4, unsigned long r5,
102#endif 111#endif
103 112
104#ifdef CONFIG_CPU_HAS_INTEVT 113#ifdef CONFIG_CPU_HAS_INTEVT
105 __asm__ __volatile__ ( 114 irq = (ctrl_inl(INTEVT) >> 5) - 16;
106#ifdef CONFIG_CPU_HAS_SR_RB
107 "stc r2_bank, %0\n\t"
108#else 115#else
109 "mov.l @%1, %0\n\t" 116 irq = r4;
110#endif
111 "shlr2 %0\n\t"
112 "shlr2 %0\n\t"
113 "shlr %0\n\t"
114 "add #-16, %0\n\t"
115 : "=z" (irq), "=r" (r4)
116 : "1" (INTEVT)
117 : "memory"
118 );
119#endif 117#endif
120 118
121 irq = irq_demux(irq); 119 irq = irq_demux(irq);
@@ -139,25 +137,25 @@ asmlinkage int do_IRQ(unsigned long r4, unsigned long r5,
139 137
140 __asm__ __volatile__ ( 138 __asm__ __volatile__ (
141 "mov %0, r4 \n" 139 "mov %0, r4 \n"
142 "mov %1, r5 \n"
143 "mov r15, r9 \n" 140 "mov r15, r9 \n"
144 "jsr @%2 \n" 141 "jsr @%1 \n"
145 /* swith to the irq stack */ 142 /* swith to the irq stack */
146 " mov %3, r15 \n" 143 " mov %2, r15 \n"
147 /* restore the stack (ring zero) */ 144 /* restore the stack (ring zero) */
148 "mov r9, r15 \n" 145 "mov r9, r15 \n"
149 : /* no outputs */ 146 : /* no outputs */
150 : "r" (irq), "r" (&regs), "r" (__do_IRQ), "r" (isp) 147 : "r" (irq), "r" (generic_handle_irq), "r" (isp)
151 /* XXX: A somewhat excessive clobber list? -PFM */ 148 /* XXX: A somewhat excessive clobber list? -PFM */
152 : "memory", "r0", "r1", "r2", "r3", "r4", 149 : "memory", "r0", "r1", "r2", "r3", "r4",
153 "r5", "r6", "r7", "r8", "t", "pr" 150 "r5", "r6", "r7", "r8", "t", "pr"
154 ); 151 );
155 } else 152 } else
156#endif 153#endif
157 __do_IRQ(irq, &regs); 154 generic_handle_irq(irq);
158 155
159 irq_exit(); 156 irq_exit();
160 157
158 set_irq_regs(old_regs);
161 return 1; 159 return 1;
162} 160}
163 161
diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c
index 0b1d5dd7a93b..a52b13ac6b7f 100644
--- a/arch/sh/kernel/process.c
+++ b/arch/sh/kernel/process.c
@@ -5,6 +5,7 @@
5 * Copyright (C) 1995 Linus Torvalds 5 * Copyright (C) 1995 Linus Torvalds
6 * 6 *
7 * SuperH version: Copyright (C) 1999, 2000 Niibe Yutaka & Kaz Kojima 7 * SuperH version: Copyright (C) 1999, 2000 Niibe Yutaka & Kaz Kojima
8 * Copyright (C) 2006 Lineo Solutions Inc. support SH4A UBC
8 */ 9 */
9 10
10/* 11/*
@@ -104,7 +105,7 @@ void show_regs(struct pt_regs * regs)
104{ 105{
105 printk("\n"); 106 printk("\n");
106 printk("Pid : %d, Comm: %20s\n", current->pid, current->comm); 107 printk("Pid : %d, Comm: %20s\n", current->pid, current->comm);
107 print_symbol("PC is at %s\n", regs->pc); 108 print_symbol("PC is at %s\n", instruction_pointer(regs));
108 printk("PC : %08lx SP : %08lx SR : %08lx ", 109 printk("PC : %08lx SP : %08lx SR : %08lx ",
109 regs->pc, regs->regs[15], regs->sr); 110 regs->pc, regs->regs[15], regs->sr);
110#ifdef CONFIG_MMU 111#ifdef CONFIG_MMU
@@ -129,15 +130,7 @@ void show_regs(struct pt_regs * regs)
129 printk("MACH: %08lx MACL: %08lx GBR : %08lx PR : %08lx\n", 130 printk("MACH: %08lx MACL: %08lx GBR : %08lx PR : %08lx\n",
130 regs->mach, regs->macl, regs->gbr, regs->pr); 131 regs->mach, regs->macl, regs->gbr, regs->pr);
131 132
132 /* 133 show_trace(NULL, (unsigned long *)regs->regs[15], regs);
133 * If we're in kernel mode, dump the stack too..
134 */
135 if (!user_mode(regs)) {
136 extern void show_task(unsigned long *sp);
137 unsigned long sp = regs->regs[15];
138
139 show_task((unsigned long *)sp);
140 }
141} 134}
142 135
143/* 136/*
@@ -290,6 +283,24 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
290static void 283static void
291ubc_set_tracing(int asid, unsigned long pc) 284ubc_set_tracing(int asid, unsigned long pc)
292{ 285{
286#if defined(CONFIG_CPU_SH4A)
287 unsigned long val;
288
289 val = (UBC_CBR_ID_INST | UBC_CBR_RW_READ | UBC_CBR_CE);
290 val |= (UBC_CBR_AIE | UBC_CBR_AIV_SET(asid));
291
292 ctrl_outl(val, UBC_CBR0);
293 ctrl_outl(pc, UBC_CAR0);
294 ctrl_outl(0x0, UBC_CAMR0);
295 ctrl_outl(0x0, UBC_CBCR);
296
297 val = (UBC_CRR_RES | UBC_CRR_PCB | UBC_CRR_BIE);
298 ctrl_outl(val, UBC_CRR0);
299
300 /* Read UBC register that we writed last. For chekking UBC Register changed */
301 val = ctrl_inl(UBC_CRR0);
302
303#else /* CONFIG_CPU_SH4A */
293 ctrl_outl(pc, UBC_BARA); 304 ctrl_outl(pc, UBC_BARA);
294 305
295#ifdef CONFIG_MMU 306#ifdef CONFIG_MMU
@@ -307,6 +318,7 @@ ubc_set_tracing(int asid, unsigned long pc)
307 ctrl_outw(BBR_INST | BBR_READ, UBC_BBRA); 318 ctrl_outw(BBR_INST | BBR_READ, UBC_BBRA);
308 ctrl_outw(BRCR_PCBA, UBC_BRCR); 319 ctrl_outw(BRCR_PCBA, UBC_BRCR);
309 } 320 }
321#endif /* CONFIG_CPU_SH4A */
310} 322}
311 323
312/* 324/*
@@ -359,8 +371,13 @@ struct task_struct *__switch_to(struct task_struct *prev, struct task_struct *ne
359#endif 371#endif
360 ubc_set_tracing(asid, next->thread.ubc_pc); 372 ubc_set_tracing(asid, next->thread.ubc_pc);
361 } else { 373 } else {
374#if defined(CONFIG_CPU_SH4A)
375 ctrl_outl(UBC_CBR_INIT, UBC_CBR0);
376 ctrl_outl(UBC_CRR_INIT, UBC_CRR0);
377#else
362 ctrl_outw(0, UBC_BBRA); 378 ctrl_outw(0, UBC_BBRA);
363 ctrl_outw(0, UBC_BBRB); 379 ctrl_outw(0, UBC_BBRB);
380#endif
364 } 381 }
365 382
366 return prev; 383 return prev;
@@ -460,8 +477,13 @@ asmlinkage void break_point_trap(unsigned long r4, unsigned long r5,
460 struct pt_regs regs) 477 struct pt_regs regs)
461{ 478{
462 /* Clear tracing. */ 479 /* Clear tracing. */
480#if defined(CONFIG_CPU_SH4A)
481 ctrl_outl(UBC_CBR_INIT, UBC_CBR0);
482 ctrl_outl(UBC_CRR_INIT, UBC_CRR0);
483#else
463 ctrl_outw(0, UBC_BBRA); 484 ctrl_outw(0, UBC_BBRA);
464 ctrl_outw(0, UBC_BBRB); 485 ctrl_outw(0, UBC_BBRB);
486#endif
465 current->thread.ubc_pc = 0; 487 current->thread.ubc_pc = 0;
466 ubc_usercnt -= 1; 488 ubc_usercnt -= 1;
467 489
diff --git a/arch/sh/kernel/syscalls.S b/arch/sh/kernel/syscalls.S
index 768334e95075..ca81976e9e34 100644
--- a/arch/sh/kernel/syscalls.S
+++ b/arch/sh/kernel/syscalls.S
@@ -351,3 +351,6 @@ ENTRY(sys_call_table)
351 .long sys_sync_file_range 351 .long sys_sync_file_range
352 .long sys_tee /* 315 */ 352 .long sys_tee /* 315 */
353 .long sys_vmsplice 353 .long sys_vmsplice
354 .long sys_move_pages
355 .long sys_getcpu
356 .long sys_epoll_pwait
diff --git a/arch/sh/kernel/time.c b/arch/sh/kernel/time.c
index 450c68f1df05..57e708d7b52d 100644
--- a/arch/sh/kernel/time.c
+++ b/arch/sh/kernel/time.c
@@ -47,6 +47,7 @@ unsigned long long __attribute__ ((weak)) sched_clock(void)
47 return (unsigned long long)jiffies * (1000000000 / HZ); 47 return (unsigned long long)jiffies * (1000000000 / HZ);
48} 48}
49 49
50#ifndef CONFIG_GENERIC_TIME
50void do_gettimeofday(struct timeval *tv) 51void do_gettimeofday(struct timeval *tv)
51{ 52{
52 unsigned long seq; 53 unsigned long seq;
@@ -99,6 +100,7 @@ int do_settimeofday(struct timespec *tv)
99 return 0; 100 return 0;
100} 101}
101EXPORT_SYMBOL(do_settimeofday); 102EXPORT_SYMBOL(do_settimeofday);
103#endif /* !CONFIG_GENERIC_TIME */
102 104
103/* last time the RTC clock got updated */ 105/* last time the RTC clock got updated */
104static long last_rtc_update; 106static long last_rtc_update;
@@ -107,13 +109,14 @@ static long last_rtc_update;
107 * handle_timer_tick() needs to keep up the real-time clock, 109 * handle_timer_tick() needs to keep up the real-time clock,
108 * as well as call the "do_timer()" routine every clocktick 110 * as well as call the "do_timer()" routine every clocktick
109 */ 111 */
110void handle_timer_tick(struct pt_regs *regs) 112void handle_timer_tick(void)
111{ 113{
112 do_timer(1); 114 do_timer(1);
113#ifndef CONFIG_SMP 115#ifndef CONFIG_SMP
114 update_process_times(user_mode(regs)); 116 update_process_times(user_mode(get_irq_regs()));
115#endif 117#endif
116 profile_tick(CPU_PROFILING, regs); 118 if (current->pid)
119 profile_tick(CPU_PROFILING);
117 120
118#ifdef CONFIG_HEARTBEAT 121#ifdef CONFIG_HEARTBEAT
119 if (sh_mv.mv_heartbeat != NULL) 122 if (sh_mv.mv_heartbeat != NULL)
diff --git a/arch/sh/kernel/timers/timer-tmu.c b/arch/sh/kernel/timers/timer-tmu.c
index 205816fcf0da..24927015dc31 100644
--- a/arch/sh/kernel/timers/timer-tmu.c
+++ b/arch/sh/kernel/timers/timer-tmu.c
@@ -80,8 +80,7 @@ static unsigned long tmu_timer_get_offset(void)
80 return count; 80 return count;
81} 81}
82 82
83static irqreturn_t tmu_timer_interrupt(int irq, void *dev_id, 83static irqreturn_t tmu_timer_interrupt(int irq, void *dummy)
84 struct pt_regs *regs)
85{ 84{
86 unsigned long timer_status; 85 unsigned long timer_status;
87 86
@@ -98,7 +97,7 @@ static irqreturn_t tmu_timer_interrupt(int irq, void *dev_id,
98 * locally disabled. -arca 97 * locally disabled. -arca
99 */ 98 */
100 write_seqlock(&xtime_lock); 99 write_seqlock(&xtime_lock);
101 handle_timer_tick(regs); 100 handle_timer_tick();
102 write_sequnlock(&xtime_lock); 101 write_sequnlock(&xtime_lock);
103 102
104 return IRQ_HANDLED; 103 return IRQ_HANDLED;
@@ -111,60 +110,6 @@ static struct irqaction tmu_irq = {
111 .mask = CPU_MASK_NONE, 110 .mask = CPU_MASK_NONE,
112}; 111};
113 112
114/*
115 * Hah! We'll see if this works (switching from usecs to nsecs).
116 */
117static unsigned long tmu_timer_get_frequency(void)
118{
119 u32 freq;
120 struct timespec ts1, ts2;
121 unsigned long diff_nsec;
122 unsigned long factor;
123
124 /* Setup the timer: We don't want to generate interrupts, just
125 * have it count down at its natural rate.
126 */
127 ctrl_outb(0, TMU_TSTR);
128#if !defined(CONFIG_CPU_SUBTYPE_SH7300) && !defined(CONFIG_CPU_SUBTYPE_SH7760)
129 ctrl_outb(TMU_TOCR_INIT, TMU_TOCR);
130#endif
131 ctrl_outw(TMU0_TCR_CALIB, TMU0_TCR);
132 ctrl_outl(0xffffffff, TMU0_TCOR);
133 ctrl_outl(0xffffffff, TMU0_TCNT);
134
135 rtc_sh_get_time(&ts2);
136
137 do {
138 rtc_sh_get_time(&ts1);
139 } while (ts1.tv_nsec == ts2.tv_nsec && ts1.tv_sec == ts2.tv_sec);
140
141 /* actually start the timer */
142 ctrl_outb(TMU_TSTR_INIT, TMU_TSTR);
143
144 do {
145 rtc_sh_get_time(&ts2);
146 } while (ts1.tv_nsec == ts2.tv_nsec && ts1.tv_sec == ts2.tv_sec);
147
148 freq = 0xffffffff - ctrl_inl(TMU0_TCNT);
149 if (ts2.tv_nsec < ts1.tv_nsec) {
150 ts2.tv_nsec += 1000000000;
151 ts2.tv_sec--;
152 }
153
154 diff_nsec = (ts2.tv_sec - ts1.tv_sec) * 1000000000 + (ts2.tv_nsec - ts1.tv_nsec);
155
156 /* this should work well if the RTC has a precision of n Hz, where
157 * n is an integer. I don't think we have to worry about the other
158 * cases. */
159 factor = (1000000000 + diff_nsec/2) / diff_nsec;
160
161 if (factor * diff_nsec > 1100000000 ||
162 factor * diff_nsec < 900000000)
163 panic("weird RTC (diff_nsec %ld)", diff_nsec);
164
165 return freq * factor;
166}
167
168static void tmu_clk_init(struct clk *clk) 113static void tmu_clk_init(struct clk *clk)
169{ 114{
170 u8 divisor = TMU0_TCR_INIT & 0x7; 115 u8 divisor = TMU0_TCR_INIT & 0x7;
@@ -232,12 +177,12 @@ struct sys_timer_ops tmu_timer_ops = {
232 .init = tmu_timer_init, 177 .init = tmu_timer_init,
233 .start = tmu_timer_start, 178 .start = tmu_timer_start,
234 .stop = tmu_timer_stop, 179 .stop = tmu_timer_stop,
235 .get_frequency = tmu_timer_get_frequency, 180#ifndef CONFIG_GENERIC_TIME
236 .get_offset = tmu_timer_get_offset, 181 .get_offset = tmu_timer_get_offset,
182#endif
237}; 183};
238 184
239struct sys_timer tmu_timer = { 185struct sys_timer tmu_timer = {
240 .name = "tmu", 186 .name = "tmu",
241 .ops = &tmu_timer_ops, 187 .ops = &tmu_timer_ops,
242}; 188};
243
diff --git a/arch/sh/kernel/traps.c b/arch/sh/kernel/traps.c
index c2c597e09482..53dfa55f3156 100644
--- a/arch/sh/kernel/traps.c
+++ b/arch/sh/kernel/traps.c
@@ -1,38 +1,25 @@
1/* $Id: traps.c,v 1.17 2004/05/02 01:46:30 sugioka Exp $ 1/*
2 * 2 * 'traps.c' handles hardware traps and faults after we have saved some
3 * linux/arch/sh/traps.c 3 * state in 'entry.S'.
4 * 4 *
5 * SuperH version: Copyright (C) 1999 Niibe Yutaka 5 * SuperH version: Copyright (C) 1999 Niibe Yutaka
6 * Copyright (C) 2000 Philipp Rumpf 6 * Copyright (C) 2000 Philipp Rumpf
7 * Copyright (C) 2000 David Howells 7 * Copyright (C) 2000 David Howells
8 * Copyright (C) 2002, 2003 Paul Mundt 8 * Copyright (C) 2002 - 2006 Paul Mundt
9 */ 9 *
10 10 * This file is subject to the terms and conditions of the GNU General Public
11/* 11 * License. See the file "COPYING" in the main directory of this archive
12 * 'Traps.c' handles hardware traps and faults after we have saved some 12 * for more details.
13 * state in 'entry.S'.
14 */ 13 */
15#include <linux/sched.h>
16#include <linux/kernel.h> 14#include <linux/kernel.h>
17#include <linux/string.h>
18#include <linux/errno.h>
19#include <linux/ptrace.h> 15#include <linux/ptrace.h>
20#include <linux/timer.h>
21#include <linux/mm.h>
22#include <linux/smp.h>
23#include <linux/smp_lock.h>
24#include <linux/init.h> 16#include <linux/init.h>
25#include <linux/delay.h>
26#include <linux/spinlock.h> 17#include <linux/spinlock.h>
27#include <linux/module.h> 18#include <linux/module.h>
28#include <linux/kallsyms.h> 19#include <linux/kallsyms.h>
29 20#include <linux/io.h>
30#include <asm/system.h> 21#include <asm/system.h>
31#include <asm/uaccess.h> 22#include <asm/uaccess.h>
32#include <asm/io.h>
33#include <asm/atomic.h>
34#include <asm/processor.h>
35#include <asm/sections.h>
36 23
37#ifdef CONFIG_SH_KGDB 24#ifdef CONFIG_SH_KGDB
38#include <asm/kgdb.h> 25#include <asm/kgdb.h>
@@ -53,13 +40,32 @@
53#define TRAP_ILLEGAL_SLOT_INST 13 40#define TRAP_ILLEGAL_SLOT_INST 13
54#endif 41#endif
55 42
56/* 43static void dump_mem(const char *str, unsigned long bottom, unsigned long top)
57 * These constants are for searching for possible module text 44{
58 * segments. VMALLOC_OFFSET comes from mm/vmalloc.c; MODULE_RANGE is 45 unsigned long p;
59 * a guess of how much space is likely to be vmalloced. 46 int i;
60 */ 47
61#define VMALLOC_OFFSET (8*1024*1024) 48 printk("%s(0x%08lx to 0x%08lx)\n", str, bottom, top);
62#define MODULE_RANGE (8*1024*1024) 49
50 for (p = bottom & ~31; p < top; ) {
51 printk("%04lx: ", p & 0xffff);
52
53 for (i = 0; i < 8; i++, p += 4) {
54 unsigned int val;
55
56 if (p < bottom || p >= top)
57 printk(" ");
58 else {
59 if (__get_user(val, (unsigned int __user *)p)) {
60 printk("\n");
61 return;
62 }
63 printk("%08x ", val);
64 }
65 }
66 printk("\n");
67 }
68}
63 69
64DEFINE_SPINLOCK(die_lock); 70DEFINE_SPINLOCK(die_lock);
65 71
@@ -69,14 +75,28 @@ void die(const char * str, struct pt_regs * regs, long err)
69 75
70 console_verbose(); 76 console_verbose();
71 spin_lock_irq(&die_lock); 77 spin_lock_irq(&die_lock);
78 bust_spinlocks(1);
79
72 printk("%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter); 80 printk("%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter);
81
73 CHK_REMOTE_DEBUG(regs); 82 CHK_REMOTE_DEBUG(regs);
83 print_modules();
74 show_regs(regs); 84 show_regs(regs);
85
86 printk("Process: %s (pid: %d, stack limit = %p)\n",
87 current->comm, current->pid, task_stack_page(current) + 1);
88
89 if (!user_mode(regs) || in_interrupt())
90 dump_mem("Stack: ", regs->regs[15], THREAD_SIZE +
91 (unsigned long)task_stack_page(current));
92
93 bust_spinlocks(0);
75 spin_unlock_irq(&die_lock); 94 spin_unlock_irq(&die_lock);
76 do_exit(SIGSEGV); 95 do_exit(SIGSEGV);
77} 96}
78 97
79static inline void die_if_kernel(const char * str, struct pt_regs * regs, long err) 98static inline void die_if_kernel(const char *str, struct pt_regs *regs,
99 long err)
80{ 100{
81 if (!user_mode(regs)) 101 if (!user_mode(regs))
82 die(str, regs, err); 102 die(str, regs, err);
@@ -93,8 +113,7 @@ static int handle_unaligned_notify_count = 10;
93 */ 113 */
94static int die_if_no_fixup(const char * str, struct pt_regs * regs, long err) 114static int die_if_no_fixup(const char * str, struct pt_regs * regs, long err)
95{ 115{
96 if (!user_mode(regs)) 116 if (!user_mode(regs)) {
97 {
98 const struct exception_table_entry *fixup; 117 const struct exception_table_entry *fixup;
99 fixup = search_exception_tables(regs->pc); 118 fixup = search_exception_tables(regs->pc);
100 if (fixup) { 119 if (fixup) {
@@ -550,7 +569,10 @@ int is_dsp_inst(struct pt_regs *regs)
550#define is_dsp_inst(regs) (0) 569#define is_dsp_inst(regs) (0)
551#endif /* CONFIG_SH_DSP */ 570#endif /* CONFIG_SH_DSP */
552 571
553extern int do_fpu_inst(unsigned short, struct pt_regs*); 572/* arch/sh/kernel/cpu/sh4/fpu.c */
573extern int do_fpu_inst(unsigned short, struct pt_regs *);
574extern asmlinkage void do_fpu_state_restore(unsigned long r4, unsigned long r5,
575 unsigned long r6, unsigned long r7, struct pt_regs regs);
554 576
555asmlinkage void do_reserved_inst(unsigned long r4, unsigned long r5, 577asmlinkage void do_reserved_inst(unsigned long r4, unsigned long r5,
556 unsigned long r6, unsigned long r7, 578 unsigned long r6, unsigned long r7,
@@ -709,14 +731,20 @@ void __init per_cpu_trap_init(void)
709 : "memory"); 731 : "memory");
710} 732}
711 733
712void __init trap_init(void) 734void *set_exception_table_vec(unsigned int vec, void *handler)
713{ 735{
714 extern void *exception_handling_table[]; 736 extern void *exception_handling_table[];
737 void *old_handler;
738
739 old_handler = exception_handling_table[vec];
740 exception_handling_table[vec] = handler;
741 return old_handler;
742}
715 743
716 exception_handling_table[TRAP_RESERVED_INST] 744void __init trap_init(void)
717 = (void *)do_reserved_inst; 745{
718 exception_handling_table[TRAP_ILLEGAL_SLOT_INST] 746 set_exception_table_vec(TRAP_RESERVED_INST, do_reserved_inst);
719 = (void *)do_illegal_slot_inst; 747 set_exception_table_vec(TRAP_ILLEGAL_SLOT_INST, do_illegal_slot_inst);
720 748
721#if defined(CONFIG_CPU_SH4) && !defined(CONFIG_SH_FPU) || \ 749#if defined(CONFIG_CPU_SH4) && !defined(CONFIG_SH_FPU) || \
722 defined(CONFIG_SH_FPU_EMU) 750 defined(CONFIG_SH_FPU_EMU)
@@ -725,61 +753,54 @@ void __init trap_init(void)
725 * reserved. They'll be handled in the math-emu case, or faulted on 753 * reserved. They'll be handled in the math-emu case, or faulted on
726 * otherwise. 754 * otherwise.
727 */ 755 */
728 /* entry 64 corresponds to EXPEVT=0x800 */ 756 set_exception_table_evt(0x800, do_reserved_inst);
729 exception_handling_table[64] = (void *)do_reserved_inst; 757 set_exception_table_evt(0x820, do_illegal_slot_inst);
730 exception_handling_table[65] = (void *)do_illegal_slot_inst; 758#elif defined(CONFIG_SH_FPU)
759 set_exception_table_evt(0x800, do_fpu_state_restore);
760 set_exception_table_evt(0x820, do_fpu_state_restore);
731#endif 761#endif
732 762
733 /* Setup VBR for boot cpu */ 763 /* Setup VBR for boot cpu */
734 per_cpu_trap_init(); 764 per_cpu_trap_init();
735} 765}
736 766
737void show_stack(struct task_struct *tsk, unsigned long *sp) 767void show_trace(struct task_struct *tsk, unsigned long *sp,
768 struct pt_regs *regs)
738{ 769{
739 unsigned long *stack, addr; 770 unsigned long addr;
740 unsigned long module_start = VMALLOC_START;
741 unsigned long module_end = VMALLOC_END;
742 int i = 1;
743
744 if (!tsk)
745 tsk = current;
746 if (tsk == current)
747 sp = (unsigned long *)current_stack_pointer;
748 else
749 sp = (unsigned long *)tsk->thread.sp;
750 771
751 stack = sp; 772 if (regs && user_mode(regs))
773 return;
752 774
753 printk("\nCall trace: "); 775 printk("\nCall trace: ");
754#ifdef CONFIG_KALLSYMS 776#ifdef CONFIG_KALLSYMS
755 printk("\n"); 777 printk("\n");
756#endif 778#endif
757 779
758 while (!kstack_end(stack)) { 780 while (!kstack_end(sp)) {
759 addr = *stack++; 781 addr = *sp++;
760 if (((addr >= (unsigned long)_text) && 782 if (kernel_text_address(addr))
761 (addr <= (unsigned long)_etext)) || 783 print_ip_sym(addr);
762 ((addr >= module_start) && (addr <= module_end))) {
763 /*
764 * For 80-columns display, 6 entry is maximum.
765 * NOTE: '[<8c00abcd>] ' consumes 13 columns .
766 */
767#ifndef CONFIG_KALLSYMS
768 if (i && ((i % 6) == 0))
769 printk("\n ");
770#endif
771 printk("[<%08lx>] ", addr);
772 print_symbol("%s\n", addr);
773 i++;
774 }
775 } 784 }
776 785
777 printk("\n"); 786 printk("\n");
778} 787}
779 788
780void show_task(unsigned long *sp) 789void show_stack(struct task_struct *tsk, unsigned long *sp)
781{ 790{
782 show_stack(NULL, sp); 791 unsigned long stack;
792
793 if (!tsk)
794 tsk = current;
795 if (tsk == current)
796 sp = (unsigned long *)current_stack_pointer;
797 else
798 sp = (unsigned long *)tsk->thread.sp;
799
800 stack = (unsigned long)sp;
801 dump_mem("Stack: ", stack, THREAD_SIZE +
802 (unsigned long)task_stack_page(tsk));
803 show_trace(tsk, sp, NULL);
783} 804}
784 805
785void dump_stack(void) 806void dump_stack(void)
diff --git a/arch/sh/kernel/vmlinux.lds.S b/arch/sh/kernel/vmlinux.lds.S
index 5eb930918186..77b4026d5688 100644
--- a/arch/sh/kernel/vmlinux.lds.S
+++ b/arch/sh/kernel/vmlinux.lds.S
@@ -76,13 +76,7 @@ SECTIONS
76 __setup_end = .; 76 __setup_end = .;
77 __initcall_start = .; 77 __initcall_start = .;
78 .initcall.init : { 78 .initcall.init : {
79 *(.initcall1.init) 79 INITCALLS
80 *(.initcall2.init)
81 *(.initcall3.init)
82 *(.initcall4.init)
83 *(.initcall5.init)
84 *(.initcall6.init)
85 *(.initcall7.init)
86 } 80 }
87 __initcall_end = .; 81 __initcall_end = .;
88 __con_initcall_start = .; 82 __con_initcall_start = .;
diff --git a/arch/sh/mm/consistent.c b/arch/sh/mm/consistent.c
index c81e6b67ad30..38c82d890ffd 100644
--- a/arch/sh/mm/consistent.c
+++ b/arch/sh/mm/consistent.c
@@ -28,6 +28,7 @@ void *consistent_alloc(gfp_t gfp, size_t size, dma_addr_t *handle)
28 split_page(page, order); 28 split_page(page, order);
29 29
30 ret = page_address(page); 30 ret = page_address(page);
31 memset(ret, 0, size);
31 *handle = virt_to_phys(ret); 32 *handle = virt_to_phys(ret);
32 33
33 /* 34 /*
diff --git a/arch/sh64/kernel/vmlinux.lds.S b/arch/sh64/kernel/vmlinux.lds.S
index a8fcc3a71585..95c4d753e357 100644
--- a/arch/sh64/kernel/vmlinux.lds.S
+++ b/arch/sh64/kernel/vmlinux.lds.S
@@ -108,13 +108,7 @@ SECTIONS
108 __setup_end = .; 108 __setup_end = .;
109 __initcall_start = .; 109 __initcall_start = .;
110 .initcall.init : C_PHYS(.initcall.init) { 110 .initcall.init : C_PHYS(.initcall.init) {
111 *(.initcall1.init) 111 INITCALLS
112 *(.initcall2.init)
113 *(.initcall3.init)
114 *(.initcall4.init)
115 *(.initcall5.init)
116 *(.initcall6.init)
117 *(.initcall7.init)
118 } 112 }
119 __initcall_end = .; 113 __initcall_end = .;
120 __con_initcall_start = .; 114 __con_initcall_start = .;
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 9431e967aa45..2f96610a83e9 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -289,6 +289,13 @@ endmenu
289 289
290source "fs/Kconfig" 290source "fs/Kconfig"
291 291
292menu "Instrumentation Support"
293 depends on EXPERIMENTAL
294
295source "arch/sparc/oprofile/Kconfig"
296
297endmenu
298
292source "arch/sparc/Kconfig.debug" 299source "arch/sparc/Kconfig.debug"
293 300
294source "security/Kconfig" 301source "security/Kconfig"
diff --git a/arch/sparc/Makefile b/arch/sparc/Makefile
index 4cdbb2d59ed0..f33c3817f014 100644
--- a/arch/sparc/Makefile
+++ b/arch/sparc/Makefile
@@ -30,6 +30,8 @@ HEAD_Y := $(head-y)
30core-y += arch/sparc/kernel/ arch/sparc/mm/ arch/sparc/math-emu/ 30core-y += arch/sparc/kernel/ arch/sparc/mm/ arch/sparc/math-emu/
31libs-y += arch/sparc/prom/ arch/sparc/lib/ 31libs-y += arch/sparc/prom/ arch/sparc/lib/
32 32
33drivers-$(CONFIG_OPROFILE) += arch/sparc/oprofile/
34
33# Export what is needed by arch/sparc/boot/Makefile 35# Export what is needed by arch/sparc/boot/Makefile
34# Renaming is done to avoid confusing pattern matching rules in 2.5.45 (multy-) 36# Renaming is done to avoid confusing pattern matching rules in 2.5.45 (multy-)
35INIT_Y := $(patsubst %/, %/built-in.o, $(init-y)) 37INIT_Y := $(patsubst %/, %/built-in.o, $(init-y))
diff --git a/arch/sparc/kernel/ebus.c b/arch/sparc/kernel/ebus.c
index 75ac24d229b1..ba58c3a061fd 100644
--- a/arch/sparc/kernel/ebus.c
+++ b/arch/sparc/kernel/ebus.c
@@ -237,12 +237,12 @@ void __init fill_ebus_device(struct device_node *dp, struct linux_ebus_device *d
237 dev->ofdev.node = dp; 237 dev->ofdev.node = dp;
238 dev->ofdev.dev.parent = &dev->bus->ofdev.dev; 238 dev->ofdev.dev.parent = &dev->bus->ofdev.dev;
239 dev->ofdev.dev.bus = &ebus_bus_type; 239 dev->ofdev.dev.bus = &ebus_bus_type;
240 strcpy(dev->ofdev.dev.bus_id, dp->path_component_name); 240 sprintf(dev->ofdev.dev.bus_id, "ebus[%08x]", dp->node);
241 241
242 /* Register with core */ 242 /* Register with core */
243 if (of_device_register(&dev->ofdev) != 0) 243 if (of_device_register(&dev->ofdev) != 0)
244 printk(KERN_DEBUG "ebus: device registration error for %s!\n", 244 printk(KERN_DEBUG "ebus: device registration error for %s!\n",
245 dev->ofdev.dev.bus_id); 245 dp->path_component_name);
246 246
247 if ((dp = dp->child) != NULL) { 247 if ((dp = dp->child) != NULL) {
248 dev->children = (struct linux_ebus_child *) 248 dev->children = (struct linux_ebus_child *)
@@ -332,12 +332,12 @@ void __init ebus_init(void)
332 ebus->ofdev.node = dp; 332 ebus->ofdev.node = dp;
333 ebus->ofdev.dev.parent = &pdev->dev; 333 ebus->ofdev.dev.parent = &pdev->dev;
334 ebus->ofdev.dev.bus = &ebus_bus_type; 334 ebus->ofdev.dev.bus = &ebus_bus_type;
335 strcpy(ebus->ofdev.dev.bus_id, dp->path_component_name); 335 sprintf(ebus->ofdev.dev.bus_id, "ebus%d", num_ebus);
336 336
337 /* Register with core */ 337 /* Register with core */
338 if (of_device_register(&ebus->ofdev) != 0) 338 if (of_device_register(&ebus->ofdev) != 0)
339 printk(KERN_DEBUG "ebus: device registration error for %s!\n", 339 printk(KERN_DEBUG "ebus: device registration error for %s!\n",
340 ebus->ofdev.dev.bus_id); 340 dp->path_component_name);
341 341
342 342
343 nd = dp->child; 343 nd = dp->child;
diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
index a4edff4c3be3..831f540251f8 100644
--- a/arch/sparc/kernel/entry.S
+++ b/arch/sparc/kernel/entry.S
@@ -32,13 +32,12 @@
32#include <asm/mxcc.h> 32#include <asm/mxcc.h>
33#include <asm/thread_info.h> 33#include <asm/thread_info.h>
34#include <asm/param.h> 34#include <asm/param.h>
35#include <asm/unistd.h>
35 36
36#include <asm/asmmacro.h> 37#include <asm/asmmacro.h>
37 38
38#define curptr g6 39#define curptr g6
39 40
40#define NR_SYSCALLS 300 /* Each OS is different... */
41
42/* These are just handy. */ 41/* These are just handy. */
43#define _SV save %sp, -STACKFRAME_SZ, %sp 42#define _SV save %sp, -STACKFRAME_SZ, %sp
44#define _RS restore 43#define _RS restore
diff --git a/arch/sparc/kernel/irq.c b/arch/sparc/kernel/irq.c
index b3b6680a2a30..c8cb211b9072 100644
--- a/arch/sparc/kernel/irq.c
+++ b/arch/sparc/kernel/irq.c
@@ -351,7 +351,7 @@ void handler_irq(int irq, struct pt_regs * regs)
351} 351}
352 352
353#ifdef CONFIG_BLK_DEV_FD 353#ifdef CONFIG_BLK_DEV_FD
354extern void floppy_interrupt(int irq, void *dev_id) 354extern void floppy_interrupt(int irq, void *dev_id);
355 355
356void sparc_floppy_irq(int irq, void *dev_id, struct pt_regs *regs) 356void sparc_floppy_irq(int irq, void *dev_id, struct pt_regs *regs)
357{ 357{
diff --git a/arch/sparc/kernel/of_device.c b/arch/sparc/kernel/of_device.c
index 74bef2a2d37f..46200c43ffb1 100644
--- a/arch/sparc/kernel/of_device.c
+++ b/arch/sparc/kernel/of_device.c
@@ -651,7 +651,7 @@ build_resources:
651 if (!parent) 651 if (!parent)
652 strcpy(op->dev.bus_id, "root"); 652 strcpy(op->dev.bus_id, "root");
653 else 653 else
654 strcpy(op->dev.bus_id, dp->path_component_name); 654 sprintf(op->dev.bus_id, "%08x", dp->node);
655 655
656 if (of_device_register(op)) { 656 if (of_device_register(op)) {
657 printk("%s: Could not register of device.\n", 657 printk("%s: Could not register of device.\n",
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
index b4e50ae323bf..207f1b6eef53 100644
--- a/arch/sparc/kernel/pcic.c
+++ b/arch/sparc/kernel/pcic.c
@@ -34,6 +34,7 @@
34#include <asm/pcic.h> 34#include <asm/pcic.h>
35#include <asm/timer.h> 35#include <asm/timer.h>
36#include <asm/uaccess.h> 36#include <asm/uaccess.h>
37#include <asm/irq_regs.h>
37 38
38 39
39unsigned int pcic_pin_to_irq(unsigned int pin, char *name); 40unsigned int pcic_pin_to_irq(unsigned int pin, char *name);
diff --git a/arch/sparc/kernel/setup.c b/arch/sparc/kernel/setup.c
index 0251cab4708b..383526ad94fc 100644
--- a/arch/sparc/kernel/setup.c
+++ b/arch/sparc/kernel/setup.c
@@ -103,7 +103,6 @@ void prom_sync_me(void)
103 103
104unsigned int boot_flags __initdata = 0; 104unsigned int boot_flags __initdata = 0;
105#define BOOTME_DEBUG 0x1 105#define BOOTME_DEBUG 0x1
106#define BOOTME_SINGLE 0x2
107 106
108/* Exported for mm/init.c:paging_init. */ 107/* Exported for mm/init.c:paging_init. */
109unsigned long cmdline_memory_size __initdata = 0; 108unsigned long cmdline_memory_size __initdata = 0;
@@ -121,16 +120,6 @@ static struct console prom_debug_console = {
121 .index = -1, 120 .index = -1,
122}; 121};
123 122
124int obp_system_intr(void)
125{
126 if (boot_flags & BOOTME_DEBUG) {
127 printk("OBP: system interrupted\n");
128 prom_halt();
129 return 1;
130 }
131 return 0;
132}
133
134/* 123/*
135 * Process kernel command line switches that are specific to the 124 * Process kernel command line switches that are specific to the
136 * SPARC or that require special low-level processing. 125 * SPARC or that require special low-level processing.
@@ -142,7 +131,6 @@ static void __init process_switch(char c)
142 boot_flags |= BOOTME_DEBUG; 131 boot_flags |= BOOTME_DEBUG;
143 break; 132 break;
144 case 's': 133 case 's':
145 boot_flags |= BOOTME_SINGLE;
146 break; 134 break;
147 case 'h': 135 case 'h':
148 prom_printf("boot_flags_init: Halt!\n"); 136 prom_printf("boot_flags_init: Halt!\n");
diff --git a/arch/sparc/kernel/systbls.S b/arch/sparc/kernel/systbls.S
index 10df38eeae08..ea75ca569052 100644
--- a/arch/sparc/kernel/systbls.S
+++ b/arch/sparc/kernel/systbls.S
@@ -78,7 +78,7 @@ sys_call_table:
78/*285*/ .long sys_mkdirat, sys_mknodat, sys_fchownat, sys_futimesat, sys_fstatat64 78/*285*/ .long sys_mkdirat, sys_mknodat, sys_fchownat, sys_futimesat, sys_fstatat64
79/*290*/ .long sys_unlinkat, sys_renameat, sys_linkat, sys_symlinkat, sys_readlinkat 79/*290*/ .long sys_unlinkat, sys_renameat, sys_linkat, sys_symlinkat, sys_readlinkat
80/*295*/ .long sys_fchmodat, sys_faccessat, sys_pselect6, sys_ppoll, sys_unshare 80/*295*/ .long sys_fchmodat, sys_faccessat, sys_pselect6, sys_ppoll, sys_unshare
81/*300*/ .long sys_set_robust_list, sys_get_robust_list 81/*300*/ .long sys_set_robust_list, sys_get_robust_list, sys_migrate_pages
82 82
83#ifdef CONFIG_SUNOS_EMUL 83#ifdef CONFIG_SUNOS_EMUL
84 /* Now the SunOS syscall table. */ 84 /* Now the SunOS syscall table. */
@@ -190,6 +190,7 @@ sunos_sys_table:
190/*290*/ .long sunos_nosys, sunos_nosys, sunos_nosys 190/*290*/ .long sunos_nosys, sunos_nosys, sunos_nosys
191 .long sunos_nosys, sunos_nosys, sunos_nosys 191 .long sunos_nosys, sunos_nosys, sunos_nosys
192 .long sunos_nosys, sunos_nosys, sunos_nosys 192 .long sunos_nosys, sunos_nosys, sunos_nosys
193 .long sunos_nosys, sunos_nosys, sunos_nosys 193 .long sunos_nosys
194/*300*/ .long sunos_nosys, sunos_nosys, sunos_nosys
194 195
195#endif 196#endif
diff --git a/arch/sparc/kernel/time.c b/arch/sparc/kernel/time.c
index 7dcd1a16c6e4..6c7aa51b590f 100644
--- a/arch/sparc/kernel/time.c
+++ b/arch/sparc/kernel/time.c
@@ -95,6 +95,8 @@ unsigned long profile_pc(struct pt_regs *regs)
95 return pc; 95 return pc;
96} 96}
97 97
98EXPORT_SYMBOL(profile_pc);
99
98__volatile__ unsigned int *master_l10_counter; 100__volatile__ unsigned int *master_l10_counter;
99__volatile__ unsigned int *master_l10_limit; 101__volatile__ unsigned int *master_l10_limit;
100 102
diff --git a/arch/sparc/kernel/vmlinux.lds.S b/arch/sparc/kernel/vmlinux.lds.S
index 346c19a949fd..5cc5ff7f8824 100644
--- a/arch/sparc/kernel/vmlinux.lds.S
+++ b/arch/sparc/kernel/vmlinux.lds.S
@@ -36,11 +36,11 @@ SECTIONS
36 36
37 . = ALIGN(4096); 37 . = ALIGN(4096);
38 __init_begin = .; 38 __init_begin = .;
39 _sinittext = .;
39 .init.text : { 40 .init.text : {
40 _sinittext = .;
41 *(.init.text) 41 *(.init.text)
42 _einittext = .;
43 } 42 }
43 _einittext = .;
44 __init_text_end = .; 44 __init_text_end = .;
45 .init.data : { *(.init.data) } 45 .init.data : { *(.init.data) }
46 . = ALIGN(16); 46 . = ALIGN(16);
@@ -49,13 +49,7 @@ SECTIONS
49 __setup_end = .; 49 __setup_end = .;
50 __initcall_start = .; 50 __initcall_start = .;
51 .initcall.init : { 51 .initcall.init : {
52 *(.initcall1.init) 52 INITCALLS
53 *(.initcall2.init)
54 *(.initcall3.init)
55 *(.initcall4.init)
56 *(.initcall5.init)
57 *(.initcall6.init)
58 *(.initcall7.init)
59 } 53 }
60 __initcall_end = .; 54 __initcall_end = .;
61 __con_initcall_start = .; 55 __con_initcall_start = .;
diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
index b27a506309ee..0df7121cef07 100644
--- a/arch/sparc/mm/srmmu.c
+++ b/arch/sparc/mm/srmmu.c
@@ -402,7 +402,7 @@ void srmmu_nocache_calcsize(void)
402 srmmu_nocache_end = SRMMU_NOCACHE_VADDR + srmmu_nocache_size; 402 srmmu_nocache_end = SRMMU_NOCACHE_VADDR + srmmu_nocache_size;
403} 403}
404 404
405void srmmu_nocache_init(void) 405void __init srmmu_nocache_init(void)
406{ 406{
407 unsigned int bitmap_bits; 407 unsigned int bitmap_bits;
408 pgd_t *pgd; 408 pgd_t *pgd;
diff --git a/arch/sparc/oprofile/Kconfig b/arch/sparc/oprofile/Kconfig
new file mode 100644
index 000000000000..d8a84088471a
--- /dev/null
+++ b/arch/sparc/oprofile/Kconfig
@@ -0,0 +1,17 @@
1config PROFILING
2 bool "Profiling support (EXPERIMENTAL)"
3 help
4 Say Y here to enable the extended profiling support mechanisms used
5 by profilers such as OProfile.
6
7
8config OPROFILE
9 tristate "OProfile system profiling (EXPERIMENTAL)"
10 depends on PROFILING
11 help
12 OProfile is a profiling system capable of profiling the
13 whole system, include the kernel, kernel modules, libraries,
14 and applications.
15
16 If unsure, say N.
17
diff --git a/arch/sparc/oprofile/Makefile b/arch/sparc/oprofile/Makefile
new file mode 100644
index 000000000000..e9feca1ca28b
--- /dev/null
+++ b/arch/sparc/oprofile/Makefile
@@ -0,0 +1,9 @@
1obj-$(CONFIG_OPROFILE) += oprofile.o
2
3DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \
4 oprof.o cpu_buffer.o buffer_sync.o \
5 event_buffer.o oprofile_files.o \
6 oprofilefs.o oprofile_stats.o \
7 timer_int.o )
8
9oprofile-y := $(DRIVER_OBJS) init.o
diff --git a/arch/sparc/oprofile/init.c b/arch/sparc/oprofile/init.c
new file mode 100644
index 000000000000..9ab815b95b5a
--- /dev/null
+++ b/arch/sparc/oprofile/init.c
@@ -0,0 +1,23 @@
1/**
2 * @file init.c
3 *
4 * @remark Copyright 2002 OProfile authors
5 * @remark Read the file COPYING
6 *
7 * @author John Levon <levon@movementarian.org>
8 */
9
10#include <linux/kernel.h>
11#include <linux/oprofile.h>
12#include <linux/errno.h>
13#include <linux/init.h>
14
15int __init oprofile_arch_init(struct oprofile_operations * ops)
16{
17 return -ENODEV;
18}
19
20
21void oprofile_arch_exit(void)
22{
23}
diff --git a/arch/sparc64/defconfig b/arch/sparc64/defconfig
index dcae559879ae..2f4612fa81f2 100644
--- a/arch/sparc64/defconfig
+++ b/arch/sparc64/defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.19-rc1 3# Linux kernel version: 2.6.19-rc2
4# Thu Oct 5 02:08:41 2006 4# Tue Oct 17 19:29:20 2006
5# 5#
6CONFIG_SPARC=y 6CONFIG_SPARC=y
7CONFIG_SPARC64=y 7CONFIG_SPARC64=y
@@ -217,6 +217,7 @@ CONFIG_INET6_XFRM_MODE_TRANSPORT=m
217CONFIG_INET6_XFRM_MODE_TUNNEL=m 217CONFIG_INET6_XFRM_MODE_TUNNEL=m
218CONFIG_INET6_XFRM_MODE_BEET=m 218CONFIG_INET6_XFRM_MODE_BEET=m
219# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set 219# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
220CONFIG_IPV6_SIT=m
220CONFIG_IPV6_TUNNEL=m 221CONFIG_IPV6_TUNNEL=m
221# CONFIG_IPV6_SUBTREES is not set 222# CONFIG_IPV6_SUBTREES is not set
222# CONFIG_IPV6_MULTIPLE_TABLES is not set 223# CONFIG_IPV6_MULTIPLE_TABLES is not set
@@ -334,6 +335,12 @@ CONFIG_CDROM_PKTCDVD_WCACHE=y
334CONFIG_ATA_OVER_ETH=m 335CONFIG_ATA_OVER_ETH=m
335 336
336# 337#
338# Misc devices
339#
340# CONFIG_SGI_IOC4 is not set
341# CONFIG_TIFM_CORE is not set
342
343#
337# ATA/ATAPI/MFM/RLL support 344# ATA/ATAPI/MFM/RLL support
338# 345#
339CONFIG_IDE=y 346CONFIG_IDE=y
@@ -728,7 +735,6 @@ CONFIG_RTC=y
728# TPM devices 735# TPM devices
729# 736#
730# CONFIG_TCG_TPM is not set 737# CONFIG_TCG_TPM is not set
731# CONFIG_TELCLOCK is not set
732 738
733# 739#
734# I2C support 740# I2C support
@@ -842,11 +848,6 @@ CONFIG_HWMON=y
842# CONFIG_HWMON_DEBUG_CHIP is not set 848# CONFIG_HWMON_DEBUG_CHIP is not set
843 849
844# 850#
845# Misc devices
846#
847# CONFIG_TIFM_CORE is not set
848
849#
850# Multimedia devices 851# Multimedia devices
851# 852#
852# CONFIG_VIDEO_DEV is not set 853# CONFIG_VIDEO_DEV is not set
@@ -1104,7 +1105,6 @@ CONFIG_USB_HIDDEV=y
1104# CONFIG_USB_ATI_REMOTE2 is not set 1105# CONFIG_USB_ATI_REMOTE2 is not set
1105# CONFIG_USB_KEYSPAN_REMOTE is not set 1106# CONFIG_USB_KEYSPAN_REMOTE is not set
1106# CONFIG_USB_APPLETOUCH is not set 1107# CONFIG_USB_APPLETOUCH is not set
1107# CONFIG_USB_TRANCEVIBRATOR is not set
1108 1108
1109# 1109#
1110# USB Imaging devices 1110# USB Imaging devices
@@ -1150,6 +1150,7 @@ CONFIG_USB_HIDDEV=y
1150# CONFIG_USB_APPLEDISPLAY is not set 1150# CONFIG_USB_APPLEDISPLAY is not set
1151# CONFIG_USB_SISUSBVGA is not set 1151# CONFIG_USB_SISUSBVGA is not set
1152# CONFIG_USB_LD is not set 1152# CONFIG_USB_LD is not set
1153# CONFIG_USB_TRANCEVIBRATOR is not set
1153# CONFIG_USB_TEST is not set 1154# CONFIG_USB_TEST is not set
1154 1155
1155# 1156#
@@ -1234,6 +1235,7 @@ CONFIG_EXT3_FS=y
1234CONFIG_EXT3_FS_XATTR=y 1235CONFIG_EXT3_FS_XATTR=y
1235CONFIG_EXT3_FS_POSIX_ACL=y 1236CONFIG_EXT3_FS_POSIX_ACL=y
1236CONFIG_EXT3_FS_SECURITY=y 1237CONFIG_EXT3_FS_SECURITY=y
1238# CONFIG_EXT4DEV_FS is not set
1237CONFIG_JBD=y 1239CONFIG_JBD=y
1238# CONFIG_JBD_DEBUG is not set 1240# CONFIG_JBD_DEBUG is not set
1239CONFIG_FS_MBCACHE=y 1241CONFIG_FS_MBCACHE=y
@@ -1362,10 +1364,6 @@ CONFIG_NLS_DEFAULT="iso8859-1"
1362# CONFIG_NLS_UTF8 is not set 1364# CONFIG_NLS_UTF8 is not set
1363 1365
1364# 1366#
1365# Distributed Lock Manager
1366#
1367
1368#
1369# Instrumentation Support 1367# Instrumentation Support
1370# 1368#
1371CONFIG_PROFILING=y 1369CONFIG_PROFILING=y
@@ -1399,6 +1397,7 @@ CONFIG_DEBUG_FS=y
1399# CONFIG_DEBUG_LIST is not set 1397# CONFIG_DEBUG_LIST is not set
1400# CONFIG_UNWIND_INFO is not set 1398# CONFIG_UNWIND_INFO is not set
1401CONFIG_FORCED_INLINING=y 1399CONFIG_FORCED_INLINING=y
1400# CONFIG_HEADERS_CHECK is not set
1402# CONFIG_RCU_TORTURE_TEST is not set 1401# CONFIG_RCU_TORTURE_TEST is not set
1403# CONFIG_LKDTM is not set 1402# CONFIG_LKDTM is not set
1404# CONFIG_DEBUG_STACK_USAGE is not set 1403# CONFIG_DEBUG_STACK_USAGE is not set
diff --git a/arch/sparc64/kernel/central.c b/arch/sparc64/kernel/central.c
index b66336db00ee..e724c54af029 100644
--- a/arch/sparc64/kernel/central.c
+++ b/arch/sparc64/kernel/central.c
@@ -126,6 +126,10 @@ static void probe_other_fhcs(void)
126 int board; 126 int board;
127 u32 tmp; 127 u32 tmp;
128 128
129 if (dp->parent &&
130 dp->parent->parent != NULL)
131 continue;
132
129 fhc = (struct linux_fhc *) 133 fhc = (struct linux_fhc *)
130 central_alloc_bootmem(sizeof(struct linux_fhc)); 134 central_alloc_bootmem(sizeof(struct linux_fhc));
131 if (fhc == NULL) 135 if (fhc == NULL)
diff --git a/arch/sparc64/kernel/ebus.c b/arch/sparc64/kernel/ebus.c
index 2df25c2b4071..35bf895fdeee 100644
--- a/arch/sparc64/kernel/ebus.c
+++ b/arch/sparc64/kernel/ebus.c
@@ -389,12 +389,12 @@ static void __init fill_ebus_device(struct device_node *dp, struct linux_ebus_de
389 dev->ofdev.node = dp; 389 dev->ofdev.node = dp;
390 dev->ofdev.dev.parent = &dev->bus->ofdev.dev; 390 dev->ofdev.dev.parent = &dev->bus->ofdev.dev;
391 dev->ofdev.dev.bus = &ebus_bus_type; 391 dev->ofdev.dev.bus = &ebus_bus_type;
392 strcpy(dev->ofdev.dev.bus_id, dp->path_component_name); 392 sprintf(dev->ofdev.dev.bus_id, "ebus[%08x]", dp->node);
393 393
394 /* Register with core */ 394 /* Register with core */
395 if (of_device_register(&dev->ofdev) != 0) 395 if (of_device_register(&dev->ofdev) != 0)
396 printk(KERN_DEBUG "ebus: device registration error for %s!\n", 396 printk(KERN_DEBUG "ebus: device registration error for %s!\n",
397 dev->ofdev.dev.bus_id); 397 dp->path_component_name);
398 398
399 dp = dp->child; 399 dp = dp->child;
400 if (dp) { 400 if (dp) {
@@ -494,12 +494,12 @@ void __init ebus_init(void)
494 ebus->ofdev.node = dp; 494 ebus->ofdev.node = dp;
495 ebus->ofdev.dev.parent = &pdev->dev; 495 ebus->ofdev.dev.parent = &pdev->dev;
496 ebus->ofdev.dev.bus = &ebus_bus_type; 496 ebus->ofdev.dev.bus = &ebus_bus_type;
497 strcpy(ebus->ofdev.dev.bus_id, dp->path_component_name); 497 sprintf(ebus->ofdev.dev.bus_id, "ebus%d", num_ebus);
498 498
499 /* Register with core */ 499 /* Register with core */
500 if (of_device_register(&ebus->ofdev) != 0) 500 if (of_device_register(&ebus->ofdev) != 0)
501 printk(KERN_DEBUG "ebus: device registration error for %s!\n", 501 printk(KERN_DEBUG "ebus: device registration error for %s!\n",
502 ebus->ofdev.dev.bus_id); 502 dp->path_component_name);
503 503
504 504
505 child = dp->child; 505 child = dp->child;
diff --git a/arch/sparc64/kernel/entry.S b/arch/sparc64/kernel/entry.S
index 0aaa35fc5a9c..6f28bec0a9bf 100644
--- a/arch/sparc64/kernel/entry.S
+++ b/arch/sparc64/kernel/entry.S
@@ -22,11 +22,10 @@
22#include <asm/auxio.h> 22#include <asm/auxio.h>
23#include <asm/sfafsr.h> 23#include <asm/sfafsr.h>
24#include <asm/pil.h> 24#include <asm/pil.h>
25#include <asm/unistd.h>
25 26
26#define curptr g6 27#define curptr g6
27 28
28#define NR_SYSCALLS 300 /* Each OS is different... */
29
30 .text 29 .text
31 .align 32 30 .align 32
32 31
diff --git a/arch/sparc64/kernel/isa.c b/arch/sparc64/kernel/isa.c
index 0f3aec72ef5f..f028e68b23f2 100644
--- a/arch/sparc64/kernel/isa.c
+++ b/arch/sparc64/kernel/isa.c
@@ -115,12 +115,12 @@ static void __init isa_fill_devices(struct sparc_isa_bridge *isa_br)
115 isa_dev->ofdev.node = dp; 115 isa_dev->ofdev.node = dp;
116 isa_dev->ofdev.dev.parent = &isa_br->ofdev.dev; 116 isa_dev->ofdev.dev.parent = &isa_br->ofdev.dev;
117 isa_dev->ofdev.dev.bus = &isa_bus_type; 117 isa_dev->ofdev.dev.bus = &isa_bus_type;
118 strcpy(isa_dev->ofdev.dev.bus_id, dp->path_component_name); 118 sprintf(isa_dev->ofdev.dev.bus_id, "isa[%08x]", dp->node);
119 119
120 /* Register with core */ 120 /* Register with core */
121 if (of_device_register(&isa_dev->ofdev) != 0) { 121 if (of_device_register(&isa_dev->ofdev) != 0) {
122 printk(KERN_DEBUG "isa: device registration error for %s!\n", 122 printk(KERN_DEBUG "isa: device registration error for %s!\n",
123 isa_dev->ofdev.dev.bus_id); 123 dp->path_component_name);
124 kfree(isa_dev); 124 kfree(isa_dev);
125 goto next_sibling; 125 goto next_sibling;
126 } 126 }
@@ -191,12 +191,12 @@ void __init isa_init(void)
191 isa_br->ofdev.node = dp; 191 isa_br->ofdev.node = dp;
192 isa_br->ofdev.dev.parent = &pdev->dev; 192 isa_br->ofdev.dev.parent = &pdev->dev;
193 isa_br->ofdev.dev.bus = &isa_bus_type; 193 isa_br->ofdev.dev.bus = &isa_bus_type;
194 strcpy(isa_br->ofdev.dev.bus_id, dp->path_component_name); 194 sprintf(isa_br->ofdev.dev.bus_id, "isa%d", index);
195 195
196 /* Register with core */ 196 /* Register with core */
197 if (of_device_register(&isa_br->ofdev) != 0) { 197 if (of_device_register(&isa_br->ofdev) != 0) {
198 printk(KERN_DEBUG "isa: device registration error for %s!\n", 198 printk(KERN_DEBUG "isa: device registration error for %s!\n",
199 isa_br->ofdev.dev.bus_id); 199 dp->path_component_name);
200 kfree(isa_br); 200 kfree(isa_br);
201 return; 201 return;
202 } 202 }
diff --git a/arch/sparc64/kernel/of_device.c b/arch/sparc64/kernel/of_device.c
index d822c7c18e1f..8cc14fc6b6f1 100644
--- a/arch/sparc64/kernel/of_device.c
+++ b/arch/sparc64/kernel/of_device.c
@@ -131,8 +131,13 @@ static int of_device_resume(struct device * dev)
131void __iomem *of_ioremap(struct resource *res, unsigned long offset, unsigned long size, char *name) 131void __iomem *of_ioremap(struct resource *res, unsigned long offset, unsigned long size, char *name)
132{ 132{
133 unsigned long ret = res->start + offset; 133 unsigned long ret = res->start + offset;
134 struct resource *r;
134 135
135 if (!request_region(ret, size, name)) 136 if (res->flags & IORESOURCE_MEM)
137 r = request_mem_region(ret, size, name);
138 else
139 r = request_region(ret, size, name);
140 if (!r)
136 ret = 0; 141 ret = 0;
137 142
138 return (void __iomem *) ret; 143 return (void __iomem *) ret;
@@ -397,16 +402,22 @@ static void of_bus_sbus_count_cells(struct device_node *child,
397 *sizec = 1; 402 *sizec = 1;
398} 403}
399 404
400static int of_bus_sbus_map(u32 *addr, const u32 *range, int na, int ns, int pna) 405/*
401{ 406 * FHC/Central bus specific translator.
402 return of_bus_default_map(addr, range, na, ns, pna); 407 *
403} 408 * This is just needed to hard-code the address and size cell
404 409 * counts. 'fhc' and 'central' nodes lack the #address-cells and
405static unsigned int of_bus_sbus_get_flags(u32 *addr) 410 * #size-cells properties, and if you walk to the root on such
411 * Enterprise boxes all you'll get is a #size-cells of 2 which is
412 * not what we want to use.
413 */
414static int of_bus_fhc_match(struct device_node *np)
406{ 415{
407 return IORESOURCE_MEM; 416 return !strcmp(np->name, "fhc") ||
417 !strcmp(np->name, "central");
408} 418}
409 419
420#define of_bus_fhc_count_cells of_bus_sbus_count_cells
410 421
411/* 422/*
412 * Array of bus specific translators 423 * Array of bus specific translators
@@ -428,8 +439,17 @@ static struct of_bus of_busses[] = {
428 .addr_prop_name = "reg", 439 .addr_prop_name = "reg",
429 .match = of_bus_sbus_match, 440 .match = of_bus_sbus_match,
430 .count_cells = of_bus_sbus_count_cells, 441 .count_cells = of_bus_sbus_count_cells,
431 .map = of_bus_sbus_map, 442 .map = of_bus_default_map,
432 .get_flags = of_bus_sbus_get_flags, 443 .get_flags = of_bus_default_get_flags,
444 },
445 /* FHC */
446 {
447 .name = "fhc",
448 .addr_prop_name = "reg",
449 .match = of_bus_fhc_match,
450 .count_cells = of_bus_fhc_count_cells,
451 .map = of_bus_default_map,
452 .get_flags = of_bus_default_get_flags,
433 }, 453 },
434 /* Default */ 454 /* Default */
435 { 455 {
@@ -841,7 +861,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
841 if (!parent) 861 if (!parent)
842 strcpy(op->dev.bus_id, "root"); 862 strcpy(op->dev.bus_id, "root");
843 else 863 else
844 sprintf(op->dev.bus_id, "%s@%08x", dp->name, dp->node); 864 sprintf(op->dev.bus_id, "%08x", dp->node);
845 865
846 if (of_device_register(op)) { 866 if (of_device_register(op)) {
847 printk("%s: Could not register of device.\n", 867 printk("%s: Could not register of device.\n",
diff --git a/arch/sparc64/kernel/pci_common.c b/arch/sparc64/kernel/pci_common.c
index 7a59cc72c844..827ae30aa497 100644
--- a/arch/sparc64/kernel/pci_common.c
+++ b/arch/sparc64/kernel/pci_common.c
@@ -330,19 +330,6 @@ __init get_device_resource(struct linux_prom_pci_registers *ap,
330 return res; 330 return res;
331} 331}
332 332
333static int __init pdev_resource_collisions_expected(struct pci_dev *pdev)
334{
335 if (pdev->vendor != PCI_VENDOR_ID_SUN)
336 return 0;
337
338 if (pdev->device == PCI_DEVICE_ID_SUN_RIO_EBUS ||
339 pdev->device == PCI_DEVICE_ID_SUN_RIO_1394 ||
340 pdev->device == PCI_DEVICE_ID_SUN_RIO_USB)
341 return 1;
342
343 return 0;
344}
345
346static void __init pdev_record_assignments(struct pci_pbm_info *pbm, 333static void __init pdev_record_assignments(struct pci_pbm_info *pbm,
347 struct pci_dev *pdev) 334 struct pci_dev *pdev)
348{ 335{
@@ -400,19 +387,23 @@ static void __init pdev_record_assignments(struct pci_pbm_info *pbm,
400 pbm->parent->resource_adjust(pdev, res, root); 387 pbm->parent->resource_adjust(pdev, res, root);
401 388
402 if (request_resource(root, res) < 0) { 389 if (request_resource(root, res) < 0) {
390 int rnum;
391
403 /* OK, there is some conflict. But this is fine 392 /* OK, there is some conflict. But this is fine
404 * since we'll reassign it in the fixup pass. 393 * since we'll reassign it in the fixup pass.
405 * 394 *
406 * We notify the user that OBP made an error if it 395 * Do not print the warning for ROM resources
407 * is a case we don't expect. 396 * as such a conflict is quite common and
397 * harmless as the ROM bar is disabled.
408 */ 398 */
409 if (!pdev_resource_collisions_expected(pdev)) { 399 rnum = (res - &pdev->resource[0]);
410 printk(KERN_ERR "PCI: Address space collision on region %ld " 400 if (rnum != PCI_ROM_RESOURCE)
401 printk(KERN_ERR "PCI: Resource collision, "
402 "region %d "
411 "[%016lx:%016lx] of device %s\n", 403 "[%016lx:%016lx] of device %s\n",
412 (res - &pdev->resource[0]), 404 rnum,
413 res->start, res->end, 405 res->start, res->end,
414 pci_name(pdev)); 406 pci_name(pdev));
415 }
416 } 407 }
417 } 408 }
418} 409}
diff --git a/arch/sparc64/kernel/pci_iommu.c b/arch/sparc64/kernel/pci_iommu.c
index 82e5455134c6..2e7f1427088a 100644
--- a/arch/sparc64/kernel/pci_iommu.c
+++ b/arch/sparc64/kernel/pci_iommu.c
@@ -281,7 +281,7 @@ static void pci_4u_free_consistent(struct pci_dev *pdev, size_t size, void *cpu,
281 281
282 spin_lock_irqsave(&iommu->lock, flags); 282 spin_lock_irqsave(&iommu->lock, flags);
283 283
284 free_npages(iommu, dvma, npages); 284 free_npages(iommu, dvma - iommu->page_table_map_base, npages);
285 285
286 spin_unlock_irqrestore(&iommu->lock, flags); 286 spin_unlock_irqrestore(&iommu->lock, flags);
287 287
diff --git a/arch/sparc64/kernel/pci_sabre.c b/arch/sparc64/kernel/pci_sabre.c
index 6ec569828c29..94bb681f2323 100644
--- a/arch/sparc64/kernel/pci_sabre.c
+++ b/arch/sparc64/kernel/pci_sabre.c
@@ -1196,7 +1196,7 @@ static void pbm_register_toplevel_resources(struct pci_controller_info *p,
1196 &pbm->mem_space); 1196 &pbm->mem_space);
1197} 1197}
1198 1198
1199static void sabre_pbm_init(struct pci_controller_info *p, struct device_node *dp, u32 dma_begin) 1199static void sabre_pbm_init(struct pci_controller_info *p, struct device_node *dp, u32 dma_start, u32 dma_end)
1200{ 1200{
1201 struct pci_pbm_info *pbm; 1201 struct pci_pbm_info *pbm;
1202 struct device_node *node; 1202 struct device_node *node;
@@ -1261,6 +1261,8 @@ static void sabre_pbm_init(struct pci_controller_info *p, struct device_node *dp
1261 node = node->sibling; 1261 node = node->sibling;
1262 } 1262 }
1263 if (simbas_found == 0) { 1263 if (simbas_found == 0) {
1264 struct resource *rp;
1265
1264 /* No APBs underneath, probably this is a hummingbird 1266 /* No APBs underneath, probably this is a hummingbird
1265 * system. 1267 * system.
1266 */ 1268 */
@@ -1302,8 +1304,10 @@ static void sabre_pbm_init(struct pci_controller_info *p, struct device_node *dp
1302 pbm->io_space.end = pbm->io_space.start + (1UL << 24) - 1UL; 1304 pbm->io_space.end = pbm->io_space.start + (1UL << 24) - 1UL;
1303 pbm->io_space.flags = IORESOURCE_IO; 1305 pbm->io_space.flags = IORESOURCE_IO;
1304 1306
1305 pbm->mem_space.start = p->pbm_A.controller_regs + SABRE_MEMSPACE; 1307 pbm->mem_space.start =
1306 pbm->mem_space.end = pbm->mem_space.start + (unsigned long)dma_begin - 1UL; 1308 (p->pbm_A.controller_regs + SABRE_MEMSPACE);
1309 pbm->mem_space.end =
1310 (pbm->mem_space.start + ((1UL << 32UL) - 1UL));
1307 pbm->mem_space.flags = IORESOURCE_MEM; 1311 pbm->mem_space.flags = IORESOURCE_MEM;
1308 1312
1309 if (request_resource(&ioport_resource, &pbm->io_space) < 0) { 1313 if (request_resource(&ioport_resource, &pbm->io_space) < 0) {
@@ -1315,6 +1319,17 @@ static void sabre_pbm_init(struct pci_controller_info *p, struct device_node *dp
1315 prom_halt(); 1319 prom_halt();
1316 } 1320 }
1317 1321
1322 rp = kmalloc(sizeof(*rp), GFP_KERNEL);
1323 if (!rp) {
1324 prom_printf("Cannot allocate IOMMU resource.\n");
1325 prom_halt();
1326 }
1327 rp->name = "IOMMU";
1328 rp->start = pbm->mem_space.start + (unsigned long) dma_start;
1329 rp->end = pbm->mem_space.start + (unsigned long) dma_end - 1UL;
1330 rp->flags = IORESOURCE_BUSY;
1331 request_resource(&pbm->mem_space, rp);
1332
1318 pci_register_legacy_regions(&pbm->io_space, 1333 pci_register_legacy_regions(&pbm->io_space,
1319 &pbm->mem_space); 1334 &pbm->mem_space);
1320 } 1335 }
@@ -1450,5 +1465,5 @@ void sabre_init(struct device_node *dp, char *model_name)
1450 /* 1465 /*
1451 * Look for APB underneath. 1466 * Look for APB underneath.
1452 */ 1467 */
1453 sabre_pbm_init(p, dp, vdma[0]); 1468 sabre_pbm_init(p, dp, vdma[0], vdma[0] + vdma[1]);
1454} 1469}
diff --git a/arch/sparc64/kernel/prom.c b/arch/sparc64/kernel/prom.c
index e21cd6afa709..0917c24c4f08 100644
--- a/arch/sparc64/kernel/prom.c
+++ b/arch/sparc64/kernel/prom.c
@@ -793,7 +793,7 @@ static unsigned int schizo_irq_build(struct device_node *dp,
793 return virt_irq; 793 return virt_irq;
794} 794}
795 795
796static void schizo_irq_trans_init(struct device_node *dp) 796static void __schizo_irq_trans_init(struct device_node *dp, int is_tomatillo)
797{ 797{
798 struct linux_prom64_registers *regs; 798 struct linux_prom64_registers *regs;
799 struct schizo_irq_data *irq_data; 799 struct schizo_irq_data *irq_data;
@@ -807,11 +807,24 @@ static void schizo_irq_trans_init(struct device_node *dp)
807 dp->irq_trans->data = irq_data; 807 dp->irq_trans->data = irq_data;
808 808
809 irq_data->pbm_regs = regs[0].phys_addr; 809 irq_data->pbm_regs = regs[0].phys_addr;
810 irq_data->sync_reg = regs[3].phys_addr + 0x1a18UL; 810 if (is_tomatillo)
811 irq_data->sync_reg = regs[3].phys_addr + 0x1a18UL;
812 else
813 irq_data->sync_reg = 0UL;
811 irq_data->portid = of_getintprop_default(dp, "portid", 0); 814 irq_data->portid = of_getintprop_default(dp, "portid", 0);
812 irq_data->chip_version = of_getintprop_default(dp, "version#", 0); 815 irq_data->chip_version = of_getintprop_default(dp, "version#", 0);
813} 816}
814 817
818static void schizo_irq_trans_init(struct device_node *dp)
819{
820 __schizo_irq_trans_init(dp, 0);
821}
822
823static void tomatillo_irq_trans_init(struct device_node *dp)
824{
825 __schizo_irq_trans_init(dp, 1);
826}
827
815static unsigned int pci_sun4v_irq_build(struct device_node *dp, 828static unsigned int pci_sun4v_irq_build(struct device_node *dp,
816 unsigned int devino, 829 unsigned int devino,
817 void *_data) 830 void *_data)
@@ -1050,8 +1063,8 @@ static struct irq_trans pci_irq_trans_table[] = {
1050 { "pci108e,8001", schizo_irq_trans_init }, 1063 { "pci108e,8001", schizo_irq_trans_init },
1051 { "SUNW,schizo+", schizo_irq_trans_init }, 1064 { "SUNW,schizo+", schizo_irq_trans_init },
1052 { "pci108e,8002", schizo_irq_trans_init }, 1065 { "pci108e,8002", schizo_irq_trans_init },
1053 { "SUNW,tomatillo", schizo_irq_trans_init }, 1066 { "SUNW,tomatillo", tomatillo_irq_trans_init },
1054 { "pci108e,a801", schizo_irq_trans_init }, 1067 { "pci108e,a801", tomatillo_irq_trans_init },
1055 { "SUNW,sun4v-pci", pci_sun4v_irq_trans_init }, 1068 { "SUNW,sun4v-pci", pci_sun4v_irq_trans_init },
1056}; 1069};
1057#endif 1070#endif
@@ -1079,23 +1092,22 @@ static void sun4v_vdev_irq_trans_init(struct device_node *dp)
1079 1092
1080static void irq_trans_init(struct device_node *dp) 1093static void irq_trans_init(struct device_node *dp)
1081{ 1094{
1082 const char *model;
1083#ifdef CONFIG_PCI 1095#ifdef CONFIG_PCI
1096 const char *model;
1084 int i; 1097 int i;
1085#endif 1098#endif
1086 1099
1100#ifdef CONFIG_PCI
1087 model = of_get_property(dp, "model", NULL); 1101 model = of_get_property(dp, "model", NULL);
1088 if (!model) 1102 if (!model)
1089 model = of_get_property(dp, "compatible", NULL); 1103 model = of_get_property(dp, "compatible", NULL);
1090 if (!model) 1104 if (model) {
1091 return; 1105 for (i = 0; i < ARRAY_SIZE(pci_irq_trans_table); i++) {
1092 1106 struct irq_trans *t = &pci_irq_trans_table[i];
1093#ifdef CONFIG_PCI
1094 for (i = 0; i < ARRAY_SIZE(pci_irq_trans_table); i++) {
1095 struct irq_trans *t = &pci_irq_trans_table[i];
1096 1107
1097 if (!strcmp(model, t->name)) 1108 if (!strcmp(model, t->name))
1098 return t->init(dp); 1109 return t->init(dp);
1110 }
1099 } 1111 }
1100#endif 1112#endif
1101#ifdef CONFIG_SBUS 1113#ifdef CONFIG_SBUS
@@ -1103,8 +1115,9 @@ static void irq_trans_init(struct device_node *dp)
1103 !strcmp(dp->name, "sbi")) 1115 !strcmp(dp->name, "sbi"))
1104 return sbus_irq_trans_init(dp); 1116 return sbus_irq_trans_init(dp);
1105#endif 1117#endif
1106 if (!strcmp(dp->name, "central")) 1118 if (!strcmp(dp->name, "fhc") &&
1107 return central_irq_trans_init(dp->child); 1119 !strcmp(dp->parent->name, "central"))
1120 return central_irq_trans_init(dp);
1108 if (!strcmp(dp->name, "virtual-devices")) 1121 if (!strcmp(dp->name, "virtual-devices"))
1109 return sun4v_vdev_irq_trans_init(dp); 1122 return sun4v_vdev_irq_trans_init(dp);
1110} 1123}
@@ -1516,7 +1529,7 @@ static char * __init get_one_property(phandle node, const char *name)
1516 return buf; 1529 return buf;
1517} 1530}
1518 1531
1519static struct device_node * __init create_node(phandle node) 1532static struct device_node * __init create_node(phandle node, struct device_node *parent)
1520{ 1533{
1521 struct device_node *dp; 1534 struct device_node *dp;
1522 1535
@@ -1525,6 +1538,7 @@ static struct device_node * __init create_node(phandle node)
1525 1538
1526 dp = prom_early_alloc(sizeof(*dp)); 1539 dp = prom_early_alloc(sizeof(*dp));
1527 dp->unique_id = unique_id++; 1540 dp->unique_id = unique_id++;
1541 dp->parent = parent;
1528 1542
1529 kref_init(&dp->kref); 1543 kref_init(&dp->kref);
1530 1544
@@ -1543,12 +1557,11 @@ static struct device_node * __init build_tree(struct device_node *parent, phandl
1543{ 1557{
1544 struct device_node *dp; 1558 struct device_node *dp;
1545 1559
1546 dp = create_node(node); 1560 dp = create_node(node, parent);
1547 if (dp) { 1561 if (dp) {
1548 *(*nextp) = dp; 1562 *(*nextp) = dp;
1549 *nextp = &dp->allnext; 1563 *nextp = &dp->allnext;
1550 1564
1551 dp->parent = parent;
1552 dp->path_component_name = build_path_component(dp); 1565 dp->path_component_name = build_path_component(dp);
1553 dp->full_name = build_full_name(dp); 1566 dp->full_name = build_full_name(dp);
1554 1567
@@ -1564,7 +1577,7 @@ void __init prom_build_devicetree(void)
1564{ 1577{
1565 struct device_node **nextp; 1578 struct device_node **nextp;
1566 1579
1567 allnodes = create_node(prom_root_node); 1580 allnodes = create_node(prom_root_node, NULL);
1568 allnodes->path_component_name = ""; 1581 allnodes->path_component_name = "";
1569 allnodes->full_name = "/"; 1582 allnodes->full_name = "/";
1570 1583
diff --git a/arch/sparc64/kernel/setup.c b/arch/sparc64/kernel/setup.c
index 958287448cfe..bf033b31d437 100644
--- a/arch/sparc64/kernel/setup.c
+++ b/arch/sparc64/kernel/setup.c
@@ -74,7 +74,6 @@ prom_console_write(struct console *con, const char *s, unsigned n)
74 74
75unsigned int boot_flags = 0; 75unsigned int boot_flags = 0;
76#define BOOTME_DEBUG 0x1 76#define BOOTME_DEBUG 0x1
77#define BOOTME_SINGLE 0x2
78 77
79/* Exported for mm/init.c:paging_init. */ 78/* Exported for mm/init.c:paging_init. */
80unsigned long cmdline_memory_size = 0; 79unsigned long cmdline_memory_size = 0;
@@ -91,16 +90,6 @@ void kernel_enter_debugger(void)
91{ 90{
92} 91}
93 92
94int obp_system_intr(void)
95{
96 if (boot_flags & BOOTME_DEBUG) {
97 printk("OBP: system interrupted\n");
98 prom_halt();
99 return 1;
100 }
101 return 0;
102}
103
104/* 93/*
105 * Process kernel command line switches that are specific to the 94 * Process kernel command line switches that are specific to the
106 * SPARC or that require special low-level processing. 95 * SPARC or that require special low-level processing.
@@ -112,7 +101,6 @@ static void __init process_switch(char c)
112 boot_flags |= BOOTME_DEBUG; 101 boot_flags |= BOOTME_DEBUG;
113 break; 102 break;
114 case 's': 103 case 's':
115 boot_flags |= BOOTME_SINGLE;
116 break; 104 break;
117 case 'h': 105 case 'h':
118 prom_printf("boot_flags_init: Halt!\n"); 106 prom_printf("boot_flags_init: Halt!\n");
diff --git a/arch/sparc64/kernel/systbls.S b/arch/sparc64/kernel/systbls.S
index 419a63fca172..9a8026797ac0 100644
--- a/arch/sparc64/kernel/systbls.S
+++ b/arch/sparc64/kernel/systbls.S
@@ -79,7 +79,7 @@ sys_call_table32:
79 .word sys_mkdirat, sys_mknodat, sys_fchownat, compat_sys_futimesat, compat_sys_fstatat64 79 .word sys_mkdirat, sys_mknodat, sys_fchownat, compat_sys_futimesat, compat_sys_fstatat64
80/*290*/ .word sys_unlinkat, sys_renameat, sys_linkat, sys_symlinkat, sys_readlinkat 80/*290*/ .word sys_unlinkat, sys_renameat, sys_linkat, sys_symlinkat, sys_readlinkat
81 .word sys_fchmodat, sys_faccessat, compat_sys_pselect6, compat_sys_ppoll, sys_unshare 81 .word sys_fchmodat, sys_faccessat, compat_sys_pselect6, compat_sys_ppoll, sys_unshare
82/*300*/ .word compat_sys_set_robust_list, compat_sys_get_robust_list 82/*300*/ .word compat_sys_set_robust_list, compat_sys_get_robust_list, compat_sys_migrate_pages
83 83
84#endif /* CONFIG_COMPAT */ 84#endif /* CONFIG_COMPAT */
85 85
@@ -149,7 +149,7 @@ sys_call_table:
149 .word sys_mkdirat, sys_mknodat, sys_fchownat, sys_futimesat, sys_fstatat64 149 .word sys_mkdirat, sys_mknodat, sys_fchownat, sys_futimesat, sys_fstatat64
150/*290*/ .word sys_unlinkat, sys_renameat, sys_linkat, sys_symlinkat, sys_readlinkat 150/*290*/ .word sys_unlinkat, sys_renameat, sys_linkat, sys_symlinkat, sys_readlinkat
151 .word sys_fchmodat, sys_faccessat, sys_pselect6, sys_ppoll, sys_unshare 151 .word sys_fchmodat, sys_faccessat, sys_pselect6, sys_ppoll, sys_unshare
152/*300*/ .word sys_set_robust_list, sys_get_robust_list 152/*300*/ .word sys_set_robust_list, sys_get_robust_list, sys_migrate_pages
153 153
154#if defined(CONFIG_SUNOS_EMUL) || defined(CONFIG_SOLARIS_EMUL) || \ 154#if defined(CONFIG_SUNOS_EMUL) || defined(CONFIG_SOLARIS_EMUL) || \
155 defined(CONFIG_SOLARIS_EMUL_MODULE) 155 defined(CONFIG_SOLARIS_EMUL_MODULE)
@@ -262,5 +262,7 @@ sunos_sys_table:
262/*290*/ .word sunos_nosys, sunos_nosys, sunos_nosys 262/*290*/ .word sunos_nosys, sunos_nosys, sunos_nosys
263 .word sunos_nosys, sunos_nosys, sunos_nosys 263 .word sunos_nosys, sunos_nosys, sunos_nosys
264 .word sunos_nosys, sunos_nosys, sunos_nosys 264 .word sunos_nosys, sunos_nosys, sunos_nosys
265 .word sunos_nosys, sunos_nosys, sunos_nosys 265 .word sunos_nosys
266/*300*/ .word sunos_nosys, sunos_nosys, sunos_nosys
267
266#endif 268#endif
diff --git a/arch/sparc64/kernel/traps.c b/arch/sparc64/kernel/traps.c
index 68420e2dad0e..fe1796c939c3 100644
--- a/arch/sparc64/kernel/traps.c
+++ b/arch/sparc64/kernel/traps.c
@@ -87,6 +87,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
87 i + 1, 87 i + 1,
88 p->trapstack[i].tstate, p->trapstack[i].tpc, 88 p->trapstack[i].tstate, p->trapstack[i].tpc,
89 p->trapstack[i].tnpc, p->trapstack[i].tt); 89 p->trapstack[i].tnpc, p->trapstack[i].tt);
90 print_symbol("TRAPLOG: TPC<%s>\n", p->trapstack[i].tpc);
90 } 91 }
91} 92}
92 93
@@ -1134,6 +1135,9 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
1134 printk("%s" "ERROR(%d): TPC[%lx] TNPC[%lx] O7[%lx] TSTATE[%lx]\n", 1135 printk("%s" "ERROR(%d): TPC[%lx] TNPC[%lx] O7[%lx] TSTATE[%lx]\n",
1135 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(), 1136 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
1136 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate); 1137 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
1138 printk("%s" "ERROR(%d): ",
1139 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
1140 print_symbol("TPC<%s>\n", regs->tpc);
1137 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n", 1141 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
1138 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(), 1142 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
1139 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT, 1143 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
@@ -1741,6 +1745,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
1741 smp_processor_id(), 1745 smp_processor_id(),
1742 (type & 0x1) ? 'I' : 'D', 1746 (type & 0x1) ? 'I' : 'D',
1743 regs->tpc); 1747 regs->tpc);
1748 print_symbol(KERN_EMERG "TPC<%s>\n", regs->tpc);
1744 panic("Irrecoverable Cheetah+ parity error."); 1749 panic("Irrecoverable Cheetah+ parity error.");
1745 } 1750 }
1746 1751
@@ -1748,6 +1753,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
1748 smp_processor_id(), 1753 smp_processor_id(),
1749 (type & 0x1) ? 'I' : 'D', 1754 (type & 0x1) ? 'I' : 'D',
1750 regs->tpc); 1755 regs->tpc);
1756 print_symbol(KERN_WARNING "TPC<%s>\n", regs->tpc);
1751} 1757}
1752 1758
1753struct sun4v_error_entry { 1759struct sun4v_error_entry {
@@ -1946,6 +1952,7 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
1946 1952
1947 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n", 1953 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
1948 regs->tpc, tl); 1954 regs->tpc, tl);
1955 print_symbol(KERN_EMERG "SUN4V-ITLB: TPC<%s>\n", regs->tpc);
1949 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] " 1956 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
1950 "pte[%lx] error[%lx]\n", 1957 "pte[%lx] error[%lx]\n",
1951 sun4v_err_itlb_vaddr, sun4v_err_itlb_ctx, 1958 sun4v_err_itlb_vaddr, sun4v_err_itlb_ctx,
@@ -1966,6 +1973,7 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
1966 1973
1967 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n", 1974 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
1968 regs->tpc, tl); 1975 regs->tpc, tl);
1976 print_symbol(KERN_EMERG "SUN4V-DTLB: TPC<%s>\n", regs->tpc);
1969 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] " 1977 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
1970 "pte[%lx] error[%lx]\n", 1978 "pte[%lx] error[%lx]\n",
1971 sun4v_err_dtlb_vaddr, sun4v_err_dtlb_ctx, 1979 sun4v_err_dtlb_vaddr, sun4v_err_dtlb_ctx,
diff --git a/arch/sparc64/kernel/vmlinux.lds.S b/arch/sparc64/kernel/vmlinux.lds.S
index b097379a49a8..bd9de8c2a2aa 100644
--- a/arch/sparc64/kernel/vmlinux.lds.S
+++ b/arch/sparc64/kernel/vmlinux.lds.S
@@ -57,13 +57,7 @@ SECTIONS
57 __setup_end = .; 57 __setup_end = .;
58 __initcall_start = .; 58 __initcall_start = .;
59 .initcall.init : { 59 .initcall.init : {
60 *(.initcall1.init) 60 INITCALLS
61 *(.initcall2.init)
62 *(.initcall3.init)
63 *(.initcall4.init)
64 *(.initcall5.init)
65 *(.initcall6.init)
66 *(.initcall7.init)
67 } 61 }
68 __initcall_end = .; 62 __initcall_end = .;
69 __con_initcall_start = .; 63 __con_initcall_start = .;
diff --git a/arch/um/Kconfig b/arch/um/Kconfig
index d75307589d74..5ac1f2963ae3 100644
--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -1,3 +1,8 @@
1config DEFCONFIG_LIST
2 string
3 option defconfig_list
4 default "arch/$ARCH/defconfig"
5
1# UML uses the generic IRQ sugsystem 6# UML uses the generic IRQ sugsystem
2config GENERIC_HARDIRQS 7config GENERIC_HARDIRQS
3 bool 8 bool
@@ -25,6 +30,19 @@ config PCI
25config PCMCIA 30config PCMCIA
26 bool 31 bool
27 32
33# Yet to do!
34config TRACE_IRQFLAGS_SUPPORT
35 bool
36 default n
37
38config LOCKDEP_SUPPORT
39 bool
40 default y
41
42config STACKTRACE_SUPPORT
43 bool
44 default y
45
28config GENERIC_CALIBRATE_DELAY 46config GENERIC_CALIBRATE_DELAY
29 bool 47 bool
30 default y 48 default y
@@ -37,13 +55,16 @@ config IRQ_RELEASE_METHOD
37menu "UML-specific options" 55menu "UML-specific options"
38 56
39config MODE_TT 57config MODE_TT
40 bool "Tracing thread support" 58 bool "Tracing thread support (DEPRECATED)"
41 default n 59 default n
60 depends on BROKEN
42 help 61 help
43 This option controls whether tracing thread support is compiled 62 This option controls whether tracing thread support is compiled
44 into UML. This option is largely obsolete, given that skas0 provides 63 into UML. This option is largely obsolete, given that skas0 provides
45 skas security and performance without needing to patch the host. 64 skas security and performance without needing to patch the host.
46 It is safe to say 'N' here. 65 It is safe to say 'N' here; saying 'Y' may cause additional problems
66 with the resulting binary even if you run UML in SKAS mode, and running
67 in TT mode is strongly *NOT RECOMMENDED*.
47 68
48config STATIC_LINK 69config STATIC_LINK
49 bool "Force a static link" 70 bool "Force a static link"
@@ -56,6 +77,9 @@ config STATIC_LINK
56 for use in a chroot jail. So, if you intend to run UML inside a 77 for use in a chroot jail. So, if you intend to run UML inside a
57 chroot, and you disable CONFIG_MODE_TT, you probably want to say Y 78 chroot, and you disable CONFIG_MODE_TT, you probably want to say Y
58 here. 79 here.
80 Additionally, this option enables using higher memory spaces (up to
81 2.75G) for UML - disabling CONFIG_MODE_TT and enabling this option leads
82 to best results for this.
59 83
60config KERNEL_HALF_GIGS 84config KERNEL_HALF_GIGS
61 int "Kernel address space size (in .5G units)" 85 int "Kernel address space size (in .5G units)"
@@ -72,10 +96,13 @@ config MODE_SKAS
72 default y 96 default y
73 help 97 help
74 This option controls whether skas (separate kernel address space) 98 This option controls whether skas (separate kernel address space)
75 support is compiled in. If you have applied the skas patch to the 99 support is compiled in.
76 host, then you certainly want to say Y here (and consider saying N 100 Unless you have specific needs to use TT mode (which applies almost only
77 to CONFIG_MODE_TT). Otherwise, it is safe to say Y. Disabling this 101 to developers), you should say Y here.
78 option will shrink the UML binary slightly. 102 SKAS mode will make use of the SKAS3 patch if it is applied on the host
103 (and your UML will run in SKAS3 mode), but if no SKAS patch is applied
104 on the host it will run in SKAS0 mode, which is anyway faster than TT
105 mode.
79 106
80source "arch/um/Kconfig.arch" 107source "arch/um/Kconfig.arch"
81source "mm/Kconfig" 108source "mm/Kconfig"
diff --git a/arch/um/Kconfig.char b/arch/um/Kconfig.char
index 62d87b71179b..e03e40c7aac3 100644
--- a/arch/um/Kconfig.char
+++ b/arch/um/Kconfig.char
@@ -190,6 +190,11 @@ config HOSTAUDIO
190 tristate 190 tristate
191 default UML_SOUND 191 default UML_SOUND
192 192
193#It is selected elsewhere, so kconfig would warn without this.
194config HW_RANDOM
195 tristate
196 default n
197
193config UML_RANDOM 198config UML_RANDOM
194 tristate "Hardware random number generator" 199 tristate "Hardware random number generator"
195 help 200 help
diff --git a/arch/um/Kconfig.i386 b/arch/um/Kconfig.i386
index f6eb72d117b9..f191a550a079 100644
--- a/arch/um/Kconfig.i386
+++ b/arch/um/Kconfig.i386
@@ -16,23 +16,42 @@ config SEMAPHORE_SLEEPERS
16 bool 16 bool
17 default y 17 default y
18 18
19config HOST_2G_2G 19choice
20 bool "2G/2G host address space split" 20 prompt "Host memory split"
21 default n 21 default HOST_VMSPLIT_3G
22 help 22 ---help---
23 This is needed when the host on which you run has a 2G/2G memory 23 This is needed when the host kernel on which you run has a non-default
24 split, instead of the customary 3G/1G. 24 (like 2G/2G) memory split, instead of the customary 3G/1G. If you did
25 25 not recompile your own kernel but use the default distro's one, you can
26 Note that to enable such a host 26 safely accept the "Default split" option.
27 configuration, which makes sense only in some cases, you need special 27
28 host patches. 28 It can be enabled on recent (>=2.6.16-rc2) vanilla kernels via
29 29 CONFIG_VM_SPLIT_*, or on previous kernels with special patches (-ck
30 So, if you do not know what to do here, say 'N'. 30 patchset by Con Kolivas, or other ones) - option names match closely the
31 host CONFIG_VM_SPLIT_* ones.
32
33 A lower setting (where 1G/3G is lowest and 3G/1G is higher) will
34 tolerate even more "normal" host kernels, but an higher setting will be
35 stricter.
36
37 So, if you do not know what to do here, say 'Default split'.
38
39 config HOST_VMSPLIT_3G
40 bool "Default split (3G/1G user/kernel host split)"
41 config HOST_VMSPLIT_3G_OPT
42 bool "3G/1G user/kernel host split (for full 1G low memory)"
43 config HOST_VMSPLIT_2G
44 bool "2G/2G user/kernel host split"
45 config HOST_VMSPLIT_1G
46 bool "1G/3G user/kernel host split"
47endchoice
31 48
32config TOP_ADDR 49config TOP_ADDR
33 hex 50 hex
34 default 0xc0000000 if !HOST_2G_2G 51 default 0xB0000000 if HOST_VMSPLIT_3G_OPT
35 default 0x80000000 if HOST_2G_2G 52 default 0x78000000 if HOST_VMSPLIT_2G
53 default 0x40000000 if HOST_VMSPLIT_1G
54 default 0xC0000000
36 55
37config 3_LEVEL_PGTABLES 56config 3_LEVEL_PGTABLES
38 bool "Three-level pagetables (EXPERIMENTAL)" 57 bool "Three-level pagetables (EXPERIMENTAL)"
diff --git a/arch/um/Makefile b/arch/um/Makefile
index c8016a98483b..5d5ed726faa0 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -64,9 +64,14 @@ CFLAGS += $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \
64 64
65AFLAGS += $(ARCH_INCLUDE) 65AFLAGS += $(ARCH_INCLUDE)
66 66
67USER_CFLAGS := $(patsubst -I%,,$(CFLAGS)) 67USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
68USER_CFLAGS := $(patsubst -D__KERNEL__,,$(USER_CFLAGS)) $(ARCH_INCLUDE) \ 68 $(patsubst -I%,,$(CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
69 $(MODE_INCLUDE) -D_FILE_OFFSET_BITS=64 69 -D_FILE_OFFSET_BITS=64
70
71include $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH)
72
73#This will adjust *FLAGS accordingly to the platform.
74include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
70 75
71# -Derrno=kernel_errno - This turns all kernel references to errno into 76# -Derrno=kernel_errno - This turns all kernel references to errno into
72# kernel_errno to separate them from the libc errno. This allows -fno-common 77# kernel_errno to separate them from the libc errno. This allows -fno-common
@@ -74,15 +79,11 @@ USER_CFLAGS := $(patsubst -D__KERNEL__,,$(USER_CFLAGS)) $(ARCH_INCLUDE) \
74# errnos. 79# errnos.
75# These apply to kernelspace only. 80# These apply to kernelspace only.
76 81
77CFLAGS += -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \ 82KERNEL_DEFINES = -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \
78 -Dmktime=kernel_mktime 83 -Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES)
84CFLAGS += $(KERNEL_DEFINES)
79CFLAGS += $(call cc-option,-fno-unit-at-a-time,) 85CFLAGS += $(call cc-option,-fno-unit-at-a-time,)
80 86
81include $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH)
82
83#This will adjust *FLAGS accordingly to the platform.
84include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
85
86# These are needed for clean and mrproper, since in that case .config is not 87# These are needed for clean and mrproper, since in that case .config is not
87# included; the values here are meaningless 88# included; the values here are meaningless
88 89
diff --git a/arch/um/Makefile-i386 b/arch/um/Makefile-i386
index b65ca115ef77..c9f1c5b24c9a 100644
--- a/arch/um/Makefile-i386
+++ b/arch/um/Makefile-i386
@@ -16,7 +16,6 @@ OBJCOPYFLAGS := -O binary -R .note -R .comment -S
16ifeq ("$(origin SUBARCH)", "command line") 16ifeq ("$(origin SUBARCH)", "command line")
17ifneq ("$(shell uname -m | sed -e s/i.86/i386/)", "$(SUBARCH)") 17ifneq ("$(shell uname -m | sed -e s/i.86/i386/)", "$(SUBARCH)")
18CFLAGS += $(call cc-option,-m32) 18CFLAGS += $(call cc-option,-m32)
19USER_CFLAGS += $(call cc-option,-m32)
20AFLAGS += $(call cc-option,-m32) 19AFLAGS += $(call cc-option,-m32)
21LINK-y += $(call cc-option,-m32) 20LINK-y += $(call cc-option,-m32)
22UML_OBJCOPYFLAGS += -F $(ELF_FORMAT) 21UML_OBJCOPYFLAGS += -F $(ELF_FORMAT)
@@ -25,7 +24,7 @@ export LDFLAGS HOSTCFLAGS HOSTLDFLAGS UML_OBJCOPYFLAGS
25endif 24endif
26endif 25endif
27 26
28CFLAGS += -U__$(SUBARCH)__ -U$(SUBARCH) 27ARCH_KERNEL_DEFINES += -U__$(SUBARCH)__ -U$(SUBARCH)
29 28
30# First of all, tune CFLAGS for the specific CPU. This actually sets cflags-y. 29# First of all, tune CFLAGS for the specific CPU. This actually sets cflags-y.
31include $(srctree)/arch/i386/Makefile.cpu 30include $(srctree)/arch/i386/Makefile.cpu
@@ -38,4 +37,3 @@ cflags-y += $(call cc-option,-mpreferred-stack-boundary=2)
38cflags-y += -ffreestanding 37cflags-y += -ffreestanding
39 38
40CFLAGS += $(cflags-y) 39CFLAGS += $(cflags-y)
41USER_CFLAGS += $(cflags-y)
diff --git a/arch/um/Makefile-x86_64 b/arch/um/Makefile-x86_64
index 11154b6773ec..69ecea63fdae 100644
--- a/arch/um/Makefile-x86_64
+++ b/arch/um/Makefile-x86_64
@@ -1,15 +1,15 @@
1# Copyright 2003 - 2004 Pathscale, Inc 1# Copyright 2003 - 2004 Pathscale, Inc
2# Released under the GPL 2# Released under the GPL
3 3
4core-y += arch/um/sys-x86_64/ 4core-y += arch/um/sys-x86_64/ arch/x86_64/crypto/
5START := 0x60000000 5START := 0x60000000
6 6
7_extra_flags_ = -fno-builtin -m64 -mcmodel=kernel 7_extra_flags_ = -fno-builtin -m64
8 8
9#We #undef __x86_64__ for kernelspace, not for userspace where 9#We #undef __x86_64__ for kernelspace, not for userspace where
10#it's needed for headers to work! 10#it's needed for headers to work!
11CFLAGS += -U__$(SUBARCH)__ $(_extra_flags_) 11ARCH_KERNEL_DEFINES = -U__$(SUBARCH)__
12USER_CFLAGS += $(_extra_flags_) 12CFLAGS += $(_extra_flags_)
13 13
14CHECKFLAGS += -m64 14CHECKFLAGS += -m64
15AFLAGS += -m64 15AFLAGS += -m64
diff --git a/arch/um/drivers/cow_sys.h b/arch/um/drivers/cow_sys.h
index 7a5b4afde692..c6a308464acb 100644
--- a/arch/um/drivers/cow_sys.h
+++ b/arch/um/drivers/cow_sys.h
@@ -5,6 +5,7 @@
5#include "user_util.h" 5#include "user_util.h"
6#include "os.h" 6#include "os.h"
7#include "user.h" 7#include "user.h"
8#include "um_malloc.h"
8 9
9static inline void *cow_malloc(int size) 10static inline void *cow_malloc(int size)
10{ 11{
diff --git a/arch/um/drivers/daemon_user.c b/arch/um/drivers/daemon_user.c
index 77954ea77043..310af0f1e49e 100644
--- a/arch/um/drivers/daemon_user.c
+++ b/arch/um/drivers/daemon_user.c
@@ -17,6 +17,7 @@
17#include "user_util.h" 17#include "user_util.h"
18#include "user.h" 18#include "user.h"
19#include "os.h" 19#include "os.h"
20#include "um_malloc.h"
20 21
21#define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER) 22#define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER)
22 23
diff --git a/arch/um/drivers/fd.c b/arch/um/drivers/fd.c
index 108b7dafbd0e..218aa0e9b792 100644
--- a/arch/um/drivers/fd.c
+++ b/arch/um/drivers/fd.c
@@ -12,6 +12,7 @@
12#include "user_util.h" 12#include "user_util.h"
13#include "chan_user.h" 13#include "chan_user.h"
14#include "os.h" 14#include "os.h"
15#include "um_malloc.h"
15 16
16struct fd_chan { 17struct fd_chan {
17 int fd; 18 int fd;
diff --git a/arch/um/drivers/mcast_user.c b/arch/um/drivers/mcast_user.c
index 4d2bd39a85bc..8138f5ea1bf7 100644
--- a/arch/um/drivers/mcast_user.c
+++ b/arch/um/drivers/mcast_user.c
@@ -23,6 +23,7 @@
23#include "user_util.h" 23#include "user_util.h"
24#include "user.h" 24#include "user.h"
25#include "os.h" 25#include "os.h"
26#include "um_malloc.h"
26 27
27#define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER) 28#define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER)
28 29
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index d08bd036ccb8..7b172160fe04 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -79,7 +79,7 @@ static irqreturn_t mconsole_interrupt(int irq, void *dev_id)
79 /* long to avoid size mismatch warnings from gcc */ 79 /* long to avoid size mismatch warnings from gcc */
80 long fd; 80 long fd;
81 struct mconsole_entry *new; 81 struct mconsole_entry *new;
82 struct mc_request req; 82 static struct mc_request req; /* that's OK */
83 83
84 fd = (long) dev_id; 84 fd = (long) dev_id;
85 while (mconsole_get_request(fd, &req)){ 85 while (mconsole_get_request(fd, &req)){
@@ -91,6 +91,7 @@ static irqreturn_t mconsole_interrupt(int irq, void *dev_id)
91 mconsole_reply(&req, "Out of memory", 1, 0); 91 mconsole_reply(&req, "Out of memory", 1, 0);
92 else { 92 else {
93 new->request = req; 93 new->request = req;
94 new->request.regs = get_irq_regs()->regs;
94 list_add(&new->list, &mc_requests); 95 list_add(&new->list, &mc_requests);
95 } 96 }
96 } 97 }
@@ -314,9 +315,21 @@ void mconsole_stop(struct mc_request *req)
314{ 315{
315 deactivate_fd(req->originating_fd, MCONSOLE_IRQ); 316 deactivate_fd(req->originating_fd, MCONSOLE_IRQ);
316 os_set_fd_block(req->originating_fd, 1); 317 os_set_fd_block(req->originating_fd, 1);
317 mconsole_reply(req, "", 0, 0); 318 mconsole_reply(req, "stopped", 0, 0);
318 while(mconsole_get_request(req->originating_fd, req)){ 319 while (mconsole_get_request(req->originating_fd, req)) {
319 if(req->cmd->handler == mconsole_go) break; 320 if (req->cmd->handler == mconsole_go)
321 break;
322 if (req->cmd->handler == mconsole_stop) {
323 mconsole_reply(req, "Already stopped", 1, 0);
324 continue;
325 }
326 if (req->cmd->handler == mconsole_sysrq) {
327 struct pt_regs *old_regs;
328 old_regs = set_irq_regs((struct pt_regs *)&req->regs);
329 mconsole_sysrq(req);
330 set_irq_regs(old_regs);
331 continue;
332 }
320 (*req->cmd->handler)(req); 333 (*req->cmd->handler)(req);
321 } 334 }
322 os_set_fd_block(req->originating_fd, 0); 335 os_set_fd_block(req->originating_fd, 0);
@@ -673,9 +686,7 @@ static void with_console(struct mc_request *req, void (*proc)(void *),
673static void sysrq_proc(void *arg) 686static void sysrq_proc(void *arg)
674{ 687{
675 char *op = arg; 688 char *op = arg;
676 struct pt_regs *old_regs = set_irq_regs(&current->thread.regs);
677 handle_sysrq(*op, NULL); 689 handle_sysrq(*op, NULL);
678 set_irq_regs(old_regs);
679} 690}
680 691
681void mconsole_sysrq(struct mc_request *req) 692void mconsole_sysrq(struct mc_request *req)
diff --git a/arch/um/drivers/mconsole_user.c b/arch/um/drivers/mconsole_user.c
index 17068eb746c0..75aef6f7ef6e 100644
--- a/arch/um/drivers/mconsole_user.c
+++ b/arch/um/drivers/mconsole_user.c
@@ -14,6 +14,7 @@
14#include <sys/un.h> 14#include <sys/un.h>
15#include <unistd.h> 15#include <unistd.h>
16#include "user.h" 16#include "user.h"
17#include "sysdep/ptrace.h"
17#include "mconsole.h" 18#include "mconsole.h"
18#include "umid.h" 19#include "umid.h"
19#include "user_util.h" 20#include "user_util.h"
diff --git a/arch/um/drivers/mmapper_kern.c b/arch/um/drivers/mmapper_kern.c
index 9a3b5daf6250..df3516e47d4d 100644
--- a/arch/um/drivers/mmapper_kern.c
+++ b/arch/um/drivers/mmapper_kern.c
@@ -95,7 +95,8 @@ static const struct file_operations mmapper_fops = {
95 .release = mmapper_release, 95 .release = mmapper_release,
96}; 96};
97 97
98static const struct miscdevice mmapper_dev = { 98/* No locking needed - only used (and modified) by below initcall and exitcall. */
99static struct miscdevice mmapper_dev = {
99 .minor = MISC_DYNAMIC_MINOR, 100 .minor = MISC_DYNAMIC_MINOR,
100 .name = "mmapper", 101 .name = "mmapper",
101 .fops = &mmapper_fops 102 .fops = &mmapper_fops
diff --git a/arch/um/drivers/net_user.c b/arch/um/drivers/net_user.c
index f3a3f8a29c7a..0ffd7ac295d4 100644
--- a/arch/um/drivers/net_user.c
+++ b/arch/um/drivers/net_user.c
@@ -18,6 +18,7 @@
18#include "kern_util.h" 18#include "kern_util.h"
19#include "net_user.h" 19#include "net_user.h"
20#include "os.h" 20#include "os.h"
21#include "um_malloc.h"
21 22
22int tap_open_common(void *dev, char *gate_addr) 23int tap_open_common(void *dev, char *gate_addr)
23{ 24{
diff --git a/arch/um/drivers/pcap_user.c b/arch/um/drivers/pcap_user.c
index 2ef641ded960..11921a7baa7b 100644
--- a/arch/um/drivers/pcap_user.c
+++ b/arch/um/drivers/pcap_user.c
@@ -12,6 +12,7 @@
12#include "net_user.h" 12#include "net_user.h"
13#include "pcap_user.h" 13#include "pcap_user.h"
14#include "user.h" 14#include "user.h"
15#include "um_malloc.h"
15 16
16#define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER) 17#define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER)
17 18
diff --git a/arch/um/drivers/port_user.c b/arch/um/drivers/port_user.c
index f2e8fc42ecc2..bc6afaf74c1a 100644
--- a/arch/um/drivers/port_user.c
+++ b/arch/um/drivers/port_user.c
@@ -19,6 +19,7 @@
19#include "chan_user.h" 19#include "chan_user.h"
20#include "port.h" 20#include "port.h"
21#include "os.h" 21#include "os.h"
22#include "um_malloc.h"
22 23
23struct port_chan { 24struct port_chan {
24 int raw; 25 int raw;
diff --git a/arch/um/drivers/pty.c b/arch/um/drivers/pty.c
index abec620e8380..829a5eca8c07 100644
--- a/arch/um/drivers/pty.c
+++ b/arch/um/drivers/pty.c
@@ -13,6 +13,7 @@
13#include "user_util.h" 13#include "user_util.h"
14#include "kern_util.h" 14#include "kern_util.h"
15#include "os.h" 15#include "os.h"
16#include "um_malloc.h"
16 17
17struct pty_chan { 18struct pty_chan {
18 void (*announce)(char *dev_name, int dev); 19 void (*announce)(char *dev_name, int dev);
diff --git a/arch/um/drivers/slip_user.c b/arch/um/drivers/slip_user.c
index 8460285c69a5..7eddacc53b6e 100644
--- a/arch/um/drivers/slip_user.c
+++ b/arch/um/drivers/slip_user.c
@@ -15,6 +15,7 @@
15#include "slip.h" 15#include "slip.h"
16#include "slip_common.h" 16#include "slip_common.h"
17#include "os.h" 17#include "os.h"
18#include "um_malloc.h"
18 19
19void slip_user_init(void *data, void *dev) 20void slip_user_init(void *data, void *dev)
20{ 21{
diff --git a/arch/um/drivers/tty.c b/arch/um/drivers/tty.c
index 11de3ac1eb5c..d95d64309eaf 100644
--- a/arch/um/drivers/tty.c
+++ b/arch/um/drivers/tty.c
@@ -11,6 +11,7 @@
11#include "user_util.h" 11#include "user_util.h"
12#include "user.h" 12#include "user.h"
13#include "os.h" 13#include "os.h"
14#include "um_malloc.h"
14 15
15struct tty_chan { 16struct tty_chan {
16 char *dev; 17 char *dev;
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index bc458f57921b..49c047b75cc5 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -106,10 +106,15 @@ static inline void ubd_set_bit(__u64 bit, unsigned char *data)
106 106
107#define DRIVER_NAME "uml-blkdev" 107#define DRIVER_NAME "uml-blkdev"
108 108
109/* Can be taken in interrupt context, and is passed to the block layer to lock
110 * the request queue. Kernel side code knows that. */
109static DEFINE_SPINLOCK(ubd_io_lock); 111static DEFINE_SPINLOCK(ubd_io_lock);
110static DEFINE_SPINLOCK(ubd_lock);
111 112
112static void (*do_ubd)(void); 113static DEFINE_MUTEX(ubd_lock);
114
115/* XXX - this made sense in 2.4 days, now it's only used as a boolean, and
116 * probably it doesn't make sense even for that. */
117static int do_ubd;
113 118
114static int ubd_open(struct inode * inode, struct file * filp); 119static int ubd_open(struct inode * inode, struct file * filp);
115static int ubd_release(struct inode * inode, struct file * file); 120static int ubd_release(struct inode * inode, struct file * file);
@@ -117,7 +122,7 @@ static int ubd_ioctl(struct inode * inode, struct file * file,
117 unsigned int cmd, unsigned long arg); 122 unsigned int cmd, unsigned long arg);
118static int ubd_getgeo(struct block_device *bdev, struct hd_geometry *geo); 123static int ubd_getgeo(struct block_device *bdev, struct hd_geometry *geo);
119 124
120#define MAX_DEV (8) 125#define MAX_DEV (16)
121 126
122static struct block_device_operations ubd_blops = { 127static struct block_device_operations ubd_blops = {
123 .owner = THIS_MODULE, 128 .owner = THIS_MODULE,
@@ -150,8 +155,9 @@ static struct gendisk *fake_gendisk[MAX_DEV];
150static struct openflags global_openflags = OPEN_FLAGS; 155static struct openflags global_openflags = OPEN_FLAGS;
151 156
152struct cow { 157struct cow {
153 /* This is the backing file, actually */ 158 /* backing file name */
154 char *file; 159 char *file;
160 /* backing file fd */
155 int fd; 161 int fd;
156 unsigned long *bitmap; 162 unsigned long *bitmap;
157 unsigned long bitmap_len; 163 unsigned long bitmap_len;
@@ -160,14 +166,16 @@ struct cow {
160}; 166};
161 167
162struct ubd { 168struct ubd {
169 /* name (and fd, below) of the file opened for writing, either the
170 * backing or the cow file. */
163 char *file; 171 char *file;
164 int count; 172 int count;
165 int fd; 173 int fd;
166 __u64 size; 174 __u64 size;
167 struct openflags boot_openflags; 175 struct openflags boot_openflags;
168 struct openflags openflags; 176 struct openflags openflags;
169 int shared; 177 unsigned shared:1;
170 int no_cow; 178 unsigned no_cow:1;
171 struct cow cow; 179 struct cow cow;
172 struct platform_device pdev; 180 struct platform_device pdev;
173}; 181};
@@ -192,18 +200,7 @@ struct ubd {
192 .cow = DEFAULT_COW, \ 200 .cow = DEFAULT_COW, \
193} 201}
194 202
195struct ubd ubd_dev[MAX_DEV] = { [ 0 ... MAX_DEV - 1 ] = DEFAULT_UBD }; 203struct ubd ubd_devs[MAX_DEV] = { [ 0 ... MAX_DEV - 1 ] = DEFAULT_UBD };
196
197static int ubd0_init(void)
198{
199 struct ubd *dev = &ubd_dev[0];
200
201 if(dev->file == NULL)
202 dev->file = "root_fs";
203 return(0);
204}
205
206__initcall(ubd0_init);
207 204
208/* Only changed by fake_ide_setup which is a setup */ 205/* Only changed by fake_ide_setup which is a setup */
209static int fake_ide = 0; 206static int fake_ide = 0;
@@ -277,7 +274,7 @@ static int parse_unit(char **ptr)
277 return(-1); 274 return(-1);
278 *ptr = end; 275 *ptr = end;
279 } 276 }
280 else if (('a' <= *str) && (*str <= 'h')) { 277 else if (('a' <= *str) && (*str <= 'z')) {
281 n = *str - 'a'; 278 n = *str - 'a';
282 str++; 279 str++;
283 *ptr = str; 280 *ptr = str;
@@ -285,9 +282,13 @@ static int parse_unit(char **ptr)
285 return(n); 282 return(n);
286} 283}
287 284
285/* If *index_out == -1 at exit, the passed option was a general one;
286 * otherwise, the str pointer is used (and owned) inside ubd_devs array, so it
287 * should not be freed on exit.
288 */
288static int ubd_setup_common(char *str, int *index_out) 289static int ubd_setup_common(char *str, int *index_out)
289{ 290{
290 struct ubd *dev; 291 struct ubd *ubd_dev;
291 struct openflags flags = global_openflags; 292 struct openflags flags = global_openflags;
292 char *backing_file; 293 char *backing_file;
293 int n, err, i; 294 int n, err, i;
@@ -311,7 +312,7 @@ static int ubd_setup_common(char *str, int *index_out)
311 } 312 }
312 313
313 err = 1; 314 err = 1;
314 spin_lock(&ubd_lock); 315 mutex_lock(&ubd_lock);
315 if(fake_major != MAJOR_NR){ 316 if(fake_major != MAJOR_NR){
316 printk(KERN_ERR "Can't assign a fake major twice\n"); 317 printk(KERN_ERR "Can't assign a fake major twice\n");
317 goto out1; 318 goto out1;
@@ -323,7 +324,7 @@ static int ubd_setup_common(char *str, int *index_out)
323 major); 324 major);
324 err = 0; 325 err = 0;
325 out1: 326 out1:
326 spin_unlock(&ubd_lock); 327 mutex_unlock(&ubd_lock);
327 return(err); 328 return(err);
328 } 329 }
329 330
@@ -340,10 +341,10 @@ static int ubd_setup_common(char *str, int *index_out)
340 } 341 }
341 342
342 err = 1; 343 err = 1;
343 spin_lock(&ubd_lock); 344 mutex_lock(&ubd_lock);
344 345
345 dev = &ubd_dev[n]; 346 ubd_dev = &ubd_devs[n];
346 if(dev->file != NULL){ 347 if(ubd_dev->file != NULL){
347 printk(KERN_ERR "ubd_setup : device already configured\n"); 348 printk(KERN_ERR "ubd_setup : device already configured\n");
348 goto out; 349 goto out;
349 } 350 }
@@ -360,10 +361,10 @@ static int ubd_setup_common(char *str, int *index_out)
360 flags.s = 1; 361 flags.s = 1;
361 break; 362 break;
362 case 'd': 363 case 'd':
363 dev->no_cow = 1; 364 ubd_dev->no_cow = 1;
364 break; 365 break;
365 case 'c': 366 case 'c':
366 dev->shared = 1; 367 ubd_dev->shared = 1;
367 break; 368 break;
368 case '=': 369 case '=':
369 str++; 370 str++;
@@ -390,7 +391,7 @@ break_loop:
390 } 391 }
391 392
392 if(backing_file){ 393 if(backing_file){
393 if(dev->no_cow) 394 if(ubd_dev->no_cow)
394 printk(KERN_ERR "Can't specify both 'd' and a " 395 printk(KERN_ERR "Can't specify both 'd' and a "
395 "cow file\n"); 396 "cow file\n");
396 else { 397 else {
@@ -398,11 +399,11 @@ break_loop:
398 backing_file++; 399 backing_file++;
399 } 400 }
400 } 401 }
401 dev->file = str; 402 ubd_dev->file = str;
402 dev->cow.file = backing_file; 403 ubd_dev->cow.file = backing_file;
403 dev->boot_openflags = flags; 404 ubd_dev->boot_openflags = flags;
404out: 405out:
405 spin_unlock(&ubd_lock); 406 mutex_unlock(&ubd_lock);
406 return(err); 407 return(err);
407} 408}
408 409
@@ -472,8 +473,9 @@ int thread_fd = -1;
472 473
473/* Changed by ubd_handler, which is serialized because interrupts only 474/* Changed by ubd_handler, which is serialized because interrupts only
474 * happen on CPU 0. 475 * happen on CPU 0.
476 * XXX: currently unused.
475 */ 477 */
476int intr_count = 0; 478static int intr_count = 0;
477 479
478/* call ubd_finish if you need to serialize */ 480/* call ubd_finish if you need to serialize */
479static void __ubd_finish(struct request *req, int error) 481static void __ubd_finish(struct request *req, int error)
@@ -493,6 +495,8 @@ static void __ubd_finish(struct request *req, int error)
493 end_request(req, 1); 495 end_request(req, 1);
494} 496}
495 497
498/* Callable only from interrupt context - otherwise you need to do
499 * spin_lock_irq()/spin_lock_irqsave() */
496static inline void ubd_finish(struct request *req, int error) 500static inline void ubd_finish(struct request *req, int error)
497{ 501{
498 spin_lock(&ubd_io_lock); 502 spin_lock(&ubd_io_lock);
@@ -500,14 +504,15 @@ static inline void ubd_finish(struct request *req, int error)
500 spin_unlock(&ubd_io_lock); 504 spin_unlock(&ubd_io_lock);
501} 505}
502 506
503/* Called without ubd_io_lock held */ 507/* XXX - move this inside ubd_intr. */
508/* Called without ubd_io_lock held, and only in interrupt context. */
504static void ubd_handler(void) 509static void ubd_handler(void)
505{ 510{
506 struct io_thread_req req; 511 struct io_thread_req req;
507 struct request *rq = elv_next_request(ubd_queue); 512 struct request *rq = elv_next_request(ubd_queue);
508 int n; 513 int n;
509 514
510 do_ubd = NULL; 515 do_ubd = 0;
511 intr_count++; 516 intr_count++;
512 n = os_read_file(thread_fd, &req, sizeof(req)); 517 n = os_read_file(thread_fd, &req, sizeof(req));
513 if(n != sizeof(req)){ 518 if(n != sizeof(req)){
@@ -521,7 +526,9 @@ static void ubd_handler(void)
521 526
522 ubd_finish(rq, req.error); 527 ubd_finish(rq, req.error);
523 reactivate_fd(thread_fd, UBD_IRQ); 528 reactivate_fd(thread_fd, UBD_IRQ);
529 spin_lock(&ubd_io_lock);
524 do_ubd_request(ubd_queue); 530 do_ubd_request(ubd_queue);
531 spin_unlock(&ubd_io_lock);
525} 532}
526 533
527static irqreturn_t ubd_intr(int irq, void *dev) 534static irqreturn_t ubd_intr(int irq, void *dev)
@@ -541,87 +548,90 @@ void kill_io_thread(void)
541 548
542__uml_exitcall(kill_io_thread); 549__uml_exitcall(kill_io_thread);
543 550
544static int ubd_file_size(struct ubd *dev, __u64 *size_out) 551static inline int ubd_file_size(struct ubd *ubd_dev, __u64 *size_out)
545{ 552{
546 char *file; 553 char *file;
547 554
548 file = dev->cow.file ? dev->cow.file : dev->file; 555 file = ubd_dev->cow.file ? ubd_dev->cow.file : ubd_dev->file;
549 return(os_file_size(file, size_out)); 556 return(os_file_size(file, size_out));
550} 557}
551 558
552static void ubd_close(struct ubd *dev) 559static void ubd_close_dev(struct ubd *ubd_dev)
553{ 560{
554 os_close_file(dev->fd); 561 os_close_file(ubd_dev->fd);
555 if(dev->cow.file == NULL) 562 if(ubd_dev->cow.file == NULL)
556 return; 563 return;
557 564
558 os_close_file(dev->cow.fd); 565 os_close_file(ubd_dev->cow.fd);
559 vfree(dev->cow.bitmap); 566 vfree(ubd_dev->cow.bitmap);
560 dev->cow.bitmap = NULL; 567 ubd_dev->cow.bitmap = NULL;
561} 568}
562 569
563static int ubd_open_dev(struct ubd *dev) 570static int ubd_open_dev(struct ubd *ubd_dev)
564{ 571{
565 struct openflags flags; 572 struct openflags flags;
566 char **back_ptr; 573 char **back_ptr;
567 int err, create_cow, *create_ptr; 574 int err, create_cow, *create_ptr;
575 int fd;
568 576
569 dev->openflags = dev->boot_openflags; 577 ubd_dev->openflags = ubd_dev->boot_openflags;
570 create_cow = 0; 578 create_cow = 0;
571 create_ptr = (dev->cow.file != NULL) ? &create_cow : NULL; 579 create_ptr = (ubd_dev->cow.file != NULL) ? &create_cow : NULL;
572 back_ptr = dev->no_cow ? NULL : &dev->cow.file; 580 back_ptr = ubd_dev->no_cow ? NULL : &ubd_dev->cow.file;
573 dev->fd = open_ubd_file(dev->file, &dev->openflags, dev->shared, 581
574 back_ptr, &dev->cow.bitmap_offset, 582 fd = open_ubd_file(ubd_dev->file, &ubd_dev->openflags, ubd_dev->shared,
575 &dev->cow.bitmap_len, &dev->cow.data_offset, 583 back_ptr, &ubd_dev->cow.bitmap_offset,
584 &ubd_dev->cow.bitmap_len, &ubd_dev->cow.data_offset,
576 create_ptr); 585 create_ptr);
577 586
578 if((dev->fd == -ENOENT) && create_cow){ 587 if((fd == -ENOENT) && create_cow){
579 dev->fd = create_cow_file(dev->file, dev->cow.file, 588 fd = create_cow_file(ubd_dev->file, ubd_dev->cow.file,
580 dev->openflags, 1 << 9, PAGE_SIZE, 589 ubd_dev->openflags, 1 << 9, PAGE_SIZE,
581 &dev->cow.bitmap_offset, 590 &ubd_dev->cow.bitmap_offset,
582 &dev->cow.bitmap_len, 591 &ubd_dev->cow.bitmap_len,
583 &dev->cow.data_offset); 592 &ubd_dev->cow.data_offset);
584 if(dev->fd >= 0){ 593 if(fd >= 0){
585 printk(KERN_INFO "Creating \"%s\" as COW file for " 594 printk(KERN_INFO "Creating \"%s\" as COW file for "
586 "\"%s\"\n", dev->file, dev->cow.file); 595 "\"%s\"\n", ubd_dev->file, ubd_dev->cow.file);
587 } 596 }
588 } 597 }
589 598
590 if(dev->fd < 0){ 599 if(fd < 0){
591 printk("Failed to open '%s', errno = %d\n", dev->file, 600 printk("Failed to open '%s', errno = %d\n", ubd_dev->file,
592 -dev->fd); 601 -fd);
593 return(dev->fd); 602 return fd;
594 } 603 }
604 ubd_dev->fd = fd;
595 605
596 if(dev->cow.file != NULL){ 606 if(ubd_dev->cow.file != NULL){
597 err = -ENOMEM; 607 err = -ENOMEM;
598 dev->cow.bitmap = (void *) vmalloc(dev->cow.bitmap_len); 608 ubd_dev->cow.bitmap = (void *) vmalloc(ubd_dev->cow.bitmap_len);
599 if(dev->cow.bitmap == NULL){ 609 if(ubd_dev->cow.bitmap == NULL){
600 printk(KERN_ERR "Failed to vmalloc COW bitmap\n"); 610 printk(KERN_ERR "Failed to vmalloc COW bitmap\n");
601 goto error; 611 goto error;
602 } 612 }
603 flush_tlb_kernel_vm(); 613 flush_tlb_kernel_vm();
604 614
605 err = read_cow_bitmap(dev->fd, dev->cow.bitmap, 615 err = read_cow_bitmap(ubd_dev->fd, ubd_dev->cow.bitmap,
606 dev->cow.bitmap_offset, 616 ubd_dev->cow.bitmap_offset,
607 dev->cow.bitmap_len); 617 ubd_dev->cow.bitmap_len);
608 if(err < 0) 618 if(err < 0)
609 goto error; 619 goto error;
610 620
611 flags = dev->openflags; 621 flags = ubd_dev->openflags;
612 flags.w = 0; 622 flags.w = 0;
613 err = open_ubd_file(dev->cow.file, &flags, dev->shared, NULL, 623 err = open_ubd_file(ubd_dev->cow.file, &flags, ubd_dev->shared, NULL,
614 NULL, NULL, NULL, NULL); 624 NULL, NULL, NULL, NULL);
615 if(err < 0) goto error; 625 if(err < 0) goto error;
616 dev->cow.fd = err; 626 ubd_dev->cow.fd = err;
617 } 627 }
618 return(0); 628 return(0);
619 error: 629 error:
620 os_close_file(dev->fd); 630 os_close_file(ubd_dev->fd);
621 return(err); 631 return(err);
622} 632}
623 633
624static int ubd_new_disk(int major, u64 size, int unit, 634static int ubd_disk_register(int major, u64 size, int unit,
625 struct gendisk **disk_out) 635 struct gendisk **disk_out)
626 636
627{ 637{
@@ -642,13 +652,13 @@ static int ubd_new_disk(int major, u64 size, int unit,
642 652
643 /* sysfs register (not for ide fake devices) */ 653 /* sysfs register (not for ide fake devices) */
644 if (major == MAJOR_NR) { 654 if (major == MAJOR_NR) {
645 ubd_dev[unit].pdev.id = unit; 655 ubd_devs[unit].pdev.id = unit;
646 ubd_dev[unit].pdev.name = DRIVER_NAME; 656 ubd_devs[unit].pdev.name = DRIVER_NAME;
647 platform_device_register(&ubd_dev[unit].pdev); 657 platform_device_register(&ubd_devs[unit].pdev);
648 disk->driverfs_dev = &ubd_dev[unit].pdev.dev; 658 disk->driverfs_dev = &ubd_devs[unit].pdev.dev;
649 } 659 }
650 660
651 disk->private_data = &ubd_dev[unit]; 661 disk->private_data = &ubd_devs[unit];
652 disk->queue = ubd_queue; 662 disk->queue = ubd_queue;
653 add_disk(disk); 663 add_disk(disk);
654 664
@@ -660,25 +670,25 @@ static int ubd_new_disk(int major, u64 size, int unit,
660 670
661static int ubd_add(int n) 671static int ubd_add(int n)
662{ 672{
663 struct ubd *dev = &ubd_dev[n]; 673 struct ubd *ubd_dev = &ubd_devs[n];
664 int err; 674 int err;
665 675
666 err = -ENODEV; 676 err = -ENODEV;
667 if(dev->file == NULL) 677 if(ubd_dev->file == NULL)
668 goto out; 678 goto out;
669 679
670 err = ubd_file_size(dev, &dev->size); 680 err = ubd_file_size(ubd_dev, &ubd_dev->size);
671 if(err < 0) 681 if(err < 0)
672 goto out; 682 goto out;
673 683
674 dev->size = ROUND_BLOCK(dev->size); 684 ubd_dev->size = ROUND_BLOCK(ubd_dev->size);
675 685
676 err = ubd_new_disk(MAJOR_NR, dev->size, n, &ubd_gendisk[n]); 686 err = ubd_disk_register(MAJOR_NR, ubd_dev->size, n, &ubd_gendisk[n]);
677 if(err) 687 if(err)
678 goto out; 688 goto out;
679 689
680 if(fake_major != MAJOR_NR) 690 if(fake_major != MAJOR_NR)
681 ubd_new_disk(fake_major, dev->size, n, 691 ubd_disk_register(fake_major, ubd_dev->size, n,
682 &fake_gendisk[n]); 692 &fake_gendisk[n]);
683 693
684 /* perhaps this should also be under the "if (fake_major)" above */ 694 /* perhaps this should also be under the "if (fake_major)" above */
@@ -693,32 +703,41 @@ out:
693 703
694static int ubd_config(char *str) 704static int ubd_config(char *str)
695{ 705{
696 int n, err; 706 int n, ret;
697 707
698 str = kstrdup(str, GFP_KERNEL); 708 str = kstrdup(str, GFP_KERNEL);
699 if(str == NULL){ 709 if (str == NULL) {
700 printk(KERN_ERR "ubd_config failed to strdup string\n"); 710 printk(KERN_ERR "ubd_config failed to strdup string\n");
701 return(1); 711 ret = 1;
712 goto out;
702 } 713 }
703 err = ubd_setup_common(str, &n); 714 ret = ubd_setup_common(str, &n);
704 if(err){ 715 if (ret) {
705 kfree(str); 716 ret = -1;
706 return(-1); 717 goto err_free;
718 }
719 if (n == -1) {
720 ret = 0;
721 goto err_free;
707 } 722 }
708 if(n == -1) return(0);
709 723
710 spin_lock(&ubd_lock); 724 mutex_lock(&ubd_lock);
711 err = ubd_add(n); 725 ret = ubd_add(n);
712 if(err) 726 if (ret)
713 ubd_dev[n].file = NULL; 727 ubd_devs[n].file = NULL;
714 spin_unlock(&ubd_lock); 728 mutex_unlock(&ubd_lock);
715 729
716 return(err); 730out:
731 return ret;
732
733err_free:
734 kfree(str);
735 goto out;
717} 736}
718 737
719static int ubd_get_config(char *name, char *str, int size, char **error_out) 738static int ubd_get_config(char *name, char *str, int size, char **error_out)
720{ 739{
721 struct ubd *dev; 740 struct ubd *ubd_dev;
722 int n, len = 0; 741 int n, len = 0;
723 742
724 n = parse_unit(&name); 743 n = parse_unit(&name);
@@ -727,24 +746,24 @@ static int ubd_get_config(char *name, char *str, int size, char **error_out)
727 return(-1); 746 return(-1);
728 } 747 }
729 748
730 dev = &ubd_dev[n]; 749 ubd_dev = &ubd_devs[n];
731 spin_lock(&ubd_lock); 750 mutex_lock(&ubd_lock);
732 751
733 if(dev->file == NULL){ 752 if(ubd_dev->file == NULL){
734 CONFIG_CHUNK(str, size, len, "", 1); 753 CONFIG_CHUNK(str, size, len, "", 1);
735 goto out; 754 goto out;
736 } 755 }
737 756
738 CONFIG_CHUNK(str, size, len, dev->file, 0); 757 CONFIG_CHUNK(str, size, len, ubd_dev->file, 0);
739 758
740 if(dev->cow.file != NULL){ 759 if(ubd_dev->cow.file != NULL){
741 CONFIG_CHUNK(str, size, len, ",", 0); 760 CONFIG_CHUNK(str, size, len, ",", 0);
742 CONFIG_CHUNK(str, size, len, dev->cow.file, 1); 761 CONFIG_CHUNK(str, size, len, ubd_dev->cow.file, 1);
743 } 762 }
744 else CONFIG_CHUNK(str, size, len, "", 1); 763 else CONFIG_CHUNK(str, size, len, "", 1);
745 764
746 out: 765 out:
747 spin_unlock(&ubd_lock); 766 mutex_unlock(&ubd_lock);
748 return(len); 767 return(len);
749} 768}
750 769
@@ -760,22 +779,22 @@ static int ubd_id(char **str, int *start_out, int *end_out)
760 779
761static int ubd_remove(int n) 780static int ubd_remove(int n)
762{ 781{
763 struct ubd *dev; 782 struct ubd *ubd_dev;
764 int err = -ENODEV; 783 int err = -ENODEV;
765 784
766 spin_lock(&ubd_lock); 785 mutex_lock(&ubd_lock);
767 786
768 if(ubd_gendisk[n] == NULL) 787 if(ubd_gendisk[n] == NULL)
769 goto out; 788 goto out;
770 789
771 dev = &ubd_dev[n]; 790 ubd_dev = &ubd_devs[n];
772 791
773 if(dev->file == NULL) 792 if(ubd_dev->file == NULL)
774 goto out; 793 goto out;
775 794
776 /* you cannot remove a open disk */ 795 /* you cannot remove a open disk */
777 err = -EBUSY; 796 err = -EBUSY;
778 if(dev->count > 0) 797 if(ubd_dev->count > 0)
779 goto out; 798 goto out;
780 799
781 del_gendisk(ubd_gendisk[n]); 800 del_gendisk(ubd_gendisk[n]);
@@ -788,14 +807,15 @@ static int ubd_remove(int n)
788 fake_gendisk[n] = NULL; 807 fake_gendisk[n] = NULL;
789 } 808 }
790 809
791 platform_device_unregister(&dev->pdev); 810 platform_device_unregister(&ubd_dev->pdev);
792 *dev = ((struct ubd) DEFAULT_UBD); 811 *ubd_dev = ((struct ubd) DEFAULT_UBD);
793 err = 0; 812 err = 0;
794out: 813out:
795 spin_unlock(&ubd_lock); 814 mutex_unlock(&ubd_lock);
796 return err; 815 return err;
797} 816}
798 817
818/* All these are called by mconsole in process context and without ubd-specific locks. */
799static struct mc_device ubd_mc = { 819static struct mc_device ubd_mc = {
800 .name = "ubd", 820 .name = "ubd",
801 .config = ubd_config, 821 .config = ubd_config,
@@ -804,7 +824,7 @@ static struct mc_device ubd_mc = {
804 .remove = ubd_remove, 824 .remove = ubd_remove,
805}; 825};
806 826
807static int ubd_mc_init(void) 827static int __init ubd_mc_init(void)
808{ 828{
809 mconsole_register_dev(&ubd_mc); 829 mconsole_register_dev(&ubd_mc);
810 return 0; 830 return 0;
@@ -812,13 +832,24 @@ static int ubd_mc_init(void)
812 832
813__initcall(ubd_mc_init); 833__initcall(ubd_mc_init);
814 834
835static int __init ubd0_init(void)
836{
837 struct ubd *ubd_dev = &ubd_devs[0];
838
839 if(ubd_dev->file == NULL)
840 ubd_dev->file = "root_fs";
841 return(0);
842}
843
844__initcall(ubd0_init);
845
815static struct platform_driver ubd_driver = { 846static struct platform_driver ubd_driver = {
816 .driver = { 847 .driver = {
817 .name = DRIVER_NAME, 848 .name = DRIVER_NAME,
818 }, 849 },
819}; 850};
820 851
821int ubd_init(void) 852static int __init ubd_init(void)
822{ 853{
823 int i; 854 int i;
824 855
@@ -846,7 +877,7 @@ int ubd_init(void)
846 877
847late_initcall(ubd_init); 878late_initcall(ubd_init);
848 879
849int ubd_driver_init(void){ 880static int __init ubd_driver_init(void){
850 unsigned long stack; 881 unsigned long stack;
851 int err; 882 int err;
852 883
@@ -867,7 +898,7 @@ int ubd_driver_init(void){
867 return(0); 898 return(0);
868 } 899 }
869 err = um_request_irq(UBD_IRQ, thread_fd, IRQ_READ, ubd_intr, 900 err = um_request_irq(UBD_IRQ, thread_fd, IRQ_READ, ubd_intr,
870 IRQF_DISABLED, "ubd", ubd_dev); 901 IRQF_DISABLED, "ubd", ubd_devs);
871 if(err != 0) 902 if(err != 0)
872 printk(KERN_ERR "um_request_irq failed - errno = %d\n", -err); 903 printk(KERN_ERR "um_request_irq failed - errno = %d\n", -err);
873 return 0; 904 return 0;
@@ -878,24 +909,24 @@ device_initcall(ubd_driver_init);
878static int ubd_open(struct inode *inode, struct file *filp) 909static int ubd_open(struct inode *inode, struct file *filp)
879{ 910{
880 struct gendisk *disk = inode->i_bdev->bd_disk; 911 struct gendisk *disk = inode->i_bdev->bd_disk;
881 struct ubd *dev = disk->private_data; 912 struct ubd *ubd_dev = disk->private_data;
882 int err = 0; 913 int err = 0;
883 914
884 if(dev->count == 0){ 915 if(ubd_dev->count == 0){
885 err = ubd_open_dev(dev); 916 err = ubd_open_dev(ubd_dev);
886 if(err){ 917 if(err){
887 printk(KERN_ERR "%s: Can't open \"%s\": errno = %d\n", 918 printk(KERN_ERR "%s: Can't open \"%s\": errno = %d\n",
888 disk->disk_name, dev->file, -err); 919 disk->disk_name, ubd_dev->file, -err);
889 goto out; 920 goto out;
890 } 921 }
891 } 922 }
892 dev->count++; 923 ubd_dev->count++;
893 set_disk_ro(disk, !dev->openflags.w); 924 set_disk_ro(disk, !ubd_dev->openflags.w);
894 925
895 /* This should no more be needed. And it didn't work anyway to exclude 926 /* This should no more be needed. And it didn't work anyway to exclude
896 * read-write remounting of filesystems.*/ 927 * read-write remounting of filesystems.*/
897 /*if((filp->f_mode & FMODE_WRITE) && !dev->openflags.w){ 928 /*if((filp->f_mode & FMODE_WRITE) && !ubd_dev->openflags.w){
898 if(--dev->count == 0) ubd_close(dev); 929 if(--ubd_dev->count == 0) ubd_close_dev(ubd_dev);
899 err = -EROFS; 930 err = -EROFS;
900 }*/ 931 }*/
901 out: 932 out:
@@ -905,10 +936,10 @@ static int ubd_open(struct inode *inode, struct file *filp)
905static int ubd_release(struct inode * inode, struct file * file) 936static int ubd_release(struct inode * inode, struct file * file)
906{ 937{
907 struct gendisk *disk = inode->i_bdev->bd_disk; 938 struct gendisk *disk = inode->i_bdev->bd_disk;
908 struct ubd *dev = disk->private_data; 939 struct ubd *ubd_dev = disk->private_data;
909 940
910 if(--dev->count == 0) 941 if(--ubd_dev->count == 0)
911 ubd_close(dev); 942 ubd_close_dev(ubd_dev);
912 return(0); 943 return(0);
913} 944}
914 945
@@ -976,12 +1007,12 @@ static void cowify_req(struct io_thread_req *req, unsigned long *bitmap,
976static int prepare_request(struct request *req, struct io_thread_req *io_req) 1007static int prepare_request(struct request *req, struct io_thread_req *io_req)
977{ 1008{
978 struct gendisk *disk = req->rq_disk; 1009 struct gendisk *disk = req->rq_disk;
979 struct ubd *dev = disk->private_data; 1010 struct ubd *ubd_dev = disk->private_data;
980 __u64 offset; 1011 __u64 offset;
981 int len; 1012 int len;
982 1013
983 /* This should be impossible now */ 1014 /* This should be impossible now */
984 if((rq_data_dir(req) == WRITE) && !dev->openflags.w){ 1015 if((rq_data_dir(req) == WRITE) && !ubd_dev->openflags.w){
985 printk("Write attempted on readonly ubd device %s\n", 1016 printk("Write attempted on readonly ubd device %s\n",
986 disk->disk_name); 1017 disk->disk_name);
987 end_request(req, 0); 1018 end_request(req, 0);
@@ -991,8 +1022,8 @@ static int prepare_request(struct request *req, struct io_thread_req *io_req)
991 offset = ((__u64) req->sector) << 9; 1022 offset = ((__u64) req->sector) << 9;
992 len = req->current_nr_sectors << 9; 1023 len = req->current_nr_sectors << 9;
993 1024
994 io_req->fds[0] = (dev->cow.file != NULL) ? dev->cow.fd : dev->fd; 1025 io_req->fds[0] = (ubd_dev->cow.file != NULL) ? ubd_dev->cow.fd : ubd_dev->fd;
995 io_req->fds[1] = dev->fd; 1026 io_req->fds[1] = ubd_dev->fd;
996 io_req->cow_offset = -1; 1027 io_req->cow_offset = -1;
997 io_req->offset = offset; 1028 io_req->offset = offset;
998 io_req->length = len; 1029 io_req->length = len;
@@ -1001,13 +1032,13 @@ static int prepare_request(struct request *req, struct io_thread_req *io_req)
1001 1032
1002 io_req->op = (rq_data_dir(req) == READ) ? UBD_READ : UBD_WRITE; 1033 io_req->op = (rq_data_dir(req) == READ) ? UBD_READ : UBD_WRITE;
1003 io_req->offsets[0] = 0; 1034 io_req->offsets[0] = 0;
1004 io_req->offsets[1] = dev->cow.data_offset; 1035 io_req->offsets[1] = ubd_dev->cow.data_offset;
1005 io_req->buffer = req->buffer; 1036 io_req->buffer = req->buffer;
1006 io_req->sectorsize = 1 << 9; 1037 io_req->sectorsize = 1 << 9;
1007 1038
1008 if(dev->cow.file != NULL) 1039 if(ubd_dev->cow.file != NULL)
1009 cowify_req(io_req, dev->cow.bitmap, dev->cow.bitmap_offset, 1040 cowify_req(io_req, ubd_dev->cow.bitmap, ubd_dev->cow.bitmap_offset,
1010 dev->cow.bitmap_len); 1041 ubd_dev->cow.bitmap_len);
1011 1042
1012 return(0); 1043 return(0);
1013} 1044}
@@ -1033,7 +1064,7 @@ static void do_ubd_request(request_queue_t *q)
1033 return; 1064 return;
1034 err = prepare_request(req, &io_req); 1065 err = prepare_request(req, &io_req);
1035 if(!err){ 1066 if(!err){
1036 do_ubd = ubd_handler; 1067 do_ubd = 1;
1037 n = os_write_file(thread_fd, (char *) &io_req, 1068 n = os_write_file(thread_fd, (char *) &io_req,
1038 sizeof(io_req)); 1069 sizeof(io_req));
1039 if(n != sizeof(io_req)) 1070 if(n != sizeof(io_req))
@@ -1045,18 +1076,18 @@ static void do_ubd_request(request_queue_t *q)
1045 1076
1046static int ubd_getgeo(struct block_device *bdev, struct hd_geometry *geo) 1077static int ubd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
1047{ 1078{
1048 struct ubd *dev = bdev->bd_disk->private_data; 1079 struct ubd *ubd_dev = bdev->bd_disk->private_data;
1049 1080
1050 geo->heads = 128; 1081 geo->heads = 128;
1051 geo->sectors = 32; 1082 geo->sectors = 32;
1052 geo->cylinders = dev->size / (128 * 32 * 512); 1083 geo->cylinders = ubd_dev->size / (128 * 32 * 512);
1053 return 0; 1084 return 0;
1054} 1085}
1055 1086
1056static int ubd_ioctl(struct inode * inode, struct file * file, 1087static int ubd_ioctl(struct inode * inode, struct file * file,
1057 unsigned int cmd, unsigned long arg) 1088 unsigned int cmd, unsigned long arg)
1058{ 1089{
1059 struct ubd *dev = inode->i_bdev->bd_disk->private_data; 1090 struct ubd *ubd_dev = inode->i_bdev->bd_disk->private_data;
1060 struct hd_driveid ubd_id = { 1091 struct hd_driveid ubd_id = {
1061 .cyls = 0, 1092 .cyls = 0,
1062 .heads = 128, 1093 .heads = 128,
@@ -1066,7 +1097,7 @@ static int ubd_ioctl(struct inode * inode, struct file * file,
1066 switch (cmd) { 1097 switch (cmd) {
1067 struct cdrom_volctrl volume; 1098 struct cdrom_volctrl volume;
1068 case HDIO_GET_IDENTITY: 1099 case HDIO_GET_IDENTITY:
1069 ubd_id.cyls = dev->size / (128 * 32 * 512); 1100 ubd_id.cyls = ubd_dev->size / (128 * 32 * 512);
1070 if(copy_to_user((char __user *) arg, (char *) &ubd_id, 1101 if(copy_to_user((char __user *) arg, (char *) &ubd_id,
1071 sizeof(ubd_id))) 1102 sizeof(ubd_id)))
1072 return(-EFAULT); 1103 return(-EFAULT);
@@ -1353,8 +1384,8 @@ void do_io(struct io_thread_req *req)
1353 */ 1384 */
1354int kernel_fd = -1; 1385int kernel_fd = -1;
1355 1386
1356/* Only changed by the io thread */ 1387/* Only changed by the io thread. XXX: currently unused. */
1357int io_count = 0; 1388static int io_count = 0;
1358 1389
1359int io_thread(void *arg) 1390int io_thread(void *arg)
1360{ 1391{
diff --git a/arch/um/drivers/xterm.c b/arch/um/drivers/xterm.c
index 386f8b952982..850221d9b4c9 100644
--- a/arch/um/drivers/xterm.c
+++ b/arch/um/drivers/xterm.c
@@ -136,8 +136,6 @@ int xterm_open(int input, int output, int primary, void *d,
136 return(pid); 136 return(pid);
137 } 137 }
138 138
139 if(data->stack == 0) free_stack(stack, 0);
140
141 if (data->direct_rcv) { 139 if (data->direct_rcv) {
142 new = os_rcv_fd(fd, &data->helper_pid); 140 new = os_rcv_fd(fd, &data->helper_pid);
143 } else { 141 } else {
diff --git a/arch/um/include/common-offsets.h b/arch/um/include/common-offsets.h
index 356390d1f8b9..461175f8b1d9 100644
--- a/arch/um/include/common-offsets.h
+++ b/arch/um/include/common-offsets.h
@@ -1,9 +1,16 @@
1/* for use by sys-$SUBARCH/kernel-offsets.c */ 1/* for use by sys-$SUBARCH/kernel-offsets.c */
2 2
3DEFINE(KERNEL_MADV_REMOVE, MADV_REMOVE);
4#ifdef CONFIG_MODE_TT
5OFFSET(HOST_TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid);
6#endif
7
3OFFSET(HOST_TASK_REGS, task_struct, thread.regs); 8OFFSET(HOST_TASK_REGS, task_struct, thread.regs);
4OFFSET(HOST_TASK_PID, task_struct, pid); 9OFFSET(HOST_TASK_PID, task_struct, pid);
10
5DEFINE(UM_KERN_PAGE_SIZE, PAGE_SIZE); 11DEFINE(UM_KERN_PAGE_SIZE, PAGE_SIZE);
6DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC); 12DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC);
13
7DEFINE_STR(UM_KERN_EMERG, KERN_EMERG); 14DEFINE_STR(UM_KERN_EMERG, KERN_EMERG);
8DEFINE_STR(UM_KERN_ALERT, KERN_ALERT); 15DEFINE_STR(UM_KERN_ALERT, KERN_ALERT);
9DEFINE_STR(UM_KERN_CRIT, KERN_CRIT); 16DEFINE_STR(UM_KERN_CRIT, KERN_CRIT);
@@ -12,6 +19,10 @@ DEFINE_STR(UM_KERN_WARNING, KERN_WARNING);
12DEFINE_STR(UM_KERN_NOTICE, KERN_NOTICE); 19DEFINE_STR(UM_KERN_NOTICE, KERN_NOTICE);
13DEFINE_STR(UM_KERN_INFO, KERN_INFO); 20DEFINE_STR(UM_KERN_INFO, KERN_INFO);
14DEFINE_STR(UM_KERN_DEBUG, KERN_DEBUG); 21DEFINE_STR(UM_KERN_DEBUG, KERN_DEBUG);
22
15DEFINE(UM_ELF_CLASS, ELF_CLASS); 23DEFINE(UM_ELF_CLASS, ELF_CLASS);
16DEFINE(UM_ELFCLASS32, ELFCLASS32); 24DEFINE(UM_ELFCLASS32, ELFCLASS32);
17DEFINE(UM_ELFCLASS64, ELFCLASS64); 25DEFINE(UM_ELFCLASS64, ELFCLASS64);
26
27/* For crypto assembler code. */
28DEFINE(crypto_tfm_ctx_offset, offsetof(struct crypto_tfm, __crt_ctx));
diff --git a/arch/um/include/kern_util.h b/arch/um/include/kern_util.h
index 59cfa9e0cad0..cec9fcc57bf5 100644
--- a/arch/um/include/kern_util.h
+++ b/arch/um/include/kern_util.h
@@ -6,7 +6,6 @@
6#ifndef __KERN_UTIL_H__ 6#ifndef __KERN_UTIL_H__
7#define __KERN_UTIL_H__ 7#define __KERN_UTIL_H__
8 8
9#include "linux/threads.h"
10#include "sysdep/ptrace.h" 9#include "sysdep/ptrace.h"
11#include "sysdep/faultinfo.h" 10#include "sysdep/faultinfo.h"
12 11
diff --git a/arch/um/include/longjmp.h b/arch/um/include/longjmp.h
index e93c6d3e893b..e860bc5848e0 100644
--- a/arch/um/include/longjmp.h
+++ b/arch/um/include/longjmp.h
@@ -12,7 +12,8 @@ extern void longjmp(jmp_buf, int);
12} while(0) 12} while(0)
13 13
14#define UML_SETJMP(buf) ({ \ 14#define UML_SETJMP(buf) ({ \
15 int n, enable; \ 15 int n; \
16 volatile int enable; \
16 enable = get_signals(); \ 17 enable = get_signals(); \
17 n = setjmp(*buf); \ 18 n = setjmp(*buf); \
18 if(n != 0) \ 19 if(n != 0) \
diff --git a/arch/um/include/mconsole.h b/arch/um/include/mconsole.h
index 58f67d391105..2666815b6af5 100644
--- a/arch/um/include/mconsole.h
+++ b/arch/um/include/mconsole.h
@@ -61,6 +61,7 @@ struct mc_request
61 61
62 struct mconsole_request request; 62 struct mconsole_request request;
63 struct mconsole_command *cmd; 63 struct mconsole_command *cmd;
64 union uml_pt_regs regs;
64}; 65};
65 66
66extern char mconsole_socket_name[]; 67extern char mconsole_socket_name[];
diff --git a/arch/um/include/mconsole_kern.h b/arch/um/include/mconsole_kern.h
index d0b690197fd7..1ea6d928e1cd 100644
--- a/arch/um/include/mconsole_kern.h
+++ b/arch/um/include/mconsole_kern.h
@@ -14,6 +14,7 @@ struct mconsole_entry {
14 struct mc_request request; 14 struct mc_request request;
15}; 15};
16 16
17/* All these methods are called in process context. */
17struct mc_device { 18struct mc_device {
18 struct list_head list; 19 struct list_head list;
19 char *name; 20 char *name;
diff --git a/arch/um/include/os.h b/arch/um/include/os.h
index 120ca21a513a..6516f6dca96d 100644
--- a/arch/um/include/os.h
+++ b/arch/um/include/os.h
@@ -201,6 +201,7 @@ extern int os_getpgrp(void);
201 201
202#ifdef UML_CONFIG_MODE_TT 202#ifdef UML_CONFIG_MODE_TT
203extern void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int)); 203extern void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int));
204extern void stop(void);
204#endif 205#endif
205extern void init_new_thread_signals(void); 206extern void init_new_thread_signals(void);
206extern int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr); 207extern int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr);
diff --git a/arch/um/include/sysdep-i386/barrier.h b/arch/um/include/sysdep-i386/barrier.h
new file mode 100644
index 000000000000..b58d52c5b2f4
--- /dev/null
+++ b/arch/um/include/sysdep-i386/barrier.h
@@ -0,0 +1,9 @@
1#ifndef __SYSDEP_I386_BARRIER_H
2#define __SYSDEP_I386_BARRIER_H
3
4/* Copied from include/asm-i386 for use by userspace. i386 has the option
5 * of using mfence, but I'm just using this, which works everywhere, for now.
6 */
7#define mb() asm volatile("lock; addl $0,0(%esp)")
8
9#endif
diff --git a/arch/um/include/sysdep-i386/kernel-offsets.h b/arch/um/include/sysdep-i386/kernel-offsets.h
index 2c13de321f2f..97ec9d894d75 100644
--- a/arch/um/include/sysdep-i386/kernel-offsets.h
+++ b/arch/um/include/sysdep-i386/kernel-offsets.h
@@ -1,6 +1,7 @@
1#include <linux/stddef.h> 1#include <linux/stddef.h>
2#include <linux/sched.h> 2#include <linux/sched.h>
3#include <linux/elf.h> 3#include <linux/elf.h>
4#include <linux/crypto.h>
4#include <asm/mman.h> 5#include <asm/mman.h>
5 6
6#define DEFINE(sym, val) \ 7#define DEFINE(sym, val) \
@@ -17,9 +18,5 @@
17void foo(void) 18void foo(void)
18{ 19{
19 OFFSET(HOST_TASK_DEBUGREGS, task_struct, thread.arch.debugregs); 20 OFFSET(HOST_TASK_DEBUGREGS, task_struct, thread.arch.debugregs);
20 DEFINE(KERNEL_MADV_REMOVE, MADV_REMOVE);
21#ifdef CONFIG_MODE_TT
22 OFFSET(HOST_TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid);
23#endif
24#include <common-offsets.h> 21#include <common-offsets.h>
25} 22}
diff --git a/arch/um/include/sysdep-x86_64/barrier.h b/arch/um/include/sysdep-x86_64/barrier.h
new file mode 100644
index 000000000000..7b610befdc8f
--- /dev/null
+++ b/arch/um/include/sysdep-x86_64/barrier.h
@@ -0,0 +1,7 @@
1#ifndef __SYSDEP_X86_64_BARRIER_H
2#define __SYSDEP_X86_64_BARRIER_H
3
4/* Copied from include/asm-x86_64 for use by userspace. */
5#define mb() asm volatile("mfence":::"memory")
6
7#endif
diff --git a/arch/um/include/sysdep-x86_64/kernel-offsets.h b/arch/um/include/sysdep-x86_64/kernel-offsets.h
index 91d129fb3930..a307237b7964 100644
--- a/arch/um/include/sysdep-x86_64/kernel-offsets.h
+++ b/arch/um/include/sysdep-x86_64/kernel-offsets.h
@@ -2,6 +2,7 @@
2#include <linux/sched.h> 2#include <linux/sched.h>
3#include <linux/time.h> 3#include <linux/time.h>
4#include <linux/elf.h> 4#include <linux/elf.h>
5#include <linux/crypto.h>
5#include <asm/page.h> 6#include <asm/page.h>
6#include <asm/mman.h> 7#include <asm/mman.h>
7 8
@@ -18,9 +19,5 @@
18 19
19void foo(void) 20void foo(void)
20{ 21{
21 DEFINE(KERNEL_MADV_REMOVE, MADV_REMOVE);
22#ifdef CONFIG_MODE_TT
23 OFFSET(HOST_TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid);
24#endif
25#include <common-offsets.h> 22#include <common-offsets.h>
26} 23}
diff --git a/arch/um/include/um_malloc.h b/arch/um/include/um_malloc.h
new file mode 100644
index 000000000000..0363a9b53f8d
--- /dev/null
+++ b/arch/um/include/um_malloc.h
@@ -0,0 +1,17 @@
1/*
2 * Copyright (C) 2005 Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
3 * Licensed under the GPL
4 */
5
6#ifndef __UM_MALLOC_H__
7#define __UM_MALLOC_H__
8
9extern void *um_kmalloc(int size);
10extern void *um_kmalloc_atomic(int size);
11extern void kfree(const void *ptr);
12
13extern void *um_vmalloc(int size);
14extern void *um_vmalloc_atomic(int size);
15extern void vfree(void *ptr);
16
17#endif /* __UM_MALLOC_H__ */
diff --git a/arch/um/include/user.h b/arch/um/include/user.h
index 39f8c8801076..acadce3f271f 100644
--- a/arch/um/include/user.h
+++ b/arch/um/include/user.h
@@ -11,17 +11,11 @@ extern void panic(const char *fmt, ...)
11extern int printk(const char *fmt, ...) 11extern int printk(const char *fmt, ...)
12 __attribute__ ((format (printf, 1, 2))); 12 __attribute__ ((format (printf, 1, 2)));
13extern void schedule(void); 13extern void schedule(void);
14extern void *um_kmalloc(int size);
15extern void *um_kmalloc_atomic(int size);
16extern void kfree(void *ptr);
17extern int in_aton(char *str); 14extern int in_aton(char *str);
18extern int open_gdb_chan(void); 15extern int open_gdb_chan(void);
19/* These use size_t, however unsigned long is correct on both i386 and x86_64. */ 16/* These use size_t, however unsigned long is correct on both i386 and x86_64. */
20extern unsigned long strlcpy(char *, const char *, unsigned long); 17extern unsigned long strlcpy(char *, const char *, unsigned long);
21extern unsigned long strlcat(char *, const char *, unsigned long); 18extern unsigned long strlcat(char *, const char *, unsigned long);
22extern void *um_vmalloc(int size);
23extern void *um_vmalloc_atomic(int size);
24extern void vfree(void *ptr);
25 19
26#endif 20#endif
27 21
diff --git a/arch/um/include/user_util.h b/arch/um/include/user_util.h
index 802d7842514d..06625fefef33 100644
--- a/arch/um/include/user_util.h
+++ b/arch/um/include/user_util.h
@@ -52,7 +52,6 @@ extern int linux_main(int argc, char **argv);
52extern void set_cmdline(char *cmd); 52extern void set_cmdline(char *cmd);
53extern void input_cb(void (*proc)(void *), void *arg, int arg_len); 53extern void input_cb(void (*proc)(void *), void *arg, int arg_len);
54extern int get_pty(void); 54extern int get_pty(void);
55extern void *um_kmalloc(int size);
56extern int switcheroo(int fd, int prot, void *from, void *to, int size); 55extern int switcheroo(int fd, int prot, void *from, void *to, int size);
57extern void do_exec(int old_pid, int new_pid); 56extern void do_exec(int old_pid, int new_pid);
58extern void tracer_panic(char *msg, ...) 57extern void tracer_panic(char *msg, ...)
diff --git a/arch/um/kernel/dyn.lds.S b/arch/um/kernel/dyn.lds.S
index 68ed24df5c8f..e36f92b463ce 100644
--- a/arch/um/kernel/dyn.lds.S
+++ b/arch/um/kernel/dyn.lds.S
@@ -14,6 +14,7 @@ SECTIONS
14 * is remapped.*/ 14 * is remapped.*/
15 __binary_start = .; 15 __binary_start = .;
16 . = ALIGN(4096); /* Init code and data */ 16 . = ALIGN(4096); /* Init code and data */
17 _text = .;
17 _stext = .; 18 _stext = .;
18 __init_begin = .; 19 __init_begin = .;
19 .init.text : { 20 .init.text : {
diff --git a/arch/um/kernel/irq.c b/arch/um/kernel/irq.c
index ef259569fd8c..5c1e611f628d 100644
--- a/arch/um/kernel/irq.c
+++ b/arch/um/kernel/irq.c
@@ -31,6 +31,7 @@
31#include "irq_kern.h" 31#include "irq_kern.h"
32#include "os.h" 32#include "os.h"
33#include "sigio.h" 33#include "sigio.h"
34#include "um_malloc.h"
34#include "misc_constants.h" 35#include "misc_constants.h"
35 36
36/* 37/*
diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
index fe6c64abda5b..348b272bb766 100644
--- a/arch/um/kernel/process.c
+++ b/arch/um/kernel/process.c
@@ -46,6 +46,7 @@
46#include "mode.h" 46#include "mode.h"
47#include "mode_kern.h" 47#include "mode_kern.h"
48#include "choose-mode.h" 48#include "choose-mode.h"
49#include "um_malloc.h"
49 50
50/* This is a per-cpu array. A processor only modifies its entry and it only 51/* This is a per-cpu array. A processor only modifies its entry and it only
51 * cares about its entry, so it's OK if another processor is modifying its 52 * cares about its entry, so it's OK if another processor is modifying its
diff --git a/arch/um/kernel/skas/mmu.c b/arch/um/kernel/skas/mmu.c
index c17eddcf89b3..2c6d090a2e87 100644
--- a/arch/um/kernel/skas/mmu.c
+++ b/arch/um/kernel/skas/mmu.c
@@ -60,10 +60,7 @@ static int init_stub_pte(struct mm_struct *mm, unsigned long proc,
60#endif 60#endif
61 61
62 *pte = mk_pte(virt_to_page(kernel), __pgprot(_PAGE_PRESENT)); 62 *pte = mk_pte(virt_to_page(kernel), __pgprot(_PAGE_PRESENT));
63 /* This is wrong for the code page, but it doesn't matter since the 63 *pte = pte_mkread(*pte);
64 * stub is mapped by hand with the correct permissions.
65 */
66 *pte = pte_mkwrite(*pte);
67 return(0); 64 return(0);
68 65
69 out_pmd: 66 out_pmd:
diff --git a/arch/um/kernel/tt/tracer.c b/arch/um/kernel/tt/tracer.c
index 9882342206ec..b9195355075a 100644
--- a/arch/um/kernel/tt/tracer.c
+++ b/arch/um/kernel/tt/tracer.c
@@ -176,7 +176,6 @@ struct {
176int signal_index[32]; 176int signal_index[32];
177int nsignals = 0; 177int nsignals = 0;
178int debug_trace = 0; 178int debug_trace = 0;
179extern int io_nsignals, io_count, intr_count;
180 179
181extern void signal_usr1(int sig); 180extern void signal_usr1(int sig);
182 181
diff --git a/arch/um/kernel/tt/uaccess_user.c b/arch/um/kernel/tt/uaccess_user.c
index 6c92bbccb49c..ed1abcf4d057 100644
--- a/arch/um/kernel/tt/uaccess_user.c
+++ b/arch/um/kernel/tt/uaccess_user.c
@@ -4,13 +4,13 @@
4 * Licensed under the GPL 4 * Licensed under the GPL
5 */ 5 */
6 6
7#include <setjmp.h>
8#include <string.h> 7#include <string.h>
9#include "user_util.h" 8#include "user_util.h"
10#include "uml_uaccess.h" 9#include "uml_uaccess.h"
11#include "task.h" 10#include "task.h"
12#include "kern_util.h" 11#include "kern_util.h"
13#include "os.h" 12#include "os.h"
13#include "longjmp.h"
14 14
15int __do_copy_from_user(void *to, const void *from, int n, 15int __do_copy_from_user(void *to, const void *from, int n,
16 void **fault_addr, void **fault_catcher) 16 void **fault_addr, void **fault_catcher)
@@ -80,10 +80,10 @@ int __do_strnlen_user(const char *str, unsigned long n,
80 struct tt_regs save = TASK_REGS(get_current())->tt; 80 struct tt_regs save = TASK_REGS(get_current())->tt;
81 int ret; 81 int ret;
82 unsigned long *faddrp = (unsigned long *)fault_addr; 82 unsigned long *faddrp = (unsigned long *)fault_addr;
83 sigjmp_buf jbuf; 83 jmp_buf jbuf;
84 84
85 *fault_catcher = &jbuf; 85 *fault_catcher = &jbuf;
86 if(sigsetjmp(jbuf, 1) == 0) 86 if(UML_SETJMP(&jbuf) == 0)
87 ret = strlen(str) + 1; 87 ret = strlen(str) + 1;
88 else ret = *faddrp - (unsigned long) str; 88 else ret = *faddrp - (unsigned long) str;
89 89
diff --git a/arch/um/kernel/uml.lds.S b/arch/um/kernel/uml.lds.S
index 8eca47a6ff08..f6301274cf3c 100644
--- a/arch/um/kernel/uml.lds.S
+++ b/arch/um/kernel/uml.lds.S
@@ -25,6 +25,7 @@ SECTIONS
25 . = ALIGN(4096); /* Init code and data */ 25 . = ALIGN(4096); /* Init code and data */
26#endif 26#endif
27 27
28 _text = .;
28 _stext = .; 29 _stext = .;
29 __init_begin = .; 30 __init_begin = .;
30 .init.text : { 31 .init.text : {
diff --git a/arch/um/os-Linux/drivers/ethertap_user.c b/arch/um/os-Linux/drivers/ethertap_user.c
index f559bdf746e6..863981ba1468 100644
--- a/arch/um/os-Linux/drivers/ethertap_user.c
+++ b/arch/um/os-Linux/drivers/ethertap_user.c
@@ -20,6 +20,7 @@
20#include "net_user.h" 20#include "net_user.h"
21#include "etap.h" 21#include "etap.h"
22#include "os.h" 22#include "os.h"
23#include "um_malloc.h"
23 24
24#define MAX_PACKET ETH_MAX_PACKET 25#define MAX_PACKET ETH_MAX_PACKET
25 26
diff --git a/arch/um/os-Linux/helper.c b/arch/um/os-Linux/helper.c
index cd15b9df5b5c..d13299cfa318 100644
--- a/arch/um/os-Linux/helper.c
+++ b/arch/um/os-Linux/helper.c
@@ -35,22 +35,23 @@ static int helper_child(void *arg)
35 char **argv = data->argv; 35 char **argv = data->argv;
36 int errval; 36 int errval;
37 37
38 if(helper_pause){ 38 if (helper_pause){
39 signal(SIGHUP, helper_hup); 39 signal(SIGHUP, helper_hup);
40 pause(); 40 pause();
41 } 41 }
42 if(data->pre_exec != NULL) 42 if (data->pre_exec != NULL)
43 (*data->pre_exec)(data->pre_data); 43 (*data->pre_exec)(data->pre_data);
44 execvp(argv[0], argv); 44 execvp(argv[0], argv);
45 errval = -errno; 45 errval = -errno;
46 printk("helper_child - execve of '%s' failed - errno = %d\n", argv[0], errno); 46 printk("helper_child - execve of '%s' failed - errno = %d\n", argv[0], errno);
47 os_write_file(data->fd, &errval, sizeof(errval)); 47 os_write_file(data->fd, &errval, sizeof(errval));
48 kill(os_getpid(), SIGKILL); 48 kill(os_getpid(), SIGKILL);
49 return(0); 49 return 0;
50} 50}
51 51
52/* Returns either the pid of the child process we run or -E* on failure. 52/* Returns either the pid of the child process we run or -E* on failure.
53 * XXX The alloc_stack here breaks if this is called in the tracing thread */ 53 * XXX The alloc_stack here breaks if this is called in the tracing thread, so
54 * we need to receive a preallocated stack (a local buffer is ok). */
54int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv, 55int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv,
55 unsigned long *stack_out) 56 unsigned long *stack_out)
56{ 57{
@@ -58,20 +59,21 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv,
58 unsigned long stack, sp; 59 unsigned long stack, sp;
59 int pid, fds[2], ret, n; 60 int pid, fds[2], ret, n;
60 61
61 if((stack_out != NULL) && (*stack_out != 0)) 62 if ((stack_out != NULL) && (*stack_out != 0))
62 stack = *stack_out; 63 stack = *stack_out;
63 else stack = alloc_stack(0, __cant_sleep()); 64 else
64 if(stack == 0) 65 stack = alloc_stack(0, __cant_sleep());
66 if (stack == 0)
65 return -ENOMEM; 67 return -ENOMEM;
66 68
67 ret = os_pipe(fds, 1, 0); 69 ret = os_pipe(fds, 1, 0);
68 if(ret < 0){ 70 if (ret < 0) {
69 printk("run_helper : pipe failed, ret = %d\n", -ret); 71 printk("run_helper : pipe failed, ret = %d\n", -ret);
70 goto out_free; 72 goto out_free;
71 } 73 }
72 74
73 ret = os_set_exec_close(fds[1], 1); 75 ret = os_set_exec_close(fds[1], 1);
74 if(ret < 0){ 76 if (ret < 0) {
75 printk("run_helper : setting FD_CLOEXEC failed, ret = %d\n", 77 printk("run_helper : setting FD_CLOEXEC failed, ret = %d\n",
76 -ret); 78 -ret);
77 goto out_close; 79 goto out_close;
@@ -83,7 +85,7 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv,
83 data.argv = argv; 85 data.argv = argv;
84 data.fd = fds[1]; 86 data.fd = fds[1];
85 pid = clone(helper_child, (void *) sp, CLONE_VM | SIGCHLD, &data); 87 pid = clone(helper_child, (void *) sp, CLONE_VM | SIGCHLD, &data);
86 if(pid < 0){ 88 if (pid < 0) {
87 ret = -errno; 89 ret = -errno;
88 printk("run_helper : clone failed, errno = %d\n", errno); 90 printk("run_helper : clone failed, errno = %d\n", errno);
89 goto out_close; 91 goto out_close;
@@ -95,10 +97,10 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv,
95 /* Read the errno value from the child, if the exec failed, or get 0 if 97 /* Read the errno value from the child, if the exec failed, or get 0 if
96 * the exec succeeded because the pipe fd was set as close-on-exec. */ 98 * the exec succeeded because the pipe fd was set as close-on-exec. */
97 n = os_read_file(fds[0], &ret, sizeof(ret)); 99 n = os_read_file(fds[0], &ret, sizeof(ret));
98 if(n == 0) 100 if (n == 0) {
99 ret = pid; 101 ret = pid;
100 else { 102 } else {
101 if(n < 0){ 103 if (n < 0) {
102 printk("run_helper : read on pipe failed, ret = %d\n", 104 printk("run_helper : read on pipe failed, ret = %d\n",
103 -n); 105 -n);
104 ret = n; 106 ret = n;
@@ -112,10 +114,9 @@ out_close:
112 close(fds[1]); 114 close(fds[1]);
113 close(fds[0]); 115 close(fds[0]);
114out_free: 116out_free:
115 if(stack_out == NULL) 117 if ((stack_out == NULL) || (*stack_out == 0))
116 free_stack(stack, 0); 118 free_stack(stack, 0);
117 else *stack_out = stack; 119 return ret;
118 return(ret);
119} 120}
120 121
121int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags, 122int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags,
@@ -125,31 +126,32 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags,
125 int pid, status, err; 126 int pid, status, err;
126 127
127 stack = alloc_stack(stack_order, __cant_sleep()); 128 stack = alloc_stack(stack_order, __cant_sleep());
128 if(stack == 0) return(-ENOMEM); 129 if (stack == 0)
130 return -ENOMEM;
129 131
130 sp = stack + (page_size() << stack_order) - sizeof(void *); 132 sp = stack + (page_size() << stack_order) - sizeof(void *);
131 pid = clone(proc, (void *) sp, flags | SIGCHLD, arg); 133 pid = clone(proc, (void *) sp, flags | SIGCHLD, arg);
132 if(pid < 0){ 134 if (pid < 0) {
133 err = -errno; 135 err = -errno;
134 printk("run_helper_thread : clone failed, errno = %d\n", 136 printk("run_helper_thread : clone failed, errno = %d\n",
135 errno); 137 errno);
136 return err; 138 return err;
137 } 139 }
138 if(stack_out == NULL){ 140 if (stack_out == NULL) {
139 CATCH_EINTR(pid = waitpid(pid, &status, 0)); 141 CATCH_EINTR(pid = waitpid(pid, &status, 0));
140 if(pid < 0){ 142 if (pid < 0) {
141 err = -errno; 143 err = -errno;
142 printk("run_helper_thread - wait failed, errno = %d\n", 144 printk("run_helper_thread - wait failed, errno = %d\n",
143 errno); 145 errno);
144 pid = err; 146 pid = err;
145 } 147 }
146 if(!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) 148 if (!WIFEXITED(status) || (WEXITSTATUS(status) != 0))
147 printk("run_helper_thread - thread returned status " 149 printk("run_helper_thread - thread returned status "
148 "0x%x\n", status); 150 "0x%x\n", status);
149 free_stack(stack, stack_order); 151 free_stack(stack, stack_order);
150 } 152 } else
151 else *stack_out = stack; 153 *stack_out = stack;
152 return(pid); 154 return pid;
153} 155}
154 156
155int helper_wait(int pid) 157int helper_wait(int pid)
@@ -157,9 +159,9 @@ int helper_wait(int pid)
157 int ret; 159 int ret;
158 160
159 CATCH_EINTR(ret = waitpid(pid, NULL, WNOHANG)); 161 CATCH_EINTR(ret = waitpid(pid, NULL, WNOHANG));
160 if(ret < 0){ 162 if (ret < 0) {
161 ret = -errno; 163 ret = -errno;
162 printk("helper_wait : waitpid failed, errno = %d\n", errno); 164 printk("helper_wait : waitpid failed, errno = %d\n", errno);
163 } 165 }
164 return(ret); 166 return ret;
165} 167}
diff --git a/arch/um/os-Linux/irq.c b/arch/um/os-Linux/irq.c
index a97206df5b52..d46b818c1311 100644
--- a/arch/um/os-Linux/irq.c
+++ b/arch/um/os-Linux/irq.c
@@ -18,6 +18,7 @@
18#include "sigio.h" 18#include "sigio.h"
19#include "irq_user.h" 19#include "irq_user.h"
20#include "os.h" 20#include "os.h"
21#include "um_malloc.h"
21 22
22static struct pollfd *pollfds = NULL; 23static struct pollfd *pollfds = NULL;
23static int pollfds_num = 0; 24static int pollfds_num = 0;
diff --git a/arch/um/os-Linux/main.c b/arch/um/os-Linux/main.c
index d1c5670787dc..685feaab65d2 100644
--- a/arch/um/os-Linux/main.c
+++ b/arch/um/os-Linux/main.c
@@ -23,6 +23,7 @@
23#include "choose-mode.h" 23#include "choose-mode.h"
24#include "uml-config.h" 24#include "uml-config.h"
25#include "os.h" 25#include "os.h"
26#include "um_malloc.h"
26 27
27/* Set in set_stklim, which is called from main and __wrap_malloc. 28/* Set in set_stklim, which is called from main and __wrap_malloc.
28 * __wrap_malloc only calls it if main hasn't started. 29 * __wrap_malloc only calls it if main hasn't started.
diff --git a/arch/um/os-Linux/process.c b/arch/um/os-Linux/process.c
index 51f0893640a6..c692a192957a 100644
--- a/arch/um/os-Linux/process.c
+++ b/arch/um/os-Linux/process.c
@@ -7,7 +7,6 @@
7#include <stdio.h> 7#include <stdio.h>
8#include <errno.h> 8#include <errno.h>
9#include <signal.h> 9#include <signal.h>
10#include <linux/unistd.h>
11#include <sys/mman.h> 10#include <sys/mman.h>
12#include <sys/wait.h> 11#include <sys/wait.h>
13#include <sys/mman.h> 12#include <sys/mman.h>
diff --git a/arch/um/os-Linux/sigio.c b/arch/um/os-Linux/sigio.c
index f6457765b17d..925a65240cfe 100644
--- a/arch/um/os-Linux/sigio.c
+++ b/arch/um/os-Linux/sigio.c
@@ -19,6 +19,7 @@
19#include "user_util.h" 19#include "user_util.h"
20#include "sigio.h" 20#include "sigio.h"
21#include "os.h" 21#include "os.h"
22#include "um_malloc.h"
22 23
23/* Protected by sigio_lock(), also used by sigio_cleanup, which is an 24/* Protected by sigio_lock(), also used by sigio_cleanup, which is an
24 * exitcall. 25 * exitcall.
diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c
index 6b81739279d1..b897e8592d77 100644
--- a/arch/um/os-Linux/signal.c
+++ b/arch/um/os-Linux/signal.c
@@ -15,6 +15,7 @@
15#include "user.h" 15#include "user.h"
16#include "signal_kern.h" 16#include "signal_kern.h"
17#include "sysdep/sigcontext.h" 17#include "sysdep/sigcontext.h"
18#include "sysdep/barrier.h"
18#include "sigcontext.h" 19#include "sigcontext.h"
19#include "mode.h" 20#include "mode.h"
20#include "os.h" 21#include "os.h"
@@ -34,8 +35,12 @@
34#define SIGALRM_BIT 2 35#define SIGALRM_BIT 2
35#define SIGALRM_MASK (1 << SIGALRM_BIT) 36#define SIGALRM_MASK (1 << SIGALRM_BIT)
36 37
37static int signals_enabled = 1; 38/* These are used by both the signal handlers and
38static int pending = 0; 39 * block/unblock_signals. I don't want modifications cached in a
40 * register - they must go straight to memory.
41 */
42static volatile int signals_enabled = 1;
43static volatile int pending = 0;
39 44
40void sig_handler(int sig, struct sigcontext *sc) 45void sig_handler(int sig, struct sigcontext *sc)
41{ 46{
@@ -152,6 +157,12 @@ int change_sig(int signal, int on)
152void block_signals(void) 157void block_signals(void)
153{ 158{
154 signals_enabled = 0; 159 signals_enabled = 0;
160 /* This must return with signals disabled, so this barrier
161 * ensures that writes are flushed out before the return.
162 * This might matter if gcc figures out how to inline this and
163 * decides to shuffle this code into the caller.
164 */
165 mb();
155} 166}
156 167
157void unblock_signals(void) 168void unblock_signals(void)
@@ -171,9 +182,23 @@ void unblock_signals(void)
171 */ 182 */
172 signals_enabled = 1; 183 signals_enabled = 1;
173 184
185 /* Setting signals_enabled and reading pending must
186 * happen in this order.
187 */
188 mb();
189
174 save_pending = pending; 190 save_pending = pending;
175 if(save_pending == 0) 191 if(save_pending == 0){
192 /* This must return with signals enabled, so
193 * this barrier ensures that writes are
194 * flushed out before the return. This might
195 * matter if gcc figures out how to inline
196 * this (unlikely, given its size) and decides
197 * to shuffle this code into the caller.
198 */
199 mb();
176 return; 200 return;
201 }
177 202
178 pending = 0; 203 pending = 0;
179 204
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c
index cb9ab54146cc..9b34fe65949a 100644
--- a/arch/um/os-Linux/skas/process.c
+++ b/arch/um/os-Linux/skas/process.c
@@ -14,7 +14,7 @@
14#include <sys/mman.h> 14#include <sys/mman.h>
15#include <sys/user.h> 15#include <sys/user.h>
16#include <sys/time.h> 16#include <sys/time.h>
17#include <asm/unistd.h> 17#include <sys/syscall.h>
18#include <asm/types.h> 18#include <asm/types.h>
19#include "user.h" 19#include "user.h"
20#include "sysdep/ptrace.h" 20#include "sysdep/ptrace.h"
diff --git a/arch/um/os-Linux/sys-i386/tls.c b/arch/um/os-Linux/sys-i386/tls.c
index 6e945ab45843..256532034c62 100644
--- a/arch/um/os-Linux/sys-i386/tls.c
+++ b/arch/um/os-Linux/sys-i386/tls.c
@@ -1,6 +1,9 @@
1#include <errno.h> 1#include <errno.h>
2#include <linux/unistd.h> 2#include <linux/unistd.h>
3
3#include <sys/syscall.h> 4#include <sys/syscall.h>
5#include <unistd.h>
6
4#include "sysdep/tls.h" 7#include "sysdep/tls.h"
5#include "user_util.h" 8#include "user_util.h"
6 9
diff --git a/arch/um/os-Linux/time.c b/arch/um/os-Linux/time.c
index 38be096e750f..2115b8beb541 100644
--- a/arch/um/os-Linux/time.c
+++ b/arch/um/os-Linux/time.c
@@ -16,6 +16,7 @@
16#include "process.h" 16#include "process.h"
17#include "kern_constants.h" 17#include "kern_constants.h"
18#include "os.h" 18#include "os.h"
19#include "uml-config.h"
19 20
20int set_interval(int is_virtual) 21int set_interval(int is_virtual)
21{ 22{
@@ -30,7 +31,7 @@ int set_interval(int is_virtual)
30 return 0; 31 return 0;
31} 32}
32 33
33#ifdef CONFIG_MODE_TT 34#ifdef UML_CONFIG_MODE_TT
34void enable_timer(void) 35void enable_timer(void)
35{ 36{
36 set_interval(1); 37 set_interval(1);
diff --git a/arch/um/os-Linux/tls.c b/arch/um/os-Linux/tls.c
index a2de2580b8af..16215b990804 100644
--- a/arch/um/os-Linux/tls.c
+++ b/arch/um/os-Linux/tls.c
@@ -1,4 +1,5 @@
1#include <errno.h> 1#include <errno.h>
2#include <unistd.h>
2#include <sys/ptrace.h> 3#include <sys/ptrace.h>
3#include <sys/syscall.h> 4#include <sys/syscall.h>
4#include <asm/ldt.h> 5#include <asm/ldt.h>
diff --git a/arch/um/os-Linux/tt.c b/arch/um/os-Linux/tt.c
index 5461a065bbb9..3dc3a02d6263 100644
--- a/arch/um/os-Linux/tt.c
+++ b/arch/um/os-Linux/tt.c
@@ -10,7 +10,6 @@
10#include <errno.h> 10#include <errno.h>
11#include <stdarg.h> 11#include <stdarg.h>
12#include <stdlib.h> 12#include <stdlib.h>
13#include <setjmp.h>
14#include <sys/time.h> 13#include <sys/time.h>
15#include <sys/ptrace.h> 14#include <sys/ptrace.h>
16#include <linux/ptrace.h> 15#include <linux/ptrace.h>
diff --git a/arch/um/os-Linux/util.c b/arch/um/os-Linux/util.c
index 3f5b1514e8a7..56b8a50e8bc2 100644
--- a/arch/um/os-Linux/util.c
+++ b/arch/um/os-Linux/util.c
@@ -80,11 +80,18 @@ void setup_machinename(char *machine_out)
80 struct utsname host; 80 struct utsname host;
81 81
82 uname(&host); 82 uname(&host);
83#if defined(UML_CONFIG_UML_X86) && !defined(UML_CONFIG_64BIT) 83#ifdef UML_CONFIG_UML_X86
84# ifndef UML_CONFIG_64BIT
84 if (!strcmp(host.machine, "x86_64")) { 85 if (!strcmp(host.machine, "x86_64")) {
85 strcpy(machine_out, "i686"); 86 strcpy(machine_out, "i686");
86 return; 87 return;
87 } 88 }
89# else
90 if (!strcmp(host.machine, "i686")) {
91 strcpy(machine_out, "x86_64");
92 return;
93 }
94# endif
88#endif 95#endif
89 strcpy(machine_out, host.machine); 96 strcpy(machine_out, host.machine);
90} 97}
diff --git a/arch/um/sys-i386/unmap.c b/arch/um/sys-i386/unmap.c
index 8e55cd5d3d07..1b0ad0e4adcd 100644
--- a/arch/um/sys-i386/unmap.c
+++ b/arch/um/sys-i386/unmap.c
@@ -5,17 +5,20 @@
5 5
6#include <linux/mman.h> 6#include <linux/mman.h>
7#include <asm/unistd.h> 7#include <asm/unistd.h>
8#include <sys/syscall.h>
9 8
9static int errno;
10
11static inline _syscall2(int,munmap,void *,start,size_t,len)
12static inline _syscall6(void *,mmap2,void *,addr,size_t,len,int,prot,int,flags,int,fd,off_t,offset)
10int switcheroo(int fd, int prot, void *from, void *to, int size) 13int switcheroo(int fd, int prot, void *from, void *to, int size)
11{ 14{
12 if (syscall(__NR_munmap, to, size) < 0){ 15 if(munmap(to, size) < 0){
13 return(-1); 16 return(-1);
14 } 17 }
15 if (syscall(__NR_mmap2, to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1 ){ 18 if(mmap2(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1 ){
16 return(-1); 19 return(-1);
17 } 20 }
18 if (syscall(__NR_munmap, from, size) < 0){ 21 if(munmap(from, size) < 0){
19 return(-1); 22 return(-1);
20 } 23 }
21 return(0); 24 return(0);
diff --git a/arch/um/sys-x86_64/ksyms.c b/arch/um/sys-x86_64/ksyms.c
index 859273808203..12c593607c59 100644
--- a/arch/um/sys-x86_64/ksyms.c
+++ b/arch/um/sys-x86_64/ksyms.c
@@ -14,6 +14,3 @@ EXPORT_SYMBOL(__up_wakeup);
14 14
15/*XXX: we need them because they would be exported by x86_64 */ 15/*XXX: we need them because they would be exported by x86_64 */
16EXPORT_SYMBOL(__memcpy); 16EXPORT_SYMBOL(__memcpy);
17
18/* Networking helper routines. */
19EXPORT_SYMBOL(ip_compute_csum);
diff --git a/arch/um/sys-x86_64/stub_segv.c b/arch/um/sys-x86_64/stub_segv.c
index 1c967026c957..652fa34c2cd3 100644
--- a/arch/um/sys-x86_64/stub_segv.c
+++ b/arch/um/sys-x86_64/stub_segv.c
@@ -5,7 +5,6 @@
5 5
6#include <stddef.h> 6#include <stddef.h>
7#include <signal.h> 7#include <signal.h>
8#include <linux/compiler.h>
9#include <asm/unistd.h> 8#include <asm/unistd.h>
10#include "uml-config.h" 9#include "uml-config.h"
11#include "sysdep/sigcontext.h" 10#include "sysdep/sigcontext.h"
diff --git a/arch/um/sys-x86_64/unmap.c b/arch/um/sys-x86_64/unmap.c
index 57c9286a701b..f4a4bffd8a18 100644
--- a/arch/um/sys-x86_64/unmap.c
+++ b/arch/um/sys-x86_64/unmap.c
@@ -5,17 +5,20 @@
5 5
6#include <linux/mman.h> 6#include <linux/mman.h>
7#include <asm/unistd.h> 7#include <asm/unistd.h>
8#include <sys/syscall.h>
9 8
9static int errno;
10
11static inline _syscall2(int,munmap,void *,start,size_t,len)
12static inline _syscall6(void *,mmap,void *,addr,size_t,len,int,prot,int,flags,int,fd,off_t,offset)
10int switcheroo(int fd, int prot, void *from, void *to, int size) 13int switcheroo(int fd, int prot, void *from, void *to, int size)
11{ 14{
12 if (syscall(__NR_munmap, to, size) < 0){ 15 if(munmap(to, size) < 0){
13 return(-1); 16 return(-1);
14 } 17 }
15 if (syscall(__NR_mmap, to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1){ 18 if(mmap(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1){
16 return(-1); 19 return(-1);
17 } 20 }
18 if (syscall(__NR_munmap, from, size) < 0){ 21 if(munmap(from, size) < 0){
19 return(-1); 22 return(-1);
20 } 23 }
21 return(0); 24 return(0);
diff --git a/arch/v850/kernel/vmlinux.lds.S b/arch/v850/kernel/vmlinux.lds.S
index 63399219cd9f..88d087f527c9 100644
--- a/arch/v850/kernel/vmlinux.lds.S
+++ b/arch/v850/kernel/vmlinux.lds.S
@@ -140,13 +140,7 @@
140 ___setup_end = . ; \ 140 ___setup_end = . ; \
141 ___initcall_start = . ; \ 141 ___initcall_start = . ; \
142 *(.initcall.init) \ 142 *(.initcall.init) \
143 *(.initcall1.init) \ 143 INITCALLS \
144 *(.initcall2.init) \
145 *(.initcall3.init) \
146 *(.initcall4.init) \
147 *(.initcall5.init) \
148 *(.initcall6.init) \
149 *(.initcall7.init) \
150 . = ALIGN (4) ; \ 144 . = ALIGN (4) ; \
151 ___initcall_end = . ; \ 145 ___initcall_end = . ; \
152 ___con_initcall_start = .; \ 146 ___con_initcall_start = .; \
diff --git a/arch/x86_64/Makefile b/arch/x86_64/Makefile
index 1c0f18d4f887..6e38d4daeed7 100644
--- a/arch/x86_64/Makefile
+++ b/arch/x86_64/Makefile
@@ -54,6 +54,10 @@ endif
54cflags-y += $(call cc-option,-funit-at-a-time) 54cflags-y += $(call cc-option,-funit-at-a-time)
55# prevent gcc from generating any FP code by mistake 55# prevent gcc from generating any FP code by mistake
56cflags-y += $(call cc-option,-mno-sse -mno-mmx -mno-sse2 -mno-3dnow,) 56cflags-y += $(call cc-option,-mno-sse -mno-mmx -mno-sse2 -mno-3dnow,)
57# this works around some issues with generating unwind tables in older gccs
58# newer gccs do it by default
59cflags-y += -maccumulate-outgoing-args
60
57# do binutils support CFI? 61# do binutils support CFI?
58cflags-y += $(call as-instr,.cfi_startproc\n.cfi_endproc,-DCONFIG_AS_CFI=1,) 62cflags-y += $(call as-instr,.cfi_startproc\n.cfi_endproc,-DCONFIG_AS_CFI=1,)
59AFLAGS += $(call as-instr,.cfi_startproc\n.cfi_endproc,-DCONFIG_AS_CFI=1,) 63AFLAGS += $(call as-instr,.cfi_startproc\n.cfi_endproc,-DCONFIG_AS_CFI=1,)
@@ -62,8 +66,8 @@ AFLAGS += $(call as-instr,.cfi_startproc\n.cfi_endproc,-DCONFIG_AS_CFI=1,)
62cflags-y += $(call as-instr,.cfi_startproc\n.cfi_signal_frame\n.cfi_endproc,-DCONFIG_AS_CFI_SIGNAL_FRAME=1,) 66cflags-y += $(call as-instr,.cfi_startproc\n.cfi_signal_frame\n.cfi_endproc,-DCONFIG_AS_CFI_SIGNAL_FRAME=1,)
63AFLAGS += $(call as-instr,.cfi_startproc\n.cfi_signal_frame\n.cfi_endproc,-DCONFIG_AS_CFI_SIGNAL_FRAME=1,) 67AFLAGS += $(call as-instr,.cfi_startproc\n.cfi_signal_frame\n.cfi_endproc,-DCONFIG_AS_CFI_SIGNAL_FRAME=1,)
64 68
65cflags-$(CONFIG_CC_STACKPROTECTOR) += $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-x86_64-has-stack-protector.sh $(CC) -fstack-protector ) 69cflags-$(CONFIG_CC_STACKPROTECTOR) += $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-x86_64-has-stack-protector.sh "$(CC)" -fstack-protector )
66cflags-$(CONFIG_CC_STACKPROTECTOR_ALL) += $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-x86_64-has-stack-protector.sh $(CC) -fstack-protector-all ) 70cflags-$(CONFIG_CC_STACKPROTECTOR_ALL) += $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-x86_64-has-stack-protector.sh "$(CC)" -fstack-protector-all )
67 71
68CFLAGS += $(cflags-y) 72CFLAGS += $(cflags-y)
69CFLAGS_KERNEL += $(cflags-kernel-y) 73CFLAGS_KERNEL += $(cflags-kernel-y)
diff --git a/arch/x86_64/boot/setup.S b/arch/x86_64/boot/setup.S
index c3bfd223ab49..770940cc0108 100644
--- a/arch/x86_64/boot/setup.S
+++ b/arch/x86_64/boot/setup.S
@@ -836,13 +836,12 @@ gdt:
836 .word 0x9200 # data read/write 836 .word 0x9200 # data read/write
837 .word 0x00CF # granularity = 4096, 386 837 .word 0x00CF # granularity = 4096, 386
838 # (+5th nibble of limit) 838 # (+5th nibble of limit)
839gdt_end:
839idt_48: 840idt_48:
840 .word 0 # idt limit = 0 841 .word 0 # idt limit = 0
841 .word 0, 0 # idt base = 0L 842 .word 0, 0 # idt base = 0L
842gdt_48: 843gdt_48:
843 .word 0x8000 # gdt limit=2048, 844 .word gdt_end-gdt-1 # gdt limit
844 # 256 GDT entries
845
846 .word 0, 0 # gdt base (filled in later) 845 .word 0, 0 # gdt base (filled in later)
847 846
848# Include video setup & detection code 847# Include video setup & detection code
diff --git a/arch/x86_64/defconfig b/arch/x86_64/defconfig
index 47bfba6e9dc4..0f5d44e86be5 100644
--- a/arch/x86_64/defconfig
+++ b/arch/x86_64/defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.19-rc1 3# Linux kernel version: 2.6.19-rc2-git4
4# Thu Oct 5 13:04:43 2006 4# Sat Oct 21 03:38:52 2006
5# 5#
6CONFIG_X86_64=y 6CONFIG_X86_64=y
7CONFIG_64BIT=y 7CONFIG_64BIT=y
@@ -335,8 +335,8 @@ CONFIG_IPV6=y
335# CONFIG_INET6_XFRM_MODE_TUNNEL is not set 335# CONFIG_INET6_XFRM_MODE_TUNNEL is not set
336# CONFIG_INET6_XFRM_MODE_BEET is not set 336# CONFIG_INET6_XFRM_MODE_BEET is not set
337# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set 337# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
338CONFIG_IPV6_SIT=y
338# CONFIG_IPV6_TUNNEL is not set 339# CONFIG_IPV6_TUNNEL is not set
339# CONFIG_IPV6_SUBTREES is not set
340# CONFIG_IPV6_MULTIPLE_TABLES is not set 340# CONFIG_IPV6_MULTIPLE_TABLES is not set
341# CONFIG_NETWORK_SECMARK is not set 341# CONFIG_NETWORK_SECMARK is not set
342# CONFIG_NETFILTER is not set 342# CONFIG_NETFILTER is not set
@@ -438,6 +438,13 @@ CONFIG_BLK_DEV_INITRD=y
438# CONFIG_ATA_OVER_ETH is not set 438# CONFIG_ATA_OVER_ETH is not set
439 439
440# 440#
441# Misc devices
442#
443# CONFIG_IBM_ASM is not set
444# CONFIG_SGI_IOC4 is not set
445# CONFIG_TIFM_CORE is not set
446
447#
441# ATA/ATAPI/MFM/RLL support 448# ATA/ATAPI/MFM/RLL support
442# 449#
443CONFIG_IDE=y 450CONFIG_IDE=y
@@ -1008,6 +1015,7 @@ CONFIG_I2C_ISA=m
1008# 1015#
1009# Dallas's 1-wire bus 1016# Dallas's 1-wire bus
1010# 1017#
1018# CONFIG_W1 is not set
1011 1019
1012# 1020#
1013# Hardware Monitoring support 1021# Hardware Monitoring support
@@ -1059,12 +1067,6 @@ CONFIG_SENSORS_SMSC47B397=m
1059# CONFIG_HWMON_DEBUG_CHIP is not set 1067# CONFIG_HWMON_DEBUG_CHIP is not set
1060 1068
1061# 1069#
1062# Misc devices
1063#
1064# CONFIG_IBM_ASM is not set
1065# CONFIG_TIFM_CORE is not set
1066
1067#
1068# Multimedia devices 1070# Multimedia devices
1069# 1071#
1070# CONFIG_VIDEO_DEV is not set 1072# CONFIG_VIDEO_DEV is not set
@@ -1196,7 +1198,6 @@ CONFIG_USB_HIDINPUT=y
1196# CONFIG_USB_ATI_REMOTE2 is not set 1198# CONFIG_USB_ATI_REMOTE2 is not set
1197# CONFIG_USB_KEYSPAN_REMOTE is not set 1199# CONFIG_USB_KEYSPAN_REMOTE is not set
1198# CONFIG_USB_APPLETOUCH is not set 1200# CONFIG_USB_APPLETOUCH is not set
1199# CONFIG_USB_TRANCEVIBRATOR is not set
1200 1201
1201# 1202#
1202# USB Imaging devices 1203# USB Imaging devices
@@ -1242,6 +1243,7 @@ CONFIG_USB_MON=y
1242# CONFIG_USB_APPLEDISPLAY is not set 1243# CONFIG_USB_APPLEDISPLAY is not set
1243# CONFIG_USB_SISUSBVGA is not set 1244# CONFIG_USB_SISUSBVGA is not set
1244# CONFIG_USB_LD is not set 1245# CONFIG_USB_LD is not set
1246# CONFIG_USB_TRANCEVIBRATOR is not set
1245# CONFIG_USB_TEST is not set 1247# CONFIG_USB_TEST is not set
1246 1248
1247# 1249#
@@ -1318,6 +1320,7 @@ CONFIG_EXT3_FS=y
1318CONFIG_EXT3_FS_XATTR=y 1320CONFIG_EXT3_FS_XATTR=y
1319CONFIG_EXT3_FS_POSIX_ACL=y 1321CONFIG_EXT3_FS_POSIX_ACL=y
1320# CONFIG_EXT3_FS_SECURITY is not set 1322# CONFIG_EXT3_FS_SECURITY is not set
1323# CONFIG_EXT4DEV_FS is not set
1321CONFIG_JBD=y 1324CONFIG_JBD=y
1322# CONFIG_JBD_DEBUG is not set 1325# CONFIG_JBD_DEBUG is not set
1323CONFIG_FS_MBCACHE=y 1326CONFIG_FS_MBCACHE=y
@@ -1341,6 +1344,7 @@ CONFIG_DNOTIFY=y
1341# CONFIG_AUTOFS_FS is not set 1344# CONFIG_AUTOFS_FS is not set
1342CONFIG_AUTOFS4_FS=y 1345CONFIG_AUTOFS4_FS=y
1343# CONFIG_FUSE_FS is not set 1346# CONFIG_FUSE_FS is not set
1347CONFIG_GENERIC_ACL=y
1344 1348
1345# 1349#
1346# CD-ROM/DVD Filesystems 1350# CD-ROM/DVD Filesystems
@@ -1418,7 +1422,6 @@ CONFIG_SUNRPC=y
1418# CONFIG_CODA_FS is not set 1422# CONFIG_CODA_FS is not set
1419# CONFIG_AFS_FS is not set 1423# CONFIG_AFS_FS is not set
1420# CONFIG_9P_FS is not set 1424# CONFIG_9P_FS is not set
1421CONFIG_GENERIC_ACL=y
1422 1425
1423# 1426#
1424# Partition Types 1427# Partition Types
@@ -1471,10 +1474,6 @@ CONFIG_NLS_ISO8859_15=y
1471CONFIG_NLS_UTF8=y 1474CONFIG_NLS_UTF8=y
1472 1475
1473# 1476#
1474# Distributed Lock Manager
1475#
1476
1477#
1478# Instrumentation Support 1477# Instrumentation Support
1479# 1478#
1480CONFIG_PROFILING=y 1479CONFIG_PROFILING=y
@@ -1512,6 +1511,7 @@ CONFIG_DEBUG_FS=y
1512CONFIG_UNWIND_INFO=y 1511CONFIG_UNWIND_INFO=y
1513CONFIG_STACK_UNWIND=y 1512CONFIG_STACK_UNWIND=y
1514# CONFIG_FORCED_INLINING is not set 1513# CONFIG_FORCED_INLINING is not set
1514# CONFIG_HEADERS_CHECK is not set
1515# CONFIG_RCU_TORTURE_TEST is not set 1515# CONFIG_RCU_TORTURE_TEST is not set
1516# CONFIG_LKDTM is not set 1516# CONFIG_LKDTM is not set
1517# CONFIG_DEBUG_RODATA is not set 1517# CONFIG_DEBUG_RODATA is not set
diff --git a/arch/x86_64/ia32/ia32_signal.c b/arch/x86_64/ia32/ia32_signal.c
index a6ba9951e86c..0e0a266d976f 100644
--- a/arch/x86_64/ia32/ia32_signal.c
+++ b/arch/x86_64/ia32/ia32_signal.c
@@ -579,6 +579,11 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
579 regs->rsp = (unsigned long) frame; 579 regs->rsp = (unsigned long) frame;
580 regs->rip = (unsigned long) ka->sa.sa_handler; 580 regs->rip = (unsigned long) ka->sa.sa_handler;
581 581
582 /* Make -mregparm=3 work */
583 regs->rax = sig;
584 regs->rdx = (unsigned long) &frame->info;
585 regs->rcx = (unsigned long) &frame->uc;
586
582 asm volatile("movl %0,%%ds" :: "r" (__USER32_DS)); 587 asm volatile("movl %0,%%ds" :: "r" (__USER32_DS));
583 asm volatile("movl %0,%%es" :: "r" (__USER32_DS)); 588 asm volatile("movl %0,%%es" :: "r" (__USER32_DS));
584 589
diff --git a/arch/x86_64/ia32/ptrace32.c b/arch/x86_64/ia32/ptrace32.c
index 3a7561d4703e..04566fe5de49 100644
--- a/arch/x86_64/ia32/ptrace32.c
+++ b/arch/x86_64/ia32/ptrace32.c
@@ -244,6 +244,8 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
244 case PTRACE_DETACH: 244 case PTRACE_DETACH:
245 case PTRACE_SYSCALL: 245 case PTRACE_SYSCALL:
246 case PTRACE_SETOPTIONS: 246 case PTRACE_SETOPTIONS:
247 case PTRACE_SET_THREAD_AREA:
248 case PTRACE_GET_THREAD_AREA:
247 return sys_ptrace(request, pid, addr, data); 249 return sys_ptrace(request, pid, addr, data);
248 250
249 default: 251 default:
diff --git a/arch/x86_64/kernel/e820.c b/arch/x86_64/kernel/e820.c
index b3f0908668ec..6fe191c58084 100644
--- a/arch/x86_64/kernel/e820.c
+++ b/arch/x86_64/kernel/e820.c
@@ -54,13 +54,13 @@ static inline int bad_addr(unsigned long *addrp, unsigned long size)
54 54
55 /* various gunk below that needed for SMP startup */ 55 /* various gunk below that needed for SMP startup */
56 if (addr < 0x8000) { 56 if (addr < 0x8000) {
57 *addrp = 0x8000; 57 *addrp = PAGE_ALIGN(0x8000);
58 return 1; 58 return 1;
59 } 59 }
60 60
61 /* direct mapping tables of the kernel */ 61 /* direct mapping tables of the kernel */
62 if (last >= table_start<<PAGE_SHIFT && addr < table_end<<PAGE_SHIFT) { 62 if (last >= table_start<<PAGE_SHIFT && addr < table_end<<PAGE_SHIFT) {
63 *addrp = table_end << PAGE_SHIFT; 63 *addrp = PAGE_ALIGN(table_end << PAGE_SHIFT);
64 return 1; 64 return 1;
65 } 65 }
66 66
@@ -68,18 +68,18 @@ static inline int bad_addr(unsigned long *addrp, unsigned long size)
68#ifdef CONFIG_BLK_DEV_INITRD 68#ifdef CONFIG_BLK_DEV_INITRD
69 if (LOADER_TYPE && INITRD_START && last >= INITRD_START && 69 if (LOADER_TYPE && INITRD_START && last >= INITRD_START &&
70 addr < INITRD_START+INITRD_SIZE) { 70 addr < INITRD_START+INITRD_SIZE) {
71 *addrp = INITRD_START + INITRD_SIZE; 71 *addrp = PAGE_ALIGN(INITRD_START + INITRD_SIZE);
72 return 1; 72 return 1;
73 } 73 }
74#endif 74#endif
75 /* kernel code */ 75 /* kernel code */
76 if (last >= __pa_symbol(&_text) && last < __pa_symbol(&_end)) { 76 if (last >= __pa_symbol(&_text) && addr < __pa_symbol(&_end)) {
77 *addrp = __pa_symbol(&_end); 77 *addrp = PAGE_ALIGN(__pa_symbol(&_end));
78 return 1; 78 return 1;
79 } 79 }
80 80
81 if (last >= ebda_addr && addr < ebda_addr + ebda_size) { 81 if (last >= ebda_addr && addr < ebda_addr + ebda_size) {
82 *addrp = ebda_addr + ebda_size; 82 *addrp = PAGE_ALIGN(ebda_addr + ebda_size);
83 return 1; 83 return 1;
84 } 84 }
85 85
@@ -152,7 +152,7 @@ unsigned long __init find_e820_area(unsigned long start, unsigned long end, unsi
152 continue; 152 continue;
153 while (bad_addr(&addr, size) && addr+size <= ei->addr+ei->size) 153 while (bad_addr(&addr, size) && addr+size <= ei->addr+ei->size)
154 ; 154 ;
155 last = addr + size; 155 last = PAGE_ALIGN(addr) + size;
156 if (last > ei->addr + ei->size) 156 if (last > ei->addr + ei->size)
157 continue; 157 continue;
158 if (last > end) 158 if (last > end)
@@ -278,7 +278,7 @@ e820_register_active_regions(int nid, unsigned long start_pfn,
278 >> PAGE_SHIFT; 278 >> PAGE_SHIFT;
279 279
280 /* Skip map entries smaller than a page */ 280 /* Skip map entries smaller than a page */
281 if (ei_startpfn > ei_endpfn) 281 if (ei_startpfn >= ei_endpfn)
282 continue; 282 continue;
283 283
284 /* Check if end_pfn_map should be updated */ 284 /* Check if end_pfn_map should be updated */
@@ -594,7 +594,9 @@ static int __init parse_memmap_opt(char *p)
594 * size before original memory map is 594 * size before original memory map is
595 * reset. 595 * reset.
596 */ 596 */
597 e820_register_active_regions(0, 0, -1UL);
597 saved_max_pfn = e820_end_of_ram(); 598 saved_max_pfn = e820_end_of_ram();
599 remove_all_active_ranges();
598#endif 600#endif
599 end_pfn_map = 0; 601 end_pfn_map = 0;
600 e820.nr_map = 0; 602 e820.nr_map = 0;
diff --git a/arch/x86_64/kernel/early-quirks.c b/arch/x86_64/kernel/early-quirks.c
index 208e38a372c1..68273bff58cc 100644
--- a/arch/x86_64/kernel/early-quirks.c
+++ b/arch/x86_64/kernel/early-quirks.c
@@ -45,7 +45,13 @@ static void nvidia_bugs(void)
45 /* 45 /*
46 * All timer overrides on Nvidia are 46 * All timer overrides on Nvidia are
47 * wrong unless HPET is enabled. 47 * wrong unless HPET is enabled.
48 * Unfortunately that's not true on many Asus boards.
49 * We don't know yet how to detect this automatically, but
50 * at least allow a command line override.
48 */ 51 */
52 if (acpi_use_timer_override)
53 return;
54
49 nvidia_hpet_detected = 0; 55 nvidia_hpet_detected = 0;
50 acpi_table_parse(ACPI_HPET, nvidia_hpet_check); 56 acpi_table_parse(ACPI_HPET, nvidia_hpet_check);
51 if (nvidia_hpet_detected == 0) { 57 if (nvidia_hpet_detected == 0) {
@@ -53,6 +59,8 @@ static void nvidia_bugs(void)
53 printk(KERN_INFO "Nvidia board " 59 printk(KERN_INFO "Nvidia board "
54 "detected. Ignoring ACPI " 60 "detected. Ignoring ACPI "
55 "timer override.\n"); 61 "timer override.\n");
62 printk(KERN_INFO "If you got timer trouble "
63 "try acpi_use_timer_override\n");
56 } 64 }
57#endif 65#endif
58 /* RED-PEN skip them on mptables too? */ 66 /* RED-PEN skip them on mptables too? */
@@ -61,10 +69,11 @@ static void nvidia_bugs(void)
61 69
62static void ati_bugs(void) 70static void ati_bugs(void)
63{ 71{
64#if 1 /* for testing */ 72 if (timer_over_8254 == 1) {
65 printk("ATI board detected\n"); 73 timer_over_8254 = 0;
66#endif 74 printk(KERN_INFO
67 /* No bugs right now */ 75 "ATI board detected. Disabling timer routing over 8254.\n");
76 }
68} 77}
69 78
70struct chipset { 79struct chipset {
diff --git a/arch/x86_64/kernel/entry.S b/arch/x86_64/kernel/entry.S
index 38a7b2d528e2..7d401b00d822 100644
--- a/arch/x86_64/kernel/entry.S
+++ b/arch/x86_64/kernel/entry.S
@@ -315,6 +315,8 @@ tracesys:
315 LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */ 315 LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */
316 RESTORE_REST 316 RESTORE_REST
317 cmpq $__NR_syscall_max,%rax 317 cmpq $__NR_syscall_max,%rax
318 movq $-ENOSYS,%rcx
319 cmova %rcx,%rax
318 ja 1f 320 ja 1f
319 movq %r10,%rcx /* fixup for C */ 321 movq %r10,%rcx /* fixup for C */
320 call *sys_call_table(,%rax,8) 322 call *sys_call_table(,%rax,8)
@@ -535,8 +537,6 @@ END(stub_rt_sigreturn)
5351: incl %gs:pda_irqcount 5371: incl %gs:pda_irqcount
536 cmoveq %gs:pda_irqstackptr,%rsp 538 cmoveq %gs:pda_irqstackptr,%rsp
537 push %rbp # backlink for old unwinder 539 push %rbp # backlink for old unwinder
538 CFI_ADJUST_CFA_OFFSET 8
539 CFI_REL_OFFSET rbp,0
540 /* 540 /*
541 * We entered an interrupt context - irqs are off: 541 * We entered an interrupt context - irqs are off:
542 */ 542 */
@@ -980,11 +980,6 @@ ENTRY(kernel_thread)
980 call do_fork 980 call do_fork
981 movq %rax,RAX(%rsp) 981 movq %rax,RAX(%rsp)
982 xorl %edi,%edi 982 xorl %edi,%edi
983 test %rax,%rax
984 jnz 1f
985 /* terminate stack in child */
986 movq %rdi,RIP(%rsp)
9871:
988 983
989 /* 984 /*
990 * It isn't worth to check for reschedule here, 985 * It isn't worth to check for reschedule here,
@@ -1176,7 +1171,6 @@ ENTRY(call_softirq)
1176 incl %gs:pda_irqcount 1171 incl %gs:pda_irqcount
1177 cmove %gs:pda_irqstackptr,%rsp 1172 cmove %gs:pda_irqstackptr,%rsp
1178 push %rbp # backlink for old unwinder 1173 push %rbp # backlink for old unwinder
1179 CFI_ADJUST_CFA_OFFSET 8
1180 call __do_softirq 1174 call __do_softirq
1181 leaveq 1175 leaveq
1182 CFI_DEF_CFA_REGISTER rsp 1176 CFI_DEF_CFA_REGISTER rsp
diff --git a/arch/x86_64/kernel/genapic_flat.c b/arch/x86_64/kernel/genapic_flat.c
index 0dfc223c1839..7c01db8fa9d1 100644
--- a/arch/x86_64/kernel/genapic_flat.c
+++ b/arch/x86_64/kernel/genapic_flat.c
@@ -153,7 +153,7 @@ struct genapic apic_flat = {
153 153
154static cpumask_t physflat_target_cpus(void) 154static cpumask_t physflat_target_cpus(void)
155{ 155{
156 return cpumask_of_cpu(0); 156 return cpu_online_map;
157} 157}
158 158
159static cpumask_t physflat_vector_allocation_domain(int cpu) 159static cpumask_t physflat_vector_allocation_domain(int cpu)
diff --git a/arch/x86_64/kernel/i8259.c b/arch/x86_64/kernel/i8259.c
index 0612a33bb896..c4ef801b765b 100644
--- a/arch/x86_64/kernel/i8259.c
+++ b/arch/x86_64/kernel/i8259.c
@@ -178,7 +178,8 @@ void make_8259A_irq(unsigned int irq)
178{ 178{
179 disable_irq_nosync(irq); 179 disable_irq_nosync(irq);
180 io_apic_irqs &= ~(1<<irq); 180 io_apic_irqs &= ~(1<<irq);
181 set_irq_chip_and_handler(irq, &i8259A_chip, handle_level_irq); 181 set_irq_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
182 "XT");
182 enable_irq(irq); 183 enable_irq(irq);
183} 184}
184 185
@@ -431,8 +432,8 @@ void __init init_ISA_irqs (void)
431 /* 432 /*
432 * 16 old-style INTA-cycle interrupts: 433 * 16 old-style INTA-cycle interrupts:
433 */ 434 */
434 set_irq_chip_and_handler(i, &i8259A_chip, 435 set_irq_chip_and_handler_name(i, &i8259A_chip,
435 handle_level_irq); 436 handle_level_irq, "XT");
436 } else { 437 } else {
437 /* 438 /*
438 * 'high' PCI IRQs filled in on demand 439 * 'high' PCI IRQs filled in on demand
diff --git a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c
index 771bcf77daf2..14654e682411 100644
--- a/arch/x86_64/kernel/io_apic.c
+++ b/arch/x86_64/kernel/io_apic.c
@@ -57,13 +57,13 @@ static int no_timer_check;
57 57
58static int disable_timer_pin_1 __initdata; 58static int disable_timer_pin_1 __initdata;
59 59
60int timer_over_8254 __initdata = 0; 60int timer_over_8254 __initdata = 1;
61 61
62/* Where if anywhere is the i8259 connect in external int mode */ 62/* Where if anywhere is the i8259 connect in external int mode */
63static struct { int pin, apic; } ioapic_i8259 = { -1, -1 }; 63static struct { int pin, apic; } ioapic_i8259 = { -1, -1 };
64 64
65static DEFINE_SPINLOCK(ioapic_lock); 65static DEFINE_SPINLOCK(ioapic_lock);
66static DEFINE_SPINLOCK(vector_lock); 66DEFINE_SPINLOCK(vector_lock);
67 67
68/* 68/*
69 * # of IRQ routing registers 69 * # of IRQ routing registers
@@ -88,6 +88,52 @@ static struct irq_pin_list {
88 short apic, pin, next; 88 short apic, pin, next;
89} irq_2_pin[PIN_MAP_SIZE]; 89} irq_2_pin[PIN_MAP_SIZE];
90 90
91struct io_apic {
92 unsigned int index;
93 unsigned int unused[3];
94 unsigned int data;
95};
96
97static __attribute_const__ struct io_apic __iomem *io_apic_base(int idx)
98{
99 return (void __iomem *) __fix_to_virt(FIX_IO_APIC_BASE_0 + idx)
100 + (mp_ioapics[idx].mpc_apicaddr & ~PAGE_MASK);
101}
102
103static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg)
104{
105 struct io_apic __iomem *io_apic = io_apic_base(apic);
106 writel(reg, &io_apic->index);
107 return readl(&io_apic->data);
108}
109
110static inline void io_apic_write(unsigned int apic, unsigned int reg, unsigned int value)
111{
112 struct io_apic __iomem *io_apic = io_apic_base(apic);
113 writel(reg, &io_apic->index);
114 writel(value, &io_apic->data);
115}
116
117/*
118 * Re-write a value: to be used for read-modify-write
119 * cycles where the read already set up the index register.
120 */
121static inline void io_apic_modify(unsigned int apic, unsigned int value)
122{
123 struct io_apic __iomem *io_apic = io_apic_base(apic);
124 writel(value, &io_apic->data);
125}
126
127/*
128 * Synchronize the IO-APIC and the CPU by doing
129 * a dummy read from the IO-APIC
130 */
131static inline void io_apic_sync(unsigned int apic)
132{
133 struct io_apic __iomem *io_apic = io_apic_base(apic);
134 readl(&io_apic->data);
135}
136
91#define __DO_ACTION(R, ACTION, FINAL) \ 137#define __DO_ACTION(R, ACTION, FINAL) \
92 \ 138 \
93{ \ 139{ \
@@ -126,12 +172,34 @@ static struct IO_APIC_route_entry ioapic_read_entry(int apic, int pin)
126 return eu.entry; 172 return eu.entry;
127} 173}
128 174
175/*
176 * When we write a new IO APIC routing entry, we need to write the high
177 * word first! If the mask bit in the low word is clear, we will enable
178 * the interrupt, and we need to make sure the entry is fully populated
179 * before that happens.
180 */
129static void ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e) 181static void ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e)
130{ 182{
131 unsigned long flags; 183 unsigned long flags;
132 union entry_union eu; 184 union entry_union eu;
133 eu.entry = e; 185 eu.entry = e;
134 spin_lock_irqsave(&ioapic_lock, flags); 186 spin_lock_irqsave(&ioapic_lock, flags);
187 io_apic_write(apic, 0x11 + 2*pin, eu.w2);
188 io_apic_write(apic, 0x10 + 2*pin, eu.w1);
189 spin_unlock_irqrestore(&ioapic_lock, flags);
190}
191
192/*
193 * When we mask an IO APIC routing entry, we need to write the low
194 * word first, in order to set the mask bit before we change the
195 * high bits!
196 */
197static void ioapic_mask_entry(int apic, int pin)
198{
199 unsigned long flags;
200 union entry_union eu = { .entry.mask = 1 };
201
202 spin_lock_irqsave(&ioapic_lock, flags);
135 io_apic_write(apic, 0x10 + 2*pin, eu.w1); 203 io_apic_write(apic, 0x10 + 2*pin, eu.w1);
136 io_apic_write(apic, 0x11 + 2*pin, eu.w2); 204 io_apic_write(apic, 0x11 + 2*pin, eu.w2);
137 spin_unlock_irqrestore(&ioapic_lock, flags); 205 spin_unlock_irqrestore(&ioapic_lock, flags);
@@ -256,9 +324,7 @@ static void clear_IO_APIC_pin(unsigned int apic, unsigned int pin)
256 /* 324 /*
257 * Disable it in the IO-APIC irq-routing table: 325 * Disable it in the IO-APIC irq-routing table:
258 */ 326 */
259 memset(&entry, 0, sizeof(entry)); 327 ioapic_mask_entry(apic, pin);
260 entry.mask = 1;
261 ioapic_write_entry(apic, pin, entry);
262} 328}
263 329
264static void clear_IO_APIC (void) 330static void clear_IO_APIC (void)
@@ -612,15 +678,15 @@ static int __assign_irq_vector(int irq, cpumask_t mask, cpumask_t *result)
612 * Also, we've got to be careful not to trash gate 678 * Also, we've got to be careful not to trash gate
613 * 0x80, because int 0x80 is hm, kind of importantish. ;) 679 * 0x80, because int 0x80 is hm, kind of importantish. ;)
614 */ 680 */
615 static struct { 681 static int current_vector = FIRST_DEVICE_VECTOR, current_offset = 0;
616 int vector;
617 int offset;
618 } pos[NR_CPUS] = { [ 0 ... NR_CPUS - 1] = {FIRST_DEVICE_VECTOR, 0} };
619 int old_vector = -1; 682 int old_vector = -1;
620 int cpu; 683 int cpu;
621 684
622 BUG_ON((unsigned)irq >= NR_IRQ_VECTORS); 685 BUG_ON((unsigned)irq >= NR_IRQ_VECTORS);
623 686
687 /* Only try and allocate irqs on cpus that are present */
688 cpus_and(mask, mask, cpu_online_map);
689
624 if (irq_vector[irq] > 0) 690 if (irq_vector[irq] > 0)
625 old_vector = irq_vector[irq]; 691 old_vector = irq_vector[irq];
626 if (old_vector > 0) { 692 if (old_vector > 0) {
@@ -630,15 +696,15 @@ static int __assign_irq_vector(int irq, cpumask_t mask, cpumask_t *result)
630 } 696 }
631 697
632 for_each_cpu_mask(cpu, mask) { 698 for_each_cpu_mask(cpu, mask) {
633 cpumask_t domain; 699 cpumask_t domain, new_mask;
634 int first, new_cpu; 700 int new_cpu;
635 int vector, offset; 701 int vector, offset;
636 702
637 domain = vector_allocation_domain(cpu); 703 domain = vector_allocation_domain(cpu);
638 first = first_cpu(domain); 704 cpus_and(new_mask, domain, cpu_online_map);
639 705
640 vector = pos[first].vector; 706 vector = current_vector;
641 offset = pos[first].offset; 707 offset = current_offset;
642next: 708next:
643 vector += 8; 709 vector += 8;
644 if (vector >= FIRST_SYSTEM_VECTOR) { 710 if (vector >= FIRST_SYSTEM_VECTOR) {
@@ -646,24 +712,24 @@ next:
646 offset = (offset + 1) % 8; 712 offset = (offset + 1) % 8;
647 vector = FIRST_DEVICE_VECTOR + offset; 713 vector = FIRST_DEVICE_VECTOR + offset;
648 } 714 }
649 if (unlikely(pos[first].vector == vector)) 715 if (unlikely(current_vector == vector))
650 continue; 716 continue;
651 if (vector == IA32_SYSCALL_VECTOR) 717 if (vector == IA32_SYSCALL_VECTOR)
652 goto next; 718 goto next;
653 for_each_cpu_mask(new_cpu, domain) 719 for_each_cpu_mask(new_cpu, new_mask)
654 if (per_cpu(vector_irq, cpu)[vector] != -1) 720 if (per_cpu(vector_irq, new_cpu)[vector] != -1)
655 goto next; 721 goto next;
656 /* Found one! */ 722 /* Found one! */
657 for_each_cpu_mask(new_cpu, domain) { 723 current_vector = vector;
658 pos[cpu].vector = vector; 724 current_offset = offset;
659 pos[cpu].offset = offset;
660 }
661 if (old_vector >= 0) { 725 if (old_vector >= 0) {
726 cpumask_t old_mask;
662 int old_cpu; 727 int old_cpu;
663 for_each_cpu_mask(old_cpu, domain) 728 cpus_and(old_mask, irq_domain[irq], cpu_online_map);
729 for_each_cpu_mask(old_cpu, old_mask)
664 per_cpu(vector_irq, old_cpu)[old_vector] = -1; 730 per_cpu(vector_irq, old_cpu)[old_vector] = -1;
665 } 731 }
666 for_each_cpu_mask(new_cpu, domain) 732 for_each_cpu_mask(new_cpu, new_mask)
667 per_cpu(vector_irq, new_cpu)[vector] = irq; 733 per_cpu(vector_irq, new_cpu)[vector] = irq;
668 irq_vector[irq] = vector; 734 irq_vector[irq] = vector;
669 irq_domain[irq] = domain; 735 irq_domain[irq] = domain;
@@ -684,6 +750,32 @@ static int assign_irq_vector(int irq, cpumask_t mask, cpumask_t *result)
684 return vector; 750 return vector;
685} 751}
686 752
753void __setup_vector_irq(int cpu)
754{
755 /* Initialize vector_irq on a new cpu */
756 /* This function must be called with vector_lock held */
757 unsigned long flags;
758 int irq, vector;
759
760
761 /* Mark the inuse vectors */
762 for (irq = 0; irq < NR_IRQ_VECTORS; ++irq) {
763 if (!cpu_isset(cpu, irq_domain[irq]))
764 continue;
765 vector = irq_vector[irq];
766 per_cpu(vector_irq, cpu)[vector] = irq;
767 }
768 /* Mark the free vectors */
769 for (vector = 0; vector < NR_VECTORS; ++vector) {
770 irq = per_cpu(vector_irq, cpu)[vector];
771 if (irq < 0)
772 continue;
773 if (!cpu_isset(cpu, irq_domain[irq]))
774 per_cpu(vector_irq, cpu)[vector] = -1;
775 }
776}
777
778
687extern void (*interrupt[NR_IRQS])(void); 779extern void (*interrupt[NR_IRQS])(void);
688 780
689static struct irq_chip ioapic_chip; 781static struct irq_chip ioapic_chip;
@@ -696,11 +788,13 @@ static void ioapic_register_intr(int irq, int vector, unsigned long trigger)
696{ 788{
697 if ((trigger == IOAPIC_AUTO && IO_APIC_irq_trigger(irq)) || 789 if ((trigger == IOAPIC_AUTO && IO_APIC_irq_trigger(irq)) ||
698 trigger == IOAPIC_LEVEL) 790 trigger == IOAPIC_LEVEL)
699 set_irq_chip_and_handler(irq, &ioapic_chip, 791 set_irq_chip_and_handler_name(irq, &ioapic_chip,
700 handle_fasteoi_irq); 792 handle_fasteoi_irq, "fasteoi");
701 else 793 else {
702 set_irq_chip_and_handler(irq, &ioapic_chip, 794 irq_desc[irq].status |= IRQ_DELAYED_DISABLE;
703 handle_edge_irq); 795 set_irq_chip_and_handler_name(irq, &ioapic_chip,
796 handle_edge_irq, "edge");
797 }
704} 798}
705 799
706static void __init setup_IO_APIC_irqs(void) 800static void __init setup_IO_APIC_irqs(void)
@@ -806,7 +900,7 @@ static void __init setup_ExtINT_IRQ0_pin(unsigned int apic, unsigned int pin, in
806 * The timer IRQ doesn't have to know that behind the 900 * The timer IRQ doesn't have to know that behind the
807 * scene we have a 8259A-master in AEOI mode ... 901 * scene we have a 8259A-master in AEOI mode ...
808 */ 902 */
809 set_irq_chip_and_handler(0, &ioapic_chip, handle_edge_irq); 903 set_irq_chip_and_handler_name(0, &ioapic_chip, handle_edge_irq, "edge");
810 904
811 /* 905 /*
812 * Add it to the IO-APIC irq-routing table: 906 * Add it to the IO-APIC irq-routing table:
@@ -1255,12 +1349,15 @@ static int ioapic_retrigger_irq(unsigned int irq)
1255{ 1349{
1256 cpumask_t mask; 1350 cpumask_t mask;
1257 unsigned vector; 1351 unsigned vector;
1352 unsigned long flags;
1258 1353
1354 spin_lock_irqsave(&vector_lock, flags);
1259 vector = irq_vector[irq]; 1355 vector = irq_vector[irq];
1260 cpus_clear(mask); 1356 cpus_clear(mask);
1261 cpu_set(vector >> 8, mask); 1357 cpu_set(first_cpu(irq_domain[irq]), mask);
1262 1358
1263 send_IPI_mask(mask, vector & 0xff); 1359 send_IPI_mask(mask, vector);
1360 spin_unlock_irqrestore(&vector_lock, flags);
1264 1361
1265 return 1; 1362 return 1;
1266} 1363}
@@ -1839,7 +1936,7 @@ int arch_setup_msi_irq(unsigned int irq, struct pci_dev *dev)
1839 1936
1840 write_msi_msg(irq, &msg); 1937 write_msi_msg(irq, &msg);
1841 1938
1842 set_irq_chip_and_handler(irq, &msi_chip, handle_edge_irq); 1939 set_irq_chip_and_handler_name(irq, &msi_chip, handle_edge_irq, "edge");
1843 1940
1844 return 0; 1941 return 0;
1845} 1942}
@@ -1860,18 +1957,16 @@ void arch_teardown_msi_irq(unsigned int irq)
1860 1957
1861static void target_ht_irq(unsigned int irq, unsigned int dest, u8 vector) 1958static void target_ht_irq(unsigned int irq, unsigned int dest, u8 vector)
1862{ 1959{
1863 u32 low, high; 1960 struct ht_irq_msg msg;
1864 low = read_ht_irq_low(irq); 1961 fetch_ht_irq_msg(irq, &msg);
1865 high = read_ht_irq_high(irq);
1866 1962
1867 low &= ~(HT_IRQ_LOW_VECTOR_MASK | HT_IRQ_LOW_DEST_ID_MASK); 1963 msg.address_lo &= ~(HT_IRQ_LOW_VECTOR_MASK | HT_IRQ_LOW_DEST_ID_MASK);
1868 high &= ~(HT_IRQ_HIGH_DEST_ID_MASK); 1964 msg.address_hi &= ~(HT_IRQ_HIGH_DEST_ID_MASK);
1869 1965
1870 low |= HT_IRQ_LOW_VECTOR(vector) | HT_IRQ_LOW_DEST_ID(dest); 1966 msg.address_lo |= HT_IRQ_LOW_VECTOR(vector) | HT_IRQ_LOW_DEST_ID(dest);
1871 high |= HT_IRQ_HIGH_DEST_ID(dest); 1967 msg.address_hi |= HT_IRQ_HIGH_DEST_ID(dest);
1872 1968
1873 write_ht_irq_low(irq, low); 1969 write_ht_irq_msg(irq, &msg);
1874 write_ht_irq_high(irq, high);
1875} 1970}
1876 1971
1877static void set_ht_irq_affinity(unsigned int irq, cpumask_t mask) 1972static void set_ht_irq_affinity(unsigned int irq, cpumask_t mask)
@@ -1892,12 +1987,12 @@ static void set_ht_irq_affinity(unsigned int irq, cpumask_t mask)
1892 1987
1893 dest = cpu_mask_to_apicid(tmp); 1988 dest = cpu_mask_to_apicid(tmp);
1894 1989
1895 target_ht_irq(irq, dest, vector & 0xff); 1990 target_ht_irq(irq, dest, vector);
1896 set_native_irq_info(irq, mask); 1991 set_native_irq_info(irq, mask);
1897} 1992}
1898#endif 1993#endif
1899 1994
1900static struct hw_interrupt_type ht_irq_chip = { 1995static struct irq_chip ht_irq_chip = {
1901 .name = "PCI-HT", 1996 .name = "PCI-HT",
1902 .mask = mask_ht_irq, 1997 .mask = mask_ht_irq,
1903 .unmask = unmask_ht_irq, 1998 .unmask = unmask_ht_irq,
@@ -1915,14 +2010,15 @@ int arch_setup_ht_irq(unsigned int irq, struct pci_dev *dev)
1915 2010
1916 vector = assign_irq_vector(irq, TARGET_CPUS, &tmp); 2011 vector = assign_irq_vector(irq, TARGET_CPUS, &tmp);
1917 if (vector >= 0) { 2012 if (vector >= 0) {
1918 u32 low, high; 2013 struct ht_irq_msg msg;
1919 unsigned dest; 2014 unsigned dest;
1920 2015
1921 dest = cpu_mask_to_apicid(tmp); 2016 dest = cpu_mask_to_apicid(tmp);
1922 2017
1923 high = HT_IRQ_HIGH_DEST_ID(dest); 2018 msg.address_hi = HT_IRQ_HIGH_DEST_ID(dest);
1924 2019
1925 low = HT_IRQ_LOW_BASE | 2020 msg.address_lo =
2021 HT_IRQ_LOW_BASE |
1926 HT_IRQ_LOW_DEST_ID(dest) | 2022 HT_IRQ_LOW_DEST_ID(dest) |
1927 HT_IRQ_LOW_VECTOR(vector) | 2023 HT_IRQ_LOW_VECTOR(vector) |
1928 ((INT_DEST_MODE == 0) ? 2024 ((INT_DEST_MODE == 0) ?
@@ -1931,12 +2027,13 @@ int arch_setup_ht_irq(unsigned int irq, struct pci_dev *dev)
1931 HT_IRQ_LOW_RQEOI_EDGE | 2027 HT_IRQ_LOW_RQEOI_EDGE |
1932 ((INT_DELIVERY_MODE != dest_LowestPrio) ? 2028 ((INT_DELIVERY_MODE != dest_LowestPrio) ?
1933 HT_IRQ_LOW_MT_FIXED : 2029 HT_IRQ_LOW_MT_FIXED :
1934 HT_IRQ_LOW_MT_ARBITRATED); 2030 HT_IRQ_LOW_MT_ARBITRATED) |
2031 HT_IRQ_LOW_IRQ_MASKED;
1935 2032
1936 write_ht_irq_low(irq, low); 2033 write_ht_irq_msg(irq, &msg);
1937 write_ht_irq_high(irq, high);
1938 2034
1939 set_irq_chip_and_handler(irq, &ht_irq_chip, handle_edge_irq); 2035 set_irq_chip_and_handler_name(irq, &ht_irq_chip,
2036 handle_edge_irq, "edge");
1940 } 2037 }
1941 return vector; 2038 return vector;
1942} 2039}
diff --git a/arch/x86_64/kernel/irq.c b/arch/x86_64/kernel/irq.c
index dff68eb2b787..e46c55856d40 100644
--- a/arch/x86_64/kernel/irq.c
+++ b/arch/x86_64/kernel/irq.c
@@ -75,7 +75,7 @@ int show_interrupts(struct seq_file *p, void *v)
75 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]); 75 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
76#endif 76#endif
77 seq_printf(p, " %8s", irq_desc[i].chip->name); 77 seq_printf(p, " %8s", irq_desc[i].chip->name);
78 seq_printf(p, "-%s", handle_irq_name(irq_desc[i].handle_irq)); 78 seq_printf(p, "-%-8s", irq_desc[i].name);
79 79
80 seq_printf(p, " %s", action->name); 80 seq_printf(p, " %s", action->name);
81 for (action=action->next; action; action = action->next) 81 for (action=action->next; action; action = action->next)
diff --git a/arch/x86_64/kernel/pci-calgary.c b/arch/x86_64/kernel/pci-calgary.c
index b3296cc2f2f2..37a770859e71 100644
--- a/arch/x86_64/kernel/pci-calgary.c
+++ b/arch/x86_64/kernel/pci-calgary.c
@@ -52,7 +52,8 @@
52#define ONE_BASED_CHASSIS_NUM 1 52#define ONE_BASED_CHASSIS_NUM 1
53 53
54/* register offsets inside the host bridge space */ 54/* register offsets inside the host bridge space */
55#define PHB_CSR_OFFSET 0x0110 55#define CALGARY_CONFIG_REG 0x0108
56#define PHB_CSR_OFFSET 0x0110 /* Channel Status */
56#define PHB_PLSSR_OFFSET 0x0120 57#define PHB_PLSSR_OFFSET 0x0120
57#define PHB_CONFIG_RW_OFFSET 0x0160 58#define PHB_CONFIG_RW_OFFSET 0x0160
58#define PHB_IOBASE_BAR_LOW 0x0170 59#define PHB_IOBASE_BAR_LOW 0x0170
@@ -83,6 +84,8 @@
83#define TAR_VALID 0x0000000000000008UL 84#define TAR_VALID 0x0000000000000008UL
84/* CSR (Channel/DMA Status Register) */ 85/* CSR (Channel/DMA Status Register) */
85#define CSR_AGENT_MASK 0xffe0ffff 86#define CSR_AGENT_MASK 0xffe0ffff
87/* CCR (Calgary Configuration Register) */
88#define CCR_2SEC_TIMEOUT 0x000000000000000EUL
86 89
87#define MAX_NUM_OF_PHBS 8 /* how many PHBs in total? */ 90#define MAX_NUM_OF_PHBS 8 /* how many PHBs in total? */
88#define MAX_NUM_CHASSIS 8 /* max number of chassis */ 91#define MAX_NUM_CHASSIS 8 /* max number of chassis */
@@ -732,6 +735,38 @@ static void calgary_watchdog(unsigned long data)
732 } 735 }
733} 736}
734 737
738static void __init calgary_increase_split_completion_timeout(void __iomem *bbar,
739 unsigned char busnum)
740{
741 u64 val64;
742 void __iomem *target;
743 unsigned long phb_shift = -1;
744 u64 mask;
745
746 switch (busno_to_phbid(busnum)) {
747 case 0: phb_shift = (63 - 19);
748 break;
749 case 1: phb_shift = (63 - 23);
750 break;
751 case 2: phb_shift = (63 - 27);
752 break;
753 case 3: phb_shift = (63 - 35);
754 break;
755 default:
756 BUG_ON(busno_to_phbid(busnum));
757 }
758
759 target = calgary_reg(bbar, CALGARY_CONFIG_REG);
760 val64 = be64_to_cpu(readq(target));
761
762 /* zero out this PHB's timer bits */
763 mask = ~(0xFUL << phb_shift);
764 val64 &= mask;
765 val64 |= (CCR_2SEC_TIMEOUT << phb_shift);
766 writeq(cpu_to_be64(val64), target);
767 readq(target); /* flush */
768}
769
735static void __init calgary_enable_translation(struct pci_dev *dev) 770static void __init calgary_enable_translation(struct pci_dev *dev)
736{ 771{
737 u32 val32; 772 u32 val32;
@@ -756,6 +791,13 @@ static void __init calgary_enable_translation(struct pci_dev *dev)
756 writel(cpu_to_be32(val32), target); 791 writel(cpu_to_be32(val32), target);
757 readl(target); /* flush */ 792 readl(target); /* flush */
758 793
794 /*
795 * Give split completion a longer timeout on bus 1 for aic94xx
796 * http://bugzilla.kernel.org/show_bug.cgi?id=7180
797 */
798 if (busnum == 1)
799 calgary_increase_split_completion_timeout(bbar, busnum);
800
759 init_timer(&tbl->watchdog_timer); 801 init_timer(&tbl->watchdog_timer);
760 tbl->watchdog_timer.function = &calgary_watchdog; 802 tbl->watchdog_timer.function = &calgary_watchdog;
761 tbl->watchdog_timer.data = (unsigned long)dev; 803 tbl->watchdog_timer.data = (unsigned long)dev;
diff --git a/arch/x86_64/kernel/process.c b/arch/x86_64/kernel/process.c
index 5e95b257ee26..7451a4c43c16 100644
--- a/arch/x86_64/kernel/process.c
+++ b/arch/x86_64/kernel/process.c
@@ -88,9 +88,8 @@ void enter_idle(void)
88 88
89static void __exit_idle(void) 89static void __exit_idle(void)
90{ 90{
91 if (read_pda(isidle) == 0) 91 if (test_and_clear_bit_pda(0, isidle) == 0)
92 return; 92 return;
93 write_pda(isidle, 0);
94 atomic_notifier_call_chain(&idle_notifier, IDLE_END, NULL); 93 atomic_notifier_call_chain(&idle_notifier, IDLE_END, NULL);
95} 94}
96 95
@@ -145,7 +144,7 @@ static void poll_idle (void)
145void cpu_idle_wait(void) 144void cpu_idle_wait(void)
146{ 145{
147 unsigned int cpu, this_cpu = get_cpu(); 146 unsigned int cpu, this_cpu = get_cpu();
148 cpumask_t map; 147 cpumask_t map, tmp = current->cpus_allowed;
149 148
150 set_cpus_allowed(current, cpumask_of_cpu(this_cpu)); 149 set_cpus_allowed(current, cpumask_of_cpu(this_cpu));
151 put_cpu(); 150 put_cpu();
@@ -168,6 +167,8 @@ void cpu_idle_wait(void)
168 } 167 }
169 cpus_and(map, map, cpu_online_map); 168 cpus_and(map, map, cpu_online_map);
170 } while (!cpus_empty(map)); 169 } while (!cpus_empty(map));
170
171 set_cpus_allowed(current, tmp);
171} 172}
172EXPORT_SYMBOL_GPL(cpu_idle_wait); 173EXPORT_SYMBOL_GPL(cpu_idle_wait);
173 174
@@ -238,20 +239,28 @@ void cpu_idle (void)
238 * We execute MONITOR against need_resched and enter optimized wait state 239 * We execute MONITOR against need_resched and enter optimized wait state
239 * through MWAIT. Whenever someone changes need_resched, we would be woken 240 * through MWAIT. Whenever someone changes need_resched, we would be woken
240 * up from MWAIT (without an IPI). 241 * up from MWAIT (without an IPI).
242 *
243 * New with Core Duo processors, MWAIT can take some hints based on CPU
244 * capability.
241 */ 245 */
242static void mwait_idle(void) 246void mwait_idle_with_hints(unsigned long eax, unsigned long ecx)
243{ 247{
244 local_irq_enable(); 248 if (!need_resched()) {
245
246 while (!need_resched()) {
247 __monitor((void *)&current_thread_info()->flags, 0, 0); 249 __monitor((void *)&current_thread_info()->flags, 0, 0);
248 smp_mb(); 250 smp_mb();
249 if (need_resched()) 251 if (!need_resched())
250 break; 252 __mwait(eax, ecx);
251 __mwait(0, 0);
252 } 253 }
253} 254}
254 255
256/* Default MONITOR/MWAIT with no hints, used for default C1 state */
257static void mwait_idle(void)
258{
259 local_irq_enable();
260 while (!need_resched())
261 mwait_idle_with_hints(0,0);
262}
263
255void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c) 264void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)
256{ 265{
257 static int printed; 266 static int printed;
diff --git a/arch/x86_64/kernel/smp.c b/arch/x86_64/kernel/smp.c
index 4f67697f5036..9f74c883568c 100644
--- a/arch/x86_64/kernel/smp.c
+++ b/arch/x86_64/kernel/smp.c
@@ -376,9 +376,8 @@ int smp_call_function_single (int cpu, void (*func) (void *info), void *info,
376 /* prevent preemption and reschedule on another processor */ 376 /* prevent preemption and reschedule on another processor */
377 int me = get_cpu(); 377 int me = get_cpu();
378 if (cpu == me) { 378 if (cpu == me) {
379 WARN_ON(1);
380 put_cpu(); 379 put_cpu();
381 return -EBUSY; 380 return 0;
382 } 381 }
383 spin_lock_bh(&call_lock); 382 spin_lock_bh(&call_lock);
384 __smp_call_function_single(cpu, func, info, nonatomic, wait); 383 __smp_call_function_single(cpu, func, info, nonatomic, wait);
diff --git a/arch/x86_64/kernel/smpboot.c b/arch/x86_64/kernel/smpboot.c
index 7b7a6870288a..62c2e747af58 100644
--- a/arch/x86_64/kernel/smpboot.c
+++ b/arch/x86_64/kernel/smpboot.c
@@ -581,12 +581,16 @@ void __cpuinit start_secondary(void)
581 * smp_call_function(). 581 * smp_call_function().
582 */ 582 */
583 lock_ipi_call_lock(); 583 lock_ipi_call_lock();
584 spin_lock(&vector_lock);
584 585
586 /* Setup the per cpu irq handling data structures */
587 __setup_vector_irq(smp_processor_id());
585 /* 588 /*
586 * Allow the master to continue. 589 * Allow the master to continue.
587 */ 590 */
588 cpu_set(smp_processor_id(), cpu_online_map); 591 cpu_set(smp_processor_id(), cpu_online_map);
589 per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE; 592 per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
593 spin_unlock(&vector_lock);
590 unlock_ipi_call_lock(); 594 unlock_ipi_call_lock();
591 595
592 cpu_idle(); 596 cpu_idle();
@@ -799,7 +803,6 @@ static int __cpuinit do_boot_cpu(int cpu, int apicid)
799 cpu, node); 803 cpu, node);
800 } 804 }
801 805
802
803 alternatives_smp_switch(1); 806 alternatives_smp_switch(1);
804 807
805 c_idle.idle = get_idle_for_cpu(cpu); 808 c_idle.idle = get_idle_for_cpu(cpu);
@@ -1246,8 +1249,10 @@ int __cpu_disable(void)
1246 local_irq_disable(); 1249 local_irq_disable();
1247 remove_siblinginfo(cpu); 1250 remove_siblinginfo(cpu);
1248 1251
1252 spin_lock(&vector_lock);
1249 /* It's now safe to remove this processor from the online map */ 1253 /* It's now safe to remove this processor from the online map */
1250 cpu_clear(cpu, cpu_online_map); 1254 cpu_clear(cpu, cpu_online_map);
1255 spin_unlock(&vector_lock);
1251 remove_cpu_from_maps(); 1256 remove_cpu_from_maps();
1252 fixup_irqs(cpu_online_map); 1257 fixup_irqs(cpu_online_map);
1253 return 0; 1258 return 0;
diff --git a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c
index 1ba5a442ac32..e3ef544d2cfb 100644
--- a/arch/x86_64/kernel/time.c
+++ b/arch/x86_64/kernel/time.c
@@ -876,15 +876,6 @@ static struct irqaction irq0 = {
876 timer_interrupt, IRQF_DISABLED, CPU_MASK_NONE, "timer", NULL, NULL 876 timer_interrupt, IRQF_DISABLED, CPU_MASK_NONE, "timer", NULL, NULL
877}; 877};
878 878
879static int __cpuinit
880time_cpu_notifier(struct notifier_block *nb, unsigned long action, void *hcpu)
881{
882 unsigned cpu = (unsigned long) hcpu;
883 if (action == CPU_ONLINE)
884 vsyscall_set_cpu(cpu);
885 return NOTIFY_DONE;
886}
887
888void __init time_init(void) 879void __init time_init(void)
889{ 880{
890 if (nohpet) 881 if (nohpet)
@@ -925,8 +916,6 @@ void __init time_init(void)
925 vxtime.last_tsc = get_cycles_sync(); 916 vxtime.last_tsc = get_cycles_sync();
926 set_cyc2ns_scale(cpu_khz); 917 set_cyc2ns_scale(cpu_khz);
927 setup_irq(0, &irq0); 918 setup_irq(0, &irq0);
928 hotcpu_notifier(time_cpu_notifier, 0);
929 time_cpu_notifier(NULL, CPU_ONLINE, (void *)(long)smp_processor_id());
930 919
931#ifndef CONFIG_SMP 920#ifndef CONFIG_SMP
932 time_init_gtod(); 921 time_init_gtod();
@@ -948,7 +937,7 @@ __cpuinit int unsynchronized_tsc(void)
948 if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) { 937 if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) {
949#ifdef CONFIG_ACPI 938#ifdef CONFIG_ACPI
950 /* But TSC doesn't tick in C3 so don't use it there */ 939 /* But TSC doesn't tick in C3 so don't use it there */
951 if (acpi_fadt.length > 0 && acpi_fadt.plvl3_lat < 100) 940 if (acpi_fadt.length > 0 && acpi_fadt.plvl3_lat < 1000)
952 return 1; 941 return 1;
953#endif 942#endif
954 return 0; 943 return 0;
diff --git a/arch/x86_64/kernel/traps.c b/arch/x86_64/kernel/traps.c
index 7819022a8db5..a153d0a01b72 100644
--- a/arch/x86_64/kernel/traps.c
+++ b/arch/x86_64/kernel/traps.c
@@ -290,6 +290,12 @@ void dump_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long * s
290 if (tsk && tsk != current) 290 if (tsk && tsk != current)
291 stack = (unsigned long *)tsk->thread.rsp; 291 stack = (unsigned long *)tsk->thread.rsp;
292 } 292 }
293 /*
294 * Align the stack pointer on word boundary, later loops
295 * rely on that (and corruption / debug info bugs can cause
296 * unaligned values here):
297 */
298 stack = (unsigned long *)((unsigned long)stack & ~(sizeof(long)-1));
293 299
294 /* 300 /*
295 * Print function call entries within a stack. 'cond' is the 301 * Print function call entries within a stack. 'cond' is the
diff --git a/arch/x86_64/kernel/vmlinux.lds.S b/arch/x86_64/kernel/vmlinux.lds.S
index b9df2ab6529f..d9534e750d4f 100644
--- a/arch/x86_64/kernel/vmlinux.lds.S
+++ b/arch/x86_64/kernel/vmlinux.lds.S
@@ -17,6 +17,7 @@ PHDRS {
17 text PT_LOAD FLAGS(5); /* R_E */ 17 text PT_LOAD FLAGS(5); /* R_E */
18 data PT_LOAD FLAGS(7); /* RWE */ 18 data PT_LOAD FLAGS(7); /* RWE */
19 user PT_LOAD FLAGS(7); /* RWE */ 19 user PT_LOAD FLAGS(7); /* RWE */
20 data.init PT_LOAD FLAGS(7); /* RWE */
20 note PT_NOTE FLAGS(4); /* R__ */ 21 note PT_NOTE FLAGS(4); /* R__ */
21} 22}
22SECTIONS 23SECTIONS
@@ -59,6 +60,7 @@ SECTIONS
59 } 60 }
60#endif 61#endif
61 62
63 . = ALIGN(PAGE_SIZE); /* Align data segment to page size boundary */
62 /* Data */ 64 /* Data */
63 .data : AT(ADDR(.data) - LOAD_OFFSET) { 65 .data : AT(ADDR(.data) - LOAD_OFFSET) {
64 *(.data) 66 *(.data)
@@ -131,7 +133,7 @@ SECTIONS
131 . = ALIGN(8192); /* init_task */ 133 . = ALIGN(8192); /* init_task */
132 .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) { 134 .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
133 *(.data.init_task) 135 *(.data.init_task)
134 } :data 136 }:data.init
135 137
136 . = ALIGN(4096); 138 . = ALIGN(4096);
137 .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) { 139 .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
@@ -174,13 +176,7 @@ SECTIONS
174 __setup_end = .; 176 __setup_end = .;
175 __initcall_start = .; 177 __initcall_start = .;
176 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) { 178 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
177 *(.initcall1.init) 179 INITCALLS
178 *(.initcall2.init)
179 *(.initcall3.init)
180 *(.initcall4.init)
181 *(.initcall5.init)
182 *(.initcall6.init)
183 *(.initcall7.init)
184 } 180 }
185 __initcall_end = .; 181 __initcall_end = .;
186 __con_initcall_start = .; 182 __con_initcall_start = .;
diff --git a/arch/x86_64/kernel/vsmp.c b/arch/x86_64/kernel/vsmp.c
index 044e852bd25e..414caf0c5f9a 100644
--- a/arch/x86_64/kernel/vsmp.c
+++ b/arch/x86_64/kernel/vsmp.c
@@ -14,6 +14,7 @@
14#include <linux/pci_ids.h> 14#include <linux/pci_ids.h>
15#include <linux/pci_regs.h> 15#include <linux/pci_regs.h>
16#include <asm/pci-direct.h> 16#include <asm/pci-direct.h>
17#include <asm/io.h>
17 18
18static int __init vsmp_init(void) 19static int __init vsmp_init(void)
19{ 20{
diff --git a/arch/x86_64/kernel/vsyscall.c b/arch/x86_64/kernel/vsyscall.c
index a98b460af6a1..92546c1526f1 100644
--- a/arch/x86_64/kernel/vsyscall.c
+++ b/arch/x86_64/kernel/vsyscall.c
@@ -27,6 +27,9 @@
27#include <linux/jiffies.h> 27#include <linux/jiffies.h>
28#include <linux/sysctl.h> 28#include <linux/sysctl.h>
29#include <linux/getcpu.h> 29#include <linux/getcpu.h>
30#include <linux/cpu.h>
31#include <linux/smp.h>
32#include <linux/notifier.h>
30 33
31#include <asm/vsyscall.h> 34#include <asm/vsyscall.h>
32#include <asm/pgtable.h> 35#include <asm/pgtable.h>
@@ -243,32 +246,17 @@ static ctl_table kernel_root_table2[] = {
243 246
244#endif 247#endif
245 248
246static void __cpuinit write_rdtscp_cb(void *info) 249/* Assume __initcall executes before all user space. Hopefully kmod
247{ 250 doesn't violate that. We'll find out if it does. */
248 write_rdtscp_aux((unsigned long)info); 251static void __cpuinit vsyscall_set_cpu(int cpu)
249}
250
251void __cpuinit vsyscall_set_cpu(int cpu)
252{ 252{
253 unsigned long *d; 253 unsigned long *d;
254 unsigned long node = 0; 254 unsigned long node = 0;
255#ifdef CONFIG_NUMA 255#ifdef CONFIG_NUMA
256 node = cpu_to_node[cpu]; 256 node = cpu_to_node[cpu];
257#endif 257#endif
258 if (cpu_has(&cpu_data[cpu], X86_FEATURE_RDTSCP)) { 258 if (cpu_has(&cpu_data[cpu], X86_FEATURE_RDTSCP))
259 void *info = (void *)((node << 12) | cpu); 259 write_rdtscp_aux((node << 12) | cpu);
260 /* Can happen on preemptive kernel */
261 if (get_cpu() == cpu)
262 write_rdtscp_cb(info);
263#ifdef CONFIG_SMP
264 else {
265 /* the notifier is unfortunately not executed on the
266 target CPU */
267 smp_call_function_single(cpu,write_rdtscp_cb,info,0,1);
268 }
269#endif
270 put_cpu();
271 }
272 260
273 /* Store cpu number in limit so that it can be loaded quickly 261 /* Store cpu number in limit so that it can be loaded quickly
274 in user space in vgetcpu. 262 in user space in vgetcpu.
@@ -280,6 +268,23 @@ void __cpuinit vsyscall_set_cpu(int cpu)
280 *d |= (node >> 4) << 48; 268 *d |= (node >> 4) << 48;
281} 269}
282 270
271static void __cpuinit cpu_vsyscall_init(void *arg)
272{
273 /* preemption should be already off */
274 vsyscall_set_cpu(raw_smp_processor_id());
275}
276
277#ifdef CONFIG_HOTPLUG_CPU
278static int __cpuinit
279cpu_vsyscall_notifier(struct notifier_block *n, unsigned long action, void *arg)
280{
281 long cpu = (long)arg;
282 if (action == CPU_ONLINE)
283 smp_call_function_single(cpu, cpu_vsyscall_init, NULL, 0, 1);
284 return NOTIFY_DONE;
285}
286#endif
287
283static void __init map_vsyscall(void) 288static void __init map_vsyscall(void)
284{ 289{
285 extern char __vsyscall_0; 290 extern char __vsyscall_0;
@@ -299,6 +304,8 @@ static int __init vsyscall_init(void)
299#ifdef CONFIG_SYSCTL 304#ifdef CONFIG_SYSCTL
300 register_sysctl_table(kernel_root_table2, 0); 305 register_sysctl_table(kernel_root_table2, 0);
301#endif 306#endif
307 on_each_cpu(cpu_vsyscall_init, NULL, 0, 1);
308 hotcpu_notifier(cpu_vsyscall_notifier, 0);
302 return 0; 309 return 0;
303} 310}
304 311
diff --git a/arch/x86_64/mm/init.c b/arch/x86_64/mm/init.c
index 19c72520a868..4c0c00ef3ca7 100644
--- a/arch/x86_64/mm/init.c
+++ b/arch/x86_64/mm/init.c
@@ -406,9 +406,12 @@ void __cpuinit zap_low_mappings(int cpu)
406#ifndef CONFIG_NUMA 406#ifndef CONFIG_NUMA
407void __init paging_init(void) 407void __init paging_init(void)
408{ 408{
409 unsigned long max_zone_pfns[MAX_NR_ZONES] = {MAX_DMA_PFN, 409 unsigned long max_zone_pfns[MAX_NR_ZONES];
410 MAX_DMA32_PFN, 410 memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
411 end_pfn}; 411 max_zone_pfns[ZONE_DMA] = MAX_DMA_PFN;
412 max_zone_pfns[ZONE_DMA32] = MAX_DMA32_PFN;
413 max_zone_pfns[ZONE_NORMAL] = end_pfn;
414
412 memory_present(0, 0, end_pfn); 415 memory_present(0, 0, end_pfn);
413 sparse_init(); 416 sparse_init();
414 free_area_init_nodes(max_zone_pfns); 417 free_area_init_nodes(max_zone_pfns);
@@ -493,7 +496,7 @@ int remove_memory(u64 start, u64 size)
493} 496}
494EXPORT_SYMBOL_GPL(remove_memory); 497EXPORT_SYMBOL_GPL(remove_memory);
495 498
496#ifndef CONFIG_ACPI_NUMA 499#if !defined(CONFIG_ACPI_NUMA) && defined(CONFIG_NUMA)
497int memory_add_physaddr_to_nid(u64 start) 500int memory_add_physaddr_to_nid(u64 start)
498{ 501{
499 return 0; 502 return 0;
@@ -501,13 +504,6 @@ int memory_add_physaddr_to_nid(u64 start)
501EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid); 504EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
502#endif 505#endif
503 506
504#ifndef CONFIG_ACPI_NUMA
505int memory_add_physaddr_to_nid(u64 start)
506{
507 return 0;
508}
509#endif
510
511#endif /* CONFIG_MEMORY_HOTPLUG */ 507#endif /* CONFIG_MEMORY_HOTPLUG */
512 508
513#ifdef CONFIG_MEMORY_HOTPLUG_RESERVE 509#ifdef CONFIG_MEMORY_HOTPLUG_RESERVE
@@ -652,9 +648,22 @@ void free_initrd_mem(unsigned long start, unsigned long end)
652 648
653void __init reserve_bootmem_generic(unsigned long phys, unsigned len) 649void __init reserve_bootmem_generic(unsigned long phys, unsigned len)
654{ 650{
655 /* Should check here against the e820 map to avoid double free */
656#ifdef CONFIG_NUMA 651#ifdef CONFIG_NUMA
657 int nid = phys_to_nid(phys); 652 int nid = phys_to_nid(phys);
653#endif
654 unsigned long pfn = phys >> PAGE_SHIFT;
655 if (pfn >= end_pfn) {
656 /* This can happen with kdump kernels when accessing firmware
657 tables. */
658 if (pfn < end_pfn_map)
659 return;
660 printk(KERN_ERR "reserve_bootmem: illegal reserve %lx %u\n",
661 phys, len);
662 return;
663 }
664
665 /* Should check here against the e820 map to avoid double free */
666#ifdef CONFIG_NUMA
658 reserve_bootmem_node(NODE_DATA(nid), phys, len); 667 reserve_bootmem_node(NODE_DATA(nid), phys, len);
659#else 668#else
660 reserve_bootmem(phys, len); 669 reserve_bootmem(phys, len);
diff --git a/arch/x86_64/mm/numa.c b/arch/x86_64/mm/numa.c
index 829a008bd39b..2ee2e003606c 100644
--- a/arch/x86_64/mm/numa.c
+++ b/arch/x86_64/mm/numa.c
@@ -338,9 +338,11 @@ static void __init arch_sparse_init(void)
338void __init paging_init(void) 338void __init paging_init(void)
339{ 339{
340 int i; 340 int i;
341 unsigned long max_zone_pfns[MAX_NR_ZONES] = { MAX_DMA_PFN, 341 unsigned long max_zone_pfns[MAX_NR_ZONES];
342 MAX_DMA32_PFN, 342 memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
343 end_pfn}; 343 max_zone_pfns[ZONE_DMA] = MAX_DMA_PFN;
344 max_zone_pfns[ZONE_DMA32] = MAX_DMA32_PFN;
345 max_zone_pfns[ZONE_NORMAL] = end_pfn;
344 346
345 arch_sparse_init(); 347 arch_sparse_init();
346 348
diff --git a/arch/x86_64/mm/srat.c b/arch/x86_64/mm/srat.c
index 3cc0544e25f5..1087e150a218 100644
--- a/arch/x86_64/mm/srat.c
+++ b/arch/x86_64/mm/srat.c
@@ -207,7 +207,7 @@ static inline int save_add_info(void)
207 return hotadd_percent > 0; 207 return hotadd_percent > 0;
208} 208}
209#else 209#else
210int update_end_of_memory(unsigned long end) {return 0;} 210int update_end_of_memory(unsigned long end) {return -1;}
211static int hotadd_enough_memory(struct bootnode *nd) {return 1;} 211static int hotadd_enough_memory(struct bootnode *nd) {return 1;}
212#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE 212#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
213static inline int save_add_info(void) {return 1;} 213static inline int save_add_info(void) {return 1;}
@@ -337,7 +337,7 @@ acpi_numa_memory_affinity_init(struct acpi_table_memory_affinity *ma)
337 push_node_boundaries(node, nd->start >> PAGE_SHIFT, 337 push_node_boundaries(node, nd->start >> PAGE_SHIFT,
338 nd->end >> PAGE_SHIFT); 338 nd->end >> PAGE_SHIFT);
339 339
340 if (ma->flags.hot_pluggable && !reserve_hotadd(node, start, end) < 0) { 340 if (ma->flags.hot_pluggable && (reserve_hotadd(node, start, end) < 0)) {
341 /* Ignore hotadd region. Undo damage */ 341 /* Ignore hotadd region. Undo damage */
342 printk(KERN_NOTICE "SRAT: Hotplug region ignored\n"); 342 printk(KERN_NOTICE "SRAT: Hotplug region ignored\n");
343 *nd = oldnode; 343 *nd = oldnode;
diff --git a/arch/x86_64/pci/Makefile b/arch/x86_64/pci/Makefile
index 1eb18f421edf..149aba05a5b8 100644
--- a/arch/x86_64/pci/Makefile
+++ b/arch/x86_64/pci/Makefile
@@ -3,7 +3,7 @@
3# 3#
4# Reuse the i386 PCI subsystem 4# Reuse the i386 PCI subsystem
5# 5#
6CFLAGS += -Iarch/i386/pci 6EXTRA_CFLAGS += -Iarch/i386/pci
7 7
8obj-y := i386.o 8obj-y := i386.o
9obj-$(CONFIG_PCI_DIRECT)+= direct.o 9obj-$(CONFIG_PCI_DIRECT)+= direct.o
diff --git a/arch/x86_64/pci/mmconfig.c b/arch/x86_64/pci/mmconfig.c
index 7732f4254d21..f8b6b2800a62 100644
--- a/arch/x86_64/pci/mmconfig.c
+++ b/arch/x86_64/pci/mmconfig.c
@@ -163,37 +163,6 @@ static __init void unreachable_devices(void)
163 } 163 }
164} 164}
165 165
166static __init void pci_mmcfg_insert_resources(void)
167{
168#define PCI_MMCFG_RESOURCE_NAME_LEN 19
169 int i;
170 struct resource *res;
171 char *names;
172 unsigned num_buses;
173
174 res = kcalloc(PCI_MMCFG_RESOURCE_NAME_LEN + sizeof(*res),
175 pci_mmcfg_config_num, GFP_KERNEL);
176
177 if (!res) {
178 printk(KERN_ERR "PCI: Unable to allocate MMCONFIG resources\n");
179 return;
180 }
181
182 names = (void *)&res[pci_mmcfg_config_num];
183 for (i = 0; i < pci_mmcfg_config_num; i++, res++) {
184 num_buses = pci_mmcfg_config[i].end_bus_number -
185 pci_mmcfg_config[i].start_bus_number + 1;
186 res->name = names;
187 snprintf(names, PCI_MMCFG_RESOURCE_NAME_LEN, "PCI MMCONFIG %u",
188 pci_mmcfg_config[i].pci_segment_group_number);
189 res->start = pci_mmcfg_config[i].base_address;
190 res->end = res->start + (num_buses << 20) - 1;
191 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
192 insert_resource(&iomem_resource, res);
193 names += PCI_MMCFG_RESOURCE_NAME_LEN;
194 }
195}
196
197void __init pci_mmcfg_init(int type) 166void __init pci_mmcfg_init(int type)
198{ 167{
199 int i; 168 int i;
@@ -220,7 +189,7 @@ void __init pci_mmcfg_init(int type)
220 189
221 pci_mmcfg_virt = kmalloc(sizeof(*pci_mmcfg_virt) * pci_mmcfg_config_num, GFP_KERNEL); 190 pci_mmcfg_virt = kmalloc(sizeof(*pci_mmcfg_virt) * pci_mmcfg_config_num, GFP_KERNEL);
222 if (pci_mmcfg_virt == NULL) { 191 if (pci_mmcfg_virt == NULL) {
223 printk("PCI: Can not allocate memory for mmconfig structures\n"); 192 printk(KERN_ERR "PCI: Can not allocate memory for mmconfig structures\n");
224 return; 193 return;
225 } 194 }
226 for (i = 0; i < pci_mmcfg_config_num; ++i) { 195 for (i = 0; i < pci_mmcfg_config_num; ++i) {
@@ -228,7 +197,8 @@ void __init pci_mmcfg_init(int type)
228 pci_mmcfg_virt[i].virt = ioremap_nocache(pci_mmcfg_config[i].base_address, 197 pci_mmcfg_virt[i].virt = ioremap_nocache(pci_mmcfg_config[i].base_address,
229 MMCONFIG_APER_MAX); 198 MMCONFIG_APER_MAX);
230 if (!pci_mmcfg_virt[i].virt) { 199 if (!pci_mmcfg_virt[i].virt) {
231 printk("PCI: Cannot map mmconfig aperture for segment %d\n", 200 printk(KERN_ERR "PCI: Cannot map mmconfig aperture for "
201 "segment %d\n",
232 pci_mmcfg_config[i].pci_segment_group_number); 202 pci_mmcfg_config[i].pci_segment_group_number);
233 return; 203 return;
234 } 204 }
@@ -236,7 +206,6 @@ void __init pci_mmcfg_init(int type)
236 } 206 }
237 207
238 unreachable_devices(); 208 unreachable_devices();
239 pci_mmcfg_insert_resources();
240 209
241 raw_pci_ops = &pci_mmcfg; 210 raw_pci_ops = &pci_mmcfg;
242 pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF; 211 pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF;
diff --git a/arch/xtensa/kernel/vmlinux.lds.S b/arch/xtensa/kernel/vmlinux.lds.S
index ab6cdbd5eb68..cfe75f528725 100644
--- a/arch/xtensa/kernel/vmlinux.lds.S
+++ b/arch/xtensa/kernel/vmlinux.lds.S
@@ -184,13 +184,7 @@ SECTIONS
184 184
185 __initcall_start = .; 185 __initcall_start = .;
186 .initcall.init : { 186 .initcall.init : {
187 *(.initcall1.init) 187 INITCALLS
188 *(.initcall2.init)
189 *(.initcall3.init)
190 *(.initcall4.init)
191 *(.initcall5.init)
192 *(.initcall6.init)
193 *(.initcall7.init)
194 } 188 }
195 __initcall_end = .; 189 __initcall_end = .;
196 190
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index d3d76136f53a..1d9c3c70a9a0 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -456,6 +456,9 @@ static void cfq_add_rq_rb(struct request *rq)
456 */ 456 */
457 while ((__alias = elv_rb_add(&cfqq->sort_list, rq)) != NULL) 457 while ((__alias = elv_rb_add(&cfqq->sort_list, rq)) != NULL)
458 cfq_dispatch_insert(cfqd->queue, __alias); 458 cfq_dispatch_insert(cfqd->queue, __alias);
459
460 if (!cfq_cfqq_on_rr(cfqq))
461 cfq_add_cfqq_rr(cfqd, cfqq);
459} 462}
460 463
461static inline void 464static inline void
@@ -1215,11 +1218,12 @@ static inline void changed_ioprio(struct cfq_io_context *cic)
1215{ 1218{
1216 struct cfq_data *cfqd = cic->key; 1219 struct cfq_data *cfqd = cic->key;
1217 struct cfq_queue *cfqq; 1220 struct cfq_queue *cfqq;
1221 unsigned long flags;
1218 1222
1219 if (unlikely(!cfqd)) 1223 if (unlikely(!cfqd))
1220 return; 1224 return;
1221 1225
1222 spin_lock(cfqd->queue->queue_lock); 1226 spin_lock_irqsave(cfqd->queue->queue_lock, flags);
1223 1227
1224 cfqq = cic->cfqq[ASYNC]; 1228 cfqq = cic->cfqq[ASYNC];
1225 if (cfqq) { 1229 if (cfqq) {
@@ -1236,7 +1240,7 @@ static inline void changed_ioprio(struct cfq_io_context *cic)
1236 if (cfqq) 1240 if (cfqq)
1237 cfq_mark_cfqq_prio_changed(cfqq); 1241 cfq_mark_cfqq_prio_changed(cfqq);
1238 1242
1239 spin_unlock(cfqd->queue->queue_lock); 1243 spin_unlock_irqrestore(cfqd->queue->queue_lock, flags);
1240} 1244}
1241 1245
1242static void cfq_ioc_set_ioprio(struct io_context *ioc) 1246static void cfq_ioc_set_ioprio(struct io_context *ioc)
@@ -1362,6 +1366,7 @@ cfq_cic_link(struct cfq_data *cfqd, struct io_context *ioc,
1362 struct rb_node **p; 1366 struct rb_node **p;
1363 struct rb_node *parent; 1367 struct rb_node *parent;
1364 struct cfq_io_context *__cic; 1368 struct cfq_io_context *__cic;
1369 unsigned long flags;
1365 void *k; 1370 void *k;
1366 1371
1367 cic->ioc = ioc; 1372 cic->ioc = ioc;
@@ -1391,9 +1396,9 @@ restart:
1391 rb_link_node(&cic->rb_node, parent, p); 1396 rb_link_node(&cic->rb_node, parent, p);
1392 rb_insert_color(&cic->rb_node, &ioc->cic_root); 1397 rb_insert_color(&cic->rb_node, &ioc->cic_root);
1393 1398
1394 spin_lock_irq(cfqd->queue->queue_lock); 1399 spin_lock_irqsave(cfqd->queue->queue_lock, flags);
1395 list_add(&cic->queue_list, &cfqd->cic_list); 1400 list_add(&cic->queue_list, &cfqd->cic_list);
1396 spin_unlock_irq(cfqd->queue->queue_lock); 1401 spin_unlock_irqrestore(cfqd->queue->queue_lock, flags);
1397} 1402}
1398 1403
1399/* 1404/*
@@ -1650,9 +1655,6 @@ static void cfq_insert_request(request_queue_t *q, struct request *rq)
1650 1655
1651 cfq_add_rq_rb(rq); 1656 cfq_add_rq_rb(rq);
1652 1657
1653 if (!cfq_cfqq_on_rr(cfqq))
1654 cfq_add_cfqq_rr(cfqd, cfqq);
1655
1656 list_add_tail(&rq->queuelist, &cfqq->fifo); 1658 list_add_tail(&rq->queuelist, &cfqq->fifo);
1657 1659
1658 cfq_rq_enqueued(cfqd, cfqq, rq); 1660 cfq_rq_enqueued(cfqd, cfqq, rq);
diff --git a/block/elevator.c b/block/elevator.c
index 487dd3da8853..8ccd163254b8 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -93,21 +93,18 @@ static inline int elv_try_merge(struct request *__rq, struct bio *bio)
93 93
94static struct elevator_type *elevator_find(const char *name) 94static struct elevator_type *elevator_find(const char *name)
95{ 95{
96 struct elevator_type *e = NULL; 96 struct elevator_type *e;
97 struct list_head *entry; 97 struct list_head *entry;
98 98
99 list_for_each(entry, &elv_list) { 99 list_for_each(entry, &elv_list) {
100 struct elevator_type *__e;
101 100
102 __e = list_entry(entry, struct elevator_type, list); 101 e = list_entry(entry, struct elevator_type, list);
103 102
104 if (!strcmp(__e->elevator_name, name)) { 103 if (!strcmp(e->elevator_name, name))
105 e = __e; 104 return e;
106 break;
107 }
108 } 105 }
109 106
110 return e; 107 return NULL;
111} 108}
112 109
113static void elevator_put(struct elevator_type *e) 110static void elevator_put(struct elevator_type *e)
@@ -1088,7 +1085,7 @@ ssize_t elv_iosched_show(request_queue_t *q, char *name)
1088 struct list_head *entry; 1085 struct list_head *entry;
1089 int len = 0; 1086 int len = 0;
1090 1087
1091 spin_lock_irq(q->queue_lock); 1088 spin_lock_irq(&elv_list_lock);
1092 list_for_each(entry, &elv_list) { 1089 list_for_each(entry, &elv_list) {
1093 struct elevator_type *__e; 1090 struct elevator_type *__e;
1094 1091
@@ -1098,7 +1095,7 @@ ssize_t elv_iosched_show(request_queue_t *q, char *name)
1098 else 1095 else
1099 len += sprintf(name+len, "%s ", __e->elevator_name); 1096 len += sprintf(name+len, "%s ", __e->elevator_name);
1100 } 1097 }
1101 spin_unlock_irq(q->queue_lock); 1098 spin_unlock_irq(&elv_list_lock);
1102 1099
1103 len += sprintf(len+name, "\n"); 1100 len += sprintf(len+name, "\n");
1104 return len; 1101 return len;
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index c847e17e5caa..9eaee6640535 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -56,11 +56,6 @@ static kmem_cache_t *requestq_cachep;
56 */ 56 */
57static kmem_cache_t *iocontext_cachep; 57static kmem_cache_t *iocontext_cachep;
58 58
59static wait_queue_head_t congestion_wqh[2] = {
60 __WAIT_QUEUE_HEAD_INITIALIZER(congestion_wqh[0]),
61 __WAIT_QUEUE_HEAD_INITIALIZER(congestion_wqh[1])
62 };
63
64/* 59/*
65 * Controlling structure to kblockd 60 * Controlling structure to kblockd
66 */ 61 */
@@ -112,35 +107,6 @@ static void blk_queue_congestion_threshold(struct request_queue *q)
112 q->nr_congestion_off = nr; 107 q->nr_congestion_off = nr;
113} 108}
114 109
115/*
116 * A queue has just exitted congestion. Note this in the global counter of
117 * congested queues, and wake up anyone who was waiting for requests to be
118 * put back.
119 */
120static void clear_queue_congested(request_queue_t *q, int rw)
121{
122 enum bdi_state bit;
123 wait_queue_head_t *wqh = &congestion_wqh[rw];
124
125 bit = (rw == WRITE) ? BDI_write_congested : BDI_read_congested;
126 clear_bit(bit, &q->backing_dev_info.state);
127 smp_mb__after_clear_bit();
128 if (waitqueue_active(wqh))
129 wake_up(wqh);
130}
131
132/*
133 * A queue has just entered congestion. Flag that in the queue's VM-visible
134 * state flags and increment the global gounter of congested queues.
135 */
136static void set_queue_congested(request_queue_t *q, int rw)
137{
138 enum bdi_state bit;
139
140 bit = (rw == WRITE) ? BDI_write_congested : BDI_read_congested;
141 set_bit(bit, &q->backing_dev_info.state);
142}
143
144/** 110/**
145 * blk_get_backing_dev_info - get the address of a queue's backing_dev_info 111 * blk_get_backing_dev_info - get the address of a queue's backing_dev_info
146 * @bdev: device 112 * @bdev: device
@@ -159,7 +125,6 @@ struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev)
159 ret = &q->backing_dev_info; 125 ret = &q->backing_dev_info;
160 return ret; 126 return ret;
161} 127}
162
163EXPORT_SYMBOL(blk_get_backing_dev_info); 128EXPORT_SYMBOL(blk_get_backing_dev_info);
164 129
165void blk_queue_activity_fn(request_queue_t *q, activity_fn *fn, void *data) 130void blk_queue_activity_fn(request_queue_t *q, activity_fn *fn, void *data)
@@ -167,7 +132,6 @@ void blk_queue_activity_fn(request_queue_t *q, activity_fn *fn, void *data)
167 q->activity_fn = fn; 132 q->activity_fn = fn;
168 q->activity_data = data; 133 q->activity_data = data;
169} 134}
170
171EXPORT_SYMBOL(blk_queue_activity_fn); 135EXPORT_SYMBOL(blk_queue_activity_fn);
172 136
173/** 137/**
@@ -2067,7 +2031,7 @@ static void __freed_request(request_queue_t *q, int rw)
2067 struct request_list *rl = &q->rq; 2031 struct request_list *rl = &q->rq;
2068 2032
2069 if (rl->count[rw] < queue_congestion_off_threshold(q)) 2033 if (rl->count[rw] < queue_congestion_off_threshold(q))
2070 clear_queue_congested(q, rw); 2034 blk_clear_queue_congested(q, rw);
2071 2035
2072 if (rl->count[rw] + 1 <= q->nr_requests) { 2036 if (rl->count[rw] + 1 <= q->nr_requests) {
2073 if (waitqueue_active(&rl->wait[rw])) 2037 if (waitqueue_active(&rl->wait[rw]))
@@ -2137,7 +2101,7 @@ static struct request *get_request(request_queue_t *q, int rw, struct bio *bio,
2137 } 2101 }
2138 } 2102 }
2139 } 2103 }
2140 set_queue_congested(q, rw); 2104 blk_set_queue_congested(q, rw);
2141 } 2105 }
2142 2106
2143 /* 2107 /*
@@ -2755,41 +2719,6 @@ void blk_end_sync_rq(struct request *rq, int error)
2755} 2719}
2756EXPORT_SYMBOL(blk_end_sync_rq); 2720EXPORT_SYMBOL(blk_end_sync_rq);
2757 2721
2758/**
2759 * blk_congestion_wait - wait for a queue to become uncongested
2760 * @rw: READ or WRITE
2761 * @timeout: timeout in jiffies
2762 *
2763 * Waits for up to @timeout jiffies for a queue (any queue) to exit congestion.
2764 * If no queues are congested then just wait for the next request to be
2765 * returned.
2766 */
2767long blk_congestion_wait(int rw, long timeout)
2768{
2769 long ret;
2770 DEFINE_WAIT(wait);
2771 wait_queue_head_t *wqh = &congestion_wqh[rw];
2772
2773 prepare_to_wait(wqh, &wait, TASK_UNINTERRUPTIBLE);
2774 ret = io_schedule_timeout(timeout);
2775 finish_wait(wqh, &wait);
2776 return ret;
2777}
2778
2779EXPORT_SYMBOL(blk_congestion_wait);
2780
2781/**
2782 * blk_congestion_end - wake up sleepers on a congestion queue
2783 * @rw: READ or WRITE
2784 */
2785void blk_congestion_end(int rw)
2786{
2787 wait_queue_head_t *wqh = &congestion_wqh[rw];
2788
2789 if (waitqueue_active(wqh))
2790 wake_up(wqh);
2791}
2792
2793/* 2722/*
2794 * Has to be called with the request spinlock acquired 2723 * Has to be called with the request spinlock acquired
2795 */ 2724 */
@@ -3070,6 +2999,7 @@ void generic_make_request(struct bio *bio)
3070{ 2999{
3071 request_queue_t *q; 3000 request_queue_t *q;
3072 sector_t maxsector; 3001 sector_t maxsector;
3002 sector_t old_sector;
3073 int ret, nr_sectors = bio_sectors(bio); 3003 int ret, nr_sectors = bio_sectors(bio);
3074 dev_t old_dev; 3004 dev_t old_dev;
3075 3005
@@ -3098,7 +3028,7 @@ void generic_make_request(struct bio *bio)
3098 * NOTE: we don't repeat the blk_size check for each new device. 3028 * NOTE: we don't repeat the blk_size check for each new device.
3099 * Stacking drivers are expected to know what they are doing. 3029 * Stacking drivers are expected to know what they are doing.
3100 */ 3030 */
3101 maxsector = -1; 3031 old_sector = -1;
3102 old_dev = 0; 3032 old_dev = 0;
3103 do { 3033 do {
3104 char b[BDEVNAME_SIZE]; 3034 char b[BDEVNAME_SIZE];
@@ -3132,15 +3062,31 @@ end_io:
3132 */ 3062 */
3133 blk_partition_remap(bio); 3063 blk_partition_remap(bio);
3134 3064
3135 if (maxsector != -1) 3065 if (old_sector != -1)
3136 blk_add_trace_remap(q, bio, old_dev, bio->bi_sector, 3066 blk_add_trace_remap(q, bio, old_dev, bio->bi_sector,
3137 maxsector); 3067 old_sector);
3138 3068
3139 blk_add_trace_bio(q, bio, BLK_TA_QUEUE); 3069 blk_add_trace_bio(q, bio, BLK_TA_QUEUE);
3140 3070
3141 maxsector = bio->bi_sector; 3071 old_sector = bio->bi_sector;
3142 old_dev = bio->bi_bdev->bd_dev; 3072 old_dev = bio->bi_bdev->bd_dev;
3143 3073
3074 maxsector = bio->bi_bdev->bd_inode->i_size >> 9;
3075 if (maxsector) {
3076 sector_t sector = bio->bi_sector;
3077
3078 if (maxsector < nr_sectors ||
3079 maxsector - nr_sectors < sector) {
3080 /*
3081 * This may well happen - partitions are not
3082 * checked to make sure they are within the size
3083 * of the whole device.
3084 */
3085 handle_bad_sector(bio);
3086 goto end_io;
3087 }
3088 }
3089
3144 ret = q->make_request_fn(q, bio); 3090 ret = q->make_request_fn(q, bio);
3145 } while (ret); 3091 } while (ret);
3146} 3092}
@@ -3765,14 +3711,14 @@ queue_requests_store(struct request_queue *q, const char *page, size_t count)
3765 blk_queue_congestion_threshold(q); 3711 blk_queue_congestion_threshold(q);
3766 3712
3767 if (rl->count[READ] >= queue_congestion_on_threshold(q)) 3713 if (rl->count[READ] >= queue_congestion_on_threshold(q))
3768 set_queue_congested(q, READ); 3714 blk_set_queue_congested(q, READ);
3769 else if (rl->count[READ] < queue_congestion_off_threshold(q)) 3715 else if (rl->count[READ] < queue_congestion_off_threshold(q))
3770 clear_queue_congested(q, READ); 3716 blk_clear_queue_congested(q, READ);
3771 3717
3772 if (rl->count[WRITE] >= queue_congestion_on_threshold(q)) 3718 if (rl->count[WRITE] >= queue_congestion_on_threshold(q))
3773 set_queue_congested(q, WRITE); 3719 blk_set_queue_congested(q, WRITE);
3774 else if (rl->count[WRITE] < queue_congestion_off_threshold(q)) 3720 else if (rl->count[WRITE] < queue_congestion_off_threshold(q))
3775 clear_queue_congested(q, WRITE); 3721 blk_clear_queue_congested(q, WRITE);
3776 3722
3777 if (rl->count[READ] >= q->nr_requests) { 3723 if (rl->count[READ] >= q->nr_requests) {
3778 blk_set_queue_full(q, READ); 3724 blk_set_queue_full(q, READ);
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index ac63964b7242..dcd9c71fe8d3 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -246,10 +246,10 @@ static int sg_io(struct file *file, request_queue_t *q,
246 switch (hdr->dxfer_direction) { 246 switch (hdr->dxfer_direction) {
247 default: 247 default:
248 return -EINVAL; 248 return -EINVAL;
249 case SG_DXFER_TO_FROM_DEV:
250 case SG_DXFER_TO_DEV: 249 case SG_DXFER_TO_DEV:
251 writing = 1; 250 writing = 1;
252 break; 251 break;
252 case SG_DXFER_TO_FROM_DEV:
253 case SG_DXFER_FROM_DEV: 253 case SG_DXFER_FROM_DEV:
254 break; 254 break;
255 } 255 }
@@ -286,9 +286,8 @@ static int sg_io(struct file *file, request_queue_t *q,
286 * fill in request structure 286 * fill in request structure
287 */ 287 */
288 rq->cmd_len = hdr->cmd_len; 288 rq->cmd_len = hdr->cmd_len;
289 memset(rq->cmd, 0, BLK_MAX_CDB); /* ATAPI hates garbage after CDB */
289 memcpy(rq->cmd, cmd, hdr->cmd_len); 290 memcpy(rq->cmd, cmd, hdr->cmd_len);
290 if (sizeof(rq->cmd) != hdr->cmd_len)
291 memset(rq->cmd + hdr->cmd_len, 0, sizeof(rq->cmd) - hdr->cmd_len);
292 291
293 memset(sense, 0, sizeof(sense)); 292 memset(sense, 0, sizeof(sense));
294 rq->sense = sense; 293 rq->sense = sense;
diff --git a/crypto/Kconfig b/crypto/Kconfig
index 1e2f39c21180..cbae8392ce11 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -27,7 +27,6 @@ config CRYPTO_HASH
27config CRYPTO_MANAGER 27config CRYPTO_MANAGER
28 tristate "Cryptographic algorithm manager" 28 tristate "Cryptographic algorithm manager"
29 select CRYPTO_ALGAPI 29 select CRYPTO_ALGAPI
30 default m
31 help 30 help
32 Create default cryptographic template instantiations such as 31 Create default cryptographic template instantiations such as
33 cbc(aes). 32 cbc(aes).
@@ -35,6 +34,7 @@ config CRYPTO_MANAGER
35config CRYPTO_HMAC 34config CRYPTO_HMAC
36 tristate "HMAC support" 35 tristate "HMAC support"
37 select CRYPTO_HASH 36 select CRYPTO_HASH
37 select CRYPTO_MANAGER
38 help 38 help
39 HMAC: Keyed-Hashing for Message Authentication (RFC2104). 39 HMAC: Keyed-Hashing for Message Authentication (RFC2104).
40 This is required for IPSec. 40 This is required for IPSec.
@@ -131,6 +131,7 @@ config CRYPTO_TGR192
131config CRYPTO_ECB 131config CRYPTO_ECB
132 tristate "ECB support" 132 tristate "ECB support"
133 select CRYPTO_BLKCIPHER 133 select CRYPTO_BLKCIPHER
134 select CRYPTO_MANAGER
134 default m 135 default m
135 help 136 help
136 ECB: Electronic CodeBook mode 137 ECB: Electronic CodeBook mode
@@ -140,6 +141,7 @@ config CRYPTO_ECB
140config CRYPTO_CBC 141config CRYPTO_CBC
141 tristate "CBC support" 142 tristate "CBC support"
142 select CRYPTO_BLKCIPHER 143 select CRYPTO_BLKCIPHER
144 select CRYPTO_MANAGER
143 default m 145 default m
144 help 146 help
145 CBC: Cipher Block Chaining mode 147 CBC: Cipher Block Chaining mode
diff --git a/crypto/api.c b/crypto/api.c
index 2e84d4b54790..4fb7fa45cb0d 100644
--- a/crypto/api.c
+++ b/crypto/api.c
@@ -331,7 +331,7 @@ struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 flags)
331 tfm_size = sizeof(*tfm) + crypto_ctxsize(alg, flags); 331 tfm_size = sizeof(*tfm) + crypto_ctxsize(alg, flags);
332 tfm = kzalloc(tfm_size, GFP_KERNEL); 332 tfm = kzalloc(tfm_size, GFP_KERNEL);
333 if (tfm == NULL) 333 if (tfm == NULL)
334 goto out; 334 goto out_err;
335 335
336 tfm->__crt_alg = alg; 336 tfm->__crt_alg = alg;
337 337
@@ -355,6 +355,7 @@ cra_init_failed:
355 crypto_exit_ops(tfm); 355 crypto_exit_ops(tfm);
356out_free_tfm: 356out_free_tfm:
357 kfree(tfm); 357 kfree(tfm);
358out_err:
358 tfm = ERR_PTR(err); 359 tfm = ERR_PTR(err);
359out: 360out:
360 return tfm; 361 return tfm;
@@ -414,14 +415,14 @@ struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask)
414 struct crypto_alg *alg; 415 struct crypto_alg *alg;
415 416
416 alg = crypto_alg_mod_lookup(alg_name, type, mask); 417 alg = crypto_alg_mod_lookup(alg_name, type, mask);
417 err = PTR_ERR(alg); 418 if (IS_ERR(alg)) {
418 tfm = ERR_PTR(err); 419 err = PTR_ERR(alg);
419 if (IS_ERR(alg))
420 goto err; 420 goto err;
421 }
421 422
422 tfm = __crypto_alloc_tfm(alg, 0); 423 tfm = __crypto_alloc_tfm(alg, 0);
423 if (!IS_ERR(tfm)) 424 if (!IS_ERR(tfm))
424 break; 425 return tfm;
425 426
426 crypto_mod_put(alg); 427 crypto_mod_put(alg);
427 err = PTR_ERR(tfm); 428 err = PTR_ERR(tfm);
@@ -433,9 +434,9 @@ err:
433 err = -EINTR; 434 err = -EINTR;
434 break; 435 break;
435 } 436 }
436 }; 437 }
437 438
438 return tfm; 439 return ERR_PTR(err);
439} 440}
440EXPORT_SYMBOL_GPL(crypto_alloc_base); 441EXPORT_SYMBOL_GPL(crypto_alloc_base);
441 442
diff --git a/drivers/Kconfig b/drivers/Kconfig
index 263e86ddc1a4..f39463418904 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -14,6 +14,10 @@ source "drivers/pnp/Kconfig"
14 14
15source "drivers/block/Kconfig" 15source "drivers/block/Kconfig"
16 16
17# misc before ide - BLK_DEV_SGIIOC4 depends on SGI_IOC4
18
19source "drivers/misc/Kconfig"
20
17source "drivers/ide/Kconfig" 21source "drivers/ide/Kconfig"
18 22
19source "drivers/scsi/Kconfig" 23source "drivers/scsi/Kconfig"
@@ -52,8 +56,6 @@ source "drivers/w1/Kconfig"
52 56
53source "drivers/hwmon/Kconfig" 57source "drivers/hwmon/Kconfig"
54 58
55source "drivers/misc/Kconfig"
56
57source "drivers/mfd/Kconfig" 59source "drivers/mfd/Kconfig"
58 60
59source "drivers/media/Kconfig" 61source "drivers/media/Kconfig"
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 98099de59b45..6bcd9e8e7bcb 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -85,6 +85,8 @@ struct acpi_memory_device {
85 struct list_head res_list; 85 struct list_head res_list;
86}; 86};
87 87
88static int acpi_hotmem_initialized;
89
88static acpi_status 90static acpi_status
89acpi_memory_get_resource(struct acpi_resource *resource, void *context) 91acpi_memory_get_resource(struct acpi_resource *resource, void *context)
90{ 92{
@@ -414,7 +416,7 @@ static int acpi_memory_device_add(struct acpi_device *device)
414 /* Set the device state */ 416 /* Set the device state */
415 mem_device->state = MEMORY_POWER_ON_STATE; 417 mem_device->state = MEMORY_POWER_ON_STATE;
416 418
417 printk(KERN_INFO "%s \n", acpi_device_name(device)); 419 printk(KERN_DEBUG "%s \n", acpi_device_name(device));
418 420
419 return result; 421 return result;
420} 422}
@@ -438,6 +440,15 @@ static int acpi_memory_device_start (struct acpi_device *device)
438 struct acpi_memory_device *mem_device; 440 struct acpi_memory_device *mem_device;
439 int result = 0; 441 int result = 0;
440 442
443 /*
444 * Early boot code has recognized memory area by EFI/E820.
445 * If DSDT shows these memory devices on boot, hotplug is not necessary
446 * for them. So, it just returns until completion of this driver's
447 * start up.
448 */
449 if (!acpi_hotmem_initialized)
450 return 0;
451
441 mem_device = acpi_driver_data(device); 452 mem_device = acpi_driver_data(device);
442 453
443 if (!acpi_memory_check_device(mem_device)) { 454 if (!acpi_memory_check_device(mem_device)) {
@@ -537,6 +548,7 @@ static int __init acpi_memory_device_init(void)
537 return -ENODEV; 548 return -ENODEV;
538 } 549 }
539 550
551 acpi_hotmem_initialized = 1;
540 return 0; 552 return 0;
541} 553}
542 554
diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c
index e9ee4c52a5f6..c7ac9297a204 100644
--- a/drivers/acpi/asus_acpi.c
+++ b/drivers/acpi/asus_acpi.c
@@ -138,6 +138,7 @@ struct asus_hotk {
138 S2x, //S200 (J1 reported), Victor MP-XP7210 138 S2x, //S200 (J1 reported), Victor MP-XP7210
139 W1N, //W1000N 139 W1N, //W1000N
140 W5A, //W5A 140 W5A, //W5A
141 W3V, //W3030V
141 xxN, //M2400N, M3700N, M5200N, M6800N, S1300N, S5200N 142 xxN, //M2400N, M3700N, M5200N, M6800N, S1300N, S5200N
142 //(Centrino) 143 //(Centrino)
143 END_MODEL 144 END_MODEL
@@ -376,6 +377,17 @@ static struct model_data model_conf[END_MODEL] = {
376 .display_get = "\\ADVG"}, 377 .display_get = "\\ADVG"},
377 378
378 { 379 {
380 .name = "W3V",
381 .mt_mled = "MLED",
382 .mt_wled = "WLED",
383 .mt_lcd_switch = xxN_PREFIX "_Q10",
384 .lcd_status = "\\BKLT",
385 .brightness_set = "SPLV",
386 .brightness_get = "GPLV",
387 .display_set = "SDSP",
388 .display_get = "\\INFB"},
389
390 {
379 .name = "xxN", 391 .name = "xxN",
380 .mt_mled = "MLED", 392 .mt_mled = "MLED",
381/* WLED present, but not controlled by ACPI */ 393/* WLED present, but not controlled by ACPI */
@@ -555,11 +567,11 @@ static int
555write_led(const char __user * buffer, unsigned long count, 567write_led(const char __user * buffer, unsigned long count,
556 char *ledname, int ledmask, int invert) 568 char *ledname, int ledmask, int invert)
557{ 569{
558 int value; 570 int rv, value;
559 int led_out = 0; 571 int led_out = 0;
560 572
561 count = parse_arg(buffer, count, &value); 573 rv = parse_arg(buffer, count, &value);
562 if (count > 0) 574 if (rv > 0)
563 led_out = value ? 1 : 0; 575 led_out = value ? 1 : 0;
564 576
565 hotk->status = 577 hotk->status =
@@ -572,7 +584,7 @@ write_led(const char __user * buffer, unsigned long count,
572 printk(KERN_WARNING "Asus ACPI: LED (%s) write failed\n", 584 printk(KERN_WARNING "Asus ACPI: LED (%s) write failed\n",
573 ledname); 585 ledname);
574 586
575 return count; 587 return rv;
576} 588}
577 589
578/* 590/*
@@ -607,20 +619,18 @@ static int
607proc_write_ledd(struct file *file, const char __user * buffer, 619proc_write_ledd(struct file *file, const char __user * buffer,
608 unsigned long count, void *data) 620 unsigned long count, void *data)
609{ 621{
610 int value; 622 int rv, value;
611 623
612 count = parse_arg(buffer, count, &value); 624 rv = parse_arg(buffer, count, &value);
613 if (count > 0) { 625 if (rv > 0) {
614 if (!write_acpi_int 626 if (!write_acpi_int
615 (hotk->handle, hotk->methods->mt_ledd, value, NULL)) 627 (hotk->handle, hotk->methods->mt_ledd, value, NULL))
616 printk(KERN_WARNING 628 printk(KERN_WARNING
617 "Asus ACPI: LED display write failed\n"); 629 "Asus ACPI: LED display write failed\n");
618 else 630 else
619 hotk->ledd_status = (u32) value; 631 hotk->ledd_status = (u32) value;
620 } else if (count < 0) 632 }
621 printk(KERN_WARNING "Asus ACPI: Error reading user input\n"); 633 return rv;
622
623 return count;
624} 634}
625 635
626/* 636/*
@@ -761,12 +771,12 @@ static int
761proc_write_lcd(struct file *file, const char __user * buffer, 771proc_write_lcd(struct file *file, const char __user * buffer,
762 unsigned long count, void *data) 772 unsigned long count, void *data)
763{ 773{
764 int value; 774 int rv, value;
765 775
766 count = parse_arg(buffer, count, &value); 776 rv = parse_arg(buffer, count, &value);
767 if (count > 0) 777 if (rv > 0)
768 set_lcd_state(value); 778 set_lcd_state(value);
769 return count; 779 return rv;
770} 780}
771 781
772static int read_brightness(void) 782static int read_brightness(void)
@@ -830,18 +840,15 @@ static int
830proc_write_brn(struct file *file, const char __user * buffer, 840proc_write_brn(struct file *file, const char __user * buffer,
831 unsigned long count, void *data) 841 unsigned long count, void *data)
832{ 842{
833 int value; 843 int rv, value;
834 844
835 count = parse_arg(buffer, count, &value); 845 rv = parse_arg(buffer, count, &value);
836 if (count > 0) { 846 if (rv > 0) {
837 value = (0 < value) ? ((15 < value) ? 15 : value) : 0; 847 value = (0 < value) ? ((15 < value) ? 15 : value) : 0;
838 /* 0 <= value <= 15 */ 848 /* 0 <= value <= 15 */
839 set_brightness(value); 849 set_brightness(value);
840 } else if (count < 0) {
841 printk(KERN_WARNING "Asus ACPI: Error reading user input\n");
842 } 850 }
843 851 return rv;
844 return count;
845} 852}
846 853
847static void set_display(int value) 854static void set_display(int value)
@@ -880,15 +887,12 @@ static int
880proc_write_disp(struct file *file, const char __user * buffer, 887proc_write_disp(struct file *file, const char __user * buffer,
881 unsigned long count, void *data) 888 unsigned long count, void *data)
882{ 889{
883 int value; 890 int rv, value;
884 891
885 count = parse_arg(buffer, count, &value); 892 rv = parse_arg(buffer, count, &value);
886 if (count > 0) 893 if (rv > 0)
887 set_display(value); 894 set_display(value);
888 else if (count < 0) 895 return rv;
889 printk(KERN_WARNING "Asus ACPI: Error reading user input\n");
890
891 return count;
892} 896}
893 897
894typedef int (proc_readfunc) (char *page, char **start, off_t off, int count, 898typedef int (proc_readfunc) (char *page, char **start, off_t off, int count,
@@ -1097,6 +1101,8 @@ static int asus_model_match(char *model)
1097 return A4G; 1101 return A4G;
1098 else if (strncmp(model, "W1N", 3) == 0) 1102 else if (strncmp(model, "W1N", 3) == 0)
1099 return W1N; 1103 return W1N;
1104 else if (strncmp(model, "W3V", 3) == 0)
1105 return W3V;
1100 else if (strncmp(model, "W5A", 3) == 0) 1106 else if (strncmp(model, "W5A", 3) == 0)
1101 return W5A; 1107 return W5A;
1102 else 1108 else
@@ -1200,9 +1206,10 @@ static int asus_hotk_get_info(void)
1200 hotk->methods->mt_wled = NULL; 1206 hotk->methods->mt_wled = NULL;
1201 /* L5D's WLED is not controlled by ACPI */ 1207 /* L5D's WLED is not controlled by ACPI */
1202 else if (strncmp(string, "M2N", 3) == 0 || 1208 else if (strncmp(string, "M2N", 3) == 0 ||
1209 strncmp(string, "W3V", 3) == 0 ||
1203 strncmp(string, "S1N", 3) == 0) 1210 strncmp(string, "S1N", 3) == 0)
1204 hotk->methods->mt_wled = "WLED"; 1211 hotk->methods->mt_wled = "WLED";
1205 /* M2N and S1N have a usable WLED */ 1212 /* M2N, S1N and W3V have a usable WLED */
1206 else if (asus_info) { 1213 else if (asus_info) {
1207 if (strncmp(asus_info->oem_table_id, "L1", 2) == 0) 1214 if (strncmp(asus_info->oem_table_id, "L1", 2) == 0)
1208 hotk->methods->mled_status = NULL; 1215 hotk->methods->mled_status = NULL;
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 9810e2a55d0a..026e40755cdd 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -64,6 +64,7 @@ extern void *acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir);
64 64
65static int acpi_battery_add(struct acpi_device *device); 65static int acpi_battery_add(struct acpi_device *device);
66static int acpi_battery_remove(struct acpi_device *device, int type); 66static int acpi_battery_remove(struct acpi_device *device, int type);
67static int acpi_battery_resume(struct acpi_device *device, int status);
67 68
68static struct acpi_driver acpi_battery_driver = { 69static struct acpi_driver acpi_battery_driver = {
69 .name = ACPI_BATTERY_DRIVER_NAME, 70 .name = ACPI_BATTERY_DRIVER_NAME,
@@ -71,6 +72,7 @@ static struct acpi_driver acpi_battery_driver = {
71 .ids = ACPI_BATTERY_HID, 72 .ids = ACPI_BATTERY_HID,
72 .ops = { 73 .ops = {
73 .add = acpi_battery_add, 74 .add = acpi_battery_add,
75 .resume = acpi_battery_resume,
74 .remove = acpi_battery_remove, 76 .remove = acpi_battery_remove,
75 }, 77 },
76}; 78};
@@ -753,6 +755,18 @@ static int acpi_battery_remove(struct acpi_device *device, int type)
753 return 0; 755 return 0;
754} 756}
755 757
758/* this is needed to learn about changes made in suspended state */
759static int acpi_battery_resume(struct acpi_device *device, int state)
760{
761 struct acpi_battery *battery;
762
763 if (!device)
764 return -EINVAL;
765
766 battery = device->driver_data;
767 return acpi_battery_check(battery);
768}
769
756static int __init acpi_battery_init(void) 770static int __init acpi_battery_init(void)
757{ 771{
758 int result; 772 int result;
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index e5d796362854..e6d4b084dca2 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -45,206 +45,143 @@ ACPI_MODULE_NAME("acpi_ec")
45#define ACPI_EC_DRIVER_NAME "ACPI Embedded Controller Driver" 45#define ACPI_EC_DRIVER_NAME "ACPI Embedded Controller Driver"
46#define ACPI_EC_DEVICE_NAME "Embedded Controller" 46#define ACPI_EC_DEVICE_NAME "Embedded Controller"
47#define ACPI_EC_FILE_INFO "info" 47#define ACPI_EC_FILE_INFO "info"
48
49/* EC status register */
48#define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */ 50#define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */
49#define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */ 51#define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */
50#define ACPI_EC_FLAG_BURST 0x10 /* burst mode */ 52#define ACPI_EC_FLAG_BURST 0x10 /* burst mode */
51#define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */ 53#define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */
52#define ACPI_EC_EVENT_OBF 0x01 /* Output buffer full */ 54
53#define ACPI_EC_EVENT_IBE 0x02 /* Input buffer empty */ 55/* EC commands */
54#define ACPI_EC_DELAY 50 /* Wait 50ms max. during EC ops */
55#define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */
56#define ACPI_EC_UDELAY 100 /* Poll @ 100us increments */
57#define ACPI_EC_UDELAY_COUNT 1000 /* Wait 10ms max. during EC ops */
58#define ACPI_EC_COMMAND_READ 0x80 56#define ACPI_EC_COMMAND_READ 0x80
59#define ACPI_EC_COMMAND_WRITE 0x81 57#define ACPI_EC_COMMAND_WRITE 0x81
60#define ACPI_EC_BURST_ENABLE 0x82 58#define ACPI_EC_BURST_ENABLE 0x82
61#define ACPI_EC_BURST_DISABLE 0x83 59#define ACPI_EC_BURST_DISABLE 0x83
62#define ACPI_EC_COMMAND_QUERY 0x84 60#define ACPI_EC_COMMAND_QUERY 0x84
63#define EC_POLL 0xFF 61
64#define EC_INTR 0x00 62/* EC events */
63enum {
64 ACPI_EC_EVENT_OBF_1 = 1, /* Output buffer full */
65 ACPI_EC_EVENT_IBF_0, /* Input buffer empty */
66};
67
68#define ACPI_EC_DELAY 50 /* Wait 50ms max. during EC ops */
69#define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */
70#define ACPI_EC_UDELAY 100 /* Poll @ 100us increments */
71#define ACPI_EC_UDELAY_COUNT 1000 /* Wait 10ms max. during EC ops */
72
73enum {
74 EC_INTR = 1, /* Output buffer full */
75 EC_POLL, /* Input buffer empty */
76};
77
65static int acpi_ec_remove(struct acpi_device *device, int type); 78static int acpi_ec_remove(struct acpi_device *device, int type);
66static int acpi_ec_start(struct acpi_device *device); 79static int acpi_ec_start(struct acpi_device *device);
67static int acpi_ec_stop(struct acpi_device *device, int type); 80static int acpi_ec_stop(struct acpi_device *device, int type);
68static int acpi_ec_intr_add(struct acpi_device *device); 81static int acpi_ec_add(struct acpi_device *device);
69static int acpi_ec_poll_add(struct acpi_device *device);
70 82
71static struct acpi_driver acpi_ec_driver = { 83static struct acpi_driver acpi_ec_driver = {
72 .name = ACPI_EC_DRIVER_NAME, 84 .name = ACPI_EC_DRIVER_NAME,
73 .class = ACPI_EC_CLASS, 85 .class = ACPI_EC_CLASS,
74 .ids = ACPI_EC_HID, 86 .ids = ACPI_EC_HID,
75 .ops = { 87 .ops = {
76 .add = acpi_ec_intr_add, 88 .add = acpi_ec_add,
77 .remove = acpi_ec_remove, 89 .remove = acpi_ec_remove,
78 .start = acpi_ec_start, 90 .start = acpi_ec_start,
79 .stop = acpi_ec_stop, 91 .stop = acpi_ec_stop,
80 }, 92 },
81}; 93};
82union acpi_ec {
83 struct {
84 u32 mode;
85 acpi_handle handle;
86 unsigned long uid;
87 unsigned long gpe_bit;
88 struct acpi_generic_address status_addr;
89 struct acpi_generic_address command_addr;
90 struct acpi_generic_address data_addr;
91 unsigned long global_lock;
92 } common;
93
94 struct {
95 u32 mode;
96 acpi_handle handle;
97 unsigned long uid;
98 unsigned long gpe_bit;
99 struct acpi_generic_address status_addr;
100 struct acpi_generic_address command_addr;
101 struct acpi_generic_address data_addr;
102 unsigned long global_lock;
103 unsigned int expect_event;
104 atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort */
105 atomic_t pending_gpe;
106 struct semaphore sem;
107 wait_queue_head_t wait;
108 } intr;
109
110 struct {
111 u32 mode;
112 acpi_handle handle;
113 unsigned long uid;
114 unsigned long gpe_bit;
115 struct acpi_generic_address status_addr;
116 struct acpi_generic_address command_addr;
117 struct acpi_generic_address data_addr;
118 unsigned long global_lock;
119 struct semaphore sem;
120 } poll;
121};
122 94
123static int acpi_ec_poll_wait(union acpi_ec *ec, u8 event);
124static int acpi_ec_intr_wait(union acpi_ec *ec, unsigned int event);
125static int acpi_ec_poll_read(union acpi_ec *ec, u8 address, u32 * data);
126static int acpi_ec_intr_read(union acpi_ec *ec, u8 address, u32 * data);
127static int acpi_ec_poll_write(union acpi_ec *ec, u8 address, u8 data);
128static int acpi_ec_intr_write(union acpi_ec *ec, u8 address, u8 data);
129static int acpi_ec_poll_query(union acpi_ec *ec, u32 * data);
130static int acpi_ec_intr_query(union acpi_ec *ec, u32 * data);
131static void acpi_ec_gpe_poll_query(void *ec_cxt);
132static void acpi_ec_gpe_intr_query(void *ec_cxt);
133static u32 acpi_ec_gpe_poll_handler(void *data);
134static u32 acpi_ec_gpe_intr_handler(void *data);
135static acpi_status __init
136acpi_fake_ecdt_poll_callback(acpi_handle handle,
137 u32 Level, void *context, void **retval);
138
139static acpi_status __init
140acpi_fake_ecdt_intr_callback(acpi_handle handle,
141 u32 Level, void *context, void **retval);
142
143static int __init acpi_ec_poll_get_real_ecdt(void);
144static int __init acpi_ec_intr_get_real_ecdt(void);
145/* If we find an EC via the ECDT, we need to keep a ptr to its context */ 95/* If we find an EC via the ECDT, we need to keep a ptr to its context */
146static union acpi_ec *ec_ecdt; 96struct acpi_ec {
97 acpi_handle handle;
98 unsigned long uid;
99 unsigned long gpe_bit;
100 unsigned long command_addr;
101 unsigned long data_addr;
102 unsigned long global_lock;
103 struct semaphore sem;
104 unsigned int expect_event;
105 atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort */
106 wait_queue_head_t wait;
107} *ec_ecdt;
147 108
148/* External interfaces use first EC only, so remember */ 109/* External interfaces use first EC only, so remember */
149static struct acpi_device *first_ec; 110static struct acpi_device *first_ec;
150static int acpi_ec_poll_mode = EC_INTR; 111static int acpi_ec_mode = EC_INTR;
151 112
152/* -------------------------------------------------------------------------- 113/* --------------------------------------------------------------------------
153 Transaction Management 114 Transaction Management
154 -------------------------------------------------------------------------- */ 115 -------------------------------------------------------------------------- */
155 116
156static u32 acpi_ec_read_status(union acpi_ec *ec) 117static inline u8 acpi_ec_read_status(struct acpi_ec *ec)
157{ 118{
158 u32 status = 0; 119 return inb(ec->command_addr);
159
160 acpi_hw_low_level_read(8, &status, &ec->common.status_addr);
161 return status;
162} 120}
163 121
164static int acpi_ec_wait(union acpi_ec *ec, u8 event) 122static inline u8 acpi_ec_read_data(struct acpi_ec *ec)
165{ 123{
166 if (acpi_ec_poll_mode) 124 return inb(ec->data_addr);
167 return acpi_ec_poll_wait(ec, event);
168 else
169 return acpi_ec_intr_wait(ec, event);
170} 125}
171 126
172static int acpi_ec_poll_wait(union acpi_ec *ec, u8 event) 127static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command)
173{ 128{
174 u32 acpi_ec_status = 0; 129 outb(command, ec->command_addr);
175 u32 i = ACPI_EC_UDELAY_COUNT; 130}
176 131
177 if (!ec) 132static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data)
178 return -EINVAL; 133{
134 outb(data, ec->data_addr);
135}
179 136
180 /* Poll the EC status register waiting for the event to occur. */ 137static int acpi_ec_check_status(u8 status, u8 event)
138{
181 switch (event) { 139 switch (event) {
182 case ACPI_EC_EVENT_OBF: 140 case ACPI_EC_EVENT_OBF_1:
183 do { 141 if (status & ACPI_EC_FLAG_OBF)
184 acpi_hw_low_level_read(8, &acpi_ec_status, 142 return 1;
185 &ec->common.status_addr);
186 if (acpi_ec_status & ACPI_EC_FLAG_OBF)
187 return 0;
188 udelay(ACPI_EC_UDELAY);
189 } while (--i > 0);
190 break; 143 break;
191 case ACPI_EC_EVENT_IBE: 144 case ACPI_EC_EVENT_IBF_0:
192 do { 145 if (!(status & ACPI_EC_FLAG_IBF))
193 acpi_hw_low_level_read(8, &acpi_ec_status, 146 return 1;
194 &ec->common.status_addr);
195 if (!(acpi_ec_status & ACPI_EC_FLAG_IBF))
196 return 0;
197 udelay(ACPI_EC_UDELAY);
198 } while (--i > 0);
199 break; 147 break;
200 default: 148 default:
201 return -EINVAL; 149 break;
202 } 150 }
203 151
204 return -ETIME; 152 return 0;
205} 153}
206static int acpi_ec_intr_wait(union acpi_ec *ec, unsigned int event)
207{
208 int result = 0;
209
210 154
211 ec->intr.expect_event = event; 155static int acpi_ec_wait(struct acpi_ec *ec, u8 event)
212 smp_mb(); 156{
157 int i = (acpi_ec_mode == EC_POLL) ? ACPI_EC_UDELAY_COUNT : 0;
158 long time_left;
213 159
214 switch (event) { 160 ec->expect_event = event;
215 case ACPI_EC_EVENT_IBE: 161 if (acpi_ec_check_status(acpi_ec_read_status(ec), event)) {
216 if (~acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) { 162 ec->expect_event = 0;
217 ec->intr.expect_event = 0; 163 return 0;
218 return 0;
219 }
220 break;
221 default:
222 break;
223 } 164 }
224 165
225 result = wait_event_timeout(ec->intr.wait, 166 do {
226 !ec->intr.expect_event, 167 if (acpi_ec_mode == EC_POLL) {
168 udelay(ACPI_EC_UDELAY);
169 } else {
170 time_left = wait_event_timeout(ec->wait,
171 !ec->expect_event,
227 msecs_to_jiffies(ACPI_EC_DELAY)); 172 msecs_to_jiffies(ACPI_EC_DELAY));
228 173 if (time_left > 0) {
229 ec->intr.expect_event = 0; 174 ec->expect_event = 0;
230 smp_mb(); 175 return 0;
231 176 }
232 /* 177 }
233 * Verify that the event in question has actually happened by 178 if (acpi_ec_check_status(acpi_ec_read_status(ec), event)) {
234 * querying EC status. Do the check even if operation timed-out 179 ec->expect_event = 0;
235 * to make sure that we did not miss interrupt.
236 */
237 switch (event) {
238 case ACPI_EC_EVENT_OBF:
239 if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_OBF)
240 return 0; 180 return 0;
241 break; 181 }
182 } while (--i > 0);
242 183
243 case ACPI_EC_EVENT_IBE: 184 ec->expect_event = 0;
244 if (~acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF)
245 return 0;
246 break;
247 }
248 185
249 return -ETIME; 186 return -ETIME;
250} 187}
@@ -254,272 +191,150 @@ static int acpi_ec_intr_wait(union acpi_ec *ec, unsigned int event)
254 * Note: samsung nv5000 doesn't work with ec burst mode. 191 * Note: samsung nv5000 doesn't work with ec burst mode.
255 * http://bugzilla.kernel.org/show_bug.cgi?id=4980 192 * http://bugzilla.kernel.org/show_bug.cgi?id=4980
256 */ 193 */
257int acpi_ec_enter_burst_mode(union acpi_ec *ec) 194int acpi_ec_enter_burst_mode(struct acpi_ec *ec)
258{ 195{
259 u32 tmp = 0; 196 u8 tmp = 0;
260 int status = 0; 197 u8 status = 0;
261 198
262 199
263 status = acpi_ec_read_status(ec); 200 status = acpi_ec_read_status(ec);
264 if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) { 201 if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) {
265 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 202 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
266 if (status) 203 if (status)
267 goto end; 204 goto end;
268 acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, 205 acpi_ec_write_cmd(ec, ACPI_EC_BURST_ENABLE);
269 &ec->common.command_addr); 206 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1);
270 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 207 tmp = acpi_ec_read_data(ec);
271 acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr);
272 if (tmp != 0x90) { /* Burst ACK byte */ 208 if (tmp != 0x90) { /* Burst ACK byte */
273 return -EINVAL; 209 return -EINVAL;
274 } 210 }
275 } 211 }
276 212
277 atomic_set(&ec->intr.leaving_burst, 0); 213 atomic_set(&ec->leaving_burst, 0);
278 return 0; 214 return 0;
279 end: 215 end:
280 ACPI_EXCEPTION ((AE_INFO, status, "EC wait, burst mode"); 216 ACPI_EXCEPTION((AE_INFO, status, "EC wait, burst mode"));
281 return -1; 217 return -1;
282} 218}
283 219
284int acpi_ec_leave_burst_mode(union acpi_ec *ec) 220int acpi_ec_leave_burst_mode(struct acpi_ec *ec)
285{ 221{
286 int status = 0; 222 u8 status = 0;
287 223
288 224
289 status = acpi_ec_read_status(ec); 225 status = acpi_ec_read_status(ec);
290 if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)){ 226 if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)){
291 status = acpi_ec_wait(ec, ACPI_EC_FLAG_IBF); 227 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
292 if(status) 228 if(status)
293 goto end; 229 goto end;
294 acpi_hw_low_level_write(8, ACPI_EC_BURST_DISABLE, &ec->common.command_addr); 230 acpi_ec_write_cmd(ec, ACPI_EC_BURST_DISABLE);
295 acpi_ec_wait(ec, ACPI_EC_FLAG_IBF); 231 acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
296 } 232 }
297 atomic_set(&ec->intr.leaving_burst, 1); 233 atomic_set(&ec->leaving_burst, 1);
298 return 0; 234 return 0;
299end: 235 end:
300 ACPI_EXCEPTION((AE_INFO, status, "EC leave burst mode"); 236 ACPI_EXCEPTION((AE_INFO, status, "EC leave burst mode"));
301 return -1; 237 return -1;
302} 238}
303#endif /* ACPI_FUTURE_USAGE */ 239#endif /* ACPI_FUTURE_USAGE */
304 240
305static int acpi_ec_read(union acpi_ec *ec, u8 address, u32 * data) 241static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
306{ 242 const u8 *wdata, unsigned wdata_len,
307 if (acpi_ec_poll_mode) 243 u8 *rdata, unsigned rdata_len)
308 return acpi_ec_poll_read(ec, address, data);
309 else
310 return acpi_ec_intr_read(ec, address, data);
311}
312static int acpi_ec_write(union acpi_ec *ec, u8 address, u8 data)
313{
314 if (acpi_ec_poll_mode)
315 return acpi_ec_poll_write(ec, address, data);
316 else
317 return acpi_ec_intr_write(ec, address, data);
318}
319static int acpi_ec_poll_read(union acpi_ec *ec, u8 address, u32 * data)
320{ 244{
321 acpi_status status = AE_OK; 245 int result;
322 int result = 0;
323 u32 glk = 0;
324 246
247 acpi_ec_write_cmd(ec, command);
325 248
326 if (!ec || !data) 249 for (; wdata_len > 0; wdata_len --) {
327 return -EINVAL; 250 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
328 251 if (result)
329 *data = 0; 252 return result;
330 253 acpi_ec_write_data(ec, *(wdata++));
331 if (ec->common.global_lock) {
332 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
333 if (ACPI_FAILURE(status))
334 return -ENODEV;
335 } 254 }
336 255
337 if (down_interruptible(&ec->poll.sem)) { 256 if (command == ACPI_EC_COMMAND_WRITE) {
338 result = -ERESTARTSYS; 257 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
339 goto end_nosem; 258 if (result)
259 return result;
340 } 260 }
341
342 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ,
343 &ec->common.command_addr);
344 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
345 if (result)
346 goto end;
347
348 acpi_hw_low_level_write(8, address, &ec->common.data_addr);
349 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
350 if (result)
351 goto end;
352
353 acpi_hw_low_level_read(8, data, &ec->common.data_addr);
354
355 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n",
356 *data, address));
357
358 end:
359 up(&ec->poll.sem);
360end_nosem:
361 if (ec->common.global_lock)
362 acpi_release_global_lock(glk);
363
364 return result;
365}
366
367static int acpi_ec_poll_write(union acpi_ec *ec, u8 address, u8 data)
368{
369 int result = 0;
370 acpi_status status = AE_OK;
371 u32 glk = 0;
372 261
262 for (; rdata_len > 0; rdata_len --) {
263 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1);
264 if (result)
265 return result;
373 266
374 if (!ec) 267 *(rdata++) = acpi_ec_read_data(ec);
375 return -EINVAL;
376
377 if (ec->common.global_lock) {
378 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
379 if (ACPI_FAILURE(status))
380 return -ENODEV;
381 }
382
383 if (down_interruptible(&ec->poll.sem)) {
384 result = -ERESTARTSYS;
385 goto end_nosem;
386 } 268 }
387
388 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE,
389 &ec->common.command_addr);
390 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
391 if (result)
392 goto end;
393
394 acpi_hw_low_level_write(8, address, &ec->common.data_addr);
395 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
396 if (result)
397 goto end;
398
399 acpi_hw_low_level_write(8, data, &ec->common.data_addr);
400 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
401 if (result)
402 goto end;
403 269
404 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n", 270 return 0;
405 data, address));
406
407 end:
408 up(&ec->poll.sem);
409end_nosem:
410 if (ec->common.global_lock)
411 acpi_release_global_lock(glk);
412
413 return result;
414} 271}
415 272
416static int acpi_ec_intr_read(union acpi_ec *ec, u8 address, u32 * data) 273static int acpi_ec_transaction(struct acpi_ec *ec, u8 command,
274 const u8 *wdata, unsigned wdata_len,
275 u8 *rdata, unsigned rdata_len)
417{ 276{
418 int status = 0; 277 int status;
419 u32 glk; 278 u32 glk;
420 279
421 280 if (!ec || (wdata_len && !wdata) || (rdata_len && !rdata))
422 if (!ec || !data)
423 return -EINVAL; 281 return -EINVAL;
424 282
425 *data = 0; 283 if (rdata)
284 memset(rdata, 0, rdata_len);
426 285
427 if (ec->common.global_lock) { 286 if (ec->global_lock) {
428 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); 287 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
429 if (ACPI_FAILURE(status)) 288 if (ACPI_FAILURE(status))
430 return -ENODEV; 289 return -ENODEV;
431 } 290 }
291 down(&ec->sem);
432 292
433 WARN_ON(in_interrupt()); 293 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
434 down(&ec->intr.sem);
435
436 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
437 if (status) { 294 if (status) {
438 printk(KERN_DEBUG PREFIX "read EC, IB not empty\n"); 295 printk(KERN_DEBUG PREFIX "read EC, IB not empty\n");
439 goto end; 296 goto end;
440 } 297 }
441 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ,
442 &ec->common.command_addr);
443 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
444 if (status) {
445 printk(KERN_DEBUG PREFIX "read EC, IB not empty\n");
446 }
447 298
448 acpi_hw_low_level_write(8, address, &ec->common.data_addr); 299 status = acpi_ec_transaction_unlocked(ec, command,
449 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 300 wdata, wdata_len,
450 if (status) { 301 rdata, rdata_len);
451 printk(KERN_DEBUG PREFIX "read EC, OB not full\n");
452 goto end;
453 }
454 acpi_hw_low_level_read(8, data, &ec->common.data_addr);
455 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n",
456 *data, address));
457 302
458 end: 303end:
459 up(&ec->intr.sem); 304 up(&ec->sem);
460 305
461 if (ec->common.global_lock) 306 if (ec->global_lock)
462 acpi_release_global_lock(glk); 307 acpi_release_global_lock(glk);
463 308
464 return status; 309 return status;
465} 310}
466 311
467static int acpi_ec_intr_write(union acpi_ec *ec, u8 address, u8 data) 312static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 *data)
468{ 313{
469 int status = 0; 314 int result;
470 u32 glk; 315 u8 d;
471
472
473 if (!ec)
474 return -EINVAL;
475
476 if (ec->common.global_lock) {
477 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
478 if (ACPI_FAILURE(status))
479 return -ENODEV;
480 }
481
482 WARN_ON(in_interrupt());
483 down(&ec->intr.sem);
484
485 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
486 if (status) {
487 printk(KERN_DEBUG PREFIX "write EC, IB not empty\n");
488 }
489 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE,
490 &ec->common.command_addr);
491 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
492 if (status) {
493 printk(KERN_DEBUG PREFIX "write EC, IB not empty\n");
494 }
495
496 acpi_hw_low_level_write(8, address, &ec->common.data_addr);
497 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
498 if (status) {
499 printk(KERN_DEBUG PREFIX "write EC, IB not empty\n");
500 }
501
502 acpi_hw_low_level_write(8, data, &ec->common.data_addr);
503 316
504 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n", 317 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_READ,
505 data, address)); 318 &address, 1, &d, 1);
506 319 *data = d;
507 up(&ec->intr.sem); 320 return result;
508 321}
509 if (ec->common.global_lock)
510 acpi_release_global_lock(glk);
511 322
512 return status; 323static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data)
324{
325 u8 wdata[2] = { address, data };
326 return acpi_ec_transaction(ec, ACPI_EC_COMMAND_WRITE,
327 wdata, 2, NULL, 0);
513} 328}
514 329
515/* 330/*
516 * Externally callable EC access functions. For now, assume 1 EC only 331 * Externally callable EC access functions. For now, assume 1 EC only
517 */ 332 */
518int ec_read(u8 addr, u8 * val) 333int ec_read(u8 addr, u8 *val)
519{ 334{
520 union acpi_ec *ec; 335 struct acpi_ec *ec;
521 int err; 336 int err;
522 u32 temp_data; 337 u8 temp_data;
523 338
524 if (!first_ec) 339 if (!first_ec)
525 return -ENODEV; 340 return -ENODEV;
@@ -539,7 +354,7 @@ EXPORT_SYMBOL(ec_read);
539 354
540int ec_write(u8 addr, u8 val) 355int ec_write(u8 addr, u8 val)
541{ 356{
542 union acpi_ec *ec; 357 struct acpi_ec *ec;
543 int err; 358 int err;
544 359
545 if (!first_ec) 360 if (!first_ec)
@@ -554,255 +369,106 @@ int ec_write(u8 addr, u8 val)
554 369
555EXPORT_SYMBOL(ec_write); 370EXPORT_SYMBOL(ec_write);
556 371
557static int acpi_ec_query(union acpi_ec *ec, u32 * data) 372extern int ec_transaction(u8 command,
558{ 373 const u8 *wdata, unsigned wdata_len,
559 if (acpi_ec_poll_mode) 374 u8 *rdata, unsigned rdata_len)
560 return acpi_ec_poll_query(ec, data);
561 else
562 return acpi_ec_intr_query(ec, data);
563}
564static int acpi_ec_poll_query(union acpi_ec *ec, u32 * data)
565{ 375{
566 int result = 0; 376 struct acpi_ec *ec;
567 acpi_status status = AE_OK;
568 u32 glk = 0;
569
570
571 if (!ec || !data)
572 return -EINVAL;
573
574 *data = 0;
575
576 if (ec->common.global_lock) {
577 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
578 if (ACPI_FAILURE(status))
579 return -ENODEV;
580 }
581 377
582 /* 378 if (!first_ec)
583 * Query the EC to find out which _Qxx method we need to evaluate. 379 return -ENODEV;
584 * Note that successful completion of the query causes the ACPI_EC_SCI
585 * bit to be cleared (and thus clearing the interrupt source).
586 */
587 if (down_interruptible(&ec->poll.sem)) {
588 result = -ERESTARTSYS;
589 goto end_nosem;
590 }
591
592 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY,
593 &ec->common.command_addr);
594 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
595 if (result)
596 goto end;
597
598 acpi_hw_low_level_read(8, data, &ec->common.data_addr);
599 if (!*data)
600 result = -ENODATA;
601 380
602 end: 381 ec = acpi_driver_data(first_ec);
603 up(&ec->poll.sem);
604end_nosem:
605 if (ec->common.global_lock)
606 acpi_release_global_lock(glk);
607 382
608 return result; 383 return acpi_ec_transaction(ec, command, wdata,
384 wdata_len, rdata, rdata_len);
609} 385}
610static int acpi_ec_intr_query(union acpi_ec *ec, u32 * data)
611{
612 int status = 0;
613 u32 glk;
614
615 386
616 if (!ec || !data) 387EXPORT_SYMBOL(ec_transaction);
617 return -EINVAL;
618 *data = 0;
619
620 if (ec->common.global_lock) {
621 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
622 if (ACPI_FAILURE(status))
623 return -ENODEV;
624 }
625 388
626 down(&ec->intr.sem); 389static int acpi_ec_query(struct acpi_ec *ec, u8 *data)
390{
391 int result;
392 u8 d;
627 393
628 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 394 if (!ec || !data)
629 if (status) { 395 return -EINVAL;
630 printk(KERN_DEBUG PREFIX "query EC, IB not empty\n");
631 goto end;
632 }
633 /*
634 * Query the EC to find out which _Qxx method we need to evaluate.
635 * Note that successful completion of the query causes the ACPI_EC_SCI
636 * bit to be cleared (and thus clearing the interrupt source).
637 */
638 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY,
639 &ec->common.command_addr);
640 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
641 if (status) {
642 printk(KERN_DEBUG PREFIX "query EC, OB not full\n");
643 goto end;
644 }
645 396
646 acpi_hw_low_level_read(8, data, &ec->common.data_addr); 397 /*
647 if (!*data) 398 * Query the EC to find out which _Qxx method we need to evaluate.
648 status = -ENODATA; 399 * Note that successful completion of the query causes the ACPI_EC_SCI
400 * bit to be cleared (and thus clearing the interrupt source).
401 */
649 402
650 end: 403 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_QUERY, NULL, 0, &d, 1);
651 up(&ec->intr.sem); 404 if (result)
405 return result;
652 406
653 if (ec->common.global_lock) 407 if (!d)
654 acpi_release_global_lock(glk); 408 return -ENODATA;
655 409
656 return status; 410 *data = d;
411 return 0;
657} 412}
658 413
659/* -------------------------------------------------------------------------- 414/* --------------------------------------------------------------------------
660 Event Management 415 Event Management
661 -------------------------------------------------------------------------- */ 416 -------------------------------------------------------------------------- */
662 417
663union acpi_ec_query_data { 418struct acpi_ec_query_data {
664 acpi_handle handle; 419 acpi_handle handle;
665 u8 data; 420 u8 data;
666}; 421};
667 422
668static void acpi_ec_gpe_query(void *ec_cxt) 423static void acpi_ec_gpe_query(void *ec_cxt)
669{ 424{
670 if (acpi_ec_poll_mode) 425 struct acpi_ec *ec = (struct acpi_ec *)ec_cxt;
671 acpi_ec_gpe_poll_query(ec_cxt); 426 u8 value = 0;
672 else 427 static char object_name[8];
673 acpi_ec_gpe_intr_query(ec_cxt);
674}
675
676static void acpi_ec_gpe_poll_query(void *ec_cxt)
677{
678 union acpi_ec *ec = (union acpi_ec *)ec_cxt;
679 u32 value = 0;
680 static char object_name[5] = { '_', 'Q', '0', '0', '\0' };
681 const char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7',
682 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
683 };
684
685 428
686 if (!ec_cxt) 429 if (!ec)
687 goto end; 430 goto end;
688 431
689 if (down_interruptible (&ec->poll.sem)) { 432 value = acpi_ec_read_status(ec);
690 return; 433
691 }
692 acpi_hw_low_level_read(8, &value, &ec->common.command_addr);
693 up(&ec->poll.sem);
694
695 /* TBD: Implement asynch events!
696 * NOTE: All we care about are EC-SCI's. Other EC events are
697 * handled via polling (yuck!). This is because some systems
698 * treat EC-SCIs as level (versus EDGE!) triggered, preventing
699 * a purely interrupt-driven approach (grumble, grumble).
700 */
701 if (!(value & ACPI_EC_FLAG_SCI)) 434 if (!(value & ACPI_EC_FLAG_SCI))
702 goto end; 435 goto end;
703 436
704 if (acpi_ec_query(ec, &value)) 437 if (acpi_ec_query(ec, &value))
705 goto end; 438 goto end;
706 439
707 object_name[2] = hex[((value >> 4) & 0x0F)]; 440 snprintf(object_name, 8, "_Q%2.2X", value);
708 object_name[3] = hex[(value & 0x0F)];
709
710 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name));
711 441
712 acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL); 442 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s", object_name));
713 443
714 end: 444 acpi_evaluate_object(ec->handle, object_name, NULL, NULL);
715 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
716}
717static void acpi_ec_gpe_intr_query(void *ec_cxt)
718{
719 union acpi_ec *ec = (union acpi_ec *)ec_cxt;
720 u32 value;
721 int result = -ENODATA;
722 static char object_name[5] = { '_', 'Q', '0', '0', '\0' };
723 const char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7',
724 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
725 };
726 445
727
728 if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_SCI)
729 result = acpi_ec_query(ec, &value);
730
731 if (result)
732 goto end;
733
734 object_name[2] = hex[((value >> 4) & 0x0F)];
735 object_name[3] = hex[(value & 0x0F)];
736
737 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name));
738
739 acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL);
740 end: 446 end:
741 atomic_dec(&ec->intr.pending_gpe); 447 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
742 return;
743} 448}
744 449
745static u32 acpi_ec_gpe_handler(void *data) 450static u32 acpi_ec_gpe_handler(void *data)
746{ 451{
747 if (acpi_ec_poll_mode)
748 return acpi_ec_gpe_poll_handler(data);
749 else
750 return acpi_ec_gpe_intr_handler(data);
751}
752static u32 acpi_ec_gpe_poll_handler(void *data)
753{
754 acpi_status status = AE_OK; 452 acpi_status status = AE_OK;
755 union acpi_ec *ec = (union acpi_ec *)data; 453 u8 value;
756 454 struct acpi_ec *ec = (struct acpi_ec *)data;
757 if (!ec)
758 return ACPI_INTERRUPT_NOT_HANDLED;
759
760 acpi_disable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR);
761
762 status = acpi_os_execute(OSL_EC_POLL_HANDLER, acpi_ec_gpe_query, ec);
763
764 if (status == AE_OK)
765 return ACPI_INTERRUPT_HANDLED;
766 else
767 return ACPI_INTERRUPT_NOT_HANDLED;
768}
769static u32 acpi_ec_gpe_intr_handler(void *data)
770{
771 acpi_status status = AE_OK;
772 u32 value;
773 union acpi_ec *ec = (union acpi_ec *)data;
774
775 if (!ec)
776 return ACPI_INTERRUPT_NOT_HANDLED;
777 455
778 acpi_clear_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); 456 acpi_clear_gpe(NULL, ec->gpe_bit, ACPI_ISR);
779 value = acpi_ec_read_status(ec); 457 value = acpi_ec_read_status(ec);
780 458
781 switch (ec->intr.expect_event) { 459 if (acpi_ec_mode == EC_INTR) {
782 case ACPI_EC_EVENT_OBF: 460 if (acpi_ec_check_status(value, ec->expect_event)) {
783 if (!(value & ACPI_EC_FLAG_OBF)) 461 ec->expect_event = 0;
784 break; 462 wake_up(&ec->wait);
785 ec->intr.expect_event = 0; 463 }
786 wake_up(&ec->intr.wait);
787 break;
788 case ACPI_EC_EVENT_IBE:
789 if ((value & ACPI_EC_FLAG_IBF))
790 break;
791 ec->intr.expect_event = 0;
792 wake_up(&ec->intr.wait);
793 break;
794 default:
795 break;
796 } 464 }
797 465
798 if (value & ACPI_EC_FLAG_SCI) { 466 if (value & ACPI_EC_FLAG_SCI) {
799 atomic_add(1, &ec->intr.pending_gpe); 467 status = acpi_os_execute(OSL_EC_BURST_HANDLER, acpi_ec_gpe_query, ec);
800 status = acpi_os_execute(OSL_EC_BURST_HANDLER,
801 acpi_ec_gpe_query, ec);
802 return status == AE_OK ? 468 return status == AE_OK ?
803 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; 469 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
804 } 470 }
805 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); 471 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_ISR);
806 return status == AE_OK ? 472 return status == AE_OK ?
807 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; 473 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
808} 474}
@@ -833,7 +499,7 @@ acpi_ec_space_handler(u32 function,
833 void *handler_context, void *region_context) 499 void *handler_context, void *region_context)
834{ 500{
835 int result = 0; 501 int result = 0;
836 union acpi_ec *ec = NULL; 502 struct acpi_ec *ec = NULL;
837 u64 temp = *value; 503 u64 temp = *value;
838 acpi_integer f_v = 0; 504 acpi_integer f_v = 0;
839 int i = 0; 505 int i = 0;
@@ -843,18 +509,16 @@ acpi_ec_space_handler(u32 function,
843 return AE_BAD_PARAMETER; 509 return AE_BAD_PARAMETER;
844 510
845 if (bit_width != 8 && acpi_strict) { 511 if (bit_width != 8 && acpi_strict) {
846 printk(KERN_WARNING PREFIX
847 "acpi_ec_space_handler: bit_width should be 8\n");
848 return AE_BAD_PARAMETER; 512 return AE_BAD_PARAMETER;
849 } 513 }
850 514
851 ec = (union acpi_ec *)handler_context; 515 ec = (struct acpi_ec *)handler_context;
852 516
853 next_byte: 517 next_byte:
854 switch (function) { 518 switch (function) {
855 case ACPI_READ: 519 case ACPI_READ:
856 temp = 0; 520 temp = 0;
857 result = acpi_ec_read(ec, (u8) address, (u32 *) & temp); 521 result = acpi_ec_read(ec, (u8) address, (u8 *) &temp);
858 break; 522 break;
859 case ACPI_WRITE: 523 case ACPI_WRITE:
860 result = acpi_ec_write(ec, (u8) address, (u8) temp); 524 result = acpi_ec_write(ec, (u8) address, (u8) temp);
@@ -905,20 +569,20 @@ static struct proc_dir_entry *acpi_ec_dir;
905 569
906static int acpi_ec_read_info(struct seq_file *seq, void *offset) 570static int acpi_ec_read_info(struct seq_file *seq, void *offset)
907{ 571{
908 union acpi_ec *ec = (union acpi_ec *)seq->private; 572 struct acpi_ec *ec = (struct acpi_ec *)seq->private;
909 573
910 574
911 if (!ec) 575 if (!ec)
912 goto end; 576 goto end;
913 577
914 seq_printf(seq, "gpe bit: 0x%02x\n", 578 seq_printf(seq, "gpe bit: 0x%02x\n",
915 (u32) ec->common.gpe_bit); 579 (u32) ec->gpe_bit);
916 seq_printf(seq, "ports: 0x%02x, 0x%02x\n", 580 seq_printf(seq, "ports: 0x%02x, 0x%02x\n",
917 (u32) ec->common.status_addr.address, 581 (u32) ec->command_addr,
918 (u32) ec->common.data_addr.address); 582 (u32) ec->data_addr);
919 seq_printf(seq, "use global lock: %s\n", 583 seq_printf(seq, "use global lock: %s\n",
920 ec->common.global_lock ? "yes" : "no"); 584 ec->global_lock ? "yes" : "no");
921 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 585 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
922 586
923 end: 587 end:
924 return 0; 588 return 0;
@@ -929,7 +593,7 @@ static int acpi_ec_info_open_fs(struct inode *inode, struct file *file)
929 return single_open(file, acpi_ec_read_info, PDE(inode)->data); 593 return single_open(file, acpi_ec_read_info, PDE(inode)->data);
930} 594}
931 595
932static const struct file_operations acpi_ec_info_ops = { 596static struct file_operations acpi_ec_info_ops = {
933 .open = acpi_ec_info_open_fs, 597 .open = acpi_ec_info_open_fs,
934 .read = seq_read, 598 .read = seq_read,
935 .llseek = seq_lseek, 599 .llseek = seq_lseek,
@@ -978,101 +642,35 @@ static int acpi_ec_remove_fs(struct acpi_device *device)
978 Driver Interface 642 Driver Interface
979 -------------------------------------------------------------------------- */ 643 -------------------------------------------------------------------------- */
980 644
981static int acpi_ec_poll_add(struct acpi_device *device) 645static int acpi_ec_add(struct acpi_device *device)
982{ 646{
983 int result = 0; 647 int result = 0;
984 acpi_status status = AE_OK; 648 acpi_status status = AE_OK;
985 union acpi_ec *ec = NULL; 649 struct acpi_ec *ec = NULL;
986 650
987 651
988 if (!device) 652 if (!device)
989 return -EINVAL; 653 return -EINVAL;
990 654
991 ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL); 655 ec = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL);
992 if (!ec) 656 if (!ec)
993 return -ENOMEM; 657 return -ENOMEM;
994 memset(ec, 0, sizeof(union acpi_ec)); 658 memset(ec, 0, sizeof(struct acpi_ec));
995 659
996 ec->common.handle = device->handle; 660 ec->handle = device->handle;
997 ec->common.uid = -1; 661 ec->uid = -1;
998 init_MUTEX(&ec->poll.sem); 662 init_MUTEX(&ec->sem);
999 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME); 663 if (acpi_ec_mode == EC_INTR) {
1000 strcpy(acpi_device_class(device), ACPI_EC_CLASS); 664 atomic_set(&ec->leaving_burst, 1);
1001 acpi_driver_data(device) = ec; 665 init_waitqueue_head(&ec->wait);
1002
1003 /* Use the global lock for all EC transactions? */
1004 acpi_evaluate_integer(ec->common.handle, "_GLK", NULL,
1005 &ec->common.global_lock);
1006
1007 /* XXX we don't test uids, because on some boxes ecdt uid = 0, see:
1008 http://bugzilla.kernel.org/show_bug.cgi?id=6111 */
1009 if (ec_ecdt) {
1010 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT,
1011 ACPI_ADR_SPACE_EC,
1012 &acpi_ec_space_handler);
1013
1014 acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit,
1015 &acpi_ec_gpe_handler);
1016
1017 kfree(ec_ecdt);
1018 } 666 }
1019
1020 /* Get GPE bit assignment (EC events). */
1021 /* TODO: Add support for _GPE returning a package */
1022 status =
1023 acpi_evaluate_integer(ec->common.handle, "_GPE", NULL,
1024 &ec->common.gpe_bit);
1025 if (ACPI_FAILURE(status)) {
1026 ACPI_EXCEPTION((AE_INFO, status, "Obtaining GPE bit"));
1027 result = -ENODEV;
1028 goto end;
1029 }
1030
1031 result = acpi_ec_add_fs(device);
1032 if (result)
1033 goto end;
1034
1035 printk(KERN_INFO PREFIX "%s [%s] (gpe %d) polling mode.\n",
1036 acpi_device_name(device), acpi_device_bid(device),
1037 (u32) ec->common.gpe_bit);
1038
1039 if (!first_ec)
1040 first_ec = device;
1041
1042 end:
1043 if (result)
1044 kfree(ec);
1045
1046 return result;
1047}
1048static int acpi_ec_intr_add(struct acpi_device *device)
1049{
1050 int result = 0;
1051 acpi_status status = AE_OK;
1052 union acpi_ec *ec = NULL;
1053
1054
1055 if (!device)
1056 return -EINVAL;
1057
1058 ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
1059 if (!ec)
1060 return -ENOMEM;
1061 memset(ec, 0, sizeof(union acpi_ec));
1062
1063 ec->common.handle = device->handle;
1064 ec->common.uid = -1;
1065 atomic_set(&ec->intr.pending_gpe, 0);
1066 atomic_set(&ec->intr.leaving_burst, 1);
1067 init_MUTEX(&ec->intr.sem);
1068 init_waitqueue_head(&ec->intr.wait);
1069 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME); 667 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
1070 strcpy(acpi_device_class(device), ACPI_EC_CLASS); 668 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
1071 acpi_driver_data(device) = ec; 669 acpi_driver_data(device) = ec;
1072 670
1073 /* Use the global lock for all EC transactions? */ 671 /* Use the global lock for all EC transactions? */
1074 acpi_evaluate_integer(ec->common.handle, "_GLK", NULL, 672 acpi_evaluate_integer(ec->handle, "_GLK", NULL,
1075 &ec->common.global_lock); 673 &ec->global_lock);
1076 674
1077 /* XXX we don't test uids, because on some boxes ecdt uid = 0, see: 675 /* XXX we don't test uids, because on some boxes ecdt uid = 0, see:
1078 http://bugzilla.kernel.org/show_bug.cgi?id=6111 */ 676 http://bugzilla.kernel.org/show_bug.cgi?id=6111 */
@@ -1081,7 +679,7 @@ static int acpi_ec_intr_add(struct acpi_device *device)
1081 ACPI_ADR_SPACE_EC, 679 ACPI_ADR_SPACE_EC,
1082 &acpi_ec_space_handler); 680 &acpi_ec_space_handler);
1083 681
1084 acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, 682 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe_bit,
1085 &acpi_ec_gpe_handler); 683 &acpi_ec_gpe_handler);
1086 684
1087 kfree(ec_ecdt); 685 kfree(ec_ecdt);
@@ -1090,10 +688,10 @@ static int acpi_ec_intr_add(struct acpi_device *device)
1090 /* Get GPE bit assignment (EC events). */ 688 /* Get GPE bit assignment (EC events). */
1091 /* TODO: Add support for _GPE returning a package */ 689 /* TODO: Add support for _GPE returning a package */
1092 status = 690 status =
1093 acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, 691 acpi_evaluate_integer(ec->handle, "_GPE", NULL,
1094 &ec->common.gpe_bit); 692 &ec->gpe_bit);
1095 if (ACPI_FAILURE(status)) { 693 if (ACPI_FAILURE(status)) {
1096 printk(KERN_ERR PREFIX "Obtaining GPE bit assignment\n"); 694 ACPI_EXCEPTION((AE_INFO, status, "Obtaining GPE bit assignment"));
1097 result = -ENODEV; 695 result = -ENODEV;
1098 goto end; 696 goto end;
1099 } 697 }
@@ -1102,14 +700,14 @@ static int acpi_ec_intr_add(struct acpi_device *device)
1102 if (result) 700 if (result)
1103 goto end; 701 goto end;
1104 702
1105 printk(KERN_INFO PREFIX "%s [%s] (gpe %d) interrupt mode.\n", 703 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s [%s] (gpe %d) interrupt mode.",
1106 acpi_device_name(device), acpi_device_bid(device), 704 acpi_device_name(device), acpi_device_bid(device),
1107 (u32) ec->common.gpe_bit); 705 (u32) ec->gpe_bit));
1108 706
1109 if (!first_ec) 707 if (!first_ec)
1110 first_ec = device; 708 first_ec = device;
1111 709
1112 end: 710 end:
1113 if (result) 711 if (result)
1114 kfree(ec); 712 kfree(ec);
1115 713
@@ -1118,7 +716,7 @@ static int acpi_ec_intr_add(struct acpi_device *device)
1118 716
1119static int acpi_ec_remove(struct acpi_device *device, int type) 717static int acpi_ec_remove(struct acpi_device *device, int type)
1120{ 718{
1121 union acpi_ec *ec = NULL; 719 struct acpi_ec *ec = NULL;
1122 720
1123 721
1124 if (!device) 722 if (!device)
@@ -1136,8 +734,7 @@ static int acpi_ec_remove(struct acpi_device *device, int type)
1136static acpi_status 734static acpi_status
1137acpi_ec_io_ports(struct acpi_resource *resource, void *context) 735acpi_ec_io_ports(struct acpi_resource *resource, void *context)
1138{ 736{
1139 union acpi_ec *ec = (union acpi_ec *)context; 737 struct acpi_ec *ec = (struct acpi_ec *)context;
1140 struct acpi_generic_address *addr;
1141 738
1142 if (resource->type != ACPI_RESOURCE_TYPE_IO) { 739 if (resource->type != ACPI_RESOURCE_TYPE_IO) {
1143 return AE_OK; 740 return AE_OK;
@@ -1148,26 +745,21 @@ acpi_ec_io_ports(struct acpi_resource *resource, void *context)
1148 * the second address region returned is the status/command 745 * the second address region returned is the status/command
1149 * port. 746 * port.
1150 */ 747 */
1151 if (ec->common.data_addr.register_bit_width == 0) { 748 if (ec->data_addr == 0) {
1152 addr = &ec->common.data_addr; 749 ec->data_addr = resource->data.io.minimum;
1153 } else if (ec->common.command_addr.register_bit_width == 0) { 750 } else if (ec->command_addr == 0) {
1154 addr = &ec->common.command_addr; 751 ec->command_addr = resource->data.io.minimum;
1155 } else { 752 } else {
1156 return AE_CTRL_TERMINATE; 753 return AE_CTRL_TERMINATE;
1157 } 754 }
1158 755
1159 addr->address_space_id = ACPI_ADR_SPACE_SYSTEM_IO;
1160 addr->register_bit_width = 8;
1161 addr->register_bit_offset = 0;
1162 addr->address = resource->data.io.minimum;
1163
1164 return AE_OK; 756 return AE_OK;
1165} 757}
1166 758
1167static int acpi_ec_start(struct acpi_device *device) 759static int acpi_ec_start(struct acpi_device *device)
1168{ 760{
1169 acpi_status status = AE_OK; 761 acpi_status status = AE_OK;
1170 union acpi_ec *ec = NULL; 762 struct acpi_ec *ec = NULL;
1171 763
1172 764
1173 if (!device) 765 if (!device)
@@ -1181,39 +773,35 @@ static int acpi_ec_start(struct acpi_device *device)
1181 /* 773 /*
1182 * Get I/O port addresses. Convert to GAS format. 774 * Get I/O port addresses. Convert to GAS format.
1183 */ 775 */
1184 status = acpi_walk_resources(ec->common.handle, METHOD_NAME__CRS, 776 status = acpi_walk_resources(ec->handle, METHOD_NAME__CRS,
1185 acpi_ec_io_ports, ec); 777 acpi_ec_io_ports, ec);
1186 if (ACPI_FAILURE(status) 778 if (ACPI_FAILURE(status) || ec->command_addr == 0) {
1187 || ec->common.command_addr.register_bit_width == 0) { 779 ACPI_EXCEPTION((AE_INFO, status,
1188 printk(KERN_ERR PREFIX "Error getting I/O port addresses\n"); 780 "Error getting I/O port addresses"));
1189 return -ENODEV; 781 return -ENODEV;
1190 } 782 }
1191 783
1192 ec->common.status_addr = ec->common.command_addr; 784 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02lx, ports=0x%2lx,0x%2lx",
1193 785 ec->gpe_bit, ec->command_addr, ec->data_addr));
1194 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02x, ports=0x%2x,0x%2x\n",
1195 (u32) ec->common.gpe_bit,
1196 (u32) ec->common.command_addr.address,
1197 (u32) ec->common.data_addr.address));
1198 786
1199 /* 787 /*
1200 * Install GPE handler 788 * Install GPE handler
1201 */ 789 */
1202 status = acpi_install_gpe_handler(NULL, ec->common.gpe_bit, 790 status = acpi_install_gpe_handler(NULL, ec->gpe_bit,
1203 ACPI_GPE_EDGE_TRIGGERED, 791 ACPI_GPE_EDGE_TRIGGERED,
1204 &acpi_ec_gpe_handler, ec); 792 &acpi_ec_gpe_handler, ec);
1205 if (ACPI_FAILURE(status)) { 793 if (ACPI_FAILURE(status)) {
1206 return -ENODEV; 794 return -ENODEV;
1207 } 795 }
1208 acpi_set_gpe_type(NULL, ec->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME); 796 acpi_set_gpe_type(NULL, ec->gpe_bit, ACPI_GPE_TYPE_RUNTIME);
1209 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 797 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
1210 798
1211 status = acpi_install_address_space_handler(ec->common.handle, 799 status = acpi_install_address_space_handler(ec->handle,
1212 ACPI_ADR_SPACE_EC, 800 ACPI_ADR_SPACE_EC,
1213 &acpi_ec_space_handler, 801 &acpi_ec_space_handler,
1214 &acpi_ec_space_setup, ec); 802 &acpi_ec_space_setup, ec);
1215 if (ACPI_FAILURE(status)) { 803 if (ACPI_FAILURE(status)) {
1216 acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, 804 acpi_remove_gpe_handler(NULL, ec->gpe_bit,
1217 &acpi_ec_gpe_handler); 805 &acpi_ec_gpe_handler);
1218 return -ENODEV; 806 return -ENODEV;
1219 } 807 }
@@ -1224,7 +812,7 @@ static int acpi_ec_start(struct acpi_device *device)
1224static int acpi_ec_stop(struct acpi_device *device, int type) 812static int acpi_ec_stop(struct acpi_device *device, int type)
1225{ 813{
1226 acpi_status status = AE_OK; 814 acpi_status status = AE_OK;
1227 union acpi_ec *ec = NULL; 815 struct acpi_ec *ec = NULL;
1228 816
1229 817
1230 if (!device) 818 if (!device)
@@ -1232,14 +820,14 @@ static int acpi_ec_stop(struct acpi_device *device, int type)
1232 820
1233 ec = acpi_driver_data(device); 821 ec = acpi_driver_data(device);
1234 822
1235 status = acpi_remove_address_space_handler(ec->common.handle, 823 status = acpi_remove_address_space_handler(ec->handle,
1236 ACPI_ADR_SPACE_EC, 824 ACPI_ADR_SPACE_EC,
1237 &acpi_ec_space_handler); 825 &acpi_ec_space_handler);
1238 if (ACPI_FAILURE(status)) 826 if (ACPI_FAILURE(status))
1239 return -ENODEV; 827 return -ENODEV;
1240 828
1241 status = 829 status =
1242 acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, 830 acpi_remove_gpe_handler(NULL, ec->gpe_bit,
1243 &acpi_ec_gpe_handler); 831 &acpi_ec_gpe_handler);
1244 if (ACPI_FAILURE(status)) 832 if (ACPI_FAILURE(status))
1245 return -ENODEV; 833 return -ENODEV;
@@ -1251,76 +839,30 @@ static acpi_status __init
1251acpi_fake_ecdt_callback(acpi_handle handle, 839acpi_fake_ecdt_callback(acpi_handle handle,
1252 u32 Level, void *context, void **retval) 840 u32 Level, void *context, void **retval)
1253{ 841{
1254
1255 if (acpi_ec_poll_mode)
1256 return acpi_fake_ecdt_poll_callback(handle,
1257 Level, context, retval);
1258 else
1259 return acpi_fake_ecdt_intr_callback(handle,
1260 Level, context, retval);
1261}
1262
1263static acpi_status __init
1264acpi_fake_ecdt_poll_callback(acpi_handle handle,
1265 u32 Level, void *context, void **retval)
1266{
1267 acpi_status status;
1268
1269 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
1270 acpi_ec_io_ports, ec_ecdt);
1271 if (ACPI_FAILURE(status))
1272 return status;
1273 ec_ecdt->common.status_addr = ec_ecdt->common.command_addr;
1274
1275 ec_ecdt->common.uid = -1;
1276 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid);
1277
1278 status =
1279 acpi_evaluate_integer(handle, "_GPE", NULL,
1280 &ec_ecdt->common.gpe_bit);
1281 if (ACPI_FAILURE(status))
1282 return status;
1283 init_MUTEX(&ec_ecdt->poll.sem);
1284 ec_ecdt->common.global_lock = TRUE;
1285 ec_ecdt->common.handle = handle;
1286
1287 printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n",
1288 (u32) ec_ecdt->common.gpe_bit,
1289 (u32) ec_ecdt->common.command_addr.address,
1290 (u32) ec_ecdt->common.data_addr.address);
1291
1292 return AE_CTRL_TERMINATE;
1293}
1294
1295static acpi_status __init
1296acpi_fake_ecdt_intr_callback(acpi_handle handle,
1297 u32 Level, void *context, void **retval)
1298{
1299 acpi_status status; 842 acpi_status status;
1300 843
1301 init_MUTEX(&ec_ecdt->intr.sem); 844 init_MUTEX(&ec_ecdt->sem);
1302 init_waitqueue_head(&ec_ecdt->intr.wait); 845 if (acpi_ec_mode == EC_INTR) {
846 init_waitqueue_head(&ec_ecdt->wait);
847 }
1303 status = acpi_walk_resources(handle, METHOD_NAME__CRS, 848 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
1304 acpi_ec_io_ports, ec_ecdt); 849 acpi_ec_io_ports, ec_ecdt);
1305 if (ACPI_FAILURE(status)) 850 if (ACPI_FAILURE(status))
1306 return status; 851 return status;
1307 ec_ecdt->common.status_addr = ec_ecdt->common.command_addr;
1308 852
1309 ec_ecdt->common.uid = -1; 853 ec_ecdt->uid = -1;
1310 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid); 854 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->uid);
1311 855
1312 status = 856 status =
1313 acpi_evaluate_integer(handle, "_GPE", NULL, 857 acpi_evaluate_integer(handle, "_GPE", NULL,
1314 &ec_ecdt->common.gpe_bit); 858 &ec_ecdt->gpe_bit);
1315 if (ACPI_FAILURE(status)) 859 if (ACPI_FAILURE(status))
1316 return status; 860 return status;
1317 ec_ecdt->common.global_lock = TRUE; 861 ec_ecdt->global_lock = TRUE;
1318 ec_ecdt->common.handle = handle; 862 ec_ecdt->handle = handle;
1319 863
1320 printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n", 864 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "GPE=0x%02lx, ports=0x%2lx, 0x%2lx",
1321 (u32) ec_ecdt->common.gpe_bit, 865 ec_ecdt->gpe_bit, ec_ecdt->command_addr, ec_ecdt->data_addr));
1322 (u32) ec_ecdt->common.command_addr.address,
1323 (u32) ec_ecdt->common.data_addr.address);
1324 866
1325 return AE_CTRL_TERMINATE; 867 return AE_CTRL_TERMINATE;
1326} 868}
@@ -1340,14 +882,14 @@ static int __init acpi_ec_fake_ecdt(void)
1340 acpi_status status; 882 acpi_status status;
1341 int ret = 0; 883 int ret = 0;
1342 884
1343 printk(KERN_INFO PREFIX "Try to make an fake ECDT\n"); 885 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Try to make an fake ECDT"));
1344 886
1345 ec_ecdt = kmalloc(sizeof(union acpi_ec), GFP_KERNEL); 887 ec_ecdt = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL);
1346 if (!ec_ecdt) { 888 if (!ec_ecdt) {
1347 ret = -ENOMEM; 889 ret = -ENOMEM;
1348 goto error; 890 goto error;
1349 } 891 }
1350 memset(ec_ecdt, 0, sizeof(union acpi_ec)); 892 memset(ec_ecdt, 0, sizeof(struct acpi_ec));
1351 893
1352 status = acpi_get_devices(ACPI_EC_HID, 894 status = acpi_get_devices(ACPI_EC_HID,
1353 acpi_fake_ecdt_callback, NULL, NULL); 895 acpi_fake_ecdt_callback, NULL, NULL);
@@ -1355,24 +897,16 @@ static int __init acpi_ec_fake_ecdt(void)
1355 kfree(ec_ecdt); 897 kfree(ec_ecdt);
1356 ec_ecdt = NULL; 898 ec_ecdt = NULL;
1357 ret = -ENODEV; 899 ret = -ENODEV;
900 ACPI_EXCEPTION((AE_INFO, status, "Can't make an fake ECDT"));
1358 goto error; 901 goto error;
1359 } 902 }
1360 return 0; 903 return 0;
1361 error: 904 error:
1362 printk(KERN_ERR PREFIX "Can't make an fake ECDT\n");
1363 return ret; 905 return ret;
1364} 906}
1365 907
1366static int __init acpi_ec_get_real_ecdt(void) 908static int __init acpi_ec_get_real_ecdt(void)
1367{ 909{
1368 if (acpi_ec_poll_mode)
1369 return acpi_ec_poll_get_real_ecdt();
1370 else
1371 return acpi_ec_intr_get_real_ecdt();
1372}
1373
1374static int __init acpi_ec_poll_get_real_ecdt(void)
1375{
1376 acpi_status status; 910 acpi_status status;
1377 struct acpi_table_ecdt *ecdt_ptr; 911 struct acpi_table_ecdt *ecdt_ptr;
1378 912
@@ -1382,80 +916,36 @@ static int __init acpi_ec_poll_get_real_ecdt(void)
1382 if (ACPI_FAILURE(status)) 916 if (ACPI_FAILURE(status))
1383 return -ENODEV; 917 return -ENODEV;
1384 918
1385 printk(KERN_INFO PREFIX "Found ECDT\n"); 919 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found ECDT"));
1386 920
1387 /* 921 /*
1388 * Generate a temporary ec context to use until the namespace is scanned 922 * Generate a temporary ec context to use until the namespace is scanned
1389 */ 923 */
1390 ec_ecdt = kmalloc(sizeof(union acpi_ec), GFP_KERNEL); 924 ec_ecdt = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL);
1391 if (!ec_ecdt) 925 if (!ec_ecdt)
1392 return -ENOMEM; 926 return -ENOMEM;
1393 memset(ec_ecdt, 0, sizeof(union acpi_ec)); 927 memset(ec_ecdt, 0, sizeof(struct acpi_ec));
1394
1395 ec_ecdt->common.command_addr = ecdt_ptr->ec_control;
1396 ec_ecdt->common.status_addr = ecdt_ptr->ec_control;
1397 ec_ecdt->common.data_addr = ecdt_ptr->ec_data;
1398 ec_ecdt->common.gpe_bit = ecdt_ptr->gpe_bit;
1399 init_MUTEX(&ec_ecdt->poll.sem);
1400 /* use the GL just to be safe */
1401 ec_ecdt->common.global_lock = TRUE;
1402 ec_ecdt->common.uid = ecdt_ptr->uid;
1403 928
1404 status = 929 init_MUTEX(&ec_ecdt->sem);
1405 acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle); 930 if (acpi_ec_mode == EC_INTR) {
1406 if (ACPI_FAILURE(status)) { 931 init_waitqueue_head(&ec_ecdt->wait);
1407 goto error;
1408 } 932 }
1409 933 ec_ecdt->command_addr = ecdt_ptr->ec_control.address;
1410 return 0; 934 ec_ecdt->data_addr = ecdt_ptr->ec_data.address;
1411 error: 935 ec_ecdt->gpe_bit = ecdt_ptr->gpe_bit;
1412 printk(KERN_ERR PREFIX "Could not use ECDT\n");
1413 kfree(ec_ecdt);
1414 ec_ecdt = NULL;
1415
1416 return -ENODEV;
1417}
1418
1419static int __init acpi_ec_intr_get_real_ecdt(void)
1420{
1421 acpi_status status;
1422 struct acpi_table_ecdt *ecdt_ptr;
1423
1424 status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING,
1425 (struct acpi_table_header **)
1426 &ecdt_ptr);
1427 if (ACPI_FAILURE(status))
1428 return -ENODEV;
1429
1430 printk(KERN_INFO PREFIX "Found ECDT\n");
1431
1432 /*
1433 * Generate a temporary ec context to use until the namespace is scanned
1434 */
1435 ec_ecdt = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
1436 if (!ec_ecdt)
1437 return -ENOMEM;
1438 memset(ec_ecdt, 0, sizeof(union acpi_ec));
1439
1440 init_MUTEX(&ec_ecdt->intr.sem);
1441 init_waitqueue_head(&ec_ecdt->intr.wait);
1442 ec_ecdt->common.command_addr = ecdt_ptr->ec_control;
1443 ec_ecdt->common.status_addr = ecdt_ptr->ec_control;
1444 ec_ecdt->common.data_addr = ecdt_ptr->ec_data;
1445 ec_ecdt->common.gpe_bit = ecdt_ptr->gpe_bit;
1446 /* use the GL just to be safe */ 936 /* use the GL just to be safe */
1447 ec_ecdt->common.global_lock = TRUE; 937 ec_ecdt->global_lock = TRUE;
1448 ec_ecdt->common.uid = ecdt_ptr->uid; 938 ec_ecdt->uid = ecdt_ptr->uid;
1449 939
1450 status = 940 status =
1451 acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle); 941 acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->handle);
1452 if (ACPI_FAILURE(status)) { 942 if (ACPI_FAILURE(status)) {
1453 goto error; 943 goto error;
1454 } 944 }
1455 945
1456 return 0; 946 return 0;
1457 error: 947 error:
1458 printk(KERN_ERR PREFIX "Could not use ECDT\n"); 948 ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT"));
1459 kfree(ec_ecdt); 949 kfree(ec_ecdt);
1460 ec_ecdt = NULL; 950 ec_ecdt = NULL;
1461 951
@@ -1480,14 +970,14 @@ int __init acpi_ec_ecdt_probe(void)
1480 /* 970 /*
1481 * Install GPE handler 971 * Install GPE handler
1482 */ 972 */
1483 status = acpi_install_gpe_handler(NULL, ec_ecdt->common.gpe_bit, 973 status = acpi_install_gpe_handler(NULL, ec_ecdt->gpe_bit,
1484 ACPI_GPE_EDGE_TRIGGERED, 974 ACPI_GPE_EDGE_TRIGGERED,
1485 &acpi_ec_gpe_handler, ec_ecdt); 975 &acpi_ec_gpe_handler, ec_ecdt);
1486 if (ACPI_FAILURE(status)) { 976 if (ACPI_FAILURE(status)) {
1487 goto error; 977 goto error;
1488 } 978 }
1489 acpi_set_gpe_type(NULL, ec_ecdt->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME); 979 acpi_set_gpe_type(NULL, ec_ecdt->gpe_bit, ACPI_GPE_TYPE_RUNTIME);
1490 acpi_enable_gpe(NULL, ec_ecdt->common.gpe_bit, ACPI_NOT_ISR); 980 acpi_enable_gpe(NULL, ec_ecdt->gpe_bit, ACPI_NOT_ISR);
1491 981
1492 status = acpi_install_address_space_handler(ACPI_ROOT_OBJECT, 982 status = acpi_install_address_space_handler(ACPI_ROOT_OBJECT,
1493 ACPI_ADR_SPACE_EC, 983 ACPI_ADR_SPACE_EC,
@@ -1495,7 +985,7 @@ int __init acpi_ec_ecdt_probe(void)
1495 &acpi_ec_space_setup, 985 &acpi_ec_space_setup,
1496 ec_ecdt); 986 ec_ecdt);
1497 if (ACPI_FAILURE(status)) { 987 if (ACPI_FAILURE(status)) {
1498 acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, 988 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe_bit,
1499 &acpi_ec_gpe_handler); 989 &acpi_ec_gpe_handler);
1500 goto error; 990 goto error;
1501 } 991 }
@@ -1503,7 +993,7 @@ int __init acpi_ec_ecdt_probe(void)
1503 return 0; 993 return 0;
1504 994
1505 error: 995 error:
1506 printk(KERN_ERR PREFIX "Could not use ECDT\n"); 996 ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT"));
1507 kfree(ec_ecdt); 997 kfree(ec_ecdt);
1508 ec_ecdt = NULL; 998 ec_ecdt = NULL;
1509 999
@@ -1562,13 +1052,13 @@ static int __init acpi_ec_set_intr_mode(char *str)
1562 return 0; 1052 return 0;
1563 1053
1564 if (intr) { 1054 if (intr) {
1565 acpi_ec_poll_mode = EC_INTR; 1055 acpi_ec_mode = EC_INTR;
1566 acpi_ec_driver.ops.add = acpi_ec_intr_add;
1567 } else { 1056 } else {
1568 acpi_ec_poll_mode = EC_POLL; 1057 acpi_ec_mode = EC_POLL;
1569 acpi_ec_driver.ops.add = acpi_ec_poll_add;
1570 } 1058 }
1571 printk(KERN_INFO PREFIX "EC %s mode.\n", intr ? "interrupt" : "polling"); 1059 acpi_ec_driver.ops.add = acpi_ec_add;
1060 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "EC %s mode.\n", intr ? "interrupt" : "polling"));
1061
1572 return 1; 1062 return 1;
1573} 1063}
1574 1064
diff --git a/drivers/acpi/events/evmisc.c b/drivers/acpi/events/evmisc.c
index 6eef4efddcf6..ee2a10bf9077 100644
--- a/drivers/acpi/events/evmisc.c
+++ b/drivers/acpi/events/evmisc.c
@@ -342,20 +342,8 @@ static u32 acpi_ev_global_lock_handler(void *context)
342 if (acquired) { 342 if (acquired) {
343 343
344 /* Got the lock, now wake all threads waiting for it */ 344 /* Got the lock, now wake all threads waiting for it */
345
346 acpi_gbl_global_lock_acquired = TRUE; 345 acpi_gbl_global_lock_acquired = TRUE;
347 346 acpi_ev_global_lock_thread(context);
348 /* Run the Global Lock thread which will signal all waiting threads */
349
350 status =
351 acpi_os_execute(OSL_GLOBAL_LOCK_HANDLER,
352 acpi_ev_global_lock_thread, context);
353 if (ACPI_FAILURE(status)) {
354 ACPI_EXCEPTION((AE_INFO, status,
355 "Could not queue Global Lock thread"));
356
357 return (ACPI_INTERRUPT_NOT_HANDLED);
358 }
359 } 347 }
360 348
361 return (ACPI_INTERRUPT_HANDLED); 349 return (ACPI_INTERRUPT_HANDLED);
diff --git a/drivers/acpi/events/evrgnini.c b/drivers/acpi/events/evrgnini.c
index 5b3c7a85eb9a..203d1359190a 100644
--- a/drivers/acpi/events/evrgnini.c
+++ b/drivers/acpi/events/evrgnini.c
@@ -225,13 +225,12 @@ acpi_ev_pci_config_region_setup(acpi_handle handle,
225 if (! 225 if (!
226 (ACPI_STRNCMP 226 (ACPI_STRNCMP
227 (object_hID.value, PCI_ROOT_HID_STRING, 227 (object_hID.value, PCI_ROOT_HID_STRING,
228 sizeof(PCI_ROOT_HID_STRING)) 228 sizeof(PCI_ROOT_HID_STRING)))
229 || 229 ||
230 !(ACPI_STRNCMP 230 !(ACPI_STRNCMP
231 (object_hID.value, 231 (object_hID.value,
232 PCI_EXPRESS_ROOT_HID_STRING, 232 PCI_EXPRESS_ROOT_HID_STRING,
233 sizeof(PCI_EXPRESS_ROOT_HID_STRING))))) 233 sizeof(PCI_EXPRESS_ROOT_HID_STRING)))) {
234 {
235 234
236 /* Install a handler for this PCI root bridge */ 235 /* Install a handler for this PCI root bridge */
237 236
diff --git a/drivers/acpi/ibm_acpi.c b/drivers/acpi/ibm_acpi.c
index 15fc12482ba0..003a9876c968 100644
--- a/drivers/acpi/ibm_acpi.c
+++ b/drivers/acpi/ibm_acpi.c
@@ -1702,13 +1702,11 @@ static struct ibm_struct ibms[] = {
1702 .name = "brightness", 1702 .name = "brightness",
1703 .read = brightness_read, 1703 .read = brightness_read,
1704 .write = brightness_write, 1704 .write = brightness_write,
1705 .experimental = 1,
1706 }, 1705 },
1707 { 1706 {
1708 .name = "volume", 1707 .name = "volume",
1709 .read = volume_read, 1708 .read = volume_read,
1710 .write = volume_write, 1709 .write = volume_write,
1711 .experimental = 1,
1712 }, 1710 },
1713 { 1711 {
1714 .name = "fan", 1712 .name = "fan",
diff --git a/drivers/acpi/motherboard.c b/drivers/acpi/motherboard.c
index ec6b7f9ede34..2e17ec75af03 100644
--- a/drivers/acpi/motherboard.c
+++ b/drivers/acpi/motherboard.c
@@ -48,6 +48,12 @@ ACPI_MODULE_NAME("acpi_motherboard")
48 * the io ports if they really know they can use it, while 48 * the io ports if they really know they can use it, while
49 * still preventing hotplug PCI devices from using it. 49 * still preventing hotplug PCI devices from using it.
50 */ 50 */
51
52/*
53 * When CONFIG_PNP is enabled, pnp/system.c binds to PNP0C01
54 * and PNP0C02, redundant with acpi_reserve_io_ranges().
55 * But acpi_reserve_io_ranges() is necessary for !CONFIG_PNP.
56 */
51static acpi_status acpi_reserve_io_ranges(struct acpi_resource *res, void *data) 57static acpi_status acpi_reserve_io_ranges(struct acpi_resource *res, void *data)
52{ 58{
53 struct resource *requested_res = NULL; 59 struct resource *requested_res = NULL;
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index 7f3e7e77e794..d53bd9878ca2 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -307,7 +307,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
307 if (!link || !irq) 307 if (!link || !irq)
308 return -EINVAL; 308 return -EINVAL;
309 309
310 resource = kmalloc(sizeof(*resource) + 1, GFP_ATOMIC); 310 resource = kmalloc(sizeof(*resource) + 1, irqs_disabled() ? GFP_ATOMIC: GFP_KERNEL);
311 if (!resource) 311 if (!resource)
312 return -ENOMEM; 312 return -ENOMEM;
313 313
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index fec225d1b6b7..fe67a8af520e 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -216,10 +216,8 @@ static int acpi_power_off_device(acpi_handle handle)
216{ 216{
217 int result = 0; 217 int result = 0;
218 acpi_status status = AE_OK; 218 acpi_status status = AE_OK;
219 struct acpi_device *device = NULL;
220 struct acpi_power_resource *resource = NULL; 219 struct acpi_power_resource *resource = NULL;
221 220
222
223 result = acpi_power_get_context(handle, &resource); 221 result = acpi_power_get_context(handle, &resource);
224 if (result) 222 if (result)
225 return result; 223 return result;
@@ -230,13 +228,13 @@ static int acpi_power_off_device(acpi_handle handle)
230 if (resource->references) { 228 if (resource->references) {
231 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 229 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
232 "Resource [%s] is still in use, dereferencing\n", 230 "Resource [%s] is still in use, dereferencing\n",
233 device->pnp.bus_id)); 231 resource->device->pnp.bus_id));
234 return 0; 232 return 0;
235 } 233 }
236 234
237 if (resource->state == ACPI_POWER_RESOURCE_STATE_OFF) { 235 if (resource->state == ACPI_POWER_RESOURCE_STATE_OFF) {
238 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already off\n", 236 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already off\n",
239 device->pnp.bus_id)); 237 resource->device->pnp.bus_id));
240 return 0; 238 return 0;
241 } 239 }
242 240
@@ -251,8 +249,7 @@ static int acpi_power_off_device(acpi_handle handle)
251 return -ENOEXEC; 249 return -ENOEXEC;
252 250
253 /* Update the power resource's _device_ power state */ 251 /* Update the power resource's _device_ power state */
254 device = resource->device; 252 resource->device->power.state = ACPI_STATE_D3;
255 device->power.state = ACPI_STATE_D3;
256 253
257 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned off\n", 254 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned off\n",
258 resource->name)); 255 resource->name));
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index b13d64415b7a..1908e0d20222 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -519,7 +519,7 @@ static int acpi_processor_get_info(struct acpi_processor *pr)
519 519
520static void *processor_device_array[NR_CPUS]; 520static void *processor_device_array[NR_CPUS];
521 521
522static int acpi_processor_start(struct acpi_device *device) 522static int __cpuinit acpi_processor_start(struct acpi_device *device)
523{ 523{
524 int result = 0; 524 int result = 0;
525 acpi_status status = AE_OK; 525 acpi_status status = AE_OK;
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 0a395fca843b..65b3f056ad89 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -219,6 +219,23 @@ static void acpi_safe_halt(void)
219 219
220static atomic_t c3_cpu_count; 220static atomic_t c3_cpu_count;
221 221
222/* Common C-state entry for C2, C3, .. */
223static void acpi_cstate_enter(struct acpi_processor_cx *cstate)
224{
225 if (cstate->space_id == ACPI_CSTATE_FFH) {
226 /* Call into architectural FFH based C-state */
227 acpi_processor_ffh_cstate_enter(cstate);
228 } else {
229 int unused;
230 /* IO port based C-state */
231 inb(cstate->address);
232 /* Dummy wait op - must do something useless after P_LVL2 read
233 because chipsets cannot guarantee that STPCLK# signal
234 gets asserted in time to freeze execution properly. */
235 unused = inl(acpi_fadt.xpm_tmr_blk.address);
236 }
237}
238
222static void acpi_processor_idle(void) 239static void acpi_processor_idle(void)
223{ 240{
224 struct acpi_processor *pr = NULL; 241 struct acpi_processor *pr = NULL;
@@ -361,11 +378,7 @@ static void acpi_processor_idle(void)
361 /* Get start time (ticks) */ 378 /* Get start time (ticks) */
362 t1 = inl(acpi_fadt.xpm_tmr_blk.address); 379 t1 = inl(acpi_fadt.xpm_tmr_blk.address);
363 /* Invoke C2 */ 380 /* Invoke C2 */
364 inb(cx->address); 381 acpi_cstate_enter(cx);
365 /* Dummy wait op - must do something useless after P_LVL2 read
366 because chipsets cannot guarantee that STPCLK# signal
367 gets asserted in time to freeze execution properly. */
368 t2 = inl(acpi_fadt.xpm_tmr_blk.address);
369 /* Get end time (ticks) */ 382 /* Get end time (ticks) */
370 t2 = inl(acpi_fadt.xpm_tmr_blk.address); 383 t2 = inl(acpi_fadt.xpm_tmr_blk.address);
371 384
@@ -401,9 +414,7 @@ static void acpi_processor_idle(void)
401 /* Get start time (ticks) */ 414 /* Get start time (ticks) */
402 t1 = inl(acpi_fadt.xpm_tmr_blk.address); 415 t1 = inl(acpi_fadt.xpm_tmr_blk.address);
403 /* Invoke C3 */ 416 /* Invoke C3 */
404 inb(cx->address); 417 acpi_cstate_enter(cx);
405 /* Dummy wait op (see above) */
406 t2 = inl(acpi_fadt.xpm_tmr_blk.address);
407 /* Get end time (ticks) */ 418 /* Get end time (ticks) */
408 t2 = inl(acpi_fadt.xpm_tmr_blk.address); 419 t2 = inl(acpi_fadt.xpm_tmr_blk.address);
409 if (pr->flags.bm_check) { 420 if (pr->flags.bm_check) {
@@ -628,20 +639,16 @@ static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
628 return 0; 639 return 0;
629} 640}
630 641
631static int acpi_processor_get_power_info_default_c1(struct acpi_processor *pr) 642static int acpi_processor_get_power_info_default(struct acpi_processor *pr)
632{ 643{
633 644 if (!pr->power.states[ACPI_STATE_C1].valid) {
634 /* Zero initialize all the C-states info. */ 645 /* set the first C-State to C1 */
635 memset(pr->power.states, 0, sizeof(pr->power.states)); 646 /* all processors need to support C1 */
636 647 pr->power.states[ACPI_STATE_C1].type = ACPI_STATE_C1;
637 /* set the first C-State to C1 */ 648 pr->power.states[ACPI_STATE_C1].valid = 1;
638 pr->power.states[ACPI_STATE_C1].type = ACPI_STATE_C1; 649 }
639 650 /* the C0 state only exists as a filler in our array */
640 /* the C0 state only exists as a filler in our array,
641 * and all processors need to support C1 */
642 pr->power.states[ACPI_STATE_C0].valid = 1; 651 pr->power.states[ACPI_STATE_C0].valid = 1;
643 pr->power.states[ACPI_STATE_C1].valid = 1;
644
645 return 0; 652 return 0;
646} 653}
647 654
@@ -658,12 +665,7 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
658 if (nocst) 665 if (nocst)
659 return -ENODEV; 666 return -ENODEV;
660 667
661 current_count = 1; 668 current_count = 0;
662
663 /* Zero initialize C2 onwards and prepare for fresh CST lookup */
664 for (i = 2; i < ACPI_PROCESSOR_MAX_POWER; i++)
665 memset(&(pr->power.states[i]), 0,
666 sizeof(struct acpi_processor_cx));
667 669
668 status = acpi_evaluate_object(pr->handle, "_CST", NULL, &buffer); 670 status = acpi_evaluate_object(pr->handle, "_CST", NULL, &buffer);
669 if (ACPI_FAILURE(status)) { 671 if (ACPI_FAILURE(status)) {
@@ -718,22 +720,39 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
718 (reg->space_id != ACPI_ADR_SPACE_FIXED_HARDWARE)) 720 (reg->space_id != ACPI_ADR_SPACE_FIXED_HARDWARE))
719 continue; 721 continue;
720 722
721 cx.address = (reg->space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) ?
722 0 : reg->address;
723
724 /* There should be an easy way to extract an integer... */ 723 /* There should be an easy way to extract an integer... */
725 obj = (union acpi_object *)&(element->package.elements[1]); 724 obj = (union acpi_object *)&(element->package.elements[1]);
726 if (obj->type != ACPI_TYPE_INTEGER) 725 if (obj->type != ACPI_TYPE_INTEGER)
727 continue; 726 continue;
728 727
729 cx.type = obj->integer.value; 728 cx.type = obj->integer.value;
730 729 /*
731 if ((cx.type != ACPI_STATE_C1) && 730 * Some buggy BIOSes won't list C1 in _CST -
732 (reg->space_id != ACPI_ADR_SPACE_SYSTEM_IO)) 731 * Let acpi_processor_get_power_info_default() handle them later
733 continue; 732 */
734 733 if (i == 1 && cx.type != ACPI_STATE_C1)
735 if ((cx.type < ACPI_STATE_C2) || (cx.type > ACPI_STATE_C3)) 734 current_count++;
736 continue; 735
736 cx.address = reg->address;
737 cx.index = current_count + 1;
738
739 cx.space_id = ACPI_CSTATE_SYSTEMIO;
740 if (reg->space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) {
741 if (acpi_processor_ffh_cstate_probe
742 (pr->id, &cx, reg) == 0) {
743 cx.space_id = ACPI_CSTATE_FFH;
744 } else if (cx.type != ACPI_STATE_C1) {
745 /*
746 * C1 is a special case where FIXED_HARDWARE
747 * can be handled in non-MWAIT way as well.
748 * In that case, save this _CST entry info.
749 * That is, we retain space_id of SYSTEM_IO for
750 * halt based C1.
751 * Otherwise, ignore this info and continue.
752 */
753 continue;
754 }
755 }
737 756
738 obj = (union acpi_object *)&(element->package.elements[2]); 757 obj = (union acpi_object *)&(element->package.elements[2]);
739 if (obj->type != ACPI_TYPE_INTEGER) 758 if (obj->type != ACPI_TYPE_INTEGER)
@@ -938,11 +957,17 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr)
938 /* NOTE: the idle thread may not be running while calling 957 /* NOTE: the idle thread may not be running while calling
939 * this function */ 958 * this function */
940 959
941 /* Adding C1 state */ 960 /* Zero initialize all the C-states info. */
942 acpi_processor_get_power_info_default_c1(pr); 961 memset(pr->power.states, 0, sizeof(pr->power.states));
962
943 result = acpi_processor_get_power_info_cst(pr); 963 result = acpi_processor_get_power_info_cst(pr);
944 if (result == -ENODEV) 964 if (result == -ENODEV)
945 acpi_processor_get_power_info_fadt(pr); 965 result = acpi_processor_get_power_info_fadt(pr);
966
967 if (result)
968 return result;
969
970 acpi_processor_get_power_info_default(pr);
946 971
947 pr->power.count = acpi_processor_power_verify(pr); 972 pr->power.count = acpi_processor_power_verify(pr);
948 973
@@ -1083,6 +1108,7 @@ static const struct file_operations acpi_processor_power_fops = {
1083 .release = single_release, 1108 .release = single_release,
1084}; 1109};
1085 1110
1111#ifdef CONFIG_SMP
1086static void smp_callback(void *v) 1112static void smp_callback(void *v)
1087{ 1113{
1088 /* we already woke the CPU up, nothing more to do */ 1114 /* we already woke the CPU up, nothing more to do */
@@ -1104,8 +1130,9 @@ static int acpi_processor_latency_notify(struct notifier_block *b,
1104static struct notifier_block acpi_processor_latency_notifier = { 1130static struct notifier_block acpi_processor_latency_notifier = {
1105 .notifier_call = acpi_processor_latency_notify, 1131 .notifier_call = acpi_processor_latency_notify,
1106}; 1132};
1133#endif
1107 1134
1108int acpi_processor_power_init(struct acpi_processor *pr, 1135int __cpuinit acpi_processor_power_init(struct acpi_processor *pr,
1109 struct acpi_device *device) 1136 struct acpi_device *device)
1110{ 1137{
1111 acpi_status status = 0; 1138 acpi_status status = 0;
@@ -1121,7 +1148,9 @@ int acpi_processor_power_init(struct acpi_processor *pr,
1121 "ACPI: processor limited to max C-state %d\n", 1148 "ACPI: processor limited to max C-state %d\n",
1122 max_cstate); 1149 max_cstate);
1123 first_run++; 1150 first_run++;
1151#ifdef CONFIG_SMP
1124 register_latency_notifier(&acpi_processor_latency_notifier); 1152 register_latency_notifier(&acpi_processor_latency_notifier);
1153#endif
1125 } 1154 }
1126 1155
1127 if (!pr) 1156 if (!pr)
@@ -1193,7 +1222,9 @@ int acpi_processor_power_exit(struct acpi_processor *pr,
1193 * copies of pm_idle before proceeding. 1222 * copies of pm_idle before proceeding.
1194 */ 1223 */
1195 cpu_idle_wait(); 1224 cpu_idle_wait();
1225#ifdef CONFIG_SMP
1196 unregister_latency_notifier(&acpi_processor_latency_notifier); 1226 unregister_latency_notifier(&acpi_processor_latency_notifier);
1227#endif
1197 } 1228 }
1198 1229
1199 return 0; 1230 return 0;
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index 62bef0b3b614..8908a975e575 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -98,11 +98,11 @@ static int update_info_mode = UPDATE_INFO_MODE;
98static int update_time = UPDATE_TIME; 98static int update_time = UPDATE_TIME;
99static int update_time2 = UPDATE_TIME2; 99static int update_time2 = UPDATE_TIME2;
100 100
101module_param(capacity_mode, int, CAPACITY_UNIT); 101module_param(capacity_mode, int, 0);
102module_param(update_mode, int, UPDATE_MODE); 102module_param(update_mode, int, 0);
103module_param(update_info_mode, int, UPDATE_INFO_MODE); 103module_param(update_info_mode, int, 0);
104module_param(update_time, int, UPDATE_TIME); 104module_param(update_time, int, 0);
105module_param(update_time2, int, UPDATE_TIME2); 105module_param(update_time2, int, 0);
106 106
107static int acpi_sbs_add(struct acpi_device *device); 107static int acpi_sbs_add(struct acpi_device *device);
108static int acpi_sbs_remove(struct acpi_device *device, int type); 108static int acpi_sbs_remove(struct acpi_device *device, int type);
@@ -1685,10 +1685,16 @@ static int acpi_sbs_add(struct acpi_device *device)
1685 1685
1686int acpi_sbs_remove(struct acpi_device *device, int type) 1686int acpi_sbs_remove(struct acpi_device *device, int type)
1687{ 1687{
1688 struct acpi_sbs *sbs = (struct acpi_sbs *)acpi_driver_data(device); 1688 struct acpi_sbs *sbs = NULL;
1689 int id; 1689 int id;
1690 1690
1691 if (!device || !sbs) { 1691 if (!device) {
1692 return -EINVAL;
1693 }
1694
1695 sbs = (struct acpi_sbs *)acpi_driver_data(device);
1696
1697 if (!sbs) {
1692 return -EINVAL; 1698 return -EINVAL;
1693 } 1699 }
1694 1700
diff --git a/drivers/acpi/tables/tbget.c b/drivers/acpi/tables/tbget.c
index 7856db759af0..11e2d4454e05 100644
--- a/drivers/acpi/tables/tbget.c
+++ b/drivers/acpi/tables/tbget.c
@@ -324,7 +324,7 @@ acpi_tb_get_this_table(struct acpi_pointer *address,
324 324
325 if (header->length < sizeof(struct acpi_table_header)) { 325 if (header->length < sizeof(struct acpi_table_header)) {
326 ACPI_ERROR((AE_INFO, 326 ACPI_ERROR((AE_INFO,
327 "Table length (%X) is smaller than minimum (%X)", 327 "Table length (%X) is smaller than minimum (%zX)",
328 header->length, sizeof(struct acpi_table_header))); 328 header->length, sizeof(struct acpi_table_header)));
329 329
330 return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH); 330 return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
diff --git a/drivers/acpi/tables/tbrsdt.c b/drivers/acpi/tables/tbrsdt.c
index 0ad3dbb9ebca..86a5fca9b739 100644
--- a/drivers/acpi/tables/tbrsdt.c
+++ b/drivers/acpi/tables/tbrsdt.c
@@ -187,7 +187,7 @@ acpi_status acpi_tb_validate_rsdt(struct acpi_table_header *table_ptr)
187 187
188 if (table_ptr->length < sizeof(struct acpi_table_header)) { 188 if (table_ptr->length < sizeof(struct acpi_table_header)) {
189 ACPI_ERROR((AE_INFO, 189 ACPI_ERROR((AE_INFO,
190 "RSDT/XSDT length (%X) is smaller than minimum (%X)", 190 "RSDT/XSDT length (%X) is smaller than minimum (%zX)",
191 table_ptr->length, 191 table_ptr->length,
192 sizeof(struct acpi_table_header))); 192 sizeof(struct acpi_table_header)));
193 193
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 3f4aa0c99ee4..03f6338acc8f 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -6,6 +6,7 @@ menu "Serial ATA (prod) and Parallel ATA (experimental) drivers"
6 6
7config ATA 7config ATA
8 tristate "ATA device support" 8 tristate "ATA device support"
9 depends on BLOCK
9 depends on !(M32R || M68K) || BROKEN 10 depends on !(M32R || M68K) || BROKEN
10 depends on !SUN4 || BROKEN 11 depends on !SUN4 || BROKEN
11 select SCSI 12 select SCSI
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 25929123ffff..234197e57e9e 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -334,6 +334,14 @@ static const struct pci_device_id ahci_pci_tbl[] = {
334 { PCI_VDEVICE(NVIDIA, 0x044d), board_ahci }, /* MCP65 */ 334 { PCI_VDEVICE(NVIDIA, 0x044d), board_ahci }, /* MCP65 */
335 { PCI_VDEVICE(NVIDIA, 0x044e), board_ahci }, /* MCP65 */ 335 { PCI_VDEVICE(NVIDIA, 0x044e), board_ahci }, /* MCP65 */
336 { PCI_VDEVICE(NVIDIA, 0x044f), board_ahci }, /* MCP65 */ 336 { PCI_VDEVICE(NVIDIA, 0x044f), board_ahci }, /* MCP65 */
337 { PCI_VDEVICE(NVIDIA, 0x0554), board_ahci }, /* MCP67 */
338 { PCI_VDEVICE(NVIDIA, 0x0555), board_ahci }, /* MCP67 */
339 { PCI_VDEVICE(NVIDIA, 0x0556), board_ahci }, /* MCP67 */
340 { PCI_VDEVICE(NVIDIA, 0x0557), board_ahci }, /* MCP67 */
341 { PCI_VDEVICE(NVIDIA, 0x0558), board_ahci }, /* MCP67 */
342 { PCI_VDEVICE(NVIDIA, 0x0559), board_ahci }, /* MCP67 */
343 { PCI_VDEVICE(NVIDIA, 0x055a), board_ahci }, /* MCP67 */
344 { PCI_VDEVICE(NVIDIA, 0x055b), board_ahci }, /* MCP67 */
337 345
338 /* SiS */ 346 /* SiS */
339 { PCI_VDEVICE(SI, 0x1184), board_ahci }, /* SiS 966 */ 347 { PCI_VDEVICE(SI, 0x1184), board_ahci }, /* SiS 966 */
@@ -736,8 +744,7 @@ static int ahci_softreset(struct ata_port *ap, unsigned int *class)
736 } 744 }
737 745
738 /* check BUSY/DRQ, perform Command List Override if necessary */ 746 /* check BUSY/DRQ, perform Command List Override if necessary */
739 ahci_tf_read(ap, &tf); 747 if (ahci_check_status(ap) & (ATA_BUSY | ATA_DRQ)) {
740 if (tf.command & (ATA_BUSY | ATA_DRQ)) {
741 rc = ahci_clo(ap); 748 rc = ahci_clo(ap);
742 749
743 if (rc == -EOPNOTSUPP) { 750 if (rc == -EOPNOTSUPP) {
@@ -1041,7 +1048,7 @@ static void ahci_host_intr(struct ata_port *ap)
1041 /* hmmm... a spurious interupt */ 1048 /* hmmm... a spurious interupt */
1042 1049
1043 /* some devices send D2H reg with I bit set during NCQ command phase */ 1050 /* some devices send D2H reg with I bit set during NCQ command phase */
1044 if (ap->sactive && status & PORT_IRQ_D2H_REG_FIS) 1051 if (ap->sactive && (status & PORT_IRQ_D2H_REG_FIS))
1045 return; 1052 return;
1046 1053
1047 /* ignore interim PIO setup fis interrupts */ 1054 /* ignore interim PIO setup fis interrupts */
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index 5719704eb0ee..720174d628fa 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -126,8 +126,7 @@ enum {
126 ich6_sata = 7, 126 ich6_sata = 7,
127 ich6_sata_ahci = 8, 127 ich6_sata_ahci = 8,
128 ich6m_sata_ahci = 9, 128 ich6m_sata_ahci = 9,
129 ich7m_sata_ahci = 10, 129 ich8_sata_ahci = 10,
130 ich8_sata_ahci = 11,
131 130
132 /* constants for mapping table */ 131 /* constants for mapping table */
133 P0 = 0, /* port 0 */ 132 P0 = 0, /* port 0 */
@@ -227,7 +226,7 @@ static const struct pci_device_id piix_pci_tbl[] = {
227 /* 82801GB/GR/GH (ICH7, identical to ICH6) */ 226 /* 82801GB/GR/GH (ICH7, identical to ICH6) */
228 { 0x8086, 0x27c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, 227 { 0x8086, 0x27c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci },
229 /* 2801GBM/GHM (ICH7M, identical to ICH6M) */ 228 /* 2801GBM/GHM (ICH7M, identical to ICH6M) */
230 { 0x8086, 0x27c4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich7m_sata_ahci }, 229 { 0x8086, 0x27c4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6m_sata_ahci },
231 /* Enterprise Southbridge 2 (where's the datasheet?) */ 230 /* Enterprise Southbridge 2 (where's the datasheet?) */
232 { 0x8086, 0x2680, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, 231 { 0x8086, 0x2680, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci },
233 /* SATA Controller 1 IDE (ICH8, no datasheet yet) */ 232 /* SATA Controller 1 IDE (ICH8, no datasheet yet) */
@@ -399,23 +398,10 @@ static const struct piix_map_db ich6m_map_db = {
399 .mask = 0x3, 398 .mask = 0x3,
400 .port_enable = 0x5, 399 .port_enable = 0x5,
401 .present_shift = 4, 400 .present_shift = 4,
402 .map = {
403 /* PM PS SM SS MAP */
404 { P0, P2, RV, RV }, /* 00b */
405 { RV, RV, RV, RV },
406 { P0, P2, IDE, IDE }, /* 10b */
407 { RV, RV, RV, RV },
408 },
409};
410
411static const struct piix_map_db ich7m_map_db = {
412 .mask = 0x3,
413 .port_enable = 0x5,
414 .present_shift = 4,
415 401
416 /* Map 01b isn't specified in the doc but some notebooks use 402 /* Map 01b isn't specified in the doc but some notebooks use
417 * it anyway. ATM, the only case spotted carries subsystem ID 403 * it anyway. MAP 01b have been spotted on both ICH6M and
418 * 1025:0107. This is the only difference from ich6m. 404 * ICH7M.
419 */ 405 */
420 .map = { 406 .map = {
421 /* PM PS SM SS MAP */ 407 /* PM PS SM SS MAP */
@@ -432,9 +418,9 @@ static const struct piix_map_db ich8_map_db = {
432 .present_shift = 8, 418 .present_shift = 8,
433 .map = { 419 .map = {
434 /* PM PS SM SS MAP */ 420 /* PM PS SM SS MAP */
435 { P0, NA, P1, NA }, /* 00b (hardwired) */ 421 { P0, P2, P1, P3 }, /* 00b (hardwired when in AHCI) */
436 { RV, RV, RV, RV }, 422 { RV, RV, RV, RV },
437 { RV, RV, RV, RV }, /* 10b (never) */ 423 { IDE, IDE, NA, NA }, /* 10b (IDE mode) */
438 { RV, RV, RV, RV }, 424 { RV, RV, RV, RV },
439 }, 425 },
440}; 426};
@@ -445,7 +431,6 @@ static const struct piix_map_db *piix_map_db_table[] = {
445 [ich6_sata] = &ich6_map_db, 431 [ich6_sata] = &ich6_map_db,
446 [ich6_sata_ahci] = &ich6_map_db, 432 [ich6_sata_ahci] = &ich6_map_db,
447 [ich6m_sata_ahci] = &ich6m_map_db, 433 [ich6m_sata_ahci] = &ich6m_map_db,
448 [ich7m_sata_ahci] = &ich7m_map_db,
449 [ich8_sata_ahci] = &ich8_map_db, 434 [ich8_sata_ahci] = &ich8_map_db,
450}; 435};
451 436
@@ -556,19 +541,7 @@ static struct ata_port_info piix_port_info[] = {
556 .port_ops = &piix_sata_ops, 541 .port_ops = &piix_sata_ops,
557 }, 542 },
558 543
559 /* ich7m_sata_ahci: 10 */ 544 /* ich8_sata_ahci: 10 */
560 {
561 .sht = &piix_sht,
562 .flags = ATA_FLAG_SATA |
563 PIIX_FLAG_CHECKINTR | PIIX_FLAG_SCR |
564 PIIX_FLAG_AHCI,
565 .pio_mask = 0x1f, /* pio0-4 */
566 .mwdma_mask = 0x07, /* mwdma0-2 */
567 .udma_mask = 0x7f, /* udma0-6 */
568 .port_ops = &piix_sata_ops,
569 },
570
571 /* ich8_sata_ahci: 11 */
572 { 545 {
573 .sht = &piix_sht, 546 .sht = &piix_sht,
574 .flags = ATA_FLAG_SATA | 547 .flags = ATA_FLAG_SATA |
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 77138a39eb04..915a55a6cc14 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -870,7 +870,11 @@ static unsigned int ata_id_xfermask(const u16 *id)
870 * the PIO timing number for the maximum. Turn it into 870 * the PIO timing number for the maximum. Turn it into
871 * a mask. 871 * a mask.
872 */ 872 */
873 pio_mask = (2 << (id[ATA_ID_OLD_PIO_MODES] & 0xFF)) - 1 ; 873 u8 mode = id[ATA_ID_OLD_PIO_MODES] & 0xFF;
874 if (mode < 5) /* Valid PIO range */
875 pio_mask = (2 << mode) - 1;
876 else
877 pio_mask = 1;
874 878
875 /* But wait.. there's more. Design your standards by 879 /* But wait.. there's more. Design your standards by
876 * committee and you too can get a free iordy field to 880 * committee and you too can get a free iordy field to
@@ -5953,7 +5957,7 @@ static void __exit ata_exit(void)
5953 destroy_workqueue(ata_aux_wq); 5957 destroy_workqueue(ata_aux_wq);
5954} 5958}
5955 5959
5956module_init(ata_init); 5960subsys_initcall(ata_init);
5957module_exit(ata_exit); 5961module_exit(ata_exit);
5958 5962
5959static unsigned long ratelimit_time; 5963static unsigned long ratelimit_time;
@@ -6118,7 +6122,6 @@ EXPORT_SYMBOL_GPL(ata_std_prereset);
6118EXPORT_SYMBOL_GPL(ata_std_softreset); 6122EXPORT_SYMBOL_GPL(ata_std_softreset);
6119EXPORT_SYMBOL_GPL(sata_std_hardreset); 6123EXPORT_SYMBOL_GPL(sata_std_hardreset);
6120EXPORT_SYMBOL_GPL(ata_std_postreset); 6124EXPORT_SYMBOL_GPL(ata_std_postreset);
6121EXPORT_SYMBOL_GPL(ata_dev_revalidate);
6122EXPORT_SYMBOL_GPL(ata_dev_classify); 6125EXPORT_SYMBOL_GPL(ata_dev_classify);
6123EXPORT_SYMBOL_GPL(ata_dev_pair); 6126EXPORT_SYMBOL_GPL(ata_dev_pair);
6124EXPORT_SYMBOL_GPL(ata_port_disable); 6127EXPORT_SYMBOL_GPL(ata_port_disable);
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index b0d0cc41f3e8..5c1fc467fc7f 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -164,10 +164,10 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
164{ 164{
165 int rc = 0; 165 int rc = 0;
166 u8 scsi_cmd[MAX_COMMAND_SIZE]; 166 u8 scsi_cmd[MAX_COMMAND_SIZE];
167 u8 args[4], *argbuf = NULL; 167 u8 args[4], *argbuf = NULL, *sensebuf = NULL;
168 int argsize = 0; 168 int argsize = 0;
169 struct scsi_sense_hdr sshdr;
170 enum dma_data_direction data_dir; 169 enum dma_data_direction data_dir;
170 int cmd_result;
171 171
172 if (arg == NULL) 172 if (arg == NULL)
173 return -EINVAL; 173 return -EINVAL;
@@ -175,6 +175,10 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
175 if (copy_from_user(args, arg, sizeof(args))) 175 if (copy_from_user(args, arg, sizeof(args)))
176 return -EFAULT; 176 return -EFAULT;
177 177
178 sensebuf = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_NOIO);
179 if (!sensebuf)
180 return -ENOMEM;
181
178 memset(scsi_cmd, 0, sizeof(scsi_cmd)); 182 memset(scsi_cmd, 0, sizeof(scsi_cmd));
179 183
180 if (args[3]) { 184 if (args[3]) {
@@ -191,7 +195,7 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
191 data_dir = DMA_FROM_DEVICE; 195 data_dir = DMA_FROM_DEVICE;
192 } else { 196 } else {
193 scsi_cmd[1] = (3 << 1); /* Non-data */ 197 scsi_cmd[1] = (3 << 1); /* Non-data */
194 /* scsi_cmd[2] is already 0 -- no off.line, cc, or data xfer */ 198 scsi_cmd[2] = 0x20; /* cc but no off.line or data xfer */
195 data_dir = DMA_NONE; 199 data_dir = DMA_NONE;
196 } 200 }
197 201
@@ -210,18 +214,46 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
210 214
211 /* Good values for timeout and retries? Values below 215 /* Good values for timeout and retries? Values below
212 from scsi_ioctl_send_command() for default case... */ 216 from scsi_ioctl_send_command() for default case... */
213 if (scsi_execute_req(scsidev, scsi_cmd, data_dir, argbuf, argsize, 217 cmd_result = scsi_execute(scsidev, scsi_cmd, data_dir, argbuf, argsize,
214 &sshdr, (10*HZ), 5)) { 218 sensebuf, (10*HZ), 5, 0);
219
220 if (driver_byte(cmd_result) == DRIVER_SENSE) {/* sense data available */
221 u8 *desc = sensebuf + 8;
222 cmd_result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */
223
224 /* If we set cc then ATA pass-through will cause a
225 * check condition even if no error. Filter that. */
226 if (cmd_result & SAM_STAT_CHECK_CONDITION) {
227 struct scsi_sense_hdr sshdr;
228 scsi_normalize_sense(sensebuf, SCSI_SENSE_BUFFERSIZE,
229 &sshdr);
230 if (sshdr.sense_key==0 &&
231 sshdr.asc==0 && sshdr.ascq==0)
232 cmd_result &= ~SAM_STAT_CHECK_CONDITION;
233 }
234
235 /* Send userspace a few ATA registers (same as drivers/ide) */
236 if (sensebuf[0] == 0x72 && /* format is "descriptor" */
237 desc[0] == 0x09 ) { /* code is "ATA Descriptor" */
238 args[0] = desc[13]; /* status */
239 args[1] = desc[3]; /* error */
240 args[2] = desc[5]; /* sector count (0:7) */
241 if (copy_to_user(arg, args, sizeof(args)))
242 rc = -EFAULT;
243 }
244 }
245
246
247 if (cmd_result) {
215 rc = -EIO; 248 rc = -EIO;
216 goto error; 249 goto error;
217 } 250 }
218 251
219 /* Need code to retrieve data from check condition? */
220
221 if ((argbuf) 252 if ((argbuf)
222 && copy_to_user(arg + sizeof(args), argbuf, argsize)) 253 && copy_to_user(arg + sizeof(args), argbuf, argsize))
223 rc = -EFAULT; 254 rc = -EFAULT;
224error: 255error:
256 kfree(sensebuf);
225 kfree(argbuf); 257 kfree(argbuf);
226 return rc; 258 return rc;
227} 259}
@@ -1580,9 +1612,9 @@ early_finish:
1580 1612
1581err_did: 1613err_did:
1582 ata_qc_free(qc); 1614 ata_qc_free(qc);
1583err_mem:
1584 cmd->result = (DID_ERROR << 16); 1615 cmd->result = (DID_ERROR << 16);
1585 done(cmd); 1616 done(cmd);
1617err_mem:
1586 DPRINTK("EXIT - internal\n"); 1618 DPRINTK("EXIT - internal\n");
1587 return 0; 1619 return 0;
1588 1620
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index 06daaa3736a2..7645f2b30ccf 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -981,6 +981,15 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
981 mask = (1 << 2) | (1 << 0); 981 mask = (1 << 2) | (1 << 0);
982 if ((tmp8 & mask) != mask) 982 if ((tmp8 & mask) != mask)
983 legacy_mode = (1 << 3); 983 legacy_mode = (1 << 3);
984#if defined(CONFIG_NO_ATA_LEGACY)
985 /* Some platforms with PCI limits cannot address compat
986 port space. In that case we punt if their firmware has
987 left a device in compatibility mode */
988 if (legacy_mode) {
989 printk(KERN_ERR "ata: Compatibility mode ATA is not supported on this platform, skipping.\n");
990 return -EOPNOTSUPP;
991 }
992#endif
984 } 993 }
985 994
986 rc = pci_request_regions(pdev, DRV_NAME); 995 rc = pci_request_regions(pdev, DRV_NAME);
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index a5ecb71390a9..0ed263be652a 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -53,6 +53,7 @@ extern unsigned ata_exec_internal(struct ata_device *dev,
53extern unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd); 53extern unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd);
54extern int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, 54extern int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
55 int post_reset, u16 *id); 55 int post_reset, u16 *id);
56extern int ata_dev_revalidate(struct ata_device *dev, int post_reset);
56extern int ata_dev_configure(struct ata_device *dev, int print_info); 57extern int ata_dev_configure(struct ata_device *dev, int print_info);
57extern int sata_down_spd_limit(struct ata_port *ap); 58extern int sata_down_spd_limit(struct ata_port *ap);
58extern int sata_set_spd_needed(struct ata_port *ap); 59extern int sata_set_spd_needed(struct ata_port *ap);
diff --git a/drivers/ata/pata_amd.c b/drivers/ata/pata_amd.c
index 29234c897118..5c47a9e0e0ca 100644
--- a/drivers/ata/pata_amd.c
+++ b/drivers/ata/pata_amd.c
@@ -677,6 +677,8 @@ static const struct pci_device_id amd[] = {
677 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE), 8 }, 677 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE), 8 },
678 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE), 8 }, 678 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE), 8 },
679 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE), 8 }, 679 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE), 8 },
680 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE), 8 },
681 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE), 8 },
680 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CS5536_IDE), 9 }, 682 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CS5536_IDE), 9 },
681 683
682 { }, 684 { },
diff --git a/drivers/ata/pata_artop.c b/drivers/ata/pata_artop.c
index 690828eb5226..96a098020a8f 100644
--- a/drivers/ata/pata_artop.c
+++ b/drivers/ata/pata_artop.c
@@ -92,7 +92,7 @@ static int artop6260_pre_reset(struct ata_port *ap)
92 return -ENOENT; 92 return -ENOENT;
93 93
94 pci_read_config_byte(pdev, 0x49, &tmp); 94 pci_read_config_byte(pdev, 0x49, &tmp);
95 if (tmp & (1 >> ap->port_no)) 95 if (tmp & (1 << ap->port_no))
96 ap->cbl = ATA_CBL_PATA40; 96 ap->cbl = ATA_CBL_PATA40;
97 else 97 else
98 ap->cbl = ATA_CBL_PATA80; 98 ap->cbl = ATA_CBL_PATA80;
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c
index 7350443948c1..fce3fcdc7e79 100644
--- a/drivers/ata/pata_hpt37x.c
+++ b/drivers/ata/pata_hpt37x.c
@@ -25,7 +25,7 @@
25#include <linux/libata.h> 25#include <linux/libata.h>
26 26
27#define DRV_NAME "pata_hpt37x" 27#define DRV_NAME "pata_hpt37x"
28#define DRV_VERSION "0.5" 28#define DRV_VERSION "0.5.1"
29 29
30struct hpt_clock { 30struct hpt_clock {
31 u8 xfer_speed; 31 u8 xfer_speed;
@@ -453,7 +453,13 @@ static int hpt37x_pre_reset(struct ata_port *ap)
453{ 453{
454 u8 scr2, ata66; 454 u8 scr2, ata66;
455 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 455 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
456 456 static const struct pci_bits hpt37x_enable_bits[] = {
457 { 0x50, 1, 0x04, 0x04 },
458 { 0x54, 1, 0x04, 0x04 }
459 };
460 if (!pci_test_config_bits(pdev, &hpt37x_enable_bits[ap->port_no]))
461 return -ENOENT;
462
457 pci_read_config_byte(pdev, 0x5B, &scr2); 463 pci_read_config_byte(pdev, 0x5B, &scr2);
458 pci_write_config_byte(pdev, 0x5B, scr2 & ~0x01); 464 pci_write_config_byte(pdev, 0x5B, scr2 & ~0x01);
459 /* Cable register now active */ 465 /* Cable register now active */
@@ -488,10 +494,17 @@ static void hpt37x_error_handler(struct ata_port *ap)
488 494
489static int hpt374_pre_reset(struct ata_port *ap) 495static int hpt374_pre_reset(struct ata_port *ap)
490{ 496{
497 static const struct pci_bits hpt37x_enable_bits[] = {
498 { 0x50, 1, 0x04, 0x04 },
499 { 0x54, 1, 0x04, 0x04 }
500 };
491 u16 mcr3, mcr6; 501 u16 mcr3, mcr6;
492 u8 ata66; 502 u8 ata66;
493
494 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 503 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
504
505 if (!pci_test_config_bits(pdev, &hpt37x_enable_bits[ap->port_no]))
506 return -ENOENT;
507
495 /* Do the extra channel work */ 508 /* Do the extra channel work */
496 pci_read_config_word(pdev, 0x52, &mcr3); 509 pci_read_config_word(pdev, 0x52, &mcr3);
497 pci_read_config_word(pdev, 0x56, &mcr6); 510 pci_read_config_word(pdev, 0x56, &mcr6);
diff --git a/drivers/ata/pata_qdi.c b/drivers/ata/pata_qdi.c
index 7977f471d5e9..2c3cc0ccc606 100644
--- a/drivers/ata/pata_qdi.c
+++ b/drivers/ata/pata_qdi.c
@@ -141,7 +141,7 @@ static void qdi_data_xfer(struct ata_device *adev, unsigned char *buf, unsigned
141 memcpy(&pad, buf + buflen - slop, slop); 141 memcpy(&pad, buf + buflen - slop, slop);
142 outl(le32_to_cpu(pad), ap->ioaddr.data_addr); 142 outl(le32_to_cpu(pad), ap->ioaddr.data_addr);
143 } else { 143 } else {
144 pad = cpu_to_le16(inl(ap->ioaddr.data_addr)); 144 pad = cpu_to_le32(inl(ap->ioaddr.data_addr));
145 memcpy(buf + buflen - slop, &pad, slop); 145 memcpy(buf + buflen - slop, &pad, slop);
146 } 146 }
147 } 147 }
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
index 323b60710806..d65ebfd7c7b2 100644
--- a/drivers/ata/sata_nv.c
+++ b/drivers/ata/sata_nv.c
@@ -117,10 +117,14 @@ static const struct pci_device_id nv_pci_tbl[] = {
117 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA), GENERIC }, 117 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA), GENERIC },
118 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA2), GENERIC }, 118 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA2), GENERIC },
119 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA3), GENERIC }, 119 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA3), GENERIC },
120 { PCI_VDEVICE(NVIDIA, 0x045c), GENERIC }, 120 { PCI_VDEVICE(NVIDIA, 0x045c), GENERIC }, /* MCP65 */
121 { PCI_VDEVICE(NVIDIA, 0x045d), GENERIC }, 121 { PCI_VDEVICE(NVIDIA, 0x045d), GENERIC }, /* MCP65 */
122 { PCI_VDEVICE(NVIDIA, 0x045e), GENERIC }, 122 { PCI_VDEVICE(NVIDIA, 0x045e), GENERIC }, /* MCP65 */
123 { PCI_VDEVICE(NVIDIA, 0x045f), GENERIC }, 123 { PCI_VDEVICE(NVIDIA, 0x045f), GENERIC }, /* MCP65 */
124 { PCI_VDEVICE(NVIDIA, 0x0550), GENERIC }, /* MCP67 */
125 { PCI_VDEVICE(NVIDIA, 0x0551), GENERIC }, /* MCP67 */
126 { PCI_VDEVICE(NVIDIA, 0x0552), GENERIC }, /* MCP67 */
127 { PCI_VDEVICE(NVIDIA, 0x0553), GENERIC }, /* MCP67 */
124 { PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, 128 { PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID,
125 PCI_ANY_ID, PCI_ANY_ID, 129 PCI_ANY_ID, PCI_ANY_ID,
126 PCI_CLASS_STORAGE_IDE<<8, 0xffff00, GENERIC }, 130 PCI_CLASS_STORAGE_IDE<<8, 0xffff00, GENERIC },
diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c
index 8bcdfa64667c..72eda5160fad 100644
--- a/drivers/ata/sata_promise.c
+++ b/drivers/ata/sata_promise.c
@@ -260,6 +260,7 @@ static const struct pci_device_id pdc_ata_pci_tbl[] = {
260#if 0 260#if 0
261 { PCI_VDEVICE(PROMISE, 0x3570), board_20771 }, 261 { PCI_VDEVICE(PROMISE, 0x3570), board_20771 },
262#endif 262#endif
263 { PCI_VDEVICE(PROMISE, 0x3577), board_20771 },
263 264
264 { } /* terminate list */ 265 { } /* terminate list */
265}; 266};
diff --git a/drivers/ata/sata_sis.c b/drivers/ata/sata_sis.c
index 0738f52463a9..9d1235ba06b1 100644
--- a/drivers/ata/sata_sis.c
+++ b/drivers/ata/sata_sis.c
@@ -240,7 +240,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
240 struct ata_probe_ent *probe_ent = NULL; 240 struct ata_probe_ent *probe_ent = NULL;
241 int rc; 241 int rc;
242 u32 genctl; 242 u32 genctl;
243 struct ata_port_info *ppi[2]; 243 struct ata_port_info pi = sis_port_info, *ppi[2] = { &pi, &pi };
244 int pci_dev_busy = 0; 244 int pci_dev_busy = 0;
245 u8 pmr; 245 u8 pmr;
246 u8 port2_start; 246 u8 port2_start;
@@ -265,27 +265,20 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
265 if (rc) 265 if (rc)
266 goto err_out_regions; 266 goto err_out_regions;
267 267
268 ppi[0] = ppi[1] = &sis_port_info;
269 probe_ent = ata_pci_init_native_mode(pdev, ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY);
270 if (!probe_ent) {
271 rc = -ENOMEM;
272 goto err_out_regions;
273 }
274
275 /* check and see if the SCRs are in IO space or PCI cfg space */ 268 /* check and see if the SCRs are in IO space or PCI cfg space */
276 pci_read_config_dword(pdev, SIS_GENCTL, &genctl); 269 pci_read_config_dword(pdev, SIS_GENCTL, &genctl);
277 if ((genctl & GENCTL_IOMAPPED_SCR) == 0) 270 if ((genctl & GENCTL_IOMAPPED_SCR) == 0)
278 probe_ent->port_flags |= SIS_FLAG_CFGSCR; 271 pi.flags |= SIS_FLAG_CFGSCR;
279 272
280 /* if hardware thinks SCRs are in IO space, but there are 273 /* if hardware thinks SCRs are in IO space, but there are
281 * no IO resources assigned, change to PCI cfg space. 274 * no IO resources assigned, change to PCI cfg space.
282 */ 275 */
283 if ((!(probe_ent->port_flags & SIS_FLAG_CFGSCR)) && 276 if ((!(pi.flags & SIS_FLAG_CFGSCR)) &&
284 ((pci_resource_start(pdev, SIS_SCR_PCI_BAR) == 0) || 277 ((pci_resource_start(pdev, SIS_SCR_PCI_BAR) == 0) ||
285 (pci_resource_len(pdev, SIS_SCR_PCI_BAR) < 128))) { 278 (pci_resource_len(pdev, SIS_SCR_PCI_BAR) < 128))) {
286 genctl &= ~GENCTL_IOMAPPED_SCR; 279 genctl &= ~GENCTL_IOMAPPED_SCR;
287 pci_write_config_dword(pdev, SIS_GENCTL, genctl); 280 pci_write_config_dword(pdev, SIS_GENCTL, genctl);
288 probe_ent->port_flags |= SIS_FLAG_CFGSCR; 281 pi.flags |= SIS_FLAG_CFGSCR;
289 } 282 }
290 283
291 pci_read_config_byte(pdev, SIS_PMR, &pmr); 284 pci_read_config_byte(pdev, SIS_PMR, &pmr);
@@ -306,6 +299,12 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
306 port2_start = 0x20; 299 port2_start = 0x20;
307 } 300 }
308 301
302 probe_ent = ata_pci_init_native_mode(pdev, ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY);
303 if (!probe_ent) {
304 rc = -ENOMEM;
305 goto err_out_regions;
306 }
307
309 if (!(probe_ent->port_flags & SIS_FLAG_CFGSCR)) { 308 if (!(probe_ent->port_flags & SIS_FLAG_CFGSCR)) {
310 probe_ent->port[0].scr_addr = 309 probe_ent->port[0].scr_addr =
311 pci_resource_start(pdev, SIS_SCR_PCI_BAR); 310 pci_resource_start(pdev, SIS_SCR_PCI_BAR);
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c
index f4455a1efe2d..1c7f19aecc25 100644
--- a/drivers/ata/sata_via.c
+++ b/drivers/ata/sata_via.c
@@ -230,7 +230,7 @@ static int vt6420_prereset(struct ata_port *ap)
230 int online; 230 int online;
231 231
232 /* don't do any SCR stuff if we're not loading */ 232 /* don't do any SCR stuff if we're not loading */
233 if (!ATA_PFLAG_LOADING) 233 if (!(ap->pflags & ATA_PFLAG_LOADING))
234 goto skip_scr; 234 goto skip_scr;
235 235
236 /* Resume phy. This is the old resume sequence from 236 /* Resume phy. This is the old resume sequence from
diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
index 323592de047b..9fffa7af6db1 100644
--- a/drivers/atm/ambassador.c
+++ b/drivers/atm/ambassador.c
@@ -2452,8 +2452,8 @@ static int __init amb_module_init (void)
2452static void __exit amb_module_exit (void) 2452static void __exit amb_module_exit (void)
2453{ 2453{
2454 PRINTD (DBG_FLOW|DBG_INIT, "cleanup_module"); 2454 PRINTD (DBG_FLOW|DBG_INIT, "cleanup_module");
2455 2455
2456 return pci_unregister_driver(&amb_driver); 2456 pci_unregister_driver(&amb_driver);
2457} 2457}
2458 2458
2459module_init(amb_module_init); 2459module_init(amb_module_init);
diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
index 40ab9b65fae9..697ad82f6634 100644
--- a/drivers/atm/firestream.c
+++ b/drivers/atm/firestream.c
@@ -1002,6 +1002,10 @@ static int fs_open(struct atm_vcc *atm_vcc)
1002 r = ROUND_UP; 1002 r = ROUND_UP;
1003 } 1003 }
1004 error = make_rate (pcr, r, &tmc0, NULL); 1004 error = make_rate (pcr, r, &tmc0, NULL);
1005 if (error) {
1006 kfree(tc);
1007 return error;
1008 }
1005 } 1009 }
1006 fs_dprintk (FS_DEBUG_OPEN, "pcr = %d.\n", pcr); 1010 fs_dprintk (FS_DEBUG_OPEN, "pcr = %d.\n", pcr);
1007 } 1011 }
diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
index f59349206dd2..4dc10105d610 100644
--- a/drivers/atm/horizon.c
+++ b/drivers/atm/horizon.c
@@ -1789,7 +1789,7 @@ static inline void CLOCK_IT (const hrz_dev *dev, u32 ctrl)
1789 WRITE_IT_WAIT(dev, ctrl | SEEPROM_SK); 1789 WRITE_IT_WAIT(dev, ctrl | SEEPROM_SK);
1790} 1790}
1791 1791
1792static u16 __init read_bia (const hrz_dev * dev, u16 addr) 1792static u16 __devinit read_bia (const hrz_dev * dev, u16 addr)
1793{ 1793{
1794 u32 ctrl = rd_regl (dev, CONTROL_0_REG); 1794 u32 ctrl = rd_regl (dev, CONTROL_0_REG);
1795 1795
@@ -2932,8 +2932,8 @@ static int __init hrz_module_init (void) {
2932 2932
2933static void __exit hrz_module_exit (void) { 2933static void __exit hrz_module_exit (void) {
2934 PRINTD (DBG_FLOW, "cleanup_module"); 2934 PRINTD (DBG_FLOW, "cleanup_module");
2935 2935
2936 return pci_unregister_driver(&hrz_driver); 2936 pci_unregister_driver(&hrz_driver);
2937} 2937}
2938 2938
2939module_init(hrz_module_init); 2939module_init(hrz_module_init);
diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
index 632ede552761..bd0904594805 100644
--- a/drivers/atm/nicstar.c
+++ b/drivers/atm/nicstar.c
@@ -2759,7 +2759,7 @@ static int ns_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
2759{ 2759{
2760 ns_dev *card; 2760 ns_dev *card;
2761 pool_levels pl; 2761 pool_levels pl;
2762 int btype; 2762 long btype;
2763 unsigned long flags; 2763 unsigned long flags;
2764 2764
2765 card = dev->dev_data; 2765 card = dev->dev_data;
@@ -2859,7 +2859,7 @@ static int ns_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
2859 case NS_ADJBUFLEV: 2859 case NS_ADJBUFLEV:
2860 if (!capable(CAP_NET_ADMIN)) 2860 if (!capable(CAP_NET_ADMIN))
2861 return -EPERM; 2861 return -EPERM;
2862 btype = (int) arg; /* an int is the same size as a pointer */ 2862 btype = (long) arg; /* a long is the same size as a pointer or bigger */
2863 switch (btype) 2863 switch (btype)
2864 { 2864 {
2865 case NS_BUFTYPE_SMALL: 2865 case NS_BUFTYPE_SMALL:
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index 0b4e22436935..1429f3a2629e 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -37,8 +37,8 @@ config DEBUG_DRIVER
37 37
38 If you are unsure about this, say N here. 38 If you are unsure about this, say N here.
39 39
40endmenu
41
42config SYS_HYPERVISOR 40config SYS_HYPERVISOR
43 bool 41 bool
44 default n 42 default n
43
44endmenu
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 12173d16bea7..7d8a7ce73fb3 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -372,19 +372,30 @@ int bus_add_device(struct device * dev)
372 pr_debug("bus %s: add device %s\n", bus->name, dev->bus_id); 372 pr_debug("bus %s: add device %s\n", bus->name, dev->bus_id);
373 error = device_add_attrs(bus, dev); 373 error = device_add_attrs(bus, dev);
374 if (error) 374 if (error)
375 goto out; 375 goto out_put;
376 error = sysfs_create_link(&bus->devices.kobj, 376 error = sysfs_create_link(&bus->devices.kobj,
377 &dev->kobj, dev->bus_id); 377 &dev->kobj, dev->bus_id);
378 if (error) 378 if (error)
379 goto out; 379 goto out_id;
380 error = sysfs_create_link(&dev->kobj, 380 error = sysfs_create_link(&dev->kobj,
381 &dev->bus->subsys.kset.kobj, "subsystem"); 381 &dev->bus->subsys.kset.kobj, "subsystem");
382 if (error) 382 if (error)
383 goto out; 383 goto out_subsys;
384 error = sysfs_create_link(&dev->kobj, 384 error = sysfs_create_link(&dev->kobj,
385 &dev->bus->subsys.kset.kobj, "bus"); 385 &dev->bus->subsys.kset.kobj, "bus");
386 if (error)
387 goto out_deprecated;
386 } 388 }
387out: 389 return 0;
390
391out_deprecated:
392 sysfs_remove_link(&dev->kobj, "subsystem");
393out_subsys:
394 sysfs_remove_link(&bus->devices.kobj, dev->bus_id);
395out_id:
396 device_remove_attrs(bus, dev);
397out_put:
398 put_bus(dev->bus);
388 return error; 399 return error;
389} 400}
390 401
@@ -428,8 +439,10 @@ void bus_remove_device(struct device * dev)
428 sysfs_remove_link(&dev->kobj, "bus"); 439 sysfs_remove_link(&dev->kobj, "bus");
429 sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id); 440 sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id);
430 device_remove_attrs(dev->bus, dev); 441 device_remove_attrs(dev->bus, dev);
431 dev->is_registered = 0; 442 if (dev->is_registered) {
432 klist_del(&dev->knode_bus); 443 dev->is_registered = 0;
444 klist_del(&dev->knode_bus);
445 }
433 pr_debug("bus %s: remove device %s\n", dev->bus->name, dev->bus_id); 446 pr_debug("bus %s: remove device %s\n", dev->bus->name, dev->bus_id);
434 device_release_driver(dev); 447 device_release_driver(dev);
435 put_bus(dev->bus); 448 put_bus(dev->bus);
@@ -505,34 +518,36 @@ int bus_add_driver(struct device_driver *drv)
505 struct bus_type * bus = get_bus(drv->bus); 518 struct bus_type * bus = get_bus(drv->bus);
506 int error = 0; 519 int error = 0;
507 520
508 if (bus) { 521 if (!bus)
509 pr_debug("bus %s: add driver %s\n", bus->name, drv->name); 522 return 0;
510 error = kobject_set_name(&drv->kobj, "%s", drv->name); 523
511 if (error) 524 pr_debug("bus %s: add driver %s\n", bus->name, drv->name);
512 goto out_put_bus; 525 error = kobject_set_name(&drv->kobj, "%s", drv->name);
513 drv->kobj.kset = &bus->drivers; 526 if (error)
514 if ((error = kobject_register(&drv->kobj))) 527 goto out_put_bus;
515 goto out_put_bus; 528 drv->kobj.kset = &bus->drivers;
516 529 if ((error = kobject_register(&drv->kobj)))
517 error = driver_attach(drv); 530 goto out_put_bus;
518 if (error) 531
519 goto out_unregister; 532 error = driver_attach(drv);
520 klist_add_tail(&drv->knode_bus, &bus->klist_drivers); 533 if (error)
521 module_add_driver(drv->owner, drv); 534 goto out_unregister;
522 535 klist_add_tail(&drv->knode_bus, &bus->klist_drivers);
523 error = driver_add_attrs(bus, drv); 536 module_add_driver(drv->owner, drv);
524 if (error) { 537
525 /* How the hell do we get out of this pickle? Give up */ 538 error = driver_add_attrs(bus, drv);
526 printk(KERN_ERR "%s: driver_add_attrs(%s) failed\n", 539 if (error) {
527 __FUNCTION__, drv->name); 540 /* How the hell do we get out of this pickle? Give up */
528 } 541 printk(KERN_ERR "%s: driver_add_attrs(%s) failed\n",
529 error = add_bind_files(drv); 542 __FUNCTION__, drv->name);
530 if (error) {
531 /* Ditto */
532 printk(KERN_ERR "%s: add_bind_files(%s) failed\n",
533 __FUNCTION__, drv->name);
534 }
535 } 543 }
544 error = add_bind_files(drv);
545 if (error) {
546 /* Ditto */
547 printk(KERN_ERR "%s: add_bind_files(%s) failed\n",
548 __FUNCTION__, drv->name);
549 }
550
536 return error; 551 return error;
537out_unregister: 552out_unregister:
538 kobject_unregister(&drv->kobj); 553 kobject_unregister(&drv->kobj);
@@ -552,16 +567,17 @@ out_put_bus:
552 567
553void bus_remove_driver(struct device_driver * drv) 568void bus_remove_driver(struct device_driver * drv)
554{ 569{
555 if (drv->bus) { 570 if (!drv->bus)
556 remove_bind_files(drv); 571 return;
557 driver_remove_attrs(drv->bus, drv); 572
558 klist_remove(&drv->knode_bus); 573 remove_bind_files(drv);
559 pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name); 574 driver_remove_attrs(drv->bus, drv);
560 driver_detach(drv); 575 klist_remove(&drv->knode_bus);
561 module_remove_driver(drv); 576 pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name);
562 kobject_unregister(&drv->kobj); 577 driver_detach(drv);
563 put_bus(drv->bus); 578 module_remove_driver(drv);
564 } 579 kobject_unregister(&drv->kobj);
580 put_bus(drv->bus);
565} 581}
566 582
567 583
@@ -732,11 +748,15 @@ int bus_register(struct bus_type * bus)
732 748
733 klist_init(&bus->klist_devices, klist_devices_get, klist_devices_put); 749 klist_init(&bus->klist_devices, klist_devices_get, klist_devices_put);
734 klist_init(&bus->klist_drivers, NULL, NULL); 750 klist_init(&bus->klist_drivers, NULL, NULL);
735 bus_add_attrs(bus); 751 retval = bus_add_attrs(bus);
752 if (retval)
753 goto bus_attrs_fail;
736 754
737 pr_debug("bus type '%s' registered\n", bus->name); 755 pr_debug("bus type '%s' registered\n", bus->name);
738 return 0; 756 return 0;
739 757
758bus_attrs_fail:
759 kset_unregister(&bus->drivers);
740bus_drivers_fail: 760bus_drivers_fail:
741 kset_unregister(&bus->devices); 761 kset_unregister(&bus->devices);
742bus_devices_fail: 762bus_devices_fail:
diff --git a/drivers/base/class.c b/drivers/base/class.c
index b32b77ff2dcd..0ff267a248db 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -562,7 +562,10 @@ int class_device_add(struct class_device *class_dev)
562 goto out2; 562 goto out2;
563 563
564 /* add the needed attributes to this device */ 564 /* add the needed attributes to this device */
565 sysfs_create_link(&class_dev->kobj, &parent_class->subsys.kset.kobj, "subsystem"); 565 error = sysfs_create_link(&class_dev->kobj,
566 &parent_class->subsys.kset.kobj, "subsystem");
567 if (error)
568 goto out3;
566 class_dev->uevent_attr.attr.name = "uevent"; 569 class_dev->uevent_attr.attr.name = "uevent";
567 class_dev->uevent_attr.attr.mode = S_IWUSR; 570 class_dev->uevent_attr.attr.mode = S_IWUSR;
568 class_dev->uevent_attr.attr.owner = parent_class->owner; 571 class_dev->uevent_attr.attr.owner = parent_class->owner;
diff --git a/drivers/base/core.c b/drivers/base/core.c
index b224bb43ff63..68ad11af22b4 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -44,7 +44,7 @@ const char *dev_driver_string(struct device *dev)
44 return dev->driver ? dev->driver->name : 44 return dev->driver ? dev->driver->name :
45 (dev->bus ? dev->bus->name : ""); 45 (dev->bus ? dev->bus->name : "");
46} 46}
47EXPORT_SYMBOL_GPL(dev_driver_string); 47EXPORT_SYMBOL(dev_driver_string);
48 48
49#define to_dev(obj) container_of(obj, struct device, kobj) 49#define to_dev(obj) container_of(obj, struct device, kobj)
50#define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr) 50#define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr)
@@ -433,14 +433,16 @@ int device_add(struct device *dev)
433 if (dev->driver) 433 if (dev->driver)
434 dev->uevent_attr.attr.owner = dev->driver->owner; 434 dev->uevent_attr.attr.owner = dev->driver->owner;
435 dev->uevent_attr.store = store_uevent; 435 dev->uevent_attr.store = store_uevent;
436 device_create_file(dev, &dev->uevent_attr); 436 error = device_create_file(dev, &dev->uevent_attr);
437 if (error)
438 goto attrError;
437 439
438 if (MAJOR(dev->devt)) { 440 if (MAJOR(dev->devt)) {
439 struct device_attribute *attr; 441 struct device_attribute *attr;
440 attr = kzalloc(sizeof(*attr), GFP_KERNEL); 442 attr = kzalloc(sizeof(*attr), GFP_KERNEL);
441 if (!attr) { 443 if (!attr) {
442 error = -ENOMEM; 444 error = -ENOMEM;
443 goto PMError; 445 goto ueventattrError;
444 } 446 }
445 attr->attr.name = "dev"; 447 attr->attr.name = "dev";
446 attr->attr.mode = S_IRUGO; 448 attr->attr.mode = S_IRUGO;
@@ -450,7 +452,7 @@ int device_add(struct device *dev)
450 error = device_create_file(dev, attr); 452 error = device_create_file(dev, attr);
451 if (error) { 453 if (error) {
452 kfree(attr); 454 kfree(attr);
453 goto attrError; 455 goto ueventattrError;
454 } 456 }
455 457
456 dev->devt_attr = attr; 458 dev->devt_attr = attr;
@@ -477,7 +479,8 @@ int device_add(struct device *dev)
477 if ((error = bus_add_device(dev))) 479 if ((error = bus_add_device(dev)))
478 goto BusError; 480 goto BusError;
479 kobject_uevent(&dev->kobj, KOBJ_ADD); 481 kobject_uevent(&dev->kobj, KOBJ_ADD);
480 bus_attach_device(dev); 482 if ((error = bus_attach_device(dev)))
483 goto AttachError;
481 if (parent) 484 if (parent)
482 klist_add_tail(&dev->knode_parent, &parent->klist_children); 485 klist_add_tail(&dev->knode_parent, &parent->klist_children);
483 486
@@ -496,6 +499,8 @@ int device_add(struct device *dev)
496 kfree(class_name); 499 kfree(class_name);
497 put_device(dev); 500 put_device(dev);
498 return error; 501 return error;
502 AttachError:
503 bus_remove_device(dev);
499 BusError: 504 BusError:
500 device_pm_remove(dev); 505 device_pm_remove(dev);
501 PMError: 506 PMError:
@@ -507,6 +512,8 @@ int device_add(struct device *dev)
507 device_remove_file(dev, dev->devt_attr); 512 device_remove_file(dev, dev->devt_attr);
508 kfree(dev->devt_attr); 513 kfree(dev->devt_attr);
509 } 514 }
515 ueventattrError:
516 device_remove_file(dev, &dev->uevent_attr);
510 attrError: 517 attrError:
511 kobject_uevent(&dev->kobj, KOBJ_REMOVE); 518 kobject_uevent(&dev->kobj, KOBJ_REMOVE);
512 kobject_del(&dev->kobj); 519 kobject_del(&dev->kobj);
@@ -805,8 +812,10 @@ int device_rename(struct device *dev, char *new_name)
805 812
806 if (dev->class) { 813 if (dev->class) {
807 old_symlink_name = kmalloc(BUS_ID_SIZE, GFP_KERNEL); 814 old_symlink_name = kmalloc(BUS_ID_SIZE, GFP_KERNEL);
808 if (!old_symlink_name) 815 if (!old_symlink_name) {
809 return -ENOMEM; 816 error = -ENOMEM;
817 goto out_free_old_class;
818 }
810 strlcpy(old_symlink_name, dev->bus_id, BUS_ID_SIZE); 819 strlcpy(old_symlink_name, dev->bus_id, BUS_ID_SIZE);
811 } 820 }
812 821
@@ -830,9 +839,10 @@ int device_rename(struct device *dev, char *new_name)
830 } 839 }
831 put_device(dev); 840 put_device(dev);
832 841
833 kfree(old_class_name);
834 kfree(new_class_name); 842 kfree(new_class_name);
835 kfree(old_symlink_name); 843 kfree(old_symlink_name);
844 out_free_old_class:
845 kfree(old_class_name);
836 846
837 return error; 847 return error;
838} 848}
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index b5f43c3e44fa..c5d6bb4290ad 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -18,6 +18,7 @@
18#include <linux/device.h> 18#include <linux/device.h>
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/kthread.h> 20#include <linux/kthread.h>
21#include <linux/wait.h>
21 22
22#include "base.h" 23#include "base.h"
23#include "power/power.h" 24#include "power/power.h"
@@ -70,6 +71,8 @@ struct stupid_thread_structure {
70}; 71};
71 72
72static atomic_t probe_count = ATOMIC_INIT(0); 73static atomic_t probe_count = ATOMIC_INIT(0);
74static DECLARE_WAIT_QUEUE_HEAD(probe_waitqueue);
75
73static int really_probe(void *void_data) 76static int really_probe(void *void_data)
74{ 77{
75 struct stupid_thread_structure *data = void_data; 78 struct stupid_thread_structure *data = void_data;
@@ -121,6 +124,7 @@ probe_failed:
121done: 124done:
122 kfree(data); 125 kfree(data);
123 atomic_dec(&probe_count); 126 atomic_dec(&probe_count);
127 wake_up(&probe_waitqueue);
124 return ret; 128 return ret;
125} 129}
126 130
@@ -171,6 +175,8 @@ int driver_probe_device(struct device_driver * drv, struct device * dev)
171 drv->bus->name, dev->bus_id, drv->name); 175 drv->bus->name, dev->bus_id, drv->name);
172 176
173 data = kmalloc(sizeof(*data), GFP_KERNEL); 177 data = kmalloc(sizeof(*data), GFP_KERNEL);
178 if (!data)
179 return -ENOMEM;
174 data->drv = drv; 180 data->drv = drv;
175 data->dev = dev; 181 data->dev = dev;
176 182
@@ -178,7 +184,7 @@ int driver_probe_device(struct device_driver * drv, struct device * dev)
178 probe_task = kthread_run(really_probe, data, 184 probe_task = kthread_run(really_probe, data,
179 "probe-%s", dev->bus_id); 185 "probe-%s", dev->bus_id);
180 if (IS_ERR(probe_task)) 186 if (IS_ERR(probe_task))
181 ret = PTR_ERR(probe_task); 187 ret = really_probe(data);
182 } else 188 } else
183 ret = really_probe(data); 189 ret = really_probe(data);
184 190
@@ -335,6 +341,32 @@ void driver_detach(struct device_driver * drv)
335 } 341 }
336} 342}
337 343
344#ifdef CONFIG_PCI_MULTITHREAD_PROBE
345static int __init wait_for_probes(void)
346{
347 DEFINE_WAIT(wait);
348
349 printk(KERN_INFO "%s: waiting for %d threads\n", __FUNCTION__,
350 atomic_read(&probe_count));
351 if (!atomic_read(&probe_count))
352 return 0;
353 while (atomic_read(&probe_count)) {
354 prepare_to_wait(&probe_waitqueue, &wait, TASK_UNINTERRUPTIBLE);
355 if (atomic_read(&probe_count))
356 schedule();
357 }
358 finish_wait(&probe_waitqueue, &wait);
359 return 0;
360}
361
362core_initcall_sync(wait_for_probes);
363postcore_initcall_sync(wait_for_probes);
364arch_initcall_sync(wait_for_probes);
365subsys_initcall_sync(wait_for_probes);
366fs_initcall_sync(wait_for_probes);
367device_initcall_sync(wait_for_probes);
368late_initcall_sync(wait_for_probes);
369#endif
338 370
339EXPORT_SYMBOL_GPL(device_bind_driver); 371EXPORT_SYMBOL_GPL(device_bind_driver);
340EXPORT_SYMBOL_GPL(device_release_driver); 372EXPORT_SYMBOL_GPL(device_release_driver);
diff --git a/drivers/base/dmapool.c b/drivers/base/dmapool.c
index 33c5cce1560b..b2efbd4cf710 100644
--- a/drivers/base/dmapool.c
+++ b/drivers/base/dmapool.c
@@ -141,11 +141,20 @@ dma_pool_create (const char *name, struct device *dev,
141 init_waitqueue_head (&retval->waitq); 141 init_waitqueue_head (&retval->waitq);
142 142
143 if (dev) { 143 if (dev) {
144 int ret;
145
144 down (&pools_lock); 146 down (&pools_lock);
145 if (list_empty (&dev->dma_pools)) 147 if (list_empty (&dev->dma_pools))
146 device_create_file (dev, &dev_attr_pools); 148 ret = device_create_file (dev, &dev_attr_pools);
149 else
150 ret = 0;
147 /* note: not currently insisting "name" be unique */ 151 /* note: not currently insisting "name" be unique */
148 list_add (&retval->pools, &dev->dma_pools); 152 if (!ret)
153 list_add (&retval->pools, &dev->dma_pools);
154 else {
155 kfree(retval);
156 retval = NULL;
157 }
149 up (&pools_lock); 158 up (&pools_lock);
150 } else 159 } else
151 INIT_LIST_HEAD (&retval->pools); 160 INIT_LIST_HEAD (&retval->pools);
diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index 3ef9d514b916..28dccb730af9 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -97,8 +97,7 @@ static struct attribute_group topology_attr_group = {
97/* Add/Remove cpu_topology interface for CPU device */ 97/* Add/Remove cpu_topology interface for CPU device */
98static int __cpuinit topology_add_dev(struct sys_device * sys_dev) 98static int __cpuinit topology_add_dev(struct sys_device * sys_dev)
99{ 99{
100 sysfs_create_group(&sys_dev->kobj, &topology_attr_group); 100 return sysfs_create_group(&sys_dev->kobj, &topology_attr_group);
101 return 0;
102} 101}
103 102
104static int __cpuinit topology_remove_dev(struct sys_device * sys_dev) 103static int __cpuinit topology_remove_dev(struct sys_device * sys_dev)
diff --git a/drivers/block/DAC960.h b/drivers/block/DAC960.h
index cec539e601fe..6148073532b2 100644
--- a/drivers/block/DAC960.h
+++ b/drivers/block/DAC960.h
@@ -4379,8 +4379,8 @@ static inline void DAC960_P_To_PD_TranslateEnquiry(void *Enquiry)
4379static inline void DAC960_P_To_PD_TranslateDeviceState(void *DeviceState) 4379static inline void DAC960_P_To_PD_TranslateDeviceState(void *DeviceState)
4380{ 4380{
4381 memcpy(DeviceState + 2, DeviceState + 3, 1); 4381 memcpy(DeviceState + 2, DeviceState + 3, 1);
4382 memcpy(DeviceState + 4, DeviceState + 5, 2); 4382 memmove(DeviceState + 4, DeviceState + 5, 2);
4383 memcpy(DeviceState + 6, DeviceState + 8, 4); 4383 memmove(DeviceState + 6, DeviceState + 8, 4);
4384} 4384}
4385 4385
4386static inline 4386static inline
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c
index 5d254b714509..5d6562171533 100644
--- a/drivers/block/amiflop.c
+++ b/drivers/block/amiflop.c
@@ -1709,10 +1709,13 @@ static struct kobject *floppy_find(dev_t dev, int *part, void *data)
1709 return get_disk(unit[drive].gendisk); 1709 return get_disk(unit[drive].gendisk);
1710} 1710}
1711 1711
1712int __init amiga_floppy_init(void) 1712static int __init amiga_floppy_init(void)
1713{ 1713{
1714 int i, ret; 1714 int i, ret;
1715 1715
1716 if (!MACH_IS_AMIGA)
1717 return -ENXIO;
1718
1716 if (!AMIGAHW_PRESENT(AMI_FLOPPY)) 1719 if (!AMIGAHW_PRESENT(AMI_FLOPPY))
1717 return -ENXIO; 1720 return -ENXIO;
1718 1721
@@ -1809,15 +1812,9 @@ out_blkdev:
1809 return ret; 1812 return ret;
1810} 1813}
1811 1814
1815module_init(amiga_floppy_init);
1812#ifdef MODULE 1816#ifdef MODULE
1813 1817
1814int init_module(void)
1815{
1816 if (!MACH_IS_AMIGA)
1817 return -ENXIO;
1818 return amiga_floppy_init();
1819}
1820
1821#if 0 /* not safe to unload */ 1818#if 0 /* not safe to unload */
1822void cleanup_module(void) 1819void cleanup_module(void)
1823{ 1820{
diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h
index 6eebcb7be97e..6d111228cfac 100644
--- a/drivers/block/aoe/aoe.h
+++ b/drivers/block/aoe/aoe.h
@@ -1,5 +1,5 @@
1/* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */ 1/* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */
2#define VERSION "22" 2#define VERSION "32"
3#define AOE_MAJOR 152 3#define AOE_MAJOR 152
4#define DEVICE_NAME "aoe" 4#define DEVICE_NAME "aoe"
5 5
@@ -65,7 +65,7 @@ struct aoe_atahdr {
65struct aoe_cfghdr { 65struct aoe_cfghdr {
66 __be16 bufcnt; 66 __be16 bufcnt;
67 __be16 fwver; 67 __be16 fwver;
68 unsigned char res; 68 unsigned char scnt;
69 unsigned char aoeccmd; 69 unsigned char aoeccmd;
70 unsigned char cslen[2]; 70 unsigned char cslen[2];
71}; 71};
@@ -78,12 +78,14 @@ enum {
78 DEVFL_GDALLOC = (1<<4), /* need to alloc gendisk */ 78 DEVFL_GDALLOC = (1<<4), /* need to alloc gendisk */
79 DEVFL_PAUSE = (1<<5), 79 DEVFL_PAUSE = (1<<5),
80 DEVFL_NEWSIZE = (1<<6), /* need to update dev size in block layer */ 80 DEVFL_NEWSIZE = (1<<6), /* need to update dev size in block layer */
81 DEVFL_MAXBCNT = (1<<7), /* d->maxbcnt is not changeable */
82 DEVFL_KICKME = (1<<8),
81 83
82 BUFFL_FAIL = 1, 84 BUFFL_FAIL = 1,
83}; 85};
84 86
85enum { 87enum {
86 MAXATADATA = 1024, 88 DEFAULTBCNT = 2 * 512, /* 2 sectors */
87 NPERSHELF = 16, /* number of slots per shelf address */ 89 NPERSHELF = 16, /* number of slots per shelf address */
88 FREETAG = -1, 90 FREETAG = -1,
89 MIN_BUFS = 8, 91 MIN_BUFS = 8,
@@ -107,11 +109,9 @@ struct frame {
107 ulong waited; 109 ulong waited;
108 struct buf *buf; 110 struct buf *buf;
109 char *bufaddr; 111 char *bufaddr;
110 int writedatalen; 112 ulong bcnt;
111 int ndata; 113 sector_t lba;
112 114 struct sk_buff *skb;
113 /* largest possible */
114 unsigned char data[sizeof(struct aoe_hdr) + sizeof(struct aoe_atahdr)];
115}; 115};
116 116
117struct aoedev { 117struct aoedev {
@@ -121,9 +121,12 @@ struct aoedev {
121 ulong sysminor; 121 ulong sysminor;
122 ulong aoemajor; 122 ulong aoemajor;
123 ulong aoeminor; 123 ulong aoeminor;
124 ulong nopen; /* (bd_openers isn't available without sleeping) */ 124 u16 nopen; /* (bd_openers isn't available without sleeping) */
125 ulong rttavg; /* round trip average of requests/responses */ 125 u16 lasttag; /* last tag sent */
126 u16 rttavg; /* round trip average of requests/responses */
127 u16 mintimer;
126 u16 fw_ver; /* version of blade's firmware */ 128 u16 fw_ver; /* version of blade's firmware */
129 u16 maxbcnt;
127 struct work_struct work;/* disk create work struct */ 130 struct work_struct work;/* disk create work struct */
128 struct gendisk *gd; 131 struct gendisk *gd;
129 request_queue_t blkq; 132 request_queue_t blkq;
@@ -137,8 +140,8 @@ struct aoedev {
137 mempool_t *bufpool; /* for deadlock-free Buf allocation */ 140 mempool_t *bufpool; /* for deadlock-free Buf allocation */
138 struct list_head bufq; /* queue of bios to work on */ 141 struct list_head bufq; /* queue of bios to work on */
139 struct buf *inprocess; /* the one we're currently working on */ 142 struct buf *inprocess; /* the one we're currently working on */
140 ulong lasttag; /* last tag sent */ 143 ushort lostjumbo;
141 ulong nframes; /* number of frames below */ 144 ushort nframes; /* number of frames below */
142 struct frame *frames; 145 struct frame *frames;
143}; 146};
144 147
@@ -157,6 +160,7 @@ void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor);
157void aoecmd_ata_rsp(struct sk_buff *); 160void aoecmd_ata_rsp(struct sk_buff *);
158void aoecmd_cfg_rsp(struct sk_buff *); 161void aoecmd_cfg_rsp(struct sk_buff *);
159void aoecmd_sleepwork(void *vp); 162void aoecmd_sleepwork(void *vp);
163struct sk_buff *new_skb(ulong);
160 164
161int aoedev_init(void); 165int aoedev_init(void);
162void aoedev_exit(void); 166void aoedev_exit(void);
diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
index 393b86a3dbf8..aa25f8b09fe3 100644
--- a/drivers/block/aoe/aoeblk.c
+++ b/drivers/block/aoe/aoeblk.c
@@ -1,4 +1,4 @@
1/* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */ 1/* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */
2/* 2/*
3 * aoeblk.c 3 * aoeblk.c
4 * block device routines 4 * block device routines
@@ -14,7 +14,6 @@
14 14
15static kmem_cache_t *buf_pool_cache; 15static kmem_cache_t *buf_pool_cache;
16 16
17/* add attributes for our block devices in sysfs */
18static ssize_t aoedisk_show_state(struct gendisk * disk, char *page) 17static ssize_t aoedisk_show_state(struct gendisk * disk, char *page)
19{ 18{
20 struct aoedev *d = disk->private_data; 19 struct aoedev *d = disk->private_data;
@@ -64,21 +63,27 @@ static struct disk_attribute disk_attr_fwver = {
64 .show = aoedisk_show_fwver 63 .show = aoedisk_show_fwver
65}; 64};
66 65
67static void 66static struct attribute *aoe_attrs[] = {
67 &disk_attr_state.attr,
68 &disk_attr_mac.attr,
69 &disk_attr_netif.attr,
70 &disk_attr_fwver.attr,
71 NULL
72};
73
74static const struct attribute_group attr_group = {
75 .attrs = aoe_attrs,
76};
77
78static int
68aoedisk_add_sysfs(struct aoedev *d) 79aoedisk_add_sysfs(struct aoedev *d)
69{ 80{
70 sysfs_create_file(&d->gd->kobj, &disk_attr_state.attr); 81 return sysfs_create_group(&d->gd->kobj, &attr_group);
71 sysfs_create_file(&d->gd->kobj, &disk_attr_mac.attr);
72 sysfs_create_file(&d->gd->kobj, &disk_attr_netif.attr);
73 sysfs_create_file(&d->gd->kobj, &disk_attr_fwver.attr);
74} 82}
75void 83void
76aoedisk_rm_sysfs(struct aoedev *d) 84aoedisk_rm_sysfs(struct aoedev *d)
77{ 85{
78 sysfs_remove_link(&d->gd->kobj, "state"); 86 sysfs_remove_group(&d->gd->kobj, &attr_group);
79 sysfs_remove_link(&d->gd->kobj, "mac");
80 sysfs_remove_link(&d->gd->kobj, "netif");
81 sysfs_remove_link(&d->gd->kobj, "firmware-version");
82} 87}
83 88
84static int 89static int
@@ -132,8 +137,7 @@ aoeblk_make_request(request_queue_t *q, struct bio *bio)
132 d = bio->bi_bdev->bd_disk->private_data; 137 d = bio->bi_bdev->bd_disk->private_data;
133 buf = mempool_alloc(d->bufpool, GFP_NOIO); 138 buf = mempool_alloc(d->bufpool, GFP_NOIO);
134 if (buf == NULL) { 139 if (buf == NULL) {
135 printk(KERN_INFO "aoe: aoeblk_make_request: buf allocation " 140 printk(KERN_INFO "aoe: buf allocation failure\n");
136 "failure\n");
137 bio_endio(bio, bio->bi_size, -ENOMEM); 141 bio_endio(bio, bio->bi_size, -ENOMEM);
138 return 0; 142 return 0;
139 } 143 }
@@ -143,14 +147,15 @@ aoeblk_make_request(request_queue_t *q, struct bio *bio)
143 buf->bio = bio; 147 buf->bio = bio;
144 buf->resid = bio->bi_size; 148 buf->resid = bio->bi_size;
145 buf->sector = bio->bi_sector; 149 buf->sector = bio->bi_sector;
146 buf->bv = buf->bio->bi_io_vec; 150 buf->bv = &bio->bi_io_vec[bio->bi_idx];
151 WARN_ON(buf->bv->bv_len == 0);
147 buf->bv_resid = buf->bv->bv_len; 152 buf->bv_resid = buf->bv->bv_len;
148 buf->bufaddr = page_address(buf->bv->bv_page) + buf->bv->bv_offset; 153 buf->bufaddr = page_address(buf->bv->bv_page) + buf->bv->bv_offset;
149 154
150 spin_lock_irqsave(&d->lock, flags); 155 spin_lock_irqsave(&d->lock, flags);
151 156
152 if ((d->flags & DEVFL_UP) == 0) { 157 if ((d->flags & DEVFL_UP) == 0) {
153 printk(KERN_INFO "aoe: aoeblk_make_request: device %ld.%ld is not up\n", 158 printk(KERN_INFO "aoe: device %ld.%ld is not up\n",
154 d->aoemajor, d->aoeminor); 159 d->aoemajor, d->aoeminor);
155 spin_unlock_irqrestore(&d->lock, flags); 160 spin_unlock_irqrestore(&d->lock, flags);
156 mempool_free(buf, d->bufpool); 161 mempool_free(buf, d->bufpool);
@@ -176,7 +181,7 @@ aoeblk_getgeo(struct block_device *bdev, struct hd_geometry *geo)
176 struct aoedev *d = bdev->bd_disk->private_data; 181 struct aoedev *d = bdev->bd_disk->private_data;
177 182
178 if ((d->flags & DEVFL_UP) == 0) { 183 if ((d->flags & DEVFL_UP) == 0) {
179 printk(KERN_ERR "aoe: aoeblk_ioctl: disk not up\n"); 184 printk(KERN_ERR "aoe: disk not up\n");
180 return -ENODEV; 185 return -ENODEV;
181 } 186 }
182 187
@@ -203,8 +208,8 @@ aoeblk_gdalloc(void *vp)
203 208
204 gd = alloc_disk(AOE_PARTITIONS); 209 gd = alloc_disk(AOE_PARTITIONS);
205 if (gd == NULL) { 210 if (gd == NULL) {
206 printk(KERN_ERR "aoe: aoeblk_gdalloc: cannot allocate disk " 211 printk(KERN_ERR "aoe: cannot allocate disk structure for %ld.%ld\n",
207 "structure for %ld.%ld\n", d->aoemajor, d->aoeminor); 212 d->aoemajor, d->aoeminor);
208 spin_lock_irqsave(&d->lock, flags); 213 spin_lock_irqsave(&d->lock, flags);
209 d->flags &= ~DEVFL_GDALLOC; 214 d->flags &= ~DEVFL_GDALLOC;
210 spin_unlock_irqrestore(&d->lock, flags); 215 spin_unlock_irqrestore(&d->lock, flags);
@@ -213,8 +218,8 @@ aoeblk_gdalloc(void *vp)
213 218
214 d->bufpool = mempool_create_slab_pool(MIN_BUFS, buf_pool_cache); 219 d->bufpool = mempool_create_slab_pool(MIN_BUFS, buf_pool_cache);
215 if (d->bufpool == NULL) { 220 if (d->bufpool == NULL) {
216 printk(KERN_ERR "aoe: aoeblk_gdalloc: cannot allocate bufpool " 221 printk(KERN_ERR "aoe: cannot allocate bufpool for %ld.%ld\n",
217 "for %ld.%ld\n", d->aoemajor, d->aoeminor); 222 d->aoemajor, d->aoeminor);
218 put_disk(gd); 223 put_disk(gd);
219 spin_lock_irqsave(&d->lock, flags); 224 spin_lock_irqsave(&d->lock, flags);
220 d->flags &= ~DEVFL_GDALLOC; 225 d->flags &= ~DEVFL_GDALLOC;
diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c
index 1bc1cf9603f1..e22b4c9520a9 100644
--- a/drivers/block/aoe/aoechr.c
+++ b/drivers/block/aoe/aoechr.c
@@ -1,4 +1,4 @@
1/* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */ 1/* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */
2/* 2/*
3 * aoechr.c 3 * aoechr.c
4 * AoE character device driver 4 * AoE character device driver
@@ -15,7 +15,6 @@ enum {
15 MINOR_INTERFACES, 15 MINOR_INTERFACES,
16 MINOR_REVALIDATE, 16 MINOR_REVALIDATE,
17 MSGSZ = 2048, 17 MSGSZ = 2048,
18 NARGS = 10,
19 NMSG = 100, /* message backlog to retain */ 18 NMSG = 100, /* message backlog to retain */
20}; 19};
21 20
@@ -56,9 +55,8 @@ static int
56interfaces(const char __user *str, size_t size) 55interfaces(const char __user *str, size_t size)
57{ 56{
58 if (set_aoe_iflist(str, size)) { 57 if (set_aoe_iflist(str, size)) {
59 printk(KERN_CRIT 58 printk(KERN_ERR
60 "%s: could not set interface list: %s\n", 59 "aoe: could not set interface list: too many interfaces\n");
61 __FUNCTION__, "too many interfaces");
62 return -EINVAL; 60 return -EINVAL;
63 } 61 }
64 return 0; 62 return 0;
@@ -81,8 +79,7 @@ revalidate(const char __user *str, size_t size)
81 /* should be e%d.%d format */ 79 /* should be e%d.%d format */
82 n = sscanf(buf, "e%d.%d", &major, &minor); 80 n = sscanf(buf, "e%d.%d", &major, &minor);
83 if (n != 2) { 81 if (n != 2) {
84 printk(KERN_ERR "aoe: %s: invalid device specification\n", 82 printk(KERN_ERR "aoe: invalid device specification\n");
85 __FUNCTION__);
86 return -EINVAL; 83 return -EINVAL;
87 } 84 }
88 d = aoedev_by_aoeaddr(major, minor); 85 d = aoedev_by_aoeaddr(major, minor);
@@ -90,6 +87,7 @@ revalidate(const char __user *str, size_t size)
90 return -EINVAL; 87 return -EINVAL;
91 88
92 spin_lock_irqsave(&d->lock, flags); 89 spin_lock_irqsave(&d->lock, flags);
90 d->flags &= ~DEVFL_MAXBCNT;
93 d->flags |= DEVFL_PAUSE; 91 d->flags |= DEVFL_PAUSE;
94 spin_unlock_irqrestore(&d->lock, flags); 92 spin_unlock_irqrestore(&d->lock, flags);
95 aoecmd_cfg(major, minor); 93 aoecmd_cfg(major, minor);
@@ -116,7 +114,7 @@ bail: spin_unlock_irqrestore(&emsgs_lock, flags);
116 114
117 mp = kmalloc(n, GFP_ATOMIC); 115 mp = kmalloc(n, GFP_ATOMIC);
118 if (mp == NULL) { 116 if (mp == NULL) {
119 printk(KERN_CRIT "aoe: aoechr_error: allocation failure, len=%ld\n", n); 117 printk(KERN_ERR "aoe: allocation failure, len=%ld\n", n);
120 goto bail; 118 goto bail;
121 } 119 }
122 120
@@ -141,7 +139,7 @@ aoechr_write(struct file *filp, const char __user *buf, size_t cnt, loff_t *offp
141 139
142 switch ((unsigned long) filp->private_data) { 140 switch ((unsigned long) filp->private_data) {
143 default: 141 default:
144 printk(KERN_INFO "aoe: aoechr_write: can't write to that file.\n"); 142 printk(KERN_INFO "aoe: can't write to that file.\n");
145 break; 143 break;
146 case MINOR_DISCOVER: 144 case MINOR_DISCOVER:
147 ret = discover(); 145 ret = discover();
@@ -250,7 +248,7 @@ aoechr_init(void)
250 248
251 n = register_chrdev(AOE_MAJOR, "aoechr", &aoe_fops); 249 n = register_chrdev(AOE_MAJOR, "aoechr", &aoe_fops);
252 if (n < 0) { 250 if (n < 0) {
253 printk(KERN_ERR "aoe: aoechr_init: can't register char device\n"); 251 printk(KERN_ERR "aoe: can't register char device\n");
254 return n; 252 return n;
255 } 253 }
256 sema_init(&emsgs_sema, 0); 254 sema_init(&emsgs_sema, 0);
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index 39da28d344fe..8a13b1af8bab 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -1,4 +1,4 @@
1/* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */ 1/* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */
2/* 2/*
3 * aoecmd.c 3 * aoecmd.c
4 * Filesystem request handling methods 4 * Filesystem request handling methods
@@ -15,17 +15,19 @@
15#define TIMERTICK (HZ / 10) 15#define TIMERTICK (HZ / 10)
16#define MINTIMER (2 * TIMERTICK) 16#define MINTIMER (2 * TIMERTICK)
17#define MAXTIMER (HZ << 1) 17#define MAXTIMER (HZ << 1)
18#define MAXWAIT (60 * 3) /* After MAXWAIT seconds, give up and fail dev */
19 18
20static struct sk_buff * 19static int aoe_deadsecs = 60 * 3;
21new_skb(struct net_device *if_dev, ulong len) 20module_param(aoe_deadsecs, int, 0644);
21MODULE_PARM_DESC(aoe_deadsecs, "After aoe_deadsecs seconds, give up and fail dev.");
22
23struct sk_buff *
24new_skb(ulong len)
22{ 25{
23 struct sk_buff *skb; 26 struct sk_buff *skb;
24 27
25 skb = alloc_skb(len, GFP_ATOMIC); 28 skb = alloc_skb(len, GFP_ATOMIC);
26 if (skb) { 29 if (skb) {
27 skb->nh.raw = skb->mac.raw = skb->data; 30 skb->nh.raw = skb->mac.raw = skb->data;
28 skb->dev = if_dev;
29 skb->protocol = __constant_htons(ETH_P_AOE); 31 skb->protocol = __constant_htons(ETH_P_AOE);
30 skb->priority = 0; 32 skb->priority = 0;
31 skb_put(skb, len); 33 skb_put(skb, len);
@@ -40,29 +42,6 @@ new_skb(struct net_device *if_dev, ulong len)
40 return skb; 42 return skb;
41} 43}
42 44
43static struct sk_buff *
44skb_prepare(struct aoedev *d, struct frame *f)
45{
46 struct sk_buff *skb;
47 char *p;
48
49 skb = new_skb(d->ifp, f->ndata + f->writedatalen);
50 if (!skb) {
51 printk(KERN_INFO "aoe: skb_prepare: failure to allocate skb\n");
52 return NULL;
53 }
54
55 p = skb->mac.raw;
56 memcpy(p, f->data, f->ndata);
57
58 if (f->writedatalen) {
59 p += sizeof(struct aoe_hdr) + sizeof(struct aoe_atahdr);
60 memcpy(p, f->bufaddr, f->writedatalen);
61 }
62
63 return skb;
64}
65
66static struct frame * 45static struct frame *
67getframe(struct aoedev *d, int tag) 46getframe(struct aoedev *d, int tag)
68{ 47{
@@ -107,6 +86,17 @@ aoehdr_atainit(struct aoedev *d, struct aoe_hdr *h)
107 return host_tag; 86 return host_tag;
108} 87}
109 88
89static inline void
90put_lba(struct aoe_atahdr *ah, sector_t lba)
91{
92 ah->lba0 = lba;
93 ah->lba1 = lba >>= 8;
94 ah->lba2 = lba >>= 8;
95 ah->lba3 = lba >>= 8;
96 ah->lba4 = lba >>= 8;
97 ah->lba5 = lba >>= 8;
98}
99
110static void 100static void
111aoecmd_ata_rw(struct aoedev *d, struct frame *f) 101aoecmd_ata_rw(struct aoedev *d, struct frame *f)
112{ 102{
@@ -125,29 +115,27 @@ aoecmd_ata_rw(struct aoedev *d, struct frame *f)
125 115
126 sector = buf->sector; 116 sector = buf->sector;
127 bcnt = buf->bv_resid; 117 bcnt = buf->bv_resid;
128 if (bcnt > MAXATADATA) 118 if (bcnt > d->maxbcnt)
129 bcnt = MAXATADATA; 119 bcnt = d->maxbcnt;
130 120
131 /* initialize the headers & frame */ 121 /* initialize the headers & frame */
132 h = (struct aoe_hdr *) f->data; 122 skb = f->skb;
123 h = (struct aoe_hdr *) skb->mac.raw;
133 ah = (struct aoe_atahdr *) (h+1); 124 ah = (struct aoe_atahdr *) (h+1);
134 f->ndata = sizeof *h + sizeof *ah; 125 skb->len = sizeof *h + sizeof *ah;
135 memset(h, 0, f->ndata); 126 memset(h, 0, ETH_ZLEN);
136 f->tag = aoehdr_atainit(d, h); 127 f->tag = aoehdr_atainit(d, h);
137 f->waited = 0; 128 f->waited = 0;
138 f->buf = buf; 129 f->buf = buf;
139 f->bufaddr = buf->bufaddr; 130 f->bufaddr = buf->bufaddr;
131 f->bcnt = bcnt;
132 f->lba = sector;
140 133
141 /* set up ata header */ 134 /* set up ata header */
142 ah->scnt = bcnt >> 9; 135 ah->scnt = bcnt >> 9;
143 ah->lba0 = sector; 136 put_lba(ah, sector);
144 ah->lba1 = sector >>= 8;
145 ah->lba2 = sector >>= 8;
146 ah->lba3 = sector >>= 8;
147 if (d->flags & DEVFL_EXT) { 137 if (d->flags & DEVFL_EXT) {
148 ah->aflags |= AOEAFL_EXT; 138 ah->aflags |= AOEAFL_EXT;
149 ah->lba4 = sector >>= 8;
150 ah->lba5 = sector >>= 8;
151 } else { 139 } else {
152 extbit = 0; 140 extbit = 0;
153 ah->lba3 &= 0x0f; 141 ah->lba3 &= 0x0f;
@@ -155,11 +143,14 @@ aoecmd_ata_rw(struct aoedev *d, struct frame *f)
155 } 143 }
156 144
157 if (bio_data_dir(buf->bio) == WRITE) { 145 if (bio_data_dir(buf->bio) == WRITE) {
146 skb_fill_page_desc(skb, 0, virt_to_page(f->bufaddr),
147 offset_in_page(f->bufaddr), bcnt);
158 ah->aflags |= AOEAFL_WRITE; 148 ah->aflags |= AOEAFL_WRITE;
159 f->writedatalen = bcnt; 149 skb->len += bcnt;
150 skb->data_len = bcnt;
160 } else { 151 } else {
152 skb->len = ETH_ZLEN;
161 writebit = 0; 153 writebit = 0;
162 f->writedatalen = 0;
163 } 154 }
164 155
165 ah->cmdstat = WIN_READ | writebit | extbit; 156 ah->cmdstat = WIN_READ | writebit | extbit;
@@ -168,26 +159,27 @@ aoecmd_ata_rw(struct aoedev *d, struct frame *f)
168 buf->nframesout += 1; 159 buf->nframesout += 1;
169 buf->bufaddr += bcnt; 160 buf->bufaddr += bcnt;
170 buf->bv_resid -= bcnt; 161 buf->bv_resid -= bcnt;
171/* printk(KERN_INFO "aoe: bv_resid=%ld\n", buf->bv_resid); */ 162/* printk(KERN_DEBUG "aoe: bv_resid=%ld\n", buf->bv_resid); */
172 buf->resid -= bcnt; 163 buf->resid -= bcnt;
173 buf->sector += bcnt >> 9; 164 buf->sector += bcnt >> 9;
174 if (buf->resid == 0) { 165 if (buf->resid == 0) {
175 d->inprocess = NULL; 166 d->inprocess = NULL;
176 } else if (buf->bv_resid == 0) { 167 } else if (buf->bv_resid == 0) {
177 buf->bv++; 168 buf->bv++;
169 WARN_ON(buf->bv->bv_len == 0);
178 buf->bv_resid = buf->bv->bv_len; 170 buf->bv_resid = buf->bv->bv_len;
179 buf->bufaddr = page_address(buf->bv->bv_page) + buf->bv->bv_offset; 171 buf->bufaddr = page_address(buf->bv->bv_page) + buf->bv->bv_offset;
180 } 172 }
181 173
182 skb = skb_prepare(d, f); 174 skb->dev = d->ifp;
183 if (skb) { 175 skb = skb_clone(skb, GFP_ATOMIC);
184 skb->next = NULL; 176 if (skb == NULL)
185 if (d->sendq_hd) 177 return;
186 d->sendq_tl->next = skb; 178 if (d->sendq_hd)
187 else 179 d->sendq_tl->next = skb;
188 d->sendq_hd = skb; 180 else
189 d->sendq_tl = skb; 181 d->sendq_hd = skb;
190 } 182 d->sendq_tl = skb;
191} 183}
192 184
193/* some callers cannot sleep, and they can call this function, 185/* some callers cannot sleep, and they can call this function,
@@ -209,11 +201,12 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff **tail)
209 if (!is_aoe_netif(ifp)) 201 if (!is_aoe_netif(ifp))
210 continue; 202 continue;
211 203
212 skb = new_skb(ifp, sizeof *h + sizeof *ch); 204 skb = new_skb(sizeof *h + sizeof *ch);
213 if (skb == NULL) { 205 if (skb == NULL) {
214 printk(KERN_INFO "aoe: aoecmd_cfg: skb alloc failure\n"); 206 printk(KERN_INFO "aoe: skb alloc failure\n");
215 continue; 207 continue;
216 } 208 }
209 skb->dev = ifp;
217 if (sl_tail == NULL) 210 if (sl_tail == NULL)
218 sl_tail = skb; 211 sl_tail = skb;
219 h = (struct aoe_hdr *) skb->mac.raw; 212 h = (struct aoe_hdr *) skb->mac.raw;
@@ -237,6 +230,29 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff **tail)
237 return sl; 230 return sl;
238} 231}
239 232
233static struct frame *
234freeframe(struct aoedev *d)
235{
236 struct frame *f, *e;
237 int n = 0;
238
239 f = d->frames;
240 e = f + d->nframes;
241 for (; f<e; f++) {
242 if (f->tag != FREETAG)
243 continue;
244 if (atomic_read(&skb_shinfo(f->skb)->dataref) == 1) {
245 skb_shinfo(f->skb)->nr_frags = f->skb->data_len = 0;
246 return f;
247 }
248 n++;
249 }
250 if (n == d->nframes) /* wait for network layer */
251 d->flags |= DEVFL_KICKME;
252
253 return NULL;
254}
255
240/* enters with d->lock held */ 256/* enters with d->lock held */
241void 257void
242aoecmd_work(struct aoedev *d) 258aoecmd_work(struct aoedev *d)
@@ -252,7 +268,7 @@ aoecmd_work(struct aoedev *d)
252 } 268 }
253 269
254loop: 270loop:
255 f = getframe(d, FREETAG); 271 f = freeframe(d);
256 if (f == NULL) 272 if (f == NULL)
257 return; 273 return;
258 if (d->inprocess == NULL) { 274 if (d->inprocess == NULL) {
@@ -260,7 +276,7 @@ loop:
260 return; 276 return;
261 buf = container_of(d->bufq.next, struct buf, bufs); 277 buf = container_of(d->bufq.next, struct buf, bufs);
262 list_del(d->bufq.next); 278 list_del(d->bufq.next);
263/*printk(KERN_INFO "aoecmd_work: bi_size=%ld\n", buf->bio->bi_size); */ 279/*printk(KERN_DEBUG "aoe: bi_size=%ld\n", buf->bio->bi_size); */
264 d->inprocess = buf; 280 d->inprocess = buf;
265 } 281 }
266 aoecmd_ata_rw(d, f); 282 aoecmd_ata_rw(d, f);
@@ -272,6 +288,7 @@ rexmit(struct aoedev *d, struct frame *f)
272{ 288{
273 struct sk_buff *skb; 289 struct sk_buff *skb;
274 struct aoe_hdr *h; 290 struct aoe_hdr *h;
291 struct aoe_atahdr *ah;
275 char buf[128]; 292 char buf[128];
276 u32 n; 293 u32 n;
277 294
@@ -283,21 +300,41 @@ rexmit(struct aoedev *d, struct frame *f)
283 d->aoemajor, d->aoeminor, f->tag, jiffies, n); 300 d->aoemajor, d->aoeminor, f->tag, jiffies, n);
284 aoechr_error(buf); 301 aoechr_error(buf);
285 302
286 h = (struct aoe_hdr *) f->data; 303 skb = f->skb;
304 h = (struct aoe_hdr *) skb->mac.raw;
305 ah = (struct aoe_atahdr *) (h+1);
287 f->tag = n; 306 f->tag = n;
288 h->tag = cpu_to_be32(n); 307 h->tag = cpu_to_be32(n);
289 memcpy(h->dst, d->addr, sizeof h->dst); 308 memcpy(h->dst, d->addr, sizeof h->dst);
290 memcpy(h->src, d->ifp->dev_addr, sizeof h->src); 309 memcpy(h->src, d->ifp->dev_addr, sizeof h->src);
291 310
292 skb = skb_prepare(d, f); 311 n = DEFAULTBCNT / 512;
293 if (skb) { 312 if (ah->scnt > n) {
294 skb->next = NULL; 313 ah->scnt = n;
295 if (d->sendq_hd) 314 if (ah->aflags & AOEAFL_WRITE) {
296 d->sendq_tl->next = skb; 315 skb_fill_page_desc(skb, 0, virt_to_page(f->bufaddr),
297 else 316 offset_in_page(f->bufaddr), DEFAULTBCNT);
298 d->sendq_hd = skb; 317 skb->len = sizeof *h + sizeof *ah + DEFAULTBCNT;
299 d->sendq_tl = skb; 318 skb->data_len = DEFAULTBCNT;
319 }
320 if (++d->lostjumbo > (d->nframes << 1))
321 if (d->maxbcnt != DEFAULTBCNT) {
322 printk(KERN_INFO "aoe: e%ld.%ld: too many lost jumbo on %s - using 1KB frames.\n",
323 d->aoemajor, d->aoeminor, d->ifp->name);
324 d->maxbcnt = DEFAULTBCNT;
325 d->flags |= DEVFL_MAXBCNT;
326 }
300 } 327 }
328
329 skb->dev = d->ifp;
330 skb = skb_clone(skb, GFP_ATOMIC);
331 if (skb == NULL)
332 return;
333 if (d->sendq_hd)
334 d->sendq_tl->next = skb;
335 else
336 d->sendq_hd = skb;
337 d->sendq_tl = skb;
301} 338}
302 339
303static int 340static int
@@ -340,13 +377,17 @@ rexmit_timer(ulong vp)
340 if (f->tag != FREETAG && tsince(f->tag) >= timeout) { 377 if (f->tag != FREETAG && tsince(f->tag) >= timeout) {
341 n = f->waited += timeout; 378 n = f->waited += timeout;
342 n /= HZ; 379 n /= HZ;
343 if (n > MAXWAIT) { /* waited too long. device failure. */ 380 if (n > aoe_deadsecs) { /* waited too long for response */
344 aoedev_downdev(d); 381 aoedev_downdev(d);
345 break; 382 break;
346 } 383 }
347 rexmit(d, f); 384 rexmit(d, f);
348 } 385 }
349 } 386 }
387 if (d->flags & DEVFL_KICKME) {
388 d->flags &= ~DEVFL_KICKME;
389 aoecmd_work(d);
390 }
350 391
351 sl = d->sendq_hd; 392 sl = d->sendq_hd;
352 d->sendq_hd = d->sendq_tl = NULL; 393 d->sendq_hd = d->sendq_tl = NULL;
@@ -431,8 +472,8 @@ ataid_complete(struct aoedev *d, unsigned char *id)
431 } 472 }
432 473
433 if (d->ssize != ssize) 474 if (d->ssize != ssize)
434 printk(KERN_INFO "aoe: %012llx e%lu.%lu v%04x has %llu " 475 printk(KERN_INFO "aoe: %012llx e%lu.%lu v%04x has %llu sectors\n",
435 "sectors\n", (unsigned long long)mac_addr(d->addr), 476 (unsigned long long)mac_addr(d->addr),
436 d->aoemajor, d->aoeminor, 477 d->aoemajor, d->aoeminor,
437 d->fw_ver, (long long)ssize); 478 d->fw_ver, (long long)ssize);
438 d->ssize = ssize; 479 d->ssize = ssize;
@@ -442,11 +483,9 @@ ataid_complete(struct aoedev *d, unsigned char *id)
442 d->flags |= DEVFL_NEWSIZE; 483 d->flags |= DEVFL_NEWSIZE;
443 } else { 484 } else {
444 if (d->flags & DEVFL_GDALLOC) { 485 if (d->flags & DEVFL_GDALLOC) {
445 printk(KERN_INFO "aoe: %s: %s e%lu.%lu, %s\n", 486 printk(KERN_ERR "aoe: can't schedule work for e%lu.%lu, %s\n",
446 __FUNCTION__,
447 "can't schedule work for",
448 d->aoemajor, d->aoeminor, 487 d->aoemajor, d->aoeminor,
449 "it's already on! (This really shouldn't happen).\n"); 488 "it's already on! This shouldn't happen.\n");
450 return; 489 return;
451 } 490 }
452 d->flags |= DEVFL_GDALLOC; 491 d->flags |= DEVFL_GDALLOC;
@@ -460,8 +499,15 @@ calc_rttavg(struct aoedev *d, int rtt)
460 register long n; 499 register long n;
461 500
462 n = rtt; 501 n = rtt;
463 if (n < MINTIMER) 502 if (n < 0) {
464 n = MINTIMER; 503 n = -rtt;
504 if (n < MINTIMER)
505 n = MINTIMER;
506 else if (n > MAXTIMER)
507 n = MAXTIMER;
508 d->mintimer += (n - d->mintimer) >> 1;
509 } else if (n < d->mintimer)
510 n = d->mintimer;
465 else if (n > MAXTIMER) 511 else if (n > MAXTIMER)
466 n = MAXTIMER; 512 n = MAXTIMER;
467 513
@@ -474,7 +520,7 @@ void
474aoecmd_ata_rsp(struct sk_buff *skb) 520aoecmd_ata_rsp(struct sk_buff *skb)
475{ 521{
476 struct aoedev *d; 522 struct aoedev *d;
477 struct aoe_hdr *hin; 523 struct aoe_hdr *hin, *hout;
478 struct aoe_atahdr *ahin, *ahout; 524 struct aoe_atahdr *ahin, *ahout;
479 struct frame *f; 525 struct frame *f;
480 struct buf *buf; 526 struct buf *buf;
@@ -497,8 +543,10 @@ aoecmd_ata_rsp(struct sk_buff *skb)
497 543
498 spin_lock_irqsave(&d->lock, flags); 544 spin_lock_irqsave(&d->lock, flags);
499 545
500 f = getframe(d, be32_to_cpu(hin->tag)); 546 n = be32_to_cpu(hin->tag);
547 f = getframe(d, n);
501 if (f == NULL) { 548 if (f == NULL) {
549 calc_rttavg(d, -tsince(n));
502 spin_unlock_irqrestore(&d->lock, flags); 550 spin_unlock_irqrestore(&d->lock, flags);
503 snprintf(ebuf, sizeof ebuf, 551 snprintf(ebuf, sizeof ebuf,
504 "%15s e%d.%d tag=%08x@%08lx\n", 552 "%15s e%d.%d tag=%08x@%08lx\n",
@@ -514,26 +562,27 @@ aoecmd_ata_rsp(struct sk_buff *skb)
514 calc_rttavg(d, tsince(f->tag)); 562 calc_rttavg(d, tsince(f->tag));
515 563
516 ahin = (struct aoe_atahdr *) (hin+1); 564 ahin = (struct aoe_atahdr *) (hin+1);
517 ahout = (struct aoe_atahdr *) (f->data + sizeof(struct aoe_hdr)); 565 hout = (struct aoe_hdr *) f->skb->mac.raw;
566 ahout = (struct aoe_atahdr *) (hout+1);
518 buf = f->buf; 567 buf = f->buf;
519 568
520 if (ahout->cmdstat == WIN_IDENTIFY) 569 if (ahout->cmdstat == WIN_IDENTIFY)
521 d->flags &= ~DEVFL_PAUSE; 570 d->flags &= ~DEVFL_PAUSE;
522 if (ahin->cmdstat & 0xa9) { /* these bits cleared on success */ 571 if (ahin->cmdstat & 0xa9) { /* these bits cleared on success */
523 printk(KERN_CRIT "aoe: aoecmd_ata_rsp: ata error cmd=%2.2Xh " 572 printk(KERN_ERR
524 "stat=%2.2Xh from e%ld.%ld\n", 573 "aoe: ata error cmd=%2.2Xh stat=%2.2Xh from e%ld.%ld\n",
525 ahout->cmdstat, ahin->cmdstat, 574 ahout->cmdstat, ahin->cmdstat,
526 d->aoemajor, d->aoeminor); 575 d->aoemajor, d->aoeminor);
527 if (buf) 576 if (buf)
528 buf->flags |= BUFFL_FAIL; 577 buf->flags |= BUFFL_FAIL;
529 } else { 578 } else {
579 n = ahout->scnt << 9;
530 switch (ahout->cmdstat) { 580 switch (ahout->cmdstat) {
531 case WIN_READ: 581 case WIN_READ:
532 case WIN_READ_EXT: 582 case WIN_READ_EXT:
533 n = ahout->scnt << 9;
534 if (skb->len - sizeof *hin - sizeof *ahin < n) { 583 if (skb->len - sizeof *hin - sizeof *ahin < n) {
535 printk(KERN_CRIT "aoe: aoecmd_ata_rsp: runt " 584 printk(KERN_ERR
536 "ata data size in read. skb->len=%d\n", 585 "aoe: runt data size in read. skb->len=%d\n",
537 skb->len); 586 skb->len);
538 /* fail frame f? just returning will rexmit. */ 587 /* fail frame f? just returning will rexmit. */
539 spin_unlock_irqrestore(&d->lock, flags); 588 spin_unlock_irqrestore(&d->lock, flags);
@@ -542,22 +591,49 @@ aoecmd_ata_rsp(struct sk_buff *skb)
542 memcpy(f->bufaddr, ahin+1, n); 591 memcpy(f->bufaddr, ahin+1, n);
543 case WIN_WRITE: 592 case WIN_WRITE:
544 case WIN_WRITE_EXT: 593 case WIN_WRITE_EXT:
594 if (f->bcnt -= n) {
595 skb = f->skb;
596 f->bufaddr += n;
597 put_lba(ahout, f->lba += ahout->scnt);
598 n = f->bcnt;
599 if (n > DEFAULTBCNT)
600 n = DEFAULTBCNT;
601 ahout->scnt = n >> 9;
602 if (ahout->aflags & AOEAFL_WRITE) {
603 skb_fill_page_desc(skb, 0,
604 virt_to_page(f->bufaddr),
605 offset_in_page(f->bufaddr), n);
606 skb->len = sizeof *hout + sizeof *ahout + n;
607 skb->data_len = n;
608 }
609 f->tag = newtag(d);
610 hout->tag = cpu_to_be32(f->tag);
611 skb->dev = d->ifp;
612 skb = skb_clone(skb, GFP_ATOMIC);
613 spin_unlock_irqrestore(&d->lock, flags);
614 if (skb)
615 aoenet_xmit(skb);
616 return;
617 }
618 if (n > DEFAULTBCNT)
619 d->lostjumbo = 0;
545 break; 620 break;
546 case WIN_IDENTIFY: 621 case WIN_IDENTIFY:
547 if (skb->len - sizeof *hin - sizeof *ahin < 512) { 622 if (skb->len - sizeof *hin - sizeof *ahin < 512) {
548 printk(KERN_INFO "aoe: aoecmd_ata_rsp: runt data size " 623 printk(KERN_INFO
549 "in ataid. skb->len=%d\n", skb->len); 624 "aoe: runt data size in ataid. skb->len=%d\n",
625 skb->len);
550 spin_unlock_irqrestore(&d->lock, flags); 626 spin_unlock_irqrestore(&d->lock, flags);
551 return; 627 return;
552 } 628 }
553 ataid_complete(d, (char *) (ahin+1)); 629 ataid_complete(d, (char *) (ahin+1));
554 break; 630 break;
555 default: 631 default:
556 printk(KERN_INFO "aoe: aoecmd_ata_rsp: unrecognized " 632 printk(KERN_INFO
557 "outbound ata command %2.2Xh for %d.%d\n", 633 "aoe: unrecognized ata command %2.2Xh for %d.%d\n",
558 ahout->cmdstat, 634 ahout->cmdstat,
559 be16_to_cpu(hin->major), 635 be16_to_cpu(hin->major),
560 hin->minor); 636 hin->minor);
561 } 637 }
562 } 638 }
563 639
@@ -612,33 +688,32 @@ aoecmd_ata_id(struct aoedev *d)
612 struct frame *f; 688 struct frame *f;
613 struct sk_buff *skb; 689 struct sk_buff *skb;
614 690
615 f = getframe(d, FREETAG); 691 f = freeframe(d);
616 if (f == NULL) { 692 if (f == NULL) {
617 printk(KERN_CRIT "aoe: aoecmd_ata_id: can't get a frame. " 693 printk(KERN_ERR "aoe: can't get a frame. This shouldn't happen.\n");
618 "This shouldn't happen.\n");
619 return NULL; 694 return NULL;
620 } 695 }
621 696
622 /* initialize the headers & frame */ 697 /* initialize the headers & frame */
623 h = (struct aoe_hdr *) f->data; 698 skb = f->skb;
699 h = (struct aoe_hdr *) skb->mac.raw;
624 ah = (struct aoe_atahdr *) (h+1); 700 ah = (struct aoe_atahdr *) (h+1);
625 f->ndata = sizeof *h + sizeof *ah; 701 skb->len = ETH_ZLEN;
626 memset(h, 0, f->ndata); 702 memset(h, 0, ETH_ZLEN);
627 f->tag = aoehdr_atainit(d, h); 703 f->tag = aoehdr_atainit(d, h);
628 f->waited = 0; 704 f->waited = 0;
629 f->writedatalen = 0;
630 705
631 /* set up ata header */ 706 /* set up ata header */
632 ah->scnt = 1; 707 ah->scnt = 1;
633 ah->cmdstat = WIN_IDENTIFY; 708 ah->cmdstat = WIN_IDENTIFY;
634 ah->lba3 = 0xa0; 709 ah->lba3 = 0xa0;
635 710
636 skb = skb_prepare(d, f); 711 skb->dev = d->ifp;
637 712
638 d->rttavg = MAXTIMER; 713 d->rttavg = MAXTIMER;
639 d->timer.function = rexmit_timer; 714 d->timer.function = rexmit_timer;
640 715
641 return skb; 716 return skb_clone(skb, GFP_ATOMIC);
642} 717}
643 718
644void 719void
@@ -648,9 +723,9 @@ aoecmd_cfg_rsp(struct sk_buff *skb)
648 struct aoe_hdr *h; 723 struct aoe_hdr *h;
649 struct aoe_cfghdr *ch; 724 struct aoe_cfghdr *ch;
650 ulong flags, sysminor, aoemajor; 725 ulong flags, sysminor, aoemajor;
651 u16 bufcnt;
652 struct sk_buff *sl; 726 struct sk_buff *sl;
653 enum { MAXFRAMES = 16 }; 727 enum { MAXFRAMES = 16 };
728 u16 n;
654 729
655 h = (struct aoe_hdr *) skb->mac.raw; 730 h = (struct aoe_hdr *) skb->mac.raw;
656 ch = (struct aoe_cfghdr *) (h+1); 731 ch = (struct aoe_cfghdr *) (h+1);
@@ -661,26 +736,25 @@ aoecmd_cfg_rsp(struct sk_buff *skb)
661 */ 736 */
662 aoemajor = be16_to_cpu(h->major); 737 aoemajor = be16_to_cpu(h->major);
663 if (aoemajor == 0xfff) { 738 if (aoemajor == 0xfff) {
664 printk(KERN_CRIT "aoe: aoecmd_cfg_rsp: Warning: shelf " 739 printk(KERN_ERR "aoe: Warning: shelf address is all ones. "
665 "address is all ones. Check shelf dip switches\n"); 740 "Check shelf dip switches.\n");
666 return; 741 return;
667 } 742 }
668 743
669 sysminor = SYSMINOR(aoemajor, h->minor); 744 sysminor = SYSMINOR(aoemajor, h->minor);
670 if (sysminor * AOE_PARTITIONS + AOE_PARTITIONS > MINORMASK) { 745 if (sysminor * AOE_PARTITIONS + AOE_PARTITIONS > MINORMASK) {
671 printk(KERN_INFO 746 printk(KERN_INFO "aoe: e%ld.%d: minor number too large\n",
672 "aoe: e%ld.%d: minor number too large\n",
673 aoemajor, (int) h->minor); 747 aoemajor, (int) h->minor);
674 return; 748 return;
675 } 749 }
676 750
677 bufcnt = be16_to_cpu(ch->bufcnt); 751 n = be16_to_cpu(ch->bufcnt);
678 if (bufcnt > MAXFRAMES) /* keep it reasonable */ 752 if (n > MAXFRAMES) /* keep it reasonable */
679 bufcnt = MAXFRAMES; 753 n = MAXFRAMES;
680 754
681 d = aoedev_by_sysminor_m(sysminor, bufcnt); 755 d = aoedev_by_sysminor_m(sysminor, n);
682 if (d == NULL) { 756 if (d == NULL) {
683 printk(KERN_INFO "aoe: aoecmd_cfg_rsp: device sysminor_m failure\n"); 757 printk(KERN_INFO "aoe: device sysminor_m failure\n");
684 return; 758 return;
685 } 759 }
686 760
@@ -689,6 +763,20 @@ aoecmd_cfg_rsp(struct sk_buff *skb)
689 /* permit device to migrate mac and network interface */ 763 /* permit device to migrate mac and network interface */
690 d->ifp = skb->dev; 764 d->ifp = skb->dev;
691 memcpy(d->addr, h->src, sizeof d->addr); 765 memcpy(d->addr, h->src, sizeof d->addr);
766 if (!(d->flags & DEVFL_MAXBCNT)) {
767 n = d->ifp->mtu;
768 n -= sizeof (struct aoe_hdr) + sizeof (struct aoe_atahdr);
769 n /= 512;
770 if (n > ch->scnt)
771 n = ch->scnt;
772 n = n ? n * 512 : DEFAULTBCNT;
773 if (n != d->maxbcnt) {
774 printk(KERN_INFO
775 "aoe: e%ld.%ld: setting %d byte data frames on %s\n",
776 d->aoemajor, d->aoeminor, n, d->ifp->name);
777 d->maxbcnt = n;
778 }
779 }
692 780
693 /* don't change users' perspective */ 781 /* don't change users' perspective */
694 if (d->nopen && !(d->flags & DEVFL_PAUSE)) { 782 if (d->nopen && !(d->flags & DEVFL_PAUSE)) {
@@ -696,6 +784,7 @@ aoecmd_cfg_rsp(struct sk_buff *skb)
696 return; 784 return;
697 } 785 }
698 d->flags |= DEVFL_PAUSE; /* force pause */ 786 d->flags |= DEVFL_PAUSE; /* force pause */
787 d->mintimer = MINTIMER;
699 d->fw_ver = be16_to_cpu(ch->fwver); 788 d->fw_ver = be16_to_cpu(ch->fwver);
700 789
701 /* check for already outstanding ataid */ 790 /* check for already outstanding ataid */
diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c
index ed4258a62df5..6125921bbec4 100644
--- a/drivers/block/aoe/aoedev.c
+++ b/drivers/block/aoe/aoedev.c
@@ -1,4 +1,4 @@
1/* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */ 1/* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */
2/* 2/*
3 * aoedev.c 3 * aoedev.c
4 * AoE device utility functions; maintains device list. 4 * AoE device utility functions; maintains device list.
@@ -20,11 +20,8 @@ aoedev_isbusy(struct aoedev *d)
20 f = d->frames; 20 f = d->frames;
21 e = f + d->nframes; 21 e = f + d->nframes;
22 do { 22 do {
23 if (f->tag != FREETAG) { 23 if (f->tag != FREETAG)
24 printk(KERN_DEBUG "aoe: %ld.%ld isbusy\n",
25 d->aoemajor, d->aoeminor);
26 return 1; 24 return 1;
27 }
28 } while (++f < e); 25 } while (++f < e);
29 26
30 return 0; 27 return 0;
@@ -66,22 +63,32 @@ aoedev_newdev(ulong nframes)
66 struct frame *f, *e; 63 struct frame *f, *e;
67 64
68 d = kzalloc(sizeof *d, GFP_ATOMIC); 65 d = kzalloc(sizeof *d, GFP_ATOMIC);
69 if (d == NULL)
70 return NULL;
71 f = kcalloc(nframes, sizeof *f, GFP_ATOMIC); 66 f = kcalloc(nframes, sizeof *f, GFP_ATOMIC);
72 if (f == NULL) { 67 switch (!d || !f) {
73 kfree(d); 68 case 0:
69 d->nframes = nframes;
70 d->frames = f;
71 e = f + nframes;
72 for (; f<e; f++) {
73 f->tag = FREETAG;
74 f->skb = new_skb(ETH_ZLEN);
75 if (!f->skb)
76 break;
77 }
78 if (f == e)
79 break;
80 while (f > d->frames) {
81 f--;
82 dev_kfree_skb(f->skb);
83 }
84 default:
85 if (f)
86 kfree(f);
87 if (d)
88 kfree(d);
74 return NULL; 89 return NULL;
75 } 90 }
76
77 INIT_WORK(&d->work, aoecmd_sleepwork, d); 91 INIT_WORK(&d->work, aoecmd_sleepwork, d);
78
79 d->nframes = nframes;
80 d->frames = f;
81 e = f + nframes;
82 for (; f<e; f++)
83 f->tag = FREETAG;
84
85 spin_lock_init(&d->lock); 92 spin_lock_init(&d->lock);
86 init_timer(&d->timer); 93 init_timer(&d->timer);
87 d->timer.data = (ulong) d; 94 d->timer.data = (ulong) d;
@@ -114,6 +121,7 @@ aoedev_downdev(struct aoedev *d)
114 mempool_free(buf, d->bufpool); 121 mempool_free(buf, d->bufpool);
115 bio_endio(bio, bio->bi_size, -EIO); 122 bio_endio(bio, bio->bi_size, -EIO);
116 } 123 }
124 skb_shinfo(f->skb)->nr_frags = f->skb->data_len = 0;
117 } 125 }
118 d->inprocess = NULL; 126 d->inprocess = NULL;
119 127
@@ -148,7 +156,7 @@ aoedev_by_sysminor_m(ulong sysminor, ulong bufcnt)
148 d = aoedev_newdev(bufcnt); 156 d = aoedev_newdev(bufcnt);
149 if (d == NULL) { 157 if (d == NULL) {
150 spin_unlock_irqrestore(&devlist_lock, flags); 158 spin_unlock_irqrestore(&devlist_lock, flags);
151 printk(KERN_INFO "aoe: aoedev_set: aoedev_newdev failure.\n"); 159 printk(KERN_INFO "aoe: aoedev_newdev failure.\n");
152 return NULL; 160 return NULL;
153 } 161 }
154 d->sysminor = sysminor; 162 d->sysminor = sysminor;
@@ -163,11 +171,19 @@ aoedev_by_sysminor_m(ulong sysminor, ulong bufcnt)
163static void 171static void
164aoedev_freedev(struct aoedev *d) 172aoedev_freedev(struct aoedev *d)
165{ 173{
174 struct frame *f, *e;
175
166 if (d->gd) { 176 if (d->gd) {
167 aoedisk_rm_sysfs(d); 177 aoedisk_rm_sysfs(d);
168 del_gendisk(d->gd); 178 del_gendisk(d->gd);
169 put_disk(d->gd); 179 put_disk(d->gd);
170 } 180 }
181 f = d->frames;
182 e = f + d->nframes;
183 for (; f<e; f++) {
184 skb_shinfo(f->skb)->nr_frags = 0;
185 dev_kfree_skb(f->skb);
186 }
171 kfree(d->frames); 187 kfree(d->frames);
172 if (d->bufpool) 188 if (d->bufpool)
173 mempool_destroy(d->bufpool); 189 mempool_destroy(d->bufpool);
diff --git a/drivers/block/aoe/aoemain.c b/drivers/block/aoe/aoemain.c
index de08491ebe66..a04b7d613299 100644
--- a/drivers/block/aoe/aoemain.c
+++ b/drivers/block/aoe/aoemain.c
@@ -1,4 +1,4 @@
1/* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */ 1/* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */
2/* 2/*
3 * aoemain.c 3 * aoemain.c
4 * Module initialization routines, discover timer 4 * Module initialization routines, discover timer
@@ -84,13 +84,11 @@ aoe_init(void)
84 goto net_fail; 84 goto net_fail;
85 ret = register_blkdev(AOE_MAJOR, DEVICE_NAME); 85 ret = register_blkdev(AOE_MAJOR, DEVICE_NAME);
86 if (ret < 0) { 86 if (ret < 0) {
87 printk(KERN_ERR "aoe: aoeblk_init: can't register major\n"); 87 printk(KERN_ERR "aoe: can't register major\n");
88 goto blkreg_fail; 88 goto blkreg_fail;
89 } 89 }
90 90
91 printk(KERN_INFO 91 printk(KERN_INFO "aoe: AoE v%s initialised.\n", VERSION);
92 "aoe: aoe_init: AoE v%s initialised.\n",
93 VERSION);
94 discover_timer(TINIT); 92 discover_timer(TINIT);
95 return 0; 93 return 0;
96 94
@@ -103,7 +101,7 @@ aoe_init(void)
103 chr_fail: 101 chr_fail:
104 aoedev_exit(); 102 aoedev_exit();
105 103
106 printk(KERN_INFO "aoe: aoe_init: initialisation failure.\n"); 104 printk(KERN_INFO "aoe: initialisation failure.\n");
107 return ret; 105 return ret;
108} 106}
109 107
diff --git a/drivers/block/aoe/aoenet.c b/drivers/block/aoe/aoenet.c
index c1434ed11880..9626e0f5da9d 100644
--- a/drivers/block/aoe/aoenet.c
+++ b/drivers/block/aoe/aoenet.c
@@ -1,4 +1,4 @@
1/* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */ 1/* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */
2/* 2/*
3 * aoenet.c 3 * aoenet.c
4 * Ethernet portion of AoE driver 4 * Ethernet portion of AoE driver
@@ -74,7 +74,7 @@ set_aoe_iflist(const char __user *user_str, size_t size)
74 return -EINVAL; 74 return -EINVAL;
75 75
76 if (copy_from_user(aoe_iflist, user_str, size)) { 76 if (copy_from_user(aoe_iflist, user_str, size)) {
77 printk(KERN_INFO "aoe: %s: copy from user failed\n", __FUNCTION__); 77 printk(KERN_INFO "aoe: copy from user failed\n");
78 return -EFAULT; 78 return -EFAULT;
79 } 79 }
80 aoe_iflist[size] = 0x00; 80 aoe_iflist[size] = 0x00;
@@ -132,8 +132,7 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt,
132 if (n > NECODES) 132 if (n > NECODES)
133 n = 0; 133 n = 0;
134 if (net_ratelimit()) 134 if (net_ratelimit())
135 printk(KERN_ERR "aoe: aoenet_rcv: error packet from %d.%d; " 135 printk(KERN_ERR "aoe: error packet from %d.%d; ecode=%d '%s'\n",
136 "ecode=%d '%s'\n",
137 be16_to_cpu(h->major), h->minor, 136 be16_to_cpu(h->major), h->minor,
138 h->err, aoe_errlist[n]); 137 h->err, aoe_errlist[n]);
139 goto exit; 138 goto exit;
@@ -147,7 +146,7 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt,
147 aoecmd_cfg_rsp(skb); 146 aoecmd_cfg_rsp(skb);
148 break; 147 break;
149 default: 148 default:
150 printk(KERN_INFO "aoe: aoenet_rcv: unknown cmd %d\n", h->cmd); 149 printk(KERN_INFO "aoe: unknown cmd %d\n", h->cmd);
151 } 150 }
152exit: 151exit:
153 dev_kfree_skb(skb); 152 dev_kfree_skb(skb);
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index dcccaf2782f3..4105c3bf3476 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -1300,6 +1300,12 @@ static void cciss_softirq_done(struct request *rq)
1300 1300
1301 complete_buffers(rq->bio, rq->errors); 1301 complete_buffers(rq->bio, rq->errors);
1302 1302
1303 if (blk_fs_request(rq)) {
1304 const int rw = rq_data_dir(rq);
1305
1306 disk_stat_add(rq->rq_disk, sectors[rw], rq->nr_sectors);
1307 }
1308
1303#ifdef CCISS_DEBUG 1309#ifdef CCISS_DEBUG
1304 printk("Done with %p\n", rq); 1310 printk("Done with %p\n", rq);
1305#endif /* CCISS_DEBUG */ 1311#endif /* CCISS_DEBUG */
@@ -1923,7 +1929,6 @@ static void cciss_geometry_inquiry(int ctlr, int logvol,
1923{ 1929{
1924 int return_code; 1930 int return_code;
1925 unsigned long t; 1931 unsigned long t;
1926 unsigned long rem;
1927 1932
1928 memset(inq_buff, 0, sizeof(InquiryData_struct)); 1933 memset(inq_buff, 0, sizeof(InquiryData_struct));
1929 if (withirq) 1934 if (withirq)
@@ -1939,26 +1944,23 @@ static void cciss_geometry_inquiry(int ctlr, int logvol,
1939 printk(KERN_WARNING 1944 printk(KERN_WARNING
1940 "cciss: reading geometry failed, volume " 1945 "cciss: reading geometry failed, volume "
1941 "does not support reading geometry\n"); 1946 "does not support reading geometry\n");
1942 drv->block_size = block_size;
1943 drv->nr_blocks = total_size;
1944 drv->heads = 255; 1947 drv->heads = 255;
1945 drv->sectors = 32; // Sectors per track 1948 drv->sectors = 32; // Sectors per track
1946 t = drv->heads * drv->sectors;
1947 drv->cylinders = total_size;
1948 rem = do_div(drv->cylinders, t);
1949 } else { 1949 } else {
1950 drv->block_size = block_size;
1951 drv->nr_blocks = total_size;
1952 drv->heads = inq_buff->data_byte[6]; 1950 drv->heads = inq_buff->data_byte[6];
1953 drv->sectors = inq_buff->data_byte[7]; 1951 drv->sectors = inq_buff->data_byte[7];
1954 drv->cylinders = (inq_buff->data_byte[4] & 0xff) << 8; 1952 drv->cylinders = (inq_buff->data_byte[4] & 0xff) << 8;
1955 drv->cylinders += inq_buff->data_byte[5]; 1953 drv->cylinders += inq_buff->data_byte[5];
1956 drv->raid_level = inq_buff->data_byte[8]; 1954 drv->raid_level = inq_buff->data_byte[8];
1957 t = drv->heads * drv->sectors; 1955 }
1958 if (t > 1) { 1956 drv->block_size = block_size;
1959 drv->cylinders = total_size; 1957 drv->nr_blocks = total_size;
1960 rem = do_div(drv->cylinders, t); 1958 t = drv->heads * drv->sectors;
1961 } 1959 if (t > 1) {
1960 unsigned rem = sector_div(total_size, t);
1961 if (rem)
1962 total_size++;
1963 drv->cylinders = total_size;
1962 } 1964 }
1963 } else { /* Get geometry failed */ 1965 } else { /* Get geometry failed */
1964 printk(KERN_WARNING "cciss: reading geometry failed\n"); 1966 printk(KERN_WARNING "cciss: reading geometry failed\n");
@@ -1996,8 +1998,8 @@ cciss_read_capacity(int ctlr, int logvol, int withirq, sector_t *total_size,
1996 *block_size = BLOCK_SIZE; 1998 *block_size = BLOCK_SIZE;
1997 } 1999 }
1998 if (*total_size != (__u32) 0) 2000 if (*total_size != (__u32) 0)
1999 printk(KERN_INFO " blocks= %lld block_size= %d\n", 2001 printk(KERN_INFO " blocks= %llu block_size= %d\n",
2000 *total_size, *block_size); 2002 (unsigned long long)*total_size, *block_size);
2001 kfree(buf); 2003 kfree(buf);
2002 return; 2004 return;
2003} 2005}
@@ -2031,8 +2033,8 @@ cciss_read_capacity_16(int ctlr, int logvol, int withirq, sector_t *total_size,
2031 *total_size = 0; 2033 *total_size = 0;
2032 *block_size = BLOCK_SIZE; 2034 *block_size = BLOCK_SIZE;
2033 } 2035 }
2034 printk(KERN_INFO " blocks= %lld block_size= %d\n", 2036 printk(KERN_INFO " blocks= %llu block_size= %d\n",
2035 *total_size, *block_size); 2037 (unsigned long long)*total_size, *block_size);
2036 kfree(buf); 2038 kfree(buf);
2037 return; 2039 return;
2038} 2040}
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index 570d2f049323..d5f519ebbc08 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -998,6 +998,7 @@ static inline void complete_buffers(struct bio *bio, int ok)
998 */ 998 */
999static inline void complete_command(cmdlist_t *cmd, int timeout) 999static inline void complete_command(cmdlist_t *cmd, int timeout)
1000{ 1000{
1001 struct request *rq = cmd->rq;
1001 int ok=1; 1002 int ok=1;
1002 int i, ddir; 1003 int i, ddir;
1003 1004
@@ -1029,12 +1030,18 @@ static inline void complete_command(cmdlist_t *cmd, int timeout)
1029 pci_unmap_page(hba[cmd->ctlr]->pci_dev, cmd->req.sg[i].addr, 1030 pci_unmap_page(hba[cmd->ctlr]->pci_dev, cmd->req.sg[i].addr,
1030 cmd->req.sg[i].size, ddir); 1031 cmd->req.sg[i].size, ddir);
1031 1032
1032 complete_buffers(cmd->rq->bio, ok); 1033 complete_buffers(rq->bio, ok);
1033 1034
1034 add_disk_randomness(cmd->rq->rq_disk); 1035 if (blk_fs_request(rq)) {
1036 const int rw = rq_data_dir(rq);
1035 1037
1036 DBGPX(printk("Done with %p\n", cmd->rq);); 1038 disk_stat_add(rq->rq_disk, sectors[rw], rq->nr_sectors);
1037 end_that_request_last(cmd->rq, ok ? 1 : -EIO); 1039 }
1040
1041 add_disk_randomness(rq->rq_disk);
1042
1043 DBGPX(printk("Done with %p\n", rq););
1044 end_that_request_last(rq, ok ? 1 : -EIO);
1038} 1045}
1039 1046
1040/* 1047/*
diff --git a/drivers/block/rd.c b/drivers/block/rd.c
index a3f64bfe6b58..485aa87e9bcd 100644
--- a/drivers/block/rd.c
+++ b/drivers/block/rd.c
@@ -432,6 +432,12 @@ static int __init rd_init(void)
432 rd_disks[i] = alloc_disk(1); 432 rd_disks[i] = alloc_disk(1);
433 if (!rd_disks[i]) 433 if (!rd_disks[i])
434 goto out; 434 goto out;
435
436 rd_queue[i] = blk_alloc_queue(GFP_KERNEL);
437 if (!rd_queue[i]) {
438 put_disk(rd_disks[i]);
439 goto out;
440 }
435 } 441 }
436 442
437 if (register_blkdev(RAMDISK_MAJOR, "ramdisk")) { 443 if (register_blkdev(RAMDISK_MAJOR, "ramdisk")) {
@@ -442,10 +448,6 @@ static int __init rd_init(void)
442 for (i = 0; i < CONFIG_BLK_DEV_RAM_COUNT; i++) { 448 for (i = 0; i < CONFIG_BLK_DEV_RAM_COUNT; i++) {
443 struct gendisk *disk = rd_disks[i]; 449 struct gendisk *disk = rd_disks[i];
444 450
445 rd_queue[i] = blk_alloc_queue(GFP_KERNEL);
446 if (!rd_queue[i])
447 goto out_queue;
448
449 blk_queue_make_request(rd_queue[i], &rd_make_request); 451 blk_queue_make_request(rd_queue[i], &rd_make_request);
450 blk_queue_hardsect_size(rd_queue[i], rd_blocksize); 452 blk_queue_hardsect_size(rd_queue[i], rd_blocksize);
451 453
@@ -466,8 +468,6 @@ static int __init rd_init(void)
466 CONFIG_BLK_DEV_RAM_COUNT, rd_size, rd_blocksize); 468 CONFIG_BLK_DEV_RAM_COUNT, rd_size, rd_blocksize);
467 469
468 return 0; 470 return 0;
469out_queue:
470 unregister_blkdev(RAMDISK_MAJOR, "ramdisk");
471out: 471out:
472 while (i--) { 472 while (i--) {
473 put_disk(rd_disks[i]); 473 put_disk(rd_disks[i]);
diff --git a/drivers/block/xd.c b/drivers/block/xd.c
index 10cc38783bdf..0d97b7eb818a 100644
--- a/drivers/block/xd.c
+++ b/drivers/block/xd.c
@@ -48,9 +48,9 @@
48#include <linux/blkdev.h> 48#include <linux/blkdev.h>
49#include <linux/blkpg.h> 49#include <linux/blkpg.h>
50#include <linux/delay.h> 50#include <linux/delay.h>
51#include <linux/io.h>
51 52
52#include <asm/system.h> 53#include <asm/system.h>
53#include <asm/io.h>
54#include <asm/uaccess.h> 54#include <asm/uaccess.h>
55#include <asm/dma.h> 55#include <asm/dma.h>
56 56
diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c
index 82ddbdd7bd4b..7cc2685ca84a 100644
--- a/drivers/block/z2ram.c
+++ b/drivers/block/z2ram.c
@@ -329,7 +329,7 @@ static struct kobject *z2_find(dev_t dev, int *part, void *data)
329 329
330static struct request_queue *z2_queue; 330static struct request_queue *z2_queue;
331 331
332int __init 332static int __init
333z2_init(void) 333z2_init(void)
334{ 334{
335 int ret; 335 int ret;
@@ -370,26 +370,7 @@ err:
370 return ret; 370 return ret;
371} 371}
372 372
373#if defined(MODULE) 373static void __exit z2_exit(void)
374
375MODULE_LICENSE("GPL");
376
377int
378init_module( void )
379{
380 int error;
381
382 error = z2_init();
383 if ( error == 0 )
384 {
385 printk( KERN_INFO DEVICE_NAME ": loaded as module\n" );
386 }
387
388 return error;
389}
390
391void
392cleanup_module( void )
393{ 374{
394 int i, j; 375 int i, j;
395 blk_unregister_region(MKDEV(Z2RAM_MAJOR, 0), 256); 376 blk_unregister_region(MKDEV(Z2RAM_MAJOR, 0), 256);
@@ -425,4 +406,7 @@ cleanup_module( void )
425 406
426 return; 407 return;
427} 408}
428#endif 409
410module_init(z2_init);
411module_exit(z2_exit);
412MODULE_LICENSE("GPL");
diff --git a/drivers/bluetooth/bcm203x.c b/drivers/bluetooth/bcm203x.c
index 67cdda43f229..516751754aa9 100644
--- a/drivers/bluetooth/bcm203x.c
+++ b/drivers/bluetooth/bcm203x.c
@@ -29,7 +29,6 @@
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/errno.h> 31#include <linux/errno.h>
32#include <linux/timer.h>
33 32
34#include <linux/device.h> 33#include <linux/device.h>
35#include <linux/firmware.h> 34#include <linux/firmware.h>
@@ -43,7 +42,7 @@
43#define BT_DBG(D...) 42#define BT_DBG(D...)
44#endif 43#endif
45 44
46#define VERSION "1.0" 45#define VERSION "1.1"
47 46
48static int ignore = 0; 47static int ignore = 0;
49 48
@@ -72,7 +71,7 @@ struct bcm203x_data {
72 71
73 unsigned long state; 72 unsigned long state;
74 73
75 struct timer_list timer; 74 struct work_struct work;
76 75
77 struct urb *urb; 76 struct urb *urb;
78 unsigned char *buffer; 77 unsigned char *buffer;
@@ -105,7 +104,7 @@ static void bcm203x_complete(struct urb *urb)
105 104
106 data->state = BCM203X_SELECT_MEMORY; 105 data->state = BCM203X_SELECT_MEMORY;
107 106
108 mod_timer(&data->timer, jiffies + (HZ / 10)); 107 schedule_work(&data->work);
109 break; 108 break;
110 109
111 case BCM203X_SELECT_MEMORY: 110 case BCM203X_SELECT_MEMORY:
@@ -158,9 +157,9 @@ static void bcm203x_complete(struct urb *urb)
158 } 157 }
159} 158}
160 159
161static void bcm203x_timer(unsigned long user_data) 160static void bcm203x_work(void *user_data)
162{ 161{
163 struct bcm203x_data *data = (struct bcm203x_data *) user_data; 162 struct bcm203x_data *data = user_data;
164 163
165 if (usb_submit_urb(data->urb, GFP_ATOMIC) < 0) 164 if (usb_submit_urb(data->urb, GFP_ATOMIC) < 0)
166 BT_ERR("Can't submit URB"); 165 BT_ERR("Can't submit URB");
@@ -247,13 +246,11 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id
247 246
248 release_firmware(firmware); 247 release_firmware(firmware);
249 248
250 init_timer(&data->timer); 249 INIT_WORK(&data->work, bcm203x_work, (void *) data);
251 data->timer.function = bcm203x_timer;
252 data->timer.data = (unsigned long) data;
253 250
254 usb_set_intfdata(intf, data); 251 usb_set_intfdata(intf, data);
255 252
256 mod_timer(&data->timer, jiffies + HZ); 253 schedule_work(&data->work);
257 254
258 return 0; 255 return 0;
259} 256}
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c
index 845b8680032a..cbc07250b898 100644
--- a/drivers/bluetooth/bluecard_cs.c
+++ b/drivers/bluetooth/bluecard_cs.c
@@ -282,7 +282,7 @@ static void bluecard_write_wakeup(bluecard_info_t *info)
282 clear_bit(ready_bit, &(info->tx_state)); 282 clear_bit(ready_bit, &(info->tx_state));
283 283
284 if (bt_cb(skb)->pkt_type & 0x80) { 284 if (bt_cb(skb)->pkt_type & 0x80) {
285 DECLARE_WAIT_QUEUE_HEAD(wq); 285 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);
286 DEFINE_WAIT(wait); 286 DEFINE_WAIT(wait);
287 287
288 unsigned char baud_reg; 288 unsigned char baud_reg;
diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c
index e7c800f4c3ad..07eafbc5dc3a 100644
--- a/drivers/bluetooth/dtl1_cs.c
+++ b/drivers/bluetooth/dtl1_cs.c
@@ -711,6 +711,7 @@ static void dtl1_release(struct pcmcia_device *link)
711 711
712static struct pcmcia_device_id dtl1_ids[] = { 712static struct pcmcia_device_id dtl1_ids[] = {
713 PCMCIA_DEVICE_PROD_ID12("Nokia Mobile Phones", "DTL-1", 0xe1bfdd64, 0xe168480d), 713 PCMCIA_DEVICE_PROD_ID12("Nokia Mobile Phones", "DTL-1", 0xe1bfdd64, 0xe168480d),
714 PCMCIA_DEVICE_PROD_ID12("Nokia Mobile Phones", "DTL-4", 0xe1bfdd64, 0x9102bc82),
714 PCMCIA_DEVICE_PROD_ID12("Socket", "CF", 0xb38bcc2e, 0x44ebf863), 715 PCMCIA_DEVICE_PROD_ID12("Socket", "CF", 0xb38bcc2e, 0x44ebf863),
715 PCMCIA_DEVICE_PROD_ID12("Socket", "CF+ Personal Network Card", 0xb38bcc2e, 0xe732bae3), 716 PCMCIA_DEVICE_PROD_ID12("Socket", "CF+ Personal Network Card", 0xb38bcc2e, 0xe732bae3),
716 PCMCIA_DEVICE_NULL 717 PCMCIA_DEVICE_NULL
diff --git a/drivers/bluetooth/hci_usb.c b/drivers/bluetooth/hci_usb.c
index 7565642a007a..fdea58ae16b2 100644
--- a/drivers/bluetooth/hci_usb.c
+++ b/drivers/bluetooth/hci_usb.c
@@ -118,6 +118,9 @@ static struct usb_device_id blacklist_ids[] = {
118 /* IBM/Lenovo ThinkPad with Broadcom chip */ 118 /* IBM/Lenovo ThinkPad with Broadcom chip */
119 { USB_DEVICE(0x0a5c, 0x201e), .driver_info = HCI_WRONG_SCO_MTU }, 119 { USB_DEVICE(0x0a5c, 0x201e), .driver_info = HCI_WRONG_SCO_MTU },
120 120
121 /* ANYCOM Bluetooth USB-200 and USB-250 */
122 { USB_DEVICE(0x0a5c, 0x2111), .driver_info = HCI_RESET },
123
121 /* Microsoft Wireless Transceiver for Bluetooth 2.0 */ 124 /* Microsoft Wireless Transceiver for Bluetooth 2.0 */
122 { USB_DEVICE(0x045e, 0x009c), .driver_info = HCI_RESET }, 125 { USB_DEVICE(0x045e, 0x009c), .driver_info = HCI_RESET },
123 126
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 0e6f35fcc2eb..2af12fc45115 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -409,14 +409,6 @@ config SGI_MBCS
409 If you have an SGI Altix with an attached SABrick 409 If you have an SGI Altix with an attached SABrick
410 say Y or M here, otherwise say N. 410 say Y or M here, otherwise say N.
411 411
412config MSPEC
413 tristate "Memory special operations driver"
414 depends on IA64
415 help
416 If you have an ia64 and you want to enable memory special
417 operations support (formerly known as fetchop), say Y here,
418 otherwise say N.
419
420source "drivers/serial/Kconfig" 412source "drivers/serial/Kconfig"
421 413
422config UNIX98_PTYS 414config UNIX98_PTYS
@@ -1046,7 +1038,7 @@ source "drivers/char/tpm/Kconfig"
1046 1038
1047config TELCLOCK 1039config TELCLOCK
1048 tristate "Telecom clock driver for MPBL0010 ATCA SBC" 1040 tristate "Telecom clock driver for MPBL0010 ATCA SBC"
1049 depends on EXPERIMENTAL 1041 depends on EXPERIMENTAL && X86
1050 default n 1042 default n
1051 help 1043 help
1052 The telecom clock device is specific to the MPBL0010 ATCA computer and 1044 The telecom clock device is specific to the MPBL0010 ATCA computer and
diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c
index 91b71e750ee1..dffc19382f7e 100644
--- a/drivers/char/agp/uninorth-agp.c
+++ b/drivers/char/agp/uninorth-agp.c
@@ -27,32 +27,42 @@
27static int uninorth_rev; 27static int uninorth_rev;
28static int is_u3; 28static int is_u3;
29 29
30static char __devinitdata *aperture = NULL;
30 31
31static int uninorth_fetch_size(void) 32static int uninorth_fetch_size(void)
32{ 33{
33 int i; 34 int i, size = 0;
34 u32 temp; 35 struct aper_size_info_32 *values =
35 struct aper_size_info_32 *values; 36 A_SIZE_32(agp_bridge->driver->aperture_sizes);
36 37
37 pci_read_config_dword(agp_bridge->dev, UNI_N_CFG_GART_BASE, &temp); 38 if (aperture) {
38 temp &= ~(0xfffff000); 39 char *save = aperture;
39 values = A_SIZE_32(agp_bridge->driver->aperture_sizes); 40
40 41 size = memparse(aperture, &aperture) >> 20;
41 for (i = 0; i < agp_bridge->driver->num_aperture_sizes; i++) { 42 aperture = save;
42 if (temp == values[i].size_value) { 43
43 agp_bridge->previous_size = 44 for (i = 0; i < agp_bridge->driver->num_aperture_sizes; i++)
44 agp_bridge->current_size = (void *) (values + i); 45 if (size == values[i].size)
45 agp_bridge->aperture_size_idx = i; 46 break;
46 return values[i].size; 47
48 if (i == agp_bridge->driver->num_aperture_sizes) {
49 printk(KERN_ERR PFX "Invalid aperture size, using"
50 " default\n");
51 size = 0;
52 aperture = NULL;
47 } 53 }
48 } 54 }
49 55
50 agp_bridge->previous_size = 56 if (!size) {
51 agp_bridge->current_size = (void *) (values + 1); 57 for (i = 0; i < agp_bridge->driver->num_aperture_sizes; i++)
52 agp_bridge->aperture_size_idx = 1; 58 if (values[i].size == 32)
53 return values[1].size; 59 break;
60 }
54 61
55 return 0; 62 agp_bridge->previous_size =
63 agp_bridge->current_size = (void *)(values + i);
64 agp_bridge->aperture_size_idx = i;
65 return values[i].size;
56} 66}
57 67
58static void uninorth_tlbflush(struct agp_memory *mem) 68static void uninorth_tlbflush(struct agp_memory *mem)
@@ -683,5 +693,11 @@ static void __exit agp_uninorth_cleanup(void)
683module_init(agp_uninorth_init); 693module_init(agp_uninorth_init);
684module_exit(agp_uninorth_cleanup); 694module_exit(agp_uninorth_cleanup);
685 695
696module_param(aperture, charp, 0);
697MODULE_PARM_DESC(aperture,
698 "Aperture size, must be power of two between 4MB and an\n"
699 "\t\tupper limit specific to the UniNorth revision.\n"
700 "\t\tDefault: 32M");
701
686MODULE_AUTHOR("Ben Herrenschmidt & Paul Mackerras"); 702MODULE_AUTHOR("Ben Herrenschmidt & Paul Mackerras");
687MODULE_LICENSE("GPL"); 703MODULE_LICENSE("GPL");
diff --git a/drivers/char/drm/drm_bufs.c b/drivers/char/drm/drm_bufs.c
index 029baea33b62..6eafff13dab6 100644
--- a/drivers/char/drm/drm_bufs.c
+++ b/drivers/char/drm/drm_bufs.c
@@ -237,6 +237,8 @@ static int drm_addmap_core(drm_device_t * dev, unsigned int offset,
237 237
238 list = drm_alloc(sizeof(*list), DRM_MEM_MAPS); 238 list = drm_alloc(sizeof(*list), DRM_MEM_MAPS);
239 if (!list) { 239 if (!list) {
240 if (map->type == _DRM_REGISTERS)
241 drm_ioremapfree(map->handle, map->size, dev);
240 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 242 drm_free(map, sizeof(*map), DRM_MEM_MAPS);
241 return -EINVAL; 243 return -EINVAL;
242 } 244 }
@@ -252,6 +254,8 @@ static int drm_addmap_core(drm_device_t * dev, unsigned int offset,
252 map->offset; 254 map->offset;
253 ret = drm_map_handle(dev, &list->hash, user_token, 0); 255 ret = drm_map_handle(dev, &list->hash, user_token, 0);
254 if (ret) { 256 if (ret) {
257 if (map->type == _DRM_REGISTERS)
258 drm_ioremapfree(map->handle, map->size, dev);
255 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 259 drm_free(map, sizeof(*map), DRM_MEM_MAPS);
256 drm_free(list, sizeof(*list), DRM_MEM_MAPS); 260 drm_free(list, sizeof(*list), DRM_MEM_MAPS);
257 mutex_unlock(&dev->struct_mutex); 261 mutex_unlock(&dev->struct_mutex);
diff --git a/drivers/char/drm/drm_sysfs.c b/drivers/char/drm/drm_sysfs.c
index 51ad98c685c3..ba4b8de83cf0 100644
--- a/drivers/char/drm/drm_sysfs.c
+++ b/drivers/char/drm/drm_sysfs.c
@@ -42,13 +42,24 @@ static CLASS_ATTR(version, S_IRUGO, version_show, NULL);
42struct class *drm_sysfs_create(struct module *owner, char *name) 42struct class *drm_sysfs_create(struct module *owner, char *name)
43{ 43{
44 struct class *class; 44 struct class *class;
45 int err;
45 46
46 class = class_create(owner, name); 47 class = class_create(owner, name);
47 if (!class) 48 if (!class) {
48 return class; 49 err = -ENOMEM;
50 goto err_out;
51 }
52
53 err = class_create_file(class, &class_attr_version);
54 if (err)
55 goto err_out_class;
49 56
50 class_create_file(class, &class_attr_version);
51 return class; 57 return class;
58
59err_out_class:
60 class_destroy(class);
61err_out:
62 return ERR_PTR(err);
52} 63}
53 64
54/** 65/**
@@ -96,20 +107,36 @@ static struct class_device_attribute class_device_attrs[] = {
96struct class_device *drm_sysfs_device_add(struct class *cs, drm_head_t *head) 107struct class_device *drm_sysfs_device_add(struct class *cs, drm_head_t *head)
97{ 108{
98 struct class_device *class_dev; 109 struct class_device *class_dev;
99 int i; 110 int i, j, err;
100 111
101 class_dev = class_device_create(cs, NULL, 112 class_dev = class_device_create(cs, NULL,
102 MKDEV(DRM_MAJOR, head->minor), 113 MKDEV(DRM_MAJOR, head->minor),
103 &(head->dev->pdev)->dev, 114 &(head->dev->pdev)->dev,
104 "card%d", head->minor); 115 "card%d", head->minor);
105 if (!class_dev) 116 if (!class_dev) {
106 return NULL; 117 err = -ENOMEM;
118 goto err_out;
119 }
107 120
108 class_set_devdata(class_dev, head); 121 class_set_devdata(class_dev, head);
109 122
110 for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) 123 for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) {
111 class_device_create_file(class_dev, &class_device_attrs[i]); 124 err = class_device_create_file(class_dev,
125 &class_device_attrs[i]);
126 if (err)
127 goto err_out_files;
128 }
129
112 return class_dev; 130 return class_dev;
131
132err_out_files:
133 if (i > 0)
134 for (j = 0; j < i; j++)
135 class_device_remove_file(class_dev,
136 &class_device_attrs[i]);
137 class_device_unregister(class_dev);
138err_out:
139 return ERR_PTR(err);
113} 140}
114 141
115/** 142/**
diff --git a/drivers/char/drm/mga_drv.c b/drivers/char/drm/mga_drv.c
index e30f556b79f1..be49dbb9ec3f 100644
--- a/drivers/char/drm/mga_drv.c
+++ b/drivers/char/drm/mga_drv.c
@@ -47,6 +47,7 @@ static struct drm_driver driver = {
47 DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | 47 DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA |
48 DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | 48 DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED |
49 DRIVER_IRQ_VBL, 49 DRIVER_IRQ_VBL,
50 .dev_priv_size = sizeof(drm_mga_buf_priv_t),
50 .load = mga_driver_load, 51 .load = mga_driver_load,
51 .unload = mga_driver_unload, 52 .unload = mga_driver_unload,
52 .lastclose = mga_driver_lastclose, 53 .lastclose = mga_driver_lastclose,
diff --git a/drivers/char/drm/r300_cmdbuf.c b/drivers/char/drm/r300_cmdbuf.c
index 26bdf2ca59d7..d14477ba3679 100644
--- a/drivers/char/drm/r300_cmdbuf.c
+++ b/drivers/char/drm/r300_cmdbuf.c
@@ -538,6 +538,36 @@ static __inline__ int r300_emit_bitblt_multi(drm_radeon_private_t *dev_priv,
538 return 0; 538 return 0;
539} 539}
540 540
541static __inline__ int r300_emit_indx_buffer(drm_radeon_private_t *dev_priv,
542 drm_radeon_kcmd_buffer_t *cmdbuf)
543{
544 u32 *cmd = (u32 *) cmdbuf->buf;
545 int count, ret;
546 RING_LOCALS;
547
548 count=(cmd[0]>>16) & 0x3fff;
549
550 if ((cmd[1] & 0x8000ffff) != 0x80000810) {
551 DRM_ERROR("Invalid indx_buffer reg address %08X\n", cmd[1]);
552 return DRM_ERR(EINVAL);
553 }
554 ret = r300_check_offset(dev_priv, cmd[2]);
555 if (ret) {
556 DRM_ERROR("Invalid indx_buffer offset is %08X\n", cmd[2]);
557 return DRM_ERR(EINVAL);
558 }
559
560 BEGIN_RING(count+2);
561 OUT_RING(cmd[0]);
562 OUT_RING_TABLE((int *)(cmdbuf->buf + 4), count + 1);
563 ADVANCE_RING();
564
565 cmdbuf->buf += (count+2)*4;
566 cmdbuf->bufsz -= (count+2)*4;
567
568 return 0;
569}
570
541static __inline__ int r300_emit_raw_packet3(drm_radeon_private_t *dev_priv, 571static __inline__ int r300_emit_raw_packet3(drm_radeon_private_t *dev_priv,
542 drm_radeon_kcmd_buffer_t *cmdbuf) 572 drm_radeon_kcmd_buffer_t *cmdbuf)
543{ 573{
@@ -578,10 +608,11 @@ static __inline__ int r300_emit_raw_packet3(drm_radeon_private_t *dev_priv,
578 case RADEON_CNTL_BITBLT_MULTI: 608 case RADEON_CNTL_BITBLT_MULTI:
579 return r300_emit_bitblt_multi(dev_priv, cmdbuf); 609 return r300_emit_bitblt_multi(dev_priv, cmdbuf);
580 610
611 case RADEON_CP_INDX_BUFFER: /* DRAW_INDX_2 without INDX_BUFFER seems to lock up the gpu */
612 return r300_emit_indx_buffer(dev_priv, cmdbuf);
581 case RADEON_CP_3D_DRAW_IMMD_2: /* triggers drawing using in-packet vertex data */ 613 case RADEON_CP_3D_DRAW_IMMD_2: /* triggers drawing using in-packet vertex data */
582 case RADEON_CP_3D_DRAW_VBUF_2: /* triggers drawing of vertex buffers setup elsewhere */ 614 case RADEON_CP_3D_DRAW_VBUF_2: /* triggers drawing of vertex buffers setup elsewhere */
583 case RADEON_CP_3D_DRAW_INDX_2: /* triggers drawing using indices to vertex buffer */ 615 case RADEON_CP_3D_DRAW_INDX_2: /* triggers drawing using indices to vertex buffer */
584 case RADEON_CP_INDX_BUFFER: /* DRAW_INDX_2 without INDX_BUFFER seems to lock up the gpu */
585 case RADEON_WAIT_FOR_IDLE: 616 case RADEON_WAIT_FOR_IDLE:
586 case RADEON_CP_NOP: 617 case RADEON_CP_NOP:
587 /* these packets are safe */ 618 /* these packets are safe */
diff --git a/drivers/char/drm/radeon_state.c b/drivers/char/drm/radeon_state.c
index feac5f005d47..6e04fdd732ac 100644
--- a/drivers/char/drm/radeon_state.c
+++ b/drivers/char/drm/radeon_state.c
@@ -275,6 +275,8 @@ static __inline__ int radeon_check_and_fixup_packet3(drm_radeon_private_t *
275 unsigned int *cmdsz) 275 unsigned int *cmdsz)
276{ 276{
277 u32 *cmd = (u32 *) cmdbuf->buf; 277 u32 *cmd = (u32 *) cmdbuf->buf;
278 u32 offset, narrays;
279 int count, i, k;
278 280
279 *cmdsz = 2 + ((cmd[0] & RADEON_CP_PACKET_COUNT_MASK) >> 16); 281 *cmdsz = 2 + ((cmd[0] & RADEON_CP_PACKET_COUNT_MASK) >> 16);
280 282
@@ -288,10 +290,106 @@ static __inline__ int radeon_check_and_fixup_packet3(drm_radeon_private_t *
288 return DRM_ERR(EINVAL); 290 return DRM_ERR(EINVAL);
289 } 291 }
290 292
291 /* Check client state and fix it up if necessary */ 293 switch(cmd[0] & 0xff00) {
292 if (cmd[0] & 0x8000) { /* MSB of opcode: next DWORD GUI_CNTL */ 294 /* XXX Are there old drivers needing other packets? */
293 u32 offset;
294 295
296 case RADEON_3D_DRAW_IMMD:
297 case RADEON_3D_DRAW_VBUF:
298 case RADEON_3D_DRAW_INDX:
299 case RADEON_WAIT_FOR_IDLE:
300 case RADEON_CP_NOP:
301 case RADEON_3D_CLEAR_ZMASK:
302/* case RADEON_CP_NEXT_CHAR:
303 case RADEON_CP_PLY_NEXTSCAN:
304 case RADEON_CP_SET_SCISSORS: */ /* probably safe but will never need them? */
305 /* these packets are safe */
306 break;
307
308 case RADEON_CP_3D_DRAW_IMMD_2:
309 case RADEON_CP_3D_DRAW_VBUF_2:
310 case RADEON_CP_3D_DRAW_INDX_2:
311 case RADEON_3D_CLEAR_HIZ:
312 /* safe but r200 only */
313 if (dev_priv->microcode_version != UCODE_R200) {
314 DRM_ERROR("Invalid 3d packet for r100-class chip\n");
315 return DRM_ERR(EINVAL);
316 }
317 break;
318
319 case RADEON_3D_LOAD_VBPNTR:
320 count = (cmd[0] >> 16) & 0x3fff;
321
322 if (count > 18) { /* 12 arrays max */
323 DRM_ERROR("Too large payload in 3D_LOAD_VBPNTR (count=%d)\n",
324 count);
325 return DRM_ERR(EINVAL);
326 }
327
328 /* carefully check packet contents */
329 narrays = cmd[1] & ~0xc000;
330 k = 0;
331 i = 2;
332 while ((k < narrays) && (i < (count + 2))) {
333 i++; /* skip attribute field */
334 if (radeon_check_and_fixup_offset(dev_priv, filp_priv, &cmd[i])) {
335 DRM_ERROR
336 ("Invalid offset (k=%d i=%d) in 3D_LOAD_VBPNTR packet.\n",
337 k, i);
338 return DRM_ERR(EINVAL);
339 }
340 k++;
341 i++;
342 if (k == narrays)
343 break;
344 /* have one more to process, they come in pairs */
345 if (radeon_check_and_fixup_offset(dev_priv, filp_priv, &cmd[i])) {
346 DRM_ERROR
347 ("Invalid offset (k=%d i=%d) in 3D_LOAD_VBPNTR packet.\n",
348 k, i);
349 return DRM_ERR(EINVAL);
350 }
351 k++;
352 i++;
353 }
354 /* do the counts match what we expect ? */
355 if ((k != narrays) || (i != (count + 2))) {
356 DRM_ERROR
357 ("Malformed 3D_LOAD_VBPNTR packet (k=%d i=%d narrays=%d count+1=%d).\n",
358 k, i, narrays, count + 1);
359 return DRM_ERR(EINVAL);
360 }
361 break;
362
363 case RADEON_3D_RNDR_GEN_INDX_PRIM:
364 if (dev_priv->microcode_version != UCODE_R100) {
365 DRM_ERROR("Invalid 3d packet for r200-class chip\n");
366 return DRM_ERR(EINVAL);
367 }
368 if (radeon_check_and_fixup_offset(dev_priv, filp_priv, &cmd[1])) {
369 DRM_ERROR("Invalid rndr_gen_indx offset\n");
370 return DRM_ERR(EINVAL);
371 }
372 break;
373
374 case RADEON_CP_INDX_BUFFER:
375 if (dev_priv->microcode_version != UCODE_R200) {
376 DRM_ERROR("Invalid 3d packet for r100-class chip\n");
377 return DRM_ERR(EINVAL);
378 }
379 if ((cmd[1] & 0x8000ffff) != 0x80000810) {
380 DRM_ERROR("Invalid indx_buffer reg address %08X\n", cmd[1]);
381 return DRM_ERR(EINVAL);
382 }
383 if (radeon_check_and_fixup_offset(dev_priv, filp_priv, &cmd[2])) {
384 DRM_ERROR("Invalid indx_buffer offset is %08X\n", cmd[2]);
385 return DRM_ERR(EINVAL);
386 }
387 break;
388
389 case RADEON_CNTL_HOSTDATA_BLT:
390 case RADEON_CNTL_PAINT_MULTI:
391 case RADEON_CNTL_BITBLT_MULTI:
392 /* MSB of opcode: next DWORD GUI_CNTL */
295 if (cmd[1] & (RADEON_GMC_SRC_PITCH_OFFSET_CNTL 393 if (cmd[1] & (RADEON_GMC_SRC_PITCH_OFFSET_CNTL
296 | RADEON_GMC_DST_PITCH_OFFSET_CNTL)) { 394 | RADEON_GMC_DST_PITCH_OFFSET_CNTL)) {
297 offset = cmd[2] << 10; 395 offset = cmd[2] << 10;
@@ -313,6 +411,11 @@ static __inline__ int radeon_check_and_fixup_packet3(drm_radeon_private_t *
313 } 411 }
314 cmd[3] = (cmd[3] & 0xffc00000) | offset >> 10; 412 cmd[3] = (cmd[3] & 0xffc00000) | offset >> 10;
315 } 413 }
414 break;
415
416 default:
417 DRM_ERROR("Invalid packet type %x\n", cmd[0] & 0xff00);
418 return DRM_ERR(EINVAL);
316 } 419 }
317 420
318 return 0; 421 return 0;
diff --git a/drivers/char/drm/savage_bci.c b/drivers/char/drm/savage_bci.c
index 59c7520bf9a2..a9a84f88df5e 100644
--- a/drivers/char/drm/savage_bci.c
+++ b/drivers/char/drm/savage_bci.c
@@ -728,6 +728,7 @@ static int savage_do_init_bci(drm_device_t * dev, drm_savage_init_t * init)
728 dev_priv->status = NULL; 728 dev_priv->status = NULL;
729 } 729 }
730 if (dev_priv->dma_type == SAVAGE_DMA_AGP && init->buffers_offset) { 730 if (dev_priv->dma_type == SAVAGE_DMA_AGP && init->buffers_offset) {
731 dev->agp_buffer_token = init->buffers_offset;
731 dev->agp_buffer_map = drm_core_findmap(dev, 732 dev->agp_buffer_map = drm_core_findmap(dev,
732 init->buffers_offset); 733 init->buffers_offset);
733 if (!dev->agp_buffer_map) { 734 if (!dev->agp_buffer_map) {
diff --git a/drivers/char/drm/savage_state.c b/drivers/char/drm/savage_state.c
index ef2581d16146..1ca1e9cb5a33 100644
--- a/drivers/char/drm/savage_state.c
+++ b/drivers/char/drm/savage_state.c
@@ -994,7 +994,7 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS)
994 if (cmdbuf.size) { 994 if (cmdbuf.size) {
995 kcmd_addr = drm_alloc(cmdbuf.size * 8, DRM_MEM_DRIVER); 995 kcmd_addr = drm_alloc(cmdbuf.size * 8, DRM_MEM_DRIVER);
996 if (kcmd_addr == NULL) 996 if (kcmd_addr == NULL)
997 return ENOMEM; 997 return DRM_ERR(ENOMEM);
998 998
999 if (DRM_COPY_FROM_USER(kcmd_addr, cmdbuf.cmd_addr, 999 if (DRM_COPY_FROM_USER(kcmd_addr, cmdbuf.cmd_addr,
1000 cmdbuf.size * 8)) 1000 cmdbuf.size * 8))
diff --git a/drivers/char/epca.c b/drivers/char/epca.c
index c3f95583a120..706733c0b36a 100644
--- a/drivers/char/epca.c
+++ b/drivers/char/epca.c
@@ -1157,6 +1157,7 @@ static int __init pc_init(void)
1157 int crd; 1157 int crd;
1158 struct board_info *bd; 1158 struct board_info *bd;
1159 unsigned char board_id = 0; 1159 unsigned char board_id = 0;
1160 int err = -ENOMEM;
1160 1161
1161 int pci_boards_found, pci_count; 1162 int pci_boards_found, pci_count;
1162 1163
@@ -1164,13 +1165,11 @@ static int __init pc_init(void)
1164 1165
1165 pc_driver = alloc_tty_driver(MAX_ALLOC); 1166 pc_driver = alloc_tty_driver(MAX_ALLOC);
1166 if (!pc_driver) 1167 if (!pc_driver)
1167 return -ENOMEM; 1168 goto out1;
1168 1169
1169 pc_info = alloc_tty_driver(MAX_ALLOC); 1170 pc_info = alloc_tty_driver(MAX_ALLOC);
1170 if (!pc_info) { 1171 if (!pc_info)
1171 put_tty_driver(pc_driver); 1172 goto out2;
1172 return -ENOMEM;
1173 }
1174 1173
1175 /* ----------------------------------------------------------------------- 1174 /* -----------------------------------------------------------------------
1176 If epca_setup has not been ran by LILO set num_cards to defaults; copy 1175 If epca_setup has not been ran by LILO set num_cards to defaults; copy
@@ -1370,11 +1369,17 @@ static int __init pc_init(void)
1370 1369
1371 } /* End for each card */ 1370 } /* End for each card */
1372 1371
1373 if (tty_register_driver(pc_driver)) 1372 err = tty_register_driver(pc_driver);
1374 panic("Couldn't register Digi PC/ driver"); 1373 if (err) {
1374 printk(KERN_ERR "Couldn't register Digi PC/ driver");
1375 goto out3;
1376 }
1375 1377
1376 if (tty_register_driver(pc_info)) 1378 err = tty_register_driver(pc_info);
1377 panic("Couldn't register Digi PC/ info "); 1379 if (err) {
1380 printk(KERN_ERR "Couldn't register Digi PC/ info ");
1381 goto out4;
1382 }
1378 1383
1379 /* ------------------------------------------------------------------- 1384 /* -------------------------------------------------------------------
1380 Start up the poller to check for events on all enabled boards 1385 Start up the poller to check for events on all enabled boards
@@ -1385,6 +1390,15 @@ static int __init pc_init(void)
1385 mod_timer(&epca_timer, jiffies + HZ/25); 1390 mod_timer(&epca_timer, jiffies + HZ/25);
1386 return 0; 1391 return 0;
1387 1392
1393out4:
1394 tty_unregister_driver(pc_driver);
1395out3:
1396 put_tty_driver(pc_info);
1397out2:
1398 put_tty_driver(pc_driver);
1399out1:
1400 return err;
1401
1388} /* End pc_init */ 1402} /* End pc_init */
1389 1403
1390/* ------------------ Begin post_fep_init ---------------------- */ 1404/* ------------------ Begin post_fep_init ---------------------- */
diff --git a/drivers/char/ftape/zftape/zftape-buffers.c b/drivers/char/ftape/zftape/zftape-buffers.c
index da06f138334e..7ebce2ec7897 100644
--- a/drivers/char/ftape/zftape/zftape-buffers.c
+++ b/drivers/char/ftape/zftape/zftape-buffers.c
@@ -85,7 +85,7 @@ int zft_vmalloc_once(void *new, size_t size)
85 peak_memory = used_memory; 85 peak_memory = used_memory;
86 } 86 }
87 TRACE_ABORT(0, ft_t_noise, 87 TRACE_ABORT(0, ft_t_noise,
88 "allocated buffer @ %p, %d bytes", *(void **)new, size); 88 "allocated buffer @ %p, %zd bytes", *(void **)new, size);
89} 89}
90int zft_vmalloc_always(void *new, size_t size) 90int zft_vmalloc_always(void *new, size_t size)
91{ 91{
@@ -101,7 +101,7 @@ void zft_vfree(void *old, size_t size)
101 if (*(void **)old) { 101 if (*(void **)old) {
102 vfree(*(void **)old); 102 vfree(*(void **)old);
103 used_memory -= size; 103 used_memory -= size;
104 TRACE(ft_t_noise, "released buffer @ %p, %d bytes", 104 TRACE(ft_t_noise, "released buffer @ %p, %zd bytes",
105 *(void **)old, size); 105 *(void **)old, size);
106 *(void **)old = NULL; 106 *(void **)old = NULL;
107 } 107 }
diff --git a/drivers/char/ip2/i2lib.c b/drivers/char/ip2/i2lib.c
index fc944d375be7..54d93f0345e8 100644
--- a/drivers/char/ip2/i2lib.c
+++ b/drivers/char/ip2/i2lib.c
@@ -1007,7 +1007,7 @@ i2InputAvailable(i2ChanStrPtr pCh)
1007// applications that one cannot break out of. 1007// applications that one cannot break out of.
1008//****************************************************************************** 1008//******************************************************************************
1009static int 1009static int
1010i2Output(i2ChanStrPtr pCh, const char *pSource, int count, int user ) 1010i2Output(i2ChanStrPtr pCh, const char *pSource, int count)
1011{ 1011{
1012 i2eBordStrPtr pB; 1012 i2eBordStrPtr pB;
1013 unsigned char *pInsert; 1013 unsigned char *pInsert;
@@ -1020,7 +1020,7 @@ i2Output(i2ChanStrPtr pCh, const char *pSource, int count, int user )
1020 1020
1021 int bailout = 10; 1021 int bailout = 10;
1022 1022
1023 ip2trace (CHANN, ITRC_OUTPUT, ITRC_ENTER, 2, count, user ); 1023 ip2trace (CHANN, ITRC_OUTPUT, ITRC_ENTER, 2, count, 0 );
1024 1024
1025 // Ensure channel structure seems real 1025 // Ensure channel structure seems real
1026 if ( !i2Validate ( pCh ) ) 1026 if ( !i2Validate ( pCh ) )
@@ -1087,12 +1087,7 @@ i2Output(i2ChanStrPtr pCh, const char *pSource, int count, int user )
1087 DATA_COUNT_OF(pInsert) = amountToMove; 1087 DATA_COUNT_OF(pInsert) = amountToMove;
1088 1088
1089 // Move the data 1089 // Move the data
1090 if ( user ) { 1090 memcpy( (char*)(DATA_OF(pInsert)), pSource, amountToMove );
1091 rc = copy_from_user((char*)(DATA_OF(pInsert)), pSource,
1092 amountToMove );
1093 } else {
1094 memcpy( (char*)(DATA_OF(pInsert)), pSource, amountToMove );
1095 }
1096 // Adjust pointers and indices 1091 // Adjust pointers and indices
1097 pSource += amountToMove; 1092 pSource += amountToMove;
1098 pCh->Obuf_char_count += amountToMove; 1093 pCh->Obuf_char_count += amountToMove;
diff --git a/drivers/char/ip2/i2lib.h b/drivers/char/ip2/i2lib.h
index 952e113ccd8a..e559e9bac06d 100644
--- a/drivers/char/ip2/i2lib.h
+++ b/drivers/char/ip2/i2lib.h
@@ -332,7 +332,7 @@ static int i2QueueCommands(int, i2ChanStrPtr, int, int, cmdSyntaxPtr,...);
332static int i2GetStatus(i2ChanStrPtr, int); 332static int i2GetStatus(i2ChanStrPtr, int);
333static int i2Input(i2ChanStrPtr); 333static int i2Input(i2ChanStrPtr);
334static int i2InputFlush(i2ChanStrPtr); 334static int i2InputFlush(i2ChanStrPtr);
335static int i2Output(i2ChanStrPtr, const char *, int, int); 335static int i2Output(i2ChanStrPtr, const char *, int);
336static int i2OutputFree(i2ChanStrPtr); 336static int i2OutputFree(i2ChanStrPtr);
337static int i2ServiceBoard(i2eBordStrPtr); 337static int i2ServiceBoard(i2eBordStrPtr);
338static void i2DrainOutput(i2ChanStrPtr, int); 338static void i2DrainOutput(i2ChanStrPtr, int);
diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c
index 858ba5432c99..a3f32d46d2f8 100644
--- a/drivers/char/ip2/ip2main.c
+++ b/drivers/char/ip2/ip2main.c
@@ -1704,7 +1704,7 @@ ip2_write( PTTY tty, const unsigned char *pData, int count)
1704 1704
1705 /* This is the actual move bit. Make sure it does what we need!!!!! */ 1705 /* This is the actual move bit. Make sure it does what we need!!!!! */
1706 WRITE_LOCK_IRQSAVE(&pCh->Pbuf_spinlock,flags); 1706 WRITE_LOCK_IRQSAVE(&pCh->Pbuf_spinlock,flags);
1707 bytesSent = i2Output( pCh, pData, count, 0 ); 1707 bytesSent = i2Output( pCh, pData, count);
1708 WRITE_UNLOCK_IRQRESTORE(&pCh->Pbuf_spinlock,flags); 1708 WRITE_UNLOCK_IRQRESTORE(&pCh->Pbuf_spinlock,flags);
1709 1709
1710 ip2trace (CHANN, ITRC_WRITE, ITRC_RETURN, 1, bytesSent ); 1710 ip2trace (CHANN, ITRC_WRITE, ITRC_RETURN, 1, bytesSent );
@@ -1764,7 +1764,7 @@ ip2_flush_chars( PTTY tty )
1764 // 1764 //
1765 // We may need to restart i2Output if it does not fullfill this request 1765 // We may need to restart i2Output if it does not fullfill this request
1766 // 1766 //
1767 strip = i2Output( pCh, pCh->Pbuf, pCh->Pbuf_stuff, 0 ); 1767 strip = i2Output( pCh, pCh->Pbuf, pCh->Pbuf_stuff);
1768 if ( strip != pCh->Pbuf_stuff ) { 1768 if ( strip != pCh->Pbuf_stuff ) {
1769 memmove( pCh->Pbuf, &pCh->Pbuf[strip], pCh->Pbuf_stuff - strip ); 1769 memmove( pCh->Pbuf, &pCh->Pbuf[strip], pCh->Pbuf_stuff - strip );
1770 } 1770 }
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 2455e8d478ac..c47add8e47df 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -376,13 +376,23 @@ static void free_recv_msg_list(struct list_head *q)
376 } 376 }
377} 377}
378 378
379static void free_smi_msg_list(struct list_head *q)
380{
381 struct ipmi_smi_msg *msg, *msg2;
382
383 list_for_each_entry_safe(msg, msg2, q, link) {
384 list_del(&msg->link);
385 ipmi_free_smi_msg(msg);
386 }
387}
388
379static void clean_up_interface_data(ipmi_smi_t intf) 389static void clean_up_interface_data(ipmi_smi_t intf)
380{ 390{
381 int i; 391 int i;
382 struct cmd_rcvr *rcvr, *rcvr2; 392 struct cmd_rcvr *rcvr, *rcvr2;
383 struct list_head list; 393 struct list_head list;
384 394
385 free_recv_msg_list(&intf->waiting_msgs); 395 free_smi_msg_list(&intf->waiting_msgs);
386 free_recv_msg_list(&intf->waiting_events); 396 free_recv_msg_list(&intf->waiting_events);
387 397
388 /* Wholesale remove all the entries from the list in the 398 /* Wholesale remove all the entries from the list in the
@@ -1844,7 +1854,7 @@ static ssize_t provides_dev_sdrs_show(struct device *dev,
1844 struct bmc_device *bmc = dev_get_drvdata(dev); 1854 struct bmc_device *bmc = dev_get_drvdata(dev);
1845 1855
1846 return snprintf(buf, 10, "%u\n", 1856 return snprintf(buf, 10, "%u\n",
1847 bmc->id.device_revision && 0x80 >> 7); 1857 (bmc->id.device_revision & 0x80) >> 7);
1848} 1858}
1849 1859
1850static ssize_t revision_show(struct device *dev, struct device_attribute *attr, 1860static ssize_t revision_show(struct device *dev, struct device_attribute *attr,
@@ -1853,7 +1863,7 @@ static ssize_t revision_show(struct device *dev, struct device_attribute *attr,
1853 struct bmc_device *bmc = dev_get_drvdata(dev); 1863 struct bmc_device *bmc = dev_get_drvdata(dev);
1854 1864
1855 return snprintf(buf, 20, "%u\n", 1865 return snprintf(buf, 20, "%u\n",
1856 bmc->id.device_revision && 0x0F); 1866 bmc->id.device_revision & 0x0F);
1857} 1867}
1858 1868
1859static ssize_t firmware_rev_show(struct device *dev, 1869static ssize_t firmware_rev_show(struct device *dev,
@@ -1928,13 +1938,8 @@ static ssize_t guid_show(struct device *dev, struct device_attribute *attr,
1928 (long long) bmc->guid[8]); 1938 (long long) bmc->guid[8]);
1929} 1939}
1930 1940
1931static void 1941static void remove_files(struct bmc_device *bmc)
1932cleanup_bmc_device(struct kref *ref)
1933{ 1942{
1934 struct bmc_device *bmc;
1935
1936 bmc = container_of(ref, struct bmc_device, refcount);
1937
1938 device_remove_file(&bmc->dev->dev, 1943 device_remove_file(&bmc->dev->dev,
1939 &bmc->device_id_attr); 1944 &bmc->device_id_attr);
1940 device_remove_file(&bmc->dev->dev, 1945 device_remove_file(&bmc->dev->dev,
@@ -1951,12 +1956,23 @@ cleanup_bmc_device(struct kref *ref)
1951 &bmc->manufacturer_id_attr); 1956 &bmc->manufacturer_id_attr);
1952 device_remove_file(&bmc->dev->dev, 1957 device_remove_file(&bmc->dev->dev,
1953 &bmc->product_id_attr); 1958 &bmc->product_id_attr);
1959
1954 if (bmc->id.aux_firmware_revision_set) 1960 if (bmc->id.aux_firmware_revision_set)
1955 device_remove_file(&bmc->dev->dev, 1961 device_remove_file(&bmc->dev->dev,
1956 &bmc->aux_firmware_rev_attr); 1962 &bmc->aux_firmware_rev_attr);
1957 if (bmc->guid_set) 1963 if (bmc->guid_set)
1958 device_remove_file(&bmc->dev->dev, 1964 device_remove_file(&bmc->dev->dev,
1959 &bmc->guid_attr); 1965 &bmc->guid_attr);
1966}
1967
1968static void
1969cleanup_bmc_device(struct kref *ref)
1970{
1971 struct bmc_device *bmc;
1972
1973 bmc = container_of(ref, struct bmc_device, refcount);
1974
1975 remove_files(bmc);
1960 platform_device_unregister(bmc->dev); 1976 platform_device_unregister(bmc->dev);
1961 kfree(bmc); 1977 kfree(bmc);
1962} 1978}
@@ -1977,6 +1993,79 @@ static void ipmi_bmc_unregister(ipmi_smi_t intf)
1977 mutex_unlock(&ipmidriver_mutex); 1993 mutex_unlock(&ipmidriver_mutex);
1978} 1994}
1979 1995
1996static int create_files(struct bmc_device *bmc)
1997{
1998 int err;
1999
2000 err = device_create_file(&bmc->dev->dev,
2001 &bmc->device_id_attr);
2002 if (err) goto out;
2003 err = device_create_file(&bmc->dev->dev,
2004 &bmc->provides_dev_sdrs_attr);
2005 if (err) goto out_devid;
2006 err = device_create_file(&bmc->dev->dev,
2007 &bmc->revision_attr);
2008 if (err) goto out_sdrs;
2009 err = device_create_file(&bmc->dev->dev,
2010 &bmc->firmware_rev_attr);
2011 if (err) goto out_rev;
2012 err = device_create_file(&bmc->dev->dev,
2013 &bmc->version_attr);
2014 if (err) goto out_firm;
2015 err = device_create_file(&bmc->dev->dev,
2016 &bmc->add_dev_support_attr);
2017 if (err) goto out_version;
2018 err = device_create_file(&bmc->dev->dev,
2019 &bmc->manufacturer_id_attr);
2020 if (err) goto out_add_dev;
2021 err = device_create_file(&bmc->dev->dev,
2022 &bmc->product_id_attr);
2023 if (err) goto out_manu;
2024 if (bmc->id.aux_firmware_revision_set) {
2025 err = device_create_file(&bmc->dev->dev,
2026 &bmc->aux_firmware_rev_attr);
2027 if (err) goto out_prod_id;
2028 }
2029 if (bmc->guid_set) {
2030 err = device_create_file(&bmc->dev->dev,
2031 &bmc->guid_attr);
2032 if (err) goto out_aux_firm;
2033 }
2034
2035 return 0;
2036
2037out_aux_firm:
2038 if (bmc->id.aux_firmware_revision_set)
2039 device_remove_file(&bmc->dev->dev,
2040 &bmc->aux_firmware_rev_attr);
2041out_prod_id:
2042 device_remove_file(&bmc->dev->dev,
2043 &bmc->product_id_attr);
2044out_manu:
2045 device_remove_file(&bmc->dev->dev,
2046 &bmc->manufacturer_id_attr);
2047out_add_dev:
2048 device_remove_file(&bmc->dev->dev,
2049 &bmc->add_dev_support_attr);
2050out_version:
2051 device_remove_file(&bmc->dev->dev,
2052 &bmc->version_attr);
2053out_firm:
2054 device_remove_file(&bmc->dev->dev,
2055 &bmc->firmware_rev_attr);
2056out_rev:
2057 device_remove_file(&bmc->dev->dev,
2058 &bmc->revision_attr);
2059out_sdrs:
2060 device_remove_file(&bmc->dev->dev,
2061 &bmc->provides_dev_sdrs_attr);
2062out_devid:
2063 device_remove_file(&bmc->dev->dev,
2064 &bmc->device_id_attr);
2065out:
2066 return err;
2067}
2068
1980static int ipmi_bmc_register(ipmi_smi_t intf) 2069static int ipmi_bmc_register(ipmi_smi_t intf)
1981{ 2070{
1982 int rv; 2071 int rv;
@@ -2029,7 +2118,7 @@ static int ipmi_bmc_register(ipmi_smi_t intf)
2029 dev_set_drvdata(&bmc->dev->dev, bmc); 2118 dev_set_drvdata(&bmc->dev->dev, bmc);
2030 kref_init(&bmc->refcount); 2119 kref_init(&bmc->refcount);
2031 2120
2032 rv = platform_device_register(bmc->dev); 2121 rv = platform_device_add(bmc->dev);
2033 mutex_unlock(&ipmidriver_mutex); 2122 mutex_unlock(&ipmidriver_mutex);
2034 if (rv) { 2123 if (rv) {
2035 printk(KERN_ERR 2124 printk(KERN_ERR
@@ -2051,7 +2140,6 @@ static int ipmi_bmc_register(ipmi_smi_t intf)
2051 bmc->provides_dev_sdrs_attr.attr.mode = S_IRUGO; 2140 bmc->provides_dev_sdrs_attr.attr.mode = S_IRUGO;
2052 bmc->provides_dev_sdrs_attr.show = provides_dev_sdrs_show; 2141 bmc->provides_dev_sdrs_attr.show = provides_dev_sdrs_show;
2053 2142
2054
2055 bmc->revision_attr.attr.name = "revision"; 2143 bmc->revision_attr.attr.name = "revision";
2056 bmc->revision_attr.attr.owner = THIS_MODULE; 2144 bmc->revision_attr.attr.owner = THIS_MODULE;
2057 bmc->revision_attr.attr.mode = S_IRUGO; 2145 bmc->revision_attr.attr.mode = S_IRUGO;
@@ -2093,28 +2181,14 @@ static int ipmi_bmc_register(ipmi_smi_t intf)
2093 bmc->aux_firmware_rev_attr.attr.mode = S_IRUGO; 2181 bmc->aux_firmware_rev_attr.attr.mode = S_IRUGO;
2094 bmc->aux_firmware_rev_attr.show = aux_firmware_rev_show; 2182 bmc->aux_firmware_rev_attr.show = aux_firmware_rev_show;
2095 2183
2096 device_create_file(&bmc->dev->dev, 2184 rv = create_files(bmc);
2097 &bmc->device_id_attr); 2185 if (rv) {
2098 device_create_file(&bmc->dev->dev, 2186 mutex_lock(&ipmidriver_mutex);
2099 &bmc->provides_dev_sdrs_attr); 2187 platform_device_unregister(bmc->dev);
2100 device_create_file(&bmc->dev->dev, 2188 mutex_unlock(&ipmidriver_mutex);
2101 &bmc->revision_attr); 2189
2102 device_create_file(&bmc->dev->dev, 2190 return rv;
2103 &bmc->firmware_rev_attr); 2191 }
2104 device_create_file(&bmc->dev->dev,
2105 &bmc->version_attr);
2106 device_create_file(&bmc->dev->dev,
2107 &bmc->add_dev_support_attr);
2108 device_create_file(&bmc->dev->dev,
2109 &bmc->manufacturer_id_attr);
2110 device_create_file(&bmc->dev->dev,
2111 &bmc->product_id_attr);
2112 if (bmc->id.aux_firmware_revision_set)
2113 device_create_file(&bmc->dev->dev,
2114 &bmc->aux_firmware_rev_attr);
2115 if (bmc->guid_set)
2116 device_create_file(&bmc->dev->dev,
2117 &bmc->guid_attr);
2118 2192
2119 printk(KERN_INFO 2193 printk(KERN_INFO
2120 "ipmi: Found new BMC (man_id: 0x%6.6x, " 2194 "ipmi: Found new BMC (man_id: 0x%6.6x, "
@@ -3168,7 +3242,9 @@ void ipmi_smi_msg_received(ipmi_smi_t intf,
3168 report the error immediately. */ 3242 report the error immediately. */
3169 if ((msg->rsp_size >= 3) && (msg->rsp[2] != 0) 3243 if ((msg->rsp_size >= 3) && (msg->rsp[2] != 0)
3170 && (msg->rsp[2] != IPMI_NODE_BUSY_ERR) 3244 && (msg->rsp[2] != IPMI_NODE_BUSY_ERR)
3171 && (msg->rsp[2] != IPMI_LOST_ARBITRATION_ERR)) 3245 && (msg->rsp[2] != IPMI_LOST_ARBITRATION_ERR)
3246 && (msg->rsp[2] != IPMI_BUS_ERR)
3247 && (msg->rsp[2] != IPMI_NAK_ON_WRITE_ERR))
3172 { 3248 {
3173 int chan = msg->rsp[3] & 0xf; 3249 int chan = msg->rsp[3] & 0xf;
3174 3250
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index 24825bdca8f4..bb1fac104fda 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -1211,7 +1211,7 @@ static void intf_mem_outb(struct si_sm_io *io, unsigned int offset,
1211static unsigned char intf_mem_inw(struct si_sm_io *io, unsigned int offset) 1211static unsigned char intf_mem_inw(struct si_sm_io *io, unsigned int offset)
1212{ 1212{
1213 return (readw((io->addr)+(offset * io->regspacing)) >> io->regshift) 1213 return (readw((io->addr)+(offset * io->regspacing)) >> io->regshift)
1214 && 0xff; 1214 & 0xff;
1215} 1215}
1216 1216
1217static void intf_mem_outw(struct si_sm_io *io, unsigned int offset, 1217static void intf_mem_outw(struct si_sm_io *io, unsigned int offset,
@@ -1223,7 +1223,7 @@ static void intf_mem_outw(struct si_sm_io *io, unsigned int offset,
1223static unsigned char intf_mem_inl(struct si_sm_io *io, unsigned int offset) 1223static unsigned char intf_mem_inl(struct si_sm_io *io, unsigned int offset)
1224{ 1224{
1225 return (readl((io->addr)+(offset * io->regspacing)) >> io->regshift) 1225 return (readl((io->addr)+(offset * io->regspacing)) >> io->regshift)
1226 && 0xff; 1226 & 0xff;
1227} 1227}
1228 1228
1229static void intf_mem_outl(struct si_sm_io *io, unsigned int offset, 1229static void intf_mem_outl(struct si_sm_io *io, unsigned int offset,
@@ -1236,7 +1236,7 @@ static void intf_mem_outl(struct si_sm_io *io, unsigned int offset,
1236static unsigned char mem_inq(struct si_sm_io *io, unsigned int offset) 1236static unsigned char mem_inq(struct si_sm_io *io, unsigned int offset)
1237{ 1237{
1238 return (readq((io->addr)+(offset * io->regspacing)) >> io->regshift) 1238 return (readq((io->addr)+(offset * io->regspacing)) >> io->regshift)
1239 && 0xff; 1239 & 0xff;
1240} 1240}
1241 1241
1242static void mem_outq(struct si_sm_io *io, unsigned int offset, 1242static void mem_outq(struct si_sm_io *io, unsigned int offset,
@@ -1789,7 +1789,7 @@ static int __devinit ipmi_pci_probe(struct pci_dev *pdev,
1789 1789
1790 info = kzalloc(sizeof(*info), GFP_KERNEL); 1790 info = kzalloc(sizeof(*info), GFP_KERNEL);
1791 if (!info) 1791 if (!info)
1792 return ENOMEM; 1792 return -ENOMEM;
1793 1793
1794 info->addr_source = "PCI"; 1794 info->addr_source = "PCI";
1795 1795
@@ -1810,7 +1810,7 @@ static int __devinit ipmi_pci_probe(struct pci_dev *pdev,
1810 kfree(info); 1810 kfree(info);
1811 printk(KERN_INFO "ipmi_si: %s: Unknown IPMI type: %d\n", 1811 printk(KERN_INFO "ipmi_si: %s: Unknown IPMI type: %d\n",
1812 pci_name(pdev), class_type); 1812 pci_name(pdev), class_type);
1813 return ENOMEM; 1813 return -ENOMEM;
1814 } 1814 }
1815 1815
1816 rv = pci_enable_device(pdev); 1816 rv = pci_enable_device(pdev);
@@ -1867,7 +1867,7 @@ static int ipmi_pci_resume(struct pci_dev *pdev)
1867 1867
1868static struct pci_device_id ipmi_pci_devices[] = { 1868static struct pci_device_id ipmi_pci_devices[] = {
1869 { PCI_DEVICE(PCI_HP_VENDOR_ID, PCI_MMC_DEVICE_ID) }, 1869 { PCI_DEVICE(PCI_HP_VENDOR_ID, PCI_MMC_DEVICE_ID) },
1870 { PCI_DEVICE_CLASS(PCI_ERMC_CLASSCODE, PCI_ERMC_CLASSCODE) } 1870 { PCI_DEVICE_CLASS(PCI_ERMC_CLASSCODE, PCI_ERMC_CLASSCODE_MASK) }
1871}; 1871};
1872MODULE_DEVICE_TABLE(pci, ipmi_pci_devices); 1872MODULE_DEVICE_TABLE(pci, ipmi_pci_devices);
1873 1873
@@ -2346,7 +2346,7 @@ static int try_smi_init(struct smi_info *new_smi)
2346 new_smi->dev = &new_smi->pdev->dev; 2346 new_smi->dev = &new_smi->pdev->dev;
2347 new_smi->dev->driver = &ipmi_driver; 2347 new_smi->dev->driver = &ipmi_driver;
2348 2348
2349 rv = platform_device_register(new_smi->pdev); 2349 rv = platform_device_add(new_smi->pdev);
2350 if (rv) { 2350 if (rv) {
2351 printk(KERN_ERR 2351 printk(KERN_ERR
2352 "ipmi_si_intf:" 2352 "ipmi_si_intf:"
diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c
index e9e9bf31c369..58c955e390b3 100644
--- a/drivers/char/isicom.c
+++ b/drivers/char/isicom.c
@@ -1062,11 +1062,12 @@ static void isicom_shutdown_port(struct isi_port *port)
1062static void isicom_close(struct tty_struct *tty, struct file *filp) 1062static void isicom_close(struct tty_struct *tty, struct file *filp)
1063{ 1063{
1064 struct isi_port *port = tty->driver_data; 1064 struct isi_port *port = tty->driver_data;
1065 struct isi_board *card = port->card; 1065 struct isi_board *card;
1066 unsigned long flags; 1066 unsigned long flags;
1067 1067
1068 if (!port) 1068 if (!port)
1069 return; 1069 return;
1070 card = port->card;
1070 if (isicom_paranoia_check(port, tty->name, "isicom_close")) 1071 if (isicom_paranoia_check(port, tty->name, "isicom_close"))
1071 return; 1072 return;
1072 1073
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 6511012cbdcd..55473371b7c6 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -26,6 +26,7 @@
26#include <linux/backing-dev.h> 26#include <linux/backing-dev.h>
27#include <linux/bootmem.h> 27#include <linux/bootmem.h>
28#include <linux/pipe_fs_i.h> 28#include <linux/pipe_fs_i.h>
29#include <linux/pfn.h>
29 30
30#include <asm/uaccess.h> 31#include <asm/uaccess.h>
31#include <asm/io.h> 32#include <asm/io.h>
@@ -292,8 +293,8 @@ static int mmap_kmem(struct file * file, struct vm_area_struct * vma)
292{ 293{
293 unsigned long pfn; 294 unsigned long pfn;
294 295
295 /* Turn a kernel-virtual address into a physical page frame */ 296 /* Turn a pfn offset into an absolute pfn */
296 pfn = __pa((u64)vma->vm_pgoff << PAGE_SHIFT) >> PAGE_SHIFT; 297 pfn = PFN_DOWN(virt_to_phys((void *)PAGE_OFFSET)) + vma->vm_pgoff;
297 298
298 /* 299 /*
299 * RED-PEN: on some architectures there is more mapped memory 300 * RED-PEN: on some architectures there is more mapped memory
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
index b401383808c2..96cb1f07332b 100644
--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -130,6 +130,7 @@ static moxa_isa_board_conf moxa_isa_boards[] =
130typedef struct _moxa_pci_devinfo { 130typedef struct _moxa_pci_devinfo {
131 ushort busNum; 131 ushort busNum;
132 ushort devNum; 132 ushort devNum;
133 struct pci_dev *pdev;
133} moxa_pci_devinfo; 134} moxa_pci_devinfo;
134 135
135typedef struct _moxa_board_conf { 136typedef struct _moxa_board_conf {
@@ -324,6 +325,9 @@ static int moxa_get_PCI_conf(struct pci_dev *p, int board_type, moxa_board_conf
324 board->busType = MOXA_BUS_TYPE_PCI; 325 board->busType = MOXA_BUS_TYPE_PCI;
325 board->pciInfo.busNum = p->bus->number; 326 board->pciInfo.busNum = p->bus->number;
326 board->pciInfo.devNum = p->devfn >> 3; 327 board->pciInfo.devNum = p->devfn >> 3;
328 board->pciInfo.pdev = p;
329 /* don't lose the reference in the next pci_get_device iteration */
330 pci_dev_get(p);
327 331
328 return (0); 332 return (0);
329} 333}
@@ -493,6 +497,11 @@ static void __exit moxa_exit(void)
493 if (tty_unregister_driver(moxaDriver)) 497 if (tty_unregister_driver(moxaDriver))
494 printk("Couldn't unregister MOXA Intellio family serial driver\n"); 498 printk("Couldn't unregister MOXA Intellio family serial driver\n");
495 put_tty_driver(moxaDriver); 499 put_tty_driver(moxaDriver);
500
501 for (i = 0; i < MAX_BOARDS; i++)
502 if (moxa_boards[i].busType == MOXA_BUS_TYPE_PCI)
503 pci_dev_put(moxa_boards[i].pciInfo.pdev);
504
496 if (verbose) 505 if (verbose)
497 printk("Done\n"); 506 printk("Done\n");
498} 507}
diff --git a/drivers/char/mspec.c b/drivers/char/mspec.c
index 5c0dec39cf6c..235e89226112 100644
--- a/drivers/char/mspec.c
+++ b/drivers/char/mspec.c
@@ -72,7 +72,11 @@ enum {
72 MSPEC_UNCACHED 72 MSPEC_UNCACHED
73}; 73};
74 74
75#ifdef CONFIG_SGI_SN
75static int is_sn2; 76static int is_sn2;
77#else
78#define is_sn2 0
79#endif
76 80
77/* 81/*
78 * One of these structures is allocated when an mspec region is mmaped. The 82 * One of these structures is allocated when an mspec region is mmaped. The
@@ -211,7 +215,7 @@ mspec_nopfn(struct vm_area_struct *vma, unsigned long address)
211 if (vdata->type == MSPEC_FETCHOP) 215 if (vdata->type == MSPEC_FETCHOP)
212 paddr = TO_AMO(maddr); 216 paddr = TO_AMO(maddr);
213 else 217 else
214 paddr = __pa(TO_CAC(maddr)); 218 paddr = maddr & ~__IA64_UNCACHED_OFFSET;
215 219
216 pfn = paddr >> PAGE_SHIFT; 220 pfn = paddr >> PAGE_SHIFT;
217 221
@@ -335,6 +339,7 @@ mspec_init(void)
335 * The fetchop device only works on SN2 hardware, uncached and cached 339 * The fetchop device only works on SN2 hardware, uncached and cached
336 * memory drivers should both be valid on all ia64 hardware 340 * memory drivers should both be valid on all ia64 hardware
337 */ 341 */
342#ifdef CONFIG_SGI_SN
338 if (ia64_platform_is("sn2")) { 343 if (ia64_platform_is("sn2")) {
339 is_sn2 = 1; 344 is_sn2 = 1;
340 if (is_shub2()) { 345 if (is_shub2()) {
@@ -363,6 +368,7 @@ mspec_init(void)
363 goto free_scratch_pages; 368 goto free_scratch_pages;
364 } 369 }
365 } 370 }
371#endif
366 ret = misc_register(&cached_miscdev); 372 ret = misc_register(&cached_miscdev);
367 if (ret) { 373 if (ret) {
368 printk(KERN_ERR "%s: failed to register device %i\n", 374 printk(KERN_ERR "%s: failed to register device %i\n",
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 07f47a0208a7..eb6b13f4211a 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -645,6 +645,7 @@ void add_input_randomness(unsigned int type, unsigned int code,
645 add_timer_randomness(&input_timer_state, 645 add_timer_randomness(&input_timer_state,
646 (type << 4) ^ code ^ (code >> 4) ^ value); 646 (type << 4) ^ code ^ (code >> 4) ^ value);
647} 647}
648EXPORT_SYMBOL_GPL(add_input_randomness);
648 649
649void add_interrupt_randomness(int irq) 650void add_interrupt_randomness(int irq)
650{ 651{
diff --git a/drivers/char/rio/host.h b/drivers/char/rio/host.h
index ee2ddea7a63a..23d0681fe491 100644
--- a/drivers/char/rio/host.h
+++ b/drivers/char/rio/host.h
@@ -44,6 +44,7 @@
44** the host. 44** the host.
45*/ 45*/
46struct Host { 46struct Host {
47 struct pci_dev *pdev;
47 unsigned char Type; /* RIO_EISA, RIO_MCA, ... */ 48 unsigned char Type; /* RIO_EISA, RIO_MCA, ... */
48 unsigned char Ivec; /* POLLED or ivec number */ 49 unsigned char Ivec; /* POLLED or ivec number */
49 unsigned char Mode; /* Control stuff */ 50 unsigned char Mode; /* Control stuff */
diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c
index c382df0f82f6..7ac68cb3bedd 100644
--- a/drivers/char/rio/rio_linux.c
+++ b/drivers/char/rio/rio_linux.c
@@ -1017,6 +1017,10 @@ static int __init rio_init(void)
1017 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum); 1017 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum);
1018 1018
1019 fix_rio_pci(pdev); 1019 fix_rio_pci(pdev);
1020
1021 p->RIOHosts[p->RIONumHosts].pdev = pdev;
1022 pci_dev_get(pdev);
1023
1020 p->RIOLastPCISearch = 0; 1024 p->RIOLastPCISearch = 0;
1021 p->RIONumHosts++; 1025 p->RIONumHosts++;
1022 found++; 1026 found++;
@@ -1066,6 +1070,9 @@ static int __init rio_init(void)
1066 ((readb(&p->RIOHosts[p->RIONumHosts].Unique[1]) & 0xFF) << 8) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[2]) & 0xFF) << 16) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[3]) & 0xFF) << 24); 1070 ((readb(&p->RIOHosts[p->RIONumHosts].Unique[1]) & 0xFF) << 8) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[2]) & 0xFF) << 16) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[3]) & 0xFF) << 24);
1067 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum); 1071 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum);
1068 1072
1073 p->RIOHosts[p->RIONumHosts].pdev = pdev;
1074 pci_dev_get(pdev);
1075
1069 p->RIOLastPCISearch = 0; 1076 p->RIOLastPCISearch = 0;
1070 p->RIONumHosts++; 1077 p->RIONumHosts++;
1071 found++; 1078 found++;
@@ -1181,6 +1188,8 @@ static void __exit rio_exit(void)
1181 } 1188 }
1182 /* It is safe/allowed to del_timer a non-active timer */ 1189 /* It is safe/allowed to del_timer a non-active timer */
1183 del_timer(&hp->timer); 1190 del_timer(&hp->timer);
1191 if (hp->Type == RIO_PCI)
1192 pci_dev_put(hp->pdev);
1184 } 1193 }
1185 1194
1186 if (misc_deregister(&rio_fw_device) < 0) { 1195 if (misc_deregister(&rio_fw_device) < 0) {
diff --git a/drivers/char/rio/rioctrl.c b/drivers/char/rio/rioctrl.c
index 052e8120a471..7ce77619707c 100644
--- a/drivers/char/rio/rioctrl.c
+++ b/drivers/char/rio/rioctrl.c
@@ -662,7 +662,7 @@ int riocontrol(struct rio_info *p, dev_t dev, int cmd, unsigned long arg, int su
662 p->RIOError.Error = COPYIN_FAILED; 662 p->RIOError.Error = COPYIN_FAILED;
663 return -EFAULT; 663 return -EFAULT;
664 } 664 }
665 if (portStats.port >= RIO_PORTS) { 665 if (portStats.port < 0 || portStats.port >= RIO_PORTS) {
666 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; 666 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
667 return -ENXIO; 667 return -ENXIO;
668 } 668 }
@@ -702,7 +702,7 @@ int riocontrol(struct rio_info *p, dev_t dev, int cmd, unsigned long arg, int su
702 p->RIOError.Error = COPYIN_FAILED; 702 p->RIOError.Error = COPYIN_FAILED;
703 return -EFAULT; 703 return -EFAULT;
704 } 704 }
705 if (portStats.port >= RIO_PORTS) { 705 if (portStats.port < 0 || portStats.port >= RIO_PORTS) {
706 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; 706 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
707 return -ENXIO; 707 return -ENXIO;
708 } 708 }
diff --git a/drivers/char/serial167.c b/drivers/char/serial167.c
index 461bfe0234c9..3af7f0958c5d 100644
--- a/drivers/char/serial167.c
+++ b/drivers/char/serial167.c
@@ -839,7 +839,7 @@ shutdown(struct cyclades_port * info)
839 local_irq_save(flags); 839 local_irq_save(flags);
840 if (info->xmit_buf){ 840 if (info->xmit_buf){
841 free_page((unsigned long) info->xmit_buf); 841 free_page((unsigned long) info->xmit_buf);
842 info->xmit_buf = 0; 842 info->xmit_buf = NULL;
843 } 843 }
844 844
845 base_addr[CyCAR] = (u_char)channel; 845 base_addr[CyCAR] = (u_char)channel;
@@ -1354,7 +1354,7 @@ cy_unthrottle(struct tty_struct * tty)
1354 1354
1355static int 1355static int
1356get_serial_info(struct cyclades_port * info, 1356get_serial_info(struct cyclades_port * info,
1357 struct serial_struct * retinfo) 1357 struct serial_struct __user * retinfo)
1358{ 1358{
1359 struct serial_struct tmp; 1359 struct serial_struct tmp;
1360 1360
@@ -1376,7 +1376,7 @@ get_serial_info(struct cyclades_port * info,
1376 1376
1377static int 1377static int
1378set_serial_info(struct cyclades_port * info, 1378set_serial_info(struct cyclades_port * info,
1379 struct serial_struct * new_info) 1379 struct serial_struct __user * new_info)
1380{ 1380{
1381 struct serial_struct new_serial; 1381 struct serial_struct new_serial;
1382 struct cyclades_port old_info; 1382 struct cyclades_port old_info;
@@ -1503,7 +1503,7 @@ send_break( struct cyclades_port * info, int duration)
1503} /* send_break */ 1503} /* send_break */
1504 1504
1505static int 1505static int
1506get_mon_info(struct cyclades_port * info, struct cyclades_monitor * mon) 1506get_mon_info(struct cyclades_port * info, struct cyclades_monitor __user * mon)
1507{ 1507{
1508 1508
1509 if (copy_to_user(mon, &info->mon, sizeof(struct cyclades_monitor))) 1509 if (copy_to_user(mon, &info->mon, sizeof(struct cyclades_monitor)))
@@ -1516,7 +1516,7 @@ get_mon_info(struct cyclades_port * info, struct cyclades_monitor * mon)
1516} 1516}
1517 1517
1518static int 1518static int
1519set_threshold(struct cyclades_port * info, unsigned long *arg) 1519set_threshold(struct cyclades_port * info, unsigned long __user *arg)
1520{ 1520{
1521 volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 1521 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
1522 unsigned long value; 1522 unsigned long value;
@@ -1533,7 +1533,7 @@ set_threshold(struct cyclades_port * info, unsigned long *arg)
1533} 1533}
1534 1534
1535static int 1535static int
1536get_threshold(struct cyclades_port * info, unsigned long *value) 1536get_threshold(struct cyclades_port * info, unsigned long __user *value)
1537{ 1537{
1538 volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 1538 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
1539 int channel; 1539 int channel;
@@ -1546,7 +1546,7 @@ get_threshold(struct cyclades_port * info, unsigned long *value)
1546} 1546}
1547 1547
1548static int 1548static int
1549set_default_threshold(struct cyclades_port * info, unsigned long *arg) 1549set_default_threshold(struct cyclades_port * info, unsigned long __user *arg)
1550{ 1550{
1551 unsigned long value; 1551 unsigned long value;
1552 1552
@@ -1558,13 +1558,13 @@ set_default_threshold(struct cyclades_port * info, unsigned long *arg)
1558} 1558}
1559 1559
1560static int 1560static int
1561get_default_threshold(struct cyclades_port * info, unsigned long *value) 1561get_default_threshold(struct cyclades_port * info, unsigned long __user *value)
1562{ 1562{
1563 return put_user(info->default_threshold,value); 1563 return put_user(info->default_threshold,value);
1564} 1564}
1565 1565
1566static int 1566static int
1567set_timeout(struct cyclades_port * info, unsigned long *arg) 1567set_timeout(struct cyclades_port * info, unsigned long __user *arg)
1568{ 1568{
1569 volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 1569 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
1570 int channel; 1570 int channel;
@@ -1581,7 +1581,7 @@ set_timeout(struct cyclades_port * info, unsigned long *arg)
1581} 1581}
1582 1582
1583static int 1583static int
1584get_timeout(struct cyclades_port * info, unsigned long *value) 1584get_timeout(struct cyclades_port * info, unsigned long __user *value)
1585{ 1585{
1586 volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 1586 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
1587 int channel; 1587 int channel;
@@ -1601,7 +1601,7 @@ set_default_timeout(struct cyclades_port * info, unsigned long value)
1601} 1601}
1602 1602
1603static int 1603static int
1604get_default_timeout(struct cyclades_port * info, unsigned long *value) 1604get_default_timeout(struct cyclades_port * info, unsigned long __user *value)
1605{ 1605{
1606 return put_user(info->default_timeout,value); 1606 return put_user(info->default_timeout,value);
1607} 1607}
@@ -1613,6 +1613,7 @@ cy_ioctl(struct tty_struct *tty, struct file * file,
1613 unsigned long val; 1613 unsigned long val;
1614 struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; 1614 struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
1615 int ret_val = 0; 1615 int ret_val = 0;
1616 void __user *argp = (void __user *)arg;
1616 1617
1617#ifdef SERIAL_DEBUG_OTHER 1618#ifdef SERIAL_DEBUG_OTHER
1618 printk("cy_ioctl %s, cmd = %x arg = %lx\n", tty->name, cmd, arg); /* */ 1619 printk("cy_ioctl %s, cmd = %x arg = %lx\n", tty->name, cmd, arg); /* */
@@ -1620,28 +1621,28 @@ cy_ioctl(struct tty_struct *tty, struct file * file,
1620 1621
1621 switch (cmd) { 1622 switch (cmd) {
1622 case CYGETMON: 1623 case CYGETMON:
1623 ret_val = get_mon_info(info, (struct cyclades_monitor *)arg); 1624 ret_val = get_mon_info(info, argp);
1624 break; 1625 break;
1625 case CYGETTHRESH: 1626 case CYGETTHRESH:
1626 ret_val = get_threshold(info, (unsigned long *)arg); 1627 ret_val = get_threshold(info, argp);
1627 break; 1628 break;
1628 case CYSETTHRESH: 1629 case CYSETTHRESH:
1629 ret_val = set_threshold(info, (unsigned long *)arg); 1630 ret_val = set_threshold(info, argp);
1630 break; 1631 break;
1631 case CYGETDEFTHRESH: 1632 case CYGETDEFTHRESH:
1632 ret_val = get_default_threshold(info, (unsigned long *)arg); 1633 ret_val = get_default_threshold(info, argp);
1633 break; 1634 break;
1634 case CYSETDEFTHRESH: 1635 case CYSETDEFTHRESH:
1635 ret_val = set_default_threshold(info, (unsigned long *)arg); 1636 ret_val = set_default_threshold(info, argp);
1636 break; 1637 break;
1637 case CYGETTIMEOUT: 1638 case CYGETTIMEOUT:
1638 ret_val = get_timeout(info, (unsigned long *)arg); 1639 ret_val = get_timeout(info, argp);
1639 break; 1640 break;
1640 case CYSETTIMEOUT: 1641 case CYSETTIMEOUT:
1641 ret_val = set_timeout(info, (unsigned long *)arg); 1642 ret_val = set_timeout(info, argp);
1642 break; 1643 break;
1643 case CYGETDEFTIMEOUT: 1644 case CYGETDEFTIMEOUT:
1644 ret_val = get_default_timeout(info, (unsigned long *)arg); 1645 ret_val = get_default_timeout(info, argp);
1645 break; 1646 break;
1646 case CYSETDEFTIMEOUT: 1647 case CYSETDEFTIMEOUT:
1647 ret_val = set_default_timeout(info, (unsigned long)arg); 1648 ret_val = set_default_timeout(info, (unsigned long)arg);
@@ -1664,21 +1665,20 @@ cy_ioctl(struct tty_struct *tty, struct file * file,
1664 1665
1665/* The following commands are incompletely implemented!!! */ 1666/* The following commands are incompletely implemented!!! */
1666 case TIOCGSOFTCAR: 1667 case TIOCGSOFTCAR:
1667 ret_val = put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long *) arg); 1668 ret_val = put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *) argp);
1668 break; 1669 break;
1669 case TIOCSSOFTCAR: 1670 case TIOCSSOFTCAR:
1670 ret_val = get_user(val, (unsigned long *) arg); 1671 ret_val = get_user(val, (unsigned long __user *) argp);
1671 if (ret_val) 1672 if (ret_val)
1672 break; 1673 break;
1673 tty->termios->c_cflag = 1674 tty->termios->c_cflag =
1674 ((tty->termios->c_cflag & ~CLOCAL) | (val ? CLOCAL : 0)); 1675 ((tty->termios->c_cflag & ~CLOCAL) | (val ? CLOCAL : 0));
1675 break; 1676 break;
1676 case TIOCGSERIAL: 1677 case TIOCGSERIAL:
1677 ret_val = get_serial_info(info, (struct serial_struct *) arg); 1678 ret_val = get_serial_info(info, argp);
1678 break; 1679 break;
1679 case TIOCSSERIAL: 1680 case TIOCSSERIAL:
1680 ret_val = set_serial_info(info, 1681 ret_val = set_serial_info(info, argp);
1681 (struct serial_struct *) arg);
1682 break; 1682 break;
1683 default: 1683 default:
1684 ret_val = -ENOIOCTLCMD; 1684 ret_val = -ENOIOCTLCMD;
@@ -1773,7 +1773,7 @@ cy_close(struct tty_struct * tty, struct file * filp)
1773 tty->driver->flush_buffer(tty); 1773 tty->driver->flush_buffer(tty);
1774 tty_ldisc_flush(tty); 1774 tty_ldisc_flush(tty);
1775 info->event = 0; 1775 info->event = 0;
1776 info->tty = 0; 1776 info->tty = NULL;
1777 if (info->blocked_open) { 1777 if (info->blocked_open) {
1778 if (info->close_delay) { 1778 if (info->close_delay) {
1779 msleep_interruptible(jiffies_to_msecs(info->close_delay)); 1779 msleep_interruptible(jiffies_to_msecs(info->close_delay));
@@ -2250,7 +2250,7 @@ scrn[1] = '\0';
2250 info->card = index; 2250 info->card = index;
2251 info->line = port_num; 2251 info->line = port_num;
2252 info->flags = STD_COM_FLAGS; 2252 info->flags = STD_COM_FLAGS;
2253 info->tty = 0; 2253 info->tty = NULL;
2254 info->xmit_fifo_size = 12; 2254 info->xmit_fifo_size = 12;
2255 info->cor1 = CyPARITY_NONE|Cy_8_BITS; 2255 info->cor1 = CyPARITY_NONE|Cy_8_BITS;
2256 info->cor2 = CyETC; 2256 info->cor2 = CyETC;
diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c
index d0b88d0e87fd..7e1bd9562c2a 100644
--- a/drivers/char/specialix.c
+++ b/drivers/char/specialix.c
@@ -183,11 +183,6 @@ static int sx_poll = HZ;
183 183
184static struct tty_driver *specialix_driver; 184static struct tty_driver *specialix_driver;
185 185
186static unsigned long baud_table[] = {
187 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
188 9600, 19200, 38400, 57600, 115200, 0,
189};
190
191static struct specialix_board sx_board[SX_NBOARD] = { 186static struct specialix_board sx_board[SX_NBOARD] = {
192 { 0, SX_IOBASE1, 9, }, 187 { 0, SX_IOBASE1, 9, },
193 { 0, SX_IOBASE2, 11, }, 188 { 0, SX_IOBASE2, 11, },
@@ -1090,9 +1085,9 @@ static void sx_change_speed(struct specialix_board *bp, struct specialix_port *p
1090 1085
1091 if (baud == 38400) { 1086 if (baud == 38400) {
1092 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) 1087 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
1093 baud ++; 1088 baud = 57600;
1094 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) 1089 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
1095 baud += 2; 1090 baud = 115200;
1096 } 1091 }
1097 1092
1098 if (!baud) { 1093 if (!baud) {
@@ -1150,11 +1145,9 @@ static void sx_change_speed(struct specialix_board *bp, struct specialix_port *p
1150 sx_out(bp, CD186x_RBPRL, tmp & 0xff); 1145 sx_out(bp, CD186x_RBPRL, tmp & 0xff);
1151 sx_out(bp, CD186x_TBPRL, tmp & 0xff); 1146 sx_out(bp, CD186x_TBPRL, tmp & 0xff);
1152 spin_unlock_irqrestore(&bp->lock, flags); 1147 spin_unlock_irqrestore(&bp->lock, flags);
1153 if (port->custom_divisor) { 1148 if (port->custom_divisor)
1154 baud = (SX_OSCFREQ + port->custom_divisor/2) / port->custom_divisor; 1149 baud = (SX_OSCFREQ + port->custom_divisor/2) / port->custom_divisor;
1155 baud = ( baud + 5 ) / 10; 1150 baud = (baud + 5) / 10; /* Estimated CPS */
1156 } else
1157 baud = (baud_table[baud] + 5) / 10; /* Estimated CPS */
1158 1151
1159 /* Two timer ticks seems enough to wakeup something like SLIP driver */ 1152 /* Two timer ticks seems enough to wakeup something like SLIP driver */
1160 tmp = ((baud + HZ/2) / HZ) * 2 - CD186x_NFIFO; 1153 tmp = ((baud + HZ/2) / HZ) * 2 - CD186x_NFIFO;
diff --git a/drivers/char/sx.c b/drivers/char/sx.c
index 5fec626598cd..cc10af08cb05 100644
--- a/drivers/char/sx.c
+++ b/drivers/char/sx.c
@@ -2602,7 +2602,7 @@ static void __exit sx_exit (void)
2602 } 2602 }
2603 } 2603 }
2604 if (misc_deregister(&sx_fw_device) < 0) { 2604 if (misc_deregister(&sx_fw_device) < 0) {
2605 printk (KERN_INFO "sx: couldn't deregister firmware loader devic\n"); 2605 printk (KERN_INFO "sx: couldn't deregister firmware loader device\n");
2606 } 2606 }
2607 sx_dprintk (SX_DEBUG_CLEANUP, "Cleaning up drivers (%d)\n", sx_initialized); 2607 sx_dprintk (SX_DEBUG_CLEANUP, "Cleaning up drivers (%d)\n", sx_initialized);
2608 if (sx_initialized) 2608 if (sx_initialized)
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c
index f2864cc64240..06784adcc35c 100644
--- a/drivers/char/synclink.c
+++ b/drivers/char/synclink.c
@@ -133,8 +133,8 @@ static MGSL_PARAMS default_params = {
133}; 133};
134 134
135#define SHARED_MEM_ADDRESS_SIZE 0x40000 135#define SHARED_MEM_ADDRESS_SIZE 0x40000
136#define BUFFERLISTSIZE (PAGE_SIZE) 136#define BUFFERLISTSIZE 4096
137#define DMABUFFERSIZE (PAGE_SIZE) 137#define DMABUFFERSIZE 4096
138#define MAXRXFRAMES 7 138#define MAXRXFRAMES 7
139 139
140typedef struct _DMABUFFERENTRY 140typedef struct _DMABUFFERENTRY
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index a082a2e34252..6ad2d3bb945c 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -1153,7 +1153,14 @@ struct tpm_chip *tpm_register_hardware(struct device *dev, const struct tpm_vend
1153 1153
1154 spin_unlock(&driver_lock); 1154 spin_unlock(&driver_lock);
1155 1155
1156 sysfs_create_group(&dev->kobj, chip->vendor.attr_group); 1156 if (sysfs_create_group(&dev->kobj, chip->vendor.attr_group)) {
1157 list_del(&chip->list);
1158 put_device(dev);
1159 clear_bit(chip->dev_num, dev_mask);
1160 kfree(chip);
1161 kfree(devname);
1162 return NULL;
1163 }
1157 1164
1158 chip->bios_dir = tpm_bios_log_setup(devname); 1165 chip->bios_dir = tpm_bios_log_setup(devname);
1159 1166
diff --git a/drivers/char/tpm/tpm_atmel.c b/drivers/char/tpm/tpm_atmel.c
index ad8ffe49256f..1ab0896070be 100644
--- a/drivers/char/tpm/tpm_atmel.c
+++ b/drivers/char/tpm/tpm_atmel.c
@@ -184,7 +184,9 @@ static int __init init_atmel(void)
184 unsigned long base; 184 unsigned long base;
185 struct tpm_chip *chip; 185 struct tpm_chip *chip;
186 186
187 driver_register(&atml_drv); 187 rc = driver_register(&atml_drv);
188 if (rc)
189 return rc;
188 190
189 if ((iobase = atmel_get_base_addr(&base, &region_size)) == NULL) { 191 if ((iobase = atmel_get_base_addr(&base, &region_size)) == NULL) {
190 rc = -ENODEV; 192 rc = -ENODEV;
@@ -195,10 +197,8 @@ static int __init init_atmel(void)
195 (atmel_request_region 197 (atmel_request_region
196 (tpm_atmel.base, region_size, "tpm_atmel0") == NULL) ? 0 : 1; 198 (tpm_atmel.base, region_size, "tpm_atmel0") == NULL) ? 0 : 1;
197 199
198 200 pdev = platform_device_register_simple("tpm_atmel", -1, NULL, 0);
199 if (IS_ERR 201 if (IS_ERR(pdev)) {
200 (pdev =
201 platform_device_register_simple("tpm_atmel", -1, NULL, 0))) {
202 rc = PTR_ERR(pdev); 202 rc = PTR_ERR(pdev);
203 goto err_rel_reg; 203 goto err_rel_reg;
204 } 204 }
diff --git a/drivers/char/tpm/tpm_nsc.c b/drivers/char/tpm/tpm_nsc.c
index 26287aace87d..608f73071bef 100644
--- a/drivers/char/tpm/tpm_nsc.c
+++ b/drivers/char/tpm/tpm_nsc.c
@@ -284,7 +284,7 @@ static struct device_driver nsc_drv = {
284static int __init init_nsc(void) 284static int __init init_nsc(void)
285{ 285{
286 int rc = 0; 286 int rc = 0;
287 int lo, hi; 287 int lo, hi, err;
288 int nscAddrBase = TPM_ADDR; 288 int nscAddrBase = TPM_ADDR;
289 struct tpm_chip *chip; 289 struct tpm_chip *chip;
290 unsigned long base; 290 unsigned long base;
@@ -297,7 +297,9 @@ static int __init init_nsc(void)
297 return -ENODEV; 297 return -ENODEV;
298 } 298 }
299 299
300 driver_register(&nsc_drv); 300 err = driver_register(&nsc_drv);
301 if (err)
302 return err;
301 303
302 hi = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_HI); 304 hi = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_HI);
303 lo = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_LO); 305 lo = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_LO);
diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig
index 89e46d6dfc4e..0187b1185323 100644
--- a/drivers/char/watchdog/Kconfig
+++ b/drivers/char/watchdog/Kconfig
@@ -13,7 +13,7 @@ config WATCHDOG
13 subsequently opening the file and then failing to write to it for 13 subsequently opening the file and then failing to write to it for
14 longer than 1 minute will result in rebooting the machine. This 14 longer than 1 minute will result in rebooting the machine. This
15 could be useful for a networked machine that needs to come back 15 could be useful for a networked machine that needs to come back
16 online as fast as possible after a lock-up. There's both a watchdog 16 on-line as fast as possible after a lock-up. There's both a watchdog
17 implementation entirely in software (which can sometimes fail to 17 implementation entirely in software (which can sometimes fail to
18 reboot the machine) and a driver for hardware watchdog boards, which 18 reboot the machine) and a driver for hardware watchdog boards, which
19 are more robust and can also keep track of the temperature inside 19 are more robust and can also keep track of the temperature inside
@@ -60,7 +60,7 @@ config SOFT_WATCHDOG
60 60
61# ARM Architecture 61# ARM Architecture
62 62
63config AT91_WATCHDOG 63config AT91RM9200_WATCHDOG
64 tristate "AT91RM9200 watchdog" 64 tristate "AT91RM9200 watchdog"
65 depends on WATCHDOG && ARCH_AT91RM9200 65 depends on WATCHDOG && ARCH_AT91RM9200
66 help 66 help
@@ -71,7 +71,7 @@ config 21285_WATCHDOG
71 tristate "DC21285 watchdog" 71 tristate "DC21285 watchdog"
72 depends on WATCHDOG && FOOTBRIDGE 72 depends on WATCHDOG && FOOTBRIDGE
73 help 73 help
74 The Intel Footbridge chip contains a builtin watchdog circuit. Say Y 74 The Intel Footbridge chip contains a built-in watchdog circuit. Say Y
75 here if you wish to use this. Alternatively say M to compile the 75 here if you wish to use this. Alternatively say M to compile the
76 driver as a module, which will be called wdt285. 76 driver as a module, which will be called wdt285.
77 77
@@ -269,11 +269,11 @@ config IB700_WDT
269 Most people will say N. 269 Most people will say N.
270 270
271config IBMASR 271config IBMASR
272 tristate "IBM Automatic Server Restart" 272 tristate "IBM Automatic Server Restart"
273 depends on WATCHDOG && X86 273 depends on WATCHDOG && X86
274 help 274 help
275 This is the driver for the IBM Automatic Server Restart watchdog 275 This is the driver for the IBM Automatic Server Restart watchdog
276 timer builtin into some eServer xSeries machines. 276 timer built-in into some eServer xSeries machines.
277 277
278 To compile this driver as a module, choose M here: the 278 To compile this driver as a module, choose M here: the
279 module will be called ibmasr. 279 module will be called ibmasr.
@@ -316,13 +316,16 @@ config I8XX_TCO
316 To compile this driver as a module, choose M here: the 316 To compile this driver as a module, choose M here: the
317 module will be called i8xx_tco. 317 module will be called i8xx_tco.
318 318
319 Note: This driver will be removed in the near future. Please
320 use the Intel TCO Timer/Watchdog driver.
321
319config ITCO_WDT 322config ITCO_WDT
320 tristate "Intel TCO Timer/Watchdog (EXPERIMENTAL)" 323 tristate "Intel TCO Timer/Watchdog"
321 depends on WATCHDOG && (X86 || IA64) && PCI && EXPERIMENTAL 324 depends on WATCHDOG && (X86 || IA64) && PCI
322 ---help--- 325 ---help---
323 Hardware driver for the intel TCO timer based watchdog devices. 326 Hardware driver for the intel TCO timer based watchdog devices.
324 These drivers are included in the Intel 82801 I/O Controller 327 These drivers are included in the Intel 82801 I/O Controller
325 Hub family 'from ICH0 up to ICH7) and in the Intel 6300ESB 328 Hub family (from ICH0 up to ICH8) and in the Intel 6300ESB
326 controller hub. 329 controller hub.
327 330
328 The TCO (Total Cost of Ownership) timer is a watchdog timer 331 The TCO (Total Cost of Ownership) timer is a watchdog timer
@@ -395,6 +398,26 @@ config CPU5_WDT
395 To compile this driver as a module, choose M here: the 398 To compile this driver as a module, choose M here: the
396 module will be called cpu5wdt. 399 module will be called cpu5wdt.
397 400
401config SMSC37B787_WDT
402 tristate "Winbond SMsC37B787 Watchdog Timer"
403 depends on WATCHDOG && X86
404 ---help---
405 This is the driver for the hardware watchdog component on the
406 Winbond SMsC37B787 chipset as used on the NetRunner Mainboard
407 from Vision Systems and maybe others.
408
409 This watchdog simply watches your kernel to make sure it doesn't
410 freeze, and if it does, it reboots your computer after a certain
411 amount of time.
412
413 Usually a userspace daemon will notify the kernel WDT driver that
414 userspace is still alive, at regular intervals.
415
416 To compile this driver as a module, choose M here: the
417 module will be called smsc37b787_wdt.
418
419 Most people will say N.
420
398config W83627HF_WDT 421config W83627HF_WDT
399 tristate "W83627HF Watchdog Timer" 422 tristate "W83627HF Watchdog Timer"
400 depends on WATCHDOG && X86 423 depends on WATCHDOG && X86
@@ -410,6 +433,21 @@ config W83627HF_WDT
410 433
411 Most people will say N. 434 Most people will say N.
412 435
436config W83697HF_WDT
437 tristate "W83697HF/W83697HG Watchdog Timer"
438 depends on WATCHDOG && X86
439 ---help---
440 This is the driver for the hardware watchdog on the W83697HF/HG
441 chipset as used in Dedibox/VIA motherboards (and likely others).
442 This watchdog simply watches your kernel to make sure it doesn't
443 freeze, and if it does, it reboots your computer after a certain
444 amount of time.
445
446 To compile this driver as a module, choose M here: the
447 module will be called w83697hf_wdt.
448
449 Most people will say N.
450
413config W83877F_WDT 451config W83877F_WDT
414 tristate "W83877F (EMACS) Watchdog Timer" 452 tristate "W83877F (EMACS) Watchdog Timer"
415 depends on WATCHDOG && X86 453 depends on WATCHDOG && X86
@@ -443,7 +481,7 @@ config MACHZ_WDT
443 depends on WATCHDOG && X86 481 depends on WATCHDOG && X86
444 ---help--- 482 ---help---
445 If you are using a ZF Micro MachZ processor, say Y here, otherwise 483 If you are using a ZF Micro MachZ processor, say Y here, otherwise
446 N. This is the driver for the watchdog timer builtin on that 484 N. This is the driver for the watchdog timer built-in on that
447 processor using ZF-Logic interface. This watchdog simply watches 485 processor using ZF-Logic interface. This watchdog simply watches
448 your kernel to make sure it doesn't freeze, and if it does, it 486 your kernel to make sure it doesn't freeze, and if it does, it
449 reboots your computer after a certain amount of time. 487 reboots your computer after a certain amount of time.
@@ -472,7 +510,6 @@ config SBC_EPX_C3_WATCHDOG
472 To compile this driver as a module, choose M here: the 510 To compile this driver as a module, choose M here: the
473 module will be called sbc_epx_c3. 511 module will be called sbc_epx_c3.
474 512
475
476# PowerPC Architecture 513# PowerPC Architecture
477 514
478config 8xx_WDT 515config 8xx_WDT
@@ -502,7 +539,7 @@ config WATCHDOG_RTAS
502 help 539 help
503 This driver adds watchdog support for the RTAS watchdog. 540 This driver adds watchdog support for the RTAS watchdog.
504 541
505 To compile this driver as a module, choose M here. The module 542 To compile this driver as a module, choose M here. The module
506 will be called wdrtas. 543 will be called wdrtas.
507 544
508# MIPS Architecture 545# MIPS Architecture
@@ -556,7 +593,7 @@ config SH_WDT_MMAP
556 help 593 help
557 If you say Y here, user applications will be able to mmap the 594 If you say Y here, user applications will be able to mmap the
558 WDT/CPG registers. 595 WDT/CPG registers.
559# 596
560# SPARC64 Architecture 597# SPARC64 Architecture
561 598
562config WATCHDOG_CP1XXX 599config WATCHDOG_CP1XXX
diff --git a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile
index 7f70abad465a..36440497047c 100644
--- a/drivers/char/watchdog/Makefile
+++ b/drivers/char/watchdog/Makefile
@@ -23,7 +23,7 @@ obj-$(CONFIG_WDTPCI) += wdt_pci.o
23obj-$(CONFIG_USBPCWATCHDOG) += pcwd_usb.o 23obj-$(CONFIG_USBPCWATCHDOG) += pcwd_usb.o
24 24
25# ARM Architecture 25# ARM Architecture
26obj-$(CONFIG_AT91_WATCHDOG) += at91_wdt.o 26obj-$(CONFIG_AT91RM9200_WATCHDOG) += at91rm9200_wdt.o
27obj-$(CONFIG_OMAP_WATCHDOG) += omap_wdt.o 27obj-$(CONFIG_OMAP_WATCHDOG) += omap_wdt.o
28obj-$(CONFIG_21285_WATCHDOG) += wdt285.o 28obj-$(CONFIG_21285_WATCHDOG) += wdt285.o
29obj-$(CONFIG_977_WATCHDOG) += wdt977.o 29obj-$(CONFIG_977_WATCHDOG) += wdt977.o
@@ -53,7 +53,9 @@ obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o
53obj-$(CONFIG_60XX_WDT) += sbc60xxwdt.o 53obj-$(CONFIG_60XX_WDT) += sbc60xxwdt.o
54obj-$(CONFIG_SBC8360_WDT) += sbc8360.o 54obj-$(CONFIG_SBC8360_WDT) += sbc8360.o
55obj-$(CONFIG_CPU5_WDT) += cpu5wdt.o 55obj-$(CONFIG_CPU5_WDT) += cpu5wdt.o
56obj-$(CONFIG_SMSC37B787_WDT) += smsc37b787_wdt.o
56obj-$(CONFIG_W83627HF_WDT) += w83627hf_wdt.o 57obj-$(CONFIG_W83627HF_WDT) += w83627hf_wdt.o
58obj-$(CONFIG_W83697HF_WDT) += w83697hf_wdt.o
57obj-$(CONFIG_W83877F_WDT) += w83877f_wdt.o 59obj-$(CONFIG_W83877F_WDT) += w83877f_wdt.o
58obj-$(CONFIG_W83977F_WDT) += w83977f_wdt.o 60obj-$(CONFIG_W83977F_WDT) += w83977f_wdt.o
59obj-$(CONFIG_MACHZ_WDT) += machzwd.o 61obj-$(CONFIG_MACHZ_WDT) += machzwd.o
diff --git a/drivers/char/watchdog/alim7101_wdt.c b/drivers/char/watchdog/alim7101_wdt.c
index 5948863b592b..bf25d0a55a99 100644
--- a/drivers/char/watchdog/alim7101_wdt.c
+++ b/drivers/char/watchdog/alim7101_wdt.c
@@ -77,7 +77,8 @@ static struct pci_dev *alim7101_pmu;
77 77
78static int nowayout = WATCHDOG_NOWAYOUT; 78static int nowayout = WATCHDOG_NOWAYOUT;
79module_param(nowayout, int, 0); 79module_param(nowayout, int, 0);
80MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); 80MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
81 __stringify(CONFIG_WATCHDOG_NOWAYOUT) ")");
81 82
82/* 83/*
83 * Whack the dog 84 * Whack the dog
@@ -415,6 +416,16 @@ err_out:
415module_init(alim7101_wdt_init); 416module_init(alim7101_wdt_init);
416module_exit(alim7101_wdt_unload); 417module_exit(alim7101_wdt_unload);
417 418
419static struct pci_device_id alim7101_pci_tbl[] __devinitdata = {
420 { PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533,
421 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
422 { PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101,
423 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
424 { }
425};
426
427MODULE_DEVICE_TABLE(pci, alim7101_pci_tbl);
428
418MODULE_AUTHOR("Steve Hill"); 429MODULE_AUTHOR("Steve Hill");
419MODULE_DESCRIPTION("ALi M7101 PMU Computer Watchdog Timer driver"); 430MODULE_DESCRIPTION("ALi M7101 PMU Computer Watchdog Timer driver");
420MODULE_LICENSE("GPL"); 431MODULE_LICENSE("GPL");
diff --git a/drivers/char/watchdog/at91_wdt.c b/drivers/char/watchdog/at91rm9200_wdt.c
index 4e7a1145e78f..4e7a1145e78f 100644
--- a/drivers/char/watchdog/at91_wdt.c
+++ b/drivers/char/watchdog/at91rm9200_wdt.c
diff --git a/drivers/char/watchdog/iTCO_wdt.c b/drivers/char/watchdog/iTCO_wdt.c
index aaac94db0d8b..b6f29cb8bd39 100644
--- a/drivers/char/watchdog/iTCO_wdt.c
+++ b/drivers/char/watchdog/iTCO_wdt.c
@@ -35,6 +35,10 @@
35 * 82801GDH (ICH7DH) : document number 307013-002, 307014-009, 35 * 82801GDH (ICH7DH) : document number 307013-002, 307014-009,
36 * 82801GBM (ICH7-M) : document number 307013-002, 307014-009, 36 * 82801GBM (ICH7-M) : document number 307013-002, 307014-009,
37 * 82801GHM (ICH7-M DH) : document number 307013-002, 307014-009, 37 * 82801GHM (ICH7-M DH) : document number 307013-002, 307014-009,
38 * 82801HB (ICH8) : document number 313056-002, 313057-004,
39 * 82801HR (ICH8R) : document number 313056-002, 313057-004,
40 * 82801HH (ICH8DH) : document number 313056-002, 313057-004,
41 * 82801HO (ICH8DO) : document number 313056-002, 313057-004,
38 * 6300ESB (6300ESB) : document number 300641-003 42 * 6300ESB (6300ESB) : document number 300641-003
39 */ 43 */
40 44
@@ -45,7 +49,7 @@
45/* Module and version information */ 49/* Module and version information */
46#define DRV_NAME "iTCO_wdt" 50#define DRV_NAME "iTCO_wdt"
47#define DRV_VERSION "1.00" 51#define DRV_VERSION "1.00"
48#define DRV_RELDATE "30-Jul-2006" 52#define DRV_RELDATE "08-Oct-2006"
49#define PFX DRV_NAME ": " 53#define PFX DRV_NAME ": "
50 54
51/* Includes */ 55/* Includes */
@@ -85,6 +89,9 @@ enum iTCO_chipsets {
85 TCO_ICH7, /* ICH7 & ICH7R */ 89 TCO_ICH7, /* ICH7 & ICH7R */
86 TCO_ICH7M, /* ICH7-M */ 90 TCO_ICH7M, /* ICH7-M */
87 TCO_ICH7MDH, /* ICH7-M DH */ 91 TCO_ICH7MDH, /* ICH7-M DH */
92 TCO_ICH8, /* ICH8 & ICH8R */
93 TCO_ICH8DH, /* ICH8DH */
94 TCO_ICH8DO, /* ICH8DO */
88}; 95};
89 96
90static struct { 97static struct {
@@ -108,6 +115,9 @@ static struct {
108 {"ICH7 or ICH7R", 2}, 115 {"ICH7 or ICH7R", 2},
109 {"ICH7-M", 2}, 116 {"ICH7-M", 2},
110 {"ICH7-M DH", 2}, 117 {"ICH7-M DH", 2},
118 {"ICH8 or ICH8R", 2},
119 {"ICH8DH", 2},
120 {"ICH8DO", 2},
111 {NULL,0} 121 {NULL,0}
112}; 122};
113 123
@@ -135,6 +145,9 @@ static struct pci_device_id iTCO_wdt_pci_tbl[] = {
135 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH7 }, 145 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH7 },
136 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH7M }, 146 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH7M },
137 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_31, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH7MDH }, 147 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_31, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH7MDH },
148 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH8 },
149 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH8DH },
150 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH8DO },
138 { 0, }, /* End of list */ 151 { 0, }, /* End of list */
139}; 152};
140MODULE_DEVICE_TABLE (pci, iTCO_wdt_pci_tbl); 153MODULE_DEVICE_TABLE (pci, iTCO_wdt_pci_tbl);
@@ -355,7 +368,8 @@ static int iTCO_wdt_get_timeleft (int *time_left)
355 spin_unlock(&iTCO_wdt_private.io_lock); 368 spin_unlock(&iTCO_wdt_private.io_lock);
356 369
357 *time_left = (val8 * 6) / 10; 370 *time_left = (val8 * 6) / 10;
358 } 371 } else
372 return -EINVAL;
359 return 0; 373 return 0;
360} 374}
361 375
@@ -426,7 +440,6 @@ static int iTCO_wdt_ioctl (struct inode *inode, struct file *file,
426{ 440{
427 int new_options, retval = -EINVAL; 441 int new_options, retval = -EINVAL;
428 int new_heartbeat; 442 int new_heartbeat;
429 int time_left;
430 void __user *argp = (void __user *)arg; 443 void __user *argp = (void __user *)arg;
431 int __user *p = argp; 444 int __user *p = argp;
432 static struct watchdog_info ident = { 445 static struct watchdog_info ident = {
@@ -486,6 +499,8 @@ static int iTCO_wdt_ioctl (struct inode *inode, struct file *file,
486 499
487 case WDIOC_GETTIMELEFT: 500 case WDIOC_GETTIMELEFT:
488 { 501 {
502 int time_left;
503
489 if (iTCO_wdt_get_timeleft(&time_left)) 504 if (iTCO_wdt_get_timeleft(&time_left))
490 return -EINVAL; 505 return -EINVAL;
491 506
diff --git a/drivers/char/watchdog/s3c2410_wdt.c b/drivers/char/watchdog/s3c2410_wdt.c
index 68b1ca976d53..18cb050c3862 100644
--- a/drivers/char/watchdog/s3c2410_wdt.c
+++ b/drivers/char/watchdog/s3c2410_wdt.c
@@ -380,18 +380,21 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
380 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 380 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
381 if (res == NULL) { 381 if (res == NULL) {
382 printk(KERN_INFO PFX "failed to get irq resource\n"); 382 printk(KERN_INFO PFX "failed to get irq resource\n");
383 iounmap(wdt_base);
383 return -ENOENT; 384 return -ENOENT;
384 } 385 }
385 386
386 ret = request_irq(res->start, s3c2410wdt_irq, 0, pdev->name, pdev); 387 ret = request_irq(res->start, s3c2410wdt_irq, 0, pdev->name, pdev);
387 if (ret != 0) { 388 if (ret != 0) {
388 printk(KERN_INFO PFX "failed to install irq (%d)\n", ret); 389 printk(KERN_INFO PFX "failed to install irq (%d)\n", ret);
390 iounmap(wdt_base);
389 return ret; 391 return ret;
390 } 392 }
391 393
392 wdt_clock = clk_get(&pdev->dev, "watchdog"); 394 wdt_clock = clk_get(&pdev->dev, "watchdog");
393 if (wdt_clock == NULL) { 395 if (wdt_clock == NULL) {
394 printk(KERN_INFO PFX "failed to find watchdog clock source\n"); 396 printk(KERN_INFO PFX "failed to find watchdog clock source\n");
397 iounmap(wdt_base);
395 return -ENOENT; 398 return -ENOENT;
396 } 399 }
397 400
@@ -415,6 +418,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
415 if (ret) { 418 if (ret) {
416 printk (KERN_ERR PFX "cannot register miscdev on minor=%d (%d)\n", 419 printk (KERN_ERR PFX "cannot register miscdev on minor=%d (%d)\n",
417 WATCHDOG_MINOR, ret); 420 WATCHDOG_MINOR, ret);
421 iounmap(wdt_base);
418 return ret; 422 return ret;
419 } 423 }
420 424
@@ -451,6 +455,7 @@ static int s3c2410wdt_remove(struct platform_device *dev)
451 wdt_clock = NULL; 455 wdt_clock = NULL;
452 } 456 }
453 457
458 iounmap(wdt_base);
454 misc_deregister(&s3c2410wdt_miscdev); 459 misc_deregister(&s3c2410wdt_miscdev);
455 return 0; 460 return 0;
456} 461}
diff --git a/drivers/char/watchdog/sc1200wdt.c b/drivers/char/watchdog/sc1200wdt.c
index d8d0f28e0acf..e3239833e4b0 100644
--- a/drivers/char/watchdog/sc1200wdt.c
+++ b/drivers/char/watchdog/sc1200wdt.c
@@ -392,7 +392,7 @@ static int __init sc1200wdt_init(void)
392 if (io == -1) { 392 if (io == -1) {
393 printk(KERN_ERR PFX "io parameter must be specified\n"); 393 printk(KERN_ERR PFX "io parameter must be specified\n");
394 ret = -EINVAL; 394 ret = -EINVAL;
395 goto out_clean; 395 goto out_pnp;
396 } 396 }
397 397
398#if defined CONFIG_PNP 398#if defined CONFIG_PNP
@@ -405,7 +405,7 @@ static int __init sc1200wdt_init(void)
405 if (!request_region(io, io_len, SC1200_MODULE_NAME)) { 405 if (!request_region(io, io_len, SC1200_MODULE_NAME)) {
406 printk(KERN_ERR PFX "Unable to register IO port %#x\n", io); 406 printk(KERN_ERR PFX "Unable to register IO port %#x\n", io);
407 ret = -EBUSY; 407 ret = -EBUSY;
408 goto out_clean; 408 goto out_pnp;
409 } 409 }
410 410
411 ret = sc1200wdt_probe(); 411 ret = sc1200wdt_probe();
@@ -435,6 +435,11 @@ out_rbt:
435out_io: 435out_io:
436 release_region(io, io_len); 436 release_region(io, io_len);
437 437
438out_pnp:
439#if defined CONFIG_PNP
440 if (isapnp)
441 pnp_unregister_driver(&scl200wdt_pnp_driver);
442#endif
438 goto out_clean; 443 goto out_clean;
439} 444}
440 445
diff --git a/drivers/char/watchdog/smsc37b787_wdt.c b/drivers/char/watchdog/smsc37b787_wdt.c
new file mode 100644
index 000000000000..9f56913b484f
--- /dev/null
+++ b/drivers/char/watchdog/smsc37b787_wdt.c
@@ -0,0 +1,627 @@
1/*
2 * SMsC 37B787 Watchdog Timer driver for Linux 2.6.x.x
3 *
4 * Based on acquirewdt.c by Alan Cox <alan@redhat.com>
5 * and some other existing drivers
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 *
12 * The authors do NOT admit liability nor provide warranty for
13 * any of this software. This material is provided "AS-IS" in
14 * the hope that it may be useful for others.
15 *
16 * (C) Copyright 2003-2006 Sven Anders <anders@anduras.de>
17 *
18 * History:
19 * 2003 - Created version 1.0 for Linux 2.4.x.
20 * 2006 - Ported to Linux 2.6, added nowayout and MAGICCLOSE
21 * features. Released version 1.1
22 *
23 * Theory of operation:
24 *
25 * A Watchdog Timer (WDT) is a hardware circuit that can
26 * reset the computer system in case of a software fault.
27 * You probably knew that already.
28 *
29 * Usually a userspace daemon will notify the kernel WDT driver
30 * via the /dev/watchdog special device file that userspace is
31 * still alive, at regular intervals. When such a notification
32 * occurs, the driver will usually tell the hardware watchdog
33 * that everything is in order, and that the watchdog should wait
34 * for yet another little while to reset the system.
35 * If userspace fails (RAM error, kernel bug, whatever), the
36 * notifications cease to occur, and the hardware watchdog will
37 * reset the system (causing a reboot) after the timeout occurs.
38 *
39 * Create device with:
40 * mknod /dev/watchdog c 10 130
41 *
42 * For an example userspace keep-alive daemon, see:
43 * Documentation/watchdog/watchdog.txt
44 */
45
46#include <linux/module.h>
47#include <linux/moduleparam.h>
48#include <linux/types.h>
49#include <linux/miscdevice.h>
50#include <linux/watchdog.h>
51#include <linux/delay.h>
52#include <linux/fs.h>
53#include <linux/ioport.h>
54#include <linux/notifier.h>
55#include <linux/reboot.h>
56#include <linux/init.h>
57#include <linux/spinlock.h>
58
59#include <asm/io.h>
60#include <asm/uaccess.h>
61#include <asm/system.h>
62
63/* enable support for minutes as units? */
64/* (does not always work correctly, so disabled by default!) */
65#define SMSC_SUPPORT_MINUTES
66#undef SMSC_SUPPORT_MINUTES
67
68#define MAX_TIMEOUT 255
69
70#define UNIT_SECOND 0
71#define UNIT_MINUTE 1
72
73#define MODNAME "smsc37b787_wdt: "
74#define VERSION "1.1"
75
76#define IOPORT 0x3F0
77#define IOPORT_SIZE 2
78#define IODEV_NO 8
79
80static int unit = UNIT_SECOND; /* timer's unit */
81static int timeout = 60; /* timeout value: default is 60 "units" */
82static unsigned long timer_enabled = 0; /* is the timer enabled? */
83
84static char expect_close; /* is the close expected? */
85
86static spinlock_t io_lock; /* to guard the watchdog from io races */
87
88static int nowayout = WATCHDOG_NOWAYOUT;
89
90/* -- Low level function ----------------------------------------*/
91
92/* unlock the IO chip */
93
94static inline void open_io_config(void)
95{
96 outb(0x55, IOPORT);
97 mdelay(1);
98 outb(0x55, IOPORT);
99}
100
101/* lock the IO chip */
102static inline void close_io_config(void)
103{
104 outb(0xAA, IOPORT);
105}
106
107/* select the IO device */
108static inline void select_io_device(unsigned char devno)
109{
110 outb(0x07, IOPORT);
111 outb(devno, IOPORT+1);
112}
113
114/* write to the control register */
115static inline void write_io_cr(unsigned char reg, unsigned char data)
116{
117 outb(reg, IOPORT);
118 outb(data, IOPORT+1);
119}
120
121/* read from the control register */
122static inline char read_io_cr(unsigned char reg)
123{
124 outb(reg, IOPORT);
125 return inb(IOPORT+1);
126}
127
128/* -- Medium level functions ------------------------------------*/
129
130static inline void gpio_bit12(unsigned char reg)
131{
132 // -- General Purpose I/O Bit 1.2 --
133 // Bit 0, In/Out: 0 = Output, 1 = Input
134 // Bit 1, Polarity: 0 = No Invert, 1 = Invert
135 // Bit 2, Group Enable Intr.: 0 = Disable, 1 = Enable
136 // Bit 3/4, Function select: 00 = GPI/O, 01 = WDT, 10 = P17,
137 // 11 = Either Edge Triggered Intr. 2
138 // Bit 5/6 (Reserved)
139 // Bit 7, Output Type: 0 = Push Pull Bit, 1 = Open Drain
140 write_io_cr(0xE2, reg);
141}
142
143static inline void gpio_bit13(unsigned char reg)
144{
145 // -- General Purpose I/O Bit 1.3 --
146 // Bit 0, In/Out: 0 = Output, 1 = Input
147 // Bit 1, Polarity: 0 = No Invert, 1 = Invert
148 // Bit 2, Group Enable Intr.: 0 = Disable, 1 = Enable
149 // Bit 3, Function select: 0 = GPI/O, 1 = LED
150 // Bit 4-6 (Reserved)
151 // Bit 7, Output Type: 0 = Push Pull Bit, 1 = Open Drain
152 write_io_cr(0xE3, reg);
153}
154
155static inline void wdt_timer_units(unsigned char new_units)
156{
157 // -- Watchdog timer units --
158 // Bit 0-6 (Reserved)
159 // Bit 7, WDT Time-out Value Units Select
160 // (0 = Minutes, 1 = Seconds)
161 write_io_cr(0xF1, new_units);
162}
163
164static inline void wdt_timeout_value(unsigned char new_timeout)
165{
166 // -- Watchdog Timer Time-out Value --
167 // Bit 0-7 Binary coded units (0=Disabled, 1..255)
168 write_io_cr(0xF2, new_timeout);
169}
170
171static inline void wdt_timer_conf(unsigned char conf)
172{
173 // -- Watchdog timer configuration --
174 // Bit 0 Joystick enable: 0* = No Reset, 1 = Reset WDT upon Gameport I/O
175 // Bit 1 Keyboard enable: 0* = No Reset, 1 = Reset WDT upon KBD Intr.
176 // Bit 2 Mouse enable: 0* = No Reset, 1 = Reset WDT upon Mouse Intr.
177 // Bit 3 Reset the timer
178 // (Wrong in SMsC documentation? Given as: PowerLED Timout Enabled)
179 // Bit 4-7 WDT Interrupt Mapping: (0000* = Disabled,
180 // 0001=IRQ1, 0010=(Invalid), 0011=IRQ3 to 1111=IRQ15)
181 write_io_cr(0xF3, conf);
182}
183
184static inline void wdt_timer_ctrl(unsigned char reg)
185{
186 // -- Watchdog timer control --
187 // Bit 0 Status Bit: 0 = Timer counting, 1 = Timeout occured
188 // Bit 1 Power LED Toggle: 0 = Disable Toggle, 1 = Toggle at 1 Hz
189 // Bit 2 Force Timeout: 1 = Forces WD timeout event (self-cleaning)
190 // Bit 3 P20 Force Timeout enabled:
191 // 0 = P20 activity does not generate the WD timeout event
192 // 1 = P20 Allows rising edge of P20, from the keyboard
193 // controller, to force the WD timeout event.
194 // Bit 4 (Reserved)
195 // -- Soft power management --
196 // Bit 5 Stop Counter: 1 = Stop software power down counter
197 // set via register 0xB8, (self-cleaning)
198 // (Upon read: 0 = Counter running, 1 = Counter stopped)
199 // Bit 6 Restart Counter: 1 = Restart software power down counter
200 // set via register 0xB8, (self-cleaning)
201 // Bit 7 SPOFF: 1 = Force software power down (self-cleaning)
202
203 write_io_cr(0xF4, reg);
204}
205
206/* -- Higher level functions ------------------------------------*/
207
208/* initialize watchdog */
209
210static void wb_smsc_wdt_initialize(void)
211{
212 unsigned char old;
213
214 spin_lock(&io_lock);
215 open_io_config();
216 select_io_device(IODEV_NO);
217
218 // enable the watchdog
219 gpio_bit13(0x08); // Select pin 80 = LED not GPIO
220 gpio_bit12(0x0A); // Set pin 79 = WDT not GPIO/Output/Polarity=Invert
221
222 // disable the timeout
223 wdt_timeout_value(0);
224
225 // reset control register
226 wdt_timer_ctrl(0x00);
227
228 // reset configuration register
229 wdt_timer_conf(0x00);
230
231 // read old (timer units) register
232 old = read_io_cr(0xF1) & 0x7F;
233 if (unit == UNIT_SECOND) old |= 0x80; // set to seconds
234
235 // set the watchdog timer units
236 wdt_timer_units(old);
237
238 close_io_config();
239 spin_unlock(&io_lock);
240}
241
242/* shutdown the watchdog */
243
244static void wb_smsc_wdt_shutdown(void)
245{
246 spin_lock(&io_lock);
247 open_io_config();
248 select_io_device(IODEV_NO);
249
250 // disable the watchdog
251 gpio_bit13(0x09);
252 gpio_bit12(0x09);
253
254 // reset watchdog config register
255 wdt_timer_conf(0x00);
256
257 // reset watchdog control register
258 wdt_timer_ctrl(0x00);
259
260 // disable timeout
261 wdt_timeout_value(0x00);
262
263 close_io_config();
264 spin_unlock(&io_lock);
265}
266
267/* set timeout => enable watchdog */
268
269static void wb_smsc_wdt_set_timeout(unsigned char new_timeout)
270{
271 spin_lock(&io_lock);
272 open_io_config();
273 select_io_device(IODEV_NO);
274
275 // set Power LED to blink, if we enable the timeout
276 wdt_timer_ctrl((new_timeout == 0) ? 0x00 : 0x02);
277
278 // set timeout value
279 wdt_timeout_value(new_timeout);
280
281 close_io_config();
282 spin_unlock(&io_lock);
283}
284
285/* get timeout */
286
287static unsigned char wb_smsc_wdt_get_timeout(void)
288{
289 unsigned char set_timeout;
290
291 spin_lock(&io_lock);
292 open_io_config();
293 select_io_device(IODEV_NO);
294 set_timeout = read_io_cr(0xF2);
295 close_io_config();
296 spin_unlock(&io_lock);
297
298 return set_timeout;
299}
300
301/* disable watchdog */
302
303static void wb_smsc_wdt_disable(void)
304{
305 // set the timeout to 0 to disable the watchdog
306 wb_smsc_wdt_set_timeout(0);
307}
308
309/* enable watchdog by setting the current timeout */
310
311static void wb_smsc_wdt_enable(void)
312{
313 // set the current timeout...
314 wb_smsc_wdt_set_timeout(timeout);
315}
316
317/* reset the timer */
318
319static void wb_smsc_wdt_reset_timer(void)
320{
321 spin_lock(&io_lock);
322 open_io_config();
323 select_io_device(IODEV_NO);
324
325 // reset the timer
326 wdt_timeout_value(timeout);
327 wdt_timer_conf(0x08);
328
329 close_io_config();
330 spin_unlock(&io_lock);
331}
332
333/* return, if the watchdog is enabled (timeout is set...) */
334
335static int wb_smsc_wdt_status(void)
336{
337 return (wb_smsc_wdt_get_timeout() == 0) ? 0 : WDIOF_KEEPALIVEPING;
338}
339
340
341/* -- File operations -------------------------------------------*/
342
343/* open => enable watchdog and set initial timeout */
344
345static int wb_smsc_wdt_open(struct inode *inode, struct file *file)
346{
347 /* /dev/watchdog can only be opened once */
348
349 if (test_and_set_bit(0, &timer_enabled))
350 return -EBUSY;
351
352 if (nowayout)
353 __module_get(THIS_MODULE);
354
355 /* Reload and activate timer */
356 wb_smsc_wdt_enable();
357
358 printk(KERN_INFO MODNAME "Watchdog enabled. Timeout set to %d %s.\n", timeout, (unit == UNIT_SECOND) ? "second(s)" : "minute(s)");
359
360 return nonseekable_open(inode, file);
361}
362
363/* close => shut off the timer */
364
365static int wb_smsc_wdt_release(struct inode *inode, struct file *file)
366{
367 /* Shut off the timer. */
368
369 if (expect_close == 42) {
370 wb_smsc_wdt_disable();
371 printk(KERN_INFO MODNAME "Watchdog disabled, sleeping again...\n");
372 } else {
373 printk(KERN_CRIT MODNAME "Unexpected close, not stopping watchdog!\n");
374 wb_smsc_wdt_reset_timer();
375 }
376
377 clear_bit(0, &timer_enabled);
378 expect_close = 0;
379 return 0;
380}
381
382/* write => update the timer to keep the machine alive */
383
384static ssize_t wb_smsc_wdt_write(struct file *file, const char __user *data,
385 size_t len, loff_t *ppos)
386{
387 /* See if we got the magic character 'V' and reload the timer */
388 if (len) {
389 if (!nowayout) {
390 size_t i;
391
392 /* reset expect flag */
393 expect_close = 0;
394
395 /* scan to see whether or not we got the magic character */
396 for (i = 0; i != len; i++) {
397 char c;
398 if (get_user(c, data+i))
399 return -EFAULT;
400 if (c == 'V')
401 expect_close = 42;
402 }
403 }
404
405 /* someone wrote to us, we should reload the timer */
406 wb_smsc_wdt_reset_timer();
407 }
408 return len;
409}
410
411/* ioctl => control interface */
412
413static int wb_smsc_wdt_ioctl(struct inode *inode, struct file *file,
414 unsigned int cmd, unsigned long arg)
415{
416 int new_timeout;
417
418 union {
419 struct watchdog_info __user *ident;
420 int __user *i;
421 } uarg;
422
423 static struct watchdog_info ident = {
424 .options = WDIOF_KEEPALIVEPING |
425 WDIOF_SETTIMEOUT |
426 WDIOF_MAGICCLOSE,
427 .firmware_version = 0,
428 .identity = "SMsC 37B787 Watchdog"
429 };
430
431 uarg.i = (int __user *)arg;
432
433 switch (cmd) {
434 default:
435 return -ENOTTY;
436
437 case WDIOC_GETSUPPORT:
438 return copy_to_user(uarg.ident, &ident,
439 sizeof(ident)) ? -EFAULT : 0;
440
441 case WDIOC_GETSTATUS:
442 return put_user(wb_smsc_wdt_status(), uarg.i);
443
444 case WDIOC_GETBOOTSTATUS:
445 return put_user(0, uarg.i);
446
447 case WDIOC_KEEPALIVE:
448 wb_smsc_wdt_reset_timer();
449 return 0;
450
451 case WDIOC_SETTIMEOUT:
452 if (get_user(new_timeout, uarg.i))
453 return -EFAULT;
454
455 // the API states this is given in secs
456 if (unit == UNIT_MINUTE)
457 new_timeout /= 60;
458
459 if (new_timeout < 0 || new_timeout > MAX_TIMEOUT)
460 return -EINVAL;
461
462 timeout = new_timeout;
463 wb_smsc_wdt_set_timeout(timeout);
464
465 // fall through and return the new timeout...
466
467 case WDIOC_GETTIMEOUT:
468
469 new_timeout = timeout;
470
471 if (unit == UNIT_MINUTE)
472 new_timeout *= 60;
473
474 return put_user(new_timeout, uarg.i);
475
476 case WDIOC_SETOPTIONS:
477 {
478 int options, retval = -EINVAL;
479
480 if (get_user(options, uarg.i))
481 return -EFAULT;
482
483 if (options & WDIOS_DISABLECARD) {
484 wb_smsc_wdt_disable();
485 retval = 0;
486 }
487
488 if (options & WDIOS_ENABLECARD) {
489 wb_smsc_wdt_enable();
490 retval = 0;
491 }
492
493 return retval;
494 }
495 }
496}
497
498/* -- Notifier funtions -----------------------------------------*/
499
500static int wb_smsc_wdt_notify_sys(struct notifier_block *this, unsigned long code, void *unused)
501{
502 if (code == SYS_DOWN || code == SYS_HALT)
503 {
504 // set timeout to 0, to avoid possible race-condition
505 timeout = 0;
506 wb_smsc_wdt_disable();
507 }
508 return NOTIFY_DONE;
509}
510
511/* -- Module's structures ---------------------------------------*/
512
513static struct file_operations wb_smsc_wdt_fops =
514{
515 .owner = THIS_MODULE,
516 .llseek = no_llseek,
517 .write = wb_smsc_wdt_write,
518 .ioctl = wb_smsc_wdt_ioctl,
519 .open = wb_smsc_wdt_open,
520 .release = wb_smsc_wdt_release,
521};
522
523static struct notifier_block wb_smsc_wdt_notifier =
524{
525 .notifier_call = wb_smsc_wdt_notify_sys,
526};
527
528static struct miscdevice wb_smsc_wdt_miscdev =
529{
530 .minor = WATCHDOG_MINOR,
531 .name = "watchdog",
532 .fops = &wb_smsc_wdt_fops,
533};
534
535/* -- Module init functions -------------------------------------*/
536
537/* module's "constructor" */
538
539static int __init wb_smsc_wdt_init(void)
540{
541 int ret;
542
543 spin_lock_init(&io_lock);
544
545 printk("SMsC 37B787 watchdog component driver " VERSION " initialising...\n");
546
547 if (!request_region(IOPORT, IOPORT_SIZE, "SMsC 37B787 watchdog")) {
548 printk(KERN_ERR MODNAME "Unable to register IO port %#x\n", IOPORT);
549 ret = -EBUSY;
550 goto out_pnp;
551 }
552
553 // set new maximum, if it's too big
554 if (timeout > MAX_TIMEOUT)
555 timeout = MAX_TIMEOUT;
556
557 // init the watchdog timer
558 wb_smsc_wdt_initialize();
559
560 ret = register_reboot_notifier(&wb_smsc_wdt_notifier);
561 if (ret) {
562 printk(KERN_ERR MODNAME "Unable to register reboot notifier err = %d\n", ret);
563 goto out_io;
564 }
565
566 ret = misc_register(&wb_smsc_wdt_miscdev);
567 if (ret) {
568 printk(KERN_ERR MODNAME "Unable to register miscdev on minor %d\n", WATCHDOG_MINOR);
569 goto out_rbt;
570 }
571
572 // output info
573 printk(KERN_INFO MODNAME "Timeout set to %d %s.\n", timeout, (unit == UNIT_SECOND) ? "second(s)" : "minute(s)");
574 printk(KERN_INFO MODNAME "Watchdog initialized and sleeping (nowayout=%d)...\n", nowayout);
575
576 // ret = 0
577
578out_clean:
579 return ret;
580
581out_rbt:
582 unregister_reboot_notifier(&wb_smsc_wdt_notifier);
583
584out_io:
585 release_region(IOPORT, IOPORT_SIZE);
586
587out_pnp:
588 goto out_clean;
589}
590
591/* module's "destructor" */
592
593static void __exit wb_smsc_wdt_exit(void)
594{
595 /* Stop the timer before we leave */
596 if (!nowayout)
597 {
598 wb_smsc_wdt_shutdown();
599 printk(KERN_INFO MODNAME "Watchdog disabled.\n");
600 }
601
602 misc_deregister(&wb_smsc_wdt_miscdev);
603 unregister_reboot_notifier(&wb_smsc_wdt_notifier);
604 release_region(IOPORT, IOPORT_SIZE);
605
606 printk("SMsC 37B787 watchdog component driver removed.\n");
607}
608
609module_init(wb_smsc_wdt_init);
610module_exit(wb_smsc_wdt_exit);
611
612MODULE_AUTHOR("Sven Anders <anders@anduras.de>");
613MODULE_DESCRIPTION("Driver for SMsC 37B787 watchdog component (Version " VERSION ")");
614MODULE_LICENSE("GPL");
615
616MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
617
618#ifdef SMSC_SUPPORT_MINUTES
619module_param(unit, int, 0);
620MODULE_PARM_DESC(unit, "set unit to use, 0=seconds or 1=minutes, default is 0");
621#endif
622
623module_param(timeout, int, 0);
624MODULE_PARM_DESC(timeout, "range is 1-255 units, default is 60");
625
626module_param(nowayout, int, 0);
627MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
diff --git a/drivers/char/watchdog/w83627hf_wdt.c b/drivers/char/watchdog/w83627hf_wdt.c
index b4adc527e687..07d4bff27226 100644
--- a/drivers/char/watchdog/w83627hf_wdt.c
+++ b/drivers/char/watchdog/w83627hf_wdt.c
@@ -33,6 +33,7 @@
33#include <linux/notifier.h> 33#include <linux/notifier.h>
34#include <linux/reboot.h> 34#include <linux/reboot.h>
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/spinlock.h>
36 37
37#include <asm/io.h> 38#include <asm/io.h>
38#include <asm/uaccess.h> 39#include <asm/uaccess.h>
@@ -44,6 +45,7 @@
44 45
45static unsigned long wdt_is_open; 46static unsigned long wdt_is_open;
46static char expect_close; 47static char expect_close;
48static spinlock_t io_lock;
47 49
48/* You must set this - there is no sane way to probe for this board. */ 50/* You must set this - there is no sane way to probe for this board. */
49static int wdt_io = 0x2E; 51static int wdt_io = 0x2E;
@@ -110,12 +112,16 @@ w83627hf_init(void)
110static void 112static void
111wdt_ctrl(int timeout) 113wdt_ctrl(int timeout)
112{ 114{
115 spin_lock(&io_lock);
116
113 w83627hf_select_wd_register(); 117 w83627hf_select_wd_register();
114 118
115 outb_p(0xF6, WDT_EFER); /* Select CRF6 */ 119 outb_p(0xF6, WDT_EFER); /* Select CRF6 */
116 outb_p(timeout, WDT_EFDR); /* Write Timeout counter to CRF6 */ 120 outb_p(timeout, WDT_EFDR); /* Write Timeout counter to CRF6 */
117 121
118 w83627hf_unselect_wd_register(); 122 w83627hf_unselect_wd_register();
123
124 spin_unlock(&io_lock);
119} 125}
120 126
121static int 127static int
@@ -303,6 +309,8 @@ wdt_init(void)
303{ 309{
304 int ret; 310 int ret;
305 311
312 spin_lock_init(&io_lock);
313
306 printk(KERN_INFO "WDT driver for the Winbond(TM) W83627HF Super I/O chip initialising.\n"); 314 printk(KERN_INFO "WDT driver for the Winbond(TM) W83627HF Super I/O chip initialising.\n");
307 315
308 if (wdt_set_heartbeat(timeout)) { 316 if (wdt_set_heartbeat(timeout)) {
diff --git a/drivers/char/watchdog/w83697hf_wdt.c b/drivers/char/watchdog/w83697hf_wdt.c
new file mode 100644
index 000000000000..7768b55487c8
--- /dev/null
+++ b/drivers/char/watchdog/w83697hf_wdt.c
@@ -0,0 +1,450 @@
1/*
2 * w83697hf/hg WDT driver
3 *
4 * (c) Copyright 2006 Samuel Tardieu <sam@rfc1149.net>
5 * (c) Copyright 2006 Marcus Junker <junker@anduras.de>
6 *
7 * Based on w83627hf_wdt.c which is based on advantechwdt.c
8 * which is based on wdt.c.
9 * Original copyright messages:
10 *
11 * (c) Copyright 2003 Pádraig Brady <P@draigBrady.com>
12 *
13 * (c) Copyright 2000-2001 Marek Michalkiewicz <marekm@linux.org.pl>
14 *
15 * (c) Copyright 1996 Alan Cox <alan@redhat.com>, All Rights Reserved.
16 * http://www.redhat.com
17 *
18 * This program is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU General Public License
20 * as published by the Free Software Foundation; either version
21 * 2 of the License, or (at your option) any later version.
22 *
23 * Neither Marcus Junker nor ANDURAS AG admit liability nor provide
24 * warranty for any of this software. This material is provided
25 * "AS-IS" and at no charge.
26 */
27
28#include <linux/module.h>
29#include <linux/moduleparam.h>
30#include <linux/types.h>
31#include <linux/miscdevice.h>
32#include <linux/watchdog.h>
33#include <linux/fs.h>
34#include <linux/ioport.h>
35#include <linux/notifier.h>
36#include <linux/reboot.h>
37#include <linux/init.h>
38#include <linux/spinlock.h>
39
40#include <asm/io.h>
41#include <asm/uaccess.h>
42#include <asm/system.h>
43
44#define WATCHDOG_NAME "w83697hf/hg WDT"
45#define PFX WATCHDOG_NAME ": "
46#define WATCHDOG_TIMEOUT 60 /* 60 sec default timeout */
47
48static unsigned long wdt_is_open;
49static char expect_close;
50static spinlock_t io_lock;
51
52/* You must set this - there is no sane way to probe for this board. */
53static int wdt_io = 0x2e;
54module_param(wdt_io, int, 0);
55MODULE_PARM_DESC(wdt_io, "w83697hf/hg WDT io port (default 0x2e, 0 = autodetect)");
56
57static int timeout = WATCHDOG_TIMEOUT; /* in seconds */
58module_param(timeout, int, 0);
59MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. 1<= timeout <=255, default=" __MODULE_STRING(WATCHDOG_TIMEOUT) ".");
60
61static int nowayout = WATCHDOG_NOWAYOUT;
62module_param(nowayout, int, 0);
63MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
64
65/*
66 * Kernel methods.
67 */
68
69#define W83697HF_EFER (wdt_io+0) /* Extended Function Enable Register */
70#define W83697HF_EFIR (wdt_io+0) /* Extended Function Index Register (same as EFER) */
71#define W83697HF_EFDR (wdt_io+1) /* Extended Function Data Register */
72
73static inline void
74w83697hf_unlock(void)
75{
76 outb_p(0x87, W83697HF_EFER); /* Enter extended function mode */
77 outb_p(0x87, W83697HF_EFER); /* Again according to manual */
78}
79
80static inline void
81w83697hf_lock(void)
82{
83 outb_p(0xAA, W83697HF_EFER); /* Leave extended function mode */
84}
85
86/*
87 * The three functions w83697hf_get_reg(), w83697hf_set_reg() and
88 * w83697hf_write_timeout() must be called with the device unlocked.
89 */
90
91static unsigned char
92w83697hf_get_reg(unsigned char reg)
93{
94 outb_p(reg, W83697HF_EFIR);
95 return inb_p(W83697HF_EFDR);
96}
97
98static void
99w83697hf_set_reg(unsigned char reg, unsigned char data)
100{
101 outb_p(reg, W83697HF_EFIR);
102 outb_p(data, W83697HF_EFDR);
103}
104
105static void
106w83697hf_write_timeout(int timeout)
107{
108 w83697hf_set_reg(0xF4, timeout); /* Write Timeout counter to CRF4 */
109}
110
111static void
112w83697hf_select_wdt(void)
113{
114 w83697hf_unlock();
115 w83697hf_set_reg(0x07, 0x08); /* Switch to logic device 8 (GPIO2) */
116}
117
118static inline void
119w83697hf_deselect_wdt(void)
120{
121 w83697hf_lock();
122}
123
124static void
125w83697hf_init(void)
126{
127 unsigned char bbuf;
128
129 w83697hf_select_wdt();
130
131 bbuf = w83697hf_get_reg(0x29);
132 bbuf &= ~0x60;
133 bbuf |= 0x20;
134 w83697hf_set_reg(0x29, bbuf); /* Set pin 119 to WDTO# mode (= CR29, WDT0) */
135
136 bbuf = w83697hf_get_reg(0xF3);
137 bbuf &= ~0x04;
138 w83697hf_set_reg(0xF3, bbuf); /* Count mode is seconds */
139
140 w83697hf_deselect_wdt();
141}
142
143static int
144wdt_ping(void)
145{
146 spin_lock(&io_lock);
147 w83697hf_select_wdt();
148
149 w83697hf_write_timeout(timeout);
150
151 w83697hf_deselect_wdt();
152 spin_unlock(&io_lock);
153 return 0;
154}
155
156static int
157wdt_enable(void)
158{
159 spin_lock(&io_lock);
160 w83697hf_select_wdt();
161
162 w83697hf_write_timeout(timeout);
163 w83697hf_set_reg(0x30, 1); /* Enable timer */
164
165 w83697hf_deselect_wdt();
166 spin_unlock(&io_lock);
167 return 0;
168}
169
170static int
171wdt_disable(void)
172{
173 spin_lock(&io_lock);
174 w83697hf_select_wdt();
175
176 w83697hf_set_reg(0x30, 0); /* Disable timer */
177 w83697hf_write_timeout(0);
178
179 w83697hf_deselect_wdt();
180 spin_unlock(&io_lock);
181 return 0;
182}
183
184static int
185wdt_set_heartbeat(int t)
186{
187 if ((t < 1) || (t > 255))
188 return -EINVAL;
189
190 timeout = t;
191 return 0;
192}
193
194static ssize_t
195wdt_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
196{
197 if (count) {
198 if (!nowayout) {
199 size_t i;
200
201 expect_close = 0;
202
203 for (i = 0; i != count; i++) {
204 char c;
205 if (get_user(c, buf+i))
206 return -EFAULT;
207 if (c == 'V')
208 expect_close = 42;
209 }
210 }
211 wdt_ping();
212 }
213 return count;
214}
215
216static int
217wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
218 unsigned long arg)
219{
220 void __user *argp = (void __user *)arg;
221 int __user *p = argp;
222 int new_timeout;
223 static struct watchdog_info ident = {
224 .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE,
225 .firmware_version = 1,
226 .identity = "W83697HF WDT",
227 };
228
229 switch (cmd) {
230 case WDIOC_GETSUPPORT:
231 if (copy_to_user(argp, &ident, sizeof(ident)))
232 return -EFAULT;
233 break;
234
235 case WDIOC_GETSTATUS:
236 case WDIOC_GETBOOTSTATUS:
237 return put_user(0, p);
238
239 case WDIOC_KEEPALIVE:
240 wdt_ping();
241 break;
242
243 case WDIOC_SETTIMEOUT:
244 if (get_user(new_timeout, p))
245 return -EFAULT;
246 if (wdt_set_heartbeat(new_timeout))
247 return -EINVAL;
248 wdt_ping();
249 /* Fall */
250
251 case WDIOC_GETTIMEOUT:
252 return put_user(timeout, p);
253
254 case WDIOC_SETOPTIONS:
255 {
256 int options, retval = -EINVAL;
257
258 if (get_user(options, p))
259 return -EFAULT;
260
261 if (options & WDIOS_DISABLECARD) {
262 wdt_disable();
263 retval = 0;
264 }
265
266 if (options & WDIOS_ENABLECARD) {
267 wdt_enable();
268 retval = 0;
269 }
270
271 return retval;
272 }
273
274 default:
275 return -ENOTTY;
276 }
277 return 0;
278}
279
280static int
281wdt_open(struct inode *inode, struct file *file)
282{
283 if (test_and_set_bit(0, &wdt_is_open))
284 return -EBUSY;
285 /*
286 * Activate
287 */
288
289 wdt_enable();
290 return nonseekable_open(inode, file);
291}
292
293static int
294wdt_close(struct inode *inode, struct file *file)
295{
296 if (expect_close == 42) {
297 wdt_disable();
298 } else {
299 printk (KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n");
300 wdt_ping();
301 }
302 expect_close = 0;
303 clear_bit(0, &wdt_is_open);
304 return 0;
305}
306
307/*
308 * Notifier for system down
309 */
310
311static int
312wdt_notify_sys(struct notifier_block *this, unsigned long code,
313 void *unused)
314{
315 if (code == SYS_DOWN || code == SYS_HALT) {
316 /* Turn the WDT off */
317 wdt_disable();
318 }
319 return NOTIFY_DONE;
320}
321
322/*
323 * Kernel Interfaces
324 */
325
326static struct file_operations wdt_fops = {
327 .owner = THIS_MODULE,
328 .llseek = no_llseek,
329 .write = wdt_write,
330 .ioctl = wdt_ioctl,
331 .open = wdt_open,
332 .release = wdt_close,
333};
334
335static struct miscdevice wdt_miscdev = {
336 .minor = WATCHDOG_MINOR,
337 .name = "watchdog",
338 .fops = &wdt_fops,
339};
340
341/*
342 * The WDT needs to learn about soft shutdowns in order to
343 * turn the timebomb registers off.
344 */
345
346static struct notifier_block wdt_notifier = {
347 .notifier_call = wdt_notify_sys,
348};
349
350static int
351w83697hf_check_wdt(void)
352{
353 if (!request_region(wdt_io, 2, WATCHDOG_NAME)) {
354 printk (KERN_ERR PFX "I/O address 0x%x already in use\n", wdt_io);
355 return -EIO;
356 }
357
358 printk (KERN_DEBUG PFX "Looking for watchdog at address 0x%x\n", wdt_io);
359 w83697hf_unlock();
360 if (w83697hf_get_reg(0x20) == 0x60) {
361 printk (KERN_INFO PFX "watchdog found at address 0x%x\n", wdt_io);
362 w83697hf_lock();
363 return 0;
364 }
365 w83697hf_lock(); /* Reprotect in case it was a compatible device */
366
367 printk (KERN_INFO PFX "watchdog not found at address 0x%x\n", wdt_io);
368 release_region(wdt_io, 2);
369 return -EIO;
370}
371
372static int w83697hf_ioports[] = { 0x2e, 0x4e, 0x00 };
373
374static int __init
375wdt_init(void)
376{
377 int ret, i, found = 0;
378
379 spin_lock_init(&io_lock);
380
381 printk (KERN_INFO PFX "WDT driver for W83697HF/HG initializing\n");
382
383 if (wdt_io == 0) {
384 /* we will autodetect the W83697HF/HG watchdog */
385 for (i = 0; ((!found) && (w83697hf_ioports[i] != 0)); i++) {
386 wdt_io = w83697hf_ioports[i];
387 if (!w83697hf_check_wdt())
388 found++;
389 }
390 } else {
391 if (!w83697hf_check_wdt())
392 found++;
393 }
394
395 if (!found) {
396 printk (KERN_ERR PFX "No W83697HF/HG could be found\n");
397 ret = -EIO;
398 goto out;
399 }
400
401 w83697hf_init();
402 wdt_disable(); /* Disable watchdog until first use */
403
404 if (wdt_set_heartbeat(timeout)) {
405 wdt_set_heartbeat(WATCHDOG_TIMEOUT);
406 printk (KERN_INFO PFX "timeout value must be 1<=timeout<=255, using %d\n",
407 WATCHDOG_TIMEOUT);
408 }
409
410 ret = register_reboot_notifier(&wdt_notifier);
411 if (ret != 0) {
412 printk (KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",
413 ret);
414 goto unreg_regions;
415 }
416
417 ret = misc_register(&wdt_miscdev);
418 if (ret != 0) {
419 printk (KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
420 WATCHDOG_MINOR, ret);
421 goto unreg_reboot;
422 }
423
424 printk (KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d)\n",
425 timeout, nowayout);
426
427out:
428 return ret;
429unreg_reboot:
430 unregister_reboot_notifier(&wdt_notifier);
431unreg_regions:
432 release_region(wdt_io, 2);
433 goto out;
434}
435
436static void __exit
437wdt_exit(void)
438{
439 misc_deregister(&wdt_miscdev);
440 unregister_reboot_notifier(&wdt_notifier);
441 release_region(wdt_io, 2);
442}
443
444module_init(wdt_init);
445module_exit(wdt_exit);
446
447MODULE_LICENSE("GPL");
448MODULE_AUTHOR("Marcus Junker <junker@anduras.de>, Samuel Tardieu <sam@rfc1149.net>");
449MODULE_DESCRIPTION("w83697hf/hg WDT driver");
450MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
diff --git a/drivers/clocksource/acpi_pm.c b/drivers/clocksource/acpi_pm.c
index 7ad3be8c0f49..7fcb77a9d011 100644
--- a/drivers/clocksource/acpi_pm.c
+++ b/drivers/clocksource/acpi_pm.c
@@ -54,8 +54,8 @@ static cycle_t acpi_pm_read_verified(void)
54 v1 = read_pmtmr(); 54 v1 = read_pmtmr();
55 v2 = read_pmtmr(); 55 v2 = read_pmtmr();
56 v3 = read_pmtmr(); 56 v3 = read_pmtmr();
57 } while ((v1 > v2 && v1 < v3) || (v2 > v3 && v2 < v1) 57 } while (unlikely((v1 > v2 && v1 < v3) || (v2 > v3 && v2 < v1)
58 || (v3 > v1 && v3 < v2)); 58 || (v3 > v1 && v3 < v2)));
59 59
60 return (cycle_t)v2; 60 return (cycle_t)v2;
61} 61}
@@ -138,6 +138,8 @@ static void __devinit acpi_pm_check_graylist(struct pci_dev *dev)
138} 138}
139DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0, 139DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0,
140 acpi_pm_check_graylist); 140 acpi_pm_check_graylist);
141DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_LE,
142 acpi_pm_check_graylist);
141#endif 143#endif
142 144
143 145
diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
index 2cc71b66231e..491779af8d55 100644
--- a/drivers/cpufreq/Kconfig
+++ b/drivers/cpufreq/Kconfig
@@ -107,6 +107,7 @@ config CPU_FREQ_GOV_USERSPACE
107 107
108config CPU_FREQ_GOV_ONDEMAND 108config CPU_FREQ_GOV_ONDEMAND
109 tristate "'ondemand' cpufreq policy governor" 109 tristate "'ondemand' cpufreq policy governor"
110 select CPU_FREQ_TABLE
110 help 111 help
111 'ondemand' - This driver adds a dynamic cpufreq policy governor. 112 'ondemand' - This driver adds a dynamic cpufreq policy governor.
112 The governor does a periodic polling and 113 The governor does a periodic polling and
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 86e69b7f9122..dd0c2623e27b 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -59,7 +59,7 @@ static int __init init_cpufreq_transition_notifier_list(void)
59 srcu_init_notifier_head(&cpufreq_transition_notifier_list); 59 srcu_init_notifier_head(&cpufreq_transition_notifier_list);
60 return 0; 60 return 0;
61} 61}
62core_initcall(init_cpufreq_transition_notifier_list); 62pure_initcall(init_cpufreq_transition_notifier_list);
63 63
64static LIST_HEAD(cpufreq_governor_list); 64static LIST_HEAD(cpufreq_governor_list);
65static DEFINE_MUTEX (cpufreq_governor_mutex); 65static DEFINE_MUTEX (cpufreq_governor_mutex);
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index 4bde30bb3be7..75e9e38330ff 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -230,34 +230,43 @@ static struct kobj_type ktype_memctrl = {
230 */ 230 */
231static int edac_sysfs_memctrl_setup(void) 231static int edac_sysfs_memctrl_setup(void)
232{ 232{
233 int err=0; 233 int err = 0;
234 234
235 debugf1("%s()\n", __func__); 235 debugf1("%s()\n", __func__);
236 236
237 /* create the /sys/devices/system/edac directory */ 237 /* create the /sys/devices/system/edac directory */
238 err = sysdev_class_register(&edac_class); 238 err = sysdev_class_register(&edac_class);
239 239
240 if (!err) { 240 if (err) {
241 /* Init the MC's kobject */ 241 debugf1("%s() error=%d\n", __func__, err);
242 memset(&edac_memctrl_kobj, 0, sizeof (edac_memctrl_kobj)); 242 return err;
243 edac_memctrl_kobj.parent = &edac_class.kset.kobj; 243 }
244 edac_memctrl_kobj.ktype = &ktype_memctrl;
245 244
246 /* generate sysfs "..../edac/mc" */ 245 /* Init the MC's kobject */
247 err = kobject_set_name(&edac_memctrl_kobj,"mc"); 246 memset(&edac_memctrl_kobj, 0, sizeof (edac_memctrl_kobj));
247 edac_memctrl_kobj.parent = &edac_class.kset.kobj;
248 edac_memctrl_kobj.ktype = &ktype_memctrl;
248 249
249 if (!err) { 250 /* generate sysfs "..../edac/mc" */
250 /* FIXME: maybe new sysdev_create_subdir() */ 251 err = kobject_set_name(&edac_memctrl_kobj,"mc");
251 err = kobject_register(&edac_memctrl_kobj);
252 252
253 if (err) 253 if (err)
254 debugf1("Failed to register '.../edac/mc'\n"); 254 goto fail;
255 else 255
256 debugf1("Registered '.../edac/mc' kobject\n"); 256 /* FIXME: maybe new sysdev_create_subdir() */
257 } 257 err = kobject_register(&edac_memctrl_kobj);
258 } else 258
259 debugf1("%s() error=%d\n", __func__, err); 259 if (err) {
260 debugf1("Failed to register '.../edac/mc'\n");
261 goto fail;
262 }
260 263
264 debugf1("Registered '.../edac/mc' kobject\n");
265
266 return 0;
267
268fail:
269 sysdev_class_unregister(&edac_class);
261 return err; 270 return err;
262} 271}
263 272
diff --git a/drivers/eisa/eisa-bus.c b/drivers/eisa/eisa-bus.c
index 3a365e159d89..d944647c82c2 100644
--- a/drivers/eisa/eisa-bus.c
+++ b/drivers/eisa/eisa-bus.c
@@ -226,14 +226,26 @@ static int __init eisa_init_device (struct eisa_root_device *root,
226 226
227static int __init eisa_register_device (struct eisa_device *edev) 227static int __init eisa_register_device (struct eisa_device *edev)
228{ 228{
229 if (device_register (&edev->dev)) 229 int rc = device_register (&edev->dev);
230 return -1; 230 if (rc)
231 return rc;
231 232
232 device_create_file (&edev->dev, &dev_attr_signature); 233 rc = device_create_file (&edev->dev, &dev_attr_signature);
233 device_create_file (&edev->dev, &dev_attr_enabled); 234 if (rc) goto err_devreg;
234 device_create_file (&edev->dev, &dev_attr_modalias); 235 rc = device_create_file (&edev->dev, &dev_attr_enabled);
236 if (rc) goto err_sig;
237 rc = device_create_file (&edev->dev, &dev_attr_modalias);
238 if (rc) goto err_enab;
235 239
236 return 0; 240 return 0;
241
242err_enab:
243 device_remove_file (&edev->dev, &dev_attr_enabled);
244err_sig:
245 device_remove_file (&edev->dev, &dev_attr_signature);
246err_devreg:
247 device_unregister(&edev->dev);
248 return rc;
237} 249}
238 250
239static int __init eisa_request_resources (struct eisa_root_device *root, 251static int __init eisa_request_resources (struct eisa_root_device *root,
diff --git a/drivers/fc4/fc.c b/drivers/fc4/fc.c
index 22d17474755f..ca4e67a022d0 100644
--- a/drivers/fc4/fc.c
+++ b/drivers/fc4/fc.c
@@ -70,9 +70,9 @@
70 70
71#define FCP_CMND(SCpnt) ((fcp_cmnd *)&(SCpnt->SCp)) 71#define FCP_CMND(SCpnt) ((fcp_cmnd *)&(SCpnt->SCp))
72#define FC_SCMND(SCpnt) ((fc_channel *)(SCpnt->device->host->hostdata[0])) 72#define FC_SCMND(SCpnt) ((fc_channel *)(SCpnt->device->host->hostdata[0]))
73#define SC_FCMND(fcmnd) ((Scsi_Cmnd *)((long)fcmnd - (long)&(((Scsi_Cmnd *)0)->SCp))) 73#define SC_FCMND(fcmnd) ((struct scsi_cmnd *)((long)fcmnd - (long)&(((struct scsi_cmnd *)0)->SCp)))
74 74
75static int fcp_scsi_queue_it(fc_channel *, Scsi_Cmnd *, fcp_cmnd *, int); 75static int fcp_scsi_queue_it(fc_channel *, struct scsi_cmnd *, fcp_cmnd *, int);
76void fcp_queue_empty(fc_channel *); 76void fcp_queue_empty(fc_channel *);
77 77
78static void fcp_scsi_insert_queue (fc_channel *fc, fcp_cmnd *fcmd) 78static void fcp_scsi_insert_queue (fc_channel *fc, fcp_cmnd *fcmd)
@@ -378,14 +378,14 @@ void fcp_register(fc_channel *fc, u8 type, int unregister)
378 printk ("FC: %segistering unknown type %02x\n", unregister ? "Unr" : "R", type); 378 printk ("FC: %segistering unknown type %02x\n", unregister ? "Unr" : "R", type);
379} 379}
380 380
381static void fcp_scsi_done(Scsi_Cmnd *SCpnt); 381static void fcp_scsi_done(struct scsi_cmnd *SCpnt);
382 382
383static inline void fcp_scsi_receive(fc_channel *fc, int token, int status, fc_hdr *fch) 383static inline void fcp_scsi_receive(fc_channel *fc, int token, int status, fc_hdr *fch)
384{ 384{
385 fcp_cmnd *fcmd; 385 fcp_cmnd *fcmd;
386 fcp_rsp *rsp; 386 fcp_rsp *rsp;
387 int host_status; 387 int host_status;
388 Scsi_Cmnd *SCpnt; 388 struct scsi_cmnd *SCpnt;
389 int sense_len; 389 int sense_len;
390 int rsp_status; 390 int rsp_status;
391 391
@@ -757,13 +757,14 @@ void fcp_release(fc_channel *fcchain, int count) /* count must > 0 */
757} 757}
758 758
759 759
760static void fcp_scsi_done (Scsi_Cmnd *SCpnt) 760static void fcp_scsi_done(struct scsi_cmnd *SCpnt)
761{ 761{
762 if (FCP_CMND(SCpnt)->done) 762 if (FCP_CMND(SCpnt)->done)
763 FCP_CMND(SCpnt)->done(SCpnt); 763 FCP_CMND(SCpnt)->done(SCpnt);
764} 764}
765 765
766static int fcp_scsi_queue_it(fc_channel *fc, Scsi_Cmnd *SCpnt, fcp_cmnd *fcmd, int prepare) 766static int fcp_scsi_queue_it(fc_channel *fc, struct scsi_cmnd *SCpnt,
767 fcp_cmnd *fcmd, int prepare)
767{ 768{
768 long i; 769 long i;
769 fcp_cmd *cmd; 770 fcp_cmd *cmd;
@@ -837,7 +838,8 @@ static int fcp_scsi_queue_it(fc_channel *fc, Scsi_Cmnd *SCpnt, fcp_cmnd *fcmd, i
837 return 0; 838 return 0;
838} 839}
839 840
840int fcp_scsi_queuecommand(Scsi_Cmnd *SCpnt, void (* done)(Scsi_Cmnd *)) 841int fcp_scsi_queuecommand(struct scsi_cmnd *SCpnt,
842 void (* done)(struct scsi_cmnd *))
841{ 843{
842 fcp_cmnd *fcmd = FCP_CMND(SCpnt); 844 fcp_cmnd *fcmd = FCP_CMND(SCpnt);
843 fc_channel *fc = FC_SCMND(SCpnt); 845 fc_channel *fc = FC_SCMND(SCpnt);
@@ -873,7 +875,7 @@ void fcp_queue_empty(fc_channel *fc)
873 } 875 }
874} 876}
875 877
876int fcp_scsi_abort(Scsi_Cmnd *SCpnt) 878int fcp_scsi_abort(struct scsi_cmnd *SCpnt)
877{ 879{
878 /* Internal bookkeeping only. Lose 1 cmd_slots slot. */ 880 /* Internal bookkeeping only. Lose 1 cmd_slots slot. */
879 fcp_cmnd *fcmd = FCP_CMND(SCpnt); 881 fcp_cmnd *fcmd = FCP_CMND(SCpnt);
@@ -910,7 +912,7 @@ int fcp_scsi_abort(Scsi_Cmnd *SCpnt)
910} 912}
911 913
912#if 0 914#if 0
913void fcp_scsi_reset_done(Scsi_Cmnd *SCpnt) 915void fcp_scsi_reset_done(struct scsi_cmnd *SCpnt)
914{ 916{
915 fc_channel *fc = FC_SCMND(SCpnt); 917 fc_channel *fc = FC_SCMND(SCpnt);
916 918
@@ -921,7 +923,7 @@ void fcp_scsi_reset_done(Scsi_Cmnd *SCpnt)
921 923
922#define FCP_RESET_TIMEOUT (2*HZ) 924#define FCP_RESET_TIMEOUT (2*HZ)
923 925
924int fcp_scsi_dev_reset(Scsi_Cmnd *SCpnt) 926int fcp_scsi_dev_reset(struct scsi_cmnd *SCpnt)
925{ 927{
926#if 0 /* broken junk, but if davem wants to compile this driver, let him.. */ 928#if 0 /* broken junk, but if davem wants to compile this driver, let him.. */
927 unsigned long flags; 929 unsigned long flags;
@@ -931,7 +933,7 @@ int fcp_scsi_dev_reset(Scsi_Cmnd *SCpnt)
931 DECLARE_MUTEX_LOCKED(sem); 933 DECLARE_MUTEX_LOCKED(sem);
932 934
933 if (!fc->rst_pkt) { 935 if (!fc->rst_pkt) {
934 fc->rst_pkt = (Scsi_Cmnd *) kmalloc(sizeof(SCpnt), GFP_KERNEL); 936 fc->rst_pkt = (struct scsi_cmnd *) kmalloc(sizeof(SCpnt), GFP_KERNEL);
935 if (!fc->rst_pkt) return FAILED; 937 if (!fc->rst_pkt) return FAILED;
936 938
937 fcmd = FCP_CMND(fc->rst_pkt); 939 fcmd = FCP_CMND(fc->rst_pkt);
@@ -999,7 +1001,7 @@ int fcp_scsi_dev_reset(Scsi_Cmnd *SCpnt)
999 return SUCCESS; 1001 return SUCCESS;
1000} 1002}
1001 1003
1002static int __fcp_scsi_host_reset(Scsi_Cmnd *SCpnt) 1004static int __fcp_scsi_host_reset(struct scsi_cmnd *SCpnt)
1003{ 1005{
1004 fc_channel *fc = FC_SCMND(SCpnt); 1006 fc_channel *fc = FC_SCMND(SCpnt);
1005 fcp_cmnd *fcmd = FCP_CMND(SCpnt); 1007 fcp_cmnd *fcmd = FCP_CMND(SCpnt);
@@ -1020,7 +1022,7 @@ static int __fcp_scsi_host_reset(Scsi_Cmnd *SCpnt)
1020 else return FAILED; 1022 else return FAILED;
1021} 1023}
1022 1024
1023int fcp_scsi_host_reset(Scsi_Cmnd *SCpnt) 1025int fcp_scsi_host_reset(struct scsi_cmnd *SCpnt)
1024{ 1026{
1025 unsigned long flags; 1027 unsigned long flags;
1026 int rc; 1028 int rc;
diff --git a/drivers/fc4/fcp_impl.h b/drivers/fc4/fcp_impl.h
index c397c84bef63..1ac61330592e 100644
--- a/drivers/fc4/fcp_impl.h
+++ b/drivers/fc4/fcp_impl.h
@@ -39,7 +39,7 @@ struct _fc_channel;
39typedef struct fcp_cmnd { 39typedef struct fcp_cmnd {
40 struct fcp_cmnd *next; 40 struct fcp_cmnd *next;
41 struct fcp_cmnd *prev; 41 struct fcp_cmnd *prev;
42 void (*done)(Scsi_Cmnd *); 42 void (*done)(struct scsi_cmnd *);
43 unsigned short proto; 43 unsigned short proto;
44 unsigned short token; 44 unsigned short token;
45 unsigned int did; 45 unsigned int did;
@@ -94,14 +94,14 @@ typedef struct _fc_channel {
94 long *scsi_bitmap; 94 long *scsi_bitmap;
95 long scsi_bitmap_end; 95 long scsi_bitmap_end;
96 int scsi_free; 96 int scsi_free;
97 int (*encode_addr)(Scsi_Cmnd *, u16 *, struct _fc_channel *, fcp_cmnd *); 97 int (*encode_addr)(struct scsi_cmnd *, u16 *, struct _fc_channel *, fcp_cmnd *);
98 fcp_cmnd *scsi_que; 98 fcp_cmnd *scsi_que;
99 char scsi_name[4]; 99 char scsi_name[4];
100 fcp_cmnd **cmd_slots; 100 fcp_cmnd **cmd_slots;
101 int channels; 101 int channels;
102 int targets; 102 int targets;
103 long *ages; 103 long *ages;
104 Scsi_Cmnd *rst_pkt; 104 struct scsi_cmnd *rst_pkt;
105 fcp_posmap *posmap; 105 fcp_posmap *posmap;
106 /* LOGIN stuff */ 106 /* LOGIN stuff */
107 fcp_cmnd *login; 107 fcp_cmnd *login;
@@ -155,9 +155,10 @@ int fc_do_prli(fc_channel *, unsigned char);
155 for_each_fc_channel(fc) \ 155 for_each_fc_channel(fc) \
156 if (fc->state == FC_STATE_ONLINE) 156 if (fc->state == FC_STATE_ONLINE)
157 157
158int fcp_scsi_queuecommand(Scsi_Cmnd *, void (* done)(Scsi_Cmnd *)); 158int fcp_scsi_queuecommand(struct scsi_cmnd *,
159int fcp_scsi_abort(Scsi_Cmnd *); 159 void (* done) (struct scsi_cmnd *));
160int fcp_scsi_dev_reset(Scsi_Cmnd *); 160int fcp_scsi_abort(struct scsi_cmnd *);
161int fcp_scsi_host_reset(Scsi_Cmnd *); 161int fcp_scsi_dev_reset(struct scsi_cmnd *);
162int fcp_scsi_host_reset(struct scsi_cmnd *);
162 163
163#endif /* !(_FCP_SCSI_H) */ 164#endif /* !(_FCP_SCSI_H) */
diff --git a/drivers/firmware/dcdbas.c b/drivers/firmware/dcdbas.c
index 8bcb58cd4ac0..1865b56fb141 100644
--- a/drivers/firmware/dcdbas.c
+++ b/drivers/firmware/dcdbas.c
@@ -8,7 +8,7 @@
8 * 8 *
9 * See Documentation/dcdbas.txt for more information. 9 * See Documentation/dcdbas.txt for more information.
10 * 10 *
11 * Copyright (C) 1995-2005 Dell Inc. 11 * Copyright (C) 1995-2006 Dell Inc.
12 * 12 *
13 * This program is free software; you can redistribute it and/or modify 13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License v2.0 as published by 14 * it under the terms of the GNU General Public License v2.0 as published by
@@ -40,7 +40,7 @@
40#include "dcdbas.h" 40#include "dcdbas.h"
41 41
42#define DRIVER_NAME "dcdbas" 42#define DRIVER_NAME "dcdbas"
43#define DRIVER_VERSION "5.6.0-2" 43#define DRIVER_VERSION "5.6.0-3.2"
44#define DRIVER_DESCRIPTION "Dell Systems Management Base Driver" 44#define DRIVER_DESCRIPTION "Dell Systems Management Base Driver"
45 45
46static struct platform_device *dcdbas_pdev; 46static struct platform_device *dcdbas_pdev;
@@ -175,6 +175,9 @@ static ssize_t smi_data_write(struct kobject *kobj, char *buf, loff_t pos,
175{ 175{
176 ssize_t ret; 176 ssize_t ret;
177 177
178 if ((pos + count) > MAX_SMI_DATA_BUF_SIZE)
179 return -EINVAL;
180
178 mutex_lock(&smi_data_lock); 181 mutex_lock(&smi_data_lock);
179 182
180 ret = smi_data_buf_realloc(pos + count); 183 ret = smi_data_buf_realloc(pos + count);
diff --git a/drivers/firmware/dell_rbu.c b/drivers/firmware/dell_rbu.c
index fc17599c905e..fc702e40bd43 100644
--- a/drivers/firmware/dell_rbu.c
+++ b/drivers/firmware/dell_rbu.c
@@ -249,7 +249,7 @@ static int packetize_data(void *data, size_t length)
249 if ((rc = create_packet(temp, packet_length))) 249 if ((rc = create_packet(temp, packet_length)))
250 return rc; 250 return rc;
251 251
252 pr_debug("%p:%lu\n", temp, (end - temp)); 252 pr_debug("%p:%td\n", temp, (end - temp));
253 temp += packet_length; 253 temp += packet_length;
254 } 254 }
255 255
@@ -705,27 +705,39 @@ static struct bin_attribute rbu_packet_size_attr = {
705 705
706static int __init dcdrbu_init(void) 706static int __init dcdrbu_init(void)
707{ 707{
708 int rc = 0; 708 int rc;
709 spin_lock_init(&rbu_data.lock); 709 spin_lock_init(&rbu_data.lock);
710 710
711 init_packet_head(); 711 init_packet_head();
712 rbu_device = 712 rbu_device = platform_device_register_simple("dell_rbu", -1, NULL, 0);
713 platform_device_register_simple("dell_rbu", -1, NULL, 0); 713 if (IS_ERR(rbu_device)) {
714 if (!rbu_device) {
715 printk(KERN_ERR 714 printk(KERN_ERR
716 "dell_rbu:%s:platform_device_register_simple " 715 "dell_rbu:%s:platform_device_register_simple "
717 "failed\n", __FUNCTION__); 716 "failed\n", __FUNCTION__);
718 return -EIO; 717 return PTR_ERR(rbu_device);
719 } 718 }
720 719
721 sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_data_attr); 720 rc = sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_data_attr);
722 sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_image_type_attr); 721 if (rc)
723 sysfs_create_bin_file(&rbu_device->dev.kobj, 722 goto out_devreg;
723 rc = sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_image_type_attr);
724 if (rc)
725 goto out_data;
726 rc = sysfs_create_bin_file(&rbu_device->dev.kobj,
724 &rbu_packet_size_attr); 727 &rbu_packet_size_attr);
728 if (rc)
729 goto out_imtype;
725 730
726 rbu_data.entry_created = 0; 731 rbu_data.entry_created = 0;
727 return rc; 732 return 0;
728 733
734out_imtype:
735 sysfs_remove_bin_file(&rbu_device->dev.kobj, &rbu_image_type_attr);
736out_data:
737 sysfs_remove_bin_file(&rbu_device->dev.kobj, &rbu_data_attr);
738out_devreg:
739 platform_device_unregister(rbu_device);
740 return rc;
729} 741}
730 742
731static __exit void dcdrbu_exit(void) 743static __exit void dcdrbu_exit(void)
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index b8b596d5778d..37deee6c0c1c 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -326,6 +326,26 @@ char *dmi_get_system_info(int field)
326} 326}
327EXPORT_SYMBOL(dmi_get_system_info); 327EXPORT_SYMBOL(dmi_get_system_info);
328 328
329
330/**
331 * dmi_name_in_vendors - Check if string is anywhere in the DMI vendor information.
332 * @str: Case sensitive Name
333 */
334int dmi_name_in_vendors(char *str)
335{
336 static int fields[] = { DMI_BIOS_VENDOR, DMI_BIOS_VERSION, DMI_SYS_VENDOR,
337 DMI_PRODUCT_NAME, DMI_PRODUCT_VERSION, DMI_BOARD_VENDOR,
338 DMI_BOARD_NAME, DMI_BOARD_VERSION, DMI_NONE };
339 int i;
340 for (i = 0; fields[i] != DMI_NONE; i++) {
341 int f = fields[i];
342 if (dmi_ident[f] && strstr(dmi_ident[f], str))
343 return 1;
344 }
345 return 0;
346}
347EXPORT_SYMBOL(dmi_name_in_vendors);
348
329/** 349/**
330 * dmi_find_device - find onboard device by type/name 350 * dmi_find_device - find onboard device by type/name
331 * @type: device type or %DMI_DEV_TYPE_ANY to match all device types 351 * @type: device type or %DMI_DEV_TYPE_ANY to match all device types
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index 8ebce1c03ad7..5ab5e393b882 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -639,7 +639,12 @@ efivar_create_sysfs_entry(unsigned long variable_name_size,
639 639
640 kobject_set_name(&new_efivar->kobj, "%s", short_name); 640 kobject_set_name(&new_efivar->kobj, "%s", short_name);
641 kobj_set_kset_s(new_efivar, vars_subsys); 641 kobj_set_kset_s(new_efivar, vars_subsys);
642 kobject_register(&new_efivar->kobj); 642 i = kobject_register(&new_efivar->kobj);
643 if (i) {
644 kfree(short_name);
645 kfree(new_efivar);
646 return 1;
647 }
643 648
644 kfree(short_name); 649 kfree(short_name);
645 short_name = NULL; 650 short_name = NULL;
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 9b88b25b6edb..e76d91906c99 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -95,11 +95,13 @@ config SENSORS_ADM9240
95 will be called adm9240. 95 will be called adm9240.
96 96
97config SENSORS_K8TEMP 97config SENSORS_K8TEMP
98 tristate "AMD K8 processor sensor" 98 tristate "AMD Athlon64/FX or Opteron temperature sensor"
99 depends on HWMON && X86 && PCI && EXPERIMENTAL 99 depends on HWMON && X86 && PCI && EXPERIMENTAL
100 help 100 help
101 If you say yes here you get support for the temperature 101 If you say yes here you get support for the temperature
102 sensor(s) inside your AMD K8 CPU. 102 sensor(s) inside your CPU. Supported is whole AMD K8
103 microarchitecture. Please note that you will need at least
104 lm-sensors 2.10.1 for proper userspace support.
103 105
104 This driver can also be built as a module. If so, the module 106 This driver can also be built as a module. If so, the module
105 will be called k8temp. 107 will be called k8temp.
@@ -369,8 +371,8 @@ config SENSORS_SMSC47M1
369 help 371 help
370 If you say yes here you get support for the integrated fan 372 If you say yes here you get support for the integrated fan
371 monitoring and control capabilities of the SMSC LPC47B27x, 373 monitoring and control capabilities of the SMSC LPC47B27x,
372 LPC47M10x, LPC47M13x, LPC47M14x, LPC47M15x, LPC47M192 and 374 LPC47M10x, LPC47M112, LPC47M13x, LPC47M14x, LPC47M15x,
373 LPC47M997 chips. 375 LPC47M192 and LPC47M997 chips.
374 376
375 The temperature and voltage sensor features of the LPC47M192 377 The temperature and voltage sensor features of the LPC47M192
376 and LPC47M997 are supported by another driver, select also 378 and LPC47M997 are supported by another driver, select also
diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c
index 377961c4a41e..aad594adf0c7 100644
--- a/drivers/hwmon/adm9240.c
+++ b/drivers/hwmon/adm9240.c
@@ -5,7 +5,7 @@
5 * Copyright (C) 1999 Frodo Looijaard <frodol@dds.nl> 5 * Copyright (C) 1999 Frodo Looijaard <frodol@dds.nl>
6 * Philip Edelbrock <phil@netroedge.com> 6 * Philip Edelbrock <phil@netroedge.com>
7 * Copyright (C) 2003 Michiel Rook <michiel@grendelproject.nl> 7 * Copyright (C) 2003 Michiel Rook <michiel@grendelproject.nl>
8 * Copyright (C) 2005 Grant Coady <gcoady@gmail.com> with valuable 8 * Copyright (C) 2005 Grant Coady <gcoady.lk@gmail.com> with valuable
9 * guidance from Jean Delvare 9 * guidance from Jean Delvare
10 * 10 *
11 * Driver supports Analog Devices ADM9240 11 * Driver supports Analog Devices ADM9240
@@ -774,7 +774,7 @@ static void __exit sensors_adm9240_exit(void)
774} 774}
775 775
776MODULE_AUTHOR("Michiel Rook <michiel@grendelproject.nl>, " 776MODULE_AUTHOR("Michiel Rook <michiel@grendelproject.nl>, "
777 "Grant Coady <gcoady@gmail.com> and others"); 777 "Grant Coady <gcoady.lk@gmail.com> and others");
778MODULE_DESCRIPTION("ADM9240/DS1780/LM81 driver"); 778MODULE_DESCRIPTION("ADM9240/DS1780/LM81 driver");
779MODULE_LICENSE("GPL"); 779MODULE_LICENSE("GPL");
780 780
diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c
index ac1b746df6d0..73bc2ffc598d 100644
--- a/drivers/hwmon/lm78.c
+++ b/drivers/hwmon/lm78.c
@@ -815,18 +815,18 @@ static int __init sm_lm78_init(void)
815 if (res) 815 if (res)
816 return res; 816 return res;
817 817
818 res = i2c_isa_add_driver(&lm78_isa_driver); 818 /* Don't exit if this one fails, we still want the I2C variants
819 if (res) { 819 to work! */
820 i2c_del_driver(&lm78_driver); 820 if (i2c_isa_add_driver(&lm78_isa_driver))
821 return res; 821 isa_address = 0;
822 }
823 822
824 return 0; 823 return 0;
825} 824}
826 825
827static void __exit sm_lm78_exit(void) 826static void __exit sm_lm78_exit(void)
828{ 827{
829 i2c_isa_del_driver(&lm78_isa_driver); 828 if (isa_address)
829 i2c_isa_del_driver(&lm78_isa_driver);
830 i2c_del_driver(&lm78_driver); 830 i2c_del_driver(&lm78_driver);
831} 831}
832 832
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
index 47132fd26b1b..beb881c4b2e8 100644
--- a/drivers/hwmon/smsc47m1.c
+++ b/drivers/hwmon/smsc47m1.c
@@ -2,8 +2,8 @@
2 smsc47m1.c - Part of lm_sensors, Linux kernel modules 2 smsc47m1.c - Part of lm_sensors, Linux kernel modules
3 for hardware monitoring 3 for hardware monitoring
4 4
5 Supports the SMSC LPC47B27x, LPC47M10x, LPC47M13x, LPC47M14x, 5 Supports the SMSC LPC47B27x, LPC47M10x, LPC47M112, LPC47M13x,
6 LPC47M15x, LPC47M192 and LPC47M997 Super-I/O chips. 6 LPC47M14x, LPC47M15x, LPC47M192 and LPC47M997 Super-I/O chips.
7 7
8 Copyright (C) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com> 8 Copyright (C) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com>
9 Copyright (C) 2004 Jean Delvare <khali@linux-fr.org> 9 Copyright (C) 2004 Jean Delvare <khali@linux-fr.org>
@@ -380,8 +380,8 @@ static int __init smsc47m1_find(unsigned short *addr)
380 val = superio_inb(SUPERIO_REG_DEVID); 380 val = superio_inb(SUPERIO_REG_DEVID);
381 381
382 /* 382 /*
383 * SMSC LPC47M10x/LPC47M13x (device id 0x59), LPC47M14x (device id 383 * SMSC LPC47M10x/LPC47M112/LPC47M13x (device id 0x59), LPC47M14x
384 * 0x5F) and LPC47B27x (device id 0x51) have fan control. 384 * (device id 0x5F) and LPC47B27x (device id 0x51) have fan control.
385 * The LPC47M15x and LPC47M192 chips "with hardware monitoring block" 385 * The LPC47M15x and LPC47M192 chips "with hardware monitoring block"
386 * can do much more besides (device id 0x60). 386 * can do much more besides (device id 0x60).
387 * The LPC47M997 is undocumented, but seems to be compatible with 387 * The LPC47M997 is undocumented, but seems to be compatible with
@@ -390,7 +390,8 @@ static int __init smsc47m1_find(unsigned short *addr)
390 if (val == 0x51) 390 if (val == 0x51)
391 printk(KERN_INFO "smsc47m1: Found SMSC LPC47B27x\n"); 391 printk(KERN_INFO "smsc47m1: Found SMSC LPC47B27x\n");
392 else if (val == 0x59) 392 else if (val == 0x59)
393 printk(KERN_INFO "smsc47m1: Found SMSC LPC47M10x/LPC47M13x\n"); 393 printk(KERN_INFO "smsc47m1: Found SMSC "
394 "LPC47M10x/LPC47M112/LPC47M13x\n");
394 else if (val == 0x5F) 395 else if (val == 0x5F)
395 printk(KERN_INFO "smsc47m1: Found SMSC LPC47M14x\n"); 396 printk(KERN_INFO "smsc47m1: Found SMSC LPC47M14x\n");
396 else if (val == 0x60) 397 else if (val == 0x60)
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index 833faa275ffa..2257806d0102 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -354,6 +354,8 @@ static void w83627ehf_write_fan_div(struct i2c_client *client, int nr)
354 case 0: 354 case 0:
355 reg = (w83627ehf_read_value(client, W83627EHF_REG_FANDIV1) & 0xcf) 355 reg = (w83627ehf_read_value(client, W83627EHF_REG_FANDIV1) & 0xcf)
356 | ((data->fan_div[0] & 0x03) << 4); 356 | ((data->fan_div[0] & 0x03) << 4);
357 /* fan5 input control bit is write only, compute the value */
358 reg |= (data->has_fan & (1 << 4)) ? 1 : 0;
357 w83627ehf_write_value(client, W83627EHF_REG_FANDIV1, reg); 359 w83627ehf_write_value(client, W83627EHF_REG_FANDIV1, reg);
358 reg = (w83627ehf_read_value(client, W83627EHF_REG_VBAT) & 0xdf) 360 reg = (w83627ehf_read_value(client, W83627EHF_REG_VBAT) & 0xdf)
359 | ((data->fan_div[0] & 0x04) << 3); 361 | ((data->fan_div[0] & 0x04) << 3);
@@ -362,6 +364,8 @@ static void w83627ehf_write_fan_div(struct i2c_client *client, int nr)
362 case 1: 364 case 1:
363 reg = (w83627ehf_read_value(client, W83627EHF_REG_FANDIV1) & 0x3f) 365 reg = (w83627ehf_read_value(client, W83627EHF_REG_FANDIV1) & 0x3f)
364 | ((data->fan_div[1] & 0x03) << 6); 366 | ((data->fan_div[1] & 0x03) << 6);
367 /* fan5 input control bit is write only, compute the value */
368 reg |= (data->has_fan & (1 << 4)) ? 1 : 0;
365 w83627ehf_write_value(client, W83627EHF_REG_FANDIV1, reg); 369 w83627ehf_write_value(client, W83627EHF_REG_FANDIV1, reg);
366 reg = (w83627ehf_read_value(client, W83627EHF_REG_VBAT) & 0xbf) 370 reg = (w83627ehf_read_value(client, W83627EHF_REG_VBAT) & 0xbf)
367 | ((data->fan_div[1] & 0x04) << 4); 371 | ((data->fan_div[1] & 0x04) << 4);
@@ -1216,13 +1220,16 @@ static int w83627ehf_detect(struct i2c_adapter *adapter)
1216 superio_exit(); 1220 superio_exit();
1217 1221
1218 /* It looks like fan4 and fan5 pins can be alternatively used 1222 /* It looks like fan4 and fan5 pins can be alternatively used
1219 as fan on/off switches */ 1223 as fan on/off switches, but fan5 control is write only :/
1224 We assume that if the serial interface is disabled, designers
1225 connected fan5 as input unless they are emitting log 1, which
1226 is not the default. */
1220 1227
1221 data->has_fan = 0x07; /* fan1, fan2 and fan3 */ 1228 data->has_fan = 0x07; /* fan1, fan2 and fan3 */
1222 i = w83627ehf_read_value(client, W83627EHF_REG_FANDIV1); 1229 i = w83627ehf_read_value(client, W83627EHF_REG_FANDIV1);
1223 if ((i & (1 << 2)) && (!fan4pin)) 1230 if ((i & (1 << 2)) && (!fan4pin))
1224 data->has_fan |= (1 << 3); 1231 data->has_fan |= (1 << 3);
1225 if ((i & (1 << 0)) && (!fan5pin)) 1232 if (!(i & (1 << 1)) && (!fan5pin))
1226 data->has_fan |= (1 << 4); 1233 data->has_fan |= (1 << 4);
1227 1234
1228 /* Register sysfs hooks */ 1235 /* Register sysfs hooks */
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c
index a4584ec69842..1232171c3aad 100644
--- a/drivers/hwmon/w83781d.c
+++ b/drivers/hwmon/w83781d.c
@@ -1099,7 +1099,8 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1099 bank. */ 1099 bank. */
1100 if (kind < 0) { 1100 if (kind < 0) {
1101 if (w83781d_read_value(client, W83781D_REG_CONFIG) & 0x80) { 1101 if (w83781d_read_value(client, W83781D_REG_CONFIG) & 0x80) {
1102 dev_dbg(dev, "Detection failed at step 3\n"); 1102 dev_dbg(&adapter->dev, "Detection of w83781d chip "
1103 "failed at step 3\n");
1103 err = -ENODEV; 1104 err = -ENODEV;
1104 goto ERROR2; 1105 goto ERROR2;
1105 } 1106 }
@@ -1109,7 +1110,8 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1109 if ((!(val1 & 0x07)) && 1110 if ((!(val1 & 0x07)) &&
1110 (((!(val1 & 0x80)) && (val2 != 0xa3) && (val2 != 0xc3)) 1111 (((!(val1 & 0x80)) && (val2 != 0xa3) && (val2 != 0xc3))
1111 || ((val1 & 0x80) && (val2 != 0x5c) && (val2 != 0x12)))) { 1112 || ((val1 & 0x80) && (val2 != 0x5c) && (val2 != 0x12)))) {
1112 dev_dbg(dev, "Detection failed at step 4\n"); 1113 dev_dbg(&adapter->dev, "Detection of w83781d chip "
1114 "failed at step 4\n");
1113 err = -ENODEV; 1115 err = -ENODEV;
1114 goto ERROR2; 1116 goto ERROR2;
1115 } 1117 }
@@ -1119,7 +1121,8 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1119 ((val1 & 0x80) && (val2 == 0x5c)))) { 1121 ((val1 & 0x80) && (val2 == 0x5c)))) {
1120 if (w83781d_read_value 1122 if (w83781d_read_value
1121 (client, W83781D_REG_I2C_ADDR) != address) { 1123 (client, W83781D_REG_I2C_ADDR) != address) {
1122 dev_dbg(dev, "Detection failed at step 5\n"); 1124 dev_dbg(&adapter->dev, "Detection of w83781d "
1125 "chip failed at step 5\n");
1123 err = -ENODEV; 1126 err = -ENODEV;
1124 goto ERROR2; 1127 goto ERROR2;
1125 } 1128 }
@@ -1141,8 +1144,8 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1141 else if (val2 == 0x12) 1144 else if (val2 == 0x12)
1142 vendid = asus; 1145 vendid = asus;
1143 else { 1146 else {
1144 dev_dbg(dev, "Chip was made by neither " 1147 dev_dbg(&adapter->dev, "w83781d chip vendor is "
1145 "Winbond nor Asus?\n"); 1148 "neither Winbond nor Asus\n");
1146 err = -ENODEV; 1149 err = -ENODEV;
1147 goto ERROR2; 1150 goto ERROR2;
1148 } 1151 }
@@ -1161,10 +1164,9 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1161 kind = as99127f; 1164 kind = as99127f;
1162 else { 1165 else {
1163 if (kind == 0) 1166 if (kind == 0)
1164 dev_warn(dev, "Ignoring 'force' " 1167 dev_warn(&adapter->dev, "Ignoring 'force' "
1165 "parameter for unknown chip at " 1168 "parameter for unknown chip at "
1166 "adapter %d, address 0x%02x\n", 1169 "address 0x%02x\n", address);
1167 i2c_adapter_id(adapter), address);
1168 err = -EINVAL; 1170 err = -EINVAL;
1169 goto ERROR2; 1171 goto ERROR2;
1170 } 1172 }
@@ -1685,11 +1687,10 @@ sensors_w83781d_init(void)
1685 if (res) 1687 if (res)
1686 return res; 1688 return res;
1687 1689
1688 res = i2c_isa_add_driver(&w83781d_isa_driver); 1690 /* Don't exit if this one fails, we still want the I2C variants
1689 if (res) { 1691 to work! */
1690 i2c_del_driver(&w83781d_driver); 1692 if (i2c_isa_add_driver(&w83781d_isa_driver))
1691 return res; 1693 isa_address = 0;
1692 }
1693 1694
1694 return 0; 1695 return 0;
1695} 1696}
@@ -1697,7 +1698,8 @@ sensors_w83781d_init(void)
1697static void __exit 1698static void __exit
1698sensors_w83781d_exit(void) 1699sensors_w83781d_exit(void)
1699{ 1700{
1700 i2c_isa_del_driver(&w83781d_isa_driver); 1701 if (isa_address)
1702 i2c_isa_del_driver(&w83781d_isa_driver);
1701 i2c_del_driver(&w83781d_driver); 1703 i2c_del_driver(&w83781d_driver);
1702} 1704}
1703 1705
diff --git a/drivers/hwmon/w83791d.c b/drivers/hwmon/w83791d.c
index 371ed4f69a97..9e5f885368b4 100644
--- a/drivers/hwmon/w83791d.c
+++ b/drivers/hwmon/w83791d.c
@@ -746,6 +746,52 @@ static ssize_t store_vrm_reg(struct device *dev,
746 746
747static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg); 747static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg);
748 748
749#define IN_UNIT_ATTRS(X) \
750 &sda_in_input[X].dev_attr.attr, \
751 &sda_in_min[X].dev_attr.attr, \
752 &sda_in_max[X].dev_attr.attr
753
754#define FAN_UNIT_ATTRS(X) \
755 &sda_fan_input[X].dev_attr.attr, \
756 &sda_fan_min[X].dev_attr.attr, \
757 &sda_fan_div[X].dev_attr.attr
758
759#define TEMP_UNIT_ATTRS(X) \
760 &sda_temp_input[X].dev_attr.attr, \
761 &sda_temp_max[X].dev_attr.attr, \
762 &sda_temp_max_hyst[X].dev_attr.attr
763
764static struct attribute *w83791d_attributes[] = {
765 IN_UNIT_ATTRS(0),
766 IN_UNIT_ATTRS(1),
767 IN_UNIT_ATTRS(2),
768 IN_UNIT_ATTRS(3),
769 IN_UNIT_ATTRS(4),
770 IN_UNIT_ATTRS(5),
771 IN_UNIT_ATTRS(6),
772 IN_UNIT_ATTRS(7),
773 IN_UNIT_ATTRS(8),
774 IN_UNIT_ATTRS(9),
775 FAN_UNIT_ATTRS(0),
776 FAN_UNIT_ATTRS(1),
777 FAN_UNIT_ATTRS(2),
778 FAN_UNIT_ATTRS(3),
779 FAN_UNIT_ATTRS(4),
780 TEMP_UNIT_ATTRS(0),
781 TEMP_UNIT_ATTRS(1),
782 TEMP_UNIT_ATTRS(2),
783 &dev_attr_alarms.attr,
784 &sda_beep_ctrl[0].dev_attr.attr,
785 &sda_beep_ctrl[1].dev_attr.attr,
786 &dev_attr_cpu0_vid.attr,
787 &dev_attr_vrm.attr,
788 NULL
789};
790
791static const struct attribute_group w83791d_group = {
792 .attrs = w83791d_attributes,
793};
794
749/* This function is called when: 795/* This function is called when:
750 * w83791d_driver is inserted (when this module is loaded), for each 796 * w83791d_driver is inserted (when this module is loaded), for each
751 available adapter 797 available adapter
@@ -967,41 +1013,20 @@ static int w83791d_detect(struct i2c_adapter *adapter, int address, int kind)
967 } 1013 }
968 1014
969 /* Register sysfs hooks */ 1015 /* Register sysfs hooks */
1016 if ((err = sysfs_create_group(&client->dev.kobj, &w83791d_group)))
1017 goto error3;
1018
1019 /* Everything is ready, now register the working device */
970 data->class_dev = hwmon_device_register(dev); 1020 data->class_dev = hwmon_device_register(dev);
971 if (IS_ERR(data->class_dev)) { 1021 if (IS_ERR(data->class_dev)) {
972 err = PTR_ERR(data->class_dev); 1022 err = PTR_ERR(data->class_dev);
973 goto error3; 1023 goto error4;
974 } 1024 }
975 1025
976 for (i = 0; i < NUMBER_OF_VIN; i++) {
977 device_create_file(dev, &sda_in_input[i].dev_attr);
978 device_create_file(dev, &sda_in_min[i].dev_attr);
979 device_create_file(dev, &sda_in_max[i].dev_attr);
980 }
981
982 for (i = 0; i < NUMBER_OF_FANIN; i++) {
983 device_create_file(dev, &sda_fan_input[i].dev_attr);
984 device_create_file(dev, &sda_fan_div[i].dev_attr);
985 device_create_file(dev, &sda_fan_min[i].dev_attr);
986 }
987
988 for (i = 0; i < NUMBER_OF_TEMPIN; i++) {
989 device_create_file(dev, &sda_temp_input[i].dev_attr);
990 device_create_file(dev, &sda_temp_max[i].dev_attr);
991 device_create_file(dev, &sda_temp_max_hyst[i].dev_attr);
992 }
993
994 device_create_file(dev, &dev_attr_alarms);
995
996 for (i = 0; i < ARRAY_SIZE(sda_beep_ctrl); i++) {
997 device_create_file(dev, &sda_beep_ctrl[i].dev_attr);
998 }
999
1000 device_create_file(dev, &dev_attr_cpu0_vid);
1001 device_create_file(dev, &dev_attr_vrm);
1002
1003 return 0; 1026 return 0;
1004 1027
1028error4:
1029 sysfs_remove_group(&client->dev.kobj, &w83791d_group);
1005error3: 1030error3:
1006 if (data->lm75[0] != NULL) { 1031 if (data->lm75[0] != NULL) {
1007 i2c_detach_client(data->lm75[0]); 1032 i2c_detach_client(data->lm75[0]);
@@ -1025,8 +1050,10 @@ static int w83791d_detach_client(struct i2c_client *client)
1025 int err; 1050 int err;
1026 1051
1027 /* main client */ 1052 /* main client */
1028 if (data) 1053 if (data) {
1029 hwmon_device_unregister(data->class_dev); 1054 hwmon_device_unregister(data->class_dev);
1055 sysfs_remove_group(&client->dev.kobj, &w83791d_group);
1056 }
1030 1057
1031 if ((err = i2c_detach_client(client))) 1058 if ((err = i2c_detach_client(client)))
1032 return err; 1059 return err;
diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c
index 4380653748a4..8ed59a2dff53 100644
--- a/drivers/i2c/busses/i2c-isa.c
+++ b/drivers/i2c/busses/i2c-isa.c
@@ -91,7 +91,7 @@ int i2c_isa_add_driver(struct i2c_driver *driver)
91 /* Now look for clients */ 91 /* Now look for clients */
92 res = driver->attach_adapter(&isa_adapter); 92 res = driver->attach_adapter(&isa_adapter);
93 if (res) { 93 if (res) {
94 dev_err(&isa_adapter.dev, 94 dev_dbg(&isa_adapter.dev,
95 "Driver %s failed to attach adapter, unregistering\n", 95 "Driver %s failed to attach adapter, unregistering\n",
96 driver->driver.name); 96 driver->driver.name);
97 driver_unregister(&driver->driver); 97 driver_unregister(&driver->driver);
diff --git a/drivers/i2c/busses/i2c-ixp4xx.c b/drivers/i2c/busses/i2c-ixp4xx.c
index 1ce01fb0ac09..05fffb9415a2 100644
--- a/drivers/i2c/busses/i2c-ixp4xx.c
+++ b/drivers/i2c/busses/i2c-ixp4xx.c
@@ -137,7 +137,8 @@ static int ixp4xx_i2c_probe(struct platform_device *plat_dev)
137 gpio_line_set(gpio->scl_pin, 0); 137 gpio_line_set(gpio->scl_pin, 0);
138 gpio_line_set(gpio->sda_pin, 0); 138 gpio_line_set(gpio->sda_pin, 0);
139 139
140 if ((err = i2c_bit_add_bus(&drv_data->adapter) != 0)) { 140 err = i2c_bit_add_bus(&drv_data->adapter);
141 if (err != 0)
141 printk(KERN_ERR "ERROR: Could not install %s\n", plat_dev->dev.bus_id); 142 printk(KERN_ERR "ERROR: Could not install %s\n", plat_dev->dev.bus_id);
142 143
143 kfree(drv_data); 144 kfree(drv_data);
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 81050d3c9b21..c95a6c154165 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -272,7 +272,8 @@ static int i2c_pxa_wait_slave(struct pxa_i2c *i2c)
272 dev_dbg(&i2c->adap.dev, "%s: %ld: ISR=%08x, ICR=%08x, IBMR=%02x\n", 272 dev_dbg(&i2c->adap.dev, "%s: %ld: ISR=%08x, ICR=%08x, IBMR=%02x\n",
273 __func__, (long)jiffies, ISR, ICR, IBMR); 273 __func__, (long)jiffies, ISR, ICR, IBMR);
274 274
275 if ((ISR & (ISR_UB|ISR_IBB|ISR_SAD)) == ISR_SAD || 275 if ((ISR & (ISR_UB|ISR_IBB)) == 0 ||
276 (ISR & ISR_SAD) != 0 ||
276 (ICR & ICR_SCLE) == 0) { 277 (ICR & ICR_SCLE) == 0) {
277 if (i2c_debug > 1) 278 if (i2c_debug > 1)
278 dev_dbg(&i2c->adap.dev, "%s: done\n", __func__); 279 dev_dbg(&i2c->adap.dev, "%s: done\n", __func__);
@@ -492,7 +493,10 @@ static void i2c_pxa_slave_txempty(struct pxa_i2c *i2c, u32 isr)
492 if (isr & ISR_BED) { 493 if (isr & ISR_BED) {
493 /* what should we do here? */ 494 /* what should we do here? */
494 } else { 495 } else {
495 int ret = i2c->slave->read(i2c->slave->data); 496 int ret = 0;
497
498 if (i2c->slave != NULL)
499 ret = i2c->slave->read(i2c->slave->data);
496 500
497 IDBR = ret; 501 IDBR = ret;
498 ICR |= ICR_TB; /* allow next byte */ 502 ICR |= ICR_TB; /* allow next byte */
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c
index 32aab0d34ee9..714bae780953 100644
--- a/drivers/i2c/busses/scx200_acb.c
+++ b/drivers/i2c/busses/scx200_acb.c
@@ -494,11 +494,12 @@ static __init int scx200_create_pci(const char *text, struct pci_dev *pdev,
494 iface->pdev = pdev; 494 iface->pdev = pdev;
495 iface->bar = bar; 495 iface->bar = bar;
496 496
497 pci_enable_device_bars(iface->pdev, 1 << iface->bar); 497 rc = pci_enable_device_bars(iface->pdev, 1 << iface->bar);
498 if (rc)
499 goto errout_free;
498 500
499 rc = pci_request_region(iface->pdev, iface->bar, iface->adapter.name); 501 rc = pci_request_region(iface->pdev, iface->bar, iface->adapter.name);
500 502 if (rc) {
501 if (rc != 0) {
502 printk(KERN_ERR NAME ": can't allocate PCI BAR %d\n", 503 printk(KERN_ERR NAME ": can't allocate PCI BAR %d\n",
503 iface->bar); 504 iface->bar);
504 goto errout_free; 505 goto errout_free;
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 69bbb6206a00..88214943d00a 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -597,7 +597,7 @@ static void cdrom_prepare_request(ide_drive_t *drive, struct request *rq)
597 struct cdrom_info *cd = drive->driver_data; 597 struct cdrom_info *cd = drive->driver_data;
598 598
599 ide_init_drive_cmd(rq); 599 ide_init_drive_cmd(rq);
600 rq->cmd_type = REQ_TYPE_BLOCK_PC; 600 rq->cmd_type = REQ_TYPE_ATA_PC;
601 rq->rq_disk = cd->disk; 601 rq->rq_disk = cd->disk;
602} 602}
603 603
@@ -716,7 +716,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
716 ide_error(drive, "request sense failure", stat); 716 ide_error(drive, "request sense failure", stat);
717 return 1; 717 return 1;
718 718
719 } else if (blk_pc_request(rq)) { 719 } else if (blk_pc_request(rq) || rq->cmd_type == REQ_TYPE_ATA_PC) {
720 /* All other functions, except for READ. */ 720 /* All other functions, except for READ. */
721 unsigned long flags; 721 unsigned long flags;
722 722
@@ -724,7 +724,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
724 * if we have an error, pass back CHECK_CONDITION as the 724 * if we have an error, pass back CHECK_CONDITION as the
725 * scsi status byte 725 * scsi status byte
726 */ 726 */
727 if (!rq->errors) 727 if (blk_pc_request(rq) && !rq->errors)
728 rq->errors = SAM_STAT_CHECK_CONDITION; 728 rq->errors = SAM_STAT_CHECK_CONDITION;
729 729
730 /* Check for tray open. */ 730 /* Check for tray open. */
@@ -2023,7 +2023,8 @@ ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, sector_t block)
2023 } 2023 }
2024 info->last_block = block; 2024 info->last_block = block;
2025 return action; 2025 return action;
2026 } else if (rq->cmd_type == REQ_TYPE_SENSE) { 2026 } else if (rq->cmd_type == REQ_TYPE_SENSE ||
2027 rq->cmd_type == REQ_TYPE_ATA_PC) {
2027 return cdrom_do_packet_command(drive); 2028 return cdrom_do_packet_command(drive);
2028 } else if (blk_pc_request(rq)) { 2029 } else if (blk_pc_request(rq)) {
2029 return cdrom_do_block_pc(drive, rq); 2030 return cdrom_do_block_pc(drive, rq);
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index 1d0470c1f957..30175c7688e8 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -524,8 +524,8 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
524 task_ioreg_t *hobsptr = args.hobRegister; 524 task_ioreg_t *hobsptr = args.hobRegister;
525 int err = 0; 525 int err = 0;
526 int tasksize = sizeof(struct ide_task_request_s); 526 int tasksize = sizeof(struct ide_task_request_s);
527 int taskin = 0; 527 unsigned int taskin = 0;
528 int taskout = 0; 528 unsigned int taskout = 0;
529 u8 io_32bit = drive->io_32bit; 529 u8 io_32bit = drive->io_32bit;
530 char __user *buf = (char __user *)arg; 530 char __user *buf = (char __user *)arg;
531 531
@@ -538,8 +538,13 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
538 return -EFAULT; 538 return -EFAULT;
539 } 539 }
540 540
541 taskout = (int) req_task->out_size; 541 taskout = req_task->out_size;
542 taskin = (int) req_task->in_size; 542 taskin = req_task->in_size;
543
544 if (taskin > 65536 || taskout > 65536) {
545 err = -EINVAL;
546 goto abort;
547 }
543 548
544 if (taskout) { 549 if (taskout) {
545 int outtotal = tasksize; 550 int outtotal = tasksize;
diff --git a/drivers/ide/legacy/hd.c b/drivers/ide/legacy/hd.c
index b1d5291531b7..45ed03591cd8 100644
--- a/drivers/ide/legacy/hd.c
+++ b/drivers/ide/legacy/hd.c
@@ -459,7 +459,7 @@ ok_to_read:
459#ifdef DEBUG 459#ifdef DEBUG
460 printk("%s: read: sector %ld, remaining = %ld, buffer=%p\n", 460 printk("%s: read: sector %ld, remaining = %ld, buffer=%p\n",
461 req->rq_disk->disk_name, req->sector, req->nr_sectors, 461 req->rq_disk->disk_name, req->sector, req->nr_sectors,
462 req->buffer+512)); 462 req->buffer+512);
463#endif 463#endif
464 if (req->current_nr_sectors <= 0) 464 if (req->current_nr_sectors <= 0)
465 end_request(req, 1); 465 end_request(req, 1);
diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c
index 2b0ea8b6608d..753fe0e21456 100644
--- a/drivers/ide/pci/amd74xx.c
+++ b/drivers/ide/pci/amd74xx.c
@@ -75,6 +75,7 @@ static struct amd_ide_chip {
75 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE, 0x50, AMD_UDMA_133 }, 75 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE, 0x50, AMD_UDMA_133 },
76 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE, 0x50, AMD_UDMA_133 }, 76 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE, 0x50, AMD_UDMA_133 },
77 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE, 0x50, AMD_UDMA_133 }, 77 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE, 0x50, AMD_UDMA_133 },
78 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE, 0x50, AMD_UDMA_133 },
78 { PCI_DEVICE_ID_AMD_CS5536_IDE, 0x40, AMD_UDMA_100 }, 79 { PCI_DEVICE_ID_AMD_CS5536_IDE, 0x40, AMD_UDMA_100 },
79 { 0 } 80 { 0 }
80}; 81};
@@ -491,7 +492,8 @@ static ide_pci_device_t amd74xx_chipsets[] __devinitdata = {
491 /* 16 */ DECLARE_NV_DEV("NFORCE-MCP55"), 492 /* 16 */ DECLARE_NV_DEV("NFORCE-MCP55"),
492 /* 17 */ DECLARE_NV_DEV("NFORCE-MCP61"), 493 /* 17 */ DECLARE_NV_DEV("NFORCE-MCP61"),
493 /* 18 */ DECLARE_NV_DEV("NFORCE-MCP65"), 494 /* 18 */ DECLARE_NV_DEV("NFORCE-MCP65"),
494 /* 19 */ DECLARE_AMD_DEV("AMD5536"), 495 /* 19 */ DECLARE_NV_DEV("NFORCE-MCP67"),
496 /* 20 */ DECLARE_AMD_DEV("AMD5536"),
495}; 497};
496 498
497static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id) 499static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id)
@@ -530,7 +532,8 @@ static struct pci_device_id amd74xx_pci_tbl[] = {
530 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 16 }, 532 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 16 },
531 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 17 }, 533 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 17 },
532 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 18 }, 534 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 18 },
533 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 19 }, 535 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 19 },
536 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 20 },
534 { 0, }, 537 { 0, },
535}; 538};
536MODULE_DEVICE_TABLE(pci, amd74xx_pci_tbl); 539MODULE_DEVICE_TABLE(pci, amd74xx_pci_tbl);
diff --git a/drivers/ide/pci/generic.c b/drivers/ide/pci/generic.c
index 965c43659e35..9f306880491a 100644
--- a/drivers/ide/pci/generic.c
+++ b/drivers/ide/pci/generic.c
@@ -40,6 +40,19 @@
40 40
41static int ide_generic_all; /* Set to claim all devices */ 41static int ide_generic_all; /* Set to claim all devices */
42 42
43/*
44 * the module_param_named() was added for the modular case
45 * the __setup() is left as compatibility for existing setups
46 */
47#ifndef MODULE
48static int __init ide_generic_all_on(char *unused)
49{
50 ide_generic_all = 1;
51 printk(KERN_INFO "IDE generic will claim all unknown PCI IDE storage controllers.\n");
52 return 1;
53}
54__setup("all-generic-ide", ide_generic_all_on);
55#endif
43module_param_named(all_generic_ide, ide_generic_all, bool, 0444); 56module_param_named(all_generic_ide, ide_generic_all, bool, 0444);
44MODULE_PARM_DESC(all_generic_ide, "IDE generic will claim all unknown PCI IDE storage controllers."); 57MODULE_PARM_DESC(all_generic_ide, "IDE generic will claim all unknown PCI IDE storage controllers.");
45 58
@@ -234,13 +247,17 @@ static int __devinit generic_init_one(struct pci_dev *dev, const struct pci_devi
234 (!(PCI_FUNC(dev->devfn) & 1))) 247 (!(PCI_FUNC(dev->devfn) & 1)))
235 goto out; 248 goto out;
236 249
237 if (dev->vendor == PCI_VENDOR_ID_JMICRON && PCI_FUNC(dev->devfn) != 1) 250 if (dev->vendor == PCI_VENDOR_ID_JMICRON) {
238 goto out; 251 if (dev->device != PCI_DEVICE_ID_JMICRON_JMB368 && PCI_FUNC(dev->devfn) != 1)
252 goto out;
253 }
239 254
240 pci_read_config_word(dev, PCI_COMMAND, &command); 255 if (dev->vendor != PCI_VENDOR_ID_JMICRON) {
241 if (!(command & PCI_COMMAND_IO)) { 256 pci_read_config_word(dev, PCI_COMMAND, &command);
242 printk(KERN_INFO "Skipping disabled %s IDE controller.\n", d->name); 257 if (!(command & PCI_COMMAND_IO)) {
243 goto out; 258 printk(KERN_INFO "Skipping disabled %s IDE controller.\n", d->name);
259 goto out;
260 }
244 } 261 }
245 ret = ide_setup_pci_device(dev, d); 262 ret = ide_setup_pci_device(dev, d);
246out: 263out:
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
index f3fe287fbd89..244f7eb7006d 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -774,7 +774,7 @@ ioc4_ide_exit(void)
774 ioc4_unregister_submodule(&ioc4_ide_submodule); 774 ioc4_unregister_submodule(&ioc4_ide_submodule);
775} 775}
776 776
777module_init(ioc4_ide_init); 777late_initcall(ioc4_ide_init); /* Call only after IDE init is done */
778module_exit(ioc4_ide_exit); 778module_exit(ioc4_ide_exit);
779 779
780MODULE_AUTHOR("Aniket Malatpure/Jeremy Higdon"); 780MODULE_AUTHOR("Aniket Malatpure/Jeremy Higdon");
diff --git a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c
index 8a7b8fab6238..31e5cc49d61a 100644
--- a/drivers/ieee1394/eth1394.c
+++ b/drivers/ieee1394/eth1394.c
@@ -64,6 +64,7 @@
64#include <linux/ethtool.h> 64#include <linux/ethtool.h>
65#include <asm/uaccess.h> 65#include <asm/uaccess.h>
66#include <asm/delay.h> 66#include <asm/delay.h>
67#include <asm/unaligned.h>
67#include <net/arp.h> 68#include <net/arp.h>
68 69
69#include "config_roms.h" 70#include "config_roms.h"
@@ -491,7 +492,7 @@ static void ether1394_reset_priv (struct net_device *dev, int set_mtu)
491 int i; 492 int i;
492 struct eth1394_priv *priv = netdev_priv(dev); 493 struct eth1394_priv *priv = netdev_priv(dev);
493 struct hpsb_host *host = priv->host; 494 struct hpsb_host *host = priv->host;
494 u64 guid = *((u64*)&(host->csr.rom->bus_info_data[3])); 495 u64 guid = get_unaligned((u64*)&(host->csr.rom->bus_info_data[3]));
495 u16 maxpayload = 1 << (host->csr.max_rec + 1); 496 u16 maxpayload = 1 << (host->csr.max_rec + 1);
496 int max_speed = IEEE1394_SPEED_MAX; 497 int max_speed = IEEE1394_SPEED_MAX;
497 498
@@ -514,8 +515,8 @@ static void ether1394_reset_priv (struct net_device *dev, int set_mtu)
514 ETHER1394_GASP_OVERHEAD))); 515 ETHER1394_GASP_OVERHEAD)));
515 516
516 /* Set our hardware address while we're at it */ 517 /* Set our hardware address while we're at it */
517 *(u64*)dev->dev_addr = guid; 518 memcpy(dev->dev_addr, &guid, sizeof(u64));
518 *(u64*)dev->broadcast = ~0x0ULL; 519 memset(dev->broadcast, 0xff, sizeof(u64));
519 } 520 }
520 521
521 spin_unlock_irqrestore (&priv->lock, flags); 522 spin_unlock_irqrestore (&priv->lock, flags);
@@ -894,6 +895,7 @@ static inline u16 ether1394_parse_encap(struct sk_buff *skb,
894 u16 maxpayload; 895 u16 maxpayload;
895 struct eth1394_node_ref *node; 896 struct eth1394_node_ref *node;
896 struct eth1394_node_info *node_info; 897 struct eth1394_node_info *node_info;
898 __be64 guid;
897 899
898 /* Sanity check. MacOSX seems to be sending us 131 in this 900 /* Sanity check. MacOSX seems to be sending us 131 in this
899 * field (atleast on my Panther G5). Not sure why. */ 901 * field (atleast on my Panther G5). Not sure why. */
@@ -902,8 +904,9 @@ static inline u16 ether1394_parse_encap(struct sk_buff *skb,
902 904
903 maxpayload = min(eth1394_speedto_maxpayload[sspd], (u16)(1 << (max_rec + 1))); 905 maxpayload = min(eth1394_speedto_maxpayload[sspd], (u16)(1 << (max_rec + 1)));
904 906
907 guid = get_unaligned(&arp1394->s_uniq_id);
905 node = eth1394_find_node_guid(&priv->ip_node_list, 908 node = eth1394_find_node_guid(&priv->ip_node_list,
906 be64_to_cpu(arp1394->s_uniq_id)); 909 be64_to_cpu(guid));
907 if (!node) { 910 if (!node) {
908 return 0; 911 return 0;
909 } 912 }
@@ -931,10 +934,9 @@ static inline u16 ether1394_parse_encap(struct sk_buff *skb,
931 arp_ptr += arp->ar_pln; /* skip over sender IP addr */ 934 arp_ptr += arp->ar_pln; /* skip over sender IP addr */
932 935
933 if (arp->ar_op == htons(ARPOP_REQUEST)) 936 if (arp->ar_op == htons(ARPOP_REQUEST))
934 /* just set ARP req target unique ID to 0 */ 937 memset(arp_ptr, 0, sizeof(u64));
935 *((u64*)arp_ptr) = 0;
936 else 938 else
937 *((u64*)arp_ptr) = *((u64*)dev->dev_addr); 939 memcpy(arp_ptr, dev->dev_addr, sizeof(u64));
938 } 940 }
939 941
940 /* Now add the ethernet header. */ 942 /* Now add the ethernet header. */
@@ -1675,8 +1677,10 @@ static int ether1394_tx (struct sk_buff *skb, struct net_device *dev)
1675 if (max_payload < dg_size + hdr_type_len[ETH1394_HDR_LF_UF]) 1677 if (max_payload < dg_size + hdr_type_len[ETH1394_HDR_LF_UF])
1676 priv->bc_dgl++; 1678 priv->bc_dgl++;
1677 } else { 1679 } else {
1680 __be64 guid = get_unaligned((u64 *)eth->h_dest);
1681
1678 node = eth1394_find_node_guid(&priv->ip_node_list, 1682 node = eth1394_find_node_guid(&priv->ip_node_list,
1679 be64_to_cpu(*(u64*)eth->h_dest)); 1683 be64_to_cpu(guid));
1680 if (!node) { 1684 if (!node) {
1681 ret = -EAGAIN; 1685 ret = -EAGAIN;
1682 goto fail; 1686 goto fail;
diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c
index dea13525df88..6e8ea9110c46 100644
--- a/drivers/ieee1394/ohci1394.c
+++ b/drivers/ieee1394/ohci1394.c
@@ -3552,12 +3552,21 @@ static int ohci1394_pci_suspend (struct pci_dev *pdev, pm_message_t state)
3552{ 3552{
3553 int err; 3553 int err;
3554 3554
3555 printk(KERN_INFO "%s does not fully support suspend and resume yet\n",
3556 OHCI1394_DRIVER_NAME);
3557
3555 err = pci_save_state(pdev); 3558 err = pci_save_state(pdev);
3556 if (err) 3559 if (err) {
3557 goto out; 3560 printk(KERN_ERR "%s: pci_save_state failed with %d\n",
3561 OHCI1394_DRIVER_NAME, err);
3562 return err;
3563 }
3558 err = pci_set_power_state(pdev, pci_choose_state(pdev, state)); 3564 err = pci_set_power_state(pdev, pci_choose_state(pdev, state));
3565#ifdef OHCI1394_DEBUG
3559 if (err) 3566 if (err)
3560 goto out; 3567 printk(KERN_DEBUG "%s: pci_set_power_state failed with %d\n",
3568 OHCI1394_DRIVER_NAME, err);
3569#endif /* OHCI1394_DEBUG */
3561 3570
3562/* PowerMac suspend code comes last */ 3571/* PowerMac suspend code comes last */
3563#ifdef CONFIG_PPC_PMAC 3572#ifdef CONFIG_PPC_PMAC
@@ -3570,8 +3579,8 @@ static int ohci1394_pci_suspend (struct pci_dev *pdev, pm_message_t state)
3570 pmac_call_feature(PMAC_FTR_1394_ENABLE, of_node, 0, 0); 3579 pmac_call_feature(PMAC_FTR_1394_ENABLE, of_node, 0, 0);
3571 } 3580 }
3572#endif /* CONFIG_PPC_PMAC */ 3581#endif /* CONFIG_PPC_PMAC */
3573out: 3582
3574 return err; 3583 return 0;
3575} 3584}
3576#endif /* CONFIG_PM */ 3585#endif /* CONFIG_PM */
3577 3586
diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index 60d3fbdd216c..e11187ecc931 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -47,6 +47,7 @@ struct addr_req {
47 struct sockaddr src_addr; 47 struct sockaddr src_addr;
48 struct sockaddr dst_addr; 48 struct sockaddr dst_addr;
49 struct rdma_dev_addr *addr; 49 struct rdma_dev_addr *addr;
50 struct rdma_addr_client *client;
50 void *context; 51 void *context;
51 void (*callback)(int status, struct sockaddr *src_addr, 52 void (*callback)(int status, struct sockaddr *src_addr,
52 struct rdma_dev_addr *addr, void *context); 53 struct rdma_dev_addr *addr, void *context);
@@ -61,6 +62,26 @@ static LIST_HEAD(req_list);
61static DECLARE_WORK(work, process_req, NULL); 62static DECLARE_WORK(work, process_req, NULL);
62static struct workqueue_struct *addr_wq; 63static struct workqueue_struct *addr_wq;
63 64
65void rdma_addr_register_client(struct rdma_addr_client *client)
66{
67 atomic_set(&client->refcount, 1);
68 init_completion(&client->comp);
69}
70EXPORT_SYMBOL(rdma_addr_register_client);
71
72static inline void put_client(struct rdma_addr_client *client)
73{
74 if (atomic_dec_and_test(&client->refcount))
75 complete(&client->comp);
76}
77
78void rdma_addr_unregister_client(struct rdma_addr_client *client)
79{
80 put_client(client);
81 wait_for_completion(&client->comp);
82}
83EXPORT_SYMBOL(rdma_addr_unregister_client);
84
64int rdma_copy_addr(struct rdma_dev_addr *dev_addr, struct net_device *dev, 85int rdma_copy_addr(struct rdma_dev_addr *dev_addr, struct net_device *dev,
65 const unsigned char *dst_dev_addr) 86 const unsigned char *dst_dev_addr)
66{ 87{
@@ -229,6 +250,7 @@ static void process_req(void *data)
229 list_del(&req->list); 250 list_del(&req->list);
230 req->callback(req->status, &req->src_addr, req->addr, 251 req->callback(req->status, &req->src_addr, req->addr,
231 req->context); 252 req->context);
253 put_client(req->client);
232 kfree(req); 254 kfree(req);
233 } 255 }
234} 256}
@@ -264,7 +286,8 @@ static int addr_resolve_local(struct sockaddr_in *src_in,
264 return ret; 286 return ret;
265} 287}
266 288
267int rdma_resolve_ip(struct sockaddr *src_addr, struct sockaddr *dst_addr, 289int rdma_resolve_ip(struct rdma_addr_client *client,
290 struct sockaddr *src_addr, struct sockaddr *dst_addr,
268 struct rdma_dev_addr *addr, int timeout_ms, 291 struct rdma_dev_addr *addr, int timeout_ms,
269 void (*callback)(int status, struct sockaddr *src_addr, 292 void (*callback)(int status, struct sockaddr *src_addr,
270 struct rdma_dev_addr *addr, void *context), 293 struct rdma_dev_addr *addr, void *context),
@@ -285,6 +308,8 @@ int rdma_resolve_ip(struct sockaddr *src_addr, struct sockaddr *dst_addr,
285 req->addr = addr; 308 req->addr = addr;
286 req->callback = callback; 309 req->callback = callback;
287 req->context = context; 310 req->context = context;
311 req->client = client;
312 atomic_inc(&client->refcount);
288 313
289 src_in = (struct sockaddr_in *) &req->src_addr; 314 src_in = (struct sockaddr_in *) &req->src_addr;
290 dst_in = (struct sockaddr_in *) &req->dst_addr; 315 dst_in = (struct sockaddr_in *) &req->dst_addr;
@@ -305,6 +330,7 @@ int rdma_resolve_ip(struct sockaddr *src_addr, struct sockaddr *dst_addr,
305 break; 330 break;
306 default: 331 default:
307 ret = req->status; 332 ret = req->status;
333 atomic_dec(&client->refcount);
308 kfree(req); 334 kfree(req);
309 break; 335 break;
310 } 336 }
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 9ae4f3a67c70..845090b0859c 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -63,6 +63,7 @@ static struct ib_client cma_client = {
63}; 63};
64 64
65static struct ib_sa_client sa_client; 65static struct ib_sa_client sa_client;
66static struct rdma_addr_client addr_client;
66static LIST_HEAD(dev_list); 67static LIST_HEAD(dev_list);
67static LIST_HEAD(listen_any_list); 68static LIST_HEAD(listen_any_list);
68static DEFINE_MUTEX(lock); 69static DEFINE_MUTEX(lock);
@@ -1625,8 +1626,8 @@ int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
1625 if (cma_any_addr(dst_addr)) 1626 if (cma_any_addr(dst_addr))
1626 ret = cma_resolve_loopback(id_priv); 1627 ret = cma_resolve_loopback(id_priv);
1627 else 1628 else
1628 ret = rdma_resolve_ip(&id->route.addr.src_addr, dst_addr, 1629 ret = rdma_resolve_ip(&addr_client, &id->route.addr.src_addr,
1629 &id->route.addr.dev_addr, 1630 dst_addr, &id->route.addr.dev_addr,
1630 timeout_ms, addr_handler, id_priv); 1631 timeout_ms, addr_handler, id_priv);
1631 if (ret) 1632 if (ret)
1632 goto err; 1633 goto err;
@@ -1762,22 +1763,29 @@ int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr)
1762 1763
1763 if (!cma_any_addr(addr)) { 1764 if (!cma_any_addr(addr)) {
1764 ret = rdma_translate_ip(addr, &id->route.addr.dev_addr); 1765 ret = rdma_translate_ip(addr, &id->route.addr.dev_addr);
1765 if (!ret) {
1766 mutex_lock(&lock);
1767 ret = cma_acquire_dev(id_priv);
1768 mutex_unlock(&lock);
1769 }
1770 if (ret) 1766 if (ret)
1771 goto err; 1767 goto err1;
1768
1769 mutex_lock(&lock);
1770 ret = cma_acquire_dev(id_priv);
1771 mutex_unlock(&lock);
1772 if (ret)
1773 goto err1;
1772 } 1774 }
1773 1775
1774 memcpy(&id->route.addr.src_addr, addr, ip_addr_size(addr)); 1776 memcpy(&id->route.addr.src_addr, addr, ip_addr_size(addr));
1775 ret = cma_get_port(id_priv); 1777 ret = cma_get_port(id_priv);
1776 if (ret) 1778 if (ret)
1777 goto err; 1779 goto err2;
1778 1780
1779 return 0; 1781 return 0;
1780err: 1782err2:
1783 if (!cma_any_addr(addr)) {
1784 mutex_lock(&lock);
1785 cma_detach_from_dev(id_priv);
1786 mutex_unlock(&lock);
1787 }
1788err1:
1781 cma_comp_exch(id_priv, CMA_ADDR_BOUND, CMA_IDLE); 1789 cma_comp_exch(id_priv, CMA_ADDR_BOUND, CMA_IDLE);
1782 return ret; 1790 return ret;
1783} 1791}
@@ -2210,6 +2218,7 @@ static int cma_init(void)
2210 return -ENOMEM; 2218 return -ENOMEM;
2211 2219
2212 ib_sa_register_client(&sa_client); 2220 ib_sa_register_client(&sa_client);
2221 rdma_addr_register_client(&addr_client);
2213 2222
2214 ret = ib_register_client(&cma_client); 2223 ret = ib_register_client(&cma_client);
2215 if (ret) 2224 if (ret)
@@ -2217,6 +2226,7 @@ static int cma_init(void)
2217 return 0; 2226 return 0;
2218 2227
2219err: 2228err:
2229 rdma_addr_unregister_client(&addr_client);
2220 ib_sa_unregister_client(&sa_client); 2230 ib_sa_unregister_client(&sa_client);
2221 destroy_workqueue(cma_wq); 2231 destroy_workqueue(cma_wq);
2222 return ret; 2232 return ret;
@@ -2225,6 +2235,7 @@ err:
2225static void cma_cleanup(void) 2235static void cma_cleanup(void)
2226{ 2236{
2227 ib_unregister_client(&cma_client); 2237 ib_unregister_client(&cma_client);
2238 rdma_addr_unregister_client(&addr_client);
2228 ib_sa_unregister_client(&sa_client); 2239 ib_sa_unregister_client(&sa_client);
2229 destroy_workqueue(cma_wq); 2240 destroy_workqueue(cma_wq);
2230 idr_destroy(&sdp_ps); 2241 idr_destroy(&sdp_ps);
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index 493f4c65c7a2..a72bcea46ff6 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -1750,7 +1750,7 @@ ib_find_send_mad(struct ib_mad_agent_private *mad_agent_priv,
1750 */ 1750 */
1751 (is_direct(wc->recv_buf.mad->mad_hdr.mgmt_class) || 1751 (is_direct(wc->recv_buf.mad->mad_hdr.mgmt_class) ||
1752 rcv_has_same_gid(mad_agent_priv, wr, wc))) 1752 rcv_has_same_gid(mad_agent_priv, wr, wc)))
1753 return wr; 1753 return (wr->status == IB_WC_SUCCESS) ? wr : NULL;
1754 } 1754 }
1755 1755
1756 /* 1756 /*
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index b72c7f69ca90..743247ec065e 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -1214,7 +1214,7 @@ ssize_t ib_uverbs_query_qp(struct ib_uverbs_file *file,
1214 resp.qp_access_flags = attr->qp_access_flags; 1214 resp.qp_access_flags = attr->qp_access_flags;
1215 resp.pkey_index = attr->pkey_index; 1215 resp.pkey_index = attr->pkey_index;
1216 resp.alt_pkey_index = attr->alt_pkey_index; 1216 resp.alt_pkey_index = attr->alt_pkey_index;
1217 resp.en_sqd_async_notify = attr->en_sqd_async_notify; 1217 resp.sq_draining = attr->sq_draining;
1218 resp.max_rd_atomic = attr->max_rd_atomic; 1218 resp.max_rd_atomic = attr->max_rd_atomic;
1219 resp.max_dest_rd_atomic = attr->max_dest_rd_atomic; 1219 resp.max_dest_rd_atomic = attr->max_dest_rd_atomic;
1220 resp.min_rnr_timer = attr->min_rnr_timer; 1220 resp.min_rnr_timer = attr->min_rnr_timer;
diff --git a/drivers/infiniband/hw/amso1100/c2.c b/drivers/infiniband/hw/amso1100/c2.c
index dc1ebeac35c7..27fe242ed435 100644
--- a/drivers/infiniband/hw/amso1100/c2.c
+++ b/drivers/infiniband/hw/amso1100/c2.c
@@ -1155,7 +1155,8 @@ static int __devinit c2_probe(struct pci_dev *pcidev,
1155 goto bail10; 1155 goto bail10;
1156 } 1156 }
1157 1157
1158 c2_register_device(c2dev); 1158 if (c2_register_device(c2dev))
1159 goto bail10;
1159 1160
1160 return 0; 1161 return 0;
1161 1162
@@ -1243,7 +1244,7 @@ static struct pci_driver c2_pci_driver = {
1243 1244
1244static int __init c2_init_module(void) 1245static int __init c2_init_module(void)
1245{ 1246{
1246 return pci_module_init(&c2_pci_driver); 1247 return pci_register_driver(&c2_pci_driver);
1247} 1248}
1248 1249
1249static void __exit c2_exit_module(void) 1250static void __exit c2_exit_module(void)
diff --git a/drivers/infiniband/hw/amso1100/c2_alloc.c b/drivers/infiniband/hw/amso1100/c2_alloc.c
index 028a60bbfca9..0315f99e4191 100644
--- a/drivers/infiniband/hw/amso1100/c2_alloc.c
+++ b/drivers/infiniband/hw/amso1100/c2_alloc.c
@@ -42,13 +42,14 @@ static int c2_alloc_mqsp_chunk(struct c2_dev *c2dev, gfp_t gfp_mask,
42{ 42{
43 int i; 43 int i;
44 struct sp_chunk *new_head; 44 struct sp_chunk *new_head;
45 dma_addr_t dma_addr;
45 46
46 new_head = (struct sp_chunk *) __get_free_page(gfp_mask); 47 new_head = dma_alloc_coherent(&c2dev->pcidev->dev, PAGE_SIZE,
48 &dma_addr, gfp_mask);
47 if (new_head == NULL) 49 if (new_head == NULL)
48 return -ENOMEM; 50 return -ENOMEM;
49 51
50 new_head->dma_addr = dma_map_single(c2dev->ibdev.dma_device, new_head, 52 new_head->dma_addr = dma_addr;
51 PAGE_SIZE, DMA_FROM_DEVICE);
52 pci_unmap_addr_set(new_head, mapping, new_head->dma_addr); 53 pci_unmap_addr_set(new_head, mapping, new_head->dma_addr);
53 54
54 new_head->next = NULL; 55 new_head->next = NULL;
@@ -80,10 +81,8 @@ void c2_free_mqsp_pool(struct c2_dev *c2dev, struct sp_chunk *root)
80 81
81 while (root) { 82 while (root) {
82 next = root->next; 83 next = root->next;
83 dma_unmap_single(c2dev->ibdev.dma_device, 84 dma_free_coherent(&c2dev->pcidev->dev, PAGE_SIZE, root,
84 pci_unmap_addr(root, mapping), PAGE_SIZE, 85 pci_unmap_addr(root, mapping));
85 DMA_FROM_DEVICE);
86 __free_page((struct page *) root);
87 root = next; 86 root = next;
88 } 87 }
89} 88}
diff --git a/drivers/infiniband/hw/amso1100/c2_cq.c b/drivers/infiniband/hw/amso1100/c2_cq.c
index 9d7bcc5ade93..05c9154d46f4 100644
--- a/drivers/infiniband/hw/amso1100/c2_cq.c
+++ b/drivers/infiniband/hw/amso1100/c2_cq.c
@@ -246,20 +246,17 @@ int c2_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify notify)
246 246
247static void c2_free_cq_buf(struct c2_dev *c2dev, struct c2_mq *mq) 247static void c2_free_cq_buf(struct c2_dev *c2dev, struct c2_mq *mq)
248{ 248{
249 249 dma_free_coherent(&c2dev->pcidev->dev, mq->q_size * mq->msg_size,
250 dma_unmap_single(c2dev->ibdev.dma_device, pci_unmap_addr(mq, mapping), 250 mq->msg_pool.host, pci_unmap_addr(mq, mapping));
251 mq->q_size * mq->msg_size, DMA_FROM_DEVICE);
252 free_pages((unsigned long) mq->msg_pool.host,
253 get_order(mq->q_size * mq->msg_size));
254} 251}
255 252
256static int c2_alloc_cq_buf(struct c2_dev *c2dev, struct c2_mq *mq, int q_size, 253static int c2_alloc_cq_buf(struct c2_dev *c2dev, struct c2_mq *mq, int q_size,
257 int msg_size) 254 int msg_size)
258{ 255{
259 unsigned long pool_start; 256 u8 *pool_start;
260 257
261 pool_start = __get_free_pages(GFP_KERNEL, 258 pool_start = dma_alloc_coherent(&c2dev->pcidev->dev, q_size * msg_size,
262 get_order(q_size * msg_size)); 259 &mq->host_dma, GFP_KERNEL);
263 if (!pool_start) 260 if (!pool_start)
264 return -ENOMEM; 261 return -ENOMEM;
265 262
@@ -267,13 +264,10 @@ static int c2_alloc_cq_buf(struct c2_dev *c2dev, struct c2_mq *mq, int q_size,
267 0, /* index (currently unknown) */ 264 0, /* index (currently unknown) */
268 q_size, 265 q_size,
269 msg_size, 266 msg_size,
270 (u8 *) pool_start, 267 pool_start,
271 NULL, /* peer (currently unknown) */ 268 NULL, /* peer (currently unknown) */
272 C2_MQ_HOST_TARGET); 269 C2_MQ_HOST_TARGET);
273 270
274 mq->host_dma = dma_map_single(c2dev->ibdev.dma_device,
275 (void *)pool_start,
276 q_size * msg_size, DMA_FROM_DEVICE);
277 pci_unmap_addr_set(mq, mapping, mq->host_dma); 271 pci_unmap_addr_set(mq, mapping, mq->host_dma);
278 272
279 return 0; 273 return 0;
diff --git a/drivers/infiniband/hw/amso1100/c2_provider.c b/drivers/infiniband/hw/amso1100/c2_provider.c
index da98d9f71429..fef972752912 100644
--- a/drivers/infiniband/hw/amso1100/c2_provider.c
+++ b/drivers/infiniband/hw/amso1100/c2_provider.c
@@ -757,20 +757,17 @@ static struct net_device *c2_pseudo_netdev_init(struct c2_dev *c2dev)
757 757
758int c2_register_device(struct c2_dev *dev) 758int c2_register_device(struct c2_dev *dev)
759{ 759{
760 int ret; 760 int ret = -ENOMEM;
761 int i; 761 int i;
762 762
763 /* Register pseudo network device */ 763 /* Register pseudo network device */
764 dev->pseudo_netdev = c2_pseudo_netdev_init(dev); 764 dev->pseudo_netdev = c2_pseudo_netdev_init(dev);
765 if (dev->pseudo_netdev) { 765 if (!dev->pseudo_netdev)
766 ret = register_netdev(dev->pseudo_netdev); 766 goto out3;
767 if (ret) { 767
768 printk(KERN_ERR PFX 768 ret = register_netdev(dev->pseudo_netdev);
769 "Unable to register netdev, ret = %d\n", ret); 769 if (ret)
770 free_netdev(dev->pseudo_netdev); 770 goto out2;
771 return ret;
772 }
773 }
774 771
775 pr_debug("%s:%u\n", __FUNCTION__, __LINE__); 772 pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
776 strlcpy(dev->ibdev.name, "amso%d", IB_DEVICE_NAME_MAX); 773 strlcpy(dev->ibdev.name, "amso%d", IB_DEVICE_NAME_MAX);
@@ -848,21 +845,25 @@ int c2_register_device(struct c2_dev *dev)
848 845
849 ret = ib_register_device(&dev->ibdev); 846 ret = ib_register_device(&dev->ibdev);
850 if (ret) 847 if (ret)
851 return ret; 848 goto out1;
852 849
853 for (i = 0; i < ARRAY_SIZE(c2_class_attributes); ++i) { 850 for (i = 0; i < ARRAY_SIZE(c2_class_attributes); ++i) {
854 ret = class_device_create_file(&dev->ibdev.class_dev, 851 ret = class_device_create_file(&dev->ibdev.class_dev,
855 c2_class_attributes[i]); 852 c2_class_attributes[i]);
856 if (ret) { 853 if (ret)
857 unregister_netdev(dev->pseudo_netdev); 854 goto out0;
858 free_netdev(dev->pseudo_netdev);
859 ib_unregister_device(&dev->ibdev);
860 return ret;
861 }
862 } 855 }
856 goto out3;
863 857
864 pr_debug("%s:%u\n", __FUNCTION__, __LINE__); 858out0:
865 return 0; 859 ib_unregister_device(&dev->ibdev);
860out1:
861 unregister_netdev(dev->pseudo_netdev);
862out2:
863 free_netdev(dev->pseudo_netdev);
864out3:
865 pr_debug("%s:%u ret=%d\n", __FUNCTION__, __LINE__, ret);
866 return ret;
866} 867}
867 868
868void c2_unregister_device(struct c2_dev *dev) 869void c2_unregister_device(struct c2_dev *dev)
diff --git a/drivers/infiniband/hw/amso1100/c2_rnic.c b/drivers/infiniband/hw/amso1100/c2_rnic.c
index e37c5688c214..623dc95f91df 100644
--- a/drivers/infiniband/hw/amso1100/c2_rnic.c
+++ b/drivers/infiniband/hw/amso1100/c2_rnic.c
@@ -150,15 +150,15 @@ static int c2_rnic_query(struct c2_dev *c2dev, struct ib_device_attr *props)
150 (struct c2wr_rnic_query_rep *) (unsigned long) (vq_req->reply_msg); 150 (struct c2wr_rnic_query_rep *) (unsigned long) (vq_req->reply_msg);
151 if (!reply) 151 if (!reply)
152 err = -ENOMEM; 152 err = -ENOMEM;
153 153 else
154 err = c2_errno(reply); 154 err = c2_errno(reply);
155 if (err) 155 if (err)
156 goto bail2; 156 goto bail2;
157 157
158 props->fw_ver = 158 props->fw_ver =
159 ((u64)be32_to_cpu(reply->fw_ver_major) << 32) | 159 ((u64)be32_to_cpu(reply->fw_ver_major) << 32) |
160 ((be32_to_cpu(reply->fw_ver_minor) && 0xFFFF) << 16) | 160 ((be32_to_cpu(reply->fw_ver_minor) & 0xFFFF) << 16) |
161 (be32_to_cpu(reply->fw_ver_patch) && 0xFFFF); 161 (be32_to_cpu(reply->fw_ver_patch) & 0xFFFF);
162 memcpy(&props->sys_image_guid, c2dev->netdev->dev_addr, 6); 162 memcpy(&props->sys_image_guid, c2dev->netdev->dev_addr, 6);
163 props->max_mr_size = 0xFFFFFFFF; 163 props->max_mr_size = 0xFFFFFFFF;
164 props->page_size_cap = ~(C2_MIN_PAGESIZE-1); 164 props->page_size_cap = ~(C2_MIN_PAGESIZE-1);
@@ -517,14 +517,12 @@ int c2_rnic_init(struct c2_dev *c2dev)
517 /* Initialize the Verbs Reply Queue */ 517 /* Initialize the Verbs Reply Queue */
518 qsize = be32_to_cpu(readl(mmio_regs + C2_REGS_Q1_QSIZE)); 518 qsize = be32_to_cpu(readl(mmio_regs + C2_REGS_Q1_QSIZE));
519 msgsize = be32_to_cpu(readl(mmio_regs + C2_REGS_Q1_MSGSIZE)); 519 msgsize = be32_to_cpu(readl(mmio_regs + C2_REGS_Q1_MSGSIZE));
520 q1_pages = kmalloc(qsize * msgsize, GFP_KERNEL); 520 q1_pages = dma_alloc_coherent(&c2dev->pcidev->dev, qsize * msgsize,
521 &c2dev->rep_vq.host_dma, GFP_KERNEL);
521 if (!q1_pages) { 522 if (!q1_pages) {
522 err = -ENOMEM; 523 err = -ENOMEM;
523 goto bail1; 524 goto bail1;
524 } 525 }
525 c2dev->rep_vq.host_dma = dma_map_single(c2dev->ibdev.dma_device,
526 (void *)q1_pages, qsize * msgsize,
527 DMA_FROM_DEVICE);
528 pci_unmap_addr_set(&c2dev->rep_vq, mapping, c2dev->rep_vq.host_dma); 526 pci_unmap_addr_set(&c2dev->rep_vq, mapping, c2dev->rep_vq.host_dma);
529 pr_debug("%s rep_vq va %p dma %llx\n", __FUNCTION__, q1_pages, 527 pr_debug("%s rep_vq va %p dma %llx\n", __FUNCTION__, q1_pages,
530 (unsigned long long) c2dev->rep_vq.host_dma); 528 (unsigned long long) c2dev->rep_vq.host_dma);
@@ -540,17 +538,15 @@ int c2_rnic_init(struct c2_dev *c2dev)
540 /* Initialize the Asynchronus Event Queue */ 538 /* Initialize the Asynchronus Event Queue */
541 qsize = be32_to_cpu(readl(mmio_regs + C2_REGS_Q2_QSIZE)); 539 qsize = be32_to_cpu(readl(mmio_regs + C2_REGS_Q2_QSIZE));
542 msgsize = be32_to_cpu(readl(mmio_regs + C2_REGS_Q2_MSGSIZE)); 540 msgsize = be32_to_cpu(readl(mmio_regs + C2_REGS_Q2_MSGSIZE));
543 q2_pages = kmalloc(qsize * msgsize, GFP_KERNEL); 541 q2_pages = dma_alloc_coherent(&c2dev->pcidev->dev, qsize * msgsize,
542 &c2dev->aeq.host_dma, GFP_KERNEL);
544 if (!q2_pages) { 543 if (!q2_pages) {
545 err = -ENOMEM; 544 err = -ENOMEM;
546 goto bail2; 545 goto bail2;
547 } 546 }
548 c2dev->aeq.host_dma = dma_map_single(c2dev->ibdev.dma_device,
549 (void *)q2_pages, qsize * msgsize,
550 DMA_FROM_DEVICE);
551 pci_unmap_addr_set(&c2dev->aeq, mapping, c2dev->aeq.host_dma); 547 pci_unmap_addr_set(&c2dev->aeq, mapping, c2dev->aeq.host_dma);
552 pr_debug("%s aeq va %p dma %llx\n", __FUNCTION__, q1_pages, 548 pr_debug("%s aeq va %p dma %llx\n", __FUNCTION__, q2_pages,
553 (unsigned long long) c2dev->rep_vq.host_dma); 549 (unsigned long long) c2dev->aeq.host_dma);
554 c2_mq_rep_init(&c2dev->aeq, 550 c2_mq_rep_init(&c2dev->aeq,
555 2, 551 2,
556 qsize, 552 qsize,
@@ -597,17 +593,13 @@ int c2_rnic_init(struct c2_dev *c2dev)
597 bail4: 593 bail4:
598 vq_term(c2dev); 594 vq_term(c2dev);
599 bail3: 595 bail3:
600 dma_unmap_single(c2dev->ibdev.dma_device, 596 dma_free_coherent(&c2dev->pcidev->dev,
601 pci_unmap_addr(&c2dev->aeq, mapping), 597 c2dev->aeq.q_size * c2dev->aeq.msg_size,
602 c2dev->aeq.q_size * c2dev->aeq.msg_size, 598 q2_pages, pci_unmap_addr(&c2dev->aeq, mapping));
603 DMA_FROM_DEVICE);
604 kfree(q2_pages);
605 bail2: 599 bail2:
606 dma_unmap_single(c2dev->ibdev.dma_device, 600 dma_free_coherent(&c2dev->pcidev->dev,
607 pci_unmap_addr(&c2dev->rep_vq, mapping), 601 c2dev->rep_vq.q_size * c2dev->rep_vq.msg_size,
608 c2dev->rep_vq.q_size * c2dev->rep_vq.msg_size, 602 q1_pages, pci_unmap_addr(&c2dev->rep_vq, mapping));
609 DMA_FROM_DEVICE);
610 kfree(q1_pages);
611 bail1: 603 bail1:
612 c2_free_mqsp_pool(c2dev, c2dev->kern_mqsp_pool); 604 c2_free_mqsp_pool(c2dev, c2dev->kern_mqsp_pool);
613 bail0: 605 bail0:
@@ -640,19 +632,17 @@ void c2_rnic_term(struct c2_dev *c2dev)
640 /* Free the verbs request allocator */ 632 /* Free the verbs request allocator */
641 vq_term(c2dev); 633 vq_term(c2dev);
642 634
643 /* Unmap and free the asynchronus event queue */ 635 /* Free the asynchronus event queue */
644 dma_unmap_single(c2dev->ibdev.dma_device, 636 dma_free_coherent(&c2dev->pcidev->dev,
645 pci_unmap_addr(&c2dev->aeq, mapping), 637 c2dev->aeq.q_size * c2dev->aeq.msg_size,
646 c2dev->aeq.q_size * c2dev->aeq.msg_size, 638 c2dev->aeq.msg_pool.host,
647 DMA_FROM_DEVICE); 639 pci_unmap_addr(&c2dev->aeq, mapping));
648 kfree(c2dev->aeq.msg_pool.host); 640
649 641 /* Free the verbs reply queue */
650 /* Unmap and free the verbs reply queue */ 642 dma_free_coherent(&c2dev->pcidev->dev,
651 dma_unmap_single(c2dev->ibdev.dma_device, 643 c2dev->rep_vq.q_size * c2dev->rep_vq.msg_size,
652 pci_unmap_addr(&c2dev->rep_vq, mapping), 644 c2dev->rep_vq.msg_pool.host,
653 c2dev->rep_vq.q_size * c2dev->rep_vq.msg_size, 645 pci_unmap_addr(&c2dev->rep_vq, mapping));
654 DMA_FROM_DEVICE);
655 kfree(c2dev->rep_vq.msg_pool.host);
656 646
657 /* Free the MQ shared pointer pool */ 647 /* Free the MQ shared pointer pool */
658 c2_free_mqsp_pool(c2dev, c2dev->kern_mqsp_pool); 648 c2_free_mqsp_pool(c2dev, c2dev->kern_mqsp_pool);
diff --git a/drivers/infiniband/hw/ehca/Kconfig b/drivers/infiniband/hw/ehca/Kconfig
index 922389b64394..727b10d89686 100644
--- a/drivers/infiniband/hw/ehca/Kconfig
+++ b/drivers/infiniband/hw/ehca/Kconfig
@@ -10,6 +10,7 @@ config INFINIBAND_EHCA
10config INFINIBAND_EHCA_SCALING 10config INFINIBAND_EHCA_SCALING
11 bool "Scaling support (EXPERIMENTAL)" 11 bool "Scaling support (EXPERIMENTAL)"
12 depends on IBMEBUS && INFINIBAND_EHCA && HOTPLUG_CPU && EXPERIMENTAL 12 depends on IBMEBUS && INFINIBAND_EHCA && HOTPLUG_CPU && EXPERIMENTAL
13 default y
13 ---help--- 14 ---help---
14 eHCA scaling support schedules the CQ callbacks to different CPUs. 15 eHCA scaling support schedules the CQ callbacks to different CPUs.
15 16
diff --git a/drivers/infiniband/hw/ehca/ehca_av.c b/drivers/infiniband/hw/ehca/ehca_av.c
index 3bac197f9014..214e2fdddeef 100644
--- a/drivers/infiniband/hw/ehca/ehca_av.c
+++ b/drivers/infiniband/hw/ehca/ehca_av.c
@@ -118,8 +118,7 @@ struct ib_ah *ehca_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
118 } 118 }
119 memcpy(&av->av.grh.word_1, &gid, sizeof(gid)); 119 memcpy(&av->av.grh.word_1, &gid, sizeof(gid));
120 } 120 }
121 /* for the time being we use a hard coded PMTU of 2048 Bytes */ 121 av->av.pmtu = EHCA_MAX_MTU;
122 av->av.pmtu = 4;
123 122
124 /* dgid comes in grh.word_3 */ 123 /* dgid comes in grh.word_3 */
125 memcpy(&av->av.grh.word_3, &ah_attr->grh.dgid, 124 memcpy(&av->av.grh.word_3, &ah_attr->grh.dgid,
@@ -193,7 +192,7 @@ int ehca_modify_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr)
193 memcpy(&new_ehca_av.grh.word_1, &gid, sizeof(gid)); 192 memcpy(&new_ehca_av.grh.word_1, &gid, sizeof(gid));
194 } 193 }
195 194
196 new_ehca_av.pmtu = 4; /* see also comment in create_ah() */ 195 new_ehca_av.pmtu = EHCA_MAX_MTU;
197 196
198 memcpy(&new_ehca_av.grh.word_3, &ah_attr->grh.dgid, 197 memcpy(&new_ehca_av.grh.word_3, &ah_attr->grh.dgid,
199 sizeof(ah_attr->grh.dgid)); 198 sizeof(ah_attr->grh.dgid));
diff --git a/drivers/infiniband/hw/ehca/ehca_hca.c b/drivers/infiniband/hw/ehca/ehca_hca.c
index 5eae6ac48425..e1b618c5f685 100644
--- a/drivers/infiniband/hw/ehca/ehca_hca.c
+++ b/drivers/infiniband/hw/ehca/ehca_hca.c
@@ -40,6 +40,7 @@
40 */ 40 */
41 41
42#include "ehca_tools.h" 42#include "ehca_tools.h"
43#include "ehca_iverbs.h"
43#include "hcp_if.h" 44#include "hcp_if.h"
44 45
45int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props) 46int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props)
@@ -49,7 +50,7 @@ int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props)
49 ib_device); 50 ib_device);
50 struct hipz_query_hca *rblock; 51 struct hipz_query_hca *rblock;
51 52
52 rblock = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 53 rblock = ehca_alloc_fw_ctrlblock();
53 if (!rblock) { 54 if (!rblock) {
54 ehca_err(&shca->ib_device, "Can't allocate rblock memory."); 55 ehca_err(&shca->ib_device, "Can't allocate rblock memory.");
55 return -ENOMEM; 56 return -ENOMEM;
@@ -96,7 +97,7 @@ int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props)
96 = min_t(int, rblock->max_total_mcast_qp_attach, INT_MAX); 97 = min_t(int, rblock->max_total_mcast_qp_attach, INT_MAX);
97 98
98query_device1: 99query_device1:
99 kfree(rblock); 100 ehca_free_fw_ctrlblock(rblock);
100 101
101 return ret; 102 return ret;
102} 103}
@@ -109,7 +110,7 @@ int ehca_query_port(struct ib_device *ibdev,
109 ib_device); 110 ib_device);
110 struct hipz_query_port *rblock; 111 struct hipz_query_port *rblock;
111 112
112 rblock = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 113 rblock = ehca_alloc_fw_ctrlblock();
113 if (!rblock) { 114 if (!rblock) {
114 ehca_err(&shca->ib_device, "Can't allocate rblock memory."); 115 ehca_err(&shca->ib_device, "Can't allocate rblock memory.");
115 return -ENOMEM; 116 return -ENOMEM;
@@ -162,7 +163,7 @@ int ehca_query_port(struct ib_device *ibdev,
162 props->active_speed = 0x1; 163 props->active_speed = 0x1;
163 164
164query_port1: 165query_port1:
165 kfree(rblock); 166 ehca_free_fw_ctrlblock(rblock);
166 167
167 return ret; 168 return ret;
168} 169}
@@ -178,7 +179,7 @@ int ehca_query_pkey(struct ib_device *ibdev, u8 port, u16 index, u16 *pkey)
178 return -EINVAL; 179 return -EINVAL;
179 } 180 }
180 181
181 rblock = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 182 rblock = ehca_alloc_fw_ctrlblock();
182 if (!rblock) { 183 if (!rblock) {
183 ehca_err(&shca->ib_device, "Can't allocate rblock memory."); 184 ehca_err(&shca->ib_device, "Can't allocate rblock memory.");
184 return -ENOMEM; 185 return -ENOMEM;
@@ -193,7 +194,7 @@ int ehca_query_pkey(struct ib_device *ibdev, u8 port, u16 index, u16 *pkey)
193 memcpy(pkey, &rblock->pkey_entries + index, sizeof(u16)); 194 memcpy(pkey, &rblock->pkey_entries + index, sizeof(u16));
194 195
195query_pkey1: 196query_pkey1:
196 kfree(rblock); 197 ehca_free_fw_ctrlblock(rblock);
197 198
198 return ret; 199 return ret;
199} 200}
@@ -211,7 +212,7 @@ int ehca_query_gid(struct ib_device *ibdev, u8 port,
211 return -EINVAL; 212 return -EINVAL;
212 } 213 }
213 214
214 rblock = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 215 rblock = ehca_alloc_fw_ctrlblock();
215 if (!rblock) { 216 if (!rblock) {
216 ehca_err(&shca->ib_device, "Can't allocate rblock memory."); 217 ehca_err(&shca->ib_device, "Can't allocate rblock memory.");
217 return -ENOMEM; 218 return -ENOMEM;
@@ -227,7 +228,7 @@ int ehca_query_gid(struct ib_device *ibdev, u8 port,
227 memcpy(&gid->raw[8], &rblock->guid_entries[index], sizeof(u64)); 228 memcpy(&gid->raw[8], &rblock->guid_entries[index], sizeof(u64));
228 229
229query_gid1: 230query_gid1:
230 kfree(rblock); 231 ehca_free_fw_ctrlblock(rblock);
231 232
232 return ret; 233 return ret;
233} 234}
diff --git a/drivers/infiniband/hw/ehca/ehca_irq.c b/drivers/infiniband/hw/ehca/ehca_irq.c
index 048cc443d1e7..c3ea746e9045 100644
--- a/drivers/infiniband/hw/ehca/ehca_irq.c
+++ b/drivers/infiniband/hw/ehca/ehca_irq.c
@@ -45,6 +45,7 @@
45#include "ehca_tools.h" 45#include "ehca_tools.h"
46#include "hcp_if.h" 46#include "hcp_if.h"
47#include "hipz_fns.h" 47#include "hipz_fns.h"
48#include "ipz_pt_fn.h"
48 49
49#define EQE_COMPLETION_EVENT EHCA_BMASK_IBM(1,1) 50#define EQE_COMPLETION_EVENT EHCA_BMASK_IBM(1,1)
50#define EQE_CQ_QP_NUMBER EHCA_BMASK_IBM(8,31) 51#define EQE_CQ_QP_NUMBER EHCA_BMASK_IBM(8,31)
@@ -137,38 +138,36 @@ int ehca_error_data(struct ehca_shca *shca, void *data,
137 u64 *rblock; 138 u64 *rblock;
138 unsigned long block_count; 139 unsigned long block_count;
139 140
140 rblock = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 141 rblock = ehca_alloc_fw_ctrlblock();
141 if (!rblock) { 142 if (!rblock) {
142 ehca_err(&shca->ib_device, "Cannot allocate rblock memory."); 143 ehca_err(&shca->ib_device, "Cannot allocate rblock memory.");
143 ret = -ENOMEM; 144 ret = -ENOMEM;
144 goto error_data1; 145 goto error_data1;
145 } 146 }
146 147
148 /* rblock must be 4K aligned and should be 4K large */
147 ret = hipz_h_error_data(shca->ipz_hca_handle, 149 ret = hipz_h_error_data(shca->ipz_hca_handle,
148 resource, 150 resource,
149 rblock, 151 rblock,
150 &block_count); 152 &block_count);
151 153
152 if (ret == H_R_STATE) { 154 if (ret == H_R_STATE)
153 ehca_err(&shca->ib_device, 155 ehca_err(&shca->ib_device,
154 "No error data is available: %lx.", resource); 156 "No error data is available: %lx.", resource);
155 }
156 else if (ret == H_SUCCESS) { 157 else if (ret == H_SUCCESS) {
157 int length; 158 int length;
158 159
159 length = EHCA_BMASK_GET(ERROR_DATA_LENGTH, rblock[0]); 160 length = EHCA_BMASK_GET(ERROR_DATA_LENGTH, rblock[0]);
160 161
161 if (length > PAGE_SIZE) 162 if (length > EHCA_PAGESIZE)
162 length = PAGE_SIZE; 163 length = EHCA_PAGESIZE;
163 164
164 print_error_data(shca, data, rblock, length); 165 print_error_data(shca, data, rblock, length);
165 } 166 } else
166 else {
167 ehca_err(&shca->ib_device, 167 ehca_err(&shca->ib_device,
168 "Error data could not be fetched: %lx", resource); 168 "Error data could not be fetched: %lx", resource);
169 }
170 169
171 kfree(rblock); 170 ehca_free_fw_ctrlblock(rblock);
172 171
173error_data1: 172error_data1:
174 return ret; 173 return ret;
diff --git a/drivers/infiniband/hw/ehca/ehca_iverbs.h b/drivers/infiniband/hw/ehca/ehca_iverbs.h
index 319c39d47f3a..3720e3032cce 100644
--- a/drivers/infiniband/hw/ehca/ehca_iverbs.h
+++ b/drivers/infiniband/hw/ehca/ehca_iverbs.h
@@ -179,4 +179,12 @@ int ehca_mmap_register(u64 physical,void **mapped,
179 179
180int ehca_munmap(unsigned long addr, size_t len); 180int ehca_munmap(unsigned long addr, size_t len);
181 181
182#ifdef CONFIG_PPC_64K_PAGES
183void *ehca_alloc_fw_ctrlblock(void);
184void ehca_free_fw_ctrlblock(void *ptr);
185#else
186#define ehca_alloc_fw_ctrlblock() ((void *) get_zeroed_page(GFP_KERNEL))
187#define ehca_free_fw_ctrlblock(ptr) free_page((unsigned long)(ptr))
188#endif
189
182#endif 190#endif
diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c
index 024d511c4b58..01f5aa9cb56d 100644
--- a/drivers/infiniband/hw/ehca/ehca_main.c
+++ b/drivers/infiniband/hw/ehca/ehca_main.c
@@ -40,6 +40,9 @@
40 * POSSIBILITY OF SUCH DAMAGE. 40 * POSSIBILITY OF SUCH DAMAGE.
41 */ 41 */
42 42
43#ifdef CONFIG_PPC_64K_PAGES
44#include <linux/slab.h>
45#endif
43#include "ehca_classes.h" 46#include "ehca_classes.h"
44#include "ehca_iverbs.h" 47#include "ehca_iverbs.h"
45#include "ehca_mrmw.h" 48#include "ehca_mrmw.h"
@@ -49,7 +52,7 @@
49MODULE_LICENSE("Dual BSD/GPL"); 52MODULE_LICENSE("Dual BSD/GPL");
50MODULE_AUTHOR("Christoph Raisch <raisch@de.ibm.com>"); 53MODULE_AUTHOR("Christoph Raisch <raisch@de.ibm.com>");
51MODULE_DESCRIPTION("IBM eServer HCA InfiniBand Device Driver"); 54MODULE_DESCRIPTION("IBM eServer HCA InfiniBand Device Driver");
52MODULE_VERSION("SVNEHCA_0017"); 55MODULE_VERSION("SVNEHCA_0018");
53 56
54int ehca_open_aqp1 = 0; 57int ehca_open_aqp1 = 0;
55int ehca_debug_level = 0; 58int ehca_debug_level = 0;
@@ -94,11 +97,31 @@ spinlock_t ehca_cq_idr_lock;
94DEFINE_IDR(ehca_qp_idr); 97DEFINE_IDR(ehca_qp_idr);
95DEFINE_IDR(ehca_cq_idr); 98DEFINE_IDR(ehca_cq_idr);
96 99
100
97static struct list_head shca_list; /* list of all registered ehcas */ 101static struct list_head shca_list; /* list of all registered ehcas */
98static spinlock_t shca_list_lock; 102static spinlock_t shca_list_lock;
99 103
100static struct timer_list poll_eqs_timer; 104static struct timer_list poll_eqs_timer;
101 105
106#ifdef CONFIG_PPC_64K_PAGES
107static struct kmem_cache *ctblk_cache = NULL;
108
109void *ehca_alloc_fw_ctrlblock(void)
110{
111 void *ret = kmem_cache_zalloc(ctblk_cache, SLAB_KERNEL);
112 if (!ret)
113 ehca_gen_err("Out of memory for ctblk");
114 return ret;
115}
116
117void ehca_free_fw_ctrlblock(void *ptr)
118{
119 if (ptr)
120 kmem_cache_free(ctblk_cache, ptr);
121
122}
123#endif
124
102static int ehca_create_slab_caches(void) 125static int ehca_create_slab_caches(void)
103{ 126{
104 int ret; 127 int ret;
@@ -133,6 +156,17 @@ static int ehca_create_slab_caches(void)
133 goto create_slab_caches5; 156 goto create_slab_caches5;
134 } 157 }
135 158
159#ifdef CONFIG_PPC_64K_PAGES
160 ctblk_cache = kmem_cache_create("ehca_cache_ctblk",
161 EHCA_PAGESIZE, H_CB_ALIGNMENT,
162 SLAB_HWCACHE_ALIGN,
163 NULL, NULL);
164 if (!ctblk_cache) {
165 ehca_gen_err("Cannot create ctblk SLAB cache.");
166 ehca_cleanup_mrmw_cache();
167 goto create_slab_caches5;
168 }
169#endif
136 return 0; 170 return 0;
137 171
138create_slab_caches5: 172create_slab_caches5:
@@ -157,6 +191,10 @@ static void ehca_destroy_slab_caches(void)
157 ehca_cleanup_qp_cache(); 191 ehca_cleanup_qp_cache();
158 ehca_cleanup_cq_cache(); 192 ehca_cleanup_cq_cache();
159 ehca_cleanup_pd_cache(); 193 ehca_cleanup_pd_cache();
194#ifdef CONFIG_PPC_64K_PAGES
195 if (ctblk_cache)
196 kmem_cache_destroy(ctblk_cache);
197#endif
160} 198}
161 199
162#define EHCA_HCAAVER EHCA_BMASK_IBM(32,39) 200#define EHCA_HCAAVER EHCA_BMASK_IBM(32,39)
@@ -168,7 +206,7 @@ int ehca_sense_attributes(struct ehca_shca *shca)
168 u64 h_ret; 206 u64 h_ret;
169 struct hipz_query_hca *rblock; 207 struct hipz_query_hca *rblock;
170 208
171 rblock = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 209 rblock = ehca_alloc_fw_ctrlblock();
172 if (!rblock) { 210 if (!rblock) {
173 ehca_gen_err("Cannot allocate rblock memory."); 211 ehca_gen_err("Cannot allocate rblock memory.");
174 return -ENOMEM; 212 return -ENOMEM;
@@ -211,7 +249,7 @@ int ehca_sense_attributes(struct ehca_shca *shca)
211 shca->sport[1].rate = IB_RATE_30_GBPS; 249 shca->sport[1].rate = IB_RATE_30_GBPS;
212 250
213num_ports1: 251num_ports1:
214 kfree(rblock); 252 ehca_free_fw_ctrlblock(rblock);
215 return ret; 253 return ret;
216} 254}
217 255
@@ -220,7 +258,7 @@ static int init_node_guid(struct ehca_shca *shca)
220 int ret = 0; 258 int ret = 0;
221 struct hipz_query_hca *rblock; 259 struct hipz_query_hca *rblock;
222 260
223 rblock = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 261 rblock = ehca_alloc_fw_ctrlblock();
224 if (!rblock) { 262 if (!rblock) {
225 ehca_err(&shca->ib_device, "Can't allocate rblock memory."); 263 ehca_err(&shca->ib_device, "Can't allocate rblock memory.");
226 return -ENOMEM; 264 return -ENOMEM;
@@ -235,7 +273,7 @@ static int init_node_guid(struct ehca_shca *shca)
235 memcpy(&shca->ib_device.node_guid, &rblock->node_guid, sizeof(u64)); 273 memcpy(&shca->ib_device.node_guid, &rblock->node_guid, sizeof(u64));
236 274
237init_node_guid1: 275init_node_guid1:
238 kfree(rblock); 276 ehca_free_fw_ctrlblock(rblock);
239 return ret; 277 return ret;
240} 278}
241 279
@@ -431,7 +469,7 @@ static ssize_t ehca_show_##name(struct device *dev, \
431 \ 469 \
432 shca = dev->driver_data; \ 470 shca = dev->driver_data; \
433 \ 471 \
434 rblock = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); \ 472 rblock = ehca_alloc_fw_ctrlblock(); \
435 if (!rblock) { \ 473 if (!rblock) { \
436 dev_err(dev, "Can't allocate rblock memory."); \ 474 dev_err(dev, "Can't allocate rblock memory."); \
437 return 0; \ 475 return 0; \
@@ -439,12 +477,12 @@ static ssize_t ehca_show_##name(struct device *dev, \
439 \ 477 \
440 if (hipz_h_query_hca(shca->ipz_hca_handle, rblock) != H_SUCCESS) { \ 478 if (hipz_h_query_hca(shca->ipz_hca_handle, rblock) != H_SUCCESS) { \
441 dev_err(dev, "Can't query device properties"); \ 479 dev_err(dev, "Can't query device properties"); \
442 kfree(rblock); \ 480 ehca_free_fw_ctrlblock(rblock); \
443 return 0; \ 481 return 0; \
444 } \ 482 } \
445 \ 483 \
446 data = rblock->name; \ 484 data = rblock->name; \
447 kfree(rblock); \ 485 ehca_free_fw_ctrlblock(rblock); \
448 \ 486 \
449 if ((strcmp(#name, "num_ports") == 0) && (ehca_nr_ports == 1)) \ 487 if ((strcmp(#name, "num_ports") == 0) && (ehca_nr_ports == 1)) \
450 return snprintf(buf, 256, "1\n"); \ 488 return snprintf(buf, 256, "1\n"); \
@@ -752,7 +790,7 @@ int __init ehca_module_init(void)
752 int ret; 790 int ret;
753 791
754 printk(KERN_INFO "eHCA Infiniband Device Driver " 792 printk(KERN_INFO "eHCA Infiniband Device Driver "
755 "(Rel.: SVNEHCA_0017)\n"); 793 "(Rel.: SVNEHCA_0018)\n");
756 idr_init(&ehca_qp_idr); 794 idr_init(&ehca_qp_idr);
757 idr_init(&ehca_cq_idr); 795 idr_init(&ehca_cq_idr);
758 spin_lock_init(&ehca_qp_idr_lock); 796 spin_lock_init(&ehca_qp_idr_lock);
diff --git a/drivers/infiniband/hw/ehca/ehca_mrmw.c b/drivers/infiniband/hw/ehca/ehca_mrmw.c
index 5ca65441e1da..abce676c0ae0 100644
--- a/drivers/infiniband/hw/ehca/ehca_mrmw.c
+++ b/drivers/infiniband/hw/ehca/ehca_mrmw.c
@@ -1013,7 +1013,7 @@ int ehca_reg_mr_rpages(struct ehca_shca *shca,
1013 u32 i; 1013 u32 i;
1014 u64 *kpage; 1014 u64 *kpage;
1015 1015
1016 kpage = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 1016 kpage = ehca_alloc_fw_ctrlblock();
1017 if (!kpage) { 1017 if (!kpage) {
1018 ehca_err(&shca->ib_device, "kpage alloc failed"); 1018 ehca_err(&shca->ib_device, "kpage alloc failed");
1019 ret = -ENOMEM; 1019 ret = -ENOMEM;
@@ -1092,7 +1092,7 @@ int ehca_reg_mr_rpages(struct ehca_shca *shca,
1092 1092
1093 1093
1094ehca_reg_mr_rpages_exit1: 1094ehca_reg_mr_rpages_exit1:
1095 kfree(kpage); 1095 ehca_free_fw_ctrlblock(kpage);
1096ehca_reg_mr_rpages_exit0: 1096ehca_reg_mr_rpages_exit0:
1097 if (ret) 1097 if (ret)
1098 ehca_err(&shca->ib_device, "ret=%x shca=%p e_mr=%p pginfo=%p " 1098 ehca_err(&shca->ib_device, "ret=%x shca=%p e_mr=%p pginfo=%p "
@@ -1124,7 +1124,7 @@ inline int ehca_rereg_mr_rereg1(struct ehca_shca *shca,
1124 ehca_mrmw_map_acl(acl, &hipz_acl); 1124 ehca_mrmw_map_acl(acl, &hipz_acl);
1125 ehca_mrmw_set_pgsize_hipz_acl(&hipz_acl); 1125 ehca_mrmw_set_pgsize_hipz_acl(&hipz_acl);
1126 1126
1127 kpage = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 1127 kpage = ehca_alloc_fw_ctrlblock();
1128 if (!kpage) { 1128 if (!kpage) {
1129 ehca_err(&shca->ib_device, "kpage alloc failed"); 1129 ehca_err(&shca->ib_device, "kpage alloc failed");
1130 ret = -ENOMEM; 1130 ret = -ENOMEM;
@@ -1181,7 +1181,7 @@ inline int ehca_rereg_mr_rereg1(struct ehca_shca *shca,
1181 } 1181 }
1182 1182
1183ehca_rereg_mr_rereg1_exit1: 1183ehca_rereg_mr_rereg1_exit1:
1184 kfree(kpage); 1184 ehca_free_fw_ctrlblock(kpage);
1185ehca_rereg_mr_rereg1_exit0: 1185ehca_rereg_mr_rereg1_exit0:
1186 if ( ret && (ret != -EAGAIN) ) 1186 if ( ret && (ret != -EAGAIN) )
1187 ehca_err(&shca->ib_device, "ret=%x lkey=%x rkey=%x " 1187 ehca_err(&shca->ib_device, "ret=%x lkey=%x rkey=%x "
diff --git a/drivers/infiniband/hw/ehca/ehca_qp.c b/drivers/infiniband/hw/ehca/ehca_qp.c
index 4394123cdbd7..cf3e50ee2d06 100644
--- a/drivers/infiniband/hw/ehca/ehca_qp.c
+++ b/drivers/infiniband/hw/ehca/ehca_qp.c
@@ -811,8 +811,8 @@ static int internal_modify_qp(struct ib_qp *ibqp,
811 unsigned long spl_flags = 0; 811 unsigned long spl_flags = 0;
812 812
813 /* do query_qp to obtain current attr values */ 813 /* do query_qp to obtain current attr values */
814 mqpcb = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 814 mqpcb = ehca_alloc_fw_ctrlblock();
815 if (mqpcb == NULL) { 815 if (!mqpcb) {
816 ehca_err(ibqp->device, "Could not get zeroed page for mqpcb " 816 ehca_err(ibqp->device, "Could not get zeroed page for mqpcb "
817 "ehca_qp=%p qp_num=%x ", my_qp, ibqp->qp_num); 817 "ehca_qp=%p qp_num=%x ", my_qp, ibqp->qp_num);
818 return -ENOMEM; 818 return -ENOMEM;
@@ -1225,7 +1225,7 @@ modify_qp_exit2:
1225 } 1225 }
1226 1226
1227modify_qp_exit1: 1227modify_qp_exit1:
1228 kfree(mqpcb); 1228 ehca_free_fw_ctrlblock(mqpcb);
1229 1229
1230 return ret; 1230 return ret;
1231} 1231}
@@ -1277,7 +1277,7 @@ int ehca_query_qp(struct ib_qp *qp,
1277 return -EINVAL; 1277 return -EINVAL;
1278 } 1278 }
1279 1279
1280 qpcb = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL ); 1280 qpcb = ehca_alloc_fw_ctrlblock();
1281 if (!qpcb) { 1281 if (!qpcb) {
1282 ehca_err(qp->device,"Out of memory for qpcb " 1282 ehca_err(qp->device,"Out of memory for qpcb "
1283 "ehca_qp=%p qp_num=%x", my_qp, qp->qp_num); 1283 "ehca_qp=%p qp_num=%x", my_qp, qp->qp_num);
@@ -1401,7 +1401,7 @@ int ehca_query_qp(struct ib_qp *qp,
1401 ehca_dmp(qpcb, 4*70, "qp_num=%x", qp->qp_num); 1401 ehca_dmp(qpcb, 4*70, "qp_num=%x", qp->qp_num);
1402 1402
1403query_qp_exit1: 1403query_qp_exit1:
1404 kfree(qpcb); 1404 ehca_free_fw_ctrlblock(qpcb);
1405 1405
1406 return ret; 1406 return ret;
1407} 1407}
diff --git a/drivers/infiniband/hw/ehca/ehca_tools.h b/drivers/infiniband/hw/ehca/ehca_tools.h
index 809da3ef706b..973c4b591545 100644
--- a/drivers/infiniband/hw/ehca/ehca_tools.h
+++ b/drivers/infiniband/hw/ehca/ehca_tools.h
@@ -63,6 +63,7 @@
63#include <asm/ibmebus.h> 63#include <asm/ibmebus.h>
64#include <asm/io.h> 64#include <asm/io.h>
65#include <asm/pgtable.h> 65#include <asm/pgtable.h>
66#include <asm/hvcall.h>
66 67
67extern int ehca_debug_level; 68extern int ehca_debug_level;
68 69
diff --git a/drivers/infiniband/hw/ehca/hipz_hw.h b/drivers/infiniband/hw/ehca/hipz_hw.h
index 3fc92b031c50..fad91368dc5a 100644
--- a/drivers/infiniband/hw/ehca/hipz_hw.h
+++ b/drivers/infiniband/hw/ehca/hipz_hw.h
@@ -45,6 +45,8 @@
45 45
46#include "ehca_tools.h" 46#include "ehca_tools.h"
47 47
48#define EHCA_MAX_MTU 4
49
48/* QP Table Entry Memory Map */ 50/* QP Table Entry Memory Map */
49struct hipz_qptemm { 51struct hipz_qptemm {
50 u64 qpx_hcr; 52 u64 qpx_hcr;
diff --git a/drivers/infiniband/hw/ipath/Kconfig b/drivers/infiniband/hw/ipath/Kconfig
index 574a678e7fdd..90c14543677d 100644
--- a/drivers/infiniband/hw/ipath/Kconfig
+++ b/drivers/infiniband/hw/ipath/Kconfig
@@ -1,6 +1,6 @@
1config INFINIBAND_IPATH 1config INFINIBAND_IPATH
2 tristate "QLogic InfiniPath Driver" 2 tristate "QLogic InfiniPath Driver"
3 depends on PCI_MSI && 64BIT && INFINIBAND 3 depends on (PCI_MSI || HT_IRQ) && 64BIT && INFINIBAND && NET
4 ---help--- 4 ---help---
5 This is a driver for QLogic InfiniPath host channel adapters, 5 This is a driver for QLogic InfiniPath host channel adapters,
6 including InfiniBand verbs support. This driver allows these 6 including InfiniBand verbs support. This driver allows these
diff --git a/drivers/infiniband/hw/ipath/Makefile b/drivers/infiniband/hw/ipath/Makefile
index 5e29cb0095e5..7dc10551cf18 100644
--- a/drivers/infiniband/hw/ipath/Makefile
+++ b/drivers/infiniband/hw/ipath/Makefile
@@ -10,8 +10,6 @@ ib_ipath-y := \
10 ipath_eeprom.o \ 10 ipath_eeprom.o \
11 ipath_file_ops.o \ 11 ipath_file_ops.o \
12 ipath_fs.o \ 12 ipath_fs.o \
13 ipath_iba6110.o \
14 ipath_iba6120.o \
15 ipath_init_chip.o \ 13 ipath_init_chip.o \
16 ipath_intr.o \ 14 ipath_intr.o \
17 ipath_keys.o \ 15 ipath_keys.o \
@@ -31,5 +29,8 @@ ib_ipath-y := \
31 ipath_verbs_mcast.o \ 29 ipath_verbs_mcast.o \
32 ipath_verbs.o 30 ipath_verbs.o
33 31
32ib_ipath-$(CONFIG_HT_IRQ) += ipath_iba6110.o
33ib_ipath-$(CONFIG_PCI_MSI) += ipath_iba6120.o
34
34ib_ipath-$(CONFIG_X86_64) += ipath_wc_x86_64.o 35ib_ipath-$(CONFIG_X86_64) += ipath_wc_x86_64.o
35ib_ipath-$(CONFIG_PPC64) += ipath_wc_ppc64.o 36ib_ipath-$(CONFIG_PPC64) += ipath_wc_ppc64.o
diff --git a/drivers/infiniband/hw/ipath/ipath_diag.c b/drivers/infiniband/hw/ipath/ipath_diag.c
index 29958b6e0214..28c087b824c2 100644
--- a/drivers/infiniband/hw/ipath/ipath_diag.c
+++ b/drivers/infiniband/hw/ipath/ipath_diag.c
@@ -67,19 +67,54 @@ static struct file_operations diag_file_ops = {
67 .release = ipath_diag_release 67 .release = ipath_diag_release
68}; 68};
69 69
70static ssize_t ipath_diagpkt_write(struct file *fp,
71 const char __user *data,
72 size_t count, loff_t *off);
73
74static struct file_operations diagpkt_file_ops = {
75 .owner = THIS_MODULE,
76 .write = ipath_diagpkt_write,
77};
78
79static atomic_t diagpkt_count = ATOMIC_INIT(0);
80static struct cdev *diagpkt_cdev;
81static struct class_device *diagpkt_class_dev;
82
70int ipath_diag_add(struct ipath_devdata *dd) 83int ipath_diag_add(struct ipath_devdata *dd)
71{ 84{
72 char name[16]; 85 char name[16];
86 int ret = 0;
87
88 if (atomic_inc_return(&diagpkt_count) == 1) {
89 ret = ipath_cdev_init(IPATH_DIAGPKT_MINOR,
90 "ipath_diagpkt", &diagpkt_file_ops,
91 &diagpkt_cdev, &diagpkt_class_dev);
92
93 if (ret) {
94 ipath_dev_err(dd, "Couldn't create ipath_diagpkt "
95 "device: %d", ret);
96 goto done;
97 }
98 }
73 99
74 snprintf(name, sizeof(name), "ipath_diag%d", dd->ipath_unit); 100 snprintf(name, sizeof(name), "ipath_diag%d", dd->ipath_unit);
75 101
76 return ipath_cdev_init(IPATH_DIAG_MINOR_BASE + dd->ipath_unit, name, 102 ret = ipath_cdev_init(IPATH_DIAG_MINOR_BASE + dd->ipath_unit, name,
77 &diag_file_ops, &dd->diag_cdev, 103 &diag_file_ops, &dd->diag_cdev,
78 &dd->diag_class_dev); 104 &dd->diag_class_dev);
105 if (ret)
106 ipath_dev_err(dd, "Couldn't create %s device: %d",
107 name, ret);
108
109done:
110 return ret;
79} 111}
80 112
81void ipath_diag_remove(struct ipath_devdata *dd) 113void ipath_diag_remove(struct ipath_devdata *dd)
82{ 114{
115 if (atomic_dec_and_test(&diagpkt_count))
116 ipath_cdev_cleanup(&diagpkt_cdev, &diagpkt_class_dev);
117
83 ipath_cdev_cleanup(&dd->diag_cdev, &dd->diag_class_dev); 118 ipath_cdev_cleanup(&dd->diag_cdev, &dd->diag_class_dev);
84} 119}
85 120
@@ -275,30 +310,6 @@ bail:
275 return ret; 310 return ret;
276} 311}
277 312
278static ssize_t ipath_diagpkt_write(struct file *fp,
279 const char __user *data,
280 size_t count, loff_t *off);
281
282static struct file_operations diagpkt_file_ops = {
283 .owner = THIS_MODULE,
284 .write = ipath_diagpkt_write,
285};
286
287static struct cdev *diagpkt_cdev;
288static struct class_device *diagpkt_class_dev;
289
290int __init ipath_diagpkt_add(void)
291{
292 return ipath_cdev_init(IPATH_DIAGPKT_MINOR,
293 "ipath_diagpkt", &diagpkt_file_ops,
294 &diagpkt_cdev, &diagpkt_class_dev);
295}
296
297void __exit ipath_diagpkt_remove(void)
298{
299 ipath_cdev_cleanup(&diagpkt_cdev, &diagpkt_class_dev);
300}
301
302/** 313/**
303 * ipath_diagpkt_write - write an IB packet 314 * ipath_diagpkt_write - write an IB packet
304 * @fp: the diag data device file pointer 315 * @fp: the diag data device file pointer
diff --git a/drivers/infiniband/hw/ipath/ipath_driver.c b/drivers/infiniband/hw/ipath/ipath_driver.c
index 12cefa658f3b..1aeddb48e355 100644
--- a/drivers/infiniband/hw/ipath/ipath_driver.c
+++ b/drivers/infiniband/hw/ipath/ipath_driver.c
@@ -304,7 +304,7 @@ static int __devinit ipath_init_one(struct pci_dev *pdev,
304 } 304 }
305 addr = pci_resource_start(pdev, 0); 305 addr = pci_resource_start(pdev, 0);
306 len = pci_resource_len(pdev, 0); 306 len = pci_resource_len(pdev, 0);
307 ipath_cdbg(VERBOSE, "regbase (0) %llx len %d irq %x, vend %x/%x " 307 ipath_cdbg(VERBOSE, "regbase (0) %llx len %d pdev->irq %d, vend %x/%x "
308 "driver_data %lx\n", addr, len, pdev->irq, ent->vendor, 308 "driver_data %lx\n", addr, len, pdev->irq, ent->vendor,
309 ent->device, ent->driver_data); 309 ent->device, ent->driver_data);
310 310
@@ -390,12 +390,16 @@ static int __devinit ipath_init_one(struct pci_dev *pdev,
390 390
391 /* setup the chip-specific functions, as early as possible. */ 391 /* setup the chip-specific functions, as early as possible. */
392 switch (ent->device) { 392 switch (ent->device) {
393#ifdef CONFIG_HT_IRQ
393 case PCI_DEVICE_ID_INFINIPATH_HT: 394 case PCI_DEVICE_ID_INFINIPATH_HT:
394 ipath_init_iba6110_funcs(dd); 395 ipath_init_iba6110_funcs(dd);
395 break; 396 break;
397#endif
398#ifdef CONFIG_PCI_MSI
396 case PCI_DEVICE_ID_INFINIPATH_PE800: 399 case PCI_DEVICE_ID_INFINIPATH_PE800:
397 ipath_init_iba6120_funcs(dd); 400 ipath_init_iba6120_funcs(dd);
398 break; 401 break;
402#endif
399 default: 403 default:
400 ipath_dev_err(dd, "Found unknown QLogic deviceid 0x%x, " 404 ipath_dev_err(dd, "Found unknown QLogic deviceid 0x%x, "
401 "failing\n", ent->device); 405 "failing\n", ent->device);
@@ -467,15 +471,15 @@ static int __devinit ipath_init_one(struct pci_dev *pdev,
467 * check 0 irq after we return from chip-specific bus setup, since 471 * check 0 irq after we return from chip-specific bus setup, since
468 * that can affect this due to setup 472 * that can affect this due to setup
469 */ 473 */
470 if (!pdev->irq) 474 if (!dd->ipath_irq)
471 ipath_dev_err(dd, "irq is 0, BIOS error? Interrupts won't " 475 ipath_dev_err(dd, "irq is 0, BIOS error? Interrupts won't "
472 "work\n"); 476 "work\n");
473 else { 477 else {
474 ret = request_irq(pdev->irq, ipath_intr, IRQF_SHARED, 478 ret = request_irq(dd->ipath_irq, ipath_intr, IRQF_SHARED,
475 IPATH_DRV_NAME, dd); 479 IPATH_DRV_NAME, dd);
476 if (ret) { 480 if (ret) {
477 ipath_dev_err(dd, "Couldn't setup irq handler, " 481 ipath_dev_err(dd, "Couldn't setup irq handler, "
478 "irq=%u: %d\n", pdev->irq, ret); 482 "irq=%d: %d\n", dd->ipath_irq, ret);
479 goto bail_iounmap; 483 goto bail_iounmap;
480 } 484 }
481 } 485 }
@@ -637,11 +641,10 @@ static void __devexit ipath_remove_one(struct pci_dev *pdev)
637 * free up port 0 (kernel) rcvhdr, egr bufs, and eventually tid bufs 641 * free up port 0 (kernel) rcvhdr, egr bufs, and eventually tid bufs
638 * for all versions of the driver, if they were allocated 642 * for all versions of the driver, if they were allocated
639 */ 643 */
640 if (pdev->irq) { 644 if (dd->ipath_irq) {
641 ipath_cdbg(VERBOSE, 645 ipath_cdbg(VERBOSE, "unit %u free irq %d\n",
642 "unit %u free_irq of irq %x\n", 646 dd->ipath_unit, dd->ipath_irq);
643 dd->ipath_unit, pdev->irq); 647 dd->ipath_f_free_irq(dd);
644 free_irq(pdev->irq, dd);
645 } else 648 } else
646 ipath_dbg("irq is 0, not doing free_irq " 649 ipath_dbg("irq is 0, not doing free_irq "
647 "for unit %u\n", dd->ipath_unit); 650 "for unit %u\n", dd->ipath_unit);
@@ -2005,18 +2008,8 @@ static int __init infinipath_init(void)
2005 goto bail_group; 2008 goto bail_group;
2006 } 2009 }
2007 2010
2008 ret = ipath_diagpkt_add();
2009 if (ret < 0) {
2010 printk(KERN_ERR IPATH_DRV_NAME ": Unable to create "
2011 "diag data device: error %d\n", -ret);
2012 goto bail_ipathfs;
2013 }
2014
2015 goto bail; 2011 goto bail;
2016 2012
2017bail_ipathfs:
2018 ipath_exit_ipathfs();
2019
2020bail_group: 2013bail_group:
2021 ipath_driver_remove_group(&ipath_driver.driver); 2014 ipath_driver_remove_group(&ipath_driver.driver);
2022 2015
diff --git a/drivers/infiniband/hw/ipath/ipath_iba6110.c b/drivers/infiniband/hw/ipath/ipath_iba6110.c
index 9e4e8d4c6e20..e57c7a351cb5 100644
--- a/drivers/infiniband/hw/ipath/ipath_iba6110.c
+++ b/drivers/infiniband/hw/ipath/ipath_iba6110.c
@@ -38,6 +38,7 @@
38 38
39#include <linux/pci.h> 39#include <linux/pci.h>
40#include <linux/delay.h> 40#include <linux/delay.h>
41#include <linux/htirq.h>
41 42
42#include "ipath_kernel.h" 43#include "ipath_kernel.h"
43#include "ipath_registers.h" 44#include "ipath_registers.h"
@@ -913,49 +914,40 @@ static void slave_or_pri_blk(struct ipath_devdata *dd, struct pci_dev *pdev,
913 } 914 }
914} 915}
915 916
916static int set_int_handler(struct ipath_devdata *dd, struct pci_dev *pdev, 917static int ipath_ht_intconfig(struct ipath_devdata *dd)
917 int pos)
918{ 918{
919 u32 int_handler_addr_lower; 919 int ret;
920 u32 int_handler_addr_upper;
921 u64 ihandler;
922 u32 intvec;
923 920
924 /* use indirection register to get the intr handler */ 921 if (dd->ipath_intconfig) {
925 pci_write_config_byte(pdev, pos + HT_INTR_REG_INDEX, 0x10); 922 ipath_write_kreg(dd, dd->ipath_kregs->kr_interruptconfig,
926 pci_read_config_dword(pdev, pos + 4, &int_handler_addr_lower); 923 dd->ipath_intconfig); /* interrupt address */
927 pci_write_config_byte(pdev, pos + HT_INTR_REG_INDEX, 0x11); 924 ret = 0;
928 pci_read_config_dword(pdev, pos + 4, &int_handler_addr_upper); 925 } else {
926 ipath_dev_err(dd, "No interrupts enabled, couldn't setup "
927 "interrupt address\n");
928 ret = -EINVAL;
929 }
929 930
930 ihandler = (u64) int_handler_addr_lower | 931 return ret;
931 ((u64) int_handler_addr_upper << 32); 932}
933
934static void ipath_ht_irq_update(struct pci_dev *dev, int irq,
935 struct ht_irq_msg *msg)
936{
937 struct ipath_devdata *dd = pci_get_drvdata(dev);
938 u64 prev_intconfig = dd->ipath_intconfig;
939
940 dd->ipath_intconfig = msg->address_lo;
941 dd->ipath_intconfig |= ((u64) msg->address_hi) << 32;
932 942
933 /* 943 /*
934 * kernels with CONFIG_PCI_MSI set the vector in the irq field of 944 * If the previous value of dd->ipath_intconfig is zero, we're
935 * struct pci_device, so we use that to program the internal 945 * getting configured for the first time, and must not program the
936 * interrupt register (not config space) with that value. The BIOS 946 * intconfig register here (it will be programmed later, when the
937 * must still have done the basic MSI setup. 947 * hardware is ready). Otherwise, we should.
938 */
939 intvec = pdev->irq;
940 /*
941 * clear any vector bits there; normally not set but we'll overload
942 * this for some debug purposes (setting the HTC debug register
943 * value from software, rather than GPIOs), so it might be set on a
944 * driver reload.
945 */ 948 */
946 ihandler &= ~0xff0000; 949 if (prev_intconfig)
947 /* x86 vector goes in intrinfo[23:16] */ 950 ipath_ht_intconfig(dd);
948 ihandler |= intvec << 16;
949 ipath_cdbg(VERBOSE, "ihandler lower %x, upper %x, intvec %x, "
950 "interruptconfig %llx\n", int_handler_addr_lower,
951 int_handler_addr_upper, intvec,
952 (unsigned long long) ihandler);
953
954 /* can't program yet, so save for interrupt setup */
955 dd->ipath_intconfig = ihandler;
956 /* keep going, so we find link control stuff also */
957
958 return ihandler != 0;
959} 951}
960 952
961/** 953/**
@@ -971,12 +963,19 @@ static int set_int_handler(struct ipath_devdata *dd, struct pci_dev *pdev,
971static int ipath_setup_ht_config(struct ipath_devdata *dd, 963static int ipath_setup_ht_config(struct ipath_devdata *dd,
972 struct pci_dev *pdev) 964 struct pci_dev *pdev)
973{ 965{
974 int pos, ret = 0; 966 int pos, ret;
975 int ihandler = 0; 967
968 ret = __ht_create_irq(pdev, 0, ipath_ht_irq_update);
969 if (ret < 0) {
970 ipath_dev_err(dd, "Couldn't create interrupt handler: "
971 "err %d\n", ret);
972 goto bail;
973 }
974 dd->ipath_irq = ret;
975 ret = 0;
976 976
977 /* 977 /*
978 * Read the capability info to find the interrupt info, and also 978 * Handle clearing CRC errors in linkctrl register if necessary. We
979 * handle clearing CRC errors in linkctrl register if necessary. We
980 * do this early, before we ever enable errors or hardware errors, 979 * do this early, before we ever enable errors or hardware errors,
981 * mostly to avoid causing the chip to enter freeze mode. 980 * mostly to avoid causing the chip to enter freeze mode.
982 */ 981 */
@@ -1000,17 +999,9 @@ static int ipath_setup_ht_config(struct ipath_devdata *dd,
1000 } 999 }
1001 if (!(cap_type & 0xE0)) 1000 if (!(cap_type & 0xE0))
1002 slave_or_pri_blk(dd, pdev, pos, cap_type); 1001 slave_or_pri_blk(dd, pdev, pos, cap_type);
1003 else if (cap_type == HT_INTR_DISC_CONFIG)
1004 ihandler = set_int_handler(dd, pdev, pos);
1005 } while ((pos = pci_find_next_capability(pdev, pos, 1002 } while ((pos = pci_find_next_capability(pdev, pos,
1006 PCI_CAP_ID_HT))); 1003 PCI_CAP_ID_HT)));
1007 1004
1008 if (!ihandler) {
1009 ipath_dev_err(dd, "Couldn't find interrupt handler in "
1010 "config space\n");
1011 ret = -ENODEV;
1012 }
1013
1014bail: 1005bail:
1015 return ret; 1006 return ret;
1016} 1007}
@@ -1360,25 +1351,6 @@ static void ipath_ht_quiet_serdes(struct ipath_devdata *dd)
1360 ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0, val); 1351 ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0, val);
1361} 1352}
1362 1353
1363static int ipath_ht_intconfig(struct ipath_devdata *dd)
1364{
1365 int ret;
1366
1367 if (!dd->ipath_intconfig) {
1368 ipath_dev_err(dd, "No interrupts enabled, couldn't setup "
1369 "interrupt address\n");
1370 ret = 1;
1371 goto bail;
1372 }
1373
1374 ipath_write_kreg(dd, dd->ipath_kregs->kr_interruptconfig,
1375 dd->ipath_intconfig); /* interrupt address */
1376 ret = 0;
1377
1378bail:
1379 return ret;
1380}
1381
1382/** 1354/**
1383 * ipath_pe_put_tid - write a TID in chip 1355 * ipath_pe_put_tid - write a TID in chip
1384 * @dd: the infinipath device 1356 * @dd: the infinipath device
@@ -1575,6 +1547,14 @@ static int ipath_ht_get_base_info(struct ipath_portdata *pd, void *kbase)
1575 return 0; 1547 return 0;
1576} 1548}
1577 1549
1550static void ipath_ht_free_irq(struct ipath_devdata *dd)
1551{
1552 free_irq(dd->ipath_irq, dd);
1553 ht_destroy_irq(dd->ipath_irq);
1554 dd->ipath_irq = 0;
1555 dd->ipath_intconfig = 0;
1556}
1557
1578/** 1558/**
1579 * ipath_init_iba6110_funcs - set up the chip-specific function pointers 1559 * ipath_init_iba6110_funcs - set up the chip-specific function pointers
1580 * @dd: the infinipath device 1560 * @dd: the infinipath device
@@ -1598,6 +1578,7 @@ void ipath_init_iba6110_funcs(struct ipath_devdata *dd)
1598 dd->ipath_f_cleanup = ipath_setup_ht_cleanup; 1578 dd->ipath_f_cleanup = ipath_setup_ht_cleanup;
1599 dd->ipath_f_setextled = ipath_setup_ht_setextled; 1579 dd->ipath_f_setextled = ipath_setup_ht_setextled;
1600 dd->ipath_f_get_base_info = ipath_ht_get_base_info; 1580 dd->ipath_f_get_base_info = ipath_ht_get_base_info;
1581 dd->ipath_f_free_irq = ipath_ht_free_irq;
1601 1582
1602 /* 1583 /*
1603 * initialize chip-specific variables 1584 * initialize chip-specific variables
diff --git a/drivers/infiniband/hw/ipath/ipath_iba6120.c b/drivers/infiniband/hw/ipath/ipath_iba6120.c
index a72ab9de386a..6af89683f710 100644
--- a/drivers/infiniband/hw/ipath/ipath_iba6120.c
+++ b/drivers/infiniband/hw/ipath/ipath_iba6120.c
@@ -851,6 +851,7 @@ static int ipath_setup_pe_config(struct ipath_devdata *dd,
851 int pos, ret; 851 int pos, ret;
852 852
853 dd->ipath_msi_lo = 0; /* used as a flag during reset processing */ 853 dd->ipath_msi_lo = 0; /* used as a flag during reset processing */
854 dd->ipath_irq = pdev->irq;
854 ret = pci_enable_msi(dd->pcidev); 855 ret = pci_enable_msi(dd->pcidev);
855 if (ret) 856 if (ret)
856 ipath_dev_err(dd, "pci_enable_msi failed: %d, " 857 ipath_dev_err(dd, "pci_enable_msi failed: %d, "
@@ -1323,6 +1324,12 @@ done:
1323 return 0; 1324 return 0;
1324} 1325}
1325 1326
1327static void ipath_pe_free_irq(struct ipath_devdata *dd)
1328{
1329 free_irq(dd->ipath_irq, dd);
1330 dd->ipath_irq = 0;
1331}
1332
1326/** 1333/**
1327 * ipath_init_iba6120_funcs - set up the chip-specific function pointers 1334 * ipath_init_iba6120_funcs - set up the chip-specific function pointers
1328 * @dd: the infinipath device 1335 * @dd: the infinipath device
@@ -1349,6 +1356,7 @@ void ipath_init_iba6120_funcs(struct ipath_devdata *dd)
1349 dd->ipath_f_cleanup = ipath_setup_pe_cleanup; 1356 dd->ipath_f_cleanup = ipath_setup_pe_cleanup;
1350 dd->ipath_f_setextled = ipath_setup_pe_setextled; 1357 dd->ipath_f_setextled = ipath_setup_pe_setextled;
1351 dd->ipath_f_get_base_info = ipath_pe_get_base_info; 1358 dd->ipath_f_get_base_info = ipath_pe_get_base_info;
1359 dd->ipath_f_free_irq = ipath_pe_free_irq;
1352 1360
1353 /* initialize chip-specific variables */ 1361 /* initialize chip-specific variables */
1354 dd->ipath_f_tidtemplate = ipath_pe_tidtemplate; 1362 dd->ipath_f_tidtemplate = ipath_pe_tidtemplate;
diff --git a/drivers/infiniband/hw/ipath/ipath_intr.c b/drivers/infiniband/hw/ipath/ipath_intr.c
index d9079ee12030..5652a550d442 100644
--- a/drivers/infiniband/hw/ipath/ipath_intr.c
+++ b/drivers/infiniband/hw/ipath/ipath_intr.c
@@ -710,14 +710,14 @@ static void ipath_bad_intr(struct ipath_devdata *dd, u32 * unexpectp)
710 * linuxbios development work, and it may happen in 710 * linuxbios development work, and it may happen in
711 * the future again. 711 * the future again.
712 */ 712 */
713 if (dd->pcidev && dd->pcidev->irq) { 713 if (dd->pcidev && dd->ipath_irq) {
714 ipath_dev_err(dd, "Now %u unexpected " 714 ipath_dev_err(dd, "Now %u unexpected "
715 "interrupts, unregistering " 715 "interrupts, unregistering "
716 "interrupt handler\n", 716 "interrupt handler\n",
717 *unexpectp); 717 *unexpectp);
718 ipath_dbg("free_irq of irq %x\n", 718 ipath_dbg("free_irq of irq %d\n",
719 dd->pcidev->irq); 719 dd->ipath_irq);
720 free_irq(dd->pcidev->irq, dd); 720 dd->ipath_f_free_irq(dd);
721 } 721 }
722 } 722 }
723 if (ipath_read_kreg32(dd, dd->ipath_kregs->kr_intmask)) { 723 if (ipath_read_kreg32(dd, dd->ipath_kregs->kr_intmask)) {
@@ -753,7 +753,7 @@ static void ipath_bad_regread(struct ipath_devdata *dd)
753 if (allbits == 2) { 753 if (allbits == 2) {
754 ipath_dev_err(dd, "Still bad interrupt status, " 754 ipath_dev_err(dd, "Still bad interrupt status, "
755 "unregistering interrupt\n"); 755 "unregistering interrupt\n");
756 free_irq(dd->pcidev->irq, dd); 756 dd->ipath_f_free_irq(dd);
757 } else if (allbits > 2) { 757 } else if (allbits > 2) {
758 if ((allbits % 10000) == 0) 758 if ((allbits % 10000) == 0)
759 printk("."); 759 printk(".");
diff --git a/drivers/infiniband/hw/ipath/ipath_kernel.h b/drivers/infiniband/hw/ipath/ipath_kernel.h
index 7c436697d0e4..986b2125b8f5 100644
--- a/drivers/infiniband/hw/ipath/ipath_kernel.h
+++ b/drivers/infiniband/hw/ipath/ipath_kernel.h
@@ -213,6 +213,8 @@ struct ipath_devdata {
213 void (*ipath_f_setextled)(struct ipath_devdata *, u64, u64); 213 void (*ipath_f_setextled)(struct ipath_devdata *, u64, u64);
214 /* fill out chip-specific fields */ 214 /* fill out chip-specific fields */
215 int (*ipath_f_get_base_info)(struct ipath_portdata *, void *); 215 int (*ipath_f_get_base_info)(struct ipath_portdata *, void *);
216 /* free irq */
217 void (*ipath_f_free_irq)(struct ipath_devdata *);
216 struct ipath_ibdev *verbs_dev; 218 struct ipath_ibdev *verbs_dev;
217 struct timer_list verbs_timer; 219 struct timer_list verbs_timer;
218 /* total dwords sent (summed from counter) */ 220 /* total dwords sent (summed from counter) */
@@ -328,6 +330,8 @@ struct ipath_devdata {
328 /* so we can rewrite it after a chip reset */ 330 /* so we can rewrite it after a chip reset */
329 u32 ipath_pcibar1; 331 u32 ipath_pcibar1;
330 332
333 /* interrupt number */
334 int ipath_irq;
331 /* HT/PCI Vendor ID (here for NodeInfo) */ 335 /* HT/PCI Vendor ID (here for NodeInfo) */
332 u16 ipath_vendorid; 336 u16 ipath_vendorid;
333 /* HT/PCI Device ID (here for NodeInfo) */ 337 /* HT/PCI Device ID (here for NodeInfo) */
@@ -869,9 +873,6 @@ int ipath_device_create_group(struct device *, struct ipath_devdata *);
869void ipath_device_remove_group(struct device *, struct ipath_devdata *); 873void ipath_device_remove_group(struct device *, struct ipath_devdata *);
870int ipath_expose_reset(struct device *); 874int ipath_expose_reset(struct device *);
871 875
872int ipath_diagpkt_add(void);
873void ipath_diagpkt_remove(void);
874
875int ipath_init_ipathfs(void); 876int ipath_init_ipathfs(void);
876void ipath_exit_ipathfs(void); 877void ipath_exit_ipathfs(void);
877int ipathfs_add_device(struct ipath_devdata *); 878int ipathfs_add_device(struct ipath_devdata *);
diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
index 99a94d710935..768df7265b81 100644
--- a/drivers/infiniband/hw/mthca/mthca_cmd.c
+++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
@@ -1820,11 +1820,11 @@ int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
1820 1820
1821#define MAD_IFC_BOX_SIZE 0x400 1821#define MAD_IFC_BOX_SIZE 0x400
1822#define MAD_IFC_MY_QPN_OFFSET 0x100 1822#define MAD_IFC_MY_QPN_OFFSET 0x100
1823#define MAD_IFC_RQPN_OFFSET 0x104 1823#define MAD_IFC_RQPN_OFFSET 0x108
1824#define MAD_IFC_SL_OFFSET 0x108 1824#define MAD_IFC_SL_OFFSET 0x10c
1825#define MAD_IFC_G_PATH_OFFSET 0x109 1825#define MAD_IFC_G_PATH_OFFSET 0x10d
1826#define MAD_IFC_RLID_OFFSET 0x10a 1826#define MAD_IFC_RLID_OFFSET 0x10e
1827#define MAD_IFC_PKEY_OFFSET 0x10e 1827#define MAD_IFC_PKEY_OFFSET 0x112
1828#define MAD_IFC_GRH_OFFSET 0x140 1828#define MAD_IFC_GRH_OFFSET 0x140
1829 1829
1830 inmailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); 1830 inmailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
@@ -1862,7 +1862,7 @@ int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
1862 1862
1863 val = in_wc->dlid_path_bits | 1863 val = in_wc->dlid_path_bits |
1864 (in_wc->wc_flags & IB_WC_GRH ? 0x80 : 0); 1864 (in_wc->wc_flags & IB_WC_GRH ? 0x80 : 0);
1865 MTHCA_PUT(inbox, val, MAD_IFC_GRH_OFFSET); 1865 MTHCA_PUT(inbox, val, MAD_IFC_G_PATH_OFFSET);
1866 1866
1867 MTHCA_PUT(inbox, in_wc->slid, MAD_IFC_RLID_OFFSET); 1867 MTHCA_PUT(inbox, in_wc->slid, MAD_IFC_RLID_OFFSET);
1868 MTHCA_PUT(inbox, in_wc->pkey_index, MAD_IFC_PKEY_OFFSET); 1868 MTHCA_PUT(inbox, in_wc->pkey_index, MAD_IFC_PKEY_OFFSET);
@@ -1870,7 +1870,7 @@ int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
1870 if (in_grh) 1870 if (in_grh)
1871 memcpy(inbox + MAD_IFC_GRH_OFFSET, in_grh, 40); 1871 memcpy(inbox + MAD_IFC_GRH_OFFSET, in_grh, 40);
1872 1872
1873 op_modifier |= 0x10; 1873 op_modifier |= 0x4;
1874 1874
1875 in_modifier |= in_wc->slid << 16; 1875 in_modifier |= in_wc->slid << 16;
1876 } 1876 }
diff --git a/drivers/infiniband/hw/mthca/mthca_cq.c b/drivers/infiniband/hw/mthca/mthca_cq.c
index e393681ba7d4..149b36901239 100644
--- a/drivers/infiniband/hw/mthca/mthca_cq.c
+++ b/drivers/infiniband/hw/mthca/mthca_cq.c
@@ -39,6 +39,8 @@
39#include <linux/init.h> 39#include <linux/init.h>
40#include <linux/hardirq.h> 40#include <linux/hardirq.h>
41 41
42#include <asm/io.h>
43
42#include <rdma/ib_pack.h> 44#include <rdma/ib_pack.h>
43 45
44#include "mthca_dev.h" 46#include "mthca_dev.h"
@@ -210,6 +212,11 @@ static inline void update_cons_index(struct mthca_dev *dev, struct mthca_cq *cq,
210 mthca_write64(doorbell, 212 mthca_write64(doorbell,
211 dev->kar + MTHCA_CQ_DOORBELL, 213 dev->kar + MTHCA_CQ_DOORBELL,
212 MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock)); 214 MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
215 /*
216 * Make sure doorbells don't leak out of CQ spinlock
217 * and reach the HCA out of order:
218 */
219 mmiowb();
213 } 220 }
214} 221}
215 222
diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c
index 5e5c58b9920b..6a7822e0fc19 100644
--- a/drivers/infiniband/hw/mthca/mthca_qp.c
+++ b/drivers/infiniband/hw/mthca/mthca_qp.c
@@ -39,6 +39,8 @@
39#include <linux/string.h> 39#include <linux/string.h>
40#include <linux/slab.h> 40#include <linux/slab.h>
41 41
42#include <asm/io.h>
43
42#include <rdma/ib_verbs.h> 44#include <rdma/ib_verbs.h>
43#include <rdma/ib_cache.h> 45#include <rdma/ib_cache.h>
44#include <rdma/ib_pack.h> 46#include <rdma/ib_pack.h>
@@ -1732,6 +1734,11 @@ out:
1732 mthca_write64(doorbell, 1734 mthca_write64(doorbell,
1733 dev->kar + MTHCA_SEND_DOORBELL, 1735 dev->kar + MTHCA_SEND_DOORBELL,
1734 MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock)); 1736 MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
1737 /*
1738 * Make sure doorbells don't leak out of SQ spinlock
1739 * and reach the HCA out of order:
1740 */
1741 mmiowb();
1735 } 1742 }
1736 1743
1737 qp->sq.next_ind = ind; 1744 qp->sq.next_ind = ind;
@@ -1851,6 +1858,12 @@ out:
1851 qp->rq.next_ind = ind; 1858 qp->rq.next_ind = ind;
1852 qp->rq.head += nreq; 1859 qp->rq.head += nreq;
1853 1860
1861 /*
1862 * Make sure doorbells don't leak out of RQ spinlock and reach
1863 * the HCA out of order:
1864 */
1865 mmiowb();
1866
1854 spin_unlock_irqrestore(&qp->rq.lock, flags); 1867 spin_unlock_irqrestore(&qp->rq.lock, flags);
1855 return err; 1868 return err;
1856} 1869}
@@ -2112,6 +2125,12 @@ out:
2112 MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock)); 2125 MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
2113 } 2126 }
2114 2127
2128 /*
2129 * Make sure doorbells don't leak out of SQ spinlock and reach
2130 * the HCA out of order:
2131 */
2132 mmiowb();
2133
2115 spin_unlock_irqrestore(&qp->sq.lock, flags); 2134 spin_unlock_irqrestore(&qp->sq.lock, flags);
2116 return err; 2135 return err;
2117} 2136}
diff --git a/drivers/infiniband/hw/mthca/mthca_srq.c b/drivers/infiniband/hw/mthca/mthca_srq.c
index 92a72f521528..f5d7677d1079 100644
--- a/drivers/infiniband/hw/mthca/mthca_srq.c
+++ b/drivers/infiniband/hw/mthca/mthca_srq.c
@@ -35,6 +35,8 @@
35#include <linux/slab.h> 35#include <linux/slab.h>
36#include <linux/string.h> 36#include <linux/string.h>
37 37
38#include <asm/io.h>
39
38#include "mthca_dev.h" 40#include "mthca_dev.h"
39#include "mthca_cmd.h" 41#include "mthca_cmd.h"
40#include "mthca_memfree.h" 42#include "mthca_memfree.h"
@@ -595,6 +597,12 @@ int mthca_tavor_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
595 MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock)); 597 MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
596 } 598 }
597 599
600 /*
601 * Make sure doorbells don't leak out of SRQ spinlock and
602 * reach the HCA out of order:
603 */
604 mmiowb();
605
598 spin_unlock_irqrestore(&srq->lock, flags); 606 spin_unlock_irqrestore(&srq->lock, flags);
599 return err; 607 return err;
600} 608}
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 1eaf00e9862c..85522daeb946 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -49,6 +49,8 @@
49 49
50#include <net/dst.h> 50#include <net/dst.h>
51 51
52#define IPOIB_QPN(ha) (be32_to_cpup((__be32 *) ha) & 0xffffff)
53
52MODULE_AUTHOR("Roland Dreier"); 54MODULE_AUTHOR("Roland Dreier");
53MODULE_DESCRIPTION("IP-over-InfiniBand net driver"); 55MODULE_DESCRIPTION("IP-over-InfiniBand net driver");
54MODULE_LICENSE("Dual BSD/GPL"); 56MODULE_LICENSE("Dual BSD/GPL");
@@ -520,8 +522,7 @@ static void neigh_add_path(struct sk_buff *skb, struct net_device *dev)
520 memcpy(&neigh->dgid.raw, &path->pathrec.dgid.raw, 522 memcpy(&neigh->dgid.raw, &path->pathrec.dgid.raw,
521 sizeof(union ib_gid)); 523 sizeof(union ib_gid));
522 524
523 ipoib_send(dev, skb, path->ah, 525 ipoib_send(dev, skb, path->ah, IPOIB_QPN(skb->dst->neighbour->ha));
524 be32_to_cpup((__be32 *) skb->dst->neighbour->ha));
525 } else { 526 } else {
526 neigh->ah = NULL; 527 neigh->ah = NULL;
527 __skb_queue_tail(&neigh->queue, skb); 528 __skb_queue_tail(&neigh->queue, skb);
@@ -599,8 +600,7 @@ static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev,
599 ipoib_dbg(priv, "Send unicast ARP to %04x\n", 600 ipoib_dbg(priv, "Send unicast ARP to %04x\n",
600 be16_to_cpu(path->pathrec.dlid)); 601 be16_to_cpu(path->pathrec.dlid));
601 602
602 ipoib_send(dev, skb, path->ah, 603 ipoib_send(dev, skb, path->ah, IPOIB_QPN(phdr->hwaddr));
603 be32_to_cpup((__be32 *) phdr->hwaddr));
604 } else if ((path->query || !path_rec_start(dev, path)) && 604 } else if ((path->query || !path_rec_start(dev, path)) &&
605 skb_queue_len(&path->queue) < IPOIB_MAX_PATH_REC_QUEUE) { 605 skb_queue_len(&path->queue) < IPOIB_MAX_PATH_REC_QUEUE) {
606 /* put pseudoheader back on for next time */ 606 /* put pseudoheader back on for next time */
@@ -661,8 +661,7 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
661 goto out; 661 goto out;
662 } 662 }
663 663
664 ipoib_send(dev, skb, neigh->ah, 664 ipoib_send(dev, skb, neigh->ah, IPOIB_QPN(skb->dst->neighbour->ha));
665 be32_to_cpup((__be32 *) skb->dst->neighbour->ha));
666 goto out; 665 goto out;
667 } 666 }
668 667
@@ -694,7 +693,7 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
694 IPOIB_GID_FMT "\n", 693 IPOIB_GID_FMT "\n",
695 skb->dst ? "neigh" : "dst", 694 skb->dst ? "neigh" : "dst",
696 be16_to_cpup((__be16 *) skb->data), 695 be16_to_cpup((__be16 *) skb->data),
697 be32_to_cpup((__be32 *) phdr->hwaddr), 696 IPOIB_QPN(phdr->hwaddr),
698 IPOIB_GID_RAW_ARG(phdr->hwaddr + 4)); 697 IPOIB_GID_RAW_ARG(phdr->hwaddr + 4));
699 dev_kfree_skb_any(skb); 698 dev_kfree_skb_any(skb);
700 ++priv->stats.tx_dropped; 699 ++priv->stats.tx_dropped;
@@ -777,7 +776,7 @@ static void ipoib_neigh_destructor(struct neighbour *n)
777 776
778 ipoib_dbg(priv, 777 ipoib_dbg(priv,
779 "neigh_destructor for %06x " IPOIB_GID_FMT "\n", 778 "neigh_destructor for %06x " IPOIB_GID_FMT "\n",
780 be32_to_cpup((__be32 *) n->ha), 779 IPOIB_QPN(n->ha),
781 IPOIB_GID_RAW_ARG(n->ha + 4)); 780 IPOIB_GID_RAW_ARG(n->ha + 4));
782 781
783 spin_lock_irqsave(&priv->lock, flags); 782 spin_lock_irqsave(&priv->lock, flags);
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c
index eb6f98d82289..9b2041e25d59 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.c
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.c
@@ -363,11 +363,11 @@ iscsi_iser_conn_start(struct iscsi_cls_conn *cls_conn)
363 struct iscsi_conn *conn = cls_conn->dd_data; 363 struct iscsi_conn *conn = cls_conn->dd_data;
364 int err; 364 int err;
365 365
366 err = iscsi_conn_start(cls_conn); 366 err = iser_conn_set_full_featured_mode(conn);
367 if (err) 367 if (err)
368 return err; 368 return err;
369 369
370 return iser_conn_set_full_featured_mode(conn); 370 return iscsi_conn_start(cls_conn);
371} 371}
372 372
373static struct iscsi_transport iscsi_iser_transport; 373static struct iscsi_transport iscsi_iser_transport;
diff --git a/drivers/input/gameport/fm801-gp.c b/drivers/input/gameport/fm801-gp.c
index 90de5afe03c2..1dec00e20dbc 100644
--- a/drivers/input/gameport/fm801-gp.c
+++ b/drivers/input/gameport/fm801-gp.c
@@ -82,17 +82,19 @@ static int __devinit fm801_gp_probe(struct pci_dev *pci, const struct pci_device
82{ 82{
83 struct fm801_gp *gp; 83 struct fm801_gp *gp;
84 struct gameport *port; 84 struct gameport *port;
85 int error;
85 86
86 gp = kzalloc(sizeof(struct fm801_gp), GFP_KERNEL); 87 gp = kzalloc(sizeof(struct fm801_gp), GFP_KERNEL);
87 port = gameport_allocate_port(); 88 port = gameport_allocate_port();
88 if (!gp || !port) { 89 if (!gp || !port) {
89 printk(KERN_ERR "fm801-gp: Memory allocation failed\n"); 90 printk(KERN_ERR "fm801-gp: Memory allocation failed\n");
90 kfree(gp); 91 error = -ENOMEM;
91 gameport_free_port(port); 92 goto err_out_free;
92 return -ENOMEM;
93 } 93 }
94 94
95 pci_enable_device(pci); 95 error = pci_enable_device(pci);
96 if (error)
97 goto err_out_free;
96 98
97 port->open = fm801_gp_open; 99 port->open = fm801_gp_open;
98#ifdef HAVE_COOKED 100#ifdef HAVE_COOKED
@@ -108,9 +110,8 @@ static int __devinit fm801_gp_probe(struct pci_dev *pci, const struct pci_device
108 if (!gp->res_port) { 110 if (!gp->res_port) {
109 printk(KERN_DEBUG "fm801-gp: unable to grab region 0x%x-0x%x\n", 111 printk(KERN_DEBUG "fm801-gp: unable to grab region 0x%x-0x%x\n",
110 port->io, port->io + 0x0f); 112 port->io, port->io + 0x0f);
111 gameport_free_port(port); 113 error = -EBUSY;
112 kfree(gp); 114 goto err_out_disable_dev;
113 return -EBUSY;
114 } 115 }
115 116
116 pci_set_drvdata(pci, gp); 117 pci_set_drvdata(pci, gp);
@@ -119,6 +120,13 @@ static int __devinit fm801_gp_probe(struct pci_dev *pci, const struct pci_device
119 gameport_register_port(port); 120 gameport_register_port(port);
120 121
121 return 0; 122 return 0;
123
124 err_out_disable_dev:
125 pci_disable_device(pci);
126 err_out_free:
127 gameport_free_port(port);
128 kfree(gp);
129 return error;
122} 130}
123 131
124static void __devexit fm801_gp_remove(struct pci_dev *pci) 132static void __devexit fm801_gp_remove(struct pci_dev *pci)
diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
index 3f47ae55c6f3..a0af97efe6ac 100644
--- a/drivers/input/gameport/gameport.c
+++ b/drivers/input/gameport/gameport.c
@@ -191,6 +191,8 @@ static void gameport_run_poll_handler(unsigned long d)
191 191
192static void gameport_bind_driver(struct gameport *gameport, struct gameport_driver *drv) 192static void gameport_bind_driver(struct gameport *gameport, struct gameport_driver *drv)
193{ 193{
194 int error;
195
194 down_write(&gameport_bus.subsys.rwsem); 196 down_write(&gameport_bus.subsys.rwsem);
195 197
196 gameport->dev.driver = &drv->driver; 198 gameport->dev.driver = &drv->driver;
@@ -198,8 +200,20 @@ static void gameport_bind_driver(struct gameport *gameport, struct gameport_driv
198 gameport->dev.driver = NULL; 200 gameport->dev.driver = NULL;
199 goto out; 201 goto out;
200 } 202 }
201 device_bind_driver(&gameport->dev); 203
202out: 204 error = device_bind_driver(&gameport->dev);
205 if (error) {
206 printk(KERN_WARNING
207 "gameport: device_bind_driver() failed "
208 "for %s (%s) and %s, error: %d\n",
209 gameport->phys, gameport->name,
210 drv->description, error);
211 drv->disconnect(gameport);
212 gameport->dev.driver = NULL;
213 goto out;
214 }
215
216 out:
203 up_write(&gameport_bus.subsys.rwsem); 217 up_write(&gameport_bus.subsys.rwsem);
204} 218}
205 219
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index b6ef9eaad1dc..cbb93669d1ce 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -221,6 +221,7 @@ struct atkbd {
221 unsigned long xl_bit; 221 unsigned long xl_bit;
222 unsigned int last; 222 unsigned int last;
223 unsigned long time; 223 unsigned long time;
224 unsigned long err_count;
224 225
225 struct work_struct event_work; 226 struct work_struct event_work;
226 struct mutex event_mutex; 227 struct mutex event_mutex;
@@ -234,11 +235,13 @@ static ssize_t atkbd_attr_set_helper(struct device *dev, const char *buf, size_t
234#define ATKBD_DEFINE_ATTR(_name) \ 235#define ATKBD_DEFINE_ATTR(_name) \
235static ssize_t atkbd_show_##_name(struct atkbd *, char *); \ 236static ssize_t atkbd_show_##_name(struct atkbd *, char *); \
236static ssize_t atkbd_set_##_name(struct atkbd *, const char *, size_t); \ 237static ssize_t atkbd_set_##_name(struct atkbd *, const char *, size_t); \
237static ssize_t atkbd_do_show_##_name(struct device *d, struct device_attribute *attr, char *b) \ 238static ssize_t atkbd_do_show_##_name(struct device *d, \
239 struct device_attribute *attr, char *b) \
238{ \ 240{ \
239 return atkbd_attr_show_helper(d, b, atkbd_show_##_name); \ 241 return atkbd_attr_show_helper(d, b, atkbd_show_##_name); \
240} \ 242} \
241static ssize_t atkbd_do_set_##_name(struct device *d, struct device_attribute *attr, const char *b, size_t s) \ 243static ssize_t atkbd_do_set_##_name(struct device *d, \
244 struct device_attribute *attr, const char *b, size_t s) \
242{ \ 245{ \
243 return atkbd_attr_set_helper(d, b, s, atkbd_set_##_name); \ 246 return atkbd_attr_set_helper(d, b, s, atkbd_set_##_name); \
244} \ 247} \
@@ -251,6 +254,32 @@ ATKBD_DEFINE_ATTR(set);
251ATKBD_DEFINE_ATTR(softrepeat); 254ATKBD_DEFINE_ATTR(softrepeat);
252ATKBD_DEFINE_ATTR(softraw); 255ATKBD_DEFINE_ATTR(softraw);
253 256
257#define ATKBD_DEFINE_RO_ATTR(_name) \
258static ssize_t atkbd_show_##_name(struct atkbd *, char *); \
259static ssize_t atkbd_do_show_##_name(struct device *d, \
260 struct device_attribute *attr, char *b) \
261{ \
262 return atkbd_attr_show_helper(d, b, atkbd_show_##_name); \
263} \
264static struct device_attribute atkbd_attr_##_name = \
265 __ATTR(_name, S_IRUGO, atkbd_do_show_##_name, NULL);
266
267ATKBD_DEFINE_RO_ATTR(err_count);
268
269static struct attribute *atkbd_attributes[] = {
270 &atkbd_attr_extra.attr,
271 &atkbd_attr_scroll.attr,
272 &atkbd_attr_set.attr,
273 &atkbd_attr_softrepeat.attr,
274 &atkbd_attr_softraw.attr,
275 &atkbd_attr_err_count.attr,
276 NULL
277};
278
279static struct attribute_group atkbd_attribute_group = {
280 .attrs = atkbd_attributes,
281};
282
254static const unsigned int xl_table[] = { 283static const unsigned int xl_table[] = {
255 ATKBD_RET_BAT, ATKBD_RET_ERR, ATKBD_RET_ACK, 284 ATKBD_RET_BAT, ATKBD_RET_ERR, ATKBD_RET_ACK,
256 ATKBD_RET_NAK, ATKBD_RET_HANJA, ATKBD_RET_HANGEUL, 285 ATKBD_RET_NAK, ATKBD_RET_HANJA, ATKBD_RET_HANGEUL,
@@ -396,7 +425,10 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
396 add_release_event = 1; 425 add_release_event = 1;
397 break; 426 break;
398 case ATKBD_RET_ERR: 427 case ATKBD_RET_ERR:
428 atkbd->err_count++;
429#ifdef ATKBD_DEBUG
399 printk(KERN_DEBUG "atkbd.c: Keyboard on %s reports too many keys pressed.\n", serio->phys); 430 printk(KERN_DEBUG "atkbd.c: Keyboard on %s reports too many keys pressed.\n", serio->phys);
431#endif
400 goto out; 432 goto out;
401 } 433 }
402 434
@@ -786,12 +818,7 @@ static void atkbd_disconnect(struct serio *serio)
786 synchronize_sched(); /* Allow atkbd_interrupt()s to complete. */ 818 synchronize_sched(); /* Allow atkbd_interrupt()s to complete. */
787 flush_scheduled_work(); 819 flush_scheduled_work();
788 820
789 device_remove_file(&serio->dev, &atkbd_attr_extra); 821 sysfs_remove_group(&serio->dev.kobj, &atkbd_attribute_group);
790 device_remove_file(&serio->dev, &atkbd_attr_scroll);
791 device_remove_file(&serio->dev, &atkbd_attr_set);
792 device_remove_file(&serio->dev, &atkbd_attr_softrepeat);
793 device_remove_file(&serio->dev, &atkbd_attr_softraw);
794
795 input_unregister_device(atkbd->dev); 822 input_unregister_device(atkbd->dev);
796 serio_close(serio); 823 serio_close(serio);
797 serio_set_drvdata(serio, NULL); 824 serio_set_drvdata(serio, NULL);
@@ -961,11 +988,7 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv)
961 atkbd_set_keycode_table(atkbd); 988 atkbd_set_keycode_table(atkbd);
962 atkbd_set_device_attrs(atkbd); 989 atkbd_set_device_attrs(atkbd);
963 990
964 device_create_file(&serio->dev, &atkbd_attr_extra); 991 sysfs_create_group(&serio->dev.kobj, &atkbd_attribute_group);
965 device_create_file(&serio->dev, &atkbd_attr_scroll);
966 device_create_file(&serio->dev, &atkbd_attr_set);
967 device_create_file(&serio->dev, &atkbd_attr_softrepeat);
968 device_create_file(&serio->dev, &atkbd_attr_softraw);
969 992
970 atkbd_enable(atkbd); 993 atkbd_enable(atkbd);
971 994
@@ -1259,6 +1282,11 @@ static ssize_t atkbd_set_softraw(struct atkbd *atkbd, const char *buf, size_t co
1259 return count; 1282 return count;
1260} 1283}
1261 1284
1285static ssize_t atkbd_show_err_count(struct atkbd *atkbd, char *buf)
1286{
1287 return sprintf(buf, "%lu\n", atkbd->err_count);
1288}
1289
1262 1290
1263static int __init atkbd_init(void) 1291static int __init atkbd_init(void)
1264{ 1292{
diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c
index cb70970625b5..befdd6006b50 100644
--- a/drivers/input/keyboard/corgikbd.c
+++ b/drivers/input/keyboard/corgikbd.c
@@ -207,7 +207,7 @@ static irqreturn_t corgikbd_interrupt(int irq, void *dev_id)
207static void corgikbd_timer_callback(unsigned long data) 207static void corgikbd_timer_callback(unsigned long data)
208{ 208{
209 struct corgikbd *corgikbd_data = (struct corgikbd *) data; 209 struct corgikbd *corgikbd_data = (struct corgikbd *) data;
210 corgikbd_scankeyboard(corgikbd_data, NULL); 210 corgikbd_scankeyboard(corgikbd_data);
211} 211}
212 212
213/* 213/*
diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c
index 708d5a1bc3d2..979b93e33da7 100644
--- a/drivers/input/keyboard/lkkbd.c
+++ b/drivers/input/keyboard/lkkbd.c
@@ -59,11 +59,6 @@
59 * You should have received a copy of the GNU General Public License 59 * You should have received a copy of the GNU General Public License
60 * along with this program; if not, write to the Free Software 60 * along with this program; if not, write to the Free Software
61 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 61 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
62 *
63 * Should you need to contact me, the author, you can do so either by
64 * email or by paper mail:
65 * Jan-Benedict Glaw, Lilienstraße 16, 33790 Hörste (near Halle/Westf.),
66 * Germany.
67 */ 62 */
68 63
69#include <linux/delay.h> 64#include <linux/delay.h>
diff --git a/drivers/input/keyboard/locomokbd.c b/drivers/input/keyboard/locomokbd.c
index fd33c9cc3272..5788dbc317bb 100644
--- a/drivers/input/keyboard/locomokbd.c
+++ b/drivers/input/keyboard/locomokbd.c
@@ -186,7 +186,7 @@ static irqreturn_t locomokbd_interrupt(int irq, void *dev_id)
186static void locomokbd_timer_callback(unsigned long data) 186static void locomokbd_timer_callback(unsigned long data)
187{ 187{
188 struct locomokbd *locomokbd = (struct locomokbd *) data; 188 struct locomokbd *locomokbd = (struct locomokbd *) data;
189 locomokbd_scankeyboard(locomokbd, NULL); 189 locomokbd_scankeyboard(locomokbd);
190} 190}
191 191
192static int locomokbd_probe(struct locomo_dev *dev) 192static int locomokbd_probe(struct locomo_dev *dev)
diff --git a/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c
index 8b18c009e3e0..28b2748e82d0 100644
--- a/drivers/input/keyboard/spitzkbd.c
+++ b/drivers/input/keyboard/spitzkbd.c
@@ -257,7 +257,7 @@ static void spitzkbd_timer_callback(unsigned long data)
257{ 257{
258 struct spitzkbd *spitzkbd_data = (struct spitzkbd *) data; 258 struct spitzkbd *spitzkbd_data = (struct spitzkbd *) data;
259 259
260 spitzkbd_scankeyboard(spitzkbd_data, NULL); 260 spitzkbd_scankeyboard(spitzkbd_data);
261} 261}
262 262
263/* 263/*
diff --git a/drivers/input/misc/hp_sdc_rtc.c b/drivers/input/misc/hp_sdc_rtc.c
index 1be963961c15..ab4da79ee560 100644
--- a/drivers/input/misc/hp_sdc_rtc.c
+++ b/drivers/input/misc/hp_sdc_rtc.c
@@ -60,7 +60,7 @@ static struct fasync_struct *hp_sdc_rtc_async_queue;
60 60
61static DECLARE_WAIT_QUEUE_HEAD(hp_sdc_rtc_wait); 61static DECLARE_WAIT_QUEUE_HEAD(hp_sdc_rtc_wait);
62 62
63static ssize_t hp_sdc_rtc_read(struct file *file, char *buf, 63static ssize_t hp_sdc_rtc_read(struct file *file, char __user *buf,
64 size_t count, loff_t *ppos); 64 size_t count, loff_t *ppos);
65 65
66static int hp_sdc_rtc_ioctl(struct inode *inode, struct file *file, 66static int hp_sdc_rtc_ioctl(struct inode *inode, struct file *file,
@@ -385,14 +385,14 @@ static int hp_sdc_rtc_set_i8042timer (struct timeval *setto, uint8_t setcmd)
385 return 0; 385 return 0;
386} 386}
387 387
388static ssize_t hp_sdc_rtc_read(struct file *file, char *buf, 388static ssize_t hp_sdc_rtc_read(struct file *file, char __user *buf,
389 size_t count, loff_t *ppos) { 389 size_t count, loff_t *ppos) {
390 ssize_t retval; 390 ssize_t retval;
391 391
392 if (count < sizeof(unsigned long)) 392 if (count < sizeof(unsigned long))
393 return -EINVAL; 393 return -EINVAL;
394 394
395 retval = put_user(68, (unsigned long *)buf); 395 retval = put_user(68, (unsigned long __user *)buf);
396 return retval; 396 return retval;
397} 397}
398 398
@@ -696,7 +696,7 @@ static int __init hp_sdc_rtc_init(void)
696 if ((ret = hp_sdc_request_timer_irq(&hp_sdc_rtc_isr))) 696 if ((ret = hp_sdc_request_timer_irq(&hp_sdc_rtc_isr)))
697 return ret; 697 return ret;
698 misc_register(&hp_sdc_rtc_dev); 698 misc_register(&hp_sdc_rtc_dev);
699 create_proc_read_entry ("driver/rtc", 0, 0, 699 create_proc_read_entry ("driver/rtc", 0, NULL,
700 hp_sdc_rtc_read_proc, NULL); 700 hp_sdc_rtc_read_proc, NULL);
701 701
702 printk(KERN_INFO "HP i8042 SDC + MSM-58321 RTC support loaded " 702 printk(KERN_INFO "HP i8042 SDC + MSM-58321 RTC support loaded "
diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c
index 4639537336fc..7b9d1c1da41a 100644
--- a/drivers/input/misc/wistron_btns.c
+++ b/drivers/input/misc/wistron_btns.c
@@ -17,7 +17,7 @@
17 * with this program; if not, write to the Free Software Foundation, Inc., 17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 59 Temple Place Suite 330, Boston, MA 02111-1307, USA. 18 * 59 Temple Place Suite 330, Boston, MA 02111-1307, USA.
19 */ 19 */
20#include <asm/io.h> 20#include <linux/io.h>
21#include <linux/dmi.h> 21#include <linux/dmi.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/input.h> 23#include <linux/input.h>
diff --git a/drivers/input/serio/hil_mlc.c b/drivers/input/serio/hil_mlc.c
index bdfde046b741..49e11e2c1d5d 100644
--- a/drivers/input/serio/hil_mlc.c
+++ b/drivers/input/serio/hil_mlc.c
@@ -391,23 +391,23 @@ static int hilse_operate(hil_mlc *mlc, int repoll) {
391} 391}
392 392
393#define FUNC(funct, funct_arg, zero_rc, neg_rc, pos_rc) \ 393#define FUNC(funct, funct_arg, zero_rc, neg_rc, pos_rc) \
394{ HILSE_FUNC, { func: &funct }, funct_arg, zero_rc, neg_rc, pos_rc }, 394{ HILSE_FUNC, { .func = funct }, funct_arg, zero_rc, neg_rc, pos_rc },
395#define OUT(pack) \ 395#define OUT(pack) \
396{ HILSE_OUT, { packet: pack }, 0, HILSEN_NEXT, HILSEN_DOZE, 0 }, 396{ HILSE_OUT, { .packet = pack }, 0, HILSEN_NEXT, HILSEN_DOZE, 0 },
397#define CTS \ 397#define CTS \
398{ HILSE_CTS, { packet: 0 }, 0, HILSEN_NEXT | HILSEN_SCHED | HILSEN_BREAK, HILSEN_DOZE, 0 }, 398{ HILSE_CTS, { .packet = 0 }, 0, HILSEN_NEXT | HILSEN_SCHED | HILSEN_BREAK, HILSEN_DOZE, 0 },
399#define EXPECT(comp, to, got, got_wrong, timed_out) \ 399#define EXPECT(comp, to, got, got_wrong, timed_out) \
400{ HILSE_EXPECT, { packet: comp }, to, got, got_wrong, timed_out }, 400{ HILSE_EXPECT, { .packet = comp }, to, got, got_wrong, timed_out },
401#define EXPECT_LAST(comp, to, got, got_wrong, timed_out) \ 401#define EXPECT_LAST(comp, to, got, got_wrong, timed_out) \
402{ HILSE_EXPECT_LAST, { packet: comp }, to, got, got_wrong, timed_out }, 402{ HILSE_EXPECT_LAST, { .packet = comp }, to, got, got_wrong, timed_out },
403#define EXPECT_DISC(comp, to, got, got_wrong, timed_out) \ 403#define EXPECT_DISC(comp, to, got, got_wrong, timed_out) \
404{ HILSE_EXPECT_DISC, { packet: comp }, to, got, got_wrong, timed_out }, 404{ HILSE_EXPECT_DISC, { .packet = comp }, to, got, got_wrong, timed_out },
405#define IN(to, got, got_error, timed_out) \ 405#define IN(to, got, got_error, timed_out) \
406{ HILSE_IN, { packet: 0 }, to, got, got_error, timed_out }, 406{ HILSE_IN, { .packet = 0 }, to, got, got_error, timed_out },
407#define OUT_DISC(pack) \ 407#define OUT_DISC(pack) \
408{ HILSE_OUT_DISC, { packet: pack }, 0, 0, 0, 0 }, 408{ HILSE_OUT_DISC, { .packet = pack }, 0, 0, 0, 0 },
409#define OUT_LAST(pack) \ 409#define OUT_LAST(pack) \
410{ HILSE_OUT_LAST, { packet: pack }, 0, 0, 0, 0 }, 410{ HILSE_OUT_LAST, { .packet = pack }, 0, 0, 0, 0 },
411 411
412struct hilse_node hil_mlc_se[HILSEN_END] = { 412struct hilse_node hil_mlc_se[HILSEN_END] = {
413 413
diff --git a/drivers/input/serio/hp_sdc.c b/drivers/input/serio/hp_sdc.c
index ba7b920347e3..9907ad3bea23 100644
--- a/drivers/input/serio/hp_sdc.c
+++ b/drivers/input/serio/hp_sdc.c
@@ -310,7 +310,7 @@ static void hp_sdc_tasklet(unsigned long foo) {
310 * in tasklet/bh context. 310 * in tasklet/bh context.
311 */ 311 */
312 if (curr->act.irqhook) 312 if (curr->act.irqhook)
313 curr->act.irqhook(0, 0, 0, 0); 313 curr->act.irqhook(0, NULL, 0, 0);
314 } 314 }
315 curr->actidx = curr->idx; 315 curr->actidx = curr->idx;
316 curr->idx++; 316 curr->idx++;
@@ -525,7 +525,7 @@ actdone:
525 up(curr->act.semaphore); 525 up(curr->act.semaphore);
526 } 526 }
527 else if (act & HP_SDC_ACT_CALLBACK) { 527 else if (act & HP_SDC_ACT_CALLBACK) {
528 curr->act.irqhook(0,0,0,0); 528 curr->act.irqhook(0,NULL,0,0);
529 } 529 }
530 if (curr->idx >= curr->endidx) { /* This transaction is over. */ 530 if (curr->idx >= curr->endidx) { /* This transaction is over. */
531 if (act & HP_SDC_ACT_DEALLOC) kfree(curr); 531 if (act & HP_SDC_ACT_DEALLOC) kfree(curr);
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 09b06e605b50..7e3141f37e32 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -106,6 +106,7 @@ static unsigned char i8042_ctr;
106static unsigned char i8042_mux_present; 106static unsigned char i8042_mux_present;
107static unsigned char i8042_kbd_irq_registered; 107static unsigned char i8042_kbd_irq_registered;
108static unsigned char i8042_aux_irq_registered; 108static unsigned char i8042_aux_irq_registered;
109static unsigned char i8042_suppress_kbd_ack;
109static struct platform_device *i8042_platform_device; 110static struct platform_device *i8042_platform_device;
110 111
111static irqreturn_t i8042_interrupt(int irq, void *dev_id); 112static irqreturn_t i8042_interrupt(int irq, void *dev_id);
@@ -316,7 +317,7 @@ static irqreturn_t i8042_interrupt(int irq, void *dev_id)
316 unsigned char str, data; 317 unsigned char str, data;
317 unsigned int dfl; 318 unsigned int dfl;
318 unsigned int port_no; 319 unsigned int port_no;
319 int ret; 320 int ret = 1;
320 321
321 spin_lock_irqsave(&i8042_lock, flags); 322 spin_lock_irqsave(&i8042_lock, flags);
322 str = i8042_read_status(); 323 str = i8042_read_status();
@@ -378,10 +379,16 @@ static irqreturn_t i8042_interrupt(int irq, void *dev_id)
378 dfl & SERIO_PARITY ? ", bad parity" : "", 379 dfl & SERIO_PARITY ? ", bad parity" : "",
379 dfl & SERIO_TIMEOUT ? ", timeout" : ""); 380 dfl & SERIO_TIMEOUT ? ", timeout" : "");
380 381
382 if (unlikely(i8042_suppress_kbd_ack))
383 if (port_no == I8042_KBD_PORT_NO &&
384 (data == 0xfa || data == 0xfe)) {
385 i8042_suppress_kbd_ack = 0;
386 goto out;
387 }
388
381 if (likely(port->exists)) 389 if (likely(port->exists))
382 serio_interrupt(port->serio, data, dfl); 390 serio_interrupt(port->serio, data, dfl);
383 391
384 ret = 1;
385 out: 392 out:
386 return IRQ_RETVAL(ret); 393 return IRQ_RETVAL(ret);
387} 394}
@@ -842,11 +849,13 @@ static long i8042_panic_blink(long count)
842 led ^= 0x01 | 0x04; 849 led ^= 0x01 | 0x04;
843 while (i8042_read_status() & I8042_STR_IBF) 850 while (i8042_read_status() & I8042_STR_IBF)
844 DELAY; 851 DELAY;
852 i8042_suppress_kbd_ack = 1;
845 i8042_write_data(0xed); /* set leds */ 853 i8042_write_data(0xed); /* set leds */
846 DELAY; 854 DELAY;
847 while (i8042_read_status() & I8042_STR_IBF) 855 while (i8042_read_status() & I8042_STR_IBF)
848 DELAY; 856 DELAY;
849 DELAY; 857 DELAY;
858 i8042_suppress_kbd_ack = 1;
850 i8042_write_data(led); 859 i8042_write_data(led);
851 DELAY; 860 DELAY;
852 last_blink = count; 861 last_blink = count;
diff --git a/drivers/input/serio/libps2.c b/drivers/input/serio/libps2.c
index dcb16b5cbec0..e5b1b60757bb 100644
--- a/drivers/input/serio/libps2.c
+++ b/drivers/input/serio/libps2.c
@@ -189,7 +189,7 @@ int ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command)
189 return -1; 189 return -1;
190 } 190 }
191 191
192 mutex_lock_nested(&ps2dev->cmd_mutex, SINGLE_DEPTH_NESTING); 192 mutex_lock(&ps2dev->cmd_mutex);
193 193
194 serio_pause_rx(ps2dev->serio); 194 serio_pause_rx(ps2dev->serio);
195 ps2dev->flags = command == PS2_CMD_GETID ? PS2_FLAG_WAITID : 0; 195 ps2dev->flags = command == PS2_CMD_GETID ? PS2_FLAG_WAITID : 0;
@@ -296,6 +296,7 @@ EXPORT_SYMBOL(ps2_schedule_command);
296void ps2_init(struct ps2dev *ps2dev, struct serio *serio) 296void ps2_init(struct ps2dev *ps2dev, struct serio *serio)
297{ 297{
298 mutex_init(&ps2dev->cmd_mutex); 298 mutex_init(&ps2dev->cmd_mutex);
299 lockdep_set_subclass(&ps2dev->cmd_mutex, serio->depth);
299 init_waitqueue_head(&ps2dev->wait); 300 init_waitqueue_head(&ps2dev->wait);
300 ps2dev->serio = serio; 301 ps2dev->serio = serio;
301} 302}
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index 960fae3c3cea..211943f85cb6 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -118,6 +118,8 @@ static int serio_match_port(const struct serio_device_id *ids, struct serio *ser
118 118
119static void serio_bind_driver(struct serio *serio, struct serio_driver *drv) 119static void serio_bind_driver(struct serio *serio, struct serio_driver *drv)
120{ 120{
121 int error;
122
121 down_write(&serio_bus.subsys.rwsem); 123 down_write(&serio_bus.subsys.rwsem);
122 124
123 if (serio_match_port(drv->id_table, serio)) { 125 if (serio_match_port(drv->id_table, serio)) {
@@ -126,9 +128,19 @@ static void serio_bind_driver(struct serio *serio, struct serio_driver *drv)
126 serio->dev.driver = NULL; 128 serio->dev.driver = NULL;
127 goto out; 129 goto out;
128 } 130 }
129 device_bind_driver(&serio->dev); 131 error = device_bind_driver(&serio->dev);
132 if (error) {
133 printk(KERN_WARNING
134 "serio: device_bind_driver() failed "
135 "for %s (%s) and %s, error: %d\n",
136 serio->phys, serio->name,
137 drv->description, error);
138 serio_disconnect_driver(serio);
139 serio->dev.driver = NULL;
140 goto out;
141 }
130 } 142 }
131out: 143 out:
132 up_write(&serio_bus.subsys.rwsem); 144 up_write(&serio_bus.subsys.rwsem);
133} 145}
134 146
@@ -538,8 +550,12 @@ static void serio_init_port(struct serio *serio)
538 "serio%ld", (long)atomic_inc_return(&serio_no) - 1); 550 "serio%ld", (long)atomic_inc_return(&serio_no) - 1);
539 serio->dev.bus = &serio_bus; 551 serio->dev.bus = &serio_bus;
540 serio->dev.release = serio_release_port; 552 serio->dev.release = serio_release_port;
541 if (serio->parent) 553 if (serio->parent) {
542 serio->dev.parent = &serio->parent->dev; 554 serio->dev.parent = &serio->parent->dev;
555 serio->depth = serio->parent->depth + 1;
556 } else
557 serio->depth = 0;
558 lockdep_set_subclass(&serio->lock, serio->depth);
543} 559}
544 560
545/* 561/*
diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c
index ca79b2246195..66121f6a89ad 100644
--- a/drivers/input/touchscreen/corgi_ts.c
+++ b/drivers/input/touchscreen/corgi_ts.c
@@ -219,7 +219,7 @@ static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer)
219static void corgi_ts_timer(unsigned long data) 219static void corgi_ts_timer(unsigned long data)
220{ 220{
221 struct corgi_ts *corgits_data = (struct corgi_ts *) data; 221 struct corgi_ts *corgits_data = (struct corgi_ts *) data;
222 ts_interrupt_main(corgits_data, 1, NULL); 222 ts_interrupt_main(corgits_data, 1);
223} 223}
224 224
225static irqreturn_t ts_interrupt(int irq, void *dev_id) 225static irqreturn_t ts_interrupt(int irq, void *dev_id)
@@ -237,7 +237,7 @@ static int corgits_suspend(struct platform_device *dev, pm_message_t state)
237 if (corgi_ts->pendown) { 237 if (corgi_ts->pendown) {
238 del_timer_sync(&corgi_ts->timer); 238 del_timer_sync(&corgi_ts->timer);
239 corgi_ts->tc.pressure = 0; 239 corgi_ts->tc.pressure = 0;
240 new_data(corgi_ts, NULL); 240 new_data(corgi_ts);
241 corgi_ts->pendown = 0; 241 corgi_ts->pendown = 0;
242 } 242 }
243 corgi_ts->power_mode = PWR_MODE_SUSPEND; 243 corgi_ts->power_mode = PWR_MODE_SUSPEND;
diff --git a/drivers/input/touchscreen/hp680_ts_input.c b/drivers/input/touchscreen/hp680_ts_input.c
index e31c6c55b2e2..58fca316786c 100644
--- a/drivers/input/touchscreen/hp680_ts_input.c
+++ b/drivers/input/touchscreen/hp680_ts_input.c
@@ -6,7 +6,7 @@
6#include <asm/io.h> 6#include <asm/io.h>
7#include <asm/delay.h> 7#include <asm/delay.h>
8#include <asm/adc.h> 8#include <asm/adc.h>
9#include <asm/hp6xx/hp6xx.h> 9#include <asm/hp6xx.h>
10 10
11#define MODNAME "hp680_ts_input" 11#define MODNAME "hp680_ts_input"
12 12
diff --git a/drivers/isdn/capi/capidrv.c b/drivers/isdn/capi/capidrv.c
index d10c8b82e6aa..b6f9476c0501 100644
--- a/drivers/isdn/capi/capidrv.c
+++ b/drivers/isdn/capi/capidrv.c
@@ -1907,7 +1907,8 @@ static int if_readstat(u8 __user *buf, int len, int id, int channel)
1907 } 1907 }
1908 1908
1909 for (p=buf, count=0; count < len; p++, count++) { 1909 for (p=buf, count=0; count < len; p++, count++) {
1910 put_user(*card->q931_read++, p); 1910 if (put_user(*card->q931_read++, p))
1911 return -EFAULT;
1911 if (card->q931_read > card->q931_end) 1912 if (card->q931_read > card->q931_end)
1912 card->q931_read = card->q931_buf; 1913 card->q931_read = card->q931_buf;
1913 } 1914 }
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c
index aca165d43aa0..5800beeebb85 100644
--- a/drivers/isdn/gigaset/common.c
+++ b/drivers/isdn/gigaset/common.c
@@ -616,7 +616,7 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
616 } else if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL) 616 } else if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)
617 skb_reserve(bcs->skb, HW_HDR_LEN); 617 skb_reserve(bcs->skb, HW_HDR_LEN);
618 else { 618 else {
619 dev_warn(cs->dev, "could not allocate skb\n"); 619 warn("could not allocate skb\n");
620 bcs->inputstate |= INS_skip_frame; 620 bcs->inputstate |= INS_skip_frame;
621 } 621 }
622 622
diff --git a/drivers/isdn/hisax/Kconfig b/drivers/isdn/hisax/Kconfig
index eb57a988e048..cfd2718a490d 100644
--- a/drivers/isdn/hisax/Kconfig
+++ b/drivers/isdn/hisax/Kconfig
@@ -344,7 +344,7 @@ config HISAX_HFC_SX
344 344
345config HISAX_ENTERNOW_PCI 345config HISAX_ENTERNOW_PCI
346 bool "Formula-n enter:now PCI card" 346 bool "Formula-n enter:now PCI card"
347 depends on PCI && (BROKEN || !(SPARC || PPC || PARISC || M68K || FRV)) 347 depends on HISAX_NETJET && PCI && (BROKEN || !(SPARC || PPC || PARISC || M68K || FRV))
348 help 348 help
349 This enables HiSax support for the Formula-n enter:now PCI 349 This enables HiSax support for the Formula-n enter:now PCI
350 ISDN card. 350 ISDN card.
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index e4823ab2b127..785b08554fca 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -631,7 +631,8 @@ static int HiSax_readstatus(u_char __user *buf, int len, int id, int channel)
631 count = cs->status_end - cs->status_read + 1; 631 count = cs->status_end - cs->status_read + 1;
632 if (count >= len) 632 if (count >= len)
633 count = len; 633 count = len;
634 copy_to_user(p, cs->status_read, count); 634 if (copy_to_user(p, cs->status_read, count))
635 return -EFAULT;
635 cs->status_read += count; 636 cs->status_read += count;
636 if (cs->status_read > cs->status_end) 637 if (cs->status_read > cs->status_end)
637 cs->status_read = cs->status_buf; 638 cs->status_read = cs->status_buf;
@@ -642,7 +643,8 @@ static int HiSax_readstatus(u_char __user *buf, int len, int id, int channel)
642 cnt = HISAX_STATUS_BUFSIZE; 643 cnt = HISAX_STATUS_BUFSIZE;
643 else 644 else
644 cnt = count; 645 cnt = count;
645 copy_to_user(p, cs->status_read, cnt); 646 if (copy_to_user(p, cs->status_read, cnt))
647 return -EFAULT;
646 p += cnt; 648 p += cnt;
647 cs->status_read += cnt % HISAX_STATUS_BUFSIZE; 649 cs->status_read += cnt % HISAX_STATUS_BUFSIZE;
648 count -= cnt; 650 count -= cnt;
diff --git a/drivers/isdn/hisax/diva.c b/drivers/isdn/hisax/diva.c
index 7e95f04f13da..3dacfff93f5f 100644
--- a/drivers/isdn/hisax/diva.c
+++ b/drivers/isdn/hisax/diva.c
@@ -716,8 +716,10 @@ release_io_diva(struct IsdnCardState *cs)
716 716
717 *cfg = 0; /* disable INT0/1 */ 717 *cfg = 0; /* disable INT0/1 */
718 *cfg = 2; /* reset pending INT0 */ 718 *cfg = 2; /* reset pending INT0 */
719 iounmap((void *)cs->hw.diva.cfg_reg); 719 if (cs->hw.diva.cfg_reg)
720 iounmap((void *)cs->hw.diva.pci_cfg); 720 iounmap((void *)cs->hw.diva.cfg_reg);
721 if (cs->hw.diva.pci_cfg)
722 iounmap((void *)cs->hw.diva.pci_cfg);
721 return; 723 return;
722 } else if (cs->subtyp != DIVA_IPAC_ISA) { 724 } else if (cs->subtyp != DIVA_IPAC_ISA) {
723 del_timer(&cs->hw.diva.tl); 725 del_timer(&cs->hw.diva.tl);
@@ -734,6 +736,23 @@ release_io_diva(struct IsdnCardState *cs)
734} 736}
735 737
736static void 738static void
739iounmap_diva(struct IsdnCardState *cs)
740{
741 if ((cs->subtyp == DIVA_IPAC_PCI) || (cs->subtyp == DIVA_IPACX_PCI)) {
742 if (cs->hw.diva.cfg_reg) {
743 iounmap((void *)cs->hw.diva.cfg_reg);
744 cs->hw.diva.cfg_reg = 0;
745 }
746 if (cs->hw.diva.pci_cfg) {
747 iounmap((void *)cs->hw.diva.pci_cfg);
748 cs->hw.diva.pci_cfg = 0;
749 }
750 }
751
752 return;
753}
754
755static void
737reset_diva(struct IsdnCardState *cs) 756reset_diva(struct IsdnCardState *cs)
738{ 757{
739 if (cs->subtyp == DIVA_IPAC_ISA) { 758 if (cs->subtyp == DIVA_IPAC_ISA) {
@@ -1069,11 +1088,13 @@ setup_diva(struct IsdnCard *card)
1069 1088
1070 if (!cs->irq) { 1089 if (!cs->irq) {
1071 printk(KERN_WARNING "Diva: No IRQ for PCI card found\n"); 1090 printk(KERN_WARNING "Diva: No IRQ for PCI card found\n");
1091 iounmap_diva(cs);
1072 return(0); 1092 return(0);
1073 } 1093 }
1074 1094
1075 if (!cs->hw.diva.cfg_reg) { 1095 if (!cs->hw.diva.cfg_reg) {
1076 printk(KERN_WARNING "Diva: No IO-Adr for PCI card found\n"); 1096 printk(KERN_WARNING "Diva: No IO-Adr for PCI card found\n");
1097 iounmap_diva(cs);
1077 return(0); 1098 return(0);
1078 } 1099 }
1079 cs->irq_flags |= IRQF_SHARED; 1100 cs->irq_flags |= IRQF_SHARED;
@@ -1123,6 +1144,7 @@ ready:
1123 CardType[card->typ], 1144 CardType[card->typ],
1124 cs->hw.diva.cfg_reg, 1145 cs->hw.diva.cfg_reg,
1125 cs->hw.diva.cfg_reg + bytecnt); 1146 cs->hw.diva.cfg_reg + bytecnt);
1147 iounmap_diva(cs);
1126 return (0); 1148 return (0);
1127 } 1149 }
1128 } 1150 }
diff --git a/drivers/isdn/hysdn/boardergo.c b/drivers/isdn/hysdn/boardergo.c
index 160f22fa5941..82e42a80dc4b 100644
--- a/drivers/isdn/hysdn/boardergo.c
+++ b/drivers/isdn/hysdn/boardergo.c
@@ -45,11 +45,10 @@ ergo_interrupt(int intno, void *dev_id)
45 if (!card->irq_enabled) 45 if (!card->irq_enabled)
46 return IRQ_NONE; /* other device interrupting or irq switched off */ 46 return IRQ_NONE; /* other device interrupting or irq switched off */
47 47
48 save_flags(flags); 48 spin_lock_irqsave(&card->hysdn_lock, flags); /* no further irqs allowed */
49 cli(); /* no further irqs allowed */
50 49
51 if (!(bytein(card->iobase + PCI9050_INTR_REG) & PCI9050_INTR_REG_STAT1)) { 50 if (!(bytein(card->iobase + PCI9050_INTR_REG) & PCI9050_INTR_REG_STAT1)) {
52 restore_flags(flags); /* restore old state */ 51 spin_unlock_irqrestore(&card->hysdn_lock, flags); /* restore old state */
53 return IRQ_NONE; /* no interrupt requested by E1 */ 52 return IRQ_NONE; /* no interrupt requested by E1 */
54 } 53 }
55 /* clear any pending ints on the board */ 54 /* clear any pending ints on the board */
@@ -61,7 +60,7 @@ ergo_interrupt(int intno, void *dev_id)
61 /* start kernel task immediately after leaving all interrupts */ 60 /* start kernel task immediately after leaving all interrupts */
62 if (!card->hw_lock) 61 if (!card->hw_lock)
63 schedule_work(&card->irq_queue); 62 schedule_work(&card->irq_queue);
64 restore_flags(flags); 63 spin_unlock_irqrestore(&card->hysdn_lock, flags);
65 return IRQ_HANDLED; 64 return IRQ_HANDLED;
66} /* ergo_interrupt */ 65} /* ergo_interrupt */
67 66
@@ -83,10 +82,9 @@ ergo_irq_bh(hysdn_card * card)
83 82
84 dpr = card->dpram; /* point to DPRAM */ 83 dpr = card->dpram; /* point to DPRAM */
85 84
86 save_flags(flags); 85 spin_lock_irqsave(&card->hysdn_lock, flags);
87 cli();
88 if (card->hw_lock) { 86 if (card->hw_lock) {
89 restore_flags(flags); /* hardware currently unavailable */ 87 spin_unlock_irqrestore(&card->hysdn_lock, flags); /* hardware currently unavailable */
90 return; 88 return;
91 } 89 }
92 card->hw_lock = 1; /* we now lock the hardware */ 90 card->hw_lock = 1; /* we now lock the hardware */
@@ -120,7 +118,7 @@ ergo_irq_bh(hysdn_card * card)
120 card->hw_lock = 0; /* free hardware again */ 118 card->hw_lock = 0; /* free hardware again */
121 } while (again); /* until nothing more to do */ 119 } while (again); /* until nothing more to do */
122 120
123 restore_flags(flags); 121 spin_unlock_irqrestore(&card->hysdn_lock, flags);
124} /* ergo_irq_bh */ 122} /* ergo_irq_bh */
125 123
126 124
@@ -137,8 +135,7 @@ ergo_stopcard(hysdn_card * card)
137#ifdef CONFIG_HYSDN_CAPI 135#ifdef CONFIG_HYSDN_CAPI
138 hycapi_capi_stop(card); 136 hycapi_capi_stop(card);
139#endif /* CONFIG_HYSDN_CAPI */ 137#endif /* CONFIG_HYSDN_CAPI */
140 save_flags(flags); 138 spin_lock_irqsave(&card->hysdn_lock, flags);
141 cli();
142 val = bytein(card->iobase + PCI9050_INTR_REG); /* get actual value */ 139 val = bytein(card->iobase + PCI9050_INTR_REG); /* get actual value */
143 val &= ~(PCI9050_INTR_REG_ENPCI | PCI9050_INTR_REG_EN1); /* mask irq */ 140 val &= ~(PCI9050_INTR_REG_ENPCI | PCI9050_INTR_REG_EN1); /* mask irq */
144 byteout(card->iobase + PCI9050_INTR_REG, val); 141 byteout(card->iobase + PCI9050_INTR_REG, val);
@@ -147,7 +144,7 @@ ergo_stopcard(hysdn_card * card)
147 card->state = CARD_STATE_UNUSED; 144 card->state = CARD_STATE_UNUSED;
148 card->err_log_state = ERRLOG_STATE_OFF; /* currently no log active */ 145 card->err_log_state = ERRLOG_STATE_OFF; /* currently no log active */
149 146
150 restore_flags(flags); 147 spin_unlock_irqrestore(&card->hysdn_lock, flags);
151} /* ergo_stopcard */ 148} /* ergo_stopcard */
152 149
153/**************************************************************************/ 150/**************************************************************************/
@@ -162,12 +159,11 @@ ergo_set_errlog_state(hysdn_card * card, int on)
162 card->err_log_state = ERRLOG_STATE_OFF; /* must be off */ 159 card->err_log_state = ERRLOG_STATE_OFF; /* must be off */
163 return; 160 return;
164 } 161 }
165 save_flags(flags); 162 spin_lock_irqsave(&card->hysdn_lock, flags);
166 cli();
167 163
168 if (((card->err_log_state == ERRLOG_STATE_OFF) && !on) || 164 if (((card->err_log_state == ERRLOG_STATE_OFF) && !on) ||
169 ((card->err_log_state == ERRLOG_STATE_ON) && on)) { 165 ((card->err_log_state == ERRLOG_STATE_ON) && on)) {
170 restore_flags(flags); 166 spin_unlock_irqrestore(&card->hysdn_lock, flags);
171 return; /* nothing to do */ 167 return; /* nothing to do */
172 } 168 }
173 if (on) 169 if (on)
@@ -175,7 +171,7 @@ ergo_set_errlog_state(hysdn_card * card, int on)
175 else 171 else
176 card->err_log_state = ERRLOG_STATE_STOP; /* request stop */ 172 card->err_log_state = ERRLOG_STATE_STOP; /* request stop */
177 173
178 restore_flags(flags); 174 spin_unlock_irqrestore(&card->hysdn_lock, flags);
179 schedule_work(&card->irq_queue); 175 schedule_work(&card->irq_queue);
180} /* ergo_set_errlog_state */ 176} /* ergo_set_errlog_state */
181 177
@@ -356,8 +352,7 @@ ergo_waitpofready(struct HYSDN_CARD *card)
356 352
357 if (card->debug_flags & LOG_POF_RECORD) 353 if (card->debug_flags & LOG_POF_RECORD)
358 hysdn_addlog(card, "ERGO: pof boot success"); 354 hysdn_addlog(card, "ERGO: pof boot success");
359 save_flags(flags); 355 spin_lock_irqsave(&card->hysdn_lock, flags);
360 cli();
361 356
362 card->state = CARD_STATE_RUN; /* now card is running */ 357 card->state = CARD_STATE_RUN; /* now card is running */
363 /* enable the cards interrupt */ 358 /* enable the cards interrupt */
@@ -370,7 +365,7 @@ ergo_waitpofready(struct HYSDN_CARD *card)
370 dpr->ToHyInt = 1; 365 dpr->ToHyInt = 1;
371 dpr->ToPcInt = 1; /* interrupt to E1 for all cards */ 366 dpr->ToPcInt = 1; /* interrupt to E1 for all cards */
372 367
373 restore_flags(flags); 368 spin_unlock_irqrestore(&card->hysdn_lock, flags);
374 if ((hynet_enable & (1 << card->myid)) 369 if ((hynet_enable & (1 << card->myid))
375 && (i = hysdn_net_create(card))) 370 && (i = hysdn_net_create(card)))
376 { 371 {
@@ -408,7 +403,7 @@ ergo_releasehardware(hysdn_card * card)
408 free_irq(card->irq, card); /* release interrupt */ 403 free_irq(card->irq, card); /* release interrupt */
409 release_region(card->iobase + PCI9050_INTR_REG, 1); /* release all io ports */ 404 release_region(card->iobase + PCI9050_INTR_REG, 1); /* release all io ports */
410 release_region(card->iobase + PCI9050_USER_IO, 1); 405 release_region(card->iobase + PCI9050_USER_IO, 1);
411 vfree(card->dpram); 406 iounmap(card->dpram);
412 card->dpram = NULL; /* release shared mem */ 407 card->dpram = NULL; /* release shared mem */
413} /* ergo_releasehardware */ 408} /* ergo_releasehardware */
414 409
@@ -448,6 +443,7 @@ ergo_inithardware(hysdn_card * card)
448 card->waitpofready = ergo_waitpofready; 443 card->waitpofready = ergo_waitpofready;
449 card->set_errlog_state = ergo_set_errlog_state; 444 card->set_errlog_state = ergo_set_errlog_state;
450 INIT_WORK(&card->irq_queue, (void *) (void *) ergo_irq_bh, card); 445 INIT_WORK(&card->irq_queue, (void *) (void *) ergo_irq_bh, card);
446 card->hysdn_lock = SPIN_LOCK_UNLOCKED;
451 447
452 return (0); 448 return (0);
453} /* ergo_inithardware */ 449} /* ergo_inithardware */
diff --git a/drivers/isdn/hysdn/hysdn_defs.h b/drivers/isdn/hysdn/hysdn_defs.h
index 461e831592dd..729df4089385 100644
--- a/drivers/isdn/hysdn/hysdn_defs.h
+++ b/drivers/isdn/hysdn/hysdn_defs.h
@@ -188,6 +188,8 @@ typedef struct HYSDN_CARD {
188 /* init and deinit stopcard for booting, too */ 188 /* init and deinit stopcard for booting, too */
189 void (*stopcard) (struct HYSDN_CARD *); 189 void (*stopcard) (struct HYSDN_CARD *);
190 void (*releasehardware) (struct HYSDN_CARD *); 190 void (*releasehardware) (struct HYSDN_CARD *);
191
192 spinlock_t hysdn_lock;
191#ifdef CONFIG_HYSDN_CAPI 193#ifdef CONFIG_HYSDN_CAPI
192 struct hycapictrl_info { 194 struct hycapictrl_info {
193 char cardname[32]; 195 char cardname[32];
diff --git a/drivers/isdn/hysdn/hysdn_proclog.c b/drivers/isdn/hysdn/hysdn_proclog.c
index c4301e8338ef..fcd49920b220 100644
--- a/drivers/isdn/hysdn/hysdn_proclog.c
+++ b/drivers/isdn/hysdn/hysdn_proclog.c
@@ -116,8 +116,7 @@ put_log_buffer(hysdn_card * card, char *cp)
116 strcpy(ib->log_start, cp); /* set output string */ 116 strcpy(ib->log_start, cp); /* set output string */
117 ib->next = NULL; 117 ib->next = NULL;
118 ib->proc_ctrl = pd; /* point to own control structure */ 118 ib->proc_ctrl = pd; /* point to own control structure */
119 save_flags(flags); 119 spin_lock_irqsave(&card->hysdn_lock, flags);
120 cli();
121 ib->usage_cnt = pd->if_used; 120 ib->usage_cnt = pd->if_used;
122 if (!pd->log_head) 121 if (!pd->log_head)
123 pd->log_head = ib; /* new head */ 122 pd->log_head = ib; /* new head */
@@ -125,7 +124,7 @@ put_log_buffer(hysdn_card * card, char *cp)
125 pd->log_tail->next = ib; /* follows existing messages */ 124 pd->log_tail->next = ib; /* follows existing messages */
126 pd->log_tail = ib; /* new tail */ 125 pd->log_tail = ib; /* new tail */
127 i = pd->del_lock++; /* get lock state */ 126 i = pd->del_lock++; /* get lock state */
128 restore_flags(flags); 127 spin_unlock_irqrestore(&card->hysdn_lock, flags);
129 128
130 /* delete old entrys */ 129 /* delete old entrys */
131 if (!i) 130 if (!i)
@@ -270,14 +269,13 @@ hysdn_log_open(struct inode *ino, struct file *filep)
270 } else if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) { 269 } else if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) {
271 270
272 /* read access -> log/debug read */ 271 /* read access -> log/debug read */
273 save_flags(flags); 272 spin_lock_irqsave(&card->hysdn_lock, flags);
274 cli();
275 pd->if_used++; 273 pd->if_used++;
276 if (pd->log_head) 274 if (pd->log_head)
277 filep->private_data = &pd->log_tail->next; 275 filep->private_data = &pd->log_tail->next;
278 else 276 else
279 filep->private_data = &pd->log_head; 277 filep->private_data = &pd->log_head;
280 restore_flags(flags); 278 spin_unlock_irqrestore(&card->hysdn_lock, flags);
281 } else { /* simultaneous read/write access forbidden ! */ 279 } else { /* simultaneous read/write access forbidden ! */
282 unlock_kernel(); 280 unlock_kernel();
283 return (-EPERM); /* no permission this time */ 281 return (-EPERM); /* no permission this time */
@@ -301,7 +299,7 @@ hysdn_log_close(struct inode *ino, struct file *filep)
301 hysdn_card *card; 299 hysdn_card *card;
302 int retval = 0; 300 int retval = 0;
303 unsigned long flags; 301 unsigned long flags;
304 302 spinlock_t hysdn_lock = SPIN_LOCK_UNLOCKED;
305 303
306 lock_kernel(); 304 lock_kernel();
307 if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) { 305 if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) {
@@ -311,8 +309,7 @@ hysdn_log_close(struct inode *ino, struct file *filep)
311 /* read access -> log/debug read, mark one further file as closed */ 309 /* read access -> log/debug read, mark one further file as closed */
312 310
313 pd = NULL; 311 pd = NULL;
314 save_flags(flags); 312 spin_lock_irqsave(&hysdn_lock, flags);
315 cli();
316 inf = *((struct log_data **) filep->private_data); /* get first log entry */ 313 inf = *((struct log_data **) filep->private_data); /* get first log entry */
317 if (inf) 314 if (inf)
318 pd = (struct procdata *) inf->proc_ctrl; /* still entries there */ 315 pd = (struct procdata *) inf->proc_ctrl; /* still entries there */
@@ -335,7 +332,7 @@ hysdn_log_close(struct inode *ino, struct file *filep)
335 inf->usage_cnt--; /* decrement usage count for buffers */ 332 inf->usage_cnt--; /* decrement usage count for buffers */
336 inf = inf->next; 333 inf = inf->next;
337 } 334 }
338 restore_flags(flags); 335 spin_unlock_irqrestore(&hysdn_lock, flags);
339 336
340 if (pd) 337 if (pd)
341 if (pd->if_used <= 0) /* delete buffers if last file closed */ 338 if (pd->if_used <= 0) /* delete buffers if last file closed */
diff --git a/drivers/isdn/hysdn/hysdn_sched.c b/drivers/isdn/hysdn/hysdn_sched.c
index 1c0d54ac12ab..18758772b744 100644
--- a/drivers/isdn/hysdn/hysdn_sched.c
+++ b/drivers/isdn/hysdn/hysdn_sched.c
@@ -155,22 +155,17 @@ hysdn_tx_cfgline(hysdn_card *card, unsigned char *line, unsigned short chan)
155 if (card->debug_flags & LOG_SCHED_ASYN) 155 if (card->debug_flags & LOG_SCHED_ASYN)
156 hysdn_addlog(card, "async tx-cfg chan=%d len=%d", chan, strlen(line) + 1); 156 hysdn_addlog(card, "async tx-cfg chan=%d len=%d", chan, strlen(line) + 1);
157 157
158 save_flags(flags);
159 cli();
160 while (card->async_busy) { 158 while (card->async_busy) {
161 sti();
162 159
163 if (card->debug_flags & LOG_SCHED_ASYN) 160 if (card->debug_flags & LOG_SCHED_ASYN)
164 hysdn_addlog(card, "async tx-cfg delayed"); 161 hysdn_addlog(card, "async tx-cfg delayed");
165 162
166 msleep_interruptible(20); /* Timeout 20ms */ 163 msleep_interruptible(20); /* Timeout 20ms */
167 if (!--cnt) { 164 if (!--cnt)
168 restore_flags(flags);
169 return (-ERR_ASYNC_TIME); /* timed out */ 165 return (-ERR_ASYNC_TIME); /* timed out */
170 }
171 cli();
172 } /* wait for buffer to become free */ 166 } /* wait for buffer to become free */
173 167
168 spin_lock_irqsave(&card->hysdn_lock, flags);
174 strcpy(card->async_data, line); 169 strcpy(card->async_data, line);
175 card->async_len = strlen(line) + 1; 170 card->async_len = strlen(line) + 1;
176 card->async_channel = chan; 171 card->async_channel = chan;
@@ -178,30 +173,23 @@ hysdn_tx_cfgline(hysdn_card *card, unsigned char *line, unsigned short chan)
178 173
179 /* now queue the task */ 174 /* now queue the task */
180 schedule_work(&card->irq_queue); 175 schedule_work(&card->irq_queue);
181 sti(); 176 spin_unlock_irqrestore(&card->hysdn_lock, flags);
182 177
183 if (card->debug_flags & LOG_SCHED_ASYN) 178 if (card->debug_flags & LOG_SCHED_ASYN)
184 hysdn_addlog(card, "async tx-cfg data queued"); 179 hysdn_addlog(card, "async tx-cfg data queued");
185 180
186 cnt++; /* short delay */ 181 cnt++; /* short delay */
187 cli();
188 182
189 while (card->async_busy) { 183 while (card->async_busy) {
190 sti();
191 184
192 if (card->debug_flags & LOG_SCHED_ASYN) 185 if (card->debug_flags & LOG_SCHED_ASYN)
193 hysdn_addlog(card, "async tx-cfg waiting for tx-ready"); 186 hysdn_addlog(card, "async tx-cfg waiting for tx-ready");
194 187
195 msleep_interruptible(20); /* Timeout 20ms */ 188 msleep_interruptible(20); /* Timeout 20ms */
196 if (!--cnt) { 189 if (!--cnt)
197 restore_flags(flags);
198 return (-ERR_ASYNC_TIME); /* timed out */ 190 return (-ERR_ASYNC_TIME); /* timed out */
199 }
200 cli();
201 } /* wait for buffer to become free again */ 191 } /* wait for buffer to become free again */
202 192
203 restore_flags(flags);
204
205 if (card->debug_flags & LOG_SCHED_ASYN) 193 if (card->debug_flags & LOG_SCHED_ASYN)
206 hysdn_addlog(card, "async tx-cfg data send"); 194 hysdn_addlog(card, "async tx-cfg data send");
207 195
diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
index c3d79eef9e32..69aee2602aa6 100644
--- a/drivers/isdn/i4l/isdn_common.c
+++ b/drivers/isdn/i4l/isdn_common.c
@@ -1134,9 +1134,12 @@ isdn_read(struct file *file, char __user *buf, size_t count, loff_t * off)
1134 if (dev->drv[drvidx]->interface->readstat) { 1134 if (dev->drv[drvidx]->interface->readstat) {
1135 if (count > dev->drv[drvidx]->stavail) 1135 if (count > dev->drv[drvidx]->stavail)
1136 count = dev->drv[drvidx]->stavail; 1136 count = dev->drv[drvidx]->stavail;
1137 len = dev->drv[drvidx]->interface-> 1137 len = dev->drv[drvidx]->interface->readstat(buf, count,
1138 readstat(buf, count, drvidx, 1138 drvidx, isdn_minor2chan(minor));
1139 isdn_minor2chan(minor)); 1139 if (len < 0) {
1140 retval = len;
1141 goto out;
1142 }
1140 } else { 1143 } else {
1141 len = 0; 1144 len = 0;
1142 } 1145 }
diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
index 6649f8bc9951..730bbd07ebc7 100644
--- a/drivers/isdn/icn/icn.c
+++ b/drivers/isdn/icn/icn.c
@@ -1010,7 +1010,8 @@ icn_readstatus(u_char __user *buf, int len, icn_card * card)
1010 for (p = buf, count = 0; count < len; p++, count++) { 1010 for (p = buf, count = 0; count < len; p++, count++) {
1011 if (card->msg_buf_read == card->msg_buf_write) 1011 if (card->msg_buf_read == card->msg_buf_write)
1012 return count; 1012 return count;
1013 put_user(*card->msg_buf_read++, p); 1013 if (put_user(*card->msg_buf_read++, p))
1014 return -EFAULT;
1014 if (card->msg_buf_read > card->msg_buf_end) 1015 if (card->msg_buf_read > card->msg_buf_end)
1015 card->msg_buf_read = card->msg_buf; 1016 card->msg_buf_read = card->msg_buf;
1016 } 1017 }
diff --git a/drivers/isdn/isdnloop/isdnloop.c b/drivers/isdn/isdnloop/isdnloop.c
index fabbd461603e..c3ae2edaf6fa 100644
--- a/drivers/isdn/isdnloop/isdnloop.c
+++ b/drivers/isdn/isdnloop/isdnloop.c
@@ -100,12 +100,11 @@ isdnloop_pollbchan(unsigned long data)
100 isdnloop_bchan_send(card, 1); 100 isdnloop_bchan_send(card, 1);
101 if (card->flags & (ISDNLOOP_FLAGS_B1ACTIVE | ISDNLOOP_FLAGS_B2ACTIVE)) { 101 if (card->flags & (ISDNLOOP_FLAGS_B1ACTIVE | ISDNLOOP_FLAGS_B2ACTIVE)) {
102 /* schedule b-channel polling again */ 102 /* schedule b-channel polling again */
103 save_flags(flags); 103 spin_lock_irqsave(&card->isdnloop_lock, flags);
104 cli();
105 card->rb_timer.expires = jiffies + ISDNLOOP_TIMER_BCREAD; 104 card->rb_timer.expires = jiffies + ISDNLOOP_TIMER_BCREAD;
106 add_timer(&card->rb_timer); 105 add_timer(&card->rb_timer);
107 card->flags |= ISDNLOOP_FLAGS_RBTIMER; 106 card->flags |= ISDNLOOP_FLAGS_RBTIMER;
108 restore_flags(flags); 107 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
109 } else 108 } else
110 card->flags &= ~ISDNLOOP_FLAGS_RBTIMER; 109 card->flags &= ~ISDNLOOP_FLAGS_RBTIMER;
111} 110}
@@ -281,8 +280,7 @@ isdnloop_putmsg(isdnloop_card * card, unsigned char c)
281{ 280{
282 ulong flags; 281 ulong flags;
283 282
284 save_flags(flags); 283 spin_lock_irqsave(&card->isdnloop_lock, flags);
285 cli();
286 *card->msg_buf_write++ = (c == 0xff) ? '\n' : c; 284 *card->msg_buf_write++ = (c == 0xff) ? '\n' : c;
287 if (card->msg_buf_write == card->msg_buf_read) { 285 if (card->msg_buf_write == card->msg_buf_read) {
288 if (++card->msg_buf_read > card->msg_buf_end) 286 if (++card->msg_buf_read > card->msg_buf_end)
@@ -290,7 +288,7 @@ isdnloop_putmsg(isdnloop_card * card, unsigned char c)
290 } 288 }
291 if (card->msg_buf_write > card->msg_buf_end) 289 if (card->msg_buf_write > card->msg_buf_end)
292 card->msg_buf_write = card->msg_buf; 290 card->msg_buf_write = card->msg_buf;
293 restore_flags(flags); 291 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
294} 292}
295 293
296/* 294/*
@@ -372,21 +370,19 @@ isdnloop_polldchan(unsigned long data)
372 if (!(card->flags & ISDNLOOP_FLAGS_RBTIMER)) { 370 if (!(card->flags & ISDNLOOP_FLAGS_RBTIMER)) {
373 /* schedule b-channel polling */ 371 /* schedule b-channel polling */
374 card->flags |= ISDNLOOP_FLAGS_RBTIMER; 372 card->flags |= ISDNLOOP_FLAGS_RBTIMER;
375 save_flags(flags); 373 spin_lock_irqsave(&card->isdnloop_lock, flags);
376 cli();
377 del_timer(&card->rb_timer); 374 del_timer(&card->rb_timer);
378 card->rb_timer.function = isdnloop_pollbchan; 375 card->rb_timer.function = isdnloop_pollbchan;
379 card->rb_timer.data = (unsigned long) card; 376 card->rb_timer.data = (unsigned long) card;
380 card->rb_timer.expires = jiffies + ISDNLOOP_TIMER_BCREAD; 377 card->rb_timer.expires = jiffies + ISDNLOOP_TIMER_BCREAD;
381 add_timer(&card->rb_timer); 378 add_timer(&card->rb_timer);
382 restore_flags(flags); 379 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
383 } 380 }
384 /* schedule again */ 381 /* schedule again */
385 save_flags(flags); 382 spin_lock_irqsave(&card->isdnloop_lock, flags);
386 cli();
387 card->st_timer.expires = jiffies + ISDNLOOP_TIMER_DCREAD; 383 card->st_timer.expires = jiffies + ISDNLOOP_TIMER_DCREAD;
388 add_timer(&card->st_timer); 384 add_timer(&card->st_timer);
389 restore_flags(flags); 385 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
390} 386}
391 387
392/* 388/*
@@ -416,8 +412,7 @@ isdnloop_sendbuf(int channel, struct sk_buff *skb, isdnloop_card * card)
416 return 0; 412 return 0;
417 if (card->sndcount[channel] > ISDNLOOP_MAX_SQUEUE) 413 if (card->sndcount[channel] > ISDNLOOP_MAX_SQUEUE)
418 return 0; 414 return 0;
419 save_flags(flags); 415 spin_lock_irqsave(&card->isdnloop_lock, flags);
420 cli();
421 nskb = dev_alloc_skb(skb->len); 416 nskb = dev_alloc_skb(skb->len);
422 if (nskb) { 417 if (nskb) {
423 memcpy(skb_put(nskb, len), skb->data, len); 418 memcpy(skb_put(nskb, len), skb->data, len);
@@ -426,7 +421,7 @@ isdnloop_sendbuf(int channel, struct sk_buff *skb, isdnloop_card * card)
426 } else 421 } else
427 len = 0; 422 len = 0;
428 card->sndcount[channel] += len; 423 card->sndcount[channel] += len;
429 restore_flags(flags); 424 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
430 } 425 }
431 return len; 426 return len;
432} 427}
@@ -451,7 +446,8 @@ isdnloop_readstatus(u_char __user *buf, int len, isdnloop_card * card)
451 for (p = buf, count = 0; count < len; p++, count++) { 446 for (p = buf, count = 0; count < len; p++, count++) {
452 if (card->msg_buf_read == card->msg_buf_write) 447 if (card->msg_buf_read == card->msg_buf_write)
453 return count; 448 return count;
454 put_user(*card->msg_buf_read++, p); 449 if (put_user(*card->msg_buf_read++, p))
450 return -EFAULT;
455 if (card->msg_buf_read > card->msg_buf_end) 451 if (card->msg_buf_read > card->msg_buf_end)
456 card->msg_buf_read = card->msg_buf; 452 card->msg_buf_read = card->msg_buf;
457 } 453 }
@@ -576,8 +572,7 @@ isdnloop_atimeout(isdnloop_card * card, int ch)
576 unsigned long flags; 572 unsigned long flags;
577 char buf[60]; 573 char buf[60];
578 574
579 save_flags(flags); 575 spin_lock_irqsave(&card->isdnloop_lock, flags);
580 cli();
581 if (card->rcard) { 576 if (card->rcard) {
582 isdnloop_fake(card->rcard[ch], "DDIS_I", card->rch[ch] + 1); 577 isdnloop_fake(card->rcard[ch], "DDIS_I", card->rch[ch] + 1);
583 card->rcard[ch]->rcard[card->rch[ch]] = NULL; 578 card->rcard[ch]->rcard[card->rch[ch]] = NULL;
@@ -587,7 +582,7 @@ isdnloop_atimeout(isdnloop_card * card, int ch)
587 /* No user responding */ 582 /* No user responding */
588 sprintf(buf, "CAU%s", isdnloop_unicause(card, 1, 3)); 583 sprintf(buf, "CAU%s", isdnloop_unicause(card, 1, 3));
589 isdnloop_fake(card, buf, ch + 1); 584 isdnloop_fake(card, buf, ch + 1);
590 restore_flags(flags); 585 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
591} 586}
592 587
593/* 588/*
@@ -622,8 +617,7 @@ isdnloop_start_ctimer(isdnloop_card * card, int ch)
622{ 617{
623 unsigned long flags; 618 unsigned long flags;
624 619
625 save_flags(flags); 620 spin_lock_irqsave(&card->isdnloop_lock, flags);
626 cli();
627 init_timer(&card->c_timer[ch]); 621 init_timer(&card->c_timer[ch]);
628 card->c_timer[ch].expires = jiffies + ISDNLOOP_TIMER_ALERTWAIT; 622 card->c_timer[ch].expires = jiffies + ISDNLOOP_TIMER_ALERTWAIT;
629 if (ch) 623 if (ch)
@@ -632,7 +626,7 @@ isdnloop_start_ctimer(isdnloop_card * card, int ch)
632 card->c_timer[ch].function = isdnloop_atimeout0; 626 card->c_timer[ch].function = isdnloop_atimeout0;
633 card->c_timer[ch].data = (unsigned long) card; 627 card->c_timer[ch].data = (unsigned long) card;
634 add_timer(&card->c_timer[ch]); 628 add_timer(&card->c_timer[ch]);
635 restore_flags(flags); 629 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
636} 630}
637 631
638/* 632/*
@@ -647,10 +641,9 @@ isdnloop_kill_ctimer(isdnloop_card * card, int ch)
647{ 641{
648 unsigned long flags; 642 unsigned long flags;
649 643
650 save_flags(flags); 644 spin_lock_irqsave(&card->isdnloop_lock, flags);
651 cli();
652 del_timer(&card->c_timer[ch]); 645 del_timer(&card->c_timer[ch]);
653 restore_flags(flags); 646 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
654} 647}
655 648
656static u_char si2bit[] = 649static u_char si2bit[] =
@@ -706,13 +699,12 @@ isdnloop_try_call(isdnloop_card * card, char *p, int lch, isdn_ctrl * cmd)
706 } 699 }
707 } 700 }
708 if (num_match) { 701 if (num_match) {
709 save_flags(flags); 702 spin_lock_irqsave(&card->isdnloop_lock, flags);
710 cli();
711 /* channel idle? */ 703 /* channel idle? */
712 if (!(cc->rcard[ch])) { 704 if (!(cc->rcard[ch])) {
713 /* Check SI */ 705 /* Check SI */
714 if (!(si2bit[cmd->parm.setup.si1] & cc->sil[ch])) { 706 if (!(si2bit[cmd->parm.setup.si1] & cc->sil[ch])) {
715 restore_flags(flags); 707 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
716 return 3; 708 return 3;
717 } 709 }
718 /* ch is idle, si and number matches */ 710 /* ch is idle, si and number matches */
@@ -720,10 +712,10 @@ isdnloop_try_call(isdnloop_card * card, char *p, int lch, isdn_ctrl * cmd)
720 cc->rch[ch] = lch; 712 cc->rch[ch] = lch;
721 card->rcard[lch] = cc; 713 card->rcard[lch] = cc;
722 card->rch[lch] = ch; 714 card->rch[lch] = ch;
723 restore_flags(flags); 715 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
724 return 0; 716 return 0;
725 } else { 717 } else {
726 restore_flags(flags); 718 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
727 /* num matches, but busy */ 719 /* num matches, but busy */
728 if (ch == 1) 720 if (ch == 1)
729 return 1; 721 return 1;
@@ -1027,8 +1019,7 @@ isdnloop_stopcard(isdnloop_card * card)
1027 unsigned long flags; 1019 unsigned long flags;
1028 isdn_ctrl cmd; 1020 isdn_ctrl cmd;
1029 1021
1030 save_flags(flags); 1022 spin_lock_irqsave(&card->isdnloop_lock, flags);
1031 cli();
1032 if (card->flags & ISDNLOOP_FLAGS_RUNNING) { 1023 if (card->flags & ISDNLOOP_FLAGS_RUNNING) {
1033 card->flags &= ~ISDNLOOP_FLAGS_RUNNING; 1024 card->flags &= ~ISDNLOOP_FLAGS_RUNNING;
1034 del_timer(&card->st_timer); 1025 del_timer(&card->st_timer);
@@ -1039,7 +1030,7 @@ isdnloop_stopcard(isdnloop_card * card)
1039 cmd.driver = card->myid; 1030 cmd.driver = card->myid;
1040 card->interface.statcallb(&cmd); 1031 card->interface.statcallb(&cmd);
1041 } 1032 }
1042 restore_flags(flags); 1033 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
1043} 1034}
1044 1035
1045/* 1036/*
@@ -1078,18 +1069,17 @@ isdnloop_start(isdnloop_card * card, isdnloop_sdef * sdefp)
1078 return -EBUSY; 1069 return -EBUSY;
1079 if (copy_from_user((char *) &sdef, (char *) sdefp, sizeof(sdef))) 1070 if (copy_from_user((char *) &sdef, (char *) sdefp, sizeof(sdef)))
1080 return -EFAULT; 1071 return -EFAULT;
1081 save_flags(flags); 1072 spin_lock_irqsave(&card->isdnloop_lock, flags);
1082 cli();
1083 switch (sdef.ptype) { 1073 switch (sdef.ptype) {
1084 case ISDN_PTYPE_EURO: 1074 case ISDN_PTYPE_EURO:
1085 if (isdnloop_fake(card, "DRV1.23EC-Q.931-CAPI-CNS-BASIS-20.02.96", 1075 if (isdnloop_fake(card, "DRV1.23EC-Q.931-CAPI-CNS-BASIS-20.02.96",
1086 -1)) { 1076 -1)) {
1087 restore_flags(flags); 1077 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
1088 return -ENOMEM; 1078 return -ENOMEM;
1089 } 1079 }
1090 card->sil[0] = card->sil[1] = 4; 1080 card->sil[0] = card->sil[1] = 4;
1091 if (isdnloop_fake(card, "TEI OK", 0)) { 1081 if (isdnloop_fake(card, "TEI OK", 0)) {
1092 restore_flags(flags); 1082 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
1093 return -ENOMEM; 1083 return -ENOMEM;
1094 } 1084 }
1095 for (i = 0; i < 3; i++) 1085 for (i = 0; i < 3; i++)
@@ -1098,12 +1088,12 @@ isdnloop_start(isdnloop_card * card, isdnloop_sdef * sdefp)
1098 case ISDN_PTYPE_1TR6: 1088 case ISDN_PTYPE_1TR6:
1099 if (isdnloop_fake(card, "DRV1.04TC-1TR6-CAPI-CNS-BASIS-29.11.95", 1089 if (isdnloop_fake(card, "DRV1.04TC-1TR6-CAPI-CNS-BASIS-29.11.95",
1100 -1)) { 1090 -1)) {
1101 restore_flags(flags); 1091 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
1102 return -ENOMEM; 1092 return -ENOMEM;
1103 } 1093 }
1104 card->sil[0] = card->sil[1] = 4; 1094 card->sil[0] = card->sil[1] = 4;
1105 if (isdnloop_fake(card, "TEI OK", 0)) { 1095 if (isdnloop_fake(card, "TEI OK", 0)) {
1106 restore_flags(flags); 1096 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
1107 return -ENOMEM; 1097 return -ENOMEM;
1108 } 1098 }
1109 strcpy(card->s0num[0], sdef.num[0]); 1099 strcpy(card->s0num[0], sdef.num[0]);
@@ -1111,7 +1101,7 @@ isdnloop_start(isdnloop_card * card, isdnloop_sdef * sdefp)
1111 card->s0num[2][0] = '\0'; 1101 card->s0num[2][0] = '\0';
1112 break; 1102 break;
1113 default: 1103 default:
1114 restore_flags(flags); 1104 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
1115 printk(KERN_WARNING "isdnloop: Illegal D-channel protocol %d\n", 1105 printk(KERN_WARNING "isdnloop: Illegal D-channel protocol %d\n",
1116 sdef.ptype); 1106 sdef.ptype);
1117 return -EINVAL; 1107 return -EINVAL;
@@ -1122,7 +1112,7 @@ isdnloop_start(isdnloop_card * card, isdnloop_sdef * sdefp)
1122 card->st_timer.data = (unsigned long) card; 1112 card->st_timer.data = (unsigned long) card;
1123 add_timer(&card->st_timer); 1113 add_timer(&card->st_timer);
1124 card->flags |= ISDNLOOP_FLAGS_RUNNING; 1114 card->flags |= ISDNLOOP_FLAGS_RUNNING;
1125 restore_flags(flags); 1115 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
1126 return 0; 1116 return 0;
1127} 1117}
1128 1118
@@ -1472,6 +1462,7 @@ isdnloop_initcard(char *id)
1472 skb_queue_head_init(&card->bqueue[i]); 1462 skb_queue_head_init(&card->bqueue[i]);
1473 } 1463 }
1474 skb_queue_head_init(&card->dqueue); 1464 skb_queue_head_init(&card->dqueue);
1465 card->isdnloop_lock = SPIN_LOCK_UNLOCKED;
1475 card->next = cards; 1466 card->next = cards;
1476 cards = card; 1467 cards = card;
1477 if (!register_isdn(&card->interface)) { 1468 if (!register_isdn(&card->interface)) {
diff --git a/drivers/isdn/isdnloop/isdnloop.h b/drivers/isdn/isdnloop/isdnloop.h
index d699fe53e1c3..0d458a86f529 100644
--- a/drivers/isdn/isdnloop/isdnloop.h
+++ b/drivers/isdn/isdnloop/isdnloop.h
@@ -94,6 +94,7 @@ typedef struct isdnloop_card {
94 struct sk_buff_head 94 struct sk_buff_head
95 bqueue[ISDNLOOP_BCH]; /* B-Channel queues */ 95 bqueue[ISDNLOOP_BCH]; /* B-Channel queues */
96 struct sk_buff_head dqueue; /* D-Channel queue */ 96 struct sk_buff_head dqueue; /* D-Channel queue */
97 spinlock_t isdnloop_lock;
97} isdnloop_card; 98} isdnloop_card;
98 99
99/* 100/*
diff --git a/drivers/isdn/pcbit/drv.c b/drivers/isdn/pcbit/drv.c
index 94f21486bb24..6ead5e1508b7 100644
--- a/drivers/isdn/pcbit/drv.c
+++ b/drivers/isdn/pcbit/drv.c
@@ -725,23 +725,27 @@ static int pcbit_stat(u_char __user *buf, int len, int driver, int channel)
725 725
726 if (stat_st < stat_end) 726 if (stat_st < stat_end)
727 { 727 {
728 copy_to_user(buf, statbuf + stat_st, len); 728 if (copy_to_user(buf, statbuf + stat_st, len))
729 return -EFAULT;
729 stat_st += len; 730 stat_st += len;
730 } 731 }
731 else 732 else
732 { 733 {
733 if (len > STATBUF_LEN - stat_st) 734 if (len > STATBUF_LEN - stat_st)
734 { 735 {
735 copy_to_user(buf, statbuf + stat_st, 736 if (copy_to_user(buf, statbuf + stat_st,
736 STATBUF_LEN - stat_st); 737 STATBUF_LEN - stat_st))
737 copy_to_user(buf, statbuf, 738 return -EFAULT;
738 len - (STATBUF_LEN - stat_st)); 739 if (copy_to_user(buf, statbuf,
740 len - (STATBUF_LEN - stat_st)))
741 return -EFAULT;
739 742
740 stat_st = len - (STATBUF_LEN - stat_st); 743 stat_st = len - (STATBUF_LEN - stat_st);
741 } 744 }
742 else 745 else
743 { 746 {
744 copy_to_user(buf, statbuf + stat_st, len); 747 if (copy_to_user(buf, statbuf + stat_st, len))
748 return -EFAULT;
745 749
746 stat_st += len; 750 stat_st += len;
747 751
diff --git a/drivers/isdn/pcbit/layer2.c b/drivers/isdn/pcbit/layer2.c
index 13e7d219d1c7..937fd2120381 100644
--- a/drivers/isdn/pcbit/layer2.c
+++ b/drivers/isdn/pcbit/layer2.c
@@ -311,6 +311,7 @@ pcbit_deliver(void *data)
311 dev->read_queue = frame->next; 311 dev->read_queue = frame->next;
312 spin_unlock_irqrestore(&dev->lock, flags); 312 spin_unlock_irqrestore(&dev->lock, flags);
313 313
314 msg = 0;
314 SET_MSG_CPU(msg, 0); 315 SET_MSG_CPU(msg, 0);
315 SET_MSG_PROC(msg, 0); 316 SET_MSG_PROC(msg, 0);
316 SET_MSG_CMD(msg, frame->skb->data[2]); 317 SET_MSG_CMD(msg, frame->skb->data[2]);
diff --git a/drivers/isdn/sc/init.c b/drivers/isdn/sc/init.c
index 222ca7c08baa..06c9872e8c6a 100644
--- a/drivers/isdn/sc/init.c
+++ b/drivers/isdn/sc/init.c
@@ -98,13 +98,14 @@ static int __init sc_init(void)
98 * Confirm the I/O Address with a test 98 * Confirm the I/O Address with a test
99 */ 99 */
100 if(io[b] == 0) { 100 if(io[b] == 0) {
101 pr_debug("I/O Address 0x%x is in use.\n"); 101 pr_debug("I/O Address invalid.\n");
102 continue; 102 continue;
103 } 103 }
104 104
105 outb(0x18, io[b] + 0x400 * EXP_PAGE0); 105 outb(0x18, io[b] + 0x400 * EXP_PAGE0);
106 if(inb(io[b] + 0x400 * EXP_PAGE0) != 0x18) { 106 if(inb(io[b] + 0x400 * EXP_PAGE0) != 0x18) {
107 pr_debug("I/O Base 0x%x fails test\n"); 107 pr_debug("I/O Base 0x%x fails test\n",
108 io[b] + 0x400 * EXP_PAGE0);
108 continue; 109 continue;
109 } 110 }
110 } 111 }
@@ -158,8 +159,8 @@ static int __init sc_init(void)
158 outb(0xFF, io[b] + RESET_OFFSET); 159 outb(0xFF, io[b] + RESET_OFFSET);
159 msleep_interruptible(10000); 160 msleep_interruptible(10000);
160 } 161 }
161 pr_debug("RAM Base for board %d is 0x%x, %s probe\n", b, ram[b], 162 pr_debug("RAM Base for board %d is 0x%lx, %s probe\n", b,
162 ram[b] == 0 ? "will" : "won't"); 163 ram[b], ram[b] == 0 ? "will" : "won't");
163 164
164 if(ram[b]) { 165 if(ram[b]) {
165 /* 166 /*
@@ -168,7 +169,7 @@ static int __init sc_init(void)
168 * board model 169 * board model
169 */ 170 */
170 if(request_region(ram[b], SRAM_PAGESIZE, "sc test")) { 171 if(request_region(ram[b], SRAM_PAGESIZE, "sc test")) {
171 pr_debug("request_region for RAM base 0x%x succeeded\n", ram[b]); 172 pr_debug("request_region for RAM base 0x%lx succeeded\n", ram[b]);
172 model = identify_board(ram[b], io[b]); 173 model = identify_board(ram[b], io[b]);
173 release_region(ram[b], SRAM_PAGESIZE); 174 release_region(ram[b], SRAM_PAGESIZE);
174 } 175 }
@@ -204,7 +205,7 @@ static int __init sc_init(void)
204 * Nope, there was no place in RAM for the 205 * Nope, there was no place in RAM for the
205 * board, or it couldn't be identified 206 * board, or it couldn't be identified
206 */ 207 */
207 pr_debug("Failed to find an adapter at 0x%x\n", ram[b]); 208 pr_debug("Failed to find an adapter at 0x%lx\n", ram[b]);
208 continue; 209 continue;
209 } 210 }
210 211
@@ -451,7 +452,7 @@ static int identify_board(unsigned long rambase, unsigned int iobase)
451 HWConfig_pl hwci; 452 HWConfig_pl hwci;
452 int x; 453 int x;
453 454
454 pr_debug("Attempting to identify adapter @ 0x%x io 0x%x\n", 455 pr_debug("Attempting to identify adapter @ 0x%lx io 0x%x\n",
455 rambase, iobase); 456 rambase, iobase);
456 457
457 /* 458 /*
@@ -490,7 +491,7 @@ static int identify_board(unsigned long rambase, unsigned int iobase)
490 outb(PRI_BASEPG_VAL, pgport); 491 outb(PRI_BASEPG_VAL, pgport);
491 msleep_interruptible(1000); 492 msleep_interruptible(1000);
492 sig = readl(rambase + SIG_OFFSET); 493 sig = readl(rambase + SIG_OFFSET);
493 pr_debug("Looking for a signature, got 0x%x\n", sig); 494 pr_debug("Looking for a signature, got 0x%lx\n", sig);
494 if(sig == SIGNATURE) 495 if(sig == SIGNATURE)
495 return PRI_BOARD; 496 return PRI_BOARD;
496 497
@@ -500,7 +501,7 @@ static int identify_board(unsigned long rambase, unsigned int iobase)
500 outb(BRI_BASEPG_VAL, pgport); 501 outb(BRI_BASEPG_VAL, pgport);
501 msleep_interruptible(1000); 502 msleep_interruptible(1000);
502 sig = readl(rambase + SIG_OFFSET); 503 sig = readl(rambase + SIG_OFFSET);
503 pr_debug("Looking for a signature, got 0x%x\n", sig); 504 pr_debug("Looking for a signature, got 0x%lx\n", sig);
504 if(sig == SIGNATURE) 505 if(sig == SIGNATURE)
505 return BRI_BOARD; 506 return BRI_BOARD;
506 507
@@ -510,7 +511,7 @@ static int identify_board(unsigned long rambase, unsigned int iobase)
510 * Try to spot a card 511 * Try to spot a card
511 */ 512 */
512 sig = readl(rambase + SIG_OFFSET); 513 sig = readl(rambase + SIG_OFFSET);
513 pr_debug("Looking for a signature, got 0x%x\n", sig); 514 pr_debug("Looking for a signature, got 0x%lx\n", sig);
514 if(sig != SIGNATURE) 515 if(sig != SIGNATURE)
515 return -1; 516 return -1;
516 517
@@ -540,7 +541,7 @@ static int identify_board(unsigned long rambase, unsigned int iobase)
540 memcpy_fromio(&rcvmsg, &(dpm->rsp_queue[dpm->rsp_tail]), MSG_LEN); 541 memcpy_fromio(&rcvmsg, &(dpm->rsp_queue[dpm->rsp_tail]), MSG_LEN);
541 pr_debug("Got HWConfig response, status = 0x%x\n", rcvmsg.rsp_status); 542 pr_debug("Got HWConfig response, status = 0x%x\n", rcvmsg.rsp_status);
542 memcpy(&hwci, &(rcvmsg.msg_data.HWCresponse), sizeof(HWConfig_pl)); 543 memcpy(&hwci, &(rcvmsg.msg_data.HWCresponse), sizeof(HWConfig_pl));
543 pr_debug("Hardware Config: Interface: %s, RAM Size: %d, Serial: %s\n" 544 pr_debug("Hardware Config: Interface: %s, RAM Size: %ld, Serial: %s\n"
544 " Part: %s, Rev: %s\n", 545 " Part: %s, Rev: %s\n",
545 hwci.st_u_sense ? "S/T" : "U", hwci.ram_size, 546 hwci.st_u_sense ? "S/T" : "U", hwci.ram_size,
546 hwci.serial_no, hwci.part_no, hwci.rev_no); 547 hwci.serial_no, hwci.part_no, hwci.rev_no);
diff --git a/drivers/isdn/sc/packet.c b/drivers/isdn/sc/packet.c
index f50defc38ae5..1e04676b016b 100644
--- a/drivers/isdn/sc/packet.c
+++ b/drivers/isdn/sc/packet.c
@@ -44,7 +44,7 @@ int sndpkt(int devId, int channel, struct sk_buff *data)
44 return -ENODEV; 44 return -ENODEV;
45 } 45 }
46 46
47 pr_debug("%s: sndpkt: frst = 0x%x nxt = %d f = %d n = %d\n", 47 pr_debug("%s: sndpkt: frst = 0x%lx nxt = %d f = %d n = %d\n",
48 sc_adapter[card]->devicename, 48 sc_adapter[card]->devicename,
49 sc_adapter[card]->channel[channel].first_sendbuf, 49 sc_adapter[card]->channel[channel].first_sendbuf,
50 sc_adapter[card]->channel[channel].next_sendbuf, 50 sc_adapter[card]->channel[channel].next_sendbuf,
@@ -66,7 +66,7 @@ int sndpkt(int devId, int channel, struct sk_buff *data)
66 ReqLnkWrite.buff_offset = sc_adapter[card]->channel[channel].next_sendbuf * 66 ReqLnkWrite.buff_offset = sc_adapter[card]->channel[channel].next_sendbuf *
67 BUFFER_SIZE + sc_adapter[card]->channel[channel].first_sendbuf; 67 BUFFER_SIZE + sc_adapter[card]->channel[channel].first_sendbuf;
68 ReqLnkWrite.msg_len = data->len; /* sk_buff size */ 68 ReqLnkWrite.msg_len = data->len; /* sk_buff size */
69 pr_debug("%s: writing %d bytes to buffer offset 0x%x\n", 69 pr_debug("%s: writing %d bytes to buffer offset 0x%lx\n",
70 sc_adapter[card]->devicename, 70 sc_adapter[card]->devicename,
71 ReqLnkWrite.msg_len, ReqLnkWrite.buff_offset); 71 ReqLnkWrite.msg_len, ReqLnkWrite.buff_offset);
72 memcpy_toshmem(card, (char *)ReqLnkWrite.buff_offset, data->data, ReqLnkWrite.msg_len); 72 memcpy_toshmem(card, (char *)ReqLnkWrite.buff_offset, data->data, ReqLnkWrite.msg_len);
@@ -74,7 +74,7 @@ int sndpkt(int devId, int channel, struct sk_buff *data)
74 /* 74 /*
75 * sendmessage 75 * sendmessage
76 */ 76 */
77 pr_debug("%s: sndpkt size=%d, buf_offset=0x%x buf_indx=%d\n", 77 pr_debug("%s: sndpkt size=%d, buf_offset=0x%lx buf_indx=%d\n",
78 sc_adapter[card]->devicename, 78 sc_adapter[card]->devicename,
79 ReqLnkWrite.msg_len, ReqLnkWrite.buff_offset, 79 ReqLnkWrite.msg_len, ReqLnkWrite.buff_offset,
80 sc_adapter[card]->channel[channel].next_sendbuf); 80 sc_adapter[card]->channel[channel].next_sendbuf);
@@ -124,7 +124,7 @@ void rcvpkt(int card, RspMessage *rcvmsg)
124 return; 124 return;
125 } 125 }
126 skb_put(skb, rcvmsg->msg_data.response.msg_len); 126 skb_put(skb, rcvmsg->msg_data.response.msg_len);
127 pr_debug("%s: getting data from offset: 0x%x\n", 127 pr_debug("%s: getting data from offset: 0x%lx\n",
128 sc_adapter[card]->devicename, 128 sc_adapter[card]->devicename,
129 rcvmsg->msg_data.response.buff_offset); 129 rcvmsg->msg_data.response.buff_offset);
130 memcpy_fromshmem(card, 130 memcpy_fromshmem(card,
@@ -143,7 +143,7 @@ void rcvpkt(int card, RspMessage *rcvmsg)
143/* memset_shmem(card, rcvmsg->msg_data.response.buff_offset, 0, BUFFER_SIZE); */ 143/* memset_shmem(card, rcvmsg->msg_data.response.buff_offset, 0, BUFFER_SIZE); */
144 newll.buff_offset = rcvmsg->msg_data.response.buff_offset; 144 newll.buff_offset = rcvmsg->msg_data.response.buff_offset;
145 newll.msg_len = BUFFER_SIZE; 145 newll.msg_len = BUFFER_SIZE;
146 pr_debug("%s: recycled buffer at offset 0x%x size %d\n", 146 pr_debug("%s: recycled buffer at offset 0x%lx size %d\n",
147 sc_adapter[card]->devicename, 147 sc_adapter[card]->devicename,
148 newll.buff_offset, newll.msg_len); 148 newll.buff_offset, newll.msg_len);
149 sendmessage(card, CEPID, ceReqTypeLnk, ceReqClass1, ceReqLnkRead, 149 sendmessage(card, CEPID, ceReqTypeLnk, ceReqClass1, ceReqLnkRead,
@@ -186,7 +186,7 @@ int setup_buffers(int card, int c)
186 sc_adapter[card]->channel[c-1].num_sendbufs = nBuffers / 2; 186 sc_adapter[card]->channel[c-1].num_sendbufs = nBuffers / 2;
187 sc_adapter[card]->channel[c-1].free_sendbufs = nBuffers / 2; 187 sc_adapter[card]->channel[c-1].free_sendbufs = nBuffers / 2;
188 sc_adapter[card]->channel[c-1].next_sendbuf = 0; 188 sc_adapter[card]->channel[c-1].next_sendbuf = 0;
189 pr_debug("%s: send buffer setup complete: first=0x%x n=%d f=%d, nxt=%d\n", 189 pr_debug("%s: send buffer setup complete: first=0x%lx n=%d f=%d, nxt=%d\n",
190 sc_adapter[card]->devicename, 190 sc_adapter[card]->devicename,
191 sc_adapter[card]->channel[c-1].first_sendbuf, 191 sc_adapter[card]->channel[c-1].first_sendbuf,
192 sc_adapter[card]->channel[c-1].num_sendbufs, 192 sc_adapter[card]->channel[c-1].num_sendbufs,
@@ -203,7 +203,7 @@ int setup_buffers(int card, int c)
203 ((sc_adapter[card]->channel[c-1].first_sendbuf + 203 ((sc_adapter[card]->channel[c-1].first_sendbuf +
204 (nBuffers / 2) * buffer_size) + (buffer_size * i)); 204 (nBuffers / 2) * buffer_size) + (buffer_size * i));
205 RcvBuffOffset.msg_len = buffer_size; 205 RcvBuffOffset.msg_len = buffer_size;
206 pr_debug("%s: adding RcvBuffer #%d offset=0x%x sz=%d bufsz:%d\n", 206 pr_debug("%s: adding RcvBuffer #%d offset=0x%lx sz=%d bufsz:%d\n",
207 sc_adapter[card]->devicename, 207 sc_adapter[card]->devicename,
208 i + 1, RcvBuffOffset.buff_offset, 208 i + 1, RcvBuffOffset.buff_offset,
209 RcvBuffOffset.msg_len,buffer_size); 209 RcvBuffOffset.msg_len,buffer_size);
diff --git a/drivers/isdn/sc/shmem.c b/drivers/isdn/sc/shmem.c
index 24854826ca45..6f58862992db 100644
--- a/drivers/isdn/sc/shmem.c
+++ b/drivers/isdn/sc/shmem.c
@@ -61,7 +61,7 @@ void memcpy_toshmem(int card, void *dest, const void *src, size_t n)
61 spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); 61 spin_unlock_irqrestore(&sc_adapter[card]->lock, flags);
62 pr_debug("%s: set page to %#x\n",sc_adapter[card]->devicename, 62 pr_debug("%s: set page to %#x\n",sc_adapter[card]->devicename,
63 ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80); 63 ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80);
64 pr_debug("%s: copying %d bytes from %#x to %#x\n", 64 pr_debug("%s: copying %d bytes from %#lx to %#lx\n",
65 sc_adapter[card]->devicename, n, 65 sc_adapter[card]->devicename, n,
66 (unsigned long) src, 66 (unsigned long) src,
67 sc_adapter[card]->rambase + ((unsigned long) dest %0x4000)); 67 sc_adapter[card]->rambase + ((unsigned long) dest %0x4000));
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index aecbbe2e89a9..3c1711210e38 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -91,6 +91,8 @@ EXPORT_SYMBOL_GPL(led_classdev_resume);
91 */ 91 */
92int led_classdev_register(struct device *parent, struct led_classdev *led_cdev) 92int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
93{ 93{
94 int rc;
95
94 led_cdev->class_dev = class_device_create(leds_class, NULL, 0, 96 led_cdev->class_dev = class_device_create(leds_class, NULL, 0,
95 parent, "%s", led_cdev->name); 97 parent, "%s", led_cdev->name);
96 if (unlikely(IS_ERR(led_cdev->class_dev))) 98 if (unlikely(IS_ERR(led_cdev->class_dev)))
@@ -99,8 +101,10 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
99 class_set_devdata(led_cdev->class_dev, led_cdev); 101 class_set_devdata(led_cdev->class_dev, led_cdev);
100 102
101 /* register the attributes */ 103 /* register the attributes */
102 class_device_create_file(led_cdev->class_dev, 104 rc = class_device_create_file(led_cdev->class_dev,
103 &class_device_attr_brightness); 105 &class_device_attr_brightness);
106 if (rc)
107 goto err_out;
104 108
105 /* add to the list of leds */ 109 /* add to the list of leds */
106 write_lock(&leds_list_lock); 110 write_lock(&leds_list_lock);
@@ -110,16 +114,28 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
110#ifdef CONFIG_LEDS_TRIGGERS 114#ifdef CONFIG_LEDS_TRIGGERS
111 rwlock_init(&led_cdev->trigger_lock); 115 rwlock_init(&led_cdev->trigger_lock);
112 116
113 led_trigger_set_default(led_cdev); 117 rc = class_device_create_file(led_cdev->class_dev,
118 &class_device_attr_trigger);
119 if (rc)
120 goto err_out_led_list;
114 121
115 class_device_create_file(led_cdev->class_dev, 122 led_trigger_set_default(led_cdev);
116 &class_device_attr_trigger);
117#endif 123#endif
118 124
119 printk(KERN_INFO "Registered led device: %s\n", 125 printk(KERN_INFO "Registered led device: %s\n",
120 led_cdev->class_dev->class_id); 126 led_cdev->class_dev->class_id);
121 127
122 return 0; 128 return 0;
129
130#ifdef CONFIG_LEDS_TRIGGERS
131err_out_led_list:
132 class_device_remove_file(led_cdev->class_dev,
133 &class_device_attr_brightness);
134 list_del(&led_cdev->node);
135#endif
136err_out:
137 class_device_unregister(led_cdev->class_dev);
138 return rc;
123} 139}
124EXPORT_SYMBOL_GPL(led_classdev_register); 140EXPORT_SYMBOL_GPL(led_classdev_register);
125 141
diff --git a/drivers/leds/ledtrig-timer.c b/drivers/leds/ledtrig-timer.c
index 179c2876b541..29a8818a32ec 100644
--- a/drivers/leds/ledtrig-timer.c
+++ b/drivers/leds/ledtrig-timer.c
@@ -123,6 +123,7 @@ static CLASS_DEVICE_ATTR(delay_off, 0644, led_delay_off_show,
123static void timer_trig_activate(struct led_classdev *led_cdev) 123static void timer_trig_activate(struct led_classdev *led_cdev)
124{ 124{
125 struct timer_trig_data *timer_data; 125 struct timer_trig_data *timer_data;
126 int rc;
126 127
127 timer_data = kzalloc(sizeof(struct timer_trig_data), GFP_KERNEL); 128 timer_data = kzalloc(sizeof(struct timer_trig_data), GFP_KERNEL);
128 if (!timer_data) 129 if (!timer_data)
@@ -134,10 +135,21 @@ static void timer_trig_activate(struct led_classdev *led_cdev)
134 timer_data->timer.function = led_timer_function; 135 timer_data->timer.function = led_timer_function;
135 timer_data->timer.data = (unsigned long) led_cdev; 136 timer_data->timer.data = (unsigned long) led_cdev;
136 137
137 class_device_create_file(led_cdev->class_dev, 138 rc = class_device_create_file(led_cdev->class_dev,
138 &class_device_attr_delay_on); 139 &class_device_attr_delay_on);
139 class_device_create_file(led_cdev->class_dev, 140 if (rc) goto err_out;
141 rc = class_device_create_file(led_cdev->class_dev,
140 &class_device_attr_delay_off); 142 &class_device_attr_delay_off);
143 if (rc) goto err_out_delayon;
144
145 return;
146
147err_out_delayon:
148 class_device_remove_file(led_cdev->class_dev,
149 &class_device_attr_delay_on);
150err_out:
151 led_cdev->trigger_data = NULL;
152 kfree(timer_data);
141} 153}
142 154
143static void timer_trig_deactivate(struct led_classdev *led_cdev) 155static void timer_trig_deactivate(struct led_classdev *led_cdev)
diff --git a/drivers/macintosh/windfarm_pm112.c b/drivers/macintosh/windfarm_pm112.c
index fa4b13f89369..b3fbb45bc90a 100644
--- a/drivers/macintosh/windfarm_pm112.c
+++ b/drivers/macintosh/windfarm_pm112.c
@@ -685,6 +685,17 @@ static int __init wf_pm112_init(void)
685 ++nr_cores; 685 ++nr_cores;
686 686
687 printk(KERN_INFO "windfarm: initializing for dual-core desktop G5\n"); 687 printk(KERN_INFO "windfarm: initializing for dual-core desktop G5\n");
688
689#ifdef MODULE
690 request_module("windfarm_smu_controls");
691 request_module("windfarm_smu_sensors");
692 request_module("windfarm_smu_sat");
693 request_module("windfarm_lm75_sensor");
694 request_module("windfarm_max6690_sensor");
695 request_module("windfarm_cpufreq_clamp");
696
697#endif /* MODULE */
698
688 platform_driver_register(&wf_pm112_driver); 699 platform_driver_register(&wf_pm112_driver);
689 return 0; 700 return 0;
690} 701}
diff --git a/drivers/macintosh/windfarm_pm81.c b/drivers/macintosh/windfarm_pm81.c
index 2a944851b8e1..f24fa734046a 100644
--- a/drivers/macintosh/windfarm_pm81.c
+++ b/drivers/macintosh/windfarm_pm81.c
@@ -788,6 +788,7 @@ static int __init wf_smu_init(void)
788 request_module("windfarm_smu_controls"); 788 request_module("windfarm_smu_controls");
789 request_module("windfarm_smu_sensors"); 789 request_module("windfarm_smu_sensors");
790 request_module("windfarm_lm75_sensor"); 790 request_module("windfarm_lm75_sensor");
791 request_module("windfarm_cpufreq_clamp");
791 792
792#endif /* MODULE */ 793#endif /* MODULE */
793 platform_driver_register(&wf_smu_driver); 794 platform_driver_register(&wf_smu_driver);
diff --git a/drivers/macintosh/windfarm_pm91.c b/drivers/macintosh/windfarm_pm91.c
index 9961a67b4f85..26eee69ebe6d 100644
--- a/drivers/macintosh/windfarm_pm91.c
+++ b/drivers/macintosh/windfarm_pm91.c
@@ -719,6 +719,7 @@ static int __init wf_smu_init(void)
719 request_module("windfarm_smu_controls"); 719 request_module("windfarm_smu_controls");
720 request_module("windfarm_smu_sensors"); 720 request_module("windfarm_smu_sensors");
721 request_module("windfarm_lm75_sensor"); 721 request_module("windfarm_lm75_sensor");
722 request_module("windfarm_cpufreq_clamp");
722 723
723#endif /* MODULE */ 724#endif /* MODULE */
724 platform_driver_register(&wf_smu_driver); 725 platform_driver_register(&wf_smu_driver);
diff --git a/drivers/mca/mca-bus.c b/drivers/mca/mca-bus.c
index 09baa43b2599..da862e4632dd 100644
--- a/drivers/mca/mca-bus.c
+++ b/drivers/mca/mca-bus.c
@@ -100,6 +100,7 @@ static DEVICE_ATTR(pos, S_IRUGO, mca_show_pos, NULL);
100int __init mca_register_device(int bus, struct mca_device *mca_dev) 100int __init mca_register_device(int bus, struct mca_device *mca_dev)
101{ 101{
102 struct mca_bus *mca_bus = mca_root_busses[bus]; 102 struct mca_bus *mca_bus = mca_root_busses[bus];
103 int rc;
103 104
104 mca_dev->dev.parent = &mca_bus->dev; 105 mca_dev->dev.parent = &mca_bus->dev;
105 mca_dev->dev.bus = &mca_bus_type; 106 mca_dev->dev.bus = &mca_bus_type;
@@ -108,13 +109,23 @@ int __init mca_register_device(int bus, struct mca_device *mca_dev)
108 mca_dev->dev.dma_mask = &mca_dev->dma_mask; 109 mca_dev->dev.dma_mask = &mca_dev->dma_mask;
109 mca_dev->dev.coherent_dma_mask = mca_dev->dma_mask; 110 mca_dev->dev.coherent_dma_mask = mca_dev->dma_mask;
110 111
111 if (device_register(&mca_dev->dev)) 112 rc = device_register(&mca_dev->dev);
112 return 0; 113 if (rc)
114 goto err_out;
113 115
114 device_create_file(&mca_dev->dev, &dev_attr_id); 116 rc = device_create_file(&mca_dev->dev, &dev_attr_id);
115 device_create_file(&mca_dev->dev, &dev_attr_pos); 117 if (rc) goto err_out_devreg;
118 rc = device_create_file(&mca_dev->dev, &dev_attr_pos);
119 if (rc) goto err_out_id;
116 120
117 return 1; 121 return 1;
122
123err_out_id:
124 device_remove_file(&mca_dev->dev, &dev_attr_id);
125err_out_devreg:
126 device_unregister(&mca_dev->dev);
127err_out:
128 return 0;
118} 129}
119 130
120/* */ 131/* */
@@ -130,13 +141,16 @@ struct mca_bus * __devinit mca_attach_bus(int bus)
130 return NULL; 141 return NULL;
131 } 142 }
132 143
133 mca_bus = kmalloc(sizeof(struct mca_bus), GFP_KERNEL); 144 mca_bus = kzalloc(sizeof(struct mca_bus), GFP_KERNEL);
134 if (!mca_bus) 145 if (!mca_bus)
135 return NULL; 146 return NULL;
136 memset(mca_bus, 0, sizeof(struct mca_bus)); 147
137 sprintf(mca_bus->dev.bus_id,"mca%d",bus); 148 sprintf(mca_bus->dev.bus_id,"mca%d",bus);
138 sprintf(mca_bus->name,"Host %s MCA Bridge", bus ? "Secondary" : "Primary"); 149 sprintf(mca_bus->name,"Host %s MCA Bridge", bus ? "Secondary" : "Primary");
139 device_register(&mca_bus->dev); 150 if (device_register(&mca_bus->dev)) {
151 kfree(mca_bus);
152 return NULL;
153 }
140 154
141 mca_root_busses[bus] = mca_bus; 155 mca_root_busses[bus] = mca_bus;
142 156
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 8e67634e79a0..d6f614738bbd 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -536,7 +536,7 @@ static int bitmap_read_sb(struct bitmap *bitmap)
536 printk(KERN_INFO "%s: bitmap file is out of date (%llu < %llu) " 536 printk(KERN_INFO "%s: bitmap file is out of date (%llu < %llu) "
537 "-- forcing full recovery\n", bmname(bitmap), events, 537 "-- forcing full recovery\n", bmname(bitmap), events,
538 (unsigned long long) bitmap->mddev->events); 538 (unsigned long long) bitmap->mddev->events);
539 sb->state |= BITMAP_STALE; 539 sb->state |= cpu_to_le32(BITMAP_STALE);
540 } 540 }
541success: 541success:
542 /* assign fields using values from superblock */ 542 /* assign fields using values from superblock */
@@ -544,11 +544,11 @@ success:
544 bitmap->daemon_sleep = daemon_sleep; 544 bitmap->daemon_sleep = daemon_sleep;
545 bitmap->daemon_lastrun = jiffies; 545 bitmap->daemon_lastrun = jiffies;
546 bitmap->max_write_behind = write_behind; 546 bitmap->max_write_behind = write_behind;
547 bitmap->flags |= sb->state; 547 bitmap->flags |= le32_to_cpu(sb->state);
548 if (le32_to_cpu(sb->version) == BITMAP_MAJOR_HOSTENDIAN) 548 if (le32_to_cpu(sb->version) == BITMAP_MAJOR_HOSTENDIAN)
549 bitmap->flags |= BITMAP_HOSTENDIAN; 549 bitmap->flags |= BITMAP_HOSTENDIAN;
550 bitmap->events_cleared = le64_to_cpu(sb->events_cleared); 550 bitmap->events_cleared = le64_to_cpu(sb->events_cleared);
551 if (sb->state & BITMAP_STALE) 551 if (sb->state & cpu_to_le32(BITMAP_STALE))
552 bitmap->events_cleared = bitmap->mddev->events; 552 bitmap->events_cleared = bitmap->mddev->events;
553 err = 0; 553 err = 0;
554out: 554out:
@@ -578,9 +578,9 @@ static void bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits,
578 spin_unlock_irqrestore(&bitmap->lock, flags); 578 spin_unlock_irqrestore(&bitmap->lock, flags);
579 sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0); 579 sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0);
580 switch (op) { 580 switch (op) {
581 case MASK_SET: sb->state |= bits; 581 case MASK_SET: sb->state |= cpu_to_le32(bits);
582 break; 582 break;
583 case MASK_UNSET: sb->state &= ~bits; 583 case MASK_UNSET: sb->state &= cpu_to_le32(~bits);
584 break; 584 break;
585 default: BUG(); 585 default: BUG();
586 } 586 }
@@ -1413,7 +1413,7 @@ int bitmap_create(mddev_t *mddev)
1413 int err; 1413 int err;
1414 sector_t start; 1414 sector_t start;
1415 1415
1416 BUG_ON(sizeof(bitmap_super_t) != 256); 1416 BUILD_BUG_ON(sizeof(bitmap_super_t) != 256);
1417 1417
1418 if (!file && !mddev->bitmap_offset) /* bitmap disabled, nothing to do */ 1418 if (!file && !mddev->bitmap_offset) /* bitmap disabled, nothing to do */
1419 return 0; 1419 return 0;
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 655d816760e5..08a40f4e4f60 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -16,6 +16,7 @@
16#include <linux/slab.h> 16#include <linux/slab.h>
17#include <linux/crypto.h> 17#include <linux/crypto.h>
18#include <linux/workqueue.h> 18#include <linux/workqueue.h>
19#include <linux/backing-dev.h>
19#include <asm/atomic.h> 20#include <asm/atomic.h>
20#include <linux/scatterlist.h> 21#include <linux/scatterlist.h>
21#include <asm/page.h> 22#include <asm/page.h>
@@ -602,7 +603,7 @@ static void process_write(struct crypt_io *io)
602 603
603 /* out of memory -> run queues */ 604 /* out of memory -> run queues */
604 if (remaining) 605 if (remaining)
605 blk_congestion_wait(bio_data_dir(clone), HZ/100); 606 congestion_wait(bio_data_dir(clone), HZ/100);
606 } 607 }
607} 608}
608 609
@@ -914,8 +915,6 @@ static int crypt_status(struct dm_target *ti, status_type_t type,
914 char *result, unsigned int maxlen) 915 char *result, unsigned int maxlen)
915{ 916{
916 struct crypt_config *cc = (struct crypt_config *) ti->private; 917 struct crypt_config *cc = (struct crypt_config *) ti->private;
917 const char *cipher;
918 const char *chainmode = NULL;
919 unsigned int sz = 0; 918 unsigned int sz = 0;
920 919
921 switch (type) { 920 switch (type) {
@@ -924,14 +923,11 @@ static int crypt_status(struct dm_target *ti, status_type_t type,
924 break; 923 break;
925 924
926 case STATUSTYPE_TABLE: 925 case STATUSTYPE_TABLE:
927 cipher = crypto_blkcipher_name(cc->tfm);
928
929 chainmode = cc->chainmode;
930
931 if (cc->iv_mode) 926 if (cc->iv_mode)
932 DMEMIT("%s-%s-%s ", cipher, chainmode, cc->iv_mode); 927 DMEMIT("%s-%s-%s ", cc->cipher, cc->chainmode,
928 cc->iv_mode);
933 else 929 else
934 DMEMIT("%s-%s ", cipher, chainmode); 930 DMEMIT("%s-%s ", cc->cipher, cc->chainmode);
935 931
936 if (cc->key_size > 0) { 932 if (cc->key_size > 0) {
937 if ((maxlen - sz) < ((cc->key_size << 1) + 1)) 933 if ((maxlen - sz) < ((cc->key_size << 1) + 1))
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index d13bb15a8a02..4510ad8f971c 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -606,9 +606,14 @@ static struct hash_cell *__find_device_hash_cell(struct dm_ioctl *param)
606 return __get_name_cell(param->name); 606 return __get_name_cell(param->name);
607 607
608 md = dm_get_md(huge_decode_dev(param->dev)); 608 md = dm_get_md(huge_decode_dev(param->dev));
609 if (md) 609 if (!md)
610 mdptr = dm_get_mdptr(md); 610 goto out;
611 611
612 mdptr = dm_get_mdptr(md);
613 if (!mdptr)
614 dm_put(md);
615
616out:
612 return mdptr; 617 return mdptr;
613} 618}
614 619
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index 659224cb7c53..48a653b3f518 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -24,6 +24,7 @@
24 24
25static struct workqueue_struct *_kmirrord_wq; 25static struct workqueue_struct *_kmirrord_wq;
26static struct work_struct _kmirrord_work; 26static struct work_struct _kmirrord_work;
27static DECLARE_WAIT_QUEUE_HEAD(_kmirrord_recovery_stopped);
27 28
28static inline void wake(void) 29static inline void wake(void)
29{ 30{
@@ -83,6 +84,7 @@ struct region_hash {
83 struct list_head *buckets; 84 struct list_head *buckets;
84 85
85 spinlock_t region_lock; 86 spinlock_t region_lock;
87 atomic_t recovery_in_flight;
86 struct semaphore recovery_count; 88 struct semaphore recovery_count;
87 struct list_head clean_regions; 89 struct list_head clean_regions;
88 struct list_head quiesced_regions; 90 struct list_head quiesced_regions;
@@ -191,6 +193,7 @@ static int rh_init(struct region_hash *rh, struct mirror_set *ms,
191 193
192 spin_lock_init(&rh->region_lock); 194 spin_lock_init(&rh->region_lock);
193 sema_init(&rh->recovery_count, 0); 195 sema_init(&rh->recovery_count, 0);
196 atomic_set(&rh->recovery_in_flight, 0);
194 INIT_LIST_HEAD(&rh->clean_regions); 197 INIT_LIST_HEAD(&rh->clean_regions);
195 INIT_LIST_HEAD(&rh->quiesced_regions); 198 INIT_LIST_HEAD(&rh->quiesced_regions);
196 INIT_LIST_HEAD(&rh->recovered_regions); 199 INIT_LIST_HEAD(&rh->recovered_regions);
@@ -382,6 +385,8 @@ static void rh_update_states(struct region_hash *rh)
382 rh->log->type->clear_region(rh->log, reg->key); 385 rh->log->type->clear_region(rh->log, reg->key);
383 rh->log->type->complete_resync_work(rh->log, reg->key, 1); 386 rh->log->type->complete_resync_work(rh->log, reg->key, 1);
384 dispatch_bios(rh->ms, &reg->delayed_bios); 387 dispatch_bios(rh->ms, &reg->delayed_bios);
388 if (atomic_dec_and_test(&rh->recovery_in_flight))
389 wake_up_all(&_kmirrord_recovery_stopped);
385 up(&rh->recovery_count); 390 up(&rh->recovery_count);
386 mempool_free(reg, rh->region_pool); 391 mempool_free(reg, rh->region_pool);
387 } 392 }
@@ -502,11 +507,21 @@ static int __rh_recovery_prepare(struct region_hash *rh)
502 507
503static void rh_recovery_prepare(struct region_hash *rh) 508static void rh_recovery_prepare(struct region_hash *rh)
504{ 509{
505 while (!down_trylock(&rh->recovery_count)) 510 /* Extra reference to avoid race with rh_stop_recovery */
511 atomic_inc(&rh->recovery_in_flight);
512
513 while (!down_trylock(&rh->recovery_count)) {
514 atomic_inc(&rh->recovery_in_flight);
506 if (__rh_recovery_prepare(rh) <= 0) { 515 if (__rh_recovery_prepare(rh) <= 0) {
516 atomic_dec(&rh->recovery_in_flight);
507 up(&rh->recovery_count); 517 up(&rh->recovery_count);
508 break; 518 break;
509 } 519 }
520 }
521
522 /* Drop the extra reference */
523 if (atomic_dec_and_test(&rh->recovery_in_flight))
524 wake_up_all(&_kmirrord_recovery_stopped);
510} 525}
511 526
512/* 527/*
@@ -1177,6 +1192,11 @@ static void mirror_postsuspend(struct dm_target *ti)
1177 struct dirty_log *log = ms->rh.log; 1192 struct dirty_log *log = ms->rh.log;
1178 1193
1179 rh_stop_recovery(&ms->rh); 1194 rh_stop_recovery(&ms->rh);
1195
1196 /* Wait for all I/O we generated to complete */
1197 wait_event(_kmirrord_recovery_stopped,
1198 !atomic_read(&ms->rh.recovery_in_flight));
1199
1180 if (log->type->suspend && log->type->suspend(log)) 1200 if (log->type->suspend && log->type->suspend(log))
1181 /* FIXME: need better error handling */ 1201 /* FIXME: need better error handling */
1182 DMWARN("log suspend failed"); 1202 DMWARN("log suspend failed");
diff --git a/drivers/md/dm-round-robin.c b/drivers/md/dm-round-robin.c
index c5a16c550122..6f9fcd4db9b5 100644
--- a/drivers/md/dm-round-robin.c
+++ b/drivers/md/dm-round-robin.c
@@ -136,7 +136,7 @@ static int rr_add_path(struct path_selector *ps, struct path *path,
136 136
137 path->pscontext = pi; 137 path->pscontext = pi;
138 138
139 list_add(&pi->list, &s->valid_paths); 139 list_add_tail(&pi->list, &s->valid_paths);
140 140
141 return 0; 141 return 0;
142} 142}
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index b5764a86c8b5..fc4f743f3b53 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1285,7 +1285,7 @@ int dm_suspend(struct mapped_device *md, int do_lockfs)
1285 down(&md->suspend_lock); 1285 down(&md->suspend_lock);
1286 1286
1287 if (dm_suspended(md)) 1287 if (dm_suspended(md))
1288 goto out; 1288 goto out_unlock;
1289 1289
1290 map = dm_get_table(md); 1290 map = dm_get_table(md);
1291 1291
@@ -1361,6 +1361,8 @@ out:
1361 } 1361 }
1362 1362
1363 dm_table_put(map); 1363 dm_table_put(map);
1364
1365out_unlock:
1364 up(&md->suspend_lock); 1366 up(&md->suspend_lock);
1365 return r; 1367 return r;
1366} 1368}
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 57fa64f93e5f..8cbf9c9df1c3 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -974,12 +974,13 @@ static void super_90_sync(mddev_t *mddev, mdk_rdev_t *rdev)
974 * version 1 superblock 974 * version 1 superblock
975 */ 975 */
976 976
977static unsigned int calc_sb_1_csum(struct mdp_superblock_1 * sb) 977static __le32 calc_sb_1_csum(struct mdp_superblock_1 * sb)
978{ 978{
979 unsigned int disk_csum, csum; 979 __le32 disk_csum;
980 u32 csum;
980 unsigned long long newcsum; 981 unsigned long long newcsum;
981 int size = 256 + le32_to_cpu(sb->max_dev)*2; 982 int size = 256 + le32_to_cpu(sb->max_dev)*2;
982 unsigned int *isuper = (unsigned int*)sb; 983 __le32 *isuper = (__le32*)sb;
983 int i; 984 int i;
984 985
985 disk_csum = sb->sb_csum; 986 disk_csum = sb->sb_csum;
@@ -989,7 +990,7 @@ static unsigned int calc_sb_1_csum(struct mdp_superblock_1 * sb)
989 newcsum += le32_to_cpu(*isuper++); 990 newcsum += le32_to_cpu(*isuper++);
990 991
991 if (size == 2) 992 if (size == 2)
992 newcsum += le16_to_cpu(*(unsigned short*) isuper); 993 newcsum += le16_to_cpu(*(__le16*) isuper);
993 994
994 csum = (newcsum & 0xffffffff) + (newcsum >> 32); 995 csum = (newcsum & 0xffffffff) + (newcsum >> 32);
995 sb->sb_csum = disk_csum; 996 sb->sb_csum = disk_csum;
@@ -1106,7 +1107,7 @@ static int super_1_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version)
1106 if (le32_to_cpu(sb->chunksize)) 1107 if (le32_to_cpu(sb->chunksize))
1107 rdev->size &= ~((sector_t)le32_to_cpu(sb->chunksize)/2 - 1); 1108 rdev->size &= ~((sector_t)le32_to_cpu(sb->chunksize)/2 - 1);
1108 1109
1109 if (le32_to_cpu(sb->size) > rdev->size*2) 1110 if (le64_to_cpu(sb->size) > rdev->size*2)
1110 return -EINVAL; 1111 return -EINVAL;
1111 return ret; 1112 return ret;
1112} 1113}
@@ -1228,7 +1229,7 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
1228 else 1229 else
1229 sb->resync_offset = cpu_to_le64(0); 1230 sb->resync_offset = cpu_to_le64(0);
1230 1231
1231 sb->cnt_corrected_read = atomic_read(&rdev->corrected_errors); 1232 sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
1232 1233
1233 sb->raid_disks = cpu_to_le32(mddev->raid_disks); 1234 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
1234 sb->size = cpu_to_le64(mddev->size<<1); 1235 sb->size = cpu_to_le64(mddev->size<<1);
@@ -2002,6 +2003,7 @@ static mdk_rdev_t *md_import_device(dev_t newdev, int super_format, int super_mi
2002 kobject_init(&rdev->kobj); 2003 kobject_init(&rdev->kobj);
2003 2004
2004 rdev->desc_nr = -1; 2005 rdev->desc_nr = -1;
2006 rdev->saved_raid_disk = -1;
2005 rdev->flags = 0; 2007 rdev->flags = 0;
2006 rdev->data_offset = 0; 2008 rdev->data_offset = 0;
2007 rdev->sb_events = 0; 2009 rdev->sb_events = 0;
@@ -3198,6 +3200,7 @@ static int do_md_run(mddev_t * mddev)
3198 3200
3199 mddev->changed = 1; 3201 mddev->changed = 1;
3200 md_new_event(mddev); 3202 md_new_event(mddev);
3203 kobject_uevent(&mddev->gendisk->kobj, KOBJ_CHANGE);
3201 return 0; 3204 return 0;
3202} 3205}
3203 3206
@@ -4043,11 +4046,8 @@ static int update_size(mddev_t *mddev, unsigned long size)
4043 return -EBUSY; 4046 return -EBUSY;
4044 ITERATE_RDEV(mddev,rdev,tmp) { 4047 ITERATE_RDEV(mddev,rdev,tmp) {
4045 sector_t avail; 4048 sector_t avail;
4046 if (rdev->sb_offset > rdev->data_offset) 4049 avail = rdev->size * 2;
4047 avail = (rdev->sb_offset*2) - rdev->data_offset; 4050
4048 else
4049 avail = get_capacity(rdev->bdev->bd_disk)
4050 - rdev->data_offset;
4051 if (fit && (size == 0 || size > avail/2)) 4051 if (fit && (size == 0 || size > avail/2))
4052 size = avail/2; 4052 size = avail/2;
4053 if (avail < ((sector_t)size << 1)) 4053 if (avail < ((sector_t)size << 1))
@@ -4486,6 +4486,7 @@ static int md_thread(void * arg)
4486 * many dirty RAID5 blocks. 4486 * many dirty RAID5 blocks.
4487 */ 4487 */
4488 4488
4489 current->flags |= PF_NOFREEZE;
4489 allow_signal(SIGKILL); 4490 allow_signal(SIGKILL);
4490 while (!kthread_should_stop()) { 4491 while (!kthread_should_stop()) {
4491 4492
@@ -4502,7 +4503,6 @@ static int md_thread(void * arg)
4502 test_bit(THREAD_WAKEUP, &thread->flags) 4503 test_bit(THREAD_WAKEUP, &thread->flags)
4503 || kthread_should_stop(), 4504 || kthread_should_stop(),
4504 thread->timeout); 4505 thread->timeout);
4505 try_to_freeze();
4506 4506
4507 clear_bit(THREAD_WAKEUP, &thread->flags); 4507 clear_bit(THREAD_WAKEUP, &thread->flags);
4508 4508
@@ -4912,6 +4912,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
4912} 4912}
4913 4913
4914static struct file_operations md_seq_fops = { 4914static struct file_operations md_seq_fops = {
4915 .owner = THIS_MODULE,
4915 .open = md_seq_open, 4916 .open = md_seq_open,
4916 .read = seq_read, 4917 .read = seq_read,
4917 .llseek = seq_lseek, 4918 .llseek = seq_lseek,
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index 171ff41b52b0..14da37fee37b 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -277,6 +277,7 @@ static void multipath_error (mddev_t *mddev, mdk_rdev_t *rdev)
277 set_bit(Faulty, &rdev->flags); 277 set_bit(Faulty, &rdev->flags);
278 set_bit(MD_CHANGE_DEVS, &mddev->flags); 278 set_bit(MD_CHANGE_DEVS, &mddev->flags);
279 conf->working_disks--; 279 conf->working_disks--;
280 mddev->degraded++;
280 printk(KERN_ALERT "multipath: IO failure on %s," 281 printk(KERN_ALERT "multipath: IO failure on %s,"
281 " disabling IO path. \n Operation continuing" 282 " disabling IO path. \n Operation continuing"
282 " on %d IO paths.\n", 283 " on %d IO paths.\n",
@@ -336,6 +337,7 @@ static int multipath_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
336 blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9); 337 blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9);
337 338
338 conf->working_disks++; 339 conf->working_disks++;
340 mddev->degraded--;
339 rdev->raid_disk = path; 341 rdev->raid_disk = path;
340 set_bit(In_sync, &rdev->flags); 342 set_bit(In_sync, &rdev->flags);
341 rcu_assign_pointer(p->rdev, rdev); 343 rcu_assign_pointer(p->rdev, rdev);
@@ -501,7 +503,7 @@ static int multipath_run (mddev_t *mddev)
501 mdname(mddev)); 503 mdname(mddev));
502 goto out_free_conf; 504 goto out_free_conf;
503 } 505 }
504 mddev->degraded = conf->raid_disks = conf->working_disks; 506 mddev->degraded = conf->raid_disks - conf->working_disks;
505 507
506 conf->pool = mempool_create_kzalloc_pool(NR_RESERVED_BUFS, 508 conf->pool = mempool_create_kzalloc_pool(NR_RESERVED_BUFS,
507 sizeof(struct multipath_bh)); 509 sizeof(struct multipath_bh));
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index dc9d2def0270..656fae912fe3 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1474,8 +1474,8 @@ static void fix_read_error(conf_t *conf, int read_disk,
1474 "raid1:%s: read error corrected " 1474 "raid1:%s: read error corrected "
1475 "(%d sectors at %llu on %s)\n", 1475 "(%d sectors at %llu on %s)\n",
1476 mdname(mddev), s, 1476 mdname(mddev), s,
1477 (unsigned long long)sect + 1477 (unsigned long long)(sect +
1478 rdev->data_offset, 1478 rdev->data_offset),
1479 bdevname(rdev->bdev, b)); 1479 bdevname(rdev->bdev, b));
1480 } 1480 }
1481 } 1481 }
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 1250f0eab4af..7492d6033ac6 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1470,8 +1470,8 @@ static void fix_read_error(conf_t *conf, mddev_t *mddev, r10bio_t *r10_bio)
1470 "raid10:%s: read error corrected" 1470 "raid10:%s: read error corrected"
1471 " (%d sectors at %llu on %s)\n", 1471 " (%d sectors at %llu on %s)\n",
1472 mdname(mddev), s, 1472 mdname(mddev), s,
1473 (unsigned long long)sect+ 1473 (unsigned long long)(sect+
1474 rdev->data_offset, 1474 rdev->data_offset),
1475 bdevname(rdev->bdev, b)); 1475 bdevname(rdev->bdev, b));
1476 1476
1477 rdev_dec_pending(rdev, mddev); 1477 rdev_dec_pending(rdev, mddev);
@@ -2079,7 +2079,7 @@ static int run(mddev_t *mddev)
2079 disk = conf->mirrors + i; 2079 disk = conf->mirrors + i;
2080 2080
2081 if (!disk->rdev || 2081 if (!disk->rdev ||
2082 !test_bit(In_sync, &rdev->flags)) { 2082 !test_bit(In_sync, &disk->rdev->flags)) {
2083 disk->head_position = 0; 2083 disk->head_position = 0;
2084 mddev->degraded++; 2084 mddev->degraded++;
2085 } 2085 }
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index e14f45780720..69c3e201fa3b 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -3659,7 +3659,7 @@ static void end_reshape(raid5_conf_t *conf)
3659 bdev = bdget_disk(conf->mddev->gendisk, 0); 3659 bdev = bdget_disk(conf->mddev->gendisk, 0);
3660 if (bdev) { 3660 if (bdev) {
3661 mutex_lock(&bdev->bd_inode->i_mutex); 3661 mutex_lock(&bdev->bd_inode->i_mutex);
3662 i_size_write(bdev->bd_inode, conf->mddev->array_size << 10); 3662 i_size_write(bdev->bd_inode, (loff_t)conf->mddev->array_size << 10);
3663 mutex_unlock(&bdev->bd_inode->i_mutex); 3663 mutex_unlock(&bdev->bd_inode->i_mutex);
3664 bdput(bdev); 3664 bdput(bdev);
3665 } 3665 }
diff --git a/drivers/media/common/saa7146_i2c.c b/drivers/media/common/saa7146_i2c.c
index d9953f7a8b6b..5297a365c928 100644
--- a/drivers/media/common/saa7146_i2c.c
+++ b/drivers/media/common/saa7146_i2c.c
@@ -217,11 +217,9 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, u32* dword, int short_d
217 } 217 }
218 /* wait until we get a transfer done or error */ 218 /* wait until we get a transfer done or error */
219 timeout = jiffies + HZ/100 + 1; /* 10ms */ 219 timeout = jiffies + HZ/100 + 1; /* 10ms */
220 /* first read usually delivers bogus results... */
221 saa7146_i2c_status(dev);
220 while(1) { 222 while(1) {
221 /**
222 * first read usually delivers bogus results...
223 */
224 saa7146_i2c_status(dev);
225 status = saa7146_i2c_status(dev); 223 status = saa7146_i2c_status(dev);
226 if ((status & 0x3) != 1) 224 if ((status & 0x3) != 1)
227 break; 225 break;
@@ -232,10 +230,10 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, u32* dword, int short_d
232 DEB_I2C(("saa7146_i2c_writeout: timed out waiting for end of xfer\n")); 230 DEB_I2C(("saa7146_i2c_writeout: timed out waiting for end of xfer\n"));
233 return -EIO; 231 return -EIO;
234 } 232 }
235 if ((++trial < 20) && short_delay) 233 if (++trial < 50 && short_delay)
236 udelay(10); 234 udelay(10);
237 else 235 else
238 msleep(1); 236 msleep(1);
239 } 237 }
240 } 238 }
241 239
diff --git a/drivers/media/dvb/b2c2/flexcop-usb.c b/drivers/media/dvb/b2c2/flexcop-usb.c
index 2853ea1bdaf1..87fb75f0d1cf 100644
--- a/drivers/media/dvb/b2c2/flexcop-usb.c
+++ b/drivers/media/dvb/b2c2/flexcop-usb.c
@@ -246,7 +246,7 @@ static int flexcop_usb_i2c_req(struct flexcop_usb *fc_usb,
246 wIndex = (chipaddr << 8 ) | addr; 246 wIndex = (chipaddr << 8 ) | addr;
247 247
248 deb_i2c("i2c %2d: %02x %02x %02x %02x %02x %02x\n",func,request_type,req, 248 deb_i2c("i2c %2d: %02x %02x %02x %02x %02x %02x\n",func,request_type,req,
249 ((wValue && 0xff) << 8),wValue >> 8,((wIndex && 0xff) << 8),wIndex >> 8); 249 wValue & 0xff, wValue >> 8, wIndex & 0xff, wIndex >> 8);
250 250
251 len = usb_control_msg(fc_usb->udev,pipe, 251 len = usb_control_msg(fc_usb->udev,pipe,
252 req, 252 req,
diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
index fb6c4cc8477d..14e69a736eda 100644
--- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c
+++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
@@ -665,6 +665,10 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
665 case BTTV_BOARD_TWINHAN_DST: 665 case BTTV_BOARD_TWINHAN_DST:
666 /* DST is not a frontend driver !!! */ 666 /* DST is not a frontend driver !!! */
667 state = (struct dst_state *) kmalloc(sizeof (struct dst_state), GFP_KERNEL); 667 state = (struct dst_state *) kmalloc(sizeof (struct dst_state), GFP_KERNEL);
668 if (!state) {
669 printk("dvb_bt8xx: No memory\n");
670 break;
671 }
668 /* Setup the Card */ 672 /* Setup the Card */
669 state->config = &dst_config; 673 state->config = &dst_config;
670 state->i2c = card->i2c_adapter; 674 state->i2c = card->i2c_adapter;
diff --git a/drivers/media/dvb/dvb-core/Kconfig b/drivers/media/dvb/dvb-core/Kconfig
index e46eae3b9be2..1990eda10c46 100644
--- a/drivers/media/dvb/dvb-core/Kconfig
+++ b/drivers/media/dvb/dvb-core/Kconfig
@@ -19,6 +19,6 @@ config DVB_CORE_ATTACH
19 allow the card drivers to only load the frontend modules 19 allow the card drivers to only load the frontend modules
20 they require. This saves several KBytes of memory. 20 they require. This saves several KBytes of memory.
21 21
22 Note: You will need moudule-init-tools v3.2 or later for this feature. 22 Note: You will need module-init-tools v3.2 or later for this feature.
23 23
24 If unsure say Y. 24 If unsure say Y.
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index 2cc5caa26a0a..a263b3f3c21d 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -26,7 +26,7 @@ config DVB_USB_A800
26 tristate "AVerMedia AverTV DVB-T USB 2.0 (A800)" 26 tristate "AVerMedia AverTV DVB-T USB 2.0 (A800)"
27 depends on DVB_USB 27 depends on DVB_USB
28 select DVB_DIB3000MC 28 select DVB_DIB3000MC
29 select DVB_TUNER_MT2060 29 select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE
30 help 30 help
31 Say Y here to support the AVerMedia AverTV DVB-T USB 2.0 (A800) receiver. 31 Say Y here to support the AVerMedia AverTV DVB-T USB 2.0 (A800) receiver.
32 32
@@ -34,7 +34,7 @@ config DVB_USB_DIBUSB_MB
34 tristate "DiBcom USB DVB-T devices (based on the DiB3000M-B) (see help for device list)" 34 tristate "DiBcom USB DVB-T devices (based on the DiB3000M-B) (see help for device list)"
35 depends on DVB_USB 35 depends on DVB_USB
36 select DVB_DIB3000MB 36 select DVB_DIB3000MB
37 select DVB_TUNER_MT2060 37 select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE
38 help 38 help
39 Support for USB 1.1 and 2.0 DVB-T receivers based on reference designs made by 39 Support for USB 1.1 and 2.0 DVB-T receivers based on reference designs made by
40 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-B demodulator. 40 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-B demodulator.
@@ -55,7 +55,7 @@ config DVB_USB_DIBUSB_MC
55 tristate "DiBcom USB DVB-T devices (based on the DiB3000M-C/P) (see help for device list)" 55 tristate "DiBcom USB DVB-T devices (based on the DiB3000M-C/P) (see help for device list)"
56 depends on DVB_USB 56 depends on DVB_USB
57 select DVB_DIB3000MC 57 select DVB_DIB3000MC
58 select DVB_TUNER_MT2060 58 select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE
59 help 59 help
60 Support for USB2.0 DVB-T receivers based on reference designs made by 60 Support for USB2.0 DVB-T receivers based on reference designs made by
61 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-C/P demodulator. 61 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-C/P demodulator.
@@ -70,7 +70,7 @@ config DVB_USB_DIB0700
70 tristate "DiBcom DiB0700 USB DVB devices (see help for supported devices)" 70 tristate "DiBcom DiB0700 USB DVB devices (see help for supported devices)"
71 depends on DVB_USB 71 depends on DVB_USB
72 select DVB_DIB3000MC 72 select DVB_DIB3000MC
73 select DVB_TUNER_MT2060 73 select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE
74 help 74 help
75 Support for USB2.0/1.1 DVB receivers based on the DiB0700 USB bridge. The 75 Support for USB2.0/1.1 DVB receivers based on the DiB0700 USB bridge. The
76 USB bridge is also present in devices having the DiB7700 DVB-T-USB 76 USB bridge is also present in devices having the DiB7700 DVB-T-USB
@@ -87,7 +87,7 @@ config DVB_USB_UMT_010
87 tristate "HanfTek UMT-010 DVB-T USB2.0 support" 87 tristate "HanfTek UMT-010 DVB-T USB2.0 support"
88 depends on DVB_USB 88 depends on DVB_USB
89 select DVB_DIB3000MC 89 select DVB_DIB3000MC
90 select DVB_TUNER_MT2060 90 select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE
91 help 91 help
92 Say Y here to support the HanfTek UMT-010 USB2.0 stick-sized DVB-T receiver. 92 Say Y here to support the HanfTek UMT-010 USB2.0 stick-sized DVB-T receiver.
93 93
@@ -153,7 +153,7 @@ config DVB_USB_NOVA_T_USB2
153 tristate "Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 support" 153 tristate "Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 support"
154 depends on DVB_USB 154 depends on DVB_USB
155 select DVB_DIB3000MC 155 select DVB_DIB3000MC
156 select DVB_TUNER_MT2060 156 select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE
157 help 157 help
158 Say Y here to support the Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 receiver. 158 Say Y here to support the Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 receiver.
159 159
diff --git a/drivers/media/dvb/dvb-usb/dibusb-common.c b/drivers/media/dvb/dvb-usb/dibusb-common.c
index fd3a9902f98d..5143e426d283 100644
--- a/drivers/media/dvb/dvb-usb/dibusb-common.c
+++ b/drivers/media/dvb/dvb-usb/dibusb-common.c
@@ -169,7 +169,7 @@ EXPORT_SYMBOL(dibusb_read_eeprom_byte);
169// Config Adjacent channels Perf -cal22 169// Config Adjacent channels Perf -cal22
170static struct dibx000_agc_config dib3000p_mt2060_agc_config = { 170static struct dibx000_agc_config dib3000p_mt2060_agc_config = {
171 .band_caps = BAND_VHF | BAND_UHF, 171 .band_caps = BAND_VHF | BAND_UHF,
172 .setup = (0 << 15) | (0 << 14) | (1 << 13) | (1 << 12) | (29 << 0), 172 .setup = (1 << 8) | (5 << 5) | (1 << 4) | (1 << 3) | (0 << 2) | (2 << 0),
173 173
174 .agc1_max = 48497, 174 .agc1_max = 48497,
175 .agc1_min = 23593, 175 .agc1_min = 23593,
@@ -196,10 +196,14 @@ static struct dib3000mc_config stk3000p_dib3000p_config = {
196 .ln_adc_level = 0x1cc7, 196 .ln_adc_level = 0x1cc7,
197 197
198 .output_mpeg2_in_188_bytes = 1, 198 .output_mpeg2_in_188_bytes = 1,
199
200 .agc_command1 = 1,
201 .agc_command2 = 1,
199}; 202};
200 203
201static struct dibx000_agc_config dib3000p_panasonic_agc_config = { 204static struct dibx000_agc_config dib3000p_panasonic_agc_config = {
202 .setup = (0 << 15) | (0 << 14) | (1 << 13) | (1 << 12) | (29 << 0), 205 .band_caps = BAND_VHF | BAND_UHF,
206 .setup = (1 << 8) | (5 << 5) | (1 << 4) | (1 << 3) | (0 << 2) | (2 << 0),
203 207
204 .agc1_max = 56361, 208 .agc1_max = 56361,
205 .agc1_min = 22282, 209 .agc1_min = 22282,
@@ -226,6 +230,9 @@ static struct dib3000mc_config mod3000p_dib3000p_config = {
226 .ln_adc_level = 0x1cc7, 230 .ln_adc_level = 0x1cc7,
227 231
228 .output_mpeg2_in_188_bytes = 1, 232 .output_mpeg2_in_188_bytes = 1,
233
234 .agc_command1 = 1,
235 .agc_command2 = 1,
229}; 236};
230 237
231int dibusb_dib3000mc_frontend_attach(struct dvb_usb_adapter *adap) 238int dibusb_dib3000mc_frontend_attach(struct dvb_usb_adapter *adap)
diff --git a/drivers/media/dvb/dvb-usb/dibusb.h b/drivers/media/dvb/dvb-usb/dibusb.h
index 5153fb943da1..b60781032742 100644
--- a/drivers/media/dvb/dvb-usb/dibusb.h
+++ b/drivers/media/dvb/dvb-usb/dibusb.h
@@ -99,7 +99,9 @@
99struct dibusb_state { 99struct dibusb_state {
100 struct dib_fe_xfer_ops ops; 100 struct dib_fe_xfer_ops ops;
101 int mt2060_present; 101 int mt2060_present;
102};
102 103
104struct dibusb_device_state {
103 /* for RC5 remote control */ 105 /* for RC5 remote control */
104 int old_toggle; 106 int old_toggle;
105 int last_repeat_count; 107 int last_repeat_count;
diff --git a/drivers/media/dvb/dvb-usb/nova-t-usb2.c b/drivers/media/dvb/dvb-usb/nova-t-usb2.c
index a9219bf69b89..a58874c790b2 100644
--- a/drivers/media/dvb/dvb-usb/nova-t-usb2.c
+++ b/drivers/media/dvb/dvb-usb/nova-t-usb2.c
@@ -75,7 +75,7 @@ static int nova_t_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
75 u8 key[5],cmd[2] = { DIBUSB_REQ_POLL_REMOTE, 0x35 }, data,toggle,custom; 75 u8 key[5],cmd[2] = { DIBUSB_REQ_POLL_REMOTE, 0x35 }, data,toggle,custom;
76 u16 raw; 76 u16 raw;
77 int i; 77 int i;
78 struct dibusb_state *st = d->priv; 78 struct dibusb_device_state *st = d->priv;
79 79
80 dvb_usb_generic_rw(d,cmd,2,key,5,0); 80 dvb_usb_generic_rw(d,cmd,2,key,5,0);
81 81
@@ -184,6 +184,7 @@ static struct dvb_usb_device_properties nova_t_properties = {
184 .size_of_priv = sizeof(struct dibusb_state), 184 .size_of_priv = sizeof(struct dibusb_state),
185 } 185 }
186 }, 186 },
187 .size_of_priv = sizeof(struct dibusb_device_state),
187 188
188 .power_ctrl = dibusb2_0_power_ctrl, 189 .power_ctrl = dibusb2_0_power_ctrl,
189 .read_mac_address = nova_t_read_mac_address, 190 .read_mac_address = nova_t_read_mac_address,
diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig
index 080fa257a0bc..aebb8d6f26f8 100644
--- a/drivers/media/dvb/frontends/Kconfig
+++ b/drivers/media/dvb/frontends/Kconfig
@@ -276,6 +276,8 @@ config DVB_TDA826X
276 276
277config DVB_TUNER_MT2060 277config DVB_TUNER_MT2060
278 tristate "Microtune MT2060 silicon IF tuner" 278 tristate "Microtune MT2060 silicon IF tuner"
279 depends on I2C
280 default m if DVB_FE_CUSTOMISE
279 help 281 help
280 A driver for the silicon IF tuner MT2060 from Microtune. 282 A driver for the silicon IF tuner MT2060 from Microtune.
281 283
diff --git a/drivers/media/dvb/frontends/bcm3510.h b/drivers/media/dvb/frontends/bcm3510.h
index 6dfa839a7022..7e4f95e1734b 100644
--- a/drivers/media/dvb/frontends/bcm3510.h
+++ b/drivers/media/dvb/frontends/bcm3510.h
@@ -34,7 +34,7 @@ struct bcm3510_config
34 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name); 34 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);
35}; 35};
36 36
37#if defined(CONFIG_DVB_BCM3510) || defined(CONFIG_DVB_BCM3510_MODULE) 37#if defined(CONFIG_DVB_BCM3510) || (defined(CONFIG_DVB_BCM3510_MODULE) && defined(MODULE))
38extern struct dvb_frontend* bcm3510_attach(const struct bcm3510_config* config, 38extern struct dvb_frontend* bcm3510_attach(const struct bcm3510_config* config,
39 struct i2c_adapter* i2c); 39 struct i2c_adapter* i2c);
40#else 40#else
diff --git a/drivers/media/dvb/frontends/cx22700.h b/drivers/media/dvb/frontends/cx22700.h
index 10286cc29fb4..7ac33690cdcc 100644
--- a/drivers/media/dvb/frontends/cx22700.h
+++ b/drivers/media/dvb/frontends/cx22700.h
@@ -31,7 +31,7 @@ struct cx22700_config
31 u8 demod_address; 31 u8 demod_address;
32}; 32};
33 33
34#if defined(CONFIG_DVB_CX22700) || defined(CONFIG_DVB_CX22700_MODULE) 34#if defined(CONFIG_DVB_CX22700) || (defined(CONFIG_DVB_CX22700_MODULE) && defined(MODULE))
35extern struct dvb_frontend* cx22700_attach(const struct cx22700_config* config, 35extern struct dvb_frontend* cx22700_attach(const struct cx22700_config* config,
36 struct i2c_adapter* i2c); 36 struct i2c_adapter* i2c);
37#else 37#else
diff --git a/drivers/media/dvb/frontends/cx22702.h b/drivers/media/dvb/frontends/cx22702.h
index bc217ddf02c0..9cd64da6ee40 100644
--- a/drivers/media/dvb/frontends/cx22702.h
+++ b/drivers/media/dvb/frontends/cx22702.h
@@ -41,7 +41,7 @@ struct cx22702_config
41 u8 output_mode; 41 u8 output_mode;
42}; 42};
43 43
44#if defined(CONFIG_DVB_CX22702) || defined(CONFIG_DVB_CX22702_MODULE) 44#if defined(CONFIG_DVB_CX22702) || (defined(CONFIG_DVB_CX22702_MODULE) && defined(MODULE))
45extern struct dvb_frontend* cx22702_attach(const struct cx22702_config* config, 45extern struct dvb_frontend* cx22702_attach(const struct cx22702_config* config,
46 struct i2c_adapter* i2c); 46 struct i2c_adapter* i2c);
47#else 47#else
diff --git a/drivers/media/dvb/frontends/cx24110.h b/drivers/media/dvb/frontends/cx24110.h
index c9d5ae250ebb..0ca3af4db513 100644
--- a/drivers/media/dvb/frontends/cx24110.h
+++ b/drivers/media/dvb/frontends/cx24110.h
@@ -41,7 +41,7 @@ static inline int cx24110_pll_write(struct dvb_frontend *fe, u32 val) {
41 return r; 41 return r;
42} 42}
43 43
44#if defined(CONFIG_DVB_CX24110) || defined(CONFIG_DVB_CX24110_MODULE) 44#if defined(CONFIG_DVB_CX24110) || (defined(CONFIG_DVB_CX24110_MODULE) && defined(MODULE))
45extern struct dvb_frontend* cx24110_attach(const struct cx24110_config* config, 45extern struct dvb_frontend* cx24110_attach(const struct cx24110_config* config,
46 struct i2c_adapter* i2c); 46 struct i2c_adapter* i2c);
47#else 47#else
diff --git a/drivers/media/dvb/frontends/cx24123.h b/drivers/media/dvb/frontends/cx24123.h
index 57a1dae1dc40..84f9e4f5c15e 100644
--- a/drivers/media/dvb/frontends/cx24123.h
+++ b/drivers/media/dvb/frontends/cx24123.h
@@ -35,7 +35,7 @@ struct cx24123_config
35 int lnb_polarity; 35 int lnb_polarity;
36}; 36};
37 37
38#if defined(CONFIG_DVB_CX24123) || defined(CONFIG_DVB_CX24123_MODULE) 38#if defined(CONFIG_DVB_CX24123) || (defined(CONFIG_DVB_CX24123_MODULE) && defined(MODULE))
39extern struct dvb_frontend* cx24123_attach(const struct cx24123_config* config, 39extern struct dvb_frontend* cx24123_attach(const struct cx24123_config* config,
40 struct i2c_adapter* i2c); 40 struct i2c_adapter* i2c);
41#else 41#else
diff --git a/drivers/media/dvb/frontends/dib3000.h b/drivers/media/dvb/frontends/dib3000.h
index 0caac3f0f279..a6d3854a67bc 100644
--- a/drivers/media/dvb/frontends/dib3000.h
+++ b/drivers/media/dvb/frontends/dib3000.h
@@ -41,7 +41,7 @@ struct dib_fe_xfer_ops
41 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl); 41 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
42}; 42};
43 43
44#if defined(CONFIG_DVB_DIB3000MB) || defined(CONFIG_DVB_DIB3000MB_MODULE) 44#if defined(CONFIG_DVB_DIB3000MB) || (defined(CONFIG_DVB_DIB3000MB_MODULE) && defined(MODULE))
45extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config, 45extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
46 struct i2c_adapter* i2c, struct dib_fe_xfer_ops *xfer_ops); 46 struct i2c_adapter* i2c, struct dib_fe_xfer_ops *xfer_ops);
47#else 47#else
diff --git a/drivers/media/dvb/frontends/dib3000mc.c b/drivers/media/dvb/frontends/dib3000mc.c
index ccc813b525d6..3561a777568c 100644
--- a/drivers/media/dvb/frontends/dib3000mc.c
+++ b/drivers/media/dvb/frontends/dib3000mc.c
@@ -345,7 +345,7 @@ static int dib3000mc_init(struct dvb_frontend *demod)
345 345
346 /* agc */ 346 /* agc */
347 dib3000mc_write_word(state, 36, state->cfg->max_time); 347 dib3000mc_write_word(state, 36, state->cfg->max_time);
348 dib3000mc_write_word(state, 37, agc->setup); 348 dib3000mc_write_word(state, 37, (state->cfg->agc_command1 << 13) | (state->cfg->agc_command2 << 12) | (0x1d << 0));
349 dib3000mc_write_word(state, 38, state->cfg->pwm3_value); 349 dib3000mc_write_word(state, 38, state->cfg->pwm3_value);
350 dib3000mc_write_word(state, 39, state->cfg->ln_adc_level); 350 dib3000mc_write_word(state, 39, state->cfg->ln_adc_level);
351 351
diff --git a/drivers/media/dvb/frontends/dib3000mc.h b/drivers/media/dvb/frontends/dib3000mc.h
index b198cd5b1843..72d4757601d8 100644
--- a/drivers/media/dvb/frontends/dib3000mc.h
+++ b/drivers/media/dvb/frontends/dib3000mc.h
@@ -28,6 +28,9 @@ struct dib3000mc_config {
28 u16 max_time; 28 u16 max_time;
29 u16 ln_adc_level; 29 u16 ln_adc_level;
30 30
31 u8 agc_command1 :1;
32 u8 agc_command2 :1;
33
31 u8 mobile_mode; 34 u8 mobile_mode;
32 35
33 u8 output_mpeg2_in_188_bytes; 36 u8 output_mpeg2_in_188_bytes;
@@ -36,7 +39,7 @@ struct dib3000mc_config {
36#define DEFAULT_DIB3000MC_I2C_ADDRESS 16 39#define DEFAULT_DIB3000MC_I2C_ADDRESS 16
37#define DEFAULT_DIB3000P_I2C_ADDRESS 24 40#define DEFAULT_DIB3000P_I2C_ADDRESS 24
38 41
39#if defined(CONFIG_DVB_DIB3000MC) || defined(CONFIG_DVB_DIB3000MC_MODULE) 42#if defined(CONFIG_DVB_DIB3000MC) || (defined(CONFIG_DVB_DIB3000MC_MODULE) && defined(MODULE))
40extern struct dvb_frontend * dib3000mc_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib3000mc_config *cfg); 43extern struct dvb_frontend * dib3000mc_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib3000mc_config *cfg);
41#else 44#else
42static inline struct dvb_frontend * dib3000mc_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib3000mc_config *cfg) 45static inline struct dvb_frontend * dib3000mc_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib3000mc_config *cfg)
diff --git a/drivers/media/dvb/frontends/isl6421.h b/drivers/media/dvb/frontends/isl6421.h
index 1916e3eb2df3..ea7f78a7d3cd 100644
--- a/drivers/media/dvb/frontends/isl6421.h
+++ b/drivers/media/dvb/frontends/isl6421.h
@@ -39,7 +39,7 @@
39#define ISL6421_ISEL1 0x20 39#define ISL6421_ISEL1 0x20
40#define ISL6421_DCL 0x40 40#define ISL6421_DCL 0x40
41 41
42#if defined(CONFIG_DVB_ISL6421) || defined(CONFIG_DVB_ISL6421_MODULE) 42#if defined(CONFIG_DVB_ISL6421) || (defined(CONFIG_DVB_ISL6421_MODULE) && defined(MODULE))
43/* override_set and override_clear control which system register bits (above) to always set & clear */ 43/* override_set and override_clear control which system register bits (above) to always set & clear */
44extern struct dvb_frontend *isl6421_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 i2c_addr, 44extern struct dvb_frontend *isl6421_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 i2c_addr,
45 u8 override_set, u8 override_clear); 45 u8 override_set, u8 override_clear);
diff --git a/drivers/media/dvb/frontends/l64781.h b/drivers/media/dvb/frontends/l64781.h
index 21ba4a230760..cd15f76ff28d 100644
--- a/drivers/media/dvb/frontends/l64781.h
+++ b/drivers/media/dvb/frontends/l64781.h
@@ -31,7 +31,7 @@ struct l64781_config
31 u8 demod_address; 31 u8 demod_address;
32}; 32};
33 33
34#if defined(CONFIG_DVB_L64781) || defined(CONFIG_DVB_L64781_MODULE) 34#if defined(CONFIG_DVB_L64781) || (defined(CONFIG_DVB_L64781_MODULE) && defined(MODULE))
35extern struct dvb_frontend* l64781_attach(const struct l64781_config* config, 35extern struct dvb_frontend* l64781_attach(const struct l64781_config* config,
36 struct i2c_adapter* i2c); 36 struct i2c_adapter* i2c);
37#else 37#else
diff --git a/drivers/media/dvb/frontends/lgdt330x.h b/drivers/media/dvb/frontends/lgdt330x.h
index 3f96b485584c..995059004b10 100644
--- a/drivers/media/dvb/frontends/lgdt330x.h
+++ b/drivers/media/dvb/frontends/lgdt330x.h
@@ -52,7 +52,7 @@ struct lgdt330x_config
52 int clock_polarity_flip; 52 int clock_polarity_flip;
53}; 53};
54 54
55#if defined(CONFIG_DVB_LGDT330X) || defined(CONFIG_DVB_LGDT330X_MODULE) 55#if defined(CONFIG_DVB_LGDT330X) || (defined(CONFIG_DVB_LGDT330X_MODULE) && defined(MODULE))
56extern struct dvb_frontend* lgdt330x_attach(const struct lgdt330x_config* config, 56extern struct dvb_frontend* lgdt330x_attach(const struct lgdt330x_config* config,
57 struct i2c_adapter* i2c); 57 struct i2c_adapter* i2c);
58#else 58#else
diff --git a/drivers/media/dvb/frontends/lnbp21.h b/drivers/media/dvb/frontends/lnbp21.h
index 1fe1dd179312..68906acf7d63 100644
--- a/drivers/media/dvb/frontends/lnbp21.h
+++ b/drivers/media/dvb/frontends/lnbp21.h
@@ -39,7 +39,7 @@
39 39
40#include <linux/dvb/frontend.h> 40#include <linux/dvb/frontend.h>
41 41
42#if defined(CONFIG_DVB_LNBP21) || defined(CONFIG_DVB_LNBP21_MODULE) 42#if defined(CONFIG_DVB_LNBP21) || (defined(CONFIG_DVB_LNBP21_MODULE) && defined(MODULE))
43/* override_set and override_clear control which system register bits (above) to always set & clear */ 43/* override_set and override_clear control which system register bits (above) to always set & clear */
44extern struct dvb_frontend *lnbp21_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 override_set, u8 override_clear); 44extern struct dvb_frontend *lnbp21_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 override_set, u8 override_clear);
45#else 45#else
diff --git a/drivers/media/dvb/frontends/mt2060.h b/drivers/media/dvb/frontends/mt2060.h
index 34a37c2b556f..0a86eab3a954 100644
--- a/drivers/media/dvb/frontends/mt2060.h
+++ b/drivers/media/dvb/frontends/mt2060.h
@@ -30,6 +30,14 @@ struct mt2060_config {
30 u8 clock_out; /* 0 = off, 1 = CLK/4, 2 = CLK/2, 3 = CLK/1 */ 30 u8 clock_out; /* 0 = off, 1 = CLK/4, 2 = CLK/2, 3 = CLK/1 */
31}; 31};
32 32
33#if defined(CONFIG_DVB_TUNER_MT2060) || (defined(CONFIG_DVB_TUNER_MT2060_MODULE) && defined(MODULE))
33extern struct dvb_frontend * mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2060_config *cfg, u16 if1); 34extern struct dvb_frontend * mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2060_config *cfg, u16 if1);
35#else
36static inline struct dvb_frontend * mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2060_config *cfg, u16 if1)
37{
38 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
39 return NULL;
40}
41#endif // CONFIG_DVB_TUNER_MT2060
34 42
35#endif 43#endif
diff --git a/drivers/media/dvb/frontends/mt312.h b/drivers/media/dvb/frontends/mt312.h
index 7112fb4d58ac..cf9a1505ad4b 100644
--- a/drivers/media/dvb/frontends/mt312.h
+++ b/drivers/media/dvb/frontends/mt312.h
@@ -34,7 +34,7 @@ struct mt312_config
34 u8 demod_address; 34 u8 demod_address;
35}; 35};
36 36
37#if defined(CONFIG_DVB_MT312) || defined(CONFIG_DVB_MT312_MODULE) 37#if defined(CONFIG_DVB_MT312) || (defined(CONFIG_DVB_MT312_MODULE) && defined(MODULE))
38struct dvb_frontend* vp310_mt312_attach(const struct mt312_config* config, 38struct dvb_frontend* vp310_mt312_attach(const struct mt312_config* config,
39 struct i2c_adapter* i2c); 39 struct i2c_adapter* i2c);
40#else 40#else
diff --git a/drivers/media/dvb/frontends/mt352.h b/drivers/media/dvb/frontends/mt352.h
index 0035c2e2d7c2..e9964081fd84 100644
--- a/drivers/media/dvb/frontends/mt352.h
+++ b/drivers/media/dvb/frontends/mt352.h
@@ -51,7 +51,7 @@ struct mt352_config
51 int (*demod_init)(struct dvb_frontend* fe); 51 int (*demod_init)(struct dvb_frontend* fe);
52}; 52};
53 53
54#if defined(CONFIG_DVB_MT352) || defined(CONFIG_DVB_MT352_MODULE) 54#if defined(CONFIG_DVB_MT352) || (defined(CONFIG_DVB_MT352_MODULE) && defined(MODULE))
55extern struct dvb_frontend* mt352_attach(const struct mt352_config* config, 55extern struct dvb_frontend* mt352_attach(const struct mt352_config* config,
56 struct i2c_adapter* i2c); 56 struct i2c_adapter* i2c);
57#else 57#else
diff --git a/drivers/media/dvb/frontends/nxt200x.h b/drivers/media/dvb/frontends/nxt200x.h
index 2eb220e98062..28bc5591b319 100644
--- a/drivers/media/dvb/frontends/nxt200x.h
+++ b/drivers/media/dvb/frontends/nxt200x.h
@@ -45,7 +45,7 @@ struct nxt200x_config
45 int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured); 45 int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured);
46}; 46};
47 47
48#if defined(CONFIG_DVB_NXT200X) || defined(CONFIG_DVB_NXT200X_MODULE) 48#if defined(CONFIG_DVB_NXT200X) || (defined(CONFIG_DVB_NXT200X_MODULE) && defined(MODULE))
49extern struct dvb_frontend* nxt200x_attach(const struct nxt200x_config* config, 49extern struct dvb_frontend* nxt200x_attach(const struct nxt200x_config* config,
50 struct i2c_adapter* i2c); 50 struct i2c_adapter* i2c);
51#else 51#else
diff --git a/drivers/media/dvb/frontends/nxt6000.h b/drivers/media/dvb/frontends/nxt6000.h
index 9397393a6bd1..13d22518356e 100644
--- a/drivers/media/dvb/frontends/nxt6000.h
+++ b/drivers/media/dvb/frontends/nxt6000.h
@@ -33,7 +33,7 @@ struct nxt6000_config
33 u8 clock_inversion:1; 33 u8 clock_inversion:1;
34}; 34};
35 35
36#if defined(CONFIG_DVB_NXT6000) || defined(CONFIG_DVB_NXT6000_MODULE) 36#if defined(CONFIG_DVB_NXT6000) || (defined(CONFIG_DVB_NXT6000_MODULE) && defined(MODULE))
37extern struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config, 37extern struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config,
38 struct i2c_adapter* i2c); 38 struct i2c_adapter* i2c);
39#else 39#else
diff --git a/drivers/media/dvb/frontends/or51132.h b/drivers/media/dvb/frontends/or51132.h
index 9718be4fb835..add24f0a743b 100644
--- a/drivers/media/dvb/frontends/or51132.h
+++ b/drivers/media/dvb/frontends/or51132.h
@@ -34,7 +34,7 @@ struct or51132_config
34 int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured); 34 int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured);
35}; 35};
36 36
37#if defined(CONFIG_DVB_OR51132) || defined(CONFIG_DVB_OR51132_MODULE) 37#if defined(CONFIG_DVB_OR51132) || (defined(CONFIG_DVB_OR51132_MODULE) && defined(MODULE))
38extern struct dvb_frontend* or51132_attach(const struct or51132_config* config, 38extern struct dvb_frontend* or51132_attach(const struct or51132_config* config,
39 struct i2c_adapter* i2c); 39 struct i2c_adapter* i2c);
40#else 40#else
diff --git a/drivers/media/dvb/frontends/or51211.h b/drivers/media/dvb/frontends/or51211.h
index 10a5419f9e00..8aad8402d615 100644
--- a/drivers/media/dvb/frontends/or51211.h
+++ b/drivers/media/dvb/frontends/or51211.h
@@ -37,7 +37,7 @@ struct or51211_config
37 void (*sleep)(struct dvb_frontend * fe); 37 void (*sleep)(struct dvb_frontend * fe);
38}; 38};
39 39
40#if defined(CONFIG_DVB_OR51211) || defined(CONFIG_DVB_OR51211_MODULE) 40#if defined(CONFIG_DVB_OR51211) || (defined(CONFIG_DVB_OR51211_MODULE) && defined(MODULE))
41extern struct dvb_frontend* or51211_attach(const struct or51211_config* config, 41extern struct dvb_frontend* or51211_attach(const struct or51211_config* config,
42 struct i2c_adapter* i2c); 42 struct i2c_adapter* i2c);
43#else 43#else
diff --git a/drivers/media/dvb/frontends/s5h1420.h b/drivers/media/dvb/frontends/s5h1420.h
index efc54d7f3c55..1555870f7226 100644
--- a/drivers/media/dvb/frontends/s5h1420.h
+++ b/drivers/media/dvb/frontends/s5h1420.h
@@ -34,7 +34,7 @@ struct s5h1420_config
34 u8 invert:1; 34 u8 invert:1;
35}; 35};
36 36
37#if defined(CONFIG_DVB_S5H1420) || defined(CONFIG_DVB_S5H1420_MODULE) 37#if defined(CONFIG_DVB_S5H1420) || (defined(CONFIG_DVB_S5H1420_MODULE) && defined(MODULE))
38extern struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config, 38extern struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config,
39 struct i2c_adapter* i2c); 39 struct i2c_adapter* i2c);
40#else 40#else
diff --git a/drivers/media/dvb/frontends/sp8870.h b/drivers/media/dvb/frontends/sp8870.h
index 4cf27d3b10f2..909cefe7139e 100644
--- a/drivers/media/dvb/frontends/sp8870.h
+++ b/drivers/media/dvb/frontends/sp8870.h
@@ -35,7 +35,7 @@ struct sp8870_config
35 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name); 35 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);
36}; 36};
37 37
38#if defined(CONFIG_DVB_SP8870) || defined(CONFIG_DVB_SP8870_MODULE) 38#if defined(CONFIG_DVB_SP8870) || (defined(CONFIG_DVB_SP8870_MODULE) && defined(MODULE))
39extern struct dvb_frontend* sp8870_attach(const struct sp8870_config* config, 39extern struct dvb_frontend* sp8870_attach(const struct sp8870_config* config,
40 struct i2c_adapter* i2c); 40 struct i2c_adapter* i2c);
41#else 41#else
diff --git a/drivers/media/dvb/frontends/sp887x.h b/drivers/media/dvb/frontends/sp887x.h
index cab7ea644dfa..7ee78d7d916d 100644
--- a/drivers/media/dvb/frontends/sp887x.h
+++ b/drivers/media/dvb/frontends/sp887x.h
@@ -17,7 +17,7 @@ struct sp887x_config
17 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name); 17 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);
18}; 18};
19 19
20#if defined(CONFIG_DVB_SP887X) || defined(CONFIG_DVB_SP887X_MODULE) 20#if defined(CONFIG_DVB_SP887X) || (defined(CONFIG_DVB_SP887X_MODULE) && defined(MODULE))
21extern struct dvb_frontend* sp887x_attach(const struct sp887x_config* config, 21extern struct dvb_frontend* sp887x_attach(const struct sp887x_config* config,
22 struct i2c_adapter* i2c); 22 struct i2c_adapter* i2c);
23#else 23#else
diff --git a/drivers/media/dvb/frontends/stv0297.h b/drivers/media/dvb/frontends/stv0297.h
index 760b80db43a5..69f4515df2b9 100644
--- a/drivers/media/dvb/frontends/stv0297.h
+++ b/drivers/media/dvb/frontends/stv0297.h
@@ -42,7 +42,7 @@ struct stv0297_config
42 u8 stop_during_read:1; 42 u8 stop_during_read:1;
43}; 43};
44 44
45#if defined(CONFIG_DVB_STV0297) || defined(CONFIG_DVB_STV0297_MODULE) 45#if defined(CONFIG_DVB_STV0297) || (defined(CONFIG_DVB_STV0297_MODULE) && defined(MODULE))
46extern struct dvb_frontend* stv0297_attach(const struct stv0297_config* config, 46extern struct dvb_frontend* stv0297_attach(const struct stv0297_config* config,
47 struct i2c_adapter* i2c); 47 struct i2c_adapter* i2c);
48#else 48#else
diff --git a/drivers/media/dvb/frontends/stv0299.h b/drivers/media/dvb/frontends/stv0299.h
index 7ef25207081d..33df9495908f 100644
--- a/drivers/media/dvb/frontends/stv0299.h
+++ b/drivers/media/dvb/frontends/stv0299.h
@@ -89,7 +89,7 @@ struct stv0299_config
89 int (*set_symbol_rate)(struct dvb_frontend* fe, u32 srate, u32 ratio); 89 int (*set_symbol_rate)(struct dvb_frontend* fe, u32 srate, u32 ratio);
90}; 90};
91 91
92#if defined(CONFIG_DVB_STV0299) || defined(CONFIG_DVB_STV0299_MODULE) 92#if defined(CONFIG_DVB_STV0299) || (defined(CONFIG_DVB_STV0299_MODULE) && defined(MODULE))
93extern struct dvb_frontend* stv0299_attach(const struct stv0299_config* config, 93extern struct dvb_frontend* stv0299_attach(const struct stv0299_config* config,
94 struct i2c_adapter* i2c); 94 struct i2c_adapter* i2c);
95#else 95#else
diff --git a/drivers/media/dvb/frontends/tda10021.h b/drivers/media/dvb/frontends/tda10021.h
index d68ae20c8412..e3da780108f6 100644
--- a/drivers/media/dvb/frontends/tda10021.h
+++ b/drivers/media/dvb/frontends/tda10021.h
@@ -32,7 +32,7 @@ struct tda10021_config
32 u8 demod_address; 32 u8 demod_address;
33}; 33};
34 34
35#if defined(CONFIG_DVB_TDA10021) || defined(CONFIG_DVB_TDA10021_MODULE) 35#if defined(CONFIG_DVB_TDA10021) || (defined(CONFIG_DVB_TDA10021_MODULE) && defined(MODULE))
36extern struct dvb_frontend* tda10021_attach(const struct tda10021_config* config, 36extern struct dvb_frontend* tda10021_attach(const struct tda10021_config* config,
37 struct i2c_adapter* i2c, u8 pwm); 37 struct i2c_adapter* i2c, u8 pwm);
38#else 38#else
diff --git a/drivers/media/dvb/frontends/tda1004x.h b/drivers/media/dvb/frontends/tda1004x.h
index e28fca05734c..605ad2dfc09d 100644
--- a/drivers/media/dvb/frontends/tda1004x.h
+++ b/drivers/media/dvb/frontends/tda1004x.h
@@ -71,7 +71,7 @@ struct tda1004x_config
71 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name); 71 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);
72}; 72};
73 73
74#if defined(CONFIG_DVB_TDA1004X) || defined(CONFIG_DVB_TDA1004X_MODULE) 74#if defined(CONFIG_DVB_TDA1004X) || (defined(CONFIG_DVB_TDA1004X_MODULE) && defined(MODULE))
75extern struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config, 75extern struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config,
76 struct i2c_adapter* i2c); 76 struct i2c_adapter* i2c);
77 77
diff --git a/drivers/media/dvb/frontends/tda10086.h b/drivers/media/dvb/frontends/tda10086.h
index e8061db11123..ed584a8f4a89 100644
--- a/drivers/media/dvb/frontends/tda10086.h
+++ b/drivers/media/dvb/frontends/tda10086.h
@@ -35,7 +35,16 @@ struct tda10086_config
35 u8 invert; 35 u8 invert;
36}; 36};
37 37
38#if defined(CONFIG_DVB_TDA10086) || (defined(CONFIG_DVB_TDA10086_MODULE) && defined(MODULE))
38extern struct dvb_frontend* tda10086_attach(const struct tda10086_config* config, 39extern struct dvb_frontend* tda10086_attach(const struct tda10086_config* config,
39 struct i2c_adapter* i2c); 40 struct i2c_adapter* i2c);
41#else
42static inline struct dvb_frontend* tda10086_attach(const struct tda10086_config* config,
43 struct i2c_adapter* i2c)
44{
45 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
46 return NULL;
47}
48#endif // CONFIG_DVB_TDA10086
40 49
41#endif // TDA10086_H 50#endif // TDA10086_H
diff --git a/drivers/media/dvb/frontends/tda8083.h b/drivers/media/dvb/frontends/tda8083.h
index aae15bdce6eb..2d3307999f21 100644
--- a/drivers/media/dvb/frontends/tda8083.h
+++ b/drivers/media/dvb/frontends/tda8083.h
@@ -35,7 +35,7 @@ struct tda8083_config
35 u8 demod_address; 35 u8 demod_address;
36}; 36};
37 37
38#if defined(CONFIG_DVB_TDA8083) || defined(CONFIG_DVB_TDA8083_MODULE) 38#if defined(CONFIG_DVB_TDA8083) || (defined(CONFIG_DVB_TDA8083_MODULE) && defined(MODULE))
39extern struct dvb_frontend* tda8083_attach(const struct tda8083_config* config, 39extern struct dvb_frontend* tda8083_attach(const struct tda8083_config* config,
40 struct i2c_adapter* i2c); 40 struct i2c_adapter* i2c);
41#else 41#else
diff --git a/drivers/media/dvb/frontends/tda826x.c b/drivers/media/dvb/frontends/tda826x.c
index eeab26bd36ed..34815b0b97e4 100644
--- a/drivers/media/dvb/frontends/tda826x.c
+++ b/drivers/media/dvb/frontends/tda826x.c
@@ -121,7 +121,7 @@ static struct dvb_tuner_ops tda826x_tuner_ops = {
121 .info = { 121 .info = {
122 .name = "Philips TDA826X", 122 .name = "Philips TDA826X",
123 .frequency_min = 950000, 123 .frequency_min = 950000,
124 .frequency_min = 2175000 124 .frequency_max = 2175000
125 }, 125 },
126 .release = tda826x_release, 126 .release = tda826x_release,
127 .sleep = tda826x_sleep, 127 .sleep = tda826x_sleep,
diff --git a/drivers/media/dvb/frontends/tda826x.h b/drivers/media/dvb/frontends/tda826x.h
index 3307607632b0..ad9981195961 100644
--- a/drivers/media/dvb/frontends/tda826x.h
+++ b/drivers/media/dvb/frontends/tda826x.h
@@ -35,6 +35,19 @@
35 * @param has_loopthrough Set to 1 if the card has a loopthrough RF connector. 35 * @param has_loopthrough Set to 1 if the card has a loopthrough RF connector.
36 * @return FE pointer on success, NULL on failure. 36 * @return FE pointer on success, NULL on failure.
37 */ 37 */
38extern struct dvb_frontend *tda826x_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c, int has_loopthrough); 38#if defined(CONFIG_DVB_TDA826X) || (defined(CONFIG_DVB_TDA826X_MODULE) && defined(MODULE))
39 39extern struct dvb_frontend* tda826x_attach(struct dvb_frontend *fe, int addr,
40#endif 40 struct i2c_adapter *i2c,
41 int has_loopthrough);
42#else
43static inline struct dvb_frontend* tda826x_attach(struct dvb_frontend *fe,
44 int addr,
45 struct i2c_adapter *i2c,
46 int has_loopthrough)
47{
48 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
49 return NULL;
50}
51#endif // CONFIG_DVB_TDA826X
52
53#endif // __DVB_TDA826X_H__
diff --git a/drivers/media/dvb/frontends/tua6100.h b/drivers/media/dvb/frontends/tua6100.h
index 8f98033ffa7b..03a665e7df6d 100644
--- a/drivers/media/dvb/frontends/tua6100.h
+++ b/drivers/media/dvb/frontends/tua6100.h
@@ -34,7 +34,7 @@
34#include <linux/i2c.h> 34#include <linux/i2c.h>
35#include "dvb_frontend.h" 35#include "dvb_frontend.h"
36 36
37#if defined(CONFIG_DVB_TUA6100) || defined(CONFIG_DVB_TUA6100_MODULE) 37#if defined(CONFIG_DVB_TUA6100) || (defined(CONFIG_DVB_TUA6100_MODULE) && defined(MODULE))
38extern struct dvb_frontend *tua6100_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c); 38extern struct dvb_frontend *tua6100_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c);
39#else 39#else
40static inline struct dvb_frontend* tua6100_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c) 40static inline struct dvb_frontend* tua6100_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c)
diff --git a/drivers/media/dvb/frontends/ves1820.h b/drivers/media/dvb/frontends/ves1820.h
index f0c9dded39d7..e4a2a324046a 100644
--- a/drivers/media/dvb/frontends/ves1820.h
+++ b/drivers/media/dvb/frontends/ves1820.h
@@ -41,7 +41,7 @@ struct ves1820_config
41 u8 selagc:1; 41 u8 selagc:1;
42}; 42};
43 43
44#if defined(CONFIG_DVB_VES1820) || defined(CONFIG_DVB_VES1820_MODULE) 44#if defined(CONFIG_DVB_VES1820) || (defined(CONFIG_DVB_VES1820_MODULE) && defined(MODULE))
45extern struct dvb_frontend* ves1820_attach(const struct ves1820_config* config, 45extern struct dvb_frontend* ves1820_attach(const struct ves1820_config* config,
46 struct i2c_adapter* i2c, u8 pwm); 46 struct i2c_adapter* i2c, u8 pwm);
47#else 47#else
diff --git a/drivers/media/dvb/frontends/ves1x93.h b/drivers/media/dvb/frontends/ves1x93.h
index 395fed39b286..d507f8966f81 100644
--- a/drivers/media/dvb/frontends/ves1x93.h
+++ b/drivers/media/dvb/frontends/ves1x93.h
@@ -40,7 +40,7 @@ struct ves1x93_config
40 u8 invert_pwm:1; 40 u8 invert_pwm:1;
41}; 41};
42 42
43#if defined(CONFIG_DVB_VES1X93) || defined(CONFIG_DVB_VES1X93_MODULE) 43#if defined(CONFIG_DVB_VES1X93) || (defined(CONFIG_DVB_VES1X93_MODULE) && defined(MODULE))
44extern struct dvb_frontend* ves1x93_attach(const struct ves1x93_config* config, 44extern struct dvb_frontend* ves1x93_attach(const struct ves1x93_config* config,
45 struct i2c_adapter* i2c); 45 struct i2c_adapter* i2c);
46#else 46#else
diff --git a/drivers/media/dvb/frontends/zl10353.h b/drivers/media/dvb/frontends/zl10353.h
index 79a947215c4d..0bc0109737f1 100644
--- a/drivers/media/dvb/frontends/zl10353.h
+++ b/drivers/media/dvb/frontends/zl10353.h
@@ -36,7 +36,7 @@ struct zl10353_config
36 int parallel_ts; 36 int parallel_ts;
37}; 37};
38 38
39#if defined(CONFIG_DVB_ZL10353) || defined(CONFIG_DVB_ZL10353_MODULE) 39#if defined(CONFIG_DVB_ZL10353) || (defined(CONFIG_DVB_ZL10353_MODULE) && defined(MODULE))
40extern struct dvb_frontend* zl10353_attach(const struct zl10353_config *config, 40extern struct dvb_frontend* zl10353_attach(const struct zl10353_config *config,
41 struct i2c_adapter *i2c); 41 struct i2c_adapter *i2c);
42#else 42#else
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c
index 2a2e9b400613..cd5ec489af1c 100644
--- a/drivers/media/dvb/ttpci/budget-ci.c
+++ b/drivers/media/dvb/ttpci/budget-ci.c
@@ -46,7 +46,14 @@
46#include "bsbe1.h" 46#include "bsbe1.h"
47#include "bsru6.h" 47#include "bsru6.h"
48 48
49#define DEBIADDR_IR 0x1234 49/*
50 * Regarding DEBIADDR_IR:
51 * Some CI modules hang if random addresses are read.
52 * Using address 0x4000 for the IR read means that we
53 * use the same address as for CI version, which should
54 * be a safe default.
55 */
56#define DEBIADDR_IR 0x4000
50#define DEBIADDR_CICONTROL 0x0000 57#define DEBIADDR_CICONTROL 0x0000
51#define DEBIADDR_CIVERSION 0x4000 58#define DEBIADDR_CIVERSION 0x4000
52#define DEBIADDR_IO 0x1000 59#define DEBIADDR_IO 0x1000
@@ -1028,6 +1035,7 @@ static void frontend_init(struct budget_ci *budget_ci)
1028 1035
1029 case 0x1012: // TT DVB-T CI budget (tda10046/Philips tdm1316l(tda6651tt)) 1036 case 0x1012: // TT DVB-T CI budget (tda10046/Philips tdm1316l(tda6651tt))
1030 budget_ci->tuner_pll_address = 0x60; 1037 budget_ci->tuner_pll_address = 0x60;
1038 philips_tdm1316l_config.invert = 1;
1031 budget_ci->budget.dvb_frontend = 1039 budget_ci->budget.dvb_frontend =
1032 dvb_attach(tda10046_attach, &philips_tdm1316l_config, &budget_ci->budget.i2c_adap); 1040 dvb_attach(tda10046_attach, &philips_tdm1316l_config, &budget_ci->budget.i2c_adap);
1033 if (budget_ci->budget.dvb_frontend) { 1041 if (budget_ci->budget.dvb_frontend) {
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index afb734df6e05..bf267552941f 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -186,7 +186,7 @@ config VIDEO_KS0127
186 186
187config VIDEO_SAA7110 187config VIDEO_SAA7110
188 tristate "Philips SAA7110 video decoder" 188 tristate "Philips SAA7110 video decoder"
189 depends on VIDEO_V4L1 189 depends on VIDEO_V4L1 && I2C
190 ---help--- 190 ---help---
191 Support for the Philips SAA7110 video decoders. 191 Support for the Philips SAA7110 video decoders.
192 192
@@ -677,6 +677,8 @@ config VIDEO_M32R_AR_M64278
677menu "V4L USB devices" 677menu "V4L USB devices"
678 depends on USB && VIDEO_DEV 678 depends on USB && VIDEO_DEV
679 679
680source "drivers/media/video/pvrusb2/Kconfig"
681
680source "drivers/media/video/em28xx/Kconfig" 682source "drivers/media/video/em28xx/Kconfig"
681 683
682source "drivers/media/video/usbvideo/Kconfig" 684source "drivers/media/video/usbvideo/Kconfig"
diff --git a/drivers/media/video/bt8xx/bttv-cards.c b/drivers/media/video/bt8xx/bttv-cards.c
index a84903e0d810..21ebe8f13815 100644
--- a/drivers/media/video/bt8xx/bttv-cards.c
+++ b/drivers/media/video/bt8xx/bttv-cards.c
@@ -4001,7 +4001,7 @@ static void __devinit init_PXC200(struct bttv *btv)
4001 * - sleep 1ms 4001 * - sleep 1ms
4002 * - write 0x0E 4002 * - write 0x0E
4003 * read from GPIO_DATA into buf (uint_32) 4003 * read from GPIO_DATA into buf (uint_32)
4004 * - if ( buf>>18 & 0x01 ) || ( buf>>19 && 0x01 != 0 ) 4004 * - if ( buf>>18 & 0x01 ) || ( buf>>19 & 0x01 != 0 )
4005 * error. ERROR_CPLD_Check_Failed. 4005 * error. ERROR_CPLD_Check_Failed.
4006 */ 4006 */
4007/* ----------------------------------------------------------------------- */ 4007/* ----------------------------------------------------------------------- */
diff --git a/drivers/media/video/cx25840/cx25840-vbi.c b/drivers/media/video/cx25840/cx25840-vbi.c
index 48014a254e15..f85f2084324f 100644
--- a/drivers/media/video/cx25840/cx25840-vbi.c
+++ b/drivers/media/video/cx25840/cx25840-vbi.c
@@ -235,6 +235,7 @@ int cx25840_vbi(struct i2c_client *client, unsigned int cmd, void *arg)
235 0, 0, V4L2_SLICED_VPS, 0, 0, /* 9 */ 235 0, 0, V4L2_SLICED_VPS, 0, 0, /* 9 */
236 0, 0, 0, 0 236 0, 0, 0, 0
237 }; 237 };
238 int is_pal = !(cx25840_get_v4lstd(client) & V4L2_STD_525_60);
238 int i; 239 int i;
239 240
240 fmt = arg; 241 fmt = arg;
@@ -246,13 +247,25 @@ int cx25840_vbi(struct i2c_client *client, unsigned int cmd, void *arg)
246 if ((cx25840_read(client, 0x404) & 0x10) == 0) 247 if ((cx25840_read(client, 0x404) & 0x10) == 0)
247 break; 248 break;
248 249
249 for (i = 7; i <= 23; i++) { 250 if (is_pal) {
250 u8 v = cx25840_read(client, 0x424 + i - 7); 251 for (i = 7; i <= 23; i++) {
252 u8 v = cx25840_read(client, 0x424 + i - 7);
253
254 svbi->service_lines[0][i] = lcr2vbi[v >> 4];
255 svbi->service_lines[1][i] = lcr2vbi[v & 0xf];
256 svbi->service_set |=
257 svbi->service_lines[0][i] | svbi->service_lines[1][i];
258 }
259 }
260 else {
261 for (i = 10; i <= 21; i++) {
262 u8 v = cx25840_read(client, 0x424 + i - 10);
251 263
252 svbi->service_lines[0][i] = lcr2vbi[v >> 4]; 264 svbi->service_lines[0][i] = lcr2vbi[v >> 4];
253 svbi->service_lines[1][i] = lcr2vbi[v & 0xf]; 265 svbi->service_lines[1][i] = lcr2vbi[v & 0xf];
254 svbi->service_set |= 266 svbi->service_set |=
255 svbi->service_lines[0][i] | svbi->service_lines[1][i]; 267 svbi->service_lines[0][i] | svbi->service_lines[1][i];
268 }
256 } 269 }
257 break; 270 break;
258 } 271 }
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c
index af71d4225c76..f764a57c56be 100644
--- a/drivers/media/video/cx88/cx88-cards.c
+++ b/drivers/media/video/cx88/cx88-cards.c
@@ -1230,6 +1230,7 @@ struct cx88_board cx88_boards[] = {
1230 .vmux = 2, 1230 .vmux = 2,
1231 .gpio0 = 0x84bf, 1231 .gpio0 = 0x84bf,
1232 }}, 1232 }},
1233 .mpeg = CX88_MPEG_DVB,
1233 }, 1234 },
1234 [CX88_BOARD_NORWOOD_MICRO] = { 1235 [CX88_BOARD_NORWOOD_MICRO] = {
1235 .name = "Norwood Micro TV Tuner", 1236 .name = "Norwood Micro TV Tuner",
@@ -1590,6 +1591,18 @@ struct cx88_subid cx88_subids[] = {
1590 .subvendor = 0x0070, 1591 .subvendor = 0x0070,
1591 .subdevice = 0x9000, 1592 .subdevice = 0x9000,
1592 .card = CX88_BOARD_HAUPPAUGE_DVB_T1, 1593 .card = CX88_BOARD_HAUPPAUGE_DVB_T1,
1594 },{
1595 .subvendor = 0x0070,
1596 .subdevice = 0x1400,
1597 .card = CX88_BOARD_HAUPPAUGE_HVR3000,
1598 },{
1599 .subvendor = 0x0070,
1600 .subdevice = 0x1401,
1601 .card = CX88_BOARD_HAUPPAUGE_HVR3000,
1602 },{
1603 .subvendor = 0x0070,
1604 .subdevice = 0x1402,
1605 .card = CX88_BOARD_HAUPPAUGE_HVR3000,
1593 }, 1606 },
1594}; 1607};
1595const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids); 1608const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids);
@@ -1633,7 +1646,15 @@ static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data)
1633 /* Make sure we support the board model */ 1646 /* Make sure we support the board model */
1634 switch (tv.model) 1647 switch (tv.model)
1635 { 1648 {
1649 case 14009: /* WinTV-HVR3000 (Retail, IR, b/panel video, 3.5mm audio in) */
1650 case 14019: /* WinTV-HVR3000 (Retail, IR Blaster, b/panel video, 3.5mm audio in) */
1651 case 14029: /* WinTV-HVR3000 (Retail, IR, b/panel video, 3.5mm audio in - 880 bridge) */
1652 case 14109: /* WinTV-HVR3000 (Retail, IR, b/panel video, 3.5mm audio in - low profile) */
1653 case 14129: /* WinTV-HVR3000 (Retail, IR, b/panel video, 3.5mm audio in - 880 bridge - LP) */
1654 case 14559: /* WinTV-HVR3000 (OEM, no IR, b/panel video, 3.5mm audio in) */
1636 case 14569: /* WinTV-HVR3000 (OEM, no IR, no back panel video) */ 1655 case 14569: /* WinTV-HVR3000 (OEM, no IR, no back panel video) */
1656 case 14659: /* WinTV-HVR3000 (OEM, no IR, b/panel video, RCA audio in - Low profile) */
1657 case 14669: /* WinTV-HVR3000 (OEM, no IR, no b/panel video - Low profile) */
1637 case 28552: /* WinTV-PVR 'Roslyn' (No IR) */ 1658 case 28552: /* WinTV-PVR 'Roslyn' (No IR) */
1638 case 34519: /* WinTV-PCI-FM */ 1659 case 34519: /* WinTV-PCI-FM */
1639 case 90002: /* Nova-T-PCI (9002) */ 1660 case 90002: /* Nova-T-PCI (9002) */
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index bd0c8797f26d..0ef13e7efa2e 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -315,15 +315,22 @@ static struct cx22702_config hauppauge_novat_config = {
315 .demod_address = 0x43, 315 .demod_address = 0x43,
316 .output_mode = CX22702_SERIAL_OUTPUT, 316 .output_mode = CX22702_SERIAL_OUTPUT,
317}; 317};
318
318static struct cx22702_config hauppauge_hvr1100_config = { 319static struct cx22702_config hauppauge_hvr1100_config = {
319 .demod_address = 0x63, 320 .demod_address = 0x63,
320 .output_mode = CX22702_SERIAL_OUTPUT, 321 .output_mode = CX22702_SERIAL_OUTPUT,
321}; 322};
323
322static struct cx22702_config hauppauge_hvr1300_config = { 324static struct cx22702_config hauppauge_hvr1300_config = {
323 .demod_address = 0x63, 325 .demod_address = 0x63,
324 .output_mode = CX22702_SERIAL_OUTPUT, 326 .output_mode = CX22702_SERIAL_OUTPUT,
325}; 327};
326 328
329static struct cx22702_config hauppauge_hvr3000_config = {
330 .demod_address = 0x63,
331 .output_mode = CX22702_SERIAL_OUTPUT,
332};
333
327static int or51132_set_ts_param(struct dvb_frontend* fe, 334static int or51132_set_ts_param(struct dvb_frontend* fe,
328 int is_punctured) 335 int is_punctured)
329{ 336{
@@ -558,6 +565,16 @@ static int dvb_register(struct cx8802_dev *dev)
558 &dvb_pll_fmd1216me); 565 &dvb_pll_fmd1216me);
559 } 566 }
560 break; 567 break;
568 case CX88_BOARD_HAUPPAUGE_HVR3000:
569 dev->dvb.frontend = dvb_attach(cx22702_attach,
570 &hauppauge_hvr3000_config,
571 &dev->core->i2c_adap);
572 if (dev->dvb.frontend != NULL) {
573 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
574 &dev->core->i2c_adap,
575 &dvb_pll_fmd1216me);
576 }
577 break;
561 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS: 578 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
562 dev->dvb.frontend = dvb_attach(mt352_attach, 579 dev->dvb.frontend = dvb_attach(mt352_attach,
563 &dvico_fusionhdtv, 580 &dvico_fusionhdtv,
diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c
index 83ebf7a3c054..57e1c024a547 100644
--- a/drivers/media/video/cx88/cx88-input.c
+++ b/drivers/media/video/cx88/cx88-input.c
@@ -196,18 +196,25 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
196 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: 196 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
197 case CX88_BOARD_HAUPPAUGE_HVR1100: 197 case CX88_BOARD_HAUPPAUGE_HVR1100:
198 case CX88_BOARD_HAUPPAUGE_HVR1300: 198 case CX88_BOARD_HAUPPAUGE_HVR1300:
199 case CX88_BOARD_HAUPPAUGE_HVR3000:
199 ir_codes = ir_codes_hauppauge_new; 200 ir_codes = ir_codes_hauppauge_new;
200 ir_type = IR_TYPE_RC5; 201 ir_type = IR_TYPE_RC5;
201 ir->sampling = 1; 202 ir->sampling = 1;
202 break; 203 break;
203 case CX88_BOARD_WINFAST_DTV2000H: 204 case CX88_BOARD_WINFAST_DTV2000H:
204 case CX88_BOARD_WINFAST2000XP_EXPERT:
205 ir_codes = ir_codes_winfast; 205 ir_codes = ir_codes_winfast;
206 ir->gpio_addr = MO_GP0_IO; 206 ir->gpio_addr = MO_GP0_IO;
207 ir->mask_keycode = 0x8f8; 207 ir->mask_keycode = 0x8f8;
208 ir->mask_keyup = 0x100; 208 ir->mask_keyup = 0x100;
209 ir->polling = 50; /* ms */ 209 ir->polling = 50; /* ms */
210 break; 210 break;
211 case CX88_BOARD_WINFAST2000XP_EXPERT:
212 ir_codes = ir_codes_winfast;
213 ir->gpio_addr = MO_GP0_IO;
214 ir->mask_keycode = 0x8f8;
215 ir->mask_keyup = 0x100;
216 ir->polling = 1; /* ms */
217 break;
211 case CX88_BOARD_IODATA_GVBCTV7E: 218 case CX88_BOARD_IODATA_GVBCTV7E:
212 ir_codes = ir_codes_iodata_bctv7e; 219 ir_codes = ir_codes_iodata_bctv7e;
213 ir->gpio_addr = MO_GP0_IO; 220 ir->gpio_addr = MO_GP0_IO;
@@ -215,7 +222,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
215 ir->mask_keydown = 0x02; 222 ir->mask_keydown = 0x02;
216 ir->polling = 5; /* ms */ 223 ir->polling = 5; /* ms */
217 break; 224 break;
218 case CX88_BOARD_PROLINK_PLAYTVPVR: 225 case CX88_BOARD_PROLINK_PLAYTVPVR:
219 case CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO: 226 case CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO:
220 ir_codes = ir_codes_pixelview; 227 ir_codes = ir_codes_pixelview;
221 ir->gpio_addr = MO_GP1_IO; 228 ir->gpio_addr = MO_GP1_IO;
@@ -419,6 +426,7 @@ void cx88_ir_irq(struct cx88_core *core)
419 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: 426 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
420 case CX88_BOARD_HAUPPAUGE_HVR1100: 427 case CX88_BOARD_HAUPPAUGE_HVR1100:
421 case CX88_BOARD_HAUPPAUGE_HVR1300: 428 case CX88_BOARD_HAUPPAUGE_HVR1300:
429 case CX88_BOARD_HAUPPAUGE_HVR3000:
422 ircode = ir_decode_biphase(ir->samples, ir->scount, 5, 7); 430 ircode = ir_decode_biphase(ir->samples, ir->scount, 5, 7);
423 ir_dprintk("biphase decoded: %x\n", ircode); 431 ir_dprintk("biphase decoded: %x\n", ircode);
424 if ((ircode & 0xfffff000) != 0x3000) 432 if ((ircode & 0xfffff000) != 0x3000)
diff --git a/drivers/media/video/et61x251/et61x251_core.c b/drivers/media/video/et61x251/et61x251_core.c
index bc544cc7ccb8..f786ab11d2cd 100644
--- a/drivers/media/video/et61x251/et61x251_core.c
+++ b/drivers/media/video/et61x251/et61x251_core.c
@@ -973,16 +973,32 @@ static CLASS_DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR,
973 et61x251_show_i2c_val, et61x251_store_i2c_val); 973 et61x251_show_i2c_val, et61x251_store_i2c_val);
974 974
975 975
976static void et61x251_create_sysfs(struct et61x251_device* cam) 976static int et61x251_create_sysfs(struct et61x251_device* cam)
977{ 977{
978 struct video_device *v4ldev = cam->v4ldev; 978 struct video_device *v4ldev = cam->v4ldev;
979 int rc;
979 980
980 video_device_create_file(v4ldev, &class_device_attr_reg); 981 rc = video_device_create_file(v4ldev, &class_device_attr_reg);
981 video_device_create_file(v4ldev, &class_device_attr_val); 982 if (rc) goto err;
983 rc = video_device_create_file(v4ldev, &class_device_attr_val);
984 if (rc) goto err_reg;
982 if (cam->sensor.sysfs_ops) { 985 if (cam->sensor.sysfs_ops) {
983 video_device_create_file(v4ldev, &class_device_attr_i2c_reg); 986 rc = video_device_create_file(v4ldev, &class_device_attr_i2c_reg);
984 video_device_create_file(v4ldev, &class_device_attr_i2c_val); 987 if (rc) goto err_val;
988 rc = video_device_create_file(v4ldev, &class_device_attr_i2c_val);
989 if (rc) goto err_i2c_reg;
985 } 990 }
991
992 return 0;
993
994err_i2c_reg:
995 video_device_remove_file(v4ldev, &class_device_attr_i2c_reg);
996err_val:
997 video_device_remove_file(v4ldev, &class_device_attr_val);
998err_reg:
999 video_device_remove_file(v4ldev, &class_device_attr_reg);
1000err:
1001 return rc;
986} 1002}
987#endif /* CONFIG_VIDEO_ADV_DEBUG */ 1003#endif /* CONFIG_VIDEO_ADV_DEBUG */
988 1004
@@ -2534,7 +2550,9 @@ et61x251_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
2534 dev_nr = (dev_nr < ET61X251_MAX_DEVICES-1) ? dev_nr+1 : 0; 2550 dev_nr = (dev_nr < ET61X251_MAX_DEVICES-1) ? dev_nr+1 : 0;
2535 2551
2536#ifdef CONFIG_VIDEO_ADV_DEBUG 2552#ifdef CONFIG_VIDEO_ADV_DEBUG
2537 et61x251_create_sysfs(cam); 2553 err = et61x251_create_sysfs(cam);
2554 if (err)
2555 goto fail2;
2538 DBG(2, "Optional device control through 'sysfs' interface ready"); 2556 DBG(2, "Optional device control through 'sysfs' interface ready");
2539#endif 2557#endif
2540 2558
@@ -2544,6 +2562,13 @@ et61x251_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
2544 2562
2545 return 0; 2563 return 0;
2546 2564
2565#ifdef CONFIG_VIDEO_ADV_DEBUG
2566fail2:
2567 video_nr[dev_nr] = -1;
2568 dev_nr = (dev_nr < ET61X251_MAX_DEVICES-1) ? dev_nr+1 : 0;
2569 mutex_unlock(&cam->dev_mutex);
2570 video_unregister_device(cam->v4ldev);
2571#endif
2547fail: 2572fail:
2548 if (cam) { 2573 if (cam) {
2549 kfree(cam->control_buffer); 2574 kfree(cam->control_buffer);
diff --git a/drivers/media/video/ov511.c b/drivers/media/video/ov511.c
index ce4886f1528d..b4db2cbb5a84 100644
--- a/drivers/media/video/ov511.c
+++ b/drivers/media/video/ov511.c
@@ -5648,17 +5648,49 @@ static ssize_t show_exposure(struct class_device *cd, char *buf)
5648} 5648}
5649static CLASS_DEVICE_ATTR(exposure, S_IRUGO, show_exposure, NULL); 5649static CLASS_DEVICE_ATTR(exposure, S_IRUGO, show_exposure, NULL);
5650 5650
5651static void ov_create_sysfs(struct video_device *vdev) 5651static int ov_create_sysfs(struct video_device *vdev)
5652{ 5652{
5653 video_device_create_file(vdev, &class_device_attr_custom_id); 5653 int rc;
5654 video_device_create_file(vdev, &class_device_attr_model); 5654
5655 video_device_create_file(vdev, &class_device_attr_bridge); 5655 rc = video_device_create_file(vdev, &class_device_attr_custom_id);
5656 video_device_create_file(vdev, &class_device_attr_sensor); 5656 if (rc) goto err;
5657 video_device_create_file(vdev, &class_device_attr_brightness); 5657 rc = video_device_create_file(vdev, &class_device_attr_model);
5658 video_device_create_file(vdev, &class_device_attr_saturation); 5658 if (rc) goto err_id;
5659 video_device_create_file(vdev, &class_device_attr_contrast); 5659 rc = video_device_create_file(vdev, &class_device_attr_bridge);
5660 video_device_create_file(vdev, &class_device_attr_hue); 5660 if (rc) goto err_model;
5661 video_device_create_file(vdev, &class_device_attr_exposure); 5661 rc = video_device_create_file(vdev, &class_device_attr_sensor);
5662 if (rc) goto err_bridge;
5663 rc = video_device_create_file(vdev, &class_device_attr_brightness);
5664 if (rc) goto err_sensor;
5665 rc = video_device_create_file(vdev, &class_device_attr_saturation);
5666 if (rc) goto err_bright;
5667 rc = video_device_create_file(vdev, &class_device_attr_contrast);
5668 if (rc) goto err_sat;
5669 rc = video_device_create_file(vdev, &class_device_attr_hue);
5670 if (rc) goto err_contrast;
5671 rc = video_device_create_file(vdev, &class_device_attr_exposure);
5672 if (rc) goto err_hue;
5673
5674 return 0;
5675
5676err_hue:
5677 video_device_remove_file(vdev, &class_device_attr_hue);
5678err_contrast:
5679 video_device_remove_file(vdev, &class_device_attr_contrast);
5680err_sat:
5681 video_device_remove_file(vdev, &class_device_attr_saturation);
5682err_bright:
5683 video_device_remove_file(vdev, &class_device_attr_brightness);
5684err_sensor:
5685 video_device_remove_file(vdev, &class_device_attr_sensor);
5686err_bridge:
5687 video_device_remove_file(vdev, &class_device_attr_bridge);
5688err_model:
5689 video_device_remove_file(vdev, &class_device_attr_model);
5690err_id:
5691 video_device_remove_file(vdev, &class_device_attr_custom_id);
5692err:
5693 return rc;
5662} 5694}
5663 5695
5664/**************************************************************************** 5696/****************************************************************************
@@ -5817,7 +5849,11 @@ ov51x_probe(struct usb_interface *intf, const struct usb_device_id *id)
5817 ov->vdev->minor); 5849 ov->vdev->minor);
5818 5850
5819 usb_set_intfdata(intf, ov); 5851 usb_set_intfdata(intf, ov);
5820 ov_create_sysfs(ov->vdev); 5852 if (ov_create_sysfs(ov->vdev)) {
5853 err("ov_create_sysfs failed");
5854 goto error;
5855 }
5856
5821 return 0; 5857 return 0;
5822 5858
5823error: 5859error:
diff --git a/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c b/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
index df8feac16aee..c80c26be6e4d 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
@@ -221,7 +221,7 @@ static unsigned int decoder_describe(struct pvr2_v4l_cx2584x *ctxt,
221static void decoder_reset(struct pvr2_v4l_cx2584x *ctxt) 221static void decoder_reset(struct pvr2_v4l_cx2584x *ctxt)
222{ 222{
223 int ret; 223 int ret;
224 ret = pvr2_i2c_client_cmd(ctxt->client,VIDIOC_INT_RESET,0); 224 ret = pvr2_i2c_client_cmd(ctxt->client,VIDIOC_INT_RESET,NULL);
225 pvr2_trace(PVR2_TRACE_CHIPS,"i2c cx25840 decoder_reset (ret=%d)",ret); 225 pvr2_trace(PVR2_TRACE_CHIPS,"i2c cx25840 decoder_reset (ret=%d)",ret);
226} 226}
227 227
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
index 97e974d9b9c3..bb40e9085977 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
@@ -711,8 +711,8 @@ static void pvr2_v4l2_dev_destroy(struct pvr2_v4l2_dev *dip)
711 dip->devbase.minor,pvr2_config_get_name(dip->config)); 711 dip->devbase.minor,pvr2_config_get_name(dip->config));
712 712
713 /* Paranoia */ 713 /* Paranoia */
714 dip->v4lp = 0; 714 dip->v4lp = NULL;
715 dip->stream = 0; 715 dip->stream = NULL;
716 716
717 /* Actual deallocation happens later when all internal references 717 /* Actual deallocation happens later when all internal references
718 are gone. */ 718 are gone. */
@@ -1076,7 +1076,7 @@ struct pvr2_v4l2 *pvr2_v4l2_create(struct pvr2_context *mnp)
1076 vp->vdev = kmalloc(sizeof(*vp->vdev),GFP_KERNEL); 1076 vp->vdev = kmalloc(sizeof(*vp->vdev),GFP_KERNEL);
1077 if (!vp->vdev) { 1077 if (!vp->vdev) {
1078 kfree(vp); 1078 kfree(vp);
1079 return 0; 1079 return NULL;
1080 } 1080 }
1081 memset(vp->vdev,0,sizeof(*vp->vdev)); 1081 memset(vp->vdev,0,sizeof(*vp->vdev));
1082 pvr2_channel_init(&vp->channel,mnp); 1082 pvr2_channel_init(&vp->channel,mnp);
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index c77b85cf3d80..46c114830884 100644
--- a/drivers/media/video/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -1024,12 +1024,25 @@ static ssize_t show_snapshot_button_status(struct class_device *class_dev, char
1024static CLASS_DEVICE_ATTR(button, S_IRUGO | S_IWUSR, show_snapshot_button_status, 1024static CLASS_DEVICE_ATTR(button, S_IRUGO | S_IWUSR, show_snapshot_button_status,
1025 NULL); 1025 NULL);
1026 1026
1027static void pwc_create_sysfs_files(struct video_device *vdev) 1027static int pwc_create_sysfs_files(struct video_device *vdev)
1028{ 1028{
1029 struct pwc_device *pdev = video_get_drvdata(vdev); 1029 struct pwc_device *pdev = video_get_drvdata(vdev);
1030 if (pdev->features & FEATURE_MOTOR_PANTILT) 1030 int rc;
1031 video_device_create_file(vdev, &class_device_attr_pan_tilt); 1031
1032 video_device_create_file(vdev, &class_device_attr_button); 1032 rc = video_device_create_file(vdev, &class_device_attr_button);
1033 if (rc)
1034 goto err;
1035 if (pdev->features & FEATURE_MOTOR_PANTILT) {
1036 rc = video_device_create_file(vdev,&class_device_attr_pan_tilt);
1037 if (rc) goto err_button;
1038 }
1039
1040 return 0;
1041
1042err_button:
1043 video_device_remove_file(vdev, &class_device_attr_button);
1044err:
1045 return rc;
1033} 1046}
1034 1047
1035static void pwc_remove_sysfs_files(struct video_device *vdev) 1048static void pwc_remove_sysfs_files(struct video_device *vdev)
@@ -1408,7 +1421,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1408 struct usb_device *udev = interface_to_usbdev(intf); 1421 struct usb_device *udev = interface_to_usbdev(intf);
1409 struct pwc_device *pdev = NULL; 1422 struct pwc_device *pdev = NULL;
1410 int vendor_id, product_id, type_id; 1423 int vendor_id, product_id, type_id;
1411 int i, hint; 1424 int i, hint, rc;
1412 int features = 0; 1425 int features = 0;
1413 int video_nr = -1; /* default: use next available device */ 1426 int video_nr = -1; /* default: use next available device */
1414 char serial_number[30], *name; 1427 char serial_number[30], *name;
@@ -1709,9 +1722,8 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1709 i = video_register_device(pdev->vdev, VFL_TYPE_GRABBER, video_nr); 1722 i = video_register_device(pdev->vdev, VFL_TYPE_GRABBER, video_nr);
1710 if (i < 0) { 1723 if (i < 0) {
1711 PWC_ERROR("Failed to register as video device (%d).\n", i); 1724 PWC_ERROR("Failed to register as video device (%d).\n", i);
1712 video_device_release(pdev->vdev); /* Drip... drip... drip... */ 1725 rc = i;
1713 kfree(pdev); /* Oops, no memory leaks please */ 1726 goto err;
1714 return -EIO;
1715 } 1727 }
1716 else { 1728 else {
1717 PWC_INFO("Registered as /dev/video%d.\n", pdev->vdev->minor & 0x3F); 1729 PWC_INFO("Registered as /dev/video%d.\n", pdev->vdev->minor & 0x3F);
@@ -1723,13 +1735,24 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1723 1735
1724 PWC_DEBUG_PROBE("probe() function returning struct at 0x%p.\n", pdev); 1736 PWC_DEBUG_PROBE("probe() function returning struct at 0x%p.\n", pdev);
1725 usb_set_intfdata (intf, pdev); 1737 usb_set_intfdata (intf, pdev);
1726 pwc_create_sysfs_files(pdev->vdev); 1738 rc = pwc_create_sysfs_files(pdev->vdev);
1739 if (rc)
1740 goto err_unreg;
1727 1741
1728 /* Set the leds off */ 1742 /* Set the leds off */
1729 pwc_set_leds(pdev, 0, 0); 1743 pwc_set_leds(pdev, 0, 0);
1730 pwc_camera_power(pdev, 0); 1744 pwc_camera_power(pdev, 0);
1731 1745
1732 return 0; 1746 return 0;
1747
1748err_unreg:
1749 if (hint < MAX_DEV_HINTS)
1750 device_hint[hint].pdev = NULL;
1751 video_unregister_device(pdev->vdev);
1752err:
1753 video_device_release(pdev->vdev); /* Drip... drip... drip... */
1754 kfree(pdev); /* Oops, no memory leaks please */
1755 return rc;
1733} 1756}
1734 1757
1735/* The user janked out the cable... */ 1758/* The user janked out the cable... */
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c
index 974179d4d389..c5719f7bd1ac 100644
--- a/drivers/media/video/saa7115.c
+++ b/drivers/media/video/saa7115.c
@@ -960,6 +960,8 @@ static void saa711x_set_v4lstd(struct i2c_client *client, v4l2_std_id std)
960 reg |= 0x10; 960 reg |= 0x10;
961 } else if (std == V4L2_STD_NTSC_M_JP) { 961 } else if (std == V4L2_STD_NTSC_M_JP) {
962 reg |= 0x40; 962 reg |= 0x40;
963 } else if (std == V4L2_STD_SECAM) {
964 reg |= 0x50;
963 } 965 }
964 saa711x_write(client, R_0E_CHROMA_CNTL_1, reg); 966 saa711x_write(client, R_0E_CHROMA_CNTL_1, reg);
965 } else { 967 } else {
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
index c9d8e3b9cc37..51f0cfdcb680 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++ b/drivers/media/video/saa7134/saa7134-cards.c
@@ -2969,7 +2969,7 @@ struct saa7134_board saa7134_boards[] = {
2969 /* Petr Baudis <pasky@ucw.cz> */ 2969 /* Petr Baudis <pasky@ucw.cz> */
2970 .name = "AVerMedia TV Hybrid A16AR", 2970 .name = "AVerMedia TV Hybrid A16AR",
2971 .audio_clock = 0x187de7, 2971 .audio_clock = 0x187de7,
2972 .tuner_type = TUNER_PHILIPS_TDA8290, /* untested */ 2972 .tuner_type = TUNER_PHILIPS_TD1316, /* untested */
2973 .radio_type = TUNER_TEA5767, /* untested */ 2973 .radio_type = TUNER_TEA5767, /* untested */
2974 .tuner_addr = ADDR_UNSET, 2974 .tuner_addr = ADDR_UNSET,
2975 .radio_addr = ADDR_UNSET, 2975 .radio_addr = ADDR_UNSET,
@@ -3718,6 +3718,7 @@ int saa7134_board_init1(struct saa7134_dev *dev)
3718 case SAA7134_BOARD_AVERMEDIA_STUDIO_307: 3718 case SAA7134_BOARD_AVERMEDIA_STUDIO_307:
3719 case SAA7134_BOARD_AVERMEDIA_307: 3719 case SAA7134_BOARD_AVERMEDIA_307:
3720 case SAA7134_BOARD_AVERMEDIA_GO_007_FM: 3720 case SAA7134_BOARD_AVERMEDIA_GO_007_FM:
3721 case SAA7134_BOARD_AVERMEDIA_777:
3721/* case SAA7134_BOARD_SABRENT_SBTTVFM: */ /* not finished yet */ 3722/* case SAA7134_BOARD_SABRENT_SBTTVFM: */ /* not finished yet */
3722 case SAA7134_BOARD_VIDEOMATE_TV_PVR: 3723 case SAA7134_BOARD_VIDEOMATE_TV_PVR:
3723 case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS: 3724 case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS:
@@ -3734,6 +3735,7 @@ int saa7134_board_init1(struct saa7134_dev *dev)
3734 case SAA7134_BOARD_FLYDVBT_LR301: 3735 case SAA7134_BOARD_FLYDVBT_LR301:
3735 case SAA7134_BOARD_FLYDVBTDUO: 3736 case SAA7134_BOARD_FLYDVBTDUO:
3736 case SAA7134_BOARD_PROTEUS_2309: 3737 case SAA7134_BOARD_PROTEUS_2309:
3738 case SAA7134_BOARD_AVERMEDIA_A16AR:
3737 dev->has_remote = SAA7134_REMOTE_GPIO; 3739 dev->has_remote = SAA7134_REMOTE_GPIO;
3738 break; 3740 break;
3739 case SAA7134_BOARD_FLYDVBS_LR300: 3741 case SAA7134_BOARD_FLYDVBS_LR300:
@@ -3772,7 +3774,6 @@ int saa7134_board_init1(struct saa7134_dev *dev)
3772 saa_writeb(SAA7134_GPIO_GPMODE3, 0x08); 3774 saa_writeb(SAA7134_GPIO_GPMODE3, 0x08);
3773 saa_writeb(SAA7134_GPIO_GPSTATUS3, 0x00); 3775 saa_writeb(SAA7134_GPIO_GPSTATUS3, 0x00);
3774 break; 3776 break;
3775 case SAA7134_BOARD_AVERMEDIA_A16AR:
3776 case SAA7134_BOARD_AVERMEDIA_CARDBUS: 3777 case SAA7134_BOARD_AVERMEDIA_CARDBUS:
3777 /* power-up tuner chip */ 3778 /* power-up tuner chip */
3778 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0xffffffff, 0xffffffff); 3779 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0xffffffff, 0xffffffff);
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index 1ba53b525ad2..6b61d9b2fcb5 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -1147,6 +1147,8 @@ static int dvb_init(struct saa7134_dev *dev)
1147 &philips_europa_config, 1147 &philips_europa_config,
1148 &dev->i2c_adap); 1148 &dev->i2c_adap);
1149 if (dev->dvb.frontend) { 1149 if (dev->dvb.frontend) {
1150 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1151 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1150 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init; 1152 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1151 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep; 1153 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1152 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params; 1154 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c
index ff5991136f4e..dee83552e681 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -185,7 +185,6 @@ int saa7134_input_init1(struct saa7134_dev *dev)
185 case SAA7134_BOARD_AVERMEDIA_STUDIO_305: 185 case SAA7134_BOARD_AVERMEDIA_STUDIO_305:
186 case SAA7134_BOARD_AVERMEDIA_STUDIO_307: 186 case SAA7134_BOARD_AVERMEDIA_STUDIO_307:
187 case SAA7134_BOARD_AVERMEDIA_GO_007_FM: 187 case SAA7134_BOARD_AVERMEDIA_GO_007_FM:
188 case SAA7134_BOARD_AVERMEDIA_A16AR:
189 ir_codes = ir_codes_avermedia; 188 ir_codes = ir_codes_avermedia;
190 mask_keycode = 0x0007C8; 189 mask_keycode = 0x0007C8;
191 mask_keydown = 0x000010; 190 mask_keydown = 0x000010;
@@ -194,6 +193,16 @@ int saa7134_input_init1(struct saa7134_dev *dev)
194 saa_setb(SAA7134_GPIO_GPMODE0, 0x4); 193 saa_setb(SAA7134_GPIO_GPMODE0, 0x4);
195 saa_setb(SAA7134_GPIO_GPSTATUS0, 0x4); 194 saa_setb(SAA7134_GPIO_GPSTATUS0, 0x4);
196 break; 195 break;
196 case SAA7134_BOARD_AVERMEDIA_777:
197 case SAA7134_BOARD_AVERMEDIA_A16AR:
198 ir_codes = ir_codes_avermedia;
199 mask_keycode = 0x02F200;
200 mask_keydown = 0x000400;
201 polling = 50; // ms
202 /* Without this we won't receive key up events */
203 saa_setb(SAA7134_GPIO_GPMODE1, 0x1);
204 saa_setb(SAA7134_GPIO_GPSTATUS1, 0x1);
205 break;
197 case SAA7134_BOARD_KWORLD_TERMINATOR: 206 case SAA7134_BOARD_KWORLD_TERMINATOR:
198 ir_codes = ir_codes_pixelview; 207 ir_codes = ir_codes_pixelview;
199 mask_keycode = 0x00001f; 208 mask_keycode = 0x00001f;
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
index 203302f21827..830617ea81cc 100644
--- a/drivers/media/video/saa7134/saa7134-video.c
+++ b/drivers/media/video/saa7134/saa7134-video.c
@@ -2248,7 +2248,11 @@ static int radio_do_ioctl(struct inode *inode, struct file *file,
2248 t->type = V4L2_TUNER_RADIO; 2248 t->type = V4L2_TUNER_RADIO;
2249 2249
2250 saa7134_i2c_call_clients(dev, VIDIOC_G_TUNER, t); 2250 saa7134_i2c_call_clients(dev, VIDIOC_G_TUNER, t);
2251 2251 if (dev->input->amux == TV) {
2252 t->signal = 0xf800 - ((saa_readb(0x581) & 0x1f) << 11);
2253 t->rxsubchans = (saa_readb(0x529) & 0x08) ?
2254 V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO;
2255 }
2252 return 0; 2256 return 0;
2253 } 2257 }
2254 case VIDIOC_S_TUNER: 2258 case VIDIOC_S_TUNER:
diff --git a/drivers/media/video/sn9c102/sn9c102_core.c b/drivers/media/video/sn9c102/sn9c102_core.c
index 3e0ff8a78468..a4702d3c2aca 100644
--- a/drivers/media/video/sn9c102/sn9c102_core.c
+++ b/drivers/media/video/sn9c102/sn9c102_core.c
@@ -1240,23 +1240,53 @@ static CLASS_DEVICE_ATTR(frame_header, S_IRUGO,
1240 sn9c102_show_frame_header, NULL); 1240 sn9c102_show_frame_header, NULL);
1241 1241
1242 1242
1243static void sn9c102_create_sysfs(struct sn9c102_device* cam) 1243static int sn9c102_create_sysfs(struct sn9c102_device* cam)
1244{ 1244{
1245 struct video_device *v4ldev = cam->v4ldev; 1245 struct video_device *v4ldev = cam->v4ldev;
1246 int rc;
1247
1248 rc = video_device_create_file(v4ldev, &class_device_attr_reg);
1249 if (rc) goto err;
1250 rc = video_device_create_file(v4ldev, &class_device_attr_val);
1251 if (rc) goto err_reg;
1252 rc = video_device_create_file(v4ldev, &class_device_attr_frame_header);
1253 if (rc) goto err_val;
1246 1254
1247 video_device_create_file(v4ldev, &class_device_attr_reg);
1248 video_device_create_file(v4ldev, &class_device_attr_val);
1249 video_device_create_file(v4ldev, &class_device_attr_frame_header);
1250 if (cam->bridge == BRIDGE_SN9C101 || cam->bridge == BRIDGE_SN9C102)
1251 video_device_create_file(v4ldev, &class_device_attr_green);
1252 else if (cam->bridge == BRIDGE_SN9C103) {
1253 video_device_create_file(v4ldev, &class_device_attr_blue);
1254 video_device_create_file(v4ldev, &class_device_attr_red);
1255 }
1256 if (cam->sensor.sysfs_ops) { 1255 if (cam->sensor.sysfs_ops) {
1257 video_device_create_file(v4ldev, &class_device_attr_i2c_reg); 1256 rc = video_device_create_file(v4ldev, &class_device_attr_i2c_reg);
1258 video_device_create_file(v4ldev, &class_device_attr_i2c_val); 1257 if (rc) goto err_frhead;
1258 rc = video_device_create_file(v4ldev, &class_device_attr_i2c_val);
1259 if (rc) goto err_i2c_reg;
1260 }
1261
1262 if (cam->bridge == BRIDGE_SN9C101 || cam->bridge == BRIDGE_SN9C102) {
1263 rc = video_device_create_file(v4ldev, &class_device_attr_green);
1264 if (rc) goto err_i2c_val;
1265 } else if (cam->bridge == BRIDGE_SN9C103) {
1266 rc = video_device_create_file(v4ldev, &class_device_attr_blue);
1267 if (rc) goto err_i2c_val;
1268 rc = video_device_create_file(v4ldev, &class_device_attr_red);
1269 if (rc) goto err_blue;
1259 } 1270 }
1271
1272 return 0;
1273
1274err_blue:
1275 video_device_remove_file(v4ldev, &class_device_attr_blue);
1276err_i2c_val:
1277 if (cam->sensor.sysfs_ops)
1278 video_device_remove_file(v4ldev, &class_device_attr_i2c_val);
1279err_i2c_reg:
1280 if (cam->sensor.sysfs_ops)
1281 video_device_remove_file(v4ldev, &class_device_attr_i2c_reg);
1282err_frhead:
1283 video_device_remove_file(v4ldev, &class_device_attr_frame_header);
1284err_val:
1285 video_device_remove_file(v4ldev, &class_device_attr_val);
1286err_reg:
1287 video_device_remove_file(v4ldev, &class_device_attr_reg);
1288err:
1289 return rc;
1260} 1290}
1261#endif /* CONFIG_VIDEO_ADV_DEBUG */ 1291#endif /* CONFIG_VIDEO_ADV_DEBUG */
1262 1292
@@ -2809,10 +2839,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
2809 DBG(1, "V4L2 device registration failed"); 2839 DBG(1, "V4L2 device registration failed");
2810 if (err == -ENFILE && video_nr[dev_nr] == -1) 2840 if (err == -ENFILE && video_nr[dev_nr] == -1)
2811 DBG(1, "Free /dev/videoX node not found"); 2841 DBG(1, "Free /dev/videoX node not found");
2812 video_nr[dev_nr] = -1; 2842 goto fail2;
2813 dev_nr = (dev_nr < SN9C102_MAX_DEVICES-1) ? dev_nr+1 : 0;
2814 mutex_unlock(&cam->dev_mutex);
2815 goto fail;
2816 } 2843 }
2817 2844
2818 DBG(2, "V4L2 device registered as /dev/video%d", cam->v4ldev->minor); 2845 DBG(2, "V4L2 device registered as /dev/video%d", cam->v4ldev->minor);
@@ -2823,7 +2850,9 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
2823 dev_nr = (dev_nr < SN9C102_MAX_DEVICES-1) ? dev_nr+1 : 0; 2850 dev_nr = (dev_nr < SN9C102_MAX_DEVICES-1) ? dev_nr+1 : 0;
2824 2851
2825#ifdef CONFIG_VIDEO_ADV_DEBUG 2852#ifdef CONFIG_VIDEO_ADV_DEBUG
2826 sn9c102_create_sysfs(cam); 2853 err = sn9c102_create_sysfs(cam);
2854 if (err)
2855 goto fail3;
2827 DBG(2, "Optional device control through 'sysfs' interface ready"); 2856 DBG(2, "Optional device control through 'sysfs' interface ready");
2828#endif 2857#endif
2829 2858
@@ -2833,6 +2862,14 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
2833 2862
2834 return 0; 2863 return 0;
2835 2864
2865#ifdef CONFIG_VIDEO_ADV_DEBUG
2866fail3:
2867 video_unregister_device(cam->v4ldev);
2868#endif
2869fail2:
2870 video_nr[dev_nr] = -1;
2871 dev_nr = (dev_nr < SN9C102_MAX_DEVICES-1) ? dev_nr+1 : 0;
2872 mutex_unlock(&cam->dev_mutex);
2836fail: 2873fail:
2837 if (cam) { 2874 if (cam) {
2838 kfree(cam->control_buffer); 2875 kfree(cam->control_buffer);
diff --git a/drivers/media/video/stv680.c b/drivers/media/video/stv680.c
index 87e11300181d..6d1ef1e2e8ef 100644
--- a/drivers/media/video/stv680.c
+++ b/drivers/media/video/stv680.c
@@ -516,16 +516,45 @@ stv680_file(frames_read, framecount, "%d\n");
516stv680_file(packets_dropped, dropped, "%d\n"); 516stv680_file(packets_dropped, dropped, "%d\n");
517stv680_file(decoding_errors, error, "%d\n"); 517stv680_file(decoding_errors, error, "%d\n");
518 518
519static void stv680_create_sysfs_files(struct video_device *vdev) 519static int stv680_create_sysfs_files(struct video_device *vdev)
520{ 520{
521 video_device_create_file(vdev, &class_device_attr_model); 521 int rc;
522 video_device_create_file(vdev, &class_device_attr_in_use); 522
523 video_device_create_file(vdev, &class_device_attr_streaming); 523 rc = video_device_create_file(vdev, &class_device_attr_model);
524 video_device_create_file(vdev, &class_device_attr_palette); 524 if (rc) goto err;
525 video_device_create_file(vdev, &class_device_attr_frames_total); 525 rc = video_device_create_file(vdev, &class_device_attr_in_use);
526 video_device_create_file(vdev, &class_device_attr_frames_read); 526 if (rc) goto err_model;
527 video_device_create_file(vdev, &class_device_attr_packets_dropped); 527 rc = video_device_create_file(vdev, &class_device_attr_streaming);
528 video_device_create_file(vdev, &class_device_attr_decoding_errors); 528 if (rc) goto err_inuse;
529 rc = video_device_create_file(vdev, &class_device_attr_palette);
530 if (rc) goto err_stream;
531 rc = video_device_create_file(vdev, &class_device_attr_frames_total);
532 if (rc) goto err_pal;
533 rc = video_device_create_file(vdev, &class_device_attr_frames_read);
534 if (rc) goto err_framtot;
535 rc = video_device_create_file(vdev, &class_device_attr_packets_dropped);
536 if (rc) goto err_framread;
537 rc = video_device_create_file(vdev, &class_device_attr_decoding_errors);
538 if (rc) goto err_dropped;
539
540 return 0;
541
542err_dropped:
543 video_device_remove_file(vdev, &class_device_attr_packets_dropped);
544err_framread:
545 video_device_remove_file(vdev, &class_device_attr_frames_read);
546err_framtot:
547 video_device_remove_file(vdev, &class_device_attr_frames_total);
548err_pal:
549 video_device_remove_file(vdev, &class_device_attr_palette);
550err_stream:
551 video_device_remove_file(vdev, &class_device_attr_streaming);
552err_inuse:
553 video_device_remove_file(vdev, &class_device_attr_in_use);
554err_model:
555 video_device_remove_file(vdev, &class_device_attr_model);
556err:
557 return rc;
529} 558}
530 559
531static void stv680_remove_sysfs_files(struct video_device *vdev) 560static void stv680_remove_sysfs_files(struct video_device *vdev)
@@ -1418,9 +1447,13 @@ static int stv680_probe (struct usb_interface *intf, const struct usb_device_id
1418 PDEBUG (0, "STV(i): registered new video device: video%d", stv680->vdev->minor); 1447 PDEBUG (0, "STV(i): registered new video device: video%d", stv680->vdev->minor);
1419 1448
1420 usb_set_intfdata (intf, stv680); 1449 usb_set_intfdata (intf, stv680);
1421 stv680_create_sysfs_files(stv680->vdev); 1450 retval = stv680_create_sysfs_files(stv680->vdev);
1451 if (retval)
1452 goto error_unreg;
1422 return 0; 1453 return 0;
1423 1454
1455error_unreg:
1456 video_unregister_device(stv680->vdev);
1424error_vdev: 1457error_vdev:
1425 video_device_release(stv680->vdev); 1458 video_device_release(stv680->vdev);
1426error: 1459error:
diff --git a/drivers/media/video/tuner-types.c b/drivers/media/video/tuner-types.c
index 8fff642fad56..781682373b61 100644
--- a/drivers/media/video/tuner-types.c
+++ b/drivers/media/video/tuner-types.c
@@ -1046,7 +1046,6 @@ static struct tuner_params tuner_samsung_tcpn_2121p30a_params[] = {
1046 .type = TUNER_PARAM_TYPE_NTSC, 1046 .type = TUNER_PARAM_TYPE_NTSC,
1047 .ranges = tuner_samsung_tcpn_2121p30a_ntsc_ranges, 1047 .ranges = tuner_samsung_tcpn_2121p30a_ntsc_ranges,
1048 .count = ARRAY_SIZE(tuner_samsung_tcpn_2121p30a_ntsc_ranges), 1048 .count = ARRAY_SIZE(tuner_samsung_tcpn_2121p30a_ntsc_ranges),
1049 .has_tda9887 = 1,
1050 }, 1049 },
1051}; 1050};
1052 1051
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index e6baaee038bf..6b9ef731b83a 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -468,7 +468,7 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
468 (eeprom_data[i+6] << 8) + 468 (eeprom_data[i+6] << 8) +
469 (eeprom_data[i+7] << 16); 469 (eeprom_data[i+7] << 16);
470 470
471 if ( (eeprom_data[i + 8] && 0xf0) && 471 if ( (eeprom_data[i + 8] & 0xf0) &&
472 (tvee->serial_number < 0xffffff) ) { 472 (tvee->serial_number < 0xffffff) ) {
473 tvee->MAC_address[0] = 0x00; 473 tvee->MAC_address[0] = 0x00;
474 tvee->MAC_address[1] = 0x0D; 474 tvee->MAC_address[1] = 0x0D;
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c
index 479a0675cf60..d424a4129d69 100644
--- a/drivers/media/video/videodev.c
+++ b/drivers/media/video/videodev.c
@@ -17,10 +17,11 @@
17 */ 17 */
18 18
19#define dbgarg(cmd, fmt, arg...) \ 19#define dbgarg(cmd, fmt, arg...) \
20 if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) \ 20 if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) { \
21 printk (KERN_DEBUG "%s: ", vfd->name); \ 21 printk (KERN_DEBUG "%s: ", vfd->name); \
22 v4l_printk_ioctl(cmd); \ 22 v4l_printk_ioctl(cmd); \
23 printk (KERN_DEBUG "%s: " fmt, vfd->name, ## arg); 23 printk (KERN_DEBUG "%s: " fmt, vfd->name, ## arg); \
24 }
24 25
25#define dbgarg2(fmt, arg...) \ 26#define dbgarg2(fmt, arg...) \
26 if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) \ 27 if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) \
@@ -1287,6 +1288,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
1287 ret=vfd->vidioc_g_parm(file, fh, p); 1288 ret=vfd->vidioc_g_parm(file, fh, p);
1288 } else { 1289 } else {
1289 struct v4l2_standard s; 1290 struct v4l2_standard s;
1291 int i;
1290 1292
1291 if (!vfd->tvnormsize) { 1293 if (!vfd->tvnormsize) {
1292 printk (KERN_WARNING "%s: no TV norms defined!\n", 1294 printk (KERN_WARNING "%s: no TV norms defined!\n",
@@ -1297,8 +1299,14 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
1297 if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 1299 if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1298 return -EINVAL; 1300 return -EINVAL;
1299 1301
1300 v4l2_video_std_construct(&s, vfd->tvnorms[vfd->current_norm].id, 1302 for (i = 0; i < vfd->tvnormsize; i++)
1301 vfd->tvnorms[vfd->current_norm].name); 1303 if (vfd->tvnorms[i].id == vfd->current_norm)
1304 break;
1305 if (i >= vfd->tvnormsize)
1306 return -EINVAL;
1307
1308 v4l2_video_std_construct(&s, vfd->current_norm,
1309 vfd->tvnorms[i].name);
1302 1310
1303 memset(p,0,sizeof(*p)); 1311 memset(p,0,sizeof(*p));
1304 1312
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index e7c01d560b64..3c8dc72dc8e9 100644
--- a/drivers/media/video/vivi.c
+++ b/drivers/media/video/vivi.c
@@ -272,7 +272,7 @@ static void gen_line(struct sg_to_addr to_addr[],int inipos,int pages,int wmax,
272 272
273 /* Get first addr pointed to pixel position */ 273 /* Get first addr pointed to pixel position */
274 oldpg=get_addr_pos(pos,pages,to_addr); 274 oldpg=get_addr_pos(pos,pages,to_addr);
275 pg=pfn_to_page(to_addr[oldpg].sg->dma_address >> PAGE_SHIFT); 275 pg=pfn_to_page(sg_dma_address(to_addr[oldpg].sg) >> PAGE_SHIFT);
276 basep = kmap_atomic(pg, KM_BOUNCE_READ)+to_addr[oldpg].sg->offset; 276 basep = kmap_atomic(pg, KM_BOUNCE_READ)+to_addr[oldpg].sg->offset;
277 277
278 /* We will just duplicate the second pixel at the packet */ 278 /* We will just duplicate the second pixel at the packet */
@@ -287,7 +287,7 @@ static void gen_line(struct sg_to_addr to_addr[],int inipos,int pages,int wmax,
287 for (color=0;color<4;color++) { 287 for (color=0;color<4;color++) {
288 pgpos=get_addr_pos(pos,pages,to_addr); 288 pgpos=get_addr_pos(pos,pages,to_addr);
289 if (pgpos!=oldpg) { 289 if (pgpos!=oldpg) {
290 pg=pfn_to_page(to_addr[pgpos].sg->dma_address >> PAGE_SHIFT); 290 pg=pfn_to_page(sg_dma_address(to_addr[pgpos].sg) >> PAGE_SHIFT);
291 kunmap_atomic(basep, KM_BOUNCE_READ); 291 kunmap_atomic(basep, KM_BOUNCE_READ);
292 basep= kmap_atomic(pg, KM_BOUNCE_READ)+to_addr[pgpos].sg->offset; 292 basep= kmap_atomic(pg, KM_BOUNCE_READ)+to_addr[pgpos].sg->offset;
293 oldpg=pgpos; 293 oldpg=pgpos;
@@ -339,8 +339,8 @@ static void gen_line(struct sg_to_addr to_addr[],int inipos,int pages,int wmax,
339 for (color=0;color<4;color++) { 339 for (color=0;color<4;color++) {
340 pgpos=get_addr_pos(pos,pages,to_addr); 340 pgpos=get_addr_pos(pos,pages,to_addr);
341 if (pgpos!=oldpg) { 341 if (pgpos!=oldpg) {
342 pg=pfn_to_page(to_addr[pgpos]. 342 pg=pfn_to_page(sg_dma_address(
343 sg->dma_address 343 to_addr[pgpos].sg)
344 >> PAGE_SHIFT); 344 >> PAGE_SHIFT);
345 kunmap_atomic(basep, 345 kunmap_atomic(basep,
346 KM_BOUNCE_READ); 346 KM_BOUNCE_READ);
@@ -386,7 +386,7 @@ static void vivi_fillbuff(struct vivi_dev *dev,struct vivi_buffer *buf)
386 struct timeval ts; 386 struct timeval ts;
387 387
388 /* Test if DMA mapping is ready */ 388 /* Test if DMA mapping is ready */
389 if (!vb->dma.sglist[0].dma_address) 389 if (!sg_dma_address(&vb->dma.sglist[0]))
390 return; 390 return;
391 391
392 prep_to_addr(to_addr,vb); 392 prep_to_addr(to_addr,vb);
@@ -783,7 +783,7 @@ static int vivi_map_sg(void *dev, struct scatterlist *sg, int nents,
783 for (i = 0; i < nents; i++ ) { 783 for (i = 0; i < nents; i++ ) {
784 BUG_ON(!sg[i].page); 784 BUG_ON(!sg[i].page);
785 785
786 sg[i].dma_address = page_to_phys(sg[i].page) + sg[i].offset; 786 sg_dma_address(&sg[i]) = page_to_phys(sg[i].page) + sg[i].offset;
787 } 787 }
788 788
789 return nents; 789 return nents;
diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h
index c537d71c18e4..a4afad4ecab2 100644
--- a/drivers/message/fusion/mptbase.h
+++ b/drivers/message/fusion/mptbase.h
@@ -75,8 +75,8 @@
75#define COPYRIGHT "Copyright (c) 1999-2005 " MODULEAUTHOR 75#define COPYRIGHT "Copyright (c) 1999-2005 " MODULEAUTHOR
76#endif 76#endif
77 77
78#define MPT_LINUX_VERSION_COMMON "3.04.01" 78#define MPT_LINUX_VERSION_COMMON "3.04.02"
79#define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.04.01" 79#define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.04.02"
80#define WHAT_MAGIC_STRING "@" "(" "#" ")" 80#define WHAT_MAGIC_STRING "@" "(" "#" ")"
81 81
82#define show_mptmod_ver(s,ver) \ 82#define show_mptmod_ver(s,ver) \
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index e57bb035a021..1dd491773150 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -96,6 +96,10 @@ static int mptfc_qcmd(struct scsi_cmnd *SCpnt,
96static void mptfc_target_destroy(struct scsi_target *starget); 96static void mptfc_target_destroy(struct scsi_target *starget);
97static void mptfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout); 97static void mptfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout);
98static void __devexit mptfc_remove(struct pci_dev *pdev); 98static void __devexit mptfc_remove(struct pci_dev *pdev);
99static int mptfc_abort(struct scsi_cmnd *SCpnt);
100static int mptfc_dev_reset(struct scsi_cmnd *SCpnt);
101static int mptfc_bus_reset(struct scsi_cmnd *SCpnt);
102static int mptfc_host_reset(struct scsi_cmnd *SCpnt);
99 103
100static struct scsi_host_template mptfc_driver_template = { 104static struct scsi_host_template mptfc_driver_template = {
101 .module = THIS_MODULE, 105 .module = THIS_MODULE,
@@ -110,10 +114,10 @@ static struct scsi_host_template mptfc_driver_template = {
110 .target_destroy = mptfc_target_destroy, 114 .target_destroy = mptfc_target_destroy,
111 .slave_destroy = mptscsih_slave_destroy, 115 .slave_destroy = mptscsih_slave_destroy,
112 .change_queue_depth = mptscsih_change_queue_depth, 116 .change_queue_depth = mptscsih_change_queue_depth,
113 .eh_abort_handler = mptscsih_abort, 117 .eh_abort_handler = mptfc_abort,
114 .eh_device_reset_handler = mptscsih_dev_reset, 118 .eh_device_reset_handler = mptfc_dev_reset,
115 .eh_bus_reset_handler = mptscsih_bus_reset, 119 .eh_bus_reset_handler = mptfc_bus_reset,
116 .eh_host_reset_handler = mptscsih_host_reset, 120 .eh_host_reset_handler = mptfc_host_reset,
117 .bios_param = mptscsih_bios_param, 121 .bios_param = mptscsih_bios_param,
118 .can_queue = MPT_FC_CAN_QUEUE, 122 .can_queue = MPT_FC_CAN_QUEUE,
119 .this_id = -1, 123 .this_id = -1,
@@ -171,6 +175,77 @@ static struct fc_function_template mptfc_transport_functions = {
171 .show_host_symbolic_name = 1, 175 .show_host_symbolic_name = 1,
172}; 176};
173 177
178static int
179mptfc_block_error_handler(struct scsi_cmnd *SCpnt,
180 int (*func)(struct scsi_cmnd *SCpnt),
181 const char *caller)
182{
183 struct scsi_device *sdev = SCpnt->device;
184 struct Scsi_Host *shost = sdev->host;
185 struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
186 unsigned long flags;
187 int ready;
188
189 spin_lock_irqsave(shost->host_lock, flags);
190 while ((ready = fc_remote_port_chkready(rport) >> 16) == DID_IMM_RETRY) {
191 spin_unlock_irqrestore(shost->host_lock, flags);
192 dfcprintk ((MYIOC_s_INFO_FMT
193 "mptfc_block_error_handler.%d: %d:%d, port status is "
194 "DID_IMM_RETRY, deferring %s recovery.\n",
195 ((MPT_SCSI_HOST *) shost->hostdata)->ioc->name,
196 ((MPT_SCSI_HOST *) shost->hostdata)->ioc->sh->host_no,
197 SCpnt->device->id,SCpnt->device->lun,caller));
198 msleep(1000);
199 spin_lock_irqsave(shost->host_lock, flags);
200 }
201 spin_unlock_irqrestore(shost->host_lock, flags);
202
203 if (ready == DID_NO_CONNECT || !SCpnt->device->hostdata) {
204 dfcprintk ((MYIOC_s_INFO_FMT
205 "%s.%d: %d:%d, failing recovery, "
206 "port state %d, vdev %p.\n", caller,
207 ((MPT_SCSI_HOST *) shost->hostdata)->ioc->name,
208 ((MPT_SCSI_HOST *) shost->hostdata)->ioc->sh->host_no,
209 SCpnt->device->id,SCpnt->device->lun,ready,
210 SCpnt->device->hostdata));
211 return FAILED;
212 }
213 dfcprintk ((MYIOC_s_INFO_FMT
214 "%s.%d: %d:%d, executing recovery.\n", caller,
215 ((MPT_SCSI_HOST *) shost->hostdata)->ioc->name,
216 ((MPT_SCSI_HOST *) shost->hostdata)->ioc->sh->host_no,
217 SCpnt->device->id,SCpnt->device->lun));
218 return (*func)(SCpnt);
219}
220
221static int
222mptfc_abort(struct scsi_cmnd *SCpnt)
223{
224 return
225 mptfc_block_error_handler(SCpnt, mptscsih_abort, __FUNCTION__);
226}
227
228static int
229mptfc_dev_reset(struct scsi_cmnd *SCpnt)
230{
231 return
232 mptfc_block_error_handler(SCpnt, mptscsih_dev_reset, __FUNCTION__);
233}
234
235static int
236mptfc_bus_reset(struct scsi_cmnd *SCpnt)
237{
238 return
239 mptfc_block_error_handler(SCpnt, mptscsih_bus_reset, __FUNCTION__);
240}
241
242static int
243mptfc_host_reset(struct scsi_cmnd *SCpnt)
244{
245 return
246 mptfc_block_error_handler(SCpnt, mptscsih_host_reset, __FUNCTION__);
247}
248
174static void 249static void
175mptfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) 250mptfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout)
176{ 251{
@@ -562,6 +637,12 @@ mptfc_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
562 return 0; 637 return 0;
563 } 638 }
564 639
640 if (!SCpnt->device->hostdata) { /* vdev */
641 SCpnt->result = DID_NO_CONNECT << 16;
642 done(SCpnt);
643 return 0;
644 }
645
565 /* dd_data is null until finished adding target */ 646 /* dd_data is null until finished adding target */
566 ri = *((struct mptfc_rport_info **)rport->dd_data); 647 ri = *((struct mptfc_rport_info **)rport->dd_data);
567 if (unlikely(!ri)) { 648 if (unlikely(!ri)) {
diff --git a/drivers/message/i2o/bus-osm.c b/drivers/message/i2o/bus-osm.c
index ac06f10c54ec..d96c687aee93 100644
--- a/drivers/message/i2o/bus-osm.c
+++ b/drivers/message/i2o/bus-osm.c
@@ -80,18 +80,26 @@ static DEVICE_ATTR(scan, S_IWUSR, NULL, i2o_bus_store_scan);
80 * @dev: device to verify if it is a I2O Bus Adapter device 80 * @dev: device to verify if it is a I2O Bus Adapter device
81 * 81 *
82 * Because we want all Bus Adapters always return 0. 82 * Because we want all Bus Adapters always return 0.
83 * Except when we fail. Then we are sad.
83 * 84 *
84 * Returns 0. 85 * Returns 0, except when we fail to excel.
85 */ 86 */
86static int i2o_bus_probe(struct device *dev) 87static int i2o_bus_probe(struct device *dev)
87{ 88{
88 struct i2o_device *i2o_dev = to_i2o_device(get_device(dev)); 89 struct i2o_device *i2o_dev = to_i2o_device(get_device(dev));
90 int rc;
89 91
90 device_create_file(dev, &dev_attr_scan); 92 rc = device_create_file(dev, &dev_attr_scan);
93 if (rc)
94 goto err_out;
91 95
92 osm_info("device added (TID: %03x)\n", i2o_dev->lct_data.tid); 96 osm_info("device added (TID: %03x)\n", i2o_dev->lct_data.tid);
93 97
94 return 0; 98 return 0;
99
100err_out:
101 put_device(dev);
102 return rc;
95}; 103};
96 104
97/** 105/**
diff --git a/drivers/message/i2o/exec-osm.c b/drivers/message/i2o/exec-osm.c
index 7bd4d85d0b42..a2350640384b 100644
--- a/drivers/message/i2o/exec-osm.c
+++ b/drivers/message/i2o/exec-osm.c
@@ -124,10 +124,10 @@ static void i2o_exec_wait_free(struct i2o_exec_wait *wait)
124int i2o_msg_post_wait_mem(struct i2o_controller *c, struct i2o_message *msg, 124int i2o_msg_post_wait_mem(struct i2o_controller *c, struct i2o_message *msg,
125 unsigned long timeout, struct i2o_dma *dma) 125 unsigned long timeout, struct i2o_dma *dma)
126{ 126{
127 DECLARE_WAIT_QUEUE_HEAD(wq); 127 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);
128 struct i2o_exec_wait *wait; 128 struct i2o_exec_wait *wait;
129 static u32 tcntxt = 0x80000000; 129 static u32 tcntxt = 0x80000000;
130 long flags; 130 unsigned long flags;
131 int rc = 0; 131 int rc = 0;
132 132
133 wait = i2o_exec_wait_alloc(); 133 wait = i2o_exec_wait_alloc();
@@ -325,13 +325,24 @@ static DEVICE_ATTR(product_id, S_IRUGO, i2o_exec_show_product_id, NULL);
325static int i2o_exec_probe(struct device *dev) 325static int i2o_exec_probe(struct device *dev)
326{ 326{
327 struct i2o_device *i2o_dev = to_i2o_device(dev); 327 struct i2o_device *i2o_dev = to_i2o_device(dev);
328 int rc;
328 329
329 i2o_event_register(i2o_dev, &i2o_exec_driver, 0, 0xffffffff); 330 rc = i2o_event_register(i2o_dev, &i2o_exec_driver, 0, 0xffffffff);
331 if (rc) goto err_out;
330 332
331 device_create_file(dev, &dev_attr_vendor_id); 333 rc = device_create_file(dev, &dev_attr_vendor_id);
332 device_create_file(dev, &dev_attr_product_id); 334 if (rc) goto err_evtreg;
335 rc = device_create_file(dev, &dev_attr_product_id);
336 if (rc) goto err_vid;
333 337
334 return 0; 338 return 0;
339
340err_vid:
341 device_remove_file(dev, &dev_attr_vendor_id);
342err_evtreg:
343 i2o_event_register(to_i2o_device(dev), &i2o_exec_driver, 0, 0);
344err_out:
345 return rc;
335}; 346};
336 347
337/** 348/**
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 3df0e7a07c46..00db31c314e0 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -28,6 +28,18 @@ config IBM_ASM
28 28
29 If unsure, say N. 29 If unsure, say N.
30 30
31config SGI_IOC4
32 tristate "SGI IOC4 Base IO support"
33 depends on PCI
34 ---help---
35 This option enables basic support for the IOC4 chip on certain
36 SGI IO controller cards (IO9, IO10, and PCI-RT). This option
37 does not enable any specific functions on such a card, but provides
38 necessary infrastructure for other drivers to utilize.
39
40 If you have an SGI Altix with an IOC4-based card say Y.
41 Otherwise say N.
42
31config TIFM_CORE 43config TIFM_CORE
32 tristate "TI Flash Media interface support (EXPERIMENTAL)" 44 tristate "TI Flash Media interface support (EXPERIMENTAL)"
33 depends on EXPERIMENTAL 45 depends on EXPERIMENTAL
@@ -57,4 +69,23 @@ config TIFM_7XX1
57 To compile this driver as a module, choose M here: the module will 69 To compile this driver as a module, choose M here: the module will
58 be called tifm_7xx1. 70 be called tifm_7xx1.
59 71
72config MSI_LAPTOP
73 tristate "MSI Laptop Extras"
74 depends on X86
75 depends on ACPI_EC
76 depends on BACKLIGHT_CLASS_DEVICE
77 ---help---
78 This is a driver for laptops built by MSI (MICRO-STAR
79 INTERNATIONAL):
80
81 MSI MegaBook S270 (MS-1013)
82 Cytron/TCM/Medion/Tchibo MD96100/SAM2000
83
84 It adds support for Bluetooth, WLAN and LCD brightness control.
85
86 More information about this driver is available at
87 <http://0pointer.de/lennart/tchibo.html>.
88
89 If you have an MSI S270 laptop, say Y or M here.
90
60endmenu 91endmenu
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index d65ece76095a..c9e98ab021c5 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -5,6 +5,8 @@ obj- := misc.o # Dummy rule to force built-in.o to be made
5 5
6obj-$(CONFIG_IBM_ASM) += ibmasm/ 6obj-$(CONFIG_IBM_ASM) += ibmasm/
7obj-$(CONFIG_HDPU_FEATURES) += hdpuftrs/ 7obj-$(CONFIG_HDPU_FEATURES) += hdpuftrs/
8obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o
8obj-$(CONFIG_LKDTM) += lkdtm.o 9obj-$(CONFIG_LKDTM) += lkdtm.o
9obj-$(CONFIG_TIFM_CORE) += tifm_core.o 10obj-$(CONFIG_TIFM_CORE) += tifm_core.o
10obj-$(CONFIG_TIFM_7XX1) += tifm_7xx1.o 11obj-$(CONFIG_TIFM_7XX1) += tifm_7xx1.o
12obj-$(CONFIG_SGI_IOC4) += ioc4.o
diff --git a/drivers/sn/ioc4.c b/drivers/misc/ioc4.c
index 8562821e6498..b995a15b7526 100644
--- a/drivers/sn/ioc4.c
+++ b/drivers/misc/ioc4.c
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 2005 Silicon Graphics, Inc. All Rights Reserved. 6 * Copyright (C) 2005-2006 Silicon Graphics, Inc. All Rights Reserved.
7 */ 7 */
8 8
9/* This file contains the master driver module for use by SGI IOC4 subdrivers. 9/* This file contains the master driver module for use by SGI IOC4 subdrivers.
@@ -29,12 +29,10 @@
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/pci.h> 30#include <linux/pci.h>
31#include <linux/ioc4.h> 31#include <linux/ioc4.h>
32#include <linux/mmtimer.h> 32#include <linux/ktime.h>
33#include <linux/rtc.h>
34#include <linux/mutex.h> 33#include <linux/mutex.h>
35#include <asm/sn/addrs.h> 34#include <linux/time.h>
36#include <asm/sn/clksupport.h> 35#include <asm/io.h>
37#include <asm/sn/shub_mmr.h>
38 36
39/*************** 37/***************
40 * Definitions * 38 * Definitions *
@@ -43,7 +41,7 @@
43/* Tweakable values */ 41/* Tweakable values */
44 42
45/* PCI bus speed detection/calibration */ 43/* PCI bus speed detection/calibration */
46#define IOC4_CALIBRATE_COUNT 63 /* Calibration cycle period */ 44#define IOC4_CALIBRATE_COUNT 63 /* Calibration cycle period */
47#define IOC4_CALIBRATE_CYCLES 256 /* Average over this many cycles */ 45#define IOC4_CALIBRATE_CYCLES 256 /* Average over this many cycles */
48#define IOC4_CALIBRATE_DISCARD 2 /* Discard first few cycles */ 46#define IOC4_CALIBRATE_DISCARD 2 /* Discard first few cycles */
49#define IOC4_CALIBRATE_LOW_MHZ 25 /* Lower bound on bus speed sanity */ 47#define IOC4_CALIBRATE_LOW_MHZ 25 /* Lower bound on bus speed sanity */
@@ -143,11 +141,11 @@ ioc4_unregister_submodule(struct ioc4_submodule *is)
143static void 141static void
144ioc4_clock_calibrate(struct ioc4_driver_data *idd) 142ioc4_clock_calibrate(struct ioc4_driver_data *idd)
145{ 143{
146 extern unsigned long sn_rtc_cycles_per_second;
147 union ioc4_int_out int_out; 144 union ioc4_int_out int_out;
148 union ioc4_gpcr gpcr; 145 union ioc4_gpcr gpcr;
149 unsigned int state, last_state = 1; 146 unsigned int state, last_state = 1;
150 uint64_t start = 0, end, period; 147 struct timespec start_ts, end_ts;
148 uint64_t start, end, period;
151 unsigned int count = 0; 149 unsigned int count = 0;
152 150
153 /* Enable output */ 151 /* Enable output */
@@ -175,30 +173,28 @@ ioc4_clock_calibrate(struct ioc4_driver_data *idd)
175 if (!last_state && state) { 173 if (!last_state && state) {
176 count++; 174 count++;
177 if (count == IOC4_CALIBRATE_END) { 175 if (count == IOC4_CALIBRATE_END) {
178 end = rtc_time(); 176 ktime_get_ts(&end_ts);
179 break; 177 break;
180 } else if (count == IOC4_CALIBRATE_DISCARD) 178 } else if (count == IOC4_CALIBRATE_DISCARD)
181 start = rtc_time(); 179 ktime_get_ts(&start_ts);
182 } 180 }
183 last_state = state; 181 last_state = state;
184 } while (1); 182 } while (1);
185 183
186 /* Calculation rearranged to preserve intermediate precision. 184 /* Calculation rearranged to preserve intermediate precision.
187 * Logically: 185 * Logically:
188 * 1. "end - start" gives us number of RTC cycles over all the 186 * 1. "end - start" gives us the measurement period over all
189 * square wave cycles measured. 187 * the square wave cycles.
190 * 2. Divide by number of square wave cycles to get number of 188 * 2. Divide by number of square wave cycles to get the period
191 * RTC cycles per square wave cycle. 189 * of a square wave cycle.
192 * 3. Divide by 2*(int_out.fields.count+1), which is the formula 190 * 3. Divide by 2*(int_out.fields.count+1), which is the formula
193 * by which the IOC4 generates the square wave, to get the 191 * by which the IOC4 generates the square wave, to get the
194 * number of RTC cycles per IOC4 INT_OUT count. 192 * period of an IOC4 INT_OUT count.
195 * 4. Divide by sn_rtc_cycles_per_second to get seconds per
196 * count.
197 * 5. Multiply by 1E9 to get nanoseconds per count.
198 */ 193 */
199 period = ((end - start) * 1000000000) / 194 end = end_ts.tv_sec * NSEC_PER_SEC + end_ts.tv_nsec;
200 (IOC4_CALIBRATE_CYCLES * 2 * (IOC4_CALIBRATE_COUNT + 1) 195 start = start_ts.tv_sec * NSEC_PER_SEC + start_ts.tv_nsec;
201 * sn_rtc_cycles_per_second); 196 period = (end - start) /
197 (IOC4_CALIBRATE_CYCLES * 2 * (IOC4_CALIBRATE_COUNT + 1));
202 198
203 /* Bounds check the result. */ 199 /* Bounds check the result. */
204 if (period > IOC4_CALIBRATE_LOW_LIMIT || 200 if (period > IOC4_CALIBRATE_LOW_LIMIT ||
@@ -210,10 +206,12 @@ ioc4_clock_calibrate(struct ioc4_driver_data *idd)
210 IOC4_CALIBRATE_DEFAULT / IOC4_EXTINT_COUNT_DIVISOR); 206 IOC4_CALIBRATE_DEFAULT / IOC4_EXTINT_COUNT_DIVISOR);
211 period = IOC4_CALIBRATE_DEFAULT; 207 period = IOC4_CALIBRATE_DEFAULT;
212 } else { 208 } else {
209 u64 ns = period;
210
211 do_div(ns, IOC4_EXTINT_COUNT_DIVISOR);
213 printk(KERN_DEBUG 212 printk(KERN_DEBUG
214 "IOC4 %s: PCI clock is %ld ns.\n", 213 "IOC4 %s: PCI clock is %llu ns.\n",
215 pci_name(idd->idd_pdev), 214 pci_name(idd->idd_pdev), (unsigned long long)ns);
216 period / IOC4_EXTINT_COUNT_DIVISOR);
217 } 215 }
218 216
219 /* Remember results. We store the extint clock period rather 217 /* Remember results. We store the extint clock period rather
diff --git a/drivers/misc/lkdtm.c b/drivers/misc/lkdtm.c
index bbdba7b37e11..db9d7df75ae0 100644
--- a/drivers/misc/lkdtm.c
+++ b/drivers/misc/lkdtm.c
@@ -44,12 +44,14 @@
44 */ 44 */
45 45
46#include <linux/kernel.h> 46#include <linux/kernel.h>
47#include <linux/fs.h>
47#include <linux/module.h> 48#include <linux/module.h>
49#include <linux/buffer_head.h>
48#include <linux/kprobes.h> 50#include <linux/kprobes.h>
49#include <linux/kallsyms.h> 51#include <linux/list.h>
50#include <linux/init.h> 52#include <linux/init.h>
51#include <linux/irq.h>
52#include <linux/interrupt.h> 53#include <linux/interrupt.h>
54#include <linux/hrtimer.h>
53#include <scsi/scsi_cmnd.h> 55#include <scsi/scsi_cmnd.h>
54 56
55#ifdef CONFIG_IDE 57#ifdef CONFIG_IDE
@@ -116,16 +118,16 @@ static enum ctype cptype = NONE;
116static int count = DEFAULT_COUNT; 118static int count = DEFAULT_COUNT;
117 119
118module_param(recur_count, int, 0644); 120module_param(recur_count, int, 0644);
119MODULE_PARM_DESC(recur_count, "Recurcion level for the stack overflow test,\ 121MODULE_PARM_DESC(recur_count, " Recursion level for the stack overflow test, "\
120 default is 10"); 122 "default is 10");
121module_param(cpoint_name, charp, 0644); 123module_param(cpoint_name, charp, 0644);
122MODULE_PARM_DESC(cpoint_name, "Crash Point, where kernel is to be crashed"); 124MODULE_PARM_DESC(cpoint_name, " Crash Point, where kernel is to be crashed");
123module_param(cpoint_type, charp, 06444); 125module_param(cpoint_type, charp, 0644);
124MODULE_PARM_DESC(cpoint_type, "Crash Point Type, action to be taken on\ 126MODULE_PARM_DESC(cpoint_type, " Crash Point Type, action to be taken on "\
125 hitting the crash point"); 127 "hitting the crash point");
126module_param(cpoint_count, int, 06444); 128module_param(cpoint_count, int, 0644);
127MODULE_PARM_DESC(cpoint_count, "Crash Point Count, number of times the \ 129MODULE_PARM_DESC(cpoint_count, " Crash Point Count, number of times the "\
128 crash point is to be hit to trigger action"); 130 "crash point is to be hit to trigger action");
129 131
130unsigned int jp_do_irq(unsigned int irq) 132unsigned int jp_do_irq(unsigned int irq)
131{ 133{
@@ -155,8 +157,8 @@ void jp_ll_rw_block(int rw, int nr, struct buffer_head *bhs[])
155 157
156struct scan_control; 158struct scan_control;
157 159
158unsigned long jp_shrink_page_list(struct list_head *page_list, 160unsigned long jp_shrink_inactive_list(unsigned long max_scan,
159 struct scan_control *sc) 161 struct zone *zone, struct scan_control *sc)
160{ 162{
161 lkdtm_handler(); 163 lkdtm_handler();
162 jprobe_return(); 164 jprobe_return();
@@ -295,8 +297,8 @@ int lkdtm_module_init(void)
295 lkdtm.entry = (kprobe_opcode_t*) jp_ll_rw_block; 297 lkdtm.entry = (kprobe_opcode_t*) jp_ll_rw_block;
296 break; 298 break;
297 case MEM_SWAPOUT: 299 case MEM_SWAPOUT:
298 lkdtm.kp.symbol_name = "shrink_page_list"; 300 lkdtm.kp.symbol_name = "shrink_inactive_list";
299 lkdtm.entry = (kprobe_opcode_t*) jp_shrink_page_list; 301 lkdtm.entry = (kprobe_opcode_t*) jp_shrink_inactive_list;
300 break; 302 break;
301 case TIMERADD: 303 case TIMERADD:
302 lkdtm.kp.symbol_name = "hrtimer_start"; 304 lkdtm.kp.symbol_name = "hrtimer_start";
diff --git a/drivers/misc/msi-laptop.c b/drivers/misc/msi-laptop.c
new file mode 100644
index 000000000000..fdb7153f4426
--- /dev/null
+++ b/drivers/misc/msi-laptop.c
@@ -0,0 +1,395 @@
1/*-*-linux-c-*-*/
2
3/*
4 Copyright (C) 2006 Lennart Poettering <mzxreary (at) 0pointer (dot) de>
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 This program is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301, USA.
20 */
21
22/*
23 * msi-laptop.c - MSI S270 laptop support. This laptop is sold under
24 * various brands, including "Cytron/TCM/Medion/Tchibo MD96100".
25 *
26 * This driver exports a few files in /sys/devices/platform/msi-laptop-pf/:
27 *
28 * lcd_level - Screen brightness: contains a single integer in the
29 * range 0..8. (rw)
30 *
31 * auto_brightness - Enable automatic brightness control: contains
32 * either 0 or 1. If set to 1 the hardware adjusts the screen
33 * brightness automatically when the power cord is
34 * plugged/unplugged. (rw)
35 *
36 * wlan - WLAN subsystem enabled: contains either 0 or 1. (ro)
37 *
38 * bluetooth - Bluetooth subsystem enabled: contains either 0 or 1
39 * Please note that this file is constantly 0 if no Bluetooth
40 * hardware is available. (ro)
41 *
42 * In addition to these platform device attributes the driver
43 * registers itself in the Linux backlight control subsystem and is
44 * available to userspace under /sys/class/backlight/msi-laptop-bl/.
45 *
46 * This driver might work on other laptops produced by MSI. If you
47 * want to try it you can pass force=1 as argument to the module which
48 * will force it to load even when the DMI data doesn't identify the
49 * laptop as MSI S270. YMMV.
50 */
51
52#include <linux/module.h>
53#include <linux/kernel.h>
54#include <linux/init.h>
55#include <linux/acpi.h>
56#include <linux/dmi.h>
57#include <linux/backlight.h>
58#include <linux/platform_device.h>
59#include <linux/autoconf.h>
60
61#define MSI_DRIVER_VERSION "0.5"
62
63#define MSI_LCD_LEVEL_MAX 9
64
65#define MSI_EC_COMMAND_WIRELESS 0x10
66#define MSI_EC_COMMAND_LCD_LEVEL 0x11
67
68static int force;
69module_param(force, bool, 0);
70MODULE_PARM_DESC(force, "Force driver load, ignore DMI data");
71
72static int auto_brightness;
73module_param(auto_brightness, int, 0);
74MODULE_PARM_DESC(auto_brightness, "Enable automatic brightness control (0: disabled; 1: enabled; 2: don't touch)");
75
76/* Hardware access */
77
78static int set_lcd_level(int level)
79{
80 u8 buf[2];
81
82 if (level < 0 || level >= MSI_LCD_LEVEL_MAX)
83 return -EINVAL;
84
85 buf[0] = 0x80;
86 buf[1] = (u8) (level*31);
87
88 return ec_transaction(MSI_EC_COMMAND_LCD_LEVEL, buf, sizeof(buf), NULL, 0);
89}
90
91static int get_lcd_level(void)
92{
93 u8 wdata = 0, rdata;
94 int result;
95
96 result = ec_transaction(MSI_EC_COMMAND_LCD_LEVEL, &wdata, 1, &rdata, 1);
97 if (result < 0)
98 return result;
99
100 return (int) rdata / 31;
101}
102
103static int get_auto_brightness(void)
104{
105 u8 wdata = 4, rdata;
106 int result;
107
108 result = ec_transaction(MSI_EC_COMMAND_LCD_LEVEL, &wdata, 1, &rdata, 1);
109 if (result < 0)
110 return result;
111
112 return !!(rdata & 8);
113}
114
115static int set_auto_brightness(int enable)
116{
117 u8 wdata[2], rdata;
118 int result;
119
120 wdata[0] = 4;
121
122 result = ec_transaction(MSI_EC_COMMAND_LCD_LEVEL, wdata, 1, &rdata, 1);
123 if (result < 0)
124 return result;
125
126 wdata[0] = 0x84;
127 wdata[1] = (rdata & 0xF7) | (enable ? 8 : 0);
128
129 return ec_transaction(MSI_EC_COMMAND_LCD_LEVEL, wdata, 2, NULL, 0);
130}
131
132static int get_wireless_state(int *wlan, int *bluetooth)
133{
134 u8 wdata = 0, rdata;
135 int result;
136
137 result = ec_transaction(MSI_EC_COMMAND_WIRELESS, &wdata, 1, &rdata, 1);
138 if (result < 0)
139 return -1;
140
141 if (wlan)
142 *wlan = !!(rdata & 8);
143
144 if (bluetooth)
145 *bluetooth = !!(rdata & 128);
146
147 return 0;
148}
149
150/* Backlight device stuff */
151
152static int bl_get_brightness(struct backlight_device *b)
153{
154 return get_lcd_level();
155}
156
157
158static int bl_update_status(struct backlight_device *b)
159{
160 return set_lcd_level(b->props->brightness);
161}
162
163static struct backlight_properties msibl_props = {
164 .owner = THIS_MODULE,
165 .get_brightness = bl_get_brightness,
166 .update_status = bl_update_status,
167 .max_brightness = MSI_LCD_LEVEL_MAX-1,
168};
169
170static struct backlight_device *msibl_device;
171
172/* Platform device */
173
174static ssize_t show_wlan(struct device *dev,
175 struct device_attribute *attr, char *buf)
176{
177
178 int ret, enabled;
179
180 ret = get_wireless_state(&enabled, NULL);
181 if (ret < 0)
182 return ret;
183
184 return sprintf(buf, "%i\n", enabled);
185}
186
187static ssize_t show_bluetooth(struct device *dev,
188 struct device_attribute *attr, char *buf)
189{
190
191 int ret, enabled;
192
193 ret = get_wireless_state(NULL, &enabled);
194 if (ret < 0)
195 return ret;
196
197 return sprintf(buf, "%i\n", enabled);
198}
199
200static ssize_t show_lcd_level(struct device *dev,
201 struct device_attribute *attr, char *buf)
202{
203
204 int ret;
205
206 ret = get_lcd_level();
207 if (ret < 0)
208 return ret;
209
210 return sprintf(buf, "%i\n", ret);
211}
212
213static ssize_t store_lcd_level(struct device *dev,
214 struct device_attribute *attr, const char *buf, size_t count)
215{
216
217 int level, ret;
218
219 if (sscanf(buf, "%i", &level) != 1 || (level < 0 || level >= MSI_LCD_LEVEL_MAX))
220 return -EINVAL;
221
222 ret = set_lcd_level(level);
223 if (ret < 0)
224 return ret;
225
226 return count;
227}
228
229static ssize_t show_auto_brightness(struct device *dev,
230 struct device_attribute *attr, char *buf)
231{
232
233 int ret;
234
235 ret = get_auto_brightness();
236 if (ret < 0)
237 return ret;
238
239 return sprintf(buf, "%i\n", ret);
240}
241
242static ssize_t store_auto_brightness(struct device *dev,
243 struct device_attribute *attr, const char *buf, size_t count)
244{
245
246 int enable, ret;
247
248 if (sscanf(buf, "%i", &enable) != 1 || (enable != (enable & 1)))
249 return -EINVAL;
250
251 ret = set_auto_brightness(enable);
252 if (ret < 0)
253 return ret;
254
255 return count;
256}
257
258static DEVICE_ATTR(lcd_level, 0644, show_lcd_level, store_lcd_level);
259static DEVICE_ATTR(auto_brightness, 0644, show_auto_brightness, store_auto_brightness);
260static DEVICE_ATTR(bluetooth, 0444, show_bluetooth, NULL);
261static DEVICE_ATTR(wlan, 0444, show_wlan, NULL);
262
263static struct attribute *msipf_attributes[] = {
264 &dev_attr_lcd_level.attr,
265 &dev_attr_auto_brightness.attr,
266 &dev_attr_bluetooth.attr,
267 &dev_attr_wlan.attr,
268 NULL
269};
270
271static struct attribute_group msipf_attribute_group = {
272 .attrs = msipf_attributes
273};
274
275static struct platform_driver msipf_driver = {
276 .driver = {
277 .name = "msi-laptop-pf",
278 .owner = THIS_MODULE,
279 }
280};
281
282static struct platform_device *msipf_device;
283
284/* Initialization */
285
286static struct dmi_system_id __initdata msi_dmi_table[] = {
287 {
288 .ident = "MSI S270",
289 .matches = {
290 DMI_MATCH(DMI_SYS_VENDOR, "MICRO-STAR INT'L CO.,LTD"),
291 DMI_MATCH(DMI_PRODUCT_NAME, "MS-1013"),
292 }
293 },
294 {
295 .ident = "Medion MD96100",
296 .matches = {
297 DMI_MATCH(DMI_SYS_VENDOR, "NOTEBOOK"),
298 DMI_MATCH(DMI_PRODUCT_NAME, "SAM2000"),
299 }
300 },
301 { }
302};
303
304
305static int __init msi_init(void)
306{
307 int ret;
308
309 if (acpi_disabled)
310 return -ENODEV;
311
312 if (!force && !dmi_check_system(msi_dmi_table))
313 return -ENODEV;
314
315 if (auto_brightness < 0 || auto_brightness > 2)
316 return -EINVAL;
317
318 /* Register backlight stuff */
319
320 msibl_device = backlight_device_register("msi-laptop-bl", NULL, &msibl_props);
321 if (IS_ERR(msibl_device))
322 return PTR_ERR(msibl_device);
323
324 ret = platform_driver_register(&msipf_driver);
325 if (ret)
326 goto fail_backlight;
327
328 /* Register platform stuff */
329
330 msipf_device = platform_device_alloc("msi-laptop-pf", -1);
331 if (!msipf_device) {
332 ret = -ENOMEM;
333 goto fail_platform_driver;
334 }
335
336 ret = platform_device_add(msipf_device);
337 if (ret)
338 goto fail_platform_device1;
339
340 ret = sysfs_create_group(&msipf_device->dev.kobj, &msipf_attribute_group);
341 if (ret)
342 goto fail_platform_device2;
343
344 /* Disable automatic brightness control by default because
345 * this module was probably loaded to do brightness control in
346 * software. */
347
348 if (auto_brightness != 2)
349 set_auto_brightness(auto_brightness);
350
351 printk(KERN_INFO "msi-laptop: driver "MSI_DRIVER_VERSION" successfully loaded.\n");
352
353 return 0;
354
355fail_platform_device2:
356
357 platform_device_del(msipf_device);
358
359fail_platform_device1:
360
361 platform_device_put(msipf_device);
362
363fail_platform_driver:
364
365 platform_driver_unregister(&msipf_driver);
366
367fail_backlight:
368
369 backlight_device_unregister(msibl_device);
370
371 return ret;
372}
373
374static void __exit msi_cleanup(void)
375{
376
377 sysfs_remove_group(&msipf_device->dev.kobj, &msipf_attribute_group);
378 platform_device_unregister(msipf_device);
379 platform_driver_unregister(&msipf_driver);
380 backlight_device_unregister(msibl_device);
381
382 /* Enable automatic brightness control again */
383 if (auto_brightness != 2)
384 set_auto_brightness(1);
385
386 printk(KERN_INFO "msi-laptop: driver unloaded.\n");
387}
388
389module_init(msi_init);
390module_exit(msi_cleanup);
391
392MODULE_AUTHOR("Lennart Poettering");
393MODULE_DESCRIPTION("MSI Laptop Support");
394MODULE_VERSION(MSI_DRIVER_VERSION);
395MODULE_LICENSE("GPL");
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index ee8863c123e3..766bc54406e5 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -475,7 +475,7 @@ static u32 mmc_select_voltage(struct mmc_host *host, u32 ocr)
475 if (bit) { 475 if (bit) {
476 bit -= 1; 476 bit -= 1;
477 477
478 ocr = 3 << bit; 478 ocr &= 3 << bit;
479 479
480 host->ios.vdd = bit; 480 host->ios.vdd = bit;
481 mmc_set_ios(host); 481 mmc_set_ios(host);
@@ -1178,14 +1178,29 @@ static void mmc_rescan(void *data)
1178{ 1178{
1179 struct mmc_host *host = data; 1179 struct mmc_host *host = data;
1180 struct list_head *l, *n; 1180 struct list_head *l, *n;
1181 unsigned char power_mode;
1181 1182
1182 mmc_claim_host(host); 1183 mmc_claim_host(host);
1183 1184
1184 if (host->ios.power_mode == MMC_POWER_ON) 1185 /*
1186 * Check for removed cards and newly inserted ones. We check for
1187 * removed cards first so we can intelligently re-select the VDD.
1188 */
1189 power_mode = host->ios.power_mode;
1190 if (power_mode == MMC_POWER_ON)
1185 mmc_check_cards(host); 1191 mmc_check_cards(host);
1186 1192
1187 mmc_setup(host); 1193 mmc_setup(host);
1188 1194
1195 /*
1196 * Some broken cards process CMD1 even in stand-by state. There is
1197 * no reply, but an ILLEGAL_COMMAND error is cached and returned
1198 * after next command. We poll for card status here to clear any
1199 * possibly pending error.
1200 */
1201 if (power_mode == MMC_POWER_ON)
1202 mmc_check_cards(host);
1203
1189 if (!list_empty(&host->cards)) { 1204 if (!list_empty(&host->cards)) {
1190 /* 1205 /*
1191 * (Re-)calculate the fastest clock rate which the 1206 * (Re-)calculate the fastest clock rate which the
diff --git a/drivers/mmc/tifm_sd.c b/drivers/mmc/tifm_sd.c
index 2bacff60913d..0fdc55b08a6d 100644
--- a/drivers/mmc/tifm_sd.c
+++ b/drivers/mmc/tifm_sd.c
@@ -14,6 +14,7 @@
14#include <linux/mmc/protocol.h> 14#include <linux/mmc/protocol.h>
15#include <linux/mmc/host.h> 15#include <linux/mmc/host.h>
16#include <linux/highmem.h> 16#include <linux/highmem.h>
17#include <asm/io.h>
17 18
18#define DRIVER_NAME "tifm_sd" 19#define DRIVER_NAME "tifm_sd"
19#define DRIVER_VERSION "0.6" 20#define DRIVER_VERSION "0.6"
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index baece61169f4..41bfcae1fbf4 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1479,6 +1479,7 @@ static void nand_write_page_syndrome(struct mtd_info *mtd,
1479 * @buf: the data to write 1479 * @buf: the data to write
1480 * @page: page number to write 1480 * @page: page number to write
1481 * @cached: cached programming 1481 * @cached: cached programming
1482 * @raw: use _raw version of write_page
1482 */ 1483 */
1483static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip, 1484static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
1484 const uint8_t *buf, int page, int cached, int raw) 1485 const uint8_t *buf, int page, int cached, int raw)
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index ab92cc794c64..6e863aa9894c 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -486,7 +486,7 @@ config SGI_IOC3_ETH_HW_TX_CSUM
486 486
487config MIPS_SIM_NET 487config MIPS_SIM_NET
488 tristate "MIPS simulator Network device (EXPERIMENTAL)" 488 tristate "MIPS simulator Network device (EXPERIMENTAL)"
489 depends on NETDEVICES && MIPS_SIM && EXPERIMENTAL 489 depends on MIPS_SIM && EXPERIMENTAL
490 help 490 help
491 The MIPSNET device is a simple Ethernet network device which is 491 The MIPSNET device is a simple Ethernet network device which is
492 emulated by the MIPS Simulator. 492 emulated by the MIPS Simulator.
@@ -2112,7 +2112,7 @@ config SKGE
2112 2112
2113config SKY2 2113config SKY2
2114 tristate "SysKonnect Yukon2 support (EXPERIMENTAL)" 2114 tristate "SysKonnect Yukon2 support (EXPERIMENTAL)"
2115 depends on PCI && EXPERIMENTAL 2115 depends on PCI
2116 select CRC32 2116 select CRC32
2117 ---help--- 2117 ---help---
2118 This driver supports Gigabit Ethernet adapters based on the 2118 This driver supports Gigabit Ethernet adapters based on the
@@ -2120,8 +2120,8 @@ config SKY2
2120 Marvell 88E8021/88E8022/88E8035/88E8036/88E8038/88E8050/88E8052/ 2120 Marvell 88E8021/88E8022/88E8035/88E8036/88E8038/88E8050/88E8052/
2121 88E8053/88E8055/88E8061/88E8062, SysKonnect SK-9E21D/SK-9S21 2121 88E8053/88E8055/88E8061/88E8062, SysKonnect SK-9E21D/SK-9S21
2122 2122
2123 This driver does not support the original Yukon chipset: a seperate 2123 There is companion driver for the older Marvell Yukon and
2124 driver, skge, is provided for Yukon-based adapters. 2124 Genesis based adapters: skge.
2125 2125
2126 To compile this driver as a module, choose M here: the module 2126 To compile this driver as a module, choose M here: the module
2127 will be called sky2. This is recommended. 2127 will be called sky2. This is recommended.
@@ -2288,7 +2288,7 @@ config UGETH_TX_ON_DEMOND
2288 2288
2289config UGETH_HAS_GIGA 2289config UGETH_HAS_GIGA
2290 bool 2290 bool
2291 depends on UCC_GETH && MPC836x 2291 depends on UCC_GETH && PPC_MPC836x
2292 2292
2293config MV643XX_ETH 2293config MV643XX_ETH
2294 tristate "MV-643XX Ethernet support" 2294 tristate "MV-643XX Ethernet support"
@@ -2467,7 +2467,7 @@ config ISERIES_VETH
2467 2467
2468config RIONET 2468config RIONET
2469 tristate "RapidIO Ethernet over messaging driver support" 2469 tristate "RapidIO Ethernet over messaging driver support"
2470 depends on NETDEVICES && RAPIDIO 2470 depends on RAPIDIO
2471 2471
2472config RIONET_TX_SIZE 2472config RIONET_TX_SIZE
2473 int "Number of outbound queue entries" 2473 int "Number of outbound queue entries"
@@ -2717,6 +2717,7 @@ config PPP_MPPE
2717 select CRYPTO 2717 select CRYPTO
2718 select CRYPTO_SHA1 2718 select CRYPTO_SHA1
2719 select CRYPTO_ARC4 2719 select CRYPTO_ARC4
2720 select CRYPTO_ECB
2720 ---help--- 2721 ---help---
2721 Support for the MPPE Encryption protocol, as employed by the 2722 Support for the MPPE Encryption protocol, as employed by the
2722 Microsoft Point-to-Point Tunneling Protocol. 2723 Microsoft Point-to-Point Tunneling Protocol.
@@ -2832,7 +2833,7 @@ config NET_FC
2832 "SCSI generic support". 2833 "SCSI generic support".
2833 2834
2834config SHAPER 2835config SHAPER
2835 tristate "Traffic Shaper (EXPERIMENTAL)" 2836 tristate "Traffic Shaper (OBSOLETE)"
2836 depends on EXPERIMENTAL 2837 depends on EXPERIMENTAL
2837 ---help--- 2838 ---help---
2838 The traffic shaper is a virtual network device that allows you to 2839 The traffic shaper is a virtual network device that allows you to
@@ -2841,9 +2842,9 @@ config SHAPER
2841 these virtual devices. See 2842 these virtual devices. See
2842 <file:Documentation/networking/shaper.txt> for more information. 2843 <file:Documentation/networking/shaper.txt> for more information.
2843 2844
2844 An alternative to this traffic shaper is the experimental 2845 An alternative to this traffic shaper are traffic schedulers which
2845 Class-Based Queuing (CBQ) scheduling support which you get if you 2846 you'll get if you say Y to "QoS and/or fair queuing" in
2846 say Y to "QoS and/or fair queuing" above. 2847 "Networking options".
2847 2848
2848 To compile this driver as a module, choose M here: the module 2849 To compile this driver as a module, choose M here: the module
2849 will be called shaper. If unsure, say N. 2850 will be called shaper. If unsure, say N.
diff --git a/drivers/net/arcnet/com20020.c b/drivers/net/arcnet/com20020.c
index 0dc70c7b7940..aa9dd8f11269 100644
--- a/drivers/net/arcnet/com20020.c
+++ b/drivers/net/arcnet/com20020.c
@@ -337,13 +337,16 @@ static void com20020_set_mc_list(struct net_device *dev)
337 } 337 }
338} 338}
339 339
340#ifdef MODULE 340#if defined(CONFIG_ARCNET_COM20020_PCI_MODULE) || \
341 341 defined(CONFIG_ARCNET_COM20020_ISA_MODULE)
342EXPORT_SYMBOL(com20020_check); 342EXPORT_SYMBOL(com20020_check);
343EXPORT_SYMBOL(com20020_found); 343EXPORT_SYMBOL(com20020_found);
344#endif
344 345
345MODULE_LICENSE("GPL"); 346MODULE_LICENSE("GPL");
346 347
348#ifdef MODULE
349
347int init_module(void) 350int init_module(void)
348{ 351{
349 BUGLVL(D_NORMAL) printk(VERSION); 352 BUGLVL(D_NORMAL) printk(VERSION);
diff --git a/drivers/net/arm/ep93xx_eth.c b/drivers/net/arm/ep93xx_eth.c
index 127561c782fd..8ebd68e2af98 100644
--- a/drivers/net/arm/ep93xx_eth.c
+++ b/drivers/net/arm/ep93xx_eth.c
@@ -193,12 +193,9 @@ static struct net_device_stats *ep93xx_get_stats(struct net_device *dev)
193static int ep93xx_rx(struct net_device *dev, int *budget) 193static int ep93xx_rx(struct net_device *dev, int *budget)
194{ 194{
195 struct ep93xx_priv *ep = netdev_priv(dev); 195 struct ep93xx_priv *ep = netdev_priv(dev);
196 int tail_offset;
197 int rx_done; 196 int rx_done;
198 int processed; 197 int processed;
199 198
200 tail_offset = rdl(ep, REG_RXSTSQCURADD) - ep->descs_dma_addr;
201
202 rx_done = 0; 199 rx_done = 0;
203 processed = 0; 200 processed = 0;
204 while (*budget > 0) { 201 while (*budget > 0) {
@@ -211,36 +208,28 @@ static int ep93xx_rx(struct net_device *dev, int *budget)
211 208
212 entry = ep->rx_pointer; 209 entry = ep->rx_pointer;
213 rstat = ep->descs->rstat + entry; 210 rstat = ep->descs->rstat + entry;
214 if ((void *)rstat - (void *)ep->descs == tail_offset) { 211
212 rstat0 = rstat->rstat0;
213 rstat1 = rstat->rstat1;
214 if (!(rstat0 & RSTAT0_RFP) || !(rstat1 & RSTAT1_RFP)) {
215 rx_done = 1; 215 rx_done = 1;
216 break; 216 break;
217 } 217 }
218 218
219 rstat0 = rstat->rstat0;
220 rstat1 = rstat->rstat1;
221 rstat->rstat0 = 0; 219 rstat->rstat0 = 0;
222 rstat->rstat1 = 0; 220 rstat->rstat1 = 0;
223 221
224 if (!(rstat0 & RSTAT0_RFP))
225 printk(KERN_CRIT "ep93xx_rx: buffer not done "
226 " %.8x %.8x\n", rstat0, rstat1);
227 if (!(rstat0 & RSTAT0_EOF)) 222 if (!(rstat0 & RSTAT0_EOF))
228 printk(KERN_CRIT "ep93xx_rx: not end-of-frame " 223 printk(KERN_CRIT "ep93xx_rx: not end-of-frame "
229 " %.8x %.8x\n", rstat0, rstat1); 224 " %.8x %.8x\n", rstat0, rstat1);
230 if (!(rstat0 & RSTAT0_EOB)) 225 if (!(rstat0 & RSTAT0_EOB))
231 printk(KERN_CRIT "ep93xx_rx: not end-of-buffer " 226 printk(KERN_CRIT "ep93xx_rx: not end-of-buffer "
232 " %.8x %.8x\n", rstat0, rstat1); 227 " %.8x %.8x\n", rstat0, rstat1);
233 if (!(rstat1 & RSTAT1_RFP))
234 printk(KERN_CRIT "ep93xx_rx: buffer1 not done "
235 " %.8x %.8x\n", rstat0, rstat1);
236 if ((rstat1 & RSTAT1_BUFFER_INDEX) >> 16 != entry) 228 if ((rstat1 & RSTAT1_BUFFER_INDEX) >> 16 != entry)
237 printk(KERN_CRIT "ep93xx_rx: entry mismatch " 229 printk(KERN_CRIT "ep93xx_rx: entry mismatch "
238 " %.8x %.8x\n", rstat0, rstat1); 230 " %.8x %.8x\n", rstat0, rstat1);
239 231
240 if (!(rstat0 & RSTAT0_RWE)) { 232 if (!(rstat0 & RSTAT0_RWE)) {
241 printk(KERN_NOTICE "ep93xx_rx: receive error "
242 " %.8x %.8x\n", rstat0, rstat1);
243
244 ep->stats.rx_errors++; 233 ep->stats.rx_errors++;
245 if (rstat0 & RSTAT0_OE) 234 if (rstat0 & RSTAT0_OE)
246 ep->stats.rx_fifo_errors++; 235 ep->stats.rx_fifo_errors++;
@@ -301,13 +290,8 @@ err:
301 290
302static int ep93xx_have_more_rx(struct ep93xx_priv *ep) 291static int ep93xx_have_more_rx(struct ep93xx_priv *ep)
303{ 292{
304 struct ep93xx_rstat *rstat; 293 struct ep93xx_rstat *rstat = ep->descs->rstat + ep->rx_pointer;
305 int tail_offset; 294 return !!((rstat->rstat0 & RSTAT0_RFP) && (rstat->rstat1 & RSTAT1_RFP));
306
307 rstat = ep->descs->rstat + ep->rx_pointer;
308 tail_offset = rdl(ep, REG_RXSTSQCURADD) - ep->descs_dma_addr;
309
310 return !((void *)rstat - (void *)ep->descs == tail_offset);
311} 295}
312 296
313static int ep93xx_poll(struct net_device *dev, int *budget) 297static int ep93xx_poll(struct net_device *dev, int *budget)
@@ -347,7 +331,7 @@ static int ep93xx_xmit(struct sk_buff *skb, struct net_device *dev)
347 struct ep93xx_priv *ep = netdev_priv(dev); 331 struct ep93xx_priv *ep = netdev_priv(dev);
348 int entry; 332 int entry;
349 333
350 if (unlikely(skb->len) > MAX_PKT_SIZE) { 334 if (unlikely(skb->len > MAX_PKT_SIZE)) {
351 ep->stats.tx_dropped++; 335 ep->stats.tx_dropped++;
352 dev_kfree_skb(skb); 336 dev_kfree_skb(skb);
353 return NETDEV_TX_OK; 337 return NETDEV_TX_OK;
@@ -379,10 +363,8 @@ static int ep93xx_xmit(struct sk_buff *skb, struct net_device *dev)
379static void ep93xx_tx_complete(struct net_device *dev) 363static void ep93xx_tx_complete(struct net_device *dev)
380{ 364{
381 struct ep93xx_priv *ep = netdev_priv(dev); 365 struct ep93xx_priv *ep = netdev_priv(dev);
382 int tail_offset;
383 int wake; 366 int wake;
384 367
385 tail_offset = rdl(ep, REG_TXSTSQCURADD) - ep->descs_dma_addr;
386 wake = 0; 368 wake = 0;
387 369
388 spin_lock(&ep->tx_pending_lock); 370 spin_lock(&ep->tx_pending_lock);
@@ -393,15 +375,13 @@ static void ep93xx_tx_complete(struct net_device *dev)
393 375
394 entry = ep->tx_clean_pointer; 376 entry = ep->tx_clean_pointer;
395 tstat = ep->descs->tstat + entry; 377 tstat = ep->descs->tstat + entry;
396 if ((void *)tstat - (void *)ep->descs == tail_offset)
397 break;
398 378
399 tstat0 = tstat->tstat0; 379 tstat0 = tstat->tstat0;
380 if (!(tstat0 & TSTAT0_TXFP))
381 break;
382
400 tstat->tstat0 = 0; 383 tstat->tstat0 = 0;
401 384
402 if (!(tstat0 & TSTAT0_TXFP))
403 printk(KERN_CRIT "ep93xx_tx_complete: buffer not done "
404 " %.8x\n", tstat0);
405 if (tstat0 & TSTAT0_FA) 385 if (tstat0 & TSTAT0_FA)
406 printk(KERN_CRIT "ep93xx_tx_complete: frame aborted " 386 printk(KERN_CRIT "ep93xx_tx_complete: frame aborted "
407 " %.8x\n", tstat0); 387 " %.8x\n", tstat0);
diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c
index 4873dc610d22..7db3c8af0894 100644
--- a/drivers/net/au1000_eth.c
+++ b/drivers/net/au1000_eth.c
@@ -102,7 +102,7 @@ static void enable_mac(struct net_device *, int);
102// externs 102// externs
103extern int get_ethernet_addr(char *ethernet_addr); 103extern int get_ethernet_addr(char *ethernet_addr);
104extern void str2eaddr(unsigned char *ea, unsigned char *str); 104extern void str2eaddr(unsigned char *ea, unsigned char *str);
105extern char * __init prom_getcmdline(void); 105extern char * prom_getcmdline(void);
106 106
107/* 107/*
108 * Theory of operation 108 * Theory of operation
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index b124eee4eb10..474a4e3438db 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -908,8 +908,9 @@ static irqreturn_t b44_interrupt(int irq, void *dev_id)
908 istat = br32(bp, B44_ISTAT); 908 istat = br32(bp, B44_ISTAT);
909 imask = br32(bp, B44_IMASK); 909 imask = br32(bp, B44_IMASK);
910 910
911 /* ??? What the fuck is the purpose of the interrupt mask 911 /* The interrupt mask register controls which interrupt bits
912 * ??? register if we have to mask it out by hand anyways? 912 * will actually raise an interrupt to the CPU when set by hw/firmware,
913 * but doesn't mask off the bits.
913 */ 914 */
914 istat &= imask; 915 istat &= imask;
915 if (istat) { 916 if (istat) {
@@ -1706,14 +1707,15 @@ static void __b44_set_rx_mode(struct net_device *dev)
1706 1707
1707 __b44_set_mac_addr(bp); 1708 __b44_set_mac_addr(bp);
1708 1709
1709 if (dev->flags & IFF_ALLMULTI) 1710 if ((dev->flags & IFF_ALLMULTI) ||
1711 (dev->mc_count > B44_MCAST_TABLE_SIZE))
1710 val |= RXCONFIG_ALLMULTI; 1712 val |= RXCONFIG_ALLMULTI;
1711 else 1713 else
1712 i = __b44_load_mcast(bp, dev); 1714 i = __b44_load_mcast(bp, dev);
1713 1715
1714 for (; i < 64; i++) { 1716 for (; i < 64; i++)
1715 __b44_cam_write(bp, zero, i); 1717 __b44_cam_write(bp, zero, i);
1716 } 1718
1717 bw32(bp, B44_RXCONFIG, val); 1719 bw32(bp, B44_RXCONFIG, val);
1718 val = br32(bp, B44_CAM_CTRL); 1720 val = br32(bp, B44_CAM_CTRL);
1719 bw32(bp, B44_CAM_CTRL, val | CAM_CTRL_ENABLE); 1721 bw32(bp, B44_CAM_CTRL, val | CAM_CTRL_ENABLE);
@@ -2055,7 +2057,7 @@ static int b44_read_eeprom(struct b44 *bp, u8 *data)
2055 u16 *ptr = (u16 *) data; 2057 u16 *ptr = (u16 *) data;
2056 2058
2057 for (i = 0; i < 128; i += 2) 2059 for (i = 0; i < 128; i += 2)
2058 ptr[i / 2] = readw(bp->regs + 4096 + i); 2060 ptr[i / 2] = cpu_to_le16(readw(bp->regs + 4096 + i));
2059 2061
2060 return 0; 2062 return 0;
2061} 2063}
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index e83bc825f6af..32923162179e 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -1433,7 +1433,7 @@ void bond_alb_monitor(struct bonding *bond)
1433 * write lock to protect from other code that also 1433 * write lock to protect from other code that also
1434 * sets the promiscuity. 1434 * sets the promiscuity.
1435 */ 1435 */
1436 write_lock(&bond->curr_slave_lock); 1436 write_lock_bh(&bond->curr_slave_lock);
1437 1437
1438 if (bond_info->primary_is_promisc && 1438 if (bond_info->primary_is_promisc &&
1439 (++bond_info->rlb_promisc_timeout_counter >= RLB_PROMISC_TIMEOUT)) { 1439 (++bond_info->rlb_promisc_timeout_counter >= RLB_PROMISC_TIMEOUT)) {
@@ -1448,7 +1448,7 @@ void bond_alb_monitor(struct bonding *bond)
1448 bond_info->primary_is_promisc = 0; 1448 bond_info->primary_is_promisc = 0;
1449 } 1449 }
1450 1450
1451 write_unlock(&bond->curr_slave_lock); 1451 write_unlock_bh(&bond->curr_slave_lock);
1452 1452
1453 if (bond_info->rlb_rebalance) { 1453 if (bond_info->rlb_rebalance) {
1454 bond_info->rlb_rebalance = 0; 1454 bond_info->rlb_rebalance = 0;
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index c0bbddae4ec4..17a461152d39 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -4692,6 +4692,8 @@ static int bond_check_params(struct bond_params *params)
4692 return 0; 4692 return 0;
4693} 4693}
4694 4694
4695static struct lock_class_key bonding_netdev_xmit_lock_key;
4696
4695/* Create a new bond based on the specified name and bonding parameters. 4697/* Create a new bond based on the specified name and bonding parameters.
4696 * Caller must NOT hold rtnl_lock; we need to release it here before we 4698 * Caller must NOT hold rtnl_lock; we need to release it here before we
4697 * set up our sysfs entries. 4699 * set up our sysfs entries.
@@ -4727,6 +4729,9 @@ int bond_create(char *name, struct bond_params *params, struct bonding **newbond
4727 if (res < 0) { 4729 if (res < 0) {
4728 goto out_bond; 4730 goto out_bond;
4729 } 4731 }
4732
4733 lockdep_set_class(&bond_dev->_xmit_lock, &bonding_netdev_xmit_lock_key);
4734
4730 if (newbond) 4735 if (newbond)
4731 *newbond = bond_dev->priv; 4736 *newbond = bond_dev->priv;
4732 4737
diff --git a/drivers/net/cris/eth_v10.c b/drivers/net/cris/eth_v10.c
index 966b563e42bb..a03d781f6d0a 100644
--- a/drivers/net/cris/eth_v10.c
+++ b/drivers/net/cris/eth_v10.c
@@ -509,6 +509,8 @@ etrax_ethernet_init(void)
509 * does not share cacheline with any other data (to avoid cache bug) 509 * does not share cacheline with any other data (to avoid cache bug)
510 */ 510 */
511 RxDescList[i].skb = dev_alloc_skb(MAX_MEDIA_DATA_SIZE + 2 * L1_CACHE_BYTES); 511 RxDescList[i].skb = dev_alloc_skb(MAX_MEDIA_DATA_SIZE + 2 * L1_CACHE_BYTES);
512 if (!RxDescList[i].skb)
513 return -ENOMEM;
512 RxDescList[i].descr.ctrl = 0; 514 RxDescList[i].descr.ctrl = 0;
513 RxDescList[i].descr.sw_len = MAX_MEDIA_DATA_SIZE; 515 RxDescList[i].descr.sw_len = MAX_MEDIA_DATA_SIZE;
514 RxDescList[i].descr.next = virt_to_phys(&RxDescList[i + 1]); 516 RxDescList[i].descr.next = virt_to_phys(&RxDescList[i + 1]);
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 27d5d2f02533..19ab3441269c 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -2039,7 +2039,6 @@ static int e100_change_mtu(struct net_device *netdev, int new_mtu)
2039 return 0; 2039 return 0;
2040} 2040}
2041 2041
2042#ifdef CONFIG_PM
2043static int e100_asf(struct nic *nic) 2042static int e100_asf(struct nic *nic)
2044{ 2043{
2045 /* ASF can be enabled from eeprom */ 2044 /* ASF can be enabled from eeprom */
@@ -2048,7 +2047,6 @@ static int e100_asf(struct nic *nic)
2048 !(nic->eeprom[eeprom_config_asf] & eeprom_gcl) && 2047 !(nic->eeprom[eeprom_config_asf] & eeprom_gcl) &&
2049 ((nic->eeprom[eeprom_smbus_addr] & 0xFF) != 0xFE)); 2048 ((nic->eeprom[eeprom_smbus_addr] & 0xFF) != 0xFE));
2050} 2049}
2051#endif
2052 2050
2053static int e100_up(struct nic *nic) 2051static int e100_up(struct nic *nic)
2054{ 2052{
@@ -2715,34 +2713,35 @@ static void __devexit e100_remove(struct pci_dev *pdev)
2715 } 2713 }
2716} 2714}
2717 2715
2716#ifdef CONFIG_PM
2718static int e100_suspend(struct pci_dev *pdev, pm_message_t state) 2717static int e100_suspend(struct pci_dev *pdev, pm_message_t state)
2719{ 2718{
2720 struct net_device *netdev = pci_get_drvdata(pdev); 2719 struct net_device *netdev = pci_get_drvdata(pdev);
2721 struct nic *nic = netdev_priv(netdev); 2720 struct nic *nic = netdev_priv(netdev);
2722 2721
2722#ifdef CONFIG_E100_NAPI
2723 if (netif_running(netdev)) 2723 if (netif_running(netdev))
2724 e100_down(nic); 2724 netif_poll_disable(nic->netdev);
2725 e100_hw_reset(nic); 2725#endif
2726 netif_device_detach(netdev); 2726 del_timer_sync(&nic->watchdog);
2727 netif_carrier_off(nic->netdev);
2727 2728
2728#ifdef CONFIG_PM
2729 pci_save_state(pdev); 2729 pci_save_state(pdev);
2730 if (nic->flags & (wol_magic | e100_asf(nic))) 2730
2731#else 2731 if ((nic->flags & wol_magic) | e100_asf(nic)) {
2732 if (nic->flags & (wol_magic)) 2732 pci_enable_wake(pdev, PCI_D3hot, 1);
2733#endif 2733 pci_enable_wake(pdev, PCI_D3cold, 1);
2734 pci_enable_wake(pdev, pci_choose_state(pdev, state), 1); 2734 } else {
2735 else 2735 pci_enable_wake(pdev, PCI_D3hot, 0);
2736 /* disable PME */ 2736 pci_enable_wake(pdev, PCI_D3cold, 0);
2737 pci_enable_wake(pdev, 0, 0); 2737 }
2738 2738
2739 pci_disable_device(pdev); 2739 pci_disable_device(pdev);
2740 pci_set_power_state(pdev, pci_choose_state(pdev, state)); 2740 pci_set_power_state(pdev, PCI_D3hot);
2741 2741
2742 return 0; 2742 return 0;
2743} 2743}
2744 2744
2745#ifdef CONFIG_PM
2746static int e100_resume(struct pci_dev *pdev) 2745static int e100_resume(struct pci_dev *pdev)
2747{ 2746{
2748 struct net_device *netdev = pci_get_drvdata(pdev); 2747 struct net_device *netdev = pci_get_drvdata(pdev);
@@ -2764,7 +2763,26 @@ static int e100_resume(struct pci_dev *pdev)
2764 2763
2765static void e100_shutdown(struct pci_dev *pdev) 2764static void e100_shutdown(struct pci_dev *pdev)
2766{ 2765{
2767 e100_suspend(pdev, PMSG_SUSPEND); 2766 struct net_device *netdev = pci_get_drvdata(pdev);
2767 struct nic *nic = netdev_priv(netdev);
2768
2769#ifdef CONFIG_E100_NAPI
2770 if (netif_running(netdev))
2771 netif_poll_disable(nic->netdev);
2772#endif
2773 del_timer_sync(&nic->watchdog);
2774 netif_carrier_off(nic->netdev);
2775
2776 if ((nic->flags & wol_magic) | e100_asf(nic)) {
2777 pci_enable_wake(pdev, PCI_D3hot, 1);
2778 pci_enable_wake(pdev, PCI_D3cold, 1);
2779 } else {
2780 pci_enable_wake(pdev, PCI_D3hot, 0);
2781 pci_enable_wake(pdev, PCI_D3cold, 0);
2782 }
2783
2784 pci_disable_device(pdev);
2785 pci_set_power_state(pdev, PCI_D3hot);
2768} 2786}
2769 2787
2770/* ------------------ PCI Error Recovery infrastructure -------------- */ 2788/* ------------------ PCI Error Recovery infrastructure -------------- */
@@ -2848,9 +2866,9 @@ static struct pci_driver e100_driver = {
2848 .id_table = e100_id_table, 2866 .id_table = e100_id_table,
2849 .probe = e100_probe, 2867 .probe = e100_probe,
2850 .remove = __devexit_p(e100_remove), 2868 .remove = __devexit_p(e100_remove),
2869#ifdef CONFIG_PM
2851 /* Power Management hooks */ 2870 /* Power Management hooks */
2852 .suspend = e100_suspend, 2871 .suspend = e100_suspend,
2853#ifdef CONFIG_PM
2854 .resume = e100_resume, 2872 .resume = e100_resume,
2855#endif 2873#endif
2856 .shutdown = e100_shutdown, 2874 .shutdown = e100_shutdown,
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c
index 773821e4cf57..c564adbd669b 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -461,7 +461,8 @@ e1000_get_regs(struct net_device *netdev,
461 regs_buff[24] = (uint32_t)phy_data; /* phy local receiver status */ 461 regs_buff[24] = (uint32_t)phy_data; /* phy local receiver status */
462 regs_buff[25] = regs_buff[24]; /* phy remote receiver status */ 462 regs_buff[25] = regs_buff[24]; /* phy remote receiver status */
463 if (hw->mac_type >= e1000_82540 && 463 if (hw->mac_type >= e1000_82540 &&
464 hw->media_type == e1000_media_type_copper) { 464 hw->mac_type < e1000_82571 &&
465 hw->media_type == e1000_media_type_copper) {
465 regs_buff[26] = E1000_READ_REG(hw, MANC); 466 regs_buff[26] = E1000_READ_REG(hw, MANC);
466 } 467 }
467} 468}
@@ -1690,6 +1691,7 @@ static int e1000_wol_exclusion(struct e1000_adapter *adapter, struct ethtool_wol
1690 int retval = 1; /* fail by default */ 1691 int retval = 1; /* fail by default */
1691 1692
1692 switch (hw->device_id) { 1693 switch (hw->device_id) {
1694 case E1000_DEV_ID_82542:
1693 case E1000_DEV_ID_82543GC_FIBER: 1695 case E1000_DEV_ID_82543GC_FIBER:
1694 case E1000_DEV_ID_82543GC_COPPER: 1696 case E1000_DEV_ID_82543GC_COPPER:
1695 case E1000_DEV_ID_82544EI_FIBER: 1697 case E1000_DEV_ID_82544EI_FIBER:
diff --git a/drivers/net/e1000/e1000_hw.h b/drivers/net/e1000/e1000_hw.h
index 112447fd8bf2..449a60303e07 100644
--- a/drivers/net/e1000/e1000_hw.h
+++ b/drivers/net/e1000/e1000_hw.h
@@ -1961,9 +1961,9 @@ struct e1000_hw {
1961#define E1000_RXDCTL_GRAN 0x01000000 /* RXDCTL Granularity */ 1961#define E1000_RXDCTL_GRAN 0x01000000 /* RXDCTL Granularity */
1962 1962
1963/* Transmit Descriptor Control */ 1963/* Transmit Descriptor Control */
1964#define E1000_TXDCTL_PTHRESH 0x000000FF /* TXDCTL Prefetch Threshold */ 1964#define E1000_TXDCTL_PTHRESH 0x0000003F /* TXDCTL Prefetch Threshold */
1965#define E1000_TXDCTL_HTHRESH 0x0000FF00 /* TXDCTL Host Threshold */ 1965#define E1000_TXDCTL_HTHRESH 0x00003F00 /* TXDCTL Host Threshold */
1966#define E1000_TXDCTL_WTHRESH 0x00FF0000 /* TXDCTL Writeback Threshold */ 1966#define E1000_TXDCTL_WTHRESH 0x003F0000 /* TXDCTL Writeback Threshold */
1967#define E1000_TXDCTL_GRAN 0x01000000 /* TXDCTL Granularity */ 1967#define E1000_TXDCTL_GRAN 0x01000000 /* TXDCTL Granularity */
1968#define E1000_TXDCTL_LWTHRESH 0xFE000000 /* TXDCTL Low Threshold */ 1968#define E1000_TXDCTL_LWTHRESH 0xFE000000 /* TXDCTL Low Threshold */
1969#define E1000_TXDCTL_FULL_TX_DESC_WB 0x01010000 /* GRAN=1, WTHRESH=1 */ 1969#define E1000_TXDCTL_FULL_TX_DESC_WB 0x01010000 /* GRAN=1, WTHRESH=1 */
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index ce0d35fe3947..726ec5e88ab2 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -35,7 +35,7 @@ static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
35#else 35#else
36#define DRIVERNAPI "-NAPI" 36#define DRIVERNAPI "-NAPI"
37#endif 37#endif
38#define DRV_VERSION "7.2.9-k2"DRIVERNAPI 38#define DRV_VERSION "7.2.9-k4"DRIVERNAPI
39char e1000_driver_version[] = DRV_VERSION; 39char e1000_driver_version[] = DRV_VERSION;
40static char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation."; 40static char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation.";
41 41
@@ -699,7 +699,10 @@ e1000_reset(struct e1000_adapter *adapter)
699 phy_data); 699 phy_data);
700 } 700 }
701 701
702 if ((adapter->en_mng_pt) && (adapter->hw.mac_type < e1000_82571)) { 702 if ((adapter->en_mng_pt) &&
703 (adapter->hw.mac_type >= e1000_82540) &&
704 (adapter->hw.mac_type < e1000_82571) &&
705 (adapter->hw.media_type == e1000_media_type_copper)) {
703 manc = E1000_READ_REG(&adapter->hw, MANC); 706 manc = E1000_READ_REG(&adapter->hw, MANC);
704 manc |= (E1000_MANC_ARP_EN | E1000_MANC_EN_MNG2HOST); 707 manc |= (E1000_MANC_ARP_EN | E1000_MANC_EN_MNG2HOST);
705 E1000_WRITE_REG(&adapter->hw, MANC, manc); 708 E1000_WRITE_REG(&adapter->hw, MANC, manc);
@@ -1076,8 +1079,9 @@ e1000_remove(struct pci_dev *pdev)
1076 1079
1077 flush_scheduled_work(); 1080 flush_scheduled_work();
1078 1081
1079 if (adapter->hw.mac_type < e1000_82571 && 1082 if (adapter->hw.mac_type >= e1000_82540 &&
1080 adapter->hw.media_type == e1000_media_type_copper) { 1083 adapter->hw.mac_type < e1000_82571 &&
1084 adapter->hw.media_type == e1000_media_type_copper) {
1081 manc = E1000_READ_REG(&adapter->hw, MANC); 1085 manc = E1000_READ_REG(&adapter->hw, MANC);
1082 if (manc & E1000_MANC_SMBUS_EN) { 1086 if (manc & E1000_MANC_SMBUS_EN) {
1083 manc |= E1000_MANC_ARP_EN; 1087 manc |= E1000_MANC_ARP_EN;
@@ -1804,9 +1808,11 @@ e1000_setup_rctl(struct e1000_adapter *adapter)
1804 * followed by the page buffers. Therefore, skb->data is 1808 * followed by the page buffers. Therefore, skb->data is
1805 * sized to hold the largest protocol header. 1809 * sized to hold the largest protocol header.
1806 */ 1810 */
1811 /* allocations using alloc_page take too long for regular MTU
1812 * so only enable packet split for jumbo frames */
1807 pages = PAGE_USE_COUNT(adapter->netdev->mtu); 1813 pages = PAGE_USE_COUNT(adapter->netdev->mtu);
1808 if ((adapter->hw.mac_type > e1000_82547_rev_2) && (pages <= 3) && 1814 if ((adapter->hw.mac_type >= e1000_82571) && (pages <= 3) &&
1809 PAGE_SIZE <= 16384) 1815 PAGE_SIZE <= 16384 && (rctl & E1000_RCTL_LPE))
1810 adapter->rx_ps_pages = pages; 1816 adapter->rx_ps_pages = pages;
1811 else 1817 else
1812 adapter->rx_ps_pages = 0; 1818 adapter->rx_ps_pages = 0;
@@ -2986,6 +2992,11 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
2986 return NETDEV_TX_OK; 2992 return NETDEV_TX_OK;
2987 } 2993 }
2988 2994
2995 /* 82571 and newer doesn't need the workaround that limited descriptor
2996 * length to 4kB */
2997 if (adapter->hw.mac_type >= e1000_82571)
2998 max_per_txd = 8192;
2999
2989#ifdef NETIF_F_TSO 3000#ifdef NETIF_F_TSO
2990 mss = skb_shinfo(skb)->gso_size; 3001 mss = skb_shinfo(skb)->gso_size;
2991 /* The controller does a simple calculation to 3002 /* The controller does a simple calculation to
@@ -3775,9 +3786,6 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter,
3775 3786
3776 length = le16_to_cpu(rx_desc->length); 3787 length = le16_to_cpu(rx_desc->length);
3777 3788
3778 /* adjust length to remove Ethernet CRC */
3779 length -= 4;
3780
3781 if (unlikely(!(status & E1000_RXD_STAT_EOP))) { 3789 if (unlikely(!(status & E1000_RXD_STAT_EOP))) {
3782 /* All receives must fit into a single buffer */ 3790 /* All receives must fit into a single buffer */
3783 E1000_DBG("%s: Receive packet consumed multiple" 3791 E1000_DBG("%s: Receive packet consumed multiple"
@@ -3805,6 +3813,10 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter,
3805 } 3813 }
3806 } 3814 }
3807 3815
3816 /* adjust length to remove Ethernet CRC, this must be
3817 * done after the TBI_ACCEPT workaround above */
3818 length -= 4;
3819
3808 /* code added for copybreak, this should improve 3820 /* code added for copybreak, this should improve
3809 * performance for small packets with large amounts 3821 * performance for small packets with large amounts
3810 * of reassembly being done in the stack */ 3822 * of reassembly being done in the stack */
@@ -4773,8 +4785,9 @@ e1000_suspend(struct pci_dev *pdev, pm_message_t state)
4773 pci_enable_wake(pdev, PCI_D3cold, 0); 4785 pci_enable_wake(pdev, PCI_D3cold, 0);
4774 } 4786 }
4775 4787
4776 if (adapter->hw.mac_type < e1000_82571 && 4788 if (adapter->hw.mac_type >= e1000_82540 &&
4777 adapter->hw.media_type == e1000_media_type_copper) { 4789 adapter->hw.mac_type < e1000_82571 &&
4790 adapter->hw.media_type == e1000_media_type_copper) {
4778 manc = E1000_READ_REG(&adapter->hw, MANC); 4791 manc = E1000_READ_REG(&adapter->hw, MANC);
4779 if (manc & E1000_MANC_SMBUS_EN) { 4792 if (manc & E1000_MANC_SMBUS_EN) {
4780 manc |= E1000_MANC_ARP_EN; 4793 manc |= E1000_MANC_ARP_EN;
@@ -4787,6 +4800,9 @@ e1000_suspend(struct pci_dev *pdev, pm_message_t state)
4787 if (adapter->hw.phy_type == e1000_phy_igp_3) 4800 if (adapter->hw.phy_type == e1000_phy_igp_3)
4788 e1000_phy_powerdown_workaround(&adapter->hw); 4801 e1000_phy_powerdown_workaround(&adapter->hw);
4789 4802
4803 if (netif_running(netdev))
4804 e1000_free_irq(adapter);
4805
4790 /* Release control of h/w to f/w. If f/w is AMT enabled, this 4806 /* Release control of h/w to f/w. If f/w is AMT enabled, this
4791 * would have already happened in close and is redundant. */ 4807 * would have already happened in close and is redundant. */
4792 e1000_release_hw_control(adapter); 4808 e1000_release_hw_control(adapter);
@@ -4817,6 +4833,10 @@ e1000_resume(struct pci_dev *pdev)
4817 pci_enable_wake(pdev, PCI_D3hot, 0); 4833 pci_enable_wake(pdev, PCI_D3hot, 0);
4818 pci_enable_wake(pdev, PCI_D3cold, 0); 4834 pci_enable_wake(pdev, PCI_D3cold, 0);
4819 4835
4836 if (netif_running(netdev) && (err = e1000_request_irq(adapter)))
4837 return err;
4838
4839 e1000_power_up_phy(adapter);
4820 e1000_reset(adapter); 4840 e1000_reset(adapter);
4821 E1000_WRITE_REG(&adapter->hw, WUS, ~0); 4841 E1000_WRITE_REG(&adapter->hw, WUS, ~0);
4822 4842
@@ -4825,8 +4845,9 @@ e1000_resume(struct pci_dev *pdev)
4825 4845
4826 netif_device_attach(netdev); 4846 netif_device_attach(netdev);
4827 4847
4828 if (adapter->hw.mac_type < e1000_82571 && 4848 if (adapter->hw.mac_type >= e1000_82540 &&
4829 adapter->hw.media_type == e1000_media_type_copper) { 4849 adapter->hw.mac_type < e1000_82571 &&
4850 adapter->hw.media_type == e1000_media_type_copper) {
4830 manc = E1000_READ_REG(&adapter->hw, MANC); 4851 manc = E1000_READ_REG(&adapter->hw, MANC);
4831 manc &= ~(E1000_MANC_ARP_EN); 4852 manc &= ~(E1000_MANC_ARP_EN);
4832 E1000_WRITE_REG(&adapter->hw, MANC, manc); 4853 E1000_WRITE_REG(&adapter->hw, MANC, manc);
@@ -4914,10 +4935,6 @@ static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
4914 pci_enable_wake(pdev, PCI_D3hot, 0); 4935 pci_enable_wake(pdev, PCI_D3hot, 0);
4915 pci_enable_wake(pdev, PCI_D3cold, 0); 4936 pci_enable_wake(pdev, PCI_D3cold, 0);
4916 4937
4917 /* Perform card reset only on one instance of the card */
4918 if (PCI_FUNC (pdev->devfn) != 0)
4919 return PCI_ERS_RESULT_RECOVERED;
4920
4921 e1000_reset(adapter); 4938 e1000_reset(adapter);
4922 E1000_WRITE_REG(&adapter->hw, WUS, ~0); 4939 E1000_WRITE_REG(&adapter->hw, WUS, ~0);
4923 4940
@@ -4948,6 +4965,7 @@ static void e1000_io_resume(struct pci_dev *pdev)
4948 netif_device_attach(netdev); 4965 netif_device_attach(netdev);
4949 4966
4950 if (adapter->hw.mac_type >= e1000_82540 && 4967 if (adapter->hw.mac_type >= e1000_82540 &&
4968 adapter->hw.mac_type < e1000_82571 &&
4951 adapter->hw.media_type == e1000_media_type_copper) { 4969 adapter->hw.media_type == e1000_media_type_copper) {
4952 manc = E1000_READ_REG(&adapter->hw, MANC); 4970 manc = E1000_READ_REG(&adapter->hw, MANC);
4953 manc &= ~(E1000_MANC_ARP_EN); 4971 manc &= ~(E1000_MANC_ARP_EN);
diff --git a/drivers/net/ehea/ehea.h b/drivers/net/ehea/ehea.h
index 23b451a8ae12..39ad9f73d1ec 100644
--- a/drivers/net/ehea/ehea.h
+++ b/drivers/net/ehea/ehea.h
@@ -39,7 +39,7 @@
39#include <asm/io.h> 39#include <asm/io.h>
40 40
41#define DRV_NAME "ehea" 41#define DRV_NAME "ehea"
42#define DRV_VERSION "EHEA_0028" 42#define DRV_VERSION "EHEA_0043"
43 43
44#define EHEA_MSG_DEFAULT (NETIF_MSG_LINK | NETIF_MSG_TIMER \ 44#define EHEA_MSG_DEFAULT (NETIF_MSG_LINK | NETIF_MSG_TIMER \
45 | NETIF_MSG_RX_ERR | NETIF_MSG_TX_ERR) 45 | NETIF_MSG_RX_ERR | NETIF_MSG_TX_ERR)
@@ -50,6 +50,7 @@
50#define EHEA_MAX_ENTRIES_SQ 32767 50#define EHEA_MAX_ENTRIES_SQ 32767
51#define EHEA_MIN_ENTRIES_QP 127 51#define EHEA_MIN_ENTRIES_QP 127
52 52
53#define EHEA_SMALL_QUEUES
53#define EHEA_NUM_TX_QP 1 54#define EHEA_NUM_TX_QP 1
54 55
55#ifdef EHEA_SMALL_QUEUES 56#ifdef EHEA_SMALL_QUEUES
@@ -59,11 +60,11 @@
59#define EHEA_DEF_ENTRIES_RQ2 1023 60#define EHEA_DEF_ENTRIES_RQ2 1023
60#define EHEA_DEF_ENTRIES_RQ3 1023 61#define EHEA_DEF_ENTRIES_RQ3 1023
61#else 62#else
62#define EHEA_MAX_CQE_COUNT 32000 63#define EHEA_MAX_CQE_COUNT 4080
63#define EHEA_DEF_ENTRIES_SQ 16000 64#define EHEA_DEF_ENTRIES_SQ 4080
64#define EHEA_DEF_ENTRIES_RQ1 32080 65#define EHEA_DEF_ENTRIES_RQ1 8160
65#define EHEA_DEF_ENTRIES_RQ2 4020 66#define EHEA_DEF_ENTRIES_RQ2 2040
66#define EHEA_DEF_ENTRIES_RQ3 4020 67#define EHEA_DEF_ENTRIES_RQ3 2040
67#endif 68#endif
68 69
69#define EHEA_MAX_ENTRIES_EQ 20 70#define EHEA_MAX_ENTRIES_EQ 20
@@ -104,9 +105,6 @@
104#define EHEA_BCMC_VLANID_ALL 0x01 105#define EHEA_BCMC_VLANID_ALL 0x01
105#define EHEA_BCMC_VLANID_SINGLE 0x00 106#define EHEA_BCMC_VLANID_SINGLE 0x00
106 107
107/* Use this define to kmallocate pHYP control blocks */
108#define H_CB_ALIGNMENT 4096
109
110#define EHEA_CACHE_LINE 128 108#define EHEA_CACHE_LINE 128
111 109
112/* Memory Regions */ 110/* Memory Regions */
diff --git a/drivers/net/ehea/ehea_ethtool.c b/drivers/net/ehea/ehea_ethtool.c
index 82eb2fb8c75e..9f57c2e78ced 100644
--- a/drivers/net/ehea/ehea_ethtool.c
+++ b/drivers/net/ehea/ehea_ethtool.c
@@ -238,7 +238,7 @@ static void ehea_get_ethtool_stats(struct net_device *dev,
238 data[i++] = port->port_res[0].swqe_refill_th; 238 data[i++] = port->port_res[0].swqe_refill_th;
239 data[i++] = port->resets; 239 data[i++] = port->resets;
240 240
241 cb6 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 241 cb6 = kzalloc(PAGE_SIZE, GFP_KERNEL);
242 if (!cb6) { 242 if (!cb6) {
243 ehea_error("no mem for cb6"); 243 ehea_error("no mem for cb6");
244 return; 244 return;
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index c6b31775e26b..6ad696101418 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -92,7 +92,7 @@ static struct net_device_stats *ehea_get_stats(struct net_device *dev)
92 92
93 memset(stats, 0, sizeof(*stats)); 93 memset(stats, 0, sizeof(*stats));
94 94
95 cb2 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 95 cb2 = kzalloc(PAGE_SIZE, GFP_KERNEL);
96 if (!cb2) { 96 if (!cb2) {
97 ehea_error("no mem for cb2"); 97 ehea_error("no mem for cb2");
98 goto out; 98 goto out;
@@ -586,8 +586,8 @@ int ehea_sense_port_attr(struct ehea_port *port)
586 u64 hret; 586 u64 hret;
587 struct hcp_ehea_port_cb0 *cb0; 587 struct hcp_ehea_port_cb0 *cb0;
588 588
589 cb0 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 589 cb0 = kzalloc(PAGE_SIZE, GFP_ATOMIC); /* May be called via */
590 if (!cb0) { 590 if (!cb0) { /* ehea_neq_tasklet() */
591 ehea_error("no mem for cb0"); 591 ehea_error("no mem for cb0");
592 ret = -ENOMEM; 592 ret = -ENOMEM;
593 goto out; 593 goto out;
@@ -670,7 +670,7 @@ int ehea_set_portspeed(struct ehea_port *port, u32 port_speed)
670 u64 hret; 670 u64 hret;
671 int ret = 0; 671 int ret = 0;
672 672
673 cb4 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 673 cb4 = kzalloc(PAGE_SIZE, GFP_KERNEL);
674 if (!cb4) { 674 if (!cb4) {
675 ehea_error("no mem for cb4"); 675 ehea_error("no mem for cb4");
676 ret = -ENOMEM; 676 ret = -ENOMEM;
@@ -765,8 +765,7 @@ static void ehea_parse_eqe(struct ehea_adapter *adapter, u64 eqe)
765 765
766 if (EHEA_BMASK_GET(NEQE_PORT_UP, eqe)) { 766 if (EHEA_BMASK_GET(NEQE_PORT_UP, eqe)) {
767 if (!netif_carrier_ok(port->netdev)) { 767 if (!netif_carrier_ok(port->netdev)) {
768 ret = ehea_sense_port_attr( 768 ret = ehea_sense_port_attr(port);
769 adapter->port[portnum]);
770 if (ret) { 769 if (ret) {
771 ehea_error("failed resensing port " 770 ehea_error("failed resensing port "
772 "attributes"); 771 "attributes");
@@ -818,7 +817,7 @@ static void ehea_parse_eqe(struct ehea_adapter *adapter, u64 eqe)
818 netif_stop_queue(port->netdev); 817 netif_stop_queue(port->netdev);
819 break; 818 break;
820 default: 819 default:
821 ehea_error("unknown event code %x", ec); 820 ehea_error("unknown event code %x, eqe=0x%lX", ec, eqe);
822 break; 821 break;
823 } 822 }
824} 823}
@@ -986,7 +985,7 @@ static int ehea_configure_port(struct ehea_port *port)
986 struct hcp_ehea_port_cb0 *cb0; 985 struct hcp_ehea_port_cb0 *cb0;
987 986
988 ret = -ENOMEM; 987 ret = -ENOMEM;
989 cb0 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 988 cb0 = kzalloc(PAGE_SIZE, GFP_KERNEL);
990 if (!cb0) 989 if (!cb0)
991 goto out; 990 goto out;
992 991
@@ -1444,7 +1443,7 @@ static int ehea_set_mac_addr(struct net_device *dev, void *sa)
1444 goto out; 1443 goto out;
1445 } 1444 }
1446 1445
1447 cb0 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 1446 cb0 = kzalloc(PAGE_SIZE, GFP_KERNEL);
1448 if (!cb0) { 1447 if (!cb0) {
1449 ehea_error("no mem for cb0"); 1448 ehea_error("no mem for cb0");
1450 ret = -ENOMEM; 1449 ret = -ENOMEM;
@@ -1502,7 +1501,7 @@ static void ehea_promiscuous(struct net_device *dev, int enable)
1502 if ((enable && port->promisc) || (!enable && !port->promisc)) 1501 if ((enable && port->promisc) || (!enable && !port->promisc))
1503 return; 1502 return;
1504 1503
1505 cb7 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 1504 cb7 = kzalloc(PAGE_SIZE, GFP_ATOMIC);
1506 if (!cb7) { 1505 if (!cb7) {
1507 ehea_error("no mem for cb7"); 1506 ehea_error("no mem for cb7");
1508 goto out; 1507 goto out;
@@ -1606,7 +1605,7 @@ static void ehea_add_multicast_entry(struct ehea_port* port, u8* mc_mac_addr)
1606 struct ehea_mc_list *ehea_mcl_entry; 1605 struct ehea_mc_list *ehea_mcl_entry;
1607 u64 hret; 1606 u64 hret;
1608 1607
1609 ehea_mcl_entry = kzalloc(sizeof(*ehea_mcl_entry), GFP_KERNEL); 1608 ehea_mcl_entry = kzalloc(sizeof(*ehea_mcl_entry), GFP_ATOMIC);
1610 if (!ehea_mcl_entry) { 1609 if (!ehea_mcl_entry) {
1611 ehea_error("no mem for mcl_entry"); 1610 ehea_error("no mem for mcl_entry");
1612 return; 1611 return;
@@ -1841,7 +1840,7 @@ static int ehea_start_xmit(struct sk_buff *skb, struct net_device *dev)
1841 1840
1842 if (netif_msg_tx_queued(port)) { 1841 if (netif_msg_tx_queued(port)) {
1843 ehea_info("post swqe on QP %d", pr->qp->init_attr.qp_nr); 1842 ehea_info("post swqe on QP %d", pr->qp->init_attr.qp_nr);
1844 ehea_dump(swqe, sizeof(*swqe), "swqe"); 1843 ehea_dump(swqe, 512, "swqe");
1845 } 1844 }
1846 1845
1847 ehea_post_swqe(pr->qp, swqe); 1846 ehea_post_swqe(pr->qp, swqe);
@@ -1871,7 +1870,7 @@ static void ehea_vlan_rx_register(struct net_device *dev,
1871 1870
1872 port->vgrp = grp; 1871 port->vgrp = grp;
1873 1872
1874 cb1 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 1873 cb1 = kzalloc(PAGE_SIZE, GFP_KERNEL);
1875 if (!cb1) { 1874 if (!cb1) {
1876 ehea_error("no mem for cb1"); 1875 ehea_error("no mem for cb1");
1877 goto out; 1876 goto out;
@@ -1900,7 +1899,7 @@ static void ehea_vlan_rx_add_vid(struct net_device *dev, unsigned short vid)
1900 int index; 1899 int index;
1901 u64 hret; 1900 u64 hret;
1902 1901
1903 cb1 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 1902 cb1 = kzalloc(PAGE_SIZE, GFP_KERNEL);
1904 if (!cb1) { 1903 if (!cb1) {
1905 ehea_error("no mem for cb1"); 1904 ehea_error("no mem for cb1");
1906 goto out; 1905 goto out;
@@ -1936,7 +1935,7 @@ static void ehea_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
1936 if (port->vgrp) 1935 if (port->vgrp)
1937 port->vgrp->vlan_devices[vid] = NULL; 1936 port->vgrp->vlan_devices[vid] = NULL;
1938 1937
1939 cb1 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 1938 cb1 = kzalloc(PAGE_SIZE, GFP_KERNEL);
1940 if (!cb1) { 1939 if (!cb1) {
1941 ehea_error("no mem for cb1"); 1940 ehea_error("no mem for cb1");
1942 goto out; 1941 goto out;
@@ -1969,7 +1968,7 @@ int ehea_activate_qp(struct ehea_adapter *adapter, struct ehea_qp *qp)
1969 u64 dummy64 = 0; 1968 u64 dummy64 = 0;
1970 struct hcp_modify_qp_cb0* cb0; 1969 struct hcp_modify_qp_cb0* cb0;
1971 1970
1972 cb0 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 1971 cb0 = kzalloc(PAGE_SIZE, GFP_KERNEL);
1973 if (!cb0) { 1972 if (!cb0) {
1974 ret = -ENOMEM; 1973 ret = -ENOMEM;
1975 goto out; 1974 goto out;
@@ -2270,7 +2269,7 @@ int ehea_sense_adapter_attr(struct ehea_adapter *adapter)
2270 u64 hret; 2269 u64 hret;
2271 int ret; 2270 int ret;
2272 2271
2273 cb = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 2272 cb = kzalloc(PAGE_SIZE, GFP_KERNEL);
2274 if (!cb) { 2273 if (!cb) {
2275 ret = -ENOMEM; 2274 ret = -ENOMEM;
2276 goto out; 2275 goto out;
@@ -2341,7 +2340,7 @@ static int ehea_setup_single_port(struct ehea_port *port,
2341 goto out; 2340 goto out;
2342 2341
2343 /* Enable Jumbo frames */ 2342 /* Enable Jumbo frames */
2344 cb4 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 2343 cb4 = kzalloc(PAGE_SIZE, GFP_KERNEL);
2345 if (!cb4) { 2344 if (!cb4) {
2346 ehea_error("no mem for cb4"); 2345 ehea_error("no mem for cb4");
2347 } else { 2346 } else {
diff --git a/drivers/net/ehea/ehea_phyp.c b/drivers/net/ehea/ehea_phyp.c
index 4a85aca4c7e9..0cfc2bc1a27b 100644
--- a/drivers/net/ehea/ehea_phyp.c
+++ b/drivers/net/ehea/ehea_phyp.c
@@ -44,71 +44,99 @@ static inline u16 get_order_of_qentries(u16 queue_entries)
44#define H_ALL_RES_TYPE_MR 5 44#define H_ALL_RES_TYPE_MR 5
45#define H_ALL_RES_TYPE_MW 6 45#define H_ALL_RES_TYPE_MW 6
46 46
47static long ehea_hcall_9arg_9ret(unsigned long opcode, 47static long ehea_plpar_hcall_norets(unsigned long opcode,
48 unsigned long arg1, unsigned long arg2, 48 unsigned long arg1,
49 unsigned long arg3, unsigned long arg4, 49 unsigned long arg2,
50 unsigned long arg5, unsigned long arg6, 50 unsigned long arg3,
51 unsigned long arg7, unsigned long arg8, 51 unsigned long arg4,
52 unsigned long arg9, unsigned long *out1, 52 unsigned long arg5,
53 unsigned long *out2,unsigned long *out3, 53 unsigned long arg6,
54 unsigned long *out4,unsigned long *out5, 54 unsigned long arg7)
55 unsigned long *out6,unsigned long *out7,
56 unsigned long *out8,unsigned long *out9)
57{ 55{
58 long hret; 56 long ret;
59 int i, sleep_msecs; 57 int i, sleep_msecs;
60 58
61 for (i = 0; i < 5; i++) { 59 for (i = 0; i < 5; i++) {
62 hret = plpar_hcall_9arg_9ret(opcode,arg1, arg2, arg3, arg4, 60 ret = plpar_hcall_norets(opcode, arg1, arg2, arg3, arg4,
63 arg5, arg6, arg7, arg8, arg9, out1, 61 arg5, arg6, arg7);
64 out2, out3, out4, out5, out6, out7, 62
65 out8, out9); 63 if (H_IS_LONG_BUSY(ret)) {
66 if (H_IS_LONG_BUSY(hret)) { 64 sleep_msecs = get_longbusy_msecs(ret);
67 sleep_msecs = get_longbusy_msecs(hret);
68 msleep_interruptible(sleep_msecs); 65 msleep_interruptible(sleep_msecs);
69 continue; 66 continue;
70 } 67 }
71 68
72 if (hret < H_SUCCESS) 69 if (ret < H_SUCCESS)
73 ehea_error("op=%lx hret=%lx " 70 ehea_error("opcode=%lx ret=%lx"
74 "i1=%lx i2=%lx i3=%lx i4=%lx i5=%lx i6=%lx " 71 " arg1=%lx arg2=%lx arg3=%lx arg4=%lx"
75 "i7=%lx i8=%lx i9=%lx " 72 " arg5=%lx arg6=%lx arg7=%lx ",
76 "o1=%lx o2=%lx o3=%lx o4=%lx o5=%lx o6=%lx " 73 opcode, ret,
77 "o7=%lx o8=%lx o9=%lx", 74 arg1, arg2, arg3, arg4, arg5,
78 opcode, hret, arg1, arg2, arg3, arg4, arg5, 75 arg6, arg7);
79 arg6, arg7, arg8, arg9, *out1, *out2, *out3, 76
80 *out4, *out5, *out6, *out7, *out8, *out9); 77 return ret;
81 return hret;
82 } 78 }
79
83 return H_BUSY; 80 return H_BUSY;
84} 81}
85 82
86u64 ehea_h_query_ehea_qp(const u64 adapter_handle, const u8 qp_category, 83static long ehea_plpar_hcall9(unsigned long opcode,
87 const u64 qp_handle, const u64 sel_mask, void *cb_addr) 84 unsigned long *outs, /* array of 9 outputs */
85 unsigned long arg1,
86 unsigned long arg2,
87 unsigned long arg3,
88 unsigned long arg4,
89 unsigned long arg5,
90 unsigned long arg6,
91 unsigned long arg7,
92 unsigned long arg8,
93 unsigned long arg9)
88{ 94{
89 u64 dummy; 95 long ret;
96 int i, sleep_msecs;
90 97
91 if ((((u64)cb_addr) & (PAGE_SIZE - 1)) != 0) { 98 for (i = 0; i < 5; i++) {
92 ehea_error("not on pageboundary"); 99 ret = plpar_hcall9(opcode, outs,
93 return H_PARAMETER; 100 arg1, arg2, arg3, arg4, arg5,
101 arg6, arg7, arg8, arg9);
102
103 if (H_IS_LONG_BUSY(ret)) {
104 sleep_msecs = get_longbusy_msecs(ret);
105 msleep_interruptible(sleep_msecs);
106 continue;
107 }
108
109 if (ret < H_SUCCESS)
110 ehea_error("opcode=%lx ret=%lx"
111 " arg1=%lx arg2=%lx arg3=%lx arg4=%lx"
112 " arg5=%lx arg6=%lx arg7=%lx arg8=%lx"
113 " arg9=%lx"
114 " out1=%lx out2=%lx out3=%lx out4=%lx"
115 " out5=%lx out6=%lx out7=%lx out8=%lx"
116 " out9=%lx",
117 opcode, ret,
118 arg1, arg2, arg3, arg4, arg5,
119 arg6, arg7, arg8, arg9,
120 outs[0], outs[1], outs[2], outs[3],
121 outs[4], outs[5], outs[6], outs[7],
122 outs[8]);
123
124 return ret;
94 } 125 }
95 126
96 return ehea_hcall_9arg_9ret(H_QUERY_HEA_QP, 127 return H_BUSY;
97 adapter_handle, /* R4 */ 128}
98 qp_category, /* R5 */ 129
99 qp_handle, /* R6 */ 130u64 ehea_h_query_ehea_qp(const u64 adapter_handle, const u8 qp_category,
100 sel_mask, /* R7 */ 131 const u64 qp_handle, const u64 sel_mask, void *cb_addr)
101 virt_to_abs(cb_addr), /* R8 */ 132{
102 0, 0, 0, 0, /* R9-R12 */ 133 return ehea_plpar_hcall_norets(H_QUERY_HEA_QP,
103 &dummy, /* R4 */ 134 adapter_handle, /* R4 */
104 &dummy, /* R5 */ 135 qp_category, /* R5 */
105 &dummy, /* R6 */ 136 qp_handle, /* R6 */
106 &dummy, /* R7 */ 137 sel_mask, /* R7 */
107 &dummy, /* R8 */ 138 virt_to_abs(cb_addr), /* R8 */
108 &dummy, /* R9 */ 139 0, 0);
109 &dummy, /* R10 */
110 &dummy, /* R11 */
111 &dummy); /* R12 */
112} 140}
113 141
114/* input param R5 */ 142/* input param R5 */
@@ -180,6 +208,7 @@ u64 ehea_h_alloc_resource_qp(const u64 adapter_handle,
180 u64 *qp_handle, struct h_epas *h_epas) 208 u64 *qp_handle, struct h_epas *h_epas)
181{ 209{
182 u64 hret; 210 u64 hret;
211 u64 outs[PLPAR_HCALL9_BUFSIZE];
183 212
184 u64 allocate_controls = 213 u64 allocate_controls =
185 EHEA_BMASK_SET(H_ALL_RES_QP_EQPO, init_attr->low_lat_rq1 ? 1 : 0) 214 EHEA_BMASK_SET(H_ALL_RES_QP_EQPO, init_attr->low_lat_rq1 ? 1 : 0)
@@ -219,45 +248,29 @@ u64 ehea_h_alloc_resource_qp(const u64 adapter_handle,
219 EHEA_BMASK_SET(H_ALL_RES_QP_TH_RQ2, init_attr->rq2_threshold) 248 EHEA_BMASK_SET(H_ALL_RES_QP_TH_RQ2, init_attr->rq2_threshold)
220 | EHEA_BMASK_SET(H_ALL_RES_QP_TH_RQ3, init_attr->rq3_threshold); 249 | EHEA_BMASK_SET(H_ALL_RES_QP_TH_RQ3, init_attr->rq3_threshold);
221 250
222 u64 r5_out = 0; 251 hret = ehea_plpar_hcall9(H_ALLOC_HEA_RESOURCE,
223 u64 r6_out = 0; 252 outs,
224 u64 r7_out = 0; 253 adapter_handle, /* R4 */
225 u64 r8_out = 0; 254 allocate_controls, /* R5 */
226 u64 r9_out = 0; 255 init_attr->send_cq_handle, /* R6 */
227 u64 g_la_user_out = 0; 256 init_attr->recv_cq_handle, /* R7 */
228 u64 r11_out = 0; 257 init_attr->aff_eq_handle, /* R8 */
229 u64 r12_out = 0; 258 r9_reg, /* R9 */
230 259 max_r10_reg, /* R10 */
231 hret = ehea_hcall_9arg_9ret(H_ALLOC_HEA_RESOURCE, 260 r11_in, /* R11 */
232 adapter_handle, /* R4 */ 261 threshold); /* R12 */
233 allocate_controls, /* R5 */ 262
234 init_attr->send_cq_handle, /* R6 */ 263 *qp_handle = outs[0];
235 init_attr->recv_cq_handle, /* R7 */ 264 init_attr->qp_nr = (u32)outs[1];
236 init_attr->aff_eq_handle, /* R8 */
237 r9_reg, /* R9 */
238 max_r10_reg, /* R10 */
239 r11_in, /* R11 */
240 threshold, /* R12 */
241 qp_handle, /* R4 */
242 &r5_out, /* R5 */
243 &r6_out, /* R6 */
244 &r7_out, /* R7 */
245 &r8_out, /* R8 */
246 &r9_out, /* R9 */
247 &g_la_user_out, /* R10 */
248 &r11_out, /* R11 */
249 &r12_out); /* R12 */
250
251 init_attr->qp_nr = (u32)r5_out;
252 265
253 init_attr->act_nr_send_wqes = 266 init_attr->act_nr_send_wqes =
254 (u16)EHEA_BMASK_GET(H_ALL_RES_QP_ACT_SWQE, r6_out); 267 (u16)EHEA_BMASK_GET(H_ALL_RES_QP_ACT_SWQE, outs[2]);
255 init_attr->act_nr_rwqes_rq1 = 268 init_attr->act_nr_rwqes_rq1 =
256 (u16)EHEA_BMASK_GET(H_ALL_RES_QP_ACT_R1WQE, r6_out); 269 (u16)EHEA_BMASK_GET(H_ALL_RES_QP_ACT_R1WQE, outs[2]);
257 init_attr->act_nr_rwqes_rq2 = 270 init_attr->act_nr_rwqes_rq2 =
258 (u16)EHEA_BMASK_GET(H_ALL_RES_QP_ACT_R2WQE, r6_out); 271 (u16)EHEA_BMASK_GET(H_ALL_RES_QP_ACT_R2WQE, outs[2]);
259 init_attr->act_nr_rwqes_rq3 = 272 init_attr->act_nr_rwqes_rq3 =
260 (u16)EHEA_BMASK_GET(H_ALL_RES_QP_ACT_R3WQE, r6_out); 273 (u16)EHEA_BMASK_GET(H_ALL_RES_QP_ACT_R3WQE, outs[2]);
261 274
262 init_attr->act_wqe_size_enc_sq = init_attr->wqe_size_enc_sq; 275 init_attr->act_wqe_size_enc_sq = init_attr->wqe_size_enc_sq;
263 init_attr->act_wqe_size_enc_rq1 = init_attr->wqe_size_enc_rq1; 276 init_attr->act_wqe_size_enc_rq1 = init_attr->wqe_size_enc_rq1;
@@ -265,25 +278,25 @@ u64 ehea_h_alloc_resource_qp(const u64 adapter_handle,
265 init_attr->act_wqe_size_enc_rq3 = init_attr->wqe_size_enc_rq3; 278 init_attr->act_wqe_size_enc_rq3 = init_attr->wqe_size_enc_rq3;
266 279
267 init_attr->nr_sq_pages = 280 init_attr->nr_sq_pages =
268 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_SIZE_SQ, r8_out); 281 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_SIZE_SQ, outs[4]);
269 init_attr->nr_rq1_pages = 282 init_attr->nr_rq1_pages =
270 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_SIZE_RQ1, r8_out); 283 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_SIZE_RQ1, outs[4]);
271 init_attr->nr_rq2_pages = 284 init_attr->nr_rq2_pages =
272 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_SIZE_RQ2, r9_out); 285 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_SIZE_RQ2, outs[5]);
273 init_attr->nr_rq3_pages = 286 init_attr->nr_rq3_pages =
274 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_SIZE_RQ3, r9_out); 287 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_SIZE_RQ3, outs[5]);
275 288
276 init_attr->liobn_sq = 289 init_attr->liobn_sq =
277 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_LIOBN_SQ, r11_out); 290 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_LIOBN_SQ, outs[7]);
278 init_attr->liobn_rq1 = 291 init_attr->liobn_rq1 =
279 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_LIOBN_RQ1, r11_out); 292 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_LIOBN_RQ1, outs[7]);
280 init_attr->liobn_rq2 = 293 init_attr->liobn_rq2 =
281 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_LIOBN_RQ2, r12_out); 294 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_LIOBN_RQ2, outs[8]);
282 init_attr->liobn_rq3 = 295 init_attr->liobn_rq3 =
283 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_LIOBN_RQ3, r12_out); 296 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_LIOBN_RQ3, outs[8]);
284 297
285 if (!hret) 298 if (!hret)
286 hcp_epas_ctor(h_epas, g_la_user_out, g_la_user_out); 299 hcp_epas_ctor(h_epas, outs[6], outs[6]);
287 300
288 return hret; 301 return hret;
289} 302}
@@ -292,31 +305,24 @@ u64 ehea_h_alloc_resource_cq(const u64 adapter_handle,
292 struct ehea_cq_attr *cq_attr, 305 struct ehea_cq_attr *cq_attr,
293 u64 *cq_handle, struct h_epas *epas) 306 u64 *cq_handle, struct h_epas *epas)
294{ 307{
295 u64 hret, dummy, act_nr_of_cqes_out, act_pages_out; 308 u64 hret;
296 u64 g_la_privileged_out, g_la_user_out; 309 u64 outs[PLPAR_HCALL9_BUFSIZE];
297 310
298 hret = ehea_hcall_9arg_9ret(H_ALLOC_HEA_RESOURCE, 311 hret = ehea_plpar_hcall9(H_ALLOC_HEA_RESOURCE,
299 adapter_handle, /* R4 */ 312 outs,
300 H_ALL_RES_TYPE_CQ, /* R5 */ 313 adapter_handle, /* R4 */
301 cq_attr->eq_handle, /* R6 */ 314 H_ALL_RES_TYPE_CQ, /* R5 */
302 cq_attr->cq_token, /* R7 */ 315 cq_attr->eq_handle, /* R6 */
303 cq_attr->max_nr_of_cqes, /* R8 */ 316 cq_attr->cq_token, /* R7 */
304 0, 0, 0, 0, /* R9-R12 */ 317 cq_attr->max_nr_of_cqes, /* R8 */
305 cq_handle, /* R4 */ 318 0, 0, 0, 0); /* R9-R12 */
306 &dummy, /* R5 */ 319
307 &dummy, /* R6 */ 320 *cq_handle = outs[0];
308 &act_nr_of_cqes_out, /* R7 */ 321 cq_attr->act_nr_of_cqes = outs[3];
309 &act_pages_out, /* R8 */ 322 cq_attr->nr_pages = outs[4];
310 &g_la_privileged_out, /* R9 */
311 &g_la_user_out, /* R10 */
312 &dummy, /* R11 */
313 &dummy); /* R12 */
314
315 cq_attr->act_nr_of_cqes = act_nr_of_cqes_out;
316 cq_attr->nr_pages = act_pages_out;
317 323
318 if (!hret) 324 if (!hret)
319 hcp_epas_ctor(epas, g_la_privileged_out, g_la_user_out); 325 hcp_epas_ctor(epas, outs[5], outs[6]);
320 326
321 return hret; 327 return hret;
322} 328}
@@ -361,9 +367,8 @@ u64 ehea_h_alloc_resource_cq(const u64 adapter_handle,
361u64 ehea_h_alloc_resource_eq(const u64 adapter_handle, 367u64 ehea_h_alloc_resource_eq(const u64 adapter_handle,
362 struct ehea_eq_attr *eq_attr, u64 *eq_handle) 368 struct ehea_eq_attr *eq_attr, u64 *eq_handle)
363{ 369{
364 u64 hret, dummy, eq_liobn, allocate_controls; 370 u64 hret, allocate_controls;
365 u64 ist1_out, ist2_out, ist3_out, ist4_out; 371 u64 outs[PLPAR_HCALL9_BUFSIZE];
366 u64 act_nr_of_eqes_out, act_pages_out;
367 372
368 /* resource type */ 373 /* resource type */
369 allocate_controls = 374 allocate_controls =
@@ -372,27 +377,20 @@ u64 ehea_h_alloc_resource_eq(const u64 adapter_handle,
372 | EHEA_BMASK_SET(H_ALL_RES_EQ_INH_EQE_GEN, !eq_attr->eqe_gen) 377 | EHEA_BMASK_SET(H_ALL_RES_EQ_INH_EQE_GEN, !eq_attr->eqe_gen)
373 | EHEA_BMASK_SET(H_ALL_RES_EQ_NON_NEQ_ISN, 1); 378 | EHEA_BMASK_SET(H_ALL_RES_EQ_NON_NEQ_ISN, 1);
374 379
375 hret = ehea_hcall_9arg_9ret(H_ALLOC_HEA_RESOURCE, 380 hret = ehea_plpar_hcall9(H_ALLOC_HEA_RESOURCE,
376 adapter_handle, /* R4 */ 381 outs,
377 allocate_controls, /* R5 */ 382 adapter_handle, /* R4 */
378 eq_attr->max_nr_of_eqes, /* R6 */ 383 allocate_controls, /* R5 */
379 0, 0, 0, 0, 0, 0, /* R7-R10 */ 384 eq_attr->max_nr_of_eqes, /* R6 */
380 eq_handle, /* R4 */ 385 0, 0, 0, 0, 0, 0); /* R7-R10 */
381 &dummy, /* R5 */ 386
382 &eq_liobn, /* R6 */ 387 *eq_handle = outs[0];
383 &act_nr_of_eqes_out, /* R7 */ 388 eq_attr->act_nr_of_eqes = outs[3];
384 &act_pages_out, /* R8 */ 389 eq_attr->nr_pages = outs[4];
385 &ist1_out, /* R9 */ 390 eq_attr->ist1 = outs[5];
386 &ist2_out, /* R10 */ 391 eq_attr->ist2 = outs[6];
387 &ist3_out, /* R11 */ 392 eq_attr->ist3 = outs[7];
388 &ist4_out); /* R12 */ 393 eq_attr->ist4 = outs[8];
389
390 eq_attr->act_nr_of_eqes = act_nr_of_eqes_out;
391 eq_attr->nr_pages = act_pages_out;
392 eq_attr->ist1 = ist1_out;
393 eq_attr->ist2 = ist2_out;
394 eq_attr->ist3 = ist3_out;
395 eq_attr->ist4 = ist4_out;
396 394
397 return hret; 395 return hret;
398} 396}
@@ -402,31 +400,22 @@ u64 ehea_h_modify_ehea_qp(const u64 adapter_handle, const u8 cat,
402 void *cb_addr, u64 *inv_attr_id, u64 *proc_mask, 400 void *cb_addr, u64 *inv_attr_id, u64 *proc_mask,
403 u16 *out_swr, u16 *out_rwr) 401 u16 *out_swr, u16 *out_rwr)
404{ 402{
405 u64 hret, dummy, act_out_swr, act_out_rwr; 403 u64 hret;
406 404 u64 outs[PLPAR_HCALL9_BUFSIZE];
407 if ((((u64)cb_addr) & (PAGE_SIZE - 1)) != 0) { 405
408 ehea_error("not on page boundary"); 406 hret = ehea_plpar_hcall9(H_MODIFY_HEA_QP,
409 return H_PARAMETER; 407 outs,
410 } 408 adapter_handle, /* R4 */
411 409 (u64) cat, /* R5 */
412 hret = ehea_hcall_9arg_9ret(H_MODIFY_HEA_QP, 410 qp_handle, /* R6 */
413 adapter_handle, /* R4 */ 411 sel_mask, /* R7 */
414 (u64) cat, /* R5 */ 412 virt_to_abs(cb_addr), /* R8 */
415 qp_handle, /* R6 */ 413 0, 0, 0, 0); /* R9-R12 */
416 sel_mask, /* R7 */ 414
417 virt_to_abs(cb_addr), /* R8 */ 415 *inv_attr_id = outs[0];
418 0, 0, 0, 0, /* R9-R12 */ 416 *out_swr = outs[3];
419 inv_attr_id, /* R4 */ 417 *out_rwr = outs[4];
420 &dummy, /* R5 */ 418 *proc_mask = outs[5];
421 &dummy, /* R6 */
422 &act_out_swr, /* R7 */
423 &act_out_rwr, /* R8 */
424 proc_mask, /* R9 */
425 &dummy, /* R10 */
426 &dummy, /* R11 */
427 &dummy); /* R12 */
428 *out_swr = act_out_swr;
429 *out_rwr = act_out_rwr;
430 419
431 return hret; 420 return hret;
432} 421}
@@ -435,122 +424,81 @@ u64 ehea_h_register_rpage(const u64 adapter_handle, const u8 pagesize,
435 const u8 queue_type, const u64 resource_handle, 424 const u8 queue_type, const u64 resource_handle,
436 const u64 log_pageaddr, u64 count) 425 const u64 log_pageaddr, u64 count)
437{ 426{
438 u64 dummy, reg_control; 427 u64 reg_control;
439 428
440 reg_control = EHEA_BMASK_SET(H_REG_RPAGE_PAGE_SIZE, pagesize) 429 reg_control = EHEA_BMASK_SET(H_REG_RPAGE_PAGE_SIZE, pagesize)
441 | EHEA_BMASK_SET(H_REG_RPAGE_QT, queue_type); 430 | EHEA_BMASK_SET(H_REG_RPAGE_QT, queue_type);
442 431
443 return ehea_hcall_9arg_9ret(H_REGISTER_HEA_RPAGES, 432 return ehea_plpar_hcall_norets(H_REGISTER_HEA_RPAGES,
444 adapter_handle, /* R4 */ 433 adapter_handle, /* R4 */
445 reg_control, /* R5 */ 434 reg_control, /* R5 */
446 resource_handle, /* R6 */ 435 resource_handle, /* R6 */
447 log_pageaddr, /* R7 */ 436 log_pageaddr, /* R7 */
448 count, /* R8 */ 437 count, /* R8 */
449 0, 0, 0, 0, /* R9-R12 */ 438 0, 0); /* R9-R10 */
450 &dummy, /* R4 */
451 &dummy, /* R5 */
452 &dummy, /* R6 */
453 &dummy, /* R7 */
454 &dummy, /* R8 */
455 &dummy, /* R9 */
456 &dummy, /* R10 */
457 &dummy, /* R11 */
458 &dummy); /* R12 */
459} 439}
460 440
461u64 ehea_h_register_smr(const u64 adapter_handle, const u64 orig_mr_handle, 441u64 ehea_h_register_smr(const u64 adapter_handle, const u64 orig_mr_handle,
462 const u64 vaddr_in, const u32 access_ctrl, const u32 pd, 442 const u64 vaddr_in, const u32 access_ctrl, const u32 pd,
463 struct ehea_mr *mr) 443 struct ehea_mr *mr)
464{ 444{
465 u64 hret, dummy, lkey_out; 445 u64 hret;
466 446 u64 outs[PLPAR_HCALL9_BUFSIZE];
467 hret = ehea_hcall_9arg_9ret(H_REGISTER_SMR, 447
468 adapter_handle , /* R4 */ 448 hret = ehea_plpar_hcall9(H_REGISTER_SMR,
469 orig_mr_handle, /* R5 */ 449 outs,
470 vaddr_in, /* R6 */ 450 adapter_handle , /* R4 */
471 (((u64)access_ctrl) << 32ULL), /* R7 */ 451 orig_mr_handle, /* R5 */
472 pd, /* R8 */ 452 vaddr_in, /* R6 */
473 0, 0, 0, 0, /* R9-R12 */ 453 (((u64)access_ctrl) << 32ULL), /* R7 */
474 &mr->handle, /* R4 */ 454 pd, /* R8 */
475 &dummy, /* R5 */ 455 0, 0, 0, 0); /* R9-R12 */
476 &lkey_out, /* R6 */ 456
477 &dummy, /* R7 */ 457 mr->handle = outs[0];
478 &dummy, /* R8 */ 458 mr->lkey = (u32)outs[2];
479 &dummy, /* R9 */
480 &dummy, /* R10 */
481 &dummy, /* R11 */
482 &dummy); /* R12 */
483 mr->lkey = (u32)lkey_out;
484 459
485 return hret; 460 return hret;
486} 461}
487 462
488u64 ehea_h_disable_and_get_hea(const u64 adapter_handle, const u64 qp_handle) 463u64 ehea_h_disable_and_get_hea(const u64 adapter_handle, const u64 qp_handle)
489{ 464{
490 u64 hret, dummy, ladr_next_sq_wqe_out; 465 u64 outs[PLPAR_HCALL9_BUFSIZE];
491 u64 ladr_next_rq1_wqe_out, ladr_next_rq2_wqe_out, ladr_next_rq3_wqe_out; 466
492 467 return ehea_plpar_hcall9(H_DISABLE_AND_GET_HEA,
493 hret = ehea_hcall_9arg_9ret(H_DISABLE_AND_GET_HEA, 468 outs,
494 adapter_handle, /* R4 */ 469 adapter_handle, /* R4 */
495 H_DISABLE_GET_EHEA_WQE_P, /* R5 */ 470 H_DISABLE_GET_EHEA_WQE_P, /* R5 */
496 qp_handle, /* R6 */ 471 qp_handle, /* R6 */
497 0, 0, 0, 0, 0, 0, /* R7-R12 */ 472 0, 0, 0, 0, 0, 0); /* R7-R12 */
498 &ladr_next_sq_wqe_out, /* R4 */
499 &ladr_next_rq1_wqe_out, /* R5 */
500 &ladr_next_rq2_wqe_out, /* R6 */
501 &ladr_next_rq3_wqe_out, /* R7 */
502 &dummy, /* R8 */
503 &dummy, /* R9 */
504 &dummy, /* R10 */
505 &dummy, /* R11 */
506 &dummy); /* R12 */
507 return hret;
508} 473}
509 474
510u64 ehea_h_free_resource(const u64 adapter_handle, const u64 res_handle) 475u64 ehea_h_free_resource(const u64 adapter_handle, const u64 res_handle)
511{ 476{
512 u64 dummy; 477 return ehea_plpar_hcall_norets(H_FREE_RESOURCE,
513 478 adapter_handle, /* R4 */
514 return ehea_hcall_9arg_9ret(H_FREE_RESOURCE, 479 res_handle, /* R5 */
515 adapter_handle, /* R4 */ 480 0, 0, 0, 0, 0); /* R6-R10 */
516 res_handle, /* R5 */
517 0, 0, 0, 0, 0, 0, 0, /* R6-R12 */
518 &dummy, /* R4 */
519 &dummy, /* R5 */
520 &dummy, /* R6 */
521 &dummy, /* R7 */
522 &dummy, /* R8 */
523 &dummy, /* R9 */
524 &dummy, /* R10 */
525 &dummy, /* R11 */
526 &dummy); /* R12 */
527} 481}
528 482
529u64 ehea_h_alloc_resource_mr(const u64 adapter_handle, const u64 vaddr, 483u64 ehea_h_alloc_resource_mr(const u64 adapter_handle, const u64 vaddr,
530 const u64 length, const u32 access_ctrl, 484 const u64 length, const u32 access_ctrl,
531 const u32 pd, u64 *mr_handle, u32 *lkey) 485 const u32 pd, u64 *mr_handle, u32 *lkey)
532{ 486{
533 u64 hret, dummy, lkey_out; 487 u64 hret;
534 488 u64 outs[PLPAR_HCALL9_BUFSIZE];
535 hret = ehea_hcall_9arg_9ret(H_ALLOC_HEA_RESOURCE, 489
536 adapter_handle, /* R4 */ 490 hret = ehea_plpar_hcall9(H_ALLOC_HEA_RESOURCE,
537 5, /* R5 */ 491 outs,
538 vaddr, /* R6 */ 492 adapter_handle, /* R4 */
539 length, /* R7 */ 493 5, /* R5 */
540 (((u64) access_ctrl) << 32ULL),/* R8 */ 494 vaddr, /* R6 */
541 pd, /* R9 */ 495 length, /* R7 */
542 0, 0, 0, /* R10-R12 */ 496 (((u64) access_ctrl) << 32ULL), /* R8 */
543 mr_handle, /* R4 */ 497 pd, /* R9 */
544 &dummy, /* R5 */ 498 0, 0, 0); /* R10-R12 */
545 &lkey_out, /* R6 */ 499
546 &dummy, /* R7 */ 500 *mr_handle = outs[0];
547 &dummy, /* R8 */ 501 *lkey = (u32)outs[2];
548 &dummy, /* R9 */
549 &dummy, /* R10 */
550 &dummy, /* R11 */
551 &dummy); /* R12 */
552 *lkey = (u32) lkey_out;
553
554 return hret; 502 return hret;
555} 503}
556 504
@@ -558,7 +506,7 @@ u64 ehea_h_register_rpage_mr(const u64 adapter_handle, const u64 mr_handle,
558 const u8 pagesize, const u8 queue_type, 506 const u8 pagesize, const u8 queue_type,
559 const u64 log_pageaddr, const u64 count) 507 const u64 log_pageaddr, const u64 count)
560{ 508{
561 if ((count > 1) && (log_pageaddr & 0xfff)) { 509 if ((count > 1) && (log_pageaddr & ~PAGE_MASK)) {
562 ehea_error("not on pageboundary"); 510 ehea_error("not on pageboundary");
563 return H_PARAMETER; 511 return H_PARAMETER;
564 } 512 }
@@ -570,23 +518,14 @@ u64 ehea_h_register_rpage_mr(const u64 adapter_handle, const u64 mr_handle,
570 518
571u64 ehea_h_query_ehea(const u64 adapter_handle, void *cb_addr) 519u64 ehea_h_query_ehea(const u64 adapter_handle, void *cb_addr)
572{ 520{
573 u64 hret, dummy, cb_logaddr; 521 u64 hret, cb_logaddr;
574 522
575 cb_logaddr = virt_to_abs(cb_addr); 523 cb_logaddr = virt_to_abs(cb_addr);
576 524
577 hret = ehea_hcall_9arg_9ret(H_QUERY_HEA, 525 hret = ehea_plpar_hcall_norets(H_QUERY_HEA,
578 adapter_handle, /* R4 */ 526 adapter_handle, /* R4 */
579 cb_logaddr, /* R5 */ 527 cb_logaddr, /* R5 */
580 0, 0, 0, 0, 0, 0, 0, /* R6-R12 */ 528 0, 0, 0, 0, 0); /* R6-R10 */
581 &dummy, /* R4 */
582 &dummy, /* R5 */
583 &dummy, /* R6 */
584 &dummy, /* R7 */
585 &dummy, /* R8 */
586 &dummy, /* R9 */
587 &dummy, /* R10 */
588 &dummy, /* R11 */
589 &dummy); /* R12 */
590#ifdef DEBUG 529#ifdef DEBUG
591 ehea_dmp(cb_addr, sizeof(struct hcp_query_ehea), "hcp_query_ehea"); 530 ehea_dmp(cb_addr, sizeof(struct hcp_query_ehea), "hcp_query_ehea");
592#endif 531#endif
@@ -597,36 +536,28 @@ u64 ehea_h_query_ehea_port(const u64 adapter_handle, const u16 port_num,
597 const u8 cb_cat, const u64 select_mask, 536 const u8 cb_cat, const u64 select_mask,
598 void *cb_addr) 537 void *cb_addr)
599{ 538{
600 u64 port_info, dummy; 539 u64 port_info;
601 u64 cb_logaddr = virt_to_abs(cb_addr); 540 u64 cb_logaddr = virt_to_abs(cb_addr);
602 u64 arr_index = 0; 541 u64 arr_index = 0;
603 542
604 port_info = EHEA_BMASK_SET(H_MEHEAPORT_CAT, cb_cat) 543 port_info = EHEA_BMASK_SET(H_MEHEAPORT_CAT, cb_cat)
605 | EHEA_BMASK_SET(H_MEHEAPORT_PN, port_num); 544 | EHEA_BMASK_SET(H_MEHEAPORT_PN, port_num);
606 545
607 return ehea_hcall_9arg_9ret(H_QUERY_HEA_PORT, 546 return ehea_plpar_hcall_norets(H_QUERY_HEA_PORT,
608 adapter_handle, /* R4 */ 547 adapter_handle, /* R4 */
609 port_info, /* R5 */ 548 port_info, /* R5 */
610 select_mask, /* R6 */ 549 select_mask, /* R6 */
611 arr_index, /* R7 */ 550 arr_index, /* R7 */
612 cb_logaddr, /* R8 */ 551 cb_logaddr, /* R8 */
613 0, 0, 0, 0, /* R9-R12 */ 552 0, 0); /* R9-R10 */
614 &dummy, /* R4 */
615 &dummy, /* R5 */
616 &dummy, /* R6 */
617 &dummy, /* R7 */
618 &dummy, /* R8 */
619 &dummy, /* R9 */
620 &dummy, /* R10 */
621 &dummy, /* R11 */
622 &dummy); /* R12 */
623} 553}
624 554
625u64 ehea_h_modify_ehea_port(const u64 adapter_handle, const u16 port_num, 555u64 ehea_h_modify_ehea_port(const u64 adapter_handle, const u16 port_num,
626 const u8 cb_cat, const u64 select_mask, 556 const u8 cb_cat, const u64 select_mask,
627 void *cb_addr) 557 void *cb_addr)
628{ 558{
629 u64 port_info, dummy, inv_attr_ident, proc_mask; 559 u64 outs[PLPAR_HCALL9_BUFSIZE];
560 u64 port_info;
630 u64 arr_index = 0; 561 u64 arr_index = 0;
631 u64 cb_logaddr = virt_to_abs(cb_addr); 562 u64 cb_logaddr = virt_to_abs(cb_addr);
632 563
@@ -635,29 +566,21 @@ u64 ehea_h_modify_ehea_port(const u64 adapter_handle, const u16 port_num,
635#ifdef DEBUG 566#ifdef DEBUG
636 ehea_dump(cb_addr, sizeof(struct hcp_ehea_port_cb0), "Before HCALL"); 567 ehea_dump(cb_addr, sizeof(struct hcp_ehea_port_cb0), "Before HCALL");
637#endif 568#endif
638 return ehea_hcall_9arg_9ret(H_MODIFY_HEA_PORT, 569 return ehea_plpar_hcall9(H_MODIFY_HEA_PORT,
639 adapter_handle, /* R4 */ 570 outs,
640 port_info, /* R5 */ 571 adapter_handle, /* R4 */
641 select_mask, /* R6 */ 572 port_info, /* R5 */
642 arr_index, /* R7 */ 573 select_mask, /* R6 */
643 cb_logaddr, /* R8 */ 574 arr_index, /* R7 */
644 0, 0, 0, 0, /* R9-R12 */ 575 cb_logaddr, /* R8 */
645 &inv_attr_ident, /* R4 */ 576 0, 0, 0, 0); /* R9-R12 */
646 &proc_mask, /* R5 */
647 &dummy, /* R6 */
648 &dummy, /* R7 */
649 &dummy, /* R8 */
650 &dummy, /* R9 */
651 &dummy, /* R10 */
652 &dummy, /* R11 */
653 &dummy); /* R12 */
654} 577}
655 578
656u64 ehea_h_reg_dereg_bcmc(const u64 adapter_handle, const u16 port_num, 579u64 ehea_h_reg_dereg_bcmc(const u64 adapter_handle, const u16 port_num,
657 const u8 reg_type, const u64 mc_mac_addr, 580 const u8 reg_type, const u64 mc_mac_addr,
658 const u16 vlan_id, const u32 hcall_id) 581 const u16 vlan_id, const u32 hcall_id)
659{ 582{
660 u64 r5_port_num, r6_reg_type, r7_mc_mac_addr, r8_vlan_id, dummy; 583 u64 r5_port_num, r6_reg_type, r7_mc_mac_addr, r8_vlan_id;
661 u64 mac_addr = mc_mac_addr >> 16; 584 u64 mac_addr = mc_mac_addr >> 16;
662 585
663 r5_port_num = EHEA_BMASK_SET(H_REGBCMC_PN, port_num); 586 r5_port_num = EHEA_BMASK_SET(H_REGBCMC_PN, port_num);
@@ -665,41 +588,21 @@ u64 ehea_h_reg_dereg_bcmc(const u64 adapter_handle, const u16 port_num,
665 r7_mc_mac_addr = EHEA_BMASK_SET(H_REGBCMC_MACADDR, mac_addr); 588 r7_mc_mac_addr = EHEA_BMASK_SET(H_REGBCMC_MACADDR, mac_addr);
666 r8_vlan_id = EHEA_BMASK_SET(H_REGBCMC_VLANID, vlan_id); 589 r8_vlan_id = EHEA_BMASK_SET(H_REGBCMC_VLANID, vlan_id);
667 590
668 return ehea_hcall_9arg_9ret(hcall_id, 591 return ehea_plpar_hcall_norets(hcall_id,
669 adapter_handle, /* R4 */ 592 adapter_handle, /* R4 */
670 r5_port_num, /* R5 */ 593 r5_port_num, /* R5 */
671 r6_reg_type, /* R6 */ 594 r6_reg_type, /* R6 */
672 r7_mc_mac_addr, /* R7 */ 595 r7_mc_mac_addr, /* R7 */
673 r8_vlan_id, /* R8 */ 596 r8_vlan_id, /* R8 */
674 0, 0, 0, 0, /* R9-R12 */ 597 0, 0); /* R9-R12 */
675 &dummy, /* R4 */
676 &dummy, /* R5 */
677 &dummy, /* R6 */
678 &dummy, /* R7 */
679 &dummy, /* R8 */
680 &dummy, /* R9 */
681 &dummy, /* R10 */
682 &dummy, /* R11 */
683 &dummy); /* R12 */
684} 598}
685 599
686u64 ehea_h_reset_events(const u64 adapter_handle, const u64 neq_handle, 600u64 ehea_h_reset_events(const u64 adapter_handle, const u64 neq_handle,
687 const u64 event_mask) 601 const u64 event_mask)
688{ 602{
689 u64 dummy; 603 return ehea_plpar_hcall_norets(H_RESET_EVENTS,
690 604 adapter_handle, /* R4 */
691 return ehea_hcall_9arg_9ret(H_RESET_EVENTS, 605 neq_handle, /* R5 */
692 adapter_handle, /* R4 */ 606 event_mask, /* R6 */
693 neq_handle, /* R5 */ 607 0, 0, 0, 0); /* R7-R12 */
694 event_mask, /* R6 */
695 0, 0, 0, 0, 0, 0, /* R7-R12 */
696 &dummy, /* R4 */
697 &dummy, /* R5 */
698 &dummy, /* R6 */
699 &dummy, /* R7 */
700 &dummy, /* R8 */
701 &dummy, /* R9 */
702 &dummy, /* R10 */
703 &dummy, /* R11 */
704 &dummy); /* R12 */
705} 608}
diff --git a/drivers/net/ehea/ehea_phyp.h b/drivers/net/ehea/ehea_phyp.h
index fa51e3b5bb05..919f94b75933 100644
--- a/drivers/net/ehea/ehea_phyp.h
+++ b/drivers/net/ehea/ehea_phyp.h
@@ -81,14 +81,16 @@ static inline u32 get_longbusy_msecs(int long_busy_ret_code)
81static inline void hcp_epas_ctor(struct h_epas *epas, u64 paddr_kernel, 81static inline void hcp_epas_ctor(struct h_epas *epas, u64 paddr_kernel,
82 u64 paddr_user) 82 u64 paddr_user)
83{ 83{
84 epas->kernel.addr = ioremap(paddr_kernel, PAGE_SIZE); 84 /* To support 64k pages we must round to 64k page boundary */
85 epas->kernel.addr = ioremap((paddr_kernel & PAGE_MASK), PAGE_SIZE) +
86 (paddr_kernel & ~PAGE_MASK);
85 epas->user.addr = paddr_user; 87 epas->user.addr = paddr_user;
86} 88}
87 89
88static inline void hcp_epas_dtor(struct h_epas *epas) 90static inline void hcp_epas_dtor(struct h_epas *epas)
89{ 91{
90 if (epas->kernel.addr) 92 if (epas->kernel.addr)
91 iounmap(epas->kernel.addr); 93 iounmap((void __iomem*)((u64)epas->kernel.addr & PAGE_MASK));
92 94
93 epas->user.addr = 0; 95 epas->user.addr = 0;
94 epas->kernel.addr = 0; 96 epas->kernel.addr = 0;
diff --git a/drivers/net/ehea/ehea_qmr.c b/drivers/net/ehea/ehea_qmr.c
index 3e1862326c88..72ef7bde3346 100644
--- a/drivers/net/ehea/ehea_qmr.c
+++ b/drivers/net/ehea/ehea_qmr.c
@@ -209,11 +209,11 @@ int ehea_destroy_cq(struct ehea_cq *cq)
209{ 209{
210 u64 adapter_handle, hret; 210 u64 adapter_handle, hret;
211 211
212 adapter_handle = cq->adapter->handle;
213
214 if (!cq) 212 if (!cq)
215 return 0; 213 return 0;
216 214
215 adapter_handle = cq->adapter->handle;
216
217 /* deregister all previous registered pages */ 217 /* deregister all previous registered pages */
218 hret = ehea_h_free_resource(adapter_handle, cq->fw_handle); 218 hret = ehea_h_free_resource(adapter_handle, cq->fw_handle);
219 if (hret != H_SUCCESS) { 219 if (hret != H_SUCCESS) {
@@ -512,7 +512,7 @@ int ehea_reg_mr_adapter(struct ehea_adapter *adapter)
512 512
513 start = KERNELBASE; 513 start = KERNELBASE;
514 end = (u64)high_memory; 514 end = (u64)high_memory;
515 nr_pages = (end - start) / PAGE_SIZE; 515 nr_pages = (end - start) / EHEA_PAGESIZE;
516 516
517 pt = kzalloc(PAGE_SIZE, GFP_KERNEL); 517 pt = kzalloc(PAGE_SIZE, GFP_KERNEL);
518 if (!pt) { 518 if (!pt) {
@@ -538,9 +538,9 @@ int ehea_reg_mr_adapter(struct ehea_adapter *adapter)
538 if (nr_pages > 1) { 538 if (nr_pages > 1) {
539 u64 num_pages = min(nr_pages, (u64)512); 539 u64 num_pages = min(nr_pages, (u64)512);
540 for (i = 0; i < num_pages; i++) 540 for (i = 0; i < num_pages; i++)
541 pt[i] = virt_to_abs((void*)(((u64)start) 541 pt[i] = virt_to_abs((void*)(((u64)start) +
542 + ((k++) * 542 ((k++) *
543 PAGE_SIZE))); 543 EHEA_PAGESIZE)));
544 544
545 hret = ehea_h_register_rpage_mr(adapter->handle, 545 hret = ehea_h_register_rpage_mr(adapter->handle,
546 adapter->mr.handle, 0, 546 adapter->mr.handle, 0,
@@ -548,8 +548,9 @@ int ehea_reg_mr_adapter(struct ehea_adapter *adapter)
548 num_pages); 548 num_pages);
549 nr_pages -= num_pages; 549 nr_pages -= num_pages;
550 } else { 550 } else {
551 u64 abs_adr = virt_to_abs((void*)(((u64)start) 551 u64 abs_adr = virt_to_abs((void*)(((u64)start) +
552 + (k * PAGE_SIZE))); 552 (k * EHEA_PAGESIZE)));
553
553 hret = ehea_h_register_rpage_mr(adapter->handle, 554 hret = ehea_h_register_rpage_mr(adapter->handle,
554 adapter->mr.handle, 0, 555 adapter->mr.handle, 0,
555 0, abs_adr,1); 556 0, abs_adr,1);
diff --git a/drivers/net/eth16i.c b/drivers/net/eth16i.c
index 8cc3c331aca8..b7b8bc2a6307 100644
--- a/drivers/net/eth16i.c
+++ b/drivers/net/eth16i.c
@@ -162,9 +162,9 @@ static char *version =
162#include <linux/skbuff.h> 162#include <linux/skbuff.h>
163#include <linux/bitops.h> 163#include <linux/bitops.h>
164#include <linux/jiffies.h> 164#include <linux/jiffies.h>
165#include <linux/io.h>
165 166
166#include <asm/system.h> 167#include <asm/system.h>
167#include <asm/io.h>
168#include <asm/dma.h> 168#include <asm/dma.h>
169 169
170 170
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index 99b7a411db28..c5ed635bce36 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -2497,6 +2497,7 @@ static irqreturn_t nv_nic_irq_tx(int foo, void *data)
2497 u8 __iomem *base = get_hwbase(dev); 2497 u8 __iomem *base = get_hwbase(dev);
2498 u32 events; 2498 u32 events;
2499 int i; 2499 int i;
2500 unsigned long flags;
2500 2501
2501 dprintk(KERN_DEBUG "%s: nv_nic_irq_tx\n", dev->name); 2502 dprintk(KERN_DEBUG "%s: nv_nic_irq_tx\n", dev->name);
2502 2503
@@ -2508,16 +2509,16 @@ static irqreturn_t nv_nic_irq_tx(int foo, void *data)
2508 if (!(events & np->irqmask)) 2509 if (!(events & np->irqmask))
2509 break; 2510 break;
2510 2511
2511 spin_lock_irq(&np->lock); 2512 spin_lock_irqsave(&np->lock, flags);
2512 nv_tx_done(dev); 2513 nv_tx_done(dev);
2513 spin_unlock_irq(&np->lock); 2514 spin_unlock_irqrestore(&np->lock, flags);
2514 2515
2515 if (events & (NVREG_IRQ_TX_ERR)) { 2516 if (events & (NVREG_IRQ_TX_ERR)) {
2516 dprintk(KERN_DEBUG "%s: received irq with events 0x%x. Probably TX fail.\n", 2517 dprintk(KERN_DEBUG "%s: received irq with events 0x%x. Probably TX fail.\n",
2517 dev->name, events); 2518 dev->name, events);
2518 } 2519 }
2519 if (i > max_interrupt_work) { 2520 if (i > max_interrupt_work) {
2520 spin_lock_irq(&np->lock); 2521 spin_lock_irqsave(&np->lock, flags);
2521 /* disable interrupts on the nic */ 2522 /* disable interrupts on the nic */
2522 writel(NVREG_IRQ_TX_ALL, base + NvRegIrqMask); 2523 writel(NVREG_IRQ_TX_ALL, base + NvRegIrqMask);
2523 pci_push(base); 2524 pci_push(base);
@@ -2527,7 +2528,7 @@ static irqreturn_t nv_nic_irq_tx(int foo, void *data)
2527 mod_timer(&np->nic_poll, jiffies + POLL_WAIT); 2528 mod_timer(&np->nic_poll, jiffies + POLL_WAIT);
2528 } 2529 }
2529 printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq_tx.\n", dev->name, i); 2530 printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq_tx.\n", dev->name, i);
2530 spin_unlock_irq(&np->lock); 2531 spin_unlock_irqrestore(&np->lock, flags);
2531 break; 2532 break;
2532 } 2533 }
2533 2534
@@ -2601,6 +2602,7 @@ static irqreturn_t nv_nic_irq_rx(int foo, void *data)
2601 u8 __iomem *base = get_hwbase(dev); 2602 u8 __iomem *base = get_hwbase(dev);
2602 u32 events; 2603 u32 events;
2603 int i; 2604 int i;
2605 unsigned long flags;
2604 2606
2605 dprintk(KERN_DEBUG "%s: nv_nic_irq_rx\n", dev->name); 2607 dprintk(KERN_DEBUG "%s: nv_nic_irq_rx\n", dev->name);
2606 2608
@@ -2614,14 +2616,14 @@ static irqreturn_t nv_nic_irq_rx(int foo, void *data)
2614 2616
2615 nv_rx_process(dev, dev->weight); 2617 nv_rx_process(dev, dev->weight);
2616 if (nv_alloc_rx(dev)) { 2618 if (nv_alloc_rx(dev)) {
2617 spin_lock_irq(&np->lock); 2619 spin_lock_irqsave(&np->lock, flags);
2618 if (!np->in_shutdown) 2620 if (!np->in_shutdown)
2619 mod_timer(&np->oom_kick, jiffies + OOM_REFILL); 2621 mod_timer(&np->oom_kick, jiffies + OOM_REFILL);
2620 spin_unlock_irq(&np->lock); 2622 spin_unlock_irqrestore(&np->lock, flags);
2621 } 2623 }
2622 2624
2623 if (i > max_interrupt_work) { 2625 if (i > max_interrupt_work) {
2624 spin_lock_irq(&np->lock); 2626 spin_lock_irqsave(&np->lock, flags);
2625 /* disable interrupts on the nic */ 2627 /* disable interrupts on the nic */
2626 writel(NVREG_IRQ_RX_ALL, base + NvRegIrqMask); 2628 writel(NVREG_IRQ_RX_ALL, base + NvRegIrqMask);
2627 pci_push(base); 2629 pci_push(base);
@@ -2631,7 +2633,7 @@ static irqreturn_t nv_nic_irq_rx(int foo, void *data)
2631 mod_timer(&np->nic_poll, jiffies + POLL_WAIT); 2633 mod_timer(&np->nic_poll, jiffies + POLL_WAIT);
2632 } 2634 }
2633 printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq_rx.\n", dev->name, i); 2635 printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq_rx.\n", dev->name, i);
2634 spin_unlock_irq(&np->lock); 2636 spin_unlock_irqrestore(&np->lock, flags);
2635 break; 2637 break;
2636 } 2638 }
2637 } 2639 }
@@ -2648,6 +2650,7 @@ static irqreturn_t nv_nic_irq_other(int foo, void *data)
2648 u8 __iomem *base = get_hwbase(dev); 2650 u8 __iomem *base = get_hwbase(dev);
2649 u32 events; 2651 u32 events;
2650 int i; 2652 int i;
2653 unsigned long flags;
2651 2654
2652 dprintk(KERN_DEBUG "%s: nv_nic_irq_other\n", dev->name); 2655 dprintk(KERN_DEBUG "%s: nv_nic_irq_other\n", dev->name);
2653 2656
@@ -2660,14 +2663,14 @@ static irqreturn_t nv_nic_irq_other(int foo, void *data)
2660 break; 2663 break;
2661 2664
2662 if (events & NVREG_IRQ_LINK) { 2665 if (events & NVREG_IRQ_LINK) {
2663 spin_lock_irq(&np->lock); 2666 spin_lock_irqsave(&np->lock, flags);
2664 nv_link_irq(dev); 2667 nv_link_irq(dev);
2665 spin_unlock_irq(&np->lock); 2668 spin_unlock_irqrestore(&np->lock, flags);
2666 } 2669 }
2667 if (np->need_linktimer && time_after(jiffies, np->link_timeout)) { 2670 if (np->need_linktimer && time_after(jiffies, np->link_timeout)) {
2668 spin_lock_irq(&np->lock); 2671 spin_lock_irqsave(&np->lock, flags);
2669 nv_linkchange(dev); 2672 nv_linkchange(dev);
2670 spin_unlock_irq(&np->lock); 2673 spin_unlock_irqrestore(&np->lock, flags);
2671 np->link_timeout = jiffies + LINK_TIMEOUT; 2674 np->link_timeout = jiffies + LINK_TIMEOUT;
2672 } 2675 }
2673 if (events & (NVREG_IRQ_UNKNOWN)) { 2676 if (events & (NVREG_IRQ_UNKNOWN)) {
@@ -2675,7 +2678,7 @@ static irqreturn_t nv_nic_irq_other(int foo, void *data)
2675 dev->name, events); 2678 dev->name, events);
2676 } 2679 }
2677 if (i > max_interrupt_work) { 2680 if (i > max_interrupt_work) {
2678 spin_lock_irq(&np->lock); 2681 spin_lock_irqsave(&np->lock, flags);
2679 /* disable interrupts on the nic */ 2682 /* disable interrupts on the nic */
2680 writel(NVREG_IRQ_OTHER, base + NvRegIrqMask); 2683 writel(NVREG_IRQ_OTHER, base + NvRegIrqMask);
2681 pci_push(base); 2684 pci_push(base);
@@ -2685,7 +2688,7 @@ static irqreturn_t nv_nic_irq_other(int foo, void *data)
2685 mod_timer(&np->nic_poll, jiffies + POLL_WAIT); 2688 mod_timer(&np->nic_poll, jiffies + POLL_WAIT);
2686 } 2689 }
2687 printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq_other.\n", dev->name, i); 2690 printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq_other.\n", dev->name, i);
2688 spin_unlock_irq(&np->lock); 2691 spin_unlock_irqrestore(&np->lock, flags);
2689 break; 2692 break;
2690 } 2693 }
2691 2694
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
index 4bac3cd8f235..44c9f993dcc4 100644
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -212,7 +212,8 @@ static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter, struc
212 break; 212 break;
213 } 213 }
214 214
215 free_index = pool->consumer_index++ % pool->size; 215 free_index = pool->consumer_index;
216 pool->consumer_index = (pool->consumer_index + 1) % pool->size;
216 index = pool->free_map[free_index]; 217 index = pool->free_map[free_index];
217 218
218 ibmveth_assert(index != IBM_VETH_INVALID_MAP); 219 ibmveth_assert(index != IBM_VETH_INVALID_MAP);
@@ -238,7 +239,10 @@ static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter, struc
238 if(lpar_rc != H_SUCCESS) { 239 if(lpar_rc != H_SUCCESS) {
239 pool->free_map[free_index] = index; 240 pool->free_map[free_index] = index;
240 pool->skbuff[index] = NULL; 241 pool->skbuff[index] = NULL;
241 pool->consumer_index--; 242 if (pool->consumer_index == 0)
243 pool->consumer_index = pool->size - 1;
244 else
245 pool->consumer_index--;
242 dma_unmap_single(&adapter->vdev->dev, 246 dma_unmap_single(&adapter->vdev->dev,
243 pool->dma_addr[index], pool->buff_size, 247 pool->dma_addr[index], pool->buff_size,
244 DMA_FROM_DEVICE); 248 DMA_FROM_DEVICE);
@@ -325,7 +329,10 @@ static void ibmveth_remove_buffer_from_pool(struct ibmveth_adapter *adapter, u64
325 adapter->rx_buff_pool[pool].buff_size, 329 adapter->rx_buff_pool[pool].buff_size,
326 DMA_FROM_DEVICE); 330 DMA_FROM_DEVICE);
327 331
328 free_index = adapter->rx_buff_pool[pool].producer_index++ % adapter->rx_buff_pool[pool].size; 332 free_index = adapter->rx_buff_pool[pool].producer_index;
333 adapter->rx_buff_pool[pool].producer_index
334 = (adapter->rx_buff_pool[pool].producer_index + 1)
335 % adapter->rx_buff_pool[pool].size;
329 adapter->rx_buff_pool[pool].free_map[free_index] = index; 336 adapter->rx_buff_pool[pool].free_map[free_index] = index;
330 337
331 mb(); 338 mb();
@@ -437,6 +444,31 @@ static void ibmveth_cleanup(struct ibmveth_adapter *adapter)
437 &adapter->rx_buff_pool[i]); 444 &adapter->rx_buff_pool[i]);
438} 445}
439 446
447static int ibmveth_register_logical_lan(struct ibmveth_adapter *adapter,
448 union ibmveth_buf_desc rxq_desc, u64 mac_address)
449{
450 int rc, try_again = 1;
451
452 /* After a kexec the adapter will still be open, so our attempt to
453 * open it will fail. So if we get a failure we free the adapter and
454 * try again, but only once. */
455retry:
456 rc = h_register_logical_lan(adapter->vdev->unit_address,
457 adapter->buffer_list_dma, rxq_desc.desc,
458 adapter->filter_list_dma, mac_address);
459
460 if (rc != H_SUCCESS && try_again) {
461 do {
462 rc = h_free_logical_lan(adapter->vdev->unit_address);
463 } while (H_IS_LONG_BUSY(rc) || (rc == H_BUSY));
464
465 try_again = 0;
466 goto retry;
467 }
468
469 return rc;
470}
471
440static int ibmveth_open(struct net_device *netdev) 472static int ibmveth_open(struct net_device *netdev)
441{ 473{
442 struct ibmveth_adapter *adapter = netdev->priv; 474 struct ibmveth_adapter *adapter = netdev->priv;
@@ -502,12 +534,9 @@ static int ibmveth_open(struct net_device *netdev)
502 ibmveth_debug_printk("filter list @ 0x%p\n", adapter->filter_list_addr); 534 ibmveth_debug_printk("filter list @ 0x%p\n", adapter->filter_list_addr);
503 ibmveth_debug_printk("receive q @ 0x%p\n", adapter->rx_queue.queue_addr); 535 ibmveth_debug_printk("receive q @ 0x%p\n", adapter->rx_queue.queue_addr);
504 536
537 h_vio_signal(adapter->vdev->unit_address, VIO_IRQ_DISABLE);
505 538
506 lpar_rc = h_register_logical_lan(adapter->vdev->unit_address, 539 lpar_rc = ibmveth_register_logical_lan(adapter, rxq_desc, mac_address);
507 adapter->buffer_list_dma,
508 rxq_desc.desc,
509 adapter->filter_list_dma,
510 mac_address);
511 540
512 if(lpar_rc != H_SUCCESS) { 541 if(lpar_rc != H_SUCCESS) {
513 ibmveth_error_printk("h_register_logical_lan failed with %ld\n", lpar_rc); 542 ibmveth_error_printk("h_register_logical_lan failed with %ld\n", lpar_rc);
@@ -905,6 +934,14 @@ static int ibmveth_change_mtu(struct net_device *dev, int new_mtu)
905 return -EINVAL; 934 return -EINVAL;
906} 935}
907 936
937#ifdef CONFIG_NET_POLL_CONTROLLER
938static void ibmveth_poll_controller(struct net_device *dev)
939{
940 ibmveth_replenish_task(dev->priv);
941 ibmveth_interrupt(dev->irq, dev);
942}
943#endif
944
908static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id) 945static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)
909{ 946{
910 int rc, i; 947 int rc, i;
@@ -977,6 +1014,9 @@ static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_
977 netdev->ethtool_ops = &netdev_ethtool_ops; 1014 netdev->ethtool_ops = &netdev_ethtool_ops;
978 netdev->change_mtu = ibmveth_change_mtu; 1015 netdev->change_mtu = ibmveth_change_mtu;
979 SET_NETDEV_DEV(netdev, &dev->dev); 1016 SET_NETDEV_DEV(netdev, &dev->dev);
1017#ifdef CONFIG_NET_POLL_CONTROLLER
1018 netdev->poll_controller = ibmveth_poll_controller;
1019#endif
980 netdev->features |= NETIF_F_LLTX; 1020 netdev->features |= NETIF_F_LLTX;
981 spin_lock_init(&adapter->stats_lock); 1021 spin_lock_init(&adapter->stats_lock);
982 1022
@@ -1132,7 +1172,9 @@ static void ibmveth_proc_register_adapter(struct ibmveth_adapter *adapter)
1132{ 1172{
1133 struct proc_dir_entry *entry; 1173 struct proc_dir_entry *entry;
1134 if (ibmveth_proc_dir) { 1174 if (ibmveth_proc_dir) {
1135 entry = create_proc_entry(adapter->netdev->name, S_IFREG, ibmveth_proc_dir); 1175 char u_addr[10];
1176 sprintf(u_addr, "%x", adapter->vdev->unit_address);
1177 entry = create_proc_entry(u_addr, S_IFREG, ibmveth_proc_dir);
1136 if (!entry) { 1178 if (!entry) {
1137 ibmveth_error_printk("Cannot create adapter proc entry"); 1179 ibmveth_error_printk("Cannot create adapter proc entry");
1138 } else { 1180 } else {
@@ -1147,7 +1189,9 @@ static void ibmveth_proc_register_adapter(struct ibmveth_adapter *adapter)
1147static void ibmveth_proc_unregister_adapter(struct ibmveth_adapter *adapter) 1189static void ibmveth_proc_unregister_adapter(struct ibmveth_adapter *adapter)
1148{ 1190{
1149 if (ibmveth_proc_dir) { 1191 if (ibmveth_proc_dir) {
1150 remove_proc_entry(adapter->netdev->name, ibmveth_proc_dir); 1192 char u_addr[10];
1193 sprintf(u_addr, "%x", adapter->vdev->unit_address);
1194 remove_proc_entry(u_addr, ibmveth_proc_dir);
1151 } 1195 }
1152} 1196}
1153 1197
diff --git a/drivers/net/ioc3-eth.c b/drivers/net/ioc3-eth.c
index e963dbf816be..f56b00ee385e 100644
--- a/drivers/net/ioc3-eth.c
+++ b/drivers/net/ioc3-eth.c
@@ -1017,7 +1017,7 @@ static void ioc3_init(struct net_device *dev)
1017 struct ioc3_private *ip = netdev_priv(dev); 1017 struct ioc3_private *ip = netdev_priv(dev);
1018 struct ioc3 *ioc3 = ip->regs; 1018 struct ioc3 *ioc3 = ip->regs;
1019 1019
1020 del_timer(&ip->ioc3_timer); /* Kill if running */ 1020 del_timer_sync(&ip->ioc3_timer); /* Kill if running */
1021 1021
1022 ioc3_w_emcr(EMCR_RST); /* Reset */ 1022 ioc3_w_emcr(EMCR_RST); /* Reset */
1023 (void) ioc3_r_emcr(); /* Flush WB */ 1023 (void) ioc3_r_emcr(); /* Flush WB */
@@ -1081,7 +1081,7 @@ static int ioc3_close(struct net_device *dev)
1081{ 1081{
1082 struct ioc3_private *ip = netdev_priv(dev); 1082 struct ioc3_private *ip = netdev_priv(dev);
1083 1083
1084 del_timer(&ip->ioc3_timer); 1084 del_timer_sync(&ip->ioc3_timer);
1085 1085
1086 netif_stop_queue(dev); 1086 netif_stop_queue(dev);
1087 1087
diff --git a/drivers/net/irda/stir4200.c b/drivers/net/irda/stir4200.c
index be8a66e702b0..3b4c47875935 100644
--- a/drivers/net/irda/stir4200.c
+++ b/drivers/net/irda/stir4200.c
@@ -15,8 +15,7 @@
15* 15*
16* This program is free software; you can redistribute it and/or modify 16* This program is free software; you can redistribute it and/or modify
17* it under the terms of the GNU General Public License as published by 17* it under the terms of the GNU General Public License as published by
18* the Free Software Foundation; either version 2 of the License, or 18* the Free Software Foundation; either version 2 of the License.
19* (at your option) any later version.
20* 19*
21* This program is distributed in the hope that it will be useful, 20* This program is distributed in the hope that it will be useful,
22* but WITHOUT ANY WARRANTY; without even the implied warranty of 21* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index 4178b4b1d2df..82c10dec1b5a 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -58,7 +58,11 @@
58#include <linux/tcp.h> 58#include <linux/tcp.h>
59#include <linux/percpu.h> 59#include <linux/percpu.h>
60 60
61static DEFINE_PER_CPU(struct net_device_stats, loopback_stats); 61struct pcpu_lstats {
62 unsigned long packets;
63 unsigned long bytes;
64};
65static DEFINE_PER_CPU(struct pcpu_lstats, pcpu_lstats);
62 66
63#define LOOPBACK_OVERHEAD (128 + MAX_HEADER + 16 + 16) 67#define LOOPBACK_OVERHEAD (128 + MAX_HEADER + 16 + 16)
64 68
@@ -128,7 +132,7 @@ static void emulate_large_send_offload(struct sk_buff *skb)
128 */ 132 */
129static int loopback_xmit(struct sk_buff *skb, struct net_device *dev) 133static int loopback_xmit(struct sk_buff *skb, struct net_device *dev)
130{ 134{
131 struct net_device_stats *lb_stats; 135 struct pcpu_lstats *lb_stats;
132 136
133 skb_orphan(skb); 137 skb_orphan(skb);
134 138
@@ -149,16 +153,14 @@ static int loopback_xmit(struct sk_buff *skb, struct net_device *dev)
149#endif 153#endif
150 dev->last_rx = jiffies; 154 dev->last_rx = jiffies;
151 155
152 lb_stats = &per_cpu(loopback_stats, get_cpu()); 156 /* it's OK to use __get_cpu_var() because BHs are off */
153 lb_stats->rx_bytes += skb->len; 157 lb_stats = &__get_cpu_var(pcpu_lstats);
154 lb_stats->tx_bytes = lb_stats->rx_bytes; 158 lb_stats->bytes += skb->len;
155 lb_stats->rx_packets++; 159 lb_stats->packets++;
156 lb_stats->tx_packets = lb_stats->rx_packets;
157 put_cpu();
158 160
159 netif_rx(skb); 161 netif_rx(skb);
160 162
161 return(0); 163 return 0;
162} 164}
163 165
164static struct net_device_stats loopback_stats; 166static struct net_device_stats loopback_stats;
@@ -166,20 +168,21 @@ static struct net_device_stats loopback_stats;
166static struct net_device_stats *get_stats(struct net_device *dev) 168static struct net_device_stats *get_stats(struct net_device *dev)
167{ 169{
168 struct net_device_stats *stats = &loopback_stats; 170 struct net_device_stats *stats = &loopback_stats;
171 unsigned long bytes = 0;
172 unsigned long packets = 0;
169 int i; 173 int i;
170 174
171 memset(stats, 0, sizeof(struct net_device_stats));
172
173 for_each_possible_cpu(i) { 175 for_each_possible_cpu(i) {
174 struct net_device_stats *lb_stats; 176 const struct pcpu_lstats *lb_stats;
175 177
176 lb_stats = &per_cpu(loopback_stats, i); 178 lb_stats = &per_cpu(pcpu_lstats, i);
177 stats->rx_bytes += lb_stats->rx_bytes; 179 bytes += lb_stats->bytes;
178 stats->tx_bytes += lb_stats->tx_bytes; 180 packets += lb_stats->packets;
179 stats->rx_packets += lb_stats->rx_packets;
180 stats->tx_packets += lb_stats->tx_packets;
181 } 181 }
182 182 stats->rx_packets = packets;
183 stats->tx_packets = packets;
184 stats->rx_bytes = bytes;
185 stats->tx_bytes = bytes;
183 return stats; 186 return stats;
184} 187}
185 188
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 2ffa3a59e704..9997081c6dae 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -2155,7 +2155,7 @@ static void eth_update_mib_counters(struct mv643xx_private *mp)
2155 for (offset = ETH_MIB_BAD_OCTETS_RECEIVED; 2155 for (offset = ETH_MIB_BAD_OCTETS_RECEIVED;
2156 offset <= ETH_MIB_FRAMES_1024_TO_MAX_OCTETS; 2156 offset <= ETH_MIB_FRAMES_1024_TO_MAX_OCTETS;
2157 offset += 4) 2157 offset += 4)
2158 *(u32 *)((char *)p + offset) = read_mib(mp, offset); 2158 *(u32 *)((char *)p + offset) += read_mib(mp, offset);
2159 2159
2160 p->good_octets_sent += read_mib(mp, ETH_MIB_GOOD_OCTETS_SENT_LOW); 2160 p->good_octets_sent += read_mib(mp, ETH_MIB_GOOD_OCTETS_SENT_LOW);
2161 p->good_octets_sent += 2161 p->good_octets_sent +=
@@ -2164,7 +2164,7 @@ static void eth_update_mib_counters(struct mv643xx_private *mp)
2164 for (offset = ETH_MIB_GOOD_FRAMES_SENT; 2164 for (offset = ETH_MIB_GOOD_FRAMES_SENT;
2165 offset <= ETH_MIB_LATE_COLLISION; 2165 offset <= ETH_MIB_LATE_COLLISION;
2166 offset += 4) 2166 offset += 4)
2167 *(u32 *)((char *)p + offset) = read_mib(mp, offset); 2167 *(u32 *)((char *)p + offset) += read_mib(mp, offset);
2168} 2168}
2169 2169
2170/* 2170/*
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c
index fdbb0d7213b0..806081b59733 100644
--- a/drivers/net/myri10ge/myri10ge.c
+++ b/drivers/net/myri10ge/myri10ge.c
@@ -2416,7 +2416,6 @@ static void myri10ge_enable_ecrc(struct myri10ge_priv *mgp)
2416 * firmware image, and set tx.boundary to 4KB. 2416 * firmware image, and set tx.boundary to 4KB.
2417 */ 2417 */
2418 2418
2419#define PCI_DEVICE_ID_SERVERWORKS_HT2000_PCIE 0x0132
2420#define PCI_DEVICE_ID_INTEL_E5000_PCIE23 0x25f7 2419#define PCI_DEVICE_ID_INTEL_E5000_PCIE23 0x25f7
2421#define PCI_DEVICE_ID_INTEL_E5000_PCIE47 0x25fa 2420#define PCI_DEVICE_ID_INTEL_E5000_PCIE47 0x25fa
2422 2421
diff --git a/drivers/net/myri_code.h b/drivers/net/myri_code.h
index e21ec9b2c706..ba7b8652c501 100644
--- a/drivers/net/myri_code.h
+++ b/drivers/net/myri_code.h
@@ -1,8 +1,8 @@
1/* This is the Myrinet MCP code for LANai4.x */ 1/* This is the Myrinet MCP code for LANai4.x */
2/* Generated by cat $MYRI_HOME/lib/lanai/mcp4.dat > myri_code4.h */ 2/* Generated by cat $MYRI_HOME/lib/lanai/mcp4.dat > myri_code4.h */
3 3
4static unsigned int lanai4_code_off = 0x0000; /* half-word offset */ 4static unsigned int __devinitdata lanai4_code_off = 0x0000; /* half-word offset */
5static unsigned char lanai4_code[76256] __initdata = { 5static unsigned char __devinitdata lanai4_code[76256] = {
60xF2,0x0E, 60xF2,0x0E,
70xFE,0x00, 0xC2,0x90, 0x00,0x00, 0x07,0x88, 0x00,0x08, 0xE0,0x01, 0x01,0x4C, 0x97,0x93, 70xFE,0x00, 0xC2,0x90, 0x00,0x00, 0x07,0x88, 0x00,0x08, 0xE0,0x01, 0x01,0x4C, 0x97,0x93,
80xFF,0xFC, 0xE0,0x00, 0x00,0x14, 0x00,0x00, 0x00,0x01, 0x00,0x00, 0x00,0x00, 0x92,0x93, 80xFF,0xFC, 0xE0,0x00, 0x00,0x14, 0x00,0x00, 0x00,0x01, 0x00,0x00, 0x00,0x00, 0x92,0x93,
@@ -4774,8 +4774,8 @@ static unsigned char lanai4_code[76256] __initdata = {
4774 4774
4775/* This is the LANai data */ 4775/* This is the LANai data */
4776 4776
4777static unsigned int lanai4_data_off = 0x94F0; /* half-word offset */ 4777static unsigned int __devinitdata lanai4_data_off = 0x94F0; /* half-word offset */
4778static unsigned char lanai4_data[20472] __initdata; 4778static unsigned char __devinitdata lanai4_data[20472];
4779 4779
4780 4780
4781#ifdef SYMBOL_DEFINES_COMPILED 4781#ifdef SYMBOL_DEFINES_COMPILED
diff --git a/drivers/net/myri_sbus.c b/drivers/net/myri_sbus.c
index 466b484c9fa4..7747bfd99f91 100644
--- a/drivers/net/myri_sbus.c
+++ b/drivers/net/myri_sbus.c
@@ -168,7 +168,7 @@ static int myri_do_handshake(struct myri_eth *mp)
168 return 0; 168 return 0;
169} 169}
170 170
171static int myri_load_lanai(struct myri_eth *mp) 171static int __devinit myri_load_lanai(struct myri_eth *mp)
172{ 172{
173 struct net_device *dev = mp->dev; 173 struct net_device *dev = mp->dev;
174 struct myri_shmem __iomem *shmem = mp->shmem; 174 struct myri_shmem __iomem *shmem = mp->shmem;
@@ -891,7 +891,7 @@ static void dump_eeprom(struct myri_eth *mp)
891} 891}
892#endif 892#endif
893 893
894static int __init myri_ether_init(struct sbus_dev *sdev) 894static int __devinit myri_ether_init(struct sbus_dev *sdev)
895{ 895{
896 static int num; 896 static int num;
897 static unsigned version_printed; 897 static unsigned version_printed;
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index f1c75751cab7..27f90b2139c0 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -214,6 +214,7 @@ static struct pci_device_id rtl8169_pci_tbl[] = {
214 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8168), 0, 0, RTL_CFG_2 }, 214 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8168), 0, 0, RTL_CFG_2 },
215 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8169), 0, 0, RTL_CFG_0 }, 215 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8169), 0, 0, RTL_CFG_0 },
216 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4300), 0, 0, RTL_CFG_0 }, 216 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4300), 0, 0, RTL_CFG_0 },
217 { PCI_DEVICE(0x1259, 0xc107), 0, 0, RTL_CFG_0 },
217 { PCI_DEVICE(0x16ec, 0x0116), 0, 0, RTL_CFG_0 }, 218 { PCI_DEVICE(0x16ec, 0x0116), 0, 0, RTL_CFG_0 },
218 { PCI_VENDOR_ID_LINKSYS, 0x1032, 219 { PCI_VENDOR_ID_LINKSYS, 0x1032,
219 PCI_ANY_ID, 0x0024, 0, 0, RTL_CFG_0 }, 220 PCI_ANY_ID, 0x0024, 0, 0, RTL_CFG_0 },
@@ -1396,41 +1397,6 @@ static void rtl8169_netpoll(struct net_device *dev)
1396} 1397}
1397#endif 1398#endif
1398 1399
1399static void __rtl8169_set_mac_addr(struct net_device *dev, void __iomem *ioaddr)
1400{
1401 unsigned int i, j;
1402
1403 RTL_W8(Cfg9346, Cfg9346_Unlock);
1404 for (i = 0; i < 2; i++) {
1405 __le32 l = 0;
1406
1407 for (j = 0; j < 4; j++) {
1408 l <<= 8;
1409 l |= dev->dev_addr[4*i + j];
1410 }
1411 RTL_W32(MAC0 + 4*i, cpu_to_be32(l));
1412 }
1413 RTL_W8(Cfg9346, Cfg9346_Lock);
1414}
1415
1416static int rtl8169_set_mac_addr(struct net_device *dev, void *p)
1417{
1418 struct rtl8169_private *tp = netdev_priv(dev);
1419 struct sockaddr *addr = p;
1420
1421 if (!is_valid_ether_addr(addr->sa_data))
1422 return -EINVAL;
1423
1424 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
1425
1426 if (netif_running(dev)) {
1427 spin_lock_irq(&tp->lock);
1428 __rtl8169_set_mac_addr(dev, tp->mmio_addr);
1429 spin_unlock_irq(&tp->lock);
1430 }
1431 return 0;
1432}
1433
1434static void rtl8169_release_board(struct pci_dev *pdev, struct net_device *dev, 1400static void rtl8169_release_board(struct pci_dev *pdev, struct net_device *dev,
1435 void __iomem *ioaddr) 1401 void __iomem *ioaddr)
1436{ 1402{
@@ -1680,7 +1646,6 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1680 dev->stop = rtl8169_close; 1646 dev->stop = rtl8169_close;
1681 dev->tx_timeout = rtl8169_tx_timeout; 1647 dev->tx_timeout = rtl8169_tx_timeout;
1682 dev->set_multicast_list = rtl8169_set_rx_mode; 1648 dev->set_multicast_list = rtl8169_set_rx_mode;
1683 dev->set_mac_address = rtl8169_set_mac_addr;
1684 dev->watchdog_timeo = RTL8169_TX_TIMEOUT; 1649 dev->watchdog_timeo = RTL8169_TX_TIMEOUT;
1685 dev->irq = pdev->irq; 1650 dev->irq = pdev->irq;
1686 dev->base_addr = (unsigned long) ioaddr; 1651 dev->base_addr = (unsigned long) ioaddr;
@@ -1928,8 +1893,6 @@ rtl8169_hw_start(struct net_device *dev)
1928 /* Enable all known interrupts by setting the interrupt mask. */ 1893 /* Enable all known interrupts by setting the interrupt mask. */
1929 RTL_W16(IntrMask, rtl8169_intr_mask); 1894 RTL_W16(IntrMask, rtl8169_intr_mask);
1930 1895
1931 __rtl8169_set_mac_addr(dev, ioaddr);
1932
1933 netif_start_queue(dev); 1896 netif_start_queue(dev);
1934} 1897}
1935 1898
@@ -2700,6 +2663,7 @@ static void rtl8169_down(struct net_device *dev)
2700 struct rtl8169_private *tp = netdev_priv(dev); 2663 struct rtl8169_private *tp = netdev_priv(dev);
2701 void __iomem *ioaddr = tp->mmio_addr; 2664 void __iomem *ioaddr = tp->mmio_addr;
2702 unsigned int poll_locked = 0; 2665 unsigned int poll_locked = 0;
2666 unsigned int intrmask;
2703 2667
2704 rtl8169_delete_timer(dev); 2668 rtl8169_delete_timer(dev);
2705 2669
@@ -2738,8 +2702,11 @@ core_down:
2738 * 2) dev->change_mtu 2702 * 2) dev->change_mtu
2739 * -> rtl8169_poll can not be issued again and re-enable the 2703 * -> rtl8169_poll can not be issued again and re-enable the
2740 * interruptions. Let's simply issue the IRQ down sequence again. 2704 * interruptions. Let's simply issue the IRQ down sequence again.
2705 *
2706 * No loop if hotpluged or major error (0xffff).
2741 */ 2707 */
2742 if (RTL_R16(IntrMask)) 2708 intrmask = RTL_R16(IntrMask);
2709 if (intrmask && (intrmask != 0xffff))
2743 goto core_down; 2710 goto core_down;
2744 2711
2745 rtl8169_tx_clear(tp); 2712 rtl8169_tx_clear(tp);
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index a231ab7d28dd..33569ec9dbfc 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -5985,6 +5985,11 @@ static int set_rxd_buffer_pointer(nic_t *sp, RxD_t *rxdp, buffAdd_t *ba,
5985 ((RxD3_t*)rxdp)->Buffer1_ptr = *temp1; 5985 ((RxD3_t*)rxdp)->Buffer1_ptr = *temp1;
5986 } else { 5986 } else {
5987 *skb = dev_alloc_skb(size); 5987 *skb = dev_alloc_skb(size);
5988 if (!(*skb)) {
5989 DBG_PRINT(ERR_DBG, "%s: dev_alloc_skb failed\n",
5990 dev->name);
5991 return -ENOMEM;
5992 }
5988 ((RxD3_t*)rxdp)->Buffer2_ptr = *temp2 = 5993 ((RxD3_t*)rxdp)->Buffer2_ptr = *temp2 =
5989 pci_map_single(sp->pdev, (*skb)->data, 5994 pci_map_single(sp->pdev, (*skb)->data,
5990 dev->mtu + 4, 5995 dev->mtu + 4,
@@ -6007,7 +6012,11 @@ static int set_rxd_buffer_pointer(nic_t *sp, RxD_t *rxdp, buffAdd_t *ba,
6007 ((RxD3_t*)rxdp)->Buffer2_ptr = *temp2; 6012 ((RxD3_t*)rxdp)->Buffer2_ptr = *temp2;
6008 } else { 6013 } else {
6009 *skb = dev_alloc_skb(size); 6014 *skb = dev_alloc_skb(size);
6010 6015 if (!(*skb)) {
6016 DBG_PRINT(ERR_DBG, "%s: dev_alloc_skb failed\n",
6017 dev->name);
6018 return -ENOMEM;
6019 }
6011 ((RxD3_t*)rxdp)->Buffer0_ptr = *temp0 = 6020 ((RxD3_t*)rxdp)->Buffer0_ptr = *temp0 =
6012 pci_map_single(sp->pdev, ba->ba_0, BUF0_LEN, 6021 pci_map_single(sp->pdev, ba->ba_0, BUF0_LEN,
6013 PCI_DMA_FROMDEVICE); 6022 PCI_DMA_FROMDEVICE);
diff --git a/drivers/net/sb1250-mac.c b/drivers/net/sb1250-mac.c
index db2324939b69..1eae16b72b4b 100644
--- a/drivers/net/sb1250-mac.c
+++ b/drivers/net/sb1250-mac.c
@@ -2903,7 +2903,7 @@ sbmac_init_module(void)
2903 2903
2904 dev = alloc_etherdev(sizeof(struct sbmac_softc)); 2904 dev = alloc_etherdev(sizeof(struct sbmac_softc));
2905 if (!dev) 2905 if (!dev)
2906 return -ENOMEM; /* return ENOMEM */ 2906 return -ENOMEM;
2907 2907
2908 printk(KERN_DEBUG "sbmac: configuring MAC at %lx\n", port); 2908 printk(KERN_DEBUG "sbmac: configuring MAC at %lx\n", port);
2909 2909
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index a4a58e4e93a1..b2949035f66a 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -11,8 +11,7 @@
11 * 11 *
12 * This program is free software; you can redistribute it and/or modify 12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by 13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or 14 * the Free Software Foundation; either version 2 of the License.
15 * (at your option) any later version.
16 * 15 *
17 * This program is distributed in the hope that it will be useful, 16 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -43,7 +42,7 @@
43#include "skge.h" 42#include "skge.h"
44 43
45#define DRV_NAME "skge" 44#define DRV_NAME "skge"
46#define DRV_VERSION "1.8" 45#define DRV_VERSION "1.9"
47#define PFX DRV_NAME " " 46#define PFX DRV_NAME " "
48 47
49#define DEFAULT_TX_RING_SIZE 128 48#define DEFAULT_TX_RING_SIZE 128
@@ -197,8 +196,8 @@ static u32 skge_supported_modes(const struct skge_hw *hw)
197 else if (hw->chip_id == CHIP_ID_YUKON) 196 else if (hw->chip_id == CHIP_ID_YUKON)
198 supported &= ~SUPPORTED_1000baseT_Half; 197 supported &= ~SUPPORTED_1000baseT_Half;
199 } else 198 } else
200 supported = SUPPORTED_1000baseT_Full | SUPPORTED_FIBRE 199 supported = SUPPORTED_1000baseT_Full | SUPPORTED_1000baseT_Half
201 | SUPPORTED_Autoneg; 200 | SUPPORTED_FIBRE | SUPPORTED_Autoneg;
202 201
203 return supported; 202 return supported;
204} 203}
@@ -487,31 +486,37 @@ static void skge_get_pauseparam(struct net_device *dev,
487{ 486{
488 struct skge_port *skge = netdev_priv(dev); 487 struct skge_port *skge = netdev_priv(dev);
489 488
490 ecmd->tx_pause = (skge->flow_control == FLOW_MODE_LOC_SEND) 489 ecmd->rx_pause = (skge->flow_control == FLOW_MODE_SYMMETRIC)
491 || (skge->flow_control == FLOW_MODE_SYMMETRIC); 490 || (skge->flow_control == FLOW_MODE_SYM_OR_REM);
492 ecmd->rx_pause = (skge->flow_control == FLOW_MODE_REM_SEND) 491 ecmd->tx_pause = ecmd->rx_pause || (skge->flow_control == FLOW_MODE_LOC_SEND);
493 || (skge->flow_control == FLOW_MODE_SYMMETRIC);
494 492
495 ecmd->autoneg = skge->autoneg; 493 ecmd->autoneg = ecmd->rx_pause || ecmd->tx_pause;
496} 494}
497 495
498static int skge_set_pauseparam(struct net_device *dev, 496static int skge_set_pauseparam(struct net_device *dev,
499 struct ethtool_pauseparam *ecmd) 497 struct ethtool_pauseparam *ecmd)
500{ 498{
501 struct skge_port *skge = netdev_priv(dev); 499 struct skge_port *skge = netdev_priv(dev);
500 struct ethtool_pauseparam old;
502 501
503 skge->autoneg = ecmd->autoneg; 502 skge_get_pauseparam(dev, &old);
504 if (ecmd->rx_pause && ecmd->tx_pause) 503
505 skge->flow_control = FLOW_MODE_SYMMETRIC; 504 if (ecmd->autoneg != old.autoneg)
506 else if (ecmd->rx_pause && !ecmd->tx_pause) 505 skge->flow_control = ecmd->autoneg ? FLOW_MODE_NONE : FLOW_MODE_SYMMETRIC;
507 skge->flow_control = FLOW_MODE_REM_SEND; 506 else {
508 else if (!ecmd->rx_pause && ecmd->tx_pause) 507 if (ecmd->rx_pause && ecmd->tx_pause)
509 skge->flow_control = FLOW_MODE_LOC_SEND; 508 skge->flow_control = FLOW_MODE_SYMMETRIC;
510 else 509 else if (ecmd->rx_pause && !ecmd->tx_pause)
511 skge->flow_control = FLOW_MODE_NONE; 510 skge->flow_control = FLOW_MODE_SYM_OR_REM;
511 else if (!ecmd->rx_pause && ecmd->tx_pause)
512 skge->flow_control = FLOW_MODE_LOC_SEND;
513 else
514 skge->flow_control = FLOW_MODE_NONE;
515 }
512 516
513 if (netif_running(dev)) 517 if (netif_running(dev))
514 skge_phy_reset(skge); 518 skge_phy_reset(skge);
519
515 return 0; 520 return 0;
516} 521}
517 522
@@ -854,6 +859,23 @@ static int skge_rx_fill(struct net_device *dev)
854 return 0; 859 return 0;
855} 860}
856 861
862static const char *skge_pause(enum pause_status status)
863{
864 switch(status) {
865 case FLOW_STAT_NONE:
866 return "none";
867 case FLOW_STAT_REM_SEND:
868 return "rx only";
869 case FLOW_STAT_LOC_SEND:
870 return "tx_only";
871 case FLOW_STAT_SYMMETRIC: /* Both station may send PAUSE */
872 return "both";
873 default:
874 return "indeterminated";
875 }
876}
877
878
857static void skge_link_up(struct skge_port *skge) 879static void skge_link_up(struct skge_port *skge)
858{ 880{
859 skge_write8(skge->hw, SK_REG(skge->port, LNK_LED_REG), 881 skge_write8(skge->hw, SK_REG(skge->port, LNK_LED_REG),
@@ -862,16 +884,13 @@ static void skge_link_up(struct skge_port *skge)
862 netif_carrier_on(skge->netdev); 884 netif_carrier_on(skge->netdev);
863 netif_wake_queue(skge->netdev); 885 netif_wake_queue(skge->netdev);
864 886
865 if (netif_msg_link(skge)) 887 if (netif_msg_link(skge)) {
866 printk(KERN_INFO PFX 888 printk(KERN_INFO PFX
867 "%s: Link is up at %d Mbps, %s duplex, flow control %s\n", 889 "%s: Link is up at %d Mbps, %s duplex, flow control %s\n",
868 skge->netdev->name, skge->speed, 890 skge->netdev->name, skge->speed,
869 skge->duplex == DUPLEX_FULL ? "full" : "half", 891 skge->duplex == DUPLEX_FULL ? "full" : "half",
870 (skge->flow_control == FLOW_MODE_NONE) ? "none" : 892 skge_pause(skge->flow_status));
871 (skge->flow_control == FLOW_MODE_LOC_SEND) ? "tx only" : 893 }
872 (skge->flow_control == FLOW_MODE_REM_SEND) ? "rx only" :
873 (skge->flow_control == FLOW_MODE_SYMMETRIC) ? "tx and rx" :
874 "unknown");
875} 894}
876 895
877static void skge_link_down(struct skge_port *skge) 896static void skge_link_down(struct skge_port *skge)
@@ -884,6 +903,29 @@ static void skge_link_down(struct skge_port *skge)
884 printk(KERN_INFO PFX "%s: Link is down.\n", skge->netdev->name); 903 printk(KERN_INFO PFX "%s: Link is down.\n", skge->netdev->name);
885} 904}
886 905
906
907static void xm_link_down(struct skge_hw *hw, int port)
908{
909 struct net_device *dev = hw->dev[port];
910 struct skge_port *skge = netdev_priv(dev);
911 u16 cmd, msk;
912
913 if (hw->phy_type == SK_PHY_XMAC) {
914 msk = xm_read16(hw, port, XM_IMSK);
915 msk |= XM_IS_INP_ASS | XM_IS_LIPA_RC | XM_IS_RX_PAGE | XM_IS_AND;
916 xm_write16(hw, port, XM_IMSK, msk);
917 }
918
919 cmd = xm_read16(hw, port, XM_MMU_CMD);
920 cmd &= ~(XM_MMU_ENA_RX | XM_MMU_ENA_TX);
921 xm_write16(hw, port, XM_MMU_CMD, cmd);
922 /* dummy read to ensure writing */
923 (void) xm_read16(hw, port, XM_MMU_CMD);
924
925 if (netif_carrier_ok(dev))
926 skge_link_down(skge);
927}
928
887static int __xm_phy_read(struct skge_hw *hw, int port, u16 reg, u16 *val) 929static int __xm_phy_read(struct skge_hw *hw, int port, u16 reg, u16 *val)
888{ 930{
889 int i; 931 int i;
@@ -992,7 +1034,15 @@ static const u16 phy_pause_map[] = {
992 [FLOW_MODE_NONE] = 0, 1034 [FLOW_MODE_NONE] = 0,
993 [FLOW_MODE_LOC_SEND] = PHY_AN_PAUSE_ASYM, 1035 [FLOW_MODE_LOC_SEND] = PHY_AN_PAUSE_ASYM,
994 [FLOW_MODE_SYMMETRIC] = PHY_AN_PAUSE_CAP, 1036 [FLOW_MODE_SYMMETRIC] = PHY_AN_PAUSE_CAP,
995 [FLOW_MODE_REM_SEND] = PHY_AN_PAUSE_CAP | PHY_AN_PAUSE_ASYM, 1037 [FLOW_MODE_SYM_OR_REM] = PHY_AN_PAUSE_CAP | PHY_AN_PAUSE_ASYM,
1038};
1039
1040/* special defines for FIBER (88E1011S only) */
1041static const u16 fiber_pause_map[] = {
1042 [FLOW_MODE_NONE] = PHY_X_P_NO_PAUSE,
1043 [FLOW_MODE_LOC_SEND] = PHY_X_P_ASYM_MD,
1044 [FLOW_MODE_SYMMETRIC] = PHY_X_P_SYM_MD,
1045 [FLOW_MODE_SYM_OR_REM] = PHY_X_P_BOTH_MD,
996}; 1046};
997 1047
998 1048
@@ -1008,14 +1058,7 @@ static void bcom_check_link(struct skge_hw *hw, int port)
1008 status = xm_phy_read(hw, port, PHY_BCOM_STAT); 1058 status = xm_phy_read(hw, port, PHY_BCOM_STAT);
1009 1059
1010 if ((status & PHY_ST_LSYNC) == 0) { 1060 if ((status & PHY_ST_LSYNC) == 0) {
1011 u16 cmd = xm_read16(hw, port, XM_MMU_CMD); 1061 xm_link_down(hw, port);
1012 cmd &= ~(XM_MMU_ENA_RX | XM_MMU_ENA_TX);
1013 xm_write16(hw, port, XM_MMU_CMD, cmd);
1014 /* dummy read to ensure writing */
1015 (void) xm_read16(hw, port, XM_MMU_CMD);
1016
1017 if (netif_carrier_ok(dev))
1018 skge_link_down(skge);
1019 return; 1062 return;
1020 } 1063 }
1021 1064
@@ -1048,20 +1091,19 @@ static void bcom_check_link(struct skge_hw *hw, int port)
1048 return; 1091 return;
1049 } 1092 }
1050 1093
1051
1052 /* We are using IEEE 802.3z/D5.0 Table 37-4 */ 1094 /* We are using IEEE 802.3z/D5.0 Table 37-4 */
1053 switch (aux & PHY_B_AS_PAUSE_MSK) { 1095 switch (aux & PHY_B_AS_PAUSE_MSK) {
1054 case PHY_B_AS_PAUSE_MSK: 1096 case PHY_B_AS_PAUSE_MSK:
1055 skge->flow_control = FLOW_MODE_SYMMETRIC; 1097 skge->flow_status = FLOW_STAT_SYMMETRIC;
1056 break; 1098 break;
1057 case PHY_B_AS_PRR: 1099 case PHY_B_AS_PRR:
1058 skge->flow_control = FLOW_MODE_REM_SEND; 1100 skge->flow_status = FLOW_STAT_REM_SEND;
1059 break; 1101 break;
1060 case PHY_B_AS_PRT: 1102 case PHY_B_AS_PRT:
1061 skge->flow_control = FLOW_MODE_LOC_SEND; 1103 skge->flow_status = FLOW_STAT_LOC_SEND;
1062 break; 1104 break;
1063 default: 1105 default:
1064 skge->flow_control = FLOW_MODE_NONE; 1106 skge->flow_status = FLOW_STAT_NONE;
1065 } 1107 }
1066 skge->speed = SPEED_1000; 1108 skge->speed = SPEED_1000;
1067 } 1109 }
@@ -1191,17 +1233,7 @@ static void xm_phy_init(struct skge_port *skge)
1191 if (skge->advertising & ADVERTISED_1000baseT_Full) 1233 if (skge->advertising & ADVERTISED_1000baseT_Full)
1192 ctrl |= PHY_X_AN_FD; 1234 ctrl |= PHY_X_AN_FD;
1193 1235
1194 switch(skge->flow_control) { 1236 ctrl |= fiber_pause_map[skge->flow_control];
1195 case FLOW_MODE_NONE:
1196 ctrl |= PHY_X_P_NO_PAUSE;
1197 break;
1198 case FLOW_MODE_LOC_SEND:
1199 ctrl |= PHY_X_P_ASYM_MD;
1200 break;
1201 case FLOW_MODE_SYMMETRIC:
1202 ctrl |= PHY_X_P_BOTH_MD;
1203 break;
1204 }
1205 1237
1206 xm_phy_write(hw, port, PHY_XMAC_AUNE_ADV, ctrl); 1238 xm_phy_write(hw, port, PHY_XMAC_AUNE_ADV, ctrl);
1207 1239
@@ -1235,14 +1267,7 @@ static void xm_check_link(struct net_device *dev)
1235 status = xm_phy_read(hw, port, PHY_XMAC_STAT); 1267 status = xm_phy_read(hw, port, PHY_XMAC_STAT);
1236 1268
1237 if ((status & PHY_ST_LSYNC) == 0) { 1269 if ((status & PHY_ST_LSYNC) == 0) {
1238 u16 cmd = xm_read16(hw, port, XM_MMU_CMD); 1270 xm_link_down(hw, port);
1239 cmd &= ~(XM_MMU_ENA_RX | XM_MMU_ENA_TX);
1240 xm_write16(hw, port, XM_MMU_CMD, cmd);
1241 /* dummy read to ensure writing */
1242 (void) xm_read16(hw, port, XM_MMU_CMD);
1243
1244 if (netif_carrier_ok(dev))
1245 skge_link_down(skge);
1246 return; 1271 return;
1247 } 1272 }
1248 1273
@@ -1276,15 +1301,20 @@ static void xm_check_link(struct net_device *dev)
1276 } 1301 }
1277 1302
1278 /* We are using IEEE 802.3z/D5.0 Table 37-4 */ 1303 /* We are using IEEE 802.3z/D5.0 Table 37-4 */
1279 if (lpa & PHY_X_P_SYM_MD) 1304 if ((skge->flow_control == FLOW_MODE_SYMMETRIC ||
1280 skge->flow_control = FLOW_MODE_SYMMETRIC; 1305 skge->flow_control == FLOW_MODE_SYM_OR_REM) &&
1281 else if ((lpa & PHY_X_RS_PAUSE) == PHY_X_P_ASYM_MD) 1306 (lpa & PHY_X_P_SYM_MD))
1282 skge->flow_control = FLOW_MODE_REM_SEND; 1307 skge->flow_status = FLOW_STAT_SYMMETRIC;
1283 else if ((lpa & PHY_X_RS_PAUSE) == PHY_X_P_BOTH_MD) 1308 else if (skge->flow_control == FLOW_MODE_SYM_OR_REM &&
1284 skge->flow_control = FLOW_MODE_LOC_SEND; 1309 (lpa & PHY_X_RS_PAUSE) == PHY_X_P_ASYM_MD)
1310 /* Enable PAUSE receive, disable PAUSE transmit */
1311 skge->flow_status = FLOW_STAT_REM_SEND;
1312 else if (skge->flow_control == FLOW_MODE_LOC_SEND &&
1313 (lpa & PHY_X_RS_PAUSE) == PHY_X_P_BOTH_MD)
1314 /* Disable PAUSE receive, enable PAUSE transmit */
1315 skge->flow_status = FLOW_STAT_LOC_SEND;
1285 else 1316 else
1286 skge->flow_control = FLOW_MODE_NONE; 1317 skge->flow_status = FLOW_STAT_NONE;
1287
1288 1318
1289 skge->speed = SPEED_1000; 1319 skge->speed = SPEED_1000;
1290 } 1320 }
@@ -1568,6 +1598,10 @@ static void genesis_mac_intr(struct skge_hw *hw, int port)
1568 printk(KERN_DEBUG PFX "%s: mac interrupt status 0x%x\n", 1598 printk(KERN_DEBUG PFX "%s: mac interrupt status 0x%x\n",
1569 skge->netdev->name, status); 1599 skge->netdev->name, status);
1570 1600
1601 if (hw->phy_type == SK_PHY_XMAC &&
1602 (status & (XM_IS_INP_ASS | XM_IS_LIPA_RC)))
1603 xm_link_down(hw, port);
1604
1571 if (status & XM_IS_TXF_UR) { 1605 if (status & XM_IS_TXF_UR) {
1572 xm_write32(hw, port, XM_MODE, XM_MD_FTF); 1606 xm_write32(hw, port, XM_MODE, XM_MD_FTF);
1573 ++skge->net_stats.tx_fifo_errors; 1607 ++skge->net_stats.tx_fifo_errors;
@@ -1582,7 +1616,7 @@ static void genesis_link_up(struct skge_port *skge)
1582{ 1616{
1583 struct skge_hw *hw = skge->hw; 1617 struct skge_hw *hw = skge->hw;
1584 int port = skge->port; 1618 int port = skge->port;
1585 u16 cmd; 1619 u16 cmd, msk;
1586 u32 mode; 1620 u32 mode;
1587 1621
1588 cmd = xm_read16(hw, port, XM_MMU_CMD); 1622 cmd = xm_read16(hw, port, XM_MMU_CMD);
@@ -1591,8 +1625,8 @@ static void genesis_link_up(struct skge_port *skge)
1591 * enabling pause frame reception is required for 1000BT 1625 * enabling pause frame reception is required for 1000BT
1592 * because the XMAC is not reset if the link is going down 1626 * because the XMAC is not reset if the link is going down
1593 */ 1627 */
1594 if (skge->flow_control == FLOW_MODE_NONE || 1628 if (skge->flow_status == FLOW_STAT_NONE ||
1595 skge->flow_control == FLOW_MODE_LOC_SEND) 1629 skge->flow_status == FLOW_STAT_LOC_SEND)
1596 /* Disable Pause Frame Reception */ 1630 /* Disable Pause Frame Reception */
1597 cmd |= XM_MMU_IGN_PF; 1631 cmd |= XM_MMU_IGN_PF;
1598 else 1632 else
@@ -1602,8 +1636,8 @@ static void genesis_link_up(struct skge_port *skge)
1602 xm_write16(hw, port, XM_MMU_CMD, cmd); 1636 xm_write16(hw, port, XM_MMU_CMD, cmd);
1603 1637
1604 mode = xm_read32(hw, port, XM_MODE); 1638 mode = xm_read32(hw, port, XM_MODE);
1605 if (skge->flow_control == FLOW_MODE_SYMMETRIC || 1639 if (skge->flow_status== FLOW_STAT_SYMMETRIC ||
1606 skge->flow_control == FLOW_MODE_LOC_SEND) { 1640 skge->flow_status == FLOW_STAT_LOC_SEND) {
1607 /* 1641 /*
1608 * Configure Pause Frame Generation 1642 * Configure Pause Frame Generation
1609 * Use internal and external Pause Frame Generation. 1643 * Use internal and external Pause Frame Generation.
@@ -1631,7 +1665,11 @@ static void genesis_link_up(struct skge_port *skge)
1631 } 1665 }
1632 1666
1633 xm_write32(hw, port, XM_MODE, mode); 1667 xm_write32(hw, port, XM_MODE, mode);
1634 xm_write16(hw, port, XM_IMSK, XM_DEF_MSK); 1668 msk = XM_DEF_MSK;
1669 if (hw->phy_type != SK_PHY_XMAC)
1670 msk |= XM_IS_INP_ASS; /* disable GP0 interrupt bit */
1671
1672 xm_write16(hw, port, XM_IMSK, msk);
1635 xm_read16(hw, port, XM_ISRC); 1673 xm_read16(hw, port, XM_ISRC);
1636 1674
1637 /* get MMU Command Reg. */ 1675 /* get MMU Command Reg. */
@@ -1779,11 +1817,17 @@ static void yukon_init(struct skge_hw *hw, int port)
1779 adv |= PHY_M_AN_10_FD; 1817 adv |= PHY_M_AN_10_FD;
1780 if (skge->advertising & ADVERTISED_10baseT_Half) 1818 if (skge->advertising & ADVERTISED_10baseT_Half)
1781 adv |= PHY_M_AN_10_HD; 1819 adv |= PHY_M_AN_10_HD;
1782 } else /* special defines for FIBER (88E1011S only) */
1783 adv |= PHY_M_AN_1000X_AHD | PHY_M_AN_1000X_AFD;
1784 1820
1785 /* Set Flow-control capabilities */ 1821 /* Set Flow-control capabilities */
1786 adv |= phy_pause_map[skge->flow_control]; 1822 adv |= phy_pause_map[skge->flow_control];
1823 } else {
1824 if (skge->advertising & ADVERTISED_1000baseT_Full)
1825 adv |= PHY_M_AN_1000X_AFD;
1826 if (skge->advertising & ADVERTISED_1000baseT_Half)
1827 adv |= PHY_M_AN_1000X_AHD;
1828
1829 adv |= fiber_pause_map[skge->flow_control];
1830 }
1787 1831
1788 /* Restart Auto-negotiation */ 1832 /* Restart Auto-negotiation */
1789 ctrl |= PHY_CT_ANE | PHY_CT_RE_CFG; 1833 ctrl |= PHY_CT_ANE | PHY_CT_RE_CFG;
@@ -1917,6 +1961,11 @@ static void yukon_mac_init(struct skge_hw *hw, int port)
1917 case FLOW_MODE_LOC_SEND: 1961 case FLOW_MODE_LOC_SEND:
1918 /* disable Rx flow-control */ 1962 /* disable Rx flow-control */
1919 reg |= GM_GPCR_FC_RX_DIS | GM_GPCR_AU_FCT_DIS; 1963 reg |= GM_GPCR_FC_RX_DIS | GM_GPCR_AU_FCT_DIS;
1964 break;
1965 case FLOW_MODE_SYMMETRIC:
1966 case FLOW_MODE_SYM_OR_REM:
1967 /* enable Tx & Rx flow-control */
1968 break;
1920 } 1969 }
1921 1970
1922 gma_write16(hw, port, GM_GP_CTRL, reg); 1971 gma_write16(hw, port, GM_GP_CTRL, reg);
@@ -2111,13 +2160,11 @@ static void yukon_link_down(struct skge_port *skge)
2111 ctrl &= ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA); 2160 ctrl &= ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA);
2112 gma_write16(hw, port, GM_GP_CTRL, ctrl); 2161 gma_write16(hw, port, GM_GP_CTRL, ctrl);
2113 2162
2114 if (skge->flow_control == FLOW_MODE_REM_SEND) { 2163 if (skge->flow_status == FLOW_STAT_REM_SEND) {
2164 ctrl = gm_phy_read(hw, port, PHY_MARV_AUNE_ADV);
2165 ctrl |= PHY_M_AN_ASP;
2115 /* restore Asymmetric Pause bit */ 2166 /* restore Asymmetric Pause bit */
2116 gm_phy_write(hw, port, PHY_MARV_AUNE_ADV, 2167 gm_phy_write(hw, port, PHY_MARV_AUNE_ADV, ctrl);
2117 gm_phy_read(hw, port,
2118 PHY_MARV_AUNE_ADV)
2119 | PHY_M_AN_ASP);
2120
2121 } 2168 }
2122 2169
2123 yukon_reset(hw, port); 2170 yukon_reset(hw, port);
@@ -2164,19 +2211,19 @@ static void yukon_phy_intr(struct skge_port *skge)
2164 /* We are using IEEE 802.3z/D5.0 Table 37-4 */ 2211 /* We are using IEEE 802.3z/D5.0 Table 37-4 */
2165 switch (phystat & PHY_M_PS_PAUSE_MSK) { 2212 switch (phystat & PHY_M_PS_PAUSE_MSK) {
2166 case PHY_M_PS_PAUSE_MSK: 2213 case PHY_M_PS_PAUSE_MSK:
2167 skge->flow_control = FLOW_MODE_SYMMETRIC; 2214 skge->flow_status = FLOW_STAT_SYMMETRIC;
2168 break; 2215 break;
2169 case PHY_M_PS_RX_P_EN: 2216 case PHY_M_PS_RX_P_EN:
2170 skge->flow_control = FLOW_MODE_REM_SEND; 2217 skge->flow_status = FLOW_STAT_REM_SEND;
2171 break; 2218 break;
2172 case PHY_M_PS_TX_P_EN: 2219 case PHY_M_PS_TX_P_EN:
2173 skge->flow_control = FLOW_MODE_LOC_SEND; 2220 skge->flow_status = FLOW_STAT_LOC_SEND;
2174 break; 2221 break;
2175 default: 2222 default:
2176 skge->flow_control = FLOW_MODE_NONE; 2223 skge->flow_status = FLOW_STAT_NONE;
2177 } 2224 }
2178 2225
2179 if (skge->flow_control == FLOW_MODE_NONE || 2226 if (skge->flow_status == FLOW_STAT_NONE ||
2180 (skge->speed < SPEED_1000 && skge->duplex == DUPLEX_HALF)) 2227 (skge->speed < SPEED_1000 && skge->duplex == DUPLEX_HALF))
2181 skge_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_OFF); 2228 skge_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_OFF);
2182 else 2229 else
@@ -3399,7 +3446,7 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port,
3399 3446
3400 /* Auto speed and flow control */ 3447 /* Auto speed and flow control */
3401 skge->autoneg = AUTONEG_ENABLE; 3448 skge->autoneg = AUTONEG_ENABLE;
3402 skge->flow_control = FLOW_MODE_SYMMETRIC; 3449 skge->flow_control = FLOW_MODE_SYM_OR_REM;
3403 skge->duplex = -1; 3450 skge->duplex = -1;
3404 skge->speed = -1; 3451 skge->speed = -1;
3405 skge->advertising = skge_supported_modes(hw); 3452 skge->advertising = skge_supported_modes(hw);
diff --git a/drivers/net/skge.h b/drivers/net/skge.h
index d0b47d46cf9d..537c0aaa1db8 100644
--- a/drivers/net/skge.h
+++ b/drivers/net/skge.h
@@ -2195,7 +2195,8 @@ enum {
2195 XM_IS_RX_COMP = 1<<0, /* Bit 0: Frame Rx Complete */ 2195 XM_IS_RX_COMP = 1<<0, /* Bit 0: Frame Rx Complete */
2196}; 2196};
2197 2197
2198#define XM_DEF_MSK (~(XM_IS_RXC_OV | XM_IS_TXC_OV | XM_IS_RXF_OV | XM_IS_TXF_UR)) 2198#define XM_DEF_MSK (~(XM_IS_INP_ASS | XM_IS_LIPA_RC | \
2199 XM_IS_RXF_OV | XM_IS_TXF_UR))
2199 2200
2200 2201
2201/* XM_HW_CFG 16 bit r/w Hardware Config Register */ 2202/* XM_HW_CFG 16 bit r/w Hardware Config Register */
@@ -2426,13 +2427,24 @@ struct skge_hw {
2426 struct mutex phy_mutex; 2427 struct mutex phy_mutex;
2427}; 2428};
2428 2429
2429enum { 2430enum pause_control {
2430 FLOW_MODE_NONE = 0, /* No Flow-Control */ 2431 FLOW_MODE_NONE = 1, /* No Flow-Control */
2431 FLOW_MODE_LOC_SEND = 1, /* Local station sends PAUSE */ 2432 FLOW_MODE_LOC_SEND = 2, /* Local station sends PAUSE */
2432 FLOW_MODE_REM_SEND = 2, /* Symmetric or just remote */
2433 FLOW_MODE_SYMMETRIC = 3, /* Both stations may send PAUSE */ 2433 FLOW_MODE_SYMMETRIC = 3, /* Both stations may send PAUSE */
2434 FLOW_MODE_SYM_OR_REM = 4, /* Both stations may send PAUSE or
2435 * just the remote station may send PAUSE
2436 */
2437};
2438
2439enum pause_status {
2440 FLOW_STAT_INDETERMINATED=0, /* indeterminated */
2441 FLOW_STAT_NONE, /* No Flow Control */
2442 FLOW_STAT_REM_SEND, /* Remote Station sends PAUSE */
2443 FLOW_STAT_LOC_SEND, /* Local station sends PAUSE */
2444 FLOW_STAT_SYMMETRIC, /* Both station may send PAUSE */
2434}; 2445};
2435 2446
2447
2436struct skge_port { 2448struct skge_port {
2437 u32 msg_enable; 2449 u32 msg_enable;
2438 struct skge_hw *hw; 2450 struct skge_hw *hw;
@@ -2445,9 +2457,10 @@ struct skge_port {
2445 struct net_device_stats net_stats; 2457 struct net_device_stats net_stats;
2446 2458
2447 struct work_struct link_thread; 2459 struct work_struct link_thread;
2460 enum pause_control flow_control;
2461 enum pause_status flow_status;
2448 u8 rx_csum; 2462 u8 rx_csum;
2449 u8 blink_on; 2463 u8 blink_on;
2450 u8 flow_control;
2451 u8 wol; 2464 u8 wol;
2452 u8 autoneg; /* AUTONEG_ENABLE, AUTONEG_DISABLE */ 2465 u8 autoneg; /* AUTONEG_ENABLE, AUTONEG_DISABLE */
2453 u8 duplex; /* DUPLEX_HALF, DUPLEX_FULL */ 2466 u8 duplex; /* DUPLEX_HALF, DUPLEX_FULL */
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 459c845d6648..16616f5440d0 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -10,8 +10,7 @@
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by 12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or 13 * the Free Software Foundation; either version 2 of the License.
14 * (at your option) any later version.
15 * 14 *
16 * This program is distributed in the hope that it will be useful, 15 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -50,7 +49,7 @@
50#include "sky2.h" 49#include "sky2.h"
51 50
52#define DRV_NAME "sky2" 51#define DRV_NAME "sky2"
53#define DRV_VERSION "1.9" 52#define DRV_VERSION "1.10"
54#define PFX DRV_NAME " " 53#define PFX DRV_NAME " "
55 54
56/* 55/*
@@ -96,9 +95,9 @@ static int disable_msi = 0;
96module_param(disable_msi, int, 0); 95module_param(disable_msi, int, 0);
97MODULE_PARM_DESC(disable_msi, "Disable Message Signaled Interrupt (MSI)"); 96MODULE_PARM_DESC(disable_msi, "Disable Message Signaled Interrupt (MSI)");
98 97
99static int idle_timeout = 100; 98static int idle_timeout = 0;
100module_param(idle_timeout, int, 0); 99module_param(idle_timeout, int, 0);
101MODULE_PARM_DESC(idle_timeout, "Idle timeout workaround for lost interrupts (ms)"); 100MODULE_PARM_DESC(idle_timeout, "Watchdog timer for lost interrupts (ms)");
102 101
103static const struct pci_device_id sky2_id_table[] = { 102static const struct pci_device_id sky2_id_table[] = {
104 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) }, 103 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) },
@@ -284,6 +283,31 @@ static void sky2_gmac_reset(struct sky2_hw *hw, unsigned port)
284 gma_write16(hw, port, GM_RX_CTRL, reg); 283 gma_write16(hw, port, GM_RX_CTRL, reg);
285} 284}
286 285
286/* flow control to advertise bits */
287static const u16 copper_fc_adv[] = {
288 [FC_NONE] = 0,
289 [FC_TX] = PHY_M_AN_ASP,
290 [FC_RX] = PHY_M_AN_PC,
291 [FC_BOTH] = PHY_M_AN_PC | PHY_M_AN_ASP,
292};
293
294/* flow control to advertise bits when using 1000BaseX */
295static const u16 fiber_fc_adv[] = {
296 [FC_BOTH] = PHY_M_P_BOTH_MD_X,
297 [FC_TX] = PHY_M_P_ASYM_MD_X,
298 [FC_RX] = PHY_M_P_SYM_MD_X,
299 [FC_NONE] = PHY_M_P_NO_PAUSE_X,
300};
301
302/* flow control to GMA disable bits */
303static const u16 gm_fc_disable[] = {
304 [FC_NONE] = GM_GPCR_FC_RX_DIS | GM_GPCR_FC_TX_DIS,
305 [FC_TX] = GM_GPCR_FC_RX_DIS,
306 [FC_RX] = GM_GPCR_FC_TX_DIS,
307 [FC_BOTH] = 0,
308};
309
310
287static void sky2_phy_init(struct sky2_hw *hw, unsigned port) 311static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
288{ 312{
289 struct sky2_port *sky2 = netdev_priv(hw->dev[port]); 313 struct sky2_port *sky2 = netdev_priv(hw->dev[port]);
@@ -356,16 +380,7 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
356 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg); 380 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg);
357 } 381 }
358 382
359 ctrl = gm_phy_read(hw, port, PHY_MARV_CTRL); 383 ctrl = PHY_CT_RESET;
360 if (sky2->autoneg == AUTONEG_DISABLE)
361 ctrl &= ~PHY_CT_ANE;
362 else
363 ctrl |= PHY_CT_ANE;
364
365 ctrl |= PHY_CT_RESET;
366 gm_phy_write(hw, port, PHY_MARV_CTRL, ctrl);
367
368 ctrl = 0;
369 ct1000 = 0; 384 ct1000 = 0;
370 adv = PHY_AN_CSMA; 385 adv = PHY_AN_CSMA;
371 reg = 0; 386 reg = 0;
@@ -384,20 +399,16 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
384 adv |= PHY_M_AN_10_FD; 399 adv |= PHY_M_AN_10_FD;
385 if (sky2->advertising & ADVERTISED_10baseT_Half) 400 if (sky2->advertising & ADVERTISED_10baseT_Half)
386 adv |= PHY_M_AN_10_HD; 401 adv |= PHY_M_AN_10_HD;
402
403 adv |= copper_fc_adv[sky2->flow_mode];
387 } else { /* special defines for FIBER (88E1040S only) */ 404 } else { /* special defines for FIBER (88E1040S only) */
388 if (sky2->advertising & ADVERTISED_1000baseT_Full) 405 if (sky2->advertising & ADVERTISED_1000baseT_Full)
389 adv |= PHY_M_AN_1000X_AFD; 406 adv |= PHY_M_AN_1000X_AFD;
390 if (sky2->advertising & ADVERTISED_1000baseT_Half) 407 if (sky2->advertising & ADVERTISED_1000baseT_Half)
391 adv |= PHY_M_AN_1000X_AHD; 408 adv |= PHY_M_AN_1000X_AHD;
392 }
393 409
394 /* Set Flow-control capabilities */ 410 adv |= fiber_fc_adv[sky2->flow_mode];
395 if (sky2->tx_pause && sky2->rx_pause) 411 }
396 adv |= PHY_AN_PAUSE_CAP; /* symmetric */
397 else if (sky2->rx_pause && !sky2->tx_pause)
398 adv |= PHY_AN_PAUSE_ASYM | PHY_AN_PAUSE_CAP;
399 else if (!sky2->rx_pause && sky2->tx_pause)
400 adv |= PHY_AN_PAUSE_ASYM; /* local */
401 412
402 /* Restart Auto-negotiation */ 413 /* Restart Auto-negotiation */
403 ctrl |= PHY_CT_ANE | PHY_CT_RE_CFG; 414 ctrl |= PHY_CT_ANE | PHY_CT_RE_CFG;
@@ -422,25 +433,17 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
422 if (sky2->duplex == DUPLEX_FULL) { 433 if (sky2->duplex == DUPLEX_FULL) {
423 reg |= GM_GPCR_DUP_FULL; 434 reg |= GM_GPCR_DUP_FULL;
424 ctrl |= PHY_CT_DUP_MD; 435 ctrl |= PHY_CT_DUP_MD;
425 } else if (sky2->speed != SPEED_1000 && hw->chip_id != CHIP_ID_YUKON_EC_U) { 436 } else if (sky2->speed < SPEED_1000)
426 /* Turn off flow control for 10/100mbps */ 437 sky2->flow_mode = FC_NONE;
427 sky2->rx_pause = 0;
428 sky2->tx_pause = 0;
429 }
430 438
431 if (!sky2->rx_pause)
432 reg |= GM_GPCR_FC_RX_DIS;
433 439
434 if (!sky2->tx_pause) 440 reg |= gm_fc_disable[sky2->flow_mode];
435 reg |= GM_GPCR_FC_TX_DIS;
436 441
437 /* Forward pause packets to GMAC? */ 442 /* Forward pause packets to GMAC? */
438 if (sky2->tx_pause || sky2->rx_pause) 443 if (sky2->flow_mode & FC_RX)
439 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_ON); 444 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_ON);
440 else 445 else
441 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_OFF); 446 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_OFF);
442
443 ctrl |= PHY_CT_RESET;
444 } 447 }
445 448
446 gma_write16(hw, port, GM_GP_CTRL, reg); 449 gma_write16(hw, port, GM_GP_CTRL, reg);
@@ -683,7 +686,7 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
683 sky2_write16(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_OPER_ON); 686 sky2_write16(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_OPER_ON);
684 687
685 if (hw->chip_id == CHIP_ID_YUKON_EC_U) { 688 if (hw->chip_id == CHIP_ID_YUKON_EC_U) {
686 sky2_write8(hw, SK_REG(port, RX_GMF_LP_THR), 768/8); 689 sky2_write8(hw, SK_REG(port, RX_GMF_LP_THR), 512/8);
687 sky2_write8(hw, SK_REG(port, RX_GMF_UP_THR), 1024/8); 690 sky2_write8(hw, SK_REG(port, RX_GMF_UP_THR), 1024/8);
688 if (hw->dev[port]->mtu > ETH_DATA_LEN) { 691 if (hw->dev[port]->mtu > ETH_DATA_LEN) {
689 /* set Tx GMAC FIFO Almost Empty Threshold */ 692 /* set Tx GMAC FIFO Almost Empty Threshold */
@@ -695,16 +698,10 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
695 698
696} 699}
697 700
698/* Assign Ram Buffer allocation. 701/* Assign Ram Buffer allocation in units of 64bit (8 bytes) */
699 * start and end are in units of 4k bytes 702static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, u32 end)
700 * ram registers are in units of 64bit words
701 */
702static void sky2_ramset(struct sky2_hw *hw, u16 q, u8 startk, u8 endk)
703{ 703{
704 u32 start, end; 704 pr_debug(PFX "q %d %#x %#x\n", q, start, end);
705
706 start = startk * 4096/8;
707 end = (endk * 4096/8) - 1;
708 705
709 sky2_write8(hw, RB_ADDR(q, RB_CTRL), RB_RST_CLR); 706 sky2_write8(hw, RB_ADDR(q, RB_CTRL), RB_RST_CLR);
710 sky2_write32(hw, RB_ADDR(q, RB_START), start); 707 sky2_write32(hw, RB_ADDR(q, RB_START), start);
@@ -713,7 +710,7 @@ static void sky2_ramset(struct sky2_hw *hw, u16 q, u8 startk, u8 endk)
713 sky2_write32(hw, RB_ADDR(q, RB_RP), start); 710 sky2_write32(hw, RB_ADDR(q, RB_RP), start);
714 711
715 if (q == Q_R1 || q == Q_R2) { 712 if (q == Q_R1 || q == Q_R2) {
716 u32 space = (endk - startk) * 4096/8; 713 u32 space = end - start + 1;
717 u32 tp = space - space/4; 714 u32 tp = space - space/4;
718 715
719 /* On receive queue's set the thresholds 716 /* On receive queue's set the thresholds
@@ -1195,19 +1192,16 @@ static int sky2_up(struct net_device *dev)
1195 1192
1196 sky2_mac_init(hw, port); 1193 sky2_mac_init(hw, port);
1197 1194
1198 /* Determine available ram buffer space (in 4K blocks). 1195 /* Determine available ram buffer space in qwords. */
1199 * Note: not sure about the FE setting below yet 1196 ramsize = sky2_read8(hw, B2_E_0) * 4096/8;
1200 */
1201 if (hw->chip_id == CHIP_ID_YUKON_FE)
1202 ramsize = 4;
1203 else
1204 ramsize = sky2_read8(hw, B2_E_0);
1205 1197
1206 /* Give transmitter one third (rounded up) */ 1198 if (ramsize > 6*1024/8)
1207 rxspace = ramsize - (ramsize + 2) / 3; 1199 rxspace = ramsize - (ramsize + 2) / 3;
1200 else
1201 rxspace = ramsize / 2;
1208 1202
1209 sky2_ramset(hw, rxqaddr[port], 0, rxspace); 1203 sky2_ramset(hw, rxqaddr[port], 0, rxspace-1);
1210 sky2_ramset(hw, txqaddr[port], rxspace, ramsize); 1204 sky2_ramset(hw, txqaddr[port], rxspace, ramsize-1);
1211 1205
1212 /* Make sure SyncQ is disabled */ 1206 /* Make sure SyncQ is disabled */
1213 sky2_write8(hw, RB_ADDR(port == 0 ? Q_XS1 : Q_XS2, RB_CTRL), 1207 sky2_write8(hw, RB_ADDR(port == 0 ? Q_XS1 : Q_XS2, RB_CTRL),
@@ -1499,6 +1493,11 @@ static int sky2_down(struct net_device *dev)
1499 /* Stop more packets from being queued */ 1493 /* Stop more packets from being queued */
1500 netif_stop_queue(dev); 1494 netif_stop_queue(dev);
1501 1495
1496 /* Disable port IRQ */
1497 imask = sky2_read32(hw, B0_IMSK);
1498 imask &= ~portirq_msk[port];
1499 sky2_write32(hw, B0_IMSK, imask);
1500
1502 sky2_gmac_reset(hw, port); 1501 sky2_gmac_reset(hw, port);
1503 1502
1504 /* Stop transmitter */ 1503 /* Stop transmitter */
@@ -1549,11 +1548,6 @@ static int sky2_down(struct net_device *dev)
1549 sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_SET); 1548 sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_SET);
1550 sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_RST_SET); 1549 sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_RST_SET);
1551 1550
1552 /* Disable port IRQ */
1553 imask = sky2_read32(hw, B0_IMSK);
1554 imask &= ~portirq_msk[port];
1555 sky2_write32(hw, B0_IMSK, imask);
1556
1557 sky2_phy_power(hw, port, 0); 1551 sky2_phy_power(hw, port, 0);
1558 1552
1559 /* turn off LED's */ 1553 /* turn off LED's */
@@ -1605,6 +1599,12 @@ static void sky2_link_up(struct sky2_port *sky2)
1605 struct sky2_hw *hw = sky2->hw; 1599 struct sky2_hw *hw = sky2->hw;
1606 unsigned port = sky2->port; 1600 unsigned port = sky2->port;
1607 u16 reg; 1601 u16 reg;
1602 static const char *fc_name[] = {
1603 [FC_NONE] = "none",
1604 [FC_TX] = "tx",
1605 [FC_RX] = "rx",
1606 [FC_BOTH] = "both",
1607 };
1608 1608
1609 /* enable Rx/Tx */ 1609 /* enable Rx/Tx */
1610 reg = gma_read16(hw, port, GM_GP_CTRL); 1610 reg = gma_read16(hw, port, GM_GP_CTRL);
@@ -1648,8 +1648,7 @@ static void sky2_link_up(struct sky2_port *sky2)
1648 "%s: Link is up at %d Mbps, %s duplex, flow control %s\n", 1648 "%s: Link is up at %d Mbps, %s duplex, flow control %s\n",
1649 sky2->netdev->name, sky2->speed, 1649 sky2->netdev->name, sky2->speed,
1650 sky2->duplex == DUPLEX_FULL ? "full" : "half", 1650 sky2->duplex == DUPLEX_FULL ? "full" : "half",
1651 (sky2->tx_pause && sky2->rx_pause) ? "both" : 1651 fc_name[sky2->flow_status]);
1652 sky2->tx_pause ? "tx" : sky2->rx_pause ? "rx" : "none");
1653} 1652}
1654 1653
1655static void sky2_link_down(struct sky2_port *sky2) 1654static void sky2_link_down(struct sky2_port *sky2)
@@ -1664,7 +1663,7 @@ static void sky2_link_down(struct sky2_port *sky2)
1664 reg &= ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA); 1663 reg &= ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA);
1665 gma_write16(hw, port, GM_GP_CTRL, reg); 1664 gma_write16(hw, port, GM_GP_CTRL, reg);
1666 1665
1667 if (sky2->rx_pause && !sky2->tx_pause) { 1666 if (sky2->flow_status == FC_RX) {
1668 /* restore Asymmetric Pause bit */ 1667 /* restore Asymmetric Pause bit */
1669 gm_phy_write(hw, port, PHY_MARV_AUNE_ADV, 1668 gm_phy_write(hw, port, PHY_MARV_AUNE_ADV,
1670 gm_phy_read(hw, port, PHY_MARV_AUNE_ADV) 1669 gm_phy_read(hw, port, PHY_MARV_AUNE_ADV)
@@ -1683,6 +1682,14 @@ static void sky2_link_down(struct sky2_port *sky2)
1683 sky2_phy_init(hw, port); 1682 sky2_phy_init(hw, port);
1684} 1683}
1685 1684
1685static enum flow_control sky2_flow(int rx, int tx)
1686{
1687 if (rx)
1688 return tx ? FC_BOTH : FC_RX;
1689 else
1690 return tx ? FC_TX : FC_NONE;
1691}
1692
1686static int sky2_autoneg_done(struct sky2_port *sky2, u16 aux) 1693static int sky2_autoneg_done(struct sky2_port *sky2, u16 aux)
1687{ 1694{
1688 struct sky2_hw *hw = sky2->hw; 1695 struct sky2_hw *hw = sky2->hw;
@@ -1703,39 +1710,20 @@ static int sky2_autoneg_done(struct sky2_port *sky2, u16 aux)
1703 } 1710 }
1704 1711
1705 sky2->speed = sky2_phy_speed(hw, aux); 1712 sky2->speed = sky2_phy_speed(hw, aux);
1706 if (sky2->speed == SPEED_1000) { 1713 sky2->duplex = (aux & PHY_M_PS_FULL_DUP) ? DUPLEX_FULL : DUPLEX_HALF;
1707 u16 ctl2 = gm_phy_read(hw, port, PHY_MARV_1000T_CTRL);
1708 u16 lpa2 = gm_phy_read(hw, port, PHY_MARV_1000T_STAT);
1709 if (lpa2 & PHY_B_1000S_MSF) {
1710 printk(KERN_ERR PFX "%s: master/slave fault",
1711 sky2->netdev->name);
1712 return -1;
1713 }
1714
1715 if ((ctl2 & PHY_M_1000C_AFD) && (lpa2 & PHY_B_1000S_LP_FD))
1716 sky2->duplex = DUPLEX_FULL;
1717 else
1718 sky2->duplex = DUPLEX_HALF;
1719 } else {
1720 u16 adv = gm_phy_read(hw, port, PHY_MARV_AUNE_ADV);
1721 if ((aux & adv) & PHY_AN_FULL)
1722 sky2->duplex = DUPLEX_FULL;
1723 else
1724 sky2->duplex = DUPLEX_HALF;
1725 }
1726 1714
1727 /* Pause bits are offset (9..8) */ 1715 /* Pause bits are offset (9..8) */
1728 if (hw->chip_id == CHIP_ID_YUKON_XL || hw->chip_id == CHIP_ID_YUKON_EC_U) 1716 if (hw->chip_id == CHIP_ID_YUKON_XL || hw->chip_id == CHIP_ID_YUKON_EC_U)
1729 aux >>= 6; 1717 aux >>= 6;
1730 1718
1731 sky2->rx_pause = (aux & PHY_M_PS_RX_P_EN) != 0; 1719 sky2->flow_status = sky2_flow(aux & PHY_M_PS_RX_P_EN,
1732 sky2->tx_pause = (aux & PHY_M_PS_TX_P_EN) != 0; 1720 aux & PHY_M_PS_TX_P_EN);
1733 1721
1734 if (sky2->duplex == DUPLEX_HALF && sky2->speed != SPEED_1000 1722 if (sky2->duplex == DUPLEX_HALF && sky2->speed < SPEED_1000
1735 && hw->chip_id != CHIP_ID_YUKON_EC_U) 1723 && hw->chip_id != CHIP_ID_YUKON_EC_U)
1736 sky2->rx_pause = sky2->tx_pause = 0; 1724 sky2->flow_status = FC_NONE;
1737 1725
1738 if (sky2->rx_pause || sky2->tx_pause) 1726 if (aux & PHY_M_PS_RX_P_EN)
1739 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_ON); 1727 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_ON);
1740 else 1728 else
1741 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_OFF); 1729 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_OFF);
@@ -1750,13 +1738,13 @@ static void sky2_phy_intr(struct sky2_hw *hw, unsigned port)
1750 struct sky2_port *sky2 = netdev_priv(dev); 1738 struct sky2_port *sky2 = netdev_priv(dev);
1751 u16 istatus, phystat; 1739 u16 istatus, phystat;
1752 1740
1741 if (!netif_running(dev))
1742 return;
1743
1753 spin_lock(&sky2->phy_lock); 1744 spin_lock(&sky2->phy_lock);
1754 istatus = gm_phy_read(hw, port, PHY_MARV_INT_STAT); 1745 istatus = gm_phy_read(hw, port, PHY_MARV_INT_STAT);
1755 phystat = gm_phy_read(hw, port, PHY_MARV_PHY_STAT); 1746 phystat = gm_phy_read(hw, port, PHY_MARV_PHY_STAT);
1756 1747
1757 if (!netif_running(dev))
1758 goto out;
1759
1760 if (netif_msg_intr(sky2)) 1748 if (netif_msg_intr(sky2))
1761 printk(KERN_INFO PFX "%s: phy interrupt status 0x%x 0x%x\n", 1749 printk(KERN_INFO PFX "%s: phy interrupt status 0x%x 0x%x\n",
1762 sky2->netdev->name, istatus, phystat); 1750 sky2->netdev->name, istatus, phystat);
@@ -1907,7 +1895,7 @@ static struct sk_buff *receive_copy(struct sky2_port *sky2,
1907 pci_dma_sync_single_for_device(sky2->hw->pdev, re->data_addr, 1895 pci_dma_sync_single_for_device(sky2->hw->pdev, re->data_addr,
1908 length, PCI_DMA_FROMDEVICE); 1896 length, PCI_DMA_FROMDEVICE);
1909 re->skb->ip_summed = CHECKSUM_NONE; 1897 re->skb->ip_summed = CHECKSUM_NONE;
1910 __skb_put(skb, length); 1898 skb_put(skb, length);
1911 } 1899 }
1912 return skb; 1900 return skb;
1913} 1901}
@@ -1970,7 +1958,7 @@ static struct sk_buff *receive_new(struct sky2_port *sky2,
1970 if (skb_shinfo(skb)->nr_frags) 1958 if (skb_shinfo(skb)->nr_frags)
1971 skb_put_frags(skb, hdr_space, length); 1959 skb_put_frags(skb, hdr_space, length);
1972 else 1960 else
1973 skb_put(skb, hdr_space); 1961 skb_put(skb, length);
1974 return skb; 1962 return skb;
1975} 1963}
1976 1964
@@ -2016,6 +2004,10 @@ oversize:
2016 2004
2017error: 2005error:
2018 ++sky2->net_stats.rx_errors; 2006 ++sky2->net_stats.rx_errors;
2007 if (status & GMR_FS_RX_FF_OV) {
2008 sky2->net_stats.rx_fifo_errors++;
2009 goto resubmit;
2010 }
2019 2011
2020 if (netif_msg_rx_err(sky2) && net_ratelimit()) 2012 if (netif_msg_rx_err(sky2) && net_ratelimit())
2021 printk(KERN_INFO PFX "%s: rx error, status 0x%x length %d\n", 2013 printk(KERN_INFO PFX "%s: rx error, status 0x%x length %d\n",
@@ -2027,8 +2019,6 @@ error:
2027 sky2->net_stats.rx_frame_errors++; 2019 sky2->net_stats.rx_frame_errors++;
2028 if (status & GMR_FS_CRC_ERR) 2020 if (status & GMR_FS_CRC_ERR)
2029 sky2->net_stats.rx_crc_errors++; 2021 sky2->net_stats.rx_crc_errors++;
2030 if (status & GMR_FS_RX_FF_OV)
2031 sky2->net_stats.rx_fifo_errors++;
2032 2022
2033 goto resubmit; 2023 goto resubmit;
2034} 2024}
@@ -2220,8 +2210,7 @@ static void sky2_hw_intr(struct sky2_hw *hw)
2220 /* PCI-Express uncorrectable Error occurred */ 2210 /* PCI-Express uncorrectable Error occurred */
2221 u32 pex_err; 2211 u32 pex_err;
2222 2212
2223 pex_err = sky2_pci_read32(hw, 2213 pex_err = sky2_pci_read32(hw, PEX_UNC_ERR_STAT);
2224 hw->err_cap + PCI_ERR_UNCOR_STATUS);
2225 2214
2226 if (net_ratelimit()) 2215 if (net_ratelimit())
2227 printk(KERN_ERR PFX "%s: pci express error (0x%x)\n", 2216 printk(KERN_ERR PFX "%s: pci express error (0x%x)\n",
@@ -2229,20 +2218,15 @@ static void sky2_hw_intr(struct sky2_hw *hw)
2229 2218
2230 /* clear the interrupt */ 2219 /* clear the interrupt */
2231 sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); 2220 sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
2232 sky2_pci_write32(hw, 2221 sky2_pci_write32(hw, PEX_UNC_ERR_STAT,
2233 hw->err_cap + PCI_ERR_UNCOR_STATUS, 2222 0xffffffffUL);
2234 0xffffffffUL);
2235 sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF); 2223 sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
2236 2224
2237 2225 if (pex_err & PEX_FATAL_ERRORS) {
2238 /* In case of fatal error mask off to keep from getting stuck */
2239 if (pex_err & (PCI_ERR_UNC_POISON_TLP | PCI_ERR_UNC_FCP
2240 | PCI_ERR_UNC_DLP)) {
2241 u32 hwmsk = sky2_read32(hw, B0_HWE_IMSK); 2226 u32 hwmsk = sky2_read32(hw, B0_HWE_IMSK);
2242 hwmsk &= ~Y2_IS_PCI_EXP; 2227 hwmsk &= ~Y2_IS_PCI_EXP;
2243 sky2_write32(hw, B0_HWE_IMSK, hwmsk); 2228 sky2_write32(hw, B0_HWE_IMSK, hwmsk);
2244 } 2229 }
2245
2246 } 2230 }
2247 2231
2248 if (status & Y2_HWE_L1_MASK) 2232 if (status & Y2_HWE_L1_MASK)
@@ -2423,7 +2407,6 @@ static int sky2_reset(struct sky2_hw *hw)
2423 u16 status; 2407 u16 status;
2424 u8 t8; 2408 u8 t8;
2425 int i; 2409 int i;
2426 u32 msk;
2427 2410
2428 sky2_write8(hw, B0_CTST, CS_RST_CLR); 2411 sky2_write8(hw, B0_CTST, CS_RST_CLR);
2429 2412
@@ -2464,13 +2447,9 @@ static int sky2_reset(struct sky2_hw *hw)
2464 sky2_write8(hw, B0_CTST, CS_MRST_CLR); 2447 sky2_write8(hw, B0_CTST, CS_MRST_CLR);
2465 2448
2466 /* clear any PEX errors */ 2449 /* clear any PEX errors */
2467 if (pci_find_capability(hw->pdev, PCI_CAP_ID_EXP)) { 2450 if (pci_find_capability(hw->pdev, PCI_CAP_ID_EXP))
2468 hw->err_cap = pci_find_ext_capability(hw->pdev, PCI_EXT_CAP_ID_ERR); 2451 sky2_pci_write32(hw, PEX_UNC_ERR_STAT, 0xffffffffUL);
2469 if (hw->err_cap) 2452
2470 sky2_pci_write32(hw,
2471 hw->err_cap + PCI_ERR_UNCOR_STATUS,
2472 0xffffffffUL);
2473 }
2474 2453
2475 hw->pmd_type = sky2_read8(hw, B2_PMD_TYP); 2454 hw->pmd_type = sky2_read8(hw, B2_PMD_TYP);
2476 hw->ports = 1; 2455 hw->ports = 1;
@@ -2527,10 +2506,7 @@ static int sky2_reset(struct sky2_hw *hw)
2527 sky2_write8(hw, RAM_BUFFER(i, B3_RI_RTO_XS2), SK_RI_TO_53); 2506 sky2_write8(hw, RAM_BUFFER(i, B3_RI_RTO_XS2), SK_RI_TO_53);
2528 } 2507 }
2529 2508
2530 msk = Y2_HWE_ALL_MASK; 2509 sky2_write32(hw, B0_HWE_IMSK, Y2_HWE_ALL_MASK);
2531 if (!hw->err_cap)
2532 msk &= ~Y2_IS_PCI_EXP;
2533 sky2_write32(hw, B0_HWE_IMSK, msk);
2534 2510
2535 for (i = 0; i < hw->ports; i++) 2511 for (i = 0; i < hw->ports; i++)
2536 sky2_gmac_reset(hw, i); 2512 sky2_gmac_reset(hw, i);
@@ -2762,7 +2738,7 @@ static int sky2_nway_reset(struct net_device *dev)
2762{ 2738{
2763 struct sky2_port *sky2 = netdev_priv(dev); 2739 struct sky2_port *sky2 = netdev_priv(dev);
2764 2740
2765 if (sky2->autoneg != AUTONEG_ENABLE) 2741 if (!netif_running(dev) || sky2->autoneg != AUTONEG_ENABLE)
2766 return -EINVAL; 2742 return -EINVAL;
2767 2743
2768 sky2_phy_reinit(sky2); 2744 sky2_phy_reinit(sky2);
@@ -2864,6 +2840,14 @@ static int sky2_set_mac_address(struct net_device *dev, void *p)
2864 return 0; 2840 return 0;
2865} 2841}
2866 2842
2843static void inline sky2_add_filter(u8 filter[8], const u8 *addr)
2844{
2845 u32 bit;
2846
2847 bit = ether_crc(ETH_ALEN, addr) & 63;
2848 filter[bit >> 3] |= 1 << (bit & 7);
2849}
2850
2867static void sky2_set_multicast(struct net_device *dev) 2851static void sky2_set_multicast(struct net_device *dev)
2868{ 2852{
2869 struct sky2_port *sky2 = netdev_priv(dev); 2853 struct sky2_port *sky2 = netdev_priv(dev);
@@ -2872,7 +2856,10 @@ static void sky2_set_multicast(struct net_device *dev)
2872 struct dev_mc_list *list = dev->mc_list; 2856 struct dev_mc_list *list = dev->mc_list;
2873 u16 reg; 2857 u16 reg;
2874 u8 filter[8]; 2858 u8 filter[8];
2859 int rx_pause;
2860 static const u8 pause_mc_addr[ETH_ALEN] = { 0x1, 0x80, 0xc2, 0x0, 0x0, 0x1 };
2875 2861
2862 rx_pause = (sky2->flow_status == FC_RX || sky2->flow_status == FC_BOTH);
2876 memset(filter, 0, sizeof(filter)); 2863 memset(filter, 0, sizeof(filter));
2877 2864
2878 reg = gma_read16(hw, port, GM_RX_CTRL); 2865 reg = gma_read16(hw, port, GM_RX_CTRL);
@@ -2880,18 +2867,19 @@ static void sky2_set_multicast(struct net_device *dev)
2880 2867
2881 if (dev->flags & IFF_PROMISC) /* promiscuous */ 2868 if (dev->flags & IFF_PROMISC) /* promiscuous */
2882 reg &= ~(GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA); 2869 reg &= ~(GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA);
2883 else if ((dev->flags & IFF_ALLMULTI) || dev->mc_count > 16) /* all multicast */ 2870 else if (dev->flags & IFF_ALLMULTI)
2884 memset(filter, 0xff, sizeof(filter)); 2871 memset(filter, 0xff, sizeof(filter));
2885 else if (dev->mc_count == 0) /* no multicast */ 2872 else if (dev->mc_count == 0 && !rx_pause)
2886 reg &= ~GM_RXCR_MCF_ENA; 2873 reg &= ~GM_RXCR_MCF_ENA;
2887 else { 2874 else {
2888 int i; 2875 int i;
2889 reg |= GM_RXCR_MCF_ENA; 2876 reg |= GM_RXCR_MCF_ENA;
2890 2877
2891 for (i = 0; list && i < dev->mc_count; i++, list = list->next) { 2878 if (rx_pause)
2892 u32 bit = ether_crc(ETH_ALEN, list->dmi_addr) & 0x3f; 2879 sky2_add_filter(filter, pause_mc_addr);
2893 filter[bit / 8] |= 1 << (bit % 8); 2880
2894 } 2881 for (i = 0; list && i < dev->mc_count; i++, list = list->next)
2882 sky2_add_filter(filter, list->dmi_addr);
2895 } 2883 }
2896 2884
2897 gma_write16(hw, port, GM_MC_ADDR_H1, 2885 gma_write16(hw, port, GM_MC_ADDR_H1,
@@ -3004,8 +2992,20 @@ static void sky2_get_pauseparam(struct net_device *dev,
3004{ 2992{
3005 struct sky2_port *sky2 = netdev_priv(dev); 2993 struct sky2_port *sky2 = netdev_priv(dev);
3006 2994
3007 ecmd->tx_pause = sky2->tx_pause; 2995 switch (sky2->flow_mode) {
3008 ecmd->rx_pause = sky2->rx_pause; 2996 case FC_NONE:
2997 ecmd->tx_pause = ecmd->rx_pause = 0;
2998 break;
2999 case FC_TX:
3000 ecmd->tx_pause = 1, ecmd->rx_pause = 0;
3001 break;
3002 case FC_RX:
3003 ecmd->tx_pause = 0, ecmd->rx_pause = 1;
3004 break;
3005 case FC_BOTH:
3006 ecmd->tx_pause = ecmd->rx_pause = 1;
3007 }
3008
3009 ecmd->autoneg = sky2->autoneg; 3009 ecmd->autoneg = sky2->autoneg;
3010} 3010}
3011 3011
@@ -3015,10 +3015,10 @@ static int sky2_set_pauseparam(struct net_device *dev,
3015 struct sky2_port *sky2 = netdev_priv(dev); 3015 struct sky2_port *sky2 = netdev_priv(dev);
3016 3016
3017 sky2->autoneg = ecmd->autoneg; 3017 sky2->autoneg = ecmd->autoneg;
3018 sky2->tx_pause = ecmd->tx_pause != 0; 3018 sky2->flow_mode = sky2_flow(ecmd->rx_pause, ecmd->tx_pause);
3019 sky2->rx_pause = ecmd->rx_pause != 0;
3020 3019
3021 sky2_phy_reinit(sky2); 3020 if (netif_running(dev))
3021 sky2_phy_reinit(sky2);
3022 3022
3023 return 0; 3023 return 0;
3024} 3024}
@@ -3238,7 +3238,11 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw,
3238 dev->poll = sky2_poll; 3238 dev->poll = sky2_poll;
3239 dev->weight = NAPI_WEIGHT; 3239 dev->weight = NAPI_WEIGHT;
3240#ifdef CONFIG_NET_POLL_CONTROLLER 3240#ifdef CONFIG_NET_POLL_CONTROLLER
3241 dev->poll_controller = sky2_netpoll; 3241 /* Network console (only works on port 0)
3242 * because netpoll makes assumptions about NAPI
3243 */
3244 if (port == 0)
3245 dev->poll_controller = sky2_netpoll;
3242#endif 3246#endif
3243 3247
3244 sky2 = netdev_priv(dev); 3248 sky2 = netdev_priv(dev);
@@ -3248,8 +3252,8 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw,
3248 3252
3249 /* Auto speed and flow control */ 3253 /* Auto speed and flow control */
3250 sky2->autoneg = AUTONEG_ENABLE; 3254 sky2->autoneg = AUTONEG_ENABLE;
3251 sky2->tx_pause = 1; 3255 sky2->flow_mode = FC_BOTH;
3252 sky2->rx_pause = 1; 3256
3253 sky2->duplex = -1; 3257 sky2->duplex = -1;
3254 sky2->speed = -1; 3258 sky2->speed = -1;
3255 sky2->advertising = sky2_supported_modes(hw); 3259 sky2->advertising = sky2_supported_modes(hw);
@@ -3340,9 +3344,8 @@ static int __devinit sky2_test_msi(struct sky2_hw *hw)
3340 3344
3341 if (!hw->msi_detected) { 3345 if (!hw->msi_detected) {
3342 /* MSI test failed, go back to INTx mode */ 3346 /* MSI test failed, go back to INTx mode */
3343 printk(KERN_WARNING PFX "%s: No interrupt was generated using MSI, " 3347 printk(KERN_INFO PFX "%s: No interrupt generated using MSI, "
3344 "switching to INTx mode. Please report this failure to " 3348 "switching to INTx mode.\n",
3345 "the PCI maintainer and include system chipset information.\n",
3346 pci_name(pdev)); 3349 pci_name(pdev));
3347 3350
3348 err = -EOPNOTSUPP; 3351 err = -EOPNOTSUPP;
@@ -3350,6 +3353,7 @@ static int __devinit sky2_test_msi(struct sky2_hw *hw)
3350 } 3353 }
3351 3354
3352 sky2_write32(hw, B0_IMSK, 0); 3355 sky2_write32(hw, B0_IMSK, 0);
3356 sky2_read32(hw, B0_IMSK);
3353 3357
3354 free_irq(pdev->irq, hw); 3358 free_irq(pdev->irq, hw);
3355 3359
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h
index f66109a96d95..6d2a23f66c9a 100644
--- a/drivers/net/sky2.h
+++ b/drivers/net/sky2.h
@@ -6,15 +6,24 @@
6 6
7#define ETH_JUMBO_MTU 9000 /* Maximum MTU supported */ 7#define ETH_JUMBO_MTU 9000 /* Maximum MTU supported */
8 8
9/* PCI device specific config registers */ 9/* PCI config registers */
10enum { 10enum {
11 PCI_DEV_REG1 = 0x40, 11 PCI_DEV_REG1 = 0x40,
12 PCI_DEV_REG2 = 0x44, 12 PCI_DEV_REG2 = 0x44,
13 PCI_DEV_STATUS = 0x7c,
13 PCI_DEV_REG3 = 0x80, 14 PCI_DEV_REG3 = 0x80,
14 PCI_DEV_REG4 = 0x84, 15 PCI_DEV_REG4 = 0x84,
15 PCI_DEV_REG5 = 0x88, 16 PCI_DEV_REG5 = 0x88,
16}; 17};
17 18
19enum {
20 PEX_DEV_CAP = 0xe4,
21 PEX_DEV_CTRL = 0xe8,
22 PEX_DEV_STA = 0xea,
23 PEX_LNK_STAT = 0xf2,
24 PEX_UNC_ERR_STAT= 0x104,
25};
26
18/* Yukon-2 */ 27/* Yukon-2 */
19enum pci_dev_reg_1 { 28enum pci_dev_reg_1 {
20 PCI_Y2_PIG_ENA = 1<<31, /* Enable Plug-in-Go (YUKON-2) */ 29 PCI_Y2_PIG_ENA = 1<<31, /* Enable Plug-in-Go (YUKON-2) */
@@ -63,6 +72,39 @@ enum pci_dev_reg_4 {
63 PCI_STATUS_REC_MASTER_ABORT | \ 72 PCI_STATUS_REC_MASTER_ABORT | \
64 PCI_STATUS_REC_TARGET_ABORT | \ 73 PCI_STATUS_REC_TARGET_ABORT | \
65 PCI_STATUS_PARITY) 74 PCI_STATUS_PARITY)
75
76enum pex_dev_ctrl {
77 PEX_DC_MAX_RRS_MSK = 7<<12, /* Bit 14..12: Max. Read Request Size */
78 PEX_DC_EN_NO_SNOOP = 1<<11,/* Enable No Snoop */
79 PEX_DC_EN_AUX_POW = 1<<10,/* Enable AUX Power */
80 PEX_DC_EN_PHANTOM = 1<<9, /* Enable Phantom Functions */
81 PEX_DC_EN_EXT_TAG = 1<<8, /* Enable Extended Tag Field */
82 PEX_DC_MAX_PLS_MSK = 7<<5, /* Bit 7.. 5: Max. Payload Size Mask */
83 PEX_DC_EN_REL_ORD = 1<<4, /* Enable Relaxed Ordering */
84 PEX_DC_EN_UNS_RQ_RP = 1<<3, /* Enable Unsupported Request Reporting */
85 PEX_DC_EN_FAT_ER_RP = 1<<2, /* Enable Fatal Error Reporting */
86 PEX_DC_EN_NFA_ER_RP = 1<<1, /* Enable Non-Fatal Error Reporting */
87 PEX_DC_EN_COR_ER_RP = 1<<0, /* Enable Correctable Error Reporting */
88};
89#define PEX_DC_MAX_RD_RQ_SIZE(x) (((x)<<12) & PEX_DC_MAX_RRS_MSK)
90
91/* PEX_UNC_ERR_STAT PEX Uncorrectable Errors Status Register (Yukon-2) */
92enum pex_err {
93 PEX_UNSUP_REQ = 1<<20, /* Unsupported Request Error */
94
95 PEX_MALFOR_TLP = 1<<18, /* Malformed TLP */
96
97 PEX_UNEXP_COMP = 1<<16, /* Unexpected Completion */
98
99 PEX_COMP_TO = 1<<14, /* Completion Timeout */
100 PEX_FLOW_CTRL_P = 1<<13, /* Flow Control Protocol Error */
101 PEX_POIS_TLP = 1<<12, /* Poisoned TLP */
102
103 PEX_DATA_LINK_P = 1<<4, /* Data Link Protocol Error */
104 PEX_FATAL_ERRORS= (PEX_MALFOR_TLP | PEX_FLOW_CTRL_P | PEX_DATA_LINK_P),
105};
106
107
66enum csr_regs { 108enum csr_regs {
67 B0_RAP = 0x0000, 109 B0_RAP = 0x0000,
68 B0_CTST = 0x0004, 110 B0_CTST = 0x0004,
@@ -1534,7 +1576,7 @@ enum {
1534 1576
1535 GMR_FS_ANY_ERR = GMR_FS_RX_FF_OV | GMR_FS_CRC_ERR | 1577 GMR_FS_ANY_ERR = GMR_FS_RX_FF_OV | GMR_FS_CRC_ERR |
1536 GMR_FS_FRAGMENT | GMR_FS_LONG_ERR | 1578 GMR_FS_FRAGMENT | GMR_FS_LONG_ERR |
1537 GMR_FS_MII_ERR | GMR_FS_BAD_FC | 1579 GMR_FS_MII_ERR | GMR_FS_GOOD_FC | GMR_FS_BAD_FC |
1538 GMR_FS_UN_SIZE | GMR_FS_JABBER, 1580 GMR_FS_UN_SIZE | GMR_FS_JABBER,
1539}; 1581};
1540 1582
@@ -1786,6 +1828,13 @@ struct rx_ring_info {
1786 dma_addr_t frag_addr[ETH_JUMBO_MTU >> PAGE_SHIFT]; 1828 dma_addr_t frag_addr[ETH_JUMBO_MTU >> PAGE_SHIFT];
1787}; 1829};
1788 1830
1831enum flow_control {
1832 FC_NONE = 0,
1833 FC_TX = 1,
1834 FC_RX = 2,
1835 FC_BOTH = 3,
1836};
1837
1789struct sky2_port { 1838struct sky2_port {
1790 struct sky2_hw *hw; 1839 struct sky2_hw *hw;
1791 struct net_device *netdev; 1840 struct net_device *netdev;
@@ -1818,13 +1867,13 @@ struct sky2_port {
1818 1867
1819 dma_addr_t rx_le_map; 1868 dma_addr_t rx_le_map;
1820 dma_addr_t tx_le_map; 1869 dma_addr_t tx_le_map;
1821 u32 advertising; /* ADVERTISED_ bits */ 1870 u16 advertising; /* ADVERTISED_ bits */
1822 u16 speed; /* SPEED_1000, SPEED_100, ... */ 1871 u16 speed; /* SPEED_1000, SPEED_100, ... */
1823 u8 autoneg; /* AUTONEG_ENABLE, AUTONEG_DISABLE */ 1872 u8 autoneg; /* AUTONEG_ENABLE, AUTONEG_DISABLE */
1824 u8 duplex; /* DUPLEX_HALF, DUPLEX_FULL */ 1873 u8 duplex; /* DUPLEX_HALF, DUPLEX_FULL */
1825 u8 rx_pause;
1826 u8 tx_pause;
1827 u8 rx_csum; 1874 u8 rx_csum;
1875 enum flow_control flow_mode;
1876 enum flow_control flow_status;
1828 1877
1829 struct net_device_stats net_stats; 1878 struct net_device_stats net_stats;
1830 1879
@@ -1836,7 +1885,6 @@ struct sky2_hw {
1836 struct net_device *dev[2]; 1885 struct net_device *dev[2];
1837 1886
1838 int pm_cap; 1887 int pm_cap;
1839 int err_cap;
1840 u8 chip_id; 1888 u8 chip_id;
1841 u8 chip_rev; 1889 u8 chip_rev;
1842 u8 pmd_type; 1890 u8 pmd_type;
diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h
index 636dbfcdf8cb..a8640169fc77 100644
--- a/drivers/net/smc91x.h
+++ b/drivers/net/smc91x.h
@@ -398,6 +398,42 @@ static inline void LPD7_SMC_outsw (unsigned char* a, int r,
398 398
399#define SMC_IRQ_FLAGS (0) 399#define SMC_IRQ_FLAGS (0)
400 400
401#elif defined(CONFIG_ARCH_VERSATILE)
402
403#define SMC_CAN_USE_8BIT 1
404#define SMC_CAN_USE_16BIT 1
405#define SMC_CAN_USE_32BIT 1
406#define SMC_NOWAIT 1
407
408#define SMC_inb(a, r) readb((a) + (r))
409#define SMC_inw(a, r) readw((a) + (r))
410#define SMC_inl(a, r) readl((a) + (r))
411#define SMC_outb(v, a, r) writeb(v, (a) + (r))
412#define SMC_outw(v, a, r) writew(v, (a) + (r))
413#define SMC_outl(v, a, r) writel(v, (a) + (r))
414#define SMC_insl(a, r, p, l) readsl((a) + (r), p, l)
415#define SMC_outsl(a, r, p, l) writesl((a) + (r), p, l)
416
417#define SMC_IRQ_FLAGS (0)
418
419#elif defined(CONFIG_ARCH_VERSATILE)
420
421#define SMC_CAN_USE_8BIT 1
422#define SMC_CAN_USE_16BIT 1
423#define SMC_CAN_USE_32BIT 1
424#define SMC_NOWAIT 1
425
426#define SMC_inb(a, r) readb((a) + (r))
427#define SMC_inw(a, r) readw((a) + (r))
428#define SMC_inl(a, r) readl((a) + (r))
429#define SMC_outb(v, a, r) writeb(v, (a) + (r))
430#define SMC_outw(v, a, r) writew(v, (a) + (r))
431#define SMC_outl(v, a, r) writel(v, (a) + (r))
432#define SMC_insl(a, r, p, l) readsl((a) + (r), p, l)
433#define SMC_outsl(a, r, p, l) writesl((a) + (r), p, l)
434
435#define SMC_IRQ_FLAGS (0)
436
401#else 437#else
402 438
403#define SMC_CAN_USE_8BIT 1 439#define SMC_CAN_USE_8BIT 1
diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c
index 46a009085f7c..418138dd6c68 100644
--- a/drivers/net/spider_net.c
+++ b/drivers/net/spider_net.c
@@ -55,12 +55,13 @@ MODULE_AUTHOR("Utz Bacher <utz.bacher@de.ibm.com> and Jens Osterkamp " \
55 "<Jens.Osterkamp@de.ibm.com>"); 55 "<Jens.Osterkamp@de.ibm.com>");
56MODULE_DESCRIPTION("Spider Southbridge Gigabit Ethernet driver"); 56MODULE_DESCRIPTION("Spider Southbridge Gigabit Ethernet driver");
57MODULE_LICENSE("GPL"); 57MODULE_LICENSE("GPL");
58MODULE_VERSION(VERSION);
58 59
59static int rx_descriptors = SPIDER_NET_RX_DESCRIPTORS_DEFAULT; 60static int rx_descriptors = SPIDER_NET_RX_DESCRIPTORS_DEFAULT;
60static int tx_descriptors = SPIDER_NET_TX_DESCRIPTORS_DEFAULT; 61static int tx_descriptors = SPIDER_NET_TX_DESCRIPTORS_DEFAULT;
61 62
62module_param(rx_descriptors, int, 0644); 63module_param(rx_descriptors, int, 0444);
63module_param(tx_descriptors, int, 0644); 64module_param(tx_descriptors, int, 0444);
64 65
65MODULE_PARM_DESC(rx_descriptors, "number of descriptors used " \ 66MODULE_PARM_DESC(rx_descriptors, "number of descriptors used " \
66 "in rx chains"); 67 "in rx chains");
@@ -300,7 +301,7 @@ static int
300spider_net_init_chain(struct spider_net_card *card, 301spider_net_init_chain(struct spider_net_card *card,
301 struct spider_net_descr_chain *chain, 302 struct spider_net_descr_chain *chain,
302 struct spider_net_descr *start_descr, 303 struct spider_net_descr *start_descr,
303 int direction, int no) 304 int no)
304{ 305{
305 int i; 306 int i;
306 struct spider_net_descr *descr; 307 struct spider_net_descr *descr;
@@ -315,7 +316,7 @@ spider_net_init_chain(struct spider_net_card *card,
315 316
316 buf = pci_map_single(card->pdev, descr, 317 buf = pci_map_single(card->pdev, descr,
317 SPIDER_NET_DESCR_SIZE, 318 SPIDER_NET_DESCR_SIZE,
318 direction); 319 PCI_DMA_BIDIRECTIONAL);
319 320
320 if (pci_dma_mapping_error(buf)) 321 if (pci_dma_mapping_error(buf))
321 goto iommu_error; 322 goto iommu_error;
@@ -329,11 +330,6 @@ spider_net_init_chain(struct spider_net_card *card,
329 (descr-1)->next = start_descr; 330 (descr-1)->next = start_descr;
330 start_descr->prev = descr-1; 331 start_descr->prev = descr-1;
331 332
332 descr = start_descr;
333 if (direction == PCI_DMA_FROMDEVICE)
334 for (i=0; i < no; i++, descr++)
335 descr->next_descr_addr = descr->next->bus_addr;
336
337 spin_lock_init(&chain->lock); 333 spin_lock_init(&chain->lock);
338 chain->head = start_descr; 334 chain->head = start_descr;
339 chain->tail = start_descr; 335 chain->tail = start_descr;
@@ -346,7 +342,7 @@ iommu_error:
346 if (descr->bus_addr) 342 if (descr->bus_addr)
347 pci_unmap_single(card->pdev, descr->bus_addr, 343 pci_unmap_single(card->pdev, descr->bus_addr,
348 SPIDER_NET_DESCR_SIZE, 344 SPIDER_NET_DESCR_SIZE,
349 direction); 345 PCI_DMA_BIDIRECTIONAL);
350 return -ENOMEM; 346 return -ENOMEM;
351} 347}
352 348
@@ -362,15 +358,15 @@ spider_net_free_rx_chain_contents(struct spider_net_card *card)
362 struct spider_net_descr *descr; 358 struct spider_net_descr *descr;
363 359
364 descr = card->rx_chain.head; 360 descr = card->rx_chain.head;
365 while (descr->next != card->rx_chain.head) { 361 do {
366 if (descr->skb) { 362 if (descr->skb) {
367 dev_kfree_skb(descr->skb); 363 dev_kfree_skb(descr->skb);
368 pci_unmap_single(card->pdev, descr->buf_addr, 364 pci_unmap_single(card->pdev, descr->buf_addr,
369 SPIDER_NET_MAX_FRAME, 365 SPIDER_NET_MAX_FRAME,
370 PCI_DMA_FROMDEVICE); 366 PCI_DMA_BIDIRECTIONAL);
371 } 367 }
372 descr = descr->next; 368 descr = descr->next;
373 } 369 } while (descr != card->rx_chain.head);
374} 370}
375 371
376/** 372/**
@@ -645,26 +641,41 @@ static int
645spider_net_prepare_tx_descr(struct spider_net_card *card, 641spider_net_prepare_tx_descr(struct spider_net_card *card,
646 struct sk_buff *skb) 642 struct sk_buff *skb)
647{ 643{
648 struct spider_net_descr *descr = card->tx_chain.head; 644 struct spider_net_descr *descr;
649 dma_addr_t buf; 645 dma_addr_t buf;
646 unsigned long flags;
647 int length;
650 648
651 buf = pci_map_single(card->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); 649 length = skb->len;
650 if (length < ETH_ZLEN) {
651 if (skb_pad(skb, ETH_ZLEN-length))
652 return 0;
653 length = ETH_ZLEN;
654 }
655
656 buf = pci_map_single(card->pdev, skb->data, length, PCI_DMA_TODEVICE);
652 if (pci_dma_mapping_error(buf)) { 657 if (pci_dma_mapping_error(buf)) {
653 if (netif_msg_tx_err(card) && net_ratelimit()) 658 if (netif_msg_tx_err(card) && net_ratelimit())
654 pr_err("could not iommu-map packet (%p, %i). " 659 pr_err("could not iommu-map packet (%p, %i). "
655 "Dropping packet\n", skb->data, skb->len); 660 "Dropping packet\n", skb->data, length);
656 card->spider_stats.tx_iommu_map_error++; 661 card->spider_stats.tx_iommu_map_error++;
657 return -ENOMEM; 662 return -ENOMEM;
658 } 663 }
659 664
665 spin_lock_irqsave(&card->tx_chain.lock, flags);
666 descr = card->tx_chain.head;
667 card->tx_chain.head = descr->next;
668
660 descr->buf_addr = buf; 669 descr->buf_addr = buf;
661 descr->buf_size = skb->len; 670 descr->buf_size = length;
662 descr->next_descr_addr = 0; 671 descr->next_descr_addr = 0;
663 descr->skb = skb; 672 descr->skb = skb;
664 descr->data_status = 0; 673 descr->data_status = 0;
665 674
666 descr->dmac_cmd_status = 675 descr->dmac_cmd_status =
667 SPIDER_NET_DESCR_CARDOWNED | SPIDER_NET_DMAC_NOCS; 676 SPIDER_NET_DESCR_CARDOWNED | SPIDER_NET_DMAC_NOCS;
677 spin_unlock_irqrestore(&card->tx_chain.lock, flags);
678
668 if (skb->protocol == htons(ETH_P_IP)) 679 if (skb->protocol == htons(ETH_P_IP))
669 switch (skb->nh.iph->protocol) { 680 switch (skb->nh.iph->protocol) {
670 case IPPROTO_TCP: 681 case IPPROTO_TCP:
@@ -675,32 +686,51 @@ spider_net_prepare_tx_descr(struct spider_net_card *card,
675 break; 686 break;
676 } 687 }
677 688
689 /* Chain the bus address, so that the DMA engine finds this descr. */
678 descr->prev->next_descr_addr = descr->bus_addr; 690 descr->prev->next_descr_addr = descr->bus_addr;
679 691
692 card->netdev->trans_start = jiffies; /* set netdev watchdog timer */
680 return 0; 693 return 0;
681} 694}
682 695
683/** 696static int
684 * spider_net_release_tx_descr - processes a used tx descriptor 697spider_net_set_low_watermark(struct spider_net_card *card)
685 * @card: card structure
686 * @descr: descriptor to release
687 *
688 * releases a used tx descriptor (unmapping, freeing of skb)
689 */
690static inline void
691spider_net_release_tx_descr(struct spider_net_card *card)
692{ 698{
699 unsigned long flags;
700 int status;
701 int cnt=0;
702 int i;
693 struct spider_net_descr *descr = card->tx_chain.tail; 703 struct spider_net_descr *descr = card->tx_chain.tail;
694 struct sk_buff *skb;
695 704
696 card->tx_chain.tail = card->tx_chain.tail->next; 705 /* Measure the length of the queue. Measurement does not
697 descr->dmac_cmd_status |= SPIDER_NET_DESCR_NOT_IN_USE; 706 * need to be precise -- does not need a lock. */
707 while (descr != card->tx_chain.head) {
708 status = descr->dmac_cmd_status & SPIDER_NET_DESCR_NOT_IN_USE;
709 if (status == SPIDER_NET_DESCR_NOT_IN_USE)
710 break;
711 descr = descr->next;
712 cnt++;
713 }
698 714
699 /* unmap the skb */ 715 /* If TX queue is short, don't even bother with interrupts */
700 skb = descr->skb; 716 if (cnt < card->num_tx_desc/4)
701 pci_unmap_single(card->pdev, descr->buf_addr, skb->len, 717 return cnt;
702 PCI_DMA_TODEVICE); 718
703 dev_kfree_skb_any(skb); 719 /* Set low-watermark 3/4th's of the way into the queue. */
720 descr = card->tx_chain.tail;
721 cnt = (cnt*3)/4;
722 for (i=0;i<cnt; i++)
723 descr = descr->next;
724
725 /* Set the new watermark, clear the old watermark */
726 spin_lock_irqsave(&card->tx_chain.lock, flags);
727 descr->dmac_cmd_status |= SPIDER_NET_DESCR_TXDESFLG;
728 if (card->low_watermark && card->low_watermark != descr)
729 card->low_watermark->dmac_cmd_status =
730 card->low_watermark->dmac_cmd_status & ~SPIDER_NET_DESCR_TXDESFLG;
731 card->low_watermark = descr;
732 spin_unlock_irqrestore(&card->tx_chain.lock, flags);
733 return cnt;
704} 734}
705 735
706/** 736/**
@@ -719,21 +749,29 @@ static int
719spider_net_release_tx_chain(struct spider_net_card *card, int brutal) 749spider_net_release_tx_chain(struct spider_net_card *card, int brutal)
720{ 750{
721 struct spider_net_descr_chain *chain = &card->tx_chain; 751 struct spider_net_descr_chain *chain = &card->tx_chain;
752 struct spider_net_descr *descr;
753 struct sk_buff *skb;
754 u32 buf_addr;
755 unsigned long flags;
722 int status; 756 int status;
723 757
724 spider_net_read_reg(card, SPIDER_NET_GDTDMACCNTR);
725
726 while (chain->tail != chain->head) { 758 while (chain->tail != chain->head) {
727 status = spider_net_get_descr_status(chain->tail); 759 spin_lock_irqsave(&chain->lock, flags);
760 descr = chain->tail;
761
762 status = spider_net_get_descr_status(descr);
728 switch (status) { 763 switch (status) {
729 case SPIDER_NET_DESCR_COMPLETE: 764 case SPIDER_NET_DESCR_COMPLETE:
730 card->netdev_stats.tx_packets++; 765 card->netdev_stats.tx_packets++;
731 card->netdev_stats.tx_bytes += chain->tail->skb->len; 766 card->netdev_stats.tx_bytes += descr->skb->len;
732 break; 767 break;
733 768
734 case SPIDER_NET_DESCR_CARDOWNED: 769 case SPIDER_NET_DESCR_CARDOWNED:
735 if (!brutal) 770 if (!brutal) {
771 spin_unlock_irqrestore(&chain->lock, flags);
736 return 1; 772 return 1;
773 }
774
737 /* fallthrough, if we release the descriptors 775 /* fallthrough, if we release the descriptors
738 * brutally (then we don't care about 776 * brutally (then we don't care about
739 * SPIDER_NET_DESCR_CARDOWNED) */ 777 * SPIDER_NET_DESCR_CARDOWNED) */
@@ -750,11 +788,25 @@ spider_net_release_tx_chain(struct spider_net_card *card, int brutal)
750 788
751 default: 789 default:
752 card->netdev_stats.tx_dropped++; 790 card->netdev_stats.tx_dropped++;
753 return 1; 791 if (!brutal) {
792 spin_unlock_irqrestore(&chain->lock, flags);
793 return 1;
794 }
754 } 795 }
755 spider_net_release_tx_descr(card);
756 }
757 796
797 chain->tail = descr->next;
798 descr->dmac_cmd_status |= SPIDER_NET_DESCR_NOT_IN_USE;
799 skb = descr->skb;
800 buf_addr = descr->buf_addr;
801 spin_unlock_irqrestore(&chain->lock, flags);
802
803 /* unmap the skb */
804 if (skb) {
805 int len = skb->len < ETH_ZLEN ? ETH_ZLEN : skb->len;
806 pci_unmap_single(card->pdev, buf_addr, len, PCI_DMA_TODEVICE);
807 dev_kfree_skb(skb);
808 }
809 }
758 return 0; 810 return 0;
759} 811}
760 812
@@ -763,8 +815,12 @@ spider_net_release_tx_chain(struct spider_net_card *card, int brutal)
763 * @card: card structure 815 * @card: card structure
764 * @descr: descriptor address to enable TX processing at 816 * @descr: descriptor address to enable TX processing at
765 * 817 *
766 * spider_net_kick_tx_dma writes the current tx chain head as start address 818 * This routine will start the transmit DMA running if
767 * of the tx descriptor chain and enables the transmission DMA engine 819 * it is not already running. This routine ned only be
820 * called when queueing a new packet to an empty tx queue.
821 * Writes the current tx chain head as start address
822 * of the tx descriptor chain and enables the transmission
823 * DMA engine.
768 */ 824 */
769static inline void 825static inline void
770spider_net_kick_tx_dma(struct spider_net_card *card) 826spider_net_kick_tx_dma(struct spider_net_card *card)
@@ -804,65 +860,43 @@ out:
804static int 860static int
805spider_net_xmit(struct sk_buff *skb, struct net_device *netdev) 861spider_net_xmit(struct sk_buff *skb, struct net_device *netdev)
806{ 862{
863 int cnt;
807 struct spider_net_card *card = netdev_priv(netdev); 864 struct spider_net_card *card = netdev_priv(netdev);
808 struct spider_net_descr_chain *chain = &card->tx_chain; 865 struct spider_net_descr_chain *chain = &card->tx_chain;
809 struct spider_net_descr *descr = chain->head;
810 unsigned long flags;
811 int result;
812
813 spin_lock_irqsave(&chain->lock, flags);
814 866
815 spider_net_release_tx_chain(card, 0); 867 spider_net_release_tx_chain(card, 0);
816 868
817 if (chain->head->next == chain->tail->prev) { 869 if ((chain->head->next == chain->tail->prev) ||
818 card->netdev_stats.tx_dropped++; 870 (spider_net_prepare_tx_descr(card, skb) != 0)) {
819 result = NETDEV_TX_LOCKED;
820 goto out;
821 }
822 871
823 if (spider_net_get_descr_status(descr) != SPIDER_NET_DESCR_NOT_IN_USE) {
824 card->netdev_stats.tx_dropped++; 872 card->netdev_stats.tx_dropped++;
825 result = NETDEV_TX_LOCKED; 873 netif_stop_queue(netdev);
826 goto out; 874 return NETDEV_TX_BUSY;
827 } 875 }
828 876
829 if (spider_net_prepare_tx_descr(card, skb) != 0) { 877 cnt = spider_net_set_low_watermark(card);
830 card->netdev_stats.tx_dropped++; 878 if (cnt < 5)
831 result = NETDEV_TX_BUSY; 879 spider_net_kick_tx_dma(card);
832 goto out; 880 return NETDEV_TX_OK;
833 }
834
835 result = NETDEV_TX_OK;
836
837 spider_net_kick_tx_dma(card);
838 card->tx_chain.head = card->tx_chain.head->next;
839
840out:
841 spin_unlock_irqrestore(&chain->lock, flags);
842 netif_wake_queue(netdev);
843 return result;
844} 881}
845 882
846/** 883/**
847 * spider_net_cleanup_tx_ring - cleans up the TX ring 884 * spider_net_cleanup_tx_ring - cleans up the TX ring
848 * @card: card structure 885 * @card: card structure
849 * 886 *
850 * spider_net_cleanup_tx_ring is called by the tx_timer (as we don't use 887 * spider_net_cleanup_tx_ring is called by either the tx_timer
851 * interrupts to cleanup our TX ring) and returns sent packets to the stack 888 * or from the NAPI polling routine.
852 * by freeing them 889 * This routine releases resources associted with transmitted
890 * packets, including updating the queue tail pointer.
853 */ 891 */
854static void 892static void
855spider_net_cleanup_tx_ring(struct spider_net_card *card) 893spider_net_cleanup_tx_ring(struct spider_net_card *card)
856{ 894{
857 unsigned long flags;
858
859 spin_lock_irqsave(&card->tx_chain.lock, flags);
860
861 if ((spider_net_release_tx_chain(card, 0) != 0) && 895 if ((spider_net_release_tx_chain(card, 0) != 0) &&
862 (card->netdev->flags & IFF_UP)) 896 (card->netdev->flags & IFF_UP)) {
863 spider_net_kick_tx_dma(card); 897 spider_net_kick_tx_dma(card);
864 898 netif_wake_queue(card->netdev);
865 spin_unlock_irqrestore(&card->tx_chain.lock, flags); 899 }
866} 900}
867 901
868/** 902/**
@@ -1053,6 +1087,7 @@ spider_net_poll(struct net_device *netdev, int *budget)
1053 int packets_to_do, packets_done = 0; 1087 int packets_to_do, packets_done = 0;
1054 int no_more_packets = 0; 1088 int no_more_packets = 0;
1055 1089
1090 spider_net_cleanup_tx_ring(card);
1056 packets_to_do = min(*budget, netdev->quota); 1091 packets_to_do = min(*budget, netdev->quota);
1057 1092
1058 while (packets_to_do) { 1093 while (packets_to_do) {
@@ -1243,12 +1278,15 @@ spider_net_handle_error_irq(struct spider_net_card *card, u32 status_reg)
1243 case SPIDER_NET_PHYINT: 1278 case SPIDER_NET_PHYINT:
1244 case SPIDER_NET_GMAC2INT: 1279 case SPIDER_NET_GMAC2INT:
1245 case SPIDER_NET_GMAC1INT: 1280 case SPIDER_NET_GMAC1INT:
1246 case SPIDER_NET_GIPSINT:
1247 case SPIDER_NET_GFIFOINT: 1281 case SPIDER_NET_GFIFOINT:
1248 case SPIDER_NET_DMACINT: 1282 case SPIDER_NET_DMACINT:
1249 case SPIDER_NET_GSYSINT: 1283 case SPIDER_NET_GSYSINT:
1250 break; */ 1284 break; */
1251 1285
1286 case SPIDER_NET_GIPSINT:
1287 show_error = 0;
1288 break;
1289
1252 case SPIDER_NET_GPWOPCMPINT: 1290 case SPIDER_NET_GPWOPCMPINT:
1253 /* PHY write operation completed */ 1291 /* PHY write operation completed */
1254 show_error = 0; 1292 show_error = 0;
@@ -1307,9 +1345,10 @@ spider_net_handle_error_irq(struct spider_net_card *card, u32 status_reg)
1307 case SPIDER_NET_GDTDCEINT: 1345 case SPIDER_NET_GDTDCEINT:
1308 /* chain end. If a descriptor should be sent, kick off 1346 /* chain end. If a descriptor should be sent, kick off
1309 * tx dma 1347 * tx dma
1310 if (card->tx_chain.tail == card->tx_chain.head) 1348 if (card->tx_chain.tail != card->tx_chain.head)
1311 spider_net_kick_tx_dma(card); 1349 spider_net_kick_tx_dma(card);
1312 show_error = 0; */ 1350 */
1351 show_error = 0;
1313 break; 1352 break;
1314 1353
1315 /* case SPIDER_NET_G1TMCNTINT: not used. print a message */ 1354 /* case SPIDER_NET_G1TMCNTINT: not used. print a message */
@@ -1354,7 +1393,7 @@ spider_net_handle_error_irq(struct spider_net_card *card, u32 status_reg)
1354 if (netif_msg_intr(card)) 1393 if (netif_msg_intr(card))
1355 pr_err("got descriptor chain end interrupt, " 1394 pr_err("got descriptor chain end interrupt, "
1356 "restarting DMAC %c.\n", 1395 "restarting DMAC %c.\n",
1357 'D'+i-SPIDER_NET_GDDDCEINT); 1396 'D'-(i-SPIDER_NET_GDDDCEINT)/3);
1358 spider_net_refill_rx_chain(card); 1397 spider_net_refill_rx_chain(card);
1359 spider_net_enable_rxdmac(card); 1398 spider_net_enable_rxdmac(card);
1360 show_error = 0; 1399 show_error = 0;
@@ -1423,8 +1462,9 @@ spider_net_handle_error_irq(struct spider_net_card *card, u32 status_reg)
1423 } 1462 }
1424 1463
1425 if ((show_error) && (netif_msg_intr(card))) 1464 if ((show_error) && (netif_msg_intr(card)))
1426 pr_err("Got error interrupt, GHIINT0STS = 0x%08x, " 1465 pr_err("Got error interrupt on %s, GHIINT0STS = 0x%08x, "
1427 "GHIINT1STS = 0x%08x, GHIINT2STS = 0x%08x\n", 1466 "GHIINT1STS = 0x%08x, GHIINT2STS = 0x%08x\n",
1467 card->netdev->name,
1428 status_reg, error_reg1, error_reg2); 1468 status_reg, error_reg1, error_reg2);
1429 1469
1430 /* clear interrupt sources */ 1470 /* clear interrupt sources */
@@ -1460,6 +1500,8 @@ spider_net_interrupt(int irq, void *ptr)
1460 spider_net_rx_irq_off(card); 1500 spider_net_rx_irq_off(card);
1461 netif_rx_schedule(netdev); 1501 netif_rx_schedule(netdev);
1462 } 1502 }
1503 if (status_reg & SPIDER_NET_TXINT)
1504 netif_rx_schedule(netdev);
1463 1505
1464 if (status_reg & SPIDER_NET_ERRINT ) 1506 if (status_reg & SPIDER_NET_ERRINT )
1465 spider_net_handle_error_irq(card, status_reg); 1507 spider_net_handle_error_irq(card, status_reg);
@@ -1599,7 +1641,7 @@ spider_net_enable_card(struct spider_net_card *card)
1599 SPIDER_NET_INT2_MASK_VALUE); 1641 SPIDER_NET_INT2_MASK_VALUE);
1600 1642
1601 spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR, 1643 spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR,
1602 SPIDER_NET_GDTDCEIDIS); 1644 SPIDER_NET_GDTBSTA | SPIDER_NET_GDTDCEIDIS);
1603} 1645}
1604 1646
1605/** 1647/**
@@ -1615,17 +1657,26 @@ int
1615spider_net_open(struct net_device *netdev) 1657spider_net_open(struct net_device *netdev)
1616{ 1658{
1617 struct spider_net_card *card = netdev_priv(netdev); 1659 struct spider_net_card *card = netdev_priv(netdev);
1618 int result; 1660 struct spider_net_descr *descr;
1661 int i, result;
1619 1662
1620 result = -ENOMEM; 1663 result = -ENOMEM;
1621 if (spider_net_init_chain(card, &card->tx_chain, card->descr, 1664 if (spider_net_init_chain(card, &card->tx_chain, card->descr,
1622 PCI_DMA_TODEVICE, card->tx_desc)) 1665 card->num_tx_desc))
1623 goto alloc_tx_failed; 1666 goto alloc_tx_failed;
1667
1668 card->low_watermark = NULL;
1669
1670 /* rx_chain is after tx_chain, so offset is descr + tx_count */
1624 if (spider_net_init_chain(card, &card->rx_chain, 1671 if (spider_net_init_chain(card, &card->rx_chain,
1625 card->descr + card->rx_desc, 1672 card->descr + card->num_tx_desc,
1626 PCI_DMA_FROMDEVICE, card->rx_desc)) 1673 card->num_rx_desc))
1627 goto alloc_rx_failed; 1674 goto alloc_rx_failed;
1628 1675
1676 descr = card->rx_chain.head;
1677 for (i=0; i < card->num_rx_desc; i++, descr++)
1678 descr->next_descr_addr = descr->next->bus_addr;
1679
1629 /* allocate rx skbs */ 1680 /* allocate rx skbs */
1630 if (spider_net_alloc_rx_skbs(card)) 1681 if (spider_net_alloc_rx_skbs(card))
1631 goto alloc_skbs_failed; 1682 goto alloc_skbs_failed;
@@ -1878,10 +1929,7 @@ spider_net_stop(struct net_device *netdev)
1878 spider_net_disable_rxdmac(card); 1929 spider_net_disable_rxdmac(card);
1879 1930
1880 /* release chains */ 1931 /* release chains */
1881 if (spin_trylock(&card->tx_chain.lock)) { 1932 spider_net_release_tx_chain(card, 1);
1882 spider_net_release_tx_chain(card, 1);
1883 spin_unlock(&card->tx_chain.lock);
1884 }
1885 1933
1886 spider_net_free_chain(card, &card->tx_chain); 1934 spider_net_free_chain(card, &card->tx_chain);
1887 spider_net_free_chain(card, &card->rx_chain); 1935 spider_net_free_chain(card, &card->rx_chain);
@@ -2012,8 +2060,8 @@ spider_net_setup_netdev(struct spider_net_card *card)
2012 2060
2013 card->options.rx_csum = SPIDER_NET_RX_CSUM_DEFAULT; 2061 card->options.rx_csum = SPIDER_NET_RX_CSUM_DEFAULT;
2014 2062
2015 card->tx_desc = tx_descriptors; 2063 card->num_tx_desc = tx_descriptors;
2016 card->rx_desc = rx_descriptors; 2064 card->num_rx_desc = rx_descriptors;
2017 2065
2018 spider_net_setup_netdev_ops(netdev); 2066 spider_net_setup_netdev_ops(netdev);
2019 2067
@@ -2252,6 +2300,8 @@ static struct pci_driver spider_net_driver = {
2252 */ 2300 */
2253static int __init spider_net_init(void) 2301static int __init spider_net_init(void)
2254{ 2302{
2303 printk(KERN_INFO "Spidernet version %s.\n", VERSION);
2304
2255 if (rx_descriptors < SPIDER_NET_RX_DESCRIPTORS_MIN) { 2305 if (rx_descriptors < SPIDER_NET_RX_DESCRIPTORS_MIN) {
2256 rx_descriptors = SPIDER_NET_RX_DESCRIPTORS_MIN; 2306 rx_descriptors = SPIDER_NET_RX_DESCRIPTORS_MIN;
2257 pr_info("adjusting rx descriptors to %i.\n", rx_descriptors); 2307 pr_info("adjusting rx descriptors to %i.\n", rx_descriptors);
diff --git a/drivers/net/spider_net.h b/drivers/net/spider_net.h
index a59deda2f95e..b3b46119b424 100644
--- a/drivers/net/spider_net.h
+++ b/drivers/net/spider_net.h
@@ -24,6 +24,8 @@
24#ifndef _SPIDER_NET_H 24#ifndef _SPIDER_NET_H
25#define _SPIDER_NET_H 25#define _SPIDER_NET_H
26 26
27#define VERSION "1.1 A"
28
27#include "sungem_phy.h" 29#include "sungem_phy.h"
28 30
29extern int spider_net_stop(struct net_device *netdev); 31extern int spider_net_stop(struct net_device *netdev);
@@ -47,7 +49,7 @@ extern char spider_net_driver_name[];
47#define SPIDER_NET_TX_DESCRIPTORS_MIN 16 49#define SPIDER_NET_TX_DESCRIPTORS_MIN 16
48#define SPIDER_NET_TX_DESCRIPTORS_MAX 512 50#define SPIDER_NET_TX_DESCRIPTORS_MAX 512
49 51
50#define SPIDER_NET_TX_TIMER 20 52#define SPIDER_NET_TX_TIMER (HZ/5)
51 53
52#define SPIDER_NET_RX_CSUM_DEFAULT 1 54#define SPIDER_NET_RX_CSUM_DEFAULT 1
53 55
@@ -189,7 +191,9 @@ extern char spider_net_driver_name[];
189#define SPIDER_NET_MACMODE_VALUE 0x00000001 191#define SPIDER_NET_MACMODE_VALUE 0x00000001
190#define SPIDER_NET_BURSTLMT_VALUE 0x00000200 /* about 16 us */ 192#define SPIDER_NET_BURSTLMT_VALUE 0x00000200 /* about 16 us */
191 193
192/* 1(0) enable r/tx dma 194/* DMAC control register GDMACCNTR
195 *
196 * 1(0) enable r/tx dma
193 * 0000000 fixed to 0 197 * 0000000 fixed to 0
194 * 198 *
195 * 000000 fixed to 0 199 * 000000 fixed to 0
@@ -198,6 +202,7 @@ extern char spider_net_driver_name[];
198 * 202 *
199 * 000000 fixed to 0 203 * 000000 fixed to 0
200 * 00 burst alignment: 128 bytes 204 * 00 burst alignment: 128 bytes
205 * 11 burst alignment: 1024 bytes
201 * 206 *
202 * 00000 fixed to 0 207 * 00000 fixed to 0
203 * 0 descr writeback size 32 bytes 208 * 0 descr writeback size 32 bytes
@@ -208,10 +213,13 @@ extern char spider_net_driver_name[];
208#define SPIDER_NET_DMA_RX_VALUE 0x80000000 213#define SPIDER_NET_DMA_RX_VALUE 0x80000000
209#define SPIDER_NET_DMA_RX_FEND_VALUE 0x00030003 214#define SPIDER_NET_DMA_RX_FEND_VALUE 0x00030003
210/* to set TX_DMA_EN */ 215/* to set TX_DMA_EN */
211#define SPIDER_NET_TX_DMA_EN 0x80000000 216#define SPIDER_NET_TX_DMA_EN 0x80000000
212#define SPIDER_NET_GDTDCEIDIS 0x00000002 217#define SPIDER_NET_GDTBSTA 0x00000300
213#define SPIDER_NET_DMA_TX_VALUE SPIDER_NET_TX_DMA_EN | \ 218#define SPIDER_NET_GDTDCEIDIS 0x00000002
214 SPIDER_NET_GDTDCEIDIS 219#define SPIDER_NET_DMA_TX_VALUE SPIDER_NET_TX_DMA_EN | \
220 SPIDER_NET_GDTBSTA | \
221 SPIDER_NET_GDTDCEIDIS
222
215#define SPIDER_NET_DMA_TX_FEND_VALUE 0x00030003 223#define SPIDER_NET_DMA_TX_FEND_VALUE 0x00030003
216 224
217/* SPIDER_NET_UA_DESCR_VALUE is OR'ed with the unicast address */ 225/* SPIDER_NET_UA_DESCR_VALUE is OR'ed with the unicast address */
@@ -320,13 +328,10 @@ enum spider_net_int2_status {
320 SPIDER_NET_GRISPDNGINT 328 SPIDER_NET_GRISPDNGINT
321}; 329};
322 330
323#define SPIDER_NET_TXINT ( (1 << SPIDER_NET_GTTEDINT) | \ 331#define SPIDER_NET_TXINT ( (1 << SPIDER_NET_GDTFDCINT) )
324 (1 << SPIDER_NET_GDTDCEINT) | \
325 (1 << SPIDER_NET_GDTFDCINT) )
326 332
327/* we rely on flagged descriptor interrupts*/ 333/* We rely on flagged descriptor interrupts */
328#define SPIDER_NET_RXINT ( (1 << SPIDER_NET_GDAFDCINT) | \ 334#define SPIDER_NET_RXINT ( (1 << SPIDER_NET_GDAFDCINT) )
329 (1 << SPIDER_NET_GRMFLLINT) )
330 335
331#define SPIDER_NET_ERRINT ( 0xffffffff & \ 336#define SPIDER_NET_ERRINT ( 0xffffffff & \
332 (~SPIDER_NET_TXINT) & \ 337 (~SPIDER_NET_TXINT) & \
@@ -349,6 +354,7 @@ enum spider_net_int2_status {
349#define SPIDER_NET_DESCR_FORCE_END 0x50000000 /* used in rx and tx */ 354#define SPIDER_NET_DESCR_FORCE_END 0x50000000 /* used in rx and tx */
350#define SPIDER_NET_DESCR_CARDOWNED 0xA0000000 /* used in rx and tx */ 355#define SPIDER_NET_DESCR_CARDOWNED 0xA0000000 /* used in rx and tx */
351#define SPIDER_NET_DESCR_NOT_IN_USE 0xF0000000 356#define SPIDER_NET_DESCR_NOT_IN_USE 0xF0000000
357#define SPIDER_NET_DESCR_TXDESFLG 0x00800000
352 358
353struct spider_net_descr { 359struct spider_net_descr {
354 /* as defined by the hardware */ 360 /* as defined by the hardware */
@@ -433,6 +439,7 @@ struct spider_net_card {
433 439
434 struct spider_net_descr_chain tx_chain; 440 struct spider_net_descr_chain tx_chain;
435 struct spider_net_descr_chain rx_chain; 441 struct spider_net_descr_chain rx_chain;
442 struct spider_net_descr *low_watermark;
436 443
437 struct net_device_stats netdev_stats; 444 struct net_device_stats netdev_stats;
438 445
@@ -448,8 +455,8 @@ struct spider_net_card {
448 455
449 /* for ethtool */ 456 /* for ethtool */
450 int msg_enable; 457 int msg_enable;
451 int rx_desc; 458 int num_rx_desc;
452 int tx_desc; 459 int num_tx_desc;
453 struct spider_net_extra_stats spider_stats; 460 struct spider_net_extra_stats spider_stats;
454 461
455 struct spider_net_descr descr[0]; 462 struct spider_net_descr descr[0];
diff --git a/drivers/net/spider_net_ethtool.c b/drivers/net/spider_net_ethtool.c
index 589e43658dee..91b995102915 100644
--- a/drivers/net/spider_net_ethtool.c
+++ b/drivers/net/spider_net_ethtool.c
@@ -76,7 +76,7 @@ spider_net_ethtool_get_drvinfo(struct net_device *netdev,
76 /* clear and fill out info */ 76 /* clear and fill out info */
77 memset(drvinfo, 0, sizeof(struct ethtool_drvinfo)); 77 memset(drvinfo, 0, sizeof(struct ethtool_drvinfo));
78 strncpy(drvinfo->driver, spider_net_driver_name, 32); 78 strncpy(drvinfo->driver, spider_net_driver_name, 32);
79 strncpy(drvinfo->version, "0.1", 32); 79 strncpy(drvinfo->version, VERSION, 32);
80 strcpy(drvinfo->fw_version, "no information"); 80 strcpy(drvinfo->fw_version, "no information");
81 strncpy(drvinfo->bus_info, pci_name(card->pdev), 32); 81 strncpy(drvinfo->bus_info, pci_name(card->pdev), 32);
82} 82}
@@ -158,9 +158,9 @@ spider_net_ethtool_get_ringparam(struct net_device *netdev,
158 struct spider_net_card *card = netdev->priv; 158 struct spider_net_card *card = netdev->priv;
159 159
160 ering->tx_max_pending = SPIDER_NET_TX_DESCRIPTORS_MAX; 160 ering->tx_max_pending = SPIDER_NET_TX_DESCRIPTORS_MAX;
161 ering->tx_pending = card->tx_desc; 161 ering->tx_pending = card->num_tx_desc;
162 ering->rx_max_pending = SPIDER_NET_RX_DESCRIPTORS_MAX; 162 ering->rx_max_pending = SPIDER_NET_RX_DESCRIPTORS_MAX;
163 ering->rx_pending = card->rx_desc; 163 ering->rx_pending = card->num_rx_desc;
164} 164}
165 165
166static int spider_net_get_stats_count(struct net_device *netdev) 166static int spider_net_get_stats_count(struct net_device *netdev)
diff --git a/drivers/net/sun3_82586.c b/drivers/net/sun3_82586.c
index d1d1885b0295..a3220a96524f 100644
--- a/drivers/net/sun3_82586.c
+++ b/drivers/net/sun3_82586.c
@@ -330,7 +330,7 @@ out2:
330out1: 330out1:
331 free_netdev(dev); 331 free_netdev(dev);
332out: 332out:
333 iounmap((void *)ioaddr); 333 iounmap((void __iomem *)ioaddr);
334 return ERR_PTR(err); 334 return ERR_PTR(err);
335} 335}
336 336
diff --git a/drivers/net/sun3lance.c b/drivers/net/sun3lance.c
index 91c76544e4dd..b865db363ba0 100644
--- a/drivers/net/sun3lance.c
+++ b/drivers/net/sun3lance.c
@@ -286,7 +286,7 @@ struct net_device * __init sun3lance_probe(int unit)
286 286
287out1: 287out1:
288#ifdef CONFIG_SUN3 288#ifdef CONFIG_SUN3
289 iounmap((void *)dev->base_addr); 289 iounmap((void __iomem *)dev->base_addr);
290#endif 290#endif
291out: 291out:
292 free_netdev(dev); 292 free_netdev(dev);
@@ -326,7 +326,7 @@ static int __init lance_probe( struct net_device *dev)
326 ioaddr_probe[1] = tmp2; 326 ioaddr_probe[1] = tmp2;
327 327
328#ifdef CONFIG_SUN3 328#ifdef CONFIG_SUN3
329 iounmap((void *)ioaddr); 329 iounmap((void __iomem *)ioaddr);
330#endif 330#endif
331 return 0; 331 return 0;
332 } 332 }
@@ -956,7 +956,7 @@ void cleanup_module(void)
956{ 956{
957 unregister_netdev(sun3lance_dev); 957 unregister_netdev(sun3lance_dev);
958#ifdef CONFIG_SUN3 958#ifdef CONFIG_SUN3
959 iounmap((void *)sun3lance_dev->base_addr); 959 iounmap((void __iomem *)sun3lance_dev->base_addr);
960#endif 960#endif
961 free_netdev(sun3lance_dev); 961 free_netdev(sun3lance_dev);
962} 962}
diff --git a/drivers/net/sunbmac.c b/drivers/net/sunbmac.c
index 6439b0cef1e4..18f88853e1e5 100644
--- a/drivers/net/sunbmac.c
+++ b/drivers/net/sunbmac.c
@@ -42,7 +42,7 @@
42#define DRV_RELDATE "11/24/03" 42#define DRV_RELDATE "11/24/03"
43#define DRV_AUTHOR "David S. Miller (davem@redhat.com)" 43#define DRV_AUTHOR "David S. Miller (davem@redhat.com)"
44 44
45static char version[] __initdata = 45static char version[] =
46 DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n"; 46 DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n";
47 47
48MODULE_VERSION(DRV_VERSION); 48MODULE_VERSION(DRV_VERSION);
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 327836b1014e..c20bb998e0e5 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -68,8 +68,8 @@
68 68
69#define DRV_MODULE_NAME "tg3" 69#define DRV_MODULE_NAME "tg3"
70#define PFX DRV_MODULE_NAME ": " 70#define PFX DRV_MODULE_NAME ": "
71#define DRV_MODULE_VERSION "3.66" 71#define DRV_MODULE_VERSION "3.69"
72#define DRV_MODULE_RELDATE "September 23, 2006" 72#define DRV_MODULE_RELDATE "November 15, 2006"
73 73
74#define TG3_DEF_MAC_MODE 0 74#define TG3_DEF_MAC_MODE 0
75#define TG3_DEF_RX_MODE 0 75#define TG3_DEF_RX_MODE 0
@@ -129,7 +129,7 @@
129#define RX_JUMBO_PKT_BUF_SZ (9046 + tp->rx_offset + 64) 129#define RX_JUMBO_PKT_BUF_SZ (9046 + tp->rx_offset + 64)
130 130
131/* minimum number of free TX descriptors required to wake up TX process */ 131/* minimum number of free TX descriptors required to wake up TX process */
132#define TG3_TX_WAKEUP_THRESH (TG3_TX_RING_SIZE / 4) 132#define TG3_TX_WAKEUP_THRESH(tp) ((tp)->tx_pending / 4)
133 133
134/* number of ETHTOOL_GSTATS u64's */ 134/* number of ETHTOOL_GSTATS u64's */
135#define TG3_NUM_STATS (sizeof(struct tg3_ethtool_stats)/sizeof(u64)) 135#define TG3_NUM_STATS (sizeof(struct tg3_ethtool_stats)/sizeof(u64))
@@ -3075,10 +3075,10 @@ static void tg3_tx(struct tg3 *tp)
3075 smp_mb(); 3075 smp_mb();
3076 3076
3077 if (unlikely(netif_queue_stopped(tp->dev) && 3077 if (unlikely(netif_queue_stopped(tp->dev) &&
3078 (tg3_tx_avail(tp) > TG3_TX_WAKEUP_THRESH))) { 3078 (tg3_tx_avail(tp) > TG3_TX_WAKEUP_THRESH(tp)))) {
3079 netif_tx_lock(tp->dev); 3079 netif_tx_lock(tp->dev);
3080 if (netif_queue_stopped(tp->dev) && 3080 if (netif_queue_stopped(tp->dev) &&
3081 (tg3_tx_avail(tp) > TG3_TX_WAKEUP_THRESH)) 3081 (tg3_tx_avail(tp) > TG3_TX_WAKEUP_THRESH(tp)))
3082 netif_wake_queue(tp->dev); 3082 netif_wake_queue(tp->dev);
3083 netif_tx_unlock(tp->dev); 3083 netif_tx_unlock(tp->dev);
3084 } 3084 }
@@ -3928,7 +3928,7 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
3928 tp->tx_prod = entry; 3928 tp->tx_prod = entry;
3929 if (unlikely(tg3_tx_avail(tp) <= (MAX_SKB_FRAGS + 1))) { 3929 if (unlikely(tg3_tx_avail(tp) <= (MAX_SKB_FRAGS + 1))) {
3930 netif_stop_queue(dev); 3930 netif_stop_queue(dev);
3931 if (tg3_tx_avail(tp) > TG3_TX_WAKEUP_THRESH) 3931 if (tg3_tx_avail(tp) > TG3_TX_WAKEUP_THRESH(tp))
3932 netif_wake_queue(tp->dev); 3932 netif_wake_queue(tp->dev);
3933 } 3933 }
3934 3934
@@ -4143,7 +4143,7 @@ static int tg3_start_xmit_dma_bug(struct sk_buff *skb, struct net_device *dev)
4143 tp->tx_prod = entry; 4143 tp->tx_prod = entry;
4144 if (unlikely(tg3_tx_avail(tp) <= (MAX_SKB_FRAGS + 1))) { 4144 if (unlikely(tg3_tx_avail(tp) <= (MAX_SKB_FRAGS + 1))) {
4145 netif_stop_queue(dev); 4145 netif_stop_queue(dev);
4146 if (tg3_tx_avail(tp) > TG3_TX_WAKEUP_THRESH) 4146 if (tg3_tx_avail(tp) > TG3_TX_WAKEUP_THRESH(tp))
4147 netif_wake_queue(tp->dev); 4147 netif_wake_queue(tp->dev);
4148 } 4148 }
4149 4149
@@ -4728,10 +4728,11 @@ static int tg3_poll_fw(struct tg3 *tp)
4728 u32 val; 4728 u32 val;
4729 4729
4730 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) { 4730 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
4731 for (i = 0; i < 400; i++) { 4731 /* Wait up to 20ms for init done. */
4732 for (i = 0; i < 200; i++) {
4732 if (tr32(VCPU_STATUS) & VCPU_STATUS_INIT_DONE) 4733 if (tr32(VCPU_STATUS) & VCPU_STATUS_INIT_DONE)
4733 return 0; 4734 return 0;
4734 udelay(10); 4735 udelay(100);
4735 } 4736 }
4736 return -ENODEV; 4737 return -ENODEV;
4737 } 4738 }
@@ -6014,7 +6015,7 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
6014 tg3_abort_hw(tp, 1); 6015 tg3_abort_hw(tp, 1);
6015 } 6016 }
6016 6017
6017 if ((tp->tg3_flags2 & TG3_FLG2_MII_SERDES) && reset_phy) 6018 if (reset_phy)
6018 tg3_phy_reset(tp); 6019 tg3_phy_reset(tp);
6019 6020
6020 err = tg3_chip_reset(tp); 6021 err = tg3_chip_reset(tp);
@@ -6574,7 +6575,7 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
6574 tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl); 6575 tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl);
6575 } 6576 }
6576 6577
6577 err = tg3_setup_phy(tp, reset_phy); 6578 err = tg3_setup_phy(tp, 0);
6578 if (err) 6579 if (err)
6579 return err; 6580 return err;
6580 6581
@@ -6978,8 +6979,10 @@ static int tg3_open(struct net_device *dev)
6978 tg3_full_lock(tp, 0); 6979 tg3_full_lock(tp, 0);
6979 6980
6980 err = tg3_set_power_state(tp, PCI_D0); 6981 err = tg3_set_power_state(tp, PCI_D0);
6981 if (err) 6982 if (err) {
6983 tg3_full_unlock(tp);
6982 return err; 6984 return err;
6985 }
6983 6986
6984 tg3_disable_ints(tp); 6987 tg3_disable_ints(tp);
6985 tp->tg3_flags &= ~TG3_FLAG_INIT_COMPLETE; 6988 tp->tg3_flags &= ~TG3_FLAG_INIT_COMPLETE;
@@ -8106,7 +8109,10 @@ static int tg3_set_ringparam(struct net_device *dev, struct ethtool_ringparam *e
8106 8109
8107 if ((ering->rx_pending > TG3_RX_RING_SIZE - 1) || 8110 if ((ering->rx_pending > TG3_RX_RING_SIZE - 1) ||
8108 (ering->rx_jumbo_pending > TG3_RX_JUMBO_RING_SIZE - 1) || 8111 (ering->rx_jumbo_pending > TG3_RX_JUMBO_RING_SIZE - 1) ||
8109 (ering->tx_pending > TG3_TX_RING_SIZE - 1)) 8112 (ering->tx_pending > TG3_TX_RING_SIZE - 1) ||
8113 (ering->tx_pending <= MAX_SKB_FRAGS) ||
8114 ((tp->tg3_flags2 & TG3_FLG2_HW_TSO_1_BUG) &&
8115 (ering->tx_pending <= (MAX_SKB_FRAGS * 3))))
8110 return -EINVAL; 8116 return -EINVAL;
8111 8117
8112 if (netif_running(dev)) { 8118 if (netif_running(dev)) {
@@ -10209,7 +10215,7 @@ skip_phy_reset:
10209static void __devinit tg3_read_partno(struct tg3 *tp) 10215static void __devinit tg3_read_partno(struct tg3 *tp)
10210{ 10216{
10211 unsigned char vpd_data[256]; 10217 unsigned char vpd_data[256];
10212 int i; 10218 unsigned int i;
10213 u32 magic; 10219 u32 magic;
10214 10220
10215 if (tg3_nvram_read_swab(tp, 0x0, &magic)) 10221 if (tg3_nvram_read_swab(tp, 0x0, &magic))
@@ -10255,9 +10261,9 @@ static void __devinit tg3_read_partno(struct tg3 *tp)
10255 } 10261 }
10256 10262
10257 /* Now parse and find the part number. */ 10263 /* Now parse and find the part number. */
10258 for (i = 0; i < 256; ) { 10264 for (i = 0; i < 254; ) {
10259 unsigned char val = vpd_data[i]; 10265 unsigned char val = vpd_data[i];
10260 int block_end; 10266 unsigned int block_end;
10261 10267
10262 if (val == 0x82 || val == 0x91) { 10268 if (val == 0x82 || val == 0x91) {
10263 i = (i + 3 + 10269 i = (i + 3 +
@@ -10273,21 +10279,26 @@ static void __devinit tg3_read_partno(struct tg3 *tp)
10273 (vpd_data[i + 1] + 10279 (vpd_data[i + 1] +
10274 (vpd_data[i + 2] << 8))); 10280 (vpd_data[i + 2] << 8)));
10275 i += 3; 10281 i += 3;
10276 while (i < block_end) { 10282
10283 if (block_end > 256)
10284 goto out_not_found;
10285
10286 while (i < (block_end - 2)) {
10277 if (vpd_data[i + 0] == 'P' && 10287 if (vpd_data[i + 0] == 'P' &&
10278 vpd_data[i + 1] == 'N') { 10288 vpd_data[i + 1] == 'N') {
10279 int partno_len = vpd_data[i + 2]; 10289 int partno_len = vpd_data[i + 2];
10280 10290
10281 if (partno_len > 24) 10291 i += 3;
10292 if (partno_len > 24 || (partno_len + i) > 256)
10282 goto out_not_found; 10293 goto out_not_found;
10283 10294
10284 memcpy(tp->board_part_number, 10295 memcpy(tp->board_part_number,
10285 &vpd_data[i + 3], 10296 &vpd_data[i], partno_len);
10286 partno_len);
10287 10297
10288 /* Success. */ 10298 /* Success. */
10289 return; 10299 return;
10290 } 10300 }
10301 i += 3 + vpd_data[i + 2];
10291 } 10302 }
10292 10303
10293 /* Part number not found. */ 10304 /* Part number not found. */
@@ -10357,7 +10368,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
10357 u32 pci_state_reg, grc_misc_cfg; 10368 u32 pci_state_reg, grc_misc_cfg;
10358 u32 val; 10369 u32 val;
10359 u16 pci_cmd; 10370 u16 pci_cmd;
10360 int err; 10371 int err, pcie_cap;
10361 10372
10362 /* Force memory write invalidate off. If we leave it on, 10373 /* Force memory write invalidate off. If we leave it on,
10363 * then on 5700_BX chips we have to enable a workaround. 10374 * then on 5700_BX chips we have to enable a workaround.
@@ -10532,8 +10543,19 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
10532 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5906) 10543 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5906)
10533 tp->tg3_flags2 |= TG3_FLG2_JUMBO_CAPABLE; 10544 tp->tg3_flags2 |= TG3_FLG2_JUMBO_CAPABLE;
10534 10545
10535 if (pci_find_capability(tp->pdev, PCI_CAP_ID_EXP) != 0) 10546 pcie_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_EXP);
10547 if (pcie_cap != 0) {
10536 tp->tg3_flags2 |= TG3_FLG2_PCI_EXPRESS; 10548 tp->tg3_flags2 |= TG3_FLG2_PCI_EXPRESS;
10549 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
10550 u16 lnkctl;
10551
10552 pci_read_config_word(tp->pdev,
10553 pcie_cap + PCI_EXP_LNKCTL,
10554 &lnkctl);
10555 if (lnkctl & PCI_EXP_LNKCTL_CLKREQ_EN)
10556 tp->tg3_flags2 &= ~TG3_FLG2_HW_TSO_2;
10557 }
10558 }
10537 10559
10538 /* If we have an AMD 762 or VIA K8T800 chipset, write 10560 /* If we have an AMD 762 or VIA K8T800 chipset, write
10539 * reordering to the mailbox registers done by the host 10561 * reordering to the mailbox registers done by the host
@@ -11800,6 +11822,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
11800 else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 || 11822 else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
11801 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701 || 11823 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701 ||
11802 tp->pci_chip_rev_id == CHIPREV_ID_5705_A0 || 11824 tp->pci_chip_rev_id == CHIPREV_ID_5705_A0 ||
11825 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906 ||
11803 (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) != 0) { 11826 (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) != 0) {
11804 tp->tg3_flags2 &= ~TG3_FLG2_TSO_CAPABLE; 11827 tp->tg3_flags2 &= ~TG3_FLG2_TSO_CAPABLE;
11805 } else { 11828 } else {
diff --git a/drivers/net/tokenring/proteon.c b/drivers/net/tokenring/proteon.c
index 4f756960db2a..cb7dbb63c9d9 100644
--- a/drivers/net/tokenring/proteon.c
+++ b/drivers/net/tokenring/proteon.c
@@ -370,6 +370,10 @@ static int __init proteon_init(void)
370 dev->dma = dma[i]; 370 dev->dma = dma[i];
371 pdev = platform_device_register_simple("proteon", 371 pdev = platform_device_register_simple("proteon",
372 i, NULL, 0); 372 i, NULL, 0);
373 if (IS_ERR(pdev)) {
374 free_netdev(dev);
375 continue;
376 }
373 err = setup_card(dev, &pdev->dev); 377 err = setup_card(dev, &pdev->dev);
374 if (!err) { 378 if (!err) {
375 proteon_dev[i] = pdev; 379 proteon_dev[i] = pdev;
@@ -385,9 +389,10 @@ static int __init proteon_init(void)
385 /* Probe for cards. */ 389 /* Probe for cards. */
386 if (num == 0) { 390 if (num == 0) {
387 printk(KERN_NOTICE "proteon.c: No cards found.\n"); 391 printk(KERN_NOTICE "proteon.c: No cards found.\n");
388 return (-ENODEV); 392 platform_driver_unregister(&proteon_driver);
393 return -ENODEV;
389 } 394 }
390 return (0); 395 return 0;
391} 396}
392 397
393static void __exit proteon_cleanup(void) 398static void __exit proteon_cleanup(void)
diff --git a/drivers/net/tokenring/skisa.c b/drivers/net/tokenring/skisa.c
index d6ba41cf3110..33afea31d87b 100644
--- a/drivers/net/tokenring/skisa.c
+++ b/drivers/net/tokenring/skisa.c
@@ -380,6 +380,10 @@ static int __init sk_isa_init(void)
380 dev->dma = dma[i]; 380 dev->dma = dma[i];
381 pdev = platform_device_register_simple("skisa", 381 pdev = platform_device_register_simple("skisa",
382 i, NULL, 0); 382 i, NULL, 0);
383 if (IS_ERR(pdev)) {
384 free_netdev(dev);
385 continue;
386 }
383 err = setup_card(dev, &pdev->dev); 387 err = setup_card(dev, &pdev->dev);
384 if (!err) { 388 if (!err) {
385 sk_isa_dev[i] = pdev; 389 sk_isa_dev[i] = pdev;
@@ -395,9 +399,10 @@ static int __init sk_isa_init(void)
395 /* Probe for cards. */ 399 /* Probe for cards. */
396 if (num == 0) { 400 if (num == 0) {
397 printk(KERN_NOTICE "skisa.c: No cards found.\n"); 401 printk(KERN_NOTICE "skisa.c: No cards found.\n");
398 return (-ENODEV); 402 platform_driver_unregister(&sk_isa_driver);
403 return -ENODEV;
399 } 404 }
400 return (0); 405 return 0;
401} 406}
402 407
403static void __exit sk_isa_cleanup(void) 408static void __exit sk_isa_cleanup(void)
diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
index 2cfd9634895a..f6b3a94e97bf 100644
--- a/drivers/net/tulip/de2104x.c
+++ b/drivers/net/tulip/de2104x.c
@@ -1730,7 +1730,7 @@ static void __init de21040_get_media_info(struct de_private *de)
1730} 1730}
1731 1731
1732/* Note: this routine returns extra data bits for size detection. */ 1732/* Note: this routine returns extra data bits for size detection. */
1733static unsigned __init tulip_read_eeprom(void __iomem *regs, int location, int addr_len) 1733static unsigned __devinit tulip_read_eeprom(void __iomem *regs, int location, int addr_len)
1734{ 1734{
1735 int i; 1735 int i;
1736 unsigned retval = 0; 1736 unsigned retval = 0;
@@ -1926,7 +1926,7 @@ bad_srom:
1926 goto fill_defaults; 1926 goto fill_defaults;
1927} 1927}
1928 1928
1929static int __init de_init_one (struct pci_dev *pdev, 1929static int __devinit de_init_one (struct pci_dev *pdev,
1930 const struct pci_device_id *ent) 1930 const struct pci_device_id *ent)
1931{ 1931{
1932 struct net_device *dev; 1932 struct net_device *dev;
@@ -2082,7 +2082,7 @@ err_out_free:
2082 return rc; 2082 return rc;
2083} 2083}
2084 2084
2085static void __exit de_remove_one (struct pci_dev *pdev) 2085static void __devexit de_remove_one (struct pci_dev *pdev)
2086{ 2086{
2087 struct net_device *dev = pci_get_drvdata(pdev); 2087 struct net_device *dev = pci_get_drvdata(pdev);
2088 struct de_private *de = dev->priv; 2088 struct de_private *de = dev->priv;
@@ -2164,7 +2164,7 @@ static struct pci_driver de_driver = {
2164 .name = DRV_NAME, 2164 .name = DRV_NAME,
2165 .id_table = de_pci_tbl, 2165 .id_table = de_pci_tbl,
2166 .probe = de_init_one, 2166 .probe = de_init_one,
2167 .remove = __exit_p(de_remove_one), 2167 .remove = __devexit_p(de_remove_one),
2168#ifdef CONFIG_PM 2168#ifdef CONFIG_PM
2169 .suspend = de_suspend, 2169 .suspend = de_suspend,
2170 .resume = de_resume, 2170 .resume = de_resume,
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c
index 12cd7b561f35..b37888011067 100644
--- a/drivers/net/ucc_geth.c
+++ b/drivers/net/ucc_geth.c
@@ -2,14 +2,11 @@
2 * Copyright (C) Freescale Semicondutor, Inc. 2006. All rights reserved. 2 * Copyright (C) Freescale Semicondutor, Inc. 2006. All rights reserved.
3 * 3 *
4 * Author: Shlomi Gridish <gridish@freescale.com> 4 * Author: Shlomi Gridish <gridish@freescale.com>
5 * Li Yang <leoli@freescale.com>
5 * 6 *
6 * Description: 7 * Description:
7 * QE UCC Gigabit Ethernet Driver 8 * QE UCC Gigabit Ethernet Driver
8 * 9 *
9 * Changelog:
10 * Jul 6, 2006 Li Yang <LeoLi@freescale.com>
11 * - Rearrange code and style fixes
12 *
13 * This program is free software; you can redistribute it and/or modify it 10 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the 11 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your 12 * Free Software Foundation; either version 2 of the License, or (at your
@@ -31,9 +28,9 @@
31#include <linux/dma-mapping.h> 28#include <linux/dma-mapping.h>
32#include <linux/fsl_devices.h> 29#include <linux/fsl_devices.h>
33#include <linux/ethtool.h> 30#include <linux/ethtool.h>
34#include <linux/platform_device.h>
35#include <linux/mii.h> 31#include <linux/mii.h>
36 32
33#include <asm/of_device.h>
37#include <asm/uaccess.h> 34#include <asm/uaccess.h>
38#include <asm/irq.h> 35#include <asm/irq.h>
39#include <asm/io.h> 36#include <asm/io.h>
@@ -70,7 +67,7 @@
70 67
71static DEFINE_SPINLOCK(ugeth_lock); 68static DEFINE_SPINLOCK(ugeth_lock);
72 69
73static ucc_geth_info_t ugeth_primary_info = { 70static struct ucc_geth_info ugeth_primary_info = {
74 .uf_info = { 71 .uf_info = {
75 .bd_mem_part = MEM_PART_SYSTEM, 72 .bd_mem_part = MEM_PART_SYSTEM,
76 .rtsm = UCC_FAST_SEND_IDLES_BETWEEN_FRAMES, 73 .rtsm = UCC_FAST_SEND_IDLES_BETWEEN_FRAMES,
@@ -163,7 +160,7 @@ static ucc_geth_info_t ugeth_primary_info = {
163 .riscRx = QE_RISC_ALLOCATION_RISC1_AND_RISC2, 160 .riscRx = QE_RISC_ALLOCATION_RISC1_AND_RISC2,
164}; 161};
165 162
166static ucc_geth_info_t ugeth_info[8]; 163static struct ucc_geth_info ugeth_info[8];
167 164
168#ifdef DEBUG 165#ifdef DEBUG
169static void mem_disp(u8 *addr, int size) 166static void mem_disp(u8 *addr, int size)
@@ -219,8 +216,8 @@ static struct list_head *dequeue(struct list_head *lh)
219 } 216 }
220} 217}
221 218
222static int get_interface_details(enet_interface_e enet_interface, 219static int get_interface_details(enum enet_interface enet_interface,
223 enet_speed_e *speed, 220 enum enet_speed *speed,
224 int *r10m, 221 int *r10m,
225 int *rmm, 222 int *rmm,
226 int *rpm, 223 int *rpm,
@@ -283,7 +280,7 @@ static int get_interface_details(enet_interface_e enet_interface,
283 return 0; 280 return 0;
284} 281}
285 282
286static struct sk_buff *get_new_skb(ucc_geth_private_t *ugeth, u8 *bd) 283static struct sk_buff *get_new_skb(struct ucc_geth_private *ugeth, u8 *bd)
287{ 284{
288 struct sk_buff *skb = NULL; 285 struct sk_buff *skb = NULL;
289 286
@@ -303,21 +300,19 @@ static struct sk_buff *get_new_skb(ucc_geth_private_t *ugeth, u8 *bd)
303 300
304 skb->dev = ugeth->dev; 301 skb->dev = ugeth->dev;
305 302
306 BD_BUFFER_SET(bd, 303 out_be32(&((struct qe_bd *)bd)->buf,
307 dma_map_single(NULL, 304 dma_map_single(NULL,
308 skb->data, 305 skb->data,
309 ugeth->ug_info->uf_info.max_rx_buf_length + 306 ugeth->ug_info->uf_info.max_rx_buf_length +
310 UCC_GETH_RX_DATA_BUF_ALIGNMENT, 307 UCC_GETH_RX_DATA_BUF_ALIGNMENT,
311 DMA_FROM_DEVICE)); 308 DMA_FROM_DEVICE));
312 309
313 BD_STATUS_AND_LENGTH_SET(bd, 310 out_be32((u32 *)bd, (R_E | R_I | (in_be32((u32 *)bd) & R_W)));
314 (R_E | R_I |
315 (BD_STATUS_AND_LENGTH(bd) & R_W)));
316 311
317 return skb; 312 return skb;
318} 313}
319 314
320static int rx_bd_buffer_set(ucc_geth_private_t *ugeth, u8 rxQ) 315static int rx_bd_buffer_set(struct ucc_geth_private *ugeth, u8 rxQ)
321{ 316{
322 u8 *bd; 317 u8 *bd;
323 u32 bd_status; 318 u32 bd_status;
@@ -328,7 +323,7 @@ static int rx_bd_buffer_set(ucc_geth_private_t *ugeth, u8 rxQ)
328 i = 0; 323 i = 0;
329 324
330 do { 325 do {
331 bd_status = BD_STATUS_AND_LENGTH(bd); 326 bd_status = in_be32((u32*)bd);
332 skb = get_new_skb(ugeth, bd); 327 skb = get_new_skb(ugeth, bd);
333 328
334 if (!skb) /* If can not allocate data buffer, 329 if (!skb) /* If can not allocate data buffer,
@@ -338,19 +333,19 @@ static int rx_bd_buffer_set(ucc_geth_private_t *ugeth, u8 rxQ)
338 ugeth->rx_skbuff[rxQ][i] = skb; 333 ugeth->rx_skbuff[rxQ][i] = skb;
339 334
340 /* advance the BD pointer */ 335 /* advance the BD pointer */
341 bd += UCC_GETH_SIZE_OF_BD; 336 bd += sizeof(struct qe_bd);
342 i++; 337 i++;
343 } while (!(bd_status & R_W)); 338 } while (!(bd_status & R_W));
344 339
345 return 0; 340 return 0;
346} 341}
347 342
348static int fill_init_enet_entries(ucc_geth_private_t *ugeth, 343static int fill_init_enet_entries(struct ucc_geth_private *ugeth,
349 volatile u32 *p_start, 344 volatile u32 *p_start,
350 u8 num_entries, 345 u8 num_entries,
351 u32 thread_size, 346 u32 thread_size,
352 u32 thread_alignment, 347 u32 thread_alignment,
353 qe_risc_allocation_e risc, 348 enum qe_risc_allocation risc,
354 int skip_page_for_first_entry) 349 int skip_page_for_first_entry)
355{ 350{
356 u32 init_enet_offset; 351 u32 init_enet_offset;
@@ -383,10 +378,10 @@ static int fill_init_enet_entries(ucc_geth_private_t *ugeth,
383 return 0; 378 return 0;
384} 379}
385 380
386static int return_init_enet_entries(ucc_geth_private_t *ugeth, 381static int return_init_enet_entries(struct ucc_geth_private *ugeth,
387 volatile u32 *p_start, 382 volatile u32 *p_start,
388 u8 num_entries, 383 u8 num_entries,
389 qe_risc_allocation_e risc, 384 enum qe_risc_allocation risc,
390 int skip_page_for_first_entry) 385 int skip_page_for_first_entry)
391{ 386{
392 u32 init_enet_offset; 387 u32 init_enet_offset;
@@ -416,11 +411,11 @@ static int return_init_enet_entries(ucc_geth_private_t *ugeth,
416} 411}
417 412
418#ifdef DEBUG 413#ifdef DEBUG
419static int dump_init_enet_entries(ucc_geth_private_t *ugeth, 414static int dump_init_enet_entries(struct ucc_geth_private *ugeth,
420 volatile u32 *p_start, 415 volatile u32 *p_start,
421 u8 num_entries, 416 u8 num_entries,
422 u32 thread_size, 417 u32 thread_size,
423 qe_risc_allocation_e risc, 418 enum qe_risc_allocation risc,
424 int skip_page_for_first_entry) 419 int skip_page_for_first_entry)
425{ 420{
426 u32 init_enet_offset; 421 u32 init_enet_offset;
@@ -456,14 +451,14 @@ static int dump_init_enet_entries(ucc_geth_private_t *ugeth,
456#endif 451#endif
457 452
458#ifdef CONFIG_UGETH_FILTERING 453#ifdef CONFIG_UGETH_FILTERING
459static enet_addr_container_t *get_enet_addr_container(void) 454static struct enet_addr_container *get_enet_addr_container(void)
460{ 455{
461 enet_addr_container_t *enet_addr_cont; 456 struct enet_addr_container *enet_addr_cont;
462 457
463 /* allocate memory */ 458 /* allocate memory */
464 enet_addr_cont = kmalloc(sizeof(enet_addr_container_t), GFP_KERNEL); 459 enet_addr_cont = kmalloc(sizeof(struct enet_addr_container), GFP_KERNEL);
465 if (!enet_addr_cont) { 460 if (!enet_addr_cont) {
466 ugeth_err("%s: No memory for enet_addr_container_t object.", 461 ugeth_err("%s: No memory for enet_addr_container object.",
467 __FUNCTION__); 462 __FUNCTION__);
468 return NULL; 463 return NULL;
469 } 464 }
@@ -472,45 +467,43 @@ static enet_addr_container_t *get_enet_addr_container(void)
472} 467}
473#endif /* CONFIG_UGETH_FILTERING */ 468#endif /* CONFIG_UGETH_FILTERING */
474 469
475static void put_enet_addr_container(enet_addr_container_t *enet_addr_cont) 470static void put_enet_addr_container(struct enet_addr_container *enet_addr_cont)
476{ 471{
477 kfree(enet_addr_cont); 472 kfree(enet_addr_cont);
478} 473}
479 474
475static int set_mac_addr(__be16 __iomem *reg, u8 *mac)
476{
477 out_be16(&reg[0], ((u16)mac[5] << 8) | mac[4]);
478 out_be16(&reg[1], ((u16)mac[3] << 8) | mac[2]);
479 out_be16(&reg[2], ((u16)mac[1] << 8) | mac[0]);
480}
481
480#ifdef CONFIG_UGETH_FILTERING 482#ifdef CONFIG_UGETH_FILTERING
481static int hw_add_addr_in_paddr(ucc_geth_private_t *ugeth, 483static int hw_add_addr_in_paddr(struct ucc_geth_private *ugeth,
482 enet_addr_t *p_enet_addr, u8 paddr_num) 484 u8 *p_enet_addr, u8 paddr_num)
483{ 485{
484 ucc_geth_82xx_address_filtering_pram_t *p_82xx_addr_filt; 486 struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt;
485 487
486 if (!(paddr_num < NUM_OF_PADDRS)) { 488 if (!(paddr_num < NUM_OF_PADDRS)) {
487 ugeth_warn("%s: Illagel paddr_num.", __FUNCTION__); 489 ugeth_warn("%s: Illegal paddr_num.", __FUNCTION__);
488 return -EINVAL; 490 return -EINVAL;
489 } 491 }
490 492
491 p_82xx_addr_filt = 493 p_82xx_addr_filt =
492 (ucc_geth_82xx_address_filtering_pram_t *) ugeth->p_rx_glbl_pram-> 494 (struct ucc_geth_82xx_address_filtering_pram *) ugeth->p_rx_glbl_pram->
493 addressfiltering; 495 addressfiltering;
494 496
495 /* Ethernet frames are defined in Little Endian mode, */ 497 /* Ethernet frames are defined in Little Endian mode, */
496 /* therefore to insert the address we reverse the bytes. */ 498 /* therefore to insert the address we reverse the bytes. */
497 out_be16(&p_82xx_addr_filt->paddr[paddr_num].h, 499 set_mac_addr(&p_82xx_addr_filt->paddr[paddr_num].h, p_enet_addr);
498 (u16) (((u16) (((u16) ((*p_enet_addr)[5])) << 8)) |
499 (u16) (*p_enet_addr)[4]));
500 out_be16(&p_82xx_addr_filt->paddr[paddr_num].m,
501 (u16) (((u16) (((u16) ((*p_enet_addr)[3])) << 8)) |
502 (u16) (*p_enet_addr)[2]));
503 out_be16(&p_82xx_addr_filt->paddr[paddr_num].l,
504 (u16) (((u16) (((u16) ((*p_enet_addr)[1])) << 8)) |
505 (u16) (*p_enet_addr)[0]));
506
507 return 0; 500 return 0;
508} 501}
509#endif /* CONFIG_UGETH_FILTERING */ 502#endif /* CONFIG_UGETH_FILTERING */
510 503
511static int hw_clear_addr_in_paddr(ucc_geth_private_t *ugeth, u8 paddr_num) 504static int hw_clear_addr_in_paddr(struct ucc_geth_private *ugeth, u8 paddr_num)
512{ 505{
513 ucc_geth_82xx_address_filtering_pram_t *p_82xx_addr_filt; 506 struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt;
514 507
515 if (!(paddr_num < NUM_OF_PADDRS)) { 508 if (!(paddr_num < NUM_OF_PADDRS)) {
516 ugeth_warn("%s: Illagel paddr_num.", __FUNCTION__); 509 ugeth_warn("%s: Illagel paddr_num.", __FUNCTION__);
@@ -518,7 +511,7 @@ static int hw_clear_addr_in_paddr(ucc_geth_private_t *ugeth, u8 paddr_num)
518 } 511 }
519 512
520 p_82xx_addr_filt = 513 p_82xx_addr_filt =
521 (ucc_geth_82xx_address_filtering_pram_t *) ugeth->p_rx_glbl_pram-> 514 (struct ucc_geth_82xx_address_filtering_pram *) ugeth->p_rx_glbl_pram->
522 addressfiltering; 515 addressfiltering;
523 516
524 /* Writing address ff.ff.ff.ff.ff.ff disables address 517 /* Writing address ff.ff.ff.ff.ff.ff disables address
@@ -530,14 +523,14 @@ static int hw_clear_addr_in_paddr(ucc_geth_private_t *ugeth, u8 paddr_num)
530 return 0; 523 return 0;
531} 524}
532 525
533static void hw_add_addr_in_hash(ucc_geth_private_t *ugeth, 526static void hw_add_addr_in_hash(struct ucc_geth_private *ugeth,
534 enet_addr_t *p_enet_addr) 527 u8 *p_enet_addr)
535{ 528{
536 ucc_geth_82xx_address_filtering_pram_t *p_82xx_addr_filt; 529 struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt;
537 u32 cecr_subblock; 530 u32 cecr_subblock;
538 531
539 p_82xx_addr_filt = 532 p_82xx_addr_filt =
540 (ucc_geth_82xx_address_filtering_pram_t *) ugeth->p_rx_glbl_pram-> 533 (struct ucc_geth_82xx_address_filtering_pram *) ugeth->p_rx_glbl_pram->
541 addressfiltering; 534 addressfiltering;
542 535
543 cecr_subblock = 536 cecr_subblock =
@@ -546,25 +539,18 @@ static void hw_add_addr_in_hash(ucc_geth_private_t *ugeth,
546 /* Ethernet frames are defined in Little Endian mode, 539 /* Ethernet frames are defined in Little Endian mode,
547 therefor to insert */ 540 therefor to insert */
548 /* the address to the hash (Big Endian mode), we reverse the bytes.*/ 541 /* the address to the hash (Big Endian mode), we reverse the bytes.*/
549 out_be16(&p_82xx_addr_filt->taddr.h, 542
550 (u16) (((u16) (((u16) ((*p_enet_addr)[5])) << 8)) | 543 set_mac_addr(&p_82xx_addr_filt->taddr.h, p_enet_addr);
551 (u16) (*p_enet_addr)[4]));
552 out_be16(&p_82xx_addr_filt->taddr.m,
553 (u16) (((u16) (((u16) ((*p_enet_addr)[3])) << 8)) |
554 (u16) (*p_enet_addr)[2]));
555 out_be16(&p_82xx_addr_filt->taddr.l,
556 (u16) (((u16) (((u16) ((*p_enet_addr)[1])) << 8)) |
557 (u16) (*p_enet_addr)[0]));
558 544
559 qe_issue_cmd(QE_SET_GROUP_ADDRESS, cecr_subblock, 545 qe_issue_cmd(QE_SET_GROUP_ADDRESS, cecr_subblock,
560 (u8) QE_CR_PROTOCOL_ETHERNET, 0); 546 QE_CR_PROTOCOL_ETHERNET, 0);
561} 547}
562 548
563#ifdef CONFIG_UGETH_MAGIC_PACKET 549#ifdef CONFIG_UGETH_MAGIC_PACKET
564static void magic_packet_detection_enable(ucc_geth_private_t *ugeth) 550static void magic_packet_detection_enable(struct ucc_geth_private *ugeth)
565{ 551{
566 ucc_fast_private_t *uccf; 552 struct ucc_fast_private *uccf;
567 ucc_geth_t *ug_regs; 553 struct ucc_geth *ug_regs;
568 u32 maccfg2, uccm; 554 u32 maccfg2, uccm;
569 555
570 uccf = ugeth->uccf; 556 uccf = ugeth->uccf;
@@ -581,10 +567,10 @@ static void magic_packet_detection_enable(ucc_geth_private_t *ugeth)
581 out_be32(&ug_regs->maccfg2, maccfg2); 567 out_be32(&ug_regs->maccfg2, maccfg2);
582} 568}
583 569
584static void magic_packet_detection_disable(ucc_geth_private_t *ugeth) 570static void magic_packet_detection_disable(struct ucc_geth_private *ugeth)
585{ 571{
586 ucc_fast_private_t *uccf; 572 struct ucc_fast_private *uccf;
587 ucc_geth_t *ug_regs; 573 struct ucc_geth *ug_regs;
588 u32 maccfg2, uccm; 574 u32 maccfg2, uccm;
589 575
590 uccf = ugeth->uccf; 576 uccf = ugeth->uccf;
@@ -602,26 +588,26 @@ static void magic_packet_detection_disable(ucc_geth_private_t *ugeth)
602} 588}
603#endif /* MAGIC_PACKET */ 589#endif /* MAGIC_PACKET */
604 590
605static inline int compare_addr(enet_addr_t *addr1, enet_addr_t *addr2) 591static inline int compare_addr(u8 **addr1, u8 **addr2)
606{ 592{
607 return memcmp(addr1, addr2, ENET_NUM_OCTETS_PER_ADDRESS); 593 return memcmp(addr1, addr2, ENET_NUM_OCTETS_PER_ADDRESS);
608} 594}
609 595
610#ifdef DEBUG 596#ifdef DEBUG
611static void get_statistics(ucc_geth_private_t *ugeth, 597static void get_statistics(struct ucc_geth_private *ugeth,
612 ucc_geth_tx_firmware_statistics_t * 598 struct ucc_geth_tx_firmware_statistics *
613 tx_firmware_statistics, 599 tx_firmware_statistics,
614 ucc_geth_rx_firmware_statistics_t * 600 struct ucc_geth_rx_firmware_statistics *
615 rx_firmware_statistics, 601 rx_firmware_statistics,
616 ucc_geth_hardware_statistics_t *hardware_statistics) 602 struct ucc_geth_hardware_statistics *hardware_statistics)
617{ 603{
618 ucc_fast_t *uf_regs; 604 struct ucc_fast *uf_regs;
619 ucc_geth_t *ug_regs; 605 struct ucc_geth *ug_regs;
620 ucc_geth_tx_firmware_statistics_pram_t *p_tx_fw_statistics_pram; 606 struct ucc_geth_tx_firmware_statistics_pram *p_tx_fw_statistics_pram;
621 ucc_geth_rx_firmware_statistics_pram_t *p_rx_fw_statistics_pram; 607 struct ucc_geth_rx_firmware_statistics_pram *p_rx_fw_statistics_pram;
622 608
623 ug_regs = ugeth->ug_regs; 609 ug_regs = ugeth->ug_regs;
624 uf_regs = (ucc_fast_t *) ug_regs; 610 uf_regs = (struct ucc_fast *) ug_regs;
625 p_tx_fw_statistics_pram = ugeth->p_tx_fw_statistics_pram; 611 p_tx_fw_statistics_pram = ugeth->p_tx_fw_statistics_pram;
626 p_rx_fw_statistics_pram = ugeth->p_rx_fw_statistics_pram; 612 p_rx_fw_statistics_pram = ugeth->p_rx_fw_statistics_pram;
627 613
@@ -727,7 +713,7 @@ static void get_statistics(ucc_geth_private_t *ugeth,
727 } 713 }
728} 714}
729 715
730static void dump_bds(ucc_geth_private_t *ugeth) 716static void dump_bds(struct ucc_geth_private *ugeth)
731{ 717{
732 int i; 718 int i;
733 int length; 719 int length;
@@ -736,7 +722,7 @@ static void dump_bds(ucc_geth_private_t *ugeth)
736 if (ugeth->p_tx_bd_ring[i]) { 722 if (ugeth->p_tx_bd_ring[i]) {
737 length = 723 length =
738 (ugeth->ug_info->bdRingLenTx[i] * 724 (ugeth->ug_info->bdRingLenTx[i] *
739 UCC_GETH_SIZE_OF_BD); 725 sizeof(struct qe_bd));
740 ugeth_info("TX BDs[%d]", i); 726 ugeth_info("TX BDs[%d]", i);
741 mem_disp(ugeth->p_tx_bd_ring[i], length); 727 mem_disp(ugeth->p_tx_bd_ring[i], length);
742 } 728 }
@@ -745,14 +731,14 @@ static void dump_bds(ucc_geth_private_t *ugeth)
745 if (ugeth->p_rx_bd_ring[i]) { 731 if (ugeth->p_rx_bd_ring[i]) {
746 length = 732 length =
747 (ugeth->ug_info->bdRingLenRx[i] * 733 (ugeth->ug_info->bdRingLenRx[i] *
748 UCC_GETH_SIZE_OF_BD); 734 sizeof(struct qe_bd));
749 ugeth_info("RX BDs[%d]", i); 735 ugeth_info("RX BDs[%d]", i);
750 mem_disp(ugeth->p_rx_bd_ring[i], length); 736 mem_disp(ugeth->p_rx_bd_ring[i], length);
751 } 737 }
752 } 738 }
753} 739}
754 740
755static void dump_regs(ucc_geth_private_t *ugeth) 741static void dump_regs(struct ucc_geth_private *ugeth)
756{ 742{
757 int i; 743 int i;
758 744
@@ -893,7 +879,7 @@ static void dump_regs(ucc_geth_private_t *ugeth)
893 ugeth_info("Base address: 0x%08x", 879 ugeth_info("Base address: 0x%08x",
894 (u32) & ugeth->p_thread_data_tx[i]); 880 (u32) & ugeth->p_thread_data_tx[i]);
895 mem_disp((u8 *) & ugeth->p_thread_data_tx[i], 881 mem_disp((u8 *) & ugeth->p_thread_data_tx[i],
896 sizeof(ucc_geth_thread_data_tx_t)); 882 sizeof(struct ucc_geth_thread_data_tx));
897 } 883 }
898 } 884 }
899 if (ugeth->p_thread_data_rx) { 885 if (ugeth->p_thread_data_rx) {
@@ -927,7 +913,7 @@ static void dump_regs(ucc_geth_private_t *ugeth)
927 ugeth_info("Base address: 0x%08x", 913 ugeth_info("Base address: 0x%08x",
928 (u32) & ugeth->p_thread_data_rx[i]); 914 (u32) & ugeth->p_thread_data_rx[i]);
929 mem_disp((u8 *) & ugeth->p_thread_data_rx[i], 915 mem_disp((u8 *) & ugeth->p_thread_data_rx[i],
930 sizeof(ucc_geth_thread_data_rx_t)); 916 sizeof(struct ucc_geth_thread_data_rx));
931 } 917 }
932 } 918 }
933 if (ugeth->p_exf_glbl_param) { 919 if (ugeth->p_exf_glbl_param) {
@@ -1105,7 +1091,7 @@ static void dump_regs(ucc_geth_private_t *ugeth)
1105 ugeth_info("Base address: 0x%08x", 1091 ugeth_info("Base address: 0x%08x",
1106 (u32) & ugeth->p_send_q_mem_reg->sqqd[i]); 1092 (u32) & ugeth->p_send_q_mem_reg->sqqd[i]);
1107 mem_disp((u8 *) & ugeth->p_send_q_mem_reg->sqqd[i], 1093 mem_disp((u8 *) & ugeth->p_send_q_mem_reg->sqqd[i],
1108 sizeof(ucc_geth_send_queue_qd_t)); 1094 sizeof(struct ucc_geth_send_queue_qd));
1109 } 1095 }
1110 } 1096 }
1111 if (ugeth->p_scheduler) { 1097 if (ugeth->p_scheduler) {
@@ -1187,7 +1173,7 @@ static void dump_regs(ucc_geth_private_t *ugeth)
1187 qe_muram_addr(in_be32 1173 qe_muram_addr(in_be32
1188 (&ugeth->p_rx_bd_qs_tbl[i]. 1174 (&ugeth->p_rx_bd_qs_tbl[i].
1189 bdbaseptr)), 1175 bdbaseptr)),
1190 sizeof(ucc_geth_rx_prefetched_bds_t)); 1176 sizeof(struct ucc_geth_rx_prefetched_bds));
1191 } 1177 }
1192 } 1178 }
1193 if (ugeth->p_init_enet_param_shadow) { 1179 if (ugeth->p_init_enet_param_shadow) {
@@ -1198,7 +1184,7 @@ static void dump_regs(ucc_geth_private_t *ugeth)
1198 mem_disp((u8 *) ugeth->p_init_enet_param_shadow, 1184 mem_disp((u8 *) ugeth->p_init_enet_param_shadow,
1199 sizeof(*ugeth->p_init_enet_param_shadow)); 1185 sizeof(*ugeth->p_init_enet_param_shadow));
1200 1186
1201 size = sizeof(ucc_geth_thread_rx_pram_t); 1187 size = sizeof(struct ucc_geth_thread_rx_pram);
1202 if (ugeth->ug_info->rxExtendedFiltering) { 1188 if (ugeth->ug_info->rxExtendedFiltering) {
1203 size += 1189 size +=
1204 THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING; 1190 THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING;
@@ -1216,7 +1202,7 @@ static void dump_regs(ucc_geth_private_t *ugeth)
1216 &(ugeth->p_init_enet_param_shadow-> 1202 &(ugeth->p_init_enet_param_shadow->
1217 txthread[0]), 1203 txthread[0]),
1218 ENET_INIT_PARAM_MAX_ENTRIES_TX, 1204 ENET_INIT_PARAM_MAX_ENTRIES_TX,
1219 sizeof(ucc_geth_thread_tx_pram_t), 1205 sizeof(struct ucc_geth_thread_tx_pram),
1220 ugeth->ug_info->riscTx, 0); 1206 ugeth->ug_info->riscTx, 0);
1221 dump_init_enet_entries(ugeth, 1207 dump_init_enet_entries(ugeth,
1222 &(ugeth->p_init_enet_param_shadow-> 1208 &(ugeth->p_init_enet_param_shadow->
@@ -1578,12 +1564,12 @@ static int init_min_frame_len(u16 min_frame_length,
1578 return 0; 1564 return 0;
1579} 1565}
1580 1566
1581static int adjust_enet_interface(ucc_geth_private_t *ugeth) 1567static int adjust_enet_interface(struct ucc_geth_private *ugeth)
1582{ 1568{
1583 ucc_geth_info_t *ug_info; 1569 struct ucc_geth_info *ug_info;
1584 ucc_geth_t *ug_regs; 1570 struct ucc_geth *ug_regs;
1585 ucc_fast_t *uf_regs; 1571 struct ucc_fast *uf_regs;
1586 enet_speed_e speed; 1572 enum enet_speed speed;
1587 int ret_val, rpm = 0, tbi = 0, r10m = 0, rmm = 1573 int ret_val, rpm = 0, tbi = 0, r10m = 0, rmm =
1588 0, limited_to_full_duplex = 0; 1574 0, limited_to_full_duplex = 0;
1589 u32 upsmr, maccfg2, utbipar, tbiBaseAddress; 1575 u32 upsmr, maccfg2, utbipar, tbiBaseAddress;
@@ -1691,8 +1677,8 @@ static int adjust_enet_interface(ucc_geth_private_t *ugeth)
1691 */ 1677 */
1692static void adjust_link(struct net_device *dev) 1678static void adjust_link(struct net_device *dev)
1693{ 1679{
1694 ucc_geth_private_t *ugeth = netdev_priv(dev); 1680 struct ucc_geth_private *ugeth = netdev_priv(dev);
1695 ucc_geth_t *ug_regs; 1681 struct ucc_geth *ug_regs;
1696 u32 tempval; 1682 u32 tempval;
1697 struct ugeth_mii_info *mii_info = ugeth->mii_info; 1683 struct ugeth_mii_info *mii_info = ugeth->mii_info;
1698 1684
@@ -1722,7 +1708,7 @@ static void adjust_link(struct net_device *dev)
1722 if (mii_info->speed != ugeth->oldspeed) { 1708 if (mii_info->speed != ugeth->oldspeed) {
1723 switch (mii_info->speed) { 1709 switch (mii_info->speed) {
1724 case 1000: 1710 case 1000:
1725#ifdef CONFIG_MPC836x 1711#ifdef CONFIG_PPC_MPC836x
1726/* FIXME: This code is for 100Mbs BUG fixing, 1712/* FIXME: This code is for 100Mbs BUG fixing,
1727remove this when it is fixed!!! */ 1713remove this when it is fixed!!! */
1728 if (ugeth->ug_info->enet_interface == 1714 if (ugeth->ug_info->enet_interface ==
@@ -1768,7 +1754,7 @@ remove this when it is fixed!!! */
1768 break; 1754 break;
1769 case 100: 1755 case 100:
1770 case 10: 1756 case 10:
1771#ifdef CONFIG_MPC836x 1757#ifdef CONFIG_PPC_MPC836x
1772/* FIXME: This code is for 100Mbs BUG fixing, 1758/* FIXME: This code is for 100Mbs BUG fixing,
1773remove this lines when it will be fixed!!! */ 1759remove this lines when it will be fixed!!! */
1774 ugeth->ug_info->enet_interface = ENET_100_RGMII; 1760 ugeth->ug_info->enet_interface = ENET_100_RGMII;
@@ -1827,9 +1813,9 @@ remove this lines when it will be fixed!!! */
1827 */ 1813 */
1828static int init_phy(struct net_device *dev) 1814static int init_phy(struct net_device *dev)
1829{ 1815{
1830 ucc_geth_private_t *ugeth = netdev_priv(dev); 1816 struct ucc_geth_private *ugeth = netdev_priv(dev);
1831 struct phy_info *curphy; 1817 struct phy_info *curphy;
1832 ucc_mii_mng_t *mii_regs; 1818 struct ucc_mii_mng *mii_regs;
1833 struct ugeth_mii_info *mii_info; 1819 struct ugeth_mii_info *mii_info;
1834 int err; 1820 int err;
1835 1821
@@ -1914,17 +1900,17 @@ static int init_phy(struct net_device *dev)
1914} 1900}
1915 1901
1916#ifdef CONFIG_UGETH_TX_ON_DEMOND 1902#ifdef CONFIG_UGETH_TX_ON_DEMOND
1917static int ugeth_transmit_on_demand(ucc_geth_private_t *ugeth) 1903static int ugeth_transmit_on_demand(struct ucc_geth_private *ugeth)
1918{ 1904{
1919 ucc_fast_transmit_on_demand(ugeth->uccf); 1905 struct ucc_fastransmit_on_demand(ugeth->uccf);
1920 1906
1921 return 0; 1907 return 0;
1922} 1908}
1923#endif 1909#endif
1924 1910
1925static int ugeth_graceful_stop_tx(ucc_geth_private_t *ugeth) 1911static int ugeth_graceful_stop_tx(struct ucc_geth_private *ugeth)
1926{ 1912{
1927 ucc_fast_private_t *uccf; 1913 struct ucc_fast_private *uccf;
1928 u32 cecr_subblock; 1914 u32 cecr_subblock;
1929 u32 temp; 1915 u32 temp;
1930 1916
@@ -1940,7 +1926,7 @@ static int ugeth_graceful_stop_tx(ucc_geth_private_t *ugeth)
1940 cecr_subblock = 1926 cecr_subblock =
1941 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info.ucc_num); 1927 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info.ucc_num);
1942 qe_issue_cmd(QE_GRACEFUL_STOP_TX, cecr_subblock, 1928 qe_issue_cmd(QE_GRACEFUL_STOP_TX, cecr_subblock,
1943 (u8) QE_CR_PROTOCOL_ETHERNET, 0); 1929 QE_CR_PROTOCOL_ETHERNET, 0);
1944 1930
1945 /* Wait for command to complete */ 1931 /* Wait for command to complete */
1946 do { 1932 do {
@@ -1952,9 +1938,9 @@ static int ugeth_graceful_stop_tx(ucc_geth_private_t *ugeth)
1952 return 0; 1938 return 0;
1953} 1939}
1954 1940
1955static int ugeth_graceful_stop_rx(ucc_geth_private_t * ugeth) 1941static int ugeth_graceful_stop_rx(struct ucc_geth_private * ugeth)
1956{ 1942{
1957 ucc_fast_private_t *uccf; 1943 struct ucc_fast_private *uccf;
1958 u32 cecr_subblock; 1944 u32 cecr_subblock;
1959 u8 temp; 1945 u8 temp;
1960 1946
@@ -1973,7 +1959,7 @@ static int ugeth_graceful_stop_rx(ucc_geth_private_t * ugeth)
1973 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info. 1959 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info.
1974 ucc_num); 1960 ucc_num);
1975 qe_issue_cmd(QE_GRACEFUL_STOP_RX, cecr_subblock, 1961 qe_issue_cmd(QE_GRACEFUL_STOP_RX, cecr_subblock,
1976 (u8) QE_CR_PROTOCOL_ETHERNET, 0); 1962 QE_CR_PROTOCOL_ETHERNET, 0);
1977 1963
1978 temp = ugeth->p_rx_glbl_pram->rxgstpack; 1964 temp = ugeth->p_rx_glbl_pram->rxgstpack;
1979 } while (!(temp & GRACEFUL_STOP_ACKNOWLEDGE_RX)); 1965 } while (!(temp & GRACEFUL_STOP_ACKNOWLEDGE_RX));
@@ -1983,41 +1969,40 @@ static int ugeth_graceful_stop_rx(ucc_geth_private_t * ugeth)
1983 return 0; 1969 return 0;
1984} 1970}
1985 1971
1986static int ugeth_restart_tx(ucc_geth_private_t *ugeth) 1972static int ugeth_restart_tx(struct ucc_geth_private *ugeth)
1987{ 1973{
1988 ucc_fast_private_t *uccf; 1974 struct ucc_fast_private *uccf;
1989 u32 cecr_subblock; 1975 u32 cecr_subblock;
1990 1976
1991 uccf = ugeth->uccf; 1977 uccf = ugeth->uccf;
1992 1978
1993 cecr_subblock = 1979 cecr_subblock =
1994 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info.ucc_num); 1980 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info.ucc_num);
1995 qe_issue_cmd(QE_RESTART_TX, cecr_subblock, (u8) QE_CR_PROTOCOL_ETHERNET, 1981 qe_issue_cmd(QE_RESTART_TX, cecr_subblock, QE_CR_PROTOCOL_ETHERNET, 0);
1996 0);
1997 uccf->stopped_tx = 0; 1982 uccf->stopped_tx = 0;
1998 1983
1999 return 0; 1984 return 0;
2000} 1985}
2001 1986
2002static int ugeth_restart_rx(ucc_geth_private_t *ugeth) 1987static int ugeth_restart_rx(struct ucc_geth_private *ugeth)
2003{ 1988{
2004 ucc_fast_private_t *uccf; 1989 struct ucc_fast_private *uccf;
2005 u32 cecr_subblock; 1990 u32 cecr_subblock;
2006 1991
2007 uccf = ugeth->uccf; 1992 uccf = ugeth->uccf;
2008 1993
2009 cecr_subblock = 1994 cecr_subblock =
2010 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info.ucc_num); 1995 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info.ucc_num);
2011 qe_issue_cmd(QE_RESTART_RX, cecr_subblock, (u8) QE_CR_PROTOCOL_ETHERNET, 1996 qe_issue_cmd(QE_RESTART_RX, cecr_subblock, QE_CR_PROTOCOL_ETHERNET,
2012 0); 1997 0);
2013 uccf->stopped_rx = 0; 1998 uccf->stopped_rx = 0;
2014 1999
2015 return 0; 2000 return 0;
2016} 2001}
2017 2002
2018static int ugeth_enable(ucc_geth_private_t *ugeth, comm_dir_e mode) 2003static int ugeth_enable(struct ucc_geth_private *ugeth, enum comm_dir mode)
2019{ 2004{
2020 ucc_fast_private_t *uccf; 2005 struct ucc_fast_private *uccf;
2021 int enabled_tx, enabled_rx; 2006 int enabled_tx, enabled_rx;
2022 2007
2023 uccf = ugeth->uccf; 2008 uccf = ugeth->uccf;
@@ -2044,9 +2029,9 @@ static int ugeth_enable(ucc_geth_private_t *ugeth, comm_dir_e mode)
2044 2029
2045} 2030}
2046 2031
2047static int ugeth_disable(ucc_geth_private_t * ugeth, comm_dir_e mode) 2032static int ugeth_disable(struct ucc_geth_private * ugeth, enum comm_dir mode)
2048{ 2033{
2049 ucc_fast_private_t *uccf; 2034 struct ucc_fast_private *uccf;
2050 2035
2051 uccf = ugeth->uccf; 2036 uccf = ugeth->uccf;
2052 2037
@@ -2069,7 +2054,7 @@ static int ugeth_disable(ucc_geth_private_t * ugeth, comm_dir_e mode)
2069 return 0; 2054 return 0;
2070} 2055}
2071 2056
2072static void ugeth_dump_regs(ucc_geth_private_t *ugeth) 2057static void ugeth_dump_regs(struct ucc_geth_private *ugeth)
2073{ 2058{
2074#ifdef DEBUG 2059#ifdef DEBUG
2075 ucc_fast_dump_regs(ugeth->uccf); 2060 ucc_fast_dump_regs(ugeth->uccf);
@@ -2079,9 +2064,9 @@ static void ugeth_dump_regs(ucc_geth_private_t *ugeth)
2079} 2064}
2080 2065
2081#ifdef CONFIG_UGETH_FILTERING 2066#ifdef CONFIG_UGETH_FILTERING
2082static int ugeth_ext_filtering_serialize_tad(ucc_geth_tad_params_t * 2067static int ugeth_ext_filtering_serialize_tad(struct ucc_geth_tad_params *
2083 p_UccGethTadParams, 2068 p_UccGethTadParams,
2084 qe_fltr_tad_t *qe_fltr_tad) 2069 struct qe_fltr_tad *qe_fltr_tad)
2085{ 2070{
2086 u16 temp; 2071 u16 temp;
2087 2072
@@ -2119,11 +2104,11 @@ static int ugeth_ext_filtering_serialize_tad(ucc_geth_tad_params_t *
2119 return 0; 2104 return 0;
2120} 2105}
2121 2106
2122static enet_addr_container_t 2107static struct enet_addr_container_t
2123 *ugeth_82xx_filtering_get_match_addr_in_hash(ucc_geth_private_t *ugeth, 2108 *ugeth_82xx_filtering_get_match_addr_in_hash(struct ucc_geth_private *ugeth,
2124 enet_addr_t *p_enet_addr) 2109 struct enet_addr *p_enet_addr)
2125{ 2110{
2126 enet_addr_container_t *enet_addr_cont; 2111 struct enet_addr_container *enet_addr_cont;
2127 struct list_head *p_lh; 2112 struct list_head *p_lh;
2128 u16 i, num; 2113 u16 i, num;
2129 int32_t j; 2114 int32_t j;
@@ -2144,7 +2129,7 @@ static enet_addr_container_t
2144 2129
2145 for (i = 0; i < num; i++) { 2130 for (i = 0; i < num; i++) {
2146 enet_addr_cont = 2131 enet_addr_cont =
2147 (enet_addr_container_t *) 2132 (struct enet_addr_container *)
2148 ENET_ADDR_CONT_ENTRY(dequeue(p_lh)); 2133 ENET_ADDR_CONT_ENTRY(dequeue(p_lh));
2149 for (j = ENET_NUM_OCTETS_PER_ADDRESS - 1; j >= 0; j--) { 2134 for (j = ENET_NUM_OCTETS_PER_ADDRESS - 1; j >= 0; j--) {
2150 if ((*p_enet_addr)[j] != (enet_addr_cont->address)[j]) 2135 if ((*p_enet_addr)[j] != (enet_addr_cont->address)[j])
@@ -2157,11 +2142,11 @@ static enet_addr_container_t
2157 return NULL; 2142 return NULL;
2158} 2143}
2159 2144
2160static int ugeth_82xx_filtering_add_addr_in_hash(ucc_geth_private_t *ugeth, 2145static int ugeth_82xx_filtering_add_addr_in_hash(struct ucc_geth_private *ugeth,
2161 enet_addr_t *p_enet_addr) 2146 struct enet_addr *p_enet_addr)
2162{ 2147{
2163 ucc_geth_enet_address_recognition_location_e location; 2148 enum ucc_geth_enet_address_recognition_location location;
2164 enet_addr_container_t *enet_addr_cont; 2149 struct enet_addr_container *enet_addr_cont;
2165 struct list_head *p_lh; 2150 struct list_head *p_lh;
2166 u8 i; 2151 u8 i;
2167 u32 limit; 2152 u32 limit;
@@ -2196,18 +2181,17 @@ static int ugeth_82xx_filtering_add_addr_in_hash(ucc_geth_private_t *ugeth,
2196 enqueue(p_lh, &enet_addr_cont->node); /* Put it back */ 2181 enqueue(p_lh, &enet_addr_cont->node); /* Put it back */
2197 ++(*p_counter); 2182 ++(*p_counter);
2198 2183
2199 hw_add_addr_in_hash(ugeth, &(enet_addr_cont->address)); 2184 hw_add_addr_in_hash(ugeth, enet_addr_cont->address);
2200
2201 return 0; 2185 return 0;
2202} 2186}
2203 2187
2204static int ugeth_82xx_filtering_clear_addr_in_hash(ucc_geth_private_t *ugeth, 2188static int ugeth_82xx_filtering_clear_addr_in_hash(struct ucc_geth_private *ugeth,
2205 enet_addr_t *p_enet_addr) 2189 struct enet_addr *p_enet_addr)
2206{ 2190{
2207 ucc_geth_82xx_address_filtering_pram_t *p_82xx_addr_filt; 2191 struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt;
2208 enet_addr_container_t *enet_addr_cont; 2192 struct enet_addr_container *enet_addr_cont;
2209 ucc_fast_private_t *uccf; 2193 struct ucc_fast_private *uccf;
2210 comm_dir_e comm_dir; 2194 enum comm_dir comm_dir;
2211 u16 i, num; 2195 u16 i, num;
2212 struct list_head *p_lh; 2196 struct list_head *p_lh;
2213 u32 *addr_h, *addr_l; 2197 u32 *addr_h, *addr_l;
@@ -2216,7 +2200,7 @@ static int ugeth_82xx_filtering_clear_addr_in_hash(ucc_geth_private_t *ugeth,
2216 uccf = ugeth->uccf; 2200 uccf = ugeth->uccf;
2217 2201
2218 p_82xx_addr_filt = 2202 p_82xx_addr_filt =
2219 (ucc_geth_82xx_address_filtering_pram_t *) ugeth->p_rx_glbl_pram-> 2203 (struct ucc_geth_82xx_address_filtering_pram *) ugeth->p_rx_glbl_pram->
2220 addressfiltering; 2204 addressfiltering;
2221 2205
2222 if (! 2206 if (!
@@ -2256,9 +2240,9 @@ static int ugeth_82xx_filtering_clear_addr_in_hash(ucc_geth_private_t *ugeth,
2256 num = --(*p_counter); 2240 num = --(*p_counter);
2257 for (i = 0; i < num; i++) { 2241 for (i = 0; i < num; i++) {
2258 enet_addr_cont = 2242 enet_addr_cont =
2259 (enet_addr_container_t *) 2243 (struct enet_addr_container *)
2260 ENET_ADDR_CONT_ENTRY(dequeue(p_lh)); 2244 ENET_ADDR_CONT_ENTRY(dequeue(p_lh));
2261 hw_add_addr_in_hash(ugeth, &(enet_addr_cont->address)); 2245 hw_add_addr_in_hash(ugeth, enet_addr_cont->address);
2262 enqueue(p_lh, &enet_addr_cont->node); /* Put it back */ 2246 enqueue(p_lh, &enet_addr_cont->node); /* Put it back */
2263 } 2247 }
2264 2248
@@ -2269,14 +2253,14 @@ static int ugeth_82xx_filtering_clear_addr_in_hash(ucc_geth_private_t *ugeth,
2269} 2253}
2270#endif /* CONFIG_UGETH_FILTERING */ 2254#endif /* CONFIG_UGETH_FILTERING */
2271 2255
2272static int ugeth_82xx_filtering_clear_all_addr_in_hash(ucc_geth_private_t * 2256static int ugeth_82xx_filtering_clear_all_addr_in_hash(struct ucc_geth_private *
2273 ugeth, 2257 ugeth,
2274 enet_addr_type_e 2258 enum enet_addr_type
2275 enet_addr_type) 2259 enet_addr_type)
2276{ 2260{
2277 ucc_geth_82xx_address_filtering_pram_t *p_82xx_addr_filt; 2261 struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt;
2278 ucc_fast_private_t *uccf; 2262 struct ucc_fast_private *uccf;
2279 comm_dir_e comm_dir; 2263 enum comm_dir comm_dir;
2280 struct list_head *p_lh; 2264 struct list_head *p_lh;
2281 u16 i, num; 2265 u16 i, num;
2282 u32 *addr_h, *addr_l; 2266 u32 *addr_h, *addr_l;
@@ -2285,7 +2269,7 @@ static int ugeth_82xx_filtering_clear_all_addr_in_hash(ucc_geth_private_t *
2285 uccf = ugeth->uccf; 2269 uccf = ugeth->uccf;
2286 2270
2287 p_82xx_addr_filt = 2271 p_82xx_addr_filt =
2288 (ucc_geth_82xx_address_filtering_pram_t *) ugeth->p_rx_glbl_pram-> 2272 (struct ucc_geth_82xx_address_filtering_pram *) ugeth->p_rx_glbl_pram->
2289 addressfiltering; 2273 addressfiltering;
2290 2274
2291 if (enet_addr_type == ENET_ADDR_TYPE_GROUP) { 2275 if (enet_addr_type == ENET_ADDR_TYPE_GROUP) {
@@ -2331,8 +2315,8 @@ static int ugeth_82xx_filtering_clear_all_addr_in_hash(ucc_geth_private_t *
2331} 2315}
2332 2316
2333#ifdef CONFIG_UGETH_FILTERING 2317#ifdef CONFIG_UGETH_FILTERING
2334static int ugeth_82xx_filtering_add_addr_in_paddr(ucc_geth_private_t *ugeth, 2318static int ugeth_82xx_filtering_add_addr_in_paddr(struct ucc_geth_private *ugeth,
2335 enet_addr_t *p_enet_addr, 2319 struct enet_addr *p_enet_addr,
2336 u8 paddr_num) 2320 u8 paddr_num)
2337{ 2321{
2338 int i; 2322 int i;
@@ -2352,14 +2336,14 @@ static int ugeth_82xx_filtering_add_addr_in_paddr(ucc_geth_private_t *ugeth,
2352} 2336}
2353#endif /* CONFIG_UGETH_FILTERING */ 2337#endif /* CONFIG_UGETH_FILTERING */
2354 2338
2355static int ugeth_82xx_filtering_clear_addr_in_paddr(ucc_geth_private_t *ugeth, 2339static int ugeth_82xx_filtering_clear_addr_in_paddr(struct ucc_geth_private *ugeth,
2356 u8 paddr_num) 2340 u8 paddr_num)
2357{ 2341{
2358 ugeth->indAddrRegUsed[paddr_num] = 0; /* mark this paddr as not used */ 2342 ugeth->indAddrRegUsed[paddr_num] = 0; /* mark this paddr as not used */
2359 return hw_clear_addr_in_paddr(ugeth, paddr_num);/* clear in hardware */ 2343 return hw_clear_addr_in_paddr(ugeth, paddr_num);/* clear in hardware */
2360} 2344}
2361 2345
2362static void ucc_geth_memclean(ucc_geth_private_t *ugeth) 2346static void ucc_geth_memclean(struct ucc_geth_private *ugeth)
2363{ 2347{
2364 u16 i, j; 2348 u16 i, j;
2365 u8 *bd; 2349 u8 *bd;
@@ -2433,8 +2417,8 @@ static void ucc_geth_memclean(ucc_geth_private_t *ugeth)
2433 for (j = 0; j < ugeth->ug_info->bdRingLenTx[i]; j++) { 2417 for (j = 0; j < ugeth->ug_info->bdRingLenTx[i]; j++) {
2434 if (ugeth->tx_skbuff[i][j]) { 2418 if (ugeth->tx_skbuff[i][j]) {
2435 dma_unmap_single(NULL, 2419 dma_unmap_single(NULL,
2436 BD_BUFFER_ARG(bd), 2420 ((qe_bd_t *)bd)->buf,
2437 (BD_STATUS_AND_LENGTH(bd) & 2421 (in_be32((u32 *)bd) &
2438 BD_LENGTH_MASK), 2422 BD_LENGTH_MASK),
2439 DMA_TO_DEVICE); 2423 DMA_TO_DEVICE);
2440 dev_kfree_skb_any(ugeth->tx_skbuff[i][j]); 2424 dev_kfree_skb_any(ugeth->tx_skbuff[i][j]);
@@ -2460,18 +2444,17 @@ static void ucc_geth_memclean(ucc_geth_private_t *ugeth)
2460 bd = ugeth->p_rx_bd_ring[i]; 2444 bd = ugeth->p_rx_bd_ring[i];
2461 for (j = 0; j < ugeth->ug_info->bdRingLenRx[i]; j++) { 2445 for (j = 0; j < ugeth->ug_info->bdRingLenRx[i]; j++) {
2462 if (ugeth->rx_skbuff[i][j]) { 2446 if (ugeth->rx_skbuff[i][j]) {
2463 dma_unmap_single(NULL, BD_BUFFER(bd), 2447 dma_unmap_single(NULL,
2464 ugeth->ug_info-> 2448 ((struct qe_bd *)bd)->buf,
2465 uf_info. 2449 ugeth->ug_info->
2466 max_rx_buf_length + 2450 uf_info.max_rx_buf_length +
2467 UCC_GETH_RX_DATA_BUF_ALIGNMENT, 2451 UCC_GETH_RX_DATA_BUF_ALIGNMENT,
2468 DMA_FROM_DEVICE); 2452 DMA_FROM_DEVICE);
2469 2453 dev_kfree_skb_any(
2470 dev_kfree_skb_any(ugeth-> 2454 ugeth->rx_skbuff[i][j]);
2471 rx_skbuff[i][j]);
2472 ugeth->rx_skbuff[i][j] = NULL; 2455 ugeth->rx_skbuff[i][j] = NULL;
2473 } 2456 }
2474 bd += UCC_GETH_SIZE_OF_BD; 2457 bd += sizeof(struct qe_bd);
2475 } 2458 }
2476 2459
2477 kfree(ugeth->rx_skbuff[i]); 2460 kfree(ugeth->rx_skbuff[i]);
@@ -2496,11 +2479,11 @@ static void ucc_geth_memclean(ucc_geth_private_t *ugeth)
2496 2479
2497static void ucc_geth_set_multi(struct net_device *dev) 2480static void ucc_geth_set_multi(struct net_device *dev)
2498{ 2481{
2499 ucc_geth_private_t *ugeth; 2482 struct ucc_geth_private *ugeth;
2500 struct dev_mc_list *dmi; 2483 struct dev_mc_list *dmi;
2501 ucc_fast_t *uf_regs; 2484 struct ucc_fast *uf_regs;
2502 ucc_geth_82xx_address_filtering_pram_t *p_82xx_addr_filt; 2485 struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt;
2503 enet_addr_t tempaddr; 2486 u8 tempaddr[6];
2504 u8 *mcptr, *tdptr; 2487 u8 *mcptr, *tdptr;
2505 int i, j; 2488 int i, j;
2506 2489
@@ -2517,7 +2500,7 @@ static void ucc_geth_set_multi(struct net_device *dev)
2517 uf_regs->upsmr &= ~UPSMR_PRO; 2500 uf_regs->upsmr &= ~UPSMR_PRO;
2518 2501
2519 p_82xx_addr_filt = 2502 p_82xx_addr_filt =
2520 (ucc_geth_82xx_address_filtering_pram_t *) ugeth-> 2503 (struct ucc_geth_82xx_address_filtering_pram *) ugeth->
2521 p_rx_glbl_pram->addressfiltering; 2504 p_rx_glbl_pram->addressfiltering;
2522 2505
2523 if (dev->flags & IFF_ALLMULTI) { 2506 if (dev->flags & IFF_ALLMULTI) {
@@ -2546,23 +2529,22 @@ static void ucc_geth_set_multi(struct net_device *dev)
2546 * copy bytes MSB first from dmi_addr. 2529 * copy bytes MSB first from dmi_addr.
2547 */ 2530 */
2548 mcptr = (u8 *) dmi->dmi_addr + 5; 2531 mcptr = (u8 *) dmi->dmi_addr + 5;
2549 tdptr = (u8 *) & tempaddr; 2532 tdptr = (u8 *) tempaddr;
2550 for (j = 0; j < 6; j++) 2533 for (j = 0; j < 6; j++)
2551 *tdptr++ = *mcptr--; 2534 *tdptr++ = *mcptr--;
2552 2535
2553 /* Ask CPM to run CRC and set bit in 2536 /* Ask CPM to run CRC and set bit in
2554 * filter mask. 2537 * filter mask.
2555 */ 2538 */
2556 hw_add_addr_in_hash(ugeth, &tempaddr); 2539 hw_add_addr_in_hash(ugeth, tempaddr);
2557
2558 } 2540 }
2559 } 2541 }
2560 } 2542 }
2561} 2543}
2562 2544
2563static void ucc_geth_stop(ucc_geth_private_t *ugeth) 2545static void ucc_geth_stop(struct ucc_geth_private *ugeth)
2564{ 2546{
2565 ucc_geth_t *ug_regs = ugeth->ug_regs; 2547 struct ucc_geth *ug_regs = ugeth->ug_regs;
2566 u32 tempval; 2548 u32 tempval;
2567 2549
2568 ugeth_vdbg("%s: IN", __FUNCTION__); 2550 ugeth_vdbg("%s: IN", __FUNCTION__);
@@ -2605,15 +2587,15 @@ static void ucc_geth_stop(ucc_geth_private_t *ugeth)
2605 ucc_geth_memclean(ugeth); 2587 ucc_geth_memclean(ugeth);
2606} 2588}
2607 2589
2608static int ucc_geth_startup(ucc_geth_private_t *ugeth) 2590static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2609{ 2591{
2610 ucc_geth_82xx_address_filtering_pram_t *p_82xx_addr_filt; 2592 struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt;
2611 ucc_geth_init_pram_t *p_init_enet_pram; 2593 struct ucc_geth_init_pram *p_init_enet_pram;
2612 ucc_fast_private_t *uccf; 2594 struct ucc_fast_private *uccf;
2613 ucc_geth_info_t *ug_info; 2595 struct ucc_geth_info *ug_info;
2614 ucc_fast_info_t *uf_info; 2596 struct ucc_fast_info *uf_info;
2615 ucc_fast_t *uf_regs; 2597 struct ucc_fast *uf_regs;
2616 ucc_geth_t *ug_regs; 2598 struct ucc_geth *ug_regs;
2617 int ret_val = -EINVAL; 2599 int ret_val = -EINVAL;
2618 u32 remoder = UCC_GETH_REMODER_INIT; 2600 u32 remoder = UCC_GETH_REMODER_INIT;
2619 u32 init_enet_pram_offset, cecr_subblock, command, maccfg1; 2601 u32 init_enet_pram_offset, cecr_subblock, command, maccfg1;
@@ -2788,7 +2770,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
2788 UCC_GETH_VLAN_OPERATION_NON_TAGGED_NOP); 2770 UCC_GETH_VLAN_OPERATION_NON_TAGGED_NOP);
2789 2771
2790 uf_regs = uccf->uf_regs; 2772 uf_regs = uccf->uf_regs;
2791 ug_regs = (ucc_geth_t *) (uccf->uf_regs); 2773 ug_regs = (struct ucc_geth *) (uccf->uf_regs);
2792 ugeth->ug_regs = ug_regs; 2774 ugeth->ug_regs = ug_regs;
2793 2775
2794 init_default_reg_vals(&uf_regs->upsmr, 2776 init_default_reg_vals(&uf_regs->upsmr,
@@ -2869,10 +2851,10 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
2869 /* Allocate in multiple of 2851 /* Allocate in multiple of
2870 UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT, 2852 UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT,
2871 according to spec */ 2853 according to spec */
2872 length = ((ug_info->bdRingLenTx[j] * UCC_GETH_SIZE_OF_BD) 2854 length = ((ug_info->bdRingLenTx[j] * sizeof(struct qe_bd))
2873 / UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT) 2855 / UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT)
2874 * UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT; 2856 * UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT;
2875 if ((ug_info->bdRingLenTx[j] * UCC_GETH_SIZE_OF_BD) % 2857 if ((ug_info->bdRingLenTx[j] * sizeof(struct qe_bd)) %
2876 UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT) 2858 UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT)
2877 length += UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT; 2859 length += UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT;
2878 if (uf_info->bd_mem_part == MEM_PART_SYSTEM) { 2860 if (uf_info->bd_mem_part == MEM_PART_SYSTEM) {
@@ -2904,13 +2886,13 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
2904 } 2886 }
2905 /* Zero unused end of bd ring, according to spec */ 2887 /* Zero unused end of bd ring, according to spec */
2906 memset(ugeth->p_tx_bd_ring[j] + 2888 memset(ugeth->p_tx_bd_ring[j] +
2907 ug_info->bdRingLenTx[j] * UCC_GETH_SIZE_OF_BD, 0, 2889 ug_info->bdRingLenTx[j] * sizeof(struct qe_bd), 0,
2908 length - ug_info->bdRingLenTx[j] * UCC_GETH_SIZE_OF_BD); 2890 length - ug_info->bdRingLenTx[j] * sizeof(struct qe_bd));
2909 } 2891 }
2910 2892
2911 /* Allocate Rx bds */ 2893 /* Allocate Rx bds */
2912 for (j = 0; j < ug_info->numQueuesRx; j++) { 2894 for (j = 0; j < ug_info->numQueuesRx; j++) {
2913 length = ug_info->bdRingLenRx[j] * UCC_GETH_SIZE_OF_BD; 2895 length = ug_info->bdRingLenRx[j] * sizeof(struct qe_bd);
2914 if (uf_info->bd_mem_part == MEM_PART_SYSTEM) { 2896 if (uf_info->bd_mem_part == MEM_PART_SYSTEM) {
2915 u32 align = 4; 2897 u32 align = 4;
2916 if (UCC_GETH_RX_BD_RING_ALIGNMENT > 4) 2898 if (UCC_GETH_RX_BD_RING_ALIGNMENT > 4)
@@ -2960,12 +2942,15 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
2960 ugeth->skb_curtx[j] = ugeth->skb_dirtytx[j] = 0; 2942 ugeth->skb_curtx[j] = ugeth->skb_dirtytx[j] = 0;
2961 bd = ugeth->confBd[j] = ugeth->txBd[j] = ugeth->p_tx_bd_ring[j]; 2943 bd = ugeth->confBd[j] = ugeth->txBd[j] = ugeth->p_tx_bd_ring[j];
2962 for (i = 0; i < ug_info->bdRingLenTx[j]; i++) { 2944 for (i = 0; i < ug_info->bdRingLenTx[j]; i++) {
2963 BD_BUFFER_CLEAR(bd); 2945 /* clear bd buffer */
2964 BD_STATUS_AND_LENGTH_SET(bd, 0); 2946 out_be32(&((struct qe_bd *)bd)->buf, 0);
2965 bd += UCC_GETH_SIZE_OF_BD; 2947 /* set bd status and length */
2948 out_be32((u32 *)bd, 0);
2949 bd += sizeof(struct qe_bd);
2966 } 2950 }
2967 bd -= UCC_GETH_SIZE_OF_BD; 2951 bd -= sizeof(struct qe_bd);
2968 BD_STATUS_AND_LENGTH_SET(bd, T_W);/* for last BD set Wrap bit */ 2952 /* set bd status and length */
2953 out_be32((u32 *)bd, T_W); /* for last BD set Wrap bit */
2969 } 2954 }
2970 2955
2971 /* Init Rx bds */ 2956 /* Init Rx bds */
@@ -2989,12 +2974,15 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
2989 ugeth->skb_currx[j] = 0; 2974 ugeth->skb_currx[j] = 0;
2990 bd = ugeth->rxBd[j] = ugeth->p_rx_bd_ring[j]; 2975 bd = ugeth->rxBd[j] = ugeth->p_rx_bd_ring[j];
2991 for (i = 0; i < ug_info->bdRingLenRx[j]; i++) { 2976 for (i = 0; i < ug_info->bdRingLenRx[j]; i++) {
2992 BD_STATUS_AND_LENGTH_SET(bd, R_I); 2977 /* set bd status and length */
2993 BD_BUFFER_CLEAR(bd); 2978 out_be32((u32 *)bd, R_I);
2994 bd += UCC_GETH_SIZE_OF_BD; 2979 /* clear bd buffer */
2980 out_be32(&((struct qe_bd *)bd)->buf, 0);
2981 bd += sizeof(struct qe_bd);
2995 } 2982 }
2996 bd -= UCC_GETH_SIZE_OF_BD; 2983 bd -= sizeof(struct qe_bd);
2997 BD_STATUS_AND_LENGTH_SET(bd, R_W);/* for last BD set Wrap bit */ 2984 /* set bd status and length */
2985 out_be32((u32 *)bd, R_W); /* for last BD set Wrap bit */
2998 } 2986 }
2999 2987
3000 /* 2988 /*
@@ -3003,7 +2991,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3003 /* Tx global PRAM */ 2991 /* Tx global PRAM */
3004 /* Allocate global tx parameter RAM page */ 2992 /* Allocate global tx parameter RAM page */
3005 ugeth->tx_glbl_pram_offset = 2993 ugeth->tx_glbl_pram_offset =
3006 qe_muram_alloc(sizeof(ucc_geth_tx_global_pram_t), 2994 qe_muram_alloc(sizeof(struct ucc_geth_tx_global_pram),
3007 UCC_GETH_TX_GLOBAL_PRAM_ALIGNMENT); 2995 UCC_GETH_TX_GLOBAL_PRAM_ALIGNMENT);
3008 if (IS_MURAM_ERR(ugeth->tx_glbl_pram_offset)) { 2996 if (IS_MURAM_ERR(ugeth->tx_glbl_pram_offset)) {
3009 ugeth_err 2997 ugeth_err
@@ -3013,10 +3001,10 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3013 return -ENOMEM; 3001 return -ENOMEM;
3014 } 3002 }
3015 ugeth->p_tx_glbl_pram = 3003 ugeth->p_tx_glbl_pram =
3016 (ucc_geth_tx_global_pram_t *) qe_muram_addr(ugeth-> 3004 (struct ucc_geth_tx_global_pram *) qe_muram_addr(ugeth->
3017 tx_glbl_pram_offset); 3005 tx_glbl_pram_offset);
3018 /* Zero out p_tx_glbl_pram */ 3006 /* Zero out p_tx_glbl_pram */
3019 memset(ugeth->p_tx_glbl_pram, 0, sizeof(ucc_geth_tx_global_pram_t)); 3007 memset(ugeth->p_tx_glbl_pram, 0, sizeof(struct ucc_geth_tx_global_pram));
3020 3008
3021 /* Fill global PRAM */ 3009 /* Fill global PRAM */
3022 3010
@@ -3024,7 +3012,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3024 /* Size varies with number of Tx threads */ 3012 /* Size varies with number of Tx threads */
3025 ugeth->thread_dat_tx_offset = 3013 ugeth->thread_dat_tx_offset =
3026 qe_muram_alloc(numThreadsTxNumerical * 3014 qe_muram_alloc(numThreadsTxNumerical *
3027 sizeof(ucc_geth_thread_data_tx_t) + 3015 sizeof(struct ucc_geth_thread_data_tx) +
3028 32 * (numThreadsTxNumerical == 1), 3016 32 * (numThreadsTxNumerical == 1),
3029 UCC_GETH_THREAD_DATA_ALIGNMENT); 3017 UCC_GETH_THREAD_DATA_ALIGNMENT);
3030 if (IS_MURAM_ERR(ugeth->thread_dat_tx_offset)) { 3018 if (IS_MURAM_ERR(ugeth->thread_dat_tx_offset)) {
@@ -3036,7 +3024,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3036 } 3024 }
3037 3025
3038 ugeth->p_thread_data_tx = 3026 ugeth->p_thread_data_tx =
3039 (ucc_geth_thread_data_tx_t *) qe_muram_addr(ugeth-> 3027 (struct ucc_geth_thread_data_tx *) qe_muram_addr(ugeth->
3040 thread_dat_tx_offset); 3028 thread_dat_tx_offset);
3041 out_be32(&ugeth->p_tx_glbl_pram->tqptr, ugeth->thread_dat_tx_offset); 3029 out_be32(&ugeth->p_tx_glbl_pram->tqptr, ugeth->thread_dat_tx_offset);
3042 3030
@@ -3053,7 +3041,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3053 /* Size varies with number of Tx queues */ 3041 /* Size varies with number of Tx queues */
3054 ugeth->send_q_mem_reg_offset = 3042 ugeth->send_q_mem_reg_offset =
3055 qe_muram_alloc(ug_info->numQueuesTx * 3043 qe_muram_alloc(ug_info->numQueuesTx *
3056 sizeof(ucc_geth_send_queue_qd_t), 3044 sizeof(struct ucc_geth_send_queue_qd),
3057 UCC_GETH_SEND_QUEUE_QUEUE_DESCRIPTOR_ALIGNMENT); 3045 UCC_GETH_SEND_QUEUE_QUEUE_DESCRIPTOR_ALIGNMENT);
3058 if (IS_MURAM_ERR(ugeth->send_q_mem_reg_offset)) { 3046 if (IS_MURAM_ERR(ugeth->send_q_mem_reg_offset)) {
3059 ugeth_err 3047 ugeth_err
@@ -3064,7 +3052,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3064 } 3052 }
3065 3053
3066 ugeth->p_send_q_mem_reg = 3054 ugeth->p_send_q_mem_reg =
3067 (ucc_geth_send_queue_mem_region_t *) qe_muram_addr(ugeth-> 3055 (struct ucc_geth_send_queue_mem_region *) qe_muram_addr(ugeth->
3068 send_q_mem_reg_offset); 3056 send_q_mem_reg_offset);
3069 out_be32(&ugeth->p_tx_glbl_pram->sqptr, ugeth->send_q_mem_reg_offset); 3057 out_be32(&ugeth->p_tx_glbl_pram->sqptr, ugeth->send_q_mem_reg_offset);
3070 3058
@@ -3073,7 +3061,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3073 for (i = 0; i < ug_info->numQueuesTx; i++) { 3061 for (i = 0; i < ug_info->numQueuesTx; i++) {
3074 endOfRing = 3062 endOfRing =
3075 ugeth->p_tx_bd_ring[i] + (ug_info->bdRingLenTx[i] - 3063 ugeth->p_tx_bd_ring[i] + (ug_info->bdRingLenTx[i] -
3076 1) * UCC_GETH_SIZE_OF_BD; 3064 1) * sizeof(struct qe_bd);
3077 if (ugeth->ug_info->uf_info.bd_mem_part == MEM_PART_SYSTEM) { 3065 if (ugeth->ug_info->uf_info.bd_mem_part == MEM_PART_SYSTEM) {
3078 out_be32(&ugeth->p_send_q_mem_reg->sqqd[i].bd_ring_base, 3066 out_be32(&ugeth->p_send_q_mem_reg->sqqd[i].bd_ring_base,
3079 (u32) virt_to_phys(ugeth->p_tx_bd_ring[i])); 3067 (u32) virt_to_phys(ugeth->p_tx_bd_ring[i]));
@@ -3096,7 +3084,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3096 if (ug_info->numQueuesTx > 1) { 3084 if (ug_info->numQueuesTx > 1) {
3097 /* scheduler exists only if more than 1 tx queue */ 3085 /* scheduler exists only if more than 1 tx queue */
3098 ugeth->scheduler_offset = 3086 ugeth->scheduler_offset =
3099 qe_muram_alloc(sizeof(ucc_geth_scheduler_t), 3087 qe_muram_alloc(sizeof(struct ucc_geth_scheduler),
3100 UCC_GETH_SCHEDULER_ALIGNMENT); 3088 UCC_GETH_SCHEDULER_ALIGNMENT);
3101 if (IS_MURAM_ERR(ugeth->scheduler_offset)) { 3089 if (IS_MURAM_ERR(ugeth->scheduler_offset)) {
3102 ugeth_err 3090 ugeth_err
@@ -3107,12 +3095,12 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3107 } 3095 }
3108 3096
3109 ugeth->p_scheduler = 3097 ugeth->p_scheduler =
3110 (ucc_geth_scheduler_t *) qe_muram_addr(ugeth-> 3098 (struct ucc_geth_scheduler *) qe_muram_addr(ugeth->
3111 scheduler_offset); 3099 scheduler_offset);
3112 out_be32(&ugeth->p_tx_glbl_pram->schedulerbasepointer, 3100 out_be32(&ugeth->p_tx_glbl_pram->schedulerbasepointer,
3113 ugeth->scheduler_offset); 3101 ugeth->scheduler_offset);
3114 /* Zero out p_scheduler */ 3102 /* Zero out p_scheduler */
3115 memset(ugeth->p_scheduler, 0, sizeof(ucc_geth_scheduler_t)); 3103 memset(ugeth->p_scheduler, 0, sizeof(struct ucc_geth_scheduler));
3116 3104
3117 /* Set values in scheduler */ 3105 /* Set values in scheduler */
3118 out_be32(&ugeth->p_scheduler->mblinterval, 3106 out_be32(&ugeth->p_scheduler->mblinterval,
@@ -3144,7 +3132,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3144 statisticsMode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_TX) { 3132 statisticsMode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_TX) {
3145 ugeth->tx_fw_statistics_pram_offset = 3133 ugeth->tx_fw_statistics_pram_offset =
3146 qe_muram_alloc(sizeof 3134 qe_muram_alloc(sizeof
3147 (ucc_geth_tx_firmware_statistics_pram_t), 3135 (struct ucc_geth_tx_firmware_statistics_pram),
3148 UCC_GETH_TX_STATISTICS_ALIGNMENT); 3136 UCC_GETH_TX_STATISTICS_ALIGNMENT);
3149 if (IS_MURAM_ERR(ugeth->tx_fw_statistics_pram_offset)) { 3137 if (IS_MURAM_ERR(ugeth->tx_fw_statistics_pram_offset)) {
3150 ugeth_err 3138 ugeth_err
@@ -3154,11 +3142,11 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3154 return -ENOMEM; 3142 return -ENOMEM;
3155 } 3143 }
3156 ugeth->p_tx_fw_statistics_pram = 3144 ugeth->p_tx_fw_statistics_pram =
3157 (ucc_geth_tx_firmware_statistics_pram_t *) 3145 (struct ucc_geth_tx_firmware_statistics_pram *)
3158 qe_muram_addr(ugeth->tx_fw_statistics_pram_offset); 3146 qe_muram_addr(ugeth->tx_fw_statistics_pram_offset);
3159 /* Zero out p_tx_fw_statistics_pram */ 3147 /* Zero out p_tx_fw_statistics_pram */
3160 memset(ugeth->p_tx_fw_statistics_pram, 3148 memset(ugeth->p_tx_fw_statistics_pram,
3161 0, sizeof(ucc_geth_tx_firmware_statistics_pram_t)); 3149 0, sizeof(struct ucc_geth_tx_firmware_statistics_pram));
3162 } 3150 }
3163 3151
3164 /* temoder */ 3152 /* temoder */
@@ -3183,7 +3171,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3183 /* Rx global PRAM */ 3171 /* Rx global PRAM */
3184 /* Allocate global rx parameter RAM page */ 3172 /* Allocate global rx parameter RAM page */
3185 ugeth->rx_glbl_pram_offset = 3173 ugeth->rx_glbl_pram_offset =
3186 qe_muram_alloc(sizeof(ucc_geth_rx_global_pram_t), 3174 qe_muram_alloc(sizeof(struct ucc_geth_rx_global_pram),
3187 UCC_GETH_RX_GLOBAL_PRAM_ALIGNMENT); 3175 UCC_GETH_RX_GLOBAL_PRAM_ALIGNMENT);
3188 if (IS_MURAM_ERR(ugeth->rx_glbl_pram_offset)) { 3176 if (IS_MURAM_ERR(ugeth->rx_glbl_pram_offset)) {
3189 ugeth_err 3177 ugeth_err
@@ -3193,10 +3181,10 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3193 return -ENOMEM; 3181 return -ENOMEM;
3194 } 3182 }
3195 ugeth->p_rx_glbl_pram = 3183 ugeth->p_rx_glbl_pram =
3196 (ucc_geth_rx_global_pram_t *) qe_muram_addr(ugeth-> 3184 (struct ucc_geth_rx_global_pram *) qe_muram_addr(ugeth->
3197 rx_glbl_pram_offset); 3185 rx_glbl_pram_offset);
3198 /* Zero out p_rx_glbl_pram */ 3186 /* Zero out p_rx_glbl_pram */
3199 memset(ugeth->p_rx_glbl_pram, 0, sizeof(ucc_geth_rx_global_pram_t)); 3187 memset(ugeth->p_rx_glbl_pram, 0, sizeof(struct ucc_geth_rx_global_pram));
3200 3188
3201 /* Fill global PRAM */ 3189 /* Fill global PRAM */
3202 3190
@@ -3204,7 +3192,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3204 /* Size varies with number of Rx threads */ 3192 /* Size varies with number of Rx threads */
3205 ugeth->thread_dat_rx_offset = 3193 ugeth->thread_dat_rx_offset =
3206 qe_muram_alloc(numThreadsRxNumerical * 3194 qe_muram_alloc(numThreadsRxNumerical *
3207 sizeof(ucc_geth_thread_data_rx_t), 3195 sizeof(struct ucc_geth_thread_data_rx),
3208 UCC_GETH_THREAD_DATA_ALIGNMENT); 3196 UCC_GETH_THREAD_DATA_ALIGNMENT);
3209 if (IS_MURAM_ERR(ugeth->thread_dat_rx_offset)) { 3197 if (IS_MURAM_ERR(ugeth->thread_dat_rx_offset)) {
3210 ugeth_err 3198 ugeth_err
@@ -3215,7 +3203,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3215 } 3203 }
3216 3204
3217 ugeth->p_thread_data_rx = 3205 ugeth->p_thread_data_rx =
3218 (ucc_geth_thread_data_rx_t *) qe_muram_addr(ugeth-> 3206 (struct ucc_geth_thread_data_rx *) qe_muram_addr(ugeth->
3219 thread_dat_rx_offset); 3207 thread_dat_rx_offset);
3220 out_be32(&ugeth->p_rx_glbl_pram->rqptr, ugeth->thread_dat_rx_offset); 3208 out_be32(&ugeth->p_rx_glbl_pram->rqptr, ugeth->thread_dat_rx_offset);
3221 3209
@@ -3227,7 +3215,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3227 statisticsMode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_RX) { 3215 statisticsMode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_RX) {
3228 ugeth->rx_fw_statistics_pram_offset = 3216 ugeth->rx_fw_statistics_pram_offset =
3229 qe_muram_alloc(sizeof 3217 qe_muram_alloc(sizeof
3230 (ucc_geth_rx_firmware_statistics_pram_t), 3218 (struct ucc_geth_rx_firmware_statistics_pram),
3231 UCC_GETH_RX_STATISTICS_ALIGNMENT); 3219 UCC_GETH_RX_STATISTICS_ALIGNMENT);
3232 if (IS_MURAM_ERR(ugeth->rx_fw_statistics_pram_offset)) { 3220 if (IS_MURAM_ERR(ugeth->rx_fw_statistics_pram_offset)) {
3233 ugeth_err 3221 ugeth_err
@@ -3237,11 +3225,11 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3237 return -ENOMEM; 3225 return -ENOMEM;
3238 } 3226 }
3239 ugeth->p_rx_fw_statistics_pram = 3227 ugeth->p_rx_fw_statistics_pram =
3240 (ucc_geth_rx_firmware_statistics_pram_t *) 3228 (struct ucc_geth_rx_firmware_statistics_pram *)
3241 qe_muram_addr(ugeth->rx_fw_statistics_pram_offset); 3229 qe_muram_addr(ugeth->rx_fw_statistics_pram_offset);
3242 /* Zero out p_rx_fw_statistics_pram */ 3230 /* Zero out p_rx_fw_statistics_pram */
3243 memset(ugeth->p_rx_fw_statistics_pram, 0, 3231 memset(ugeth->p_rx_fw_statistics_pram, 0,
3244 sizeof(ucc_geth_rx_firmware_statistics_pram_t)); 3232 sizeof(struct ucc_geth_rx_firmware_statistics_pram));
3245 } 3233 }
3246 3234
3247 /* intCoalescingPtr */ 3235 /* intCoalescingPtr */
@@ -3249,7 +3237,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3249 /* Size varies with number of Rx queues */ 3237 /* Size varies with number of Rx queues */
3250 ugeth->rx_irq_coalescing_tbl_offset = 3238 ugeth->rx_irq_coalescing_tbl_offset =
3251 qe_muram_alloc(ug_info->numQueuesRx * 3239 qe_muram_alloc(ug_info->numQueuesRx *
3252 sizeof(ucc_geth_rx_interrupt_coalescing_entry_t), 3240 sizeof(struct ucc_geth_rx_interrupt_coalescing_entry),
3253 UCC_GETH_RX_INTERRUPT_COALESCING_ALIGNMENT); 3241 UCC_GETH_RX_INTERRUPT_COALESCING_ALIGNMENT);
3254 if (IS_MURAM_ERR(ugeth->rx_irq_coalescing_tbl_offset)) { 3242 if (IS_MURAM_ERR(ugeth->rx_irq_coalescing_tbl_offset)) {
3255 ugeth_err 3243 ugeth_err
@@ -3260,7 +3248,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3260 } 3248 }
3261 3249
3262 ugeth->p_rx_irq_coalescing_tbl = 3250 ugeth->p_rx_irq_coalescing_tbl =
3263 (ucc_geth_rx_interrupt_coalescing_table_t *) 3251 (struct ucc_geth_rx_interrupt_coalescing_table *)
3264 qe_muram_addr(ugeth->rx_irq_coalescing_tbl_offset); 3252 qe_muram_addr(ugeth->rx_irq_coalescing_tbl_offset);
3265 out_be32(&ugeth->p_rx_glbl_pram->intcoalescingptr, 3253 out_be32(&ugeth->p_rx_glbl_pram->intcoalescingptr,
3266 ugeth->rx_irq_coalescing_tbl_offset); 3254 ugeth->rx_irq_coalescing_tbl_offset);
@@ -3300,7 +3288,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3300 l3qt = 0; 3288 l3qt = 0;
3301 for (i = 0; i < 8; i++) 3289 for (i = 0; i < 8; i++)
3302 l3qt |= (ug_info->l3qt[j + i] << (28 - 4 * i)); 3290 l3qt |= (ug_info->l3qt[j + i] << (28 - 4 * i));
3303 out_be32(&ugeth->p_rx_glbl_pram->l3qt[j], l3qt); 3291 out_be32(&ugeth->p_rx_glbl_pram->l3qt[j/8], l3qt);
3304 } 3292 }
3305 3293
3306 /* vlantype */ 3294 /* vlantype */
@@ -3316,8 +3304,8 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3316 /* Size varies with number of Rx queues */ 3304 /* Size varies with number of Rx queues */
3317 ugeth->rx_bd_qs_tbl_offset = 3305 ugeth->rx_bd_qs_tbl_offset =
3318 qe_muram_alloc(ug_info->numQueuesRx * 3306 qe_muram_alloc(ug_info->numQueuesRx *
3319 (sizeof(ucc_geth_rx_bd_queues_entry_t) + 3307 (sizeof(struct ucc_geth_rx_bd_queues_entry) +
3320 sizeof(ucc_geth_rx_prefetched_bds_t)), 3308 sizeof(struct ucc_geth_rx_prefetched_bds)),
3321 UCC_GETH_RX_BD_QUEUES_ALIGNMENT); 3309 UCC_GETH_RX_BD_QUEUES_ALIGNMENT);
3322 if (IS_MURAM_ERR(ugeth->rx_bd_qs_tbl_offset)) { 3310 if (IS_MURAM_ERR(ugeth->rx_bd_qs_tbl_offset)) {
3323 ugeth_err 3311 ugeth_err
@@ -3328,14 +3316,14 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3328 } 3316 }
3329 3317
3330 ugeth->p_rx_bd_qs_tbl = 3318 ugeth->p_rx_bd_qs_tbl =
3331 (ucc_geth_rx_bd_queues_entry_t *) qe_muram_addr(ugeth-> 3319 (struct ucc_geth_rx_bd_queues_entry *) qe_muram_addr(ugeth->
3332 rx_bd_qs_tbl_offset); 3320 rx_bd_qs_tbl_offset);
3333 out_be32(&ugeth->p_rx_glbl_pram->rbdqptr, ugeth->rx_bd_qs_tbl_offset); 3321 out_be32(&ugeth->p_rx_glbl_pram->rbdqptr, ugeth->rx_bd_qs_tbl_offset);
3334 /* Zero out p_rx_bd_qs_tbl */ 3322 /* Zero out p_rx_bd_qs_tbl */
3335 memset(ugeth->p_rx_bd_qs_tbl, 3323 memset(ugeth->p_rx_bd_qs_tbl,
3336 0, 3324 0,
3337 ug_info->numQueuesRx * (sizeof(ucc_geth_rx_bd_queues_entry_t) + 3325 ug_info->numQueuesRx * (sizeof(struct ucc_geth_rx_bd_queues_entry) +
3338 sizeof(ucc_geth_rx_prefetched_bds_t))); 3326 sizeof(struct ucc_geth_rx_prefetched_bds)));
3339 3327
3340 /* Setup the table */ 3328 /* Setup the table */
3341 /* Assume BD rings are already established */ 3329 /* Assume BD rings are already established */
@@ -3406,7 +3394,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3406 /* Allocate memory for extended filtering Mode Global 3394 /* Allocate memory for extended filtering Mode Global
3407 Parameters */ 3395 Parameters */
3408 ugeth->exf_glbl_param_offset = 3396 ugeth->exf_glbl_param_offset =
3409 qe_muram_alloc(sizeof(ucc_geth_exf_global_pram_t), 3397 qe_muram_alloc(sizeof(struct ucc_geth_exf_global_pram),
3410 UCC_GETH_RX_EXTENDED_FILTERING_GLOBAL_PARAMETERS_ALIGNMENT); 3398 UCC_GETH_RX_EXTENDED_FILTERING_GLOBAL_PARAMETERS_ALIGNMENT);
3411 if (IS_MURAM_ERR(ugeth->exf_glbl_param_offset)) { 3399 if (IS_MURAM_ERR(ugeth->exf_glbl_param_offset)) {
3412 ugeth_err 3400 ugeth_err
@@ -3417,7 +3405,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3417 } 3405 }
3418 3406
3419 ugeth->p_exf_glbl_param = 3407 ugeth->p_exf_glbl_param =
3420 (ucc_geth_exf_global_pram_t *) qe_muram_addr(ugeth-> 3408 (struct ucc_geth_exf_global_pram *) qe_muram_addr(ugeth->
3421 exf_glbl_param_offset); 3409 exf_glbl_param_offset);
3422 out_be32(&ugeth->p_rx_glbl_pram->exfGlobalParam, 3410 out_be32(&ugeth->p_rx_glbl_pram->exfGlobalParam,
3423 ugeth->exf_glbl_param_offset); 3411 ugeth->exf_glbl_param_offset);
@@ -3439,7 +3427,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3439 INIT_LIST_HEAD(&ugeth->ind_hash_q); 3427 INIT_LIST_HEAD(&ugeth->ind_hash_q);
3440 } 3428 }
3441 p_82xx_addr_filt = 3429 p_82xx_addr_filt =
3442 (ucc_geth_82xx_address_filtering_pram_t *) ugeth-> 3430 (struct ucc_geth_82xx_address_filtering_pram *) ugeth->
3443 p_rx_glbl_pram->addressfiltering; 3431 p_rx_glbl_pram->addressfiltering;
3444 3432
3445 ugeth_82xx_filtering_clear_all_addr_in_hash(ugeth, 3433 ugeth_82xx_filtering_clear_all_addr_in_hash(ugeth,
@@ -3462,7 +3450,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3462 * allocated resources can be released when the channel is freed. 3450 * allocated resources can be released when the channel is freed.
3463 */ 3451 */
3464 if (!(ugeth->p_init_enet_param_shadow = 3452 if (!(ugeth->p_init_enet_param_shadow =
3465 (ucc_geth_init_pram_t *) kmalloc(sizeof(ucc_geth_init_pram_t), 3453 (struct ucc_geth_init_pram *) kmalloc(sizeof(struct ucc_geth_init_pram),
3466 GFP_KERNEL))) { 3454 GFP_KERNEL))) {
3467 ugeth_err 3455 ugeth_err
3468 ("%s: Can not allocate memory for" 3456 ("%s: Can not allocate memory for"
@@ -3472,7 +3460,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3472 } 3460 }
3473 /* Zero out *p_init_enet_param_shadow */ 3461 /* Zero out *p_init_enet_param_shadow */
3474 memset((char *)ugeth->p_init_enet_param_shadow, 3462 memset((char *)ugeth->p_init_enet_param_shadow,
3475 0, sizeof(ucc_geth_init_pram_t)); 3463 0, sizeof(struct ucc_geth_init_pram));
3476 3464
3477 /* Fill shadow InitEnet command parameter structure */ 3465 /* Fill shadow InitEnet command parameter structure */
3478 3466
@@ -3506,7 +3494,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3506 } 3494 }
3507 ugeth->p_init_enet_param_shadow->largestexternallookupkeysize = 3495 ugeth->p_init_enet_param_shadow->largestexternallookupkeysize =
3508 ug_info->largestexternallookupkeysize; 3496 ug_info->largestexternallookupkeysize;
3509 size = sizeof(ucc_geth_thread_rx_pram_t); 3497 size = sizeof(struct ucc_geth_thread_rx_pram);
3510 if (ug_info->rxExtendedFiltering) { 3498 if (ug_info->rxExtendedFiltering) {
3511 size += THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING; 3499 size += THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING;
3512 if (ug_info->largestexternallookupkeysize == 3500 if (ug_info->largestexternallookupkeysize ==
@@ -3537,7 +3525,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3537 fill_init_enet_entries(ugeth, 3525 fill_init_enet_entries(ugeth,
3538 &(ugeth->p_init_enet_param_shadow-> 3526 &(ugeth->p_init_enet_param_shadow->
3539 txthread[0]), numThreadsTxNumerical, 3527 txthread[0]), numThreadsTxNumerical,
3540 sizeof(ucc_geth_thread_tx_pram_t), 3528 sizeof(struct ucc_geth_thread_tx_pram),
3541 UCC_GETH_THREAD_TX_PRAM_ALIGNMENT, 3529 UCC_GETH_THREAD_TX_PRAM_ALIGNMENT,
3542 ug_info->riscTx, 0)) != 0) { 3530 ug_info->riscTx, 0)) != 0) {
3543 ugeth_err("%s: Can not fill p_init_enet_param_shadow.", 3531 ugeth_err("%s: Can not fill p_init_enet_param_shadow.",
@@ -3557,7 +3545,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3557 } 3545 }
3558 3546
3559 /* Allocate InitEnet command parameter structure */ 3547 /* Allocate InitEnet command parameter structure */
3560 init_enet_pram_offset = qe_muram_alloc(sizeof(ucc_geth_init_pram_t), 4); 3548 init_enet_pram_offset = qe_muram_alloc(sizeof(struct ucc_geth_init_pram), 4);
3561 if (IS_MURAM_ERR(init_enet_pram_offset)) { 3549 if (IS_MURAM_ERR(init_enet_pram_offset)) {
3562 ugeth_err 3550 ugeth_err
3563 ("%s: Can not allocate DPRAM memory for p_init_enet_pram.", 3551 ("%s: Can not allocate DPRAM memory for p_init_enet_pram.",
@@ -3566,7 +3554,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3566 return -ENOMEM; 3554 return -ENOMEM;
3567 } 3555 }
3568 p_init_enet_pram = 3556 p_init_enet_pram =
3569 (ucc_geth_init_pram_t *) qe_muram_addr(init_enet_pram_offset); 3557 (struct ucc_geth_init_pram *) qe_muram_addr(init_enet_pram_offset);
3570 3558
3571 /* Copy shadow InitEnet command parameter structure into PRAM */ 3559 /* Copy shadow InitEnet command parameter structure into PRAM */
3572 p_init_enet_pram->resinit1 = ugeth->p_init_enet_param_shadow->resinit1; 3560 p_init_enet_pram->resinit1 = ugeth->p_init_enet_param_shadow->resinit1;
@@ -3591,7 +3579,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3591 /* Issue QE command */ 3579 /* Issue QE command */
3592 cecr_subblock = 3580 cecr_subblock =
3593 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info.ucc_num); 3581 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info.ucc_num);
3594 qe_issue_cmd(command, cecr_subblock, (u8) QE_CR_PROTOCOL_ETHERNET, 3582 qe_issue_cmd(command, cecr_subblock, QE_CR_PROTOCOL_ETHERNET,
3595 init_enet_pram_offset); 3583 init_enet_pram_offset);
3596 3584
3597 /* Free InitEnet command parameter */ 3585 /* Free InitEnet command parameter */
@@ -3603,7 +3591,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3603/* returns a net_device_stats structure pointer */ 3591/* returns a net_device_stats structure pointer */
3604static struct net_device_stats *ucc_geth_get_stats(struct net_device *dev) 3592static struct net_device_stats *ucc_geth_get_stats(struct net_device *dev)
3605{ 3593{
3606 ucc_geth_private_t *ugeth = netdev_priv(dev); 3594 struct ucc_geth_private *ugeth = netdev_priv(dev);
3607 3595
3608 return &(ugeth->stats); 3596 return &(ugeth->stats);
3609} 3597}
@@ -3614,7 +3602,7 @@ static struct net_device_stats *ucc_geth_get_stats(struct net_device *dev)
3614 * starting over will fix the problem. */ 3602 * starting over will fix the problem. */
3615static void ucc_geth_timeout(struct net_device *dev) 3603static void ucc_geth_timeout(struct net_device *dev)
3616{ 3604{
3617 ucc_geth_private_t *ugeth = netdev_priv(dev); 3605 struct ucc_geth_private *ugeth = netdev_priv(dev);
3618 3606
3619 ugeth_vdbg("%s: IN", __FUNCTION__); 3607 ugeth_vdbg("%s: IN", __FUNCTION__);
3620 3608
@@ -3634,7 +3622,7 @@ static void ucc_geth_timeout(struct net_device *dev)
3634/* It is pointed to by the dev->hard_start_xmit function pointer */ 3622/* It is pointed to by the dev->hard_start_xmit function pointer */
3635static int ucc_geth_start_xmit(struct sk_buff *skb, struct net_device *dev) 3623static int ucc_geth_start_xmit(struct sk_buff *skb, struct net_device *dev)
3636{ 3624{
3637 ucc_geth_private_t *ugeth = netdev_priv(dev); 3625 struct ucc_geth_private *ugeth = netdev_priv(dev);
3638 u8 *bd; /* BD pointer */ 3626 u8 *bd; /* BD pointer */
3639 u32 bd_status; 3627 u32 bd_status;
3640 u8 txQ = 0; 3628 u8 txQ = 0;
@@ -3647,7 +3635,7 @@ static int ucc_geth_start_xmit(struct sk_buff *skb, struct net_device *dev)
3647 3635
3648 /* Start from the next BD that should be filled */ 3636 /* Start from the next BD that should be filled */
3649 bd = ugeth->txBd[txQ]; 3637 bd = ugeth->txBd[txQ];
3650 bd_status = BD_STATUS_AND_LENGTH(bd); 3638 bd_status = in_be32((u32 *)bd);
3651 /* Save the skb pointer so we can free it later */ 3639 /* Save the skb pointer so we can free it later */
3652 ugeth->tx_skbuff[txQ][ugeth->skb_curtx[txQ]] = skb; 3640 ugeth->tx_skbuff[txQ][ugeth->skb_curtx[txQ]] = skb;
3653 3641
@@ -3657,20 +3645,21 @@ static int ucc_geth_start_xmit(struct sk_buff *skb, struct net_device *dev)
3657 1) & TX_RING_MOD_MASK(ugeth->ug_info->bdRingLenTx[txQ]); 3645 1) & TX_RING_MOD_MASK(ugeth->ug_info->bdRingLenTx[txQ]);
3658 3646
3659 /* set up the buffer descriptor */ 3647 /* set up the buffer descriptor */
3660 BD_BUFFER_SET(bd, 3648 out_be32(&((struct qe_bd *)bd)->buf,
3661 dma_map_single(NULL, skb->data, skb->len, DMA_TO_DEVICE)); 3649 dma_map_single(NULL, skb->data, skb->len, DMA_TO_DEVICE));
3662 3650
3663 //printk(KERN_DEBUG"skb->data is 0x%x\n",skb->data); 3651 /* printk(KERN_DEBUG"skb->data is 0x%x\n",skb->data); */
3664 3652
3665 bd_status = (bd_status & T_W) | T_R | T_I | T_L | skb->len; 3653 bd_status = (bd_status & T_W) | T_R | T_I | T_L | skb->len;
3666 3654
3667 BD_STATUS_AND_LENGTH_SET(bd, bd_status); 3655 /* set bd status and length */
3656 out_be32((u32 *)bd, bd_status);
3668 3657
3669 dev->trans_start = jiffies; 3658 dev->trans_start = jiffies;
3670 3659
3671 /* Move to next BD in the ring */ 3660 /* Move to next BD in the ring */
3672 if (!(bd_status & T_W)) 3661 if (!(bd_status & T_W))
3673 ugeth->txBd[txQ] = bd + UCC_GETH_SIZE_OF_BD; 3662 ugeth->txBd[txQ] = bd + sizeof(struct qe_bd);
3674 else 3663 else
3675 ugeth->txBd[txQ] = ugeth->p_tx_bd_ring[txQ]; 3664 ugeth->txBd[txQ] = ugeth->p_tx_bd_ring[txQ];
3676 3665
@@ -3695,7 +3684,7 @@ static int ucc_geth_start_xmit(struct sk_buff *skb, struct net_device *dev)
3695 return 0; 3684 return 0;
3696} 3685}
3697 3686
3698static int ucc_geth_rx(ucc_geth_private_t *ugeth, u8 rxQ, int rx_work_limit) 3687static int ucc_geth_rx(struct ucc_geth_private *ugeth, u8 rxQ, int rx_work_limit)
3699{ 3688{
3700 struct sk_buff *skb; 3689 struct sk_buff *skb;
3701 u8 *bd; 3690 u8 *bd;
@@ -3709,11 +3698,11 @@ static int ucc_geth_rx(ucc_geth_private_t *ugeth, u8 rxQ, int rx_work_limit)
3709 /* collect received buffers */ 3698 /* collect received buffers */
3710 bd = ugeth->rxBd[rxQ]; 3699 bd = ugeth->rxBd[rxQ];
3711 3700
3712 bd_status = BD_STATUS_AND_LENGTH(bd); 3701 bd_status = in_be32((u32 *)bd);
3713 3702
3714 /* while there are received buffers and BD is full (~R_E) */ 3703 /* while there are received buffers and BD is full (~R_E) */
3715 while (!((bd_status & (R_E)) || (--rx_work_limit < 0))) { 3704 while (!((bd_status & (R_E)) || (--rx_work_limit < 0))) {
3716 bdBuffer = (u8 *) BD_BUFFER(bd); 3705 bdBuffer = (u8 *) in_be32(&((struct qe_bd *)bd)->buf);
3717 length = (u16) ((bd_status & BD_LENGTH_MASK) - 4); 3706 length = (u16) ((bd_status & BD_LENGTH_MASK) - 4);
3718 skb = ugeth->rx_skbuff[rxQ][ugeth->skb_currx[rxQ]]; 3707 skb = ugeth->rx_skbuff[rxQ][ugeth->skb_currx[rxQ]];
3719 3708
@@ -3768,9 +3757,9 @@ static int ucc_geth_rx(ucc_geth_private_t *ugeth, u8 rxQ, int rx_work_limit)
3768 if (bd_status & R_W) 3757 if (bd_status & R_W)
3769 bd = ugeth->p_rx_bd_ring[rxQ]; 3758 bd = ugeth->p_rx_bd_ring[rxQ];
3770 else 3759 else
3771 bd += UCC_GETH_SIZE_OF_BD; 3760 bd += sizeof(struct qe_bd);
3772 3761
3773 bd_status = BD_STATUS_AND_LENGTH(bd); 3762 bd_status = in_be32((u32 *)bd);
3774 } 3763 }
3775 3764
3776 ugeth->rxBd[rxQ] = bd; 3765 ugeth->rxBd[rxQ] = bd;
@@ -3781,12 +3770,12 @@ static int ucc_geth_rx(ucc_geth_private_t *ugeth, u8 rxQ, int rx_work_limit)
3781static int ucc_geth_tx(struct net_device *dev, u8 txQ) 3770static int ucc_geth_tx(struct net_device *dev, u8 txQ)
3782{ 3771{
3783 /* Start from the next BD that should be filled */ 3772 /* Start from the next BD that should be filled */
3784 ucc_geth_private_t *ugeth = netdev_priv(dev); 3773 struct ucc_geth_private *ugeth = netdev_priv(dev);
3785 u8 *bd; /* BD pointer */ 3774 u8 *bd; /* BD pointer */
3786 u32 bd_status; 3775 u32 bd_status;
3787 3776
3788 bd = ugeth->confBd[txQ]; 3777 bd = ugeth->confBd[txQ];
3789 bd_status = BD_STATUS_AND_LENGTH(bd); 3778 bd_status = in_be32((u32 *)bd);
3790 3779
3791 /* Normal processing. */ 3780 /* Normal processing. */
3792 while ((bd_status & T_R) == 0) { 3781 while ((bd_status & T_R) == 0) {
@@ -3813,7 +3802,7 @@ static int ucc_geth_tx(struct net_device *dev, u8 txQ)
3813 3802
3814 /* Advance the confirmation BD pointer */ 3803 /* Advance the confirmation BD pointer */
3815 if (!(bd_status & T_W)) 3804 if (!(bd_status & T_W))
3816 ugeth->confBd[txQ] += UCC_GETH_SIZE_OF_BD; 3805 ugeth->confBd[txQ] += sizeof(struct qe_bd);
3817 else 3806 else
3818 ugeth->confBd[txQ] = ugeth->p_tx_bd_ring[txQ]; 3807 ugeth->confBd[txQ] = ugeth->p_tx_bd_ring[txQ];
3819 } 3808 }
@@ -3823,7 +3812,7 @@ static int ucc_geth_tx(struct net_device *dev, u8 txQ)
3823#ifdef CONFIG_UGETH_NAPI 3812#ifdef CONFIG_UGETH_NAPI
3824static int ucc_geth_poll(struct net_device *dev, int *budget) 3813static int ucc_geth_poll(struct net_device *dev, int *budget)
3825{ 3814{
3826 ucc_geth_private_t *ugeth = netdev_priv(dev); 3815 struct ucc_geth_private *ugeth = netdev_priv(dev);
3827 int howmany; 3816 int howmany;
3828 int rx_work_limit = *budget; 3817 int rx_work_limit = *budget;
3829 u8 rxQ = 0; 3818 u8 rxQ = 0;
@@ -3847,9 +3836,9 @@ static int ucc_geth_poll(struct net_device *dev, int *budget)
3847static irqreturn_t ucc_geth_irq_handler(int irq, void *info) 3836static irqreturn_t ucc_geth_irq_handler(int irq, void *info)
3848{ 3837{
3849 struct net_device *dev = (struct net_device *)info; 3838 struct net_device *dev = (struct net_device *)info;
3850 ucc_geth_private_t *ugeth = netdev_priv(dev); 3839 struct ucc_geth_private *ugeth = netdev_priv(dev);
3851 ucc_fast_private_t *uccf; 3840 struct ucc_fast_private *uccf;
3852 ucc_geth_info_t *ug_info; 3841 struct ucc_geth_info *ug_info;
3853 register u32 ucce = 0; 3842 register u32 ucce = 0;
3854 register u32 bit_mask = UCCE_RXBF_SINGLE_MASK; 3843 register u32 bit_mask = UCCE_RXBF_SINGLE_MASK;
3855 register u32 tx_mask = UCCE_TXBF_SINGLE_MASK; 3844 register u32 tx_mask = UCCE_TXBF_SINGLE_MASK;
@@ -3912,7 +3901,7 @@ static irqreturn_t ucc_geth_irq_handler(int irq, void *info)
3912static irqreturn_t phy_interrupt(int irq, void *dev_id) 3901static irqreturn_t phy_interrupt(int irq, void *dev_id)
3913{ 3902{
3914 struct net_device *dev = (struct net_device *)dev_id; 3903 struct net_device *dev = (struct net_device *)dev_id;
3915 ucc_geth_private_t *ugeth = netdev_priv(dev); 3904 struct ucc_geth_private *ugeth = netdev_priv(dev);
3916 3905
3917 ugeth_vdbg("%s: IN", __FUNCTION__); 3906 ugeth_vdbg("%s: IN", __FUNCTION__);
3918 3907
@@ -3932,8 +3921,8 @@ static irqreturn_t phy_interrupt(int irq, void *dev_id)
3932static void ugeth_phy_change(void *data) 3921static void ugeth_phy_change(void *data)
3933{ 3922{
3934 struct net_device *dev = (struct net_device *)data; 3923 struct net_device *dev = (struct net_device *)data;
3935 ucc_geth_private_t *ugeth = netdev_priv(dev); 3924 struct ucc_geth_private *ugeth = netdev_priv(dev);
3936 ucc_geth_t *ug_regs; 3925 struct ucc_geth *ug_regs;
3937 int result = 0; 3926 int result = 0;
3938 3927
3939 ugeth_vdbg("%s: IN", __FUNCTION__); 3928 ugeth_vdbg("%s: IN", __FUNCTION__);
@@ -3963,7 +3952,7 @@ static void ugeth_phy_change(void *data)
3963static void ugeth_phy_timer(unsigned long data) 3952static void ugeth_phy_timer(unsigned long data)
3964{ 3953{
3965 struct net_device *dev = (struct net_device *)data; 3954 struct net_device *dev = (struct net_device *)data;
3966 ucc_geth_private_t *ugeth = netdev_priv(dev); 3955 struct ucc_geth_private *ugeth = netdev_priv(dev);
3967 3956
3968 schedule_work(&ugeth->tq); 3957 schedule_work(&ugeth->tq);
3969 3958
@@ -3979,7 +3968,7 @@ static void ugeth_phy_timer(unsigned long data)
3979static void ugeth_phy_startup_timer(unsigned long data) 3968static void ugeth_phy_startup_timer(unsigned long data)
3980{ 3969{
3981 struct ugeth_mii_info *mii_info = (struct ugeth_mii_info *)data; 3970 struct ugeth_mii_info *mii_info = (struct ugeth_mii_info *)data;
3982 ucc_geth_private_t *ugeth = netdev_priv(mii_info->dev); 3971 struct ucc_geth_private *ugeth = netdev_priv(mii_info->dev);
3983 static int secondary = UGETH_AN_TIMEOUT; 3972 static int secondary = UGETH_AN_TIMEOUT;
3984 int result; 3973 int result;
3985 3974
@@ -4034,7 +4023,7 @@ static void ugeth_phy_startup_timer(unsigned long data)
4034/* Returns 0 for success. */ 4023/* Returns 0 for success. */
4035static int ucc_geth_open(struct net_device *dev) 4024static int ucc_geth_open(struct net_device *dev)
4036{ 4025{
4037 ucc_geth_private_t *ugeth = netdev_priv(dev); 4026 struct ucc_geth_private *ugeth = netdev_priv(dev);
4038 int err; 4027 int err;
4039 4028
4040 ugeth_vdbg("%s: IN", __FUNCTION__); 4029 ugeth_vdbg("%s: IN", __FUNCTION__);
@@ -4111,7 +4100,7 @@ static int ucc_geth_open(struct net_device *dev)
4111/* Stops the kernel queue, and halts the controller */ 4100/* Stops the kernel queue, and halts the controller */
4112static int ucc_geth_close(struct net_device *dev) 4101static int ucc_geth_close(struct net_device *dev)
4113{ 4102{
4114 ucc_geth_private_t *ugeth = netdev_priv(dev); 4103 struct ucc_geth_private *ugeth = netdev_priv(dev);
4115 4104
4116 ugeth_vdbg("%s: IN", __FUNCTION__); 4105 ugeth_vdbg("%s: IN", __FUNCTION__);
4117 4106
@@ -4130,30 +4119,53 @@ static int ucc_geth_close(struct net_device *dev)
4130 4119
4131const struct ethtool_ops ucc_geth_ethtool_ops = { }; 4120const struct ethtool_ops ucc_geth_ethtool_ops = { };
4132 4121
4133static int ucc_geth_probe(struct device *device) 4122static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *match)
4134{ 4123{
4135 struct platform_device *pdev = to_platform_device(device); 4124 struct device *device = &ofdev->dev;
4136 struct ucc_geth_platform_data *ugeth_pdata; 4125 struct device_node *np = ofdev->node;
4137 struct net_device *dev = NULL; 4126 struct net_device *dev = NULL;
4138 struct ucc_geth_private *ugeth = NULL; 4127 struct ucc_geth_private *ugeth = NULL;
4139 struct ucc_geth_info *ug_info; 4128 struct ucc_geth_info *ug_info;
4140 int err; 4129 struct resource res;
4130 struct device_node *phy;
4131 int err, ucc_num, phy_interface;
4141 static int mii_mng_configured = 0; 4132 static int mii_mng_configured = 0;
4133 const phandle *ph;
4134 const unsigned int *prop;
4142 4135
4143 ugeth_vdbg("%s: IN", __FUNCTION__); 4136 ugeth_vdbg("%s: IN", __FUNCTION__);
4144 4137
4145 ugeth_pdata = (struct ucc_geth_platform_data *)pdev->dev.platform_data; 4138 prop = get_property(np, "device-id", NULL);
4139 ucc_num = *prop - 1;
4140 if ((ucc_num < 0) || (ucc_num > 7))
4141 return -ENODEV;
4142
4143 ug_info = &ugeth_info[ucc_num];
4144 ug_info->uf_info.ucc_num = ucc_num;
4145 prop = get_property(np, "rx-clock", NULL);
4146 ug_info->uf_info.rx_clock = *prop;
4147 prop = get_property(np, "tx-clock", NULL);
4148 ug_info->uf_info.tx_clock = *prop;
4149 err = of_address_to_resource(np, 0, &res);
4150 if (err)
4151 return -EINVAL;
4152
4153 ug_info->uf_info.regs = res.start;
4154 ug_info->uf_info.irq = irq_of_parse_and_map(np, 0);
4155
4156 ph = get_property(np, "phy-handle", NULL);
4157 phy = of_find_node_by_phandle(*ph);
4146 4158
4147 ug_info = &ugeth_info[pdev->id]; 4159 if (phy == NULL)
4148 ug_info->uf_info.ucc_num = pdev->id; 4160 return -ENODEV;
4149 ug_info->uf_info.rx_clock = ugeth_pdata->rx_clock; 4161
4150 ug_info->uf_info.tx_clock = ugeth_pdata->tx_clock; 4162 prop = get_property(phy, "reg", NULL);
4151 ug_info->uf_info.regs = ugeth_pdata->phy_reg_addr; 4163 ug_info->phy_address = *prop;
4152 ug_info->uf_info.irq = platform_get_irq(pdev, 0); 4164 prop = get_property(phy, "interface", NULL);
4153 ug_info->phy_address = ugeth_pdata->phy_id; 4165 ug_info->enet_interface = *prop;
4154 ug_info->enet_interface = ugeth_pdata->phy_interface; 4166 ug_info->phy_interrupt = irq_of_parse_and_map(phy, 0);
4155 ug_info->board_flags = ugeth_pdata->board_flags; 4167 ug_info->board_flags = (ug_info->phy_interrupt == NO_IRQ)?
4156 ug_info->phy_interrupt = ugeth_pdata->phy_interrupt; 4168 0:FSL_UGETH_BRD_HAS_PHY_INTR;
4157 4169
4158 printk(KERN_INFO "ucc_geth: UCC%1d at 0x%8x (irq = %d) \n", 4170 printk(KERN_INFO "ucc_geth: UCC%1d at 0x%8x (irq = %d) \n",
4159 ug_info->uf_info.ucc_num + 1, ug_info->uf_info.regs, 4171 ug_info->uf_info.ucc_num + 1, ug_info->uf_info.regs,
@@ -4161,12 +4173,44 @@ static int ucc_geth_probe(struct device *device)
4161 4173
4162 if (ug_info == NULL) { 4174 if (ug_info == NULL) {
4163 ugeth_err("%s: [%d] Missing additional data!", __FUNCTION__, 4175 ugeth_err("%s: [%d] Missing additional data!", __FUNCTION__,
4164 pdev->id); 4176 ucc_num);
4165 return -ENODEV; 4177 return -ENODEV;
4166 } 4178 }
4167 4179
4180 /* FIXME: Work around for early chip rev. */
4181 /* There's a bug in initial chip rev(s) in the RGMII ac */
4182 /* timing. */
4183 /* The following compensates by writing to the reserved */
4184 /* QE Port Output Hold Registers (CPOH1?). */
4185 prop = get_property(phy, "interface", NULL);
4186 phy_interface = *prop;
4187 if ((phy_interface == ENET_1000_RGMII) ||
4188 (phy_interface == ENET_100_RGMII) ||
4189 (phy_interface == ENET_10_RGMII)) {
4190 struct device_node *soc;
4191 phys_addr_t immrbase = -1;
4192 u32 *tmp_reg;
4193 u32 tmp_val;
4194
4195 soc = of_find_node_by_type(NULL, "soc");
4196 if (soc) {
4197 unsigned int size;
4198 const void *prop = get_property(soc, "reg", &size);
4199 immrbase = of_translate_address(soc, prop);
4200 of_node_put(soc);
4201 };
4202
4203 tmp_reg = (u32 *) ioremap(immrbase + 0x14A8, 0x4);
4204 tmp_val = in_be32(tmp_reg);
4205 if (ucc_num == 1)
4206 out_be32(tmp_reg, tmp_val | 0x00003000);
4207 else if (ucc_num == 2)
4208 out_be32(tmp_reg, tmp_val | 0x0c000000);
4209 iounmap(tmp_reg);
4210 }
4211
4168 if (!mii_mng_configured) { 4212 if (!mii_mng_configured) {
4169 ucc_set_qe_mux_mii_mng(ug_info->uf_info.ucc_num); 4213 ucc_set_qe_mux_mii_mng(ucc_num);
4170 mii_mng_configured = 1; 4214 mii_mng_configured = 1;
4171 } 4215 }
4172 4216
@@ -4213,13 +4257,14 @@ static int ucc_geth_probe(struct device *device)
4213 4257
4214 ugeth->ug_info = ug_info; 4258 ugeth->ug_info = ug_info;
4215 ugeth->dev = dev; 4259 ugeth->dev = dev;
4216 memcpy(dev->dev_addr, ugeth_pdata->mac_addr, 6); 4260 memcpy(dev->dev_addr, get_property(np, "mac-address", NULL), 6);
4217 4261
4218 return 0; 4262 return 0;
4219} 4263}
4220 4264
4221static int ucc_geth_remove(struct device *device) 4265static int ucc_geth_remove(struct of_device* ofdev)
4222{ 4266{
4267 struct device *device = &ofdev->dev;
4223 struct net_device *dev = dev_get_drvdata(device); 4268 struct net_device *dev = dev_get_drvdata(device);
4224 struct ucc_geth_private *ugeth = netdev_priv(dev); 4269 struct ucc_geth_private *ugeth = netdev_priv(dev);
4225 4270
@@ -4230,28 +4275,38 @@ static int ucc_geth_remove(struct device *device)
4230 return 0; 4275 return 0;
4231} 4276}
4232 4277
4233/* Structure for a device driver */ 4278static struct of_device_id ucc_geth_match[] = {
4234static struct device_driver ucc_geth_driver = { 4279 {
4235 .name = DRV_NAME, 4280 .type = "network",
4236 .bus = &platform_bus_type, 4281 .compatible = "ucc_geth",
4237 .probe = ucc_geth_probe, 4282 },
4238 .remove = ucc_geth_remove, 4283 {},
4284};
4285
4286MODULE_DEVICE_TABLE(of, ucc_geth_match);
4287
4288static struct of_platform_driver ucc_geth_driver = {
4289 .name = DRV_NAME,
4290 .match_table = ucc_geth_match,
4291 .probe = ucc_geth_probe,
4292 .remove = ucc_geth_remove,
4239}; 4293};
4240 4294
4241static int __init ucc_geth_init(void) 4295static int __init ucc_geth_init(void)
4242{ 4296{
4243 int i; 4297 int i;
4298
4244 printk(KERN_INFO "ucc_geth: " DRV_DESC "\n"); 4299 printk(KERN_INFO "ucc_geth: " DRV_DESC "\n");
4245 for (i = 0; i < 8; i++) 4300 for (i = 0; i < 8; i++)
4246 memcpy(&(ugeth_info[i]), &ugeth_primary_info, 4301 memcpy(&(ugeth_info[i]), &ugeth_primary_info,
4247 sizeof(ugeth_primary_info)); 4302 sizeof(ugeth_primary_info));
4248 4303
4249 return driver_register(&ucc_geth_driver); 4304 return of_register_driver(&ucc_geth_driver);
4250} 4305}
4251 4306
4252static void __exit ucc_geth_exit(void) 4307static void __exit ucc_geth_exit(void)
4253{ 4308{
4254 driver_unregister(&ucc_geth_driver); 4309 of_unregister_driver(&ucc_geth_driver);
4255} 4310}
4256 4311
4257module_init(ucc_geth_init); 4312module_init(ucc_geth_init);
diff --git a/drivers/net/ucc_geth.h b/drivers/net/ucc_geth.h
index 005965f5dd9b..a66561253593 100644
--- a/drivers/net/ucc_geth.h
+++ b/drivers/net/ucc_geth.h
@@ -36,24 +36,24 @@
36#define ENET_INIT_PARAM_MAX_ENTRIES_RX 9 36#define ENET_INIT_PARAM_MAX_ENTRIES_RX 9
37#define ENET_INIT_PARAM_MAX_ENTRIES_TX 8 37#define ENET_INIT_PARAM_MAX_ENTRIES_TX 8
38 38
39typedef struct ucc_mii_mng { 39struct ucc_mii_mng {
40 u32 miimcfg; /* MII management configuration reg */ 40 u32 miimcfg; /* MII management configuration reg */
41 u32 miimcom; /* MII management command reg */ 41 u32 miimcom; /* MII management command reg */
42 u32 miimadd; /* MII management address reg */ 42 u32 miimadd; /* MII management address reg */
43 u32 miimcon; /* MII management control reg */ 43 u32 miimcon; /* MII management control reg */
44 u32 miimstat; /* MII management status reg */ 44 u32 miimstat; /* MII management status reg */
45 u32 miimind; /* MII management indication reg */ 45 u32 miimind; /* MII management indication reg */
46} __attribute__ ((packed)) ucc_mii_mng_t; 46} __attribute__ ((packed));
47 47
48typedef struct ucc_geth { 48struct ucc_geth {
49 ucc_fast_t uccf; 49 struct ucc_fast uccf;
50 50
51 u32 maccfg1; /* mac configuration reg. 1 */ 51 u32 maccfg1; /* mac configuration reg. 1 */
52 u32 maccfg2; /* mac configuration reg. 2 */ 52 u32 maccfg2; /* mac configuration reg. 2 */
53 u32 ipgifg; /* interframe gap reg. */ 53 u32 ipgifg; /* interframe gap reg. */
54 u32 hafdup; /* half-duplex reg. */ 54 u32 hafdup; /* half-duplex reg. */
55 u8 res1[0x10]; 55 u8 res1[0x10];
56 ucc_mii_mng_t miimng; /* MII management structure */ 56 struct ucc_mii_mng miimng; /* MII management structure */
57 u32 ifctl; /* interface control reg */ 57 u32 ifctl; /* interface control reg */
58 u32 ifstat; /* interface statux reg */ 58 u32 ifstat; /* interface statux reg */
59 u32 macstnaddr1; /* mac station address part 1 reg */ 59 u32 macstnaddr1; /* mac station address part 1 reg */
@@ -111,7 +111,7 @@ typedef struct ucc_geth {
111 u32 scar; /* Statistics carry register */ 111 u32 scar; /* Statistics carry register */
112 u32 scam; /* Statistics caryy mask register */ 112 u32 scam; /* Statistics caryy mask register */
113 u8 res5[0x200 - 0x1c4]; 113 u8 res5[0x200 - 0x1c4];
114} __attribute__ ((packed)) ucc_geth_t; 114} __attribute__ ((packed));
115 115
116/* UCC GETH TEMODR Register */ 116/* UCC GETH TEMODR Register */
117#define TEMODER_TX_RMON_STATISTICS_ENABLE 0x0100 /* enable Tx statistics 117#define TEMODER_TX_RMON_STATISTICS_ENABLE 0x0100 /* enable Tx statistics
@@ -508,39 +508,39 @@ typedef struct ucc_geth {
508/* UCC GETH UDSR (Data Synchronization Register) */ 508/* UCC GETH UDSR (Data Synchronization Register) */
509#define UDSR_MAGIC 0x067E 509#define UDSR_MAGIC 0x067E
510 510
511typedef struct ucc_geth_thread_data_tx { 511struct ucc_geth_thread_data_tx {
512 u8 res0[104]; 512 u8 res0[104];
513} __attribute__ ((packed)) ucc_geth_thread_data_tx_t; 513} __attribute__ ((packed));
514 514
515typedef struct ucc_geth_thread_data_rx { 515struct ucc_geth_thread_data_rx {
516 u8 res0[40]; 516 u8 res0[40];
517} __attribute__ ((packed)) ucc_geth_thread_data_rx_t; 517} __attribute__ ((packed));
518 518
519/* Send Queue Queue-Descriptor */ 519/* Send Queue Queue-Descriptor */
520typedef struct ucc_geth_send_queue_qd { 520struct ucc_geth_send_queue_qd {
521 u32 bd_ring_base; /* pointer to BD ring base address */ 521 u32 bd_ring_base; /* pointer to BD ring base address */
522 u8 res0[0x8]; 522 u8 res0[0x8];
523 u32 last_bd_completed_address;/* initialize to last entry in BD ring */ 523 u32 last_bd_completed_address;/* initialize to last entry in BD ring */
524 u8 res1[0x30]; 524 u8 res1[0x30];
525} __attribute__ ((packed)) ucc_geth_send_queue_qd_t; 525} __attribute__ ((packed));
526 526
527typedef struct ucc_geth_send_queue_mem_region { 527struct ucc_geth_send_queue_mem_region {
528 ucc_geth_send_queue_qd_t sqqd[NUM_TX_QUEUES]; 528 struct ucc_geth_send_queue_qd sqqd[NUM_TX_QUEUES];
529} __attribute__ ((packed)) ucc_geth_send_queue_mem_region_t; 529} __attribute__ ((packed));
530 530
531typedef struct ucc_geth_thread_tx_pram { 531struct ucc_geth_thread_tx_pram {
532 u8 res0[64]; 532 u8 res0[64];
533} __attribute__ ((packed)) ucc_geth_thread_tx_pram_t; 533} __attribute__ ((packed));
534 534
535typedef struct ucc_geth_thread_rx_pram { 535struct ucc_geth_thread_rx_pram {
536 u8 res0[128]; 536 u8 res0[128];
537} __attribute__ ((packed)) ucc_geth_thread_rx_pram_t; 537} __attribute__ ((packed));
538 538
539#define THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING 64 539#define THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING 64
540#define THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING_8 64 540#define THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING_8 64
541#define THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING_16 96 541#define THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING_16 96
542 542
543typedef struct ucc_geth_scheduler { 543struct ucc_geth_scheduler {
544 u16 cpucount0; /* CPU packet counter */ 544 u16 cpucount0; /* CPU packet counter */
545 u16 cpucount1; /* CPU packet counter */ 545 u16 cpucount1; /* CPU packet counter */
546 u16 cecount0; /* QE packet counter */ 546 u16 cecount0; /* QE packet counter */
@@ -574,9 +574,9 @@ typedef struct ucc_geth_scheduler {
574 /**< weight factor for queues */ 574 /**< weight factor for queues */
575 u32 minw; /* temporary variable handled by QE */ 575 u32 minw; /* temporary variable handled by QE */
576 u8 res1[0x70 - 0x64]; 576 u8 res1[0x70 - 0x64];
577} __attribute__ ((packed)) ucc_geth_scheduler_t; 577} __attribute__ ((packed));
578 578
579typedef struct ucc_geth_tx_firmware_statistics_pram { 579struct ucc_geth_tx_firmware_statistics_pram {
580 u32 sicoltx; /* single collision */ 580 u32 sicoltx; /* single collision */
581 u32 mulcoltx; /* multiple collision */ 581 u32 mulcoltx; /* multiple collision */
582 u32 latecoltxfr; /* late collision */ 582 u32 latecoltxfr; /* late collision */
@@ -596,9 +596,9 @@ typedef struct ucc_geth_tx_firmware_statistics_pram {
596 and 1518 octets */ 596 and 1518 octets */
597 u32 txpktsjumbo; /* total packets (including bad) between 1024 597 u32 txpktsjumbo; /* total packets (including bad) between 1024
598 and MAXLength octets */ 598 and MAXLength octets */
599} __attribute__ ((packed)) ucc_geth_tx_firmware_statistics_pram_t; 599} __attribute__ ((packed));
600 600
601typedef struct ucc_geth_rx_firmware_statistics_pram { 601struct ucc_geth_rx_firmware_statistics_pram {
602 u32 frrxfcser; /* frames with crc error */ 602 u32 frrxfcser; /* frames with crc error */
603 u32 fraligner; /* frames with alignment error */ 603 u32 fraligner; /* frames with alignment error */
604 u32 inrangelenrxer; /* in range length error */ 604 u32 inrangelenrxer; /* in range length error */
@@ -630,33 +630,33 @@ typedef struct ucc_geth_rx_firmware_statistics_pram {
630 replaced */ 630 replaced */
631 u32 insertvlan; /* total frames that had their VLAN tag 631 u32 insertvlan; /* total frames that had their VLAN tag
632 inserted */ 632 inserted */
633} __attribute__ ((packed)) ucc_geth_rx_firmware_statistics_pram_t; 633} __attribute__ ((packed));
634 634
635typedef struct ucc_geth_rx_interrupt_coalescing_entry { 635struct ucc_geth_rx_interrupt_coalescing_entry {
636 u32 interruptcoalescingmaxvalue; /* interrupt coalescing max 636 u32 interruptcoalescingmaxvalue; /* interrupt coalescing max
637 value */ 637 value */
638 u32 interruptcoalescingcounter; /* interrupt coalescing counter, 638 u32 interruptcoalescingcounter; /* interrupt coalescing counter,
639 initialize to 639 initialize to
640 interruptcoalescingmaxvalue */ 640 interruptcoalescingmaxvalue */
641} __attribute__ ((packed)) ucc_geth_rx_interrupt_coalescing_entry_t; 641} __attribute__ ((packed));
642 642
643typedef struct ucc_geth_rx_interrupt_coalescing_table { 643struct ucc_geth_rx_interrupt_coalescing_table {
644 ucc_geth_rx_interrupt_coalescing_entry_t coalescingentry[NUM_RX_QUEUES]; 644 struct ucc_geth_rx_interrupt_coalescing_entry coalescingentry[NUM_RX_QUEUES];
645 /**< interrupt coalescing entry */ 645 /**< interrupt coalescing entry */
646} __attribute__ ((packed)) ucc_geth_rx_interrupt_coalescing_table_t; 646} __attribute__ ((packed));
647 647
648typedef struct ucc_geth_rx_prefetched_bds { 648struct ucc_geth_rx_prefetched_bds {
649 qe_bd_t bd[NUM_BDS_IN_PREFETCHED_BDS]; /* prefetched bd */ 649 struct qe_bd bd[NUM_BDS_IN_PREFETCHED_BDS]; /* prefetched bd */
650} __attribute__ ((packed)) ucc_geth_rx_prefetched_bds_t; 650} __attribute__ ((packed));
651 651
652typedef struct ucc_geth_rx_bd_queues_entry { 652struct ucc_geth_rx_bd_queues_entry {
653 u32 bdbaseptr; /* BD base pointer */ 653 u32 bdbaseptr; /* BD base pointer */
654 u32 bdptr; /* BD pointer */ 654 u32 bdptr; /* BD pointer */
655 u32 externalbdbaseptr; /* external BD base pointer */ 655 u32 externalbdbaseptr; /* external BD base pointer */
656 u32 externalbdptr; /* external BD pointer */ 656 u32 externalbdptr; /* external BD pointer */
657} __attribute__ ((packed)) ucc_geth_rx_bd_queues_entry_t; 657} __attribute__ ((packed));
658 658
659typedef struct ucc_geth_tx_global_pram { 659struct ucc_geth_tx_global_pram {
660 u16 temoder; 660 u16 temoder;
661 u8 res0[0x38 - 0x02]; 661 u8 res0[0x38 - 0x02];
662 u32 sqptr; /* a base pointer to send queue memory region */ 662 u32 sqptr; /* a base pointer to send queue memory region */
@@ -670,15 +670,15 @@ typedef struct ucc_geth_tx_global_pram {
670 u32 tqptr; /* a base pointer to the Tx Queues Memory 670 u32 tqptr; /* a base pointer to the Tx Queues Memory
671 Region */ 671 Region */
672 u8 res2[0x80 - 0x74]; 672 u8 res2[0x80 - 0x74];
673} __attribute__ ((packed)) ucc_geth_tx_global_pram_t; 673} __attribute__ ((packed));
674 674
675/* structure representing Extended Filtering Global Parameters in PRAM */ 675/* structure representing Extended Filtering Global Parameters in PRAM */
676typedef struct ucc_geth_exf_global_pram { 676struct ucc_geth_exf_global_pram {
677 u32 l2pcdptr; /* individual address filter, high */ 677 u32 l2pcdptr; /* individual address filter, high */
678 u8 res0[0x10 - 0x04]; 678 u8 res0[0x10 - 0x04];
679} __attribute__ ((packed)) ucc_geth_exf_global_pram_t; 679} __attribute__ ((packed));
680 680
681typedef struct ucc_geth_rx_global_pram { 681struct ucc_geth_rx_global_pram {
682 u32 remoder; /* ethernet mode reg. */ 682 u32 remoder; /* ethernet mode reg. */
683 u32 rqptr; /* base pointer to the Rx Queues Memory Region*/ 683 u32 rqptr; /* base pointer to the Rx Queues Memory Region*/
684 u32 res0[0x1]; 684 u32 res0[0x1];
@@ -710,12 +710,12 @@ typedef struct ucc_geth_rx_global_pram {
710 u32 exfGlobalParam; /* base address for extended filtering global 710 u32 exfGlobalParam; /* base address for extended filtering global
711 parameters */ 711 parameters */
712 u8 res6[0x100 - 0xC4]; /* Initialize to zero */ 712 u8 res6[0x100 - 0xC4]; /* Initialize to zero */
713} __attribute__ ((packed)) ucc_geth_rx_global_pram_t; 713} __attribute__ ((packed));
714 714
715#define GRACEFUL_STOP_ACKNOWLEDGE_RX 0x01 715#define GRACEFUL_STOP_ACKNOWLEDGE_RX 0x01
716 716
717/* structure representing InitEnet command */ 717/* structure representing InitEnet command */
718typedef struct ucc_geth_init_pram { 718struct ucc_geth_init_pram {
719 u8 resinit1; 719 u8 resinit1;
720 u8 resinit2; 720 u8 resinit2;
721 u8 resinit3; 721 u8 resinit3;
@@ -729,7 +729,7 @@ typedef struct ucc_geth_init_pram {
729 u32 txglobal; /* tx global */ 729 u32 txglobal; /* tx global */
730 u32 txthread[ENET_INIT_PARAM_MAX_ENTRIES_TX]; /* tx threads */ 730 u32 txthread[ENET_INIT_PARAM_MAX_ENTRIES_TX]; /* tx threads */
731 u8 res3[0x1]; 731 u8 res3[0x1];
732} __attribute__ ((packed)) ucc_geth_init_pram_t; 732} __attribute__ ((packed));
733 733
734#define ENET_INIT_PARAM_RGF_SHIFT (32 - 4) 734#define ENET_INIT_PARAM_RGF_SHIFT (32 - 4)
735#define ENET_INIT_PARAM_TGF_SHIFT (32 - 8) 735#define ENET_INIT_PARAM_TGF_SHIFT (32 - 8)
@@ -746,27 +746,27 @@ typedef struct ucc_geth_init_pram {
746#define ENET_INIT_PARAM_MAGIC_RES_INIT5 0x0400 746#define ENET_INIT_PARAM_MAGIC_RES_INIT5 0x0400
747 747
748/* structure representing 82xx Address Filtering Enet Address in PRAM */ 748/* structure representing 82xx Address Filtering Enet Address in PRAM */
749typedef struct ucc_geth_82xx_enet_address { 749struct ucc_geth_82xx_enet_address {
750 u8 res1[0x2]; 750 u8 res1[0x2];
751 u16 h; /* address (MSB) */ 751 u16 h; /* address (MSB) */
752 u16 m; /* address */ 752 u16 m; /* address */
753 u16 l; /* address (LSB) */ 753 u16 l; /* address (LSB) */
754} __attribute__ ((packed)) ucc_geth_82xx_enet_address_t; 754} __attribute__ ((packed));
755 755
756/* structure representing 82xx Address Filtering PRAM */ 756/* structure representing 82xx Address Filtering PRAM */
757typedef struct ucc_geth_82xx_address_filtering_pram { 757struct ucc_geth_82xx_address_filtering_pram {
758 u32 iaddr_h; /* individual address filter, high */ 758 u32 iaddr_h; /* individual address filter, high */
759 u32 iaddr_l; /* individual address filter, low */ 759 u32 iaddr_l; /* individual address filter, low */
760 u32 gaddr_h; /* group address filter, high */ 760 u32 gaddr_h; /* group address filter, high */
761 u32 gaddr_l; /* group address filter, low */ 761 u32 gaddr_l; /* group address filter, low */
762 ucc_geth_82xx_enet_address_t taddr; 762 struct ucc_geth_82xx_enet_address taddr;
763 ucc_geth_82xx_enet_address_t paddr[NUM_OF_PADDRS]; 763 struct ucc_geth_82xx_enet_address paddr[NUM_OF_PADDRS];
764 u8 res0[0x40 - 0x38]; 764 u8 res0[0x40 - 0x38];
765} __attribute__ ((packed)) ucc_geth_82xx_address_filtering_pram_t; 765} __attribute__ ((packed));
766 766
767/* GETH Tx firmware statistics structure, used when calling 767/* GETH Tx firmware statistics structure, used when calling
768 UCC_GETH_GetStatistics. */ 768 UCC_GETH_GetStatistics. */
769typedef struct ucc_geth_tx_firmware_statistics { 769struct ucc_geth_tx_firmware_statistics {
770 u32 sicoltx; /* single collision */ 770 u32 sicoltx; /* single collision */
771 u32 mulcoltx; /* multiple collision */ 771 u32 mulcoltx; /* multiple collision */
772 u32 latecoltxfr; /* late collision */ 772 u32 latecoltxfr; /* late collision */
@@ -786,11 +786,11 @@ typedef struct ucc_geth_tx_firmware_statistics {
786 and 1518 octets */ 786 and 1518 octets */
787 u32 txpktsjumbo; /* total packets (including bad) between 1024 787 u32 txpktsjumbo; /* total packets (including bad) between 1024
788 and MAXLength octets */ 788 and MAXLength octets */
789} __attribute__ ((packed)) ucc_geth_tx_firmware_statistics_t; 789} __attribute__ ((packed));
790 790
791/* GETH Rx firmware statistics structure, used when calling 791/* GETH Rx firmware statistics structure, used when calling
792 UCC_GETH_GetStatistics. */ 792 UCC_GETH_GetStatistics. */
793typedef struct ucc_geth_rx_firmware_statistics { 793struct ucc_geth_rx_firmware_statistics {
794 u32 frrxfcser; /* frames with crc error */ 794 u32 frrxfcser; /* frames with crc error */
795 u32 fraligner; /* frames with alignment error */ 795 u32 fraligner; /* frames with alignment error */
796 u32 inrangelenrxer; /* in range length error */ 796 u32 inrangelenrxer; /* in range length error */
@@ -822,11 +822,11 @@ typedef struct ucc_geth_rx_firmware_statistics {
822 replaced */ 822 replaced */
823 u32 insertvlan; /* total frames that had their VLAN tag 823 u32 insertvlan; /* total frames that had their VLAN tag
824 inserted */ 824 inserted */
825} __attribute__ ((packed)) ucc_geth_rx_firmware_statistics_t; 825} __attribute__ ((packed));
826 826
827/* GETH hardware statistics structure, used when calling 827/* GETH hardware statistics structure, used when calling
828 UCC_GETH_GetStatistics. */ 828 UCC_GETH_GetStatistics. */
829typedef struct ucc_geth_hardware_statistics { 829struct ucc_geth_hardware_statistics {
830 u32 tx64; /* Total number of frames (including bad 830 u32 tx64; /* Total number of frames (including bad
831 frames) transmitted that were exactly of the 831 frames) transmitted that were exactly of the
832 minimal length (64 for un tagged, 68 for 832 minimal length (64 for un tagged, 68 for
@@ -871,7 +871,7 @@ typedef struct ucc_geth_hardware_statistics {
871 u32 rbca; /* Total number of frames received succesfully 871 u32 rbca; /* Total number of frames received succesfully
872 that had destination address equal to the 872 that had destination address equal to the
873 broadcast address */ 873 broadcast address */
874} __attribute__ ((packed)) ucc_geth_hardware_statistics_t; 874} __attribute__ ((packed));
875 875
876/* UCC GETH Tx errors returned via TxConf callback */ 876/* UCC GETH Tx errors returned via TxConf callback */
877#define TX_ERRORS_DEF 0x0200 877#define TX_ERRORS_DEF 0x0200
@@ -1013,21 +1013,21 @@ typedef struct ucc_geth_hardware_statistics {
1013 (MIIMCFG_MANAGEMENT_CLOCK_DIVIDE_BY_112) 1013 (MIIMCFG_MANAGEMENT_CLOCK_DIVIDE_BY_112)
1014 1014
1015/* Ethernet speed */ 1015/* Ethernet speed */
1016typedef enum enet_speed { 1016enum enet_speed {
1017 ENET_SPEED_10BT, /* 10 Base T */ 1017 ENET_SPEED_10BT, /* 10 Base T */
1018 ENET_SPEED_100BT, /* 100 Base T */ 1018 ENET_SPEED_100BT, /* 100 Base T */
1019 ENET_SPEED_1000BT /* 1000 Base T */ 1019 ENET_SPEED_1000BT /* 1000 Base T */
1020} enet_speed_e; 1020};
1021 1021
1022/* Ethernet Address Type. */ 1022/* Ethernet Address Type. */
1023typedef enum enet_addr_type { 1023enum enet_addr_type {
1024 ENET_ADDR_TYPE_INDIVIDUAL, 1024 ENET_ADDR_TYPE_INDIVIDUAL,
1025 ENET_ADDR_TYPE_GROUP, 1025 ENET_ADDR_TYPE_GROUP,
1026 ENET_ADDR_TYPE_BROADCAST 1026 ENET_ADDR_TYPE_BROADCAST
1027} enet_addr_type_e; 1027};
1028 1028
1029/* TBI / MII Set Register */ 1029/* TBI / MII Set Register */
1030typedef enum enet_tbi_mii_reg { 1030enum enet_tbi_mii_reg {
1031 ENET_TBI_MII_CR = 0x00, /* Control (CR ) */ 1031 ENET_TBI_MII_CR = 0x00, /* Control (CR ) */
1032 ENET_TBI_MII_SR = 0x01, /* Status (SR ) */ 1032 ENET_TBI_MII_SR = 0x01, /* Status (SR ) */
1033 ENET_TBI_MII_ANA = 0x04, /* AN advertisement (ANA ) */ 1033 ENET_TBI_MII_ANA = 0x04, /* AN advertisement (ANA ) */
@@ -1040,10 +1040,10 @@ typedef enum enet_tbi_mii_reg {
1040 ENET_TBI_MII_EXST = 0x0F, /* Extended status (EXST ) */ 1040 ENET_TBI_MII_EXST = 0x0F, /* Extended status (EXST ) */
1041 ENET_TBI_MII_JD = 0x10, /* Jitter diagnostics (JD ) */ 1041 ENET_TBI_MII_JD = 0x10, /* Jitter diagnostics (JD ) */
1042 ENET_TBI_MII_TBICON = 0x11 /* TBI control (TBICON ) */ 1042 ENET_TBI_MII_TBICON = 0x11 /* TBI control (TBICON ) */
1043} enet_tbi_mii_reg_e; 1043};
1044 1044
1045/* UCC GETH 82xx Ethernet Address Recognition Location */ 1045/* UCC GETH 82xx Ethernet Address Recognition Location */
1046typedef enum ucc_geth_enet_address_recognition_location { 1046enum ucc_geth_enet_address_recognition_location {
1047 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_STATION_ADDRESS,/* station 1047 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_STATION_ADDRESS,/* station
1048 address */ 1048 address */
1049 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_PADDR_FIRST, /* additional 1049 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_PADDR_FIRST, /* additional
@@ -1065,10 +1065,10 @@ typedef enum ucc_geth_enet_address_recognition_location {
1065 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_GROUP_HASH, /* group hash */ 1065 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_GROUP_HASH, /* group hash */
1066 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_INDIVIDUAL_HASH /* individual 1066 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_INDIVIDUAL_HASH /* individual
1067 hash */ 1067 hash */
1068} ucc_geth_enet_address_recognition_location_e; 1068};
1069 1069
1070/* UCC GETH vlan operation tagged */ 1070/* UCC GETH vlan operation tagged */
1071typedef enum ucc_geth_vlan_operation_tagged { 1071enum ucc_geth_vlan_operation_tagged {
1072 UCC_GETH_VLAN_OPERATION_TAGGED_NOP = 0x0, /* Tagged - nop */ 1072 UCC_GETH_VLAN_OPERATION_TAGGED_NOP = 0x0, /* Tagged - nop */
1073 UCC_GETH_VLAN_OPERATION_TAGGED_REPLACE_VID_PORTION_OF_Q_TAG 1073 UCC_GETH_VLAN_OPERATION_TAGGED_REPLACE_VID_PORTION_OF_Q_TAG
1074 = 0x1, /* Tagged - replace vid portion of q tag */ 1074 = 0x1, /* Tagged - replace vid portion of q tag */
@@ -1076,18 +1076,18 @@ typedef enum ucc_geth_vlan_operation_tagged {
1076 = 0x2, /* Tagged - if vid0 replace vid with default value */ 1076 = 0x2, /* Tagged - if vid0 replace vid with default value */
1077 UCC_GETH_VLAN_OPERATION_TAGGED_EXTRACT_Q_TAG_FROM_FRAME 1077 UCC_GETH_VLAN_OPERATION_TAGGED_EXTRACT_Q_TAG_FROM_FRAME
1078 = 0x3 /* Tagged - extract q tag from frame */ 1078 = 0x3 /* Tagged - extract q tag from frame */
1079} ucc_geth_vlan_operation_tagged_e; 1079};
1080 1080
1081/* UCC GETH vlan operation non-tagged */ 1081/* UCC GETH vlan operation non-tagged */
1082typedef enum ucc_geth_vlan_operation_non_tagged { 1082enum ucc_geth_vlan_operation_non_tagged {
1083 UCC_GETH_VLAN_OPERATION_NON_TAGGED_NOP = 0x0, /* Non tagged - nop */ 1083 UCC_GETH_VLAN_OPERATION_NON_TAGGED_NOP = 0x0, /* Non tagged - nop */
1084 UCC_GETH_VLAN_OPERATION_NON_TAGGED_Q_TAG_INSERT = 0x1 /* Non tagged - 1084 UCC_GETH_VLAN_OPERATION_NON_TAGGED_Q_TAG_INSERT = 0x1 /* Non tagged -
1085 q tag insert 1085 q tag insert
1086 */ 1086 */
1087} ucc_geth_vlan_operation_non_tagged_e; 1087};
1088 1088
1089/* UCC GETH Rx Quality of Service Mode */ 1089/* UCC GETH Rx Quality of Service Mode */
1090typedef enum ucc_geth_qos_mode { 1090enum ucc_geth_qos_mode {
1091 UCC_GETH_QOS_MODE_DEFAULT = 0x0, /* default queue */ 1091 UCC_GETH_QOS_MODE_DEFAULT = 0x0, /* default queue */
1092 UCC_GETH_QOS_MODE_QUEUE_NUM_FROM_L2_CRITERIA = 0x1, /* queue 1092 UCC_GETH_QOS_MODE_QUEUE_NUM_FROM_L2_CRITERIA = 0x1, /* queue
1093 determined 1093 determined
@@ -1097,11 +1097,11 @@ typedef enum ucc_geth_qos_mode {
1097 determined 1097 determined
1098 by L3 1098 by L3
1099 criteria */ 1099 criteria */
1100} ucc_geth_qos_mode_e; 1100};
1101 1101
1102/* UCC GETH Statistics Gathering Mode - These are bit flags, 'or' them together 1102/* UCC GETH Statistics Gathering Mode - These are bit flags, 'or' them together
1103 for combined functionality */ 1103 for combined functionality */
1104typedef enum ucc_geth_statistics_gathering_mode { 1104enum ucc_geth_statistics_gathering_mode {
1105 UCC_GETH_STATISTICS_GATHERING_MODE_NONE = 0x00000000, /* No 1105 UCC_GETH_STATISTICS_GATHERING_MODE_NONE = 0x00000000, /* No
1106 statistics 1106 statistics
1107 gathering */ 1107 gathering */
@@ -1122,10 +1122,10 @@ typedef enum ucc_geth_statistics_gathering_mode {
1122 statistics 1122 statistics
1123 gathering 1123 gathering
1124 */ 1124 */
1125} ucc_geth_statistics_gathering_mode_e; 1125};
1126 1126
1127/* UCC GETH Pad and CRC Mode - Note, Padding without CRC is not possible */ 1127/* UCC GETH Pad and CRC Mode - Note, Padding without CRC is not possible */
1128typedef enum ucc_geth_maccfg2_pad_and_crc_mode { 1128enum ucc_geth_maccfg2_pad_and_crc_mode {
1129 UCC_GETH_PAD_AND_CRC_MODE_NONE 1129 UCC_GETH_PAD_AND_CRC_MODE_NONE
1130 = MACCFG2_PAD_AND_CRC_MODE_NONE, /* Neither Padding 1130 = MACCFG2_PAD_AND_CRC_MODE_NONE, /* Neither Padding
1131 short frames 1131 short frames
@@ -1135,61 +1135,59 @@ typedef enum ucc_geth_maccfg2_pad_and_crc_mode {
1135 CRC only */ 1135 CRC only */
1136 UCC_GETH_PAD_AND_CRC_MODE_PAD_AND_CRC = 1136 UCC_GETH_PAD_AND_CRC_MODE_PAD_AND_CRC =
1137 MACCFG2_PAD_AND_CRC_MODE_PAD_AND_CRC 1137 MACCFG2_PAD_AND_CRC_MODE_PAD_AND_CRC
1138} ucc_geth_maccfg2_pad_and_crc_mode_e; 1138};
1139 1139
1140/* UCC GETH upsmr Flow Control Mode */ 1140/* UCC GETH upsmr Flow Control Mode */
1141typedef enum ucc_geth_flow_control_mode { 1141enum ucc_geth_flow_control_mode {
1142 UPSMR_AUTOMATIC_FLOW_CONTROL_MODE_NONE = 0x00000000, /* No automatic 1142 UPSMR_AUTOMATIC_FLOW_CONTROL_MODE_NONE = 0x00000000, /* No automatic
1143 flow control 1143 flow control
1144 */ 1144 */
1145 UPSMR_AUTOMATIC_FLOW_CONTROL_MODE_PAUSE_WHEN_EMERGENCY 1145 UPSMR_AUTOMATIC_FLOW_CONTROL_MODE_PAUSE_WHEN_EMERGENCY
1146 = 0x00004000 /* Send pause frame when RxFIFO reaches its 1146 = 0x00004000 /* Send pause frame when RxFIFO reaches its
1147 emergency threshold */ 1147 emergency threshold */
1148} ucc_geth_flow_control_mode_e; 1148};
1149 1149
1150/* UCC GETH number of threads */ 1150/* UCC GETH number of threads */
1151typedef enum ucc_geth_num_of_threads { 1151enum ucc_geth_num_of_threads {
1152 UCC_GETH_NUM_OF_THREADS_1 = 0x1, /* 1 */ 1152 UCC_GETH_NUM_OF_THREADS_1 = 0x1, /* 1 */
1153 UCC_GETH_NUM_OF_THREADS_2 = 0x2, /* 2 */ 1153 UCC_GETH_NUM_OF_THREADS_2 = 0x2, /* 2 */
1154 UCC_GETH_NUM_OF_THREADS_4 = 0x0, /* 4 */ 1154 UCC_GETH_NUM_OF_THREADS_4 = 0x0, /* 4 */
1155 UCC_GETH_NUM_OF_THREADS_6 = 0x3, /* 6 */ 1155 UCC_GETH_NUM_OF_THREADS_6 = 0x3, /* 6 */
1156 UCC_GETH_NUM_OF_THREADS_8 = 0x4 /* 8 */ 1156 UCC_GETH_NUM_OF_THREADS_8 = 0x4 /* 8 */
1157} ucc_geth_num_of_threads_e; 1157};
1158 1158
1159/* UCC GETH number of station addresses */ 1159/* UCC GETH number of station addresses */
1160typedef enum ucc_geth_num_of_station_addresses { 1160enum ucc_geth_num_of_station_addresses {
1161 UCC_GETH_NUM_OF_STATION_ADDRESSES_1, /* 1 */ 1161 UCC_GETH_NUM_OF_STATION_ADDRESSES_1, /* 1 */
1162 UCC_GETH_NUM_OF_STATION_ADDRESSES_5 /* 5 */ 1162 UCC_GETH_NUM_OF_STATION_ADDRESSES_5 /* 5 */
1163} ucc_geth_num_of_station_addresses_e; 1163};
1164
1165typedef u8 enet_addr_t[ENET_NUM_OCTETS_PER_ADDRESS];
1166 1164
1167/* UCC GETH 82xx Ethernet Address Container */ 1165/* UCC GETH 82xx Ethernet Address Container */
1168typedef struct enet_addr_container { 1166struct enet_addr_container {
1169 enet_addr_t address; /* ethernet address */ 1167 u8 address[ENET_NUM_OCTETS_PER_ADDRESS]; /* ethernet address */
1170 ucc_geth_enet_address_recognition_location_e location; /* location in 1168 enum ucc_geth_enet_address_recognition_location location; /* location in
1171 82xx address 1169 82xx address
1172 recognition 1170 recognition
1173 hardware */ 1171 hardware */
1174 struct list_head node; 1172 struct list_head node;
1175} enet_addr_container_t; 1173};
1176 1174
1177#define ENET_ADDR_CONT_ENTRY(ptr) list_entry(ptr, enet_addr_container_t, node) 1175#define ENET_ADDR_CONT_ENTRY(ptr) list_entry(ptr, struct enet_addr_container, node)
1178 1176
1179/* UCC GETH Termination Action Descriptor (TAD) structure. */ 1177/* UCC GETH Termination Action Descriptor (TAD) structure. */
1180typedef struct ucc_geth_tad_params { 1178struct ucc_geth_tad_params {
1181 int rx_non_dynamic_extended_features_mode; 1179 int rx_non_dynamic_extended_features_mode;
1182 int reject_frame; 1180 int reject_frame;
1183 ucc_geth_vlan_operation_tagged_e vtag_op; 1181 enum ucc_geth_vlan_operation_tagged vtag_op;
1184 ucc_geth_vlan_operation_non_tagged_e vnontag_op; 1182 enum ucc_geth_vlan_operation_non_tagged vnontag_op;
1185 ucc_geth_qos_mode_e rqos; 1183 enum ucc_geth_qos_mode rqos;
1186 u8 vpri; 1184 u8 vpri;
1187 u16 vid; 1185 u16 vid;
1188} ucc_geth_tad_params_t; 1186};
1189 1187
1190/* GETH protocol initialization structure */ 1188/* GETH protocol initialization structure */
1191typedef struct ucc_geth_info { 1189struct ucc_geth_info {
1192 ucc_fast_info_t uf_info; 1190 struct ucc_fast_info uf_info;
1193 u8 numQueuesTx; 1191 u8 numQueuesTx;
1194 u8 numQueuesRx; 1192 u8 numQueuesRx;
1195 int ipCheckSumCheck; 1193 int ipCheckSumCheck;
@@ -1251,51 +1249,51 @@ typedef struct ucc_geth_info {
1251 u8 iphoffset[TX_IP_OFFSET_ENTRY_MAX]; 1249 u8 iphoffset[TX_IP_OFFSET_ENTRY_MAX];
1252 u16 bdRingLenTx[NUM_TX_QUEUES]; 1250 u16 bdRingLenTx[NUM_TX_QUEUES];
1253 u16 bdRingLenRx[NUM_RX_QUEUES]; 1251 u16 bdRingLenRx[NUM_RX_QUEUES];
1254 enet_interface_e enet_interface; 1252 enum enet_interface enet_interface;
1255 ucc_geth_num_of_station_addresses_e numStationAddresses; 1253 enum ucc_geth_num_of_station_addresses numStationAddresses;
1256 qe_fltr_largest_external_tbl_lookup_key_size_e 1254 enum qe_fltr_largest_external_tbl_lookup_key_size
1257 largestexternallookupkeysize; 1255 largestexternallookupkeysize;
1258 ucc_geth_statistics_gathering_mode_e statisticsMode; 1256 enum ucc_geth_statistics_gathering_mode statisticsMode;
1259 ucc_geth_vlan_operation_tagged_e vlanOperationTagged; 1257 enum ucc_geth_vlan_operation_tagged vlanOperationTagged;
1260 ucc_geth_vlan_operation_non_tagged_e vlanOperationNonTagged; 1258 enum ucc_geth_vlan_operation_non_tagged vlanOperationNonTagged;
1261 ucc_geth_qos_mode_e rxQoSMode; 1259 enum ucc_geth_qos_mode rxQoSMode;
1262 ucc_geth_flow_control_mode_e aufc; 1260 enum ucc_geth_flow_control_mode aufc;
1263 ucc_geth_maccfg2_pad_and_crc_mode_e padAndCrc; 1261 enum ucc_geth_maccfg2_pad_and_crc_mode padAndCrc;
1264 ucc_geth_num_of_threads_e numThreadsTx; 1262 enum ucc_geth_num_of_threads numThreadsTx;
1265 ucc_geth_num_of_threads_e numThreadsRx; 1263 enum ucc_geth_num_of_threads numThreadsRx;
1266 qe_risc_allocation_e riscTx; 1264 enum qe_risc_allocation riscTx;
1267 qe_risc_allocation_e riscRx; 1265 enum qe_risc_allocation riscRx;
1268} ucc_geth_info_t; 1266};
1269 1267
1270/* structure representing UCC GETH */ 1268/* structure representing UCC GETH */
1271typedef struct ucc_geth_private { 1269struct ucc_geth_private {
1272 ucc_geth_info_t *ug_info; 1270 struct ucc_geth_info *ug_info;
1273 ucc_fast_private_t *uccf; 1271 struct ucc_fast_private *uccf;
1274 struct net_device *dev; 1272 struct net_device *dev;
1275 struct net_device_stats stats; /* linux network statistics */ 1273 struct net_device_stats stats; /* linux network statistics */
1276 ucc_geth_t *ug_regs; 1274 struct ucc_geth *ug_regs;
1277 ucc_geth_init_pram_t *p_init_enet_param_shadow; 1275 struct ucc_geth_init_pram *p_init_enet_param_shadow;
1278 ucc_geth_exf_global_pram_t *p_exf_glbl_param; 1276 struct ucc_geth_exf_global_pram *p_exf_glbl_param;
1279 u32 exf_glbl_param_offset; 1277 u32 exf_glbl_param_offset;
1280 ucc_geth_rx_global_pram_t *p_rx_glbl_pram; 1278 struct ucc_geth_rx_global_pram *p_rx_glbl_pram;
1281 u32 rx_glbl_pram_offset; 1279 u32 rx_glbl_pram_offset;
1282 ucc_geth_tx_global_pram_t *p_tx_glbl_pram; 1280 struct ucc_geth_tx_global_pram *p_tx_glbl_pram;
1283 u32 tx_glbl_pram_offset; 1281 u32 tx_glbl_pram_offset;
1284 ucc_geth_send_queue_mem_region_t *p_send_q_mem_reg; 1282 struct ucc_geth_send_queue_mem_region *p_send_q_mem_reg;
1285 u32 send_q_mem_reg_offset; 1283 u32 send_q_mem_reg_offset;
1286 ucc_geth_thread_data_tx_t *p_thread_data_tx; 1284 struct ucc_geth_thread_data_tx *p_thread_data_tx;
1287 u32 thread_dat_tx_offset; 1285 u32 thread_dat_tx_offset;
1288 ucc_geth_thread_data_rx_t *p_thread_data_rx; 1286 struct ucc_geth_thread_data_rx *p_thread_data_rx;
1289 u32 thread_dat_rx_offset; 1287 u32 thread_dat_rx_offset;
1290 ucc_geth_scheduler_t *p_scheduler; 1288 struct ucc_geth_scheduler *p_scheduler;
1291 u32 scheduler_offset; 1289 u32 scheduler_offset;
1292 ucc_geth_tx_firmware_statistics_pram_t *p_tx_fw_statistics_pram; 1290 struct ucc_geth_tx_firmware_statistics_pram *p_tx_fw_statistics_pram;
1293 u32 tx_fw_statistics_pram_offset; 1291 u32 tx_fw_statistics_pram_offset;
1294 ucc_geth_rx_firmware_statistics_pram_t *p_rx_fw_statistics_pram; 1292 struct ucc_geth_rx_firmware_statistics_pram *p_rx_fw_statistics_pram;
1295 u32 rx_fw_statistics_pram_offset; 1293 u32 rx_fw_statistics_pram_offset;
1296 ucc_geth_rx_interrupt_coalescing_table_t *p_rx_irq_coalescing_tbl; 1294 struct ucc_geth_rx_interrupt_coalescing_table *p_rx_irq_coalescing_tbl;
1297 u32 rx_irq_coalescing_tbl_offset; 1295 u32 rx_irq_coalescing_tbl_offset;
1298 ucc_geth_rx_bd_queues_entry_t *p_rx_bd_qs_tbl; 1296 struct ucc_geth_rx_bd_queues_entry *p_rx_bd_qs_tbl;
1299 u32 rx_bd_qs_tbl_offset; 1297 u32 rx_bd_qs_tbl_offset;
1300 u8 *p_tx_bd_ring[NUM_TX_QUEUES]; 1298 u8 *p_tx_bd_ring[NUM_TX_QUEUES];
1301 u32 tx_bd_ring_offset[NUM_TX_QUEUES]; 1299 u32 tx_bd_ring_offset[NUM_TX_QUEUES];
@@ -1308,7 +1306,7 @@ typedef struct ucc_geth_private {
1308 u16 cpucount[NUM_TX_QUEUES]; 1306 u16 cpucount[NUM_TX_QUEUES];
1309 volatile u16 *p_cpucount[NUM_TX_QUEUES]; 1307 volatile u16 *p_cpucount[NUM_TX_QUEUES];
1310 int indAddrRegUsed[NUM_OF_PADDRS]; 1308 int indAddrRegUsed[NUM_OF_PADDRS];
1311 enet_addr_t paddr[NUM_OF_PADDRS]; 1309 u8 paddr[NUM_OF_PADDRS][ENET_NUM_OCTETS_PER_ADDRESS]; /* ethernet address */
1312 u8 numGroupAddrInHash; 1310 u8 numGroupAddrInHash;
1313 u8 numIndAddrInHash; 1311 u8 numIndAddrInHash;
1314 u8 numIndAddrInReg; 1312 u8 numIndAddrInReg;
@@ -1334,6 +1332,6 @@ typedef struct ucc_geth_private {
1334 int oldspeed; 1332 int oldspeed;
1335 int oldduplex; 1333 int oldduplex;
1336 int oldlink; 1334 int oldlink;
1337} ucc_geth_private_t; 1335};
1338 1336
1339#endif /* __UCC_GETH_H__ */ 1337#endif /* __UCC_GETH_H__ */
diff --git a/drivers/net/ucc_geth_phy.c b/drivers/net/ucc_geth_phy.c
index 67260eb3188a..5360ec05eaa3 100644
--- a/drivers/net/ucc_geth_phy.c
+++ b/drivers/net/ucc_geth_phy.c
@@ -42,7 +42,6 @@
42 42
43#include "ucc_geth.h" 43#include "ucc_geth.h"
44#include "ucc_geth_phy.h" 44#include "ucc_geth_phy.h"
45#include <platforms/83xx/mpc8360e_pb.h>
46 45
47#define ugphy_printk(level, format, arg...) \ 46#define ugphy_printk(level, format, arg...) \
48 printk(level format "\n", ## arg) 47 printk(level format "\n", ## arg)
@@ -72,16 +71,14 @@ static int genmii_read_status(struct ugeth_mii_info *mii_info);
72u16 phy_read(struct ugeth_mii_info *mii_info, u16 regnum); 71u16 phy_read(struct ugeth_mii_info *mii_info, u16 regnum);
73void phy_write(struct ugeth_mii_info *mii_info, u16 regnum, u16 val); 72void phy_write(struct ugeth_mii_info *mii_info, u16 regnum, u16 val);
74 73
75static u8 *bcsr_regs = NULL;
76
77/* Write value to the PHY for this device to the register at regnum, */ 74/* Write value to the PHY for this device to the register at regnum, */
78/* waiting until the write is done before it returns. All PHY */ 75/* waiting until the write is done before it returns. All PHY */
79/* configuration has to be done through the TSEC1 MIIM regs */ 76/* configuration has to be done through the TSEC1 MIIM regs */
80void write_phy_reg(struct net_device *dev, int mii_id, int regnum, int value) 77void write_phy_reg(struct net_device *dev, int mii_id, int regnum, int value)
81{ 78{
82 ucc_geth_private_t *ugeth = netdev_priv(dev); 79 struct ucc_geth_private *ugeth = netdev_priv(dev);
83 ucc_mii_mng_t *mii_regs; 80 struct ucc_mii_mng *mii_regs;
84 enet_tbi_mii_reg_e mii_reg = (enet_tbi_mii_reg_e) regnum; 81 enum enet_tbi_mii_reg mii_reg = (enum enet_tbi_mii_reg) regnum;
85 u32 tmp_reg; 82 u32 tmp_reg;
86 83
87 ugphy_vdbg("%s: IN", __FUNCTION__); 84 ugphy_vdbg("%s: IN", __FUNCTION__);
@@ -116,9 +113,9 @@ void write_phy_reg(struct net_device *dev, int mii_id, int regnum, int value)
116/* configuration has to be done through the TSEC1 MIIM regs */ 113/* configuration has to be done through the TSEC1 MIIM regs */
117int read_phy_reg(struct net_device *dev, int mii_id, int regnum) 114int read_phy_reg(struct net_device *dev, int mii_id, int regnum)
118{ 115{
119 ucc_geth_private_t *ugeth = netdev_priv(dev); 116 struct ucc_geth_private *ugeth = netdev_priv(dev);
120 ucc_mii_mng_t *mii_regs; 117 struct ucc_mii_mng *mii_regs;
121 enet_tbi_mii_reg_e mii_reg = (enet_tbi_mii_reg_e) regnum; 118 enum enet_tbi_mii_reg mii_reg = (enum enet_tbi_mii_reg) regnum;
122 u32 tmp_reg; 119 u32 tmp_reg;
123 u16 value; 120 u16 value;
124 121
@@ -634,11 +631,6 @@ static void dm9161_close(struct ugeth_mii_info *mii_info)
634 631
635static int dm9161_ack_interrupt(struct ugeth_mii_info *mii_info) 632static int dm9161_ack_interrupt(struct ugeth_mii_info *mii_info)
636{ 633{
637/* FIXME: This lines are for BUG fixing in the mpc8325.
638Remove this from here when it's fixed */
639 if (bcsr_regs == NULL)
640 bcsr_regs = (u8 *) ioremap(BCSR_PHYS_ADDR, BCSR_SIZE);
641 bcsr_regs[14] |= 0x40;
642 ugphy_vdbg("%s: IN", __FUNCTION__); 634 ugphy_vdbg("%s: IN", __FUNCTION__);
643 635
644 /* Clear the interrupts by reading the reg */ 636 /* Clear the interrupts by reading the reg */
@@ -650,12 +642,6 @@ Remove this from here when it's fixed */
650 642
651static int dm9161_config_intr(struct ugeth_mii_info *mii_info) 643static int dm9161_config_intr(struct ugeth_mii_info *mii_info)
652{ 644{
653/* FIXME: This lines are for BUG fixing in the mpc8325.
654Remove this from here when it's fixed */
655 if (bcsr_regs == NULL) {
656 bcsr_regs = (u8 *) ioremap(BCSR_PHYS_ADDR, BCSR_SIZE);
657 bcsr_regs[14] &= ~0x40;
658 }
659 ugphy_vdbg("%s: IN", __FUNCTION__); 645 ugphy_vdbg("%s: IN", __FUNCTION__);
660 646
661 if (mii_info->interrupts == MII_INTERRUPT_ENABLED) 647 if (mii_info->interrupts == MII_INTERRUPT_ENABLED)
diff --git a/drivers/net/ucc_geth_phy.h b/drivers/net/ucc_geth_phy.h
index 2f98b8f1bb0a..f5740783670f 100644
--- a/drivers/net/ucc_geth_phy.h
+++ b/drivers/net/ucc_geth_phy.h
@@ -126,7 +126,7 @@ struct ugeth_mii_info {
126 /* And management functions */ 126 /* And management functions */
127 struct phy_info *phyinfo; 127 struct phy_info *phyinfo;
128 128
129 ucc_mii_mng_t *mii_regs; 129 struct ucc_mii_mng *mii_regs;
130 130
131 /* forced speed & duplex (no autoneg) 131 /* forced speed & duplex (no autoneg)
132 * partner speed & duplex & pause (autoneg) 132 * partner speed & duplex & pause (autoneg)
diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig
index 58b7efbb0750..b5d0d7fb647a 100644
--- a/drivers/net/wan/Kconfig
+++ b/drivers/net/wan/Kconfig
@@ -127,7 +127,7 @@ config LANMEDIA
127# There is no way to detect a Sealevel board. Force it modular 127# There is no way to detect a Sealevel board. Force it modular
128config SEALEVEL_4021 128config SEALEVEL_4021
129 tristate "Sealevel Systems 4021 support" 129 tristate "Sealevel Systems 4021 support"
130 depends on WAN && ISA && m && ISA_DMA_API 130 depends on WAN && ISA && m && ISA_DMA_API && INET
131 help 131 help
132 This is a driver for the Sealevel Systems ACB 56 serial I/O adapter. 132 This is a driver for the Sealevel Systems ACB 56 serial I/O adapter.
133 133
diff --git a/drivers/net/wan/n2.c b/drivers/net/wan/n2.c
index dcf46add3adf..5c322dfb79f6 100644
--- a/drivers/net/wan/n2.c
+++ b/drivers/net/wan/n2.c
@@ -500,7 +500,7 @@ static int __init n2_init(void)
500#ifdef MODULE 500#ifdef MODULE
501 printk(KERN_INFO "n2: no card initialized\n"); 501 printk(KERN_INFO "n2: no card initialized\n");
502#endif 502#endif
503 return -ENOSYS; /* no parameters specified, abort */ 503 return -EINVAL; /* no parameters specified, abort */
504 } 504 }
505 505
506 printk(KERN_INFO "%s\n", version); 506 printk(KERN_INFO "%s\n", version);
@@ -538,11 +538,11 @@ static int __init n2_init(void)
538 n2_run(io, irq, ram, valid[0], valid[1]); 538 n2_run(io, irq, ram, valid[0], valid[1]);
539 539
540 if (*hw == '\x0') 540 if (*hw == '\x0')
541 return first_card ? 0 : -ENOSYS; 541 return first_card ? 0 : -EINVAL;
542 }while(*hw++ == ':'); 542 }while(*hw++ == ':');
543 543
544 printk(KERN_ERR "n2: invalid hardware parameters\n"); 544 printk(KERN_ERR "n2: invalid hardware parameters\n");
545 return first_card ? 0 : -ENOSYS; 545 return first_card ? 0 : -EINVAL;
546} 546}
547 547
548 548
diff --git a/drivers/net/wan/pc300_drv.c b/drivers/net/wan/pc300_drv.c
index 5823e3bca178..36d1c3ff7078 100644
--- a/drivers/net/wan/pc300_drv.c
+++ b/drivers/net/wan/pc300_drv.c
@@ -2867,7 +2867,6 @@ static int ch_config(pc300dev_t * d)
2867 uclong clktype = chan->conf.phys_settings.clock_type; 2867 uclong clktype = chan->conf.phys_settings.clock_type;
2868 ucshort encoding = chan->conf.proto_settings.encoding; 2868 ucshort encoding = chan->conf.proto_settings.encoding;
2869 ucshort parity = chan->conf.proto_settings.parity; 2869 ucshort parity = chan->conf.proto_settings.parity;
2870 int tmc, br;
2871 ucchar md0, md2; 2870 ucchar md0, md2;
2872 2871
2873 /* Reset the channel */ 2872 /* Reset the channel */
@@ -2940,8 +2939,12 @@ static int ch_config(pc300dev_t * d)
2940 case PC300_RSV: 2939 case PC300_RSV:
2941 case PC300_X21: 2940 case PC300_X21:
2942 if (clktype == CLOCK_INT || clktype == CLOCK_TXINT) { 2941 if (clktype == CLOCK_INT || clktype == CLOCK_TXINT) {
2942 int tmc, br;
2943
2943 /* Calculate the clkrate parameters */ 2944 /* Calculate the clkrate parameters */
2944 tmc = clock_rate_calc(clkrate, card->hw.clock, &br); 2945 tmc = clock_rate_calc(clkrate, card->hw.clock, &br);
2946 if (tmc < 0)
2947 return -EIO;
2945 cpc_writeb(scabase + M_REG(TMCT, ch), tmc); 2948 cpc_writeb(scabase + M_REG(TMCT, ch), tmc);
2946 cpc_writeb(scabase + M_REG(TXS, ch), 2949 cpc_writeb(scabase + M_REG(TXS, ch),
2947 (TXS_DTRXC | TXS_IBRG | br)); 2950 (TXS_DTRXC | TXS_IBRG | br));
@@ -3097,14 +3100,16 @@ static int cpc_attach(struct net_device *dev, unsigned short encoding,
3097 return 0; 3100 return 0;
3098} 3101}
3099 3102
3100static void cpc_opench(pc300dev_t * d) 3103static int cpc_opench(pc300dev_t * d)
3101{ 3104{
3102 pc300ch_t *chan = (pc300ch_t *) d->chan; 3105 pc300ch_t *chan = (pc300ch_t *) d->chan;
3103 pc300_t *card = (pc300_t *) chan->card; 3106 pc300_t *card = (pc300_t *) chan->card;
3104 int ch = chan->channel; 3107 int ch = chan->channel, rc;
3105 void __iomem *scabase = card->hw.scabase; 3108 void __iomem *scabase = card->hw.scabase;
3106 3109
3107 ch_config(d); 3110 rc = ch_config(d);
3111 if (rc)
3112 return rc;
3108 3113
3109 rx_config(d); 3114 rx_config(d);
3110 3115
@@ -3113,6 +3118,8 @@ static void cpc_opench(pc300dev_t * d)
3113 /* Assert RTS and DTR */ 3118 /* Assert RTS and DTR */
3114 cpc_writeb(scabase + M_REG(CTL, ch), 3119 cpc_writeb(scabase + M_REG(CTL, ch),
3115 cpc_readb(scabase + M_REG(CTL, ch)) & ~(CTL_RTS | CTL_DTR)); 3120 cpc_readb(scabase + M_REG(CTL, ch)) & ~(CTL_RTS | CTL_DTR));
3121
3122 return 0;
3116} 3123}
3117 3124
3118static void cpc_closech(pc300dev_t * d) 3125static void cpc_closech(pc300dev_t * d)
@@ -3168,9 +3175,16 @@ int cpc_open(struct net_device *dev)
3168 } 3175 }
3169 3176
3170 sprintf(ifr.ifr_name, "%s", dev->name); 3177 sprintf(ifr.ifr_name, "%s", dev->name);
3171 cpc_opench(d); 3178 result = cpc_opench(d);
3179 if (result)
3180 goto err_out;
3181
3172 netif_start_queue(dev); 3182 netif_start_queue(dev);
3173 return 0; 3183 return 0;
3184
3185err_out:
3186 hdlc_close(dev);
3187 return result;
3174} 3188}
3175 3189
3176static int cpc_close(struct net_device *dev) 3190static int cpc_close(struct net_device *dev)
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 0a33c8a56e13..efcdaf1c5f73 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -2897,6 +2897,8 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
2897 goto err_out_map; 2897 goto err_out_map;
2898 } 2898 }
2899 ai->wifidev = init_wifidev(ai, dev); 2899 ai->wifidev = init_wifidev(ai, dev);
2900 if (!ai->wifidev)
2901 goto err_out_reg;
2900 2902
2901 set_bit(FLAG_REGISTERED,&ai->flags); 2903 set_bit(FLAG_REGISTERED,&ai->flags);
2902 airo_print_info(dev->name, "MAC enabled %x:%x:%x:%x:%x:%x", 2904 airo_print_info(dev->name, "MAC enabled %x:%x:%x:%x:%x:%x",
@@ -2908,11 +2910,18 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
2908 for( i = 0; i < MAX_FIDS; i++ ) 2910 for( i = 0; i < MAX_FIDS; i++ )
2909 ai->fids[i] = transmit_allocate(ai,AIRO_DEF_MTU,i>=MAX_FIDS/2); 2911 ai->fids[i] = transmit_allocate(ai,AIRO_DEF_MTU,i>=MAX_FIDS/2);
2910 2912
2911 setup_proc_entry( dev, dev->priv ); /* XXX check for failure */ 2913 if (setup_proc_entry(dev, dev->priv) < 0)
2914 goto err_out_wifi;
2915
2912 netif_start_queue(dev); 2916 netif_start_queue(dev);
2913 SET_MODULE_OWNER(dev); 2917 SET_MODULE_OWNER(dev);
2914 return dev; 2918 return dev;
2915 2919
2920err_out_wifi:
2921 unregister_netdev(ai->wifidev);
2922 free_netdev(ai->wifidev);
2923err_out_reg:
2924 unregister_netdev(dev);
2916err_out_map: 2925err_out_map:
2917 if (test_bit(FLAG_MPI,&ai->flags) && pci) { 2926 if (test_bit(FLAG_MPI,&ai->flags) && pci) {
2918 pci_free_consistent(pci, PCI_SHARED_LEN, ai->shared, ai->shared_dma); 2927 pci_free_consistent(pci, PCI_SHARED_LEN, ai->shared, ai->shared_dma);
@@ -3089,7 +3098,8 @@ static int airo_thread(void *data) {
3089 set_bit(JOB_AUTOWEP, &ai->jobs); 3098 set_bit(JOB_AUTOWEP, &ai->jobs);
3090 break; 3099 break;
3091 } 3100 }
3092 if (!kthread_should_stop()) { 3101 if (!kthread_should_stop() &&
3102 !freezing(current)) {
3093 unsigned long wake_at; 3103 unsigned long wake_at;
3094 if (!ai->expires || !ai->scan_timeout) { 3104 if (!ai->expires || !ai->scan_timeout) {
3095 wake_at = max(ai->expires, 3105 wake_at = max(ai->expires,
@@ -3101,7 +3111,8 @@ static int airo_thread(void *data) {
3101 schedule_timeout(wake_at - jiffies); 3111 schedule_timeout(wake_at - jiffies);
3102 continue; 3112 continue;
3103 } 3113 }
3104 } else if (!kthread_should_stop()) { 3114 } else if (!kthread_should_stop() &&
3115 !freezing(current)) {
3105 schedule(); 3116 schedule();
3106 continue; 3117 continue;
3107 } 3118 }
@@ -4495,91 +4506,128 @@ static int setup_proc_entry( struct net_device *dev,
4495 apriv->proc_entry = create_proc_entry(apriv->proc_name, 4506 apriv->proc_entry = create_proc_entry(apriv->proc_name,
4496 S_IFDIR|airo_perm, 4507 S_IFDIR|airo_perm,
4497 airo_entry); 4508 airo_entry);
4498 apriv->proc_entry->uid = proc_uid; 4509 if (!apriv->proc_entry)
4499 apriv->proc_entry->gid = proc_gid; 4510 goto fail;
4500 apriv->proc_entry->owner = THIS_MODULE; 4511 apriv->proc_entry->uid = proc_uid;
4512 apriv->proc_entry->gid = proc_gid;
4513 apriv->proc_entry->owner = THIS_MODULE;
4501 4514
4502 /* Setup the StatsDelta */ 4515 /* Setup the StatsDelta */
4503 entry = create_proc_entry("StatsDelta", 4516 entry = create_proc_entry("StatsDelta",
4504 S_IFREG | (S_IRUGO&proc_perm), 4517 S_IFREG | (S_IRUGO&proc_perm),
4505 apriv->proc_entry); 4518 apriv->proc_entry);
4506 entry->uid = proc_uid; 4519 if (!entry)
4507 entry->gid = proc_gid; 4520 goto fail_stats_delta;
4521 entry->uid = proc_uid;
4522 entry->gid = proc_gid;
4508 entry->data = dev; 4523 entry->data = dev;
4509 entry->owner = THIS_MODULE; 4524 entry->owner = THIS_MODULE;
4510 SETPROC_OPS(entry, proc_statsdelta_ops); 4525 SETPROC_OPS(entry, proc_statsdelta_ops);
4511 4526
4512 /* Setup the Stats */ 4527 /* Setup the Stats */
4513 entry = create_proc_entry("Stats", 4528 entry = create_proc_entry("Stats",
4514 S_IFREG | (S_IRUGO&proc_perm), 4529 S_IFREG | (S_IRUGO&proc_perm),
4515 apriv->proc_entry); 4530 apriv->proc_entry);
4516 entry->uid = proc_uid; 4531 if (!entry)
4517 entry->gid = proc_gid; 4532 goto fail_stats;
4533 entry->uid = proc_uid;
4534 entry->gid = proc_gid;
4518 entry->data = dev; 4535 entry->data = dev;
4519 entry->owner = THIS_MODULE; 4536 entry->owner = THIS_MODULE;
4520 SETPROC_OPS(entry, proc_stats_ops); 4537 SETPROC_OPS(entry, proc_stats_ops);
4521 4538
4522 /* Setup the Status */ 4539 /* Setup the Status */
4523 entry = create_proc_entry("Status", 4540 entry = create_proc_entry("Status",
4524 S_IFREG | (S_IRUGO&proc_perm), 4541 S_IFREG | (S_IRUGO&proc_perm),
4525 apriv->proc_entry); 4542 apriv->proc_entry);
4526 entry->uid = proc_uid; 4543 if (!entry)
4527 entry->gid = proc_gid; 4544 goto fail_status;
4545 entry->uid = proc_uid;
4546 entry->gid = proc_gid;
4528 entry->data = dev; 4547 entry->data = dev;
4529 entry->owner = THIS_MODULE; 4548 entry->owner = THIS_MODULE;
4530 SETPROC_OPS(entry, proc_status_ops); 4549 SETPROC_OPS(entry, proc_status_ops);
4531 4550
4532 /* Setup the Config */ 4551 /* Setup the Config */
4533 entry = create_proc_entry("Config", 4552 entry = create_proc_entry("Config",
4534 S_IFREG | proc_perm, 4553 S_IFREG | proc_perm,
4535 apriv->proc_entry); 4554 apriv->proc_entry);
4536 entry->uid = proc_uid; 4555 if (!entry)
4537 entry->gid = proc_gid; 4556 goto fail_config;
4557 entry->uid = proc_uid;
4558 entry->gid = proc_gid;
4538 entry->data = dev; 4559 entry->data = dev;
4539 entry->owner = THIS_MODULE; 4560 entry->owner = THIS_MODULE;
4540 SETPROC_OPS(entry, proc_config_ops); 4561 SETPROC_OPS(entry, proc_config_ops);
4541 4562
4542 /* Setup the SSID */ 4563 /* Setup the SSID */
4543 entry = create_proc_entry("SSID", 4564 entry = create_proc_entry("SSID",
4544 S_IFREG | proc_perm, 4565 S_IFREG | proc_perm,
4545 apriv->proc_entry); 4566 apriv->proc_entry);
4546 entry->uid = proc_uid; 4567 if (!entry)
4547 entry->gid = proc_gid; 4568 goto fail_ssid;
4569 entry->uid = proc_uid;
4570 entry->gid = proc_gid;
4548 entry->data = dev; 4571 entry->data = dev;
4549 entry->owner = THIS_MODULE; 4572 entry->owner = THIS_MODULE;
4550 SETPROC_OPS(entry, proc_SSID_ops); 4573 SETPROC_OPS(entry, proc_SSID_ops);
4551 4574
4552 /* Setup the APList */ 4575 /* Setup the APList */
4553 entry = create_proc_entry("APList", 4576 entry = create_proc_entry("APList",
4554 S_IFREG | proc_perm, 4577 S_IFREG | proc_perm,
4555 apriv->proc_entry); 4578 apriv->proc_entry);
4556 entry->uid = proc_uid; 4579 if (!entry)
4557 entry->gid = proc_gid; 4580 goto fail_aplist;
4581 entry->uid = proc_uid;
4582 entry->gid = proc_gid;
4558 entry->data = dev; 4583 entry->data = dev;
4559 entry->owner = THIS_MODULE; 4584 entry->owner = THIS_MODULE;
4560 SETPROC_OPS(entry, proc_APList_ops); 4585 SETPROC_OPS(entry, proc_APList_ops);
4561 4586
4562 /* Setup the BSSList */ 4587 /* Setup the BSSList */
4563 entry = create_proc_entry("BSSList", 4588 entry = create_proc_entry("BSSList",
4564 S_IFREG | proc_perm, 4589 S_IFREG | proc_perm,
4565 apriv->proc_entry); 4590 apriv->proc_entry);
4591 if (!entry)
4592 goto fail_bsslist;
4566 entry->uid = proc_uid; 4593 entry->uid = proc_uid;
4567 entry->gid = proc_gid; 4594 entry->gid = proc_gid;
4568 entry->data = dev; 4595 entry->data = dev;
4569 entry->owner = THIS_MODULE; 4596 entry->owner = THIS_MODULE;
4570 SETPROC_OPS(entry, proc_BSSList_ops); 4597 SETPROC_OPS(entry, proc_BSSList_ops);
4571 4598
4572 /* Setup the WepKey */ 4599 /* Setup the WepKey */
4573 entry = create_proc_entry("WepKey", 4600 entry = create_proc_entry("WepKey",
4574 S_IFREG | proc_perm, 4601 S_IFREG | proc_perm,
4575 apriv->proc_entry); 4602 apriv->proc_entry);
4576 entry->uid = proc_uid; 4603 if (!entry)
4577 entry->gid = proc_gid; 4604 goto fail_wepkey;
4605 entry->uid = proc_uid;
4606 entry->gid = proc_gid;
4578 entry->data = dev; 4607 entry->data = dev;
4579 entry->owner = THIS_MODULE; 4608 entry->owner = THIS_MODULE;
4580 SETPROC_OPS(entry, proc_wepkey_ops); 4609 SETPROC_OPS(entry, proc_wepkey_ops);
4581 4610
4582 return 0; 4611 return 0;
4612
4613fail_wepkey:
4614 remove_proc_entry("BSSList", apriv->proc_entry);
4615fail_bsslist:
4616 remove_proc_entry("APList", apriv->proc_entry);
4617fail_aplist:
4618 remove_proc_entry("SSID", apriv->proc_entry);
4619fail_ssid:
4620 remove_proc_entry("Config", apriv->proc_entry);
4621fail_config:
4622 remove_proc_entry("Status", apriv->proc_entry);
4623fail_status:
4624 remove_proc_entry("Stats", apriv->proc_entry);
4625fail_stats:
4626 remove_proc_entry("StatsDelta", apriv->proc_entry);
4627fail_stats_delta:
4628 remove_proc_entry(apriv->proc_name, airo_entry);
4629fail:
4630 return -ENOMEM;
4583} 4631}
4584 4632
4585static int takedown_proc_entry( struct net_device *dev, 4633static int takedown_proc_entry( struct net_device *dev,
@@ -5924,7 +5972,6 @@ static int airo_get_essid(struct net_device *dev,
5924 5972
5925 /* Get the current SSID */ 5973 /* Get the current SSID */
5926 memcpy(extra, status_rid.SSID, status_rid.SSIDlen); 5974 memcpy(extra, status_rid.SSID, status_rid.SSIDlen);
5927 extra[status_rid.SSIDlen] = '\0';
5928 /* If none, we may want to get the one that was set */ 5975 /* If none, we may want to get the one that was set */
5929 5976
5930 /* Push it out ! */ 5977 /* Push it out ! */
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c
index 31eed85de60f..0c07b8b7250d 100644
--- a/drivers/net/wireless/atmel.c
+++ b/drivers/net/wireless/atmel.c
@@ -1678,11 +1678,9 @@ static int atmel_get_essid(struct net_device *dev,
1678 /* Get the current SSID */ 1678 /* Get the current SSID */
1679 if (priv->new_SSID_size != 0) { 1679 if (priv->new_SSID_size != 0) {
1680 memcpy(extra, priv->new_SSID, priv->new_SSID_size); 1680 memcpy(extra, priv->new_SSID, priv->new_SSID_size);
1681 extra[priv->new_SSID_size] = '\0';
1682 dwrq->length = priv->new_SSID_size; 1681 dwrq->length = priv->new_SSID_size;
1683 } else { 1682 } else {
1684 memcpy(extra, priv->SSID, priv->SSID_size); 1683 memcpy(extra, priv->SSID, priv->SSID_size);
1685 extra[priv->SSID_size] = '\0';
1686 dwrq->length = priv->SSID_size; 1684 dwrq->length = priv->SSID_size;
1687 } 1685 }
1688 1686
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_dma.c b/drivers/net/wireless/bcm43xx/bcm43xx_dma.c
index 76e3aed4b471..978ed099e285 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_dma.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_dma.c
@@ -705,11 +705,30 @@ int bcm43xx_dma_init(struct bcm43xx_private *bcm)
705 struct bcm43xx_dmaring *ring; 705 struct bcm43xx_dmaring *ring;
706 int err = -ENOMEM; 706 int err = -ENOMEM;
707 int dma64 = 0; 707 int dma64 = 0;
708 u32 sbtmstatehi; 708 u64 mask = bcm43xx_get_supported_dma_mask(bcm);
709 int nobits;
709 710
710 sbtmstatehi = bcm43xx_read32(bcm, BCM43xx_CIR_SBTMSTATEHIGH); 711 if (mask == DMA_64BIT_MASK) {
711 if (sbtmstatehi & BCM43xx_SBTMSTATEHIGH_DMA64BIT)
712 dma64 = 1; 712 dma64 = 1;
713 nobits = 64;
714 } else if (mask == DMA_32BIT_MASK)
715 nobits = 32;
716 else
717 nobits = 30;
718 err = pci_set_dma_mask(bcm->pci_dev, mask);
719 err |= pci_set_consistent_dma_mask(bcm->pci_dev, mask);
720 if (err) {
721#ifdef CONFIG_BCM43XX_PIO
722 printk(KERN_WARNING PFX "DMA not supported on this device."
723 " Falling back to PIO.\n");
724 bcm->__using_pio = 1;
725 return -ENOSYS;
726#else
727 printk(KERN_ERR PFX "FATAL: DMA not supported and PIO not configured. "
728 "Please recompile the driver with PIO support.\n");
729 return -ENODEV;
730#endif /* CONFIG_BCM43XX_PIO */
731 }
713 732
714 /* setup TX DMA channels. */ 733 /* setup TX DMA channels. */
715 ring = bcm43xx_setup_dmaring(bcm, 0, 1, dma64); 734 ring = bcm43xx_setup_dmaring(bcm, 0, 1, dma64);
@@ -755,8 +774,7 @@ int bcm43xx_dma_init(struct bcm43xx_private *bcm)
755 dma->rx_ring3 = ring; 774 dma->rx_ring3 = ring;
756 } 775 }
757 776
758 dprintk(KERN_INFO PFX "%s DMA initialized\n", 777 dprintk(KERN_INFO PFX "%d-bit DMA initialized\n", nobits);
759 dma64 ? "64-bit" : "32-bit");
760 err = 0; 778 err = 0;
761out: 779out:
762 return err; 780 return err;
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_dma.h b/drivers/net/wireless/bcm43xx/bcm43xx_dma.h
index e04bcaddd1d0..d1105e569a41 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_dma.h
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_dma.h
@@ -4,6 +4,7 @@
4#include <linux/list.h> 4#include <linux/list.h>
5#include <linux/spinlock.h> 5#include <linux/spinlock.h>
6#include <linux/workqueue.h> 6#include <linux/workqueue.h>
7#include <linux/dma-mapping.h>
7#include <linux/linkage.h> 8#include <linux/linkage.h>
8#include <asm/atomic.h> 9#include <asm/atomic.h>
9 10
@@ -314,6 +315,23 @@ int bcm43xx_dma_tx(struct bcm43xx_private *bcm,
314 struct ieee80211_txb *txb); 315 struct ieee80211_txb *txb);
315void bcm43xx_dma_rx(struct bcm43xx_dmaring *ring); 316void bcm43xx_dma_rx(struct bcm43xx_dmaring *ring);
316 317
318/* Helper function that returns the dma mask for this device. */
319static inline
320u64 bcm43xx_get_supported_dma_mask(struct bcm43xx_private *bcm)
321{
322 int dma64 = bcm43xx_read32(bcm, BCM43xx_CIR_SBTMSTATEHIGH) &
323 BCM43xx_SBTMSTATEHIGH_DMA64BIT;
324 u16 mmio_base = bcm43xx_dmacontroller_base(dma64, 0);
325 u32 mask = BCM43xx_DMA32_TXADDREXT_MASK;
326
327 if (dma64)
328 return DMA_64BIT_MASK;
329 bcm43xx_write32(bcm, mmio_base + BCM43xx_DMA32_TXCTL, mask);
330 if (bcm43xx_read32(bcm, mmio_base + BCM43xx_DMA32_TXCTL) & mask)
331 return DMA_32BIT_MASK;
332 return DMA_30BIT_MASK;
333}
334
317#else /* CONFIG_BCM43XX_DMA */ 335#else /* CONFIG_BCM43XX_DMA */
318 336
319 337
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_leds.c b/drivers/net/wireless/bcm43xx/bcm43xx_leds.c
index c3f90c8563d9..7d383a27b927 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_leds.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_leds.c
@@ -189,20 +189,24 @@ void bcm43xx_leds_update(struct bcm43xx_private *bcm, int activity)
189 case BCM43xx_LED_INACTIVE: 189 case BCM43xx_LED_INACTIVE:
190 continue; 190 continue;
191 case BCM43xx_LED_OFF: 191 case BCM43xx_LED_OFF:
192 case BCM43xx_LED_BCM4303_3:
192 break; 193 break;
193 case BCM43xx_LED_ON: 194 case BCM43xx_LED_ON:
194 turn_on = 1; 195 turn_on = 1;
195 break; 196 break;
196 case BCM43xx_LED_ACTIVITY: 197 case BCM43xx_LED_ACTIVITY:
198 case BCM43xx_LED_BCM4303_0:
197 turn_on = activity; 199 turn_on = activity;
198 break; 200 break;
199 case BCM43xx_LED_RADIO_ALL: 201 case BCM43xx_LED_RADIO_ALL:
200 turn_on = radio->enabled; 202 turn_on = radio->enabled;
201 break; 203 break;
202 case BCM43xx_LED_RADIO_A: 204 case BCM43xx_LED_RADIO_A:
205 case BCM43xx_LED_BCM4303_2:
203 turn_on = (radio->enabled && phy->type == BCM43xx_PHYTYPE_A); 206 turn_on = (radio->enabled && phy->type == BCM43xx_PHYTYPE_A);
204 break; 207 break;
205 case BCM43xx_LED_RADIO_B: 208 case BCM43xx_LED_RADIO_B:
209 case BCM43xx_LED_BCM4303_1:
206 turn_on = (radio->enabled && 210 turn_on = (radio->enabled &&
207 (phy->type == BCM43xx_PHYTYPE_B || 211 (phy->type == BCM43xx_PHYTYPE_B ||
208 phy->type == BCM43xx_PHYTYPE_G)); 212 phy->type == BCM43xx_PHYTYPE_G));
@@ -242,7 +246,7 @@ void bcm43xx_leds_update(struct bcm43xx_private *bcm, int activity)
242 //TODO 246 //TODO
243 break; 247 break;
244 case BCM43xx_LED_ASSOC: 248 case BCM43xx_LED_ASSOC:
245 if (bcm->softmac->associated) 249 if (bcm->softmac->associnfo.associated)
246 turn_on = 1; 250 turn_on = 1;
247 break; 251 break;
248#ifdef CONFIG_BCM43XX_DEBUG 252#ifdef CONFIG_BCM43XX_DEBUG
@@ -257,7 +261,8 @@ void bcm43xx_leds_update(struct bcm43xx_private *bcm, int activity)
257 continue; 261 continue;
258#endif /* CONFIG_BCM43XX_DEBUG */ 262#endif /* CONFIG_BCM43XX_DEBUG */
259 default: 263 default:
260 assert(0); 264 dprintkl(KERN_INFO PFX "Bad value in leds_update,"
265 " led->behaviour: 0x%x\n", led->behaviour);
261 }; 266 };
262 267
263 if (led->activelow) 268 if (led->activelow)
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_leds.h b/drivers/net/wireless/bcm43xx/bcm43xx_leds.h
index d3716cf3aebc..811e14a81198 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_leds.h
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_leds.h
@@ -46,6 +46,12 @@ enum { /* LED behaviour values */
46 BCM43xx_LED_TEST_BLINKSLOW, 46 BCM43xx_LED_TEST_BLINKSLOW,
47 BCM43xx_LED_TEST_BLINKMEDIUM, 47 BCM43xx_LED_TEST_BLINKMEDIUM,
48 BCM43xx_LED_TEST_BLINKFAST, 48 BCM43xx_LED_TEST_BLINKFAST,
49
50 /* Misc values for BCM4303 */
51 BCM43xx_LED_BCM4303_0 = 0x2B,
52 BCM43xx_LED_BCM4303_1 = 0x78,
53 BCM43xx_LED_BCM4303_2 = 0x2E,
54 BCM43xx_LED_BCM4303_3 = 0x19,
49}; 55};
50 56
51int bcm43xx_leds_init(struct bcm43xx_private *bcm); 57int bcm43xx_leds_init(struct bcm43xx_private *bcm);
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.c b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
index bad3452ea893..a1b783813d8e 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_main.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
@@ -746,7 +746,7 @@ int bcm43xx_sprom_write(struct bcm43xx_private *bcm, const u16 *sprom)
746 if (err) 746 if (err)
747 goto err_ctlreg; 747 goto err_ctlreg;
748 spromctl |= 0x10; /* SPROM WRITE enable. */ 748 spromctl |= 0x10; /* SPROM WRITE enable. */
749 bcm43xx_pci_write_config32(bcm, BCM43xx_PCICFG_SPROMCTL, spromctl); 749 err = bcm43xx_pci_write_config32(bcm, BCM43xx_PCICFG_SPROMCTL, spromctl);
750 if (err) 750 if (err)
751 goto err_ctlreg; 751 goto err_ctlreg;
752 /* We must burn lots of CPU cycles here, but that does not 752 /* We must burn lots of CPU cycles here, but that does not
@@ -768,7 +768,7 @@ int bcm43xx_sprom_write(struct bcm43xx_private *bcm, const u16 *sprom)
768 mdelay(20); 768 mdelay(20);
769 } 769 }
770 spromctl &= ~0x10; /* SPROM WRITE enable. */ 770 spromctl &= ~0x10; /* SPROM WRITE enable. */
771 bcm43xx_pci_write_config32(bcm, BCM43xx_PCICFG_SPROMCTL, spromctl); 771 err = bcm43xx_pci_write_config32(bcm, BCM43xx_PCICFG_SPROMCTL, spromctl);
772 if (err) 772 if (err)
773 goto err_ctlreg; 773 goto err_ctlreg;
774 mdelay(500); 774 mdelay(500);
@@ -1463,6 +1463,23 @@ static void handle_irq_transmit_status(struct bcm43xx_private *bcm)
1463 } 1463 }
1464} 1464}
1465 1465
1466static void drain_txstatus_queue(struct bcm43xx_private *bcm)
1467{
1468 u32 dummy;
1469
1470 if (bcm->current_core->rev < 5)
1471 return;
1472 /* Read all entries from the microcode TXstatus FIFO
1473 * and throw them away.
1474 */
1475 while (1) {
1476 dummy = bcm43xx_read32(bcm, BCM43xx_MMIO_XMITSTAT_0);
1477 if (!dummy)
1478 break;
1479 dummy = bcm43xx_read32(bcm, BCM43xx_MMIO_XMITSTAT_1);
1480 }
1481}
1482
1466static void bcm43xx_generate_noise_sample(struct bcm43xx_private *bcm) 1483static void bcm43xx_generate_noise_sample(struct bcm43xx_private *bcm)
1467{ 1484{
1468 bcm43xx_shm_write16(bcm, BCM43xx_SHM_SHARED, 0x408, 0x7F7F); 1485 bcm43xx_shm_write16(bcm, BCM43xx_SHM_SHARED, 0x408, 0x7F7F);
@@ -2925,10 +2942,13 @@ static int bcm43xx_wireless_core_init(struct bcm43xx_private *bcm,
2925 bcm43xx_write16(bcm, 0x043C, 0x000C); 2942 bcm43xx_write16(bcm, 0x043C, 0x000C);
2926 2943
2927 if (active_wlcore) { 2944 if (active_wlcore) {
2928 if (bcm43xx_using_pio(bcm)) 2945 if (bcm43xx_using_pio(bcm)) {
2929 err = bcm43xx_pio_init(bcm); 2946 err = bcm43xx_pio_init(bcm);
2930 else 2947 } else {
2931 err = bcm43xx_dma_init(bcm); 2948 err = bcm43xx_dma_init(bcm);
2949 if (err == -ENOSYS)
2950 err = bcm43xx_pio_init(bcm);
2951 }
2932 if (err) 2952 if (err)
2933 goto err_chip_cleanup; 2953 goto err_chip_cleanup;
2934 } 2954 }
@@ -3160,17 +3180,30 @@ static int estimate_periodic_work_badness(unsigned int state)
3160static void bcm43xx_periodic_work_handler(void *d) 3180static void bcm43xx_periodic_work_handler(void *d)
3161{ 3181{
3162 struct bcm43xx_private *bcm = d; 3182 struct bcm43xx_private *bcm = d;
3183 struct net_device *net_dev = bcm->net_dev;
3163 unsigned long flags; 3184 unsigned long flags;
3164 u32 savedirqs = 0; 3185 u32 savedirqs = 0;
3165 int badness; 3186 int badness;
3187 unsigned long orig_trans_start = 0;
3166 3188
3189 mutex_lock(&bcm->mutex);
3167 badness = estimate_periodic_work_badness(bcm->periodic_state); 3190 badness = estimate_periodic_work_badness(bcm->periodic_state);
3168 if (badness > BADNESS_LIMIT) { 3191 if (badness > BADNESS_LIMIT) {
3169 /* Periodic work will take a long time, so we want it to 3192 /* Periodic work will take a long time, so we want it to
3170 * be preemtible. 3193 * be preemtible.
3171 */ 3194 */
3172 mutex_lock(&bcm->mutex); 3195
3173 netif_tx_disable(bcm->net_dev); 3196 netif_tx_lock_bh(net_dev);
3197 /* We must fake a started transmission here, as we are going to
3198 * disable TX. If we wouldn't fake a TX, it would be possible to
3199 * trigger the netdev watchdog, if the last real TX is already
3200 * some time on the past (slightly less than 5secs)
3201 */
3202 orig_trans_start = net_dev->trans_start;
3203 net_dev->trans_start = jiffies;
3204 netif_stop_queue(net_dev);
3205 netif_tx_unlock_bh(net_dev);
3206
3174 spin_lock_irqsave(&bcm->irq_lock, flags); 3207 spin_lock_irqsave(&bcm->irq_lock, flags);
3175 bcm43xx_mac_suspend(bcm); 3208 bcm43xx_mac_suspend(bcm);
3176 if (bcm43xx_using_pio(bcm)) 3209 if (bcm43xx_using_pio(bcm))
@@ -3182,7 +3215,6 @@ static void bcm43xx_periodic_work_handler(void *d)
3182 /* Periodic work should take short time, so we want low 3215 /* Periodic work should take short time, so we want low
3183 * locking overhead. 3216 * locking overhead.
3184 */ 3217 */
3185 mutex_lock(&bcm->mutex);
3186 spin_lock_irqsave(&bcm->irq_lock, flags); 3218 spin_lock_irqsave(&bcm->irq_lock, flags);
3187 } 3219 }
3188 3220
@@ -3196,6 +3228,7 @@ static void bcm43xx_periodic_work_handler(void *d)
3196 bcm43xx_pio_thaw_txqueues(bcm); 3228 bcm43xx_pio_thaw_txqueues(bcm);
3197 bcm43xx_mac_enable(bcm); 3229 bcm43xx_mac_enable(bcm);
3198 netif_wake_queue(bcm->net_dev); 3230 netif_wake_queue(bcm->net_dev);
3231 net_dev->trans_start = orig_trans_start;
3199 } 3232 }
3200 mmiowb(); 3233 mmiowb();
3201 spin_unlock_irqrestore(&bcm->irq_lock, flags); 3234 spin_unlock_irqrestore(&bcm->irq_lock, flags);
@@ -3516,6 +3549,7 @@ int bcm43xx_select_wireless_core(struct bcm43xx_private *bcm,
3516 bcm43xx_macfilter_clear(bcm, BCM43xx_MACFILTER_ASSOC); 3549 bcm43xx_macfilter_clear(bcm, BCM43xx_MACFILTER_ASSOC);
3517 bcm43xx_macfilter_set(bcm, BCM43xx_MACFILTER_SELF, (u8 *)(bcm->net_dev->dev_addr)); 3550 bcm43xx_macfilter_set(bcm, BCM43xx_MACFILTER_SELF, (u8 *)(bcm->net_dev->dev_addr));
3518 bcm43xx_security_init(bcm); 3551 bcm43xx_security_init(bcm);
3552 drain_txstatus_queue(bcm);
3519 ieee80211softmac_start(bcm->net_dev); 3553 ieee80211softmac_start(bcm->net_dev);
3520 3554
3521 /* Let's go! Be careful after enabling the IRQs. 3555 /* Let's go! Be careful after enabling the IRQs.
@@ -3993,8 +4027,6 @@ static int bcm43xx_init_private(struct bcm43xx_private *bcm,
3993 struct net_device *net_dev, 4027 struct net_device *net_dev,
3994 struct pci_dev *pci_dev) 4028 struct pci_dev *pci_dev)
3995{ 4029{
3996 int err;
3997
3998 bcm43xx_set_status(bcm, BCM43xx_STAT_UNINIT); 4030 bcm43xx_set_status(bcm, BCM43xx_STAT_UNINIT);
3999 bcm->ieee = netdev_priv(net_dev); 4031 bcm->ieee = netdev_priv(net_dev);
4000 bcm->softmac = ieee80211_priv(net_dev); 4032 bcm->softmac = ieee80211_priv(net_dev);
@@ -4012,22 +4044,8 @@ static int bcm43xx_init_private(struct bcm43xx_private *bcm,
4012 (void (*)(unsigned long))bcm43xx_interrupt_tasklet, 4044 (void (*)(unsigned long))bcm43xx_interrupt_tasklet,
4013 (unsigned long)bcm); 4045 (unsigned long)bcm);
4014 tasklet_disable_nosync(&bcm->isr_tasklet); 4046 tasklet_disable_nosync(&bcm->isr_tasklet);
4015 if (modparam_pio) { 4047 if (modparam_pio)
4016 bcm->__using_pio = 1; 4048 bcm->__using_pio = 1;
4017 } else {
4018 err = pci_set_dma_mask(pci_dev, DMA_30BIT_MASK);
4019 err |= pci_set_consistent_dma_mask(pci_dev, DMA_30BIT_MASK);
4020 if (err) {
4021#ifdef CONFIG_BCM43XX_PIO
4022 printk(KERN_WARNING PFX "DMA not supported. Falling back to PIO.\n");
4023 bcm->__using_pio = 1;
4024#else
4025 printk(KERN_ERR PFX "FATAL: DMA not supported and PIO not configured. "
4026 "Recompile the driver with PIO support, please.\n");
4027 return -ENODEV;
4028#endif /* CONFIG_BCM43XX_PIO */
4029 }
4030 }
4031 bcm->rts_threshold = BCM43xx_DEFAULT_RTS_THRESHOLD; 4049 bcm->rts_threshold = BCM43xx_DEFAULT_RTS_THRESHOLD;
4032 4050
4033 /* default to sw encryption for now */ 4051 /* default to sw encryption for now */
@@ -4208,7 +4226,11 @@ static int bcm43xx_resume(struct pci_dev *pdev)
4208 dprintk(KERN_INFO PFX "Resuming...\n"); 4226 dprintk(KERN_INFO PFX "Resuming...\n");
4209 4227
4210 pci_set_power_state(pdev, 0); 4228 pci_set_power_state(pdev, 0);
4211 pci_enable_device(pdev); 4229 err = pci_enable_device(pdev);
4230 if (err) {
4231 printk(KERN_ERR PFX "Failure with pci_enable_device!\n");
4232 return err;
4233 }
4212 pci_restore_state(pdev); 4234 pci_restore_state(pdev);
4213 4235
4214 bcm43xx_chipset_attach(bcm); 4236 bcm43xx_chipset_attach(bcm);
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
index 9b7b15cf6561..d27016f8c736 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
@@ -847,7 +847,7 @@ static struct iw_statistics *bcm43xx_get_wireless_stats(struct net_device *net_d
847 unsigned long flags; 847 unsigned long flags;
848 848
849 wstats = &bcm->stats.wstats; 849 wstats = &bcm->stats.wstats;
850 if (!mac->associated) { 850 if (!mac->associnfo.associated) {
851 wstats->miss.beacon = 0; 851 wstats->miss.beacon = 0;
852// bcm->ieee->ieee_stats.tx_retry_limit_exceeded = 0; // FIXME: should this be cleared here? 852// bcm->ieee->ieee_stats.tx_retry_limit_exceeded = 0; // FIXME: should this be cleared here?
853 wstats->discard.retries = 0; 853 wstats->discard.retries = 0;
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index 686d895116de..f63909e4bc32 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -887,6 +887,13 @@ static struct pcmcia_device_id hostap_cs_ids[] = {
887 PCMCIA_DEVICE_PROD_ID123( 887 PCMCIA_DEVICE_PROD_ID123(
888 "U.S. Robotics", "IEEE 802.11b PC-CARD", "Version 01.02", 888 "U.S. Robotics", "IEEE 802.11b PC-CARD", "Version 01.02",
889 0xc7b8df9d, 0x1700d087, 0x4b74baa0), 889 0xc7b8df9d, 0x1700d087, 0x4b74baa0),
890 PCMCIA_DEVICE_PROD_ID123(
891 "Allied Telesyn", "AT-WCL452 Wireless PCMCIA Radio",
892 "Ver. 1.00",
893 0x5cd01705, 0x4271660f, 0x9d08ee12),
894 PCMCIA_DEVICE_PROD_ID123(
895 "corega", "WL PCCL-11", "ISL37300P",
896 0xa21501a, 0x59868926, 0xc9049a39),
890 PCMCIA_DEVICE_NULL 897 PCMCIA_DEVICE_NULL
891}; 898};
892MODULE_DEVICE_TABLE(pcmcia, hostap_cs_ids); 899MODULE_DEVICE_TABLE(pcmcia, hostap_cs_ids);
diff --git a/drivers/net/wireless/hostap/hostap_plx.c b/drivers/net/wireless/hostap/hostap_plx.c
index 6dfa041be66d..bc81b13a5a2a 100644
--- a/drivers/net/wireless/hostap/hostap_plx.c
+++ b/drivers/net/wireless/hostap/hostap_plx.c
@@ -364,7 +364,7 @@ static int prism2_plx_check_cis(void __iomem *attr_mem, int attr_len,
364 364
365 pos = 0; 365 pos = 0;
366 while (pos < CIS_MAX_LEN - 1 && cis[pos] != CISTPL_END) { 366 while (pos < CIS_MAX_LEN - 1 && cis[pos] != CISTPL_END) {
367 if (pos + cis[pos + 1] >= CIS_MAX_LEN) 367 if (pos + 2 + cis[pos + 1] > CIS_MAX_LEN)
368 goto cis_error; 368 goto cis_error;
369 369
370 switch (cis[pos]) { 370 switch (cis[pos]) {
@@ -391,7 +391,7 @@ static int prism2_plx_check_cis(void __iomem *attr_mem, int attr_len,
391 break; 391 break;
392 392
393 case CISTPL_MANFID: 393 case CISTPL_MANFID:
394 if (cis[pos + 1] < 5) 394 if (cis[pos + 1] < 4)
395 goto cis_error; 395 goto cis_error;
396 manfid1 = cis[pos + 2] + (cis[pos + 3] << 8); 396 manfid1 = cis[pos + 2] + (cis[pos + 3] << 8);
397 manfid2 = cis[pos + 4] + (cis[pos + 5] << 8); 397 manfid2 = cis[pos + 4] + (cis[pos + 5] << 8);
diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c
index b779c7dcc1a8..336cabac13b3 100644
--- a/drivers/net/wireless/orinoco.c
+++ b/drivers/net/wireless/orinoco.c
@@ -2457,6 +2457,7 @@ void free_orinocodev(struct net_device *dev)
2457/* Wireless extensions */ 2457/* Wireless extensions */
2458/********************************************************************/ 2458/********************************************************************/
2459 2459
2460/* Return : < 0 -> error code ; >= 0 -> length */
2460static int orinoco_hw_get_essid(struct orinoco_private *priv, int *active, 2461static int orinoco_hw_get_essid(struct orinoco_private *priv, int *active,
2461 char buf[IW_ESSID_MAX_SIZE+1]) 2462 char buf[IW_ESSID_MAX_SIZE+1])
2462{ 2463{
@@ -2501,9 +2502,9 @@ static int orinoco_hw_get_essid(struct orinoco_private *priv, int *active,
2501 len = le16_to_cpu(essidbuf.len); 2502 len = le16_to_cpu(essidbuf.len);
2502 BUG_ON(len > IW_ESSID_MAX_SIZE); 2503 BUG_ON(len > IW_ESSID_MAX_SIZE);
2503 2504
2504 memset(buf, 0, IW_ESSID_MAX_SIZE+1); 2505 memset(buf, 0, IW_ESSID_MAX_SIZE);
2505 memcpy(buf, p, len); 2506 memcpy(buf, p, len);
2506 buf[len] = '\0'; 2507 err = len;
2507 2508
2508 fail_unlock: 2509 fail_unlock:
2509 orinoco_unlock(priv, &flags); 2510 orinoco_unlock(priv, &flags);
@@ -3027,17 +3028,18 @@ static int orinoco_ioctl_getessid(struct net_device *dev,
3027 3028
3028 if (netif_running(dev)) { 3029 if (netif_running(dev)) {
3029 err = orinoco_hw_get_essid(priv, &active, essidbuf); 3030 err = orinoco_hw_get_essid(priv, &active, essidbuf);
3030 if (err) 3031 if (err < 0)
3031 return err; 3032 return err;
3033 erq->length = err;
3032 } else { 3034 } else {
3033 if (orinoco_lock(priv, &flags) != 0) 3035 if (orinoco_lock(priv, &flags) != 0)
3034 return -EBUSY; 3036 return -EBUSY;
3035 memcpy(essidbuf, priv->desired_essid, IW_ESSID_MAX_SIZE + 1); 3037 memcpy(essidbuf, priv->desired_essid, IW_ESSID_MAX_SIZE);
3038 erq->length = strlen(priv->desired_essid);
3036 orinoco_unlock(priv, &flags); 3039 orinoco_unlock(priv, &flags);
3037 } 3040 }
3038 3041
3039 erq->flags = 1; 3042 erq->flags = 1;
3040 erq->length = strlen(essidbuf);
3041 3043
3042 return 0; 3044 return 0;
3043} 3045}
@@ -3075,10 +3077,10 @@ static int orinoco_ioctl_getnick(struct net_device *dev,
3075 if (orinoco_lock(priv, &flags) != 0) 3077 if (orinoco_lock(priv, &flags) != 0)
3076 return -EBUSY; 3078 return -EBUSY;
3077 3079
3078 memcpy(nickbuf, priv->nick, IW_ESSID_MAX_SIZE+1); 3080 memcpy(nickbuf, priv->nick, IW_ESSID_MAX_SIZE);
3079 orinoco_unlock(priv, &flags); 3081 orinoco_unlock(priv, &flags);
3080 3082
3081 nrq->length = strlen(nickbuf); 3083 nrq->length = strlen(priv->nick);
3082 3084
3083 return 0; 3085 return 0;
3084} 3086}
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index 0b381d77015c..7fbfc9e41d07 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -1198,7 +1198,6 @@ static int ray_get_essid(struct net_device *dev,
1198 1198
1199 /* Get the essid that was set */ 1199 /* Get the essid that was set */
1200 memcpy(extra, local->sparm.b5.a_current_ess_id, IW_ESSID_MAX_SIZE); 1200 memcpy(extra, local->sparm.b5.a_current_ess_id, IW_ESSID_MAX_SIZE);
1201 extra[IW_ESSID_MAX_SIZE] = '\0';
1202 1201
1203 /* Push it out ! */ 1202 /* Push it out ! */
1204 dwrq->length = strlen(extra); 1203 dwrq->length = strlen(extra);
diff --git a/drivers/net/wireless/zd1201.c b/drivers/net/wireless/zd1201.c
index 30057a335a7b..36b29ff05814 100644
--- a/drivers/net/wireless/zd1201.c
+++ b/drivers/net/wireless/zd1201.c
@@ -193,10 +193,8 @@ static void zd1201_usbrx(struct urb *urb)
193 struct sk_buff *skb; 193 struct sk_buff *skb;
194 unsigned char type; 194 unsigned char type;
195 195
196 if (!zd) { 196 if (!zd)
197 free = 1; 197 return;
198 goto exit;
199 }
200 198
201 switch(urb->status) { 199 switch(urb->status) {
202 case -EILSEQ: 200 case -EILSEQ:
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index 2d12837052b0..a7d29bddb298 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -1099,7 +1099,7 @@ static void link_led_handler(void *p)
1099 int r; 1099 int r;
1100 1100
1101 spin_lock_irq(&mac->lock); 1101 spin_lock_irq(&mac->lock);
1102 is_associated = sm->associated != 0; 1102 is_associated = sm->associnfo.associated != 0;
1103 spin_unlock_irq(&mac->lock); 1103 spin_unlock_irq(&mac->lock);
1104 1104
1105 r = zd_chip_control_leds(chip, 1105 r = zd_chip_control_leds(chip,
diff --git a/drivers/parport/parport_ip32.c b/drivers/parport/parport_ip32.c
index e3e19277030a..ec44efdbb84e 100644
--- a/drivers/parport/parport_ip32.c
+++ b/drivers/parport/parport_ip32.c
@@ -780,7 +780,7 @@ static irqreturn_t parport_ip32_interrupt(int irq, void *dev_id)
780 enum parport_ip32_irq_mode irq_mode = priv->irq_mode; 780 enum parport_ip32_irq_mode irq_mode = priv->irq_mode;
781 switch (irq_mode) { 781 switch (irq_mode) {
782 case PARPORT_IP32_IRQ_FWD: 782 case PARPORT_IP32_IRQ_FWD:
783 parport_generic_irq(irq, p, regs); 783 parport_generic_irq(irq, p);
784 break; 784 break;
785 case PARPORT_IP32_IRQ_HERE: 785 case PARPORT_IP32_IRQ_HERE:
786 parport_ip32_wakeup(p); 786 parport_ip32_wakeup(p);
diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig
index 30294127a0aa..5f1b9f58070e 100644
--- a/drivers/pci/Kconfig
+++ b/drivers/pci/Kconfig
@@ -19,7 +19,7 @@ config PCI_MSI
19 19
20config PCI_MULTITHREAD_PROBE 20config PCI_MULTITHREAD_PROBE
21 bool "PCI Multi-threaded probe (EXPERIMENTAL)" 21 bool "PCI Multi-threaded probe (EXPERIMENTAL)"
22 depends on PCI && EXPERIMENTAL 22 depends on PCI && EXPERIMENTAL && BROKEN
23 help 23 help
24 Say Y here if you want the PCI core to spawn a new thread for 24 Say Y here if you want the PCI core to spawn a new thread for
25 every PCI device that is probed. This can cause a huge 25 every PCI device that is probed. This can cause a huge
@@ -55,7 +55,7 @@ config PCI_DEBUG
55config HT_IRQ 55config HT_IRQ
56 bool "Interrupts on hypertransport devices" 56 bool "Interrupts on hypertransport devices"
57 default y 57 default y
58 depends on X86_LOCAL_APIC && X86_IO_APIC 58 depends on PCI && X86_LOCAL_APIC && X86_IO_APIC
59 help 59 help
60 This allows native hypertransport devices to use interrupts. 60 This allows native hypertransport devices to use interrupts.
61 61
diff --git a/drivers/pci/hotplug/acpi_pcihp.c b/drivers/pci/hotplug/acpi_pcihp.c
index 51cb9f817c22..270a33cc08f6 100644
--- a/drivers/pci/hotplug/acpi_pcihp.c
+++ b/drivers/pci/hotplug/acpi_pcihp.c
@@ -29,10 +29,10 @@
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/pci.h> 31#include <linux/pci.h>
32#include <linux/pci_hotplug.h>
32#include <acpi/acpi.h> 33#include <acpi/acpi.h>
33#include <acpi/acpi_bus.h> 34#include <acpi/acpi_bus.h>
34#include <acpi/actypes.h> 35#include <acpi/actypes.h>
35#include "pci_hotplug.h"
36 36
37#define MY_NAME "acpi_pcihp" 37#define MY_NAME "acpi_pcihp"
38 38
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
index 7fff07e877c7..59c5b242d86d 100644
--- a/drivers/pci/hotplug/acpiphp.h
+++ b/drivers/pci/hotplug/acpiphp.h
@@ -38,7 +38,7 @@
38#include <linux/acpi.h> 38#include <linux/acpi.h>
39#include <linux/kobject.h> /* for KOBJ_NAME_LEN */ 39#include <linux/kobject.h> /* for KOBJ_NAME_LEN */
40#include <linux/mutex.h> 40#include <linux/mutex.h>
41#include "pci_hotplug.h" 41#include <linux/pci_hotplug.h>
42 42
43#define dbg(format, arg...) \ 43#define dbg(format, arg...) \
44 do { \ 44 do { \
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c
index e2fef60c2d06..c57d9d5ce84e 100644
--- a/drivers/pci/hotplug/acpiphp_core.c
+++ b/drivers/pci/hotplug/acpiphp_core.c
@@ -37,10 +37,10 @@
37 37
38#include <linux/kernel.h> 38#include <linux/kernel.h>
39#include <linux/pci.h> 39#include <linux/pci.h>
40#include <linux/pci_hotplug.h>
40#include <linux/slab.h> 41#include <linux/slab.h>
41#include <linux/smp.h> 42#include <linux/smp.h>
42#include <linux/smp_lock.h> 43#include <linux/smp_lock.h>
43#include "pci_hotplug.h"
44#include "acpiphp.h" 44#include "acpiphp.h"
45 45
46#define MY_NAME "acpiphp" 46#define MY_NAME "acpiphp"
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 83e8e4412de5..16167b016266 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -45,11 +45,11 @@
45 45
46#include <linux/kernel.h> 46#include <linux/kernel.h>
47#include <linux/pci.h> 47#include <linux/pci.h>
48#include <linux/pci_hotplug.h>
48#include <linux/smp_lock.h> 49#include <linux/smp_lock.h>
49#include <linux/mutex.h> 50#include <linux/mutex.h>
50 51
51#include "../pci.h" 52#include "../pci.h"
52#include "pci_hotplug.h"
53#include "acpiphp.h" 53#include "acpiphp.h"
54 54
55static LIST_HEAD(bridge_list); 55static LIST_HEAD(bridge_list);
@@ -1807,8 +1807,8 @@ u8 acpiphp_get_power_status(struct acpiphp_slot *slot)
1807 1807
1808 1808
1809/* 1809/*
1810 * latch closed: 1 1810 * latch open: 1
1811 * latch open: 0 1811 * latch closed: 0
1812 */ 1812 */
1813u8 acpiphp_get_latch_status(struct acpiphp_slot *slot) 1813u8 acpiphp_get_latch_status(struct acpiphp_slot *slot)
1814{ 1814{
@@ -1816,7 +1816,7 @@ u8 acpiphp_get_latch_status(struct acpiphp_slot *slot)
1816 1816
1817 sta = get_slot_status(slot); 1817 sta = get_slot_status(slot);
1818 1818
1819 return (sta & ACPI_STA_SHOW_IN_UI) ? 1 : 0; 1819 return (sta & ACPI_STA_SHOW_IN_UI) ? 0 : 1;
1820} 1820}
1821 1821
1822 1822
diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
index d0a07d9ab30c..bd40aee10e16 100644
--- a/drivers/pci/hotplug/acpiphp_ibm.c
+++ b/drivers/pci/hotplug/acpiphp_ibm.c
@@ -35,7 +35,6 @@
35#include <linux/moduleparam.h> 35#include <linux/moduleparam.h>
36 36
37#include "acpiphp.h" 37#include "acpiphp.h"
38#include "pci_hotplug.h"
39 38
40#define DRIVER_VERSION "1.0.1" 39#define DRIVER_VERSION "1.0.1"
41#define DRIVER_AUTHOR "Irene Zubarev <zubarev@us.ibm.com>, Vernon Mauery <vernux@us.ibm.com>" 40#define DRIVER_AUTHOR "Irene Zubarev <zubarev@us.ibm.com>, Vernon Mauery <vernux@us.ibm.com>"
diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c
index d06ab4045134..684551559d44 100644
--- a/drivers/pci/hotplug/cpci_hotplug_core.c
+++ b/drivers/pci/hotplug/cpci_hotplug_core.c
@@ -29,12 +29,12 @@
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/pci.h> 31#include <linux/pci.h>
32#include <linux/pci_hotplug.h>
32#include <linux/init.h> 33#include <linux/init.h>
33#include <linux/interrupt.h> 34#include <linux/interrupt.h>
34#include <linux/smp_lock.h> 35#include <linux/smp_lock.h>
35#include <asm/atomic.h> 36#include <asm/atomic.h>
36#include <linux/delay.h> 37#include <linux/delay.h>
37#include "pci_hotplug.h"
38#include "cpci_hotplug.h" 38#include "cpci_hotplug.h"
39 39
40#define DRIVER_AUTHOR "Scott Murray <scottm@somanetworks.com>" 40#define DRIVER_AUTHOR "Scott Murray <scottm@somanetworks.com>"
diff --git a/drivers/pci/hotplug/cpci_hotplug_pci.c b/drivers/pci/hotplug/cpci_hotplug_pci.c
index 4afcaffd031c..7b1beaad2752 100644
--- a/drivers/pci/hotplug/cpci_hotplug_pci.c
+++ b/drivers/pci/hotplug/cpci_hotplug_pci.c
@@ -26,9 +26,9 @@
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/pci.h> 28#include <linux/pci.h>
29#include <linux/pci_hotplug.h>
29#include <linux/proc_fs.h> 30#include <linux/proc_fs.h>
30#include "../pci.h" 31#include "../pci.h"
31#include "pci_hotplug.h"
32#include "cpci_hotplug.h" 32#include "cpci_hotplug.h"
33 33
34#define MY_NAME "cpci_hotplug" 34#define MY_NAME "cpci_hotplug"
diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
index e847f0d6c7fe..f3852a6b74ea 100644
--- a/drivers/pci/hotplug/cpcihp_generic.c
+++ b/drivers/pci/hotplug/cpcihp_generic.c
@@ -84,7 +84,7 @@ static int __init validate_parameters(void)
84 84
85 if(!bridge) { 85 if(!bridge) {
86 info("not configured, disabling."); 86 info("not configured, disabling.");
87 return 1; 87 return -EINVAL;
88 } 88 }
89 str = bridge; 89 str = bridge;
90 if(!*str) 90 if(!*str)
@@ -147,7 +147,7 @@ static int __init cpcihp_generic_init(void)
147 147
148 info(DRIVER_DESC " version: " DRIVER_VERSION); 148 info(DRIVER_DESC " version: " DRIVER_VERSION);
149 status = validate_parameters(); 149 status = validate_parameters();
150 if(status != 0) 150 if (status)
151 return status; 151 return status;
152 152
153 r = request_region(port, 1, "#ENUM hotswap signal register"); 153 r = request_region(port, 1, "#ENUM hotswap signal register");
diff --git a/drivers/pci/hotplug/cpqphp.h b/drivers/pci/hotplug/cpqphp.h
index ea040c32f47d..298ad7f3f4f4 100644
--- a/drivers/pci/hotplug/cpqphp.h
+++ b/drivers/pci/hotplug/cpqphp.h
@@ -28,7 +28,6 @@
28#ifndef _CPQPHP_H 28#ifndef _CPQPHP_H
29#define _CPQPHP_H 29#define _CPQPHP_H
30 30
31#include "pci_hotplug.h"
32#include <linux/interrupt.h> 31#include <linux/interrupt.h>
33#include <asm/io.h> /* for read? and write? functions */ 32#include <asm/io.h> /* for read? and write? functions */
34#include <linux/delay.h> /* for delays */ 33#include <linux/delay.h> /* for delays */
diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c
index 1fc259913b68..5617cfdadc5c 100644
--- a/drivers/pci/hotplug/cpqphp_core.c
+++ b/drivers/pci/hotplug/cpqphp_core.c
@@ -37,6 +37,7 @@
37#include <linux/slab.h> 37#include <linux/slab.h>
38#include <linux/workqueue.h> 38#include <linux/workqueue.h>
39#include <linux/pci.h> 39#include <linux/pci.h>
40#include <linux/pci_hotplug.h>
40#include <linux/init.h> 41#include <linux/init.h>
41#include <linux/interrupt.h> 42#include <linux/interrupt.h>
42 43
diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c
index 3ec2ad7db49a..79ff6b4de3a6 100644
--- a/drivers/pci/hotplug/cpqphp_ctrl.c
+++ b/drivers/pci/hotplug/cpqphp_ctrl.c
@@ -36,6 +36,7 @@
36#include <linux/wait.h> 36#include <linux/wait.h>
37#include <linux/smp_lock.h> 37#include <linux/smp_lock.h>
38#include <linux/pci.h> 38#include <linux/pci.h>
39#include <linux/pci_hotplug.h>
39#include "cpqphp.h" 40#include "cpqphp.h"
40 41
41static u32 configure_new_device(struct controller* ctrl, struct pci_func *func, 42static u32 configure_new_device(struct controller* ctrl, struct pci_func *func,
diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
index cf0878917537..298a6cfd8406 100644
--- a/drivers/pci/hotplug/cpqphp_nvram.c
+++ b/drivers/pci/hotplug/cpqphp_nvram.c
@@ -33,6 +33,7 @@
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <linux/workqueue.h> 34#include <linux/workqueue.h>
35#include <linux/pci.h> 35#include <linux/pci.h>
36#include <linux/pci_hotplug.h>
36#include <linux/init.h> 37#include <linux/init.h>
37#include <asm/uaccess.h> 38#include <asm/uaccess.h>
38#include "cpqphp.h" 39#include "cpqphp.h"
diff --git a/drivers/pci/hotplug/cpqphp_pci.c b/drivers/pci/hotplug/cpqphp_pci.c
index 0d9688952f4a..fc7c74d72595 100644
--- a/drivers/pci/hotplug/cpqphp_pci.c
+++ b/drivers/pci/hotplug/cpqphp_pci.c
@@ -33,6 +33,7 @@
33#include <linux/workqueue.h> 33#include <linux/workqueue.h>
34#include <linux/proc_fs.h> 34#include <linux/proc_fs.h>
35#include <linux/pci.h> 35#include <linux/pci.h>
36#include <linux/pci_hotplug.h>
36#include "../pci.h" 37#include "../pci.h"
37#include "cpqphp.h" 38#include "cpqphp.h"
38#include "cpqphp_nvram.h" 39#include "cpqphp_nvram.h"
diff --git a/drivers/pci/hotplug/cpqphp_sysfs.c b/drivers/pci/hotplug/cpqphp_sysfs.c
index 5bab666cd67e..634f74d919d3 100644
--- a/drivers/pci/hotplug/cpqphp_sysfs.c
+++ b/drivers/pci/hotplug/cpqphp_sysfs.c
@@ -32,6 +32,7 @@
32#include <linux/proc_fs.h> 32#include <linux/proc_fs.h>
33#include <linux/workqueue.h> 33#include <linux/workqueue.h>
34#include <linux/pci.h> 34#include <linux/pci.h>
35#include <linux/pci_hotplug.h>
35#include <linux/debugfs.h> 36#include <linux/debugfs.h>
36#include "cpqphp.h" 37#include "cpqphp.h"
37 38
diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c
index 05a4f0f90186..e27907c91d92 100644
--- a/drivers/pci/hotplug/fakephp.c
+++ b/drivers/pci/hotplug/fakephp.c
@@ -35,10 +35,10 @@
35#include <linux/kernel.h> 35#include <linux/kernel.h>
36#include <linux/module.h> 36#include <linux/module.h>
37#include <linux/pci.h> 37#include <linux/pci.h>
38#include <linux/pci_hotplug.h>
38#include <linux/init.h> 39#include <linux/init.h>
39#include <linux/string.h> 40#include <linux/string.h>
40#include <linux/slab.h> 41#include <linux/slab.h>
41#include "pci_hotplug.h"
42#include "../pci.h" 42#include "../pci.h"
43 43
44#if !defined(MODULE) 44#if !defined(MODULE)
@@ -181,7 +181,9 @@ static void pci_rescan_slot(struct pci_dev *temp)
181 181
182 if (!pci_read_config_byte(temp, PCI_HEADER_TYPE, &hdr_type)) { 182 if (!pci_read_config_byte(temp, PCI_HEADER_TYPE, &hdr_type)) {
183 temp->hdr_type = hdr_type & 0x7f; 183 temp->hdr_type = hdr_type & 0x7f;
184 if (!pci_find_slot(bus->number, temp->devfn)) { 184 if ((dev = pci_get_slot(bus, temp->devfn)) != NULL)
185 pci_dev_put(dev);
186 else {
185 dev = pci_scan_single_device(bus, temp->devfn); 187 dev = pci_scan_single_device(bus, temp->devfn);
186 if (dev) { 188 if (dev) {
187 dbg("New device on %s function %x:%x\n", 189 dbg("New device on %s function %x:%x\n",
@@ -205,7 +207,9 @@ static void pci_rescan_slot(struct pci_dev *temp)
205 continue; 207 continue;
206 temp->hdr_type = hdr_type & 0x7f; 208 temp->hdr_type = hdr_type & 0x7f;
207 209
208 if (!pci_find_slot(bus->number, temp->devfn)) { 210 if ((dev = pci_get_slot(bus, temp->devfn)) != NULL)
211 pci_dev_put(dev);
212 else {
209 dev = pci_scan_single_device(bus, temp->devfn); 213 dev = pci_scan_single_device(bus, temp->devfn);
210 if (dev) { 214 if (dev) {
211 dbg("New device on %s function %x:%x\n", 215 dbg("New device on %s function %x:%x\n",
@@ -305,7 +309,7 @@ static int disable_slot(struct hotplug_slot *slot)
305 /* search for subfunctions and disable them first */ 309 /* search for subfunctions and disable them first */
306 if (!(dslot->dev->devfn & 7)) { 310 if (!(dslot->dev->devfn & 7)) {
307 for (func = 1; func < 8; func++) { 311 for (func = 1; func < 8; func++) {
308 dev = pci_find_slot(dslot->dev->bus->number, 312 dev = pci_get_slot(dslot->dev->bus,
309 dslot->dev->devfn + func); 313 dslot->dev->devfn + func);
310 if (dev) { 314 if (dev) {
311 hslot = get_slot_from_dev(dev); 315 hslot = get_slot_from_dev(dev);
@@ -315,6 +319,7 @@ static int disable_slot(struct hotplug_slot *slot)
315 err("Hotplug slot not found for subfunction of PCI device\n"); 319 err("Hotplug slot not found for subfunction of PCI device\n");
316 return -ENODEV; 320 return -ENODEV;
317 } 321 }
322 pci_dev_put(dev);
318 } else 323 } else
319 dbg("No device in slot found\n"); 324 dbg("No device in slot found\n");
320 } 325 }
diff --git a/drivers/pci/hotplug/ibmphp.h b/drivers/pci/hotplug/ibmphp.h
index dba6d8ca9bda..612d96301509 100644
--- a/drivers/pci/hotplug/ibmphp.h
+++ b/drivers/pci/hotplug/ibmphp.h
@@ -30,7 +30,7 @@
30 * 30 *
31 */ 31 */
32 32
33#include "pci_hotplug.h" 33#include <linux/pci_hotplug.h>
34 34
35extern int ibmphp_debug; 35extern int ibmphp_debug;
36 36
diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
index e2823ea9c4ed..f5d632e72323 100644
--- a/drivers/pci/hotplug/pci_hotplug_core.c
+++ b/drivers/pci/hotplug/pci_hotplug_core.c
@@ -21,9 +21,7 @@
21 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 * 23 *
24 * Send feedback to <greg@kroah.com> 24 * Send feedback to <kristen.c.accardi@intel.com>
25 *
26 * Filesystem portion based on work done by Pat Mochel on ddfs/driverfs
27 * 25 *
28 */ 26 */
29 27
@@ -32,6 +30,8 @@
32#include <linux/kernel.h> 30#include <linux/kernel.h>
33#include <linux/types.h> 31#include <linux/types.h>
34#include <linux/list.h> 32#include <linux/list.h>
33#include <linux/kobject.h>
34#include <linux/sysfs.h>
35#include <linux/pagemap.h> 35#include <linux/pagemap.h>
36#include <linux/slab.h> 36#include <linux/slab.h>
37#include <linux/smp_lock.h> 37#include <linux/smp_lock.h>
@@ -39,11 +39,8 @@
39#include <linux/mount.h> 39#include <linux/mount.h>
40#include <linux/namei.h> 40#include <linux/namei.h>
41#include <linux/pci.h> 41#include <linux/pci.h>
42#include <linux/pci_hotplug.h>
42#include <asm/uaccess.h> 43#include <asm/uaccess.h>
43#include <linux/kobject.h>
44#include <linux/sysfs.h>
45#include "pci_hotplug.h"
46
47 44
48#define MY_NAME "pci_hotplug" 45#define MY_NAME "pci_hotplug"
49 46
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
index eaea9d36a1bb..4fb12fcda563 100644
--- a/drivers/pci/hotplug/pciehp.h
+++ b/drivers/pci/hotplug/pciehp.h
@@ -31,11 +31,11 @@
31 31
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/pci.h> 33#include <linux/pci.h>
34#include <linux/pci_hotplug.h>
34#include <linux/delay.h> 35#include <linux/delay.h>
35#include <linux/sched.h> /* signal_pending() */ 36#include <linux/sched.h> /* signal_pending() */
36#include <linux/pcieport_if.h> 37#include <linux/pcieport_if.h>
37#include <linux/mutex.h> 38#include <linux/mutex.h>
38#include "pci_hotplug.h"
39 39
40#define MY_NAME "pciehp" 40#define MY_NAME "pciehp"
41 41
@@ -92,6 +92,7 @@ struct php_ctlr_state_s {
92struct controller { 92struct controller {
93 struct controller *next; 93 struct controller *next;
94 struct mutex crit_sect; /* critical section mutex */ 94 struct mutex crit_sect; /* critical section mutex */
95 struct mutex ctrl_lock; /* controller lock */
95 struct php_ctlr_state_s *hpc_ctlr_handle; /* HPC controller handle */ 96 struct php_ctlr_state_s *hpc_ctlr_handle; /* HPC controller handle */
96 int num_slots; /* Number of slots on ctlr */ 97 int num_slots; /* Number of slots on ctlr */
97 int slot_num_inc; /* 1 or -1 */ 98 int slot_num_inc; /* 1 or -1 */
@@ -166,10 +167,10 @@ struct controller {
166 * error Messages 167 * error Messages
167 */ 168 */
168#define msg_initialization_err "Initialization failure, error=%d\n" 169#define msg_initialization_err "Initialization failure, error=%d\n"
169#define msg_button_on "PCI slot #%d - powering on due to button press.\n" 170#define msg_button_on "PCI slot #%s - powering on due to button press.\n"
170#define msg_button_off "PCI slot #%d - powering off due to button press.\n" 171#define msg_button_off "PCI slot #%s - powering off due to button press.\n"
171#define msg_button_cancel "PCI slot #%d - action canceled due to button press.\n" 172#define msg_button_cancel "PCI slot #%s - action canceled due to button press.\n"
172#define msg_button_ignore "PCI slot #%d - button press ignored. (action in progress...)\n" 173#define msg_button_ignore "PCI slot #%s - button press ignored. (action in progress...)\n"
173 174
174/* controller functions */ 175/* controller functions */
175extern int pciehp_event_start_thread (void); 176extern int pciehp_event_start_thread (void);
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index c67b7c3f1ddf..f93e81e2d2c7 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -448,7 +448,7 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
448 } 448 }
449 449
450 /* Wait for exclusive access to hardware */ 450 /* Wait for exclusive access to hardware */
451 mutex_lock(&ctrl->crit_sect); 451 mutex_lock(&ctrl->ctrl_lock);
452 452
453 t_slot->hpc_ops->get_adapter_status(t_slot, &value); /* Check if slot is occupied */ 453 t_slot->hpc_ops->get_adapter_status(t_slot, &value); /* Check if slot is occupied */
454 454
@@ -456,7 +456,7 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
456 rc = t_slot->hpc_ops->power_off_slot(t_slot); /* Power off slot if not occupied*/ 456 rc = t_slot->hpc_ops->power_off_slot(t_slot); /* Power off slot if not occupied*/
457 if (rc) { 457 if (rc) {
458 /* Done with exclusive hardware access */ 458 /* Done with exclusive hardware access */
459 mutex_unlock(&ctrl->crit_sect); 459 mutex_unlock(&ctrl->ctrl_lock);
460 goto err_out_free_ctrl_slot; 460 goto err_out_free_ctrl_slot;
461 } else 461 } else
462 /* Wait for the command to complete */ 462 /* Wait for the command to complete */
@@ -464,7 +464,7 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
464 } 464 }
465 465
466 /* Done with exclusive hardware access */ 466 /* Done with exclusive hardware access */
467 mutex_unlock(&ctrl->crit_sect); 467 mutex_unlock(&ctrl->ctrl_lock);
468 468
469 return 0; 469 return 0;
470 470
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
index 41290a106bd8..372c63e35aa9 100644
--- a/drivers/pci/hotplug/pciehp_ctrl.c
+++ b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -43,6 +43,11 @@ static int event_finished;
43static unsigned long pushbutton_pending; /* = 0 */ 43static unsigned long pushbutton_pending; /* = 0 */
44static unsigned long surprise_rm_pending; /* = 0 */ 44static unsigned long surprise_rm_pending; /* = 0 */
45 45
46static inline char *slot_name(struct slot *p_slot)
47{
48 return p_slot->hotplug_slot->name;
49}
50
46u8 pciehp_handle_attention_button(u8 hp_slot, void *inst_id) 51u8 pciehp_handle_attention_button(u8 hp_slot, void *inst_id)
47{ 52{
48 struct controller *ctrl = (struct controller *) inst_id; 53 struct controller *ctrl = (struct controller *) inst_id;
@@ -68,7 +73,7 @@ u8 pciehp_handle_attention_button(u8 hp_slot, void *inst_id)
68 /* 73 /*
69 * Button pressed - See if need to TAKE ACTION!!! 74 * Button pressed - See if need to TAKE ACTION!!!
70 */ 75 */
71 info("Button pressed on Slot(%d)\n", ctrl->first_slot + hp_slot); 76 info("Button pressed on Slot(%s)\n", slot_name(p_slot));
72 taskInfo->event_type = INT_BUTTON_PRESS; 77 taskInfo->event_type = INT_BUTTON_PRESS;
73 78
74 if ((p_slot->state == BLINKINGON_STATE) 79 if ((p_slot->state == BLINKINGON_STATE)
@@ -78,7 +83,7 @@ u8 pciehp_handle_attention_button(u8 hp_slot, void *inst_id)
78 * or hot-remove 83 * or hot-remove
79 */ 84 */
80 taskInfo->event_type = INT_BUTTON_CANCEL; 85 taskInfo->event_type = INT_BUTTON_CANCEL;
81 info("Button cancel on Slot(%d)\n", ctrl->first_slot + hp_slot); 86 info("Button cancel on Slot(%s)\n", slot_name(p_slot));
82 } else if ((p_slot->state == POWERON_STATE) 87 } else if ((p_slot->state == POWERON_STATE)
83 || (p_slot->state == POWEROFF_STATE)) { 88 || (p_slot->state == POWEROFF_STATE)) {
84 /* Ignore if the slot is on power-on or power-off state; this 89 /* Ignore if the slot is on power-on or power-off state; this
@@ -86,7 +91,7 @@ u8 pciehp_handle_attention_button(u8 hp_slot, void *inst_id)
86 * hot-remove is undergoing 91 * hot-remove is undergoing
87 */ 92 */
88 taskInfo->event_type = INT_BUTTON_IGNORE; 93 taskInfo->event_type = INT_BUTTON_IGNORE;
89 info("Button ignore on Slot(%d)\n", ctrl->first_slot + hp_slot); 94 info("Button ignore on Slot(%s)\n", slot_name(p_slot));
90 } 95 }
91 96
92 if (rc) 97 if (rc)
@@ -122,13 +127,13 @@ u8 pciehp_handle_switch_change(u8 hp_slot, void *inst_id)
122 /* 127 /*
123 * Switch opened 128 * Switch opened
124 */ 129 */
125 info("Latch open on Slot(%d)\n", ctrl->first_slot + hp_slot); 130 info("Latch open on Slot(%s)\n", slot_name(p_slot));
126 taskInfo->event_type = INT_SWITCH_OPEN; 131 taskInfo->event_type = INT_SWITCH_OPEN;
127 } else { 132 } else {
128 /* 133 /*
129 * Switch closed 134 * Switch closed
130 */ 135 */
131 info("Latch close on Slot(%d)\n", ctrl->first_slot + hp_slot); 136 info("Latch close on Slot(%s)\n", slot_name(p_slot));
132 taskInfo->event_type = INT_SWITCH_CLOSE; 137 taskInfo->event_type = INT_SWITCH_CLOSE;
133 } 138 }
134 139
@@ -166,13 +171,13 @@ u8 pciehp_handle_presence_change(u8 hp_slot, void *inst_id)
166 /* 171 /*
167 * Card Present 172 * Card Present
168 */ 173 */
169 info("Card present on Slot(%d)\n", ctrl->first_slot + hp_slot); 174 info("Card present on Slot(%s)\n", slot_name(p_slot));
170 taskInfo->event_type = INT_PRESENCE_ON; 175 taskInfo->event_type = INT_PRESENCE_ON;
171 } else { 176 } else {
172 /* 177 /*
173 * Not Present 178 * Not Present
174 */ 179 */
175 info("Card not present on Slot(%d)\n", ctrl->first_slot + hp_slot); 180 info("Card not present on Slot(%s)\n", slot_name(p_slot));
176 taskInfo->event_type = INT_PRESENCE_OFF; 181 taskInfo->event_type = INT_PRESENCE_OFF;
177 } 182 }
178 183
@@ -206,13 +211,13 @@ u8 pciehp_handle_power_fault(u8 hp_slot, void *inst_id)
206 /* 211 /*
207 * power fault Cleared 212 * power fault Cleared
208 */ 213 */
209 info("Power fault cleared on Slot(%d)\n", ctrl->first_slot + hp_slot); 214 info("Power fault cleared on Slot(%s)\n", slot_name(p_slot));
210 taskInfo->event_type = INT_POWER_FAULT_CLEAR; 215 taskInfo->event_type = INT_POWER_FAULT_CLEAR;
211 } else { 216 } else {
212 /* 217 /*
213 * power fault 218 * power fault
214 */ 219 */
215 info("Power fault on Slot(%d)\n", ctrl->first_slot + hp_slot); 220 info("Power fault on Slot(%s)\n", slot_name(p_slot));
216 taskInfo->event_type = INT_POWER_FAULT; 221 taskInfo->event_type = INT_POWER_FAULT;
217 info("power fault bit %x set\n", hp_slot); 222 info("power fault bit %x set\n", hp_slot);
218 } 223 }
@@ -229,13 +234,13 @@ u8 pciehp_handle_power_fault(u8 hp_slot, void *inst_id)
229static void set_slot_off(struct controller *ctrl, struct slot * pslot) 234static void set_slot_off(struct controller *ctrl, struct slot * pslot)
230{ 235{
231 /* Wait for exclusive access to hardware */ 236 /* Wait for exclusive access to hardware */
232 mutex_lock(&ctrl->crit_sect); 237 mutex_lock(&ctrl->ctrl_lock);
233 238
234 /* turn off slot, turn on Amber LED, turn off Green LED if supported*/ 239 /* turn off slot, turn on Amber LED, turn off Green LED if supported*/
235 if (POWER_CTRL(ctrl->ctrlcap)) { 240 if (POWER_CTRL(ctrl->ctrlcap)) {
236 if (pslot->hpc_ops->power_off_slot(pslot)) { 241 if (pslot->hpc_ops->power_off_slot(pslot)) {
237 err("%s: Issue of Slot Power Off command failed\n", __FUNCTION__); 242 err("%s: Issue of Slot Power Off command failed\n", __FUNCTION__);
238 mutex_unlock(&ctrl->crit_sect); 243 mutex_unlock(&ctrl->ctrl_lock);
239 return; 244 return;
240 } 245 }
241 wait_for_ctrl_irq (ctrl); 246 wait_for_ctrl_irq (ctrl);
@@ -249,14 +254,14 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot)
249 if (ATTN_LED(ctrl->ctrlcap)) { 254 if (ATTN_LED(ctrl->ctrlcap)) {
250 if (pslot->hpc_ops->set_attention_status(pslot, 1)) { 255 if (pslot->hpc_ops->set_attention_status(pslot, 1)) {
251 err("%s: Issue of Set Attention Led command failed\n", __FUNCTION__); 256 err("%s: Issue of Set Attention Led command failed\n", __FUNCTION__);
252 mutex_unlock(&ctrl->crit_sect); 257 mutex_unlock(&ctrl->ctrl_lock);
253 return; 258 return;
254 } 259 }
255 wait_for_ctrl_irq (ctrl); 260 wait_for_ctrl_irq (ctrl);
256 } 261 }
257 262
258 /* Done with exclusive hardware access */ 263 /* Done with exclusive hardware access */
259 mutex_unlock(&ctrl->crit_sect); 264 mutex_unlock(&ctrl->ctrl_lock);
260} 265}
261 266
262/** 267/**
@@ -279,13 +284,13 @@ static int board_added(struct slot *p_slot)
279 ctrl->slot_device_offset, hp_slot); 284 ctrl->slot_device_offset, hp_slot);
280 285
281 /* Wait for exclusive access to hardware */ 286 /* Wait for exclusive access to hardware */
282 mutex_lock(&ctrl->crit_sect); 287 mutex_lock(&ctrl->ctrl_lock);
283 288
284 if (POWER_CTRL(ctrl->ctrlcap)) { 289 if (POWER_CTRL(ctrl->ctrlcap)) {
285 /* Power on slot */ 290 /* Power on slot */
286 rc = p_slot->hpc_ops->power_on_slot(p_slot); 291 rc = p_slot->hpc_ops->power_on_slot(p_slot);
287 if (rc) { 292 if (rc) {
288 mutex_unlock(&ctrl->crit_sect); 293 mutex_unlock(&ctrl->ctrl_lock);
289 return -1; 294 return -1;
290 } 295 }
291 296
@@ -301,7 +306,7 @@ static int board_added(struct slot *p_slot)
301 } 306 }
302 307
303 /* Done with exclusive hardware access */ 308 /* Done with exclusive hardware access */
304 mutex_unlock(&ctrl->crit_sect); 309 mutex_unlock(&ctrl->ctrl_lock);
305 310
306 /* Wait for ~1 second */ 311 /* Wait for ~1 second */
307 wait_for_ctrl_irq (ctrl); 312 wait_for_ctrl_irq (ctrl);
@@ -335,7 +340,7 @@ static int board_added(struct slot *p_slot)
335 pci_fixup_device(pci_fixup_final, ctrl->pci_dev); 340 pci_fixup_device(pci_fixup_final, ctrl->pci_dev);
336 if (PWR_LED(ctrl->ctrlcap)) { 341 if (PWR_LED(ctrl->ctrlcap)) {
337 /* Wait for exclusive access to hardware */ 342 /* Wait for exclusive access to hardware */
338 mutex_lock(&ctrl->crit_sect); 343 mutex_lock(&ctrl->ctrl_lock);
339 344
340 p_slot->hpc_ops->green_led_on(p_slot); 345 p_slot->hpc_ops->green_led_on(p_slot);
341 346
@@ -343,7 +348,7 @@ static int board_added(struct slot *p_slot)
343 wait_for_ctrl_irq (ctrl); 348 wait_for_ctrl_irq (ctrl);
344 349
345 /* Done with exclusive hardware access */ 350 /* Done with exclusive hardware access */
346 mutex_unlock(&ctrl->crit_sect); 351 mutex_unlock(&ctrl->ctrl_lock);
347 } 352 }
348 return 0; 353 return 0;
349 354
@@ -375,14 +380,14 @@ static int remove_board(struct slot *p_slot)
375 dbg("In %s, hp_slot = %d\n", __FUNCTION__, hp_slot); 380 dbg("In %s, hp_slot = %d\n", __FUNCTION__, hp_slot);
376 381
377 /* Wait for exclusive access to hardware */ 382 /* Wait for exclusive access to hardware */
378 mutex_lock(&ctrl->crit_sect); 383 mutex_lock(&ctrl->ctrl_lock);
379 384
380 if (POWER_CTRL(ctrl->ctrlcap)) { 385 if (POWER_CTRL(ctrl->ctrlcap)) {
381 /* power off slot */ 386 /* power off slot */
382 rc = p_slot->hpc_ops->power_off_slot(p_slot); 387 rc = p_slot->hpc_ops->power_off_slot(p_slot);
383 if (rc) { 388 if (rc) {
384 err("%s: Issue of Slot Disable command failed\n", __FUNCTION__); 389 err("%s: Issue of Slot Disable command failed\n", __FUNCTION__);
385 mutex_unlock(&ctrl->crit_sect); 390 mutex_unlock(&ctrl->ctrl_lock);
386 return rc; 391 return rc;
387 } 392 }
388 /* Wait for the command to complete */ 393 /* Wait for the command to complete */
@@ -398,7 +403,7 @@ static int remove_board(struct slot *p_slot)
398 } 403 }
399 404
400 /* Done with exclusive hardware access */ 405 /* Done with exclusive hardware access */
401 mutex_unlock(&ctrl->crit_sect); 406 mutex_unlock(&ctrl->ctrl_lock);
402 407
403 return 0; 408 return 0;
404} 409}
@@ -445,7 +450,7 @@ static void pciehp_pushbutton_thread(unsigned long slot)
445 450
446 if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) { 451 if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) {
447 /* Wait for exclusive access to hardware */ 452 /* Wait for exclusive access to hardware */
448 mutex_lock(&p_slot->ctrl->crit_sect); 453 mutex_lock(&p_slot->ctrl->ctrl_lock);
449 454
450 p_slot->hpc_ops->green_led_off(p_slot); 455 p_slot->hpc_ops->green_led_off(p_slot);
451 456
@@ -453,7 +458,7 @@ static void pciehp_pushbutton_thread(unsigned long slot)
453 wait_for_ctrl_irq (p_slot->ctrl); 458 wait_for_ctrl_irq (p_slot->ctrl);
454 459
455 /* Done with exclusive hardware access */ 460 /* Done with exclusive hardware access */
456 mutex_unlock(&p_slot->ctrl->crit_sect); 461 mutex_unlock(&p_slot->ctrl->ctrl_lock);
457 } 462 }
458 p_slot->state = STATIC_STATE; 463 p_slot->state = STATIC_STATE;
459 } 464 }
@@ -495,7 +500,7 @@ static void pciehp_surprise_rm_thread(unsigned long slot)
495 500
496 if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) { 501 if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) {
497 /* Wait for exclusive access to hardware */ 502 /* Wait for exclusive access to hardware */
498 mutex_lock(&p_slot->ctrl->crit_sect); 503 mutex_lock(&p_slot->ctrl->ctrl_lock);
499 504
500 p_slot->hpc_ops->green_led_off(p_slot); 505 p_slot->hpc_ops->green_led_off(p_slot);
501 506
@@ -503,7 +508,7 @@ static void pciehp_surprise_rm_thread(unsigned long slot)
503 wait_for_ctrl_irq (p_slot->ctrl); 508 wait_for_ctrl_irq (p_slot->ctrl);
504 509
505 /* Done with exclusive hardware access */ 510 /* Done with exclusive hardware access */
506 mutex_unlock(&p_slot->ctrl->crit_sect); 511 mutex_unlock(&p_slot->ctrl->ctrl_lock);
507 } 512 }
508 p_slot->state = STATIC_STATE; 513 p_slot->state = STATIC_STATE;
509 } 514 }
@@ -616,7 +621,7 @@ static void interrupt_event_handler(struct controller *ctrl)
616 switch (p_slot->state) { 621 switch (p_slot->state) {
617 case BLINKINGOFF_STATE: 622 case BLINKINGOFF_STATE:
618 /* Wait for exclusive access to hardware */ 623 /* Wait for exclusive access to hardware */
619 mutex_lock(&ctrl->crit_sect); 624 mutex_lock(&ctrl->ctrl_lock);
620 625
621 if (PWR_LED(ctrl->ctrlcap)) { 626 if (PWR_LED(ctrl->ctrlcap)) {
622 p_slot->hpc_ops->green_led_on(p_slot); 627 p_slot->hpc_ops->green_led_on(p_slot);
@@ -630,11 +635,11 @@ static void interrupt_event_handler(struct controller *ctrl)
630 wait_for_ctrl_irq (ctrl); 635 wait_for_ctrl_irq (ctrl);
631 } 636 }
632 /* Done with exclusive hardware access */ 637 /* Done with exclusive hardware access */
633 mutex_unlock(&ctrl->crit_sect); 638 mutex_unlock(&ctrl->ctrl_lock);
634 break; 639 break;
635 case BLINKINGON_STATE: 640 case BLINKINGON_STATE:
636 /* Wait for exclusive access to hardware */ 641 /* Wait for exclusive access to hardware */
637 mutex_lock(&ctrl->crit_sect); 642 mutex_lock(&ctrl->ctrl_lock);
638 643
639 if (PWR_LED(ctrl->ctrlcap)) { 644 if (PWR_LED(ctrl->ctrlcap)) {
640 p_slot->hpc_ops->green_led_off(p_slot); 645 p_slot->hpc_ops->green_led_off(p_slot);
@@ -647,14 +652,14 @@ static void interrupt_event_handler(struct controller *ctrl)
647 wait_for_ctrl_irq (ctrl); 652 wait_for_ctrl_irq (ctrl);
648 } 653 }
649 /* Done with exclusive hardware access */ 654 /* Done with exclusive hardware access */
650 mutex_unlock(&ctrl->crit_sect); 655 mutex_unlock(&ctrl->ctrl_lock);
651 656
652 break; 657 break;
653 default: 658 default:
654 warn("Not a valid state\n"); 659 warn("Not a valid state\n");
655 return; 660 return;
656 } 661 }
657 info(msg_button_cancel, p_slot->number); 662 info(msg_button_cancel, slot_name(p_slot));
658 p_slot->state = STATIC_STATE; 663 p_slot->state = STATIC_STATE;
659 } 664 }
660 /* ***********Button Pressed (No action on 1st press...) */ 665 /* ***********Button Pressed (No action on 1st press...) */
@@ -667,16 +672,16 @@ static void interrupt_event_handler(struct controller *ctrl)
667 /* slot is on */ 672 /* slot is on */
668 dbg("slot is on\n"); 673 dbg("slot is on\n");
669 p_slot->state = BLINKINGOFF_STATE; 674 p_slot->state = BLINKINGOFF_STATE;
670 info(msg_button_off, p_slot->number); 675 info(msg_button_off, slot_name(p_slot));
671 } else { 676 } else {
672 /* slot is off */ 677 /* slot is off */
673 dbg("slot is off\n"); 678 dbg("slot is off\n");
674 p_slot->state = BLINKINGON_STATE; 679 p_slot->state = BLINKINGON_STATE;
675 info(msg_button_on, p_slot->number); 680 info(msg_button_on, slot_name(p_slot));
676 } 681 }
677 682
678 /* Wait for exclusive access to hardware */ 683 /* Wait for exclusive access to hardware */
679 mutex_lock(&ctrl->crit_sect); 684 mutex_lock(&ctrl->ctrl_lock);
680 685
681 /* blink green LED and turn off amber */ 686 /* blink green LED and turn off amber */
682 if (PWR_LED(ctrl->ctrlcap)) { 687 if (PWR_LED(ctrl->ctrlcap)) {
@@ -693,7 +698,7 @@ static void interrupt_event_handler(struct controller *ctrl)
693 } 698 }
694 699
695 /* Done with exclusive hardware access */ 700 /* Done with exclusive hardware access */
696 mutex_unlock(&ctrl->crit_sect); 701 mutex_unlock(&ctrl->ctrl_lock);
697 702
698 init_timer(&p_slot->task_event); 703 init_timer(&p_slot->task_event);
699 p_slot->task_event.expires = jiffies + 5 * HZ; /* 5 second delay */ 704 p_slot->task_event.expires = jiffies + 5 * HZ; /* 5 second delay */
@@ -708,7 +713,7 @@ static void interrupt_event_handler(struct controller *ctrl)
708 if (POWER_CTRL(ctrl->ctrlcap)) { 713 if (POWER_CTRL(ctrl->ctrlcap)) {
709 dbg("power fault\n"); 714 dbg("power fault\n");
710 /* Wait for exclusive access to hardware */ 715 /* Wait for exclusive access to hardware */
711 mutex_lock(&ctrl->crit_sect); 716 mutex_lock(&ctrl->ctrl_lock);
712 717
713 if (ATTN_LED(ctrl->ctrlcap)) { 718 if (ATTN_LED(ctrl->ctrlcap)) {
714 p_slot->hpc_ops->set_attention_status(p_slot, 1); 719 p_slot->hpc_ops->set_attention_status(p_slot, 1);
@@ -721,7 +726,7 @@ static void interrupt_event_handler(struct controller *ctrl)
721 } 726 }
722 727
723 /* Done with exclusive hardware access */ 728 /* Done with exclusive hardware access */
724 mutex_unlock(&ctrl->crit_sect); 729 mutex_unlock(&ctrl->ctrl_lock);
725 } 730 }
726 } 731 }
727 /***********SURPRISE REMOVAL********************/ 732 /***********SURPRISE REMOVAL********************/
@@ -760,14 +765,16 @@ int pciehp_enable_slot(struct slot *p_slot)
760 765
761 rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 766 rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
762 if (rc || !getstatus) { 767 if (rc || !getstatus) {
763 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); 768 info("%s: no adapter on slot(%s)\n", __FUNCTION__,
769 slot_name(p_slot));
764 mutex_unlock(&p_slot->ctrl->crit_sect); 770 mutex_unlock(&p_slot->ctrl->crit_sect);
765 return -ENODEV; 771 return -ENODEV;
766 } 772 }
767 if (MRL_SENS(p_slot->ctrl->ctrlcap)) { 773 if (MRL_SENS(p_slot->ctrl->ctrlcap)) {
768 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 774 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
769 if (rc || getstatus) { 775 if (rc || getstatus) {
770 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); 776 info("%s: latch open on slot(%s)\n", __FUNCTION__,
777 slot_name(p_slot));
771 mutex_unlock(&p_slot->ctrl->crit_sect); 778 mutex_unlock(&p_slot->ctrl->crit_sect);
772 return -ENODEV; 779 return -ENODEV;
773 } 780 }
@@ -776,12 +783,12 @@ int pciehp_enable_slot(struct slot *p_slot)
776 if (POWER_CTRL(p_slot->ctrl->ctrlcap)) { 783 if (POWER_CTRL(p_slot->ctrl->ctrlcap)) {
777 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 784 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
778 if (rc || getstatus) { 785 if (rc || getstatus) {
779 info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number); 786 info("%s: already enabled on slot(%s)\n", __FUNCTION__,
787 slot_name(p_slot));
780 mutex_unlock(&p_slot->ctrl->crit_sect); 788 mutex_unlock(&p_slot->ctrl->crit_sect);
781 return -EINVAL; 789 return -EINVAL;
782 } 790 }
783 } 791 }
784 mutex_unlock(&p_slot->ctrl->crit_sect);
785 792
786 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 793 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
787 794
@@ -790,9 +797,9 @@ int pciehp_enable_slot(struct slot *p_slot)
790 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 797 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
791 } 798 }
792 799
793 if (p_slot) 800 update_slot_info(p_slot);
794 update_slot_info(p_slot);
795 801
802 mutex_unlock(&p_slot->ctrl->crit_sect);
796 return rc; 803 return rc;
797} 804}
798 805
@@ -811,7 +818,8 @@ int pciehp_disable_slot(struct slot *p_slot)
811 if (!HP_SUPR_RM(p_slot->ctrl->ctrlcap)) { 818 if (!HP_SUPR_RM(p_slot->ctrl->ctrlcap)) {
812 ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 819 ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
813 if (ret || !getstatus) { 820 if (ret || !getstatus) {
814 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); 821 info("%s: no adapter on slot(%s)\n", __FUNCTION__,
822 slot_name(p_slot));
815 mutex_unlock(&p_slot->ctrl->crit_sect); 823 mutex_unlock(&p_slot->ctrl->crit_sect);
816 return -ENODEV; 824 return -ENODEV;
817 } 825 }
@@ -820,7 +828,8 @@ int pciehp_disable_slot(struct slot *p_slot)
820 if (MRL_SENS(p_slot->ctrl->ctrlcap)) { 828 if (MRL_SENS(p_slot->ctrl->ctrlcap)) {
821 ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 829 ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
822 if (ret || getstatus) { 830 if (ret || getstatus) {
823 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); 831 info("%s: latch open on slot(%s)\n", __FUNCTION__,
832 slot_name(p_slot));
824 mutex_unlock(&p_slot->ctrl->crit_sect); 833 mutex_unlock(&p_slot->ctrl->crit_sect);
825 return -ENODEV; 834 return -ENODEV;
826 } 835 }
@@ -829,16 +838,17 @@ int pciehp_disable_slot(struct slot *p_slot)
829 if (POWER_CTRL(p_slot->ctrl->ctrlcap)) { 838 if (POWER_CTRL(p_slot->ctrl->ctrlcap)) {
830 ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 839 ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
831 if (ret || !getstatus) { 840 if (ret || !getstatus) {
832 info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number); 841 info("%s: already disabled slot(%s)\n", __FUNCTION__,
842 slot_name(p_slot));
833 mutex_unlock(&p_slot->ctrl->crit_sect); 843 mutex_unlock(&p_slot->ctrl->crit_sect);
834 return -EINVAL; 844 return -EINVAL;
835 } 845 }
836 } 846 }
837 847
838 mutex_unlock(&p_slot->ctrl->crit_sect);
839
840 ret = remove_board(p_slot); 848 ret = remove_board(p_slot);
841 update_slot_info(p_slot); 849 update_slot_info(p_slot);
850
851 mutex_unlock(&p_slot->ctrl->crit_sect);
842 return ret; 852 return ret;
843} 853}
844 854
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index 703a64a39fe8..1c551c697c35 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -1402,6 +1402,8 @@ int pcie_init(struct controller * ctrl, struct pcie_device *dev)
1402 pdev->subsystem_vendor, pdev->subsystem_device); 1402 pdev->subsystem_vendor, pdev->subsystem_device);
1403 1403
1404 mutex_init(&ctrl->crit_sect); 1404 mutex_init(&ctrl->crit_sect);
1405 mutex_init(&ctrl->ctrl_lock);
1406
1405 /* setup wait queue */ 1407 /* setup wait queue */
1406 init_waitqueue_head(&ctrl->queue); 1408 init_waitqueue_head(&ctrl->queue);
1407 1409
diff --git a/drivers/pci/hotplug/pcihp_skeleton.c b/drivers/pci/hotplug/pcihp_skeleton.c
index 2b9e10e38613..50bcd3fe61da 100644
--- a/drivers/pci/hotplug/pcihp_skeleton.c
+++ b/drivers/pci/hotplug/pcihp_skeleton.c
@@ -33,8 +33,8 @@
33#include <linux/kernel.h> 33#include <linux/kernel.h>
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/pci.h> 35#include <linux/pci.h>
36#include <linux/pci_hotplug.h>
36#include <linux/init.h> 37#include <linux/init.h>
37#include "pci_hotplug.h"
38 38
39#define SLOT_NAME_SIZE 10 39#define SLOT_NAME_SIZE 10
40struct slot { 40struct slot {
diff --git a/drivers/pci/hotplug/rpadlpar_sysfs.c b/drivers/pci/hotplug/rpadlpar_sysfs.c
index db69be85b458..6c5be3ff578c 100644
--- a/drivers/pci/hotplug/rpadlpar_sysfs.c
+++ b/drivers/pci/hotplug/rpadlpar_sysfs.c
@@ -14,7 +14,7 @@
14 */ 14 */
15#include <linux/kobject.h> 15#include <linux/kobject.h>
16#include <linux/string.h> 16#include <linux/string.h>
17#include "pci_hotplug.h" 17#include <linux/pci_hotplug.h>
18#include "rpadlpar.h" 18#include "rpadlpar.h"
19 19
20#define DLPAR_KOBJ_NAME "control" 20#define DLPAR_KOBJ_NAME "control"
diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h
index 310b6186c0e5..2e7accf0f734 100644
--- a/drivers/pci/hotplug/rpaphp.h
+++ b/drivers/pci/hotplug/rpaphp.h
@@ -28,7 +28,7 @@
28#define _PPC64PHP_H 28#define _PPC64PHP_H
29 29
30#include <linux/pci.h> 30#include <linux/pci.h>
31#include "pci_hotplug.h" 31#include <linux/pci_hotplug.h>
32 32
33#define DR_INDICATOR 9002 33#define DR_INDICATOR 9002
34#define DR_ENTITY_SENSE 9003 34#define DR_ENTITY_SENSE 9003
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
index 7288a3eccfb3..141486df235b 100644
--- a/drivers/pci/hotplug/rpaphp_core.c
+++ b/drivers/pci/hotplug/rpaphp_core.c
@@ -26,6 +26,7 @@
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/moduleparam.h> 27#include <linux/moduleparam.h>
28#include <linux/pci.h> 28#include <linux/pci.h>
29#include <linux/pci_hotplug.h>
29#include <linux/slab.h> 30#include <linux/slab.h>
30#include <linux/smp.h> 31#include <linux/smp.h>
31#include <linux/smp_lock.h> 32#include <linux/smp_lock.h>
@@ -36,7 +37,6 @@
36#include "../pci.h" /* for pci_add_new_bus */ 37#include "../pci.h" /* for pci_add_new_bus */
37 /* and pci_do_scan_bus */ 38 /* and pci_do_scan_bus */
38#include "rpaphp.h" 39#include "rpaphp.h"
39#include "pci_hotplug.h"
40 40
41int debug; 41int debug;
42static struct semaphore rpaphp_sem; 42static struct semaphore rpaphp_sem;
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c
index f31d83c2c633..b62ad31a9739 100644
--- a/drivers/pci/hotplug/sgi_hotplug.c
+++ b/drivers/pci/hotplug/sgi_hotplug.c
@@ -13,6 +13,7 @@
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/pci.h> 15#include <linux/pci.h>
16#include <linux/pci_hotplug.h>
16#include <linux/proc_fs.h> 17#include <linux/proc_fs.h>
17#include <linux/types.h> 18#include <linux/types.h>
18#include <linux/mutex.h> 19#include <linux/mutex.h>
@@ -29,7 +30,6 @@
29#include <asm/sn/types.h> 30#include <asm/sn/types.h>
30 31
31#include "../pci.h" 32#include "../pci.h"
32#include "pci_hotplug.h"
33 33
34MODULE_LICENSE("GPL"); 34MODULE_LICENSE("GPL");
35MODULE_AUTHOR("SGI (prarit@sgi.com, dickie@sgi.com, habeck@sgi.com)"); 35MODULE_AUTHOR("SGI (prarit@sgi.com, dickie@sgi.com, habeck@sgi.com)");
diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h
index c7103ac5cd06..ea2087c34149 100644
--- a/drivers/pci/hotplug/shpchp.h
+++ b/drivers/pci/hotplug/shpchp.h
@@ -31,12 +31,11 @@
31 31
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/pci.h> 33#include <linux/pci.h>
34#include <linux/pci_hotplug.h>
34#include <linux/delay.h> 35#include <linux/delay.h>
35#include <linux/sched.h> /* signal_pending(), struct timer_list */ 36#include <linux/sched.h> /* signal_pending(), struct timer_list */
36#include <linux/mutex.h> 37#include <linux/mutex.h>
37 38
38#include "pci_hotplug.h"
39
40#if !defined(MODULE) 39#if !defined(MODULE)
41 #define MY_NAME "shpchp" 40 #define MY_NAME "shpchp"
42#else 41#else
@@ -103,7 +102,6 @@ struct controller {
103 u32 cap_offset; 102 u32 cap_offset;
104 unsigned long mmio_base; 103 unsigned long mmio_base;
105 unsigned long mmio_size; 104 unsigned long mmio_size;
106 volatile int cmd_busy;
107}; 105};
108 106
109 107
diff --git a/drivers/pci/hotplug/shpchp_hpc.c b/drivers/pci/hotplug/shpchp_hpc.c
index 4d8aee119134..83a5226ba9ed 100644
--- a/drivers/pci/hotplug/shpchp_hpc.c
+++ b/drivers/pci/hotplug/shpchp_hpc.c
@@ -302,21 +302,51 @@ static void start_int_poll_timer(struct php_ctlr_state_s *php_ctlr, int sec)
302 add_timer(&php_ctlr->int_poll_timer); 302 add_timer(&php_ctlr->int_poll_timer);
303} 303}
304 304
305static inline int is_ctrl_busy(struct controller *ctrl)
306{
307 u16 cmd_status = shpc_readw(ctrl, CMD_STATUS);
308 return cmd_status & 0x1;
309}
310
311/*
312 * Returns 1 if SHPC finishes executing a command within 1 sec,
313 * otherwise returns 0.
314 */
315static inline int shpc_poll_ctrl_busy(struct controller *ctrl)
316{
317 int i;
318
319 if (!is_ctrl_busy(ctrl))
320 return 1;
321
322 /* Check every 0.1 sec for a total of 1 sec */
323 for (i = 0; i < 10; i++) {
324 msleep(100);
325 if (!is_ctrl_busy(ctrl))
326 return 1;
327 }
328
329 return 0;
330}
331
305static inline int shpc_wait_cmd(struct controller *ctrl) 332static inline int shpc_wait_cmd(struct controller *ctrl)
306{ 333{
307 int retval = 0; 334 int retval = 0;
308 unsigned int timeout_msec = shpchp_poll_mode ? 2000 : 1000; 335 unsigned long timeout = msecs_to_jiffies(1000);
309 unsigned long timeout = msecs_to_jiffies(timeout_msec); 336 int rc;
310 int rc = wait_event_interruptible_timeout(ctrl->queue, 337
311 !ctrl->cmd_busy, timeout); 338 if (shpchp_poll_mode)
312 if (!rc) { 339 rc = shpc_poll_ctrl_busy(ctrl);
340 else
341 rc = wait_event_interruptible_timeout(ctrl->queue,
342 !is_ctrl_busy(ctrl), timeout);
343 if (!rc && is_ctrl_busy(ctrl)) {
313 retval = -EIO; 344 retval = -EIO;
314 err("Command not completed in %d msec\n", timeout_msec); 345 err("Command not completed in 1000 msec\n");
315 } else if (rc < 0) { 346 } else if (rc < 0) {
316 retval = -EINTR; 347 retval = -EINTR;
317 info("Command was interrupted by a signal\n"); 348 info("Command was interrupted by a signal\n");
318 } 349 }
319 ctrl->cmd_busy = 0;
320 350
321 return retval; 351 return retval;
322} 352}
@@ -327,26 +357,15 @@ static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd)
327 u16 cmd_status; 357 u16 cmd_status;
328 int retval = 0; 358 int retval = 0;
329 u16 temp_word; 359 u16 temp_word;
330 int i;
331 360
332 DBG_ENTER_ROUTINE 361 DBG_ENTER_ROUTINE
333 362
334 mutex_lock(&slot->ctrl->cmd_lock); 363 mutex_lock(&slot->ctrl->cmd_lock);
335 364
336 for (i = 0; i < 10; i++) { 365 if (!shpc_poll_ctrl_busy(ctrl)) {
337 cmd_status = shpc_readw(ctrl, CMD_STATUS);
338
339 if (!(cmd_status & 0x1))
340 break;
341 /* Check every 0.1 sec for a total of 1 sec*/
342 msleep(100);
343 }
344
345 cmd_status = shpc_readw(ctrl, CMD_STATUS);
346
347 if (cmd_status & 0x1) {
348 /* After 1 sec and and the controller is still busy */ 366 /* After 1 sec and and the controller is still busy */
349 err("%s : Controller is still busy after 1 sec.\n", __FUNCTION__); 367 err("%s : Controller is still busy after 1 sec.\n",
368 __FUNCTION__);
350 retval = -EBUSY; 369 retval = -EBUSY;
351 goto out; 370 goto out;
352 } 371 }
@@ -358,7 +377,6 @@ static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd)
358 /* To make sure the Controller Busy bit is 0 before we send out the 377 /* To make sure the Controller Busy bit is 0 before we send out the
359 * command. 378 * command.
360 */ 379 */
361 slot->ctrl->cmd_busy = 1;
362 shpc_writew(ctrl, CMD, temp_word); 380 shpc_writew(ctrl, CMD, temp_word);
363 381
364 /* 382 /*
@@ -908,7 +926,6 @@ static irqreturn_t shpc_isr(int irq, void *dev_id)
908 serr_int &= ~SERR_INTR_RSVDZ_MASK; 926 serr_int &= ~SERR_INTR_RSVDZ_MASK;
909 shpc_writel(ctrl, SERR_INTR_ENABLE, serr_int); 927 shpc_writel(ctrl, SERR_INTR_ENABLE, serr_int);
910 928
911 ctrl->cmd_busy = 0;
912 wake_up_interruptible(&ctrl->queue); 929 wake_up_interruptible(&ctrl->queue);
913 } 930 }
914 931
@@ -1101,7 +1118,7 @@ int shpc_init(struct controller * ctrl, struct pci_dev * pdev)
1101{ 1118{
1102 struct php_ctlr_state_s *php_ctlr, *p; 1119 struct php_ctlr_state_s *php_ctlr, *p;
1103 void *instance_id = ctrl; 1120 void *instance_id = ctrl;
1104 int rc, num_slots = 0; 1121 int rc = -1, num_slots = 0;
1105 u8 hp_slot; 1122 u8 hp_slot;
1106 u32 shpc_base_offset; 1123 u32 shpc_base_offset;
1107 u32 tempdword, slot_reg, slot_config; 1124 u32 tempdword, slot_reg, slot_config;
@@ -1167,11 +1184,15 @@ int shpc_init(struct controller * ctrl, struct pci_dev * pdev)
1167 info("HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n", pdev->vendor, pdev->device, pdev->subsystem_vendor, 1184 info("HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n", pdev->vendor, pdev->device, pdev->subsystem_vendor,
1168 pdev->subsystem_device); 1185 pdev->subsystem_device);
1169 1186
1170 if (pci_enable_device(pdev)) 1187 rc = pci_enable_device(pdev);
1188 if (rc) {
1189 err("%s: pci_enable_device failed\n", __FUNCTION__);
1171 goto abort_free_ctlr; 1190 goto abort_free_ctlr;
1191 }
1172 1192
1173 if (!request_mem_region(ctrl->mmio_base, ctrl->mmio_size, MY_NAME)) { 1193 if (!request_mem_region(ctrl->mmio_base, ctrl->mmio_size, MY_NAME)) {
1174 err("%s: cannot reserve MMIO region\n", __FUNCTION__); 1194 err("%s: cannot reserve MMIO region\n", __FUNCTION__);
1195 rc = -1;
1175 goto abort_free_ctlr; 1196 goto abort_free_ctlr;
1176 } 1197 }
1177 1198
@@ -1180,6 +1201,7 @@ int shpc_init(struct controller * ctrl, struct pci_dev * pdev)
1180 err("%s: cannot remap MMIO region %lx @ %lx\n", __FUNCTION__, 1201 err("%s: cannot remap MMIO region %lx @ %lx\n", __FUNCTION__,
1181 ctrl->mmio_size, ctrl->mmio_base); 1202 ctrl->mmio_size, ctrl->mmio_base);
1182 release_mem_region(ctrl->mmio_base, ctrl->mmio_size); 1203 release_mem_region(ctrl->mmio_base, ctrl->mmio_size);
1204 rc = -1;
1183 goto abort_free_ctlr; 1205 goto abort_free_ctlr;
1184 } 1206 }
1185 dbg("%s: php_ctlr->creg %p\n", __FUNCTION__, php_ctlr->creg); 1207 dbg("%s: php_ctlr->creg %p\n", __FUNCTION__, php_ctlr->creg);
@@ -1282,8 +1304,10 @@ int shpc_init(struct controller * ctrl, struct pci_dev * pdev)
1282 */ 1304 */
1283 if (atomic_add_return(1, &shpchp_num_controllers) == 1) { 1305 if (atomic_add_return(1, &shpchp_num_controllers) == 1) {
1284 shpchp_wq = create_singlethread_workqueue("shpchpd"); 1306 shpchp_wq = create_singlethread_workqueue("shpchpd");
1285 if (!shpchp_wq) 1307 if (!shpchp_wq) {
1286 return -ENOMEM; 1308 rc = -ENOMEM;
1309 goto abort_free_ctlr;
1310 }
1287 } 1311 }
1288 1312
1289 /* 1313 /*
@@ -1313,8 +1337,10 @@ int shpc_init(struct controller * ctrl, struct pci_dev * pdev)
1313 1337
1314 /* We end up here for the many possible ways to fail this API. */ 1338 /* We end up here for the many possible ways to fail this API. */
1315abort_free_ctlr: 1339abort_free_ctlr:
1340 if (php_ctlr->creg)
1341 iounmap(php_ctlr->creg);
1316 kfree(php_ctlr); 1342 kfree(php_ctlr);
1317abort: 1343abort:
1318 DBG_LEAVE_ROUTINE 1344 DBG_LEAVE_ROUTINE
1319 return -1; 1345 return rc;
1320} 1346}
diff --git a/drivers/pci/htirq.c b/drivers/pci/htirq.c
index 0e27f2404a83..0a8d1cce9fa0 100644
--- a/drivers/pci/htirq.c
+++ b/drivers/pci/htirq.c
@@ -25,97 +25,72 @@ static DEFINE_SPINLOCK(ht_irq_lock);
25 25
26struct ht_irq_cfg { 26struct ht_irq_cfg {
27 struct pci_dev *dev; 27 struct pci_dev *dev;
28 /* Update callback used to cope with buggy hardware */
29 ht_irq_update_t *update;
28 unsigned pos; 30 unsigned pos;
29 unsigned idx; 31 unsigned idx;
32 struct ht_irq_msg msg;
30}; 33};
31 34
32void write_ht_irq_low(unsigned int irq, u32 data)
33{
34 struct ht_irq_cfg *cfg = get_irq_data(irq);
35 unsigned long flags;
36 spin_lock_irqsave(&ht_irq_lock, flags);
37 pci_write_config_byte(cfg->dev, cfg->pos + 2, cfg->idx);
38 pci_write_config_dword(cfg->dev, cfg->pos + 4, data);
39 spin_unlock_irqrestore(&ht_irq_lock, flags);
40}
41 35
42void write_ht_irq_high(unsigned int irq, u32 data) 36void write_ht_irq_msg(unsigned int irq, struct ht_irq_msg *msg)
43{ 37{
44 struct ht_irq_cfg *cfg = get_irq_data(irq); 38 struct ht_irq_cfg *cfg = get_irq_data(irq);
45 unsigned long flags; 39 unsigned long flags;
46 spin_lock_irqsave(&ht_irq_lock, flags); 40 spin_lock_irqsave(&ht_irq_lock, flags);
47 pci_write_config_byte(cfg->dev, cfg->pos + 2, cfg->idx + 1); 41 if (cfg->msg.address_lo != msg->address_lo) {
48 pci_write_config_dword(cfg->dev, cfg->pos + 4, data); 42 pci_write_config_byte(cfg->dev, cfg->pos + 2, cfg->idx);
49 spin_unlock_irqrestore(&ht_irq_lock, flags); 43 pci_write_config_dword(cfg->dev, cfg->pos + 4, msg->address_lo);
50} 44 }
51 45 if (cfg->msg.address_hi != msg->address_hi) {
52u32 read_ht_irq_low(unsigned int irq) 46 pci_write_config_byte(cfg->dev, cfg->pos + 2, cfg->idx + 1);
53{ 47 pci_write_config_dword(cfg->dev, cfg->pos + 4, msg->address_hi);
54 struct ht_irq_cfg *cfg = get_irq_data(irq); 48 }
55 unsigned long flags; 49 if (cfg->update)
56 u32 data; 50 cfg->update(cfg->dev, irq, msg);
57 spin_lock_irqsave(&ht_irq_lock, flags);
58 pci_write_config_byte(cfg->dev, cfg->pos + 2, cfg->idx);
59 pci_read_config_dword(cfg->dev, cfg->pos + 4, &data);
60 spin_unlock_irqrestore(&ht_irq_lock, flags); 51 spin_unlock_irqrestore(&ht_irq_lock, flags);
61 return data; 52 cfg->msg = *msg;
62} 53}
63 54
64u32 read_ht_irq_high(unsigned int irq) 55void fetch_ht_irq_msg(unsigned int irq, struct ht_irq_msg *msg)
65{ 56{
66 struct ht_irq_cfg *cfg = get_irq_data(irq); 57 struct ht_irq_cfg *cfg = get_irq_data(irq);
67 unsigned long flags; 58 *msg = cfg->msg;
68 u32 data;
69 spin_lock_irqsave(&ht_irq_lock, flags);
70 pci_write_config_byte(cfg->dev, cfg->pos + 2, cfg->idx + 1);
71 pci_read_config_dword(cfg->dev, cfg->pos + 4, &data);
72 spin_unlock_irqrestore(&ht_irq_lock, flags);
73 return data;
74} 59}
75 60
76void mask_ht_irq(unsigned int irq) 61void mask_ht_irq(unsigned int irq)
77{ 62{
78 struct ht_irq_cfg *cfg; 63 struct ht_irq_cfg *cfg;
79 unsigned long flags; 64 struct ht_irq_msg msg;
80 u32 data;
81 65
82 cfg = get_irq_data(irq); 66 cfg = get_irq_data(irq);
83 67
84 spin_lock_irqsave(&ht_irq_lock, flags); 68 msg = cfg->msg;
85 pci_write_config_byte(cfg->dev, cfg->pos + 2, cfg->idx); 69 msg.address_lo |= 1;
86 pci_read_config_dword(cfg->dev, cfg->pos + 4, &data); 70 write_ht_irq_msg(irq, &msg);
87 data |= 1;
88 pci_write_config_dword(cfg->dev, cfg->pos + 4, data);
89 spin_unlock_irqrestore(&ht_irq_lock, flags);
90} 71}
91 72
92void unmask_ht_irq(unsigned int irq) 73void unmask_ht_irq(unsigned int irq)
93{ 74{
94 struct ht_irq_cfg *cfg; 75 struct ht_irq_cfg *cfg;
95 unsigned long flags; 76 struct ht_irq_msg msg;
96 u32 data;
97 77
98 cfg = get_irq_data(irq); 78 cfg = get_irq_data(irq);
99 79
100 spin_lock_irqsave(&ht_irq_lock, flags); 80 msg = cfg->msg;
101 pci_write_config_byte(cfg->dev, cfg->pos + 2, cfg->idx); 81 msg.address_lo &= ~1;
102 pci_read_config_dword(cfg->dev, cfg->pos + 4, &data); 82 write_ht_irq_msg(irq, &msg);
103 data &= ~1;
104 pci_write_config_dword(cfg->dev, cfg->pos + 4, data);
105 spin_unlock_irqrestore(&ht_irq_lock, flags);
106} 83}
107 84
108/** 85/**
109 * ht_create_irq - create an irq and attach it to a device. 86 * __ht_create_irq - create an irq and attach it to a device.
110 * @dev: The hypertransport device to find the irq capability on. 87 * @dev: The hypertransport device to find the irq capability on.
111 * @idx: Which of the possible irqs to attach to. 88 * @idx: Which of the possible irqs to attach to.
112 * 89 * @update: Function to be called when changing the htirq message
113 * ht_create_irq is needs to be called for all hypertransport devices
114 * that generate irqs.
115 * 90 *
116 * The irq number of the new irq or a negative error value is returned. 91 * The irq number of the new irq or a negative error value is returned.
117 */ 92 */
118int ht_create_irq(struct pci_dev *dev, int idx) 93int __ht_create_irq(struct pci_dev *dev, int idx, ht_irq_update_t *update)
119{ 94{
120 struct ht_irq_cfg *cfg; 95 struct ht_irq_cfg *cfg;
121 unsigned long flags; 96 unsigned long flags;
@@ -150,8 +125,12 @@ int ht_create_irq(struct pci_dev *dev, int idx)
150 return -ENOMEM; 125 return -ENOMEM;
151 126
152 cfg->dev = dev; 127 cfg->dev = dev;
128 cfg->update = update;
153 cfg->pos = pos; 129 cfg->pos = pos;
154 cfg->idx = 0x10 + (idx * 2); 130 cfg->idx = 0x10 + (idx * 2);
131 /* Initialize msg to a value that will never match the first write. */
132 cfg->msg.address_lo = 0xffffffff;
133 cfg->msg.address_hi = 0xffffffff;
155 134
156 irq = create_irq(); 135 irq = create_irq();
157 if (irq < 0) { 136 if (irq < 0) {
@@ -169,6 +148,21 @@ int ht_create_irq(struct pci_dev *dev, int idx)
169} 148}
170 149
171/** 150/**
151 * ht_create_irq - create an irq and attach it to a device.
152 * @dev: The hypertransport device to find the irq capability on.
153 * @idx: Which of the possible irqs to attach to.
154 *
155 * ht_create_irq needs to be called for all hypertransport devices
156 * that generate irqs.
157 *
158 * The irq number of the new irq or a negative error value is returned.
159 */
160int ht_create_irq(struct pci_dev *dev, int idx)
161{
162 return __ht_create_irq(dev, idx, NULL);
163}
164
165/**
172 * ht_destroy_irq - destroy an irq created with ht_create_irq 166 * ht_destroy_irq - destroy an irq created with ht_create_irq
173 * 167 *
174 * This reverses ht_create_irq removing the specified irq from 168 * This reverses ht_create_irq removing the specified irq from
@@ -186,5 +180,6 @@ void ht_destroy_irq(unsigned int irq)
186 kfree(cfg); 180 kfree(cfg);
187} 181}
188 182
183EXPORT_SYMBOL(__ht_create_irq);
189EXPORT_SYMBOL(ht_create_irq); 184EXPORT_SYMBOL(ht_create_irq);
190EXPORT_SYMBOL(ht_destroy_irq); 185EXPORT_SYMBOL(ht_destroy_irq);
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index f9fdc54473c4..9fc9a34ef24a 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -627,22 +627,24 @@ static int msix_capability_init(struct pci_dev *dev,
627 * pci_msi_supported - check whether MSI may be enabled on device 627 * pci_msi_supported - check whether MSI may be enabled on device
628 * @dev: pointer to the pci_dev data structure of MSI device function 628 * @dev: pointer to the pci_dev data structure of MSI device function
629 * 629 *
630 * MSI must be globally enabled and supported by the device and its root 630 * Look at global flags, the device itself, and its parent busses
631 * bus. But, the root bus is not easy to find since some architectures 631 * to return 0 if MSI are supported for the device.
632 * have virtual busses on top of the PCI hierarchy (for instance the
633 * hypertransport bus), while the actual bus where MSI must be supported
634 * is below. So we test the MSI flag on all parent busses and assume
635 * that no quirk will ever set the NO_MSI flag on a non-root bus.
636 **/ 632 **/
637static 633static
638int pci_msi_supported(struct pci_dev * dev) 634int pci_msi_supported(struct pci_dev * dev)
639{ 635{
640 struct pci_bus *bus; 636 struct pci_bus *bus;
641 637
638 /* MSI must be globally enabled and supported by the device */
642 if (!pci_msi_enable || !dev || dev->no_msi) 639 if (!pci_msi_enable || !dev || dev->no_msi)
643 return -EINVAL; 640 return -EINVAL;
644 641
645 /* check MSI flags of all parent busses */ 642 /* Any bridge which does NOT route MSI transactions from it's
643 * secondary bus to it's primary bus must set NO_MSI flag on
644 * the secondary pci_bus.
645 * We expect only arch-specific PCI host bus controller driver
646 * or quirks for specific PCI bridges to be setting NO_MSI.
647 */
646 for (bus = dev->bus; bus; bus = bus->parent) 648 for (bus = dev->bus; bus; bus = bus->parent)
647 if (bus->bus_flags & PCI_BUS_FLAGS_NO_MSI) 649 if (bus->bus_flags & PCI_BUS_FLAGS_NO_MSI)
648 return -EINVAL; 650 return -EINVAL;
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index b1c0c707d96c..194f1d21d3d7 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -265,6 +265,13 @@ static int pci_device_remove(struct device * dev)
265 } 265 }
266 266
267 /* 267 /*
268 * If the device is still on, set the power state as "unknown",
269 * since it might change by the next time we load the driver.
270 */
271 if (pci_dev->current_state == PCI_D0)
272 pci_dev->current_state = PCI_UNKNOWN;
273
274 /*
268 * We would love to complain here if pci_dev->is_enabled is set, that 275 * We would love to complain here if pci_dev->is_enabled is set, that
269 * the driver should have called pci_disable_device(), but the 276 * the driver should have called pci_disable_device(), but the
270 * unfortunate fact is there are too many odd BIOS and bridge setups 277 * unfortunate fact is there are too many odd BIOS and bridge setups
@@ -288,6 +295,12 @@ static int pci_device_suspend(struct device * dev, pm_message_t state)
288 suspend_report_result(drv->suspend, i); 295 suspend_report_result(drv->suspend, i);
289 } else { 296 } else {
290 pci_save_state(pci_dev); 297 pci_save_state(pci_dev);
298 /*
299 * mark its power state as "unknown", since we don't know if
300 * e.g. the BIOS will change its device state when we suspend.
301 */
302 if (pci_dev->current_state == PCI_D0)
303 pci_dev->current_state = PCI_UNKNOWN;
291 } 304 }
292 return i; 305 return i;
293} 306}
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index a1d2e979b17f..f952bfea48a6 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -642,6 +642,9 @@ err:
642 */ 642 */
643void pci_remove_sysfs_dev_files(struct pci_dev *pdev) 643void pci_remove_sysfs_dev_files(struct pci_dev *pdev)
644{ 644{
645 if (!sysfs_initialized)
646 return;
647
645 if (pdev->cfg_size < 4096) 648 if (pdev->cfg_size < 4096)
646 sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr); 649 sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr);
647 else 650 else
diff --git a/drivers/pci/pcie/portdrv.h b/drivers/pci/pcie/portdrv.h
index 67fcd176babd..3656e0349dd1 100644
--- a/drivers/pci/pcie/portdrv.h
+++ b/drivers/pci/pcie/portdrv.h
@@ -9,6 +9,8 @@
9#ifndef _PORTDRV_H_ 9#ifndef _PORTDRV_H_
10#define _PORTDRV_H_ 10#define _PORTDRV_H_
11 11
12#include <linux/compiler.h>
13
12#if !defined(PCI_CAP_ID_PME) 14#if !defined(PCI_CAP_ID_PME)
13#define PCI_CAP_ID_PME 1 15#define PCI_CAP_ID_PME 1
14#endif 16#endif
@@ -39,7 +41,7 @@ extern int pcie_port_device_suspend(struct pci_dev *dev, pm_message_t state);
39extern int pcie_port_device_resume(struct pci_dev *dev); 41extern int pcie_port_device_resume(struct pci_dev *dev);
40#endif 42#endif
41extern void pcie_port_device_remove(struct pci_dev *dev); 43extern void pcie_port_device_remove(struct pci_dev *dev);
42extern int pcie_port_bus_register(void); 44extern int __must_check pcie_port_bus_register(void);
43extern void pcie_port_bus_unregister(void); 45extern void pcie_port_bus_unregister(void);
44 46
45#endif /* _PORTDRV_H_ */ 47#endif /* _PORTDRV_H_ */
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
index bd6615b4d40e..b20a9b81dae2 100644
--- a/drivers/pci/pcie/portdrv_core.c
+++ b/drivers/pci/pcie/portdrv_core.c
@@ -6,7 +6,6 @@
6 * Copyright (C) Tom Long Nguyen (tom.l.nguyen@intel.com) 6 * Copyright (C) Tom Long Nguyen (tom.l.nguyen@intel.com)
7 */ 7 */
8 8
9#include <linux/compiler.h>
10#include <linux/module.h> 9#include <linux/module.h>
11#include <linux/pci.h> 10#include <linux/pci.h>
12#include <linux/kernel.h> 11#include <linux/kernel.h>
@@ -401,7 +400,7 @@ void pcie_port_device_remove(struct pci_dev *dev)
401 pci_disable_msi(dev); 400 pci_disable_msi(dev);
402} 401}
403 402
404int __must_check pcie_port_bus_register(void) 403int pcie_port_bus_register(void)
405{ 404{
406 return bus_register(&pcie_port_bus_type); 405 return bus_register(&pcie_port_bus_type);
407} 406}
diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c
index 037690e08f5f..b4da7954611e 100644
--- a/drivers/pci/pcie/portdrv_pci.c
+++ b/drivers/pci/pcie/portdrv_pci.c
@@ -37,7 +37,6 @@ static int pcie_portdrv_save_config(struct pci_dev *dev)
37 return pci_save_state(dev); 37 return pci_save_state(dev);
38} 38}
39 39
40#ifdef CONFIG_PM
41static int pcie_portdrv_restore_config(struct pci_dev *dev) 40static int pcie_portdrv_restore_config(struct pci_dev *dev)
42{ 41{
43 int retval; 42 int retval;
@@ -50,6 +49,7 @@ static int pcie_portdrv_restore_config(struct pci_dev *dev)
50 return 0; 49 return 0;
51} 50}
52 51
52#ifdef CONFIG_PM
53static int pcie_portdrv_suspend(struct pci_dev *dev, pm_message_t state) 53static int pcie_portdrv_suspend(struct pci_dev *dev, pm_message_t state)
54{ 54{
55 int ret = pcie_port_device_suspend(dev, state); 55 int ret = pcie_port_device_suspend(dev, state);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index a3b0a5eb5054..e159d6604494 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1067,3 +1067,95 @@ EXPORT_SYMBOL(pci_scan_bridge);
1067EXPORT_SYMBOL(pci_scan_single_device); 1067EXPORT_SYMBOL(pci_scan_single_device);
1068EXPORT_SYMBOL_GPL(pci_scan_child_bus); 1068EXPORT_SYMBOL_GPL(pci_scan_child_bus);
1069#endif 1069#endif
1070
1071static int __init pci_sort_bf_cmp(const struct pci_dev *a, const struct pci_dev *b)
1072{
1073 if (pci_domain_nr(a->bus) < pci_domain_nr(b->bus)) return -1;
1074 else if (pci_domain_nr(a->bus) > pci_domain_nr(b->bus)) return 1;
1075
1076 if (a->bus->number < b->bus->number) return -1;
1077 else if (a->bus->number > b->bus->number) return 1;
1078
1079 if (a->devfn < b->devfn) return -1;
1080 else if (a->devfn > b->devfn) return 1;
1081
1082 return 0;
1083}
1084
1085/*
1086 * Yes, this forcably breaks the klist abstraction temporarily. It
1087 * just wants to sort the klist, not change reference counts and
1088 * take/drop locks rapidly in the process. It does all this while
1089 * holding the lock for the list, so objects can't otherwise be
1090 * added/removed while we're swizzling.
1091 */
1092static void __init pci_insertion_sort_klist(struct pci_dev *a, struct list_head *list)
1093{
1094 struct list_head *pos;
1095 struct klist_node *n;
1096 struct device *dev;
1097 struct pci_dev *b;
1098
1099 list_for_each(pos, list) {
1100 n = container_of(pos, struct klist_node, n_node);
1101 dev = container_of(n, struct device, knode_bus);
1102 b = to_pci_dev(dev);
1103 if (pci_sort_bf_cmp(a, b) <= 0) {
1104 list_move_tail(&a->dev.knode_bus.n_node, &b->dev.knode_bus.n_node);
1105 return;
1106 }
1107 }
1108 list_move_tail(&a->dev.knode_bus.n_node, list);
1109}
1110
1111static void __init pci_sort_breadthfirst_klist(void)
1112{
1113 LIST_HEAD(sorted_devices);
1114 struct list_head *pos, *tmp;
1115 struct klist_node *n;
1116 struct device *dev;
1117 struct pci_dev *pdev;
1118
1119 spin_lock(&pci_bus_type.klist_devices.k_lock);
1120 list_for_each_safe(pos, tmp, &pci_bus_type.klist_devices.k_list) {
1121 n = container_of(pos, struct klist_node, n_node);
1122 dev = container_of(n, struct device, knode_bus);
1123 pdev = to_pci_dev(dev);
1124 pci_insertion_sort_klist(pdev, &sorted_devices);
1125 }
1126 list_splice(&sorted_devices, &pci_bus_type.klist_devices.k_list);
1127 spin_unlock(&pci_bus_type.klist_devices.k_lock);
1128}
1129
1130static void __init pci_insertion_sort_devices(struct pci_dev *a, struct list_head *list)
1131{
1132 struct pci_dev *b;
1133
1134 list_for_each_entry(b, list, global_list) {
1135 if (pci_sort_bf_cmp(a, b) <= 0) {
1136 list_move_tail(&a->global_list, &b->global_list);
1137 return;
1138 }
1139 }
1140 list_move_tail(&a->global_list, list);
1141}
1142
1143static void __init pci_sort_breadthfirst_devices(void)
1144{
1145 LIST_HEAD(sorted_devices);
1146 struct pci_dev *dev, *tmp;
1147
1148 down_write(&pci_bus_sem);
1149 list_for_each_entry_safe(dev, tmp, &pci_devices, global_list) {
1150 pci_insertion_sort_devices(dev, &sorted_devices);
1151 }
1152 list_splice(&sorted_devices, &pci_devices);
1153 up_write(&pci_bus_sem);
1154}
1155
1156void __init pci_sort_breadthfirst(void)
1157{
1158 pci_sort_breadthfirst_devices();
1159 pci_sort_breadthfirst_klist();
1160}
1161
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 23b599d6a9d5..5b4483811691 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -453,6 +453,12 @@ static void __devinit quirk_ich6_lpc_acpi(struct pci_dev *dev)
453} 453}
454DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_0, quirk_ich6_lpc_acpi ); 454DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_0, quirk_ich6_lpc_acpi );
455DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1, quirk_ich6_lpc_acpi ); 455DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1, quirk_ich6_lpc_acpi );
456DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_0, quirk_ich6_lpc_acpi );
457DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_1, quirk_ich6_lpc_acpi );
458DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_31, quirk_ich6_lpc_acpi );
459DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_0, quirk_ich6_lpc_acpi );
460DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_2, quirk_ich6_lpc_acpi );
461DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_3, quirk_ich6_lpc_acpi );
456 462
457/* 463/*
458 * VIA ACPI: One IO region pointed to by longword at 464 * VIA ACPI: One IO region pointed to by longword at
@@ -648,11 +654,43 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4, quirk_vi
648 * Some of the on-chip devices are actually '586 devices' so they are 654 * Some of the on-chip devices are actually '586 devices' so they are
649 * listed here. 655 * listed here.
650 */ 656 */
657
658static int via_irq_fixup_needed = -1;
659
660/*
661 * As some VIA hardware is available in PCI-card form, we need to restrict
662 * this quirk to VIA PCI hardware built onto VIA-based motherboards only.
663 * We try to locate a VIA southbridge before deciding whether the quirk
664 * should be applied.
665 */
666static const struct pci_device_id via_irq_fixup_tbl[] = {
667 {
668 .vendor = PCI_VENDOR_ID_VIA,
669 .device = PCI_ANY_ID,
670 .subvendor = PCI_ANY_ID,
671 .subdevice = PCI_ANY_ID,
672 .class = PCI_CLASS_BRIDGE_ISA << 8,
673 .class_mask = 0xffff00,
674 },
675 { 0, },
676};
677
651static void quirk_via_irq(struct pci_dev *dev) 678static void quirk_via_irq(struct pci_dev *dev)
652{ 679{
653 u8 irq, new_irq; 680 u8 irq, new_irq;
654 681
655 new_irq = dev->irq & 0xf; 682 if (via_irq_fixup_needed == -1)
683 via_irq_fixup_needed = pci_dev_present(via_irq_fixup_tbl);
684
685 if (!via_irq_fixup_needed)
686 return;
687
688 new_irq = dev->irq;
689
690 /* Don't quirk interrupts outside the legacy IRQ range */
691 if (!new_irq || new_irq > 15)
692 return;
693
656 pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq); 694 pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq);
657 if (new_irq != irq) { 695 if (new_irq != irq) {
658 printk(KERN_INFO "PCI: VIA IRQ fixup for %s, from %d to %d\n", 696 printk(KERN_INFO "PCI: VIA IRQ fixup for %s, from %d to %d\n",
@@ -661,14 +699,7 @@ static void quirk_via_irq(struct pci_dev *dev)
661 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, new_irq); 699 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, new_irq);
662 } 700 }
663} 701}
664DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_0, quirk_via_irq); 702DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_ANY_ID, quirk_via_irq);
665DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_1, quirk_via_irq);
666DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_2, quirk_via_irq);
667DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_3, quirk_via_irq);
668DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235_USB_2, quirk_via_irq);
669DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686, quirk_via_irq);
670DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4, quirk_via_irq);
671DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_5, quirk_via_irq);
672 703
673/* 704/*
674 * VIA VT82C598 has its device ID settable and many BIOSes 705 * VIA VT82C598 has its device ID settable and many BIOSes
@@ -683,33 +714,6 @@ static void __devinit quirk_vt82c598_id(struct pci_dev *dev)
683} 714}
684DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C597_0, quirk_vt82c598_id ); 715DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C597_0, quirk_vt82c598_id );
685 716
686#ifdef CONFIG_ACPI_SLEEP
687
688/*
689 * Some VIA systems boot with the abnormal status flag set. This can cause
690 * the BIOS to re-POST the system on resume rather than passing control
691 * back to the OS. Clear the flag on boot
692 */
693static void __devinit quirk_via_abnormal_poweroff(struct pci_dev *dev)
694{
695 u32 reg;
696
697 acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_STATUS,
698 &reg);
699
700 if (reg & 0x800) {
701 printk("Clearing abnormal poweroff flag\n");
702 acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
703 ACPI_REGISTER_PM1_STATUS,
704 (u16)0x800);
705 }
706}
707
708DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235, quirk_via_abnormal_poweroff);
709DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, quirk_via_abnormal_poweroff);
710
711#endif
712
713/* 717/*
714 * CardBus controllers have a legacy base address that enables them 718 * CardBus controllers have a legacy base address that enables them
715 * to respond as i82365 pcmcia controllers. We don't want them to 719 * to respond as i82365 pcmcia controllers. We don't want them to
@@ -1456,33 +1460,6 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x2609, quirk_intel_pcie_pm);
1456DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x260a, quirk_intel_pcie_pm); 1460DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x260a, quirk_intel_pcie_pm);
1457DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x260b, quirk_intel_pcie_pm); 1461DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x260b, quirk_intel_pcie_pm);
1458 1462
1459/*
1460 * Fixup the cardbus bridges on the IBM Dock II docking station
1461 */
1462static void __devinit quirk_ibm_dock2_cardbus(struct pci_dev *dev)
1463{
1464 u32 val;
1465
1466 /*
1467 * tie the 2 interrupt pins to INTA, and configure the
1468 * multifunction routing register to handle this.
1469 */
1470 if ((dev->subsystem_vendor == PCI_VENDOR_ID_IBM) &&
1471 (dev->subsystem_device == 0x0148)) {
1472 printk(KERN_INFO "PCI: Found IBM Dock II Cardbus Bridge "
1473 "applying quirk\n");
1474 pci_read_config_dword(dev, 0x8c, &val);
1475 val = ((val & 0xffffff00) | 0x1002);
1476 pci_write_config_dword(dev, 0x8c, val);
1477 pci_read_config_dword(dev, 0x80, &val);
1478 val = ((val & 0x00ffff00) | 0x2864c077);
1479 pci_write_config_dword(dev, 0x80, val);
1480 }
1481}
1482
1483DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1420,
1484 quirk_ibm_dock2_cardbus);
1485
1486static void __devinit quirk_netmos(struct pci_dev *dev) 1463static void __devinit quirk_netmos(struct pci_dev *dev)
1487{ 1464{
1488 unsigned int num_parallel = (dev->subsystem_device & 0xf0) >> 4; 1465 unsigned int num_parallel = (dev->subsystem_device & 0xf0) >> 4;
@@ -1588,7 +1565,6 @@ static void __devinit fixup_rev1_53c810(struct pci_dev* dev)
1588} 1565}
1589DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NCR, PCI_DEVICE_ID_NCR_53C810, fixup_rev1_53c810); 1566DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NCR, PCI_DEVICE_ID_NCR_53C810, fixup_rev1_53c810);
1590 1567
1591
1592static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f, struct pci_fixup *end) 1568static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f, struct pci_fixup *end)
1593{ 1569{
1594 while (f < end) { 1570 while (f < end) {
@@ -1764,7 +1740,7 @@ static void __devinit quirk_nvidia_ck804_msi_ht_cap(struct pci_dev *dev)
1764 /* check HT MSI cap on this chipset and the root one. 1740 /* check HT MSI cap on this chipset and the root one.
1765 * a single one having MSI is enough to be sure that MSI are supported. 1741 * a single one having MSI is enough to be sure that MSI are supported.
1766 */ 1742 */
1767 pdev = pci_find_slot(dev->bus->number, 0); 1743 pdev = pci_get_slot(dev->bus, 0);
1768 if (dev->subordinate && !msi_ht_cap_enabled(dev) 1744 if (dev->subordinate && !msi_ht_cap_enabled(dev)
1769 && !msi_ht_cap_enabled(pdev)) { 1745 && !msi_ht_cap_enabled(pdev)) {
1770 printk(KERN_WARNING "PCI: MSI quirk detected. " 1746 printk(KERN_WARNING "PCI: MSI quirk detected. "
@@ -1772,6 +1748,7 @@ static void __devinit quirk_nvidia_ck804_msi_ht_cap(struct pci_dev *dev)
1772 pci_name(dev)); 1748 pci_name(dev));
1773 dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI; 1749 dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI;
1774 } 1750 }
1751 pci_dev_put(pdev);
1775} 1752}
1776DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_CK804_PCIE, 1753DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_CK804_PCIE,
1777 quirk_nvidia_ck804_msi_ht_cap); 1754 quirk_nvidia_ck804_msi_ht_cap);
diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c
index f5ee7ce16fa6..e1dcefc69bb4 100644
--- a/drivers/pci/rom.c
+++ b/drivers/pci/rom.c
@@ -71,7 +71,11 @@ void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size)
71 void __iomem *image; 71 void __iomem *image;
72 int last_image; 72 int last_image;
73 73
74 /* IORESOURCE_ROM_SHADOW only set on x86 */ 74 /*
75 * IORESOURCE_ROM_SHADOW set on x86, x86_64 and IA64 supports legacy
76 * memory map if the VGA enable bit of the Bridge Control register is
77 * set for embedded VGA.
78 */
75 if (res->flags & IORESOURCE_ROM_SHADOW) { 79 if (res->flags & IORESOURCE_ROM_SHADOW) {
76 /* primary video rom always starts here */ 80 /* primary video rom always starts here */
77 start = (loff_t)0xC0000; 81 start = (loff_t)0xC0000;
diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index d529462d1b53..2f13eba5d5ae 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -140,6 +140,31 @@ struct pci_dev * pci_get_slot(struct pci_bus *bus, unsigned int devfn)
140} 140}
141 141
142/** 142/**
143 * pci_get_bus_and_slot - locate PCI device from a given PCI slot
144 * @bus: number of PCI bus on which desired PCI device resides
145 * @devfn: encodes number of PCI slot in which the desired PCI
146 * device resides and the logical device number within that slot
147 * in case of multi-function devices.
148 *
149 * Given a PCI bus and slot/function number, the desired PCI device
150 * is located in system global list of PCI devices. If the device
151 * is found, a pointer to its data structure is returned. If no
152 * device is found, %NULL is returned. The returned device has its
153 * reference count bumped by one.
154 */
155
156struct pci_dev * pci_get_bus_and_slot(unsigned int bus, unsigned int devfn)
157{
158 struct pci_dev *dev = NULL;
159
160 while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
161 if (dev->bus->number == bus && dev->devfn == devfn)
162 return dev;
163 }
164 return NULL;
165}
166
167/**
143 * pci_find_subsys - begin or continue searching for a PCI device by vendor/subvendor/device/subdevice id 168 * pci_find_subsys - begin or continue searching for a PCI device by vendor/subvendor/device/subdevice id
144 * @vendor: PCI vendor id to match, or %PCI_ANY_ID to match all vendor ids 169 * @vendor: PCI vendor id to match, or %PCI_ANY_ID to match all vendor ids
145 * @device: PCI device id to match, or %PCI_ANY_ID to match all device ids 170 * @device: PCI device id to match, or %PCI_ANY_ID to match all device ids
@@ -274,6 +299,45 @@ pci_get_device(unsigned int vendor, unsigned int device, struct pci_dev *from)
274 return pci_get_subsys(vendor, device, PCI_ANY_ID, PCI_ANY_ID, from); 299 return pci_get_subsys(vendor, device, PCI_ANY_ID, PCI_ANY_ID, from);
275} 300}
276 301
302/**
303 * pci_get_device_reverse - begin or continue searching for a PCI device by vendor/device id
304 * @vendor: PCI vendor id to match, or %PCI_ANY_ID to match all vendor ids
305 * @device: PCI device id to match, or %PCI_ANY_ID to match all device ids
306 * @from: Previous PCI device found in search, or %NULL for new search.
307 *
308 * Iterates through the list of known PCI devices in the reverse order of
309 * pci_get_device.
310 * If a PCI device is found with a matching @vendor and @device, the reference
311 * count to the device is incremented and a pointer to its device structure
312 * is returned Otherwise, %NULL is returned. A new search is initiated by
313 * passing %NULL as the @from argument. Otherwise if @from is not %NULL,
314 * searches continue from next device on the global list. The reference
315 * count for @from is always decremented if it is not %NULL.
316 */
317struct pci_dev *
318pci_get_device_reverse(unsigned int vendor, unsigned int device, struct pci_dev *from)
319{
320 struct list_head *n;
321 struct pci_dev *dev;
322
323 WARN_ON(in_interrupt());
324 down_read(&pci_bus_sem);
325 n = from ? from->global_list.prev : pci_devices.prev;
326
327 while (n && (n != &pci_devices)) {
328 dev = pci_dev_g(n);
329 if ((vendor == PCI_ANY_ID || dev->vendor == vendor) &&
330 (device == PCI_ANY_ID || dev->device == device))
331 goto exit;
332 n = n->prev;
333 }
334 dev = NULL;
335exit:
336 dev = pci_dev_get(dev);
337 up_read(&pci_bus_sem);
338 pci_dev_put(from);
339 return dev;
340}
277 341
278/** 342/**
279 * pci_find_device_reverse - begin or continue searching for a PCI device by vendor/device id 343 * pci_find_device_reverse - begin or continue searching for a PCI device by vendor/device id
@@ -382,12 +446,16 @@ exit:
382} 446}
383EXPORT_SYMBOL(pci_dev_present); 447EXPORT_SYMBOL(pci_dev_present);
384 448
385EXPORT_SYMBOL(pci_find_bus);
386EXPORT_SYMBOL(pci_find_next_bus);
387EXPORT_SYMBOL(pci_find_device); 449EXPORT_SYMBOL(pci_find_device);
388EXPORT_SYMBOL(pci_find_device_reverse); 450EXPORT_SYMBOL(pci_find_device_reverse);
389EXPORT_SYMBOL(pci_find_slot); 451EXPORT_SYMBOL(pci_find_slot);
452/* For boot time work */
453EXPORT_SYMBOL(pci_find_bus);
454EXPORT_SYMBOL(pci_find_next_bus);
455/* For everyone */
390EXPORT_SYMBOL(pci_get_device); 456EXPORT_SYMBOL(pci_get_device);
457EXPORT_SYMBOL(pci_get_device_reverse);
391EXPORT_SYMBOL(pci_get_subsys); 458EXPORT_SYMBOL(pci_get_subsys);
392EXPORT_SYMBOL(pci_get_slot); 459EXPORT_SYMBOL(pci_get_slot);
460EXPORT_SYMBOL(pci_get_bus_and_slot);
393EXPORT_SYMBOL(pci_get_class); 461EXPORT_SYMBOL(pci_get_class);
diff --git a/drivers/pcmcia/at91_cf.c b/drivers/pcmcia/at91_cf.c
index 7f5df9a9f393..3bcb7dc32995 100644
--- a/drivers/pcmcia/at91_cf.c
+++ b/drivers/pcmcia/at91_cf.c
@@ -241,12 +241,6 @@ static int __init at91_cf_probe(struct platform_device *pdev)
241 csa = at91_sys_read(AT91_EBI_CSA); 241 csa = at91_sys_read(AT91_EBI_CSA);
242 at91_sys_write(AT91_EBI_CSA, csa | AT91_EBI_CS4A_SMC_COMPACTFLASH); 242 at91_sys_write(AT91_EBI_CSA, csa | AT91_EBI_CS4A_SMC_COMPACTFLASH);
243 243
244 /* force poweron defaults for these pins ... */
245 (void) at91_set_A_periph(AT91_PIN_PC9, 0); /* A25/CFRNW */
246 (void) at91_set_A_periph(AT91_PIN_PC10, 0); /* NCS4/CFCS */
247 (void) at91_set_A_periph(AT91_PIN_PC11, 0); /* NCS5/CFCE1 */
248 (void) at91_set_A_periph(AT91_PIN_PC12, 0); /* NCS6/CFCE2 */
249
250 /* nWAIT is _not_ a default setting */ 244 /* nWAIT is _not_ a default setting */
251 (void) at91_set_A_periph(AT91_PIN_PC6, 1); /* nWAIT */ 245 (void) at91_set_A_periph(AT91_PIN_PC6, 1); /* nWAIT */
252 246
@@ -316,12 +310,14 @@ static int __init at91_cf_probe(struct platform_device *pdev)
316 return 0; 310 return 0;
317 311
318fail2: 312fail2:
319 iounmap((void __iomem *) cf->socket.io_offset);
320 release_mem_region(io->start, io->end + 1 - io->start); 313 release_mem_region(io->start, io->end + 1 - io->start);
321fail1: 314fail1:
315 if (cf->socket.io_offset)
316 iounmap((void __iomem *) cf->socket.io_offset);
322 if (board->irq_pin) 317 if (board->irq_pin)
323 free_irq(board->irq_pin, cf); 318 free_irq(board->irq_pin, cf);
324fail0a: 319fail0a:
320 device_init_wakeup(&pdev->dev, 0);
325 free_irq(board->det_pin, cf); 321 free_irq(board->det_pin, cf);
326 device_init_wakeup(&pdev->dev, 0); 322 device_init_wakeup(&pdev->dev, 0);
327fail0: 323fail0:
@@ -360,26 +356,20 @@ static int at91_cf_suspend(struct platform_device *pdev, pm_message_t mesg)
360 struct at91_cf_data *board = cf->board; 356 struct at91_cf_data *board = cf->board;
361 357
362 pcmcia_socket_dev_suspend(&pdev->dev, mesg); 358 pcmcia_socket_dev_suspend(&pdev->dev, mesg);
363 if (device_may_wakeup(&pdev->dev)) 359 if (device_may_wakeup(&pdev->dev)) {
364 enable_irq_wake(board->det_pin); 360 enable_irq_wake(board->det_pin);
365 else { 361 if (board->irq_pin)
362 enable_irq_wake(board->irq_pin);
363 } else {
366 disable_irq_wake(board->det_pin); 364 disable_irq_wake(board->det_pin);
367 disable_irq(board->det_pin); 365 if (board->irq_pin)
366 disable_irq_wake(board->irq_pin);
368 } 367 }
369 if (board->irq_pin)
370 disable_irq(board->irq_pin);
371 return 0; 368 return 0;
372} 369}
373 370
374static int at91_cf_resume(struct platform_device *pdev) 371static int at91_cf_resume(struct platform_device *pdev)
375{ 372{
376 struct at91_cf_socket *cf = platform_get_drvdata(pdev);
377 struct at91_cf_data *board = cf->board;
378
379 if (board->irq_pin)
380 enable_irq(board->irq_pin);
381 if (!device_may_wakeup(&pdev->dev))
382 enable_irq(board->det_pin);
383 pcmcia_socket_dev_resume(&pdev->dev); 373 pcmcia_socket_dev_resume(&pdev->dev);
384 return 0; 374 return 0;
385} 375}
diff --git a/drivers/pcmcia/au1000_generic.c b/drivers/pcmcia/au1000_generic.c
index d5dd0ce65536..551bde5d9430 100644
--- a/drivers/pcmcia/au1000_generic.c
+++ b/drivers/pcmcia/au1000_generic.c
@@ -351,6 +351,7 @@ struct skt_dev_info {
351int au1x00_pcmcia_socket_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr) 351int au1x00_pcmcia_socket_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr)
352{ 352{
353 struct skt_dev_info *sinfo; 353 struct skt_dev_info *sinfo;
354 struct au1000_pcmcia_socket *skt;
354 int ret, i; 355 int ret, i;
355 356
356 sinfo = kzalloc(sizeof(struct skt_dev_info), GFP_KERNEL); 357 sinfo = kzalloc(sizeof(struct skt_dev_info), GFP_KERNEL);
@@ -365,7 +366,7 @@ int au1x00_pcmcia_socket_probe(struct device *dev, struct pcmcia_low_level *ops,
365 * Initialise the per-socket structure. 366 * Initialise the per-socket structure.
366 */ 367 */
367 for (i = 0; i < nr; i++) { 368 for (i = 0; i < nr; i++) {
368 struct au1000_pcmcia_socket *skt = PCMCIA_SOCKET(i); 369 skt = PCMCIA_SOCKET(i);
369 memset(skt, 0, sizeof(*skt)); 370 memset(skt, 0, sizeof(*skt));
370 371
371 skt->socket.resource_ops = &pccard_static_ops; 372 skt->socket.resource_ops = &pccard_static_ops;
@@ -438,17 +439,29 @@ int au1x00_pcmcia_socket_probe(struct device *dev, struct pcmcia_low_level *ops,
438 dev_set_drvdata(dev, sinfo); 439 dev_set_drvdata(dev, sinfo);
439 return 0; 440 return 0;
440 441
441 do { 442
442 struct au1000_pcmcia_socket *skt = PCMCIA_SOCKET(i); 443out_err:
444 flush_scheduled_work();
445 ops->hw_shutdown(skt);
446 while (i-- > 0) {
447 skt = PCMCIA_SOCKET(i);
443 448
444 del_timer_sync(&skt->poll_timer); 449 del_timer_sync(&skt->poll_timer);
445 pcmcia_unregister_socket(&skt->socket); 450 pcmcia_unregister_socket(&skt->socket);
446out_err:
447 flush_scheduled_work(); 451 flush_scheduled_work();
452 if (i == 0) {
453 iounmap(skt->virt_io + (u32)mips_io_port_base);
454 skt->virt_io = NULL;
455 }
456#ifndef CONFIG_MIPS_XXS1500
457 else {
458 iounmap(skt->virt_io + (u32)mips_io_port_base);
459 skt->virt_io = NULL;
460 }
461#endif
448 ops->hw_shutdown(skt); 462 ops->hw_shutdown(skt);
449 463
450 i--; 464 }
451 } while (i > 0);
452 kfree(sinfo); 465 kfree(sinfo);
453out: 466out:
454 return ret; 467 return ret;
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 74b3124e8247..a20d84d707d9 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -717,6 +717,7 @@ static int pcmcia_requery(struct device *dev, void * _data)
717static void pcmcia_bus_rescan(struct pcmcia_socket *skt) 717static void pcmcia_bus_rescan(struct pcmcia_socket *skt)
718{ 718{
719 int no_devices=0; 719 int no_devices=0;
720 int ret = 0;
720 unsigned long flags; 721 unsigned long flags;
721 722
722 /* must be called with skt_mutex held */ 723 /* must be called with skt_mutex held */
@@ -729,7 +730,7 @@ static void pcmcia_bus_rescan(struct pcmcia_socket *skt)
729 * missing resource information or other trouble, we need to 730 * missing resource information or other trouble, we need to
730 * do this now. */ 731 * do this now. */
731 if (no_devices) { 732 if (no_devices) {
732 int ret = pcmcia_card_add(skt); 733 ret = pcmcia_card_add(skt);
733 if (ret) 734 if (ret)
734 return; 735 return;
735 } 736 }
@@ -741,7 +742,9 @@ static void pcmcia_bus_rescan(struct pcmcia_socket *skt)
741 742
742 /* we re-scan all devices, not just the ones connected to this 743 /* we re-scan all devices, not just the ones connected to this
743 * socket. This does not matter, though. */ 744 * socket. This does not matter, though. */
744 bus_rescan_devices(&pcmcia_bus_type); 745 ret = bus_rescan_devices(&pcmcia_bus_type);
746 if (ret)
747 printk(KERN_INFO "pcmcia: bus_rescan_devices failed\n");
745} 748}
746 749
747static inline int pcmcia_devmatch(struct pcmcia_device *dev, 750static inline int pcmcia_devmatch(struct pcmcia_device *dev,
@@ -1001,6 +1004,7 @@ static ssize_t pcmcia_store_allow_func_id_match(struct device *dev,
1001 struct device_attribute *attr, const char *buf, size_t count) 1004 struct device_attribute *attr, const char *buf, size_t count)
1002{ 1005{
1003 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); 1006 struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
1007 int ret;
1004 1008
1005 if (!count) 1009 if (!count)
1006 return -EINVAL; 1010 return -EINVAL;
@@ -1009,7 +1013,10 @@ static ssize_t pcmcia_store_allow_func_id_match(struct device *dev,
1009 p_dev->allow_func_id_match = 1; 1013 p_dev->allow_func_id_match = 1;
1010 mutex_unlock(&p_dev->socket->skt_mutex); 1014 mutex_unlock(&p_dev->socket->skt_mutex);
1011 1015
1012 bus_rescan_devices(&pcmcia_bus_type); 1016 ret = bus_rescan_devices(&pcmcia_bus_type);
1017 if (ret)
1018 printk(KERN_INFO "pcmcia: bus_rescan_devices failed after "
1019 "allowing func_id matches\n");
1013 1020
1014 return count; 1021 return count;
1015} 1022}
@@ -1264,6 +1271,9 @@ static void pcmcia_bus_remove_socket(struct class_device *class_dev,
1264 socket->pcmcia_state.dead = 1; 1271 socket->pcmcia_state.dead = 1;
1265 pccard_register_pcmcia(socket, NULL); 1272 pccard_register_pcmcia(socket, NULL);
1266 1273
1274 /* unregister any unbound devices */
1275 pcmcia_card_remove(socket, NULL);
1276
1267 pcmcia_put_socket(socket); 1277 pcmcia_put_socket(socket);
1268 1278
1269 return; 1279 return;
@@ -1292,10 +1302,22 @@ struct bus_type pcmcia_bus_type = {
1292 1302
1293static int __init init_pcmcia_bus(void) 1303static int __init init_pcmcia_bus(void)
1294{ 1304{
1305 int ret;
1306
1295 spin_lock_init(&pcmcia_dev_list_lock); 1307 spin_lock_init(&pcmcia_dev_list_lock);
1296 1308
1297 bus_register(&pcmcia_bus_type); 1309 ret = bus_register(&pcmcia_bus_type);
1298 class_interface_register(&pcmcia_bus_interface); 1310 if (ret < 0) {
1311 printk(KERN_WARNING "pcmcia: bus_register error: %d\n", ret);
1312 return ret;
1313 }
1314 ret = class_interface_register(&pcmcia_bus_interface);
1315 if (ret < 0) {
1316 printk(KERN_WARNING
1317 "pcmcia: class_interface_register error: %d\n", ret);
1318 bus_unregister(&pcmcia_bus_type);
1319 return ret;
1320 }
1299 1321
1300 pcmcia_setup_ioctl(); 1322 pcmcia_setup_ioctl();
1301 1323
diff --git a/drivers/pcmcia/i82092.c b/drivers/pcmcia/i82092.c
index 82715f448957..c2ea07aa7a12 100644
--- a/drivers/pcmcia/i82092.c
+++ b/drivers/pcmcia/i82092.c
@@ -41,6 +41,7 @@ static struct pci_device_id i82092aa_pci_ids[] = {
41}; 41};
42MODULE_DEVICE_TABLE(pci, i82092aa_pci_ids); 42MODULE_DEVICE_TABLE(pci, i82092aa_pci_ids);
43 43
44#ifdef CONFIG_PM
44static int i82092aa_socket_suspend (struct pci_dev *dev, pm_message_t state) 45static int i82092aa_socket_suspend (struct pci_dev *dev, pm_message_t state)
45{ 46{
46 return pcmcia_socket_dev_suspend(&dev->dev, state); 47 return pcmcia_socket_dev_suspend(&dev->dev, state);
@@ -50,14 +51,17 @@ static int i82092aa_socket_resume (struct pci_dev *dev)
50{ 51{
51 return pcmcia_socket_dev_resume(&dev->dev); 52 return pcmcia_socket_dev_resume(&dev->dev);
52} 53}
54#endif
53 55
54static struct pci_driver i82092aa_pci_drv = { 56static struct pci_driver i82092aa_pci_drv = {
55 .name = "i82092aa", 57 .name = "i82092aa",
56 .id_table = i82092aa_pci_ids, 58 .id_table = i82092aa_pci_ids,
57 .probe = i82092aa_pci_probe, 59 .probe = i82092aa_pci_probe,
58 .remove = __devexit_p(i82092aa_pci_remove), 60 .remove = __devexit_p(i82092aa_pci_remove),
61#ifdef CONFIG_PM
59 .suspend = i82092aa_socket_suspend, 62 .suspend = i82092aa_socket_suspend,
60 .resume = i82092aa_socket_resume, 63 .resume = i82092aa_socket_resume,
64#endif
61}; 65};
62 66
63 67
@@ -705,10 +709,7 @@ static int i82092aa_set_mem_map(struct pcmcia_socket *socket, struct pccard_mem_
705 709
706static int i82092aa_module_init(void) 710static int i82092aa_module_init(void)
707{ 711{
708 enter("i82092aa_module_init"); 712 return pci_register_driver(&i82092aa_pci_drv);
709 pci_register_driver(&i82092aa_pci_drv);
710 leave("i82092aa_module_init");
711 return 0;
712} 713}
713 714
714static void i82092aa_module_exit(void) 715static void i82092aa_module_exit(void)
diff --git a/drivers/pcmcia/m8xx_pcmcia.c b/drivers/pcmcia/m8xx_pcmcia.c
index e070a2896769..3b72be880401 100644
--- a/drivers/pcmcia/m8xx_pcmcia.c
+++ b/drivers/pcmcia/m8xx_pcmcia.c
@@ -427,7 +427,7 @@ static int voltage_set(int slot, int vcc, int vpp)
427 reg |= BCSR1_PCCVCC1; 427 reg |= BCSR1_PCCVCC1;
428 break; 428 break;
429 default: 429 default:
430 return 1; 430 goto out_unmap;
431 } 431 }
432 432
433 switch(vpp) { 433 switch(vpp) {
@@ -438,15 +438,15 @@ static int voltage_set(int slot, int vcc, int vpp)
438 if(vcc == vpp) 438 if(vcc == vpp)
439 reg |= BCSR1_PCCVPP1; 439 reg |= BCSR1_PCCVPP1;
440 else 440 else
441 return 1; 441 goto out_unmap;
442 break; 442 break;
443 case 120: 443 case 120:
444 if ((vcc == 33) || (vcc == 50)) 444 if ((vcc == 33) || (vcc == 50))
445 reg |= BCSR1_PCCVPP0; 445 reg |= BCSR1_PCCVPP0;
446 else 446 else
447 return 1; 447 goto out_unmap;
448 default: 448 default:
449 return 1; 449 goto out_unmap;
450 } 450 }
451 451
452 /* first, turn off all power */ 452 /* first, turn off all power */
@@ -457,6 +457,10 @@ static int voltage_set(int slot, int vcc, int vpp)
457 457
458 iounmap(bcsr_io); 458 iounmap(bcsr_io);
459 return 0; 459 return 0;
460
461out_unmap:
462 iounmap(bcsr_io);
463 return 1;
460} 464}
461 465
462#define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V 466#define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
diff --git a/drivers/pcmcia/omap_cf.c b/drivers/pcmcia/omap_cf.c
index c8e838c69766..06bf7f48836e 100644
--- a/drivers/pcmcia/omap_cf.c
+++ b/drivers/pcmcia/omap_cf.c
@@ -309,9 +309,10 @@ static int __devinit omap_cf_probe(struct device *dev)
309 return 0; 309 return 0;
310 310
311fail2: 311fail2:
312 iounmap((void __iomem *) cf->socket.io_offset);
313 release_mem_region(cf->phys_cf, SZ_8K); 312 release_mem_region(cf->phys_cf, SZ_8K);
314fail1: 313fail1:
314 if (cf->socket.io_offset)
315 iounmap((void __iomem *) cf->socket.io_offset);
315 free_irq(irq, cf); 316 free_irq(irq, cf);
316fail0: 317fail0:
317 kfree(cf); 318 kfree(cf);
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c
index 9ad18e62658d..310ede575caa 100644
--- a/drivers/pcmcia/pcmcia_ioctl.c
+++ b/drivers/pcmcia/pcmcia_ioctl.c
@@ -128,9 +128,12 @@ static int proc_read_drivers(char *buf, char **start, off_t pos,
128 int count, int *eof, void *data) 128 int count, int *eof, void *data)
129{ 129{
130 char *p = buf; 130 char *p = buf;
131 int rc;
131 132
132 bus_for_each_drv(&pcmcia_bus_type, NULL, 133 rc = bus_for_each_drv(&pcmcia_bus_type, NULL,
133 (void *) &p, proc_read_drivers_callback); 134 (void *) &p, proc_read_drivers_callback);
135 if (rc < 0)
136 return rc;
134 137
135 return (p - buf); 138 return (p - buf);
136} 139}
@@ -269,8 +272,10 @@ rescan:
269 * Prevent this racing with a card insertion. 272 * Prevent this racing with a card insertion.
270 */ 273 */
271 mutex_lock(&s->skt_mutex); 274 mutex_lock(&s->skt_mutex);
272 bus_rescan_devices(&pcmcia_bus_type); 275 ret = bus_rescan_devices(&pcmcia_bus_type);
273 mutex_unlock(&s->skt_mutex); 276 mutex_unlock(&s->skt_mutex);
277 if (ret)
278 goto err_put_module;
274 279
275 /* check whether the driver indeed matched. I don't care if this 280 /* check whether the driver indeed matched. I don't care if this
276 * is racy or not, because it can only happen on cardmgr access 281 * is racy or not, because it can only happen on cardmgr access
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index 74cebd424032..b9201c2ec38b 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -95,7 +95,7 @@ static int alloc_io_space(struct pcmcia_socket *s, u_int attr, ioaddr_t *base,
95 * potential conflicts, just the most obvious ones. 95 * potential conflicts, just the most obvious ones.
96 */ 96 */
97 for (i = 0; i < MAX_IO_WIN; i++) 97 for (i = 0; i < MAX_IO_WIN; i++)
98 if ((s->io[i].res) && 98 if ((s->io[i].res) && *base &&
99 ((s->io[i].res->start & (align-1)) == *base)) 99 ((s->io[i].res->start & (align-1)) == *base))
100 return 1; 100 return 1;
101 for (i = 0; i < MAX_IO_WIN; i++) { 101 for (i = 0; i < MAX_IO_WIN; i++) {
diff --git a/drivers/pcmcia/pd6729.c b/drivers/pcmcia/pd6729.c
index c83a0a6b158f..a70f97fdbbdd 100644
--- a/drivers/pcmcia/pd6729.c
+++ b/drivers/pcmcia/pd6729.c
@@ -755,6 +755,7 @@ static void __devexit pd6729_pci_remove(struct pci_dev *dev)
755 kfree(socket); 755 kfree(socket);
756} 756}
757 757
758#ifdef CONFIG_PM
758static int pd6729_socket_suspend(struct pci_dev *dev, pm_message_t state) 759static int pd6729_socket_suspend(struct pci_dev *dev, pm_message_t state)
759{ 760{
760 return pcmcia_socket_dev_suspend(&dev->dev, state); 761 return pcmcia_socket_dev_suspend(&dev->dev, state);
@@ -764,6 +765,7 @@ static int pd6729_socket_resume(struct pci_dev *dev)
764{ 765{
765 return pcmcia_socket_dev_resume(&dev->dev); 766 return pcmcia_socket_dev_resume(&dev->dev);
766} 767}
768#endif
767 769
768static struct pci_device_id pd6729_pci_ids[] = { 770static struct pci_device_id pd6729_pci_ids[] = {
769 { 771 {
@@ -781,8 +783,10 @@ static struct pci_driver pd6729_pci_drv = {
781 .id_table = pd6729_pci_ids, 783 .id_table = pd6729_pci_ids,
782 .probe = pd6729_pci_probe, 784 .probe = pd6729_pci_probe,
783 .remove = __devexit_p(pd6729_pci_remove), 785 .remove = __devexit_p(pd6729_pci_remove),
786#ifdef CONFIG_PM
784 .suspend = pd6729_socket_suspend, 787 .suspend = pd6729_socket_suspend,
785 .resume = pd6729_socket_resume, 788 .resume = pd6729_socket_resume,
789#endif
786}; 790};
787 791
788static int pd6729_module_init(void) 792static int pd6729_module_init(void)
diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c
index b3518131ea0d..dca9f8549b32 100644
--- a/drivers/pcmcia/pxa2xx_base.c
+++ b/drivers/pcmcia/pxa2xx_base.c
@@ -166,7 +166,7 @@ pxa2xx_pcmcia_frequency_change(struct soc_pcmcia_socket *skt,
166} 166}
167#endif 167#endif
168 168
169int pxa2xx_drv_pcmcia_probe(struct device *dev) 169int __pxa2xx_drv_pcmcia_probe(struct device *dev)
170{ 170{
171 int ret; 171 int ret;
172 struct pcmcia_low_level *ops; 172 struct pcmcia_low_level *ops;
@@ -203,35 +203,52 @@ int pxa2xx_drv_pcmcia_probe(struct device *dev)
203 203
204 return ret; 204 return ret;
205} 205}
206EXPORT_SYMBOL(pxa2xx_drv_pcmcia_probe); 206EXPORT_SYMBOL(__pxa2xx_drv_pcmcia_probe);
207 207
208static int pxa2xx_drv_pcmcia_resume(struct device *dev) 208
209static int pxa2xx_drv_pcmcia_probe(struct platform_device *dev)
210{
211 return __pxa2xx_drv_pcmcia_probe(&dev->dev);
212}
213
214static int pxa2xx_drv_pcmcia_remove(struct platform_device *dev)
215{
216 return soc_common_drv_pcmcia_remove(&dev->dev);
217}
218
219static int pxa2xx_drv_pcmcia_suspend(struct platform_device *dev, pm_message_t state)
220{
221 return pcmcia_socket_dev_suspend(&dev->dev, state);
222}
223
224static int pxa2xx_drv_pcmcia_resume(struct platform_device *dev)
209{ 225{
210 struct pcmcia_low_level *ops = dev->platform_data; 226 struct pcmcia_low_level *ops = dev->dev.platform_data;
211 int nr = ops ? ops->nr : 0; 227 int nr = ops ? ops->nr : 0;
212 228
213 MECR = nr > 1 ? MECR_CIT | MECR_NOS : (nr > 0 ? MECR_CIT : 0); 229 MECR = nr > 1 ? MECR_CIT | MECR_NOS : (nr > 0 ? MECR_CIT : 0);
214 230
215 return pcmcia_socket_dev_resume(dev); 231 return pcmcia_socket_dev_resume(&dev->dev);
216} 232}
217 233
218static struct device_driver pxa2xx_pcmcia_driver = { 234static struct platform_driver pxa2xx_pcmcia_driver = {
219 .probe = pxa2xx_drv_pcmcia_probe, 235 .probe = pxa2xx_drv_pcmcia_probe,
220 .remove = soc_common_drv_pcmcia_remove, 236 .remove = pxa2xx_drv_pcmcia_remove,
221 .suspend = pcmcia_socket_dev_suspend, 237 .suspend = pxa2xx_drv_pcmcia_suspend,
222 .resume = pxa2xx_drv_pcmcia_resume, 238 .resume = pxa2xx_drv_pcmcia_resume,
223 .name = "pxa2xx-pcmcia", 239 .driver = {
224 .bus = &platform_bus_type, 240 .name = "pxa2xx-pcmcia",
241 },
225}; 242};
226 243
227static int __init pxa2xx_pcmcia_init(void) 244static int __init pxa2xx_pcmcia_init(void)
228{ 245{
229 return driver_register(&pxa2xx_pcmcia_driver); 246 return platform_driver_register(&pxa2xx_pcmcia_driver);
230} 247}
231 248
232static void __exit pxa2xx_pcmcia_exit(void) 249static void __exit pxa2xx_pcmcia_exit(void)
233{ 250{
234 driver_unregister(&pxa2xx_pcmcia_driver); 251 platform_driver_unregister(&pxa2xx_pcmcia_driver);
235} 252}
236 253
237fs_initcall(pxa2xx_pcmcia_init); 254fs_initcall(pxa2xx_pcmcia_init);
diff --git a/drivers/pcmcia/pxa2xx_base.h b/drivers/pcmcia/pxa2xx_base.h
index e46cff345d47..235d681652c3 100644
--- a/drivers/pcmcia/pxa2xx_base.h
+++ b/drivers/pcmcia/pxa2xx_base.h
@@ -1,3 +1,3 @@
1/* temporary measure */ 1/* temporary measure */
2extern int pxa2xx_drv_pcmcia_probe(struct device *); 2extern int __pxa2xx_drv_pcmcia_probe(struct device *);
3 3
diff --git a/drivers/pcmcia/pxa2xx_lubbock.c b/drivers/pcmcia/pxa2xx_lubbock.c
index fd1f691c7c2c..a92f11143c43 100644
--- a/drivers/pcmcia/pxa2xx_lubbock.c
+++ b/drivers/pcmcia/pxa2xx_lubbock.c
@@ -260,7 +260,7 @@ int __init pcmcia_lubbock_init(struct sa1111_dev *sadev)
260 lubbock_set_misc_wr((1 << 15) | (1 << 14), 0); 260 lubbock_set_misc_wr((1 << 15) | (1 << 14), 0);
261 261
262 sadev->dev.platform_data = &lubbock_pcmcia_ops; 262 sadev->dev.platform_data = &lubbock_pcmcia_ops;
263 ret = pxa2xx_drv_pcmcia_probe(&sadev->dev); 263 ret = __pxa2xx_drv_pcmcia_probe(&sadev->dev);
264 } 264 }
265 265
266 return ret; 266 return ret;
diff --git a/drivers/pcmcia/soc_common.c b/drivers/pcmcia/soc_common.c
index 3627e52e0c27..e433704e026a 100644
--- a/drivers/pcmcia/soc_common.c
+++ b/drivers/pcmcia/soc_common.c
@@ -824,3 +824,4 @@ int soc_common_drv_pcmcia_remove(struct device *dev)
824 824
825 return 0; 825 return 0;
826} 826}
827EXPORT_SYMBOL(soc_common_drv_pcmcia_remove);
diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c
index 26229d9da762..da471bddc972 100644
--- a/drivers/pcmcia/yenta_socket.c
+++ b/drivers/pcmcia/yenta_socket.c
@@ -1197,8 +1197,12 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i
1197 ret = pcmcia_register_socket(&socket->socket); 1197 ret = pcmcia_register_socket(&socket->socket);
1198 if (ret == 0) { 1198 if (ret == 0) {
1199 /* Add the yenta register attributes */ 1199 /* Add the yenta register attributes */
1200 device_create_file(&dev->dev, &dev_attr_yenta_registers); 1200 ret = device_create_file(&dev->dev, &dev_attr_yenta_registers);
1201 goto out; 1201 if (ret == 0)
1202 goto out;
1203
1204 /* error path... */
1205 pcmcia_unregister_socket(&socket->socket);
1202 } 1206 }
1203 1207
1204 unmap: 1208 unmap:
@@ -1213,7 +1217,7 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i
1213 return ret; 1217 return ret;
1214} 1218}
1215 1219
1216 1220#ifdef CONFIG_PM
1217static int yenta_dev_suspend (struct pci_dev *dev, pm_message_t state) 1221static int yenta_dev_suspend (struct pci_dev *dev, pm_message_t state)
1218{ 1222{
1219 struct yenta_socket *socket = pci_get_drvdata(dev); 1223 struct yenta_socket *socket = pci_get_drvdata(dev);
@@ -1248,12 +1252,18 @@ static int yenta_dev_resume (struct pci_dev *dev)
1248 struct yenta_socket *socket = pci_get_drvdata(dev); 1252 struct yenta_socket *socket = pci_get_drvdata(dev);
1249 1253
1250 if (socket) { 1254 if (socket) {
1255 int rc;
1256
1251 pci_set_power_state(dev, 0); 1257 pci_set_power_state(dev, 0);
1252 /* FIXME: pci_restore_state needs to have a better interface */ 1258 /* FIXME: pci_restore_state needs to have a better interface */
1253 pci_restore_state(dev); 1259 pci_restore_state(dev);
1254 pci_write_config_dword(dev, 16*4, socket->saved_state[0]); 1260 pci_write_config_dword(dev, 16*4, socket->saved_state[0]);
1255 pci_write_config_dword(dev, 17*4, socket->saved_state[1]); 1261 pci_write_config_dword(dev, 17*4, socket->saved_state[1]);
1256 pci_enable_device(dev); 1262
1263 rc = pci_enable_device(dev);
1264 if (rc)
1265 return rc;
1266
1257 pci_set_master(dev); 1267 pci_set_master(dev);
1258 1268
1259 if (socket->type && socket->type->restore_state) 1269 if (socket->type && socket->type->restore_state)
@@ -1262,7 +1272,7 @@ static int yenta_dev_resume (struct pci_dev *dev)
1262 1272
1263 return pcmcia_socket_dev_resume(&dev->dev); 1273 return pcmcia_socket_dev_resume(&dev->dev);
1264} 1274}
1265 1275#endif
1266 1276
1267#define CB_ID(vend,dev,type) \ 1277#define CB_ID(vend,dev,type) \
1268 { \ 1278 { \
@@ -1359,8 +1369,10 @@ static struct pci_driver yenta_cardbus_driver = {
1359 .id_table = yenta_table, 1369 .id_table = yenta_table,
1360 .probe = yenta_probe, 1370 .probe = yenta_probe,
1361 .remove = __devexit_p(yenta_close), 1371 .remove = __devexit_p(yenta_close),
1372#ifdef CONFIG_PM
1362 .suspend = yenta_dev_suspend, 1373 .suspend = yenta_dev_suspend,
1363 .resume = yenta_dev_resume, 1374 .resume = yenta_dev_resume,
1375#endif
1364}; 1376};
1365 1377
1366 1378
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index dc79b0a0059f..379048fdf05d 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -776,21 +776,32 @@ static void pnpacpi_encode_dma(struct acpi_resource *resource,
776 struct resource *p) 776 struct resource *p)
777{ 777{
778 /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */ 778 /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */
779 if (p->flags & IORESOURCE_DMA_COMPATIBLE) 779 switch (p->flags & IORESOURCE_DMA_SPEED_MASK) {
780 resource->data.dma.type = ACPI_COMPATIBILITY; 780 case IORESOURCE_DMA_TYPEA:
781 else if (p->flags & IORESOURCE_DMA_TYPEA) 781 resource->data.dma.type = ACPI_TYPE_A;
782 resource->data.dma.type = ACPI_TYPE_A; 782 break;
783 else if (p->flags & IORESOURCE_DMA_TYPEB) 783 case IORESOURCE_DMA_TYPEB:
784 resource->data.dma.type = ACPI_TYPE_B; 784 resource->data.dma.type = ACPI_TYPE_B;
785 else if (p->flags & IORESOURCE_DMA_TYPEF) 785 break;
786 resource->data.dma.type = ACPI_TYPE_F; 786 case IORESOURCE_DMA_TYPEF:
787 if (p->flags & IORESOURCE_DMA_8BIT) 787 resource->data.dma.type = ACPI_TYPE_F;
788 resource->data.dma.transfer = ACPI_TRANSFER_8; 788 break;
789 else if (p->flags & IORESOURCE_DMA_8AND16BIT) 789 default:
790 resource->data.dma.transfer = ACPI_TRANSFER_8_16; 790 resource->data.dma.type = ACPI_COMPATIBILITY;
791 else if (p->flags & IORESOURCE_DMA_16BIT) 791 }
792 resource->data.dma.transfer = ACPI_TRANSFER_16; 792
793 resource->data.dma.bus_master = p->flags & IORESOURCE_DMA_MASTER; 793 switch (p->flags & IORESOURCE_DMA_TYPE_MASK) {
794 case IORESOURCE_DMA_8BIT:
795 resource->data.dma.transfer = ACPI_TRANSFER_8;
796 break;
797 case IORESOURCE_DMA_8AND16BIT:
798 resource->data.dma.transfer = ACPI_TRANSFER_8_16;
799 break;
800 default:
801 resource->data.dma.transfer = ACPI_TRANSFER_16;
802 }
803
804 resource->data.dma.bus_master = !!(p->flags & IORESOURCE_DMA_MASTER);
794 resource->data.dma.channel_count = 1; 805 resource->data.dma.channel_count = 1;
795 resource->data.dma.channels[0] = p->start; 806 resource->data.dma.channels[0] = p->start;
796} 807}
diff --git a/drivers/rtc/rtc-max6902.c b/drivers/rtc/rtc-max6902.c
index 0b20dfacbf59..d94170728075 100644
--- a/drivers/rtc/rtc-max6902.c
+++ b/drivers/rtc/rtc-max6902.c
@@ -136,7 +136,7 @@ static int max6902_get_datetime(struct device *dev, struct rtc_time *dt)
136 dt->tm_min = BCD2BIN(chip->buf[2]); 136 dt->tm_min = BCD2BIN(chip->buf[2]);
137 dt->tm_hour = BCD2BIN(chip->buf[3]); 137 dt->tm_hour = BCD2BIN(chip->buf[3]);
138 dt->tm_mday = BCD2BIN(chip->buf[4]); 138 dt->tm_mday = BCD2BIN(chip->buf[4]);
139 dt->tm_mon = BCD2BIN(chip->buf[5] - 1); 139 dt->tm_mon = BCD2BIN(chip->buf[5]) - 1;
140 dt->tm_wday = BCD2BIN(chip->buf[6]); 140 dt->tm_wday = BCD2BIN(chip->buf[6]);
141 dt->tm_year = BCD2BIN(chip->buf[7]); 141 dt->tm_year = BCD2BIN(chip->buf[7]);
142 142
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c
index 8b6efcc05058..143302a8e79c 100644
--- a/drivers/rtc/rtc-sh.c
+++ b/drivers/rtc/rtc-sh.c
@@ -160,7 +160,7 @@ static int sh_rtc_open(struct device *dev)
160 tmp |= RCR1_CIE; 160 tmp |= RCR1_CIE;
161 writeb(tmp, rtc->regbase + RCR1); 161 writeb(tmp, rtc->regbase + RCR1);
162 162
163 ret = request_irq(rtc->periodic_irq, sh_rtc_periodic, SA_INTERRUPT, 163 ret = request_irq(rtc->periodic_irq, sh_rtc_periodic, IRQF_DISABLED,
164 "sh-rtc period", dev); 164 "sh-rtc period", dev);
165 if (unlikely(ret)) { 165 if (unlikely(ret)) {
166 dev_err(dev, "request period IRQ failed with %d, IRQ %d\n", 166 dev_err(dev, "request period IRQ failed with %d, IRQ %d\n",
@@ -168,7 +168,7 @@ static int sh_rtc_open(struct device *dev)
168 return ret; 168 return ret;
169 } 169 }
170 170
171 ret = request_irq(rtc->carry_irq, sh_rtc_interrupt, SA_INTERRUPT, 171 ret = request_irq(rtc->carry_irq, sh_rtc_interrupt, IRQF_DISABLED,
172 "sh-rtc carry", dev); 172 "sh-rtc carry", dev);
173 if (unlikely(ret)) { 173 if (unlikely(ret)) {
174 dev_err(dev, "request carry IRQ failed with %d, IRQ %d\n", 174 dev_err(dev, "request carry IRQ failed with %d, IRQ %d\n",
@@ -177,7 +177,7 @@ static int sh_rtc_open(struct device *dev)
177 goto err_bad_carry; 177 goto err_bad_carry;
178 } 178 }
179 179
180 ret = request_irq(rtc->alarm_irq, sh_rtc_interrupt, SA_INTERRUPT, 180 ret = request_irq(rtc->alarm_irq, sh_rtc_interrupt, IRQF_DISABLED,
181 "sh-rtc alarm", dev); 181 "sh-rtc alarm", dev);
182 if (unlikely(ret)) { 182 if (unlikely(ret)) {
183 dev_err(dev, "request alarm IRQ failed with %d, IRQ %d\n", 183 dev_err(dev, "request alarm IRQ failed with %d, IRQ %d\n",
diff --git a/drivers/rtc/rtc-v3020.c b/drivers/rtc/rtc-v3020.c
index 09b714f1cdc3..3b58d3d5d38a 100644
--- a/drivers/rtc/rtc-v3020.c
+++ b/drivers/rtc/rtc-v3020.c
@@ -195,9 +195,9 @@ static int rtc_probe(struct platform_device *pdev)
195 * are all disabled */ 195 * are all disabled */
196 v3020_set_reg(chip, V3020_STATUS_0, 0x0); 196 v3020_set_reg(chip, V3020_STATUS_0, 0x0);
197 197
198 dev_info(&pdev->dev, "Chip available at physical address 0x%p," 198 dev_info(&pdev->dev, "Chip available at physical address 0x%llx,"
199 "data connected to D%d\n", 199 "data connected to D%d\n",
200 (void*)pdev->resource[0].start, 200 (unsigned long long)pdev->resource[0].start,
201 chip->leftshift); 201 chip->leftshift);
202 202
203 platform_set_drvdata(pdev, chip); 203 platform_set_drvdata(pdev, chip);
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index d0647d116eaa..79ffef6bfaf8 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -203,6 +203,7 @@ dasd_state_basic_to_known(struct dasd_device * device)
203 rc = dasd_flush_ccw_queue(device, 1); 203 rc = dasd_flush_ccw_queue(device, 1);
204 if (rc) 204 if (rc)
205 return rc; 205 return rc;
206 dasd_clear_timer(device);
206 207
207 DBF_DEV_EVENT(DBF_EMERG, device, "%p debug area deleted", device); 208 DBF_DEV_EVENT(DBF_EMERG, device, "%p debug area deleted", device);
208 if (device->debug_area != NULL) { 209 if (device->debug_area != NULL) {
diff --git a/drivers/s390/char/monwriter.c b/drivers/s390/char/monwriter.c
index 4362ff260244..b9b0fc3f812b 100644
--- a/drivers/s390/char/monwriter.c
+++ b/drivers/s390/char/monwriter.c
@@ -73,12 +73,15 @@ static inline struct mon_buf *monwrite_find_hdr(struct mon_private *monpriv,
73 struct mon_buf *entry, *next; 73 struct mon_buf *entry, *next;
74 74
75 list_for_each_entry_safe(entry, next, &monpriv->list, list) 75 list_for_each_entry_safe(entry, next, &monpriv->list, list)
76 if (entry->hdr.applid == monhdr->applid && 76 if ((entry->hdr.mon_function == monhdr->mon_function ||
77 monhdr->mon_function == MONWRITE_STOP_INTERVAL) &&
78 entry->hdr.applid == monhdr->applid &&
77 entry->hdr.record_num == monhdr->record_num && 79 entry->hdr.record_num == monhdr->record_num &&
78 entry->hdr.version == monhdr->version && 80 entry->hdr.version == monhdr->version &&
79 entry->hdr.release == monhdr->release && 81 entry->hdr.release == monhdr->release &&
80 entry->hdr.mod_level == monhdr->mod_level) 82 entry->hdr.mod_level == monhdr->mod_level)
81 return entry; 83 return entry;
84
82 return NULL; 85 return NULL;
83} 86}
84 87
@@ -92,7 +95,9 @@ static int monwrite_new_hdr(struct mon_private *monpriv)
92 monhdr->mon_function > MONWRITE_START_CONFIG || 95 monhdr->mon_function > MONWRITE_START_CONFIG ||
93 monhdr->hdrlen != sizeof(struct monwrite_hdr)) 96 monhdr->hdrlen != sizeof(struct monwrite_hdr))
94 return -EINVAL; 97 return -EINVAL;
95 monbuf = monwrite_find_hdr(monpriv, monhdr); 98 monbuf = NULL;
99 if (monhdr->mon_function != MONWRITE_GEN_EVENT)
100 monbuf = monwrite_find_hdr(monpriv, monhdr);
96 if (monbuf) { 101 if (monbuf) {
97 if (monhdr->mon_function == MONWRITE_STOP_INTERVAL) { 102 if (monhdr->mon_function == MONWRITE_STOP_INTERVAL) {
98 monhdr->datalen = monbuf->hdr.datalen; 103 monhdr->datalen = monbuf->hdr.datalen;
@@ -104,13 +109,13 @@ static int monwrite_new_hdr(struct mon_private *monpriv)
104 kfree(monbuf); 109 kfree(monbuf);
105 monbuf = NULL; 110 monbuf = NULL;
106 } 111 }
107 } else { 112 } else if (monhdr->mon_function != MONWRITE_STOP_INTERVAL) {
108 if (mon_buf_count >= mon_max_bufs) 113 if (mon_buf_count >= mon_max_bufs)
109 return -ENOSPC; 114 return -ENOSPC;
110 monbuf = kzalloc(sizeof(struct mon_buf), GFP_KERNEL); 115 monbuf = kzalloc(sizeof(struct mon_buf), GFP_KERNEL);
111 if (!monbuf) 116 if (!monbuf)
112 return -ENOMEM; 117 return -ENOMEM;
113 monbuf->data = kzalloc(monbuf->hdr.datalen, 118 monbuf->data = kzalloc(monhdr->datalen,
114 GFP_KERNEL | GFP_DMA); 119 GFP_KERNEL | GFP_DMA);
115 if (!monbuf->data) { 120 if (!monbuf->data) {
116 kfree(monbuf); 121 kfree(monbuf);
@@ -118,7 +123,8 @@ static int monwrite_new_hdr(struct mon_private *monpriv)
118 } 123 }
119 monbuf->hdr = *monhdr; 124 monbuf->hdr = *monhdr;
120 list_add_tail(&monbuf->list, &monpriv->list); 125 list_add_tail(&monbuf->list, &monpriv->list);
121 mon_buf_count++; 126 if (monhdr->mon_function != MONWRITE_GEN_EVENT)
127 mon_buf_count++;
122 } 128 }
123 monpriv->current_buf = monbuf; 129 monpriv->current_buf = monbuf;
124 return 0; 130 return 0;
diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c
index 07c7f19339d2..2d78f0f4a40f 100644
--- a/drivers/s390/cio/chsc.c
+++ b/drivers/s390/cio/chsc.c
@@ -370,7 +370,7 @@ __s390_process_res_acc(struct subchannel_id schid, void *data)
370 struct res_acc_data *res_data; 370 struct res_acc_data *res_data;
371 struct subchannel *sch; 371 struct subchannel *sch;
372 372
373 res_data = (struct res_acc_data *)data; 373 res_data = data;
374 sch = get_subchannel_by_schid(schid); 374 sch = get_subchannel_by_schid(schid);
375 if (!sch) 375 if (!sch)
376 /* Check if a subchannel is newly available. */ 376 /* Check if a subchannel is newly available. */
@@ -444,7 +444,7 @@ __get_chpid_from_lir(void *data)
444 u32 isinfo[28]; 444 u32 isinfo[28];
445 } *lir; 445 } *lir;
446 446
447 lir = (struct lir*) data; 447 lir = data;
448 if (!(lir->iq&0x80)) 448 if (!(lir->iq&0x80))
449 /* NULL link incident record */ 449 /* NULL link incident record */
450 return -EINVAL; 450 return -EINVAL;
@@ -628,7 +628,7 @@ __chp_add(struct subchannel_id schid, void *data)
628 struct channel_path *chp; 628 struct channel_path *chp;
629 struct subchannel *sch; 629 struct subchannel *sch;
630 630
631 chp = (struct channel_path *)data; 631 chp = data;
632 sch = get_subchannel_by_schid(schid); 632 sch = get_subchannel_by_schid(schid);
633 if (!sch) 633 if (!sch)
634 /* Check if the subchannel is now available. */ 634 /* Check if the subchannel is now available. */
@@ -707,8 +707,7 @@ chp_process_crw(int chpid, int on)
707 return chp_add(chpid); 707 return chp_add(chpid);
708} 708}
709 709
710static inline int 710static inline int check_for_io_on_path(struct subchannel *sch, int index)
711__check_for_io_and_kill(struct subchannel *sch, int index)
712{ 711{
713 int cc; 712 int cc;
714 713
@@ -718,10 +717,8 @@ __check_for_io_and_kill(struct subchannel *sch, int index)
718 cc = stsch(sch->schid, &sch->schib); 717 cc = stsch(sch->schid, &sch->schib);
719 if (cc) 718 if (cc)
720 return 0; 719 return 0;
721 if (sch->schib.scsw.actl && sch->schib.pmcw.lpum == (0x80 >> index)) { 720 if (sch->schib.scsw.actl && sch->schib.pmcw.lpum == (0x80 >> index))
722 device_set_waiting(sch);
723 return 1; 721 return 1;
724 }
725 return 0; 722 return 0;
726} 723}
727 724
@@ -750,12 +747,10 @@ __s390_subchannel_vary_chpid(struct subchannel *sch, __u8 chpid, int on)
750 } else { 747 } else {
751 sch->opm &= ~(0x80 >> chp); 748 sch->opm &= ~(0x80 >> chp);
752 sch->lpm &= ~(0x80 >> chp); 749 sch->lpm &= ~(0x80 >> chp);
753 /* 750 if (check_for_io_on_path(sch, chp))
754 * Give running I/O a grace period in which it 751 /* Path verification is done after killing. */
755 * can successfully terminate, even using the 752 device_kill_io(sch);
756 * just varied off path. Then kill it. 753 else if (!sch->lpm) {
757 */
758 if (!__check_for_io_and_kill(sch, chp) && !sch->lpm) {
759 if (css_enqueue_subchannel_slow(sch->schid)) { 754 if (css_enqueue_subchannel_slow(sch->schid)) {
760 css_clear_subchannel_slow_list(); 755 css_clear_subchannel_slow_list();
761 need_rescan = 1; 756 need_rescan = 1;
diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c
index f18b1623cad7..8936e460a807 100644
--- a/drivers/s390/cio/cio.c
+++ b/drivers/s390/cio/cio.c
@@ -609,8 +609,8 @@ do_IRQ (struct pt_regs *regs)
609 struct irb *irb; 609 struct irb *irb;
610 struct pt_regs *old_regs; 610 struct pt_regs *old_regs;
611 611
612 irq_enter ();
613 old_regs = set_irq_regs(regs); 612 old_regs = set_irq_regs(regs);
613 irq_enter();
614 asm volatile ("mc 0,0"); 614 asm volatile ("mc 0,0");
615 if (S390_lowcore.int_clock >= S390_lowcore.jiffy_timer) 615 if (S390_lowcore.int_clock >= S390_lowcore.jiffy_timer)
616 /** 616 /**
@@ -655,8 +655,8 @@ do_IRQ (struct pt_regs *regs)
655 * out of the sie which costs more cycles than it saves. 655 * out of the sie which costs more cycles than it saves.
656 */ 656 */
657 } while (!MACHINE_IS_VM && tpi (NULL) != 0); 657 } while (!MACHINE_IS_VM && tpi (NULL) != 0);
658 irq_exit();
658 set_irq_regs(old_regs); 659 set_irq_regs(old_regs);
659 irq_exit ();
660} 660}
661 661
662#ifdef CONFIG_CCW_CONSOLE 662#ifdef CONFIG_CCW_CONSOLE
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index 7086a74e9871..ad7f7e1c0163 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -177,7 +177,7 @@ get_subchannel_by_schid(struct subchannel_id schid)
177 struct device *dev; 177 struct device *dev;
178 178
179 dev = bus_find_device(&css_bus_type, NULL, 179 dev = bus_find_device(&css_bus_type, NULL,
180 (void *)&schid, check_subchannel); 180 &schid, check_subchannel);
181 181
182 return dev ? to_subchannel(dev) : NULL; 182 return dev ? to_subchannel(dev) : NULL;
183} 183}
@@ -271,10 +271,6 @@ static int css_evaluate_known_subchannel(struct subchannel *sch, int slow)
271 /* Reset intparm to zeroes. */ 271 /* Reset intparm to zeroes. */
272 sch->schib.pmcw.intparm = 0; 272 sch->schib.pmcw.intparm = 0;
273 cio_modify(sch); 273 cio_modify(sch);
274
275 /* Probe if necessary. */
276 if (action == UNREGISTER_PROBE)
277 ret = css_probe_device(sch->schid);
278 break; 274 break;
279 case REPROBE: 275 case REPROBE:
280 device_trigger_reprobe(sch); 276 device_trigger_reprobe(sch);
@@ -283,6 +279,9 @@ static int css_evaluate_known_subchannel(struct subchannel *sch, int slow)
283 break; 279 break;
284 } 280 }
285 spin_unlock_irqrestore(&sch->lock, flags); 281 spin_unlock_irqrestore(&sch->lock, flags);
282 /* Probe if necessary. */
283 if (action == UNREGISTER_PROBE)
284 ret = css_probe_device(sch->schid);
286 285
287 return ret; 286 return ret;
288} 287}
diff --git a/drivers/s390/cio/css.h b/drivers/s390/cio/css.h
index 8aabb4adeb5f..4c2ff8336288 100644
--- a/drivers/s390/cio/css.h
+++ b/drivers/s390/cio/css.h
@@ -76,9 +76,8 @@ struct ccw_device_private {
76 int state; /* device state */ 76 int state; /* device state */
77 atomic_t onoff; 77 atomic_t onoff;
78 unsigned long registered; 78 unsigned long registered;
79 __u16 devno; /* device number */ 79 struct ccw_dev_id dev_id; /* device id */
80 __u16 sch_no; /* subchannel number */ 80 struct subchannel_id schid; /* subchannel number */
81 __u8 ssid; /* subchannel set id */
82 __u8 imask; /* lpm mask for SNID/SID/SPGID */ 81 __u8 imask; /* lpm mask for SNID/SID/SPGID */
83 int iretry; /* retry counter SNID/SID/SPGID */ 82 int iretry; /* retry counter SNID/SID/SPGID */
84 struct { 83 struct {
@@ -171,7 +170,7 @@ void device_trigger_reprobe(struct subchannel *);
171 170
172/* Helper functions for vary on/off. */ 171/* Helper functions for vary on/off. */
173int device_is_online(struct subchannel *); 172int device_is_online(struct subchannel *);
174void device_set_waiting(struct subchannel *); 173void device_kill_io(struct subchannel *);
175 174
176/* Machine check helper function. */ 175/* Machine check helper function. */
177void device_kill_pending_timer(struct subchannel *); 176void device_kill_pending_timer(struct subchannel *);
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index 688945662c15..39c98f940507 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -532,8 +532,7 @@ device_remove_files(struct device *dev)
532 532
533/* this is a simple abstraction for device_register that sets the 533/* this is a simple abstraction for device_register that sets the
534 * correct bus type and adds the bus specific files */ 534 * correct bus type and adds the bus specific files */
535int 535static int ccw_device_register(struct ccw_device *cdev)
536ccw_device_register(struct ccw_device *cdev)
537{ 536{
538 struct device *dev = &cdev->dev; 537 struct device *dev = &cdev->dev;
539 int ret; 538 int ret;
@@ -552,21 +551,19 @@ ccw_device_register(struct ccw_device *cdev)
552} 551}
553 552
554struct match_data { 553struct match_data {
555 unsigned int devno; 554 struct ccw_dev_id dev_id;
556 unsigned int ssid;
557 struct ccw_device * sibling; 555 struct ccw_device * sibling;
558}; 556};
559 557
560static int 558static int
561match_devno(struct device * dev, void * data) 559match_devno(struct device * dev, void * data)
562{ 560{
563 struct match_data * d = (struct match_data *)data; 561 struct match_data * d = data;
564 struct ccw_device * cdev; 562 struct ccw_device * cdev;
565 563
566 cdev = to_ccwdev(dev); 564 cdev = to_ccwdev(dev);
567 if ((cdev->private->state == DEV_STATE_DISCONNECTED) && 565 if ((cdev->private->state == DEV_STATE_DISCONNECTED) &&
568 (cdev->private->devno == d->devno) && 566 ccw_dev_id_is_equal(&cdev->private->dev_id, &d->dev_id) &&
569 (cdev->private->ssid == d->ssid) &&
570 (cdev != d->sibling)) { 567 (cdev != d->sibling)) {
571 cdev->private->state = DEV_STATE_NOT_OPER; 568 cdev->private->state = DEV_STATE_NOT_OPER;
572 return 1; 569 return 1;
@@ -574,15 +571,13 @@ match_devno(struct device * dev, void * data)
574 return 0; 571 return 0;
575} 572}
576 573
577static struct ccw_device * 574static struct ccw_device * get_disc_ccwdev_by_dev_id(struct ccw_dev_id *dev_id,
578get_disc_ccwdev_by_devno(unsigned int devno, unsigned int ssid, 575 struct ccw_device *sibling)
579 struct ccw_device *sibling)
580{ 576{
581 struct device *dev; 577 struct device *dev;
582 struct match_data data; 578 struct match_data data;
583 579
584 data.devno = devno; 580 data.dev_id = *dev_id;
585 data.ssid = ssid;
586 data.sibling = sibling; 581 data.sibling = sibling;
587 dev = bus_find_device(&ccw_bus_type, NULL, &data, match_devno); 582 dev = bus_find_device(&ccw_bus_type, NULL, &data, match_devno);
588 583
@@ -595,7 +590,7 @@ ccw_device_add_changed(void *data)
595 590
596 struct ccw_device *cdev; 591 struct ccw_device *cdev;
597 592
598 cdev = (struct ccw_device *)data; 593 cdev = data;
599 if (device_add(&cdev->dev)) { 594 if (device_add(&cdev->dev)) {
600 put_device(&cdev->dev); 595 put_device(&cdev->dev);
601 return; 596 return;
@@ -616,9 +611,9 @@ ccw_device_do_unreg_rereg(void *data)
616 struct subchannel *sch; 611 struct subchannel *sch;
617 int need_rename; 612 int need_rename;
618 613
619 cdev = (struct ccw_device *)data; 614 cdev = data;
620 sch = to_subchannel(cdev->dev.parent); 615 sch = to_subchannel(cdev->dev.parent);
621 if (cdev->private->devno != sch->schib.pmcw.dev) { 616 if (cdev->private->dev_id.devno != sch->schib.pmcw.dev) {
622 /* 617 /*
623 * The device number has changed. This is usually only when 618 * The device number has changed. This is usually only when
624 * a device has been detached under VM and then re-appeared 619 * a device has been detached under VM and then re-appeared
@@ -633,10 +628,12 @@ ccw_device_do_unreg_rereg(void *data)
633 * get possibly sick... 628 * get possibly sick...
634 */ 629 */
635 struct ccw_device *other_cdev; 630 struct ccw_device *other_cdev;
631 struct ccw_dev_id dev_id;
636 632
637 need_rename = 1; 633 need_rename = 1;
638 other_cdev = get_disc_ccwdev_by_devno(sch->schib.pmcw.dev, 634 dev_id.devno = sch->schib.pmcw.dev;
639 sch->schid.ssid, cdev); 635 dev_id.ssid = sch->schid.ssid;
636 other_cdev = get_disc_ccwdev_by_dev_id(&dev_id, cdev);
640 if (other_cdev) { 637 if (other_cdev) {
641 struct subchannel *other_sch; 638 struct subchannel *other_sch;
642 639
@@ -652,7 +649,7 @@ ccw_device_do_unreg_rereg(void *data)
652 } 649 }
653 /* Update ssd info here. */ 650 /* Update ssd info here. */
654 css_get_ssd_info(sch); 651 css_get_ssd_info(sch);
655 cdev->private->devno = sch->schib.pmcw.dev; 652 cdev->private->dev_id.devno = sch->schib.pmcw.dev;
656 } else 653 } else
657 need_rename = 0; 654 need_rename = 0;
658 device_remove_files(&cdev->dev); 655 device_remove_files(&cdev->dev);
@@ -662,7 +659,7 @@ ccw_device_do_unreg_rereg(void *data)
662 snprintf (cdev->dev.bus_id, BUS_ID_SIZE, "0.%x.%04x", 659 snprintf (cdev->dev.bus_id, BUS_ID_SIZE, "0.%x.%04x",
663 sch->schid.ssid, sch->schib.pmcw.dev); 660 sch->schid.ssid, sch->schib.pmcw.dev);
664 PREPARE_WORK(&cdev->private->kick_work, 661 PREPARE_WORK(&cdev->private->kick_work,
665 ccw_device_add_changed, (void *)cdev); 662 ccw_device_add_changed, cdev);
666 queue_work(ccw_device_work, &cdev->private->kick_work); 663 queue_work(ccw_device_work, &cdev->private->kick_work);
667} 664}
668 665
@@ -687,7 +684,7 @@ io_subchannel_register(void *data)
687 int ret; 684 int ret;
688 unsigned long flags; 685 unsigned long flags;
689 686
690 cdev = (struct ccw_device *) data; 687 cdev = data;
691 sch = to_subchannel(cdev->dev.parent); 688 sch = to_subchannel(cdev->dev.parent);
692 689
693 if (klist_node_attached(&cdev->dev.knode_parent)) { 690 if (klist_node_attached(&cdev->dev.knode_parent)) {
@@ -759,7 +756,7 @@ io_subchannel_recog_done(struct ccw_device *cdev)
759 break; 756 break;
760 sch = to_subchannel(cdev->dev.parent); 757 sch = to_subchannel(cdev->dev.parent);
761 PREPARE_WORK(&cdev->private->kick_work, 758 PREPARE_WORK(&cdev->private->kick_work,
762 ccw_device_call_sch_unregister, (void *) cdev); 759 ccw_device_call_sch_unregister, cdev);
763 queue_work(slow_path_wq, &cdev->private->kick_work); 760 queue_work(slow_path_wq, &cdev->private->kick_work);
764 if (atomic_dec_and_test(&ccw_device_init_count)) 761 if (atomic_dec_and_test(&ccw_device_init_count))
765 wake_up(&ccw_device_init_wq); 762 wake_up(&ccw_device_init_wq);
@@ -774,7 +771,7 @@ io_subchannel_recog_done(struct ccw_device *cdev)
774 if (!get_device(&cdev->dev)) 771 if (!get_device(&cdev->dev))
775 break; 772 break;
776 PREPARE_WORK(&cdev->private->kick_work, 773 PREPARE_WORK(&cdev->private->kick_work,
777 io_subchannel_register, (void *) cdev); 774 io_subchannel_register, cdev);
778 queue_work(slow_path_wq, &cdev->private->kick_work); 775 queue_work(slow_path_wq, &cdev->private->kick_work);
779 break; 776 break;
780 } 777 }
@@ -792,9 +789,9 @@ io_subchannel_recog(struct ccw_device *cdev, struct subchannel *sch)
792 789
793 /* Init private data. */ 790 /* Init private data. */
794 priv = cdev->private; 791 priv = cdev->private;
795 priv->devno = sch->schib.pmcw.dev; 792 priv->dev_id.devno = sch->schib.pmcw.dev;
796 priv->ssid = sch->schid.ssid; 793 priv->dev_id.ssid = sch->schid.ssid;
797 priv->sch_no = sch->schid.sch_no; 794 priv->schid = sch->schid;
798 priv->state = DEV_STATE_NOT_OPER; 795 priv->state = DEV_STATE_NOT_OPER;
799 INIT_LIST_HEAD(&priv->cmb_list); 796 INIT_LIST_HEAD(&priv->cmb_list);
800 init_waitqueue_head(&priv->wait_q); 797 init_waitqueue_head(&priv->wait_q);
@@ -912,7 +909,7 @@ io_subchannel_remove (struct subchannel *sch)
912 */ 909 */
913 if (get_device(&cdev->dev)) { 910 if (get_device(&cdev->dev)) {
914 PREPARE_WORK(&cdev->private->kick_work, 911 PREPARE_WORK(&cdev->private->kick_work,
915 ccw_device_unregister, (void *) cdev); 912 ccw_device_unregister, cdev);
916 queue_work(ccw_device_work, &cdev->private->kick_work); 913 queue_work(ccw_device_work, &cdev->private->kick_work);
917 } 914 }
918 return 0; 915 return 0;
@@ -1055,7 +1052,7 @@ __ccwdev_check_busid(struct device *dev, void *id)
1055{ 1052{
1056 char *bus_id; 1053 char *bus_id;
1057 1054
1058 bus_id = (char *)id; 1055 bus_id = id;
1059 1056
1060 return (strncmp(bus_id, dev->bus_id, BUS_ID_SIZE) == 0); 1057 return (strncmp(bus_id, dev->bus_id, BUS_ID_SIZE) == 0);
1061} 1058}
diff --git a/drivers/s390/cio/device.h b/drivers/s390/cio/device.h
index 00be9a5b4acd..9233b5c0bcc8 100644
--- a/drivers/s390/cio/device.h
+++ b/drivers/s390/cio/device.h
@@ -21,7 +21,6 @@ enum dev_state {
21 /* states to wait for i/o completion before doing something */ 21 /* states to wait for i/o completion before doing something */
22 DEV_STATE_CLEAR_VERIFY, 22 DEV_STATE_CLEAR_VERIFY,
23 DEV_STATE_TIMEOUT_KILL, 23 DEV_STATE_TIMEOUT_KILL,
24 DEV_STATE_WAIT4IO,
25 DEV_STATE_QUIESCE, 24 DEV_STATE_QUIESCE,
26 /* special states for devices gone not operational */ 25 /* special states for devices gone not operational */
27 DEV_STATE_DISCONNECTED, 26 DEV_STATE_DISCONNECTED,
@@ -79,7 +78,6 @@ void io_subchannel_recog_done(struct ccw_device *cdev);
79 78
80int ccw_device_cancel_halt_clear(struct ccw_device *); 79int ccw_device_cancel_halt_clear(struct ccw_device *);
81 80
82int ccw_device_register(struct ccw_device *);
83void ccw_device_do_unreg_rereg(void *); 81void ccw_device_do_unreg_rereg(void *);
84void ccw_device_call_sch_unregister(void *); 82void ccw_device_call_sch_unregister(void *);
85 83
diff --git a/drivers/s390/cio/device_fsm.c b/drivers/s390/cio/device_fsm.c
index b67620208f36..de3d0857db9f 100644
--- a/drivers/s390/cio/device_fsm.c
+++ b/drivers/s390/cio/device_fsm.c
@@ -59,18 +59,6 @@ device_set_disconnected(struct subchannel *sch)
59 cdev->private->state = DEV_STATE_DISCONNECTED; 59 cdev->private->state = DEV_STATE_DISCONNECTED;
60} 60}
61 61
62void
63device_set_waiting(struct subchannel *sch)
64{
65 struct ccw_device *cdev;
66
67 if (!sch->dev.driver_data)
68 return;
69 cdev = sch->dev.driver_data;
70 ccw_device_set_timeout(cdev, 10*HZ);
71 cdev->private->state = DEV_STATE_WAIT4IO;
72}
73
74/* 62/*
75 * Timeout function. It just triggers a DEV_EVENT_TIMEOUT. 63 * Timeout function. It just triggers a DEV_EVENT_TIMEOUT.
76 */ 64 */
@@ -183,9 +171,9 @@ ccw_device_handle_oper(struct ccw_device *cdev)
183 cdev->id.cu_model != cdev->private->senseid.cu_model || 171 cdev->id.cu_model != cdev->private->senseid.cu_model ||
184 cdev->id.dev_type != cdev->private->senseid.dev_type || 172 cdev->id.dev_type != cdev->private->senseid.dev_type ||
185 cdev->id.dev_model != cdev->private->senseid.dev_model || 173 cdev->id.dev_model != cdev->private->senseid.dev_model ||
186 cdev->private->devno != sch->schib.pmcw.dev) { 174 cdev->private->dev_id.devno != sch->schib.pmcw.dev) {
187 PREPARE_WORK(&cdev->private->kick_work, 175 PREPARE_WORK(&cdev->private->kick_work,
188 ccw_device_do_unreg_rereg, (void *)cdev); 176 ccw_device_do_unreg_rereg, cdev);
189 queue_work(ccw_device_work, &cdev->private->kick_work); 177 queue_work(ccw_device_work, &cdev->private->kick_work);
190 return 0; 178 return 0;
191 } 179 }
@@ -255,7 +243,7 @@ ccw_device_recog_done(struct ccw_device *cdev, int state)
255 case DEV_STATE_NOT_OPER: 243 case DEV_STATE_NOT_OPER:
256 CIO_DEBUG(KERN_WARNING, 2, 244 CIO_DEBUG(KERN_WARNING, 2,
257 "SenseID : unknown device %04x on subchannel " 245 "SenseID : unknown device %04x on subchannel "
258 "0.%x.%04x\n", cdev->private->devno, 246 "0.%x.%04x\n", cdev->private->dev_id.devno,
259 sch->schid.ssid, sch->schid.sch_no); 247 sch->schid.ssid, sch->schid.sch_no);
260 break; 248 break;
261 case DEV_STATE_OFFLINE: 249 case DEV_STATE_OFFLINE:
@@ -282,14 +270,15 @@ ccw_device_recog_done(struct ccw_device *cdev, int state)
282 CIO_DEBUG(KERN_INFO, 2, "SenseID : device 0.%x.%04x reports: " 270 CIO_DEBUG(KERN_INFO, 2, "SenseID : device 0.%x.%04x reports: "
283 "CU Type/Mod = %04X/%02X, Dev Type/Mod = " 271 "CU Type/Mod = %04X/%02X, Dev Type/Mod = "
284 "%04X/%02X\n", 272 "%04X/%02X\n",
285 cdev->private->ssid, cdev->private->devno, 273 cdev->private->dev_id.ssid,
274 cdev->private->dev_id.devno,
286 cdev->id.cu_type, cdev->id.cu_model, 275 cdev->id.cu_type, cdev->id.cu_model,
287 cdev->id.dev_type, cdev->id.dev_model); 276 cdev->id.dev_type, cdev->id.dev_model);
288 break; 277 break;
289 case DEV_STATE_BOXED: 278 case DEV_STATE_BOXED:
290 CIO_DEBUG(KERN_WARNING, 2, 279 CIO_DEBUG(KERN_WARNING, 2,
291 "SenseID : boxed device %04x on subchannel " 280 "SenseID : boxed device %04x on subchannel "
292 "0.%x.%04x\n", cdev->private->devno, 281 "0.%x.%04x\n", cdev->private->dev_id.devno,
293 sch->schid.ssid, sch->schid.sch_no); 282 sch->schid.ssid, sch->schid.sch_no);
294 break; 283 break;
295 } 284 }
@@ -325,13 +314,13 @@ ccw_device_oper_notify(void *data)
325 struct subchannel *sch; 314 struct subchannel *sch;
326 int ret; 315 int ret;
327 316
328 cdev = (struct ccw_device *)data; 317 cdev = data;
329 sch = to_subchannel(cdev->dev.parent); 318 sch = to_subchannel(cdev->dev.parent);
330 ret = (sch->driver && sch->driver->notify) ? 319 ret = (sch->driver && sch->driver->notify) ?
331 sch->driver->notify(&sch->dev, CIO_OPER) : 0; 320 sch->driver->notify(&sch->dev, CIO_OPER) : 0;
332 if (!ret) 321 if (!ret)
333 /* Driver doesn't want device back. */ 322 /* Driver doesn't want device back. */
334 ccw_device_do_unreg_rereg((void *)cdev); 323 ccw_device_do_unreg_rereg(cdev);
335 else { 324 else {
336 /* Reenable channel measurements, if needed. */ 325 /* Reenable channel measurements, if needed. */
337 cmf_reenable(cdev); 326 cmf_reenable(cdev);
@@ -363,12 +352,12 @@ ccw_device_done(struct ccw_device *cdev, int state)
363 if (state == DEV_STATE_BOXED) 352 if (state == DEV_STATE_BOXED)
364 CIO_DEBUG(KERN_WARNING, 2, 353 CIO_DEBUG(KERN_WARNING, 2,
365 "Boxed device %04x on subchannel %04x\n", 354 "Boxed device %04x on subchannel %04x\n",
366 cdev->private->devno, sch->schid.sch_no); 355 cdev->private->dev_id.devno, sch->schid.sch_no);
367 356
368 if (cdev->private->flags.donotify) { 357 if (cdev->private->flags.donotify) {
369 cdev->private->flags.donotify = 0; 358 cdev->private->flags.donotify = 0;
370 PREPARE_WORK(&cdev->private->kick_work, ccw_device_oper_notify, 359 PREPARE_WORK(&cdev->private->kick_work, ccw_device_oper_notify,
371 (void *)cdev); 360 cdev);
372 queue_work(ccw_device_notify_work, &cdev->private->kick_work); 361 queue_work(ccw_device_notify_work, &cdev->private->kick_work);
373 } 362 }
374 wake_up(&cdev->private->wait_q); 363 wake_up(&cdev->private->wait_q);
@@ -412,7 +401,8 @@ static void __ccw_device_get_common_pgid(struct ccw_device *cdev)
412 /* PGID mismatch, can't pathgroup. */ 401 /* PGID mismatch, can't pathgroup. */
413 CIO_MSG_EVENT(0, "SNID - pgid mismatch for device " 402 CIO_MSG_EVENT(0, "SNID - pgid mismatch for device "
414 "0.%x.%04x, can't pathgroup\n", 403 "0.%x.%04x, can't pathgroup\n",
415 cdev->private->ssid, cdev->private->devno); 404 cdev->private->dev_id.ssid,
405 cdev->private->dev_id.devno);
416 cdev->private->options.pgroup = 0; 406 cdev->private->options.pgroup = 0;
417 return; 407 return;
418 } 408 }
@@ -523,7 +513,7 @@ ccw_device_nopath_notify(void *data)
523 struct subchannel *sch; 513 struct subchannel *sch;
524 int ret; 514 int ret;
525 515
526 cdev = (struct ccw_device *)data; 516 cdev = data;
527 sch = to_subchannel(cdev->dev.parent); 517 sch = to_subchannel(cdev->dev.parent);
528 /* Extra sanity. */ 518 /* Extra sanity. */
529 if (sch->lpm) 519 if (sch->lpm)
@@ -537,7 +527,7 @@ ccw_device_nopath_notify(void *data)
537 if (get_device(&cdev->dev)) { 527 if (get_device(&cdev->dev)) {
538 PREPARE_WORK(&cdev->private->kick_work, 528 PREPARE_WORK(&cdev->private->kick_work,
539 ccw_device_call_sch_unregister, 529 ccw_device_call_sch_unregister,
540 (void *)cdev); 530 cdev);
541 queue_work(ccw_device_work, 531 queue_work(ccw_device_work,
542 &cdev->private->kick_work); 532 &cdev->private->kick_work);
543 } else 533 } else
@@ -588,11 +578,15 @@ ccw_device_verify_done(struct ccw_device *cdev, int err)
588 } 578 }
589 break; 579 break;
590 case -ETIME: 580 case -ETIME:
581 /* Reset oper notify indication after verify error. */
582 cdev->private->flags.donotify = 0;
591 ccw_device_done(cdev, DEV_STATE_BOXED); 583 ccw_device_done(cdev, DEV_STATE_BOXED);
592 break; 584 break;
593 default: 585 default:
586 /* Reset oper notify indication after verify error. */
587 cdev->private->flags.donotify = 0;
594 PREPARE_WORK(&cdev->private->kick_work, 588 PREPARE_WORK(&cdev->private->kick_work,
595 ccw_device_nopath_notify, (void *)cdev); 589 ccw_device_nopath_notify, cdev);
596 queue_work(ccw_device_notify_work, &cdev->private->kick_work); 590 queue_work(ccw_device_notify_work, &cdev->private->kick_work);
597 ccw_device_done(cdev, DEV_STATE_NOT_OPER); 591 ccw_device_done(cdev, DEV_STATE_NOT_OPER);
598 break; 592 break;
@@ -723,7 +717,7 @@ ccw_device_offline_notoper(struct ccw_device *cdev, enum dev_event dev_event)
723 sch = to_subchannel(cdev->dev.parent); 717 sch = to_subchannel(cdev->dev.parent);
724 if (get_device(&cdev->dev)) { 718 if (get_device(&cdev->dev)) {
725 PREPARE_WORK(&cdev->private->kick_work, 719 PREPARE_WORK(&cdev->private->kick_work,
726 ccw_device_call_sch_unregister, (void *)cdev); 720 ccw_device_call_sch_unregister, cdev);
727 queue_work(ccw_device_work, &cdev->private->kick_work); 721 queue_work(ccw_device_work, &cdev->private->kick_work);
728 } 722 }
729 wake_up(&cdev->private->wait_q); 723 wake_up(&cdev->private->wait_q);
@@ -754,7 +748,7 @@ ccw_device_online_notoper(struct ccw_device *cdev, enum dev_event dev_event)
754 } 748 }
755 if (get_device(&cdev->dev)) { 749 if (get_device(&cdev->dev)) {
756 PREPARE_WORK(&cdev->private->kick_work, 750 PREPARE_WORK(&cdev->private->kick_work,
757 ccw_device_call_sch_unregister, (void *)cdev); 751 ccw_device_call_sch_unregister, cdev);
758 queue_work(ccw_device_work, &cdev->private->kick_work); 752 queue_work(ccw_device_work, &cdev->private->kick_work);
759 } 753 }
760 wake_up(&cdev->private->wait_q); 754 wake_up(&cdev->private->wait_q);
@@ -859,7 +853,7 @@ ccw_device_online_timeout(struct ccw_device *cdev, enum dev_event dev_event)
859 sch = to_subchannel(cdev->dev.parent); 853 sch = to_subchannel(cdev->dev.parent);
860 if (!sch->lpm) { 854 if (!sch->lpm) {
861 PREPARE_WORK(&cdev->private->kick_work, 855 PREPARE_WORK(&cdev->private->kick_work,
862 ccw_device_nopath_notify, (void *)cdev); 856 ccw_device_nopath_notify, cdev);
863 queue_work(ccw_device_notify_work, 857 queue_work(ccw_device_notify_work,
864 &cdev->private->kick_work); 858 &cdev->private->kick_work);
865 } else 859 } else
@@ -885,7 +879,8 @@ ccw_device_w4sense(struct ccw_device *cdev, enum dev_event dev_event)
885 /* Basic sense hasn't started. Try again. */ 879 /* Basic sense hasn't started. Try again. */
886 ccw_device_do_sense(cdev, irb); 880 ccw_device_do_sense(cdev, irb);
887 else { 881 else {
888 printk("Huh? %s(%s): unsolicited interrupt...\n", 882 printk(KERN_INFO "Huh? %s(%s): unsolicited "
883 "interrupt...\n",
889 __FUNCTION__, cdev->dev.bus_id); 884 __FUNCTION__, cdev->dev.bus_id);
890 if (cdev->handler) 885 if (cdev->handler)
891 cdev->handler (cdev, 0, irb); 886 cdev->handler (cdev, 0, irb);
@@ -944,10 +939,10 @@ ccw_device_killing_irq(struct ccw_device *cdev, enum dev_event dev_event)
944 cdev->private->state = DEV_STATE_ONLINE; 939 cdev->private->state = DEV_STATE_ONLINE;
945 if (cdev->handler) 940 if (cdev->handler)
946 cdev->handler(cdev, cdev->private->intparm, 941 cdev->handler(cdev, cdev->private->intparm,
947 ERR_PTR(-ETIMEDOUT)); 942 ERR_PTR(-EIO));
948 if (!sch->lpm) { 943 if (!sch->lpm) {
949 PREPARE_WORK(&cdev->private->kick_work, 944 PREPARE_WORK(&cdev->private->kick_work,
950 ccw_device_nopath_notify, (void *)cdev); 945 ccw_device_nopath_notify, cdev);
951 queue_work(ccw_device_notify_work, &cdev->private->kick_work); 946 queue_work(ccw_device_notify_work, &cdev->private->kick_work);
952 } else if (cdev->private->flags.doverify) 947 } else if (cdev->private->flags.doverify)
953 /* Start delayed path verification. */ 948 /* Start delayed path verification. */
@@ -970,7 +965,7 @@ ccw_device_killing_timeout(struct ccw_device *cdev, enum dev_event dev_event)
970 sch = to_subchannel(cdev->dev.parent); 965 sch = to_subchannel(cdev->dev.parent);
971 if (!sch->lpm) { 966 if (!sch->lpm) {
972 PREPARE_WORK(&cdev->private->kick_work, 967 PREPARE_WORK(&cdev->private->kick_work,
973 ccw_device_nopath_notify, (void *)cdev); 968 ccw_device_nopath_notify, cdev);
974 queue_work(ccw_device_notify_work, 969 queue_work(ccw_device_notify_work,
975 &cdev->private->kick_work); 970 &cdev->private->kick_work);
976 } else 971 } else
@@ -981,51 +976,15 @@ ccw_device_killing_timeout(struct ccw_device *cdev, enum dev_event dev_event)
981 cdev->private->state = DEV_STATE_ONLINE; 976 cdev->private->state = DEV_STATE_ONLINE;
982 if (cdev->handler) 977 if (cdev->handler)
983 cdev->handler(cdev, cdev->private->intparm, 978 cdev->handler(cdev, cdev->private->intparm,
984 ERR_PTR(-ETIMEDOUT)); 979 ERR_PTR(-EIO));
985}
986
987static void
988ccw_device_wait4io_irq(struct ccw_device *cdev, enum dev_event dev_event)
989{
990 struct irb *irb;
991 struct subchannel *sch;
992
993 irb = (struct irb *) __LC_IRB;
994 /*
995 * Accumulate status and find out if a basic sense is needed.
996 * This is fine since we have already adapted the lpm.
997 */
998 ccw_device_accumulate_irb(cdev, irb);
999 if (cdev->private->flags.dosense) {
1000 if (ccw_device_do_sense(cdev, irb) == 0) {
1001 cdev->private->state = DEV_STATE_W4SENSE;
1002 }
1003 return;
1004 }
1005
1006 /* Iff device is idle, reset timeout. */
1007 sch = to_subchannel(cdev->dev.parent);
1008 if (!stsch(sch->schid, &sch->schib))
1009 if (sch->schib.scsw.actl == 0)
1010 ccw_device_set_timeout(cdev, 0);
1011 /* Call the handler. */
1012 ccw_device_call_handler(cdev);
1013 if (!sch->lpm) {
1014 PREPARE_WORK(&cdev->private->kick_work,
1015 ccw_device_nopath_notify, (void *)cdev);
1016 queue_work(ccw_device_notify_work, &cdev->private->kick_work);
1017 } else if (cdev->private->flags.doverify)
1018 ccw_device_online_verify(cdev, 0);
1019} 980}
1020 981
1021static void 982void device_kill_io(struct subchannel *sch)
1022ccw_device_wait4io_timeout(struct ccw_device *cdev, enum dev_event dev_event)
1023{ 983{
1024 int ret; 984 int ret;
1025 struct subchannel *sch; 985 struct ccw_device *cdev;
1026 986
1027 sch = to_subchannel(cdev->dev.parent); 987 cdev = sch->dev.driver_data;
1028 ccw_device_set_timeout(cdev, 0);
1029 ret = ccw_device_cancel_halt_clear(cdev); 988 ret = ccw_device_cancel_halt_clear(cdev);
1030 if (ret == -EBUSY) { 989 if (ret == -EBUSY) {
1031 ccw_device_set_timeout(cdev, 3*HZ); 990 ccw_device_set_timeout(cdev, 3*HZ);
@@ -1035,7 +994,7 @@ ccw_device_wait4io_timeout(struct ccw_device *cdev, enum dev_event dev_event)
1035 if (ret == -ENODEV) { 994 if (ret == -ENODEV) {
1036 if (!sch->lpm) { 995 if (!sch->lpm) {
1037 PREPARE_WORK(&cdev->private->kick_work, 996 PREPARE_WORK(&cdev->private->kick_work,
1038 ccw_device_nopath_notify, (void *)cdev); 997 ccw_device_nopath_notify, cdev);
1039 queue_work(ccw_device_notify_work, 998 queue_work(ccw_device_notify_work,
1040 &cdev->private->kick_work); 999 &cdev->private->kick_work);
1041 } else 1000 } else
@@ -1044,12 +1003,12 @@ ccw_device_wait4io_timeout(struct ccw_device *cdev, enum dev_event dev_event)
1044 } 1003 }
1045 if (cdev->handler) 1004 if (cdev->handler)
1046 cdev->handler(cdev, cdev->private->intparm, 1005 cdev->handler(cdev, cdev->private->intparm,
1047 ERR_PTR(-ETIMEDOUT)); 1006 ERR_PTR(-EIO));
1048 if (!sch->lpm) { 1007 if (!sch->lpm) {
1049 PREPARE_WORK(&cdev->private->kick_work, 1008 PREPARE_WORK(&cdev->private->kick_work,
1050 ccw_device_nopath_notify, (void *)cdev); 1009 ccw_device_nopath_notify, cdev);
1051 queue_work(ccw_device_notify_work, &cdev->private->kick_work); 1010 queue_work(ccw_device_notify_work, &cdev->private->kick_work);
1052 } else if (cdev->private->flags.doverify) 1011 } else
1053 /* Start delayed path verification. */ 1012 /* Start delayed path verification. */
1054 ccw_device_online_verify(cdev, 0); 1013 ccw_device_online_verify(cdev, 0);
1055} 1014}
@@ -1286,12 +1245,6 @@ fsm_func_t *dev_jumptable[NR_DEV_STATES][NR_DEV_EVENTS] = {
1286 [DEV_EVENT_TIMEOUT] = ccw_device_killing_timeout, 1245 [DEV_EVENT_TIMEOUT] = ccw_device_killing_timeout,
1287 [DEV_EVENT_VERIFY] = ccw_device_nop, //FIXME 1246 [DEV_EVENT_VERIFY] = ccw_device_nop, //FIXME
1288 }, 1247 },
1289 [DEV_STATE_WAIT4IO] = {
1290 [DEV_EVENT_NOTOPER] = ccw_device_online_notoper,
1291 [DEV_EVENT_INTERRUPT] = ccw_device_wait4io_irq,
1292 [DEV_EVENT_TIMEOUT] = ccw_device_wait4io_timeout,
1293 [DEV_EVENT_VERIFY] = ccw_device_delay_verify,
1294 },
1295 [DEV_STATE_QUIESCE] = { 1248 [DEV_STATE_QUIESCE] = {
1296 [DEV_EVENT_NOTOPER] = ccw_device_quiesce_done, 1249 [DEV_EVENT_NOTOPER] = ccw_device_quiesce_done,
1297 [DEV_EVENT_INTERRUPT] = ccw_device_quiesce_done, 1250 [DEV_EVENT_INTERRUPT] = ccw_device_quiesce_done,
diff --git a/drivers/s390/cio/device_id.c b/drivers/s390/cio/device_id.c
index 1398367b5f68..a74785b9e4eb 100644
--- a/drivers/s390/cio/device_id.c
+++ b/drivers/s390/cio/device_id.c
@@ -251,7 +251,7 @@ ccw_device_check_sense_id(struct ccw_device *cdev)
251 */ 251 */
252 CIO_MSG_EVENT(2, "SenseID : device %04x on Subchannel " 252 CIO_MSG_EVENT(2, "SenseID : device %04x on Subchannel "
253 "0.%x.%04x reports cmd reject\n", 253 "0.%x.%04x reports cmd reject\n",
254 cdev->private->devno, sch->schid.ssid, 254 cdev->private->dev_id.devno, sch->schid.ssid,
255 sch->schid.sch_no); 255 sch->schid.sch_no);
256 return -EOPNOTSUPP; 256 return -EOPNOTSUPP;
257 } 257 }
@@ -259,7 +259,8 @@ ccw_device_check_sense_id(struct ccw_device *cdev)
259 CIO_MSG_EVENT(2, "SenseID : UC on dev 0.%x.%04x, " 259 CIO_MSG_EVENT(2, "SenseID : UC on dev 0.%x.%04x, "
260 "lpum %02X, cnt %02d, sns :" 260 "lpum %02X, cnt %02d, sns :"
261 " %02X%02X%02X%02X %02X%02X%02X%02X ...\n", 261 " %02X%02X%02X%02X %02X%02X%02X%02X ...\n",
262 cdev->private->ssid, cdev->private->devno, 262 cdev->private->dev_id.ssid,
263 cdev->private->dev_id.devno,
263 irb->esw.esw0.sublog.lpum, 264 irb->esw.esw0.sublog.lpum,
264 irb->esw.esw0.erw.scnt, 265 irb->esw.esw0.erw.scnt,
265 irb->ecw[0], irb->ecw[1], 266 irb->ecw[0], irb->ecw[1],
@@ -274,14 +275,15 @@ ccw_device_check_sense_id(struct ccw_device *cdev)
274 CIO_MSG_EVENT(2, "SenseID : path %02X for device %04x " 275 CIO_MSG_EVENT(2, "SenseID : path %02X for device %04x "
275 "on subchannel 0.%x.%04x is " 276 "on subchannel 0.%x.%04x is "
276 "'not operational'\n", sch->orb.lpm, 277 "'not operational'\n", sch->orb.lpm,
277 cdev->private->devno, sch->schid.ssid, 278 cdev->private->dev_id.devno,
278 sch->schid.sch_no); 279 sch->schid.ssid, sch->schid.sch_no);
279 return -EACCES; 280 return -EACCES;
280 } 281 }
281 /* Hmm, whatever happened, try again. */ 282 /* Hmm, whatever happened, try again. */
282 CIO_MSG_EVENT(2, "SenseID : start_IO() for device %04x on " 283 CIO_MSG_EVENT(2, "SenseID : start_IO() for device %04x on "
283 "subchannel 0.%x.%04x returns status %02X%02X\n", 284 "subchannel 0.%x.%04x returns status %02X%02X\n",
284 cdev->private->devno, sch->schid.ssid, sch->schid.sch_no, 285 cdev->private->dev_id.devno, sch->schid.ssid,
286 sch->schid.sch_no,
285 irb->scsw.dstat, irb->scsw.cstat); 287 irb->scsw.dstat, irb->scsw.cstat);
286 return -EAGAIN; 288 return -EAGAIN;
287} 289}
@@ -330,7 +332,7 @@ ccw_device_sense_id_irq(struct ccw_device *cdev, enum dev_event dev_event)
330 /* fall through. */ 332 /* fall through. */
331 default: /* Sense ID failed. Try asking VM. */ 333 default: /* Sense ID failed. Try asking VM. */
332 if (MACHINE_IS_VM) { 334 if (MACHINE_IS_VM) {
333 VM_virtual_device_info (cdev->private->devno, 335 VM_virtual_device_info (cdev->private->dev_id.devno,
334 &cdev->private->senseid); 336 &cdev->private->senseid);
335 if (cdev->private->senseid.cu_type != 0xFFFF) { 337 if (cdev->private->senseid.cu_type != 0xFFFF) {
336 /* Got the device information from VM. */ 338 /* Got the device information from VM. */
diff --git a/drivers/s390/cio/device_ops.c b/drivers/s390/cio/device_ops.c
index 84b9b18eabc2..b39c1fa48acd 100644
--- a/drivers/s390/cio/device_ops.c
+++ b/drivers/s390/cio/device_ops.c
@@ -50,7 +50,6 @@ ccw_device_clear(struct ccw_device *cdev, unsigned long intparm)
50 if (cdev->private->state == DEV_STATE_NOT_OPER) 50 if (cdev->private->state == DEV_STATE_NOT_OPER)
51 return -ENODEV; 51 return -ENODEV;
52 if (cdev->private->state != DEV_STATE_ONLINE && 52 if (cdev->private->state != DEV_STATE_ONLINE &&
53 cdev->private->state != DEV_STATE_WAIT4IO &&
54 cdev->private->state != DEV_STATE_W4SENSE) 53 cdev->private->state != DEV_STATE_W4SENSE)
55 return -EINVAL; 54 return -EINVAL;
56 sch = to_subchannel(cdev->dev.parent); 55 sch = to_subchannel(cdev->dev.parent);
@@ -155,7 +154,6 @@ ccw_device_halt(struct ccw_device *cdev, unsigned long intparm)
155 if (cdev->private->state == DEV_STATE_NOT_OPER) 154 if (cdev->private->state == DEV_STATE_NOT_OPER)
156 return -ENODEV; 155 return -ENODEV;
157 if (cdev->private->state != DEV_STATE_ONLINE && 156 if (cdev->private->state != DEV_STATE_ONLINE &&
158 cdev->private->state != DEV_STATE_WAIT4IO &&
159 cdev->private->state != DEV_STATE_W4SENSE) 157 cdev->private->state != DEV_STATE_W4SENSE)
160 return -EINVAL; 158 return -EINVAL;
161 sch = to_subchannel(cdev->dev.parent); 159 sch = to_subchannel(cdev->dev.parent);
@@ -592,13 +590,13 @@ ccw_device_get_chp_desc(struct ccw_device *cdev, int chp_no)
592int 590int
593_ccw_device_get_subchannel_number(struct ccw_device *cdev) 591_ccw_device_get_subchannel_number(struct ccw_device *cdev)
594{ 592{
595 return cdev->private->sch_no; 593 return cdev->private->schid.sch_no;
596} 594}
597 595
598int 596int
599_ccw_device_get_device_number(struct ccw_device *cdev) 597_ccw_device_get_device_number(struct ccw_device *cdev)
600{ 598{
601 return cdev->private->devno; 599 return cdev->private->dev_id.devno;
602} 600}
603 601
604 602
diff --git a/drivers/s390/cio/device_pgid.c b/drivers/s390/cio/device_pgid.c
index 84917b39de45..2975ce888c19 100644
--- a/drivers/s390/cio/device_pgid.c
+++ b/drivers/s390/cio/device_pgid.c
@@ -79,7 +79,8 @@ __ccw_device_sense_pgid_start(struct ccw_device *cdev)
79 CIO_MSG_EVENT(2, "SNID - Device %04x on Subchannel " 79 CIO_MSG_EVENT(2, "SNID - Device %04x on Subchannel "
80 "0.%x.%04x, lpm %02X, became 'not " 80 "0.%x.%04x, lpm %02X, became 'not "
81 "operational'\n", 81 "operational'\n",
82 cdev->private->devno, sch->schid.ssid, 82 cdev->private->dev_id.devno,
83 sch->schid.ssid,
83 sch->schid.sch_no, cdev->private->imask); 84 sch->schid.sch_no, cdev->private->imask);
84 85
85 } 86 }
@@ -135,7 +136,8 @@ __ccw_device_check_sense_pgid(struct ccw_device *cdev)
135 CIO_MSG_EVENT(2, "SNID - device 0.%x.%04x, unit check, " 136 CIO_MSG_EVENT(2, "SNID - device 0.%x.%04x, unit check, "
136 "lpum %02X, cnt %02d, sns : " 137 "lpum %02X, cnt %02d, sns : "
137 "%02X%02X%02X%02X %02X%02X%02X%02X ...\n", 138 "%02X%02X%02X%02X %02X%02X%02X%02X ...\n",
138 cdev->private->ssid, cdev->private->devno, 139 cdev->private->dev_id.ssid,
140 cdev->private->dev_id.devno,
139 irb->esw.esw0.sublog.lpum, 141 irb->esw.esw0.sublog.lpum,
140 irb->esw.esw0.erw.scnt, 142 irb->esw.esw0.erw.scnt,
141 irb->ecw[0], irb->ecw[1], 143 irb->ecw[0], irb->ecw[1],
@@ -147,7 +149,7 @@ __ccw_device_check_sense_pgid(struct ccw_device *cdev)
147 if (irb->scsw.cc == 3) { 149 if (irb->scsw.cc == 3) {
148 CIO_MSG_EVENT(2, "SNID - Device %04x on Subchannel 0.%x.%04x," 150 CIO_MSG_EVENT(2, "SNID - Device %04x on Subchannel 0.%x.%04x,"
149 " lpm %02X, became 'not operational'\n", 151 " lpm %02X, became 'not operational'\n",
150 cdev->private->devno, sch->schid.ssid, 152 cdev->private->dev_id.devno, sch->schid.ssid,
151 sch->schid.sch_no, sch->orb.lpm); 153 sch->schid.sch_no, sch->orb.lpm);
152 return -EACCES; 154 return -EACCES;
153 } 155 }
@@ -155,7 +157,7 @@ __ccw_device_check_sense_pgid(struct ccw_device *cdev)
155 if (cdev->private->pgid[i].inf.ps.state2 == SNID_STATE2_RESVD_ELSE) { 157 if (cdev->private->pgid[i].inf.ps.state2 == SNID_STATE2_RESVD_ELSE) {
156 CIO_MSG_EVENT(2, "SNID - Device %04x on Subchannel 0.%x.%04x " 158 CIO_MSG_EVENT(2, "SNID - Device %04x on Subchannel 0.%x.%04x "
157 "is reserved by someone else\n", 159 "is reserved by someone else\n",
158 cdev->private->devno, sch->schid.ssid, 160 cdev->private->dev_id.devno, sch->schid.ssid,
159 sch->schid.sch_no); 161 sch->schid.sch_no);
160 return -EUSERS; 162 return -EUSERS;
161 } 163 }
@@ -261,7 +263,7 @@ __ccw_device_do_pgid(struct ccw_device *cdev, __u8 func)
261 /* PGID command failed on this path. */ 263 /* PGID command failed on this path. */
262 CIO_MSG_EVENT(2, "SPID - Device %04x on Subchannel " 264 CIO_MSG_EVENT(2, "SPID - Device %04x on Subchannel "
263 "0.%x.%04x, lpm %02X, became 'not operational'\n", 265 "0.%x.%04x, lpm %02X, became 'not operational'\n",
264 cdev->private->devno, sch->schid.ssid, 266 cdev->private->dev_id.devno, sch->schid.ssid,
265 sch->schid.sch_no, cdev->private->imask); 267 sch->schid.sch_no, cdev->private->imask);
266 return ret; 268 return ret;
267} 269}
@@ -301,7 +303,7 @@ static int __ccw_device_do_nop(struct ccw_device *cdev)
301 /* nop command failed on this path. */ 303 /* nop command failed on this path. */
302 CIO_MSG_EVENT(2, "NOP - Device %04x on Subchannel " 304 CIO_MSG_EVENT(2, "NOP - Device %04x on Subchannel "
303 "0.%x.%04x, lpm %02X, became 'not operational'\n", 305 "0.%x.%04x, lpm %02X, became 'not operational'\n",
304 cdev->private->devno, sch->schid.ssid, 306 cdev->private->dev_id.devno, sch->schid.ssid,
305 sch->schid.sch_no, cdev->private->imask); 307 sch->schid.sch_no, cdev->private->imask);
306 return ret; 308 return ret;
307} 309}
@@ -328,8 +330,9 @@ __ccw_device_check_pgid(struct ccw_device *cdev)
328 CIO_MSG_EVENT(2, "SPID - device 0.%x.%04x, unit check, " 330 CIO_MSG_EVENT(2, "SPID - device 0.%x.%04x, unit check, "
329 "cnt %02d, " 331 "cnt %02d, "
330 "sns : %02X%02X%02X%02X %02X%02X%02X%02X ...\n", 332 "sns : %02X%02X%02X%02X %02X%02X%02X%02X ...\n",
331 cdev->private->ssid, 333 cdev->private->dev_id.ssid,
332 cdev->private->devno, irb->esw.esw0.erw.scnt, 334 cdev->private->dev_id.devno,
335 irb->esw.esw0.erw.scnt,
333 irb->ecw[0], irb->ecw[1], 336 irb->ecw[0], irb->ecw[1],
334 irb->ecw[2], irb->ecw[3], 337 irb->ecw[2], irb->ecw[3],
335 irb->ecw[4], irb->ecw[5], 338 irb->ecw[4], irb->ecw[5],
@@ -339,7 +342,7 @@ __ccw_device_check_pgid(struct ccw_device *cdev)
339 if (irb->scsw.cc == 3) { 342 if (irb->scsw.cc == 3) {
340 CIO_MSG_EVENT(2, "SPID - Device %04x on Subchannel 0.%x.%04x," 343 CIO_MSG_EVENT(2, "SPID - Device %04x on Subchannel 0.%x.%04x,"
341 " lpm %02X, became 'not operational'\n", 344 " lpm %02X, became 'not operational'\n",
342 cdev->private->devno, sch->schid.ssid, 345 cdev->private->dev_id.devno, sch->schid.ssid,
343 sch->schid.sch_no, cdev->private->imask); 346 sch->schid.sch_no, cdev->private->imask);
344 return -EACCES; 347 return -EACCES;
345 } 348 }
@@ -362,7 +365,7 @@ static int __ccw_device_check_nop(struct ccw_device *cdev)
362 if (irb->scsw.cc == 3) { 365 if (irb->scsw.cc == 3) {
363 CIO_MSG_EVENT(2, "NOP - Device %04x on Subchannel 0.%x.%04x," 366 CIO_MSG_EVENT(2, "NOP - Device %04x on Subchannel 0.%x.%04x,"
364 " lpm %02X, became 'not operational'\n", 367 " lpm %02X, became 'not operational'\n",
365 cdev->private->devno, sch->schid.ssid, 368 cdev->private->dev_id.devno, sch->schid.ssid,
366 sch->schid.sch_no, cdev->private->imask); 369 sch->schid.sch_no, cdev->private->imask);
367 return -EACCES; 370 return -EACCES;
368 } 371 }
diff --git a/drivers/s390/cio/device_status.c b/drivers/s390/cio/device_status.c
index caf148d5caad..3f7cbce4cd87 100644
--- a/drivers/s390/cio/device_status.c
+++ b/drivers/s390/cio/device_status.c
@@ -32,19 +32,18 @@ ccw_device_msg_control_check(struct ccw_device *cdev, struct irb *irb)
32 SCHN_STAT_CHN_CTRL_CHK | 32 SCHN_STAT_CHN_CTRL_CHK |
33 SCHN_STAT_INTF_CTRL_CHK))) 33 SCHN_STAT_INTF_CTRL_CHK)))
34 return; 34 return;
35
36 CIO_MSG_EVENT(0, "Channel-Check or Interface-Control-Check " 35 CIO_MSG_EVENT(0, "Channel-Check or Interface-Control-Check "
37 "received" 36 "received"
38 " ... device %04x on subchannel 0.%x.%04x, dev_stat " 37 " ... device %04x on subchannel 0.%x.%04x, dev_stat "
39 ": %02X sch_stat : %02X\n", 38 ": %02X sch_stat : %02X\n",
40 cdev->private->devno, cdev->private->ssid, 39 cdev->private->dev_id.devno, cdev->private->schid.ssid,
41 cdev->private->sch_no, 40 cdev->private->schid.sch_no,
42 irb->scsw.dstat, irb->scsw.cstat); 41 irb->scsw.dstat, irb->scsw.cstat);
43 42
44 if (irb->scsw.cc != 3) { 43 if (irb->scsw.cc != 3) {
45 char dbf_text[15]; 44 char dbf_text[15];
46 45
47 sprintf(dbf_text, "chk%x", cdev->private->sch_no); 46 sprintf(dbf_text, "chk%x", cdev->private->schid.sch_no);
48 CIO_TRACE_EVENT(0, dbf_text); 47 CIO_TRACE_EVENT(0, dbf_text);
49 CIO_HEX_EVENT(0, irb, sizeof (struct irb)); 48 CIO_HEX_EVENT(0, irb, sizeof (struct irb));
50 } 49 }
diff --git a/drivers/s390/cio/qdio.c b/drivers/s390/cio/qdio.c
index cde822d8b5c8..476aa1da5cbc 100644
--- a/drivers/s390/cio/qdio.c
+++ b/drivers/s390/cio/qdio.c
@@ -1741,7 +1741,7 @@ qdio_fill_qs(struct qdio_irq *irq_ptr, struct ccw_device *cdev,
1741 void *ptr; 1741 void *ptr;
1742 int available; 1742 int available;
1743 1743
1744 sprintf(dbf_text,"qfqs%4x",cdev->private->sch_no); 1744 sprintf(dbf_text,"qfqs%4x",cdev->private->schid.sch_no);
1745 QDIO_DBF_TEXT0(0,setup,dbf_text); 1745 QDIO_DBF_TEXT0(0,setup,dbf_text);
1746 for (i=0;i<no_input_qs;i++) { 1746 for (i=0;i<no_input_qs;i++) {
1747 q=irq_ptr->input_qs[i]; 1747 q=irq_ptr->input_qs[i];
@@ -2924,7 +2924,7 @@ qdio_establish_handle_irq(struct ccw_device *cdev, int cstat, int dstat)
2924 2924
2925 irq_ptr = cdev->private->qdio_data; 2925 irq_ptr = cdev->private->qdio_data;
2926 2926
2927 sprintf(dbf_text,"qehi%4x",cdev->private->sch_no); 2927 sprintf(dbf_text,"qehi%4x",cdev->private->schid.sch_no);
2928 QDIO_DBF_TEXT0(0,setup,dbf_text); 2928 QDIO_DBF_TEXT0(0,setup,dbf_text);
2929 QDIO_DBF_TEXT0(0,trace,dbf_text); 2929 QDIO_DBF_TEXT0(0,trace,dbf_text);
2930 2930
@@ -2943,7 +2943,7 @@ qdio_initialize(struct qdio_initialize *init_data)
2943 int rc; 2943 int rc;
2944 char dbf_text[15]; 2944 char dbf_text[15];
2945 2945
2946 sprintf(dbf_text,"qini%4x",init_data->cdev->private->sch_no); 2946 sprintf(dbf_text,"qini%4x",init_data->cdev->private->schid.sch_no);
2947 QDIO_DBF_TEXT0(0,setup,dbf_text); 2947 QDIO_DBF_TEXT0(0,setup,dbf_text);
2948 QDIO_DBF_TEXT0(0,trace,dbf_text); 2948 QDIO_DBF_TEXT0(0,trace,dbf_text);
2949 2949
@@ -2964,7 +2964,7 @@ qdio_allocate(struct qdio_initialize *init_data)
2964 struct qdio_irq *irq_ptr; 2964 struct qdio_irq *irq_ptr;
2965 char dbf_text[15]; 2965 char dbf_text[15];
2966 2966
2967 sprintf(dbf_text,"qalc%4x",init_data->cdev->private->sch_no); 2967 sprintf(dbf_text,"qalc%4x",init_data->cdev->private->schid.sch_no);
2968 QDIO_DBF_TEXT0(0,setup,dbf_text); 2968 QDIO_DBF_TEXT0(0,setup,dbf_text);
2969 QDIO_DBF_TEXT0(0,trace,dbf_text); 2969 QDIO_DBF_TEXT0(0,trace,dbf_text);
2970 if ( (init_data->no_input_qs>QDIO_MAX_QUEUES_PER_IRQ) || 2970 if ( (init_data->no_input_qs>QDIO_MAX_QUEUES_PER_IRQ) ||
@@ -3187,7 +3187,7 @@ qdio_establish(struct qdio_initialize *init_data)
3187 tiqdio_set_delay_target(irq_ptr,TIQDIO_DELAY_TARGET); 3187 tiqdio_set_delay_target(irq_ptr,TIQDIO_DELAY_TARGET);
3188 } 3188 }
3189 3189
3190 sprintf(dbf_text,"qest%4x",cdev->private->sch_no); 3190 sprintf(dbf_text,"qest%4x",cdev->private->schid.sch_no);
3191 QDIO_DBF_TEXT0(0,setup,dbf_text); 3191 QDIO_DBF_TEXT0(0,setup,dbf_text);
3192 QDIO_DBF_TEXT0(0,trace,dbf_text); 3192 QDIO_DBF_TEXT0(0,trace,dbf_text);
3193 3193
@@ -3529,7 +3529,7 @@ do_QDIO(struct ccw_device *cdev,unsigned int callflags,
3529#ifdef CONFIG_QDIO_DEBUG 3529#ifdef CONFIG_QDIO_DEBUG
3530 char dbf_text[20]; 3530 char dbf_text[20];
3531 3531
3532 sprintf(dbf_text,"doQD%04x",cdev->private->sch_no); 3532 sprintf(dbf_text,"doQD%04x",cdev->private->schid.sch_no);
3533 QDIO_DBF_TEXT3(0,trace,dbf_text); 3533 QDIO_DBF_TEXT3(0,trace,dbf_text);
3534#endif /* CONFIG_QDIO_DEBUG */ 3534#endif /* CONFIG_QDIO_DEBUG */
3535 3535
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c
index c5ccd20b110c..79d89c368919 100644
--- a/drivers/s390/crypto/ap_bus.c
+++ b/drivers/s390/crypto/ap_bus.c
@@ -739,11 +739,16 @@ static void ap_scan_bus(void *data)
739 dev = bus_find_device(&ap_bus_type, NULL, 739 dev = bus_find_device(&ap_bus_type, NULL,
740 (void *)(unsigned long)qid, 740 (void *)(unsigned long)qid,
741 __ap_scan_bus); 741 __ap_scan_bus);
742 rc = ap_query_queue(qid, &queue_depth, &device_type);
743 if (dev && rc) {
744 put_device(dev);
745 device_unregister(dev);
746 continue;
747 }
742 if (dev) { 748 if (dev) {
743 put_device(dev); 749 put_device(dev);
744 continue; 750 continue;
745 } 751 }
746 rc = ap_query_queue(qid, &queue_depth, &device_type);
747 if (rc) 752 if (rc)
748 continue; 753 continue;
749 rc = ap_init_queue(qid); 754 rc = ap_init_queue(qid);
diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h
index 8f882690994d..74c0eac083e4 100644
--- a/drivers/s390/scsi/zfcp_def.h
+++ b/drivers/s390/scsi/zfcp_def.h
@@ -107,6 +107,10 @@ zfcp_address_to_sg(void *address, struct scatterlist *list)
107 (ZFCP_MAX_SBALS_PER_REQ * ZFCP_MAX_SBALES_PER_SBAL - 2) 107 (ZFCP_MAX_SBALS_PER_REQ * ZFCP_MAX_SBALES_PER_SBAL - 2)
108 /* request ID + QTCB in SBALE 0 + 1 of first SBAL in chain */ 108 /* request ID + QTCB in SBALE 0 + 1 of first SBAL in chain */
109 109
110#define ZFCP_MAX_SECTORS (ZFCP_MAX_SBALES_PER_REQ * 8)
111 /* max. number of (data buffer) SBALEs in largest SBAL chain
112 multiplied with number of sectors per 4k block */
113
110/* FIXME(tune): free space should be one max. SBAL chain plus what? */ 114/* FIXME(tune): free space should be one max. SBAL chain plus what? */
111#define ZFCP_QDIO_PCI_INTERVAL (QDIO_MAX_BUFFERS_PER_Q \ 115#define ZFCP_QDIO_PCI_INTERVAL (QDIO_MAX_BUFFERS_PER_Q \
112 - (ZFCP_MAX_SBALS_PER_REQ + 4)) 116 - (ZFCP_MAX_SBALS_PER_REQ + 4))
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index 4d2bc7981324..452d96f92a14 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -58,6 +58,7 @@ struct zfcp_data zfcp_data = {
58 .cmd_per_lun = 1, 58 .cmd_per_lun = 1,
59 .use_clustering = 1, 59 .use_clustering = 1,
60 .sdev_attrs = zfcp_sysfs_sdev_attrs, 60 .sdev_attrs = zfcp_sysfs_sdev_attrs,
61 .max_sectors = ZFCP_MAX_SECTORS,
61 }, 62 },
62 .driver_version = ZFCP_VERSION, 63 .driver_version = ZFCP_VERSION,
63}; 64};
diff --git a/drivers/sbus/char/bbc_envctrl.c b/drivers/sbus/char/bbc_envctrl.c
index d27e4f6d7045..a54e4140683a 100644
--- a/drivers/sbus/char/bbc_envctrl.c
+++ b/drivers/sbus/char/bbc_envctrl.c
@@ -4,11 +4,9 @@
4 * Copyright (C) 2001 David S. Miller (davem@redhat.com) 4 * Copyright (C) 2001 David S. Miller (davem@redhat.com)
5 */ 5 */
6 6
7#include <linux/kernel.h>
8#include <linux/kthread.h> 7#include <linux/kthread.h>
9#include <linux/sched.h>
10#include <linux/slab.h>
11#include <linux/delay.h> 8#include <linux/delay.h>
9#include <linux/kmod.h>
12#include <asm/oplib.h> 10#include <asm/oplib.h>
13#include <asm/ebus.h> 11#include <asm/ebus.h>
14 12
@@ -197,7 +195,7 @@ static void do_envctrl_shutdown(struct bbc_cpu_temperature *tp)
197 printk(KERN_CRIT "kenvctrld: Shutting down the system now.\n"); 195 printk(KERN_CRIT "kenvctrld: Shutting down the system now.\n");
198 196
199 shutting_down = 1; 197 shutting_down = 1;
200 if (kernel_execve("/sbin/shutdown", argv, envp) < 0) 198 if (call_usermodehelper("/sbin/shutdown", argv, envp, 0) < 0)
201 printk(KERN_CRIT "envctrl: shutdown execution failed\n"); 199 printk(KERN_CRIT "envctrl: shutdown execution failed\n");
202} 200}
203 201
diff --git a/drivers/sbus/char/envctrl.c b/drivers/sbus/char/envctrl.c
index 728a133d0fc5..fff4660cdf96 100644
--- a/drivers/sbus/char/envctrl.c
+++ b/drivers/sbus/char/envctrl.c
@@ -20,16 +20,12 @@
20 */ 20 */
21 21
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/sched.h> 23#include <linux/init.h>
24#include <linux/kthread.h> 24#include <linux/kthread.h>
25#include <linux/errno.h>
26#include <linux/delay.h> 25#include <linux/delay.h>
27#include <linux/ioport.h> 26#include <linux/ioport.h>
28#include <linux/init.h>
29#include <linux/miscdevice.h> 27#include <linux/miscdevice.h>
30#include <linux/mm.h> 28#include <linux/kmod.h>
31#include <linux/slab.h>
32#include <linux/kernel.h>
33 29
34#include <asm/ebus.h> 30#include <asm/ebus.h>
35#include <asm/uaccess.h> 31#include <asm/uaccess.h>
@@ -980,7 +976,7 @@ static void envctrl_do_shutdown(void)
980 976
981 inprog = 1; 977 inprog = 1;
982 printk(KERN_CRIT "kenvctrld: WARNING: Shutting down the system now.\n"); 978 printk(KERN_CRIT "kenvctrld: WARNING: Shutting down the system now.\n");
983 ret = kernel_execve("/sbin/shutdown", argv, envp); 979 ret = call_usermodehelper("/sbin/shutdown", argv, envp, 0);
984 if (ret < 0) { 980 if (ret < 0) {
985 printk(KERN_CRIT "kenvctrld: WARNING: system shutdown failed!\n"); 981 printk(KERN_CRIT "kenvctrld: WARNING: system shutdown failed!\n");
986 inprog = 0; /* unlikely to succeed, but we could try again */ 982 inprog = 0; /* unlikely to succeed, but we could try again */
diff --git a/drivers/sbus/sbus.c b/drivers/sbus/sbus.c
index 935952ef88f1..98fcbb3d5560 100644
--- a/drivers/sbus/sbus.c
+++ b/drivers/sbus/sbus.c
@@ -61,11 +61,11 @@ static void __init fill_sbus_device(struct device_node *dp, struct sbus_dev *sde
61 else 61 else
62 sdev->ofdev.dev.parent = &sdev->bus->ofdev.dev; 62 sdev->ofdev.dev.parent = &sdev->bus->ofdev.dev;
63 sdev->ofdev.dev.bus = &sbus_bus_type; 63 sdev->ofdev.dev.bus = &sbus_bus_type;
64 strcpy(sdev->ofdev.dev.bus_id, dp->path_component_name); 64 sprintf(sdev->ofdev.dev.bus_id, "sbus[%08x]", dp->node);
65 65
66 if (of_device_register(&sdev->ofdev) != 0) 66 if (of_device_register(&sdev->ofdev) != 0)
67 printk(KERN_DEBUG "sbus: device registration error for %s!\n", 67 printk(KERN_DEBUG "sbus: device registration error for %s!\n",
68 sdev->ofdev.dev.bus_id); 68 dp->path_component_name);
69} 69}
70 70
71static void __init sbus_bus_ranges_init(struct device_node *dp, struct sbus_bus *sbus) 71static void __init sbus_bus_ranges_init(struct device_node *dp, struct sbus_bus *sbus)
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index 5f8c26cd66ca..b091a0fc4eb0 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -66,6 +66,9 @@
66 2.26.02.006 - Fix 9550SX pchip reset timeout. 66 2.26.02.006 - Fix 9550SX pchip reset timeout.
67 Add big endian support. 67 Add big endian support.
68 2.26.02.007 - Disable local interrupts during kmap/unmap_atomic(). 68 2.26.02.007 - Disable local interrupts during kmap/unmap_atomic().
69 2.26.02.008 - Free irq handler in __twa_shutdown().
70 Serialize reset code.
71 Add support for 9650SE controllers.
69*/ 72*/
70 73
71#include <linux/module.h> 74#include <linux/module.h>
@@ -89,7 +92,7 @@
89#include "3w-9xxx.h" 92#include "3w-9xxx.h"
90 93
91/* Globals */ 94/* Globals */
92#define TW_DRIVER_VERSION "2.26.02.007" 95#define TW_DRIVER_VERSION "2.26.02.008"
93static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT]; 96static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT];
94static unsigned int twa_device_extension_count; 97static unsigned int twa_device_extension_count;
95static int twa_major = -1; 98static int twa_major = -1;
@@ -566,9 +569,9 @@ static int twa_check_srl(TW_Device_Extension *tw_dev, int *flashed)
566 goto out; 569 goto out;
567 } 570 }
568 571
569 tw_dev->working_srl = fw_on_ctlr_srl; 572 tw_dev->tw_compat_info.working_srl = fw_on_ctlr_srl;
570 tw_dev->working_branch = fw_on_ctlr_branch; 573 tw_dev->tw_compat_info.working_branch = fw_on_ctlr_branch;
571 tw_dev->working_build = fw_on_ctlr_build; 574 tw_dev->tw_compat_info.working_build = fw_on_ctlr_build;
572 575
573 /* Try base mode compatibility */ 576 /* Try base mode compatibility */
574 if (!(init_connect_result & TW_CTLR_FW_COMPATIBLE)) { 577 if (!(init_connect_result & TW_CTLR_FW_COMPATIBLE)) {
@@ -590,10 +593,23 @@ static int twa_check_srl(TW_Device_Extension *tw_dev, int *flashed)
590 } 593 }
591 goto out; 594 goto out;
592 } 595 }
593 tw_dev->working_srl = TW_BASE_FW_SRL; 596 tw_dev->tw_compat_info.working_srl = TW_BASE_FW_SRL;
594 tw_dev->working_branch = TW_BASE_FW_BRANCH; 597 tw_dev->tw_compat_info.working_branch = TW_BASE_FW_BRANCH;
595 tw_dev->working_build = TW_BASE_FW_BUILD; 598 tw_dev->tw_compat_info.working_build = TW_BASE_FW_BUILD;
596 } 599 }
600
601 /* Load rest of compatibility struct */
602 strncpy(tw_dev->tw_compat_info.driver_version, TW_DRIVER_VERSION, strlen(TW_DRIVER_VERSION));
603 tw_dev->tw_compat_info.driver_srl_high = TW_CURRENT_DRIVER_SRL;
604 tw_dev->tw_compat_info.driver_branch_high = TW_CURRENT_DRIVER_BRANCH;
605 tw_dev->tw_compat_info.driver_build_high = TW_CURRENT_DRIVER_BUILD;
606 tw_dev->tw_compat_info.driver_srl_low = TW_BASE_FW_SRL;
607 tw_dev->tw_compat_info.driver_branch_low = TW_BASE_FW_BRANCH;
608 tw_dev->tw_compat_info.driver_build_low = TW_BASE_FW_BUILD;
609 tw_dev->tw_compat_info.fw_on_ctlr_srl = fw_on_ctlr_srl;
610 tw_dev->tw_compat_info.fw_on_ctlr_branch = fw_on_ctlr_branch;
611 tw_dev->tw_compat_info.fw_on_ctlr_build = fw_on_ctlr_build;
612
597 retval = 0; 613 retval = 0;
598out: 614out:
599 return retval; 615 return retval;
@@ -631,7 +647,7 @@ static int twa_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int
631 goto out2; 647 goto out2;
632 648
633 /* Check data buffer size */ 649 /* Check data buffer size */
634 if (driver_command.buffer_length > TW_MAX_SECTORS * 512) { 650 if (driver_command.buffer_length > TW_MAX_SECTORS * 2048) {
635 retval = TW_IOCTL_ERROR_OS_EINVAL; 651 retval = TW_IOCTL_ERROR_OS_EINVAL;
636 goto out2; 652 goto out2;
637 } 653 }
@@ -680,13 +696,6 @@ static int twa_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int
680 /* Now wait for command to complete */ 696 /* Now wait for command to complete */
681 timeout = wait_event_timeout(tw_dev->ioctl_wqueue, tw_dev->chrdev_request_id == TW_IOCTL_CHRDEV_FREE, timeout); 697 timeout = wait_event_timeout(tw_dev->ioctl_wqueue, tw_dev->chrdev_request_id == TW_IOCTL_CHRDEV_FREE, timeout);
682 698
683 /* See if we reset while waiting for the ioctl to complete */
684 if (test_bit(TW_IN_RESET, &tw_dev->flags)) {
685 clear_bit(TW_IN_RESET, &tw_dev->flags);
686 retval = TW_IOCTL_ERROR_OS_ERESTARTSYS;
687 goto out3;
688 }
689
690 /* We timed out, and didn't get an interrupt */ 699 /* We timed out, and didn't get an interrupt */
691 if (tw_dev->chrdev_request_id != TW_IOCTL_CHRDEV_FREE) { 700 if (tw_dev->chrdev_request_id != TW_IOCTL_CHRDEV_FREE) {
692 /* Now we need to reset the board */ 701 /* Now we need to reset the board */
@@ -694,11 +703,6 @@ static int twa_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int
694 tw_dev->host->host_no, TW_DRIVER, 0xc, 703 tw_dev->host->host_no, TW_DRIVER, 0xc,
695 cmd); 704 cmd);
696 retval = TW_IOCTL_ERROR_OS_EIO; 705 retval = TW_IOCTL_ERROR_OS_EIO;
697 spin_lock_irqsave(tw_dev->host->host_lock, flags);
698 tw_dev->state[request_id] = TW_S_COMPLETED;
699 twa_free_request_id(tw_dev, request_id);
700 tw_dev->posted_request_count--;
701 spin_unlock_irqrestore(tw_dev->host->host_lock, flags);
702 twa_reset_device_extension(tw_dev, 1); 706 twa_reset_device_extension(tw_dev, 1);
703 goto out3; 707 goto out3;
704 } 708 }
@@ -717,16 +721,7 @@ static int twa_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int
717 tw_ioctl->driver_command.status = 0; 721 tw_ioctl->driver_command.status = 0;
718 /* Copy compatiblity struct into ioctl data buffer */ 722 /* Copy compatiblity struct into ioctl data buffer */
719 tw_compat_info = (TW_Compatibility_Info *)tw_ioctl->data_buffer; 723 tw_compat_info = (TW_Compatibility_Info *)tw_ioctl->data_buffer;
720 strncpy(tw_compat_info->driver_version, TW_DRIVER_VERSION, strlen(TW_DRIVER_VERSION)); 724 memcpy(tw_compat_info, &tw_dev->tw_compat_info, sizeof(TW_Compatibility_Info));
721 tw_compat_info->working_srl = tw_dev->working_srl;
722 tw_compat_info->working_branch = tw_dev->working_branch;
723 tw_compat_info->working_build = tw_dev->working_build;
724 tw_compat_info->driver_srl_high = TW_CURRENT_DRIVER_SRL;
725 tw_compat_info->driver_branch_high = TW_CURRENT_DRIVER_BRANCH;
726 tw_compat_info->driver_build_high = TW_CURRENT_DRIVER_BUILD;
727 tw_compat_info->driver_srl_low = TW_BASE_FW_SRL;
728 tw_compat_info->driver_branch_low = TW_BASE_FW_BRANCH;
729 tw_compat_info->driver_build_low = TW_BASE_FW_BUILD;
730 break; 725 break;
731 case TW_IOCTL_GET_LAST_EVENT: 726 case TW_IOCTL_GET_LAST_EVENT:
732 if (tw_dev->event_queue_wrapped) { 727 if (tw_dev->event_queue_wrapped) {
@@ -895,7 +890,8 @@ static int twa_decode_bits(TW_Device_Extension *tw_dev, u32 status_reg_value)
895 } 890 }
896 891
897 if (status_reg_value & TW_STATUS_QUEUE_ERROR) { 892 if (status_reg_value & TW_STATUS_QUEUE_ERROR) {
898 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xe, "Controller Queue Error: clearing"); 893 if ((tw_dev->tw_pci_dev->device != PCI_DEVICE_ID_3WARE_9650SE) || (!test_bit(TW_IN_RESET, &tw_dev->flags)))
894 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xe, "Controller Queue Error: clearing");
899 writel(TW_CONTROL_CLEAR_QUEUE_ERROR, TW_CONTROL_REG_ADDR(tw_dev)); 895 writel(TW_CONTROL_CLEAR_QUEUE_ERROR, TW_CONTROL_REG_ADDR(tw_dev));
900 } 896 }
901 897
@@ -939,10 +935,12 @@ static int twa_empty_response_queue_large(TW_Device_Extension *tw_dev)
939 unsigned long before; 935 unsigned long before;
940 int retval = 1; 936 int retval = 1;
941 937
942 if (tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9550SX) { 938 if ((tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9550SX) ||
939 (tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9650SE)) {
943 before = jiffies; 940 before = jiffies;
944 while ((response_que_value & TW_9550SX_DRAIN_COMPLETED) != TW_9550SX_DRAIN_COMPLETED) { 941 while ((response_que_value & TW_9550SX_DRAIN_COMPLETED) != TW_9550SX_DRAIN_COMPLETED) {
945 response_que_value = readl(TW_RESPONSE_QUEUE_REG_ADDR_LARGE(tw_dev)); 942 response_que_value = readl(TW_RESPONSE_QUEUE_REG_ADDR_LARGE(tw_dev));
943 msleep(1);
946 if (time_after(jiffies, before + HZ * 30)) 944 if (time_after(jiffies, before + HZ * 30))
947 goto out; 945 goto out;
948 } 946 }
@@ -1214,6 +1212,10 @@ static irqreturn_t twa_interrupt(int irq, void *dev_instance)
1214 1212
1215 handled = 1; 1213 handled = 1;
1216 1214
1215 /* If we are resetting, bail */
1216 if (test_bit(TW_IN_RESET, &tw_dev->flags))
1217 goto twa_interrupt_bail;
1218
1217 /* Check controller for errors */ 1219 /* Check controller for errors */
1218 if (twa_check_bits(status_reg_value)) { 1220 if (twa_check_bits(status_reg_value)) {
1219 if (twa_decode_bits(tw_dev, status_reg_value)) { 1221 if (twa_decode_bits(tw_dev, status_reg_value)) {
@@ -1355,8 +1357,8 @@ static void twa_load_sgl(TW_Command_Full *full_command_packet, int request_id, d
1355 1357
1356 if (TW_OP_OUT(full_command_packet->command.newcommand.opcode__reserved) == TW_OP_EXECUTE_SCSI) { 1358 if (TW_OP_OUT(full_command_packet->command.newcommand.opcode__reserved) == TW_OP_EXECUTE_SCSI) {
1357 newcommand = &full_command_packet->command.newcommand; 1359 newcommand = &full_command_packet->command.newcommand;
1358 newcommand->request_id__lunl = 1360 newcommand->request_id__lunl =
1359 TW_REQ_LUN_IN(TW_LUN_OUT(newcommand->request_id__lunl), request_id); 1361 cpu_to_le16(TW_REQ_LUN_IN(TW_LUN_OUT(newcommand->request_id__lunl), request_id));
1360 newcommand->sg_list[0].address = TW_CPU_TO_SGL(dma_handle + sizeof(TW_Ioctl_Buf_Apache) - 1); 1362 newcommand->sg_list[0].address = TW_CPU_TO_SGL(dma_handle + sizeof(TW_Ioctl_Buf_Apache) - 1);
1361 newcommand->sg_list[0].length = cpu_to_le32(length); 1363 newcommand->sg_list[0].length = cpu_to_le32(length);
1362 newcommand->sgl_entries__lunh = 1364 newcommand->sgl_entries__lunh =
@@ -1531,6 +1533,13 @@ static int twa_post_command_packet(TW_Device_Extension *tw_dev, int request_id,
1531 int retval = 1; 1533 int retval = 1;
1532 1534
1533 command_que_value = tw_dev->command_packet_phys[request_id]; 1535 command_que_value = tw_dev->command_packet_phys[request_id];
1536
1537 /* For 9650SE write low 4 bytes first */
1538 if (tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9650SE) {
1539 command_que_value += TW_COMMAND_OFFSET;
1540 writel((u32)command_que_value, TW_COMMAND_QUEUE_REG_ADDR_LARGE(tw_dev));
1541 }
1542
1534 status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev)); 1543 status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev));
1535 1544
1536 if (twa_check_bits(status_reg_value)) 1545 if (twa_check_bits(status_reg_value))
@@ -1557,13 +1566,17 @@ static int twa_post_command_packet(TW_Device_Extension *tw_dev, int request_id,
1557 TW_UNMASK_COMMAND_INTERRUPT(tw_dev); 1566 TW_UNMASK_COMMAND_INTERRUPT(tw_dev);
1558 goto out; 1567 goto out;
1559 } else { 1568 } else {
1560 /* We successfully posted the command packet */ 1569 if (tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9650SE) {
1561 if (sizeof(dma_addr_t) > 4) { 1570 /* Now write upper 4 bytes */
1562 command_que_value += TW_COMMAND_OFFSET; 1571 writel((u32)((u64)command_que_value >> 32), TW_COMMAND_QUEUE_REG_ADDR_LARGE(tw_dev) + 0x4);
1563 writel((u32)command_que_value, TW_COMMAND_QUEUE_REG_ADDR(tw_dev));
1564 writel((u32)((u64)command_que_value >> 32), TW_COMMAND_QUEUE_REG_ADDR(tw_dev) + 0x4);
1565 } else { 1572 } else {
1566 writel(TW_COMMAND_OFFSET + command_que_value, TW_COMMAND_QUEUE_REG_ADDR(tw_dev)); 1573 if (sizeof(dma_addr_t) > 4) {
1574 command_que_value += TW_COMMAND_OFFSET;
1575 writel((u32)command_que_value, TW_COMMAND_QUEUE_REG_ADDR(tw_dev));
1576 writel((u32)((u64)command_que_value >> 32), TW_COMMAND_QUEUE_REG_ADDR(tw_dev) + 0x4);
1577 } else {
1578 writel(TW_COMMAND_OFFSET + command_que_value, TW_COMMAND_QUEUE_REG_ADDR(tw_dev));
1579 }
1567 } 1580 }
1568 tw_dev->state[request_id] = TW_S_POSTED; 1581 tw_dev->state[request_id] = TW_S_POSTED;
1569 tw_dev->posted_request_count++; 1582 tw_dev->posted_request_count++;
@@ -1620,14 +1633,9 @@ static int twa_reset_device_extension(TW_Device_Extension *tw_dev, int ioctl_res
1620 goto out; 1633 goto out;
1621 1634
1622 TW_ENABLE_AND_CLEAR_INTERRUPTS(tw_dev); 1635 TW_ENABLE_AND_CLEAR_INTERRUPTS(tw_dev);
1636 clear_bit(TW_IN_RESET, &tw_dev->flags);
1637 tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE;
1623 1638
1624 /* Wake up any ioctl that was pending before the reset */
1625 if ((tw_dev->chrdev_request_id == TW_IOCTL_CHRDEV_FREE) || (ioctl_reset)) {
1626 clear_bit(TW_IN_RESET, &tw_dev->flags);
1627 } else {
1628 tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE;
1629 wake_up(&tw_dev->ioctl_wqueue);
1630 }
1631 retval = 0; 1639 retval = 0;
1632out: 1640out:
1633 return retval; 1641 return retval;
@@ -1736,6 +1744,9 @@ static int twa_scsi_eh_reset(struct scsi_cmnd *SCpnt)
1736 "WARNING: (0x%02X:0x%04X): Command (0x%x) timed out, resetting card.\n", 1744 "WARNING: (0x%02X:0x%04X): Command (0x%x) timed out, resetting card.\n",
1737 TW_DRIVER, 0x2c, SCpnt->cmnd[0]); 1745 TW_DRIVER, 0x2c, SCpnt->cmnd[0]);
1738 1746
1747 /* Make sure we are not issuing an ioctl or resetting from ioctl */
1748 mutex_lock(&tw_dev->ioctl_lock);
1749
1739 /* Now reset the card and some of the device extension data */ 1750 /* Now reset the card and some of the device extension data */
1740 if (twa_reset_device_extension(tw_dev, 0)) { 1751 if (twa_reset_device_extension(tw_dev, 0)) {
1741 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x2b, "Controller reset failed during scsi host reset"); 1752 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x2b, "Controller reset failed during scsi host reset");
@@ -1744,6 +1755,7 @@ static int twa_scsi_eh_reset(struct scsi_cmnd *SCpnt)
1744 1755
1745 retval = SUCCESS; 1756 retval = SUCCESS;
1746out: 1757out:
1758 mutex_unlock(&tw_dev->ioctl_lock);
1747 return retval; 1759 return retval;
1748} /* End twa_scsi_eh_reset() */ 1760} /* End twa_scsi_eh_reset() */
1749 1761
@@ -1753,8 +1765,14 @@ static int twa_scsi_queue(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd
1753 int request_id, retval; 1765 int request_id, retval;
1754 TW_Device_Extension *tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata; 1766 TW_Device_Extension *tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata;
1755 1767
1768 /* If we are resetting due to timed out ioctl, report as busy */
1769 if (test_bit(TW_IN_RESET, &tw_dev->flags)) {
1770 retval = SCSI_MLQUEUE_HOST_BUSY;
1771 goto out;
1772 }
1773
1756 /* Check if this FW supports luns */ 1774 /* Check if this FW supports luns */
1757 if ((SCpnt->device->lun != 0) && (tw_dev->working_srl < TW_FW_SRL_LUNS_SUPPORTED)) { 1775 if ((SCpnt->device->lun != 0) && (tw_dev->tw_compat_info.working_srl < TW_FW_SRL_LUNS_SUPPORTED)) {
1758 SCpnt->result = (DID_BAD_TARGET << 16); 1776 SCpnt->result = (DID_BAD_TARGET << 16);
1759 done(SCpnt); 1777 done(SCpnt);
1760 retval = 0; 1778 retval = 0;
@@ -1960,6 +1978,9 @@ static void __twa_shutdown(TW_Device_Extension *tw_dev)
1960 /* Disable interrupts */ 1978 /* Disable interrupts */
1961 TW_DISABLE_INTERRUPTS(tw_dev); 1979 TW_DISABLE_INTERRUPTS(tw_dev);
1962 1980
1981 /* Free up the IRQ */
1982 free_irq(tw_dev->tw_pci_dev->irq, tw_dev);
1983
1963 printk(KERN_WARNING "3w-9xxx: Shutting down host %d.\n", tw_dev->host->host_no); 1984 printk(KERN_WARNING "3w-9xxx: Shutting down host %d.\n", tw_dev->host->host_no);
1964 1985
1965 /* Tell the card we are shutting down */ 1986 /* Tell the card we are shutting down */
@@ -2091,21 +2112,25 @@ static int __devinit twa_probe(struct pci_dev *pdev, const struct pci_device_id
2091 2112
2092 /* Initialize the card */ 2113 /* Initialize the card */
2093 if (twa_reset_sequence(tw_dev, 0)) 2114 if (twa_reset_sequence(tw_dev, 0))
2094 goto out_release_mem_region; 2115 goto out_iounmap;
2095 2116
2096 /* Set host specific parameters */ 2117 /* Set host specific parameters */
2097 host->max_id = TW_MAX_UNITS; 2118 if (pdev->device == PCI_DEVICE_ID_3WARE_9650SE)
2119 host->max_id = TW_MAX_UNITS_9650SE;
2120 else
2121 host->max_id = TW_MAX_UNITS;
2122
2098 host->max_cmd_len = TW_MAX_CDB_LEN; 2123 host->max_cmd_len = TW_MAX_CDB_LEN;
2099 2124
2100 /* Channels aren't supported by adapter */ 2125 /* Channels aren't supported by adapter */
2101 host->max_lun = TW_MAX_LUNS(tw_dev->working_srl); 2126 host->max_lun = TW_MAX_LUNS(tw_dev->tw_compat_info.working_srl);
2102 host->max_channel = 0; 2127 host->max_channel = 0;
2103 2128
2104 /* Register the card with the kernel SCSI layer */ 2129 /* Register the card with the kernel SCSI layer */
2105 retval = scsi_add_host(host, &pdev->dev); 2130 retval = scsi_add_host(host, &pdev->dev);
2106 if (retval) { 2131 if (retval) {
2107 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x27, "scsi add host failed"); 2132 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x27, "scsi add host failed");
2108 goto out_release_mem_region; 2133 goto out_iounmap;
2109 } 2134 }
2110 2135
2111 pci_set_drvdata(pdev, host); 2136 pci_set_drvdata(pdev, host);
@@ -2145,6 +2170,8 @@ static int __devinit twa_probe(struct pci_dev *pdev, const struct pci_device_id
2145 2170
2146out_remove_host: 2171out_remove_host:
2147 scsi_remove_host(host); 2172 scsi_remove_host(host);
2173out_iounmap:
2174 iounmap(tw_dev->base_addr);
2148out_release_mem_region: 2175out_release_mem_region:
2149 pci_release_regions(pdev); 2176 pci_release_regions(pdev);
2150out_free_device_extension: 2177out_free_device_extension:
@@ -2170,12 +2197,12 @@ static void twa_remove(struct pci_dev *pdev)
2170 twa_major = -1; 2197 twa_major = -1;
2171 } 2198 }
2172 2199
2173 /* Free up the IRQ */
2174 free_irq(tw_dev->tw_pci_dev->irq, tw_dev);
2175
2176 /* Shutdown the card */ 2200 /* Shutdown the card */
2177 __twa_shutdown(tw_dev); 2201 __twa_shutdown(tw_dev);
2178 2202
2203 /* Free IO remapping */
2204 iounmap(tw_dev->base_addr);
2205
2179 /* Free up the mem region */ 2206 /* Free up the mem region */
2180 pci_release_regions(pdev); 2207 pci_release_regions(pdev);
2181 2208
@@ -2193,6 +2220,8 @@ static struct pci_device_id twa_pci_tbl[] __devinitdata = {
2193 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 2220 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
2194 { PCI_VENDOR_ID_3WARE, PCI_DEVICE_ID_3WARE_9550SX, 2221 { PCI_VENDOR_ID_3WARE, PCI_DEVICE_ID_3WARE_9550SX,
2195 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 2222 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
2223 { PCI_VENDOR_ID_3WARE, PCI_DEVICE_ID_3WARE_9650SE,
2224 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
2196 { } 2225 { }
2197}; 2226};
2198MODULE_DEVICE_TABLE(pci, twa_pci_tbl); 2227MODULE_DEVICE_TABLE(pci, twa_pci_tbl);
diff --git a/drivers/scsi/3w-9xxx.h b/drivers/scsi/3w-9xxx.h
index e5685be96f45..7901517d4513 100644
--- a/drivers/scsi/3w-9xxx.h
+++ b/drivers/scsi/3w-9xxx.h
@@ -289,7 +289,6 @@ static twa_message_type twa_error_table[] = {
289#define TW_STATUS_VALID_INTERRUPT 0x00DF0000 289#define TW_STATUS_VALID_INTERRUPT 0x00DF0000
290 290
291/* PCI related defines */ 291/* PCI related defines */
292#define TW_NUMDEVICES 1
293#define TW_PCI_CLEAR_PARITY_ERRORS 0xc100 292#define TW_PCI_CLEAR_PARITY_ERRORS 0xc100
294#define TW_PCI_CLEAR_PCI_ABORT 0x2000 293#define TW_PCI_CLEAR_PCI_ABORT 0x2000
295 294
@@ -335,6 +334,7 @@ static twa_message_type twa_error_table[] = {
335#define TW_ALIGNMENT_9000 4 /* 4 bytes */ 334#define TW_ALIGNMENT_9000 4 /* 4 bytes */
336#define TW_ALIGNMENT_9000_SGL 0x3 335#define TW_ALIGNMENT_9000_SGL 0x3
337#define TW_MAX_UNITS 16 336#define TW_MAX_UNITS 16
337#define TW_MAX_UNITS_9650SE 32
338#define TW_INIT_MESSAGE_CREDITS 0x100 338#define TW_INIT_MESSAGE_CREDITS 0x100
339#define TW_INIT_COMMAND_PACKET_SIZE 0x3 339#define TW_INIT_COMMAND_PACKET_SIZE 0x3
340#define TW_INIT_COMMAND_PACKET_SIZE_EXTENDED 0x6 340#define TW_INIT_COMMAND_PACKET_SIZE_EXTENDED 0x6
@@ -354,7 +354,6 @@ static twa_message_type twa_error_table[] = {
354#define TW_MAX_RESPONSE_DRAIN 256 354#define TW_MAX_RESPONSE_DRAIN 256
355#define TW_MAX_AEN_DRAIN 40 355#define TW_MAX_AEN_DRAIN 40
356#define TW_IN_RESET 2 356#define TW_IN_RESET 2
357#define TW_IN_CHRDEV_IOCTL 3
358#define TW_IN_ATTENTION_LOOP 4 357#define TW_IN_ATTENTION_LOOP 4
359#define TW_MAX_SECTORS 256 358#define TW_MAX_SECTORS 256
360#define TW_AEN_WAIT_TIME 1000 359#define TW_AEN_WAIT_TIME 1000
@@ -417,6 +416,9 @@ static twa_message_type twa_error_table[] = {
417#ifndef PCI_DEVICE_ID_3WARE_9550SX 416#ifndef PCI_DEVICE_ID_3WARE_9550SX
418#define PCI_DEVICE_ID_3WARE_9550SX 0x1003 417#define PCI_DEVICE_ID_3WARE_9550SX 0x1003
419#endif 418#endif
419#ifndef PCI_DEVICE_ID_3WARE_9650SE
420#define PCI_DEVICE_ID_3WARE_9650SE 0x1004
421#endif
420 422
421/* Bitmask macros to eliminate bitfields */ 423/* Bitmask macros to eliminate bitfields */
422 424
@@ -442,6 +444,7 @@ static twa_message_type twa_error_table[] = {
442#define TW_CONTROL_REG_ADDR(x) (x->base_addr) 444#define TW_CONTROL_REG_ADDR(x) (x->base_addr)
443#define TW_STATUS_REG_ADDR(x) ((unsigned char __iomem *)x->base_addr + 0x4) 445#define TW_STATUS_REG_ADDR(x) ((unsigned char __iomem *)x->base_addr + 0x4)
444#define TW_COMMAND_QUEUE_REG_ADDR(x) (sizeof(dma_addr_t) > 4 ? ((unsigned char __iomem *)x->base_addr + 0x20) : ((unsigned char __iomem *)x->base_addr + 0x8)) 446#define TW_COMMAND_QUEUE_REG_ADDR(x) (sizeof(dma_addr_t) > 4 ? ((unsigned char __iomem *)x->base_addr + 0x20) : ((unsigned char __iomem *)x->base_addr + 0x8))
447#define TW_COMMAND_QUEUE_REG_ADDR_LARGE(x) ((unsigned char __iomem *)x->base_addr + 0x20)
445#define TW_RESPONSE_QUEUE_REG_ADDR(x) ((unsigned char __iomem *)x->base_addr + 0xC) 448#define TW_RESPONSE_QUEUE_REG_ADDR(x) ((unsigned char __iomem *)x->base_addr + 0xC)
446#define TW_RESPONSE_QUEUE_REG_ADDR_LARGE(x) ((unsigned char __iomem *)x->base_addr + 0x30) 449#define TW_RESPONSE_QUEUE_REG_ADDR_LARGE(x) ((unsigned char __iomem *)x->base_addr + 0x30)
447#define TW_CLEAR_ALL_INTERRUPTS(x) (writel(TW_STATUS_VALID_INTERRUPT, TW_CONTROL_REG_ADDR(x))) 450#define TW_CLEAR_ALL_INTERRUPTS(x) (writel(TW_STATUS_VALID_INTERRUPT, TW_CONTROL_REG_ADDR(x)))
@@ -626,6 +629,9 @@ typedef struct TAG_TW_Compatibility_Info
626 unsigned short driver_srl_low; 629 unsigned short driver_srl_low;
627 unsigned short driver_branch_low; 630 unsigned short driver_branch_low;
628 unsigned short driver_build_low; 631 unsigned short driver_build_low;
632 unsigned short fw_on_ctlr_srl;
633 unsigned short fw_on_ctlr_branch;
634 unsigned short fw_on_ctlr_build;
629} TW_Compatibility_Info; 635} TW_Compatibility_Info;
630 636
631#pragma pack() 637#pragma pack()
@@ -668,9 +674,7 @@ typedef struct TAG_TW_Device_Extension {
668 wait_queue_head_t ioctl_wqueue; 674 wait_queue_head_t ioctl_wqueue;
669 struct mutex ioctl_lock; 675 struct mutex ioctl_lock;
670 char aen_clobber; 676 char aen_clobber;
671 unsigned short working_srl; 677 TW_Compatibility_Info tw_compat_info;
672 unsigned short working_branch;
673 unsigned short working_build;
674} TW_Device_Extension; 678} TW_Device_Extension;
675 679
676#endif /* _3W_9XXX_H */ 680#endif /* _3W_9XXX_H */
diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
index 689dc4cc789c..3075204915c8 100644
--- a/drivers/scsi/BusLogic.c
+++ b/drivers/scsi/BusLogic.c
@@ -3600,5 +3600,16 @@ static void __exit BusLogic_exit(void)
3600 3600
3601__setup("BusLogic=", BusLogic_Setup); 3601__setup("BusLogic=", BusLogic_Setup);
3602 3602
3603static struct pci_device_id BusLogic_pci_tbl[] __devinitdata = {
3604 { PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER,
3605 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
3606 { PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC,
3607 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
3608 { PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT,
3609 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
3610 { }
3611};
3612MODULE_DEVICE_TABLE(pci, BusLogic_pci_tbl);
3613
3603module_init(BusLogic_init); 3614module_init(BusLogic_init);
3604module_exit(BusLogic_exit); 3615module_exit(BusLogic_exit);
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index a0d1cee0be77..306f46b85a55 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -238,7 +238,7 @@
238#include <linux/module.h> 238#include <linux/module.h>
239#include <linux/sched.h> 239#include <linux/sched.h>
240#include <asm/irq.h> 240#include <asm/irq.h>
241#include <asm/io.h> 241#include <linux/io.h>
242#include <linux/blkdev.h> 242#include <linux/blkdev.h>
243#include <asm/system.h> 243#include <asm/system.h>
244#include <linux/errno.h> 244#include <linux/errno.h>
diff --git a/drivers/scsi/aic7xxx/aic79xx.h b/drivers/scsi/aic7xxx/aic79xx.h
index df3346b5caf8..170a4344cbb2 100644
--- a/drivers/scsi/aic7xxx/aic79xx.h
+++ b/drivers/scsi/aic7xxx/aic79xx.h
@@ -53,14 +53,6 @@ struct ahd_platform_data;
53struct scb_platform_data; 53struct scb_platform_data;
54 54
55/****************************** Useful Macros *********************************/ 55/****************************** Useful Macros *********************************/
56#ifndef MAX
57#define MAX(a,b) (((a) > (b)) ? (a) : (b))
58#endif
59
60#ifndef MIN
61#define MIN(a,b) (((a) < (b)) ? (a) : (b))
62#endif
63
64#ifndef TRUE 56#ifndef TRUE
65#define TRUE 1 57#define TRUE 1
66#endif 58#endif
@@ -972,8 +964,6 @@ int ahd_read_seeprom(struct ahd_softc *ahd, uint16_t *buf,
972 964
973int ahd_write_seeprom(struct ahd_softc *ahd, uint16_t *buf, 965int ahd_write_seeprom(struct ahd_softc *ahd, uint16_t *buf,
974 u_int start_addr, u_int count); 966 u_int start_addr, u_int count);
975int ahd_wait_seeprom(struct ahd_softc *ahd);
976int ahd_verify_vpd_cksum(struct vpd_config *vpd);
977int ahd_verify_cksum(struct seeprom_config *sc); 967int ahd_verify_cksum(struct seeprom_config *sc);
978int ahd_acquire_seeprom(struct ahd_softc *ahd); 968int ahd_acquire_seeprom(struct ahd_softc *ahd);
979void ahd_release_seeprom(struct ahd_softc *ahd); 969void ahd_release_seeprom(struct ahd_softc *ahd);
@@ -1320,8 +1310,6 @@ struct ahd_pci_identity {
1320 char *name; 1310 char *name;
1321 ahd_device_setup_t *setup; 1311 ahd_device_setup_t *setup;
1322}; 1312};
1323extern struct ahd_pci_identity ahd_pci_ident_table [];
1324extern const u_int ahd_num_pci_devs;
1325 1313
1326/***************************** VL/EISA Declarations ***************************/ 1314/***************************** VL/EISA Declarations ***************************/
1327struct aic7770_identity { 1315struct aic7770_identity {
@@ -1339,15 +1327,6 @@ extern const int ahd_num_aic7770_devs;
1339/*************************** Function Declarations ****************************/ 1327/*************************** Function Declarations ****************************/
1340/******************************************************************************/ 1328/******************************************************************************/
1341void ahd_reset_cmds_pending(struct ahd_softc *ahd); 1329void ahd_reset_cmds_pending(struct ahd_softc *ahd);
1342u_int ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl);
1343void ahd_busy_tcl(struct ahd_softc *ahd,
1344 u_int tcl, u_int busyid);
1345static __inline void ahd_unbusy_tcl(struct ahd_softc *ahd, u_int tcl);
1346static __inline void
1347ahd_unbusy_tcl(struct ahd_softc *ahd, u_int tcl)
1348{
1349 ahd_busy_tcl(ahd, tcl, SCB_LIST_NULL);
1350}
1351 1330
1352/***************************** PCI Front End *********************************/ 1331/***************************** PCI Front End *********************************/
1353struct ahd_pci_identity *ahd_find_pci_device(ahd_dev_softc_t); 1332struct ahd_pci_identity *ahd_find_pci_device(ahd_dev_softc_t);
@@ -1356,7 +1335,6 @@ int ahd_pci_config(struct ahd_softc *,
1356int ahd_pci_test_register_access(struct ahd_softc *); 1335int ahd_pci_test_register_access(struct ahd_softc *);
1357 1336
1358/************************** SCB and SCB queue management **********************/ 1337/************************** SCB and SCB queue management **********************/
1359int ahd_probe_scbs(struct ahd_softc *);
1360void ahd_qinfifo_requeue_tail(struct ahd_softc *ahd, 1338void ahd_qinfifo_requeue_tail(struct ahd_softc *ahd,
1361 struct scb *scb); 1339 struct scb *scb);
1362int ahd_match_scb(struct ahd_softc *ahd, struct scb *scb, 1340int ahd_match_scb(struct ahd_softc *ahd, struct scb *scb,
@@ -1374,33 +1352,20 @@ int ahd_parse_vpddata(struct ahd_softc *ahd,
1374int ahd_parse_cfgdata(struct ahd_softc *ahd, 1352int ahd_parse_cfgdata(struct ahd_softc *ahd,
1375 struct seeprom_config *sc); 1353 struct seeprom_config *sc);
1376void ahd_intr_enable(struct ahd_softc *ahd, int enable); 1354void ahd_intr_enable(struct ahd_softc *ahd, int enable);
1377void ahd_update_coalescing_values(struct ahd_softc *ahd,
1378 u_int timer,
1379 u_int maxcmds,
1380 u_int mincmds);
1381void ahd_enable_coalescing(struct ahd_softc *ahd,
1382 int enable);
1383void ahd_pause_and_flushwork(struct ahd_softc *ahd); 1355void ahd_pause_and_flushwork(struct ahd_softc *ahd);
1384int ahd_suspend(struct ahd_softc *ahd); 1356int ahd_suspend(struct ahd_softc *ahd);
1385int ahd_resume(struct ahd_softc *ahd);
1386void ahd_set_unit(struct ahd_softc *, int); 1357void ahd_set_unit(struct ahd_softc *, int);
1387void ahd_set_name(struct ahd_softc *, char *); 1358void ahd_set_name(struct ahd_softc *, char *);
1388struct scb *ahd_get_scb(struct ahd_softc *ahd, u_int col_idx); 1359struct scb *ahd_get_scb(struct ahd_softc *ahd, u_int col_idx);
1389void ahd_free_scb(struct ahd_softc *ahd, struct scb *scb); 1360void ahd_free_scb(struct ahd_softc *ahd, struct scb *scb);
1390void ahd_alloc_scbs(struct ahd_softc *ahd);
1391void ahd_free(struct ahd_softc *ahd); 1361void ahd_free(struct ahd_softc *ahd);
1392int ahd_reset(struct ahd_softc *ahd, int reinit); 1362int ahd_reset(struct ahd_softc *ahd, int reinit);
1393void ahd_shutdown(void *arg);
1394int ahd_write_flexport(struct ahd_softc *ahd, 1363int ahd_write_flexport(struct ahd_softc *ahd,
1395 u_int addr, u_int value); 1364 u_int addr, u_int value);
1396int ahd_read_flexport(struct ahd_softc *ahd, u_int addr, 1365int ahd_read_flexport(struct ahd_softc *ahd, u_int addr,
1397 uint8_t *value); 1366 uint8_t *value);
1398int ahd_wait_flexport(struct ahd_softc *ahd);
1399 1367
1400/*************************** Interrupt Services *******************************/ 1368/*************************** Interrupt Services *******************************/
1401void ahd_pci_intr(struct ahd_softc *ahd);
1402void ahd_clear_intstat(struct ahd_softc *ahd);
1403void ahd_flush_qoutfifo(struct ahd_softc *ahd);
1404void ahd_run_qoutfifo(struct ahd_softc *ahd); 1369void ahd_run_qoutfifo(struct ahd_softc *ahd);
1405#ifdef AHD_TARGET_MODE 1370#ifdef AHD_TARGET_MODE
1406void ahd_run_tqinfifo(struct ahd_softc *ahd, int paused); 1371void ahd_run_tqinfifo(struct ahd_softc *ahd, int paused);
@@ -1409,7 +1374,6 @@ void ahd_handle_hwerrint(struct ahd_softc *ahd);
1409void ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat); 1374void ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat);
1410void ahd_handle_scsiint(struct ahd_softc *ahd, 1375void ahd_handle_scsiint(struct ahd_softc *ahd,
1411 u_int intstat); 1376 u_int intstat);
1412void ahd_clear_critical_section(struct ahd_softc *ahd);
1413 1377
1414/***************************** Error Recovery *********************************/ 1378/***************************** Error Recovery *********************************/
1415typedef enum { 1379typedef enum {
@@ -1426,23 +1390,9 @@ int ahd_search_disc_list(struct ahd_softc *ahd, int target,
1426 char channel, int lun, u_int tag, 1390 char channel, int lun, u_int tag,
1427 int stop_on_first, int remove, 1391 int stop_on_first, int remove,
1428 int save_state); 1392 int save_state);
1429void ahd_freeze_devq(struct ahd_softc *ahd, struct scb *scb);
1430int ahd_reset_channel(struct ahd_softc *ahd, char channel, 1393int ahd_reset_channel(struct ahd_softc *ahd, char channel,
1431 int initiate_reset); 1394 int initiate_reset);
1432int ahd_abort_scbs(struct ahd_softc *ahd, int target,
1433 char channel, int lun, u_int tag,
1434 role_t role, uint32_t status);
1435void ahd_restart(struct ahd_softc *ahd);
1436void ahd_clear_fifo(struct ahd_softc *ahd, u_int fifo);
1437void ahd_handle_scb_status(struct ahd_softc *ahd,
1438 struct scb *scb);
1439void ahd_handle_scsi_status(struct ahd_softc *ahd,
1440 struct scb *scb);
1441void ahd_calc_residual(struct ahd_softc *ahd,
1442 struct scb *scb);
1443/*************************** Utility Functions ********************************/ 1395/*************************** Utility Functions ********************************/
1444struct ahd_phase_table_entry*
1445 ahd_lookup_phase_entry(int phase);
1446void ahd_compile_devinfo(struct ahd_devinfo *devinfo, 1396void ahd_compile_devinfo(struct ahd_devinfo *devinfo,
1447 u_int our_id, u_int target, 1397 u_int our_id, u_int target,
1448 u_int lun, char channel, 1398 u_int lun, char channel,
@@ -1450,14 +1400,6 @@ void ahd_compile_devinfo(struct ahd_devinfo *devinfo,
1450/************************** Transfer Negotiation ******************************/ 1400/************************** Transfer Negotiation ******************************/
1451void ahd_find_syncrate(struct ahd_softc *ahd, u_int *period, 1401void ahd_find_syncrate(struct ahd_softc *ahd, u_int *period,
1452 u_int *ppr_options, u_int maxsync); 1402 u_int *ppr_options, u_int maxsync);
1453void ahd_validate_offset(struct ahd_softc *ahd,
1454 struct ahd_initiator_tinfo *tinfo,
1455 u_int period, u_int *offset,
1456 int wide, role_t role);
1457void ahd_validate_width(struct ahd_softc *ahd,
1458 struct ahd_initiator_tinfo *tinfo,
1459 u_int *bus_width,
1460 role_t role);
1461/* 1403/*
1462 * Negotiation types. These are used to qualify if we should renegotiate 1404 * Negotiation types. These are used to qualify if we should renegotiate
1463 * even if our goal and current transport parameters are identical. 1405 * even if our goal and current transport parameters are identical.
@@ -1486,11 +1428,6 @@ typedef enum {
1486 AHD_QUEUE_TAGGED 1428 AHD_QUEUE_TAGGED
1487} ahd_queue_alg; 1429} ahd_queue_alg;
1488 1430
1489void ahd_set_tags(struct ahd_softc *ahd,
1490 struct scsi_cmnd *cmd,
1491 struct ahd_devinfo *devinfo,
1492 ahd_queue_alg alg);
1493
1494/**************************** Target Mode *************************************/ 1431/**************************** Target Mode *************************************/
1495#ifdef AHD_TARGET_MODE 1432#ifdef AHD_TARGET_MODE
1496void ahd_send_lstate_events(struct ahd_softc *, 1433void ahd_send_lstate_events(struct ahd_softc *,
@@ -1528,10 +1465,8 @@ extern uint32_t ahd_debug;
1528#define AHD_SHOW_INT_COALESCING 0x10000 1465#define AHD_SHOW_INT_COALESCING 0x10000
1529#define AHD_DEBUG_SEQUENCER 0x20000 1466#define AHD_DEBUG_SEQUENCER 0x20000
1530#endif 1467#endif
1531void ahd_print_scb(struct scb *scb);
1532void ahd_print_devinfo(struct ahd_softc *ahd, 1468void ahd_print_devinfo(struct ahd_softc *ahd,
1533 struct ahd_devinfo *devinfo); 1469 struct ahd_devinfo *devinfo);
1534void ahd_dump_sglist(struct scb *scb);
1535void ahd_dump_card_state(struct ahd_softc *ahd); 1470void ahd_dump_card_state(struct ahd_softc *ahd);
1536int ahd_print_register(ahd_reg_parse_entry_t *table, 1471int ahd_print_register(ahd_reg_parse_entry_t *table,
1537 u_int num_entries, 1472 u_int num_entries,
@@ -1540,5 +1475,4 @@ int ahd_print_register(ahd_reg_parse_entry_t *table,
1540 u_int value, 1475 u_int value,
1541 u_int *cur_column, 1476 u_int *cur_column,
1542 u_int wrap_point); 1477 u_int wrap_point);
1543void ahd_dump_scbs(struct ahd_softc *ahd);
1544#endif /* _AIC79XX_H_ */ 1478#endif /* _AIC79XX_H_ */
diff --git a/drivers/scsi/aic7xxx/aic79xx_core.c b/drivers/scsi/aic7xxx/aic79xx_core.c
index 653818d2f802..07a86a30f676 100644
--- a/drivers/scsi/aic7xxx/aic79xx_core.c
+++ b/drivers/scsi/aic7xxx/aic79xx_core.c
@@ -52,7 +52,7 @@
52 52
53 53
54/***************************** Lookup Tables **********************************/ 54/***************************** Lookup Tables **********************************/
55char *ahd_chip_names[] = 55static char *ahd_chip_names[] =
56{ 56{
57 "NONE", 57 "NONE",
58 "aic7901", 58 "aic7901",
@@ -237,10 +237,33 @@ static int ahd_handle_target_cmd(struct ahd_softc *ahd,
237 struct target_cmd *cmd); 237 struct target_cmd *cmd);
238#endif 238#endif
239 239
240static int ahd_abort_scbs(struct ahd_softc *ahd, int target,
241 char channel, int lun, u_int tag,
242 role_t role, uint32_t status);
243static void ahd_alloc_scbs(struct ahd_softc *ahd);
244static void ahd_busy_tcl(struct ahd_softc *ahd, u_int tcl,
245 u_int scbid);
246static void ahd_calc_residual(struct ahd_softc *ahd,
247 struct scb *scb);
248static void ahd_clear_critical_section(struct ahd_softc *ahd);
249static void ahd_clear_intstat(struct ahd_softc *ahd);
250static void ahd_enable_coalescing(struct ahd_softc *ahd,
251 int enable);
252static u_int ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl);
253static void ahd_freeze_devq(struct ahd_softc *ahd,
254 struct scb *scb);
255static void ahd_handle_scb_status(struct ahd_softc *ahd,
256 struct scb *scb);
257static struct ahd_phase_table_entry* ahd_lookup_phase_entry(int phase);
258static void ahd_shutdown(void *arg);
259static void ahd_update_coalescing_values(struct ahd_softc *ahd,
260 u_int timer,
261 u_int maxcmds,
262 u_int mincmds);
263static int ahd_verify_vpd_cksum(struct vpd_config *vpd);
264static int ahd_wait_seeprom(struct ahd_softc *ahd);
265
240/******************************** Private Inlines *****************************/ 266/******************************** Private Inlines *****************************/
241static __inline void ahd_assert_atn(struct ahd_softc *ahd);
242static __inline int ahd_currently_packetized(struct ahd_softc *ahd);
243static __inline int ahd_set_active_fifo(struct ahd_softc *ahd);
244 267
245static __inline void 268static __inline void
246ahd_assert_atn(struct ahd_softc *ahd) 269ahd_assert_atn(struct ahd_softc *ahd)
@@ -294,11 +317,44 @@ ahd_set_active_fifo(struct ahd_softc *ahd)
294 } 317 }
295} 318}
296 319
320static __inline void
321ahd_unbusy_tcl(struct ahd_softc *ahd, u_int tcl)
322{
323 ahd_busy_tcl(ahd, tcl, SCB_LIST_NULL);
324}
325
326/*
327 * Determine whether the sequencer reported a residual
328 * for this SCB/transaction.
329 */
330static __inline void
331ahd_update_residual(struct ahd_softc *ahd, struct scb *scb)
332{
333 uint32_t sgptr;
334
335 sgptr = ahd_le32toh(scb->hscb->sgptr);
336 if ((sgptr & SG_STATUS_VALID) != 0)
337 ahd_calc_residual(ahd, scb);
338}
339
340static __inline void
341ahd_complete_scb(struct ahd_softc *ahd, struct scb *scb)
342{
343 uint32_t sgptr;
344
345 sgptr = ahd_le32toh(scb->hscb->sgptr);
346 if ((sgptr & SG_STATUS_VALID) != 0)
347 ahd_handle_scb_status(ahd, scb);
348 else
349 ahd_done(ahd, scb);
350}
351
352
297/************************* Sequencer Execution Control ************************/ 353/************************* Sequencer Execution Control ************************/
298/* 354/*
299 * Restart the sequencer program from address zero 355 * Restart the sequencer program from address zero
300 */ 356 */
301void 357static void
302ahd_restart(struct ahd_softc *ahd) 358ahd_restart(struct ahd_softc *ahd)
303{ 359{
304 360
@@ -342,7 +398,7 @@ ahd_restart(struct ahd_softc *ahd)
342 ahd_unpause(ahd); 398 ahd_unpause(ahd);
343} 399}
344 400
345void 401static void
346ahd_clear_fifo(struct ahd_softc *ahd, u_int fifo) 402ahd_clear_fifo(struct ahd_softc *ahd, u_int fifo)
347{ 403{
348 ahd_mode_state saved_modes; 404 ahd_mode_state saved_modes;
@@ -366,7 +422,7 @@ ahd_clear_fifo(struct ahd_softc *ahd, u_int fifo)
366 * Flush and completed commands that are sitting in the command 422 * Flush and completed commands that are sitting in the command
367 * complete queues down on the chip but have yet to be dma'ed back up. 423 * complete queues down on the chip but have yet to be dma'ed back up.
368 */ 424 */
369void 425static void
370ahd_flush_qoutfifo(struct ahd_softc *ahd) 426ahd_flush_qoutfifo(struct ahd_softc *ahd)
371{ 427{
372 struct scb *scb; 428 struct scb *scb;
@@ -905,6 +961,51 @@ ahd_handle_hwerrint(struct ahd_softc *ahd)
905 ahd_free(ahd); 961 ahd_free(ahd);
906} 962}
907 963
964#ifdef AHD_DEBUG
965static void
966ahd_dump_sglist(struct scb *scb)
967{
968 int i;
969
970 if (scb->sg_count > 0) {
971 if ((scb->ahd_softc->flags & AHD_64BIT_ADDRESSING) != 0) {
972 struct ahd_dma64_seg *sg_list;
973
974 sg_list = (struct ahd_dma64_seg*)scb->sg_list;
975 for (i = 0; i < scb->sg_count; i++) {
976 uint64_t addr;
977 uint32_t len;
978
979 addr = ahd_le64toh(sg_list[i].addr);
980 len = ahd_le32toh(sg_list[i].len);
981 printf("sg[%d] - Addr 0x%x%x : Length %d%s\n",
982 i,
983 (uint32_t)((addr >> 32) & 0xFFFFFFFF),
984 (uint32_t)(addr & 0xFFFFFFFF),
985 sg_list[i].len & AHD_SG_LEN_MASK,
986 (sg_list[i].len & AHD_DMA_LAST_SEG)
987 ? " Last" : "");
988 }
989 } else {
990 struct ahd_dma_seg *sg_list;
991
992 sg_list = (struct ahd_dma_seg*)scb->sg_list;
993 for (i = 0; i < scb->sg_count; i++) {
994 uint32_t len;
995
996 len = ahd_le32toh(sg_list[i].len);
997 printf("sg[%d] - Addr 0x%x%x : Length %d%s\n",
998 i,
999 (len & AHD_SG_HIGH_ADDR_MASK) >> 24,
1000 ahd_le32toh(sg_list[i].addr),
1001 len & AHD_SG_LEN_MASK,
1002 len & AHD_DMA_LAST_SEG ? " Last" : "");
1003 }
1004 }
1005 }
1006}
1007#endif /* AHD_DEBUG */
1008
908void 1009void
909ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat) 1010ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat)
910{ 1011{
@@ -1053,10 +1154,12 @@ ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat)
1053 * If a target takes us into the command phase 1154 * If a target takes us into the command phase
1054 * assume that it has been externally reset and 1155 * assume that it has been externally reset and
1055 * has thus lost our previous packetized negotiation 1156 * has thus lost our previous packetized negotiation
1056 * agreement. 1157 * agreement. Since we have not sent an identify
1057 * Revert to async/narrow transfers until we 1158 * message and may not have fully qualified the
1058 * can renegotiate with the device and notify 1159 * connection, we change our command to TUR, assert
1059 * the OSM about the reset. 1160 * ATN and ABORT the task when we go to message in
1161 * phase. The OSM will see the REQUEUE_REQUEST
1162 * status and retry the command.
1060 */ 1163 */
1061 scbid = ahd_get_scbptr(ahd); 1164 scbid = ahd_get_scbptr(ahd);
1062 scb = ahd_lookup_scb(ahd, scbid); 1165 scb = ahd_lookup_scb(ahd, scbid);
@@ -1083,7 +1186,28 @@ ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat)
1083 ahd_set_syncrate(ahd, &devinfo, /*period*/0, 1186 ahd_set_syncrate(ahd, &devinfo, /*period*/0,
1084 /*offset*/0, /*ppr_options*/0, 1187 /*offset*/0, /*ppr_options*/0,
1085 AHD_TRANS_ACTIVE, /*paused*/TRUE); 1188 AHD_TRANS_ACTIVE, /*paused*/TRUE);
1086 scb->flags |= SCB_EXTERNAL_RESET; 1189 /* Hand-craft TUR command */
1190 ahd_outb(ahd, SCB_CDB_STORE, 0);
1191 ahd_outb(ahd, SCB_CDB_STORE+1, 0);
1192 ahd_outb(ahd, SCB_CDB_STORE+2, 0);
1193 ahd_outb(ahd, SCB_CDB_STORE+3, 0);
1194 ahd_outb(ahd, SCB_CDB_STORE+4, 0);
1195 ahd_outb(ahd, SCB_CDB_STORE+5, 0);
1196 ahd_outb(ahd, SCB_CDB_LEN, 6);
1197 scb->hscb->control &= ~(TAG_ENB|SCB_TAG_TYPE);
1198 scb->hscb->control |= MK_MESSAGE;
1199 ahd_outb(ahd, SCB_CONTROL, scb->hscb->control);
1200 ahd_outb(ahd, MSG_OUT, HOST_MSG);
1201 ahd_outb(ahd, SAVED_SCSIID, scb->hscb->scsiid);
1202 /*
1203 * The lun is 0, regardless of the SCB's lun
1204 * as we have not sent an identify message.
1205 */
1206 ahd_outb(ahd, SAVED_LUN, 0);
1207 ahd_outb(ahd, SEQ_FLAGS, 0);
1208 ahd_assert_atn(ahd);
1209 scb->flags &= ~SCB_PACKETIZED;
1210 scb->flags |= SCB_ABORT|SCB_EXTERNAL_RESET;
1087 ahd_freeze_devq(ahd, scb); 1211 ahd_freeze_devq(ahd, scb);
1088 ahd_set_transaction_status(scb, CAM_REQUEUE_REQ); 1212 ahd_set_transaction_status(scb, CAM_REQUEUE_REQ);
1089 ahd_freeze_scb(scb); 1213 ahd_freeze_scb(scb);
@@ -1519,8 +1643,10 @@ ahd_handle_scsiint(struct ahd_softc *ahd, u_int intstat)
1519 /* 1643 /*
1520 * Ignore external resets after a bus reset. 1644 * Ignore external resets after a bus reset.
1521 */ 1645 */
1522 if (((status & SCSIRSTI) != 0) && (ahd->flags & AHD_BUS_RESET_ACTIVE)) 1646 if (((status & SCSIRSTI) != 0) && (ahd->flags & AHD_BUS_RESET_ACTIVE)) {
1647 ahd_outb(ahd, CLRSINT1, CLRSCSIRSTI);
1523 return; 1648 return;
1649 }
1524 1650
1525 /* 1651 /*
1526 * Clear bus reset flag 1652 * Clear bus reset flag
@@ -2200,6 +2326,22 @@ ahd_handle_nonpkt_busfree(struct ahd_softc *ahd)
2200 if (sent_msg == MSG_ABORT_TAG) 2326 if (sent_msg == MSG_ABORT_TAG)
2201 tag = SCB_GET_TAG(scb); 2327 tag = SCB_GET_TAG(scb);
2202 2328
2329 if ((scb->flags & SCB_EXTERNAL_RESET) != 0) {
2330 /*
2331 * This abort is in response to an
2332 * unexpected switch to command phase
2333 * for a packetized connection. Since
2334 * the identify message was never sent,
2335 * "saved lun" is 0. We really want to
2336 * abort only the SCB that encountered
2337 * this error, which could have a different
2338 * lun. The SCB will be retried so the OS
2339 * will see the UA after renegotiating to
2340 * packetized.
2341 */
2342 tag = SCB_GET_TAG(scb);
2343 saved_lun = scb->hscb->lun;
2344 }
2203 found = ahd_abort_scbs(ahd, target, 'A', saved_lun, 2345 found = ahd_abort_scbs(ahd, target, 'A', saved_lun,
2204 tag, ROLE_INITIATOR, 2346 tag, ROLE_INITIATOR,
2205 CAM_REQ_ABORTED); 2347 CAM_REQ_ABORTED);
@@ -2523,7 +2665,7 @@ ahd_force_renegotiation(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
2523} 2665}
2524 2666
2525#define AHD_MAX_STEPS 2000 2667#define AHD_MAX_STEPS 2000
2526void 2668static void
2527ahd_clear_critical_section(struct ahd_softc *ahd) 2669ahd_clear_critical_section(struct ahd_softc *ahd)
2528{ 2670{
2529 ahd_mode_state saved_modes; 2671 ahd_mode_state saved_modes;
@@ -2646,7 +2788,7 @@ ahd_clear_critical_section(struct ahd_softc *ahd)
2646/* 2788/*
2647 * Clear any pending interrupt status. 2789 * Clear any pending interrupt status.
2648 */ 2790 */
2649void 2791static void
2650ahd_clear_intstat(struct ahd_softc *ahd) 2792ahd_clear_intstat(struct ahd_softc *ahd)
2651{ 2793{
2652 AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK), 2794 AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK),
@@ -2677,6 +2819,8 @@ ahd_clear_intstat(struct ahd_softc *ahd)
2677#ifdef AHD_DEBUG 2819#ifdef AHD_DEBUG
2678uint32_t ahd_debug = AHD_DEBUG_OPTS; 2820uint32_t ahd_debug = AHD_DEBUG_OPTS;
2679#endif 2821#endif
2822
2823#if 0
2680void 2824void
2681ahd_print_scb(struct scb *scb) 2825ahd_print_scb(struct scb *scb)
2682{ 2826{
@@ -2701,49 +2845,7 @@ ahd_print_scb(struct scb *scb)
2701 SCB_GET_TAG(scb)); 2845 SCB_GET_TAG(scb));
2702 ahd_dump_sglist(scb); 2846 ahd_dump_sglist(scb);
2703} 2847}
2704 2848#endif /* 0 */
2705void
2706ahd_dump_sglist(struct scb *scb)
2707{
2708 int i;
2709
2710 if (scb->sg_count > 0) {
2711 if ((scb->ahd_softc->flags & AHD_64BIT_ADDRESSING) != 0) {
2712 struct ahd_dma64_seg *sg_list;
2713
2714 sg_list = (struct ahd_dma64_seg*)scb->sg_list;
2715 for (i = 0; i < scb->sg_count; i++) {
2716 uint64_t addr;
2717 uint32_t len;
2718
2719 addr = ahd_le64toh(sg_list[i].addr);
2720 len = ahd_le32toh(sg_list[i].len);
2721 printf("sg[%d] - Addr 0x%x%x : Length %d%s\n",
2722 i,
2723 (uint32_t)((addr >> 32) & 0xFFFFFFFF),
2724 (uint32_t)(addr & 0xFFFFFFFF),
2725 sg_list[i].len & AHD_SG_LEN_MASK,
2726 (sg_list[i].len & AHD_DMA_LAST_SEG)
2727 ? " Last" : "");
2728 }
2729 } else {
2730 struct ahd_dma_seg *sg_list;
2731
2732 sg_list = (struct ahd_dma_seg*)scb->sg_list;
2733 for (i = 0; i < scb->sg_count; i++) {
2734 uint32_t len;
2735
2736 len = ahd_le32toh(sg_list[i].len);
2737 printf("sg[%d] - Addr 0x%x%x : Length %d%s\n",
2738 i,
2739 (len & AHD_SG_HIGH_ADDR_MASK) >> 24,
2740 ahd_le32toh(sg_list[i].addr),
2741 len & AHD_SG_LEN_MASK,
2742 len & AHD_DMA_LAST_SEG ? " Last" : "");
2743 }
2744 }
2745 }
2746}
2747 2849
2748/************************* Transfer Negotiation *******************************/ 2850/************************* Transfer Negotiation *******************************/
2749/* 2851/*
@@ -2850,14 +2952,14 @@ ahd_devlimited_syncrate(struct ahd_softc *ahd,
2850 transinfo = &tinfo->goal; 2952 transinfo = &tinfo->goal;
2851 *ppr_options &= (transinfo->ppr_options|MSG_EXT_PPR_PCOMP_EN); 2953 *ppr_options &= (transinfo->ppr_options|MSG_EXT_PPR_PCOMP_EN);
2852 if (transinfo->width == MSG_EXT_WDTR_BUS_8_BIT) { 2954 if (transinfo->width == MSG_EXT_WDTR_BUS_8_BIT) {
2853 maxsync = MAX(maxsync, AHD_SYNCRATE_ULTRA2); 2955 maxsync = max(maxsync, (u_int)AHD_SYNCRATE_ULTRA2);
2854 *ppr_options &= ~MSG_EXT_PPR_DT_REQ; 2956 *ppr_options &= ~MSG_EXT_PPR_DT_REQ;
2855 } 2957 }
2856 if (transinfo->period == 0) { 2958 if (transinfo->period == 0) {
2857 *period = 0; 2959 *period = 0;
2858 *ppr_options = 0; 2960 *ppr_options = 0;
2859 } else { 2961 } else {
2860 *period = MAX(*period, transinfo->period); 2962 *period = max(*period, (u_int)transinfo->period);
2861 ahd_find_syncrate(ahd, period, ppr_options, maxsync); 2963 ahd_find_syncrate(ahd, period, ppr_options, maxsync);
2862 } 2964 }
2863} 2965}
@@ -2906,7 +3008,7 @@ ahd_find_syncrate(struct ahd_softc *ahd, u_int *period,
2906 * Truncate the given synchronous offset to a value the 3008 * Truncate the given synchronous offset to a value the
2907 * current adapter type and syncrate are capable of. 3009 * current adapter type and syncrate are capable of.
2908 */ 3010 */
2909void 3011static void
2910ahd_validate_offset(struct ahd_softc *ahd, 3012ahd_validate_offset(struct ahd_softc *ahd,
2911 struct ahd_initiator_tinfo *tinfo, 3013 struct ahd_initiator_tinfo *tinfo,
2912 u_int period, u_int *offset, int wide, 3014 u_int period, u_int *offset, int wide,
@@ -2924,12 +3026,12 @@ ahd_validate_offset(struct ahd_softc *ahd,
2924 maxoffset = MAX_OFFSET_PACED; 3026 maxoffset = MAX_OFFSET_PACED;
2925 } else 3027 } else
2926 maxoffset = MAX_OFFSET_NON_PACED; 3028 maxoffset = MAX_OFFSET_NON_PACED;
2927 *offset = MIN(*offset, maxoffset); 3029 *offset = min(*offset, maxoffset);
2928 if (tinfo != NULL) { 3030 if (tinfo != NULL) {
2929 if (role == ROLE_TARGET) 3031 if (role == ROLE_TARGET)
2930 *offset = MIN(*offset, tinfo->user.offset); 3032 *offset = min(*offset, (u_int)tinfo->user.offset);
2931 else 3033 else
2932 *offset = MIN(*offset, tinfo->goal.offset); 3034 *offset = min(*offset, (u_int)tinfo->goal.offset);
2933 } 3035 }
2934} 3036}
2935 3037
@@ -2937,7 +3039,7 @@ ahd_validate_offset(struct ahd_softc *ahd,
2937 * Truncate the given transfer width parameter to a value the 3039 * Truncate the given transfer width parameter to a value the
2938 * current adapter type is capable of. 3040 * current adapter type is capable of.
2939 */ 3041 */
2940void 3042static void
2941ahd_validate_width(struct ahd_softc *ahd, struct ahd_initiator_tinfo *tinfo, 3043ahd_validate_width(struct ahd_softc *ahd, struct ahd_initiator_tinfo *tinfo,
2942 u_int *bus_width, role_t role) 3044 u_int *bus_width, role_t role)
2943{ 3045{
@@ -2955,9 +3057,9 @@ ahd_validate_width(struct ahd_softc *ahd, struct ahd_initiator_tinfo *tinfo,
2955 } 3057 }
2956 if (tinfo != NULL) { 3058 if (tinfo != NULL) {
2957 if (role == ROLE_TARGET) 3059 if (role == ROLE_TARGET)
2958 *bus_width = MIN(tinfo->user.width, *bus_width); 3060 *bus_width = min((u_int)tinfo->user.width, *bus_width);
2959 else 3061 else
2960 *bus_width = MIN(tinfo->goal.width, *bus_width); 3062 *bus_width = min((u_int)tinfo->goal.width, *bus_width);
2961 } 3063 }
2962} 3064}
2963 3065
@@ -3210,7 +3312,7 @@ ahd_set_width(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
3210/* 3312/*
3211 * Update the current state of tagged queuing for a given target. 3313 * Update the current state of tagged queuing for a given target.
3212 */ 3314 */
3213void 3315static void
3214ahd_set_tags(struct ahd_softc *ahd, struct scsi_cmnd *cmd, 3316ahd_set_tags(struct ahd_softc *ahd, struct scsi_cmnd *cmd,
3215 struct ahd_devinfo *devinfo, ahd_queue_alg alg) 3317 struct ahd_devinfo *devinfo, ahd_queue_alg alg)
3216{ 3318{
@@ -3466,7 +3568,7 @@ ahd_print_devinfo(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
3466 devinfo->target, devinfo->lun); 3568 devinfo->target, devinfo->lun);
3467} 3569}
3468 3570
3469struct ahd_phase_table_entry* 3571static struct ahd_phase_table_entry*
3470ahd_lookup_phase_entry(int phase) 3572ahd_lookup_phase_entry(int phase)
3471{ 3573{
3472 struct ahd_phase_table_entry *entry; 3574 struct ahd_phase_table_entry *entry;
@@ -5351,7 +5453,7 @@ ahd_free(struct ahd_softc *ahd)
5351 return; 5453 return;
5352} 5454}
5353 5455
5354void 5456static void
5355ahd_shutdown(void *arg) 5457ahd_shutdown(void *arg)
5356{ 5458{
5357 struct ahd_softc *ahd; 5459 struct ahd_softc *ahd;
@@ -5480,7 +5582,7 @@ ahd_reset(struct ahd_softc *ahd, int reinit)
5480/* 5582/*
5481 * Determine the number of SCBs available on the controller 5583 * Determine the number of SCBs available on the controller
5482 */ 5584 */
5483int 5585static int
5484ahd_probe_scbs(struct ahd_softc *ahd) { 5586ahd_probe_scbs(struct ahd_softc *ahd) {
5485 int i; 5587 int i;
5486 5588
@@ -5929,7 +6031,7 @@ ahd_free_scb(struct ahd_softc *ahd, struct scb *scb)
5929 ahd_platform_scb_free(ahd, scb); 6031 ahd_platform_scb_free(ahd, scb);
5930} 6032}
5931 6033
5932void 6034static void
5933ahd_alloc_scbs(struct ahd_softc *ahd) 6035ahd_alloc_scbs(struct ahd_softc *ahd)
5934{ 6036{
5935 struct scb_data *scb_data; 6037 struct scb_data *scb_data;
@@ -6057,9 +6159,9 @@ ahd_alloc_scbs(struct ahd_softc *ahd)
6057#endif 6159#endif
6058 } 6160 }
6059 6161
6060 newcount = MIN(scb_data->sense_left, scb_data->scbs_left); 6162 newcount = min(scb_data->sense_left, scb_data->scbs_left);
6061 newcount = MIN(newcount, scb_data->sgs_left); 6163 newcount = min(newcount, scb_data->sgs_left);
6062 newcount = MIN(newcount, (AHD_SCB_MAX_ALLOC - scb_data->numscbs)); 6164 newcount = min(newcount, (AHD_SCB_MAX_ALLOC - scb_data->numscbs));
6063 for (i = 0; i < newcount; i++) { 6165 for (i = 0; i < newcount; i++) {
6064 struct scb_platform_data *pdata; 6166 struct scb_platform_data *pdata;
6065 u_int col_tag; 6167 u_int col_tag;
@@ -6982,7 +7084,7 @@ ahd_intr_enable(struct ahd_softc *ahd, int enable)
6982 ahd_outb(ahd, HCNTRL, hcntrl); 7084 ahd_outb(ahd, HCNTRL, hcntrl);
6983} 7085}
6984 7086
6985void 7087static void
6986ahd_update_coalescing_values(struct ahd_softc *ahd, u_int timer, u_int maxcmds, 7088ahd_update_coalescing_values(struct ahd_softc *ahd, u_int timer, u_int maxcmds,
6987 u_int mincmds) 7089 u_int mincmds)
6988{ 7090{
@@ -7000,7 +7102,7 @@ ahd_update_coalescing_values(struct ahd_softc *ahd, u_int timer, u_int maxcmds,
7000 ahd_outb(ahd, INT_COALESCING_MINCMDS, -mincmds); 7102 ahd_outb(ahd, INT_COALESCING_MINCMDS, -mincmds);
7001} 7103}
7002 7104
7003void 7105static void
7004ahd_enable_coalescing(struct ahd_softc *ahd, int enable) 7106ahd_enable_coalescing(struct ahd_softc *ahd, int enable)
7005{ 7107{
7006 7108
@@ -7070,6 +7172,7 @@ ahd_pause_and_flushwork(struct ahd_softc *ahd)
7070 ahd->flags &= ~AHD_ALL_INTERRUPTS; 7172 ahd->flags &= ~AHD_ALL_INTERRUPTS;
7071} 7173}
7072 7174
7175#if 0
7073int 7176int
7074ahd_suspend(struct ahd_softc *ahd) 7177ahd_suspend(struct ahd_softc *ahd)
7075{ 7178{
@@ -7083,7 +7186,9 @@ ahd_suspend(struct ahd_softc *ahd)
7083 ahd_shutdown(ahd); 7186 ahd_shutdown(ahd);
7084 return (0); 7187 return (0);
7085} 7188}
7189#endif /* 0 */
7086 7190
7191#if 0
7087int 7192int
7088ahd_resume(struct ahd_softc *ahd) 7193ahd_resume(struct ahd_softc *ahd)
7089{ 7194{
@@ -7093,6 +7198,7 @@ ahd_resume(struct ahd_softc *ahd)
7093 ahd_restart(ahd); 7198 ahd_restart(ahd);
7094 return (0); 7199 return (0);
7095} 7200}
7201#endif /* 0 */
7096 7202
7097/************************** Busy Target Table *********************************/ 7203/************************** Busy Target Table *********************************/
7098/* 7204/*
@@ -7125,7 +7231,7 @@ ahd_index_busy_tcl(struct ahd_softc *ahd, u_int *saved_scbid, u_int tcl)
7125/* 7231/*
7126 * Return the untagged transaction id for a given target/channel lun. 7232 * Return the untagged transaction id for a given target/channel lun.
7127 */ 7233 */
7128u_int 7234static u_int
7129ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl) 7235ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl)
7130{ 7236{
7131 u_int scbid; 7237 u_int scbid;
@@ -7138,7 +7244,7 @@ ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl)
7138 return (scbid); 7244 return (scbid);
7139} 7245}
7140 7246
7141void 7247static void
7142ahd_busy_tcl(struct ahd_softc *ahd, u_int tcl, u_int scbid) 7248ahd_busy_tcl(struct ahd_softc *ahd, u_int tcl, u_int scbid)
7143{ 7249{
7144 u_int scb_offset; 7250 u_int scb_offset;
@@ -7186,7 +7292,7 @@ ahd_match_scb(struct ahd_softc *ahd, struct scb *scb, int target,
7186 return match; 7292 return match;
7187} 7293}
7188 7294
7189void 7295static void
7190ahd_freeze_devq(struct ahd_softc *ahd, struct scb *scb) 7296ahd_freeze_devq(struct ahd_softc *ahd, struct scb *scb)
7191{ 7297{
7192 int target; 7298 int target;
@@ -7690,7 +7796,7 @@ ahd_add_scb_to_free_list(struct ahd_softc *ahd, u_int scbid)
7690 * been modified from CAM_REQ_INPROG. This routine assumes that the sequencer 7796 * been modified from CAM_REQ_INPROG. This routine assumes that the sequencer
7691 * is paused before it is called. 7797 * is paused before it is called.
7692 */ 7798 */
7693int 7799static int
7694ahd_abort_scbs(struct ahd_softc *ahd, int target, char channel, 7800ahd_abort_scbs(struct ahd_softc *ahd, int target, char channel,
7695 int lun, u_int tag, role_t role, uint32_t status) 7801 int lun, u_int tag, role_t role, uint32_t status)
7696{ 7802{
@@ -7920,6 +8026,11 @@ ahd_reset_channel(struct ahd_softc *ahd, char channel, int initiate_reset)
7920 ahd_clear_fifo(ahd, 1); 8026 ahd_clear_fifo(ahd, 1);
7921 8027
7922 /* 8028 /*
8029 * Clear SCSI interrupt status
8030 */
8031 ahd_outb(ahd, CLRSINT1, CLRSCSIRSTI);
8032
8033 /*
7923 * Reenable selections 8034 * Reenable selections
7924 */ 8035 */
7925 ahd_outb(ahd, SIMODE1, ahd_inb(ahd, SIMODE1) | ENSCSIRST); 8036 ahd_outb(ahd, SIMODE1, ahd_inb(ahd, SIMODE1) | ENSCSIRST);
@@ -7952,10 +8063,6 @@ ahd_reset_channel(struct ahd_softc *ahd, char channel, int initiate_reset)
7952 } 8063 }
7953 } 8064 }
7954#endif 8065#endif
7955 /* Notify the XPT that a bus reset occurred */
7956 ahd_send_async(ahd, devinfo.channel, CAM_TARGET_WILDCARD,
7957 CAM_LUN_WILDCARD, AC_BUS_RESET);
7958
7959 /* 8066 /*
7960 * Revert to async/narrow transfers until we renegotiate. 8067 * Revert to async/narrow transfers until we renegotiate.
7961 */ 8068 */
@@ -7977,6 +8084,10 @@ ahd_reset_channel(struct ahd_softc *ahd, char channel, int initiate_reset)
7977 } 8084 }
7978 } 8085 }
7979 8086
8087 /* Notify the XPT that a bus reset occurred */
8088 ahd_send_async(ahd, devinfo.channel, CAM_TARGET_WILDCARD,
8089 CAM_LUN_WILDCARD, AC_BUS_RESET);
8090
7980 ahd_restart(ahd); 8091 ahd_restart(ahd);
7981 8092
7982 return (found); 8093 return (found);
@@ -8019,18 +8130,8 @@ ahd_stat_timer(void *arg)
8019} 8130}
8020 8131
8021/****************************** Status Processing *****************************/ 8132/****************************** Status Processing *****************************/
8022void
8023ahd_handle_scb_status(struct ahd_softc *ahd, struct scb *scb)
8024{
8025 if (scb->hscb->shared_data.istatus.scsi_status != 0) {
8026 ahd_handle_scsi_status(ahd, scb);
8027 } else {
8028 ahd_calc_residual(ahd, scb);
8029 ahd_done(ahd, scb);
8030 }
8031}
8032 8133
8033void 8134static void
8034ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb) 8135ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb)
8035{ 8136{
8036 struct hardware_scb *hscb; 8137 struct hardware_scb *hscb;
@@ -8238,10 +8339,21 @@ ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb)
8238 } 8339 }
8239} 8340}
8240 8341
8342static void
8343ahd_handle_scb_status(struct ahd_softc *ahd, struct scb *scb)
8344{
8345 if (scb->hscb->shared_data.istatus.scsi_status != 0) {
8346 ahd_handle_scsi_status(ahd, scb);
8347 } else {
8348 ahd_calc_residual(ahd, scb);
8349 ahd_done(ahd, scb);
8350 }
8351}
8352
8241/* 8353/*
8242 * Calculate the residual for a just completed SCB. 8354 * Calculate the residual for a just completed SCB.
8243 */ 8355 */
8244void 8356static void
8245ahd_calc_residual(struct ahd_softc *ahd, struct scb *scb) 8357ahd_calc_residual(struct ahd_softc *ahd, struct scb *scb)
8246{ 8358{
8247 struct hardware_scb *hscb; 8359 struct hardware_scb *hscb;
@@ -8668,7 +8780,7 @@ ahd_resolve_seqaddr(struct ahd_softc *ahd, u_int address)
8668 if (skip_addr > i) { 8780 if (skip_addr > i) {
8669 int end_addr; 8781 int end_addr;
8670 8782
8671 end_addr = MIN(address, skip_addr); 8783 end_addr = min(address, skip_addr);
8672 address_offset += end_addr - i; 8784 address_offset += end_addr - i;
8673 i = skip_addr; 8785 i = skip_addr;
8674 } else { 8786 } else {
@@ -9092,6 +9204,7 @@ ahd_dump_card_state(struct ahd_softc *ahd)
9092 ahd_unpause(ahd); 9204 ahd_unpause(ahd);
9093} 9205}
9094 9206
9207#if 0
9095void 9208void
9096ahd_dump_scbs(struct ahd_softc *ahd) 9209ahd_dump_scbs(struct ahd_softc *ahd)
9097{ 9210{
@@ -9117,6 +9230,7 @@ ahd_dump_scbs(struct ahd_softc *ahd)
9117 ahd_set_scbptr(ahd, saved_scb_index); 9230 ahd_set_scbptr(ahd, saved_scb_index);
9118 ahd_restore_modes(ahd, saved_modes); 9231 ahd_restore_modes(ahd, saved_modes);
9119} 9232}
9233#endif /* 0 */
9120 9234
9121/**************************** Flexport Logic **********************************/ 9235/**************************** Flexport Logic **********************************/
9122/* 9236/*
@@ -9219,7 +9333,7 @@ ahd_write_seeprom(struct ahd_softc *ahd, uint16_t *buf,
9219/* 9333/*
9220 * Wait ~100us for the serial eeprom to satisfy our request. 9334 * Wait ~100us for the serial eeprom to satisfy our request.
9221 */ 9335 */
9222int 9336static int
9223ahd_wait_seeprom(struct ahd_softc *ahd) 9337ahd_wait_seeprom(struct ahd_softc *ahd)
9224{ 9338{
9225 int cnt; 9339 int cnt;
@@ -9237,7 +9351,7 @@ ahd_wait_seeprom(struct ahd_softc *ahd)
9237 * Validate the two checksums in the per_channel 9351 * Validate the two checksums in the per_channel
9238 * vital product data struct. 9352 * vital product data struct.
9239 */ 9353 */
9240int 9354static int
9241ahd_verify_vpd_cksum(struct vpd_config *vpd) 9355ahd_verify_vpd_cksum(struct vpd_config *vpd)
9242{ 9356{
9243 int i; 9357 int i;
@@ -9316,6 +9430,24 @@ ahd_release_seeprom(struct ahd_softc *ahd)
9316 /* Currently a no-op */ 9430 /* Currently a no-op */
9317} 9431}
9318 9432
9433/*
9434 * Wait at most 2 seconds for flexport arbitration to succeed.
9435 */
9436static int
9437ahd_wait_flexport(struct ahd_softc *ahd)
9438{
9439 int cnt;
9440
9441 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
9442 cnt = 1000000 * 2 / 5;
9443 while ((ahd_inb(ahd, BRDCTL) & FLXARBACK) == 0 && --cnt)
9444 ahd_delay(5);
9445
9446 if (cnt == 0)
9447 return (ETIMEDOUT);
9448 return (0);
9449}
9450
9319int 9451int
9320ahd_write_flexport(struct ahd_softc *ahd, u_int addr, u_int value) 9452ahd_write_flexport(struct ahd_softc *ahd, u_int addr, u_int value)
9321{ 9453{
@@ -9357,24 +9489,6 @@ ahd_read_flexport(struct ahd_softc *ahd, u_int addr, uint8_t *value)
9357 return (0); 9489 return (0);
9358} 9490}
9359 9491
9360/*
9361 * Wait at most 2 seconds for flexport arbitration to succeed.
9362 */
9363int
9364ahd_wait_flexport(struct ahd_softc *ahd)
9365{
9366 int cnt;
9367
9368 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
9369 cnt = 1000000 * 2 / 5;
9370 while ((ahd_inb(ahd, BRDCTL) & FLXARBACK) == 0 && --cnt)
9371 ahd_delay(5);
9372
9373 if (cnt == 0)
9374 return (ETIMEDOUT);
9375 return (0);
9376}
9377
9378/************************* Target Mode ****************************************/ 9492/************************* Target Mode ****************************************/
9379#ifdef AHD_TARGET_MODE 9493#ifdef AHD_TARGET_MODE
9380cam_status 9494cam_status
diff --git a/drivers/scsi/aic7xxx/aic79xx_inline.h b/drivers/scsi/aic7xxx/aic79xx_inline.h
index a3266e066c00..2ceb67f4af2a 100644
--- a/drivers/scsi/aic7xxx/aic79xx_inline.h
+++ b/drivers/scsi/aic7xxx/aic79xx_inline.h
@@ -418,10 +418,6 @@ ahd_targetcmd_offset(struct ahd_softc *ahd, u_int index)
418} 418}
419 419
420/*********************** Miscelaneous Support Functions ***********************/ 420/*********************** Miscelaneous Support Functions ***********************/
421static __inline void ahd_complete_scb(struct ahd_softc *ahd,
422 struct scb *scb);
423static __inline void ahd_update_residual(struct ahd_softc *ahd,
424 struct scb *scb);
425static __inline struct ahd_initiator_tinfo * 421static __inline struct ahd_initiator_tinfo *
426 ahd_fetch_transinfo(struct ahd_softc *ahd, 422 ahd_fetch_transinfo(struct ahd_softc *ahd,
427 char channel, u_int our_id, 423 char channel, u_int our_id,
@@ -467,32 +463,6 @@ static __inline uint32_t
467 ahd_get_sense_bufaddr(struct ahd_softc *ahd, 463 ahd_get_sense_bufaddr(struct ahd_softc *ahd,
468 struct scb *scb); 464 struct scb *scb);
469 465
470static __inline void
471ahd_complete_scb(struct ahd_softc *ahd, struct scb *scb)
472{
473 uint32_t sgptr;
474
475 sgptr = ahd_le32toh(scb->hscb->sgptr);
476 if ((sgptr & SG_STATUS_VALID) != 0)
477 ahd_handle_scb_status(ahd, scb);
478 else
479 ahd_done(ahd, scb);
480}
481
482/*
483 * Determine whether the sequencer reported a residual
484 * for this SCB/transaction.
485 */
486static __inline void
487ahd_update_residual(struct ahd_softc *ahd, struct scb *scb)
488{
489 uint32_t sgptr;
490
491 sgptr = ahd_le32toh(scb->hscb->sgptr);
492 if ((sgptr & SG_STATUS_VALID) != 0)
493 ahd_calc_residual(ahd, scb);
494}
495
496/* 466/*
497 * Return pointers to the transfer negotiation information 467 * Return pointers to the transfer negotiation information
498 * for the specified our_id/remote_id pair. 468 * for the specified our_id/remote_id pair.
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
index f8e60486167d..9bfcca5ede08 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
@@ -293,7 +293,7 @@ static uint32_t aic79xx_seltime;
293 * force all outstanding transactions to be serviced prior to a new 293 * force all outstanding transactions to be serviced prior to a new
294 * transaction. 294 * transaction.
295 */ 295 */
296uint32_t aic79xx_periodic_otag; 296static uint32_t aic79xx_periodic_otag;
297 297
298/* Some storage boxes are using an LSI chip which has a bug making it 298/* Some storage boxes are using an LSI chip which has a bug making it
299 * impossible to use aic79xx Rev B chip in 320 speeds. The following 299 * impossible to use aic79xx Rev B chip in 320 speeds. The following
@@ -773,6 +773,7 @@ struct scsi_host_template aic79xx_driver_template = {
773#endif 773#endif
774 .can_queue = AHD_MAX_QUEUE, 774 .can_queue = AHD_MAX_QUEUE,
775 .this_id = -1, 775 .this_id = -1,
776 .max_sectors = 8192,
776 .cmd_per_lun = 2, 777 .cmd_per_lun = 2,
777 .use_clustering = ENABLE_CLUSTERING, 778 .use_clustering = ENABLE_CLUSTERING,
778 .slave_alloc = ahd_linux_slave_alloc, 779 .slave_alloc = ahd_linux_slave_alloc,
@@ -1813,9 +1814,9 @@ ahd_linux_handle_scsi_status(struct ahd_softc *ahd,
1813 u_int sense_offset; 1814 u_int sense_offset;
1814 1815
1815 if (scb->flags & SCB_SENSE) { 1816 if (scb->flags & SCB_SENSE) {
1816 sense_size = MIN(sizeof(struct scsi_sense_data) 1817 sense_size = min(sizeof(struct scsi_sense_data)
1817 - ahd_get_sense_residual(scb), 1818 - ahd_get_sense_residual(scb),
1818 sizeof(cmd->sense_buffer)); 1819 (u_long)sizeof(cmd->sense_buffer));
1819 sense_offset = 0; 1820 sense_offset = 0;
1820 } else { 1821 } else {
1821 /* 1822 /*
@@ -1824,7 +1825,8 @@ ahd_linux_handle_scsi_status(struct ahd_softc *ahd,
1824 */ 1825 */
1825 siu = (struct scsi_status_iu_header *) 1826 siu = (struct scsi_status_iu_header *)
1826 scb->sense_data; 1827 scb->sense_data;
1827 sense_size = MIN(scsi_4btoul(siu->sense_length), 1828 sense_size = min_t(size_t,
1829 scsi_4btoul(siu->sense_length),
1828 sizeof(cmd->sense_buffer)); 1830 sizeof(cmd->sense_buffer));
1829 sense_offset = SIU_SENSE_OFFSET(siu); 1831 sense_offset = SIU_SENSE_OFFSET(siu);
1830 } 1832 }
@@ -2634,8 +2636,22 @@ static void ahd_linux_set_pcomp_en(struct scsi_target *starget, int pcomp)
2634 pcomp ? "Enable" : "Disable"); 2636 pcomp ? "Enable" : "Disable");
2635#endif 2637#endif
2636 2638
2637 if (pcomp) 2639 if (pcomp) {
2640 uint8_t precomp;
2641
2642 if (ahd->unit < ARRAY_SIZE(aic79xx_iocell_info)) {
2643 struct ahd_linux_iocell_opts *iocell_opts;
2644
2645 iocell_opts = &aic79xx_iocell_info[ahd->unit];
2646 precomp = iocell_opts->precomp;
2647 } else {
2648 precomp = AIC79XX_DEFAULT_PRECOMP;
2649 }
2638 ppr_options |= MSG_EXT_PPR_PCOMP_EN; 2650 ppr_options |= MSG_EXT_PPR_PCOMP_EN;
2651 AHD_SET_PRECOMP(ahd, precomp);
2652 } else {
2653 AHD_SET_PRECOMP(ahd, 0);
2654 }
2639 2655
2640 ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, 2656 ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0,
2641 starget->channel + 'A', ROLE_INITIATOR); 2657 starget->channel + 'A', ROLE_INITIATOR);
@@ -2678,7 +2694,25 @@ static void ahd_linux_set_hold_mcs(struct scsi_target *starget, int hold)
2678 ahd_unlock(ahd, &flags); 2694 ahd_unlock(ahd, &flags);
2679} 2695}
2680 2696
2697static void ahd_linux_get_signalling(struct Scsi_Host *shost)
2698{
2699 struct ahd_softc *ahd = *(struct ahd_softc **)shost->hostdata;
2700 unsigned long flags;
2701 u8 mode;
2702
2703 ahd_lock(ahd, &flags);
2704 ahd_pause(ahd);
2705 mode = ahd_inb(ahd, SBLKCTL);
2706 ahd_unpause(ahd);
2707 ahd_unlock(ahd, &flags);
2681 2708
2709 if (mode & ENAB40)
2710 spi_signalling(shost) = SPI_SIGNAL_LVD;
2711 else if (mode & ENAB20)
2712 spi_signalling(shost) = SPI_SIGNAL_SE;
2713 else
2714 spi_signalling(shost) = SPI_SIGNAL_UNKNOWN;
2715}
2682 2716
2683static struct spi_function_template ahd_linux_transport_functions = { 2717static struct spi_function_template ahd_linux_transport_functions = {
2684 .set_offset = ahd_linux_set_offset, 2718 .set_offset = ahd_linux_set_offset,
@@ -2703,6 +2737,7 @@ static struct spi_function_template ahd_linux_transport_functions = {
2703 .show_pcomp_en = 1, 2737 .show_pcomp_en = 1,
2704 .set_hold_mcs = ahd_linux_set_hold_mcs, 2738 .set_hold_mcs = ahd_linux_set_hold_mcs,
2705 .show_hold_mcs = 1, 2739 .show_hold_mcs = 1,
2740 .get_signalling = ahd_linux_get_signalling,
2706}; 2741};
2707 2742
2708static int __init 2743static int __init
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.h b/drivers/scsi/aic7xxx/aic79xx_osm.h
index fb3d4dd54413..3a67fc578d78 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.h
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.h
@@ -506,9 +506,6 @@ struct info_str {
506 int pos; 506 int pos;
507}; 507};
508 508
509void ahd_format_transinfo(struct info_str *info,
510 struct ahd_transinfo *tinfo);
511
512/******************************** Locking *************************************/ 509/******************************** Locking *************************************/
513static __inline void 510static __inline void
514ahd_lockinit(struct ahd_softc *ahd) 511ahd_lockinit(struct ahd_softc *ahd)
@@ -582,8 +579,6 @@ ahd_unlock(struct ahd_softc *ahd, unsigned long *flags)
582#define PCIXM_STATUS_MAXCRDS 0x1C00 /* Maximum Cumulative Read Size */ 579#define PCIXM_STATUS_MAXCRDS 0x1C00 /* Maximum Cumulative Read Size */
583#define PCIXM_STATUS_RCVDSCEM 0x2000 /* Received a Split Comp w/Error msg */ 580#define PCIXM_STATUS_RCVDSCEM 0x2000 /* Received a Split Comp w/Error msg */
584 581
585extern struct pci_driver aic79xx_pci_driver;
586
587typedef enum 582typedef enum
588{ 583{
589 AHD_POWER_STATE_D0, 584 AHD_POWER_STATE_D0,
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
index 4b5354201807..2001fe890e71 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
@@ -82,7 +82,7 @@ static struct pci_device_id ahd_linux_pci_id_table[] = {
82 82
83MODULE_DEVICE_TABLE(pci, ahd_linux_pci_id_table); 83MODULE_DEVICE_TABLE(pci, ahd_linux_pci_id_table);
84 84
85struct pci_driver aic79xx_pci_driver = { 85static struct pci_driver aic79xx_pci_driver = {
86 .name = "aic79xx", 86 .name = "aic79xx",
87 .probe = ahd_linux_pci_dev_probe, 87 .probe = ahd_linux_pci_dev_probe,
88 .remove = ahd_linux_pci_dev_remove, 88 .remove = ahd_linux_pci_dev_remove,
diff --git a/drivers/scsi/aic7xxx/aic79xx_pci.c b/drivers/scsi/aic7xxx/aic79xx_pci.c
index 14850f31aafa..c07735819cd1 100644
--- a/drivers/scsi/aic7xxx/aic79xx_pci.c
+++ b/drivers/scsi/aic7xxx/aic79xx_pci.c
@@ -97,7 +97,7 @@ static ahd_device_setup_t ahd_aic7901A_setup;
97static ahd_device_setup_t ahd_aic7902_setup; 97static ahd_device_setup_t ahd_aic7902_setup;
98static ahd_device_setup_t ahd_aic790X_setup; 98static ahd_device_setup_t ahd_aic790X_setup;
99 99
100struct ahd_pci_identity ahd_pci_ident_table [] = 100static struct ahd_pci_identity ahd_pci_ident_table [] =
101{ 101{
102 /* aic7901 based controllers */ 102 /* aic7901 based controllers */
103 { 103 {
@@ -201,7 +201,7 @@ struct ahd_pci_identity ahd_pci_ident_table [] =
201 } 201 }
202}; 202};
203 203
204const u_int ahd_num_pci_devs = ARRAY_SIZE(ahd_pci_ident_table); 204static const u_int ahd_num_pci_devs = ARRAY_SIZE(ahd_pci_ident_table);
205 205
206#define DEVCONFIG 0x40 206#define DEVCONFIG 0x40
207#define PCIXINITPAT 0x0000E000ul 207#define PCIXINITPAT 0x0000E000ul
@@ -245,6 +245,7 @@ static int ahd_check_extport(struct ahd_softc *ahd);
245static void ahd_configure_termination(struct ahd_softc *ahd, 245static void ahd_configure_termination(struct ahd_softc *ahd,
246 u_int adapter_control); 246 u_int adapter_control);
247static void ahd_pci_split_intr(struct ahd_softc *ahd, u_int intstat); 247static void ahd_pci_split_intr(struct ahd_softc *ahd, u_int intstat);
248static void ahd_pci_intr(struct ahd_softc *ahd);
248 249
249struct ahd_pci_identity * 250struct ahd_pci_identity *
250ahd_find_pci_device(ahd_dev_softc_t pci) 251ahd_find_pci_device(ahd_dev_softc_t pci)
@@ -757,7 +758,7 @@ static const char *pci_status_strings[] =
757 "%s: Address or Write Phase Parity Error Detected in %s.\n" 758 "%s: Address or Write Phase Parity Error Detected in %s.\n"
758}; 759};
759 760
760void 761static void
761ahd_pci_intr(struct ahd_softc *ahd) 762ahd_pci_intr(struct ahd_softc *ahd)
762{ 763{
763 uint8_t pci_status[8]; 764 uint8_t pci_status[8];
diff --git a/drivers/scsi/aic7xxx/aic79xx_proc.c b/drivers/scsi/aic7xxx/aic79xx_proc.c
index c5f0ee591509..6b28bebcbca0 100644
--- a/drivers/scsi/aic7xxx/aic79xx_proc.c
+++ b/drivers/scsi/aic7xxx/aic79xx_proc.c
@@ -136,7 +136,7 @@ copy_info(struct info_str *info, char *fmt, ...)
136 return (len); 136 return (len);
137} 137}
138 138
139void 139static void
140ahd_format_transinfo(struct info_str *info, struct ahd_transinfo *tinfo) 140ahd_format_transinfo(struct info_str *info, struct ahd_transinfo *tinfo)
141{ 141{
142 u_int speed; 142 u_int speed;
diff --git a/drivers/scsi/aic7xxx/aic7xxx.h b/drivers/scsi/aic7xxx/aic7xxx.h
index 62ff8c3dc2bb..954c7c24501d 100644
--- a/drivers/scsi/aic7xxx/aic7xxx.h
+++ b/drivers/scsi/aic7xxx/aic7xxx.h
@@ -54,14 +54,6 @@ struct scb_platform_data;
54struct seeprom_descriptor; 54struct seeprom_descriptor;
55 55
56/****************************** Useful Macros *********************************/ 56/****************************** Useful Macros *********************************/
57#ifndef MAX
58#define MAX(a,b) (((a) > (b)) ? (a) : (b))
59#endif
60
61#ifndef MIN
62#define MIN(a,b) (((a) < (b)) ? (a) : (b))
63#endif
64
65#ifndef TRUE 57#ifndef TRUE
66#define TRUE 1 58#define TRUE 1
67#endif 59#endif
@@ -1135,8 +1127,6 @@ struct ahc_pci_identity {
1135 char *name; 1127 char *name;
1136 ahc_device_setup_t *setup; 1128 ahc_device_setup_t *setup;
1137}; 1129};
1138extern struct ahc_pci_identity ahc_pci_ident_table[];
1139extern const u_int ahc_num_pci_devs;
1140 1130
1141/***************************** VL/EISA Declarations ***************************/ 1131/***************************** VL/EISA Declarations ***************************/
1142struct aic7770_identity { 1132struct aic7770_identity {
@@ -1289,6 +1279,7 @@ typedef enum {
1289} ahc_queue_alg; 1279} ahc_queue_alg;
1290 1280
1291void ahc_set_tags(struct ahc_softc *ahc, 1281void ahc_set_tags(struct ahc_softc *ahc,
1282 struct scsi_cmnd *cmd,
1292 struct ahc_devinfo *devinfo, 1283 struct ahc_devinfo *devinfo,
1293 ahc_queue_alg alg); 1284 ahc_queue_alg alg);
1294 1285
diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c
index 93e4e40944b6..50ef785224de 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_core.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_core.c
@@ -1671,7 +1671,7 @@ ahc_devlimited_syncrate(struct ahc_softc *ahc,
1671 transinfo = &tinfo->goal; 1671 transinfo = &tinfo->goal;
1672 *ppr_options &= transinfo->ppr_options; 1672 *ppr_options &= transinfo->ppr_options;
1673 if (transinfo->width == MSG_EXT_WDTR_BUS_8_BIT) { 1673 if (transinfo->width == MSG_EXT_WDTR_BUS_8_BIT) {
1674 maxsync = MAX(maxsync, AHC_SYNCRATE_ULTRA2); 1674 maxsync = max(maxsync, (u_int)AHC_SYNCRATE_ULTRA2);
1675 *ppr_options &= ~MSG_EXT_PPR_DT_REQ; 1675 *ppr_options &= ~MSG_EXT_PPR_DT_REQ;
1676 } 1676 }
1677 if (transinfo->period == 0) { 1677 if (transinfo->period == 0) {
@@ -1679,7 +1679,7 @@ ahc_devlimited_syncrate(struct ahc_softc *ahc,
1679 *ppr_options = 0; 1679 *ppr_options = 0;
1680 return (NULL); 1680 return (NULL);
1681 } 1681 }
1682 *period = MAX(*period, transinfo->period); 1682 *period = max(*period, (u_int)transinfo->period);
1683 return (ahc_find_syncrate(ahc, period, ppr_options, maxsync)); 1683 return (ahc_find_syncrate(ahc, period, ppr_options, maxsync));
1684} 1684}
1685 1685
@@ -1804,12 +1804,12 @@ ahc_validate_offset(struct ahc_softc *ahc,
1804 else 1804 else
1805 maxoffset = MAX_OFFSET_8BIT; 1805 maxoffset = MAX_OFFSET_8BIT;
1806 } 1806 }
1807 *offset = MIN(*offset, maxoffset); 1807 *offset = min(*offset, maxoffset);
1808 if (tinfo != NULL) { 1808 if (tinfo != NULL) {
1809 if (role == ROLE_TARGET) 1809 if (role == ROLE_TARGET)
1810 *offset = MIN(*offset, tinfo->user.offset); 1810 *offset = min(*offset, (u_int)tinfo->user.offset);
1811 else 1811 else
1812 *offset = MIN(*offset, tinfo->goal.offset); 1812 *offset = min(*offset, (u_int)tinfo->goal.offset);
1813 } 1813 }
1814} 1814}
1815 1815
@@ -1835,9 +1835,9 @@ ahc_validate_width(struct ahc_softc *ahc, struct ahc_initiator_tinfo *tinfo,
1835 } 1835 }
1836 if (tinfo != NULL) { 1836 if (tinfo != NULL) {
1837 if (role == ROLE_TARGET) 1837 if (role == ROLE_TARGET)
1838 *bus_width = MIN(tinfo->user.width, *bus_width); 1838 *bus_width = min((u_int)tinfo->user.width, *bus_width);
1839 else 1839 else
1840 *bus_width = MIN(tinfo->goal.width, *bus_width); 1840 *bus_width = min((u_int)tinfo->goal.width, *bus_width);
1841 } 1841 }
1842} 1842}
1843 1843
@@ -1986,7 +1986,7 @@ ahc_set_syncrate(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
1986 tinfo->curr.ppr_options = ppr_options; 1986 tinfo->curr.ppr_options = ppr_options;
1987 1987
1988 ahc_send_async(ahc, devinfo->channel, devinfo->target, 1988 ahc_send_async(ahc, devinfo->channel, devinfo->target,
1989 CAM_LUN_WILDCARD, AC_TRANSFER_NEG, NULL); 1989 CAM_LUN_WILDCARD, AC_TRANSFER_NEG);
1990 if (bootverbose) { 1990 if (bootverbose) {
1991 if (offset != 0) { 1991 if (offset != 0) {
1992 printf("%s: target %d synchronous at %sMHz%s, " 1992 printf("%s: target %d synchronous at %sMHz%s, "
@@ -2056,7 +2056,7 @@ ahc_set_width(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
2056 tinfo->curr.width = width; 2056 tinfo->curr.width = width;
2057 2057
2058 ahc_send_async(ahc, devinfo->channel, devinfo->target, 2058 ahc_send_async(ahc, devinfo->channel, devinfo->target,
2059 CAM_LUN_WILDCARD, AC_TRANSFER_NEG, NULL); 2059 CAM_LUN_WILDCARD, AC_TRANSFER_NEG);
2060 if (bootverbose) { 2060 if (bootverbose) {
2061 printf("%s: target %d using %dbit transfers\n", 2061 printf("%s: target %d using %dbit transfers\n",
2062 ahc_name(ahc), devinfo->target, 2062 ahc_name(ahc), devinfo->target,
@@ -2074,12 +2074,14 @@ ahc_set_width(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
2074 * Update the current state of tagged queuing for a given target. 2074 * Update the current state of tagged queuing for a given target.
2075 */ 2075 */
2076void 2076void
2077ahc_set_tags(struct ahc_softc *ahc, struct ahc_devinfo *devinfo, 2077ahc_set_tags(struct ahc_softc *ahc, struct scsi_cmnd *cmd,
2078 ahc_queue_alg alg) 2078 struct ahc_devinfo *devinfo, ahc_queue_alg alg)
2079{ 2079{
2080 ahc_platform_set_tags(ahc, devinfo, alg); 2080 struct scsi_device *sdev = cmd->device;
2081
2082 ahc_platform_set_tags(ahc, sdev, devinfo, alg);
2081 ahc_send_async(ahc, devinfo->channel, devinfo->target, 2083 ahc_send_async(ahc, devinfo->channel, devinfo->target,
2082 devinfo->lun, AC_TRANSFER_NEG, &alg); 2084 devinfo->lun, AC_TRANSFER_NEG);
2083} 2085}
2084 2086
2085/* 2087/*
@@ -3489,7 +3491,7 @@ ahc_handle_msg_reject(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
3489 printf("(%s:%c:%d:%d): refuses tagged commands. " 3491 printf("(%s:%c:%d:%d): refuses tagged commands. "
3490 "Performing non-tagged I/O\n", ahc_name(ahc), 3492 "Performing non-tagged I/O\n", ahc_name(ahc),
3491 devinfo->channel, devinfo->target, devinfo->lun); 3493 devinfo->channel, devinfo->target, devinfo->lun);
3492 ahc_set_tags(ahc, devinfo, AHC_QUEUE_NONE); 3494 ahc_set_tags(ahc, scb->io_ctx, devinfo, AHC_QUEUE_NONE);
3493 mask = ~0x23; 3495 mask = ~0x23;
3494 } else { 3496 } else {
3495 printf("(%s:%c:%d:%d): refuses %s tagged commands. " 3497 printf("(%s:%c:%d:%d): refuses %s tagged commands. "
@@ -3497,7 +3499,7 @@ ahc_handle_msg_reject(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
3497 ahc_name(ahc), devinfo->channel, devinfo->target, 3499 ahc_name(ahc), devinfo->channel, devinfo->target,
3498 devinfo->lun, tag_type == MSG_ORDERED_TASK 3500 devinfo->lun, tag_type == MSG_ORDERED_TASK
3499 ? "ordered" : "head of queue"); 3501 ? "ordered" : "head of queue");
3500 ahc_set_tags(ahc, devinfo, AHC_QUEUE_BASIC); 3502 ahc_set_tags(ahc, scb->io_ctx, devinfo, AHC_QUEUE_BASIC);
3501 mask = ~0x03; 3503 mask = ~0x03;
3502 } 3504 }
3503 3505
@@ -3763,7 +3765,7 @@ ahc_handle_devreset(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
3763 3765
3764 if (status != CAM_SEL_TIMEOUT) 3766 if (status != CAM_SEL_TIMEOUT)
3765 ahc_send_async(ahc, devinfo->channel, devinfo->target, 3767 ahc_send_async(ahc, devinfo->channel, devinfo->target,
3766 CAM_LUN_WILDCARD, AC_SENT_BDR, NULL); 3768 CAM_LUN_WILDCARD, AC_SENT_BDR);
3767 3769
3768 if (message != NULL 3770 if (message != NULL
3769 && (verbose_level <= bootverbose)) 3771 && (verbose_level <= bootverbose))
@@ -4406,7 +4408,7 @@ ahc_alloc_scbs(struct ahc_softc *ahc)
4406 physaddr = sg_map->sg_physaddr; 4408 physaddr = sg_map->sg_physaddr;
4407 4409
4408 newcount = (PAGE_SIZE / (AHC_NSEG * sizeof(struct ahc_dma_seg))); 4410 newcount = (PAGE_SIZE / (AHC_NSEG * sizeof(struct ahc_dma_seg)));
4409 newcount = MIN(newcount, (AHC_SCB_MAX_ALLOC - scb_data->numscbs)); 4411 newcount = min(newcount, (AHC_SCB_MAX_ALLOC - scb_data->numscbs));
4410 for (i = 0; i < newcount; i++) { 4412 for (i = 0; i < newcount; i++) {
4411 struct scb_platform_data *pdata; 4413 struct scb_platform_data *pdata;
4412#ifndef __linux__ 4414#ifndef __linux__
@@ -6018,7 +6020,7 @@ ahc_reset_channel(struct ahc_softc *ahc, char channel, int initiate_reset)
6018#endif 6020#endif
6019 /* Notify the XPT that a bus reset occurred */ 6021 /* Notify the XPT that a bus reset occurred */
6020 ahc_send_async(ahc, devinfo.channel, CAM_TARGET_WILDCARD, 6022 ahc_send_async(ahc, devinfo.channel, CAM_TARGET_WILDCARD,
6021 CAM_LUN_WILDCARD, AC_BUS_RESET, NULL); 6023 CAM_LUN_WILDCARD, AC_BUS_RESET);
6022 6024
6023 /* 6025 /*
6024 * Revert to async/narrow transfers until we renegotiate. 6026 * Revert to async/narrow transfers until we renegotiate.
@@ -6442,7 +6444,7 @@ ahc_download_instr(struct ahc_softc *ahc, u_int instrptr, uint8_t *dconsts)
6442 if (skip_addr > i) { 6444 if (skip_addr > i) {
6443 int end_addr; 6445 int end_addr;
6444 6446
6445 end_addr = MIN(address, skip_addr); 6447 end_addr = min(address, skip_addr);
6446 address_offset += end_addr - i; 6448 address_offset += end_addr - i;
6447 i = skip_addr; 6449 i = skip_addr;
6448 } else { 6450 } else {
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index 43ab753d2739..660f26e23a38 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -328,7 +328,7 @@ static uint32_t aic7xxx_seltime;
328 * force all outstanding transactions to be serviced prior to a new 328 * force all outstanding transactions to be serviced prior to a new
329 * transaction. 329 * transaction.
330 */ 330 */
331uint32_t aic7xxx_periodic_otag; 331static uint32_t aic7xxx_periodic_otag;
332 332
333/* 333/*
334 * Module information and settable options. 334 * Module information and settable options.
@@ -512,7 +512,6 @@ ahc_linux_target_alloc(struct scsi_target *starget)
512 struct seeprom_config *sc = ahc->seep_config; 512 struct seeprom_config *sc = ahc->seep_config;
513 unsigned long flags; 513 unsigned long flags;
514 struct scsi_target **ahc_targp = ahc_linux_target_in_softc(starget); 514 struct scsi_target **ahc_targp = ahc_linux_target_in_softc(starget);
515 struct ahc_linux_target *targ = scsi_transport_target_data(starget);
516 unsigned short scsirate; 515 unsigned short scsirate;
517 struct ahc_devinfo devinfo; 516 struct ahc_devinfo devinfo;
518 struct ahc_initiator_tinfo *tinfo; 517 struct ahc_initiator_tinfo *tinfo;
@@ -533,7 +532,6 @@ ahc_linux_target_alloc(struct scsi_target *starget)
533 BUG_ON(*ahc_targp != NULL); 532 BUG_ON(*ahc_targp != NULL);
534 533
535 *ahc_targp = starget; 534 *ahc_targp = starget;
536 memset(targ, 0, sizeof(*targ));
537 535
538 if (sc) { 536 if (sc) {
539 int maxsync = AHC_SYNCRATE_DT; 537 int maxsync = AHC_SYNCRATE_DT;
@@ -594,14 +592,11 @@ ahc_linux_slave_alloc(struct scsi_device *sdev)
594 struct ahc_softc *ahc = 592 struct ahc_softc *ahc =
595 *((struct ahc_softc **)sdev->host->hostdata); 593 *((struct ahc_softc **)sdev->host->hostdata);
596 struct scsi_target *starget = sdev->sdev_target; 594 struct scsi_target *starget = sdev->sdev_target;
597 struct ahc_linux_target *targ = scsi_transport_target_data(starget);
598 struct ahc_linux_device *dev; 595 struct ahc_linux_device *dev;
599 596
600 if (bootverbose) 597 if (bootverbose)
601 printf("%s: Slave Alloc %d\n", ahc_name(ahc), sdev->id); 598 printf("%s: Slave Alloc %d\n", ahc_name(ahc), sdev->id);
602 599
603 BUG_ON(targ->sdev[sdev->lun] != NULL);
604
605 dev = scsi_transport_device_data(sdev); 600 dev = scsi_transport_device_data(sdev);
606 memset(dev, 0, sizeof(*dev)); 601 memset(dev, 0, sizeof(*dev));
607 602
@@ -618,8 +613,6 @@ ahc_linux_slave_alloc(struct scsi_device *sdev)
618 */ 613 */
619 dev->maxtags = 0; 614 dev->maxtags = 0;
620 615
621 targ->sdev[sdev->lun] = sdev;
622
623 spi_period(starget) = 0; 616 spi_period(starget) = 0;
624 617
625 return 0; 618 return 0;
@@ -644,22 +637,6 @@ ahc_linux_slave_configure(struct scsi_device *sdev)
644 return 0; 637 return 0;
645} 638}
646 639
647static void
648ahc_linux_slave_destroy(struct scsi_device *sdev)
649{
650 struct ahc_softc *ahc;
651 struct ahc_linux_device *dev = scsi_transport_device_data(sdev);
652 struct ahc_linux_target *targ = scsi_transport_target_data(sdev->sdev_target);
653
654 ahc = *((struct ahc_softc **)sdev->host->hostdata);
655 if (bootverbose)
656 printf("%s: Slave Destroy %d\n", ahc_name(ahc), sdev->id);
657
658 BUG_ON(dev->active);
659
660 targ->sdev[sdev->lun] = NULL;
661}
662
663#if defined(__i386__) 640#if defined(__i386__)
664/* 641/*
665 * Return the disk geometry for the given SCSI device. 642 * Return the disk geometry for the given SCSI device.
@@ -777,11 +754,11 @@ struct scsi_host_template aic7xxx_driver_template = {
777#endif 754#endif
778 .can_queue = AHC_MAX_QUEUE, 755 .can_queue = AHC_MAX_QUEUE,
779 .this_id = -1, 756 .this_id = -1,
757 .max_sectors = 8192,
780 .cmd_per_lun = 2, 758 .cmd_per_lun = 2,
781 .use_clustering = ENABLE_CLUSTERING, 759 .use_clustering = ENABLE_CLUSTERING,
782 .slave_alloc = ahc_linux_slave_alloc, 760 .slave_alloc = ahc_linux_slave_alloc,
783 .slave_configure = ahc_linux_slave_configure, 761 .slave_configure = ahc_linux_slave_configure,
784 .slave_destroy = ahc_linux_slave_destroy,
785 .target_alloc = ahc_linux_target_alloc, 762 .target_alloc = ahc_linux_target_alloc,
786 .target_destroy = ahc_linux_target_destroy, 763 .target_destroy = ahc_linux_target_destroy,
787}; 764};
@@ -1203,21 +1180,13 @@ void
1203ahc_platform_free(struct ahc_softc *ahc) 1180ahc_platform_free(struct ahc_softc *ahc)
1204{ 1181{
1205 struct scsi_target *starget; 1182 struct scsi_target *starget;
1206 int i, j; 1183 int i;
1207 1184
1208 if (ahc->platform_data != NULL) { 1185 if (ahc->platform_data != NULL) {
1209 /* destroy all of the device and target objects */ 1186 /* destroy all of the device and target objects */
1210 for (i = 0; i < AHC_NUM_TARGETS; i++) { 1187 for (i = 0; i < AHC_NUM_TARGETS; i++) {
1211 starget = ahc->platform_data->starget[i]; 1188 starget = ahc->platform_data->starget[i];
1212 if (starget != NULL) { 1189 if (starget != NULL) {
1213 for (j = 0; j < AHC_NUM_LUNS; j++) {
1214 struct ahc_linux_target *targ =
1215 scsi_transport_target_data(starget);
1216
1217 if (targ->sdev[j] == NULL)
1218 continue;
1219 targ->sdev[j] = NULL;
1220 }
1221 ahc->platform_data->starget[i] = NULL; 1190 ahc->platform_data->starget[i] = NULL;
1222 } 1191 }
1223 } 1192 }
@@ -1251,24 +1220,13 @@ ahc_platform_freeze_devq(struct ahc_softc *ahc, struct scb *scb)
1251} 1220}
1252 1221
1253void 1222void
1254ahc_platform_set_tags(struct ahc_softc *ahc, struct ahc_devinfo *devinfo, 1223ahc_platform_set_tags(struct ahc_softc *ahc, struct scsi_device *sdev,
1255 ahc_queue_alg alg) 1224 struct ahc_devinfo *devinfo, ahc_queue_alg alg)
1256{ 1225{
1257 struct scsi_target *starget;
1258 struct ahc_linux_target *targ;
1259 struct ahc_linux_device *dev; 1226 struct ahc_linux_device *dev;
1260 struct scsi_device *sdev;
1261 u_int target_offset;
1262 int was_queuing; 1227 int was_queuing;
1263 int now_queuing; 1228 int now_queuing;
1264 1229
1265 target_offset = devinfo->target;
1266 if (devinfo->channel != 'A')
1267 target_offset += 8;
1268 starget = ahc->platform_data->starget[target_offset];
1269 targ = scsi_transport_target_data(starget);
1270 BUG_ON(targ == NULL);
1271 sdev = targ->sdev[devinfo->lun];
1272 if (sdev == NULL) 1230 if (sdev == NULL)
1273 return; 1231 return;
1274 dev = scsi_transport_device_data(sdev); 1232 dev = scsi_transport_device_data(sdev);
@@ -1401,11 +1359,15 @@ ahc_linux_device_queue_depth(struct scsi_device *sdev)
1401 tags = ahc_linux_user_tagdepth(ahc, &devinfo); 1359 tags = ahc_linux_user_tagdepth(ahc, &devinfo);
1402 if (tags != 0 && sdev->tagged_supported != 0) { 1360 if (tags != 0 && sdev->tagged_supported != 0) {
1403 1361
1404 ahc_set_tags(ahc, &devinfo, AHC_QUEUE_TAGGED); 1362 ahc_platform_set_tags(ahc, sdev, &devinfo, AHC_QUEUE_TAGGED);
1363 ahc_send_async(ahc, devinfo.channel, devinfo.target,
1364 devinfo.lun, AC_TRANSFER_NEG);
1405 ahc_print_devinfo(ahc, &devinfo); 1365 ahc_print_devinfo(ahc, &devinfo);
1406 printf("Tagged Queuing enabled. Depth %d\n", tags); 1366 printf("Tagged Queuing enabled. Depth %d\n", tags);
1407 } else { 1367 } else {
1408 ahc_set_tags(ahc, &devinfo, AHC_QUEUE_NONE); 1368 ahc_platform_set_tags(ahc, sdev, &devinfo, AHC_QUEUE_NONE);
1369 ahc_send_async(ahc, devinfo.channel, devinfo.target,
1370 devinfo.lun, AC_TRANSFER_NEG);
1409 } 1371 }
1410} 1372}
1411 1373
@@ -1629,7 +1591,7 @@ ahc_platform_flushwork(struct ahc_softc *ahc)
1629 1591
1630void 1592void
1631ahc_send_async(struct ahc_softc *ahc, char channel, 1593ahc_send_async(struct ahc_softc *ahc, char channel,
1632 u_int target, u_int lun, ac_code code, void *arg) 1594 u_int target, u_int lun, ac_code code)
1633{ 1595{
1634 switch (code) { 1596 switch (code) {
1635 case AC_TRANSFER_NEG: 1597 case AC_TRANSFER_NEG:
@@ -1875,9 +1837,9 @@ ahc_linux_handle_scsi_status(struct ahc_softc *ahc,
1875 if (scb->flags & SCB_SENSE) { 1837 if (scb->flags & SCB_SENSE) {
1876 u_int sense_size; 1838 u_int sense_size;
1877 1839
1878 sense_size = MIN(sizeof(struct scsi_sense_data) 1840 sense_size = min(sizeof(struct scsi_sense_data)
1879 - ahc_get_sense_residual(scb), 1841 - ahc_get_sense_residual(scb),
1880 sizeof(cmd->sense_buffer)); 1842 (u_long)sizeof(cmd->sense_buffer));
1881 memcpy(cmd->sense_buffer, 1843 memcpy(cmd->sense_buffer,
1882 ahc_get_sense_buf(ahc, scb), sense_size); 1844 ahc_get_sense_buf(ahc, scb), sense_size);
1883 if (sense_size < sizeof(cmd->sense_buffer)) 1845 if (sense_size < sizeof(cmd->sense_buffer))
@@ -1946,7 +1908,7 @@ ahc_linux_handle_scsi_status(struct ahc_softc *ahc,
1946 } 1908 }
1947 ahc_set_transaction_status(scb, CAM_REQUEUE_REQ); 1909 ahc_set_transaction_status(scb, CAM_REQUEUE_REQ);
1948 ahc_set_scsi_status(scb, SCSI_STATUS_OK); 1910 ahc_set_scsi_status(scb, SCSI_STATUS_OK);
1949 ahc_platform_set_tags(ahc, &devinfo, 1911 ahc_platform_set_tags(ahc, sdev, &devinfo,
1950 (dev->flags & AHC_DEV_Q_BASIC) 1912 (dev->flags & AHC_DEV_Q_BASIC)
1951 ? AHC_QUEUE_BASIC : AHC_QUEUE_TAGGED); 1913 ? AHC_QUEUE_BASIC : AHC_QUEUE_TAGGED);
1952 break; 1914 break;
@@ -1957,7 +1919,7 @@ ahc_linux_handle_scsi_status(struct ahc_softc *ahc,
1957 */ 1919 */
1958 dev->openings = 1; 1920 dev->openings = 1;
1959 ahc_set_scsi_status(scb, SCSI_STATUS_BUSY); 1921 ahc_set_scsi_status(scb, SCSI_STATUS_BUSY);
1960 ahc_platform_set_tags(ahc, &devinfo, 1922 ahc_platform_set_tags(ahc, sdev, &devinfo,
1961 (dev->flags & AHC_DEV_Q_BASIC) 1923 (dev->flags & AHC_DEV_Q_BASIC)
1962 ? AHC_QUEUE_BASIC : AHC_QUEUE_TAGGED); 1924 ? AHC_QUEUE_BASIC : AHC_QUEUE_TAGGED);
1963 break; 1925 break;
@@ -2599,8 +2561,6 @@ ahc_linux_init(void)
2599 if (!ahc_linux_transport_template) 2561 if (!ahc_linux_transport_template)
2600 return -ENODEV; 2562 return -ENODEV;
2601 2563
2602 scsi_transport_reserve_target(ahc_linux_transport_template,
2603 sizeof(struct ahc_linux_target));
2604 scsi_transport_reserve_device(ahc_linux_transport_template, 2564 scsi_transport_reserve_device(ahc_linux_transport_template,
2605 sizeof(struct ahc_linux_device)); 2565 sizeof(struct ahc_linux_device));
2606 2566
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.h b/drivers/scsi/aic7xxx/aic7xxx_osm.h
index a87a4ce090df..85ae5d836fa4 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.h
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.h
@@ -256,7 +256,6 @@ typedef enum {
256 AHC_DEV_PERIODIC_OTAG = 0x40, /* Send OTAG to prevent starvation */ 256 AHC_DEV_PERIODIC_OTAG = 0x40, /* Send OTAG to prevent starvation */
257} ahc_linux_dev_flags; 257} ahc_linux_dev_flags;
258 258
259struct ahc_linux_target;
260struct ahc_linux_device { 259struct ahc_linux_device {
261 /* 260 /*
262 * The number of transactions currently 261 * The number of transactions currently
@@ -329,12 +328,6 @@ struct ahc_linux_device {
329#define AHC_OTAG_THRESH 500 328#define AHC_OTAG_THRESH 500
330}; 329};
331 330
332struct ahc_linux_target {
333 struct scsi_device *sdev[AHC_NUM_LUNS];
334 struct ahc_transinfo last_tinfo;
335 struct ahc_softc *ahc;
336};
337
338/********************* Definitions Required by the Core ***********************/ 331/********************* Definitions Required by the Core ***********************/
339/* 332/*
340 * Number of SG segments we require. So long as the S/G segments for 333 * Number of SG segments we require. So long as the S/G segments for
@@ -533,8 +526,6 @@ ahc_unlock(struct ahc_softc *ahc, unsigned long *flags)
533#define PCIR_SUBVEND_0 0x2c 526#define PCIR_SUBVEND_0 0x2c
534#define PCIR_SUBDEV_0 0x2e 527#define PCIR_SUBDEV_0 0x2e
535 528
536extern struct pci_driver aic7xxx_pci_driver;
537
538typedef enum 529typedef enum
539{ 530{
540 AHC_POWER_STATE_D0, 531 AHC_POWER_STATE_D0,
@@ -824,7 +815,7 @@ ahc_freeze_scb(struct scb *scb)
824 } 815 }
825} 816}
826 817
827void ahc_platform_set_tags(struct ahc_softc *ahc, 818void ahc_platform_set_tags(struct ahc_softc *ahc, struct scsi_device *sdev,
828 struct ahc_devinfo *devinfo, ahc_queue_alg); 819 struct ahc_devinfo *devinfo, ahc_queue_alg);
829int ahc_platform_abort_scbs(struct ahc_softc *ahc, int target, 820int ahc_platform_abort_scbs(struct ahc_softc *ahc, int target,
830 char channel, int lun, u_int tag, 821 char channel, int lun, u_int tag,
@@ -834,7 +825,7 @@ irqreturn_t
834void ahc_platform_flushwork(struct ahc_softc *ahc); 825void ahc_platform_flushwork(struct ahc_softc *ahc);
835void ahc_done(struct ahc_softc*, struct scb*); 826void ahc_done(struct ahc_softc*, struct scb*);
836void ahc_send_async(struct ahc_softc *, char channel, 827void ahc_send_async(struct ahc_softc *, char channel,
837 u_int target, u_int lun, ac_code, void *); 828 u_int target, u_int lun, ac_code);
838void ahc_print_path(struct ahc_softc *, struct scb *); 829void ahc_print_path(struct ahc_softc *, struct scb *);
839void ahc_platform_dump_card_state(struct ahc_softc *ahc); 830void ahc_platform_dump_card_state(struct ahc_softc *ahc);
840 831
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
index d20ca514e9f3..ea5687df732d 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
@@ -130,7 +130,7 @@ static struct pci_device_id ahc_linux_pci_id_table[] = {
130 130
131MODULE_DEVICE_TABLE(pci, ahc_linux_pci_id_table); 131MODULE_DEVICE_TABLE(pci, ahc_linux_pci_id_table);
132 132
133struct pci_driver aic7xxx_pci_driver = { 133static struct pci_driver aic7xxx_pci_driver = {
134 .name = "aic7xxx", 134 .name = "aic7xxx",
135 .probe = ahc_linux_pci_dev_probe, 135 .probe = ahc_linux_pci_dev_probe,
136 .remove = ahc_linux_pci_dev_remove, 136 .remove = ahc_linux_pci_dev_remove,
diff --git a/drivers/scsi/aic7xxx/aic7xxx_pci.c b/drivers/scsi/aic7xxx/aic7xxx_pci.c
index 63cab2d74552..09c8172c9e5e 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_pci.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_pci.c
@@ -168,7 +168,7 @@ static ahc_device_setup_t ahc_aha394XX_setup;
168static ahc_device_setup_t ahc_aha494XX_setup; 168static ahc_device_setup_t ahc_aha494XX_setup;
169static ahc_device_setup_t ahc_aha398XX_setup; 169static ahc_device_setup_t ahc_aha398XX_setup;
170 170
171struct ahc_pci_identity ahc_pci_ident_table [] = 171static struct ahc_pci_identity ahc_pci_ident_table [] =
172{ 172{
173 /* aic7850 based controllers */ 173 /* aic7850 based controllers */
174 { 174 {
@@ -559,7 +559,7 @@ struct ahc_pci_identity ahc_pci_ident_table [] =
559 } 559 }
560}; 560};
561 561
562const u_int ahc_num_pci_devs = ARRAY_SIZE(ahc_pci_ident_table); 562static const u_int ahc_num_pci_devs = ARRAY_SIZE(ahc_pci_ident_table);
563 563
564#define AHC_394X_SLOT_CHANNEL_A 4 564#define AHC_394X_SLOT_CHANNEL_A 4
565#define AHC_394X_SLOT_CHANNEL_B 5 565#define AHC_394X_SLOT_CHANNEL_B 5
diff --git a/drivers/scsi/aic7xxx/aic7xxx_proc.c b/drivers/scsi/aic7xxx/aic7xxx_proc.c
index 5914b4aa4a8f..99e5443e7535 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_proc.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_proc.c
@@ -182,7 +182,6 @@ ahc_dump_target_state(struct ahc_softc *ahc, struct info_str *info,
182 u_int our_id, char channel, u_int target_id, 182 u_int our_id, char channel, u_int target_id,
183 u_int target_offset) 183 u_int target_offset)
184{ 184{
185 struct ahc_linux_target *targ;
186 struct scsi_target *starget; 185 struct scsi_target *starget;
187 struct ahc_initiator_tinfo *tinfo; 186 struct ahc_initiator_tinfo *tinfo;
188 struct ahc_tmode_tstate *tstate; 187 struct ahc_tmode_tstate *tstate;
@@ -198,7 +197,6 @@ ahc_dump_target_state(struct ahc_softc *ahc, struct info_str *info,
198 starget = ahc->platform_data->starget[target_offset]; 197 starget = ahc->platform_data->starget[target_offset];
199 if (!starget) 198 if (!starget)
200 return; 199 return;
201 targ = scsi_transport_target_data(starget);
202 200
203 copy_info(info, "\tGoal: "); 201 copy_info(info, "\tGoal: ");
204 ahc_format_transinfo(info, &tinfo->goal); 202 ahc_format_transinfo(info, &tinfo->goal);
@@ -208,7 +206,7 @@ ahc_dump_target_state(struct ahc_softc *ahc, struct info_str *info,
208 for (lun = 0; lun < AHC_NUM_LUNS; lun++) { 206 for (lun = 0; lun < AHC_NUM_LUNS; lun++) {
209 struct scsi_device *sdev; 207 struct scsi_device *sdev;
210 208
211 sdev = targ->sdev[lun]; 209 sdev = scsi_device_lookup_by_target(starget, lun);
212 210
213 if (sdev == NULL) 211 if (sdev == NULL)
214 continue; 212 continue;
@@ -383,11 +381,11 @@ ahc_linux_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
383 } 381 }
384 copy_info(&info, "\n"); 382 copy_info(&info, "\n");
385 383
386 max_targ = 15; 384 max_targ = 16;
387 if ((ahc->features & (AHC_WIDE|AHC_TWIN)) == 0) 385 if ((ahc->features & (AHC_WIDE|AHC_TWIN)) == 0)
388 max_targ = 7; 386 max_targ = 8;
389 387
390 for (i = 0; i <= max_targ; i++) { 388 for (i = 0; i < max_targ; i++) {
391 u_int our_id; 389 u_int our_id;
392 u_int target_id; 390 u_int target_id;
393 char channel; 391 char channel;
diff --git a/drivers/scsi/aic7xxx_old.c b/drivers/scsi/aic7xxx_old.c
index bcd7fffab907..46eed10b25d9 100644
--- a/drivers/scsi/aic7xxx_old.c
+++ b/drivers/scsi/aic7xxx_old.c
@@ -2646,7 +2646,7 @@ static void aic7xxx_done_cmds_complete(struct aic7xxx_host *p)
2646 2646
2647 while (p->completeq.head != NULL) { 2647 while (p->completeq.head != NULL) {
2648 cmd = p->completeq.head; 2648 cmd = p->completeq.head;
2649 p->completeq.head = (struct scsi_Cmnd *) cmd->host_scribble; 2649 p->completeq.head = (struct scsi_cmnd *) cmd->host_scribble;
2650 cmd->host_scribble = NULL; 2650 cmd->host_scribble = NULL;
2651 cmd->scsi_done(cmd); 2651 cmd->scsi_done(cmd);
2652 } 2652 }
diff --git a/drivers/scsi/aic94xx/aic94xx_hwi.c b/drivers/scsi/aic94xx/aic94xx_hwi.c
index 3c2d7a379931..af7e01134364 100644
--- a/drivers/scsi/aic94xx/aic94xx_hwi.c
+++ b/drivers/scsi/aic94xx/aic94xx_hwi.c
@@ -112,6 +112,21 @@ static int asd_init_phy(struct asd_phy *phy)
112 return 0; 112 return 0;
113} 113}
114 114
115static void asd_init_ports(struct asd_ha_struct *asd_ha)
116{
117 int i;
118
119 spin_lock_init(&asd_ha->asd_ports_lock);
120 for (i = 0; i < ASD_MAX_PHYS; i++) {
121 struct asd_port *asd_port = &asd_ha->asd_ports[i];
122
123 memset(asd_port->sas_addr, 0, SAS_ADDR_SIZE);
124 memset(asd_port->attached_sas_addr, 0, SAS_ADDR_SIZE);
125 asd_port->phy_mask = 0;
126 asd_port->num_phys = 0;
127 }
128}
129
115static int asd_init_phys(struct asd_ha_struct *asd_ha) 130static int asd_init_phys(struct asd_ha_struct *asd_ha)
116{ 131{
117 u8 i; 132 u8 i;
@@ -121,6 +136,7 @@ static int asd_init_phys(struct asd_ha_struct *asd_ha)
121 struct asd_phy *phy = &asd_ha->phys[i]; 136 struct asd_phy *phy = &asd_ha->phys[i];
122 137
123 phy->phy_desc = &asd_ha->hw_prof.phy_desc[i]; 138 phy->phy_desc = &asd_ha->hw_prof.phy_desc[i];
139 phy->asd_port = NULL;
124 140
125 phy->sas_phy.enabled = 0; 141 phy->sas_phy.enabled = 0;
126 phy->sas_phy.id = i; 142 phy->sas_phy.id = i;
@@ -658,6 +674,8 @@ int asd_init_hw(struct asd_ha_struct *asd_ha)
658 goto Out; 674 goto Out;
659 } 675 }
660 676
677 asd_init_ports(asd_ha);
678
661 err = asd_init_scbs(asd_ha); 679 err = asd_init_scbs(asd_ha);
662 if (err) { 680 if (err) {
663 asd_printk("couldn't initialize scbs for %s\n", 681 asd_printk("couldn't initialize scbs for %s\n",
diff --git a/drivers/scsi/aic94xx/aic94xx_hwi.h b/drivers/scsi/aic94xx/aic94xx_hwi.h
index 14319d1d6804..c6c3d18222fa 100644
--- a/drivers/scsi/aic94xx/aic94xx_hwi.h
+++ b/drivers/scsi/aic94xx/aic94xx_hwi.h
@@ -46,6 +46,7 @@
46#define PCI_DEVICE_ID_ADAPTEC2_RAZOR10 0x410 46#define PCI_DEVICE_ID_ADAPTEC2_RAZOR10 0x410
47#define PCI_DEVICE_ID_ADAPTEC2_RAZOR12 0x412 47#define PCI_DEVICE_ID_ADAPTEC2_RAZOR12 0x412
48#define PCI_DEVICE_ID_ADAPTEC2_RAZOR1E 0x41E 48#define PCI_DEVICE_ID_ADAPTEC2_RAZOR1E 0x41E
49#define PCI_DEVICE_ID_ADAPTEC2_RAZOR1F 0x41F
49#define PCI_DEVICE_ID_ADAPTEC2_RAZOR30 0x430 50#define PCI_DEVICE_ID_ADAPTEC2_RAZOR30 0x430
50#define PCI_DEVICE_ID_ADAPTEC2_RAZOR32 0x432 51#define PCI_DEVICE_ID_ADAPTEC2_RAZOR32 0x432
51#define PCI_DEVICE_ID_ADAPTEC2_RAZOR3E 0x43E 52#define PCI_DEVICE_ID_ADAPTEC2_RAZOR3E 0x43E
@@ -192,6 +193,16 @@ struct asd_seq_data {
192 struct asd_ascb **escb_arr; /* array of pointers to escbs */ 193 struct asd_ascb **escb_arr; /* array of pointers to escbs */
193}; 194};
194 195
196/* This is an internal port structure. These are used to get accurate
197 * phy_mask for updating DDB 0.
198 */
199struct asd_port {
200 u8 sas_addr[SAS_ADDR_SIZE];
201 u8 attached_sas_addr[SAS_ADDR_SIZE];
202 u32 phy_mask;
203 int num_phys;
204};
205
195/* This is the Host Adapter structure. It describes the hardware 206/* This is the Host Adapter structure. It describes the hardware
196 * SAS adapter. 207 * SAS adapter.
197 */ 208 */
@@ -210,6 +221,8 @@ struct asd_ha_struct {
210 struct hw_profile hw_prof; 221 struct hw_profile hw_prof;
211 222
212 struct asd_phy phys[ASD_MAX_PHYS]; 223 struct asd_phy phys[ASD_MAX_PHYS];
224 spinlock_t asd_ports_lock;
225 struct asd_port asd_ports[ASD_MAX_PHYS];
213 struct asd_sas_port ports[ASD_MAX_PHYS]; 226 struct asd_sas_port ports[ASD_MAX_PHYS];
214 227
215 struct dma_pool *scb_pool; 228 struct dma_pool *scb_pool;
diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c
index 3a5bbba3976e..42302ef05ee5 100644
--- a/drivers/scsi/aic94xx/aic94xx_init.c
+++ b/drivers/scsi/aic94xx/aic94xx_init.c
@@ -795,8 +795,6 @@ static void asd_remove_driver_attrs(struct device_driver *driver)
795} 795}
796 796
797static struct sas_domain_function_template aic94xx_transport_functions = { 797static struct sas_domain_function_template aic94xx_transport_functions = {
798 .lldd_port_formed = asd_update_port_links,
799
800 .lldd_dev_found = asd_dev_found, 798 .lldd_dev_found = asd_dev_found,
801 .lldd_dev_gone = asd_dev_gone, 799 .lldd_dev_gone = asd_dev_gone,
802 800
@@ -823,6 +821,8 @@ static const struct pci_device_id aic94xx_pci_table[] __devinitdata = {
823 0, 0, 1}, 821 0, 0, 1},
824 {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_RAZOR1E), 822 {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_RAZOR1E),
825 0, 0, 1}, 823 0, 0, 1},
824 {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_RAZOR1F),
825 0, 0, 1},
826 {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_RAZOR30), 826 {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_RAZOR30),
827 0, 0, 2}, 827 0, 0, 2},
828 {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_RAZOR32), 828 {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_RAZOR32),
diff --git a/drivers/scsi/aic94xx/aic94xx_sas.h b/drivers/scsi/aic94xx/aic94xx_sas.h
index 64d231712345..9050e93bfd5e 100644
--- a/drivers/scsi/aic94xx/aic94xx_sas.h
+++ b/drivers/scsi/aic94xx/aic94xx_sas.h
@@ -733,6 +733,7 @@ struct asd_phy {
733 733
734 struct sas_identify_frame *identify_frame; 734 struct sas_identify_frame *identify_frame;
735 struct asd_dma_tok *id_frm_tok; 735 struct asd_dma_tok *id_frm_tok;
736 struct asd_port *asd_port;
736 737
737 u8 frame_rcvd[ASD_EDB_SIZE]; 738 u8 frame_rcvd[ASD_EDB_SIZE];
738}; 739};
diff --git a/drivers/scsi/aic94xx/aic94xx_scb.c b/drivers/scsi/aic94xx/aic94xx_scb.c
index 52c6ea4fbf71..14d5d8c2ee13 100644
--- a/drivers/scsi/aic94xx/aic94xx_scb.c
+++ b/drivers/scsi/aic94xx/aic94xx_scb.c
@@ -169,6 +169,70 @@ static inline void asd_get_attached_sas_addr(struct asd_phy *phy, u8 *sas_addr)
169 } 169 }
170} 170}
171 171
172static void asd_form_port(struct asd_ha_struct *asd_ha, struct asd_phy *phy)
173{
174 int i;
175 struct asd_port *free_port = NULL;
176 struct asd_port *port;
177 struct asd_sas_phy *sas_phy = &phy->sas_phy;
178 unsigned long flags;
179
180 spin_lock_irqsave(&asd_ha->asd_ports_lock, flags);
181 if (!phy->asd_port) {
182 for (i = 0; i < ASD_MAX_PHYS; i++) {
183 port = &asd_ha->asd_ports[i];
184
185 /* Check for wide port */
186 if (port->num_phys > 0 &&
187 memcmp(port->sas_addr, sas_phy->sas_addr,
188 SAS_ADDR_SIZE) == 0 &&
189 memcmp(port->attached_sas_addr,
190 sas_phy->attached_sas_addr,
191 SAS_ADDR_SIZE) == 0) {
192 break;
193 }
194
195 /* Find a free port */
196 if (port->num_phys == 0 && free_port == NULL) {
197 free_port = port;
198 }
199 }
200
201 /* Use a free port if this doesn't form a wide port */
202 if (i >= ASD_MAX_PHYS) {
203 port = free_port;
204 BUG_ON(!port);
205 memcpy(port->sas_addr, sas_phy->sas_addr,
206 SAS_ADDR_SIZE);
207 memcpy(port->attached_sas_addr,
208 sas_phy->attached_sas_addr,
209 SAS_ADDR_SIZE);
210 }
211 port->num_phys++;
212 port->phy_mask |= (1U << sas_phy->id);
213 phy->asd_port = port;
214 }
215 ASD_DPRINTK("%s: updating phy_mask 0x%x for phy%d\n",
216 __FUNCTION__, phy->asd_port->phy_mask, sas_phy->id);
217 asd_update_port_links(asd_ha, phy);
218 spin_unlock_irqrestore(&asd_ha->asd_ports_lock, flags);
219}
220
221static void asd_deform_port(struct asd_ha_struct *asd_ha, struct asd_phy *phy)
222{
223 struct asd_port *port = phy->asd_port;
224 struct asd_sas_phy *sas_phy = &phy->sas_phy;
225 unsigned long flags;
226
227 spin_lock_irqsave(&asd_ha->asd_ports_lock, flags);
228 if (port) {
229 port->num_phys--;
230 port->phy_mask &= ~(1U << sas_phy->id);
231 phy->asd_port = NULL;
232 }
233 spin_unlock_irqrestore(&asd_ha->asd_ports_lock, flags);
234}
235
172static inline void asd_bytes_dmaed_tasklet(struct asd_ascb *ascb, 236static inline void asd_bytes_dmaed_tasklet(struct asd_ascb *ascb,
173 struct done_list_struct *dl, 237 struct done_list_struct *dl,
174 int edb_id, int phy_id) 238 int edb_id, int phy_id)
@@ -188,6 +252,7 @@ static inline void asd_bytes_dmaed_tasklet(struct asd_ascb *ascb,
188 asd_get_attached_sas_addr(phy, phy->sas_phy.attached_sas_addr); 252 asd_get_attached_sas_addr(phy, phy->sas_phy.attached_sas_addr);
189 spin_unlock_irqrestore(&phy->sas_phy.frame_rcvd_lock, flags); 253 spin_unlock_irqrestore(&phy->sas_phy.frame_rcvd_lock, flags);
190 asd_dump_frame_rcvd(phy, dl); 254 asd_dump_frame_rcvd(phy, dl);
255 asd_form_port(ascb->ha, phy);
191 sas_ha->notify_port_event(&phy->sas_phy, PORTE_BYTES_DMAED); 256 sas_ha->notify_port_event(&phy->sas_phy, PORTE_BYTES_DMAED);
192} 257}
193 258
@@ -198,6 +263,7 @@ static inline void asd_link_reset_err_tasklet(struct asd_ascb *ascb,
198 struct asd_ha_struct *asd_ha = ascb->ha; 263 struct asd_ha_struct *asd_ha = ascb->ha;
199 struct sas_ha_struct *sas_ha = &asd_ha->sas_ha; 264 struct sas_ha_struct *sas_ha = &asd_ha->sas_ha;
200 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id]; 265 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id];
266 struct asd_phy *phy = &asd_ha->phys[phy_id];
201 u8 lr_error = dl->status_block[1]; 267 u8 lr_error = dl->status_block[1];
202 u8 retries_left = dl->status_block[2]; 268 u8 retries_left = dl->status_block[2];
203 269
@@ -222,6 +288,7 @@ static inline void asd_link_reset_err_tasklet(struct asd_ascb *ascb,
222 288
223 asd_turn_led(asd_ha, phy_id, 0); 289 asd_turn_led(asd_ha, phy_id, 0);
224 sas_phy_disconnected(sas_phy); 290 sas_phy_disconnected(sas_phy);
291 asd_deform_port(asd_ha, phy);
225 sas_ha->notify_port_event(sas_phy, PORTE_LINK_RESET_ERR); 292 sas_ha->notify_port_event(sas_phy, PORTE_LINK_RESET_ERR);
226 293
227 if (retries_left == 0) { 294 if (retries_left == 0) {
@@ -249,6 +316,8 @@ static inline void asd_primitive_rcvd_tasklet(struct asd_ascb *ascb,
249 unsigned long flags; 316 unsigned long flags;
250 struct sas_ha_struct *sas_ha = &ascb->ha->sas_ha; 317 struct sas_ha_struct *sas_ha = &ascb->ha->sas_ha;
251 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id]; 318 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id];
319 struct asd_ha_struct *asd_ha = ascb->ha;
320 struct asd_phy *phy = &asd_ha->phys[phy_id];
252 u8 reg = dl->status_block[1]; 321 u8 reg = dl->status_block[1];
253 u32 cont = dl->status_block[2] << ((reg & 3)*8); 322 u32 cont = dl->status_block[2] << ((reg & 3)*8);
254 323
@@ -285,6 +354,7 @@ static inline void asd_primitive_rcvd_tasklet(struct asd_ascb *ascb,
285 phy_id); 354 phy_id);
286 /* The sequencer disables all phys on that port. 355 /* The sequencer disables all phys on that port.
287 * We have to re-enable the phys ourselves. */ 356 * We have to re-enable the phys ourselves. */
357 asd_deform_port(asd_ha, phy);
288 sas_ha->notify_port_event(sas_phy, PORTE_HARD_RESET); 358 sas_ha->notify_port_event(sas_phy, PORTE_HARD_RESET);
289 break; 359 break;
290 360
@@ -385,6 +455,7 @@ static void escb_tasklet_complete(struct asd_ascb *ascb,
385 u8 sb_opcode = dl->status_block[0]; 455 u8 sb_opcode = dl->status_block[0];
386 int phy_id = sb_opcode & DL_PHY_MASK; 456 int phy_id = sb_opcode & DL_PHY_MASK;
387 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id]; 457 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id];
458 struct asd_phy *phy = &asd_ha->phys[phy_id];
388 459
389 if (edb > 6 || edb < 0) { 460 if (edb > 6 || edb < 0) {
390 ASD_DPRINTK("edb is 0x%x! dl->opcode is 0x%x\n", 461 ASD_DPRINTK("edb is 0x%x! dl->opcode is 0x%x\n",
@@ -497,6 +568,7 @@ static void escb_tasklet_complete(struct asd_ascb *ascb,
497 asd_turn_led(asd_ha, phy_id, 0); 568 asd_turn_led(asd_ha, phy_id, 0);
498 /* the device is gone */ 569 /* the device is gone */
499 sas_phy_disconnected(sas_phy); 570 sas_phy_disconnected(sas_phy);
571 asd_deform_port(asd_ha, phy);
500 sas_ha->notify_port_event(sas_phy, PORTE_TIMER_EVENT); 572 sas_ha->notify_port_event(sas_phy, PORTE_TIMER_EVENT);
501 break; 573 break;
502 default: 574 default:
diff --git a/drivers/scsi/aic94xx/aic94xx_sds.c b/drivers/scsi/aic94xx/aic94xx_sds.c
index 83574b5b4e69..de7c04d4254d 100644
--- a/drivers/scsi/aic94xx/aic94xx_sds.c
+++ b/drivers/scsi/aic94xx/aic94xx_sds.c
@@ -630,10 +630,6 @@ static int asd_flash_getid(struct asd_ha_struct *asd_ha)
630 630
631 reg = asd_read_reg_dword(asd_ha, EXSICNFGR); 631 reg = asd_read_reg_dword(asd_ha, EXSICNFGR);
632 632
633 if (!(reg & FLASHEX)) {
634 ASD_DPRINTK("flash doesn't exist\n");
635 return -ENOENT;
636 }
637 if (pci_read_config_dword(asd_ha->pcidev, PCI_CONF_FLSH_BAR, 633 if (pci_read_config_dword(asd_ha->pcidev, PCI_CONF_FLSH_BAR,
638 &asd_ha->hw_prof.flash.bar)) { 634 &asd_ha->hw_prof.flash.bar)) {
639 asd_printk("couldn't read PCI_CONF_FLSH_BAR of %s\n", 635 asd_printk("couldn't read PCI_CONF_FLSH_BAR of %s\n",
diff --git a/drivers/scsi/aic94xx/aic94xx_seq.c b/drivers/scsi/aic94xx/aic94xx_seq.c
index 56e4b3ba6a08..845112539d05 100644
--- a/drivers/scsi/aic94xx/aic94xx_seq.c
+++ b/drivers/scsi/aic94xx/aic94xx_seq.c
@@ -1369,10 +1369,9 @@ int asd_start_seqs(struct asd_ha_struct *asd_ha)
1369 * port_map_by_links is also used as the conn_mask byte in the 1369 * port_map_by_links is also used as the conn_mask byte in the
1370 * initiator/target port DDB. 1370 * initiator/target port DDB.
1371 */ 1371 */
1372void asd_update_port_links(struct asd_sas_phy *sas_phy) 1372void asd_update_port_links(struct asd_ha_struct *asd_ha, struct asd_phy *phy)
1373{ 1373{
1374 struct asd_ha_struct *asd_ha = sas_phy->ha->lldd_ha; 1374 const u8 phy_mask = (u8) phy->asd_port->phy_mask;
1375 const u8 phy_mask = (u8) sas_phy->port->phy_mask;
1376 u8 phy_is_up; 1375 u8 phy_is_up;
1377 u8 mask; 1376 u8 mask;
1378 int i, err; 1377 int i, err;
diff --git a/drivers/scsi/aic94xx/aic94xx_seq.h b/drivers/scsi/aic94xx/aic94xx_seq.h
index 42281c36153b..9e715e5496af 100644
--- a/drivers/scsi/aic94xx/aic94xx_seq.h
+++ b/drivers/scsi/aic94xx/aic94xx_seq.h
@@ -64,7 +64,7 @@ int asd_unpause_lseq(struct asd_ha_struct *asd_ha, u8 lseq_mask);
64int asd_init_seqs(struct asd_ha_struct *asd_ha); 64int asd_init_seqs(struct asd_ha_struct *asd_ha);
65int asd_start_seqs(struct asd_ha_struct *asd_ha); 65int asd_start_seqs(struct asd_ha_struct *asd_ha);
66 66
67void asd_update_port_links(struct asd_sas_phy *phy); 67void asd_update_port_links(struct asd_ha_struct *asd_ha, struct asd_phy *phy);
68#endif 68#endif
69 69
70#endif 70#endif
diff --git a/drivers/scsi/dpt/dpti_i2o.h b/drivers/scsi/dpt/dpti_i2o.h
index b3fa7ed71faf..5a49216fe4cf 100644
--- a/drivers/scsi/dpt/dpti_i2o.h
+++ b/drivers/scsi/dpt/dpti_i2o.h
@@ -49,7 +49,7 @@
49 49
50#include <linux/wait.h> 50#include <linux/wait.h>
51typedef wait_queue_head_t adpt_wait_queue_head_t; 51typedef wait_queue_head_t adpt_wait_queue_head_t;
52#define ADPT_DECLARE_WAIT_QUEUE_HEAD(wait) DECLARE_WAIT_QUEUE_HEAD(wait) 52#define ADPT_DECLARE_WAIT_QUEUE_HEAD(wait) DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wait)
53typedef wait_queue_t adpt_wait_queue_t; 53typedef wait_queue_t adpt_wait_queue_t;
54 54
55/* 55/*
diff --git a/drivers/scsi/dtc.c b/drivers/scsi/dtc.c
index 0d5713dfa204..54756722dd5f 100644
--- a/drivers/scsi/dtc.c
+++ b/drivers/scsi/dtc.c
@@ -82,7 +82,7 @@
82#include <linux/string.h> 82#include <linux/string.h>
83#include <linux/init.h> 83#include <linux/init.h>
84#include <linux/interrupt.h> 84#include <linux/interrupt.h>
85#include <asm/io.h> 85#include <linux/io.h>
86#include "scsi.h" 86#include "scsi.h"
87#include <scsi/scsi_host.h> 87#include <scsi/scsi_host.h>
88#include "dtc.h" 88#include "dtc.h"
diff --git a/drivers/scsi/eata_pio.c b/drivers/scsi/eata_pio.c
index 811d8840707e..2dbb66d2f0a7 100644
--- a/drivers/scsi/eata_pio.c
+++ b/drivers/scsi/eata_pio.c
@@ -203,7 +203,7 @@ static irqreturn_t do_eata_pio_int_handler(int irq, void *dev_id)
203 irqreturn_t ret; 203 irqreturn_t ret;
204 204
205 spin_lock_irqsave(dev->host_lock, flags); 205 spin_lock_irqsave(dev->host_lock, flags);
206 ret = eata_pio_int_handler(irq, dev_id, regs); 206 ret = eata_pio_int_handler(irq, dev_id);
207 spin_unlock_irqrestore(dev->host_lock, flags); 207 spin_unlock_irqrestore(dev->host_lock, flags);
208 return ret; 208 return ret;
209} 209}
diff --git a/drivers/scsi/fdomain.c b/drivers/scsi/fdomain.c
index 41b05fc45380..5d4ea6f77953 100644
--- a/drivers/scsi/fdomain.c
+++ b/drivers/scsi/fdomain.c
@@ -278,9 +278,9 @@
278#include <linux/pci.h> 278#include <linux/pci.h>
279#include <linux/stat.h> 279#include <linux/stat.h>
280#include <linux/delay.h> 280#include <linux/delay.h>
281#include <linux/io.h>
281#include <scsi/scsicam.h> 282#include <scsi/scsicam.h>
282 283
283#include <asm/io.h>
284#include <asm/system.h> 284#include <asm/system.h>
285 285
286#include <scsi/scsi.h> 286#include <scsi/scsi.h>
@@ -387,6 +387,7 @@ static void __iomem * bios_mem;
387static int bios_major; 387static int bios_major;
388static int bios_minor; 388static int bios_minor;
389static int PCI_bus; 389static int PCI_bus;
390static struct pci_dev *PCI_dev;
390static int Quantum; /* Quantum board variant */ 391static int Quantum; /* Quantum board variant */
391static int interrupt_level; 392static int interrupt_level;
392static volatile int in_command; 393static volatile int in_command;
@@ -812,9 +813,10 @@ static int fdomain_pci_bios_detect( int *irq, int *iobase, struct pci_dev **ret_
812 PCI_DEVICE_ID_FD_36C70 ); 813 PCI_DEVICE_ID_FD_36C70 );
813#endif 814#endif
814 815
815 if ((pdev = pci_find_device(PCI_VENDOR_ID_FD, PCI_DEVICE_ID_FD_36C70, pdev)) == NULL) 816 if ((pdev = pci_get_device(PCI_VENDOR_ID_FD, PCI_DEVICE_ID_FD_36C70, pdev)) == NULL)
816 return 0; 817 return 0;
817 if (pci_enable_device(pdev)) return 0; 818 if (pci_enable_device(pdev))
819 goto fail;
818 820
819#if DEBUG_DETECT 821#if DEBUG_DETECT
820 printk( "scsi: <fdomain> TMC-3260 detect:" 822 printk( "scsi: <fdomain> TMC-3260 detect:"
@@ -831,7 +833,7 @@ static int fdomain_pci_bios_detect( int *irq, int *iobase, struct pci_dev **ret_
831 pci_irq = pdev->irq; 833 pci_irq = pdev->irq;
832 834
833 if (!request_region( pci_base, 0x10, "fdomain" )) 835 if (!request_region( pci_base, 0x10, "fdomain" ))
834 return 0; 836 goto fail;
835 837
836 /* Now we have the I/O base address and interrupt from the PCI 838 /* Now we have the I/O base address and interrupt from the PCI
837 configuration registers. */ 839 configuration registers. */
@@ -848,17 +850,22 @@ static int fdomain_pci_bios_detect( int *irq, int *iobase, struct pci_dev **ret_
848 if (!fdomain_is_valid_port(pci_base)) { 850 if (!fdomain_is_valid_port(pci_base)) {
849 printk(KERN_ERR "scsi: <fdomain> PCI card detected, but driver not loaded (invalid port)\n" ); 851 printk(KERN_ERR "scsi: <fdomain> PCI card detected, but driver not loaded (invalid port)\n" );
850 release_region(pci_base, 0x10); 852 release_region(pci_base, 0x10);
851 return 0; 853 goto fail;
852 } 854 }
853 855
854 /* Fill in a few global variables. Ugh. */ 856 /* Fill in a few global variables. Ugh. */
855 bios_major = bios_minor = -1; 857 bios_major = bios_minor = -1;
856 PCI_bus = 1; 858 PCI_bus = 1;
859 PCI_dev = pdev;
857 Quantum = 0; 860 Quantum = 0;
858 bios_base = 0; 861 bios_base = 0;
859 862
860 return 1; 863 return 1;
864fail:
865 pci_dev_put(pdev);
866 return 0;
861} 867}
868
862#endif 869#endif
863 870
864struct Scsi_Host *__fdomain_16x0_detect(struct scsi_host_template *tpnt ) 871struct Scsi_Host *__fdomain_16x0_detect(struct scsi_host_template *tpnt )
@@ -909,8 +916,7 @@ struct Scsi_Host *__fdomain_16x0_detect(struct scsi_host_template *tpnt )
909 if (setup_called) { 916 if (setup_called) {
910 printk(KERN_ERR "scsi: <fdomain> Bad LILO/INSMOD parameters?\n"); 917 printk(KERN_ERR "scsi: <fdomain> Bad LILO/INSMOD parameters?\n");
911 } 918 }
912 release_region(port_base, 0x10); 919 goto fail;
913 return NULL;
914 } 920 }
915 921
916 if (this_id) { 922 if (this_id) {
@@ -942,8 +948,7 @@ struct Scsi_Host *__fdomain_16x0_detect(struct scsi_host_template *tpnt )
942 /* Log IRQ with kernel */ 948 /* Log IRQ with kernel */
943 if (!interrupt_level) { 949 if (!interrupt_level) {
944 printk(KERN_ERR "scsi: <fdomain> Card Detected, but driver not loaded (no IRQ)\n" ); 950 printk(KERN_ERR "scsi: <fdomain> Card Detected, but driver not loaded (no IRQ)\n" );
945 release_region(port_base, 0x10); 951 goto fail;
946 return NULL;
947 } else { 952 } else {
948 /* Register the IRQ with the kernel */ 953 /* Register the IRQ with the kernel */
949 954
@@ -964,11 +969,14 @@ struct Scsi_Host *__fdomain_16x0_detect(struct scsi_host_template *tpnt )
964 printk(KERN_ERR " Send mail to faith@acm.org\n" ); 969 printk(KERN_ERR " Send mail to faith@acm.org\n" );
965 } 970 }
966 printk(KERN_ERR "scsi: <fdomain> Detected, but driver not loaded (IRQ)\n" ); 971 printk(KERN_ERR "scsi: <fdomain> Detected, but driver not loaded (IRQ)\n" );
967 release_region(port_base, 0x10); 972 goto fail;
968 return NULL;
969 } 973 }
970 } 974 }
971 return shpnt; 975 return shpnt;
976fail:
977 pci_dev_put(pdev);
978 release_region(port_base, 0x10);
979 return NULL;
972} 980}
973 981
974static int fdomain_16x0_detect(struct scsi_host_template *tpnt) 982static int fdomain_16x0_detect(struct scsi_host_template *tpnt)
@@ -1714,6 +1722,8 @@ static int fdomain_16x0_release(struct Scsi_Host *shpnt)
1714 free_irq(shpnt->irq, shpnt); 1722 free_irq(shpnt->irq, shpnt);
1715 if (shpnt->io_port && shpnt->n_io_port) 1723 if (shpnt->io_port && shpnt->n_io_port)
1716 release_region(shpnt->io_port, shpnt->n_io_port); 1724 release_region(shpnt->io_port, shpnt->n_io_port);
1725 if (PCI_bus)
1726 pci_dev_put(PCI_dev);
1717 return 0; 1727 return 0;
1718} 1728}
1719 1729
@@ -1736,6 +1746,15 @@ struct scsi_host_template fdomain_driver_template = {
1736}; 1746};
1737 1747
1738#ifndef PCMCIA 1748#ifndef PCMCIA
1749
1750static struct pci_device_id fdomain_pci_tbl[] __devinitdata = {
1751 { PCI_VENDOR_ID_FD, PCI_DEVICE_ID_FD_36C70,
1752 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
1753 { }
1754};
1755MODULE_DEVICE_TABLE(pci, fdomain_pci_tbl);
1756
1739#define driver_template fdomain_driver_template 1757#define driver_template fdomain_driver_template
1740#include "scsi_module.c" 1758#include "scsi_module.c"
1759
1741#endif 1760#endif
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 4bc14ad92e22..4c698a71f66f 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -3531,7 +3531,7 @@ static irqreturn_t gdth_interrupt(int irq,void *dev_id)
3531 IStatus &= ~0x80; 3531 IStatus &= ~0x80;
3532#ifdef INT_COAL 3532#ifdef INT_COAL
3533 if (coalesced) 3533 if (coalesced)
3534 ha->status = pcs->ext_status && 0xffff; 3534 ha->status = pcs->ext_status & 0xffff;
3535 else 3535 else
3536#endif 3536#endif
3537 ha->status = gdth_readw(&dp6m_ptr->i960r.status); 3537 ha->status = gdth_readw(&dp6m_ptr->i960r.status);
@@ -3543,7 +3543,7 @@ static irqreturn_t gdth_interrupt(int irq,void *dev_id)
3543 if (coalesced) { 3543 if (coalesced) {
3544 ha->info = pcs->info0; 3544 ha->info = pcs->info0;
3545 ha->info2 = pcs->info1; 3545 ha->info2 = pcs->info1;
3546 ha->service = (pcs->ext_status >> 16) && 0xffff; 3546 ha->service = (pcs->ext_status >> 16) & 0xffff;
3547 } else 3547 } else
3548#endif 3548#endif
3549 { 3549 {
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index 669ea4fff166..fbc1d5c3b0a7 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -1213,7 +1213,7 @@ void ibmvscsi_handle_crq(struct viosrp_crq *crq,
1213 "ibmvscsi: Re-enabling adapter!\n"); 1213 "ibmvscsi: Re-enabling adapter!\n");
1214 purge_requests(hostdata, DID_REQUEUE); 1214 purge_requests(hostdata, DID_REQUEUE);
1215 if ((ibmvscsi_reenable_crq_queue(&hostdata->queue, 1215 if ((ibmvscsi_reenable_crq_queue(&hostdata->queue,
1216 hostdata) == 0) || 1216 hostdata)) ||
1217 (ibmvscsi_send_crq(hostdata, 1217 (ibmvscsi_send_crq(hostdata,
1218 0xC001000000000000LL, 0))) { 1218 0xC001000000000000LL, 0))) {
1219 atomic_set(&hostdata->request_limit, 1219 atomic_set(&hostdata->request_limit,
diff --git a/drivers/scsi/imm.c b/drivers/scsi/imm.c
index 2d95ac9c32c1..e31f6122106f 100644
--- a/drivers/scsi/imm.c
+++ b/drivers/scsi/imm.c
@@ -1153,7 +1153,7 @@ static int __imm_attach(struct parport *pb)
1153{ 1153{
1154 struct Scsi_Host *host; 1154 struct Scsi_Host *host;
1155 imm_struct *dev; 1155 imm_struct *dev;
1156 DECLARE_WAIT_QUEUE_HEAD(waiting); 1156 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waiting);
1157 DEFINE_WAIT(wait); 1157 DEFINE_WAIT(wait);
1158 int ports; 1158 int ports;
1159 int modes, ppb; 1159 int modes, ppb;
diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c
index 911f2ff4a1f2..afed293dd7b9 100644
--- a/drivers/scsi/initio.c
+++ b/drivers/scsi/initio.c
@@ -142,8 +142,6 @@
142#define i91u_MAXQUEUE 2 142#define i91u_MAXQUEUE 2
143#define i91u_REVID "Initio INI-9X00U/UW SCSI device driver; Revision: 1.04a" 143#define i91u_REVID "Initio INI-9X00U/UW SCSI device driver; Revision: 1.04a"
144 144
145#define INI_VENDOR_ID 0x1101 /* Initio's PCI vendor ID */
146#define DMX_VENDOR_ID 0x134a /* Domex's PCI vendor ID */
147#define I950_DEVICE_ID 0x9500 /* Initio's inic-950 product ID */ 145#define I950_DEVICE_ID 0x9500 /* Initio's inic-950 product ID */
148#define I940_DEVICE_ID 0x9400 /* Initio's inic-940 product ID */ 146#define I940_DEVICE_ID 0x9400 /* Initio's inic-940 product ID */
149#define I935_DEVICE_ID 0x9401 /* Initio's inic-935 product ID */ 147#define I935_DEVICE_ID 0x9401 /* Initio's inic-935 product ID */
@@ -171,13 +169,16 @@ static int setup_debug = 0;
171 169
172static void i91uSCBPost(BYTE * pHcb, BYTE * pScb); 170static void i91uSCBPost(BYTE * pHcb, BYTE * pScb);
173 171
174static const PCI_ID i91u_pci_devices[] = { 172/* PCI Devices supported by this driver */
175 { INI_VENDOR_ID, I950_DEVICE_ID }, 173static struct pci_device_id i91u_pci_devices[] __devinitdata = {
176 { INI_VENDOR_ID, I940_DEVICE_ID }, 174 { PCI_VENDOR_ID_INIT, I950_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
177 { INI_VENDOR_ID, I935_DEVICE_ID }, 175 { PCI_VENDOR_ID_INIT, I940_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
178 { INI_VENDOR_ID, I920_DEVICE_ID }, 176 { PCI_VENDOR_ID_INIT, I935_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
179 { DMX_VENDOR_ID, I920_DEVICE_ID }, 177 { PCI_VENDOR_ID_INIT, I920_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
178 { PCI_VENDOR_ID_DOMEX, I920_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
179 { }
180}; 180};
181MODULE_DEVICE_TABLE(pci, i91u_pci_devices);
181 182
182#define DEBUG_INTERRUPT 0 183#define DEBUG_INTERRUPT 0
183#define DEBUG_QUEUE 0 184#define DEBUG_QUEUE 0
@@ -2771,7 +2772,7 @@ static int tul_NewReturnNumberOfAdapters(void)
2771 2772
2772 for (i = 0; i < ARRAY_SIZE(i91u_pci_devices); i++) 2773 for (i = 0; i < ARRAY_SIZE(i91u_pci_devices); i++)
2773 { 2774 {
2774 while ((pDev = pci_find_device(i91u_pci_devices[i].vendor_id, i91u_pci_devices[i].device_id, pDev)) != NULL) { 2775 while ((pDev = pci_find_device(i91u_pci_devices[i].vendor, i91u_pci_devices[i].device, pDev)) != NULL) {
2775 if (pci_enable_device(pDev)) 2776 if (pci_enable_device(pDev))
2776 continue; 2777 continue;
2777 pci_read_config_dword(pDev, 0x44, (u32 *) & dRegValue); 2778 pci_read_config_dword(pDev, 0x44, (u32 *) & dRegValue);
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 0a9dbc59663f..d0b139cccbbc 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -415,8 +415,8 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
415 iscsi_solicit_data_init(conn, ctask, r2t); 415 iscsi_solicit_data_init(conn, ctask, r2t);
416 416
417 tcp_ctask->exp_r2tsn = r2tsn + 1; 417 tcp_ctask->exp_r2tsn = r2tsn + 1;
418 tcp_ctask->xmstate |= XMSTATE_SOL_HDR;
419 __kfifo_put(tcp_ctask->r2tqueue, (void*)&r2t, sizeof(void*)); 418 __kfifo_put(tcp_ctask->r2tqueue, (void*)&r2t, sizeof(void*));
419 tcp_ctask->xmstate |= XMSTATE_SOL_HDR;
420 list_move_tail(&ctask->running, &conn->xmitqueue); 420 list_move_tail(&ctask->running, &conn->xmitqueue);
421 421
422 scsi_queue_work(session->host, &conn->xmitwork); 422 scsi_queue_work(session->host, &conn->xmitwork);
@@ -1627,9 +1627,12 @@ static int iscsi_send_sol_pdu(struct iscsi_conn *conn,
1627 if (tcp_ctask->xmstate & XMSTATE_SOL_HDR) { 1627 if (tcp_ctask->xmstate & XMSTATE_SOL_HDR) {
1628 tcp_ctask->xmstate &= ~XMSTATE_SOL_HDR; 1628 tcp_ctask->xmstate &= ~XMSTATE_SOL_HDR;
1629 tcp_ctask->xmstate |= XMSTATE_SOL_DATA; 1629 tcp_ctask->xmstate |= XMSTATE_SOL_DATA;
1630 if (!tcp_ctask->r2t) 1630 if (!tcp_ctask->r2t) {
1631 spin_lock_bh(&session->lock);
1631 __kfifo_get(tcp_ctask->r2tqueue, (void*)&tcp_ctask->r2t, 1632 __kfifo_get(tcp_ctask->r2tqueue, (void*)&tcp_ctask->r2t,
1632 sizeof(void*)); 1633 sizeof(void*));
1634 spin_unlock_bh(&session->lock);
1635 }
1633send_hdr: 1636send_hdr:
1634 r2t = tcp_ctask->r2t; 1637 r2t = tcp_ctask->r2t;
1635 dtask = &r2t->dtask; 1638 dtask = &r2t->dtask;
@@ -1816,21 +1819,14 @@ iscsi_tcp_conn_destroy(struct iscsi_cls_conn *cls_conn)
1816{ 1819{
1817 struct iscsi_conn *conn = cls_conn->dd_data; 1820 struct iscsi_conn *conn = cls_conn->dd_data;
1818 struct iscsi_tcp_conn *tcp_conn = conn->dd_data; 1821 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
1819 int digest = 0;
1820
1821 if (conn->hdrdgst_en || conn->datadgst_en)
1822 digest = 1;
1823 1822
1824 iscsi_tcp_release_conn(conn); 1823 iscsi_tcp_release_conn(conn);
1825 iscsi_conn_teardown(cls_conn); 1824 iscsi_conn_teardown(cls_conn);
1826 1825
1827 /* now free tcp_conn */ 1826 if (tcp_conn->tx_hash.tfm)
1828 if (digest) { 1827 crypto_free_hash(tcp_conn->tx_hash.tfm);
1829 if (tcp_conn->tx_hash.tfm) 1828 if (tcp_conn->rx_hash.tfm)
1830 crypto_free_hash(tcp_conn->tx_hash.tfm); 1829 crypto_free_hash(tcp_conn->rx_hash.tfm);
1831 if (tcp_conn->rx_hash.tfm)
1832 crypto_free_hash(tcp_conn->rx_hash.tfm);
1833 }
1834 1830
1835 kfree(tcp_conn); 1831 kfree(tcp_conn);
1836} 1832}
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index c542d0e95e68..5d8862189485 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -481,8 +481,8 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
481 break; 481 break;
482 case ISCSI_OP_ASYNC_EVENT: 482 case ISCSI_OP_ASYNC_EVENT:
483 conn->exp_statsn = be32_to_cpu(hdr->statsn) + 1; 483 conn->exp_statsn = be32_to_cpu(hdr->statsn) + 1;
484 /* we need sth like iscsi_async_event_rsp() */ 484 if (iscsi_recv_pdu(conn->cls_conn, hdr, data, datalen))
485 rc = ISCSI_ERR_BAD_OPCODE; 485 rc = ISCSI_ERR_CONN_FAILED;
486 break; 486 break;
487 default: 487 default:
488 rc = ISCSI_ERR_BAD_OPCODE; 488 rc = ISCSI_ERR_BAD_OPCODE;
@@ -578,6 +578,27 @@ void iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err)
578} 578}
579EXPORT_SYMBOL_GPL(iscsi_conn_failure); 579EXPORT_SYMBOL_GPL(iscsi_conn_failure);
580 580
581static int iscsi_xmit_imm_task(struct iscsi_conn *conn)
582{
583 struct iscsi_hdr *hdr = conn->mtask->hdr;
584 int rc, was_logout = 0;
585
586 if ((hdr->opcode & ISCSI_OPCODE_MASK) == ISCSI_OP_LOGOUT) {
587 conn->session->state = ISCSI_STATE_IN_RECOVERY;
588 iscsi_block_session(session_to_cls(conn->session));
589 was_logout = 1;
590 }
591 rc = conn->session->tt->xmit_mgmt_task(conn, conn->mtask);
592 if (rc)
593 return rc;
594
595 if (was_logout) {
596 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
597 return -ENODATA;
598 }
599 return 0;
600}
601
581/** 602/**
582 * iscsi_data_xmit - xmit any command into the scheduled connection 603 * iscsi_data_xmit - xmit any command into the scheduled connection
583 * @conn: iscsi connection 604 * @conn: iscsi connection
@@ -623,7 +644,7 @@ static int iscsi_data_xmit(struct iscsi_conn *conn)
623 conn->ctask = NULL; 644 conn->ctask = NULL;
624 } 645 }
625 if (conn->mtask) { 646 if (conn->mtask) {
626 rc = tt->xmit_mgmt_task(conn, conn->mtask); 647 rc = iscsi_xmit_imm_task(conn);
627 if (rc) 648 if (rc)
628 goto again; 649 goto again;
629 /* done with this in-progress mtask */ 650 /* done with this in-progress mtask */
@@ -638,7 +659,7 @@ static int iscsi_data_xmit(struct iscsi_conn *conn)
638 list_add_tail(&conn->mtask->running, 659 list_add_tail(&conn->mtask->running,
639 &conn->mgmt_run_list); 660 &conn->mgmt_run_list);
640 spin_unlock_bh(&conn->session->lock); 661 spin_unlock_bh(&conn->session->lock);
641 rc = tt->xmit_mgmt_task(conn, conn->mtask); 662 rc = iscsi_xmit_imm_task(conn);
642 if (rc) 663 if (rc)
643 goto again; 664 goto again;
644 } 665 }
@@ -661,8 +682,6 @@ static int iscsi_data_xmit(struct iscsi_conn *conn)
661 spin_unlock_bh(&conn->session->lock); 682 spin_unlock_bh(&conn->session->lock);
662 683
663 rc = tt->xmit_cmd_task(conn, conn->ctask); 684 rc = tt->xmit_cmd_task(conn, conn->ctask);
664 if (rc)
665 goto again;
666 685
667 spin_lock_bh(&conn->session->lock); 686 spin_lock_bh(&conn->session->lock);
668 __iscsi_put_ctask(conn->ctask); 687 __iscsi_put_ctask(conn->ctask);
@@ -778,6 +797,10 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
778 } 797 }
779 798
780 conn = session->leadconn; 799 conn = session->leadconn;
800 if (!conn) {
801 reason = FAILURE_SESSION_FREED;
802 goto fault;
803 }
781 804
782 if (!__kfifo_get(session->cmdpool.queue, (void*)&ctask, 805 if (!__kfifo_get(session->cmdpool.queue, (void*)&ctask,
783 sizeof(void*))) { 806 sizeof(void*))) {
@@ -952,13 +975,13 @@ int iscsi_eh_host_reset(struct scsi_cmnd *sc)
952 if (session->state == ISCSI_STATE_TERMINATE) { 975 if (session->state == ISCSI_STATE_TERMINATE) {
953failed: 976failed:
954 debug_scsi("failing host reset: session terminated " 977 debug_scsi("failing host reset: session terminated "
955 "[CID %d age %d]", conn->id, session->age); 978 "[CID %d age %d]\n", conn->id, session->age);
956 spin_unlock_bh(&session->lock); 979 spin_unlock_bh(&session->lock);
957 return FAILED; 980 return FAILED;
958 } 981 }
959 982
960 if (sc->SCp.phase == session->age) { 983 if (sc->SCp.phase == session->age) {
961 debug_scsi("failing connection CID %d due to SCSI host reset", 984 debug_scsi("failing connection CID %d due to SCSI host reset\n",
962 conn->id); 985 conn->id);
963 fail_session = 1; 986 fail_session = 1;
964 } 987 }
@@ -1031,7 +1054,8 @@ static int iscsi_exec_abort_task(struct scsi_cmnd *sc,
1031 NULL, 0); 1054 NULL, 0);
1032 if (rc) { 1055 if (rc) {
1033 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); 1056 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
1034 debug_scsi("abort sent failure [itt 0x%x] %d", ctask->itt, rc); 1057 debug_scsi("abort sent failure [itt 0x%x] %d\n", ctask->itt,
1058 rc);
1035 return rc; 1059 return rc;
1036 } 1060 }
1037 1061
@@ -1048,7 +1072,7 @@ static int iscsi_exec_abort_task(struct scsi_cmnd *sc,
1048 conn->tmabort_timer.function = iscsi_tmabort_timedout; 1072 conn->tmabort_timer.function = iscsi_tmabort_timedout;
1049 conn->tmabort_timer.data = (unsigned long)ctask; 1073 conn->tmabort_timer.data = (unsigned long)ctask;
1050 add_timer(&conn->tmabort_timer); 1074 add_timer(&conn->tmabort_timer);
1051 debug_scsi("abort set timeout [itt 0x%x]", ctask->itt); 1075 debug_scsi("abort set timeout [itt 0x%x]\n", ctask->itt);
1052 } 1076 }
1053 spin_unlock_bh(&session->lock); 1077 spin_unlock_bh(&session->lock);
1054 mutex_unlock(&conn->xmitmutex); 1078 mutex_unlock(&conn->xmitmutex);
@@ -1377,7 +1401,6 @@ iscsi_session_setup(struct iscsi_transport *iscsit,
1377 } 1401 }
1378 1402
1379 spin_lock_init(&session->lock); 1403 spin_lock_init(&session->lock);
1380 INIT_LIST_HEAD(&session->connections);
1381 1404
1382 /* initialize immediate command pool */ 1405 /* initialize immediate command pool */
1383 if (iscsi_pool_init(&session->mgmtpool, session->mgmtpool_max, 1406 if (iscsi_pool_init(&session->mgmtpool, session->mgmtpool_max,
@@ -1580,16 +1603,11 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
1580 kfree(conn->persistent_address); 1603 kfree(conn->persistent_address);
1581 __kfifo_put(session->mgmtpool.queue, (void*)&conn->login_mtask, 1604 __kfifo_put(session->mgmtpool.queue, (void*)&conn->login_mtask,
1582 sizeof(void*)); 1605 sizeof(void*));
1583 list_del(&conn->item); 1606 if (session->leadconn == conn) {
1584 if (list_empty(&session->connections))
1585 session->leadconn = NULL; 1607 session->leadconn = NULL;
1586 if (session->leadconn && session->leadconn == conn)
1587 session->leadconn = container_of(session->connections.next,
1588 struct iscsi_conn, item);
1589
1590 if (session->leadconn == NULL)
1591 /* no connections exits.. reset sequencing */ 1608 /* no connections exits.. reset sequencing */
1592 session->cmdsn = session->max_cmdsn = session->exp_cmdsn = 1; 1609 session->cmdsn = session->max_cmdsn = session->exp_cmdsn = 1;
1610 }
1593 spin_unlock_bh(&session->lock); 1611 spin_unlock_bh(&session->lock);
1594 1612
1595 kfifo_free(conn->immqueue); 1613 kfifo_free(conn->immqueue);
@@ -1777,32 +1795,12 @@ int iscsi_conn_bind(struct iscsi_cls_session *cls_session,
1777 struct iscsi_cls_conn *cls_conn, int is_leading) 1795 struct iscsi_cls_conn *cls_conn, int is_leading)
1778{ 1796{
1779 struct iscsi_session *session = class_to_transport_session(cls_session); 1797 struct iscsi_session *session = class_to_transport_session(cls_session);
1780 struct iscsi_conn *tmp = ERR_PTR(-EEXIST), *conn = cls_conn->dd_data; 1798 struct iscsi_conn *conn = cls_conn->dd_data;
1781 1799
1782 /* lookup for existing connection */
1783 spin_lock_bh(&session->lock); 1800 spin_lock_bh(&session->lock);
1784 list_for_each_entry(tmp, &session->connections, item) {
1785 if (tmp == conn) {
1786 if (conn->c_stage != ISCSI_CONN_STOPPED ||
1787 conn->stop_stage == STOP_CONN_TERM) {
1788 printk(KERN_ERR "iscsi: can't bind "
1789 "non-stopped connection (%d:%d)\n",
1790 conn->c_stage, conn->stop_stage);
1791 spin_unlock_bh(&session->lock);
1792 return -EIO;
1793 }
1794 break;
1795 }
1796 }
1797 if (tmp != conn) {
1798 /* bind new iSCSI connection to session */
1799 conn->session = session;
1800 list_add(&conn->item, &session->connections);
1801 }
1802 spin_unlock_bh(&session->lock);
1803
1804 if (is_leading) 1801 if (is_leading)
1805 session->leadconn = conn; 1802 session->leadconn = conn;
1803 spin_unlock_bh(&session->lock);
1806 1804
1807 /* 1805 /*
1808 * Unblock xmitworker(), Login Phase will pass through. 1806 * Unblock xmitworker(), Login Phase will pass through.
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index 30b8014bcc7a..e34a93435497 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -71,55 +71,65 @@ static void smp_task_done(struct sas_task *task)
71static int smp_execute_task(struct domain_device *dev, void *req, int req_size, 71static int smp_execute_task(struct domain_device *dev, void *req, int req_size,
72 void *resp, int resp_size) 72 void *resp, int resp_size)
73{ 73{
74 int res; 74 int res, retry;
75 struct sas_task *task = sas_alloc_task(GFP_KERNEL); 75 struct sas_task *task = NULL;
76 struct sas_internal *i = 76 struct sas_internal *i =
77 to_sas_internal(dev->port->ha->core.shost->transportt); 77 to_sas_internal(dev->port->ha->core.shost->transportt);
78 78
79 if (!task) 79 for (retry = 0; retry < 3; retry++) {
80 return -ENOMEM; 80 task = sas_alloc_task(GFP_KERNEL);
81 81 if (!task)
82 task->dev = dev; 82 return -ENOMEM;
83 task->task_proto = dev->tproto;
84 sg_init_one(&task->smp_task.smp_req, req, req_size);
85 sg_init_one(&task->smp_task.smp_resp, resp, resp_size);
86 83
87 task->task_done = smp_task_done; 84 task->dev = dev;
85 task->task_proto = dev->tproto;
86 sg_init_one(&task->smp_task.smp_req, req, req_size);
87 sg_init_one(&task->smp_task.smp_resp, resp, resp_size);
88 88
89 task->timer.data = (unsigned long) task; 89 task->task_done = smp_task_done;
90 task->timer.function = smp_task_timedout;
91 task->timer.expires = jiffies + SMP_TIMEOUT*HZ;
92 add_timer(&task->timer);
93 90
94 res = i->dft->lldd_execute_task(task, 1, GFP_KERNEL); 91 task->timer.data = (unsigned long) task;
92 task->timer.function = smp_task_timedout;
93 task->timer.expires = jiffies + SMP_TIMEOUT*HZ;
94 add_timer(&task->timer);
95 95
96 if (res) { 96 res = i->dft->lldd_execute_task(task, 1, GFP_KERNEL);
97 del_timer(&task->timer);
98 SAS_DPRINTK("executing SMP task failed:%d\n", res);
99 goto ex_err;
100 }
101 97
102 wait_for_completion(&task->completion); 98 if (res) {
103 res = -ETASK; 99 del_timer(&task->timer);
104 if ((task->task_state_flags & SAS_TASK_STATE_ABORTED)) { 100 SAS_DPRINTK("executing SMP task failed:%d\n", res);
105 SAS_DPRINTK("smp task timed out or aborted\n");
106 i->dft->lldd_abort_task(task);
107 if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) {
108 SAS_DPRINTK("SMP task aborted and not done\n");
109 goto ex_err; 101 goto ex_err;
110 } 102 }
103
104 wait_for_completion(&task->completion);
105 res = -ETASK;
106 if ((task->task_state_flags & SAS_TASK_STATE_ABORTED)) {
107 SAS_DPRINTK("smp task timed out or aborted\n");
108 i->dft->lldd_abort_task(task);
109 if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) {
110 SAS_DPRINTK("SMP task aborted and not done\n");
111 goto ex_err;
112 }
113 }
114 if (task->task_status.resp == SAS_TASK_COMPLETE &&
115 task->task_status.stat == SAM_GOOD) {
116 res = 0;
117 break;
118 } else {
119 SAS_DPRINTK("%s: task to dev %016llx response: 0x%x "
120 "status 0x%x\n", __FUNCTION__,
121 SAS_ADDR(dev->sas_addr),
122 task->task_status.resp,
123 task->task_status.stat);
124 sas_free_task(task);
125 task = NULL;
126 }
111 } 127 }
112 if (task->task_status.resp == SAS_TASK_COMPLETE &&
113 task->task_status.stat == SAM_GOOD)
114 res = 0;
115 else
116 SAS_DPRINTK("%s: task to dev %016llx response: 0x%x "
117 "status 0x%x\n", __FUNCTION__,
118 SAS_ADDR(dev->sas_addr),
119 task->task_status.resp,
120 task->task_status.stat);
121ex_err: 128ex_err:
122 sas_free_task(task); 129 BUG_ON(retry == 3 && task != NULL);
130 if (task != NULL) {
131 sas_free_task(task);
132 }
123 return res; 133 return res;
124} 134}
125 135
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 9496e87c135e..2a4e02e7a392 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -594,7 +594,8 @@ lpfc_soft_wwpn_show(struct class_device *cdev, char *buf)
594{ 594{
595 struct Scsi_Host *host = class_to_shost(cdev); 595 struct Scsi_Host *host = class_to_shost(cdev);
596 struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata; 596 struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
597 return snprintf(buf, PAGE_SIZE, "0x%llx\n", phba->cfg_soft_wwpn); 597 return snprintf(buf, PAGE_SIZE, "0x%llx\n",
598 (unsigned long long)phba->cfg_soft_wwpn);
598} 599}
599 600
600 601
diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index 1b53afb1cb57..3add7c237859 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -188,7 +188,8 @@ lpfc_alloc_ct_rsp(struct lpfc_hba * phba, int cmdcode, struct ulp_bde64 * bpl,
188 188
189 if (!mp->virt) { 189 if (!mp->virt) {
190 kfree(mp); 190 kfree(mp);
191 lpfc_free_ct_rsp(phba, mlist); 191 if (mlist)
192 lpfc_free_ct_rsp(phba, mlist);
192 return NULL; 193 return NULL;
193 } 194 }
194 195
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index d586c3d3b0d0..19c79a0549a7 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -305,7 +305,7 @@ lpfc_do_work(void *p)
305{ 305{
306 struct lpfc_hba *phba = p; 306 struct lpfc_hba *phba = p;
307 int rc; 307 int rc;
308 DECLARE_WAIT_QUEUE_HEAD(work_waitq); 308 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(work_waitq);
309 309
310 set_user_nice(current, -20); 310 set_user_nice(current, -20);
311 phba->work_wait = &work_waitq; 311 phba->work_wait = &work_waitq;
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 24a1779b9af4..582f5ea4e84e 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -2983,7 +2983,7 @@ lpfc_sli_issue_iocb_wait(struct lpfc_hba * phba,
2983 struct lpfc_iocbq * prspiocbq, 2983 struct lpfc_iocbq * prspiocbq,
2984 uint32_t timeout) 2984 uint32_t timeout)
2985{ 2985{
2986 DECLARE_WAIT_QUEUE_HEAD(done_q); 2986 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(done_q);
2987 long timeleft, timeout_req = 0; 2987 long timeleft, timeout_req = 0;
2988 int retval = IOCB_SUCCESS; 2988 int retval = IOCB_SUCCESS;
2989 uint32_t creg_val; 2989 uint32_t creg_val;
@@ -3061,7 +3061,7 @@ int
3061lpfc_sli_issue_mbox_wait(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq, 3061lpfc_sli_issue_mbox_wait(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq,
3062 uint32_t timeout) 3062 uint32_t timeout)
3063{ 3063{
3064 DECLARE_WAIT_QUEUE_HEAD(done_q); 3064 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(done_q);
3065 DECLARE_WAITQUEUE(wq_entry, current); 3065 DECLARE_WAITQUEUE(wq_entry, current);
3066 uint32_t timeleft = 0; 3066 uint32_t timeleft = 0;
3067 int retval; 3067 int retval;
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c
index c0edb662d863..7bac86dda88f 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.c
+++ b/drivers/scsi/megaraid/megaraid_mbox.c
@@ -884,7 +884,7 @@ megaraid_init_mbox(adapter_t *adapter)
884 884
885 if (((magic64 == HBA_SIGNATURE_64_BIT) && 885 if (((magic64 == HBA_SIGNATURE_64_BIT) &&
886 ((adapter->pdev->subsystem_device != 886 ((adapter->pdev->subsystem_device !=
887 PCI_SUBSYS_ID_MEGARAID_SATA_150_6) || 887 PCI_SUBSYS_ID_MEGARAID_SATA_150_6) &&
888 (adapter->pdev->subsystem_device != 888 (adapter->pdev->subsystem_device !=
889 PCI_SUBSYS_ID_MEGARAID_SATA_150_4))) || 889 PCI_SUBSYS_ID_MEGARAID_SATA_150_4))) ||
890 (adapter->pdev->vendor == PCI_VENDOR_ID_LSI_LOGIC && 890 (adapter->pdev->vendor == PCI_VENDOR_ID_LSI_LOGIC &&
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index b1d346049525..f2d79c3f0b8e 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -183,7 +183,7 @@ static void nsp_cs_dmessage(const char *func, int line, int mask, char *fmt, ...
183 * Clenaup parameters and call done() functions. 183 * Clenaup parameters and call done() functions.
184 * You must be set SCpnt->result before call this function. 184 * You must be set SCpnt->result before call this function.
185 */ 185 */
186static void nsp_scsi_done(Scsi_Cmnd *SCpnt) 186static void nsp_scsi_done(struct scsi_cmnd *SCpnt)
187{ 187{
188 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; 188 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
189 189
@@ -192,7 +192,8 @@ static void nsp_scsi_done(Scsi_Cmnd *SCpnt)
192 SCpnt->scsi_done(SCpnt); 192 SCpnt->scsi_done(SCpnt);
193} 193}
194 194
195static int nsp_queuecommand(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) 195static int nsp_queuecommand(struct scsi_cmnd *SCpnt,
196 void (*done)(struct scsi_cmnd *))
196{ 197{
197#ifdef NSP_DEBUG 198#ifdef NSP_DEBUG
198 /*unsigned int host_id = SCpnt->device->host->this_id;*/ 199 /*unsigned int host_id = SCpnt->device->host->this_id;*/
@@ -365,7 +366,7 @@ static int nsphw_init(nsp_hw_data *data)
365/* 366/*
366 * Start selection phase 367 * Start selection phase
367 */ 368 */
368static int nsphw_start_selection(Scsi_Cmnd *SCpnt) 369static int nsphw_start_selection(struct scsi_cmnd *SCpnt)
369{ 370{
370 unsigned int host_id = SCpnt->device->host->this_id; 371 unsigned int host_id = SCpnt->device->host->this_id;
371 unsigned int base = SCpnt->device->host->io_port; 372 unsigned int base = SCpnt->device->host->io_port;
@@ -446,7 +447,7 @@ static struct nsp_sync_table nsp_sync_table_20M[] = {
446/* 447/*
447 * setup synchronous data transfer mode 448 * setup synchronous data transfer mode
448 */ 449 */
449static int nsp_analyze_sdtr(Scsi_Cmnd *SCpnt) 450static int nsp_analyze_sdtr(struct scsi_cmnd *SCpnt)
450{ 451{
451 unsigned char target = scmd_id(SCpnt); 452 unsigned char target = scmd_id(SCpnt);
452// unsigned char lun = SCpnt->device->lun; 453// unsigned char lun = SCpnt->device->lun;
@@ -504,7 +505,7 @@ static int nsp_analyze_sdtr(Scsi_Cmnd *SCpnt)
504/* 505/*
505 * start ninja hardware timer 506 * start ninja hardware timer
506 */ 507 */
507static void nsp_start_timer(Scsi_Cmnd *SCpnt, int time) 508static void nsp_start_timer(struct scsi_cmnd *SCpnt, int time)
508{ 509{
509 unsigned int base = SCpnt->device->host->io_port; 510 unsigned int base = SCpnt->device->host->io_port;
510 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; 511 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
@@ -517,7 +518,8 @@ static void nsp_start_timer(Scsi_Cmnd *SCpnt, int time)
517/* 518/*
518 * wait for bus phase change 519 * wait for bus phase change
519 */ 520 */
520static int nsp_negate_signal(Scsi_Cmnd *SCpnt, unsigned char mask, char *str) 521static int nsp_negate_signal(struct scsi_cmnd *SCpnt, unsigned char mask,
522 char *str)
521{ 523{
522 unsigned int base = SCpnt->device->host->io_port; 524 unsigned int base = SCpnt->device->host->io_port;
523 unsigned char reg; 525 unsigned char reg;
@@ -544,9 +546,9 @@ static int nsp_negate_signal(Scsi_Cmnd *SCpnt, unsigned char mask, char *str)
544/* 546/*
545 * expect Ninja Irq 547 * expect Ninja Irq
546 */ 548 */
547static int nsp_expect_signal(Scsi_Cmnd *SCpnt, 549static int nsp_expect_signal(struct scsi_cmnd *SCpnt,
548 unsigned char current_phase, 550 unsigned char current_phase,
549 unsigned char mask) 551 unsigned char mask)
550{ 552{
551 unsigned int base = SCpnt->device->host->io_port; 553 unsigned int base = SCpnt->device->host->io_port;
552 int time_out; 554 int time_out;
@@ -579,7 +581,7 @@ static int nsp_expect_signal(Scsi_Cmnd *SCpnt,
579/* 581/*
580 * transfer SCSI message 582 * transfer SCSI message
581 */ 583 */
582static int nsp_xfer(Scsi_Cmnd *SCpnt, int phase) 584static int nsp_xfer(struct scsi_cmnd *SCpnt, int phase)
583{ 585{
584 unsigned int base = SCpnt->device->host->io_port; 586 unsigned int base = SCpnt->device->host->io_port;
585 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; 587 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
@@ -619,7 +621,7 @@ static int nsp_xfer(Scsi_Cmnd *SCpnt, int phase)
619/* 621/*
620 * get extra SCSI data from fifo 622 * get extra SCSI data from fifo
621 */ 623 */
622static int nsp_dataphase_bypass(Scsi_Cmnd *SCpnt) 624static int nsp_dataphase_bypass(struct scsi_cmnd *SCpnt)
623{ 625{
624 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; 626 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
625 unsigned int count; 627 unsigned int count;
@@ -651,7 +653,7 @@ static int nsp_dataphase_bypass(Scsi_Cmnd *SCpnt)
651/* 653/*
652 * accept reselection 654 * accept reselection
653 */ 655 */
654static int nsp_reselected(Scsi_Cmnd *SCpnt) 656static int nsp_reselected(struct scsi_cmnd *SCpnt)
655{ 657{
656 unsigned int base = SCpnt->device->host->io_port; 658 unsigned int base = SCpnt->device->host->io_port;
657 unsigned int host_id = SCpnt->device->host->this_id; 659 unsigned int host_id = SCpnt->device->host->this_id;
@@ -690,7 +692,7 @@ static int nsp_reselected(Scsi_Cmnd *SCpnt)
690/* 692/*
691 * count how many data transferd 693 * count how many data transferd
692 */ 694 */
693static int nsp_fifo_count(Scsi_Cmnd *SCpnt) 695static int nsp_fifo_count(struct scsi_cmnd *SCpnt)
694{ 696{
695 unsigned int base = SCpnt->device->host->io_port; 697 unsigned int base = SCpnt->device->host->io_port;
696 unsigned int count; 698 unsigned int count;
@@ -717,7 +719,7 @@ static int nsp_fifo_count(Scsi_Cmnd *SCpnt)
717/* 719/*
718 * read data in DATA IN phase 720 * read data in DATA IN phase
719 */ 721 */
720static void nsp_pio_read(Scsi_Cmnd *SCpnt) 722static void nsp_pio_read(struct scsi_cmnd *SCpnt)
721{ 723{
722 unsigned int base = SCpnt->device->host->io_port; 724 unsigned int base = SCpnt->device->host->io_port;
723 unsigned long mmio_base = SCpnt->device->host->base; 725 unsigned long mmio_base = SCpnt->device->host->base;
@@ -812,7 +814,7 @@ static void nsp_pio_read(Scsi_Cmnd *SCpnt)
812/* 814/*
813 * write data in DATA OUT phase 815 * write data in DATA OUT phase
814 */ 816 */
815static void nsp_pio_write(Scsi_Cmnd *SCpnt) 817static void nsp_pio_write(struct scsi_cmnd *SCpnt)
816{ 818{
817 unsigned int base = SCpnt->device->host->io_port; 819 unsigned int base = SCpnt->device->host->io_port;
818 unsigned long mmio_base = SCpnt->device->host->base; 820 unsigned long mmio_base = SCpnt->device->host->base;
@@ -905,7 +907,7 @@ static void nsp_pio_write(Scsi_Cmnd *SCpnt)
905/* 907/*
906 * setup synchronous/asynchronous data transfer mode 908 * setup synchronous/asynchronous data transfer mode
907 */ 909 */
908static int nsp_nexus(Scsi_Cmnd *SCpnt) 910static int nsp_nexus(struct scsi_cmnd *SCpnt)
909{ 911{
910 unsigned int base = SCpnt->device->host->io_port; 912 unsigned int base = SCpnt->device->host->io_port;
911 unsigned char target = scmd_id(SCpnt); 913 unsigned char target = scmd_id(SCpnt);
@@ -952,7 +954,7 @@ static irqreturn_t nspintr(int irq, void *dev_id)
952{ 954{
953 unsigned int base; 955 unsigned int base;
954 unsigned char irq_status, irq_phase, phase; 956 unsigned char irq_status, irq_phase, phase;
955 Scsi_Cmnd *tmpSC; 957 struct scsi_cmnd *tmpSC;
956 unsigned char target, lun; 958 unsigned char target, lun;
957 unsigned int *sync_neg; 959 unsigned int *sync_neg;
958 int i, tmp; 960 int i, tmp;
@@ -1530,7 +1532,7 @@ nsp_proc_info(
1530/*---------------------------------------------------------------*/ 1532/*---------------------------------------------------------------*/
1531 1533
1532/* 1534/*
1533static int nsp_eh_abort(Scsi_Cmnd *SCpnt) 1535static int nsp_eh_abort(struct scsi_cmnd *SCpnt)
1534{ 1536{
1535 nsp_dbg(NSP_DEBUG_BUSRESET, "SCpnt=0x%p", SCpnt); 1537 nsp_dbg(NSP_DEBUG_BUSRESET, "SCpnt=0x%p", SCpnt);
1536 1538
@@ -1558,7 +1560,7 @@ static int nsp_bus_reset(nsp_hw_data *data)
1558 return SUCCESS; 1560 return SUCCESS;
1559} 1561}
1560 1562
1561static int nsp_eh_bus_reset(Scsi_Cmnd *SCpnt) 1563static int nsp_eh_bus_reset(struct scsi_cmnd *SCpnt)
1562{ 1564{
1563 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; 1565 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
1564 1566
@@ -1567,7 +1569,7 @@ static int nsp_eh_bus_reset(Scsi_Cmnd *SCpnt)
1567 return nsp_bus_reset(data); 1569 return nsp_bus_reset(data);
1568} 1570}
1569 1571
1570static int nsp_eh_host_reset(Scsi_Cmnd *SCpnt) 1572static int nsp_eh_host_reset(struct scsi_cmnd *SCpnt)
1571{ 1573{
1572 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; 1574 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
1573 1575
diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h
index a88714f4c05b..625ca97da52d 100644
--- a/drivers/scsi/pcmcia/nsp_cs.h
+++ b/drivers/scsi/pcmcia/nsp_cs.h
@@ -266,7 +266,7 @@ typedef struct _nsp_hw_data {
266 266
267 int TimerCount; 267 int TimerCount;
268 int SelectionTimeOut; 268 int SelectionTimeOut;
269 Scsi_Cmnd *CurrentSC; 269 struct scsi_cmnd *CurrentSC;
270 //int CurrnetTarget; 270 //int CurrnetTarget;
271 271
272 int FifoCount; 272 int FifoCount;
@@ -319,30 +319,34 @@ static int nsp_proc_info (
319 int hostno, 319 int hostno,
320#endif 320#endif
321 int inout); 321 int inout);
322static int nsp_queuecommand(Scsi_Cmnd *SCpnt, void (* done)(Scsi_Cmnd *SCpnt)); 322static int nsp_queuecommand(struct scsi_cmnd *SCpnt,
323 void (* done)(struct scsi_cmnd *SCpnt));
323 324
324/* Error handler */ 325/* Error handler */
325/*static int nsp_eh_abort (Scsi_Cmnd *SCpnt);*/ 326/*static int nsp_eh_abort (struct scsi_cmnd *SCpnt);*/
326/*static int nsp_eh_device_reset(Scsi_Cmnd *SCpnt);*/ 327/*static int nsp_eh_device_reset(struct scsi_cmnd *SCpnt);*/
327static int nsp_eh_bus_reset (Scsi_Cmnd *SCpnt); 328static int nsp_eh_bus_reset (struct scsi_cmnd *SCpnt);
328static int nsp_eh_host_reset (Scsi_Cmnd *SCpnt); 329static int nsp_eh_host_reset (struct scsi_cmnd *SCpnt);
329static int nsp_bus_reset (nsp_hw_data *data); 330static int nsp_bus_reset (nsp_hw_data *data);
330 331
331/* */ 332/* */
332static int nsphw_init (nsp_hw_data *data); 333static int nsphw_init (nsp_hw_data *data);
333static int nsphw_start_selection(Scsi_Cmnd *SCpnt); 334static int nsphw_start_selection(struct scsi_cmnd *SCpnt);
334static void nsp_start_timer (Scsi_Cmnd *SCpnt, int time); 335static void nsp_start_timer (struct scsi_cmnd *SCpnt, int time);
335static int nsp_fifo_count (Scsi_Cmnd *SCpnt); 336static int nsp_fifo_count (struct scsi_cmnd *SCpnt);
336static void nsp_pio_read (Scsi_Cmnd *SCpnt); 337static void nsp_pio_read (struct scsi_cmnd *SCpnt);
337static void nsp_pio_write (Scsi_Cmnd *SCpnt); 338static void nsp_pio_write (struct scsi_cmnd *SCpnt);
338static int nsp_nexus (Scsi_Cmnd *SCpnt); 339static int nsp_nexus (struct scsi_cmnd *SCpnt);
339static void nsp_scsi_done (Scsi_Cmnd *SCpnt); 340static void nsp_scsi_done (struct scsi_cmnd *SCpnt);
340static int nsp_analyze_sdtr (Scsi_Cmnd *SCpnt); 341static int nsp_analyze_sdtr (struct scsi_cmnd *SCpnt);
341static int nsp_negate_signal (Scsi_Cmnd *SCpnt, unsigned char mask, char *str); 342static int nsp_negate_signal (struct scsi_cmnd *SCpnt,
342static int nsp_expect_signal (Scsi_Cmnd *SCpnt, unsigned char current_phase, unsigned char mask); 343 unsigned char mask, char *str);
343static int nsp_xfer (Scsi_Cmnd *SCpnt, int phase); 344static int nsp_expect_signal (struct scsi_cmnd *SCpnt,
344static int nsp_dataphase_bypass (Scsi_Cmnd *SCpnt); 345 unsigned char current_phase,
345static int nsp_reselected (Scsi_Cmnd *SCpnt); 346 unsigned char mask);
347static int nsp_xfer (struct scsi_cmnd *SCpnt, int phase);
348static int nsp_dataphase_bypass (struct scsi_cmnd *SCpnt);
349static int nsp_reselected (struct scsi_cmnd *SCpnt);
346static struct Scsi_Host *nsp_detect(struct scsi_host_template *sht); 350static struct Scsi_Host *nsp_detect(struct scsi_host_template *sht);
347 351
348/* Interrupt handler */ 352/* Interrupt handler */
@@ -355,8 +359,8 @@ static void __exit nsp_cs_exit(void);
355 359
356/* Debug */ 360/* Debug */
357#ifdef NSP_DEBUG 361#ifdef NSP_DEBUG
358static void show_command (Scsi_Cmnd *SCpnt); 362static void show_command (struct scsi_cmnd *SCpnt);
359static void show_phase (Scsi_Cmnd *SCpnt); 363static void show_phase (struct scsi_cmnd *SCpnt);
360static void show_busphase(unsigned char stat); 364static void show_busphase(unsigned char stat);
361static void show_message (nsp_hw_data *data); 365static void show_message (nsp_hw_data *data);
362#else 366#else
diff --git a/drivers/scsi/pcmcia/nsp_debug.c b/drivers/scsi/pcmcia/nsp_debug.c
index 62e5c60067fd..2f75fe6e35a7 100644
--- a/drivers/scsi/pcmcia/nsp_debug.c
+++ b/drivers/scsi/pcmcia/nsp_debug.c
@@ -138,12 +138,12 @@ static void print_commandk (unsigned char *command)
138 printk("\n"); 138 printk("\n");
139} 139}
140 140
141static void show_command(Scsi_Cmnd *SCpnt) 141static void show_command(struct scsi_cmnd *SCpnt)
142{ 142{
143 print_commandk(SCpnt->cmnd); 143 print_commandk(SCpnt->cmnd);
144} 144}
145 145
146static void show_phase(Scsi_Cmnd *SCpnt) 146static void show_phase(struct scsi_cmnd *SCpnt)
147{ 147{
148 int i = SCpnt->SCp.phase; 148 int i = SCpnt->SCp.phase;
149 149
diff --git a/drivers/scsi/pcmcia/nsp_message.c b/drivers/scsi/pcmcia/nsp_message.c
index d7057737ff34..ef593b70d0f0 100644
--- a/drivers/scsi/pcmcia/nsp_message.c
+++ b/drivers/scsi/pcmcia/nsp_message.c
@@ -8,7 +8,7 @@
8 8
9/* $Id: nsp_message.c,v 1.6 2003/07/26 14:21:09 elca Exp $ */ 9/* $Id: nsp_message.c,v 1.6 2003/07/26 14:21:09 elca Exp $ */
10 10
11static void nsp_message_in(Scsi_Cmnd *SCpnt) 11static void nsp_message_in(struct scsi_cmnd *SCpnt)
12{ 12{
13 unsigned int base = SCpnt->device->host->io_port; 13 unsigned int base = SCpnt->device->host->io_port;
14 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; 14 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
@@ -50,7 +50,7 @@ static void nsp_message_in(Scsi_Cmnd *SCpnt)
50 50
51} 51}
52 52
53static void nsp_message_out(Scsi_Cmnd *SCpnt) 53static void nsp_message_out(struct scsi_cmnd *SCpnt)
54{ 54{
55 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; 55 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
56 int ret = 1; 56 int ret = 1;
diff --git a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c
index b0eba39f208a..89a2a9f11e41 100644
--- a/drivers/scsi/ppa.c
+++ b/drivers/scsi/ppa.c
@@ -1012,7 +1012,7 @@ static LIST_HEAD(ppa_hosts);
1012static int __ppa_attach(struct parport *pb) 1012static int __ppa_attach(struct parport *pb)
1013{ 1013{
1014 struct Scsi_Host *host; 1014 struct Scsi_Host *host;
1015 DECLARE_WAIT_QUEUE_HEAD(waiting); 1015 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waiting);
1016 DEFINE_WAIT(wait); 1016 DEFINE_WAIT(wait);
1017 ppa_struct *dev; 1017 ppa_struct *dev;
1018 int ports; 1018 int ports;
diff --git a/drivers/scsi/psi240i.c b/drivers/scsi/psi240i.c
index a720c9265e66..899e89d6fe67 100644
--- a/drivers/scsi/psi240i.c
+++ b/drivers/scsi/psi240i.c
@@ -87,11 +87,11 @@ typedef struct
87 { 87 {
88 USHORT ports[13]; 88 USHORT ports[13];
89 OUR_DEVICE device[8]; 89 OUR_DEVICE device[8];
90 Scsi_Cmnd *pSCmnd; 90 struct scsi_cmnd *pSCmnd;
91 IDE_STRUCT ide; 91 IDE_STRUCT ide;
92 ULONG startSector; 92 ULONG startSector;
93 USHORT sectorCount; 93 USHORT sectorCount;
94 Scsi_Cmnd *SCpnt; 94 struct scsi_cmnd *SCpnt;
95 VOID *buffer; 95 VOID *buffer;
96 USHORT expectingIRQ; 96 USHORT expectingIRQ;
97 } ADAPTER240I, *PADAPTER240I; 97 } ADAPTER240I, *PADAPTER240I;
@@ -253,12 +253,12 @@ static ULONG DecodeError (struct Scsi_Host *pshost, UCHAR status)
253 ****************************************************************/ 253 ****************************************************************/
254static void Irq_Handler (int irq, void *dev_id) 254static void Irq_Handler (int irq, void *dev_id)
255 { 255 {
256 struct Scsi_Host *shost; // Pointer to host data block 256 struct Scsi_Host *shost; // Pointer to host data block
257 PADAPTER240I padapter; // Pointer to adapter control structure 257 PADAPTER240I padapter; // Pointer to adapter control structure
258 USHORT *pports; // I/O port array 258 USHORT *pports; // I/O port array
259 Scsi_Cmnd *SCpnt; 259 struct scsi_cmnd *SCpnt;
260 UCHAR status; 260 UCHAR status;
261 int z; 261 int z;
262 262
263 DEB(printk ("\npsi240i received interrupt\n")); 263 DEB(printk ("\npsi240i received interrupt\n"));
264 264
@@ -328,7 +328,7 @@ static void Irq_Handler (int irq, void *dev_id)
328 pinquiryData->AdditionalLength = 35 - 4; 328 pinquiryData->AdditionalLength = 35 - 4;
329 329
330 // Fill in vendor identification fields. 330 // Fill in vendor identification fields.
331 for ( z = 0; z < 20; z += 2 ) 331 for ( z = 0; z < 8; z += 2 )
332 { 332 {
333 pinquiryData->VendorId[z] = ((UCHAR *)identifyData.ModelNumber)[z + 1]; 333 pinquiryData->VendorId[z] = ((UCHAR *)identifyData.ModelNumber)[z + 1];
334 pinquiryData->VendorId[z + 1] = ((UCHAR *)identifyData.ModelNumber)[z]; 334 pinquiryData->VendorId[z + 1] = ((UCHAR *)identifyData.ModelNumber)[z];
@@ -389,12 +389,17 @@ static irqreturn_t do_Irq_Handler (int irq, void *dev_id)
389 * Returns: Status code. 389 * Returns: Status code.
390 * 390 *
391 ****************************************************************/ 391 ****************************************************************/
392static int Psi240i_QueueCommand (Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) 392static int Psi240i_QueueCommand(struct scsi_cmnd *SCpnt,
393 void (*done)(struct scsi_cmnd *))
393 { 394 {
394 UCHAR *cdb = (UCHAR *)SCpnt->cmnd; // Pointer to SCSI CDB 395 UCHAR *cdb = (UCHAR *)SCpnt->cmnd;
395 PADAPTER240I padapter = HOSTDATA (SCpnt->device->host); // Pointer to adapter control structure 396 // Pointer to SCSI CDB
396 POUR_DEVICE pdev = &padapter->device [SCpnt->device->id];// Pointer to device information 397 PADAPTER240I padapter = HOSTDATA (SCpnt->device->host);
397 UCHAR rc; // command return code 398 // Pointer to adapter control structure
399 POUR_DEVICE pdev = &padapter->device [SCpnt->device->id];
400 // Pointer to device information
401 UCHAR rc;
402 // command return code
398 403
399 SCpnt->scsi_done = done; 404 SCpnt->scsi_done = done;
400 padapter->ide.ide.ides.spigot = pdev->spigot; 405 padapter->ide.ide.ides.spigot = pdev->spigot;
diff --git a/drivers/scsi/psi240i.h b/drivers/scsi/psi240i.h
index 6a598766df51..21ebb9214004 100644
--- a/drivers/scsi/psi240i.h
+++ b/drivers/scsi/psi240i.h
@@ -309,7 +309,7 @@ typedef struct _IDENTIFY_DATA2 {
309#endif // PSI_EIDE_SCSIOP 309#endif // PSI_EIDE_SCSIOP
310 310
311// function prototypes 311// function prototypes
312int Psi240i_Command (Scsi_Cmnd *SCpnt); 312int Psi240i_Command(struct scsi_cmnd *SCpnt);
313int Psi240i_Abort (Scsi_Cmnd *SCpnt); 313int Psi240i_Abort(struct scsi_cmnd *SCpnt);
314int Psi240i_Reset (Scsi_Cmnd *SCpnt, unsigned int flags); 314int Psi240i_Reset(struct scsi_cmnd *SCpnt, unsigned int flags);
315#endif 315#endif
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index 2521d548dd59..16af5b79e587 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -931,11 +931,10 @@ qla1280_error_action(struct scsi_cmnd *cmd, enum action action)
931 931
932 case BUS_RESET: 932 case BUS_RESET:
933 if (qla1280_verbose) 933 if (qla1280_verbose)
934 printk(KERN_INFO "qla1280(%ld:%d): Issuing BUS " 934 printk(KERN_INFO "qla1280(%ld:%d): Issued bus "
935 "DEVICE RESET\n", ha->host_no, bus); 935 "reset.\n", ha->host_no, bus);
936 if (qla1280_bus_reset(ha, bus == 0)) 936 if (qla1280_bus_reset(ha, bus) == 0)
937 result = SUCCESS; 937 result = SUCCESS;
938
939 break; 938 break;
940 939
941 case ADAPTER_RESET: 940 case ADAPTER_RESET:
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index ee75a71f3c66..285c8e8ff1a0 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -379,21 +379,37 @@ static struct bin_attribute sysfs_sfp_attr = {
379 .read = qla2x00_sysfs_read_sfp, 379 .read = qla2x00_sysfs_read_sfp,
380}; 380};
381 381
382static struct sysfs_entry {
383 char *name;
384 struct bin_attribute *attr;
385 int is4GBp_only;
386} bin_file_entries[] = {
387 { "fw_dump", &sysfs_fw_dump_attr, },
388 { "nvram", &sysfs_nvram_attr, },
389 { "optrom", &sysfs_optrom_attr, },
390 { "optrom_ctl", &sysfs_optrom_ctl_attr, },
391 { "vpd", &sysfs_vpd_attr, 1 },
392 { "sfp", &sysfs_sfp_attr, 1 },
393 { 0 },
394};
395
382void 396void
383qla2x00_alloc_sysfs_attr(scsi_qla_host_t *ha) 397qla2x00_alloc_sysfs_attr(scsi_qla_host_t *ha)
384{ 398{
385 struct Scsi_Host *host = ha->host; 399 struct Scsi_Host *host = ha->host;
400 struct sysfs_entry *iter;
401 int ret;
386 402
387 sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_fw_dump_attr); 403 for (iter = bin_file_entries; iter->name; iter++) {
388 sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_nvram_attr); 404 if (iter->is4GBp_only && (!IS_QLA24XX(ha) && !IS_QLA54XX(ha)))
389 sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_optrom_attr); 405 continue;
390 sysfs_create_bin_file(&host->shost_gendev.kobj, 406
391 &sysfs_optrom_ctl_attr); 407 ret = sysfs_create_bin_file(&host->shost_gendev.kobj,
392 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 408 iter->attr);
393 sysfs_create_bin_file(&host->shost_gendev.kobj, 409 if (ret)
394 &sysfs_vpd_attr); 410 qla_printk(KERN_INFO, ha,
395 sysfs_create_bin_file(&host->shost_gendev.kobj, 411 "Unable to create sysfs %s binary attribute "
396 &sysfs_sfp_attr); 412 "(%d).\n", iter->name, ret);
397 } 413 }
398} 414}
399 415
@@ -401,17 +417,14 @@ void
401qla2x00_free_sysfs_attr(scsi_qla_host_t *ha) 417qla2x00_free_sysfs_attr(scsi_qla_host_t *ha)
402{ 418{
403 struct Scsi_Host *host = ha->host; 419 struct Scsi_Host *host = ha->host;
420 struct sysfs_entry *iter;
421
422 for (iter = bin_file_entries; iter->name; iter++) {
423 if (iter->is4GBp_only && (!IS_QLA24XX(ha) && !IS_QLA54XX(ha)))
424 continue;
404 425
405 sysfs_remove_bin_file(&host->shost_gendev.kobj, &sysfs_fw_dump_attr);
406 sysfs_remove_bin_file(&host->shost_gendev.kobj, &sysfs_nvram_attr);
407 sysfs_remove_bin_file(&host->shost_gendev.kobj, &sysfs_optrom_attr);
408 sysfs_remove_bin_file(&host->shost_gendev.kobj,
409 &sysfs_optrom_ctl_attr);
410 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) {
411 sysfs_remove_bin_file(&host->shost_gendev.kobj,
412 &sysfs_vpd_attr);
413 sysfs_remove_bin_file(&host->shost_gendev.kobj, 426 sysfs_remove_bin_file(&host->shost_gendev.kobj,
414 &sysfs_sfp_attr); 427 iter->attr);
415 } 428 }
416 429
417 if (ha->beacon_blink_led == 1) 430 if (ha->beacon_blink_led == 1)
diff --git a/drivers/scsi/qla2xxx/qla_dbg.h b/drivers/scsi/qla2xxx/qla_dbg.h
index 90dad7e88985..5b12278968e0 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.h
+++ b/drivers/scsi/qla2xxx/qla_dbg.h
@@ -38,7 +38,7 @@
38* Macros use for debugging the driver. 38* Macros use for debugging the driver.
39*/ 39*/
40 40
41#define DEBUG(x) do { if (qla2_extended_error_logging) { x; } } while (0) 41#define DEBUG(x) do { if (ql2xextended_error_logging) { x; } } while (0)
42 42
43#if defined(QL_DEBUG_LEVEL_1) 43#if defined(QL_DEBUG_LEVEL_1)
44#define DEBUG1(x) do {x;} while (0) 44#define DEBUG1(x) do {x;} while (0)
@@ -46,12 +46,12 @@
46#define DEBUG1(x) do {} while (0) 46#define DEBUG1(x) do {} while (0)
47#endif 47#endif
48 48
49#define DEBUG2(x) do { if (qla2_extended_error_logging) { x; } } while (0) 49#define DEBUG2(x) do { if (ql2xextended_error_logging) { x; } } while (0)
50#define DEBUG2_3(x) do { if (qla2_extended_error_logging) { x; } } while (0) 50#define DEBUG2_3(x) do { if (ql2xextended_error_logging) { x; } } while (0)
51#define DEBUG2_3_11(x) do { if (qla2_extended_error_logging) { x; } } while (0) 51#define DEBUG2_3_11(x) do { if (ql2xextended_error_logging) { x; } } while (0)
52#define DEBUG2_9_10(x) do { if (qla2_extended_error_logging) { x; } } while (0) 52#define DEBUG2_9_10(x) do { if (ql2xextended_error_logging) { x; } } while (0)
53#define DEBUG2_11(x) do { if (qla2_extended_error_logging) { x; } } while (0) 53#define DEBUG2_11(x) do { if (ql2xextended_error_logging) { x; } } while (0)
54#define DEBUG2_13(x) do { if (qla2_extended_error_logging) { x; } } while (0) 54#define DEBUG2_13(x) do { if (ql2xextended_error_logging) { x; } } while (0)
55 55
56#if defined(QL_DEBUG_LEVEL_3) 56#if defined(QL_DEBUG_LEVEL_3)
57#define DEBUG3(x) do {x;} while (0) 57#define DEBUG3(x) do {x;} while (0)
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index bab33f6d0bdb..c4fc40f8e8ca 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -1545,6 +1545,9 @@ typedef struct fc_port {
1545 spinlock_t rport_lock; 1545 spinlock_t rport_lock;
1546 struct fc_rport *rport, *drport; 1546 struct fc_rport *rport, *drport;
1547 u32 supported_classes; 1547 u32 supported_classes;
1548
1549 unsigned long last_queue_full;
1550 unsigned long last_ramp_up;
1548} fc_port_t; 1551} fc_port_t;
1549 1552
1550/* 1553/*
@@ -2255,6 +2258,7 @@ typedef struct scsi_qla_host {
2255 uint16_t mgmt_svr_loop_id; 2258 uint16_t mgmt_svr_loop_id;
2256 2259
2257 uint32_t login_retry_count; 2260 uint32_t login_retry_count;
2261 int max_q_depth;
2258 2262
2259 /* Fibre Channel Device List. */ 2263 /* Fibre Channel Device List. */
2260 struct list_head fcports; 2264 struct list_head fcports;
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index 7da69832d74c..32ebeec45ff0 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -48,6 +48,7 @@ extern void qla2x00_update_fcport(scsi_qla_host_t *, fc_port_t *);
48extern void qla2x00_reg_remote_port(scsi_qla_host_t *, fc_port_t *); 48extern void qla2x00_reg_remote_port(scsi_qla_host_t *, fc_port_t *);
49 49
50extern void qla2x00_alloc_fw_dump(scsi_qla_host_t *); 50extern void qla2x00_alloc_fw_dump(scsi_qla_host_t *);
51extern void qla2x00_try_to_stop_firmware(scsi_qla_host_t *);
51 52
52/* 53/*
53 * Global Data in qla_os.c source file. 54 * Global Data in qla_os.c source file.
@@ -60,7 +61,8 @@ extern int ql2xplogiabsentdevice;
60extern int ql2xloginretrycount; 61extern int ql2xloginretrycount;
61extern int ql2xfdmienable; 62extern int ql2xfdmienable;
62extern int ql2xallocfwdump; 63extern int ql2xallocfwdump;
63extern int qla2_extended_error_logging; 64extern int ql2xextended_error_logging;
65extern int ql2xqfullrampup;
64 66
65extern void qla2x00_sp_compl(scsi_qla_host_t *, srb_t *); 67extern void qla2x00_sp_compl(scsi_qla_host_t *, srb_t *);
66 68
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 833b93085fd3..08cb5e3fb553 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -1644,7 +1644,7 @@ qla2x00_nvram_config(scsi_qla_host_t *ha)
1644 * Set host adapter parameters. 1644 * Set host adapter parameters.
1645 */ 1645 */
1646 if (nv->host_p[0] & BIT_7) 1646 if (nv->host_p[0] & BIT_7)
1647 qla2_extended_error_logging = 1; 1647 ql2xextended_error_logging = 1;
1648 ha->flags.disable_risc_code_load = ((nv->host_p[0] & BIT_4) ? 1 : 0); 1648 ha->flags.disable_risc_code_load = ((nv->host_p[0] & BIT_4) ? 1 : 0);
1649 /* Always load RISC code on non ISP2[12]00 chips. */ 1649 /* Always load RISC code on non ISP2[12]00 chips. */
1650 if (!IS_QLA2100(ha) && !IS_QLA2200(ha)) 1650 if (!IS_QLA2100(ha) && !IS_QLA2200(ha))
@@ -3948,3 +3948,24 @@ qla24xx_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr)
3948fail_fw_integrity: 3948fail_fw_integrity:
3949 return QLA_FUNCTION_FAILED; 3949 return QLA_FUNCTION_FAILED;
3950} 3950}
3951
3952void
3953qla2x00_try_to_stop_firmware(scsi_qla_host_t *ha)
3954{
3955 int ret, retries;
3956
3957 if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha))
3958 return;
3959
3960 ret = qla2x00_stop_firmware(ha);
3961 for (retries = 5; ret != QLA_SUCCESS && retries ; retries--) {
3962 qla2x00_reset_chip(ha);
3963 if (qla2x00_chip_diag(ha) != QLA_SUCCESS)
3964 continue;
3965 if (qla2x00_setup_chip(ha) != QLA_SUCCESS)
3966 continue;
3967 qla_printk(KERN_INFO, ha,
3968 "Attempting retry of stop-firmware command...\n");
3969 ret = qla2x00_stop_firmware(ha);
3970 }
3971}
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 626c7178a434..d3b6df4d55c8 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -6,6 +6,8 @@
6 */ 6 */
7#include "qla_def.h" 7#include "qla_def.h"
8 8
9#include <scsi/scsi_tcq.h>
10
9static void qla2x00_mbx_completion(scsi_qla_host_t *, uint16_t); 11static void qla2x00_mbx_completion(scsi_qla_host_t *, uint16_t);
10static void qla2x00_async_event(scsi_qla_host_t *, uint16_t *); 12static void qla2x00_async_event(scsi_qla_host_t *, uint16_t *);
11static void qla2x00_process_completed_request(struct scsi_qla_host *, uint32_t); 13static void qla2x00_process_completed_request(struct scsi_qla_host *, uint32_t);
@@ -593,6 +595,67 @@ qla2x00_async_event(scsi_qla_host_t *ha, uint16_t *mb)
593 } 595 }
594} 596}
595 597
598static void
599qla2x00_adjust_sdev_qdepth_up(struct scsi_device *sdev, void *data)
600{
601 fc_port_t *fcport = data;
602
603 if (fcport->ha->max_q_depth <= sdev->queue_depth)
604 return;
605
606 if (sdev->ordered_tags)
607 scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG,
608 sdev->queue_depth + 1);
609 else
610 scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG,
611 sdev->queue_depth + 1);
612
613 fcport->last_ramp_up = jiffies;
614
615 DEBUG2(qla_printk(KERN_INFO, fcport->ha,
616 "scsi(%ld:%d:%d:%d): Queue depth adjusted-up to %d.\n",
617 fcport->ha->host_no, sdev->channel, sdev->id, sdev->lun,
618 sdev->queue_depth));
619}
620
621static void
622qla2x00_adjust_sdev_qdepth_down(struct scsi_device *sdev, void *data)
623{
624 fc_port_t *fcport = data;
625
626 if (!scsi_track_queue_full(sdev, sdev->queue_depth - 1))
627 return;
628
629 DEBUG2(qla_printk(KERN_INFO, fcport->ha,
630 "scsi(%ld:%d:%d:%d): Queue depth adjusted-down to %d.\n",
631 fcport->ha->host_no, sdev->channel, sdev->id, sdev->lun,
632 sdev->queue_depth));
633}
634
635static inline void
636qla2x00_ramp_up_queue_depth(scsi_qla_host_t *ha, srb_t *sp)
637{
638 fc_port_t *fcport;
639 struct scsi_device *sdev;
640
641 sdev = sp->cmd->device;
642 if (sdev->queue_depth >= ha->max_q_depth)
643 return;
644
645 fcport = sp->fcport;
646 if (time_before(jiffies,
647 fcport->last_ramp_up + ql2xqfullrampup * HZ))
648 return;
649 if (time_before(jiffies,
650 fcport->last_queue_full + ql2xqfullrampup * HZ))
651 return;
652
653 spin_unlock_irq(&ha->hardware_lock);
654 starget_for_each_device(sdev->sdev_target, fcport,
655 qla2x00_adjust_sdev_qdepth_up);
656 spin_lock_irq(&ha->hardware_lock);
657}
658
596/** 659/**
597 * qla2x00_process_completed_request() - Process a Fast Post response. 660 * qla2x00_process_completed_request() - Process a Fast Post response.
598 * @ha: SCSI driver HA context 661 * @ha: SCSI driver HA context
@@ -624,6 +687,8 @@ qla2x00_process_completed_request(struct scsi_qla_host *ha, uint32_t index)
624 687
625 /* Save ISP completion status */ 688 /* Save ISP completion status */
626 sp->cmd->result = DID_OK << 16; 689 sp->cmd->result = DID_OK << 16;
690
691 qla2x00_ramp_up_queue_depth(ha, sp);
627 qla2x00_sp_compl(ha, sp); 692 qla2x00_sp_compl(ha, sp);
628 } else { 693 } else {
629 DEBUG2(printk("scsi(%ld): Invalid ISP SCSI completion handle\n", 694 DEBUG2(printk("scsi(%ld): Invalid ISP SCSI completion handle\n",
@@ -823,6 +888,7 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt)
823 */ 888 */
824 switch (comp_status) { 889 switch (comp_status) {
825 case CS_COMPLETE: 890 case CS_COMPLETE:
891 case CS_QUEUE_FULL:
826 if (scsi_status == 0) { 892 if (scsi_status == 0) {
827 cp->result = DID_OK << 16; 893 cp->result = DID_OK << 16;
828 break; 894 break;
@@ -849,6 +915,20 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt)
849 } 915 }
850 cp->result = DID_OK << 16 | lscsi_status; 916 cp->result = DID_OK << 16 | lscsi_status;
851 917
918 if (lscsi_status == SAM_STAT_TASK_SET_FULL) {
919 DEBUG2(printk(KERN_INFO
920 "scsi(%ld): QUEUE FULL status detected "
921 "0x%x-0x%x.\n", ha->host_no, comp_status,
922 scsi_status));
923
924 /* Adjust queue depth for all luns on the port. */
925 fcport->last_queue_full = jiffies;
926 spin_unlock_irq(&ha->hardware_lock);
927 starget_for_each_device(cp->device->sdev_target,
928 fcport, qla2x00_adjust_sdev_qdepth_down);
929 spin_lock_irq(&ha->hardware_lock);
930 break;
931 }
852 if (lscsi_status != SS_CHECK_CONDITION) 932 if (lscsi_status != SS_CHECK_CONDITION)
853 break; 933 break;
854 934
@@ -1066,17 +1146,6 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt)
1066 qla2x00_mark_device_lost(ha, fcport, 1, 1); 1146 qla2x00_mark_device_lost(ha, fcport, 1, 1);
1067 break; 1147 break;
1068 1148
1069 case CS_QUEUE_FULL:
1070 DEBUG2(printk(KERN_INFO
1071 "scsi(%ld): QUEUE FULL status detected 0x%x-0x%x.\n",
1072 ha->host_no, comp_status, scsi_status));
1073
1074 /* SCSI Mid-Layer handles device queue full */
1075
1076 cp->result = DID_OK << 16 | lscsi_status;
1077
1078 break;
1079
1080 default: 1149 default:
1081 DEBUG3(printk("scsi(%ld): Error detected (unknown status) " 1150 DEBUG3(printk("scsi(%ld): Error detected (unknown status) "
1082 "0x%x-0x%x.\n", ha->host_no, comp_status, scsi_status)); 1151 "0x%x-0x%x.\n", ha->host_no, comp_status, scsi_status));
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 5e70c49fdf84..3eb4cd2cbc78 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -61,9 +61,9 @@ MODULE_PARM_DESC(ql2xallocfwdump,
61 "during HBA initialization. Memory allocation requirements " 61 "during HBA initialization. Memory allocation requirements "
62 "vary by ISP type. Default is 1 - allocate memory."); 62 "vary by ISP type. Default is 1 - allocate memory.");
63 63
64int qla2_extended_error_logging; 64int ql2xextended_error_logging;
65module_param(qla2_extended_error_logging, int, S_IRUGO|S_IRUSR); 65module_param(ql2xextended_error_logging, int, S_IRUGO|S_IRUSR);
66MODULE_PARM_DESC(qla2_extended_error_logging, 66MODULE_PARM_DESC(ql2xextended_error_logging,
67 "Option to enable extended error logging, " 67 "Option to enable extended error logging, "
68 "Default is 0 - no logging. 1 - log errors."); 68 "Default is 0 - no logging. 1 - log errors.");
69 69
@@ -77,6 +77,19 @@ MODULE_PARM_DESC(ql2xfdmienable,
77 "Enables FDMI registratons " 77 "Enables FDMI registratons "
78 "Default is 0 - no FDMI. 1 - perfom FDMI."); 78 "Default is 0 - no FDMI. 1 - perfom FDMI.");
79 79
80#define MAX_Q_DEPTH 32
81static int ql2xmaxqdepth = MAX_Q_DEPTH;
82module_param(ql2xmaxqdepth, int, S_IRUGO|S_IWUSR);
83MODULE_PARM_DESC(ql2xmaxqdepth,
84 "Maximum queue depth to report for target devices.");
85
86int ql2xqfullrampup = 120;
87module_param(ql2xqfullrampup, int, S_IRUGO|S_IWUSR);
88MODULE_PARM_DESC(ql2xqfullrampup,
89 "Number of seconds to wait to begin to ramp-up the queue "
90 "depth for a device after a queue-full condition has been "
91 "detected. Default is 120 seconds.");
92
80/* 93/*
81 * SCSI host template entry points 94 * SCSI host template entry points
82 */ 95 */
@@ -1104,9 +1117,9 @@ qla2xxx_slave_configure(struct scsi_device *sdev)
1104 struct fc_rport *rport = starget_to_rport(sdev->sdev_target); 1117 struct fc_rport *rport = starget_to_rport(sdev->sdev_target);
1105 1118
1106 if (sdev->tagged_supported) 1119 if (sdev->tagged_supported)
1107 scsi_activate_tcq(sdev, 32); 1120 scsi_activate_tcq(sdev, ha->max_q_depth);
1108 else 1121 else
1109 scsi_deactivate_tcq(sdev, 32); 1122 scsi_deactivate_tcq(sdev, ha->max_q_depth);
1110 1123
1111 rport->dev_loss_tmo = ha->port_down_retry_count + 5; 1124 rport->dev_loss_tmo = ha->port_down_retry_count + 5;
1112 1125
@@ -1413,6 +1426,10 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1413 ha->link_data_rate = PORT_SPEED_UNKNOWN; 1426 ha->link_data_rate = PORT_SPEED_UNKNOWN;
1414 ha->optrom_size = OPTROM_SIZE_2300; 1427 ha->optrom_size = OPTROM_SIZE_2300;
1415 1428
1429 ha->max_q_depth = MAX_Q_DEPTH;
1430 if (ql2xmaxqdepth != 0 && ql2xmaxqdepth <= 0xffffU)
1431 ha->max_q_depth = ql2xmaxqdepth;
1432
1416 /* Assign ISP specific operations. */ 1433 /* Assign ISP specific operations. */
1417 ha->isp_ops.pci_config = qla2100_pci_config; 1434 ha->isp_ops.pci_config = qla2100_pci_config;
1418 ha->isp_ops.reset_chip = qla2x00_reset_chip; 1435 ha->isp_ops.reset_chip = qla2x00_reset_chip;
@@ -1712,8 +1729,10 @@ qla2x00_free_device(scsi_qla_host_t *ha)
1712 if (ha->eft) 1729 if (ha->eft)
1713 qla2x00_trace_control(ha, TC_DISABLE, 0, 0); 1730 qla2x00_trace_control(ha, TC_DISABLE, 0, 0);
1714 1731
1732 ha->flags.online = 0;
1733
1715 /* Stop currently executing firmware. */ 1734 /* Stop currently executing firmware. */
1716 qla2x00_stop_firmware(ha); 1735 qla2x00_try_to_stop_firmware(ha);
1717 1736
1718 /* turn-off interrupts on the card */ 1737 /* turn-off interrupts on the card */
1719 if (ha->interrupts_on) 1738 if (ha->interrupts_on)
@@ -1721,8 +1740,6 @@ qla2x00_free_device(scsi_qla_host_t *ha)
1721 1740
1722 qla2x00_mem_free(ha); 1741 qla2x00_mem_free(ha);
1723 1742
1724 ha->flags.online = 0;
1725
1726 /* Detach interrupts */ 1743 /* Detach interrupts */
1727 if (ha->host->irq) 1744 if (ha->host->irq)
1728 free_irq(ha->host->irq, ha); 1745 free_irq(ha->host->irq, ha);
@@ -2697,7 +2714,7 @@ qla2x00_module_init(void)
2697 2714
2698 /* Derive version string. */ 2715 /* Derive version string. */
2699 strcpy(qla2x00_version_str, QLA2XXX_VERSION); 2716 strcpy(qla2x00_version_str, QLA2XXX_VERSION);
2700 if (qla2_extended_error_logging) 2717 if (ql2xextended_error_logging)
2701 strcat(qla2x00_version_str, "-debug"); 2718 strcat(qla2x00_version_str, "-debug");
2702 2719
2703 qla2xxx_transport_template = 2720 qla2xxx_transport_template =
diff --git a/drivers/scsi/qla2xxx/qla_version.h b/drivers/scsi/qla2xxx/qla_version.h
index e57bf45a3393..1fa0bce6b24e 100644
--- a/drivers/scsi/qla2xxx/qla_version.h
+++ b/drivers/scsi/qla2xxx/qla_version.h
@@ -7,7 +7,7 @@
7/* 7/*
8 * Driver version 8 * Driver version
9 */ 9 */
10#define QLA2XXX_VERSION "8.01.07-k2" 10#define QLA2XXX_VERSION "8.01.07-k3"
11 11
12#define QLA_DRIVER_MAJOR_VER 8 12#define QLA_DRIVER_MAJOR_VER 8
13#define QLA_DRIVER_MINOR_VER 1 13#define QLA_DRIVER_MINOR_VER 1
diff --git a/drivers/scsi/qla4xxx/Kconfig b/drivers/scsi/qla4xxx/Kconfig
index 08a07f0b8d94..69cbff3f57cf 100644
--- a/drivers/scsi/qla4xxx/Kconfig
+++ b/drivers/scsi/qla4xxx/Kconfig
@@ -1,6 +1,6 @@
1config SCSI_QLA_ISCSI 1config SCSI_QLA_ISCSI
2 tristate "QLogic ISP4XXX host adapter family support" 2 tristate "QLogic ISP4XXX host adapter family support"
3 depends on PCI && SCSI 3 depends on PCI && SCSI && NET
4 select SCSI_ISCSI_ATTRS 4 select SCSI_ISCSI_ATTRS
5 ---help--- 5 ---help---
6 This driver supports the QLogic 40xx (ISP4XXX) iSCSI host 6 This driver supports the QLogic 40xx (ISP4XXX) iSCSI host
diff --git a/drivers/scsi/qla4xxx/ql4_dbg.h b/drivers/scsi/qla4xxx/ql4_dbg.h
index 3e99dcfd5a9f..d861c3b411c8 100644
--- a/drivers/scsi/qla4xxx/ql4_dbg.h
+++ b/drivers/scsi/qla4xxx/ql4_dbg.h
@@ -22,14 +22,14 @@
22#endif 22#endif
23 23
24#if defined(QL_DEBUG_LEVEL_2) 24#if defined(QL_DEBUG_LEVEL_2)
25#define DEBUG2(x) do {if(qla4_extended_error_logging == 2) x;} while (0); 25#define DEBUG2(x) do {if(ql4xextended_error_logging == 2) x;} while (0);
26#define DEBUG2_3(x) do {x;} while (0); 26#define DEBUG2_3(x) do {x;} while (0);
27#else /* */ 27#else /* */
28#define DEBUG2(x) do {} while (0); 28#define DEBUG2(x) do {} while (0);
29#endif /* */ 29#endif /* */
30 30
31#if defined(QL_DEBUG_LEVEL_3) 31#if defined(QL_DEBUG_LEVEL_3)
32#define DEBUG3(x) do {if(qla4_extended_error_logging == 3) x;} while (0); 32#define DEBUG3(x) do {if(ql4xextended_error_logging == 3) x;} while (0);
33#else /* */ 33#else /* */
34#define DEBUG3(x) do {} while (0); 34#define DEBUG3(x) do {} while (0);
35#if !defined(QL_DEBUG_LEVEL_2) 35#if !defined(QL_DEBUG_LEVEL_2)
diff --git a/drivers/scsi/qla4xxx/ql4_glbl.h b/drivers/scsi/qla4xxx/ql4_glbl.h
index 2c803edf2de8..eeefdcb1edb5 100644
--- a/drivers/scsi/qla4xxx/ql4_glbl.h
+++ b/drivers/scsi/qla4xxx/ql4_glbl.h
@@ -8,6 +8,7 @@
8#ifndef __QLA4x_GBL_H 8#ifndef __QLA4x_GBL_H
9#define __QLA4x_GBL_H 9#define __QLA4x_GBL_H
10 10
11int ql4xxx_lock_drvr_wait(struct scsi_qla_host *a);
11int qla4xxx_send_tgts(struct scsi_qla_host *ha, char *ip, uint16_t port); 12int qla4xxx_send_tgts(struct scsi_qla_host *ha, char *ip, uint16_t port);
12int qla4xxx_send_command_to_isp(struct scsi_qla_host *ha, struct srb * srb); 13int qla4xxx_send_command_to_isp(struct scsi_qla_host *ha, struct srb * srb);
13int qla4xxx_initialize_adapter(struct scsi_qla_host * ha, 14int qla4xxx_initialize_adapter(struct scsi_qla_host * ha,
@@ -72,7 +73,7 @@ int qla4xxx_reinitialize_ddb_list(struct scsi_qla_host * ha);
72int qla4xxx_process_ddb_changed(struct scsi_qla_host * ha, 73int qla4xxx_process_ddb_changed(struct scsi_qla_host * ha,
73 uint32_t fw_ddb_index, uint32_t state); 74 uint32_t fw_ddb_index, uint32_t state);
74 75
75extern int qla4_extended_error_logging; 76extern int ql4xextended_error_logging;
76extern int ql4xdiscoverywait; 77extern int ql4xdiscoverywait;
77extern int ql4xdontresethba; 78extern int ql4xdontresethba;
78#endif /* _QLA4x_GBL_H */ 79#endif /* _QLA4x_GBL_H */
diff --git a/drivers/scsi/qla4xxx/ql4_init.c b/drivers/scsi/qla4xxx/ql4_init.c
index bb3a1c11f44c..9e81b810dc88 100644
--- a/drivers/scsi/qla4xxx/ql4_init.c
+++ b/drivers/scsi/qla4xxx/ql4_init.c
@@ -978,7 +978,7 @@ static int qla4xxx_start_firmware_from_flash(struct scsi_qla_host *ha)
978 return status; 978 return status;
979} 979}
980 980
981static int ql4xxx_lock_drvr_wait(struct scsi_qla_host *a) 981int ql4xxx_lock_drvr_wait(struct scsi_qla_host *a)
982{ 982{
983#define QL4_LOCK_DRVR_WAIT 300 983#define QL4_LOCK_DRVR_WAIT 300
984#define QL4_LOCK_DRVR_SLEEP 100 984#define QL4_LOCK_DRVR_SLEEP 100
diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c
index ef82399c0858..b721dc5dd711 100644
--- a/drivers/scsi/qla4xxx/ql4_mbx.c
+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
@@ -701,7 +701,7 @@ void qla4xxx_get_conn_event_log(struct scsi_qla_host * ha)
701 DEBUG3(printk("scsi%ld: Connection Event Log Dump (%d entries):\n", 701 DEBUG3(printk("scsi%ld: Connection Event Log Dump (%d entries):\n",
702 ha->host_no, num_valid_entries)); 702 ha->host_no, num_valid_entries));
703 703
704 if (qla4_extended_error_logging == 3) { 704 if (ql4xextended_error_logging == 3) {
705 if (oldest_entry == 0) { 705 if (oldest_entry == 0) {
706 /* Circular Buffer has not wrapped around */ 706 /* Circular Buffer has not wrapped around */
707 for (i=0; i < num_valid_entries; i++) { 707 for (i=0; i < num_valid_entries; i++) {
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 178fcddcfd81..bab434ee774b 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -34,9 +34,9 @@ MODULE_PARM_DESC(ql4xdontresethba,
34 " default it will reset hba :0" 34 " default it will reset hba :0"
35 " set to 1 to avoid resetting HBA"); 35 " set to 1 to avoid resetting HBA");
36 36
37int qla4_extended_error_logging = 0; /* 0 = off, 1 = log errors */ 37int ql4xextended_error_logging = 0; /* 0 = off, 1 = log errors */
38module_param(qla4_extended_error_logging, int, S_IRUGO | S_IRUSR); 38module_param(ql4xextended_error_logging, int, S_IRUGO | S_IRUSR);
39MODULE_PARM_DESC(qla4_extended_error_logging, 39MODULE_PARM_DESC(ql4xextended_error_logging,
40 "Option to enable extended error logging, " 40 "Option to enable extended error logging, "
41 "Default is 0 - no logging, 1 - debug logging"); 41 "Default is 0 - no logging, 1 - debug logging");
42 42
@@ -919,18 +919,11 @@ static int qla4xxx_recover_adapter(struct scsi_qla_host *ha,
919 if (status == QLA_SUCCESS) { 919 if (status == QLA_SUCCESS) {
920 DEBUG2(printk("scsi%ld: %s - Performing soft reset..\n", 920 DEBUG2(printk("scsi%ld: %s - Performing soft reset..\n",
921 ha->host_no, __func__)); 921 ha->host_no, __func__));
922 status = qla4xxx_soft_reset(ha); 922 qla4xxx_flush_active_srbs(ha);
923 } 923 if (ql4xxx_lock_drvr_wait(ha) == QLA_SUCCESS)
924 /* FIXMEkaren: Do we want to keep interrupts enabled and process 924 status = qla4xxx_soft_reset(ha);
925 AENs after soft reset */ 925 else
926 926 status = QLA_ERROR;
927 /* If firmware (SOFT) reset failed, or if all outstanding
928 * commands have not returned, then do a HARD reset.
929 */
930 if (status == QLA_ERROR) {
931 DEBUG2(printk("scsi%ld: %s - Performing hard reset..\n",
932 ha->host_no, __func__));
933 status = qla4xxx_hard_reset(ha);
934 } 927 }
935 928
936 /* Flush any pending ddb changed AENs */ 929 /* Flush any pending ddb changed AENs */
@@ -1016,13 +1009,9 @@ static void qla4xxx_do_dpc(void *data)
1016 struct scsi_qla_host *ha = (struct scsi_qla_host *) data; 1009 struct scsi_qla_host *ha = (struct scsi_qla_host *) data;
1017 struct ddb_entry *ddb_entry, *dtemp; 1010 struct ddb_entry *ddb_entry, *dtemp;
1018 1011
1019 DEBUG2(printk("scsi%ld: %s: DPC handler waking up.\n", 1012 DEBUG2(printk("scsi%ld: %s: DPC handler waking up."
1020 ha->host_no, __func__)); 1013 "flags = 0x%08lx, dpc_flags = 0x%08lx\n",
1021 1014 ha->host_no, __func__, ha->flags, ha->dpc_flags));
1022 DEBUG2(printk("scsi%ld: %s: ha->flags = 0x%08lx\n",
1023 ha->host_no, __func__, ha->flags));
1024 DEBUG2(printk("scsi%ld: %s: ha->dpc_flags = 0x%08lx\n",
1025 ha->host_no, __func__, ha->dpc_flags));
1026 1015
1027 /* Initialization not yet finished. Don't do anything yet. */ 1016 /* Initialization not yet finished. Don't do anything yet. */
1028 if (!test_bit(AF_INIT_DONE, &ha->flags)) 1017 if (!test_bit(AF_INIT_DONE, &ha->flags))
@@ -1032,16 +1021,8 @@ static void qla4xxx_do_dpc(void *data)
1032 test_bit(DPC_RESET_HA, &ha->dpc_flags) || 1021 test_bit(DPC_RESET_HA, &ha->dpc_flags) ||
1033 test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags) || 1022 test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags) ||
1034 test_bit(DPC_RESET_HA_DESTROY_DDB_LIST, &ha->dpc_flags)) { 1023 test_bit(DPC_RESET_HA_DESTROY_DDB_LIST, &ha->dpc_flags)) {
1035 if (test_bit(DPC_RESET_HA_DESTROY_DDB_LIST, &ha->dpc_flags)) 1024 if (test_bit(DPC_RESET_HA_DESTROY_DDB_LIST, &ha->dpc_flags) ||
1036 /* 1025 test_bit(DPC_RESET_HA, &ha->dpc_flags))
1037 * dg 09/23 Never initialize ddb list
1038 * once we up and running
1039 * qla4xxx_recover_adapter(ha,
1040 * REBUILD_DDB_LIST);
1041 */
1042 qla4xxx_recover_adapter(ha, PRESERVE_DDB_LIST);
1043
1044 if (test_bit(DPC_RESET_HA, &ha->dpc_flags))
1045 qla4xxx_recover_adapter(ha, PRESERVE_DDB_LIST); 1026 qla4xxx_recover_adapter(ha, PRESERVE_DDB_LIST);
1046 1027
1047 if (test_and_clear_bit(DPC_RESET_HA_INTR, &ha->dpc_flags)) { 1028 if (test_and_clear_bit(DPC_RESET_HA_INTR, &ha->dpc_flags)) {
@@ -1122,7 +1103,8 @@ static void qla4xxx_free_adapter(struct scsi_qla_host *ha)
1122 destroy_workqueue(ha->dpc_thread); 1103 destroy_workqueue(ha->dpc_thread);
1123 1104
1124 /* Issue Soft Reset to put firmware in unknown state */ 1105 /* Issue Soft Reset to put firmware in unknown state */
1125 qla4xxx_soft_reset(ha); 1106 if (ql4xxx_lock_drvr_wait(ha) == QLA_SUCCESS)
1107 qla4xxx_soft_reset(ha);
1126 1108
1127 /* Remove timer thread, if present */ 1109 /* Remove timer thread, if present */
1128 if (ha->timer_active) 1110 if (ha->timer_active)
@@ -1714,7 +1696,7 @@ static int __init qla4xxx_module_init(void)
1714 1696
1715 /* Derive version string. */ 1697 /* Derive version string. */
1716 strcpy(qla4xxx_version_str, QLA4XXX_DRIVER_VERSION); 1698 strcpy(qla4xxx_version_str, QLA4XXX_DRIVER_VERSION);
1717 if (qla4_extended_error_logging) 1699 if (ql4xextended_error_logging)
1718 strcat(qla4xxx_version_str, "-debug"); 1700 strcat(qla4xxx_version_str, "-debug");
1719 1701
1720 qla4xxx_scsi_transport = 1702 qla4xxx_scsi_transport =
@@ -1724,13 +1706,13 @@ static int __init qla4xxx_module_init(void)
1724 goto release_srb_cache; 1706 goto release_srb_cache;
1725 } 1707 }
1726 1708
1727 printk(KERN_INFO "QLogic iSCSI HBA Driver\n");
1728 ret = pci_register_driver(&qla4xxx_pci_driver); 1709 ret = pci_register_driver(&qla4xxx_pci_driver);
1729 if (ret) 1710 if (ret)
1730 goto unregister_transport; 1711 goto unregister_transport;
1731 1712
1732 printk(KERN_INFO "QLogic iSCSI HBA Driver\n"); 1713 printk(KERN_INFO "QLogic iSCSI HBA Driver\n");
1733 return 0; 1714 return 0;
1715
1734unregister_transport: 1716unregister_transport:
1735 iscsi_unregister_transport(&qla4xxx_iscsi_transport); 1717 iscsi_unregister_transport(&qla4xxx_iscsi_transport);
1736release_srb_cache: 1718release_srb_cache:
diff --git a/drivers/scsi/qla4xxx/ql4_version.h b/drivers/scsi/qla4xxx/ql4_version.h
index b3fe7e68988e..d05048b4e88a 100644
--- a/drivers/scsi/qla4xxx/ql4_version.h
+++ b/drivers/scsi/qla4xxx/ql4_version.h
@@ -5,9 +5,4 @@
5 * See LICENSE.qla4xxx for copyright and licensing details. 5 * See LICENSE.qla4xxx for copyright and licensing details.
6 */ 6 */
7 7
8#define QLA4XXX_DRIVER_VERSION "5.00.05b9-k" 8#define QLA4XXX_DRIVER_VERSION "5.00.06-k"
9
10#define QL4_DRIVER_MAJOR_VER 5
11#define QL4_DRIVER_MINOR_VER 0
12#define QL4_DRIVER_PATCH_VER 5
13#define QL4_DRIVER_BETA_VER 9
diff --git a/drivers/scsi/qlogicfas408.c b/drivers/scsi/qlogicfas408.c
index e0725353c99c..2e7db18f5aef 100644
--- a/drivers/scsi/qlogicfas408.c
+++ b/drivers/scsi/qlogicfas408.c
@@ -209,7 +209,7 @@ static int ql_wai(struct qlogicfas408_priv *priv)
209 * caller must hold host lock 209 * caller must hold host lock
210 */ 210 */
211 211
212static void ql_icmd(Scsi_Cmnd * cmd) 212static void ql_icmd(struct scsi_cmnd *cmd)
213{ 213{
214 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd); 214 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd);
215 int qbase = priv->qbase; 215 int qbase = priv->qbase;
@@ -256,7 +256,7 @@ static void ql_icmd(Scsi_Cmnd * cmd)
256 * Process scsi command - usually after interrupt 256 * Process scsi command - usually after interrupt
257 */ 257 */
258 258
259static unsigned int ql_pcmd(Scsi_Cmnd * cmd) 259static unsigned int ql_pcmd(struct scsi_cmnd *cmd)
260{ 260{
261 unsigned int i, j; 261 unsigned int i, j;
262 unsigned long k; 262 unsigned long k;
@@ -407,7 +407,7 @@ static unsigned int ql_pcmd(Scsi_Cmnd * cmd)
407 407
408static void ql_ihandl(void *dev_id) 408static void ql_ihandl(void *dev_id)
409{ 409{
410 Scsi_Cmnd *icmd; 410 struct scsi_cmnd *icmd;
411 struct Scsi_Host *host = dev_id; 411 struct Scsi_Host *host = dev_id;
412 struct qlogicfas408_priv *priv = get_priv_by_host(host); 412 struct qlogicfas408_priv *priv = get_priv_by_host(host);
413 int qbase = priv->qbase; 413 int qbase = priv->qbase;
@@ -447,7 +447,8 @@ irqreturn_t qlogicfas408_ihandl(int irq, void *dev_id)
447 * Queued command 447 * Queued command
448 */ 448 */
449 449
450int qlogicfas408_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *)) 450int qlogicfas408_queuecommand(struct scsi_cmnd *cmd,
451 void (*done) (struct scsi_cmnd *))
451{ 452{
452 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd); 453 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd);
453 if (scmd_id(cmd) == priv->qinitid) { 454 if (scmd_id(cmd) == priv->qinitid) {
@@ -470,9 +471,8 @@ int qlogicfas408_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
470 * Return bios parameters 471 * Return bios parameters
471 */ 472 */
472 473
473int qlogicfas408_biosparam(struct scsi_device * disk, 474int qlogicfas408_biosparam(struct scsi_device *disk, struct block_device *dev,
474 struct block_device *dev, 475 sector_t capacity, int ip[])
475 sector_t capacity, int ip[])
476{ 476{
477/* This should mimic the DOS Qlogic driver's behavior exactly */ 477/* This should mimic the DOS Qlogic driver's behavior exactly */
478 ip[0] = 0x40; 478 ip[0] = 0x40;
@@ -494,7 +494,7 @@ int qlogicfas408_biosparam(struct scsi_device * disk,
494 * Abort a command in progress 494 * Abort a command in progress
495 */ 495 */
496 496
497int qlogicfas408_abort(Scsi_Cmnd * cmd) 497int qlogicfas408_abort(struct scsi_cmnd *cmd)
498{ 498{
499 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd); 499 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd);
500 priv->qabort = 1; 500 priv->qabort = 1;
@@ -508,7 +508,7 @@ int qlogicfas408_abort(Scsi_Cmnd * cmd)
508 * the PCMCIA qlogic_stub code. This wants fixing 508 * the PCMCIA qlogic_stub code. This wants fixing
509 */ 509 */
510 510
511int qlogicfas408_bus_reset(Scsi_Cmnd * cmd) 511int qlogicfas408_bus_reset(struct scsi_cmnd *cmd)
512{ 512{
513 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd); 513 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd);
514 unsigned long flags; 514 unsigned long flags;
diff --git a/drivers/scsi/qlogicfas408.h b/drivers/scsi/qlogicfas408.h
index 8fd5555c75b1..260626427a32 100644
--- a/drivers/scsi/qlogicfas408.h
+++ b/drivers/scsi/qlogicfas408.h
@@ -75,15 +75,15 @@
75/*----------------------------------------------------------------*/ 75/*----------------------------------------------------------------*/
76 76
77struct qlogicfas408_priv { 77struct qlogicfas408_priv {
78 int qbase; /* Port */ 78 int qbase; /* Port */
79 int qinitid; /* initiator ID */ 79 int qinitid; /* initiator ID */
80 int qabort; /* Flag to cause an abort */ 80 int qabort; /* Flag to cause an abort */
81 int qlirq; /* IRQ being used */ 81 int qlirq; /* IRQ being used */
82 int int_type; /* type of irq, 2 for ISA board, 0 for PCMCIA */ 82 int int_type; /* type of irq, 2 for ISA board, 0 for PCMCIA */
83 char qinfo[80]; /* description */ 83 char qinfo[80]; /* description */
84 Scsi_Cmnd *qlcmd; /* current command being processed */ 84 struct scsi_cmnd *qlcmd; /* current command being processed */
85 struct Scsi_Host *shost; /* pointer back to host */ 85 struct Scsi_Host *shost; /* pointer back to host */
86 struct qlogicfas408_priv *next; /* next private struct */ 86 struct qlogicfas408_priv *next; /* next private struct */
87}; 87};
88 88
89/* The qlogic card uses two register maps - These macros select which one */ 89/* The qlogic card uses two register maps - These macros select which one */
@@ -103,12 +103,13 @@ struct qlogicfas408_priv {
103#define get_priv_by_host(x) (struct qlogicfas408_priv *)&((x)->hostdata[0]) 103#define get_priv_by_host(x) (struct qlogicfas408_priv *)&((x)->hostdata[0])
104 104
105irqreturn_t qlogicfas408_ihandl(int irq, void *dev_id); 105irqreturn_t qlogicfas408_ihandl(int irq, void *dev_id);
106int qlogicfas408_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *)); 106int qlogicfas408_queuecommand(struct scsi_cmnd * cmd,
107 void (*done) (struct scsi_cmnd *));
107int qlogicfas408_biosparam(struct scsi_device * disk, 108int qlogicfas408_biosparam(struct scsi_device * disk,
108 struct block_device *dev, 109 struct block_device *dev,
109 sector_t capacity, int ip[]); 110 sector_t capacity, int ip[]);
110int qlogicfas408_abort(Scsi_Cmnd * cmd); 111int qlogicfas408_abort(struct scsi_cmnd * cmd);
111int qlogicfas408_bus_reset(Scsi_Cmnd * cmd); 112int qlogicfas408_bus_reset(struct scsi_cmnd * cmd);
112const char *qlogicfas408_info(struct Scsi_Host *host); 113const char *qlogicfas408_info(struct Scsi_Host *host);
113int qlogicfas408_get_chip_type(int qbase, int int_type); 114int qlogicfas408_get_chip_type(int qbase, int int_type);
114void qlogicfas408_setup(int qbase, int id, int int_type); 115void qlogicfas408_setup(int qbase, int id, int int_type);
diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c
index ed58bb489889..9b827ceec501 100644
--- a/drivers/scsi/qlogicpti.c
+++ b/drivers/scsi/qlogicpti.c
@@ -461,7 +461,7 @@ static int qlogicpti_reset_hardware(struct Scsi_Host *host)
461 461
462#define PTI_RESET_LIMIT 400 462#define PTI_RESET_LIMIT 400
463 463
464static int __init qlogicpti_load_firmware(struct qlogicpti *qpti) 464static int __devinit qlogicpti_load_firmware(struct qlogicpti *qpti)
465{ 465{
466 struct Scsi_Host *host = qpti->qhost; 466 struct Scsi_Host *host = qpti->qhost;
467 unsigned short csum = 0; 467 unsigned short csum = 0;
diff --git a/drivers/scsi/qlogicpti_asm.c b/drivers/scsi/qlogicpti_asm.c
index 1545b30681b4..19aa84f46018 100644
--- a/drivers/scsi/qlogicpti_asm.c
+++ b/drivers/scsi/qlogicpti_asm.c
@@ -1,5 +1,5 @@
1/* Version 1.31.00 ISP1000 Initiator RISC firmware */ 1/* Version 1.31.00 ISP1000 Initiator RISC firmware */
2unsigned short sbus_risc_code01[] __initdata = { 2unsigned short sbus_risc_code01[] __devinitdata = {
3 0x0078, 0x1030, 0x0000, 0x2419, 0x0000, 0x12ff, 0x2043, 0x4f50, 3 0x0078, 0x1030, 0x0000, 0x2419, 0x0000, 0x12ff, 0x2043, 0x4f50,
4 0x5952, 0x4947, 0x4854, 0x2031, 0x3939, 0x312c, 0x3139, 0x3932, 4 0x5952, 0x4947, 0x4854, 0x2031, 0x3939, 0x312c, 0x3139, 0x3932,
5 0x2c31, 0x3939, 0x332c, 0x3139, 0x3934, 0x2051, 0x4c4f, 0x4749, 5 0x2c31, 0x3939, 0x332c, 0x3139, 0x3934, 0x2051, 0x4c4f, 0x4749,
@@ -1157,4 +1157,4 @@ unsigned short sbus_risc_code01[] __initdata = {
1157 0x003c, 0x0040, 0x3415, 0x2019, 0x2626, 0x7b22, 0x7b26, 0x007c, 1157 0x003c, 0x0040, 0x3415, 0x2019, 0x2626, 0x7b22, 0x7b26, 0x007c,
1158 0x92a7 1158 0x92a7
1159}; 1159};
1160unsigned short sbus_risc_code_length01 = 0x2419; 1160unsigned short __devinitdata sbus_risc_code_length01 = 0x2419;
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 9c0f35820e3e..30ee3d72c021 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -52,7 +52,7 @@
52#include "scsi_debug.h" 52#include "scsi_debug.h"
53 53
54#define SCSI_DEBUG_VERSION "1.80" 54#define SCSI_DEBUG_VERSION "1.80"
55static const char * scsi_debug_version_date = "20060914"; 55static const char * scsi_debug_version_date = "20061018";
56 56
57/* Additional Sense Code (ASC) used */ 57/* Additional Sense Code (ASC) used */
58#define NO_ADDITIONAL_SENSE 0x0 58#define NO_ADDITIONAL_SENSE 0x0
@@ -254,6 +254,8 @@ static int resp_requests(struct scsi_cmnd * SCpnt,
254 struct sdebug_dev_info * devip); 254 struct sdebug_dev_info * devip);
255static int resp_start_stop(struct scsi_cmnd * scp, 255static int resp_start_stop(struct scsi_cmnd * scp,
256 struct sdebug_dev_info * devip); 256 struct sdebug_dev_info * devip);
257static int resp_report_tgtpgs(struct scsi_cmnd * scp,
258 struct sdebug_dev_info * devip);
257static int resp_readcap(struct scsi_cmnd * SCpnt, 259static int resp_readcap(struct scsi_cmnd * SCpnt,
258 struct sdebug_dev_info * devip); 260 struct sdebug_dev_info * devip);
259static int resp_readcap16(struct scsi_cmnd * SCpnt, 261static int resp_readcap16(struct scsi_cmnd * SCpnt,
@@ -287,9 +289,9 @@ static void __init sdebug_build_parts(unsigned char * ramp);
287static void __init init_all_queued(void); 289static void __init init_all_queued(void);
288static void stop_all_queued(void); 290static void stop_all_queued(void);
289static int stop_queued_cmnd(struct scsi_cmnd * cmnd); 291static int stop_queued_cmnd(struct scsi_cmnd * cmnd);
290static int inquiry_evpd_83(unsigned char * arr, int target_dev_id, 292static int inquiry_evpd_83(unsigned char * arr, int port_group_id,
291 int dev_id_num, const char * dev_id_str, 293 int target_dev_id, int dev_id_num,
292 int dev_id_str_len); 294 const char * dev_id_str, int dev_id_str_len);
293static int inquiry_evpd_88(unsigned char * arr, int target_dev_id); 295static int inquiry_evpd_88(unsigned char * arr, int target_dev_id);
294static int do_create_driverfs_files(void); 296static int do_create_driverfs_files(void);
295static void do_remove_driverfs_files(void); 297static void do_remove_driverfs_files(void);
@@ -422,6 +424,15 @@ int scsi_debug_queuecommand(struct scsi_cmnd * SCpnt, done_funct_t done)
422 } 424 }
423 errsts = resp_readcap16(SCpnt, devip); 425 errsts = resp_readcap16(SCpnt, devip);
424 break; 426 break;
427 case MAINTENANCE_IN:
428 if (MI_REPORT_TARGET_PGS != cmd[1]) {
429 mk_sense_buffer(devip, ILLEGAL_REQUEST,
430 INVALID_OPCODE, 0);
431 errsts = check_condition_result;
432 break;
433 }
434 errsts = resp_report_tgtpgs(SCpnt, devip);
435 break;
425 case READ_16: 436 case READ_16:
426 case READ_12: 437 case READ_12:
427 case READ_10: 438 case READ_10:
@@ -665,8 +676,9 @@ static const char * inq_vendor_id = "Linux ";
665static const char * inq_product_id = "scsi_debug "; 676static const char * inq_product_id = "scsi_debug ";
666static const char * inq_product_rev = "0004"; 677static const char * inq_product_rev = "0004";
667 678
668static int inquiry_evpd_83(unsigned char * arr, int target_dev_id, 679static int inquiry_evpd_83(unsigned char * arr, int port_group_id,
669 int dev_id_num, const char * dev_id_str, 680 int target_dev_id, int dev_id_num,
681 const char * dev_id_str,
670 int dev_id_str_len) 682 int dev_id_str_len)
671{ 683{
672 int num, port_a; 684 int num, port_a;
@@ -720,6 +732,15 @@ static int inquiry_evpd_83(unsigned char * arr, int target_dev_id,
720 arr[num++] = (port_a >> 16) & 0xff; 732 arr[num++] = (port_a >> 16) & 0xff;
721 arr[num++] = (port_a >> 8) & 0xff; 733 arr[num++] = (port_a >> 8) & 0xff;
722 arr[num++] = port_a & 0xff; 734 arr[num++] = port_a & 0xff;
735 /* NAA-5, Target port group identifier */
736 arr[num++] = 0x61; /* proto=sas, binary */
737 arr[num++] = 0x95; /* piv=1, target port group id */
738 arr[num++] = 0x0;
739 arr[num++] = 0x4;
740 arr[num++] = 0;
741 arr[num++] = 0;
742 arr[num++] = (port_group_id >> 8) & 0xff;
743 arr[num++] = port_group_id & 0xff;
723 /* NAA-5, Target device identifier */ 744 /* NAA-5, Target device identifier */
724 arr[num++] = 0x61; /* proto=sas, binary */ 745 arr[num++] = 0x61; /* proto=sas, binary */
725 arr[num++] = 0xa3; /* piv=1, target device, naa */ 746 arr[num++] = 0xa3; /* piv=1, target device, naa */
@@ -928,12 +949,12 @@ static int resp_inquiry(struct scsi_cmnd * scp, int target,
928 struct sdebug_dev_info * devip) 949 struct sdebug_dev_info * devip)
929{ 950{
930 unsigned char pq_pdt; 951 unsigned char pq_pdt;
931 unsigned char arr[SDEBUG_MAX_INQ_ARR_SZ]; 952 unsigned char * arr;
932 unsigned char *cmd = (unsigned char *)scp->cmnd; 953 unsigned char *cmd = (unsigned char *)scp->cmnd;
933 int alloc_len, n; 954 int alloc_len, n, ret;
934 955
935 alloc_len = (cmd[3] << 8) + cmd[4]; 956 alloc_len = (cmd[3] << 8) + cmd[4];
936 memset(arr, 0, SDEBUG_MAX_INQ_ARR_SZ); 957 arr = kzalloc(SDEBUG_MAX_INQ_ARR_SZ, GFP_KERNEL);
937 if (devip->wlun) 958 if (devip->wlun)
938 pq_pdt = 0x1e; /* present, wlun */ 959 pq_pdt = 0x1e; /* present, wlun */
939 else if (scsi_debug_no_lun_0 && (0 == devip->lun)) 960 else if (scsi_debug_no_lun_0 && (0 == devip->lun))
@@ -944,12 +965,15 @@ static int resp_inquiry(struct scsi_cmnd * scp, int target,
944 if (0x2 & cmd[1]) { /* CMDDT bit set */ 965 if (0x2 & cmd[1]) { /* CMDDT bit set */
945 mk_sense_buffer(devip, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 966 mk_sense_buffer(devip, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB,
946 0); 967 0);
968 kfree(arr);
947 return check_condition_result; 969 return check_condition_result;
948 } else if (0x1 & cmd[1]) { /* EVPD bit set */ 970 } else if (0x1 & cmd[1]) { /* EVPD bit set */
949 int lu_id_num, target_dev_id, len; 971 int lu_id_num, port_group_id, target_dev_id, len;
950 char lu_id_str[6]; 972 char lu_id_str[6];
951 int host_no = devip->sdbg_host->shost->host_no; 973 int host_no = devip->sdbg_host->shost->host_no;
952 974
975 port_group_id = (((host_no + 1) & 0x7f) << 8) +
976 (devip->channel & 0x7f);
953 if (0 == scsi_debug_vpd_use_hostno) 977 if (0 == scsi_debug_vpd_use_hostno)
954 host_no = 0; 978 host_no = 0;
955 lu_id_num = devip->wlun ? -1 : (((host_no + 1) * 2000) + 979 lu_id_num = devip->wlun ? -1 : (((host_no + 1) * 2000) +
@@ -977,8 +1001,9 @@ static int resp_inquiry(struct scsi_cmnd * scp, int target,
977 memcpy(&arr[4], lu_id_str, len); 1001 memcpy(&arr[4], lu_id_str, len);
978 } else if (0x83 == cmd[2]) { /* device identification */ 1002 } else if (0x83 == cmd[2]) { /* device identification */
979 arr[1] = cmd[2]; /*sanity */ 1003 arr[1] = cmd[2]; /*sanity */
980 arr[3] = inquiry_evpd_83(&arr[4], target_dev_id, 1004 arr[3] = inquiry_evpd_83(&arr[4], port_group_id,
981 lu_id_num, lu_id_str, len); 1005 target_dev_id, lu_id_num,
1006 lu_id_str, len);
982 } else if (0x84 == cmd[2]) { /* Software interface ident. */ 1007 } else if (0x84 == cmd[2]) { /* Software interface ident. */
983 arr[1] = cmd[2]; /*sanity */ 1008 arr[1] = cmd[2]; /*sanity */
984 arr[3] = inquiry_evpd_84(&arr[4]); 1009 arr[3] = inquiry_evpd_84(&arr[4]);
@@ -1012,17 +1037,22 @@ static int resp_inquiry(struct scsi_cmnd * scp, int target,
1012 /* Illegal request, invalid field in cdb */ 1037 /* Illegal request, invalid field in cdb */
1013 mk_sense_buffer(devip, ILLEGAL_REQUEST, 1038 mk_sense_buffer(devip, ILLEGAL_REQUEST,
1014 INVALID_FIELD_IN_CDB, 0); 1039 INVALID_FIELD_IN_CDB, 0);
1040 kfree(arr);
1015 return check_condition_result; 1041 return check_condition_result;
1016 } 1042 }
1017 len = min(((arr[2] << 8) + arr[3]) + 4, alloc_len); 1043 len = min(((arr[2] << 8) + arr[3]) + 4, alloc_len);
1018 return fill_from_dev_buffer(scp, arr, 1044 ret = fill_from_dev_buffer(scp, arr,
1019 min(len, SDEBUG_MAX_INQ_ARR_SZ)); 1045 min(len, SDEBUG_MAX_INQ_ARR_SZ));
1046 kfree(arr);
1047 return ret;
1020 } 1048 }
1021 /* drops through here for a standard inquiry */ 1049 /* drops through here for a standard inquiry */
1022 arr[1] = DEV_REMOVEABLE(target) ? 0x80 : 0; /* Removable disk */ 1050 arr[1] = DEV_REMOVEABLE(target) ? 0x80 : 0; /* Removable disk */
1023 arr[2] = scsi_debug_scsi_level; 1051 arr[2] = scsi_debug_scsi_level;
1024 arr[3] = 2; /* response_data_format==2 */ 1052 arr[3] = 2; /* response_data_format==2 */
1025 arr[4] = SDEBUG_LONG_INQ_SZ - 5; 1053 arr[4] = SDEBUG_LONG_INQ_SZ - 5;
1054 if (0 == scsi_debug_vpd_use_hostno)
1055 arr[5] = 0x10; /* claim: implicit TGPS */
1026 arr[6] = 0x10; /* claim: MultiP */ 1056 arr[6] = 0x10; /* claim: MultiP */
1027 /* arr[6] |= 0x40; ... claim: EncServ (enclosure services) */ 1057 /* arr[6] |= 0x40; ... claim: EncServ (enclosure services) */
1028 arr[7] = 0xa; /* claim: LINKED + CMDQUE */ 1058 arr[7] = 0xa; /* claim: LINKED + CMDQUE */
@@ -1039,8 +1069,10 @@ static int resp_inquiry(struct scsi_cmnd * scp, int target,
1039 arr[n++] = 0x3; arr[n++] = 0x60; /* SSC-2 no version */ 1069 arr[n++] = 0x3; arr[n++] = 0x60; /* SSC-2 no version */
1040 } 1070 }
1041 arr[n++] = 0xc; arr[n++] = 0xf; /* SAS-1.1 rev 10 */ 1071 arr[n++] = 0xc; arr[n++] = 0xf; /* SAS-1.1 rev 10 */
1042 return fill_from_dev_buffer(scp, arr, 1072 ret = fill_from_dev_buffer(scp, arr,
1043 min(alloc_len, SDEBUG_LONG_INQ_SZ)); 1073 min(alloc_len, SDEBUG_LONG_INQ_SZ));
1074 kfree(arr);
1075 return ret;
1044} 1076}
1045 1077
1046static int resp_requests(struct scsi_cmnd * scp, 1078static int resp_requests(struct scsi_cmnd * scp,
@@ -1171,6 +1203,87 @@ static int resp_readcap16(struct scsi_cmnd * scp,
1171 min(alloc_len, SDEBUG_READCAP16_ARR_SZ)); 1203 min(alloc_len, SDEBUG_READCAP16_ARR_SZ));
1172} 1204}
1173 1205
1206#define SDEBUG_MAX_TGTPGS_ARR_SZ 1412
1207
1208static int resp_report_tgtpgs(struct scsi_cmnd * scp,
1209 struct sdebug_dev_info * devip)
1210{
1211 unsigned char *cmd = (unsigned char *)scp->cmnd;
1212 unsigned char * arr;
1213 int host_no = devip->sdbg_host->shost->host_no;
1214 int n, ret, alen, rlen;
1215 int port_group_a, port_group_b, port_a, port_b;
1216
1217 alen = ((cmd[6] << 24) + (cmd[7] << 16) + (cmd[8] << 8)
1218 + cmd[9]);
1219
1220 arr = kzalloc(SDEBUG_MAX_TGTPGS_ARR_SZ, GFP_KERNEL);
1221 /*
1222 * EVPD page 0x88 states we have two ports, one
1223 * real and a fake port with no device connected.
1224 * So we create two port groups with one port each
1225 * and set the group with port B to unavailable.
1226 */
1227 port_a = 0x1; /* relative port A */
1228 port_b = 0x2; /* relative port B */
1229 port_group_a = (((host_no + 1) & 0x7f) << 8) +
1230 (devip->channel & 0x7f);
1231 port_group_b = (((host_no + 1) & 0x7f) << 8) +
1232 (devip->channel & 0x7f) + 0x80;
1233
1234 /*
1235 * The asymmetric access state is cycled according to the host_id.
1236 */
1237 n = 4;
1238 if (0 == scsi_debug_vpd_use_hostno) {
1239 arr[n++] = host_no % 3; /* Asymm access state */
1240 arr[n++] = 0x0F; /* claim: all states are supported */
1241 } else {
1242 arr[n++] = 0x0; /* Active/Optimized path */
1243 arr[n++] = 0x01; /* claim: only support active/optimized paths */
1244 }
1245 arr[n++] = (port_group_a >> 8) & 0xff;
1246 arr[n++] = port_group_a & 0xff;
1247 arr[n++] = 0; /* Reserved */
1248 arr[n++] = 0; /* Status code */
1249 arr[n++] = 0; /* Vendor unique */
1250 arr[n++] = 0x1; /* One port per group */
1251 arr[n++] = 0; /* Reserved */
1252 arr[n++] = 0; /* Reserved */
1253 arr[n++] = (port_a >> 8) & 0xff;
1254 arr[n++] = port_a & 0xff;
1255 arr[n++] = 3; /* Port unavailable */
1256 arr[n++] = 0x08; /* claim: only unavailalbe paths are supported */
1257 arr[n++] = (port_group_b >> 8) & 0xff;
1258 arr[n++] = port_group_b & 0xff;
1259 arr[n++] = 0; /* Reserved */
1260 arr[n++] = 0; /* Status code */
1261 arr[n++] = 0; /* Vendor unique */
1262 arr[n++] = 0x1; /* One port per group */
1263 arr[n++] = 0; /* Reserved */
1264 arr[n++] = 0; /* Reserved */
1265 arr[n++] = (port_b >> 8) & 0xff;
1266 arr[n++] = port_b & 0xff;
1267
1268 rlen = n - 4;
1269 arr[0] = (rlen >> 24) & 0xff;
1270 arr[1] = (rlen >> 16) & 0xff;
1271 arr[2] = (rlen >> 8) & 0xff;
1272 arr[3] = rlen & 0xff;
1273
1274 /*
1275 * Return the smallest value of either
1276 * - The allocated length
1277 * - The constructed command length
1278 * - The maximum array size
1279 */
1280 rlen = min(alen,n);
1281 ret = fill_from_dev_buffer(scp, arr,
1282 min(rlen, SDEBUG_MAX_TGTPGS_ARR_SZ));
1283 kfree(arr);
1284 return ret;
1285}
1286
1174/* <<Following mode page info copied from ST318451LW>> */ 1287/* <<Following mode page info copied from ST318451LW>> */
1175 1288
1176static int resp_err_recov_pg(unsigned char * p, int pcontrol, int target) 1289static int resp_err_recov_pg(unsigned char * p, int pcontrol, int target)
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index ee35a62bb7a2..2f12f9f12fcb 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -410,6 +410,7 @@ int scsi_execute_async(struct scsi_device *sdev, const unsigned char *cmd,
410 goto free_req; 410 goto free_req;
411 411
412 req->cmd_len = cmd_len; 412 req->cmd_len = cmd_len;
413 memset(req->cmd, 0, BLK_MAX_CDB); /* ATAPI hates garbage after CDB */
413 memcpy(req->cmd, cmd, req->cmd_len); 414 memcpy(req->cmd, cmd, req->cmd_len);
414 req->sense = sioc->sense; 415 req->sense = sioc->sense;
415 req->sense_len = 0; 416 req->sense_len = 0;
@@ -1119,7 +1120,7 @@ static int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req)
1119 req->buffer = NULL; 1120 req->buffer = NULL;
1120 } 1121 }
1121 1122
1122 BUG_ON(sizeof(req->cmd) > sizeof(cmd->cmnd)); 1123 BUILD_BUG_ON(sizeof(req->cmd) > sizeof(cmd->cmnd));
1123 memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd)); 1124 memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd));
1124 cmd->cmd_len = req->cmd_len; 1125 cmd->cmd_len = req->cmd_len;
1125 if (!req->data_len) 1126 if (!req->data_len)
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 148e24cc3222..aa1b1e0e9d22 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -700,12 +700,22 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
700 * scanning run at their own risk, or supply a user level program 700 * scanning run at their own risk, or supply a user level program
701 * that can correctly scan. 701 * that can correctly scan.
702 */ 702 */
703 sdev->inquiry = kmalloc(sdev->inquiry_len, GFP_ATOMIC); 703
704 if (sdev->inquiry == NULL) { 704 /*
705 * Copy at least 36 bytes of INQUIRY data, so that we don't
706 * dereference unallocated memory when accessing the Vendor,
707 * Product, and Revision strings. Badly behaved devices may set
708 * the INQUIRY Additional Length byte to a small value, indicating
709 * these strings are invalid, but often they contain plausible data
710 * nonetheless. It doesn't matter if the device sent < 36 bytes
711 * total, since scsi_probe_lun() initializes inq_result with 0s.
712 */
713 sdev->inquiry = kmemdup(inq_result,
714 max_t(size_t, sdev->inquiry_len, 36),
715 GFP_ATOMIC);
716 if (sdev->inquiry == NULL)
705 return SCSI_SCAN_NO_RESPONSE; 717 return SCSI_SCAN_NO_RESPONSE;
706 }
707 718
708 memcpy(sdev->inquiry, inq_result, sdev->inquiry_len);
709 sdev->vendor = (char *) (sdev->inquiry + 8); 719 sdev->vendor = (char *) (sdev->inquiry + 8);
710 sdev->model = (char *) (sdev->inquiry + 16); 720 sdev->model = (char *) (sdev->inquiry + 16);
711 sdev->rev = (char *) (sdev->inquiry + 32); 721 sdev->rev = (char *) (sdev->inquiry + 32);
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index e7fe565b96de..e1a91665d1c2 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -192,6 +192,7 @@ static CLASS_DEVICE_ATTR(state, S_IRUGO | S_IWUSR, show_shost_state, store_shost
192shost_rd_attr(unique_id, "%u\n"); 192shost_rd_attr(unique_id, "%u\n");
193shost_rd_attr(host_busy, "%hu\n"); 193shost_rd_attr(host_busy, "%hu\n");
194shost_rd_attr(cmd_per_lun, "%hd\n"); 194shost_rd_attr(cmd_per_lun, "%hd\n");
195shost_rd_attr(can_queue, "%hd\n");
195shost_rd_attr(sg_tablesize, "%hu\n"); 196shost_rd_attr(sg_tablesize, "%hu\n");
196shost_rd_attr(unchecked_isa_dma, "%d\n"); 197shost_rd_attr(unchecked_isa_dma, "%d\n");
197shost_rd_attr2(proc_name, hostt->proc_name, "%s\n"); 198shost_rd_attr2(proc_name, hostt->proc_name, "%s\n");
@@ -200,6 +201,7 @@ static struct class_device_attribute *scsi_sysfs_shost_attrs[] = {
200 &class_device_attr_unique_id, 201 &class_device_attr_unique_id,
201 &class_device_attr_host_busy, 202 &class_device_attr_host_busy,
202 &class_device_attr_cmd_per_lun, 203 &class_device_attr_cmd_per_lun,
204 &class_device_attr_can_queue,
203 &class_device_attr_sg_tablesize, 205 &class_device_attr_sg_tablesize,
204 &class_device_attr_unchecked_isa_dma, 206 &class_device_attr_unchecked_isa_dma,
205 &class_device_attr_proc_name, 207 &class_device_attr_proc_name,
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 7b0019cccce3..9b25124a989e 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -21,7 +21,6 @@
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 */ 22 */
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/mempool.h>
25#include <linux/mutex.h> 24#include <linux/mutex.h>
26#include <net/tcp.h> 25#include <net/tcp.h>
27#include <scsi/scsi.h> 26#include <scsi/scsi.h>
@@ -34,7 +33,7 @@
34#define ISCSI_SESSION_ATTRS 11 33#define ISCSI_SESSION_ATTRS 11
35#define ISCSI_CONN_ATTRS 11 34#define ISCSI_CONN_ATTRS 11
36#define ISCSI_HOST_ATTRS 0 35#define ISCSI_HOST_ATTRS 0
37#define ISCSI_TRANSPORT_VERSION "2.0-685" 36#define ISCSI_TRANSPORT_VERSION "2.0-724"
38 37
39struct iscsi_internal { 38struct iscsi_internal {
40 int daemon_pid; 39 int daemon_pid;
@@ -149,30 +148,6 @@ static DECLARE_TRANSPORT_CLASS(iscsi_connection_class,
149static struct sock *nls; 148static struct sock *nls;
150static DEFINE_MUTEX(rx_queue_mutex); 149static DEFINE_MUTEX(rx_queue_mutex);
151 150
152struct mempool_zone {
153 mempool_t *pool;
154 atomic_t allocated;
155 int size;
156 int hiwat;
157 struct list_head freequeue;
158 spinlock_t freelock;
159};
160
161static struct mempool_zone *z_reply;
162
163/*
164 * Z_MAX_* - actual mempool size allocated at the mempool_zone_init() time
165 * Z_HIWAT_* - zone's high watermark when if_error bit will be set to -ENOMEM
166 * so daemon will notice OOM on NETLINK tranposrt level and will
167 * be able to predict or change operational behavior
168 */
169#define Z_MAX_REPLY 8
170#define Z_HIWAT_REPLY 6
171#define Z_MAX_PDU 8
172#define Z_HIWAT_PDU 6
173#define Z_MAX_ERROR 16
174#define Z_HIWAT_ERROR 12
175
176static LIST_HEAD(sesslist); 151static LIST_HEAD(sesslist);
177static DEFINE_SPINLOCK(sesslock); 152static DEFINE_SPINLOCK(sesslock);
178static LIST_HEAD(connlist); 153static LIST_HEAD(connlist);
@@ -414,59 +389,11 @@ int iscsi_destroy_session(struct iscsi_cls_session *session)
414} 389}
415EXPORT_SYMBOL_GPL(iscsi_destroy_session); 390EXPORT_SYMBOL_GPL(iscsi_destroy_session);
416 391
417static void mempool_zone_destroy(struct mempool_zone *zp)
418{
419 mempool_destroy(zp->pool);
420 kfree(zp);
421}
422
423static void*
424mempool_zone_alloc_skb(gfp_t gfp_mask, void *pool_data)
425{
426 struct mempool_zone *zone = pool_data;
427
428 return alloc_skb(zone->size, gfp_mask);
429}
430
431static void
432mempool_zone_free_skb(void *element, void *pool_data)
433{
434 kfree_skb(element);
435}
436
437static struct mempool_zone *
438mempool_zone_init(unsigned max, unsigned size, unsigned hiwat)
439{
440 struct mempool_zone *zp;
441
442 zp = kzalloc(sizeof(*zp), GFP_KERNEL);
443 if (!zp)
444 return NULL;
445
446 zp->size = size;
447 zp->hiwat = hiwat;
448 INIT_LIST_HEAD(&zp->freequeue);
449 spin_lock_init(&zp->freelock);
450 atomic_set(&zp->allocated, 0);
451
452 zp->pool = mempool_create(max, mempool_zone_alloc_skb,
453 mempool_zone_free_skb, zp);
454 if (!zp->pool) {
455 kfree(zp);
456 return NULL;
457 }
458
459 return zp;
460}
461
462static void iscsi_conn_release(struct device *dev) 392static void iscsi_conn_release(struct device *dev)
463{ 393{
464 struct iscsi_cls_conn *conn = iscsi_dev_to_conn(dev); 394 struct iscsi_cls_conn *conn = iscsi_dev_to_conn(dev);
465 struct device *parent = conn->dev.parent; 395 struct device *parent = conn->dev.parent;
466 396
467 mempool_zone_destroy(conn->z_pdu);
468 mempool_zone_destroy(conn->z_error);
469
470 kfree(conn); 397 kfree(conn);
471 put_device(parent); 398 put_device(parent);
472} 399}
@@ -476,31 +403,6 @@ static int iscsi_is_conn_dev(const struct device *dev)
476 return dev->release == iscsi_conn_release; 403 return dev->release == iscsi_conn_release;
477} 404}
478 405
479static int iscsi_create_event_pools(struct iscsi_cls_conn *conn)
480{
481 conn->z_pdu = mempool_zone_init(Z_MAX_PDU,
482 NLMSG_SPACE(sizeof(struct iscsi_uevent) +
483 sizeof(struct iscsi_hdr) +
484 DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH),
485 Z_HIWAT_PDU);
486 if (!conn->z_pdu) {
487 dev_printk(KERN_ERR, &conn->dev, "iscsi: can not allocate "
488 "pdu zone for new conn\n");
489 return -ENOMEM;
490 }
491
492 conn->z_error = mempool_zone_init(Z_MAX_ERROR,
493 NLMSG_SPACE(sizeof(struct iscsi_uevent)),
494 Z_HIWAT_ERROR);
495 if (!conn->z_error) {
496 dev_printk(KERN_ERR, &conn->dev, "iscsi: can not allocate "
497 "error zone for new conn\n");
498 mempool_zone_destroy(conn->z_pdu);
499 return -ENOMEM;
500 }
501 return 0;
502}
503
504/** 406/**
505 * iscsi_create_conn - create iscsi class connection 407 * iscsi_create_conn - create iscsi class connection
506 * @session: iscsi cls session 408 * @session: iscsi cls session
@@ -533,12 +435,9 @@ iscsi_create_conn(struct iscsi_cls_session *session, uint32_t cid)
533 conn->transport = transport; 435 conn->transport = transport;
534 conn->cid = cid; 436 conn->cid = cid;
535 437
536 if (iscsi_create_event_pools(conn))
537 goto free_conn;
538
539 /* this is released in the dev's release function */ 438 /* this is released in the dev's release function */
540 if (!get_device(&session->dev)) 439 if (!get_device(&session->dev))
541 goto free_conn_pools; 440 goto free_conn;
542 441
543 snprintf(conn->dev.bus_id, BUS_ID_SIZE, "connection%d:%u", 442 snprintf(conn->dev.bus_id, BUS_ID_SIZE, "connection%d:%u",
544 session->sid, cid); 443 session->sid, cid);
@@ -555,8 +454,6 @@ iscsi_create_conn(struct iscsi_cls_session *session, uint32_t cid)
555 454
556release_parent_ref: 455release_parent_ref:
557 put_device(&session->dev); 456 put_device(&session->dev);
558free_conn_pools:
559
560free_conn: 457free_conn:
561 kfree(conn); 458 kfree(conn);
562 return NULL; 459 return NULL;
@@ -599,81 +496,31 @@ iscsi_if_transport_lookup(struct iscsi_transport *tt)
599 return NULL; 496 return NULL;
600} 497}
601 498
602static inline struct list_head *skb_to_lh(struct sk_buff *skb)
603{
604 return (struct list_head *)&skb->cb;
605}
606
607static void
608mempool_zone_complete(struct mempool_zone *zone)
609{
610 unsigned long flags;
611 struct list_head *lh, *n;
612
613 spin_lock_irqsave(&zone->freelock, flags);
614 list_for_each_safe(lh, n, &zone->freequeue) {
615 struct sk_buff *skb = (struct sk_buff *)((char *)lh -
616 offsetof(struct sk_buff, cb));
617 if (!skb_shared(skb)) {
618 list_del(skb_to_lh(skb));
619 mempool_free(skb, zone->pool);
620 atomic_dec(&zone->allocated);
621 }
622 }
623 spin_unlock_irqrestore(&zone->freelock, flags);
624}
625
626static struct sk_buff*
627mempool_zone_get_skb(struct mempool_zone *zone)
628{
629 struct sk_buff *skb;
630
631 skb = mempool_alloc(zone->pool, GFP_ATOMIC);
632 if (skb)
633 atomic_inc(&zone->allocated);
634 return skb;
635}
636
637static int 499static int
638iscsi_broadcast_skb(struct mempool_zone *zone, struct sk_buff *skb, gfp_t gfp) 500iscsi_broadcast_skb(struct sk_buff *skb, gfp_t gfp)
639{ 501{
640 unsigned long flags;
641 int rc; 502 int rc;
642 503
643 skb_get(skb);
644 rc = netlink_broadcast(nls, skb, 0, 1, gfp); 504 rc = netlink_broadcast(nls, skb, 0, 1, gfp);
645 if (rc < 0) { 505 if (rc < 0) {
646 mempool_free(skb, zone->pool);
647 printk(KERN_ERR "iscsi: can not broadcast skb (%d)\n", rc); 506 printk(KERN_ERR "iscsi: can not broadcast skb (%d)\n", rc);
648 return rc; 507 return rc;
649 } 508 }
650 509
651 spin_lock_irqsave(&zone->freelock, flags);
652 INIT_LIST_HEAD(skb_to_lh(skb));
653 list_add(skb_to_lh(skb), &zone->freequeue);
654 spin_unlock_irqrestore(&zone->freelock, flags);
655 return 0; 510 return 0;
656} 511}
657 512
658static int 513static int
659iscsi_unicast_skb(struct mempool_zone *zone, struct sk_buff *skb, int pid) 514iscsi_unicast_skb(struct sk_buff *skb, int pid)
660{ 515{
661 unsigned long flags;
662 int rc; 516 int rc;
663 517
664 skb_get(skb);
665 rc = netlink_unicast(nls, skb, pid, MSG_DONTWAIT); 518 rc = netlink_unicast(nls, skb, pid, MSG_DONTWAIT);
666 if (rc < 0) { 519 if (rc < 0) {
667 mempool_free(skb, zone->pool);
668 printk(KERN_ERR "iscsi: can not unicast skb (%d)\n", rc); 520 printk(KERN_ERR "iscsi: can not unicast skb (%d)\n", rc);
669 return rc; 521 return rc;
670 } 522 }
671 523
672 spin_lock_irqsave(&zone->freelock, flags);
673 INIT_LIST_HEAD(skb_to_lh(skb));
674 list_add(skb_to_lh(skb), &zone->freequeue);
675 spin_unlock_irqrestore(&zone->freelock, flags);
676
677 return 0; 524 return 0;
678} 525}
679 526
@@ -692,9 +539,7 @@ int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
692 if (!priv) 539 if (!priv)
693 return -EINVAL; 540 return -EINVAL;
694 541
695 mempool_zone_complete(conn->z_pdu); 542 skb = alloc_skb(len, GFP_ATOMIC);
696
697 skb = mempool_zone_get_skb(conn->z_pdu);
698 if (!skb) { 543 if (!skb) {
699 iscsi_conn_error(conn, ISCSI_ERR_CONN_FAILED); 544 iscsi_conn_error(conn, ISCSI_ERR_CONN_FAILED);
700 dev_printk(KERN_ERR, &conn->dev, "iscsi: can not deliver " 545 dev_printk(KERN_ERR, &conn->dev, "iscsi: can not deliver "
@@ -707,15 +552,13 @@ int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
707 memset(ev, 0, sizeof(*ev)); 552 memset(ev, 0, sizeof(*ev));
708 ev->transport_handle = iscsi_handle(conn->transport); 553 ev->transport_handle = iscsi_handle(conn->transport);
709 ev->type = ISCSI_KEVENT_RECV_PDU; 554 ev->type = ISCSI_KEVENT_RECV_PDU;
710 if (atomic_read(&conn->z_pdu->allocated) >= conn->z_pdu->hiwat)
711 ev->iferror = -ENOMEM;
712 ev->r.recv_req.cid = conn->cid; 555 ev->r.recv_req.cid = conn->cid;
713 ev->r.recv_req.sid = iscsi_conn_get_sid(conn); 556 ev->r.recv_req.sid = iscsi_conn_get_sid(conn);
714 pdu = (char*)ev + sizeof(*ev); 557 pdu = (char*)ev + sizeof(*ev);
715 memcpy(pdu, hdr, sizeof(struct iscsi_hdr)); 558 memcpy(pdu, hdr, sizeof(struct iscsi_hdr));
716 memcpy(pdu + sizeof(struct iscsi_hdr), data, data_size); 559 memcpy(pdu + sizeof(struct iscsi_hdr), data, data_size);
717 560
718 return iscsi_unicast_skb(conn->z_pdu, skb, priv->daemon_pid); 561 return iscsi_unicast_skb(skb, priv->daemon_pid);
719} 562}
720EXPORT_SYMBOL_GPL(iscsi_recv_pdu); 563EXPORT_SYMBOL_GPL(iscsi_recv_pdu);
721 564
@@ -731,9 +574,7 @@ void iscsi_conn_error(struct iscsi_cls_conn *conn, enum iscsi_err error)
731 if (!priv) 574 if (!priv)
732 return; 575 return;
733 576
734 mempool_zone_complete(conn->z_error); 577 skb = alloc_skb(len, GFP_ATOMIC);
735
736 skb = mempool_zone_get_skb(conn->z_error);
737 if (!skb) { 578 if (!skb) {
738 dev_printk(KERN_ERR, &conn->dev, "iscsi: gracefully ignored " 579 dev_printk(KERN_ERR, &conn->dev, "iscsi: gracefully ignored "
739 "conn error (%d)\n", error); 580 "conn error (%d)\n", error);
@@ -744,13 +585,11 @@ void iscsi_conn_error(struct iscsi_cls_conn *conn, enum iscsi_err error)
744 ev = NLMSG_DATA(nlh); 585 ev = NLMSG_DATA(nlh);
745 ev->transport_handle = iscsi_handle(conn->transport); 586 ev->transport_handle = iscsi_handle(conn->transport);
746 ev->type = ISCSI_KEVENT_CONN_ERROR; 587 ev->type = ISCSI_KEVENT_CONN_ERROR;
747 if (atomic_read(&conn->z_error->allocated) >= conn->z_error->hiwat)
748 ev->iferror = -ENOMEM;
749 ev->r.connerror.error = error; 588 ev->r.connerror.error = error;
750 ev->r.connerror.cid = conn->cid; 589 ev->r.connerror.cid = conn->cid;
751 ev->r.connerror.sid = iscsi_conn_get_sid(conn); 590 ev->r.connerror.sid = iscsi_conn_get_sid(conn);
752 591
753 iscsi_broadcast_skb(conn->z_error, skb, GFP_ATOMIC); 592 iscsi_broadcast_skb(skb, GFP_ATOMIC);
754 593
755 dev_printk(KERN_INFO, &conn->dev, "iscsi: detected conn error (%d)\n", 594 dev_printk(KERN_INFO, &conn->dev, "iscsi: detected conn error (%d)\n",
756 error); 595 error);
@@ -767,9 +606,7 @@ iscsi_if_send_reply(int pid, int seq, int type, int done, int multi,
767 int flags = multi ? NLM_F_MULTI : 0; 606 int flags = multi ? NLM_F_MULTI : 0;
768 int t = done ? NLMSG_DONE : type; 607 int t = done ? NLMSG_DONE : type;
769 608
770 mempool_zone_complete(z_reply); 609 skb = alloc_skb(len, GFP_ATOMIC);
771
772 skb = mempool_zone_get_skb(z_reply);
773 /* 610 /*
774 * FIXME: 611 * FIXME:
775 * user is supposed to react on iferror == -ENOMEM; 612 * user is supposed to react on iferror == -ENOMEM;
@@ -780,7 +617,7 @@ iscsi_if_send_reply(int pid, int seq, int type, int done, int multi,
780 nlh = __nlmsg_put(skb, pid, seq, t, (len - sizeof(*nlh)), 0); 617 nlh = __nlmsg_put(skb, pid, seq, t, (len - sizeof(*nlh)), 0);
781 nlh->nlmsg_flags = flags; 618 nlh->nlmsg_flags = flags;
782 memcpy(NLMSG_DATA(nlh), payload, size); 619 memcpy(NLMSG_DATA(nlh), payload, size);
783 return iscsi_unicast_skb(z_reply, skb, pid); 620 return iscsi_unicast_skb(skb, pid);
784} 621}
785 622
786static int 623static int
@@ -810,9 +647,7 @@ iscsi_if_get_stats(struct iscsi_transport *transport, struct nlmsghdr *nlh)
810 do { 647 do {
811 int actual_size; 648 int actual_size;
812 649
813 mempool_zone_complete(conn->z_pdu); 650 skbstat = alloc_skb(len, GFP_ATOMIC);
814
815 skbstat = mempool_zone_get_skb(conn->z_pdu);
816 if (!skbstat) { 651 if (!skbstat) {
817 dev_printk(KERN_ERR, &conn->dev, "iscsi: can not " 652 dev_printk(KERN_ERR, &conn->dev, "iscsi: can not "
818 "deliver stats: OOM\n"); 653 "deliver stats: OOM\n");
@@ -825,8 +660,6 @@ iscsi_if_get_stats(struct iscsi_transport *transport, struct nlmsghdr *nlh)
825 memset(evstat, 0, sizeof(*evstat)); 660 memset(evstat, 0, sizeof(*evstat));
826 evstat->transport_handle = iscsi_handle(conn->transport); 661 evstat->transport_handle = iscsi_handle(conn->transport);
827 evstat->type = nlh->nlmsg_type; 662 evstat->type = nlh->nlmsg_type;
828 if (atomic_read(&conn->z_pdu->allocated) >= conn->z_pdu->hiwat)
829 evstat->iferror = -ENOMEM;
830 evstat->u.get_stats.cid = 663 evstat->u.get_stats.cid =
831 ev->u.get_stats.cid; 664 ev->u.get_stats.cid;
832 evstat->u.get_stats.sid = 665 evstat->u.get_stats.sid =
@@ -845,7 +678,7 @@ iscsi_if_get_stats(struct iscsi_transport *transport, struct nlmsghdr *nlh)
845 skb_trim(skbstat, NLMSG_ALIGN(actual_size)); 678 skb_trim(skbstat, NLMSG_ALIGN(actual_size));
846 nlhstat->nlmsg_len = actual_size; 679 nlhstat->nlmsg_len = actual_size;
847 680
848 err = iscsi_unicast_skb(conn->z_pdu, skbstat, priv->daemon_pid); 681 err = iscsi_unicast_skb(skbstat, priv->daemon_pid);
849 } while (err < 0 && err != -ECONNREFUSED); 682 } while (err < 0 && err != -ECONNREFUSED);
850 683
851 return err; 684 return err;
@@ -876,9 +709,7 @@ int iscsi_if_destroy_session_done(struct iscsi_cls_conn *conn)
876 session = iscsi_dev_to_session(conn->dev.parent); 709 session = iscsi_dev_to_session(conn->dev.parent);
877 shost = iscsi_session_to_shost(session); 710 shost = iscsi_session_to_shost(session);
878 711
879 mempool_zone_complete(conn->z_pdu); 712 skb = alloc_skb(len, GFP_KERNEL);
880
881 skb = mempool_zone_get_skb(conn->z_pdu);
882 if (!skb) { 713 if (!skb) {
883 dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of " 714 dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of "
884 "session creation event\n"); 715 "session creation event\n");
@@ -896,7 +727,7 @@ int iscsi_if_destroy_session_done(struct iscsi_cls_conn *conn)
896 * this will occur if the daemon is not up, so we just warn 727 * this will occur if the daemon is not up, so we just warn
897 * the user and when the daemon is restarted it will handle it 728 * the user and when the daemon is restarted it will handle it
898 */ 729 */
899 rc = iscsi_broadcast_skb(conn->z_pdu, skb, GFP_KERNEL); 730 rc = iscsi_broadcast_skb(skb, GFP_KERNEL);
900 if (rc < 0) 731 if (rc < 0)
901 dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of " 732 dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of "
902 "session destruction event. Check iscsi daemon\n"); 733 "session destruction event. Check iscsi daemon\n");
@@ -939,9 +770,7 @@ int iscsi_if_create_session_done(struct iscsi_cls_conn *conn)
939 session = iscsi_dev_to_session(conn->dev.parent); 770 session = iscsi_dev_to_session(conn->dev.parent);
940 shost = iscsi_session_to_shost(session); 771 shost = iscsi_session_to_shost(session);
941 772
942 mempool_zone_complete(conn->z_pdu); 773 skb = alloc_skb(len, GFP_KERNEL);
943
944 skb = mempool_zone_get_skb(conn->z_pdu);
945 if (!skb) { 774 if (!skb) {
946 dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of " 775 dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of "
947 "session creation event\n"); 776 "session creation event\n");
@@ -959,7 +788,7 @@ int iscsi_if_create_session_done(struct iscsi_cls_conn *conn)
959 * this will occur if the daemon is not up, so we just warn 788 * this will occur if the daemon is not up, so we just warn
960 * the user and when the daemon is restarted it will handle it 789 * the user and when the daemon is restarted it will handle it
961 */ 790 */
962 rc = iscsi_broadcast_skb(conn->z_pdu, skb, GFP_KERNEL); 791 rc = iscsi_broadcast_skb(skb, GFP_KERNEL);
963 if (rc < 0) 792 if (rc < 0)
964 dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of " 793 dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of "
965 "session creation event. Check iscsi daemon\n"); 794 "session creation event. Check iscsi daemon\n");
@@ -1278,9 +1107,6 @@ iscsi_if_rx(struct sock *sk, int len)
1278 err = iscsi_if_send_reply( 1107 err = iscsi_if_send_reply(
1279 NETLINK_CREDS(skb)->pid, nlh->nlmsg_seq, 1108 NETLINK_CREDS(skb)->pid, nlh->nlmsg_seq,
1280 nlh->nlmsg_type, 0, 0, ev, sizeof(*ev)); 1109 nlh->nlmsg_type, 0, 0, ev, sizeof(*ev));
1281 if (atomic_read(&z_reply->allocated) >=
1282 z_reply->hiwat)
1283 ev->iferror = -ENOMEM;
1284 } while (err < 0 && err != -ECONNREFUSED); 1110 } while (err < 0 && err != -ECONNREFUSED);
1285 skb_pull(skb, rlen); 1111 skb_pull(skb, rlen);
1286 } 1112 }
@@ -1584,32 +1410,6 @@ int iscsi_unregister_transport(struct iscsi_transport *tt)
1584} 1410}
1585EXPORT_SYMBOL_GPL(iscsi_unregister_transport); 1411EXPORT_SYMBOL_GPL(iscsi_unregister_transport);
1586 1412
1587static int
1588iscsi_rcv_nl_event(struct notifier_block *this, unsigned long event, void *ptr)
1589{
1590 struct netlink_notify *n = ptr;
1591
1592 if (event == NETLINK_URELEASE &&
1593 n->protocol == NETLINK_ISCSI && n->pid) {
1594 struct iscsi_cls_conn *conn;
1595 unsigned long flags;
1596
1597 mempool_zone_complete(z_reply);
1598 spin_lock_irqsave(&connlock, flags);
1599 list_for_each_entry(conn, &connlist, conn_list) {
1600 mempool_zone_complete(conn->z_error);
1601 mempool_zone_complete(conn->z_pdu);
1602 }
1603 spin_unlock_irqrestore(&connlock, flags);
1604 }
1605
1606 return NOTIFY_DONE;
1607}
1608
1609static struct notifier_block iscsi_nl_notifier = {
1610 .notifier_call = iscsi_rcv_nl_event,
1611};
1612
1613static __init int iscsi_transport_init(void) 1413static __init int iscsi_transport_init(void)
1614{ 1414{
1615 int err; 1415 int err;
@@ -1633,25 +1433,15 @@ static __init int iscsi_transport_init(void)
1633 if (err) 1433 if (err)
1634 goto unregister_conn_class; 1434 goto unregister_conn_class;
1635 1435
1636 err = netlink_register_notifier(&iscsi_nl_notifier);
1637 if (err)
1638 goto unregister_session_class;
1639
1640 nls = netlink_kernel_create(NETLINK_ISCSI, 1, iscsi_if_rx, 1436 nls = netlink_kernel_create(NETLINK_ISCSI, 1, iscsi_if_rx,
1641 THIS_MODULE); 1437 THIS_MODULE);
1642 if (!nls) { 1438 if (!nls) {
1643 err = -ENOBUFS; 1439 err = -ENOBUFS;
1644 goto unregister_notifier; 1440 goto unregister_session_class;
1645 } 1441 }
1646 1442
1647 z_reply = mempool_zone_init(Z_MAX_REPLY, 1443 return 0;
1648 NLMSG_SPACE(sizeof(struct iscsi_uevent)), Z_HIWAT_REPLY);
1649 if (z_reply)
1650 return 0;
1651 1444
1652 sock_release(nls->sk_socket);
1653unregister_notifier:
1654 netlink_unregister_notifier(&iscsi_nl_notifier);
1655unregister_session_class: 1445unregister_session_class:
1656 transport_class_unregister(&iscsi_session_class); 1446 transport_class_unregister(&iscsi_session_class);
1657unregister_conn_class: 1447unregister_conn_class:
@@ -1665,9 +1455,7 @@ unregister_transport_class:
1665 1455
1666static void __exit iscsi_transport_exit(void) 1456static void __exit iscsi_transport_exit(void)
1667{ 1457{
1668 mempool_zone_destroy(z_reply);
1669 sock_release(nls->sk_socket); 1458 sock_release(nls->sk_socket);
1670 netlink_unregister_notifier(&iscsi_nl_notifier);
1671 transport_class_unregister(&iscsi_connection_class); 1459 transport_class_unregister(&iscsi_connection_class);
1672 transport_class_unregister(&iscsi_session_class); 1460 transport_class_unregister(&iscsi_session_class);
1673 transport_class_unregister(&iscsi_host_class); 1461 transport_class_unregister(&iscsi_host_class);
diff --git a/drivers/scsi/seagate.c b/drivers/scsi/seagate.c
index 8ff1f2866f7b..5ffec2721b28 100644
--- a/drivers/scsi/seagate.c
+++ b/drivers/scsi/seagate.c
@@ -97,8 +97,8 @@
97#include <linux/blkdev.h> 97#include <linux/blkdev.h>
98#include <linux/stat.h> 98#include <linux/stat.h>
99#include <linux/delay.h> 99#include <linux/delay.h>
100#include <linux/io.h>
100 101
101#include <asm/io.h>
102#include <asm/system.h> 102#include <asm/system.h>
103#include <asm/uaccess.h> 103#include <asm/uaccess.h>
104 104
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 3f8b93188567..81e3bc7b02a1 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -60,7 +60,7 @@ static int sg_version_num = 30534; /* 2 digits for each component */
60 60
61#ifdef CONFIG_SCSI_PROC_FS 61#ifdef CONFIG_SCSI_PROC_FS
62#include <linux/proc_fs.h> 62#include <linux/proc_fs.h>
63static char *sg_version_date = "20060920"; 63static char *sg_version_date = "20061027";
64 64
65static int sg_proc_init(void); 65static int sg_proc_init(void);
66static void sg_proc_cleanup(void); 66static void sg_proc_cleanup(void);
@@ -710,12 +710,12 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp,
710 (int) cmnd[0], (int) hp->cmd_len)); 710 (int) cmnd[0], (int) hp->cmd_len));
711 711
712 if ((k = sg_start_req(srp))) { 712 if ((k = sg_start_req(srp))) {
713 SCSI_LOG_TIMEOUT(1, printk("sg_write: start_req err=%d\n", k)); 713 SCSI_LOG_TIMEOUT(1, printk("sg_common_write: start_req err=%d\n", k));
714 sg_finish_rem_req(srp); 714 sg_finish_rem_req(srp);
715 return k; /* probably out of space --> ENOMEM */ 715 return k; /* probably out of space --> ENOMEM */
716 } 716 }
717 if ((k = sg_write_xfer(srp))) { 717 if ((k = sg_write_xfer(srp))) {
718 SCSI_LOG_TIMEOUT(1, printk("sg_write: write_xfer, bad address\n")); 718 SCSI_LOG_TIMEOUT(1, printk("sg_common_write: write_xfer, bad address\n"));
719 sg_finish_rem_req(srp); 719 sg_finish_rem_req(srp);
720 return k; 720 return k;
721 } 721 }
@@ -746,7 +746,7 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp,
746 hp->dxfer_len, srp->data.k_use_sg, timeout, 746 hp->dxfer_len, srp->data.k_use_sg, timeout,
747 SG_DEFAULT_RETRIES, srp, sg_cmd_done, 747 SG_DEFAULT_RETRIES, srp, sg_cmd_done,
748 GFP_ATOMIC)) { 748 GFP_ATOMIC)) {
749 SCSI_LOG_TIMEOUT(1, printk("sg_write: scsi_execute_async failed\n")); 749 SCSI_LOG_TIMEOUT(1, printk("sg_common_write: scsi_execute_async failed\n"));
750 /* 750 /*
751 * most likely out of mem, but could also be a bad map 751 * most likely out of mem, but could also be a bad map
752 */ 752 */
@@ -1283,7 +1283,7 @@ sg_cmd_done(void *data, char *sense, int result, int resid)
1283 sg_finish_rem_req(srp); 1283 sg_finish_rem_req(srp);
1284 srp = NULL; 1284 srp = NULL;
1285 if (NULL == sfp->headrp) { 1285 if (NULL == sfp->headrp) {
1286 SCSI_LOG_TIMEOUT(1, printk("sg...bh: already closed, final cleanup\n")); 1286 SCSI_LOG_TIMEOUT(1, printk("sg_cmd_done: already closed, final cleanup\n"));
1287 if (0 == sg_remove_sfp(sdp, sfp)) { /* device still present */ 1287 if (0 == sg_remove_sfp(sdp, sfp)) { /* device still present */
1288 scsi_device_put(sdp->device); 1288 scsi_device_put(sdp->device);
1289 } 1289 }
@@ -1512,12 +1512,12 @@ sg_remove(struct class_device *cl_dev, struct class_interface *cl_intf)
1512 POLL_HUP); 1512 POLL_HUP);
1513 } 1513 }
1514 } 1514 }
1515 SCSI_LOG_TIMEOUT(3, printk("sg_detach: dev=%d, dirty\n", k)); 1515 SCSI_LOG_TIMEOUT(3, printk("sg_remove: dev=%d, dirty\n", k));
1516 if (NULL == sdp->headfp) { 1516 if (NULL == sdp->headfp) {
1517 sg_dev_arr[k] = NULL; 1517 sg_dev_arr[k] = NULL;
1518 } 1518 }
1519 } else { /* nothing active, simple case */ 1519 } else { /* nothing active, simple case */
1520 SCSI_LOG_TIMEOUT(3, printk("sg_detach: dev=%d\n", k)); 1520 SCSI_LOG_TIMEOUT(3, printk("sg_remove: dev=%d\n", k));
1521 sg_dev_arr[k] = NULL; 1521 sg_dev_arr[k] = NULL;
1522 } 1522 }
1523 sg_nr_dev--; 1523 sg_nr_dev--;
@@ -1876,14 +1876,15 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size)
1876 } 1876 }
1877 } 1877 }
1878 sg->page = p; 1878 sg->page = p;
1879 sg->length = ret_sz; 1879 sg->length = (ret_sz > num) ? num : ret_sz;
1880 1880
1881 SCSI_LOG_TIMEOUT(5, printk("sg_build_build: k=%d, a=0x%p, len=%d\n", 1881 SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k=%d, num=%d, "
1882 k, p, ret_sz)); 1882 "ret_sz=%d\n", k, num, ret_sz));
1883 } /* end of for loop */ 1883 } /* end of for loop */
1884 1884
1885 schp->k_use_sg = k; 1885 schp->k_use_sg = k;
1886 SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k_use_sg=%d, rem_sz=%d\n", k, rem_sz)); 1886 SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k_use_sg=%d, "
1887 "rem_sz=%d\n", k, rem_sz));
1887 1888
1888 schp->bufflen = blk_size; 1889 schp->bufflen = blk_size;
1889 if (rem_sz > 0) /* must have failed */ 1890 if (rem_sz > 0) /* must have failed */
@@ -2014,7 +2015,7 @@ sg_remove_scat(Sg_scatter_hold * schp)
2014 for (k = 0; (k < schp->k_use_sg) && sg->page; 2015 for (k = 0; (k < schp->k_use_sg) && sg->page;
2015 ++k, ++sg) { 2016 ++k, ++sg) {
2016 SCSI_LOG_TIMEOUT(5, printk( 2017 SCSI_LOG_TIMEOUT(5, printk(
2017 "sg_remove_scat: k=%d, a=0x%p, len=%d\n", 2018 "sg_remove_scat: k=%d, pg=0x%p, len=%d\n",
2018 k, sg->page, sg->length)); 2019 k, sg->page, sg->length));
2019 sg_page_free(sg->page, sg->length); 2020 sg_page_free(sg->page, sg->length);
2020 } 2021 }
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index febfac97ad38..587274dd7059 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -1177,7 +1177,10 @@ static int st_open(struct inode *inode, struct file *filp)
1177 goto err_out; 1177 goto err_out;
1178 if ((filp->f_flags & O_NONBLOCK) == 0 && 1178 if ((filp->f_flags & O_NONBLOCK) == 0 &&
1179 retval != CHKRES_READY) { 1179 retval != CHKRES_READY) {
1180 retval = (-EIO); 1180 if (STp->ready == NO_TAPE)
1181 retval = (-ENOMEDIUM);
1182 else
1183 retval = (-EIO);
1181 goto err_out; 1184 goto err_out;
1182 } 1185 }
1183 return 0; 1186 return 0;
diff --git a/drivers/scsi/sun3_NCR5380.c b/drivers/scsi/sun3_NCR5380.c
index 5ec5af8e3379..3b3f3050a877 100644
--- a/drivers/scsi/sun3_NCR5380.c
+++ b/drivers/scsi/sun3_NCR5380.c
@@ -266,8 +266,8 @@ static struct scsi_host_template *the_template = NULL;
266 (struct NCR5380_hostdata *)(in)->hostdata 266 (struct NCR5380_hostdata *)(in)->hostdata
267#define HOSTDATA(in) ((struct NCR5380_hostdata *)(in)->hostdata) 267#define HOSTDATA(in) ((struct NCR5380_hostdata *)(in)->hostdata)
268 268
269#define NEXT(cmd) ((Scsi_Cmnd *)((cmd)->host_scribble)) 269#define NEXT(cmd) ((struct scsi_cmnd *)((cmd)->host_scribble))
270#define NEXTADDR(cmd) ((Scsi_Cmnd **)&((cmd)->host_scribble)) 270#define NEXTADDR(cmd) ((struct scsi_cmnd **)&((cmd)->host_scribble))
271 271
272#define HOSTNO instance->host_no 272#define HOSTNO instance->host_no
273#define H_NO(cmd) (cmd)->device->host->host_no 273#define H_NO(cmd) (cmd)->device->host->host_no
@@ -360,7 +360,7 @@ static void __init init_tags( void )
360 * conditions. 360 * conditions.
361 */ 361 */
362 362
363static int is_lun_busy( Scsi_Cmnd *cmd, int should_be_tagged ) 363static int is_lun_busy(struct scsi_cmnd *cmd, int should_be_tagged)
364{ 364{
365 SETUP_HOSTDATA(cmd->device->host); 365 SETUP_HOSTDATA(cmd->device->host);
366 366
@@ -384,7 +384,7 @@ static int is_lun_busy( Scsi_Cmnd *cmd, int should_be_tagged )
384 * untagged. 384 * untagged.
385 */ 385 */
386 386
387static void cmd_get_tag( Scsi_Cmnd *cmd, int should_be_tagged ) 387static void cmd_get_tag(struct scsi_cmnd *cmd, int should_be_tagged)
388{ 388{
389 SETUP_HOSTDATA(cmd->device->host); 389 SETUP_HOSTDATA(cmd->device->host);
390 390
@@ -416,7 +416,7 @@ static void cmd_get_tag( Scsi_Cmnd *cmd, int should_be_tagged )
416 * unlock the LUN. 416 * unlock the LUN.
417 */ 417 */
418 418
419static void cmd_free_tag( Scsi_Cmnd *cmd ) 419static void cmd_free_tag(struct scsi_cmnd *cmd)
420{ 420{
421 SETUP_HOSTDATA(cmd->device->host); 421 SETUP_HOSTDATA(cmd->device->host);
422 422
@@ -460,18 +460,18 @@ static void free_all_tags( void )
460 460
461 461
462/* 462/*
463 * Function: void merge_contiguous_buffers( Scsi_Cmnd *cmd ) 463 * Function: void merge_contiguous_buffers(struct scsi_cmnd *cmd)
464 * 464 *
465 * Purpose: Try to merge several scatter-gather requests into one DMA 465 * Purpose: Try to merge several scatter-gather requests into one DMA
466 * transfer. This is possible if the scatter buffers lie on 466 * transfer. This is possible if the scatter buffers lie on
467 * physical contiguous addresses. 467 * physical contiguous addresses.
468 * 468 *
469 * Parameters: Scsi_Cmnd *cmd 469 * Parameters: struct scsi_cmnd *cmd
470 * The command to work on. The first scatter buffer's data are 470 * The command to work on. The first scatter buffer's data are
471 * assumed to be already transfered into ptr/this_residual. 471 * assumed to be already transfered into ptr/this_residual.
472 */ 472 */
473 473
474static void merge_contiguous_buffers( Scsi_Cmnd *cmd ) 474static void merge_contiguous_buffers(struct scsi_cmnd *cmd)
475{ 475{
476 unsigned long endaddr; 476 unsigned long endaddr;
477#if (NDEBUG & NDEBUG_MERGING) 477#if (NDEBUG & NDEBUG_MERGING)
@@ -501,15 +501,15 @@ static void merge_contiguous_buffers( Scsi_Cmnd *cmd )
501} 501}
502 502
503/* 503/*
504 * Function : void initialize_SCp(Scsi_Cmnd *cmd) 504 * Function : void initialize_SCp(struct scsi_cmnd *cmd)
505 * 505 *
506 * Purpose : initialize the saved data pointers for cmd to point to the 506 * Purpose : initialize the saved data pointers for cmd to point to the
507 * start of the buffer. 507 * start of the buffer.
508 * 508 *
509 * Inputs : cmd - Scsi_Cmnd structure to have pointers reset. 509 * Inputs : cmd - struct scsi_cmnd structure to have pointers reset.
510 */ 510 */
511 511
512static __inline__ void initialize_SCp(Scsi_Cmnd *cmd) 512static __inline__ void initialize_SCp(struct scsi_cmnd *cmd)
513{ 513{
514 /* 514 /*
515 * Initialize the Scsi Pointer field so that all of the commands in the 515 * Initialize the Scsi Pointer field so that all of the commands in the
@@ -753,14 +753,15 @@ static void NCR5380_print_status (struct Scsi_Host *instance)
753 do { if (pos + strlen(fmt) + 20 /* slop */ < buffer + length) \ 753 do { if (pos + strlen(fmt) + 20 /* slop */ < buffer + length) \
754 pos += sprintf(pos, fmt , ## args); } while(0) 754 pos += sprintf(pos, fmt , ## args); } while(0)
755static 755static
756char *lprint_Scsi_Cmnd (Scsi_Cmnd *cmd, char *pos, char *buffer, int length); 756char *lprint_Scsi_Cmnd(struct scsi_cmnd *cmd, char *pos, char *buffer,
757 int length);
757 758
758static int NCR5380_proc_info (struct Scsi_Host *instance, char *buffer, char **start, 759static int NCR5380_proc_info(struct Scsi_Host *instance, char *buffer,
759 off_t offset, int length, int inout) 760 char **start, off_t offset, int length, int inout)
760{ 761{
761 char *pos = buffer; 762 char *pos = buffer;
762 struct NCR5380_hostdata *hostdata; 763 struct NCR5380_hostdata *hostdata;
763 Scsi_Cmnd *ptr; 764 struct scsi_cmnd *ptr;
764 unsigned long flags; 765 unsigned long flags;
765 off_t begin = 0; 766 off_t begin = 0;
766#define check_offset() \ 767#define check_offset() \
@@ -784,18 +785,19 @@ static int NCR5380_proc_info (struct Scsi_Host *instance, char *buffer, char **s
784 if (!hostdata->connected) 785 if (!hostdata->connected)
785 SPRINTF("scsi%d: no currently connected command\n", HOSTNO); 786 SPRINTF("scsi%d: no currently connected command\n", HOSTNO);
786 else 787 else
787 pos = lprint_Scsi_Cmnd ((Scsi_Cmnd *) hostdata->connected, 788 pos = lprint_Scsi_Cmnd ((struct scsi_cmnd *) hostdata->connected,
788 pos, buffer, length); 789 pos, buffer, length);
789 SPRINTF("scsi%d: issue_queue\n", HOSTNO); 790 SPRINTF("scsi%d: issue_queue\n", HOSTNO);
790 check_offset(); 791 check_offset();
791 for (ptr = (Scsi_Cmnd *) hostdata->issue_queue; ptr; ptr = NEXT(ptr)) { 792 for (ptr = (struct scsi_cmnd *) hostdata->issue_queue; ptr; ptr = NEXT(ptr))
793 {
792 pos = lprint_Scsi_Cmnd (ptr, pos, buffer, length); 794 pos = lprint_Scsi_Cmnd (ptr, pos, buffer, length);
793 check_offset(); 795 check_offset();
794 } 796 }
795 797
796 SPRINTF("scsi%d: disconnected_queue\n", HOSTNO); 798 SPRINTF("scsi%d: disconnected_queue\n", HOSTNO);
797 check_offset(); 799 check_offset();
798 for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; 800 for (ptr = (struct scsi_cmnd *) hostdata->disconnected_queue; ptr;
799 ptr = NEXT(ptr)) { 801 ptr = NEXT(ptr)) {
800 pos = lprint_Scsi_Cmnd (ptr, pos, buffer, length); 802 pos = lprint_Scsi_Cmnd (ptr, pos, buffer, length);
801 check_offset(); 803 check_offset();
@@ -810,8 +812,8 @@ static int NCR5380_proc_info (struct Scsi_Host *instance, char *buffer, char **s
810 return length; 812 return length;
811} 813}
812 814
813static char * 815static char *lprint_Scsi_Cmnd(struct scsi_cmnd *cmd, char *pos, char *buffer,
814lprint_Scsi_Cmnd (Scsi_Cmnd *cmd, char *pos, char *buffer, int length) 816 int length)
815{ 817{
816 int i, s; 818 int i, s;
817 unsigned char *command; 819 unsigned char *command;
@@ -888,8 +890,8 @@ static int NCR5380_init (struct Scsi_Host *instance, int flags)
888} 890}
889 891
890/* 892/*
891 * Function : int NCR5380_queue_command (Scsi_Cmnd *cmd, 893 * Function : int NCR5380_queue_command (struct scsi_cmnd *cmd,
892 * void (*done)(Scsi_Cmnd *)) 894 * void (*done)(struct scsi_cmnd *))
893 * 895 *
894 * Purpose : enqueues a SCSI command 896 * Purpose : enqueues a SCSI command
895 * 897 *
@@ -906,10 +908,11 @@ static int NCR5380_init (struct Scsi_Host *instance, int flags)
906 */ 908 */
907 909
908/* Only make static if a wrapper function is used */ 910/* Only make static if a wrapper function is used */
909static int NCR5380_queue_command (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *)) 911static int NCR5380_queue_command(struct scsi_cmnd *cmd,
912 void (*done)(struct scsi_cmnd *))
910{ 913{
911 SETUP_HOSTDATA(cmd->device->host); 914 SETUP_HOSTDATA(cmd->device->host);
912 Scsi_Cmnd *tmp; 915 struct scsi_cmnd *tmp;
913 unsigned long flags; 916 unsigned long flags;
914 917
915#if (NDEBUG & NDEBUG_NO_WRITE) 918#if (NDEBUG & NDEBUG_NO_WRITE)
@@ -990,7 +993,7 @@ static int NCR5380_queue_command (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
990 NEXT(cmd) = hostdata->issue_queue; 993 NEXT(cmd) = hostdata->issue_queue;
991 hostdata->issue_queue = cmd; 994 hostdata->issue_queue = cmd;
992 } else { 995 } else {
993 for (tmp = (Scsi_Cmnd *)hostdata->issue_queue; 996 for (tmp = (struct scsi_cmnd *)hostdata->issue_queue;
994 NEXT(tmp); tmp = NEXT(tmp)) 997 NEXT(tmp); tmp = NEXT(tmp))
995 ; 998 ;
996 LIST(cmd, tmp); 999 LIST(cmd, tmp);
@@ -1030,7 +1033,7 @@ static int NCR5380_queue_command (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
1030 1033
1031static void NCR5380_main (void *bl) 1034static void NCR5380_main (void *bl)
1032{ 1035{
1033 Scsi_Cmnd *tmp, *prev; 1036 struct scsi_cmnd *tmp, *prev;
1034 struct Scsi_Host *instance = first_instance; 1037 struct Scsi_Host *instance = first_instance;
1035 struct NCR5380_hostdata *hostdata = HOSTDATA(instance); 1038 struct NCR5380_hostdata *hostdata = HOSTDATA(instance);
1036 int done; 1039 int done;
@@ -1073,12 +1076,12 @@ static void NCR5380_main (void *bl)
1073 * for a target that's not busy. 1076 * for a target that's not busy.
1074 */ 1077 */
1075#if (NDEBUG & NDEBUG_LISTS) 1078#if (NDEBUG & NDEBUG_LISTS)
1076 for (tmp = (Scsi_Cmnd *) hostdata->issue_queue, prev = NULL; 1079 for (tmp = (struct scsi_cmnd *) hostdata->issue_queue, prev = NULL;
1077 tmp && (tmp != prev); prev = tmp, tmp = NEXT(tmp)) 1080 tmp && (tmp != prev); prev = tmp, tmp = NEXT(tmp))
1078 ; 1081 ;
1079 if ((tmp == prev) && tmp) printk(" LOOP\n");/* else printk("\n");*/ 1082 if ((tmp == prev) && tmp) printk(" LOOP\n");/* else printk("\n");*/
1080#endif 1083#endif
1081 for (tmp = (Scsi_Cmnd *) hostdata->issue_queue, 1084 for (tmp = (struct scsi_cmnd *) hostdata->issue_queue,
1082 prev = NULL; tmp; prev = tmp, tmp = NEXT(tmp) ) { 1085 prev = NULL; tmp; prev = tmp, tmp = NEXT(tmp) ) {
1083 1086
1084#if (NDEBUG & NDEBUG_LISTS) 1087#if (NDEBUG & NDEBUG_LISTS)
@@ -1339,7 +1342,8 @@ static irqreturn_t NCR5380_intr (int irq, void *dev_id)
1339} 1342}
1340 1343
1341#ifdef NCR5380_STATS 1344#ifdef NCR5380_STATS
1342static void collect_stats(struct NCR5380_hostdata* hostdata, Scsi_Cmnd* cmd) 1345static void collect_stats(struct NCR5380_hostdata *hostdata,
1346 struct scsi_cmnd *cmd)
1343{ 1347{
1344# ifdef NCR5380_STAT_LIMIT 1348# ifdef NCR5380_STAT_LIMIT
1345 if (cmd->request_bufflen > NCR5380_STAT_LIMIT) 1349 if (cmd->request_bufflen > NCR5380_STAT_LIMIT)
@@ -1365,8 +1369,8 @@ static void collect_stats(struct NCR5380_hostdata* hostdata, Scsi_Cmnd* cmd)
1365#endif 1369#endif
1366 1370
1367/* 1371/*
1368 * Function : int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd, 1372 * Function : int NCR5380_select(struct Scsi_Host *instance,
1369 * int tag); 1373 * struct scsi_cmnd *cmd, int tag);
1370 * 1374 *
1371 * Purpose : establishes I_T_L or I_T_L_Q nexus for new or existing command, 1375 * Purpose : establishes I_T_L or I_T_L_Q nexus for new or existing command,
1372 * including ARBITRATION, SELECTION, and initial message out for 1376 * including ARBITRATION, SELECTION, and initial message out for
@@ -1395,7 +1399,8 @@ static void collect_stats(struct NCR5380_hostdata* hostdata, Scsi_Cmnd* cmd)
1395 * cmd->result host byte set to DID_BAD_TARGET. 1399 * cmd->result host byte set to DID_BAD_TARGET.
1396 */ 1400 */
1397 1401
1398static int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd, int tag) 1402static int NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd,
1403 int tag)
1399{ 1404{
1400 SETUP_HOSTDATA(instance); 1405 SETUP_HOSTDATA(instance);
1401 unsigned char tmp[3], phase; 1406 unsigned char tmp[3], phase;
@@ -1985,7 +1990,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)
1985#endif 1990#endif
1986 unsigned char *data; 1991 unsigned char *data;
1987 unsigned char phase, tmp, extended_msg[10], old_phase=0xff; 1992 unsigned char phase, tmp, extended_msg[10], old_phase=0xff;
1988 Scsi_Cmnd *cmd = (Scsi_Cmnd *) hostdata->connected; 1993 struct scsi_cmnd *cmd = (struct scsi_cmnd *) hostdata->connected;
1989 1994
1990#ifdef SUN3_SCSI_VME 1995#ifdef SUN3_SCSI_VME
1991 dregs->csr |= CSR_INTR; 1996 dregs->csr |= CSR_INTR;
@@ -2272,7 +2277,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)
2272 local_irq_save(flags); 2277 local_irq_save(flags);
2273 LIST(cmd,hostdata->issue_queue); 2278 LIST(cmd,hostdata->issue_queue);
2274 NEXT(cmd) = hostdata->issue_queue; 2279 NEXT(cmd) = hostdata->issue_queue;
2275 hostdata->issue_queue = (Scsi_Cmnd *) cmd; 2280 hostdata->issue_queue = (struct scsi_cmnd *) cmd;
2276 local_irq_restore(flags); 2281 local_irq_restore(flags);
2277 QU_PRINTK("scsi%d: REQUEST SENSE added to head of " 2282 QU_PRINTK("scsi%d: REQUEST SENSE added to head of "
2278 "issue queue\n", H_NO(cmd)); 2283 "issue queue\n", H_NO(cmd));
@@ -2502,7 +2507,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)
2502 * Function : void NCR5380_reselect (struct Scsi_Host *instance) 2507 * Function : void NCR5380_reselect (struct Scsi_Host *instance)
2503 * 2508 *
2504 * Purpose : does reselection, initializing the instance->connected 2509 * Purpose : does reselection, initializing the instance->connected
2505 * field to point to the Scsi_Cmnd for which the I_T_L or I_T_L_Q 2510 * field to point to the struct scsi_cmnd for which the I_T_L or I_T_L_Q
2506 * nexus has been reestablished, 2511 * nexus has been reestablished,
2507 * 2512 *
2508 * Inputs : instance - this instance of the NCR5380. 2513 * Inputs : instance - this instance of the NCR5380.
@@ -2521,7 +2526,7 @@ static void NCR5380_reselect (struct Scsi_Host *instance)
2521 unsigned char tag; 2526 unsigned char tag;
2522#endif 2527#endif
2523 unsigned char msg[3]; 2528 unsigned char msg[3];
2524 Scsi_Cmnd *tmp = NULL, *prev; 2529 struct scsi_cmnd *tmp = NULL, *prev;
2525/* unsigned long flags; */ 2530/* unsigned long flags; */
2526 2531
2527 /* 2532 /*
@@ -2577,7 +2582,7 @@ static void NCR5380_reselect (struct Scsi_Host *instance)
2577 * just reestablished, and remove it from the disconnected queue. 2582 * just reestablished, and remove it from the disconnected queue.
2578 */ 2583 */
2579 2584
2580 for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue, prev = NULL; 2585 for (tmp = (struct scsi_cmnd *) hostdata->disconnected_queue, prev = NULL;
2581 tmp; prev = tmp, tmp = NEXT(tmp) ) { 2586 tmp; prev = tmp, tmp = NEXT(tmp) ) {
2582 if ((target_mask == (1 << tmp->device->id)) && (lun == tmp->device->lun) 2587 if ((target_mask == (1 << tmp->device->id)) && (lun == tmp->device->lun)
2583#ifdef SUPPORT_TAGS 2588#ifdef SUPPORT_TAGS
@@ -2668,11 +2673,11 @@ static void NCR5380_reselect (struct Scsi_Host *instance)
2668 2673
2669 2674
2670/* 2675/*
2671 * Function : int NCR5380_abort (Scsi_Cmnd *cmd) 2676 * Function : int NCR5380_abort(struct scsi_cmnd *cmd)
2672 * 2677 *
2673 * Purpose : abort a command 2678 * Purpose : abort a command
2674 * 2679 *
2675 * Inputs : cmd - the Scsi_Cmnd to abort, code - code to set the 2680 * Inputs : cmd - the struct scsi_cmnd to abort, code - code to set the
2676 * host byte of the result field to, if zero DID_ABORTED is 2681 * host byte of the result field to, if zero DID_ABORTED is
2677 * used. 2682 * used.
2678 * 2683 *
@@ -2684,11 +2689,11 @@ static void NCR5380_reselect (struct Scsi_Host *instance)
2684 * called where the loop started in NCR5380_main(). 2689 * called where the loop started in NCR5380_main().
2685 */ 2690 */
2686 2691
2687static int NCR5380_abort (Scsi_Cmnd *cmd) 2692static int NCR5380_abort(struct scsi_cmnd *cmd)
2688{ 2693{
2689 struct Scsi_Host *instance = cmd->device->host; 2694 struct Scsi_Host *instance = cmd->device->host;
2690 SETUP_HOSTDATA(instance); 2695 SETUP_HOSTDATA(instance);
2691 Scsi_Cmnd *tmp, **prev; 2696 struct scsi_cmnd *tmp, **prev;
2692 unsigned long flags; 2697 unsigned long flags;
2693 2698
2694 printk(KERN_NOTICE "scsi%d: aborting command\n", HOSTNO); 2699 printk(KERN_NOTICE "scsi%d: aborting command\n", HOSTNO);
@@ -2753,9 +2758,9 @@ static int NCR5380_abort (Scsi_Cmnd *cmd)
2753 * Case 2 : If the command hasn't been issued yet, we simply remove it 2758 * Case 2 : If the command hasn't been issued yet, we simply remove it
2754 * from the issue queue. 2759 * from the issue queue.
2755 */ 2760 */
2756 for (prev = (Scsi_Cmnd **) &(hostdata->issue_queue), 2761 for (prev = (struct scsi_cmnd **) &(hostdata->issue_queue),
2757 tmp = (Scsi_Cmnd *) hostdata->issue_queue; 2762 tmp = (struct scsi_cmnd *) hostdata->issue_queue;
2758 tmp; prev = NEXTADDR(tmp), tmp = NEXT(tmp) ) 2763 tmp; prev = NEXTADDR(tmp), tmp = NEXT(tmp))
2759 if (cmd == tmp) { 2764 if (cmd == tmp) {
2760 REMOVE(5, *prev, tmp, NEXT(tmp)); 2765 REMOVE(5, *prev, tmp, NEXT(tmp));
2761 (*prev) = NEXT(tmp); 2766 (*prev) = NEXT(tmp);
@@ -2812,7 +2817,7 @@ static int NCR5380_abort (Scsi_Cmnd *cmd)
2812 * it from the disconnected queue. 2817 * it from the disconnected queue.
2813 */ 2818 */
2814 2819
2815 for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue; tmp; 2820 for (tmp = (struct scsi_cmnd *) hostdata->disconnected_queue; tmp;
2816 tmp = NEXT(tmp)) 2821 tmp = NEXT(tmp))
2817 if (cmd == tmp) { 2822 if (cmd == tmp) {
2818 local_irq_restore(flags); 2823 local_irq_restore(flags);
@@ -2826,8 +2831,8 @@ static int NCR5380_abort (Scsi_Cmnd *cmd)
2826 do_abort (instance); 2831 do_abort (instance);
2827 2832
2828 local_irq_save(flags); 2833 local_irq_save(flags);
2829 for (prev = (Scsi_Cmnd **) &(hostdata->disconnected_queue), 2834 for (prev = (struct scsi_cmnd **) &(hostdata->disconnected_queue),
2830 tmp = (Scsi_Cmnd *) hostdata->disconnected_queue; 2835 tmp = (struct scsi_cmnd *) hostdata->disconnected_queue;
2831 tmp; prev = NEXTADDR(tmp), tmp = NEXT(tmp) ) 2836 tmp; prev = NEXTADDR(tmp), tmp = NEXT(tmp) )
2832 if (cmd == tmp) { 2837 if (cmd == tmp) {
2833 REMOVE(5, *prev, tmp, NEXT(tmp)); 2838 REMOVE(5, *prev, tmp, NEXT(tmp));
@@ -2868,7 +2873,7 @@ static int NCR5380_abort (Scsi_Cmnd *cmd)
2868 2873
2869 2874
2870/* 2875/*
2871 * Function : int NCR5380_bus_reset (Scsi_Cmnd *cmd) 2876 * Function : int NCR5380_bus_reset(struct scsi_cmnd *cmd)
2872 * 2877 *
2873 * Purpose : reset the SCSI bus. 2878 * Purpose : reset the SCSI bus.
2874 * 2879 *
@@ -2876,13 +2881,13 @@ static int NCR5380_abort (Scsi_Cmnd *cmd)
2876 * 2881 *
2877 */ 2882 */
2878 2883
2879static int NCR5380_bus_reset( Scsi_Cmnd *cmd) 2884static int NCR5380_bus_reset(struct scsi_cmnd *cmd)
2880{ 2885{
2881 SETUP_HOSTDATA(cmd->device->host); 2886 SETUP_HOSTDATA(cmd->device->host);
2882 int i; 2887 int i;
2883 unsigned long flags; 2888 unsigned long flags;
2884#if 1 2889#if 1
2885 Scsi_Cmnd *connected, *disconnected_queue; 2890 struct scsi_cmnd *connected, *disconnected_queue;
2886#endif 2891#endif
2887 2892
2888 2893
@@ -2914,9 +2919,9 @@ static int NCR5380_bus_reset( Scsi_Cmnd *cmd)
2914 * remembered in local variables first. 2919 * remembered in local variables first.
2915 */ 2920 */
2916 local_irq_save(flags); 2921 local_irq_save(flags);
2917 connected = (Scsi_Cmnd *)hostdata->connected; 2922 connected = (struct scsi_cmnd *)hostdata->connected;
2918 hostdata->connected = NULL; 2923 hostdata->connected = NULL;
2919 disconnected_queue = (Scsi_Cmnd *)hostdata->disconnected_queue; 2924 disconnected_queue = (struct scsi_cmnd *)hostdata->disconnected_queue;
2920 hostdata->disconnected_queue = NULL; 2925 hostdata->disconnected_queue = NULL;
2921#ifdef SUPPORT_TAGS 2926#ifdef SUPPORT_TAGS
2922 free_all_tags(); 2927 free_all_tags();
diff --git a/drivers/scsi/sun3_scsi.c b/drivers/scsi/sun3_scsi.c
index e625b4c5833a..d56d85dd9ba0 100644
--- a/drivers/scsi/sun3_scsi.c
+++ b/drivers/scsi/sun3_scsi.c
@@ -119,7 +119,7 @@ module_param(setup_use_tagged_queuing, int, 0);
119static int setup_hostid = -1; 119static int setup_hostid = -1;
120module_param(setup_hostid, int, 0); 120module_param(setup_hostid, int, 0);
121 121
122static Scsi_Cmnd *sun3_dma_setup_done = NULL; 122static struct scsi_cmnd *sun3_dma_setup_done = NULL;
123 123
124#define AFTER_RESET_DELAY (HZ/2) 124#define AFTER_RESET_DELAY (HZ/2)
125 125
@@ -521,8 +521,9 @@ static inline unsigned long sun3scsi_dma_residual(struct Scsi_Host *instance)
521 return last_residual; 521 return last_residual;
522} 522}
523 523
524static inline unsigned long sun3scsi_dma_xfer_len(unsigned long wanted, Scsi_Cmnd *cmd, 524static inline unsigned long sun3scsi_dma_xfer_len(unsigned long wanted,
525 int write_flag) 525 struct scsi_cmnd *cmd,
526 int write_flag)
526{ 527{
527 if(blk_fs_request(cmd->request)) 528 if(blk_fs_request(cmd->request))
528 return wanted; 529 return wanted;
diff --git a/drivers/scsi/sun3_scsi.h b/drivers/scsi/sun3_scsi.h
index 834dab428019..a1103b3e2034 100644
--- a/drivers/scsi/sun3_scsi.h
+++ b/drivers/scsi/sun3_scsi.h
@@ -47,11 +47,12 @@
47 47
48#define IOBASE_SUN3_VMESCSI 0xff200000 48#define IOBASE_SUN3_VMESCSI 0xff200000
49 49
50static int sun3scsi_abort (Scsi_Cmnd *); 50static int sun3scsi_abort(struct scsi_cmnd *);
51static int sun3scsi_detect (struct scsi_host_template *); 51static int sun3scsi_detect (struct scsi_host_template *);
52static const char *sun3scsi_info (struct Scsi_Host *); 52static const char *sun3scsi_info (struct Scsi_Host *);
53static int sun3scsi_bus_reset(Scsi_Cmnd *); 53static int sun3scsi_bus_reset(struct scsi_cmnd *);
54static int sun3scsi_queue_command (Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 54static int sun3scsi_queue_command(struct scsi_cmnd *,
55 void (*done)(struct scsi_cmnd *));
55static int sun3scsi_release (struct Scsi_Host *); 56static int sun3scsi_release (struct Scsi_Host *);
56 57
57#ifndef CMD_PER_LUN 58#ifndef CMD_PER_LUN
diff --git a/drivers/scsi/sun3_scsi_vme.c b/drivers/scsi/sun3_scsi_vme.c
index e8faab16567b..92def310a84c 100644
--- a/drivers/scsi/sun3_scsi_vme.c
+++ b/drivers/scsi/sun3_scsi_vme.c
@@ -84,7 +84,7 @@ module_param(setup_use_tagged_queuing, int, 0);
84static int setup_hostid = -1; 84static int setup_hostid = -1;
85module_param(setup_hostid, int, 0); 85module_param(setup_hostid, int, 0);
86 86
87static Scsi_Cmnd *sun3_dma_setup_done = NULL; 87static struct scsi_cmnd *sun3_dma_setup_done = NULL;
88 88
89#define AFTER_RESET_DELAY (HZ/2) 89#define AFTER_RESET_DELAY (HZ/2)
90 90
@@ -455,8 +455,9 @@ static inline unsigned long sun3scsi_dma_residual(struct Scsi_Host *instance)
455 return last_residual; 455 return last_residual;
456} 456}
457 457
458static inline unsigned long sun3scsi_dma_xfer_len(unsigned long wanted, Scsi_Cmnd *cmd, 458static inline unsigned long sun3scsi_dma_xfer_len(unsigned long wanted,
459 int write_flag) 459 struct scsi_cmnd *cmd,
460 int write_flag)
460{ 461{
461 if(blk_fs_request(cmd->request)) 462 if(blk_fs_request(cmd->request))
462 return wanted; 463 return wanted;
diff --git a/drivers/scsi/t128.c b/drivers/scsi/t128.c
index 2df6747cb76f..0b7a70f61e0d 100644
--- a/drivers/scsi/t128.c
+++ b/drivers/scsi/t128.c
@@ -109,7 +109,7 @@
109#include <asm/system.h> 109#include <asm/system.h>
110#include <linux/signal.h> 110#include <linux/signal.h>
111#include <linux/sched.h> 111#include <linux/sched.h>
112#include <asm/io.h> 112#include <linux/io.h>
113#include <linux/blkdev.h> 113#include <linux/blkdev.h>
114#include <linux/interrupt.h> 114#include <linux/interrupt.h>
115#include <linux/stat.h> 115#include <linux/stat.h>
diff --git a/drivers/scsi/tmscsim.c b/drivers/scsi/tmscsim.c
index d03aa6ce8fe8..fa5382e354be 100644
--- a/drivers/scsi/tmscsim.c
+++ b/drivers/scsi/tmscsim.c
@@ -2304,6 +2304,7 @@ static struct scsi_host_template driver_template = {
2304 .sg_tablesize = SG_ALL, 2304 .sg_tablesize = SG_ALL,
2305 .cmd_per_lun = 1, 2305 .cmd_per_lun = 1,
2306 .use_clustering = ENABLE_CLUSTERING, 2306 .use_clustering = ENABLE_CLUSTERING,
2307 .max_sectors = 0x4000, /* 8MiB = 16 * 1024 * 512 */
2307}; 2308};
2308 2309
2309/*********************************************************************** 2310/***********************************************************************
diff --git a/drivers/scsi/wd7000.c b/drivers/scsi/wd7000.c
index 331e1cf159b0..30be76514c43 100644
--- a/drivers/scsi/wd7000.c
+++ b/drivers/scsi/wd7000.c
@@ -178,10 +178,10 @@
178#include <linux/blkdev.h> 178#include <linux/blkdev.h>
179#include <linux/init.h> 179#include <linux/init.h>
180#include <linux/stat.h> 180#include <linux/stat.h>
181#include <linux/io.h>
181 182
182#include <asm/system.h> 183#include <asm/system.h>
183#include <asm/dma.h> 184#include <asm/dma.h>
184#include <asm/io.h>
185 185
186#include <scsi/scsi.h> 186#include <scsi/scsi.h>
187#include <scsi/scsi_cmnd.h> 187#include <scsi/scsi_cmnd.h>
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index b0d502622d94..0b71e7d18903 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -767,37 +767,37 @@ config SERIAL_CPM_SCC1
767 bool "Support for SCC1 serial port" 767 bool "Support for SCC1 serial port"
768 depends on SERIAL_CPM=y 768 depends on SERIAL_CPM=y
769 help 769 help
770 Select the is option to use SCC1 as a serial port 770 Select this option to use SCC1 as a serial port
771 771
772config SERIAL_CPM_SCC2 772config SERIAL_CPM_SCC2
773 bool "Support for SCC2 serial port" 773 bool "Support for SCC2 serial port"
774 depends on SERIAL_CPM=y 774 depends on SERIAL_CPM=y
775 help 775 help
776 Select the is option to use SCC2 as a serial port 776 Select this option to use SCC2 as a serial port
777 777
778config SERIAL_CPM_SCC3 778config SERIAL_CPM_SCC3
779 bool "Support for SCC3 serial port" 779 bool "Support for SCC3 serial port"
780 depends on SERIAL_CPM=y 780 depends on SERIAL_CPM=y
781 help 781 help
782 Select the is option to use SCC3 as a serial port 782 Select this option to use SCC3 as a serial port
783 783
784config SERIAL_CPM_SCC4 784config SERIAL_CPM_SCC4
785 bool "Support for SCC4 serial port" 785 bool "Support for SCC4 serial port"
786 depends on SERIAL_CPM=y 786 depends on SERIAL_CPM=y
787 help 787 help
788 Select the is option to use SCC4 as a serial port 788 Select this option to use SCC4 as a serial port
789 789
790config SERIAL_CPM_SMC1 790config SERIAL_CPM_SMC1
791 bool "Support for SMC1 serial port" 791 bool "Support for SMC1 serial port"
792 depends on SERIAL_CPM=y 792 depends on SERIAL_CPM=y
793 help 793 help
794 Select the is option to use SMC1 as a serial port 794 Select this option to use SMC1 as a serial port
795 795
796config SERIAL_CPM_SMC2 796config SERIAL_CPM_SMC2
797 bool "Support for SMC2 serial port" 797 bool "Support for SMC2 serial port"
798 depends on SERIAL_CPM=y 798 depends on SERIAL_CPM=y
799 help 799 help
800 Select the is option to use SMC2 as a serial port 800 Select this option to use SMC2 as a serial port
801 801
802config SERIAL_SGI_L1_CONSOLE 802config SERIAL_SGI_L1_CONSOLE
803 bool "SGI Altix L1 serial console support" 803 bool "SGI Altix L1 serial console support"
diff --git a/drivers/serial/cpm_uart/cpm_uart.h b/drivers/serial/cpm_uart/cpm_uart.h
index a8f894c78194..69715e556506 100644
--- a/drivers/serial/cpm_uart/cpm_uart.h
+++ b/drivers/serial/cpm_uart/cpm_uart.h
@@ -88,7 +88,7 @@ extern struct uart_cpm_port cpm_uart_ports[UART_NR];
88 88
89/* these are located in their respective files */ 89/* these are located in their respective files */
90void cpm_line_cr_cmd(int line, int cmd); 90void cpm_line_cr_cmd(int line, int cmd);
91int cpm_uart_init_portdesc(void); 91int __init cpm_uart_init_portdesc(void);
92int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con); 92int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con);
93void cpm_uart_freebuf(struct uart_cpm_port *pinfo); 93void cpm_uart_freebuf(struct uart_cpm_port *pinfo);
94 94
diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c
index 0abb544ae63d..7a3b97fdf8d1 100644
--- a/drivers/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/serial/cpm_uart/cpm_uart_core.c
@@ -195,10 +195,8 @@ static void cpm_uart_start_tx(struct uart_port *port)
195 if (cpm_uart_tx_pump(port) != 0) { 195 if (cpm_uart_tx_pump(port) != 0) {
196 if (IS_SMC(pinfo)) { 196 if (IS_SMC(pinfo)) {
197 smcp->smc_smcm |= SMCM_TX; 197 smcp->smc_smcm |= SMCM_TX;
198 smcp->smc_smcmr |= SMCMR_TEN;
199 } else { 198 } else {
200 sccp->scc_sccm |= UART_SCCM_TX; 199 sccp->scc_sccm |= UART_SCCM_TX;
201 pinfo->sccp->scc_gsmrl |= SCC_GSMRL_ENT;
202 } 200 }
203 } 201 }
204} 202}
@@ -421,9 +419,10 @@ static int cpm_uart_startup(struct uart_port *port)
421 /* Startup rx-int */ 419 /* Startup rx-int */
422 if (IS_SMC(pinfo)) { 420 if (IS_SMC(pinfo)) {
423 pinfo->smcp->smc_smcm |= SMCM_RX; 421 pinfo->smcp->smc_smcm |= SMCM_RX;
424 pinfo->smcp->smc_smcmr |= SMCMR_REN; 422 pinfo->smcp->smc_smcmr |= (SMCMR_REN | SMCMR_TEN);
425 } else { 423 } else {
426 pinfo->sccp->scc_sccm |= UART_SCCM_RX; 424 pinfo->sccp->scc_sccm |= UART_SCCM_RX;
425 pinfo->sccp->scc_gsmrl |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT);
427 } 426 }
428 427
429 if (!(pinfo->flags & FLAG_CONSOLE)) 428 if (!(pinfo->flags & FLAG_CONSOLE))
@@ -1350,11 +1349,10 @@ static int cpm_uart_init(void) {
1350 pr_info("cpm_uart: WARNING: no UART devices found on platform bus!\n"); 1349 pr_info("cpm_uart: WARNING: no UART devices found on platform bus!\n");
1351 pr_info( 1350 pr_info(
1352 "cpm_uart: the driver will guess configuration, but this mode is no longer supported.\n"); 1351 "cpm_uart: the driver will guess configuration, but this mode is no longer supported.\n");
1353#ifndef CONFIG_SERIAL_CPM_CONSOLE 1352
1354 ret = cpm_uart_init_portdesc(); 1353 /* Don't run this again, if the console driver did it already */
1355 if (ret) 1354 if (cpm_uart_nr == 0)
1356 return ret; 1355 cpm_uart_init_portdesc();
1357#endif
1358 1356
1359 cpm_reg.nr = cpm_uart_nr; 1357 cpm_reg.nr = cpm_uart_nr;
1360 ret = uart_register_driver(&cpm_reg); 1358 ret = uart_register_driver(&cpm_reg);
@@ -1366,6 +1364,8 @@ static int cpm_uart_init(void) {
1366 int con = cpm_uart_port_map[i]; 1364 int con = cpm_uart_port_map[i];
1367 cpm_uart_ports[con].port.line = i; 1365 cpm_uart_ports[con].port.line = i;
1368 cpm_uart_ports[con].port.flags = UPF_BOOT_AUTOCONF; 1366 cpm_uart_ports[con].port.flags = UPF_BOOT_AUTOCONF;
1367 if (cpm_uart_ports[con].set_lineif)
1368 cpm_uart_ports[con].set_lineif(&cpm_uart_ports[con]);
1369 uart_add_one_port(&cpm_reg, &cpm_uart_ports[con].port); 1369 uart_add_one_port(&cpm_reg, &cpm_uart_ports[con].port);
1370 } 1370 }
1371 1371
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm1.c b/drivers/serial/cpm_uart/cpm_uart_cpm1.c
index 95afc37297a8..08e55fdc882a 100644
--- a/drivers/serial/cpm_uart/cpm_uart_cpm1.c
+++ b/drivers/serial/cpm_uart/cpm_uart_cpm1.c
@@ -184,7 +184,7 @@ void cpm_uart_freebuf(struct uart_cpm_port *pinfo)
184} 184}
185 185
186/* Setup any dynamic params in the uart desc */ 186/* Setup any dynamic params in the uart desc */
187int cpm_uart_init_portdesc(void) 187int __init cpm_uart_init_portdesc(void)
188{ 188{
189 pr_debug("CPM uart[-]:init portdesc\n"); 189 pr_debug("CPM uart[-]:init portdesc\n");
190 190
diff --git a/drivers/serial/ioc4_serial.c b/drivers/serial/ioc4_serial.c
index 98ce88d80207..711bd1511439 100644
--- a/drivers/serial/ioc4_serial.c
+++ b/drivers/serial/ioc4_serial.c
@@ -921,7 +921,7 @@ static void handle_dma_error_intr(void *arg, uint32_t other_ir)
921{ 921{
922 struct ioc4_port *port = (struct ioc4_port *)arg; 922 struct ioc4_port *port = (struct ioc4_port *)arg;
923 struct hooks *hooks = port->ip_hooks; 923 struct hooks *hooks = port->ip_hooks;
924 unsigned int flags; 924 unsigned long flags;
925 925
926 spin_lock_irqsave(&port->ip_lock, flags); 926 spin_lock_irqsave(&port->ip_lock, flags);
927 927
@@ -1834,7 +1834,7 @@ static void handle_intr(void *arg, uint32_t sio_ir)
1834 struct ioc4_port *port = (struct ioc4_port *)arg; 1834 struct ioc4_port *port = (struct ioc4_port *)arg;
1835 struct hooks *hooks = port->ip_hooks; 1835 struct hooks *hooks = port->ip_hooks;
1836 unsigned int rx_high_rd_aborted = 0; 1836 unsigned int rx_high_rd_aborted = 0;
1837 unsigned int flags; 1837 unsigned long flags;
1838 struct uart_port *the_port; 1838 struct uart_port *the_port;
1839 int loop_counter; 1839 int loop_counter;
1840 1840
@@ -2935,7 +2935,7 @@ static void __devexit ioc4_serial_exit(void)
2935 uart_unregister_driver(&ioc4_uart_rs422); 2935 uart_unregister_driver(&ioc4_uart_rs422);
2936} 2936}
2937 2937
2938module_init(ioc4_serial_init); 2938late_initcall(ioc4_serial_init); /* Call only after tty init is done */
2939module_exit(ioc4_serial_exit); 2939module_exit(ioc4_serial_exit);
2940 2940
2941MODULE_AUTHOR("Pat Gefre - Silicon Graphics Inc. (SGI) <pfg@sgi.com>"); 2941MODULE_AUTHOR("Pat Gefre - Silicon Graphics Inc. (SGI) <pfg@sgi.com>");
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index 266aa325569e..cfcc3caf49d8 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -808,7 +808,7 @@ static int sci_request_irq(struct sci_port *port)
808 } 808 }
809 809
810 if (request_irq(port->irqs[0], sci_mpxed_interrupt, 810 if (request_irq(port->irqs[0], sci_mpxed_interrupt,
811 SA_INTERRUPT, "sci", port)) { 811 IRQF_DISABLED, "sci", port)) {
812 printk(KERN_ERR "sci: Cannot allocate irq.\n"); 812 printk(KERN_ERR "sci: Cannot allocate irq.\n");
813 return -ENODEV; 813 return -ENODEV;
814 } 814 }
@@ -817,7 +817,7 @@ static int sci_request_irq(struct sci_port *port)
817 if (!port->irqs[i]) 817 if (!port->irqs[i])
818 continue; 818 continue;
819 if (request_irq(port->irqs[i], handlers[i], 819 if (request_irq(port->irqs[i], handlers[i],
820 SA_INTERRUPT, desc[i], port)) { 820 IRQF_DISABLED, desc[i], port)) {
821 printk(KERN_ERR "sci: Cannot allocate irq.\n"); 821 printk(KERN_ERR "sci: Cannot allocate irq.\n");
822 return -ENODEV; 822 return -ENODEV;
823 } 823 }
diff --git a/drivers/serial/sunzilog.c b/drivers/serial/sunzilog.c
index 73dd2eedaaad..b2cc703b2b9e 100644
--- a/drivers/serial/sunzilog.c
+++ b/drivers/serial/sunzilog.c
@@ -1182,7 +1182,7 @@ static int __init sunzilog_console_setup(struct console *con, char *options)
1182 return 0; 1182 return 0;
1183} 1183}
1184 1184
1185static struct console sunzilog_console = { 1185static struct console sunzilog_console_ops = {
1186 .name = "ttyS", 1186 .name = "ttyS",
1187 .write = sunzilog_console_write, 1187 .write = sunzilog_console_write,
1188 .device = uart_console_device, 1188 .device = uart_console_device,
@@ -1208,10 +1208,10 @@ static inline struct console *SUNZILOG_CONSOLE(void)
1208 if (i == NUM_CHANNELS) 1208 if (i == NUM_CHANNELS)
1209 return NULL; 1209 return NULL;
1210 1210
1211 sunzilog_console.index = i; 1211 sunzilog_console_ops.index = i;
1212 sunzilog_port_table[i].flags |= SUNZILOG_FLAG_IS_CONS; 1212 sunzilog_port_table[i].flags |= SUNZILOG_FLAG_IS_CONS;
1213 1213
1214 return &sunzilog_console; 1214 return &sunzilog_console_ops;
1215} 1215}
1216 1216
1217#else 1217#else
diff --git a/drivers/sn/Kconfig b/drivers/sn/Kconfig
index a34731625877..c66ba9ad833d 100644
--- a/drivers/sn/Kconfig
+++ b/drivers/sn/Kconfig
@@ -5,19 +5,6 @@
5menu "SN Devices" 5menu "SN Devices"
6 depends on SGI_SN 6 depends on SGI_SN
7 7
8config SGI_IOC4
9 tristate "SGI IOC4 Base IO support"
10 depends on MMTIMER
11 default m
12 ---help---
13 This option enables basic support for the SGI IOC4-based Base IO
14 controller card. This option does not enable any specific
15 functions on such a card, but provides necessary infrastructure
16 for other drivers to utilize.
17
18 If you have an SGI Altix with an IOC4-based
19 I/O controller say Y. Otherwise say N.
20
21config SGI_IOC3 8config SGI_IOC3
22 tristate "SGI IOC3 Base IO support" 9 tristate "SGI IOC3 Base IO support"
23 default m 10 default m
diff --git a/drivers/sn/Makefile b/drivers/sn/Makefile
index 2cda011597c0..693db8bb8d9c 100644
--- a/drivers/sn/Makefile
+++ b/drivers/sn/Makefile
@@ -3,5 +3,4 @@
3# 3#
4# 4#
5 5
6obj-$(CONFIG_SGI_IOC4) += ioc4.o
7obj-$(CONFIG_SGI_IOC3) += ioc3.o 6obj-$(CONFIG_SGI_IOC3) += ioc3.o
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 146298ad7371..c3c0626f550b 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -281,7 +281,6 @@ spi_register_board_info(struct spi_board_info const *info, unsigned n)
281 up(&board_lock); 281 up(&board_lock);
282 return 0; 282 return 0;
283} 283}
284EXPORT_SYMBOL_GPL(spi_register_board_info);
285 284
286/* FIXME someone should add support for a __setup("spi", ...) that 285/* FIXME someone should add support for a __setup("spi", ...) that
287 * creates board info from kernel command lines 286 * creates board info from kernel command lines
diff --git a/drivers/telephony/ixj.c b/drivers/telephony/ixj.c
index f6b2948ab288..1b601b6cf2a2 100644
--- a/drivers/telephony/ixj.c
+++ b/drivers/telephony/ixj.c
@@ -284,6 +284,14 @@ static int samplerate = 100;
284 284
285module_param(ixjdebug, int, 0); 285module_param(ixjdebug, int, 0);
286 286
287static struct pci_device_id ixj_pci_tbl[] __devinitdata = {
288 { PCI_VENDOR_ID_QUICKNET, PCI_DEVICE_ID_QUICKNET_XJ,
289 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
290 { }
291};
292
293MODULE_DEVICE_TABLE(pci, ixj_pci_tbl);
294
287/************************************************************************ 295/************************************************************************
288* 296*
289* ixjdebug meanings are now bit mapped instead of level based 297* ixjdebug meanings are now bit mapped instead of level based
@@ -7683,7 +7691,8 @@ static int __init ixj_probe_pci(int *cnt)
7683 IXJ *j = NULL; 7691 IXJ *j = NULL;
7684 7692
7685 for (i = 0; i < IXJMAX - *cnt; i++) { 7693 for (i = 0; i < IXJMAX - *cnt; i++) {
7686 pci = pci_find_device(0x15E2, 0x0500, pci); 7694 pci = pci_find_device(PCI_VENDOR_ID_QUICKNET,
7695 PCI_DEVICE_ID_QUICKNET_XJ, pci);
7687 if (!pci) 7696 if (!pci)
7688 break; 7697 break;
7689 7698
diff --git a/drivers/telephony/ixj.h b/drivers/telephony/ixj.h
index fbea4541c234..8d69bcdc29c9 100644
--- a/drivers/telephony/ixj.h
+++ b/drivers/telephony/ixj.h
@@ -1295,7 +1295,7 @@ typedef struct {
1295 Proc_Info_Type Info_write; 1295 Proc_Info_Type Info_write;
1296 unsigned short frame_count; 1296 unsigned short frame_count;
1297 unsigned int filter_hist[4]; 1297 unsigned int filter_hist[4];
1298 unsigned char filter_en[4]; 1298 unsigned char filter_en[6];
1299 unsigned short proc_load; 1299 unsigned short proc_load;
1300 unsigned long framesread; 1300 unsigned long framesread;
1301 unsigned long frameswritten; 1301 unsigned long frameswritten;
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index 97d57cfc343b..825bf884537a 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -33,7 +33,6 @@ obj-$(CONFIG_USB_KBTAB) += input/
33obj-$(CONFIG_USB_MOUSE) += input/ 33obj-$(CONFIG_USB_MOUSE) += input/
34obj-$(CONFIG_USB_MTOUCH) += input/ 34obj-$(CONFIG_USB_MTOUCH) += input/
35obj-$(CONFIG_USB_POWERMATE) += input/ 35obj-$(CONFIG_USB_POWERMATE) += input/
36obj-$(CONFIG_USB_TRANCEVIBRATOR)+= input/
37obj-$(CONFIG_USB_WACOM) += input/ 36obj-$(CONFIG_USB_WACOM) += input/
38obj-$(CONFIG_USB_XPAD) += input/ 37obj-$(CONFIG_USB_XPAD) += input/
39 38
@@ -66,6 +65,7 @@ obj-$(CONFIG_USB_PHIDGETSERVO) += misc/
66obj-$(CONFIG_USB_RIO500) += misc/ 65obj-$(CONFIG_USB_RIO500) += misc/
67obj-$(CONFIG_USB_SISUSBVGA) += misc/ 66obj-$(CONFIG_USB_SISUSBVGA) += misc/
68obj-$(CONFIG_USB_TEST) += misc/ 67obj-$(CONFIG_USB_TEST) += misc/
68obj-$(CONFIG_USB_TRANCEVIBRATOR)+= misc/
69obj-$(CONFIG_USB_USS720) += misc/ 69obj-$(CONFIG_USB_USS720) += misc/
70 70
71obj-$(CONFIG_USB_ATM) += atm/ 71obj-$(CONFIG_USB_ATM) += atm/
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index 3892a9e9aee3..e6565633ba0f 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -793,6 +793,9 @@ static const struct usb_device_id cxacru_usb_ids[] = {
793 { /* V = Conexant P = ADSL modem */ 793 { /* V = Conexant P = ADSL modem */
794 USB_DEVICE(0x0572, 0xcb06), .driver_info = (unsigned long) &cxacru_cb00 794 USB_DEVICE(0x0572, 0xcb06), .driver_info = (unsigned long) &cxacru_cb00
795 }, 795 },
796 { /* V = Conexant P = ADSL modem (ZTE ZXDSL 852) */
797 USB_DEVICE(0x0572, 0xcb07), .driver_info = (unsigned long) &cxacru_cb00
798 },
796 { /* V = Olitec P = ADSL modem version 2 */ 799 { /* V = Olitec P = ADSL modem version 2 */
797 USB_DEVICE(0x08e3, 0x0100), .driver_info = (unsigned long) &cxacru_cafe 800 USB_DEVICE(0x08e3, 0x0100), .driver_info = (unsigned long) &cxacru_cafe
798 }, 801 },
diff --git a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c
index 7c7b507af29d..c870c804470f 100644
--- a/drivers/usb/atm/speedtch.c
+++ b/drivers/usb/atm/speedtch.c
@@ -55,7 +55,6 @@ static const char speedtch_driver_name[] = "speedtch";
55#define OFFSET_d 9 /* size 4 */ 55#define OFFSET_d 9 /* size 4 */
56#define OFFSET_e 13 /* size 1 */ 56#define OFFSET_e 13 /* size 1 */
57#define OFFSET_f 14 /* size 1 */ 57#define OFFSET_f 14 /* size 1 */
58#define TOTAL 15
59 58
60#define SIZE_7 1 59#define SIZE_7 1
61#define SIZE_b 8 60#define SIZE_b 8
@@ -79,6 +78,18 @@ static int dl_512_first = DEFAULT_DL_512_FIRST;
79static int enable_isoc = DEFAULT_ENABLE_ISOC; 78static int enable_isoc = DEFAULT_ENABLE_ISOC;
80static int sw_buffering = DEFAULT_SW_BUFFERING; 79static int sw_buffering = DEFAULT_SW_BUFFERING;
81 80
81#define DEFAULT_B_MAX_DSL 8128
82#define DEFAULT_MODEM_MODE 11
83#define MODEM_OPTION_LENGTH 16
84static const unsigned char DEFAULT_MODEM_OPTION[MODEM_OPTION_LENGTH] = {
85 0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
86};
87
88static unsigned int BMaxDSL = DEFAULT_B_MAX_DSL;
89static unsigned char ModemMode = DEFAULT_MODEM_MODE;
90static unsigned char ModemOption[MODEM_OPTION_LENGTH];
91static int num_ModemOption;
92
82module_param(altsetting, uint, S_IRUGO | S_IWUSR); 93module_param(altsetting, uint, S_IRUGO | S_IWUSR);
83MODULE_PARM_DESC(altsetting, 94MODULE_PARM_DESC(altsetting,
84 "Alternative setting for data interface (bulk_default: " 95 "Alternative setting for data interface (bulk_default: "
@@ -100,6 +111,17 @@ MODULE_PARM_DESC(sw_buffering,
100 "Enable software buffering (default: " 111 "Enable software buffering (default: "
101 __MODULE_STRING(DEFAULT_SW_BUFFERING) ")"); 112 __MODULE_STRING(DEFAULT_SW_BUFFERING) ")");
102 113
114module_param(BMaxDSL, uint, S_IRUGO | S_IWUSR);
115MODULE_PARM_DESC(BMaxDSL,
116 "default: " __MODULE_STRING(DEFAULT_B_MAX_DSL));
117
118module_param(ModemMode, byte, S_IRUGO | S_IWUSR);
119MODULE_PARM_DESC(ModemMode,
120 "default: " __MODULE_STRING(DEFAULT_MODEM_MODE));
121
122module_param_array(ModemOption, byte, &num_ModemOption, S_IRUGO);
123MODULE_PARM_DESC(ModemOption, "default: 0x10,0x00,0x00,0x00,0x20");
124
103#define INTERFACE_DATA 1 125#define INTERFACE_DATA 1
104#define ENDPOINT_INT 0x81 126#define ENDPOINT_INT 0x81
105#define ENDPOINT_BULK_DATA 0x07 127#define ENDPOINT_BULK_DATA 0x07
@@ -108,10 +130,17 @@ MODULE_PARM_DESC(sw_buffering,
108 130
109#define hex2int(c) ( (c >= '0') && (c <= '9') ? (c - '0') : ((c & 0xf) + 9) ) 131#define hex2int(c) ( (c >= '0') && (c <= '9') ? (c - '0') : ((c & 0xf) + 9) )
110 132
133struct speedtch_params {
134 unsigned int altsetting;
135 unsigned int BMaxDSL;
136 unsigned char ModemMode;
137 unsigned char ModemOption[MODEM_OPTION_LENGTH];
138};
139
111struct speedtch_instance_data { 140struct speedtch_instance_data {
112 struct usbatm_data *usbatm; 141 struct usbatm_data *usbatm;
113 142
114 unsigned int altsetting; 143 struct speedtch_params params; /* set in probe, constant afterwards */
115 144
116 struct work_struct status_checker; 145 struct work_struct status_checker;
117 146
@@ -123,7 +152,7 @@ struct speedtch_instance_data {
123 struct urb *int_urb; 152 struct urb *int_urb;
124 unsigned char int_data[16]; 153 unsigned char int_data[16];
125 154
126 unsigned char scratch_buffer[TOTAL]; 155 unsigned char scratch_buffer[16];
127}; 156};
128 157
129/*************** 158/***************
@@ -186,6 +215,34 @@ static void speedtch_test_sequence(struct speedtch_instance_data *instance)
186 0x01, 0x40, 0x04, 0x00, buf, 3, CTRL_TIMEOUT); 215 0x01, 0x40, 0x04, 0x00, buf, 3, CTRL_TIMEOUT);
187 if (ret < 0) 216 if (ret < 0)
188 usb_warn(usbatm, "%s failed on URB150: %d\n", __func__, ret); 217 usb_warn(usbatm, "%s failed on URB150: %d\n", __func__, ret);
218
219 /* Extra initialisation in recent drivers - gives higher speeds */
220
221 /* URBext1 */
222 buf[0] = instance->params.ModemMode;
223 ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
224 0x01, 0x40, 0x11, 0x00, buf, 1, CTRL_TIMEOUT);
225 if (ret < 0)
226 usb_warn(usbatm, "%s failed on URBext1: %d\n", __func__, ret);
227
228 /* URBext2 */
229 /* This seems to be the one which actually triggers the higher sync
230 rate -- it does require the new firmware too, although it works OK
231 with older firmware */
232 ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
233 0x01, 0x40, 0x14, 0x00,
234 instance->params.ModemOption,
235 MODEM_OPTION_LENGTH, CTRL_TIMEOUT);
236 if (ret < 0)
237 usb_warn(usbatm, "%s failed on URBext2: %d\n", __func__, ret);
238
239 /* URBext3 */
240 buf[0] = instance->params.BMaxDSL & 0xff;
241 buf[1] = instance->params.BMaxDSL >> 8;
242 ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
243 0x01, 0x40, 0x12, 0x00, buf, 2, CTRL_TIMEOUT);
244 if (ret < 0)
245 usb_warn(usbatm, "%s failed on URBext3: %d\n", __func__, ret);
189} 246}
190 247
191static int speedtch_upload_firmware(struct speedtch_instance_data *instance, 248static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
@@ -285,8 +342,8 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
285 because we're in our own kernel thread anyway. */ 342 because we're in our own kernel thread anyway. */
286 msleep_interruptible(1000); 343 msleep_interruptible(1000);
287 344
288 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, instance->altsetting)) < 0) { 345 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, instance->params.altsetting)) < 0) {
289 usb_err(usbatm, "%s: setting interface to %d failed (%d)!\n", __func__, instance->altsetting, ret); 346 usb_err(usbatm, "%s: setting interface to %d failed (%d)!\n", __func__, instance->params.altsetting, ret);
290 goto out_free; 347 goto out_free;
291 } 348 }
292 349
@@ -372,7 +429,7 @@ static int speedtch_read_status(struct speedtch_instance_data *instance)
372 unsigned char *buf = instance->scratch_buffer; 429 unsigned char *buf = instance->scratch_buffer;
373 int ret; 430 int ret;
374 431
375 memset(buf, 0, TOTAL); 432 memset(buf, 0, 16);
376 433
377 ret = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0), 434 ret = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0),
378 0x12, 0xc0, 0x07, 0x00, buf + OFFSET_7, SIZE_7, 435 0x12, 0xc0, 0x07, 0x00, buf + OFFSET_7, SIZE_7,
@@ -746,17 +803,21 @@ static int speedtch_bind(struct usbatm_data *usbatm,
746 803
747 instance->usbatm = usbatm; 804 instance->usbatm = usbatm;
748 805
749 /* altsetting and enable_isoc may change at any moment, so take a snapshot */ 806 /* module parameters may change at any moment, so take a snapshot */
750 instance->altsetting = altsetting; 807 instance->params.altsetting = altsetting;
808 instance->params.BMaxDSL = BMaxDSL;
809 instance->params.ModemMode = ModemMode;
810 memcpy(instance->params.ModemOption, DEFAULT_MODEM_OPTION, MODEM_OPTION_LENGTH);
811 memcpy(instance->params.ModemOption, ModemOption, num_ModemOption);
751 use_isoc = enable_isoc; 812 use_isoc = enable_isoc;
752 813
753 if (instance->altsetting) 814 if (instance->params.altsetting)
754 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, instance->altsetting)) < 0) { 815 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, instance->params.altsetting)) < 0) {
755 usb_err(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, instance->altsetting, ret); 816 usb_err(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, instance->params.altsetting, ret);
756 instance->altsetting = 0; /* fall back to default */ 817 instance->params.altsetting = 0; /* fall back to default */
757 } 818 }
758 819
759 if (!instance->altsetting && use_isoc) 820 if (!instance->params.altsetting && use_isoc)
760 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, DEFAULT_ISOC_ALTSETTING)) < 0) { 821 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, DEFAULT_ISOC_ALTSETTING)) < 0) {
761 usb_dbg(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, DEFAULT_ISOC_ALTSETTING, ret); 822 usb_dbg(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, DEFAULT_ISOC_ALTSETTING, ret);
762 use_isoc = 0; /* fall back to bulk */ 823 use_isoc = 0; /* fall back to bulk */
@@ -783,14 +844,14 @@ static int speedtch_bind(struct usbatm_data *usbatm,
783 usb_info(usbatm, "isochronous transfer not supported - using bulk\n"); 844 usb_info(usbatm, "isochronous transfer not supported - using bulk\n");
784 } 845 }
785 846
786 if (!use_isoc && !instance->altsetting) 847 if (!use_isoc && !instance->params.altsetting)
787 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, DEFAULT_BULK_ALTSETTING)) < 0) { 848 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, DEFAULT_BULK_ALTSETTING)) < 0) {
788 usb_err(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, DEFAULT_BULK_ALTSETTING, ret); 849 usb_err(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, DEFAULT_BULK_ALTSETTING, ret);
789 goto fail_free; 850 goto fail_free;
790 } 851 }
791 852
792 if (!instance->altsetting) 853 if (!instance->params.altsetting)
793 instance->altsetting = use_isoc ? DEFAULT_ISOC_ALTSETTING : DEFAULT_BULK_ALTSETTING; 854 instance->params.altsetting = use_isoc ? DEFAULT_ISOC_ALTSETTING : DEFAULT_BULK_ALTSETTING;
794 855
795 usbatm->flags |= (use_isoc ? UDSL_USE_ISOC : 0); 856 usbatm->flags |= (use_isoc ? UDSL_USE_ISOC : 0);
796 857
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index f5434b1cbb1e..f6b9f7e1f716 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -68,7 +68,7 @@
68 68
69#include "usbatm.h" 69#include "usbatm.h"
70 70
71#define EAGLEUSBVERSION "ueagle 1.3" 71#define EAGLEUSBVERSION "ueagle 1.4"
72 72
73 73
74/* 74/*
@@ -80,14 +80,14 @@
80 dev_dbg(&(usb_dev)->dev, \ 80 dev_dbg(&(usb_dev)->dev, \
81 "[ueagle-atm dbg] %s: " format, \ 81 "[ueagle-atm dbg] %s: " format, \
82 __FUNCTION__, ##args); \ 82 __FUNCTION__, ##args); \
83 } while (0) 83 } while (0)
84 84
85#define uea_vdbg(usb_dev, format, args...) \ 85#define uea_vdbg(usb_dev, format, args...) \
86 do { \ 86 do { \
87 if (debug >= 2) \ 87 if (debug >= 2) \
88 dev_dbg(&(usb_dev)->dev, \ 88 dev_dbg(&(usb_dev)->dev, \
89 "[ueagle-atm vdbg] " format, ##args); \ 89 "[ueagle-atm vdbg] " format, ##args); \
90 } while (0) 90 } while (0)
91 91
92#define uea_enters(usb_dev) \ 92#define uea_enters(usb_dev) \
93 uea_vdbg(usb_dev, "entering %s\n", __FUNCTION__) 93 uea_vdbg(usb_dev, "entering %s\n", __FUNCTION__)
@@ -218,8 +218,8 @@ enum {
218#define UEA_CHIP_VERSION(x) \ 218#define UEA_CHIP_VERSION(x) \
219 ((x)->driver_info & 0xf) 219 ((x)->driver_info & 0xf)
220 220
221#define IS_ISDN(sc) \ 221#define IS_ISDN(usb_dev) \
222 (le16_to_cpu(sc->usb_dev->descriptor.bcdDevice) & 0x80) 222 (le16_to_cpu((usb_dev)->descriptor.bcdDevice) & 0x80)
223 223
224#define INS_TO_USBDEV(ins) ins->usb_dev 224#define INS_TO_USBDEV(ins) ins->usb_dev
225 225
@@ -625,12 +625,12 @@ static int request_dsp(struct uea_softc *sc)
625 char *dsp_name; 625 char *dsp_name;
626 626
627 if (UEA_CHIP_VERSION(sc) == ADI930) { 627 if (UEA_CHIP_VERSION(sc) == ADI930) {
628 if (IS_ISDN(sc)) 628 if (IS_ISDN(sc->usb_dev))
629 dsp_name = FW_DIR "DSP9i.bin"; 629 dsp_name = FW_DIR "DSP9i.bin";
630 else 630 else
631 dsp_name = FW_DIR "DSP9p.bin"; 631 dsp_name = FW_DIR "DSP9p.bin";
632 } else { 632 } else {
633 if (IS_ISDN(sc)) 633 if (IS_ISDN(sc->usb_dev))
634 dsp_name = FW_DIR "DSPei.bin"; 634 dsp_name = FW_DIR "DSPei.bin";
635 else 635 else
636 dsp_name = FW_DIR "DSPep.bin"; 636 dsp_name = FW_DIR "DSPep.bin";
@@ -744,7 +744,7 @@ static inline void wake_up_cmv_ack(struct uea_softc *sc)
744 744
745static inline int wait_cmv_ack(struct uea_softc *sc) 745static inline int wait_cmv_ack(struct uea_softc *sc)
746{ 746{
747 int ret = wait_event_timeout(sc->cmv_ack_wait, 747 int ret = wait_event_interruptible_timeout(sc->cmv_ack_wait,
748 sc->cmv_ack, ACK_TIMEOUT); 748 sc->cmv_ack, ACK_TIMEOUT);
749 sc->cmv_ack = 0; 749 sc->cmv_ack = 0;
750 750
@@ -885,7 +885,8 @@ static int uea_stat(struct uea_softc *sc)
885 break; 885 break;
886 886
887 case 3: /* fail ... */ 887 case 3: /* fail ... */
888 uea_info(INS_TO_USBDEV(sc), "modem synchronization failed\n"); 888 uea_info(INS_TO_USBDEV(sc), "modem synchronization failed"
889 " (may be try other cmv/dsp)\n");
889 return -EAGAIN; 890 return -EAGAIN;
890 891
891 case 4 ... 6: /* test state */ 892 case 4 ... 6: /* test state */
@@ -913,12 +914,6 @@ static int uea_stat(struct uea_softc *sc)
913 release_firmware(sc->dsp_firm); 914 release_firmware(sc->dsp_firm);
914 sc->dsp_firm = NULL; 915 sc->dsp_firm = NULL;
915 } 916 }
916
917 ret = uea_read_cmv(sc, SA_INFO, 10, &sc->stats.phy.firmid);
918 if (ret < 0)
919 return ret;
920 uea_info(INS_TO_USBDEV(sc), "ATU-R firmware version : %x\n",
921 sc->stats.phy.firmid);
922 } 917 }
923 918
924 /* always update it as atm layer could not be init when we switch to 919 /* always update it as atm layer could not be init when we switch to
@@ -1033,9 +1028,9 @@ static int request_cmvs(struct uea_softc *sc,
1033 1028
1034 if (cmv_file[sc->modem_index] == NULL) { 1029 if (cmv_file[sc->modem_index] == NULL) {
1035 if (UEA_CHIP_VERSION(sc) == ADI930) 1030 if (UEA_CHIP_VERSION(sc) == ADI930)
1036 file = (IS_ISDN(sc)) ? "CMV9i.bin" : "CMV9p.bin"; 1031 file = (IS_ISDN(sc->usb_dev)) ? "CMV9i.bin" : "CMV9p.bin";
1037 else 1032 else
1038 file = (IS_ISDN(sc)) ? "CMVei.bin" : "CMVep.bin"; 1033 file = (IS_ISDN(sc->usb_dev)) ? "CMVei.bin" : "CMVep.bin";
1039 } else 1034 } else
1040 file = cmv_file[sc->modem_index]; 1035 file = cmv_file[sc->modem_index];
1041 1036
@@ -1131,6 +1126,13 @@ static int uea_start_reset(struct uea_softc *sc)
1131 if (ret < 0) 1126 if (ret < 0)
1132 return ret; 1127 return ret;
1133 1128
1129 /* Dump firmware version */
1130 ret = uea_read_cmv(sc, SA_INFO, 10, &sc->stats.phy.firmid);
1131 if (ret < 0)
1132 return ret;
1133 uea_info(INS_TO_USBDEV(sc), "ATU-R firmware version : %x\n",
1134 sc->stats.phy.firmid);
1135
1134 /* get options */ 1136 /* get options */
1135 ret = len = request_cmvs(sc, &cmvs, &cmvs_fw); 1137 ret = len = request_cmvs(sc, &cmvs, &cmvs_fw);
1136 if (ret < 0) 1138 if (ret < 0)
@@ -1147,6 +1149,8 @@ static int uea_start_reset(struct uea_softc *sc)
1147 /* Enter in R-ACT-REQ */ 1149 /* Enter in R-ACT-REQ */
1148 ret = uea_write_cmv(sc, SA_CNTL, 0, 2); 1150 ret = uea_write_cmv(sc, SA_CNTL, 0, 2);
1149 uea_vdbg(INS_TO_USBDEV(sc), "Entering in R-ACT-REQ state\n"); 1151 uea_vdbg(INS_TO_USBDEV(sc), "Entering in R-ACT-REQ state\n");
1152 uea_info(INS_TO_USBDEV(sc), "Modem started, "
1153 "waiting synchronization\n");
1150out: 1154out:
1151 release_firmware(cmvs_fw); 1155 release_firmware(cmvs_fw);
1152 sc->reset = 0; 1156 sc->reset = 0;
@@ -1172,7 +1176,10 @@ static int uea_kthread(void *data)
1172 if (!ret) 1176 if (!ret)
1173 ret = uea_stat(sc); 1177 ret = uea_stat(sc);
1174 if (ret != -EAGAIN) 1178 if (ret != -EAGAIN)
1175 msleep(1000); 1179 msleep_interruptible(1000);
1180 if (try_to_freeze())
1181 uea_err(INS_TO_USBDEV(sc), "suspend/resume not supported, "
1182 "please unplug/replug your modem\n");
1176 } 1183 }
1177 uea_leaves(INS_TO_USBDEV(sc)); 1184 uea_leaves(INS_TO_USBDEV(sc));
1178 return ret; 1185 return ret;
@@ -1566,6 +1573,7 @@ UEA_ATTR(uscorr, 0);
1566UEA_ATTR(dscorr, 0); 1573UEA_ATTR(dscorr, 0);
1567UEA_ATTR(usunc, 0); 1574UEA_ATTR(usunc, 0);
1568UEA_ATTR(dsunc, 0); 1575UEA_ATTR(dsunc, 0);
1576UEA_ATTR(firmid, 0);
1569 1577
1570/* Retrieve the device End System Identifier (MAC) */ 1578/* Retrieve the device End System Identifier (MAC) */
1571 1579
@@ -1597,7 +1605,7 @@ static int uea_heavy(struct usbatm_data *usbatm, struct usb_interface *intf)
1597{ 1605{
1598 struct uea_softc *sc = usbatm->driver_data; 1606 struct uea_softc *sc = usbatm->driver_data;
1599 1607
1600 wait_event(sc->sync_q, IS_OPERATIONAL(sc)); 1608 wait_event_interruptible(sc->sync_q, IS_OPERATIONAL(sc));
1601 1609
1602 return 0; 1610 return 0;
1603 1611
@@ -1639,16 +1647,13 @@ static struct attribute *attrs[] = {
1639 &dev_attr_stat_dscorr.attr, 1647 &dev_attr_stat_dscorr.attr,
1640 &dev_attr_stat_usunc.attr, 1648 &dev_attr_stat_usunc.attr,
1641 &dev_attr_stat_dsunc.attr, 1649 &dev_attr_stat_dsunc.attr,
1650 &dev_attr_stat_firmid.attr,
1651 NULL,
1642}; 1652};
1643static struct attribute_group attr_grp = { 1653static struct attribute_group attr_grp = {
1644 .attrs = attrs, 1654 .attrs = attrs,
1645}; 1655};
1646 1656
1647static int create_fs_entries(struct usb_interface *intf)
1648{
1649 return sysfs_create_group(&intf->dev.kobj, &attr_grp);
1650}
1651
1652static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf, 1657static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf,
1653 const struct usb_device_id *id) 1658 const struct usb_device_id *id)
1654{ 1659{
@@ -1708,31 +1713,25 @@ static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf,
1708 } 1713 }
1709 } 1714 }
1710 1715
1716 ret = sysfs_create_group(&intf->dev.kobj, &attr_grp);
1717 if (ret < 0)
1718 goto error;
1719
1711 ret = uea_boot(sc); 1720 ret = uea_boot(sc);
1712 if (ret < 0) { 1721 if (ret < 0)
1713 kfree(sc); 1722 goto error;
1714 return ret;
1715 }
1716 1723
1717 ret = create_fs_entries(intf);
1718 if (ret) {
1719 uea_stop(sc);
1720 kfree(sc);
1721 return ret;
1722 }
1723 return 0; 1724 return 0;
1724} 1725error:
1725 1726 kfree(sc);
1726static void destroy_fs_entries(struct usb_interface *intf) 1727 return ret;
1727{
1728 sysfs_remove_group(&intf->dev.kobj, &attr_grp);
1729} 1728}
1730 1729
1731static void uea_unbind(struct usbatm_data *usbatm, struct usb_interface *intf) 1730static void uea_unbind(struct usbatm_data *usbatm, struct usb_interface *intf)
1732{ 1731{
1733 struct uea_softc *sc = usbatm->driver_data; 1732 struct uea_softc *sc = usbatm->driver_data;
1734 1733
1735 destroy_fs_entries(intf); 1734 sysfs_remove_group(&intf->dev.kobj, &attr_grp);
1736 uea_stop(sc); 1735 uea_stop(sc);
1737 kfree(sc); 1736 kfree(sc);
1738} 1737}
@@ -1753,10 +1752,10 @@ static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id)
1753 struct usb_device *usb = interface_to_usbdev(intf); 1752 struct usb_device *usb = interface_to_usbdev(intf);
1754 1753
1755 uea_enters(usb); 1754 uea_enters(usb);
1756 uea_info(usb, "ADSL device founded vid (%#X) pid (%#X) : %s\n", 1755 uea_info(usb, "ADSL device founded vid (%#X) pid (%#X) : %s %s\n",
1757 le16_to_cpu(usb->descriptor.idVendor), 1756 le16_to_cpu(usb->descriptor.idVendor),
1758 le16_to_cpu(usb->descriptor.idProduct), 1757 le16_to_cpu(usb->descriptor.idProduct),
1759 chip_name[UEA_CHIP_VERSION(id)]); 1758 chip_name[UEA_CHIP_VERSION(id)], IS_ISDN(usb)?"isdn":"pots");
1760 1759
1761 usb_reset_device(usb); 1760 usb_reset_device(usb);
1762 1761
diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
index 309073f6433a..ec63b0ee0743 100644
--- a/drivers/usb/atm/usbatm.c
+++ b/drivers/usb/atm/usbatm.c
@@ -1001,6 +1001,7 @@ static int usbatm_do_heavy_init(void *arg)
1001 1001
1002 daemonize(instance->driver->driver_name); 1002 daemonize(instance->driver->driver_name);
1003 allow_signal(SIGTERM); 1003 allow_signal(SIGTERM);
1004 instance->thread_pid = current->pid;
1004 1005
1005 complete(&instance->thread_started); 1006 complete(&instance->thread_started);
1006 1007
@@ -1025,10 +1026,6 @@ static int usbatm_heavy_init(struct usbatm_data *instance)
1025 return ret; 1026 return ret;
1026 } 1027 }
1027 1028
1028 mutex_lock(&instance->serialize);
1029 instance->thread_pid = ret;
1030 mutex_unlock(&instance->serialize);
1031
1032 wait_for_completion(&instance->thread_started); 1029 wait_for_completion(&instance->thread_started);
1033 1030
1034 return 0; 1031 return 0;
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index ec4d1d756725..9a9012fd284b 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -325,7 +325,7 @@ static void acm_rx_tasklet(unsigned long _acm)
325 struct acm_rb *buf; 325 struct acm_rb *buf;
326 struct tty_struct *tty = acm->tty; 326 struct tty_struct *tty = acm->tty;
327 struct acm_ru *rcv; 327 struct acm_ru *rcv;
328 //unsigned long flags; 328 unsigned long flags;
329 int i = 0; 329 int i = 0;
330 dbg("Entering acm_rx_tasklet"); 330 dbg("Entering acm_rx_tasklet");
331 331
@@ -333,15 +333,15 @@ static void acm_rx_tasklet(unsigned long _acm)
333 return; 333 return;
334 334
335next_buffer: 335next_buffer:
336 spin_lock(&acm->read_lock); 336 spin_lock_irqsave(&acm->read_lock, flags);
337 if (list_empty(&acm->filled_read_bufs)) { 337 if (list_empty(&acm->filled_read_bufs)) {
338 spin_unlock(&acm->read_lock); 338 spin_unlock_irqrestore(&acm->read_lock, flags);
339 goto urbs; 339 goto urbs;
340 } 340 }
341 buf = list_entry(acm->filled_read_bufs.next, 341 buf = list_entry(acm->filled_read_bufs.next,
342 struct acm_rb, list); 342 struct acm_rb, list);
343 list_del(&buf->list); 343 list_del(&buf->list);
344 spin_unlock(&acm->read_lock); 344 spin_unlock_irqrestore(&acm->read_lock, flags);
345 345
346 dbg("acm_rx_tasklet: procesing buf 0x%p, size = %d", buf, buf->size); 346 dbg("acm_rx_tasklet: procesing buf 0x%p, size = %d", buf, buf->size);
347 347
@@ -356,29 +356,29 @@ next_buffer:
356 memmove(buf->base, buf->base + i, buf->size - i); 356 memmove(buf->base, buf->base + i, buf->size - i);
357 buf->size -= i; 357 buf->size -= i;
358 spin_unlock(&acm->throttle_lock); 358 spin_unlock(&acm->throttle_lock);
359 spin_lock(&acm->read_lock); 359 spin_lock_irqsave(&acm->read_lock, flags);
360 list_add(&buf->list, &acm->filled_read_bufs); 360 list_add(&buf->list, &acm->filled_read_bufs);
361 spin_unlock(&acm->read_lock); 361 spin_unlock_irqrestore(&acm->read_lock, flags);
362 return; 362 return;
363 } 363 }
364 spin_unlock(&acm->throttle_lock); 364 spin_unlock(&acm->throttle_lock);
365 365
366 spin_lock(&acm->read_lock); 366 spin_lock_irqsave(&acm->read_lock, flags);
367 list_add(&buf->list, &acm->spare_read_bufs); 367 list_add(&buf->list, &acm->spare_read_bufs);
368 spin_unlock(&acm->read_lock); 368 spin_unlock_irqrestore(&acm->read_lock, flags);
369 goto next_buffer; 369 goto next_buffer;
370 370
371urbs: 371urbs:
372 while (!list_empty(&acm->spare_read_bufs)) { 372 while (!list_empty(&acm->spare_read_bufs)) {
373 spin_lock(&acm->read_lock); 373 spin_lock_irqsave(&acm->read_lock, flags);
374 if (list_empty(&acm->spare_read_urbs)) { 374 if (list_empty(&acm->spare_read_urbs)) {
375 spin_unlock(&acm->read_lock); 375 spin_unlock_irqrestore(&acm->read_lock, flags);
376 return; 376 return;
377 } 377 }
378 rcv = list_entry(acm->spare_read_urbs.next, 378 rcv = list_entry(acm->spare_read_urbs.next,
379 struct acm_ru, list); 379 struct acm_ru, list);
380 list_del(&rcv->list); 380 list_del(&rcv->list);
381 spin_unlock(&acm->read_lock); 381 spin_unlock_irqrestore(&acm->read_lock, flags);
382 382
383 buf = list_entry(acm->spare_read_bufs.next, 383 buf = list_entry(acm->spare_read_bufs.next,
384 struct acm_rb, list); 384 struct acm_rb, list);
@@ -400,9 +400,9 @@ urbs:
400 free-urbs-pool and resubmited ASAP */ 400 free-urbs-pool and resubmited ASAP */
401 if (usb_submit_urb(rcv->urb, GFP_ATOMIC) < 0) { 401 if (usb_submit_urb(rcv->urb, GFP_ATOMIC) < 0) {
402 list_add(&buf->list, &acm->spare_read_bufs); 402 list_add(&buf->list, &acm->spare_read_bufs);
403 spin_lock(&acm->read_lock); 403 spin_lock_irqsave(&acm->read_lock, flags);
404 list_add(&rcv->list, &acm->spare_read_urbs); 404 list_add(&rcv->list, &acm->spare_read_urbs);
405 spin_unlock(&acm->read_lock); 405 spin_unlock_irqrestore(&acm->read_lock, flags);
406 return; 406 return;
407 } 407 }
408 } 408 }
@@ -1083,6 +1083,9 @@ static struct usb_device_id acm_ids[] = {
1083 { USB_DEVICE(0x0482, 0x0203), /* KYOCERA AH-K3001V */ 1083 { USB_DEVICE(0x0482, 0x0203), /* KYOCERA AH-K3001V */
1084 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ 1084 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1085 }, 1085 },
1086 { USB_DEVICE(0x079b, 0x000f), /* BT On-Air USB MODEM */
1087 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1088 },
1086 { USB_DEVICE(0x0ace, 0x1608), /* ZyDAS 56K USB MODEM */ 1089 { USB_DEVICE(0x0ace, 0x1608), /* ZyDAS 56K USB MODEM */
1087 .driver_info = SINGLE_RX_URB, /* firmware bug */ 1090 .driver_info = SINGLE_RX_URB, /* firmware bug */
1088 }, 1091 },
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index a161d70e1e42..6303970e93c1 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -154,6 +154,7 @@ struct usblp {
154 unsigned char used; /* True if open */ 154 unsigned char used; /* True if open */
155 unsigned char present; /* True if not disconnected */ 155 unsigned char present; /* True if not disconnected */
156 unsigned char bidir; /* interface is bidirectional */ 156 unsigned char bidir; /* interface is bidirectional */
157 unsigned char sleeping; /* interface is suspended */
157 unsigned char *device_id_string; /* IEEE 1284 DEVICE ID string (ptr) */ 158 unsigned char *device_id_string; /* IEEE 1284 DEVICE ID string (ptr) */
158 /* first 2 bytes are (big-endian) length */ 159 /* first 2 bytes are (big-endian) length */
159}; 160};
@@ -183,6 +184,7 @@ static void usblp_dump(struct usblp *usblp) {
183 dbg("quirks=%d", usblp->quirks); 184 dbg("quirks=%d", usblp->quirks);
184 dbg("used=%d", usblp->used); 185 dbg("used=%d", usblp->used);
185 dbg("bidir=%d", usblp->bidir); 186 dbg("bidir=%d", usblp->bidir);
187 dbg("sleeping=%d", usblp->sleeping);
186 dbg("device_id_string=\"%s\"", 188 dbg("device_id_string=\"%s\"",
187 usblp->device_id_string ? 189 usblp->device_id_string ?
188 usblp->device_id_string + 2 : 190 usblp->device_id_string + 2 :
@@ -338,6 +340,20 @@ static int usblp_check_status(struct usblp *usblp, int err)
338 return newerr; 340 return newerr;
339} 341}
340 342
343static int handle_bidir (struct usblp *usblp)
344{
345 if (usblp->bidir && usblp->used && !usblp->sleeping) {
346 usblp->readcount = 0;
347 usblp->readurb->dev = usblp->dev;
348 if (usb_submit_urb(usblp->readurb, GFP_KERNEL) < 0) {
349 usblp->used = 0;
350 return -EIO;
351 }
352 }
353
354 return 0;
355}
356
341/* 357/*
342 * File op functions. 358 * File op functions.
343 */ 359 */
@@ -390,14 +406,9 @@ static int usblp_open(struct inode *inode, struct file *file)
390 usblp->writeurb->status = 0; 406 usblp->writeurb->status = 0;
391 usblp->readurb->status = 0; 407 usblp->readurb->status = 0;
392 408
393 if (usblp->bidir) { 409 if (handle_bidir(usblp) < 0) {
394 usblp->readcount = 0; 410 file->private_data = NULL;
395 usblp->readurb->dev = usblp->dev; 411 retval = -EIO;
396 if (usb_submit_urb(usblp->readurb, GFP_KERNEL) < 0) {
397 retval = -EIO;
398 usblp->used = 0;
399 file->private_data = NULL;
400 }
401 } 412 }
402out: 413out:
403 mutex_unlock (&usblp_mutex); 414 mutex_unlock (&usblp_mutex);
@@ -460,6 +471,11 @@ static long usblp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
460 goto done; 471 goto done;
461 } 472 }
462 473
474 if (usblp->sleeping) {
475 retval = -ENODEV;
476 goto done;
477 }
478
463 dbg("usblp_ioctl: cmd=0x%x (%c nr=%d len=%d dir=%d)", cmd, _IOC_TYPE(cmd), 479 dbg("usblp_ioctl: cmd=0x%x (%c nr=%d len=%d dir=%d)", cmd, _IOC_TYPE(cmd),
464 _IOC_NR(cmd), _IOC_SIZE(cmd), _IOC_DIR(cmd) ); 480 _IOC_NR(cmd), _IOC_SIZE(cmd), _IOC_DIR(cmd) );
465 481
@@ -658,6 +674,11 @@ static ssize_t usblp_write(struct file *file, const char __user *buffer, size_t
658 return -ENODEV; 674 return -ENODEV;
659 } 675 }
660 676
677 if (usblp->sleeping) {
678 up (&usblp->sem);
679 return writecount ? writecount : -ENODEV;
680 }
681
661 if (usblp->writeurb->status != 0) { 682 if (usblp->writeurb->status != 0) {
662 if (usblp->quirks & USBLP_QUIRK_BIDIR) { 683 if (usblp->quirks & USBLP_QUIRK_BIDIR) {
663 if (!usblp->wcomplete) 684 if (!usblp->wcomplete)
@@ -701,6 +722,7 @@ static ssize_t usblp_write(struct file *file, const char __user *buffer, size_t
701 usblp->wcomplete = 0; 722 usblp->wcomplete = 0;
702 err = usb_submit_urb(usblp->writeurb, GFP_KERNEL); 723 err = usb_submit_urb(usblp->writeurb, GFP_KERNEL);
703 if (err) { 724 if (err) {
725 usblp->wcomplete = 1;
704 if (err != -ENOMEM) 726 if (err != -ENOMEM)
705 count = -EIO; 727 count = -EIO;
706 else 728 else
@@ -749,6 +771,11 @@ static ssize_t usblp_read(struct file *file, char __user *buffer, size_t count,
749 goto done; 771 goto done;
750 } 772 }
751 773
774 if (usblp->sleeping) {
775 count = -ENODEV;
776 goto done;
777 }
778
752 if (usblp->readurb->status) { 779 if (usblp->readurb->status) {
753 err("usblp%d: error %d reading from printer", 780 err("usblp%d: error %d reading from printer",
754 usblp->minor, usblp->readurb->status); 781 usblp->minor, usblp->readurb->status);
@@ -1167,6 +1194,39 @@ static void usblp_disconnect(struct usb_interface *intf)
1167 mutex_unlock (&usblp_mutex); 1194 mutex_unlock (&usblp_mutex);
1168} 1195}
1169 1196
1197static int usblp_suspend (struct usb_interface *intf, pm_message_t message)
1198{
1199 struct usblp *usblp = usb_get_intfdata (intf);
1200
1201 /* this races against normal access and open */
1202 mutex_lock (&usblp_mutex);
1203 down (&usblp->sem);
1204 /* we take no more IO */
1205 usblp->sleeping = 1;
1206 usblp_unlink_urbs(usblp);
1207 up (&usblp->sem);
1208 mutex_unlock (&usblp_mutex);
1209
1210 return 0;
1211}
1212
1213static int usblp_resume (struct usb_interface *intf)
1214{
1215 struct usblp *usblp = usb_get_intfdata (intf);
1216 int r;
1217
1218 mutex_lock (&usblp_mutex);
1219 down (&usblp->sem);
1220
1221 usblp->sleeping = 0;
1222 r = handle_bidir (usblp);
1223
1224 up (&usblp->sem);
1225 mutex_unlock (&usblp_mutex);
1226
1227 return r;
1228}
1229
1170static struct usb_device_id usblp_ids [] = { 1230static struct usb_device_id usblp_ids [] = {
1171 { USB_DEVICE_INFO(7, 1, 1) }, 1231 { USB_DEVICE_INFO(7, 1, 1) },
1172 { USB_DEVICE_INFO(7, 1, 2) }, 1232 { USB_DEVICE_INFO(7, 1, 2) },
@@ -1183,6 +1243,8 @@ static struct usb_driver usblp_driver = {
1183 .name = "usblp", 1243 .name = "usblp",
1184 .probe = usblp_probe, 1244 .probe = usblp_probe,
1185 .disconnect = usblp_disconnect, 1245 .disconnect = usblp_disconnect,
1246 .suspend = usblp_suspend,
1247 .resume = usblp_resume,
1186 .id_table = usblp_ids, 1248 .id_table = usblp_ids,
1187}; 1249};
1188 1250
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 724822cac2b1..fed92be63b5e 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1588,15 +1588,18 @@ const struct file_operations usbfs_device_file_operations = {
1588 .release = usbdev_release, 1588 .release = usbdev_release,
1589}; 1589};
1590 1590
1591static void usbdev_add(struct usb_device *dev) 1591static int usbdev_add(struct usb_device *dev)
1592{ 1592{
1593 int minor = ((dev->bus->busnum-1) * 128) + (dev->devnum-1); 1593 int minor = ((dev->bus->busnum-1) * 128) + (dev->devnum-1);
1594 1594
1595 dev->class_dev = class_device_create(usb_device_class, NULL, 1595 dev->class_dev = class_device_create(usb_device_class, NULL,
1596 MKDEV(USB_DEVICE_MAJOR, minor), &dev->dev, 1596 MKDEV(USB_DEVICE_MAJOR, minor), &dev->dev,
1597 "usbdev%d.%d", dev->bus->busnum, dev->devnum); 1597 "usbdev%d.%d", dev->bus->busnum, dev->devnum);
1598 if (IS_ERR(dev->class_dev))
1599 return PTR_ERR(dev->class_dev);
1598 1600
1599 dev->class_dev->class_data = dev; 1601 dev->class_dev->class_data = dev;
1602 return 0;
1600} 1603}
1601 1604
1602static void usbdev_remove(struct usb_device *dev) 1605static void usbdev_remove(struct usb_device *dev)
@@ -1609,7 +1612,8 @@ static int usbdev_notify(struct notifier_block *self, unsigned long action,
1609{ 1612{
1610 switch (action) { 1613 switch (action) {
1611 case USB_DEVICE_ADD: 1614 case USB_DEVICE_ADD:
1612 usbdev_add(dev); 1615 if (usbdev_add(dev))
1616 return NOTIFY_BAD;
1613 break; 1617 break;
1614 case USB_DEVICE_REMOVE: 1618 case USB_DEVICE_REMOVE:
1615 usbdev_remove(dev); 1619 usbdev_remove(dev);
diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c
index 3ebb90149e93..3b2d137912be 100644
--- a/drivers/usb/core/endpoint.c
+++ b/drivers/usb/core/endpoint.c
@@ -223,7 +223,7 @@ int usb_create_ep_files(struct device *parent,
223 ep_dev = kzalloc(sizeof(*ep_dev), GFP_KERNEL); 223 ep_dev = kzalloc(sizeof(*ep_dev), GFP_KERNEL);
224 if (!ep_dev) { 224 if (!ep_dev) {
225 retval = -ENOMEM; 225 retval = -ENOMEM;
226 goto exit; 226 goto error_alloc;
227 } 227 }
228 228
229 /* fun calculation to determine the minor of this endpoint */ 229 /* fun calculation to determine the minor of this endpoint */
@@ -241,33 +241,31 @@ int usb_create_ep_files(struct device *parent,
241 241
242 retval = device_register(&ep_dev->dev); 242 retval = device_register(&ep_dev->dev);
243 if (retval) 243 if (retval)
244 goto error; 244 goto error_register;
245 retval = sysfs_create_group(&ep_dev->dev.kobj, &ep_dev_attr_grp); 245 retval = sysfs_create_group(&ep_dev->dev.kobj, &ep_dev_attr_grp);
246 if (retval) 246 if (retval)
247 goto error_group; 247 goto error_group;
248 248
249 endpoint->ep_dev = ep_dev;
250
251 /* create the symlink to the old-style "ep_XX" directory */ 249 /* create the symlink to the old-style "ep_XX" directory */
252 sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress); 250 sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress);
253 retval = sysfs_create_link(&parent->kobj, 251 retval = sysfs_create_link(&parent->kobj, &ep_dev->dev.kobj, name);
254 &endpoint->ep_dev->dev.kobj, name);
255 if (retval) 252 if (retval)
256 goto error_link; 253 goto error_link;
257exit: 254 endpoint->ep_dev = ep_dev;
258 return retval; 255 return retval;
259 256
260error_link: 257error_link:
261 sysfs_remove_group(&ep_dev->dev.kobj, &ep_dev_attr_grp); 258 sysfs_remove_group(&ep_dev->dev.kobj, &ep_dev_attr_grp);
262
263error_group: 259error_group:
264 device_unregister(&ep_dev->dev); 260 device_unregister(&ep_dev->dev);
265 endpoint->ep_dev = NULL;
266 destroy_endpoint_class(); 261 destroy_endpoint_class();
267 return retval; 262 return retval;
268error: 263
264error_register:
269 kfree(ep_dev); 265 kfree(ep_dev);
266error_alloc:
270 destroy_endpoint_class(); 267 destroy_endpoint_class();
268exit:
271 return retval; 269 return retval;
272} 270}
273 271
@@ -282,8 +280,6 @@ void usb_remove_ep_files(struct usb_host_endpoint *endpoint)
282 sysfs_remove_group(&endpoint->ep_dev->dev.kobj, &ep_dev_attr_grp); 280 sysfs_remove_group(&endpoint->ep_dev->dev.kobj, &ep_dev_attr_grp);
283 device_unregister(&endpoint->ep_dev->dev); 281 device_unregister(&endpoint->ep_dev->dev);
284 endpoint->ep_dev = NULL; 282 endpoint->ep_dev = NULL;
283 destroy_endpoint_class();
285 } 284 }
286 destroy_endpoint_class();
287} 285}
288
289
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 66bff184a30c..ba165aff9ea4 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1188,6 +1188,7 @@ static inline void show_string(struct usb_device *udev, char *id, char *string)
1188 1188
1189#ifdef CONFIG_USB_OTG 1189#ifdef CONFIG_USB_OTG
1190#include "otg_whitelist.h" 1190#include "otg_whitelist.h"
1191static int __usb_port_suspend(struct usb_device *, int port1);
1191#endif 1192#endif
1192 1193
1193/** 1194/**
@@ -1289,8 +1290,6 @@ int usb_new_device(struct usb_device *udev)
1289 * (Includes HNP test device.) 1290 * (Includes HNP test device.)
1290 */ 1291 */
1291 if (udev->bus->b_hnp_enable || udev->bus->is_b_host) { 1292 if (udev->bus->b_hnp_enable || udev->bus->is_b_host) {
1292 static int __usb_port_suspend(struct usb_device *,
1293 int port1);
1294 err = __usb_port_suspend(udev, udev->bus->otg_port); 1293 err = __usb_port_suspend(udev, udev->bus->otg_port);
1295 if (err < 0) 1294 if (err < 0)
1296 dev_dbg(&udev->dev, "HNP fail, %d\n", err); 1295 dev_dbg(&udev->dev, "HNP fail, %d\n", err);
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index fccd1952bad3..7729c0744886 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -828,10 +828,7 @@ char *usb_cache_string(struct usb_device *udev, int index)
828 * Context: !in_interrupt () 828 * Context: !in_interrupt ()
829 * 829 *
830 * Updates the copy of the device descriptor stored in the device structure, 830 * Updates the copy of the device descriptor stored in the device structure,
831 * which dedicates space for this purpose. Note that several fields are 831 * which dedicates space for this purpose.
832 * converted to the host CPU's byte order: the USB version (bcdUSB), and
833 * vendors product and version fields (idVendor, idProduct, and bcdDevice).
834 * That lets device drivers compare against non-byteswapped constants.
835 * 832 *
836 * Not exported, only for use by the core. If drivers really want to read 833 * Not exported, only for use by the core. If drivers really want to read
837 * the device descriptor directly, they can call usb_get_descriptor() with 834 * the device descriptor directly, they can call usb_get_descriptor() with
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index d954daa8e9e0..3acc896a5d4c 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -1774,8 +1774,8 @@ static DEVICE_ATTR (queues, S_IRUGO, show_queues, NULL);
1774 1774
1775#else 1775#else
1776 1776
1777#define device_create_file(a,b) do {} while (0) 1777#define device_create_file(a,b) (0)
1778#define device_remove_file device_create_file 1778#define device_remove_file(a,b) do { } while (0)
1779 1779
1780#endif 1780#endif
1781 1781
@@ -2044,8 +2044,10 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
2044 return retval; 2044 return retval;
2045 } 2045 }
2046 2046
2047 device_create_file (&dev->pdev->dev, &dev_attr_function); 2047 retval = device_create_file (&dev->pdev->dev, &dev_attr_function);
2048 device_create_file (&dev->pdev->dev, &dev_attr_queues); 2048 if (retval) goto err_unbind;
2049 retval = device_create_file (&dev->pdev->dev, &dev_attr_queues);
2050 if (retval) goto err_func;
2049 2051
2050 /* ... then enable host detection and ep0; and we're ready 2052 /* ... then enable host detection and ep0; and we're ready
2051 * for set_configuration as well as eventual disconnect. 2053 * for set_configuration as well as eventual disconnect.
@@ -2060,6 +2062,14 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
2060 2062
2061 /* pci writes may still be posted */ 2063 /* pci writes may still be posted */
2062 return 0; 2064 return 0;
2065
2066err_func:
2067 device_remove_file (&dev->pdev->dev, &dev_attr_function);
2068err_unbind:
2069 driver->unbind (&dev->gadget);
2070 dev->gadget.dev.driver = NULL;
2071 dev->driver = NULL;
2072 return retval;
2063} 2073}
2064EXPORT_SYMBOL (usb_gadget_register_driver); 2074EXPORT_SYMBOL (usb_gadget_register_driver);
2065 2075
@@ -2974,8 +2984,10 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
2974 : "disabled"); 2984 : "disabled");
2975 the_controller = dev; 2985 the_controller = dev;
2976 2986
2977 device_register (&dev->gadget.dev); 2987 retval = device_register (&dev->gadget.dev);
2978 device_create_file (&pdev->dev, &dev_attr_registers); 2988 if (retval) goto done;
2989 retval = device_create_file (&pdev->dev, &dev_attr_registers);
2990 if (retval) goto done;
2979 2991
2980 return 0; 2992 return 0;
2981 2993
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c
index f42c00ef0bca..671c24bc6d75 100644
--- a/drivers/usb/gadget/pxa2xx_udc.c
+++ b/drivers/usb/gadget/pxa2xx_udc.c
@@ -43,11 +43,11 @@
43#include <linux/mm.h> 43#include <linux/mm.h>
44#include <linux/platform_device.h> 44#include <linux/platform_device.h>
45#include <linux/dma-mapping.h> 45#include <linux/dma-mapping.h>
46#include <linux/irq.h>
46 47
47#include <asm/byteorder.h> 48#include <asm/byteorder.h>
48#include <asm/dma.h> 49#include <asm/dma.h>
49#include <asm/io.h> 50#include <asm/io.h>
50#include <asm/irq.h>
51#include <asm/system.h> 51#include <asm/system.h>
52#include <asm/mach-types.h> 52#include <asm/mach-types.h>
53#include <asm/unaligned.h> 53#include <asm/unaligned.h>
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index 23b95b2bfe15..34b7a31cd85b 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -754,7 +754,9 @@ show_registers (struct class_device *class_dev, char *buf)
754 } 754 }
755 755
756 if (ehci->reclaim) { 756 if (ehci->reclaim) {
757 temp = scnprintf (next, size, "reclaim qh %p\n", ehci->reclaim); 757 temp = scnprintf (next, size, "reclaim qh %p%s\n",
758 ehci->reclaim,
759 ehci->reclaim_ready ? " ready" : "");
758 size -= temp; 760 size -= temp;
759 next += temp; 761 next += temp;
760 } 762 }
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index aac6ec5dd7cf..9030994aba98 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -111,7 +111,7 @@ static const char hcd_name [] = "ehci_hcd";
111#define EHCI_TUNE_MULT_TT 1 111#define EHCI_TUNE_MULT_TT 1
112#define EHCI_TUNE_FLS 2 /* (small) 256 frame schedule */ 112#define EHCI_TUNE_FLS 2 /* (small) 256 frame schedule */
113 113
114#define EHCI_IAA_MSECS 10 /* arbitrary */ 114#define EHCI_IAA_JIFFIES (HZ/100) /* arbitrary; ~10 msec */
115#define EHCI_IO_JIFFIES (HZ/10) /* io watchdog > irq_thresh */ 115#define EHCI_IO_JIFFIES (HZ/10) /* io watchdog > irq_thresh */
116#define EHCI_ASYNC_JIFFIES (HZ/20) /* async idle timeout */ 116#define EHCI_ASYNC_JIFFIES (HZ/20) /* async idle timeout */
117#define EHCI_SHRINK_JIFFIES (HZ/200) /* async qh unlink delay */ 117#define EHCI_SHRINK_JIFFIES (HZ/200) /* async qh unlink delay */
@@ -254,7 +254,6 @@ static void ehci_quiesce (struct ehci_hcd *ehci)
254 254
255/*-------------------------------------------------------------------------*/ 255/*-------------------------------------------------------------------------*/
256 256
257static void end_unlink_async (struct ehci_hcd *ehci);
258static void ehci_work(struct ehci_hcd *ehci); 257static void ehci_work(struct ehci_hcd *ehci);
259 258
260#include "ehci-hub.c" 259#include "ehci-hub.c"
@@ -264,37 +263,25 @@ static void ehci_work(struct ehci_hcd *ehci);
264 263
265/*-------------------------------------------------------------------------*/ 264/*-------------------------------------------------------------------------*/
266 265
267static void ehci_iaa_watchdog (unsigned long param) 266static void ehci_watchdog (unsigned long param)
268{ 267{
269 struct ehci_hcd *ehci = (struct ehci_hcd *) param; 268 struct ehci_hcd *ehci = (struct ehci_hcd *) param;
270 unsigned long flags; 269 unsigned long flags;
271 u32 status;
272 270
273 spin_lock_irqsave (&ehci->lock, flags); 271 spin_lock_irqsave (&ehci->lock, flags);
274 WARN_ON(!ehci->reclaim);
275 272
276 /* lost IAA irqs wedge things badly; seen first with a vt8235 */ 273 /* lost IAA irqs wedge things badly; seen with a vt8235 */
277 if (ehci->reclaim) { 274 if (ehci->reclaim) {
278 status = readl (&ehci->regs->status); 275 u32 status = readl (&ehci->regs->status);
279 if (status & STS_IAA) { 276 if (status & STS_IAA) {
280 ehci_vdbg (ehci, "lost IAA\n"); 277 ehci_vdbg (ehci, "lost IAA\n");
281 COUNT (ehci->stats.lost_iaa); 278 COUNT (ehci->stats.lost_iaa);
282 writel (STS_IAA, &ehci->regs->status); 279 writel (STS_IAA, &ehci->regs->status);
283 end_unlink_async (ehci); 280 ehci->reclaim_ready = 1;
284 } 281 }
285 } 282 }
286 283
287 spin_unlock_irqrestore (&ehci->lock, flags); 284 /* stop async processing after it's idled a bit */
288}
289
290static void ehci_watchdog (unsigned long param)
291{
292 struct ehci_hcd *ehci = (struct ehci_hcd *) param;
293 unsigned long flags;
294
295 spin_lock_irqsave (&ehci->lock, flags);
296
297 /* stop async processing after it's idled a bit */
298 if (test_bit (TIMER_ASYNC_OFF, &ehci->actions)) 285 if (test_bit (TIMER_ASYNC_OFF, &ehci->actions))
299 start_unlink_async (ehci, ehci->async); 286 start_unlink_async (ehci, ehci->async);
300 287
@@ -345,6 +332,8 @@ static void ehci_port_power (struct ehci_hcd *ehci, int is_on)
345static void ehci_work (struct ehci_hcd *ehci) 332static void ehci_work (struct ehci_hcd *ehci)
346{ 333{
347 timer_action_done (ehci, TIMER_IO_WATCHDOG); 334 timer_action_done (ehci, TIMER_IO_WATCHDOG);
335 if (ehci->reclaim_ready)
336 end_unlink_async (ehci);
348 337
349 /* another CPU may drop ehci->lock during a schedule scan while 338 /* another CPU may drop ehci->lock during a schedule scan while
350 * it reports urb completions. this flag guards against bogus 339 * it reports urb completions. this flag guards against bogus
@@ -379,7 +368,6 @@ static void ehci_stop (struct usb_hcd *hcd)
379 368
380 /* no more interrupts ... */ 369 /* no more interrupts ... */
381 del_timer_sync (&ehci->watchdog); 370 del_timer_sync (&ehci->watchdog);
382 del_timer_sync (&ehci->iaa_watchdog);
383 371
384 spin_lock_irq(&ehci->lock); 372 spin_lock_irq(&ehci->lock);
385 if (HC_IS_RUNNING (hcd->state)) 373 if (HC_IS_RUNNING (hcd->state))
@@ -426,10 +414,6 @@ static int ehci_init(struct usb_hcd *hcd)
426 ehci->watchdog.function = ehci_watchdog; 414 ehci->watchdog.function = ehci_watchdog;
427 ehci->watchdog.data = (unsigned long) ehci; 415 ehci->watchdog.data = (unsigned long) ehci;
428 416
429 init_timer(&ehci->iaa_watchdog);
430 ehci->iaa_watchdog.function = ehci_iaa_watchdog;
431 ehci->iaa_watchdog.data = (unsigned long) ehci;
432
433 /* 417 /*
434 * hw default: 1K periodic list heads, one per frame. 418 * hw default: 1K periodic list heads, one per frame.
435 * periodic_size can shrink by USBCMD update if hcc_params allows. 419 * periodic_size can shrink by USBCMD update if hcc_params allows.
@@ -446,6 +430,7 @@ static int ehci_init(struct usb_hcd *hcd)
446 ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params); 430 ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params);
447 431
448 ehci->reclaim = NULL; 432 ehci->reclaim = NULL;
433 ehci->reclaim_ready = 0;
449 ehci->next_uframe = -1; 434 ehci->next_uframe = -1;
450 435
451 /* 436 /*
@@ -619,7 +604,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
619 /* complete the unlinking of some qh [4.15.2.3] */ 604 /* complete the unlinking of some qh [4.15.2.3] */
620 if (status & STS_IAA) { 605 if (status & STS_IAA) {
621 COUNT (ehci->stats.reclaim); 606 COUNT (ehci->stats.reclaim);
622 end_unlink_async (ehci); 607 ehci->reclaim_ready = 1;
623 bh = 1; 608 bh = 1;
624 } 609 }
625 610
@@ -723,14 +708,10 @@ static int ehci_urb_enqueue (
723 708
724static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh) 709static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
725{ 710{
726 // BUG_ON(qh->qh_state != QH_STATE_LINKED); 711 /* if we need to use IAA and it's busy, defer */
727 712 if (qh->qh_state == QH_STATE_LINKED
728 /* failfast */ 713 && ehci->reclaim
729 if (!HC_IS_RUNNING (ehci_to_hcd(ehci)->state)) 714 && HC_IS_RUNNING (ehci_to_hcd(ehci)->state)) {
730 end_unlink_async (ehci);
731
732 /* defer till later if busy */
733 else if (ehci->reclaim) {
734 struct ehci_qh *last; 715 struct ehci_qh *last;
735 716
736 for (last = ehci->reclaim; 717 for (last = ehci->reclaim;
@@ -740,8 +721,12 @@ static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
740 qh->qh_state = QH_STATE_UNLINK_WAIT; 721 qh->qh_state = QH_STATE_UNLINK_WAIT;
741 last->reclaim = qh; 722 last->reclaim = qh;
742 723
743 /* start IAA cycle */ 724 /* bypass IAA if the hc can't care */
744 } else 725 } else if (!HC_IS_RUNNING (ehci_to_hcd(ehci)->state) && ehci->reclaim)
726 end_unlink_async (ehci);
727
728 /* something else might have unlinked the qh by now */
729 if (qh->qh_state == QH_STATE_LINKED)
745 start_unlink_async (ehci, qh); 730 start_unlink_async (ehci, qh);
746} 731}
747 732
@@ -763,19 +748,7 @@ static int ehci_urb_dequeue (struct usb_hcd *hcd, struct urb *urb)
763 qh = (struct ehci_qh *) urb->hcpriv; 748 qh = (struct ehci_qh *) urb->hcpriv;
764 if (!qh) 749 if (!qh)
765 break; 750 break;
766 switch (qh->qh_state) { 751 unlink_async (ehci, qh);
767 case QH_STATE_LINKED:
768 case QH_STATE_COMPLETING:
769 unlink_async (ehci, qh);
770 break;
771 case QH_STATE_UNLINK:
772 case QH_STATE_UNLINK_WAIT:
773 /* already started */
774 break;
775 case QH_STATE_IDLE:
776 WARN_ON(1);
777 break;
778 }
779 break; 752 break;
780 753
781 case PIPE_INTERRUPT: 754 case PIPE_INTERRUPT:
@@ -867,7 +840,6 @@ rescan:
867 unlink_async (ehci, qh); 840 unlink_async (ehci, qh);
868 /* FALL THROUGH */ 841 /* FALL THROUGH */
869 case QH_STATE_UNLINK: /* wait for hw to finish? */ 842 case QH_STATE_UNLINK: /* wait for hw to finish? */
870 case QH_STATE_UNLINK_WAIT:
871idle_timeout: 843idle_timeout:
872 spin_unlock_irqrestore (&ehci->lock, flags); 844 spin_unlock_irqrestore (&ehci->lock, flags);
873 schedule_timeout_uninterruptible(1); 845 schedule_timeout_uninterruptible(1);
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 2012213c0a25..1b20722c102b 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -48,7 +48,7 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
48 } 48 }
49 ehci->command = readl (&ehci->regs->command); 49 ehci->command = readl (&ehci->regs->command);
50 if (ehci->reclaim) 50 if (ehci->reclaim)
51 end_unlink_async (ehci); 51 ehci->reclaim_ready = 1;
52 ehci_work(ehci); 52 ehci_work(ehci);
53 53
54 /* suspend any active/unsuspended ports, maybe allow wakeup */ 54 /* suspend any active/unsuspended ports, maybe allow wakeup */
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 35e3fab6fc4e..e51c1ed81ac4 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -303,7 +303,7 @@ restart:
303 /* emptying the schedule aborts any urbs */ 303 /* emptying the schedule aborts any urbs */
304 spin_lock_irq(&ehci->lock); 304 spin_lock_irq(&ehci->lock);
305 if (ehci->reclaim) 305 if (ehci->reclaim)
306 end_unlink_async (ehci); 306 ehci->reclaim_ready = 1;
307 ehci_work(ehci); 307 ehci_work(ehci);
308 spin_unlock_irq(&ehci->lock); 308 spin_unlock_irq(&ehci->lock);
309 309
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index 46327272f614..62e46dc60e86 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -967,7 +967,7 @@ static void end_unlink_async (struct ehci_hcd *ehci)
967 struct ehci_qh *qh = ehci->reclaim; 967 struct ehci_qh *qh = ehci->reclaim;
968 struct ehci_qh *next; 968 struct ehci_qh *next;
969 969
970 iaa_watchdog_done (ehci); 970 timer_action_done (ehci, TIMER_IAA_WATCHDOG);
971 971
972 // qh->hw_next = cpu_to_le32 (qh->qh_dma); 972 // qh->hw_next = cpu_to_le32 (qh->qh_dma);
973 qh->qh_state = QH_STATE_IDLE; 973 qh->qh_state = QH_STATE_IDLE;
@@ -977,6 +977,7 @@ static void end_unlink_async (struct ehci_hcd *ehci)
977 /* other unlink(s) may be pending (in QH_STATE_UNLINK_WAIT) */ 977 /* other unlink(s) may be pending (in QH_STATE_UNLINK_WAIT) */
978 next = qh->reclaim; 978 next = qh->reclaim;
979 ehci->reclaim = next; 979 ehci->reclaim = next;
980 ehci->reclaim_ready = 0;
980 qh->reclaim = NULL; 981 qh->reclaim = NULL;
981 982
982 qh_completions (ehci, qh); 983 qh_completions (ehci, qh);
@@ -1051,10 +1052,11 @@ static void start_unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
1051 return; 1052 return;
1052 } 1053 }
1053 1054
1055 ehci->reclaim_ready = 0;
1054 cmd |= CMD_IAAD; 1056 cmd |= CMD_IAAD;
1055 writel (cmd, &ehci->regs->command); 1057 writel (cmd, &ehci->regs->command);
1056 (void) readl (&ehci->regs->command); 1058 (void) readl (&ehci->regs->command);
1057 iaa_watchdog_start (ehci); 1059 timer_action (ehci, TIMER_IAA_WATCHDOG);
1058} 1060}
1059 1061
1060/*-------------------------------------------------------------------------*/ 1062/*-------------------------------------------------------------------------*/
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index 6aac39f50e07..bbc3082a73d7 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -58,6 +58,7 @@ struct ehci_hcd { /* one per controller */
58 /* async schedule support */ 58 /* async schedule support */
59 struct ehci_qh *async; 59 struct ehci_qh *async;
60 struct ehci_qh *reclaim; 60 struct ehci_qh *reclaim;
61 unsigned reclaim_ready : 1;
61 unsigned scanning : 1; 62 unsigned scanning : 1;
62 63
63 /* periodic schedule support */ 64 /* periodic schedule support */
@@ -80,7 +81,6 @@ struct ehci_hcd { /* one per controller */
80 struct dma_pool *itd_pool; /* itd per iso urb */ 81 struct dma_pool *itd_pool; /* itd per iso urb */
81 struct dma_pool *sitd_pool; /* sitd per split iso urb */ 82 struct dma_pool *sitd_pool; /* sitd per split iso urb */
82 83
83 struct timer_list iaa_watchdog;
84 struct timer_list watchdog; 84 struct timer_list watchdog;
85 unsigned long actions; 85 unsigned long actions;
86 unsigned stamp; 86 unsigned stamp;
@@ -114,21 +114,9 @@ static inline struct usb_hcd *ehci_to_hcd (struct ehci_hcd *ehci)
114} 114}
115 115
116 116
117static inline void
118iaa_watchdog_start (struct ehci_hcd *ehci)
119{
120 WARN_ON(timer_pending(&ehci->iaa_watchdog));
121 mod_timer (&ehci->iaa_watchdog,
122 jiffies + msecs_to_jiffies(EHCI_IAA_MSECS));
123}
124
125static inline void iaa_watchdog_done (struct ehci_hcd *ehci)
126{
127 del_timer (&ehci->iaa_watchdog);
128}
129
130enum ehci_timer_action { 117enum ehci_timer_action {
131 TIMER_IO_WATCHDOG, 118 TIMER_IO_WATCHDOG,
119 TIMER_IAA_WATCHDOG,
132 TIMER_ASYNC_SHRINK, 120 TIMER_ASYNC_SHRINK,
133 TIMER_ASYNC_OFF, 121 TIMER_ASYNC_OFF,
134}; 122};
@@ -146,6 +134,9 @@ timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action)
146 unsigned long t; 134 unsigned long t;
147 135
148 switch (action) { 136 switch (action) {
137 case TIMER_IAA_WATCHDOG:
138 t = EHCI_IAA_JIFFIES;
139 break;
149 case TIMER_IO_WATCHDOG: 140 case TIMER_IO_WATCHDOG:
150 t = EHCI_IO_JIFFIES; 141 t = EHCI_IO_JIFFIES;
151 break; 142 break;
@@ -162,7 +153,8 @@ timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action)
162 // async queue SHRINK often precedes IAA. while it's ready 153 // async queue SHRINK often precedes IAA. while it's ready
163 // to go OFF neither can matter, and afterwards the IO 154 // to go OFF neither can matter, and afterwards the IO
164 // watchdog stops unless there's still periodic traffic. 155 // watchdog stops unless there's still periodic traffic.
165 if (time_before_eq(t, ehci->watchdog.expires) 156 if (action != TIMER_IAA_WATCHDOG
157 && t > ehci->watchdog.expires
166 && timer_pending (&ehci->watchdog)) 158 && timer_pending (&ehci->watchdog))
167 return; 159 return;
168 mod_timer (&ehci->watchdog, t); 160 mod_timer (&ehci->watchdog, t);
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 9be6b303e784..ea4714e557e4 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -715,13 +715,6 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd)
715 return IRQ_NOTMINE; 715 return IRQ_NOTMINE;
716 } 716 }
717 717
718 if (ints & OHCI_INTR_RHSC) {
719 ohci_vdbg (ohci, "rhsc\n");
720 ohci->next_statechange = jiffies + STATECHANGE_DELAY;
721 ohci_writel (ohci, OHCI_INTR_RHSC, &regs->intrstatus);
722 usb_hcd_poll_rh_status(hcd);
723 }
724
725 if (ints & OHCI_INTR_UE) { 718 if (ints & OHCI_INTR_UE) {
726 disable (ohci); 719 disable (ohci);
727 ohci_err (ohci, "OHCI Unrecoverable Error, disabled\n"); 720 ohci_err (ohci, "OHCI Unrecoverable Error, disabled\n");
@@ -731,9 +724,21 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd)
731 ohci_usb_reset (ohci); 724 ohci_usb_reset (ohci);
732 } 725 }
733 726
734 if (ints & OHCI_INTR_RD) { 727 if (ints & OHCI_INTR_RHSC) {
735 ohci_vdbg (ohci, "resume detect\n"); 728 ohci_vdbg(ohci, "rhsc\n");
736 ohci_writel (ohci, OHCI_INTR_RD, &regs->intrstatus); 729 ohci->next_statechange = jiffies + STATECHANGE_DELAY;
730 ohci_writel(ohci, OHCI_INTR_RD | OHCI_INTR_RHSC,
731 &regs->intrstatus);
732 usb_hcd_poll_rh_status(hcd);
733 }
734
735 /* For connect and disconnect events, we expect the controller
736 * to turn on RHSC along with RD. But for remote wakeup events
737 * this might not happen.
738 */
739 else if (ints & OHCI_INTR_RD) {
740 ohci_vdbg(ohci, "resume detect\n");
741 ohci_writel(ohci, OHCI_INTR_RD, &regs->intrstatus);
737 hcd->poll_rh = 1; 742 hcd->poll_rh = 1;
738 if (ohci->autostop) { 743 if (ohci->autostop) {
739 spin_lock (&ohci->lock); 744 spin_lock (&ohci->lock);
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
index 6f113596af66..6995ea36f2e8 100644
--- a/drivers/usb/host/ohci-hub.c
+++ b/drivers/usb/host/ohci-hub.c
@@ -169,7 +169,8 @@ __acquires(ohci->lock)
169 break; 169 break;
170 case OHCI_USB_RESUME: 170 case OHCI_USB_RESUME:
171 /* HCFS changes sometime after INTR_RD */ 171 /* HCFS changes sometime after INTR_RD */
172 ohci_info (ohci, "wakeup\n"); 172 ohci_info(ohci, "%swakeup\n",
173 autostopped ? "auto-" : "");
173 break; 174 break;
174 case OHCI_USB_OPER: 175 case OHCI_USB_OPER:
175 /* this can happen after resuming a swsusp snapshot */ 176 /* this can happen after resuming a swsusp snapshot */
@@ -422,7 +423,8 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf)
422 ohci->autostop = 0; 423 ohci->autostop = 0;
423 ohci->next_statechange = jiffies + 424 ohci->next_statechange = jiffies +
424 STATECHANGE_DELAY; 425 STATECHANGE_DELAY;
425 } else if (time_after_eq (jiffies, 426 } else if (device_may_wakeup(&hcd->self.root_hub->dev)
427 && time_after_eq(jiffies,
426 ohci->next_statechange) 428 ohci->next_statechange)
427 && !ohci->ed_rm_list 429 && !ohci->ed_rm_list
428 && !(ohci->hc_control & 430 && !(ohci->hc_control &
diff --git a/drivers/usb/host/ohci-pnx4008.c b/drivers/usb/host/ohci-pnx4008.c
index 82cb22f002e7..2dbb77414905 100644
--- a/drivers/usb/host/ohci-pnx4008.c
+++ b/drivers/usb/host/ohci-pnx4008.c
@@ -262,6 +262,7 @@ static const struct hc_driver ohci_pnx4008_hc_driver = {
262 */ 262 */
263 .start = ohci_pnx4008_start, 263 .start = ohci_pnx4008_start,
264 .stop = ohci_stop, 264 .stop = ohci_stop,
265 .shutdown = ohci_shutdown,
265 266
266 /* 267 /*
267 * managing i/o requests and associated device resources 268 * managing i/o requests and associated device resources
@@ -280,7 +281,11 @@ static const struct hc_driver ohci_pnx4008_hc_driver = {
280 */ 281 */
281 .hub_status_data = ohci_hub_status_data, 282 .hub_status_data = ohci_hub_status_data,
282 .hub_control = ohci_hub_control, 283 .hub_control = ohci_hub_control,
283 284 .hub_irq_enable = ohci_rhsc_enable,
285#ifdef CONFIG_PM
286 .bus_suspend = ohci_bus_suspend,
287 .bus_resume = ohci_bus_resume,
288#endif
284 .start_port_reset = ohci_start_port_reset, 289 .start_port_reset = ohci_start_port_reset,
285}; 290};
286 291
@@ -410,8 +415,6 @@ static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev)
410 goto out4; 415 goto out4;
411 } 416 }
412 417
413 hcd->self.hcpriv = (void *)hcd;
414
415 pnx4008_start_hc(); 418 pnx4008_start_hc();
416 platform_set_drvdata(pdev, hcd); 419 platform_set_drvdata(pdev, hcd);
417 ohci = hcd_to_ohci(hcd); 420 ohci = hcd_to_ohci(hcd);
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index 45ee6920a850..226bf3de8edd 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -40,6 +40,7 @@
40#include <linux/dma-mapping.h> 40#include <linux/dma-mapping.h>
41#include <linux/usb.h> 41#include <linux/usb.h>
42#include <linux/bitops.h> 42#include <linux/bitops.h>
43#include <linux/dmi.h>
43 44
44#include <asm/uaccess.h> 45#include <asm/uaccess.h>
45#include <asm/io.h> 46#include <asm/io.h>
@@ -196,12 +197,42 @@ static int resume_detect_interrupts_are_broken(struct uhci_hcd *uhci)
196 return 0; 197 return 0;
197} 198}
198 199
200static int remote_wakeup_is_broken(struct uhci_hcd *uhci)
201{
202 static struct dmi_system_id broken_wakeup_table[] = {
203 {
204 .ident = "Asus A7V8X",
205 .matches = {
206 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK"),
207 DMI_MATCH(DMI_BOARD_NAME, "A7V8X"),
208 DMI_MATCH(DMI_BOARD_VERSION, "REV 1.xx"),
209 }
210 },
211 { }
212 };
213 int port;
214
215 /* One of Asus's motherboards has a bug which causes it to
216 * wake up immediately from suspend-to-RAM if any of the ports
217 * are connected. In such cases we will not set EGSM.
218 */
219 if (dmi_check_system(broken_wakeup_table)) {
220 for (port = 0; port < uhci->rh_numports; ++port) {
221 if (inw(uhci->io_addr + USBPORTSC1 + port * 2) &
222 USBPORTSC_CCS)
223 return 1;
224 }
225 }
226
227 return 0;
228}
229
199static void suspend_rh(struct uhci_hcd *uhci, enum uhci_rh_state new_state) 230static void suspend_rh(struct uhci_hcd *uhci, enum uhci_rh_state new_state)
200__releases(uhci->lock) 231__releases(uhci->lock)
201__acquires(uhci->lock) 232__acquires(uhci->lock)
202{ 233{
203 int auto_stop; 234 int auto_stop;
204 int int_enable; 235 int int_enable, egsm_enable;
205 236
206 auto_stop = (new_state == UHCI_RH_AUTO_STOPPED); 237 auto_stop = (new_state == UHCI_RH_AUTO_STOPPED);
207 dev_dbg(&uhci_to_hcd(uhci)->self.root_hub->dev, 238 dev_dbg(&uhci_to_hcd(uhci)->self.root_hub->dev,
@@ -217,15 +248,18 @@ __acquires(uhci->lock)
217 } 248 }
218 249
219 /* Enable resume-detect interrupts if they work. 250 /* Enable resume-detect interrupts if they work.
220 * Then enter Global Suspend mode, still configured. 251 * Then enter Global Suspend mode if _it_ works, still configured.
221 */ 252 */
253 egsm_enable = USBCMD_EGSM;
222 uhci->working_RD = 1; 254 uhci->working_RD = 1;
223 int_enable = USBINTR_RESUME; 255 int_enable = USBINTR_RESUME;
224 if (resume_detect_interrupts_are_broken(uhci)) { 256 if (remote_wakeup_is_broken(uhci))
257 egsm_enable = 0;
258 if (resume_detect_interrupts_are_broken(uhci) || !egsm_enable)
225 uhci->working_RD = int_enable = 0; 259 uhci->working_RD = int_enable = 0;
226 } 260
227 outw(int_enable, uhci->io_addr + USBINTR); 261 outw(int_enable, uhci->io_addr + USBINTR);
228 outw(USBCMD_EGSM | USBCMD_CF, uhci->io_addr + USBCMD); 262 outw(egsm_enable | USBCMD_CF, uhci->io_addr + USBCMD);
229 mb(); 263 mb();
230 udelay(5); 264 udelay(5);
231 265
diff --git a/drivers/usb/input/Kconfig b/drivers/usb/input/Kconfig
index 21cd22640080..20db36448ab3 100644
--- a/drivers/usb/input/Kconfig
+++ b/drivers/usb/input/Kconfig
@@ -348,13 +348,3 @@ config USB_APPLETOUCH
348 348
349 To compile this driver as a module, choose M here: the 349 To compile this driver as a module, choose M here: the
350 module will be called appletouch. 350 module will be called appletouch.
351
352config USB_TRANCEVIBRATOR
353 tristate "PlayStation 2 Trance Vibrator driver support"
354 depends on USB
355 help
356 Say Y here if you want to connect a PlayStation 2 Trance Vibrator
357 device to your computer's USB port.
358
359 To compile this driver as a module, choose M here: the
360 module will be called trancevibrator.
diff --git a/drivers/usb/input/Makefile b/drivers/usb/input/Makefile
index 295f459d1079..d946d5213b30 100644
--- a/drivers/usb/input/Makefile
+++ b/drivers/usb/input/Makefile
@@ -3,7 +3,7 @@
3# 3#
4 4
5# Multipart objects. 5# Multipart objects.
6wacom-objs := wacom_sys.o wacom_wac.o 6wacom-objs := wacom_wac.o wacom_sys.o
7usbhid-objs := hid-core.o 7usbhid-objs := hid-core.o
8 8
9# Optional parts of multipart objects. 9# Optional parts of multipart objects.
@@ -48,7 +48,6 @@ obj-$(CONFIG_USB_ACECAD) += acecad.o
48obj-$(CONFIG_USB_YEALINK) += yealink.o 48obj-$(CONFIG_USB_YEALINK) += yealink.o
49obj-$(CONFIG_USB_XPAD) += xpad.o 49obj-$(CONFIG_USB_XPAD) += xpad.o
50obj-$(CONFIG_USB_APPLETOUCH) += appletouch.o 50obj-$(CONFIG_USB_APPLETOUCH) += appletouch.o
51obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o
52 51
53ifeq ($(CONFIG_USB_DEBUG),y) 52ifeq ($(CONFIG_USB_DEBUG),y)
54EXTRA_CFLAGS += -DDEBUG 53EXTRA_CFLAGS += -DDEBUG
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index a6738a83ff5b..6d08a3bcc952 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -270,7 +270,7 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign
270 * Read data value from item. 270 * Read data value from item.
271 */ 271 */
272 272
273static __inline__ __u32 item_udata(struct hid_item *item) 273static u32 item_udata(struct hid_item *item)
274{ 274{
275 switch (item->size) { 275 switch (item->size) {
276 case 1: return item->data.u8; 276 case 1: return item->data.u8;
@@ -280,7 +280,7 @@ static __inline__ __u32 item_udata(struct hid_item *item)
280 return 0; 280 return 0;
281} 281}
282 282
283static __inline__ __s32 item_sdata(struct hid_item *item) 283static s32 item_sdata(struct hid_item *item)
284{ 284{
285 switch (item->size) { 285 switch (item->size) {
286 case 1: return item->data.s8; 286 case 1: return item->data.s8;
@@ -727,7 +727,7 @@ static struct hid_device *hid_parse_report(__u8 *start, unsigned size)
727 * done by hand. 727 * done by hand.
728 */ 728 */
729 729
730static __inline__ __s32 snto32(__u32 value, unsigned n) 730static s32 snto32(__u32 value, unsigned n)
731{ 731{
732 switch (n) { 732 switch (n) {
733 case 8: return ((__s8)value); 733 case 8: return ((__s8)value);
@@ -741,30 +741,65 @@ static __inline__ __s32 snto32(__u32 value, unsigned n)
741 * Convert a signed 32-bit integer to a signed n-bit integer. 741 * Convert a signed 32-bit integer to a signed n-bit integer.
742 */ 742 */
743 743
744static __inline__ __u32 s32ton(__s32 value, unsigned n) 744static u32 s32ton(__s32 value, unsigned n)
745{ 745{
746 __s32 a = value >> (n - 1); 746 s32 a = value >> (n - 1);
747 if (a && a != -1) 747 if (a && a != -1)
748 return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1; 748 return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1;
749 return value & ((1 << n) - 1); 749 return value & ((1 << n) - 1);
750} 750}
751 751
752/* 752/*
753 * Extract/implement a data field from/to a report. 753 * Extract/implement a data field from/to a little endian report (bit array).
754 *
755 * Code sort-of follows HID spec:
756 * http://www.usb.org/developers/devclass_docs/HID1_11.pdf
757 *
758 * While the USB HID spec allows unlimited length bit fields in "report
759 * descriptors", most devices never use more than 16 bits.
760 * One model of UPS is claimed to report "LINEV" as a 32-bit field.
761 * Search linux-kernel and linux-usb-devel archives for "hid-core extract".
754 */ 762 */
755 763
756static __inline__ __u32 extract(__u8 *report, unsigned offset, unsigned n) 764static __inline__ __u32 extract(__u8 *report, unsigned offset, unsigned n)
757{ 765{
758 report += (offset >> 5) << 2; offset &= 31; 766 u64 x;
759 return (le64_to_cpu(get_unaligned((__le64*)report)) >> offset) & ((1ULL << n) - 1); 767
768 WARN_ON(n > 32);
769
770 report += offset >> 3; /* adjust byte index */
771 offset &= 7; /* now only need bit offset into one byte */
772 x = get_unaligned((u64 *) report);
773 x = le64_to_cpu(x);
774 x = (x >> offset) & ((1ULL << n) - 1); /* extract bit field */
775 return (u32) x;
760} 776}
761 777
778/*
779 * "implement" : set bits in a little endian bit stream.
780 * Same concepts as "extract" (see comments above).
781 * The data mangled in the bit stream remains in little endian
782 * order the whole time. It make more sense to talk about
783 * endianness of register values by considering a register
784 * a "cached" copy of the little endiad bit stream.
785 */
762static __inline__ void implement(__u8 *report, unsigned offset, unsigned n, __u32 value) 786static __inline__ void implement(__u8 *report, unsigned offset, unsigned n, __u32 value)
763{ 787{
764 report += (offset >> 5) << 2; offset &= 31; 788 u64 x;
765 put_unaligned((get_unaligned((__le64*)report) 789 u64 m = (1ULL << n) - 1;
766 & cpu_to_le64(~((((__u64) 1 << n) - 1) << offset))) 790
767 | cpu_to_le64((__u64)value << offset), (__le64*)report); 791 WARN_ON(n > 32);
792
793 WARN_ON(value > m);
794 value &= m;
795
796 report += offset >> 3;
797 offset &= 7;
798
799 x = get_unaligned((u64 *)report);
800 x &= cpu_to_le64(~(m << offset));
801 x |= cpu_to_le64(((u64) value) << offset);
802 put_unaligned(x, (u64 *) report);
768} 803}
769 804
770/* 805/*
@@ -1381,6 +1416,9 @@ void hid_close(struct hid_device *hid)
1381 1416
1382#define USB_VENDOR_ID_PANJIT 0x134c 1417#define USB_VENDOR_ID_PANJIT 0x134c
1383 1418
1419#define USB_VENDOR_ID_TURBOX 0x062a
1420#define USB_DEVICE_ID_TURBOX_KEYBOARD 0x0201
1421
1384/* 1422/*
1385 * Initialize all reports 1423 * Initialize all reports
1386 */ 1424 */
@@ -1602,6 +1640,9 @@ void hid_init_reports(struct hid_device *hid)
1602#define USB_VENDOR_ID_SUN 0x0430 1640#define USB_VENDOR_ID_SUN 0x0430
1603#define USB_DEVICE_ID_RARITAN_KVM_DONGLE 0xcdab 1641#define USB_DEVICE_ID_RARITAN_KVM_DONGLE 0xcdab
1604 1642
1643#define USB_VENDOR_ID_AIRCABLE 0x16CA
1644#define USB_DEVICE_ID_AIRCABLE1 0x1502
1645
1605/* 1646/*
1606 * Alphabetically sorted blacklist by quirk type. 1647 * Alphabetically sorted blacklist by quirk type.
1607 */ 1648 */
@@ -1619,6 +1660,7 @@ static const struct hid_blacklist {
1619 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22, HID_QUIRK_IGNORE }, 1660 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22, HID_QUIRK_IGNORE },
1620 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23, HID_QUIRK_IGNORE }, 1661 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23, HID_QUIRK_IGNORE },
1621 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24, HID_QUIRK_IGNORE }, 1662 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24, HID_QUIRK_IGNORE },
1663 { USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1, HID_QUIRK_IGNORE },
1622 { USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232, HID_QUIRK_IGNORE }, 1664 { USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232, HID_QUIRK_IGNORE },
1623 { USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD, HID_QUIRK_IGNORE }, 1665 { USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD, HID_QUIRK_IGNORE },
1624 { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW40, HID_QUIRK_IGNORE }, 1666 { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW40, HID_QUIRK_IGNORE },
@@ -1755,11 +1797,12 @@ static const struct hid_blacklist {
1755 { USB_VENDOR_ID_APPLE, 0x020E, HID_QUIRK_POWERBOOK_HAS_FN }, 1797 { USB_VENDOR_ID_APPLE, 0x020E, HID_QUIRK_POWERBOOK_HAS_FN },
1756 { USB_VENDOR_ID_APPLE, 0x020F, HID_QUIRK_POWERBOOK_HAS_FN }, 1798 { USB_VENDOR_ID_APPLE, 0x020F, HID_QUIRK_POWERBOOK_HAS_FN },
1757 { USB_VENDOR_ID_APPLE, 0x0214, HID_QUIRK_POWERBOOK_HAS_FN }, 1799 { USB_VENDOR_ID_APPLE, 0x0214, HID_QUIRK_POWERBOOK_HAS_FN },
1758 { USB_VENDOR_ID_APPLE, 0x0215, HID_QUIRK_POWERBOOK_HAS_FN }, 1800 { USB_VENDOR_ID_APPLE, 0x0215, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_POWERBOOK_ISO_KEYBOARD},
1759 { USB_VENDOR_ID_APPLE, 0x0216, HID_QUIRK_POWERBOOK_HAS_FN }, 1801 { USB_VENDOR_ID_APPLE, 0x0216, HID_QUIRK_POWERBOOK_HAS_FN },
1760 { USB_VENDOR_ID_APPLE, 0x0217, HID_QUIRK_POWERBOOK_HAS_FN }, 1802 { USB_VENDOR_ID_APPLE, 0x0217, HID_QUIRK_POWERBOOK_HAS_FN },
1761 { USB_VENDOR_ID_APPLE, 0x0218, HID_QUIRK_POWERBOOK_HAS_FN }, 1803 { USB_VENDOR_ID_APPLE, 0x0218, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_POWERBOOK_ISO_KEYBOARD},
1762 { USB_VENDOR_ID_APPLE, 0x0219, HID_QUIRK_POWERBOOK_HAS_FN }, 1804 { USB_VENDOR_ID_APPLE, 0x0219, HID_QUIRK_POWERBOOK_HAS_FN },
1805 { USB_VENDOR_ID_APPLE, 0x021B, HID_QUIRK_POWERBOOK_HAS_FN },
1763 { USB_VENDOR_ID_APPLE, 0x030A, HID_QUIRK_POWERBOOK_HAS_FN }, 1806 { USB_VENDOR_ID_APPLE, 0x030A, HID_QUIRK_POWERBOOK_HAS_FN },
1764 { USB_VENDOR_ID_APPLE, 0x030B, HID_QUIRK_POWERBOOK_HAS_FN }, 1807 { USB_VENDOR_ID_APPLE, 0x030B, HID_QUIRK_POWERBOOK_HAS_FN },
1765 1808
@@ -1768,6 +1811,8 @@ static const struct hid_blacklist {
1768 { USB_VENDOR_ID_PANJIT, 0x0003, HID_QUIRK_IGNORE }, 1811 { USB_VENDOR_ID_PANJIT, 0x0003, HID_QUIRK_IGNORE },
1769 { USB_VENDOR_ID_PANJIT, 0x0004, HID_QUIRK_IGNORE }, 1812 { USB_VENDOR_ID_PANJIT, 0x0004, HID_QUIRK_IGNORE },
1770 1813
1814 { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET },
1815
1771 { 0, 0 } 1816 { 0, 0 }
1772}; 1817};
1773 1818
diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c
index 9a808a3b4d37..68e7ebb978a9 100644
--- a/drivers/usb/input/hid-input.c
+++ b/drivers/usb/input/hid-input.c
@@ -121,6 +121,12 @@ static struct hidinput_key_translation powerbook_numlock_keys[] = {
121 { } 121 { }
122}; 122};
123 123
124static struct hidinput_key_translation powerbook_iso_keyboard[] = {
125 { KEY_GRAVE, KEY_102ND },
126 { KEY_102ND, KEY_GRAVE },
127 { }
128};
129
124static int usbhid_pb_fnmode = 1; 130static int usbhid_pb_fnmode = 1;
125module_param_named(pb_fnmode, usbhid_pb_fnmode, int, 0644); 131module_param_named(pb_fnmode, usbhid_pb_fnmode, int, 0644);
126MODULE_PARM_DESC(pb_fnmode, 132MODULE_PARM_DESC(pb_fnmode,
@@ -195,6 +201,14 @@ static int hidinput_pb_event(struct hid_device *hid, struct input_dev *input,
195 } 201 }
196 } 202 }
197 203
204 if (hid->quirks & HID_QUIRK_POWERBOOK_ISO_KEYBOARD) {
205 trans = find_translation(powerbook_iso_keyboard, usage->code);
206 if (trans) {
207 input_event(input, usage->type, trans->to, value);
208 return 1;
209 }
210 }
211
198 return 0; 212 return 0;
199} 213}
200 214
@@ -210,6 +224,9 @@ static void hidinput_pb_setup(struct input_dev *input)
210 224
211 for (trans = powerbook_numlock_keys; trans->from; trans++) 225 for (trans = powerbook_numlock_keys; trans->from; trans++)
212 set_bit(trans->to, input->keybit); 226 set_bit(trans->to, input->keybit);
227
228 for (trans = powerbook_iso_keyboard; trans->from; trans++)
229 set_bit(trans->to, input->keybit);
213} 230}
214#else 231#else
215static inline int hidinput_pb_event(struct hid_device *hid, struct input_dev *input, 232static inline int hidinput_pb_event(struct hid_device *hid, struct input_dev *input,
diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h
index 9b50effef758..0e76e6dcac37 100644
--- a/drivers/usb/input/hid.h
+++ b/drivers/usb/input/hid.h
@@ -260,6 +260,7 @@ struct hid_item {
260#define HID_QUIRK_POWERBOOK_HAS_FN 0x00001000 260#define HID_QUIRK_POWERBOOK_HAS_FN 0x00001000
261#define HID_QUIRK_POWERBOOK_FN_ON 0x00002000 261#define HID_QUIRK_POWERBOOK_FN_ON 0x00002000
262#define HID_QUIRK_INVERT_HWHEEL 0x00004000 262#define HID_QUIRK_INVERT_HWHEEL 0x00004000
263#define HID_QUIRK_POWERBOOK_ISO_KEYBOARD 0x00008000
263 264
264/* 265/*
265 * This is the global environment of the parser. This information is 266 * This is the global environment of the parser. This information is
diff --git a/drivers/usb/input/usbtouchscreen.c b/drivers/usb/input/usbtouchscreen.c
index f26c1cd1129f..933ceddf3dee 100644
--- a/drivers/usb/input/usbtouchscreen.c
+++ b/drivers/usb/input/usbtouchscreen.c
@@ -256,10 +256,10 @@ static int itm_read_data(unsigned char *pkt, int *x, int *y, int *touch, int *pr
256{ 256{
257 *x = ((pkt[0] & 0x1F) << 7) | (pkt[3] & 0x7F); 257 *x = ((pkt[0] & 0x1F) << 7) | (pkt[3] & 0x7F);
258 *y = ((pkt[1] & 0x1F) << 7) | (pkt[4] & 0x7F); 258 *y = ((pkt[1] & 0x1F) << 7) | (pkt[4] & 0x7F);
259 *press = ((pkt[2] & 0x1F) << 7) | (pkt[5] & 0x7F); 259 *press = ((pkt[2] & 0x01) << 7) | (pkt[5] & 0x7F);
260 *touch = ~pkt[7] & 0x20; 260 *touch = ~pkt[7] & 0x20;
261 261
262 return 1; 262 return *touch;
263} 263}
264#endif 264#endif
265 265
@@ -640,7 +640,7 @@ static int usbtouch_probe(struct usb_interface *intf,
640 type->max_press, 0, 0); 640 type->max_press, 0, 0);
641 641
642 usb_fill_int_urb(usbtouch->irq, usbtouch->udev, 642 usb_fill_int_urb(usbtouch->irq, usbtouch->udev,
643 usb_rcvintpipe(usbtouch->udev, 0x81), 643 usb_rcvintpipe(usbtouch->udev, endpoint->bEndpointAddress),
644 usbtouch->data, type->rept_size, 644 usbtouch->data, type->rept_size,
645 usbtouch_irq, usbtouch, endpoint->bInterval); 645 usbtouch_irq, usbtouch, endpoint->bInterval);
646 646
diff --git a/drivers/usb/input/wacom.h b/drivers/usb/input/wacom.h
index 7b3840e378a8..1cf08f02c50e 100644
--- a/drivers/usb/input/wacom.h
+++ b/drivers/usb/input/wacom.h
@@ -63,6 +63,7 @@
63 * v1.46 (pc) - Split wacom.c into wacom_sys.c and wacom_wac.c, 63 * v1.46 (pc) - Split wacom.c into wacom_sys.c and wacom_wac.c,
64 * - where wacom_sys.c deals with system specific code, 64 * - where wacom_sys.c deals with system specific code,
65 * - and wacom_wac.c deals with Wacom specific code 65 * - and wacom_wac.c deals with Wacom specific code
66 * - Support Intuos3 4x6
66 */ 67 */
67 68
68/* 69/*
@@ -118,6 +119,7 @@ extern void wacom_input_sync(void *wcombo);
118extern void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_wac); 119extern void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
119extern void input_dev_g4(struct input_dev *input_dev, struct wacom_wac *wacom_wac); 120extern void input_dev_g4(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
120extern void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac); 121extern void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
122extern void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
121extern void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac); 123extern void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
122extern void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac); 124extern void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
123extern void input_dev_pl(struct input_dev *input_dev, struct wacom_wac *wacom_wac); 125extern void input_dev_pl(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
diff --git a/drivers/usb/input/wacom_sys.c b/drivers/usb/input/wacom_sys.c
index d233c37bd533..3498b893b53b 100644
--- a/drivers/usb/input/wacom_sys.c
+++ b/drivers/usb/input/wacom_sys.c
@@ -110,7 +110,7 @@ __u16 wacom_be16_to_cpu(unsigned char *data)
110__u16 wacom_le16_to_cpu(unsigned char *data) 110__u16 wacom_le16_to_cpu(unsigned char *data)
111{ 111{
112 __u16 value; 112 __u16 value;
113 value = be16_to_cpu(*(__be16 *) data); 113 value = le16_to_cpu(*(__le16 *) data);
114 return value; 114 return value;
115} 115}
116 116
@@ -143,7 +143,7 @@ void input_dev_g4(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
143 input_dev->evbit[0] |= BIT(EV_MSC); 143 input_dev->evbit[0] |= BIT(EV_MSC);
144 input_dev->mscbit[0] |= BIT(MSC_SERIAL); 144 input_dev->mscbit[0] |= BIT(MSC_SERIAL);
145 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER); 145 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER);
146 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7); 146 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_4);
147} 147}
148 148
149void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 149void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
@@ -155,11 +155,16 @@ void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
155 input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom_wac->features->distance_max, 0, 0); 155 input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom_wac->features->distance_max, 0, 0);
156} 156}
157 157
158void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 158void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
159{ 159{
160 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER); 160 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER);
161 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7); 161 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3);
162 input_set_abs_params(input_dev, ABS_RX, 0, 4097, 0, 0); 162 input_set_abs_params(input_dev, ABS_RX, 0, 4097, 0, 0);
163}
164
165void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
166{
167 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7);
163 input_set_abs_params(input_dev, ABS_RY, 0, 4097, 0, 0); 168 input_set_abs_params(input_dev, ABS_RY, 0, 4097, 0, 0);
164} 169}
165 170
@@ -218,8 +223,7 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
218 strlcat(wacom->phys, "/input0", sizeof(wacom->phys)); 223 strlcat(wacom->phys, "/input0", sizeof(wacom->phys));
219 224
220 wacom_wac->features = get_wacom_feature(id); 225 wacom_wac->features = get_wacom_feature(id);
221 if (wacom_wac->features->pktlen > 10) 226 BUG_ON(wacom_wac->features->pktlen > 10);
222 BUG();
223 227
224 input_dev->name = wacom_wac->features->name; 228 input_dev->name = wacom_wac->features->name;
225 wacom->wacom_wac = wacom_wac; 229 wacom->wacom_wac = wacom_wac;
@@ -244,7 +248,7 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
244 usb_fill_int_urb(wacom->irq, dev, 248 usb_fill_int_urb(wacom->irq, dev,
245 usb_rcvintpipe(dev, endpoint->bEndpointAddress), 249 usb_rcvintpipe(dev, endpoint->bEndpointAddress),
246 wacom_wac->data, wacom_wac->features->pktlen, 250 wacom_wac->data, wacom_wac->features->pktlen,
247 wacom_wac->features->irq, wacom, endpoint->bInterval); 251 wacom_sys_irq, wacom, endpoint->bInterval);
248 wacom->irq->transfer_dma = wacom->data_dma; 252 wacom->irq->transfer_dma = wacom->data_dma;
249 wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 253 wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
250 254
@@ -278,8 +282,8 @@ static void wacom_disconnect(struct usb_interface *intf)
278 input_unregister_device(wacom->dev); 282 input_unregister_device(wacom->dev);
279 usb_free_urb(wacom->irq); 283 usb_free_urb(wacom->irq);
280 usb_buffer_free(interface_to_usbdev(intf), 10, wacom->wacom_wac->data, wacom->data_dma); 284 usb_buffer_free(interface_to_usbdev(intf), 10, wacom->wacom_wac->data, wacom->data_dma);
281 kfree(wacom);
282 kfree(wacom->wacom_wac); 285 kfree(wacom->wacom_wac);
286 kfree(wacom);
283 } 287 }
284} 288}
285 289
diff --git a/drivers/usb/input/wacom_wac.c b/drivers/usb/input/wacom_wac.c
index aa31d22d4f05..92726fe89379 100644
--- a/drivers/usb/input/wacom_wac.c
+++ b/drivers/usb/input/wacom_wac.c
@@ -191,9 +191,9 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
191 wacom_report_key(wcombo, BTN_LEFT, data[1] & 0x01); 191 wacom_report_key(wcombo, BTN_LEFT, data[1] & 0x01);
192 wacom_report_key(wcombo, BTN_RIGHT, data[1] & 0x02); 192 wacom_report_key(wcombo, BTN_RIGHT, data[1] & 0x02);
193 if (wacom->features->type == WACOM_G4) 193 if (wacom->features->type == WACOM_G4)
194 wacom_report_abs(wcombo, ABS_DISTANCE, data[6]); 194 wacom_report_abs(wcombo, ABS_DISTANCE, data[6] & 0x3f);
195 else 195 else
196 wacom_report_abs(wcombo, ABS_DISTANCE, data[7]); 196 wacom_report_abs(wcombo, ABS_DISTANCE, data[7] & 0x3f);
197 break; 197 break;
198 } 198 }
199 } 199 }
@@ -303,8 +303,9 @@ static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
303 wacom->tool[idx] = BTN_TOOL_PEN; 303 wacom->tool[idx] = BTN_TOOL_PEN;
304 } 304 }
305 /* only large I3 support Lens Cursor */ 305 /* only large I3 support Lens Cursor */
306 if(!((wacom->tool[idx] == BTN_TOOL_LENS) && 306 if(!((wacom->tool[idx] == BTN_TOOL_LENS)
307 (wacom->features->type == INTUOS3))) { 307 && ((wacom->features->type == INTUOS3)
308 || (wacom->features->type == INTUOS3S)))) {
308 wacom_report_abs(wcombo, ABS_MISC, wacom->id[idx]); /* report tool id */ 309 wacom_report_abs(wcombo, ABS_MISC, wacom->id[idx]); /* report tool id */
309 wacom_report_key(wcombo, wacom->tool[idx], 1); 310 wacom_report_key(wcombo, wacom->tool[idx], 1);
310 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]); 311 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
@@ -315,10 +316,14 @@ static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
315 316
316 /* Exit report */ 317 /* Exit report */
317 if ((data[1] & 0xfe) == 0x80) { 318 if ((data[1] & 0xfe) == 0x80) {
318 wacom_report_key(wcombo, wacom->tool[idx], 0); 319 if(!((wacom->tool[idx] == BTN_TOOL_LENS)
319 wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */ 320 && ((wacom->features->type == INTUOS3)
320 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]); 321 || (wacom->features->type == INTUOS3S)))) {
321 return 2; 322 wacom_report_key(wcombo, wacom->tool[idx], 0);
323 wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */
324 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
325 return 2;
326 }
322 } 327 }
323 return 0; 328 return 0;
324} 329}
@@ -382,7 +387,8 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
382 wacom_report_abs(wcombo, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]); 387 wacom_report_abs(wcombo, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
383 wacom_report_abs(wcombo, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]); 388 wacom_report_abs(wcombo, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
384 389
385 if((data[5] & 0x0f) | (data[6] & 0x0f) | (data[1] & 0x1f) | data[2]) 390 if((data[5] & 0x0f) | (data[6] & 0x0f) | (data[1] & 0x1f) |
391 data[2] | (data[3] & 0x1f) | data[4])
386 wacom_report_key(wcombo, wacom->tool[1], 1); 392 wacom_report_key(wcombo, wacom->tool[1], 1);
387 else 393 else
388 wacom_report_key(wcombo, wacom->tool[1], 0); 394 wacom_report_key(wcombo, wacom->tool[1], 0);
@@ -432,7 +438,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
432 ((t - 1) / 2) : -t / 2); 438 ((t - 1) / 2) : -t / 2);
433 } 439 }
434 440
435 } else if (!(data[1] & 0x10) && wacom->features->type < INTUOS3) { 441 } else if (!(data[1] & 0x10) && wacom->features->type < INTUOS3S) {
436 /* 4D mouse packet */ 442 /* 4D mouse packet */
437 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01); 443 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01);
438 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02); 444 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02);
@@ -452,12 +458,12 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
452 - ((data[8] & 0x02) >> 1)); 458 - ((data[8] & 0x02) >> 1));
453 459
454 /* I3 2D mouse side buttons */ 460 /* I3 2D mouse side buttons */
455 if (wacom->features->type == INTUOS3) { 461 if (wacom->features->type >= INTUOS3S && wacom->features->type <= INTUOS3L) {
456 wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x40); 462 wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x40);
457 wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x20); 463 wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x20);
458 } 464 }
459 465
460 } else if (wacom->features->type < INTUOS3) { 466 } else if (wacom->features->type < INTUOS3S || wacom->features->type == INTUOS3L) {
461 /* Lens cursor packets */ 467 /* Lens cursor packets */
462 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01); 468 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01);
463 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02); 469 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02);
@@ -490,6 +496,7 @@ int wacom_wac_irq(struct wacom_wac *wacom_wac, void *wcombo)
490 return (wacom_ptu_irq(wacom_wac, wcombo)); 496 return (wacom_ptu_irq(wacom_wac, wcombo));
491 break; 497 break;
492 case INTUOS: 498 case INTUOS:
499 case INTUOS3S:
493 case INTUOS3: 500 case INTUOS3:
494 case INTUOS3L: 501 case INTUOS3L:
495 case CINTIQ: 502 case CINTIQ:
@@ -515,6 +522,8 @@ void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_w
515 case CINTIQ: 522 case CINTIQ:
516 input_dev_i3(input_dev, wacom_wac); 523 input_dev_i3(input_dev, wacom_wac);
517 /* fall through */ 524 /* fall through */
525 case INTUOS3S:
526 input_dev_i3s(input_dev, wacom_wac);
518 case INTUOS: 527 case INTUOS:
519 input_dev_i(input_dev, wacom_wac); 528 input_dev_i(input_dev, wacom_wac);
520 break; 529 break;
@@ -530,49 +539,50 @@ void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_w
530} 539}
531 540
532static struct wacom_features wacom_features[] = { 541static struct wacom_features wacom_features[] = {
533 { "Wacom Penpartner", 7, 5040, 3780, 255, 32, PENPARTNER, wacom_sys_irq }, 542 { "Wacom Penpartner", 7, 5040, 3780, 255, 0, PENPARTNER },
534 { "Wacom Graphire", 8, 10206, 7422, 511, 32, GRAPHIRE, wacom_sys_irq }, 543 { "Wacom Graphire", 8, 10206, 7422, 511, 63, GRAPHIRE },
535 { "Wacom Graphire2 4x5", 8, 10206, 7422, 511, 32, GRAPHIRE, wacom_sys_irq }, 544 { "Wacom Graphire2 4x5", 8, 10206, 7422, 511, 63, GRAPHIRE },
536 { "Wacom Graphire2 5x7", 8, 13918, 10206, 511, 32, GRAPHIRE, wacom_sys_irq }, 545 { "Wacom Graphire2 5x7", 8, 13918, 10206, 511, 63, GRAPHIRE },
537 { "Wacom Graphire3", 8, 10208, 7424, 511, 32, GRAPHIRE, wacom_sys_irq }, 546 { "Wacom Graphire3", 8, 10208, 7424, 511, 63, GRAPHIRE },
538 { "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 32, GRAPHIRE, wacom_sys_irq }, 547 { "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 63, GRAPHIRE },
539 { "Wacom Graphire4 4x5", 8, 10208, 7424, 511, 32, WACOM_G4, wacom_sys_irq }, 548 { "Wacom Graphire4 4x5", 8, 10208, 7424, 511, 63, WACOM_G4 },
540 { "Wacom Graphire4 6x8", 8, 16704, 12064, 511, 32, WACOM_G4, wacom_sys_irq }, 549 { "Wacom Graphire4 6x8", 8, 16704, 12064, 511, 63, WACOM_G4 },
541 { "Wacom Volito", 8, 5104, 3712, 511, 32, GRAPHIRE, wacom_sys_irq }, 550 { "Wacom Volito", 8, 5104, 3712, 511, 0, GRAPHIRE },
542 { "Wacom PenStation2", 8, 3250, 2320, 255, 32, GRAPHIRE, wacom_sys_irq }, 551 { "Wacom PenStation2", 8, 3250, 2320, 255, 0, GRAPHIRE },
543 { "Wacom Volito2 4x5", 8, 5104, 3712, 511, 32, GRAPHIRE, wacom_sys_irq }, 552 { "Wacom Volito2 4x5", 8, 5104, 3712, 511, 0, GRAPHIRE },
544 { "Wacom Volito2 2x3", 8, 3248, 2320, 511, 32, GRAPHIRE, wacom_sys_irq }, 553 { "Wacom Volito2 2x3", 8, 3248, 2320, 511, 0, GRAPHIRE },
545 { "Wacom PenPartner2", 8, 3250, 2320, 255, 32, GRAPHIRE, wacom_sys_irq }, 554 { "Wacom PenPartner2", 8, 3250, 2320, 255, 0, GRAPHIRE },
546 { "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 15, INTUOS, wacom_sys_irq}, 555 { "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 63, INTUOS },
547 { "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_sys_irq }, 556 { "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 63, INTUOS },
548 { "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 15, INTUOS, wacom_sys_irq }, 557 { "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 63, INTUOS },
549 { "Wacom Intuos 12x12", 10, 30480, 31680, 1023, 15, INTUOS, wacom_sys_irq }, 558 { "Wacom Intuos 12x12", 10, 30480, 31680, 1023, 63, INTUOS },
550 { "Wacom Intuos 12x18", 10, 45720, 31680, 1023, 15, INTUOS, wacom_sys_irq}, 559 { "Wacom Intuos 12x18", 10, 45720, 31680, 1023, 63, INTUOS },
551 { "Wacom PL400", 8, 5408, 4056, 255, 32, PL, wacom_sys_irq }, 560 { "Wacom PL400", 8, 5408, 4056, 255, 0, PL },
552 { "Wacom PL500", 8, 6144, 4608, 255, 32, PL, wacom_sys_irq }, 561 { "Wacom PL500", 8, 6144, 4608, 255, 0, PL },
553 { "Wacom PL600", 8, 6126, 4604, 255, 32, PL, wacom_sys_irq }, 562 { "Wacom PL600", 8, 6126, 4604, 255, 0, PL },
554 { "Wacom PL600SX", 8, 6260, 5016, 255, 32, PL, wacom_sys_irq }, 563 { "Wacom PL600SX", 8, 6260, 5016, 255, 0, PL },
555 { "Wacom PL550", 8, 6144, 4608, 511, 32, PL, wacom_sys_irq }, 564 { "Wacom PL550", 8, 6144, 4608, 511, 0, PL },
556 { "Wacom PL800", 8, 7220, 5780, 511, 32, PL, wacom_sys_irq }, 565 { "Wacom PL800", 8, 7220, 5780, 511, 0, PL },
557 { "Wacom PL700", 8, 6758, 5406, 511, 32, PL, wacom_sys_irq }, 566 { "Wacom PL700", 8, 6758, 5406, 511, 0, PL },
558 { "Wacom PL510", 8, 6282, 4762, 511, 32, PL, wacom_sys_irq }, 567 { "Wacom PL510", 8, 6282, 4762, 511, 0, PL },
559 { "Wacom DTU710", 8, 34080, 27660, 511, 32, PL, wacom_sys_irq }, 568 { "Wacom DTU710", 8, 34080, 27660, 511, 0, PL },
560 { "Wacom DTF521", 8, 6282, 4762, 511, 32, PL, wacom_sys_irq }, 569 { "Wacom DTF521", 8, 6282, 4762, 511, 0, PL },
561 { "Wacom DTF720", 8, 6858, 5506, 511, 32, PL, wacom_sys_irq }, 570 { "Wacom DTF720", 8, 6858, 5506, 511, 0, PL },
562 { "Wacom Cintiq Partner",8, 20480, 15360, 511, 32, PTU, wacom_sys_irq }, 571 { "Wacom Cintiq Partner",8, 20480, 15360, 511, 0, PTU },
563 { "Wacom Intuos2 4x5", 10, 12700, 10600, 1023, 15, INTUOS, wacom_sys_irq }, 572 { "Wacom Intuos2 4x5", 10, 12700, 10600, 1023, 63, INTUOS },
564 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_sys_irq }, 573 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 63, INTUOS },
565 { "Wacom Intuos2 9x12", 10, 30480, 24060, 1023, 15, INTUOS, wacom_sys_irq }, 574 { "Wacom Intuos2 9x12", 10, 30480, 24060, 1023, 63, INTUOS },
566 { "Wacom Intuos2 12x12", 10, 30480, 31680, 1023, 15, INTUOS, wacom_sys_irq }, 575 { "Wacom Intuos2 12x12", 10, 30480, 31680, 1023, 63, INTUOS },
567 { "Wacom Intuos2 12x18", 10, 45720, 31680, 1023, 15, INTUOS, wacom_sys_irq }, 576 { "Wacom Intuos2 12x18", 10, 45720, 31680, 1023, 63, INTUOS },
568 { "Wacom Intuos3 4x5", 10, 25400, 20320, 1023, 15, INTUOS3, wacom_sys_irq }, 577 { "Wacom Intuos3 4x5", 10, 25400, 20320, 1023, 63, INTUOS3S },
569 { "Wacom Intuos3 6x8", 10, 40640, 30480, 1023, 15, INTUOS3, wacom_sys_irq }, 578 { "Wacom Intuos3 6x8", 10, 40640, 30480, 1023, 63, INTUOS3 },
570 { "Wacom Intuos3 9x12", 10, 60960, 45720, 1023, 15, INTUOS3, wacom_sys_irq }, 579 { "Wacom Intuos3 9x12", 10, 60960, 45720, 1023, 63, INTUOS3 },
571 { "Wacom Intuos3 12x12", 10, 60960, 60960, 1023, 15, INTUOS3L, wacom_sys_irq }, 580 { "Wacom Intuos3 12x12", 10, 60960, 60960, 1023, 63, INTUOS3L },
572 { "Wacom Intuos3 12x19", 10, 97536, 60960, 1023, 15, INTUOS3L, wacom_sys_irq }, 581 { "Wacom Intuos3 12x19", 10, 97536, 60960, 1023, 63, INTUOS3L },
573 { "Wacom Intuos3 6x11", 10, 54204, 31750, 1023, 15, INTUOS3, wacom_sys_irq }, 582 { "Wacom Intuos3 6x11", 10, 54204, 31750, 1023, 63, INTUOS3 },
574 { "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 15, CINTIQ, wacom_sys_irq }, 583 { "Wacom Intuos3 4x6", 10, 31496, 19685, 1023, 15, INTUOS3S },
575 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_sys_irq }, 584 { "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 63, CINTIQ },
585 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 63, INTUOS },
576 { } 586 { }
577}; 587};
578 588
@@ -618,6 +628,7 @@ static struct usb_device_id wacom_ids[] = {
618 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB3) }, 628 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB3) },
619 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB4) }, 629 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB4) },
620 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB5) }, 630 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB5) },
631 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB7) },
621 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) }, 632 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) },
622 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) }, 633 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) },
623 { } 634 { }
diff --git a/drivers/usb/input/wacom_wac.h b/drivers/usb/input/wacom_wac.h
index ceae7bf59d9f..a1d9ce007970 100644
--- a/drivers/usb/input/wacom_wac.h
+++ b/drivers/usb/input/wacom_wac.h
@@ -20,6 +20,7 @@ enum {
20 PTU, 20 PTU,
21 PL, 21 PL,
22 INTUOS, 22 INTUOS,
23 INTUOS3S,
23 INTUOS3, 24 INTUOS3,
24 INTUOS3L, 25 INTUOS3L,
25 CINTIQ, 26 CINTIQ,
@@ -34,7 +35,6 @@ struct wacom_features {
34 int pressure_max; 35 int pressure_max;
35 int distance_max; 36 int distance_max;
36 int type; 37 int type;
37 usb_complete_t irq;
38}; 38};
39 39
40struct wacom_wac { 40struct wacom_wac {
diff --git a/drivers/usb/input/xpad.c b/drivers/usb/input/xpad.c
index cebb6c463bfb..df97e5c803f9 100644
--- a/drivers/usb/input/xpad.c
+++ b/drivers/usb/input/xpad.c
@@ -1,8 +1,13 @@
1/* 1/*
2 * X-Box gamepad - v0.0.5 2 * X-Box gamepad - v0.0.6
3 * 3 *
4 * Copyright (c) 2002 Marko Friedemann <mfr@bmx-chemnitz.de> 4 * Copyright (c) 2002 Marko Friedemann <mfr@bmx-chemnitz.de>
5 * 5 * 2004 Oliver Schwartz <Oliver.Schwartz@gmx.de>,
6 * Steven Toth <steve@toth.demon.co.uk>,
7 * Franz Lehner <franz@caos.at>,
8 * Ivan Hawkes <blackhawk@ivanhawkes.com>
9 * 2005 Dominic Cerquetti <binary1230@yahoo.com>
10 * 2006 Adam Buchbinder <adam.buchbinder@gmail.com>
6 * 11 *
7 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as 13 * modify it under the terms of the GNU General Public License as
@@ -28,11 +33,13 @@
28 * - ITO Takayuki for providing essential xpad information on his website 33 * - ITO Takayuki for providing essential xpad information on his website
29 * - Vojtech Pavlik - iforce driver / input subsystem 34 * - Vojtech Pavlik - iforce driver / input subsystem
30 * - Greg Kroah-Hartman - usb-skeleton driver 35 * - Greg Kroah-Hartman - usb-skeleton driver
36 * - XBOX Linux project - extra USB id's
31 * 37 *
32 * TODO: 38 * TODO:
33 * - fine tune axes 39 * - fine tune axes (especially trigger axes)
34 * - fix "analog" buttons (reported as digital now) 40 * - fix "analog" buttons (reported as digital now)
35 * - get rumble working 41 * - get rumble working
42 * - need USB IDs for other dance pads
36 * 43 *
37 * History: 44 * History:
38 * 45 *
@@ -52,30 +59,79 @@
52 * - fixed d-pad to axes mapping 59 * - fixed d-pad to axes mapping
53 * 60 *
54 * 2002-07-17 - 0.0.5 : simplified d-pad handling 61 * 2002-07-17 - 0.0.5 : simplified d-pad handling
62 *
63 * 2004-10-02 - 0.0.6 : DDR pad support
64 * - borrowed from the XBOX linux kernel
65 * - USB id's for commonly used dance pads are present
66 * - dance pads will map D-PAD to buttons, not axes
67 * - pass the module paramater 'dpad_to_buttons' to force
68 * the D-PAD to map to buttons if your pad is not detected
55 */ 69 */
56 70
57#include <linux/kernel.h> 71#include <linux/kernel.h>
58#include <linux/init.h> 72#include <linux/init.h>
59#include <linux/slab.h> 73#include <linux/slab.h>
74#include <linux/stat.h>
60#include <linux/module.h> 75#include <linux/module.h>
76#include <linux/moduleparam.h>
61#include <linux/smp_lock.h> 77#include <linux/smp_lock.h>
62#include <linux/usb/input.h> 78#include <linux/usb/input.h>
63 79
64#define DRIVER_VERSION "v0.0.5" 80#define DRIVER_VERSION "v0.0.6"
65#define DRIVER_AUTHOR "Marko Friedemann <mfr@bmx-chemnitz.de>" 81#define DRIVER_AUTHOR "Marko Friedemann <mfr@bmx-chemnitz.de>"
66#define DRIVER_DESC "X-Box pad driver" 82#define DRIVER_DESC "X-Box pad driver"
67 83
68#define XPAD_PKT_LEN 32 84#define XPAD_PKT_LEN 32
69 85
86/* xbox d-pads should map to buttons, as is required for DDR pads
87 but we map them to axes when possible to simplify things */
88#define MAP_DPAD_TO_BUTTONS 0
89#define MAP_DPAD_TO_AXES 1
90#define MAP_DPAD_UNKNOWN -1
91
92static int dpad_to_buttons;
93module_param(dpad_to_buttons, bool, S_IRUGO);
94MODULE_PARM_DESC(dpad_to_buttons, "Map D-PAD to buttons rather than axes for unknown pads");
95
70static const struct xpad_device { 96static const struct xpad_device {
71 u16 idVendor; 97 u16 idVendor;
72 u16 idProduct; 98 u16 idProduct;
73 char *name; 99 char *name;
100 u8 dpad_mapping;
74} xpad_device[] = { 101} xpad_device[] = {
75 { 0x045e, 0x0202, "Microsoft X-Box pad (US)" }, 102 { 0x045e, 0x0202, "Microsoft X-Box pad v1 (US)", MAP_DPAD_TO_AXES },
76 { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)" }, 103 { 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", MAP_DPAD_TO_AXES },
77 { 0x05fd, 0x107a, "InterAct 'PowerPad Pro' X-Box pad (Germany)" }, 104 { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", MAP_DPAD_TO_AXES },
78 { 0x0000, 0x0000, "X-Box pad" } 105 { 0x045e, 0x0287, "Microsoft Xbox Controller S", MAP_DPAD_TO_AXES },
106 { 0x0c12, 0x8809, "RedOctane Xbox Dance Pad", MAP_DPAD_TO_BUTTONS },
107 { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", MAP_DPAD_TO_AXES },
108 { 0x046d, 0xca84, "Logitech Xbox Cordless Controller", MAP_DPAD_TO_AXES },
109 { 0x046d, 0xca88, "Logitech Compact Controller for Xbox", MAP_DPAD_TO_AXES },
110 { 0x05fd, 0x1007, "Mad Catz Controller (unverified)", MAP_DPAD_TO_AXES },
111 { 0x05fd, 0x107a, "InterAct 'PowerPad Pro' X-Box pad (Germany)", MAP_DPAD_TO_AXES },
112 { 0x0738, 0x4516, "Mad Catz Control Pad", MAP_DPAD_TO_AXES },
113 { 0x0738, 0x4522, "Mad Catz LumiCON", MAP_DPAD_TO_AXES },
114 { 0x0738, 0x4526, "Mad Catz Control Pad Pro", MAP_DPAD_TO_AXES },
115 { 0x0738, 0x4536, "Mad Catz MicroCON", MAP_DPAD_TO_AXES },
116 { 0x0738, 0x4540, "Mad Catz Beat Pad", MAP_DPAD_TO_BUTTONS },
117 { 0x0738, 0x4556, "Mad Catz Lynx Wireless Controller", MAP_DPAD_TO_AXES },
118 { 0x0738, 0x6040, "Mad Catz Beat Pad Pro", MAP_DPAD_TO_BUTTONS },
119 { 0x0c12, 0x8802, "Zeroplus Xbox Controller", MAP_DPAD_TO_AXES },
120 { 0x0c12, 0x8810, "Zeroplus Xbox Controller", MAP_DPAD_TO_AXES },
121 { 0x0c12, 0x9902, "HAMA VibraX - *FAULTY HARDWARE*", MAP_DPAD_TO_AXES },
122 { 0x0e4c, 0x1097, "Radica Gamester Controller", MAP_DPAD_TO_AXES },
123 { 0x0e4c, 0x2390, "Radica Games Jtech Controller", MAP_DPAD_TO_AXES},
124 { 0x0e6f, 0x0003, "Logic3 Freebird wireless Controller", MAP_DPAD_TO_AXES },
125 { 0x0e6f, 0x0005, "Eclipse wireless Controller", MAP_DPAD_TO_AXES },
126 { 0x0e6f, 0x0006, "Edge wireless Controller", MAP_DPAD_TO_AXES },
127 { 0x0e8f, 0x0201, "SmartJoy Frag Xpad/PS2 adaptor", MAP_DPAD_TO_AXES },
128 { 0x0f30, 0x0202, "Joytech Advanced Controller", MAP_DPAD_TO_AXES },
129 { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", MAP_DPAD_TO_AXES },
130 { 0x102c, 0xff0c, "Joytech Wireless Advanced Controller", MAP_DPAD_TO_AXES },
131 { 0x12ab, 0x8809, "Xbox DDR dancepad", MAP_DPAD_TO_BUTTONS },
132 { 0x1430, 0x8888, "TX6500+ Dance Pad (first generation)", MAP_DPAD_TO_BUTTONS },
133 { 0xffff, 0xffff, "Chinese-made Xbox Controller", MAP_DPAD_TO_AXES },
134 { 0x0000, 0x0000, "Generic X-Box pad", MAP_DPAD_UNKNOWN }
79}; 135};
80 136
81static const signed short xpad_btn[] = { 137static const signed short xpad_btn[] = {
@@ -84,11 +140,23 @@ static const signed short xpad_btn[] = {
84 -1 /* terminating entry */ 140 -1 /* terminating entry */
85}; 141};
86 142
143/* only used if MAP_DPAD_TO_BUTTONS */
144static const signed short xpad_btn_pad[] = {
145 BTN_LEFT, BTN_RIGHT, /* d-pad left, right */
146 BTN_0, BTN_1, /* d-pad up, down (XXX names??) */
147 -1 /* terminating entry */
148};
149
87static const signed short xpad_abs[] = { 150static const signed short xpad_abs[] = {
88 ABS_X, ABS_Y, /* left stick */ 151 ABS_X, ABS_Y, /* left stick */
89 ABS_RX, ABS_RY, /* right stick */ 152 ABS_RX, ABS_RY, /* right stick */
90 ABS_Z, ABS_RZ, /* triggers left/right */ 153 ABS_Z, ABS_RZ, /* triggers left/right */
91 ABS_HAT0X, ABS_HAT0Y, /* digital pad */ 154 -1 /* terminating entry */
155};
156
157/* only used if MAP_DPAD_TO_AXES */
158static const signed short xpad_abs_pad[] = {
159 ABS_HAT0X, ABS_HAT0Y, /* d-pad axes */
92 -1 /* terminating entry */ 160 -1 /* terminating entry */
93}; 161};
94 162
@@ -100,14 +168,16 @@ static struct usb_device_id xpad_table [] = {
100MODULE_DEVICE_TABLE (usb, xpad_table); 168MODULE_DEVICE_TABLE (usb, xpad_table);
101 169
102struct usb_xpad { 170struct usb_xpad {
103 struct input_dev *dev; /* input device interface */ 171 struct input_dev *dev; /* input device interface */
104 struct usb_device *udev; /* usb device */ 172 struct usb_device *udev; /* usb device */
105 173
106 struct urb *irq_in; /* urb for interrupt in report */ 174 struct urb *irq_in; /* urb for interrupt in report */
107 unsigned char *idata; /* input data */ 175 unsigned char *idata; /* input data */
108 dma_addr_t idata_dma; 176 dma_addr_t idata_dma;
109 177
110 char phys[65]; /* physical device path */ 178 char phys[65]; /* physical device path */
179
180 int dpad_mapping; /* map d-pad to buttons or to axes */
111}; 181};
112 182
113/* 183/*
@@ -137,14 +207,21 @@ static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *d
137 input_report_abs(dev, ABS_RZ, data[11]); 207 input_report_abs(dev, ABS_RZ, data[11]);
138 208
139 /* digital pad */ 209 /* digital pad */
140 input_report_abs(dev, ABS_HAT0X, !!(data[2] & 0x08) - !!(data[2] & 0x04)); 210 if (xpad->dpad_mapping == MAP_DPAD_TO_AXES) {
141 input_report_abs(dev, ABS_HAT0Y, !!(data[2] & 0x02) - !!(data[2] & 0x01)); 211 input_report_abs(dev, ABS_HAT0X, !!(data[2] & 0x08) - !!(data[2] & 0x04));
212 input_report_abs(dev, ABS_HAT0Y, !!(data[2] & 0x02) - !!(data[2] & 0x01));
213 } else /* xpad->dpad_mapping == MAP_DPAD_TO_BUTTONS */ {
214 input_report_key(dev, BTN_LEFT, data[2] & 0x04);
215 input_report_key(dev, BTN_RIGHT, data[2] & 0x08);
216 input_report_key(dev, BTN_0, data[2] & 0x01); // up
217 input_report_key(dev, BTN_1, data[2] & 0x02); // down
218 }
142 219
143 /* start/back buttons and stick press left/right */ 220 /* start/back buttons and stick press left/right */
144 input_report_key(dev, BTN_START, (data[2] & 0x10) >> 4); 221 input_report_key(dev, BTN_START, data[2] & 0x10);
145 input_report_key(dev, BTN_BACK, (data[2] & 0x20) >> 5); 222 input_report_key(dev, BTN_BACK, data[2] & 0x20);
146 input_report_key(dev, BTN_THUMBL, (data[2] & 0x40) >> 6); 223 input_report_key(dev, BTN_THUMBL, data[2] & 0x40);
147 input_report_key(dev, BTN_THUMBR, data[2] >> 7); 224 input_report_key(dev, BTN_THUMBR, data[2] & 0x80);
148 225
149 /* "analog" buttons A, B, X, Y */ 226 /* "analog" buttons A, B, X, Y */
150 input_report_key(dev, BTN_A, data[4]); 227 input_report_key(dev, BTN_A, data[4]);
@@ -206,6 +283,28 @@ static void xpad_close (struct input_dev *dev)
206 usb_kill_urb(xpad->irq_in); 283 usb_kill_urb(xpad->irq_in);
207} 284}
208 285
286static void xpad_set_up_abs(struct input_dev *input_dev, signed short abs)
287{
288 set_bit(abs, input_dev->absbit);
289
290 switch (abs) {
291 case ABS_X:
292 case ABS_Y:
293 case ABS_RX:
294 case ABS_RY: /* the two sticks */
295 input_set_abs_params(input_dev, abs, -32768, 32767, 16, 128);
296 break;
297 case ABS_Z:
298 case ABS_RZ: /* the triggers */
299 input_set_abs_params(input_dev, abs, 0, 255, 0, 0);
300 break;
301 case ABS_HAT0X:
302 case ABS_HAT0Y: /* the d-pad (only if MAP_DPAD_TO_AXES) */
303 input_set_abs_params(input_dev, abs, -1, 1, 0, 0);
304 break;
305 }
306}
307
209static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id) 308static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id)
210{ 309{
211 struct usb_device *udev = interface_to_usbdev (intf); 310 struct usb_device *udev = interface_to_usbdev (intf);
@@ -235,6 +334,9 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
235 goto fail2; 334 goto fail2;
236 335
237 xpad->udev = udev; 336 xpad->udev = udev;
337 xpad->dpad_mapping = xpad_device[i].dpad_mapping;
338 if (xpad->dpad_mapping == MAP_DPAD_UNKNOWN)
339 xpad->dpad_mapping = dpad_to_buttons;
238 xpad->dev = input_dev; 340 xpad->dev = input_dev;
239 usb_make_path(udev, xpad->phys, sizeof(xpad->phys)); 341 usb_make_path(udev, xpad->phys, sizeof(xpad->phys));
240 strlcat(xpad->phys, "/input0", sizeof(xpad->phys)); 342 strlcat(xpad->phys, "/input0", sizeof(xpad->phys));
@@ -249,32 +351,19 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
249 351
250 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 352 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
251 353
354 /* set up buttons */
252 for (i = 0; xpad_btn[i] >= 0; i++) 355 for (i = 0; xpad_btn[i] >= 0; i++)
253 set_bit(xpad_btn[i], input_dev->keybit); 356 set_bit(xpad_btn[i], input_dev->keybit);
357 if (xpad->dpad_mapping == MAP_DPAD_TO_BUTTONS)
358 for (i = 0; xpad_btn_pad[i] >= 0; i++)
359 set_bit(xpad_btn_pad[i], input_dev->keybit);
254 360
255 for (i = 0; xpad_abs[i] >= 0; i++) { 361 /* set up axes */
256 362 for (i = 0; xpad_abs[i] >= 0; i++)
257 signed short t = xpad_abs[i]; 363 xpad_set_up_abs(input_dev, xpad_abs[i]);
258 364 if (xpad->dpad_mapping == MAP_DPAD_TO_AXES)
259 set_bit(t, input_dev->absbit); 365 for (i = 0; xpad_abs_pad[i] >= 0; i++)
260 366 xpad_set_up_abs(input_dev, xpad_abs_pad[i]);
261 switch (t) {
262 case ABS_X:
263 case ABS_Y:
264 case ABS_RX:
265 case ABS_RY: /* the two sticks */
266 input_set_abs_params(input_dev, t, -32768, 32767, 16, 128);
267 break;
268 case ABS_Z:
269 case ABS_RZ: /* the triggers */
270 input_set_abs_params(input_dev, t, 0, 255, 0, 0);
271 break;
272 case ABS_HAT0X:
273 case ABS_HAT0Y: /* the d-pad */
274 input_set_abs_params(input_dev, t, -1, 1, 0, 0);
275 break;
276 }
277 }
278 367
279 ep_irq_in = &intf->cur_altsetting->endpoint[0].desc; 368 ep_irq_in = &intf->cur_altsetting->endpoint[0].desc;
280 usb_fill_int_urb(xpad->irq_in, udev, 369 usb_fill_int_urb(xpad->irq_in, udev,
@@ -305,7 +394,8 @@ static void xpad_disconnect(struct usb_interface *intf)
305 usb_kill_urb(xpad->irq_in); 394 usb_kill_urb(xpad->irq_in);
306 input_unregister_device(xpad->dev); 395 input_unregister_device(xpad->dev);
307 usb_free_urb(xpad->irq_in); 396 usb_free_urb(xpad->irq_in);
308 usb_buffer_free(interface_to_usbdev(intf), XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); 397 usb_buffer_free(interface_to_usbdev(intf), XPAD_PKT_LEN,
398 xpad->idata, xpad->idata_dma);
309 kfree(xpad); 399 kfree(xpad);
310 } 400 }
311} 401}
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
index c29658f69e2a..a74bf8617e7f 100644
--- a/drivers/usb/misc/Kconfig
+++ b/drivers/usb/misc/Kconfig
@@ -223,6 +223,16 @@ config USB_LD
223 To compile this driver as a module, choose M here: the 223 To compile this driver as a module, choose M here: the
224 module will be called ldusb. 224 module will be called ldusb.
225 225
226config USB_TRANCEVIBRATOR
227 tristate "PlayStation 2 Trance Vibrator driver support"
228 depends on USB
229 help
230 Say Y here if you want to connect a PlayStation 2 Trance Vibrator
231 device to your computer's USB port.
232
233 To compile this driver as a module, choose M here: the
234 module will be called trancevibrator.
235
226config USB_TEST 236config USB_TEST
227 tristate "USB testing driver (DEVELOPMENT)" 237 tristate "USB testing driver (DEVELOPMENT)"
228 depends on USB && USB_DEVICEFS && EXPERIMENTAL 238 depends on USB && USB_DEVICEFS && EXPERIMENTAL
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
index 2be70fa259bf..11dc59540cda 100644
--- a/drivers/usb/misc/Makefile
+++ b/drivers/usb/misc/Makefile
@@ -21,6 +21,7 @@ obj-$(CONFIG_USB_PHIDGETMOTORCONTROL) += phidgetmotorcontrol.o
21obj-$(CONFIG_USB_PHIDGETSERVO) += phidgetservo.o 21obj-$(CONFIG_USB_PHIDGETSERVO) += phidgetservo.o
22obj-$(CONFIG_USB_RIO500) += rio500.o 22obj-$(CONFIG_USB_RIO500) += rio500.o
23obj-$(CONFIG_USB_TEST) += usbtest.o 23obj-$(CONFIG_USB_TEST) += usbtest.o
24obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o
24obj-$(CONFIG_USB_USS720) += uss720.o 25obj-$(CONFIG_USB_USS720) += uss720.o
25 26
26obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/ 27obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/
diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c
index aecd633fe9f6..af2934e016a7 100644
--- a/drivers/usb/misc/adutux.c
+++ b/drivers/usb/misc/adutux.c
@@ -370,7 +370,8 @@ static int adu_release(struct inode *inode, struct file *file)
370 retval = adu_release_internal(dev); 370 retval = adu_release_internal(dev);
371 371
372exit: 372exit:
373 up(&dev->sem); 373 if (dev)
374 up(&dev->sem);
374 dbg(2," %s : leave, return value %d", __FUNCTION__, retval); 375 dbg(2," %s : leave, return value %d", __FUNCTION__, retval);
375 return retval; 376 return retval;
376} 377}
diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c
index 0be9d62d62ae..e4971d6aaafb 100644
--- a/drivers/usb/misc/auerswald.c
+++ b/drivers/usb/misc/auerswald.c
@@ -780,7 +780,7 @@ static int auerbuf_setup (pauerbufctl_t bcp, unsigned int numElements, unsigned
780 780
781bl_fail:/* not enough memory. Free allocated elements */ 781bl_fail:/* not enough memory. Free allocated elements */
782 dbg ("auerbuf_setup: no more memory"); 782 dbg ("auerbuf_setup: no more memory");
783 kfree(bep); 783 auerbuf_free(bep);
784 auerbuf_free_buffers (bcp); 784 auerbuf_free_buffers (bcp);
785 return -ENOMEM; 785 return -ENOMEM;
786} 786}
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c
index 0eb26a26115b..9b591b8b9369 100644
--- a/drivers/usb/misc/ftdi-elan.c
+++ b/drivers/usb/misc/ftdi-elan.c
@@ -513,8 +513,6 @@ static void ftdi_elan_respond_work(void *data)
513 ftdi->disconnected += 1; 513 ftdi->disconnected += 1;
514 } else if (retval == -ENODEV) { 514 } else if (retval == -ENODEV) {
515 ftdi->disconnected += 1; 515 ftdi->disconnected += 1;
516 } else if (retval == -ENODEV) {
517 ftdi->disconnected += 1;
518 } else if (retval == -EILSEQ) { 516 } else if (retval == -EILSEQ) {
519 ftdi->disconnected += 1; 517 ftdi->disconnected += 1;
520 } else { 518 } else {
@@ -1186,11 +1184,8 @@ static ssize_t ftdi_elan_write(struct file *file,
1186 int retval = 0; 1184 int retval = 0;
1187 struct urb *urb; 1185 struct urb *urb;
1188 char *buf; 1186 char *buf;
1189 char data[30 *3 + 4]; 1187 struct usb_ftdi *ftdi = file->private_data;
1190 char *d = data; 1188
1191 const char __user *s = user_buffer;
1192 int m = (sizeof(data) - 1) / 3;
1193 struct usb_ftdi *ftdi = (struct usb_ftdi *)file->private_data;
1194 if (ftdi->disconnected > 0) { 1189 if (ftdi->disconnected > 0) {
1195 return -ENODEV; 1190 return -ENODEV;
1196 } 1191 }
@@ -1220,27 +1215,18 @@ static ssize_t ftdi_elan_write(struct file *file,
1220 if (retval) { 1215 if (retval) {
1221 dev_err(&ftdi->udev->dev, "failed submitting write urb, error %" 1216 dev_err(&ftdi->udev->dev, "failed submitting write urb, error %"
1222 "d\n", retval); 1217 "d\n", retval);
1223 goto error_4; 1218 goto error_3;
1224 } 1219 }
1225 usb_free_urb(urb); 1220 usb_free_urb(urb);
1226 exit:; 1221
1227 if (count > m) { 1222exit:
1228 int I = m - 1;
1229 while (I-- > 0) {
1230 d += sprintf(d, " %02X", 0x000000FF & *s++);
1231 }
1232 d += sprintf(d, " ..");
1233 } else {
1234 int I = count;
1235 while (I-- > 0) {
1236 d += sprintf(d, " %02X", 0x000000FF & *s++);
1237 }
1238 }
1239 return count; 1223 return count;
1240 error_4: error_3:usb_buffer_free(ftdi->udev, count, buf, 1224error_3:
1241 urb->transfer_dma); 1225 usb_buffer_free(ftdi->udev, count, buf, urb->transfer_dma);
1242 error_2:usb_free_urb(urb); 1226error_2:
1243 error_1:return retval; 1227 usb_free_urb(urb);
1228error_1:
1229 return retval;
1244} 1230}
1245 1231
1246static struct file_operations ftdi_elan_fops = { 1232static struct file_operations ftdi_elan_fops = {
diff --git a/drivers/usb/input/trancevibrator.c b/drivers/usb/misc/trancevibrator.c
index 33cd91d11eca..33cd91d11eca 100644
--- a/drivers/usb/input/trancevibrator.c
+++ b/drivers/usb/misc/trancevibrator.c
diff --git a/drivers/usb/net/Kconfig b/drivers/usb/net/Kconfig
index 054059632a21..e081836014ac 100644
--- a/drivers/usb/net/Kconfig
+++ b/drivers/usb/net/Kconfig
@@ -92,8 +92,13 @@ config USB_RTL8150
92 To compile this driver as a module, choose M here: the 92 To compile this driver as a module, choose M here: the
93 module will be called rtl8150. 93 module will be called rtl8150.
94 94
95config USB_USBNET_MII
96 tristate
97 default n
98
95config USB_USBNET 99config USB_USBNET
96 tristate "Multi-purpose USB Networking Framework" 100 tristate "Multi-purpose USB Networking Framework"
101 select MII if USBNET_MII != n
97 ---help--- 102 ---help---
98 This driver supports several kinds of network links over USB, 103 This driver supports several kinds of network links over USB,
99 with "minidrivers" built around a common network driver core 104 with "minidrivers" built around a common network driver core
@@ -129,7 +134,7 @@ config USB_NET_AX8817X
129 tristate "ASIX AX88xxx Based USB 2.0 Ethernet Adapters" 134 tristate "ASIX AX88xxx Based USB 2.0 Ethernet Adapters"
130 depends on USB_USBNET && NET_ETHERNET 135 depends on USB_USBNET && NET_ETHERNET
131 select CRC32 136 select CRC32
132 select MII 137 select USB_USBNET_MII
133 default y 138 default y
134 help 139 help
135 This option adds support for ASIX AX88xxx based USB 2.0 140 This option adds support for ASIX AX88xxx based USB 2.0
@@ -207,6 +212,15 @@ config USB_NET_PLUSB
207 Choose this option if you're using a host-to-host cable 212 Choose this option if you're using a host-to-host cable
208 with one of these chips. 213 with one of these chips.
209 214
215config USB_NET_MCS7830
216 tristate "MosChip MCS7830 based Ethernet adapters"
217 depends on USB_USBNET
218 select USB_USBNET_MII
219 help
220 Choose this option if you're using a 10/100 Ethernet USB2
221 adapter based on the MosChip 7830 controller. This includes
222 adapters marketed under the DeLOCK brand.
223
210config USB_NET_RNDIS_HOST 224config USB_NET_RNDIS_HOST
211 tristate "Host for RNDIS devices (EXPERIMENTAL)" 225 tristate "Host for RNDIS devices (EXPERIMENTAL)"
212 depends on USB_USBNET && EXPERIMENTAL 226 depends on USB_USBNET && EXPERIMENTAL
diff --git a/drivers/usb/net/Makefile b/drivers/usb/net/Makefile
index 160f19dbdf12..7b51964de171 100644
--- a/drivers/usb/net/Makefile
+++ b/drivers/usb/net/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_USB_NET_PLUSB) += plusb.o
14obj-$(CONFIG_USB_NET_RNDIS_HOST) += rndis_host.o 14obj-$(CONFIG_USB_NET_RNDIS_HOST) += rndis_host.o
15obj-$(CONFIG_USB_NET_CDC_SUBSET) += cdc_subset.o 15obj-$(CONFIG_USB_NET_CDC_SUBSET) += cdc_subset.o
16obj-$(CONFIG_USB_NET_ZAURUS) += zaurus.o 16obj-$(CONFIG_USB_NET_ZAURUS) += zaurus.o
17obj-$(CONFIG_USB_NET_MCS7830) += mcs7830.o
17obj-$(CONFIG_USB_USBNET) += usbnet.o 18obj-$(CONFIG_USB_USBNET) += usbnet.o
18 19
19ifeq ($(CONFIG_USB_DEBUG),y) 20ifeq ($(CONFIG_USB_DEBUG),y)
diff --git a/drivers/usb/net/asix.c b/drivers/usb/net/asix.c
index c73dd224aa76..881841e600de 100644
--- a/drivers/usb/net/asix.c
+++ b/drivers/usb/net/asix.c
@@ -569,10 +569,12 @@ static int asix_mdio_read(struct net_device *netdev, int phy_id, int loc)
569 struct usbnet *dev = netdev_priv(netdev); 569 struct usbnet *dev = netdev_priv(netdev);
570 u16 res; 570 u16 res;
571 571
572 mutex_lock(&dev->phy_mutex);
572 asix_set_sw_mii(dev); 573 asix_set_sw_mii(dev);
573 asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id, 574 asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id,
574 (__u16)loc, 2, (u16 *)&res); 575 (__u16)loc, 2, (u16 *)&res);
575 asix_set_hw_mii(dev); 576 asix_set_hw_mii(dev);
577 mutex_unlock(&dev->phy_mutex);
576 578
577 devdbg(dev, "asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x", phy_id, loc, le16_to_cpu(res & 0xffff)); 579 devdbg(dev, "asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x", phy_id, loc, le16_to_cpu(res & 0xffff));
578 580
@@ -586,10 +588,12 @@ asix_mdio_write(struct net_device *netdev, int phy_id, int loc, int val)
586 u16 res = cpu_to_le16(val); 588 u16 res = cpu_to_le16(val);
587 589
588 devdbg(dev, "asix_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x", phy_id, loc, val); 590 devdbg(dev, "asix_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x", phy_id, loc, val);
591 mutex_lock(&dev->phy_mutex);
589 asix_set_sw_mii(dev); 592 asix_set_sw_mii(dev);
590 asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, 593 asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id,
591 (__u16)loc, 2, (u16 *)&res); 594 (__u16)loc, 2, (u16 *)&res);
592 asix_set_hw_mii(dev); 595 asix_set_hw_mii(dev);
596 mutex_unlock(&dev->phy_mutex);
593} 597}
594 598
595/* Get the PHY Identifier from the PHYSID1 & PHYSID2 MII registers */ 599/* Get the PHY Identifier from the PHYSID1 & PHYSID2 MII registers */
@@ -700,32 +704,6 @@ static void asix_get_drvinfo (struct net_device *net,
700 info->eedump_len = data->eeprom_len; 704 info->eedump_len = data->eeprom_len;
701} 705}
702 706
703static int asix_get_settings(struct net_device *net, struct ethtool_cmd *cmd)
704{
705 struct usbnet *dev = netdev_priv(net);
706
707 return mii_ethtool_gset(&dev->mii,cmd);
708}
709
710static int asix_set_settings(struct net_device *net, struct ethtool_cmd *cmd)
711{
712 struct usbnet *dev = netdev_priv(net);
713 int res = mii_ethtool_sset(&dev->mii,cmd);
714
715 /* link speed/duplex might have changed */
716 if (dev->driver_info->link_reset)
717 dev->driver_info->link_reset(dev);
718
719 return res;
720}
721
722static int asix_nway_reset(struct net_device *net)
723{
724 struct usbnet *dev = netdev_priv(net);
725
726 return mii_nway_restart(&dev->mii);
727}
728
729static u32 asix_get_link(struct net_device *net) 707static u32 asix_get_link(struct net_device *net)
730{ 708{
731 struct usbnet *dev = netdev_priv(net); 709 struct usbnet *dev = netdev_priv(net);
@@ -746,15 +724,15 @@ static int asix_ioctl (struct net_device *net, struct ifreq *rq, int cmd)
746static struct ethtool_ops ax88172_ethtool_ops = { 724static struct ethtool_ops ax88172_ethtool_ops = {
747 .get_drvinfo = asix_get_drvinfo, 725 .get_drvinfo = asix_get_drvinfo,
748 .get_link = asix_get_link, 726 .get_link = asix_get_link,
749 .nway_reset = asix_nway_reset,
750 .get_msglevel = usbnet_get_msglevel, 727 .get_msglevel = usbnet_get_msglevel,
751 .set_msglevel = usbnet_set_msglevel, 728 .set_msglevel = usbnet_set_msglevel,
752 .get_wol = asix_get_wol, 729 .get_wol = asix_get_wol,
753 .set_wol = asix_set_wol, 730 .set_wol = asix_set_wol,
754 .get_eeprom_len = asix_get_eeprom_len, 731 .get_eeprom_len = asix_get_eeprom_len,
755 .get_eeprom = asix_get_eeprom, 732 .get_eeprom = asix_get_eeprom,
756 .get_settings = asix_get_settings, 733 .get_settings = usbnet_get_settings,
757 .set_settings = asix_set_settings, 734 .set_settings = usbnet_set_settings,
735 .nway_reset = usbnet_nway_reset,
758}; 736};
759 737
760static void ax88172_set_multicast(struct net_device *net) 738static void ax88172_set_multicast(struct net_device *net)
@@ -885,15 +863,15 @@ out1:
885static struct ethtool_ops ax88772_ethtool_ops = { 863static struct ethtool_ops ax88772_ethtool_ops = {
886 .get_drvinfo = asix_get_drvinfo, 864 .get_drvinfo = asix_get_drvinfo,
887 .get_link = asix_get_link, 865 .get_link = asix_get_link,
888 .nway_reset = asix_nway_reset,
889 .get_msglevel = usbnet_get_msglevel, 866 .get_msglevel = usbnet_get_msglevel,
890 .set_msglevel = usbnet_set_msglevel, 867 .set_msglevel = usbnet_set_msglevel,
891 .get_wol = asix_get_wol, 868 .get_wol = asix_get_wol,
892 .set_wol = asix_set_wol, 869 .set_wol = asix_set_wol,
893 .get_eeprom_len = asix_get_eeprom_len, 870 .get_eeprom_len = asix_get_eeprom_len,
894 .get_eeprom = asix_get_eeprom, 871 .get_eeprom = asix_get_eeprom,
895 .get_settings = asix_get_settings, 872 .get_settings = usbnet_get_settings,
896 .set_settings = asix_set_settings, 873 .set_settings = usbnet_set_settings,
874 .nway_reset = usbnet_nway_reset,
897}; 875};
898 876
899static int ax88772_link_reset(struct usbnet *dev) 877static int ax88772_link_reset(struct usbnet *dev)
@@ -1046,15 +1024,15 @@ out1:
1046static struct ethtool_ops ax88178_ethtool_ops = { 1024static struct ethtool_ops ax88178_ethtool_ops = {
1047 .get_drvinfo = asix_get_drvinfo, 1025 .get_drvinfo = asix_get_drvinfo,
1048 .get_link = asix_get_link, 1026 .get_link = asix_get_link,
1049 .nway_reset = asix_nway_reset,
1050 .get_msglevel = usbnet_get_msglevel, 1027 .get_msglevel = usbnet_get_msglevel,
1051 .set_msglevel = usbnet_set_msglevel, 1028 .set_msglevel = usbnet_set_msglevel,
1052 .get_wol = asix_get_wol, 1029 .get_wol = asix_get_wol,
1053 .set_wol = asix_set_wol, 1030 .set_wol = asix_set_wol,
1054 .get_eeprom_len = asix_get_eeprom_len, 1031 .get_eeprom_len = asix_get_eeprom_len,
1055 .get_eeprom = asix_get_eeprom, 1032 .get_eeprom = asix_get_eeprom,
1056 .get_settings = asix_get_settings, 1033 .get_settings = usbnet_get_settings,
1057 .set_settings = asix_set_settings, 1034 .set_settings = usbnet_set_settings,
1035 .nway_reset = usbnet_nway_reset,
1058}; 1036};
1059 1037
1060static int marvell_phy_init(struct usbnet *dev) 1038static int marvell_phy_init(struct usbnet *dev)
diff --git a/drivers/usb/net/cdc_ether.c b/drivers/usb/net/cdc_ether.c
index 82ce0358d9a3..f6971b88349d 100644
--- a/drivers/usb/net/cdc_ether.c
+++ b/drivers/usb/net/cdc_ether.c
@@ -498,7 +498,7 @@ static struct usb_driver cdc_driver = {
498 498
499static int __init cdc_init(void) 499static int __init cdc_init(void)
500{ 500{
501 BUG_ON((sizeof(((struct usbnet *)0)->data) 501 BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data)
502 < sizeof(struct cdc_state))); 502 < sizeof(struct cdc_state)));
503 503
504 return usb_register(&cdc_driver); 504 return usb_register(&cdc_driver);
diff --git a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c
index 957d4ad316f9..7c906a43e497 100644
--- a/drivers/usb/net/kaweth.c
+++ b/drivers/usb/net/kaweth.c
@@ -65,16 +65,6 @@
65 65
66#undef DEBUG 66#undef DEBUG
67 67
68#ifdef DEBUG
69#define kaweth_dbg(format, arg...) printk(KERN_DEBUG __FILE__ ": " format "\n" ,##arg)
70#else
71#define kaweth_dbg(format, arg...) do {} while (0)
72#endif
73#define kaweth_err(format, arg...) printk(KERN_ERR __FILE__ ": " format "\n" ,##arg)
74#define kaweth_info(format, arg...) printk(KERN_INFO __FILE__ ": " format "\n" , ##arg)
75#define kaweth_warn(format, arg...) printk(KERN_WARNING __FILE__ ": " format "\n" , ##arg)
76
77
78#include "kawethfw.h" 68#include "kawethfw.h"
79 69
80#define KAWETH_MTU 1514 70#define KAWETH_MTU 1514
@@ -86,6 +76,9 @@
86 76
87#define KAWETH_STATUS_BROKEN 0x0000001 77#define KAWETH_STATUS_BROKEN 0x0000001
88#define KAWETH_STATUS_CLOSING 0x0000002 78#define KAWETH_STATUS_CLOSING 0x0000002
79#define KAWETH_STATUS_SUSPENDING 0x0000004
80
81#define KAWETH_STATUS_BLOCKED (KAWETH_STATUS_CLOSING | KAWETH_STATUS_SUSPENDING)
89 82
90#define KAWETH_PACKET_FILTER_PROMISCUOUS 0x01 83#define KAWETH_PACKET_FILTER_PROMISCUOUS 0x01
91#define KAWETH_PACKET_FILTER_ALL_MULTICAST 0x02 84#define KAWETH_PACKET_FILTER_ALL_MULTICAST 0x02
@@ -112,6 +105,8 @@
112#define STATE_MASK 0x40 105#define STATE_MASK 0x40
113#define STATE_SHIFT 5 106#define STATE_SHIFT 5
114 107
108#define IS_BLOCKED(s) (s & KAWETH_STATUS_BLOCKED)
109
115 110
116MODULE_AUTHOR("Michael Zappe <zapman@interlan.net>, Stephane Alnet <stephane@u-picardie.fr>, Brad Hards <bhards@bigpond.net.au> and Oliver Neukum <oliver@neukum.org>"); 111MODULE_AUTHOR("Michael Zappe <zapman@interlan.net>, Stephane Alnet <stephane@u-picardie.fr>, Brad Hards <bhards@bigpond.net.au> and Oliver Neukum <oliver@neukum.org>");
117MODULE_DESCRIPTION("KL5USB101 USB Ethernet driver"); 112MODULE_DESCRIPTION("KL5USB101 USB Ethernet driver");
@@ -128,6 +123,8 @@ static int kaweth_internal_control_msg(struct usb_device *usb_dev,
128 unsigned int pipe, 123 unsigned int pipe,
129 struct usb_ctrlrequest *cmd, void *data, 124 struct usb_ctrlrequest *cmd, void *data,
130 int len, int timeout); 125 int len, int timeout);
126static int kaweth_suspend(struct usb_interface *intf, pm_message_t message);
127static int kaweth_resume(struct usb_interface *intf);
131 128
132/**************************************************************** 129/****************************************************************
133 * usb_device_id 130 * usb_device_id
@@ -179,6 +176,8 @@ static struct usb_driver kaweth_driver = {
179 .name = driver_name, 176 .name = driver_name,
180 .probe = kaweth_probe, 177 .probe = kaweth_probe,
181 .disconnect = kaweth_disconnect, 178 .disconnect = kaweth_disconnect,
179 .suspend = kaweth_suspend,
180 .resume = kaweth_resume,
182 .id_table = usb_klsi_table, 181 .id_table = usb_klsi_table,
183}; 182};
184 183
@@ -222,6 +221,7 @@ struct kaweth_device
222 int suspend_lowmem_rx; 221 int suspend_lowmem_rx;
223 int suspend_lowmem_ctrl; 222 int suspend_lowmem_ctrl;
224 int linkstate; 223 int linkstate;
224 int opened;
225 struct work_struct lowmem_work; 225 struct work_struct lowmem_work;
226 226
227 struct usb_device *dev; 227 struct usb_device *dev;
@@ -265,17 +265,17 @@ static int kaweth_control(struct kaweth_device *kaweth,
265{ 265{
266 struct usb_ctrlrequest *dr; 266 struct usb_ctrlrequest *dr;
267 267
268 kaweth_dbg("kaweth_control()"); 268 dbg("kaweth_control()");
269 269
270 if(in_interrupt()) { 270 if(in_interrupt()) {
271 kaweth_dbg("in_interrupt()"); 271 dbg("in_interrupt()");
272 return -EBUSY; 272 return -EBUSY;
273 } 273 }
274 274
275 dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC); 275 dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC);
276 276
277 if (!dr) { 277 if (!dr) {
278 kaweth_dbg("kmalloc() failed"); 278 dbg("kmalloc() failed");
279 return -ENOMEM; 279 return -ENOMEM;
280 } 280 }
281 281
@@ -300,7 +300,7 @@ static int kaweth_read_configuration(struct kaweth_device *kaweth)
300{ 300{
301 int retval; 301 int retval;
302 302
303 kaweth_dbg("Reading kaweth configuration"); 303 dbg("Reading kaweth configuration");
304 304
305 retval = kaweth_control(kaweth, 305 retval = kaweth_control(kaweth,
306 usb_rcvctrlpipe(kaweth->dev, 0), 306 usb_rcvctrlpipe(kaweth->dev, 0),
@@ -322,7 +322,7 @@ static int kaweth_set_urb_size(struct kaweth_device *kaweth, __u16 urb_size)
322{ 322{
323 int retval; 323 int retval;
324 324
325 kaweth_dbg("Setting URB size to %d", (unsigned)urb_size); 325 dbg("Setting URB size to %d", (unsigned)urb_size);
326 326
327 retval = kaweth_control(kaweth, 327 retval = kaweth_control(kaweth,
328 usb_sndctrlpipe(kaweth->dev, 0), 328 usb_sndctrlpipe(kaweth->dev, 0),
@@ -344,7 +344,7 @@ static int kaweth_set_sofs_wait(struct kaweth_device *kaweth, __u16 sofs_wait)
344{ 344{
345 int retval; 345 int retval;
346 346
347 kaweth_dbg("Set SOFS wait to %d", (unsigned)sofs_wait); 347 dbg("Set SOFS wait to %d", (unsigned)sofs_wait);
348 348
349 retval = kaweth_control(kaweth, 349 retval = kaweth_control(kaweth,
350 usb_sndctrlpipe(kaweth->dev, 0), 350 usb_sndctrlpipe(kaweth->dev, 0),
@@ -367,7 +367,7 @@ static int kaweth_set_receive_filter(struct kaweth_device *kaweth,
367{ 367{
368 int retval; 368 int retval;
369 369
370 kaweth_dbg("Set receive filter to %d", (unsigned)receive_filter); 370 dbg("Set receive filter to %d", (unsigned)receive_filter);
371 371
372 retval = kaweth_control(kaweth, 372 retval = kaweth_control(kaweth,
373 usb_sndctrlpipe(kaweth->dev, 0), 373 usb_sndctrlpipe(kaweth->dev, 0),
@@ -392,7 +392,7 @@ static int kaweth_download_firmware(struct kaweth_device *kaweth,
392 __u8 type) 392 __u8 type)
393{ 393{
394 if(data_len > KAWETH_FIRMWARE_BUF_SIZE) { 394 if(data_len > KAWETH_FIRMWARE_BUF_SIZE) {
395 kaweth_err("Firmware too big: %d", data_len); 395 err("Firmware too big: %d", data_len);
396 return -ENOSPC; 396 return -ENOSPC;
397 } 397 }
398 398
@@ -403,13 +403,13 @@ static int kaweth_download_firmware(struct kaweth_device *kaweth,
403 kaweth->firmware_buf[4] = type; 403 kaweth->firmware_buf[4] = type;
404 kaweth->firmware_buf[5] = interrupt; 404 kaweth->firmware_buf[5] = interrupt;
405 405
406 kaweth_dbg("High: %i, Low:%i", kaweth->firmware_buf[3], 406 dbg("High: %i, Low:%i", kaweth->firmware_buf[3],
407 kaweth->firmware_buf[2]); 407 kaweth->firmware_buf[2]);
408 408
409 kaweth_dbg("Downloading firmware at %p to kaweth device at %p", 409 dbg("Downloading firmware at %p to kaweth device at %p",
410 data, 410 data,
411 kaweth); 411 kaweth);
412 kaweth_dbg("Firmware length: %d", data_len); 412 dbg("Firmware length: %d", data_len);
413 413
414 return kaweth_control(kaweth, 414 return kaweth_control(kaweth,
415 usb_sndctrlpipe(kaweth->dev, 0), 415 usb_sndctrlpipe(kaweth->dev, 0),
@@ -437,7 +437,7 @@ static int kaweth_trigger_firmware(struct kaweth_device *kaweth,
437 kaweth->firmware_buf[6] = 0x00; 437 kaweth->firmware_buf[6] = 0x00;
438 kaweth->firmware_buf[7] = 0x00; 438 kaweth->firmware_buf[7] = 0x00;
439 439
440 kaweth_dbg("Triggering firmware"); 440 dbg("Triggering firmware");
441 441
442 return kaweth_control(kaweth, 442 return kaweth_control(kaweth,
443 usb_sndctrlpipe(kaweth->dev, 0), 443 usb_sndctrlpipe(kaweth->dev, 0),
@@ -457,7 +457,7 @@ static int kaweth_reset(struct kaweth_device *kaweth)
457{ 457{
458 int result; 458 int result;
459 459
460 kaweth_dbg("kaweth_reset(%p)", kaweth); 460 dbg("kaweth_reset(%p)", kaweth);
461 result = kaweth_control(kaweth, 461 result = kaweth_control(kaweth,
462 usb_sndctrlpipe(kaweth->dev, 0), 462 usb_sndctrlpipe(kaweth->dev, 0),
463 USB_REQ_SET_CONFIGURATION, 463 USB_REQ_SET_CONFIGURATION,
@@ -470,7 +470,7 @@ static int kaweth_reset(struct kaweth_device *kaweth)
470 470
471 mdelay(10); 471 mdelay(10);
472 472
473 kaweth_dbg("kaweth_reset() returns %d.",result); 473 dbg("kaweth_reset() returns %d.",result);
474 474
475 return result; 475 return result;
476} 476}
@@ -534,7 +534,7 @@ static void kaweth_resubmit_tl(void *d)
534{ 534{
535 struct kaweth_device *kaweth = (struct kaweth_device *)d; 535 struct kaweth_device *kaweth = (struct kaweth_device *)d;
536 536
537 if (kaweth->status | KAWETH_STATUS_CLOSING) 537 if (IS_BLOCKED(kaweth->status))
538 return; 538 return;
539 539
540 if (kaweth->suspend_lowmem_rx) 540 if (kaweth->suspend_lowmem_rx)
@@ -568,7 +568,7 @@ static int kaweth_resubmit_rx_urb(struct kaweth_device *kaweth,
568 kaweth->suspend_lowmem_rx = 1; 568 kaweth->suspend_lowmem_rx = 1;
569 schedule_delayed_work(&kaweth->lowmem_work, HZ/4); 569 schedule_delayed_work(&kaweth->lowmem_work, HZ/4);
570 } 570 }
571 kaweth_err("resubmitting rx_urb %d failed", result); 571 err("resubmitting rx_urb %d failed", result);
572 } else { 572 } else {
573 kaweth->suspend_lowmem_rx = 0; 573 kaweth->suspend_lowmem_rx = 0;
574 } 574 }
@@ -601,11 +601,15 @@ static void kaweth_usb_receive(struct urb *urb)
601 return; 601 return;
602 } 602 }
603 603
604 if (kaweth->status & KAWETH_STATUS_CLOSING) 604 spin_lock(&kaweth->device_lock);
605 if (IS_BLOCKED(kaweth->status)) {
606 spin_unlock(&kaweth->device_lock);
605 return; 607 return;
608 }
609 spin_unlock(&kaweth->device_lock);
606 610
607 if(urb->status && urb->status != -EREMOTEIO && count != 1) { 611 if(urb->status && urb->status != -EREMOTEIO && count != 1) {
608 kaweth_err("%s RX status: %d count: %d packet_len: %d", 612 err("%s RX status: %d count: %d packet_len: %d",
609 net->name, 613 net->name,
610 urb->status, 614 urb->status,
611 count, 615 count,
@@ -616,9 +620,9 @@ static void kaweth_usb_receive(struct urb *urb)
616 620
617 if(kaweth->net && (count > 2)) { 621 if(kaweth->net && (count > 2)) {
618 if(pkt_len > (count - 2)) { 622 if(pkt_len > (count - 2)) {
619 kaweth_err("Packet length too long for USB frame (pkt_len: %x, count: %x)",pkt_len, count); 623 err("Packet length too long for USB frame (pkt_len: %x, count: %x)",pkt_len, count);
620 kaweth_err("Packet len & 2047: %x", pkt_len & 2047); 624 err("Packet len & 2047: %x", pkt_len & 2047);
621 kaweth_err("Count 2: %x", count2); 625 err("Count 2: %x", count2);
622 kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC); 626 kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC);
623 return; 627 return;
624 } 628 }
@@ -655,7 +659,7 @@ static int kaweth_open(struct net_device *net)
655 struct kaweth_device *kaweth = netdev_priv(net); 659 struct kaweth_device *kaweth = netdev_priv(net);
656 int res; 660 int res;
657 661
658 kaweth_dbg("Opening network device."); 662 dbg("Opening network device.");
659 663
660 res = kaweth_resubmit_rx_urb(kaweth, GFP_KERNEL); 664 res = kaweth_resubmit_rx_urb(kaweth, GFP_KERNEL);
661 if (res) 665 if (res)
@@ -678,6 +682,7 @@ static int kaweth_open(struct net_device *net)
678 usb_kill_urb(kaweth->rx_urb); 682 usb_kill_urb(kaweth->rx_urb);
679 return -EIO; 683 return -EIO;
680 } 684 }
685 kaweth->opened = 1;
681 686
682 netif_start_queue(net); 687 netif_start_queue(net);
683 688
@@ -688,14 +693,8 @@ static int kaweth_open(struct net_device *net)
688/**************************************************************** 693/****************************************************************
689 * kaweth_close 694 * kaweth_close
690 ****************************************************************/ 695 ****************************************************************/
691static int kaweth_close(struct net_device *net) 696static void kaweth_kill_urbs(struct kaweth_device *kaweth)
692{ 697{
693 struct kaweth_device *kaweth = netdev_priv(net);
694
695 netif_stop_queue(net);
696
697 kaweth->status |= KAWETH_STATUS_CLOSING;
698
699 usb_kill_urb(kaweth->irq_urb); 698 usb_kill_urb(kaweth->irq_urb);
700 usb_kill_urb(kaweth->rx_urb); 699 usb_kill_urb(kaweth->rx_urb);
701 usb_kill_urb(kaweth->tx_urb); 700 usb_kill_urb(kaweth->tx_urb);
@@ -706,6 +705,21 @@ static int kaweth_close(struct net_device *net)
706 we hit them again */ 705 we hit them again */
707 usb_kill_urb(kaweth->irq_urb); 706 usb_kill_urb(kaweth->irq_urb);
708 usb_kill_urb(kaweth->rx_urb); 707 usb_kill_urb(kaweth->rx_urb);
708}
709
710/****************************************************************
711 * kaweth_close
712 ****************************************************************/
713static int kaweth_close(struct net_device *net)
714{
715 struct kaweth_device *kaweth = netdev_priv(net);
716
717 netif_stop_queue(net);
718 kaweth->opened = 0;
719
720 kaweth->status |= KAWETH_STATUS_CLOSING;
721
722 kaweth_kill_urbs(kaweth);
709 723
710 kaweth->status &= ~KAWETH_STATUS_CLOSING; 724 kaweth->status &= ~KAWETH_STATUS_CLOSING;
711 725
@@ -732,7 +746,7 @@ static void kaweth_usb_transmit_complete(struct urb *urb)
732 746
733 if (unlikely(urb->status != 0)) 747 if (unlikely(urb->status != 0))
734 if (urb->status != -ENOENT) 748 if (urb->status != -ENOENT)
735 kaweth_dbg("%s: TX status %d.", kaweth->net->name, urb->status); 749 dbg("%s: TX status %d.", kaweth->net->name, urb->status);
736 750
737 netif_wake_queue(kaweth->net); 751 netif_wake_queue(kaweth->net);
738 dev_kfree_skb_irq(skb); 752 dev_kfree_skb_irq(skb);
@@ -752,6 +766,9 @@ static int kaweth_start_xmit(struct sk_buff *skb, struct net_device *net)
752 766
753 kaweth_async_set_rx_mode(kaweth); 767 kaweth_async_set_rx_mode(kaweth);
754 netif_stop_queue(net); 768 netif_stop_queue(net);
769 if (IS_BLOCKED(kaweth->status)) {
770 goto skip;
771 }
755 772
756 /* We now decide whether we can put our special header into the sk_buff */ 773 /* We now decide whether we can put our special header into the sk_buff */
757 if (skb_cloned(skb) || skb_headroom(skb) < 2) { 774 if (skb_cloned(skb) || skb_headroom(skb) < 2) {
@@ -783,7 +800,8 @@ static int kaweth_start_xmit(struct sk_buff *skb, struct net_device *net)
783 800
784 if((res = usb_submit_urb(kaweth->tx_urb, GFP_ATOMIC))) 801 if((res = usb_submit_urb(kaweth->tx_urb, GFP_ATOMIC)))
785 { 802 {
786 kaweth_warn("kaweth failed tx_urb %d", res); 803 warn("kaweth failed tx_urb %d", res);
804skip:
787 kaweth->stats.tx_errors++; 805 kaweth->stats.tx_errors++;
788 806
789 netif_start_queue(net); 807 netif_start_queue(net);
@@ -812,7 +830,7 @@ static void kaweth_set_rx_mode(struct net_device *net)
812 KAWETH_PACKET_FILTER_BROADCAST | 830 KAWETH_PACKET_FILTER_BROADCAST |
813 KAWETH_PACKET_FILTER_MULTICAST; 831 KAWETH_PACKET_FILTER_MULTICAST;
814 832
815 kaweth_dbg("Setting Rx mode to %d", packet_filter_bitmap); 833 dbg("Setting Rx mode to %d", packet_filter_bitmap);
816 834
817 netif_stop_queue(net); 835 netif_stop_queue(net);
818 836
@@ -850,10 +868,10 @@ static void kaweth_async_set_rx_mode(struct kaweth_device *kaweth)
850 KAWETH_CONTROL_TIMEOUT); 868 KAWETH_CONTROL_TIMEOUT);
851 869
852 if(result < 0) { 870 if(result < 0) {
853 kaweth_err("Failed to set Rx mode: %d", result); 871 err("Failed to set Rx mode: %d", result);
854 } 872 }
855 else { 873 else {
856 kaweth_dbg("Set Rx mode to %d", packet_filter_bitmap); 874 dbg("Set Rx mode to %d", packet_filter_bitmap);
857 } 875 }
858 } 876 }
859} 877}
@@ -874,7 +892,7 @@ static void kaweth_tx_timeout(struct net_device *net)
874{ 892{
875 struct kaweth_device *kaweth = netdev_priv(net); 893 struct kaweth_device *kaweth = netdev_priv(net);
876 894
877 kaweth_warn("%s: Tx timed out. Resetting.", net->name); 895 warn("%s: Tx timed out. Resetting.", net->name);
878 kaweth->stats.tx_errors++; 896 kaweth->stats.tx_errors++;
879 net->trans_start = jiffies; 897 net->trans_start = jiffies;
880 898
@@ -882,6 +900,42 @@ static void kaweth_tx_timeout(struct net_device *net)
882} 900}
883 901
884/**************************************************************** 902/****************************************************************
903 * kaweth_suspend
904 ****************************************************************/
905static int kaweth_suspend(struct usb_interface *intf, pm_message_t message)
906{
907 struct kaweth_device *kaweth = usb_get_intfdata(intf);
908 unsigned long flags;
909
910 spin_lock_irqsave(&kaweth->device_lock, flags);
911 kaweth->status |= KAWETH_STATUS_SUSPENDING;
912 spin_unlock_irqrestore(&kaweth->device_lock, flags);
913
914 kaweth_kill_urbs(kaweth);
915 return 0;
916}
917
918/****************************************************************
919 * kaweth_resume
920 ****************************************************************/
921static int kaweth_resume(struct usb_interface *intf)
922{
923 struct kaweth_device *kaweth = usb_get_intfdata(intf);
924 unsigned long flags;
925
926 spin_lock_irqsave(&kaweth->device_lock, flags);
927 kaweth->status &= ~KAWETH_STATUS_SUSPENDING;
928 spin_unlock_irqrestore(&kaweth->device_lock, flags);
929
930 if (!kaweth->opened)
931 return 0;
932 kaweth_resubmit_rx_urb(kaweth, GFP_NOIO);
933 kaweth_resubmit_int_urb(kaweth, GFP_NOIO);
934
935 return 0;
936}
937
938/****************************************************************
885 * kaweth_probe 939 * kaweth_probe
886 ****************************************************************/ 940 ****************************************************************/
887static int kaweth_probe( 941static int kaweth_probe(
@@ -895,15 +949,15 @@ static int kaweth_probe(
895 const eth_addr_t bcast_addr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; 949 const eth_addr_t bcast_addr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
896 int result = 0; 950 int result = 0;
897 951
898 kaweth_dbg("Kawasaki Device Probe (Device number:%d): 0x%4.4x:0x%4.4x:0x%4.4x", 952 dbg("Kawasaki Device Probe (Device number:%d): 0x%4.4x:0x%4.4x:0x%4.4x",
899 dev->devnum, 953 dev->devnum,
900 le16_to_cpu(dev->descriptor.idVendor), 954 le16_to_cpu(dev->descriptor.idVendor),
901 le16_to_cpu(dev->descriptor.idProduct), 955 le16_to_cpu(dev->descriptor.idProduct),
902 le16_to_cpu(dev->descriptor.bcdDevice)); 956 le16_to_cpu(dev->descriptor.bcdDevice));
903 957
904 kaweth_dbg("Device at %p", dev); 958 dbg("Device at %p", dev);
905 959
906 kaweth_dbg("Descriptor length: %x type: %x", 960 dbg("Descriptor length: %x type: %x",
907 (int)dev->descriptor.bLength, 961 (int)dev->descriptor.bLength,
908 (int)dev->descriptor.bDescriptorType); 962 (int)dev->descriptor.bDescriptorType);
909 963
@@ -918,7 +972,7 @@ static int kaweth_probe(
918 spin_lock_init(&kaweth->device_lock); 972 spin_lock_init(&kaweth->device_lock);
919 init_waitqueue_head(&kaweth->term_wait); 973 init_waitqueue_head(&kaweth->term_wait);
920 974
921 kaweth_dbg("Resetting."); 975 dbg("Resetting.");
922 976
923 kaweth_reset(kaweth); 977 kaweth_reset(kaweth);
924 978
@@ -928,17 +982,17 @@ static int kaweth_probe(
928 */ 982 */
929 983
930 if (le16_to_cpu(dev->descriptor.bcdDevice) >> 8) { 984 if (le16_to_cpu(dev->descriptor.bcdDevice) >> 8) {
931 kaweth_info("Firmware present in device."); 985 info("Firmware present in device.");
932 } else { 986 } else {
933 /* Download the firmware */ 987 /* Download the firmware */
934 kaweth_info("Downloading firmware..."); 988 info("Downloading firmware...");
935 kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL); 989 kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL);
936 if ((result = kaweth_download_firmware(kaweth, 990 if ((result = kaweth_download_firmware(kaweth,
937 kaweth_new_code, 991 kaweth_new_code,
938 len_kaweth_new_code, 992 len_kaweth_new_code,
939 100, 993 100,
940 2)) < 0) { 994 2)) < 0) {
941 kaweth_err("Error downloading firmware (%d)", result); 995 err("Error downloading firmware (%d)", result);
942 goto err_fw; 996 goto err_fw;
943 } 997 }
944 998
@@ -947,7 +1001,7 @@ static int kaweth_probe(
947 len_kaweth_new_code_fix, 1001 len_kaweth_new_code_fix,
948 100, 1002 100,
949 3)) < 0) { 1003 3)) < 0) {
950 kaweth_err("Error downloading firmware fix (%d)", result); 1004 err("Error downloading firmware fix (%d)", result);
951 goto err_fw; 1005 goto err_fw;
952 } 1006 }
953 1007
@@ -956,7 +1010,7 @@ static int kaweth_probe(
956 len_kaweth_trigger_code, 1010 len_kaweth_trigger_code,
957 126, 1011 126,
958 2)) < 0) { 1012 2)) < 0) {
959 kaweth_err("Error downloading trigger code (%d)", result); 1013 err("Error downloading trigger code (%d)", result);
960 goto err_fw; 1014 goto err_fw;
961 1015
962 } 1016 }
@@ -966,18 +1020,18 @@ static int kaweth_probe(
966 len_kaweth_trigger_code_fix, 1020 len_kaweth_trigger_code_fix,
967 126, 1021 126,
968 3)) < 0) { 1022 3)) < 0) {
969 kaweth_err("Error downloading trigger code fix (%d)", result); 1023 err("Error downloading trigger code fix (%d)", result);
970 goto err_fw; 1024 goto err_fw;
971 } 1025 }
972 1026
973 1027
974 if ((result = kaweth_trigger_firmware(kaweth, 126)) < 0) { 1028 if ((result = kaweth_trigger_firmware(kaweth, 126)) < 0) {
975 kaweth_err("Error triggering firmware (%d)", result); 1029 err("Error triggering firmware (%d)", result);
976 goto err_fw; 1030 goto err_fw;
977 } 1031 }
978 1032
979 /* Device will now disappear for a moment... */ 1033 /* Device will now disappear for a moment... */
980 kaweth_info("Firmware loaded. I'll be back..."); 1034 info("Firmware loaded. I'll be back...");
981err_fw: 1035err_fw:
982 free_page((unsigned long)kaweth->firmware_buf); 1036 free_page((unsigned long)kaweth->firmware_buf);
983 free_netdev(netdev); 1037 free_netdev(netdev);
@@ -987,14 +1041,14 @@ err_fw:
987 result = kaweth_read_configuration(kaweth); 1041 result = kaweth_read_configuration(kaweth);
988 1042
989 if(result < 0) { 1043 if(result < 0) {
990 kaweth_err("Error reading configuration (%d), no net device created", result); 1044 err("Error reading configuration (%d), no net device created", result);
991 goto err_free_netdev; 1045 goto err_free_netdev;
992 } 1046 }
993 1047
994 kaweth_info("Statistics collection: %x", kaweth->configuration.statistics_mask); 1048 info("Statistics collection: %x", kaweth->configuration.statistics_mask);
995 kaweth_info("Multicast filter limit: %x", kaweth->configuration.max_multicast_filters & ((1 << 15) - 1)); 1049 info("Multicast filter limit: %x", kaweth->configuration.max_multicast_filters & ((1 << 15) - 1));
996 kaweth_info("MTU: %d", le16_to_cpu(kaweth->configuration.segment_size)); 1050 info("MTU: %d", le16_to_cpu(kaweth->configuration.segment_size));
997 kaweth_info("Read MAC address %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x", 1051 info("Read MAC address %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x",
998 (int)kaweth->configuration.hw_addr[0], 1052 (int)kaweth->configuration.hw_addr[0],
999 (int)kaweth->configuration.hw_addr[1], 1053 (int)kaweth->configuration.hw_addr[1],
1000 (int)kaweth->configuration.hw_addr[2], 1054 (int)kaweth->configuration.hw_addr[2],
@@ -1005,17 +1059,17 @@ err_fw:
1005 if(!memcmp(&kaweth->configuration.hw_addr, 1059 if(!memcmp(&kaweth->configuration.hw_addr,
1006 &bcast_addr, 1060 &bcast_addr,
1007 sizeof(bcast_addr))) { 1061 sizeof(bcast_addr))) {
1008 kaweth_err("Firmware not functioning properly, no net device created"); 1062 err("Firmware not functioning properly, no net device created");
1009 goto err_free_netdev; 1063 goto err_free_netdev;
1010 } 1064 }
1011 1065
1012 if(kaweth_set_urb_size(kaweth, KAWETH_BUF_SIZE) < 0) { 1066 if(kaweth_set_urb_size(kaweth, KAWETH_BUF_SIZE) < 0) {
1013 kaweth_dbg("Error setting URB size"); 1067 dbg("Error setting URB size");
1014 goto err_free_netdev; 1068 goto err_free_netdev;
1015 } 1069 }
1016 1070
1017 if(kaweth_set_sofs_wait(kaweth, KAWETH_SOFS_TO_WAIT) < 0) { 1071 if(kaweth_set_sofs_wait(kaweth, KAWETH_SOFS_TO_WAIT) < 0) {
1018 kaweth_err("Error setting SOFS wait"); 1072 err("Error setting SOFS wait");
1019 goto err_free_netdev; 1073 goto err_free_netdev;
1020 } 1074 }
1021 1075
@@ -1025,11 +1079,11 @@ err_fw:
1025 KAWETH_PACKET_FILTER_MULTICAST); 1079 KAWETH_PACKET_FILTER_MULTICAST);
1026 1080
1027 if(result < 0) { 1081 if(result < 0) {
1028 kaweth_err("Error setting receive filter"); 1082 err("Error setting receive filter");
1029 goto err_free_netdev; 1083 goto err_free_netdev;
1030 } 1084 }
1031 1085
1032 kaweth_dbg("Initializing net device."); 1086 dbg("Initializing net device.");
1033 1087
1034 kaweth->tx_urb = usb_alloc_urb(0, GFP_KERNEL); 1088 kaweth->tx_urb = usb_alloc_urb(0, GFP_KERNEL);
1035 if (!kaweth->tx_urb) 1089 if (!kaweth->tx_urb)
@@ -1086,13 +1140,13 @@ err_fw:
1086 1140
1087 SET_NETDEV_DEV(netdev, &intf->dev); 1141 SET_NETDEV_DEV(netdev, &intf->dev);
1088 if (register_netdev(netdev) != 0) { 1142 if (register_netdev(netdev) != 0) {
1089 kaweth_err("Error registering netdev."); 1143 err("Error registering netdev.");
1090 goto err_intfdata; 1144 goto err_intfdata;
1091 } 1145 }
1092 1146
1093 kaweth_info("kaweth interface created at %s", kaweth->net->name); 1147 info("kaweth interface created at %s", kaweth->net->name);
1094 1148
1095 kaweth_dbg("Kaweth probe returning."); 1149 dbg("Kaweth probe returning.");
1096 1150
1097 return 0; 1151 return 0;
1098 1152
@@ -1121,16 +1175,16 @@ static void kaweth_disconnect(struct usb_interface *intf)
1121 struct kaweth_device *kaweth = usb_get_intfdata(intf); 1175 struct kaweth_device *kaweth = usb_get_intfdata(intf);
1122 struct net_device *netdev; 1176 struct net_device *netdev;
1123 1177
1124 kaweth_info("Unregistering"); 1178 info("Unregistering");
1125 1179
1126 usb_set_intfdata(intf, NULL); 1180 usb_set_intfdata(intf, NULL);
1127 if (!kaweth) { 1181 if (!kaweth) {
1128 kaweth_warn("unregistering non-existant device"); 1182 warn("unregistering non-existant device");
1129 return; 1183 return;
1130 } 1184 }
1131 netdev = kaweth->net; 1185 netdev = kaweth->net;
1132 1186
1133 kaweth_dbg("Unregistering net device"); 1187 dbg("Unregistering net device");
1134 unregister_netdev(netdev); 1188 unregister_netdev(netdev);
1135 1189
1136 usb_free_urb(kaweth->rx_urb); 1190 usb_free_urb(kaweth->rx_urb);
@@ -1185,7 +1239,7 @@ static int usb_start_wait_urb(struct urb *urb, int timeout, int* actual_length)
1185 1239
1186 if (!wait_event_timeout(awd.wqh, awd.done, timeout)) { 1240 if (!wait_event_timeout(awd.wqh, awd.done, timeout)) {
1187 // timeout 1241 // timeout
1188 kaweth_warn("usb_control/bulk_msg: timeout"); 1242 warn("usb_control/bulk_msg: timeout");
1189 usb_kill_urb(urb); // remove urb safely 1243 usb_kill_urb(urb); // remove urb safely
1190 status = -ETIMEDOUT; 1244 status = -ETIMEDOUT;
1191 } 1245 }
@@ -1234,7 +1288,7 @@ static int kaweth_internal_control_msg(struct usb_device *usb_dev,
1234 ****************************************************************/ 1288 ****************************************************************/
1235static int __init kaweth_init(void) 1289static int __init kaweth_init(void)
1236{ 1290{
1237 kaweth_dbg("Driver loading"); 1291 dbg("Driver loading");
1238 return usb_register(&kaweth_driver); 1292 return usb_register(&kaweth_driver);
1239} 1293}
1240 1294
diff --git a/drivers/usb/net/mcs7830.c b/drivers/usb/net/mcs7830.c
new file mode 100644
index 000000000000..6240b978fe3d
--- /dev/null
+++ b/drivers/usb/net/mcs7830.c
@@ -0,0 +1,534 @@
1/*
2 * MosChips MCS7830 based USB 2.0 Ethernet Devices
3 *
4 * based on usbnet.c, asix.c and the vendor provided mcs7830 driver
5 *
6 * Copyright (C) 2006 Arnd Bergmann <arnd@arndb.de>
7 * Copyright (C) 2003-2005 David Hollis <dhollis@davehollis.com>
8 * Copyright (C) 2005 Phil Chang <pchang23@sbcglobal.net>
9 * Copyright (c) 2002-2003 TiVo Inc.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26#include <linux/crc32.h>
27#include <linux/etherdevice.h>
28#include <linux/ethtool.h>
29#include <linux/init.h>
30#include <linux/mii.h>
31#include <linux/module.h>
32#include <linux/netdevice.h>
33#include <linux/usb.h>
34
35#include "usbnet.h"
36
37/* requests */
38#define MCS7830_RD_BMREQ (USB_DIR_IN | USB_TYPE_VENDOR | \
39 USB_RECIP_DEVICE)
40#define MCS7830_WR_BMREQ (USB_DIR_OUT | USB_TYPE_VENDOR | \
41 USB_RECIP_DEVICE)
42#define MCS7830_RD_BREQ 0x0E
43#define MCS7830_WR_BREQ 0x0D
44
45#define MCS7830_CTRL_TIMEOUT 1000
46#define MCS7830_MAX_MCAST 64
47
48#define MCS7830_VENDOR_ID 0x9710
49#define MCS7830_PRODUCT_ID 0x7830
50
51#define MCS7830_MII_ADVERTISE (ADVERTISE_PAUSE_CAP | ADVERTISE_100FULL | \
52 ADVERTISE_100HALF | ADVERTISE_10FULL | \
53 ADVERTISE_10HALF | ADVERTISE_CSMA)
54
55/* HIF_REG_XX coressponding index value */
56enum {
57 HIF_REG_MULTICAST_HASH = 0x00,
58 HIF_REG_PACKET_GAP1 = 0x08,
59 HIF_REG_PACKET_GAP2 = 0x09,
60 HIF_REG_PHY_DATA = 0x0a,
61 HIF_REG_PHY_CMD1 = 0x0c,
62 HIF_REG_PHY_CMD1_READ = 0x40,
63 HIF_REG_PHY_CMD1_WRITE = 0x20,
64 HIF_REG_PHY_CMD1_PHYADDR = 0x01,
65 HIF_REG_PHY_CMD2 = 0x0d,
66 HIF_REG_PHY_CMD2_PEND_FLAG_BIT = 0x80,
67 HIF_REG_PHY_CMD2_READY_FLAG_BIT = 0x40,
68 HIF_REG_CONFIG = 0x0e,
69 HIF_REG_CONFIG_CFG = 0x80,
70 HIF_REG_CONFIG_SPEED100 = 0x40,
71 HIF_REG_CONFIG_FULLDUPLEX_ENABLE = 0x20,
72 HIF_REG_CONFIG_RXENABLE = 0x10,
73 HIF_REG_CONFIG_TXENABLE = 0x08,
74 HIF_REG_CONFIG_SLEEPMODE = 0x04,
75 HIF_REG_CONFIG_ALLMULTICAST = 0x02,
76 HIF_REG_CONFIG_PROMISCIOUS = 0x01,
77 HIF_REG_ETHERNET_ADDR = 0x0f,
78 HIF_REG_22 = 0x15,
79 HIF_REG_PAUSE_THRESHOLD = 0x16,
80 HIF_REG_PAUSE_THRESHOLD_DEFAULT = 0,
81};
82
83struct mcs7830_data {
84 u8 multi_filter[8];
85 u8 config;
86};
87
88static const char driver_name[] = "MOSCHIP usb-ethernet driver";
89
90static int mcs7830_get_reg(struct usbnet *dev, u16 index, u16 size, void *data)
91{
92 struct usb_device *xdev = dev->udev;
93 int ret;
94
95 ret = usb_control_msg(xdev, usb_rcvctrlpipe(xdev, 0), MCS7830_RD_BREQ,
96 MCS7830_RD_BMREQ, 0x0000, index, data,
97 size, msecs_to_jiffies(MCS7830_CTRL_TIMEOUT));
98 return ret;
99}
100
101static int mcs7830_set_reg(struct usbnet *dev, u16 index, u16 size, void *data)
102{
103 struct usb_device *xdev = dev->udev;
104 int ret;
105
106 ret = usb_control_msg(xdev, usb_sndctrlpipe(xdev, 0), MCS7830_WR_BREQ,
107 MCS7830_WR_BMREQ, 0x0000, index, data,
108 size, msecs_to_jiffies(MCS7830_CTRL_TIMEOUT));
109 return ret;
110}
111
112static void mcs7830_async_cmd_callback(struct urb *urb)
113{
114 struct usb_ctrlrequest *req = (struct usb_ctrlrequest *)urb->context;
115
116 if (urb->status < 0)
117 printk(KERN_DEBUG "mcs7830_async_cmd_callback() failed with %d",
118 urb->status);
119
120 kfree(req);
121 usb_free_urb(urb);
122}
123
124static void mcs7830_set_reg_async(struct usbnet *dev, u16 index, u16 size, void *data)
125{
126 struct usb_ctrlrequest *req;
127 int ret;
128 struct urb *urb;
129
130 urb = usb_alloc_urb(0, GFP_ATOMIC);
131 if (!urb) {
132 dev_dbg(&dev->udev->dev, "Error allocating URB "
133 "in write_cmd_async!");
134 return;
135 }
136
137 req = kmalloc(sizeof *req, GFP_ATOMIC);
138 if (!req) {
139 dev_err(&dev->udev->dev, "Failed to allocate memory for "
140 "control request");
141 goto out;
142 }
143 req->bRequestType = MCS7830_WR_BMREQ;
144 req->bRequest = MCS7830_WR_BREQ;
145 req->wValue = 0;
146 req->wIndex = cpu_to_le16(index);
147 req->wLength = cpu_to_le16(size);
148
149 usb_fill_control_urb(urb, dev->udev,
150 usb_sndctrlpipe(dev->udev, 0),
151 (void *)req, data, size,
152 mcs7830_async_cmd_callback, req);
153
154 ret = usb_submit_urb(urb, GFP_ATOMIC);
155 if (ret < 0) {
156 dev_err(&dev->udev->dev, "Error submitting the control "
157 "message: ret=%d", ret);
158 goto out;
159 }
160 return;
161out:
162 kfree(req);
163 usb_free_urb(urb);
164}
165
166static int mcs7830_get_address(struct usbnet *dev)
167{
168 int ret;
169 ret = mcs7830_get_reg(dev, HIF_REG_ETHERNET_ADDR, ETH_ALEN,
170 dev->net->dev_addr);
171 if (ret < 0)
172 return ret;
173 return 0;
174}
175
176static int mcs7830_read_phy(struct usbnet *dev, u8 index)
177{
178 int ret;
179 int i;
180 __le16 val;
181
182 u8 cmd[2] = {
183 HIF_REG_PHY_CMD1_READ | HIF_REG_PHY_CMD1_PHYADDR,
184 HIF_REG_PHY_CMD2_PEND_FLAG_BIT | index,
185 };
186
187 mutex_lock(&dev->phy_mutex);
188 /* write the MII command */
189 ret = mcs7830_set_reg(dev, HIF_REG_PHY_CMD1, 2, cmd);
190 if (ret < 0)
191 goto out;
192
193 /* wait for the data to become valid, should be within < 1ms */
194 for (i = 0; i < 10; i++) {
195 ret = mcs7830_get_reg(dev, HIF_REG_PHY_CMD1, 2, cmd);
196 if ((ret < 0) || (cmd[1] & HIF_REG_PHY_CMD2_READY_FLAG_BIT))
197 break;
198 ret = -EIO;
199 msleep(1);
200 }
201 if (ret < 0)
202 goto out;
203
204 /* read actual register contents */
205 ret = mcs7830_get_reg(dev, HIF_REG_PHY_DATA, 2, &val);
206 if (ret < 0)
207 goto out;
208 ret = le16_to_cpu(val);
209 dev_dbg(&dev->udev->dev, "read PHY reg %02x: %04x (%d tries)\n",
210 index, val, i);
211out:
212 mutex_unlock(&dev->phy_mutex);
213 return ret;
214}
215
216static int mcs7830_write_phy(struct usbnet *dev, u8 index, u16 val)
217{
218 int ret;
219 int i;
220 __le16 le_val;
221
222 u8 cmd[2] = {
223 HIF_REG_PHY_CMD1_WRITE | HIF_REG_PHY_CMD1_PHYADDR,
224 HIF_REG_PHY_CMD2_PEND_FLAG_BIT | (index & 0x1F),
225 };
226
227 mutex_lock(&dev->phy_mutex);
228
229 /* write the new register contents */
230 le_val = cpu_to_le16(val);
231 ret = mcs7830_set_reg(dev, HIF_REG_PHY_DATA, 2, &le_val);
232 if (ret < 0)
233 goto out;
234
235 /* write the MII command */
236 ret = mcs7830_set_reg(dev, HIF_REG_PHY_CMD1, 2, cmd);
237 if (ret < 0)
238 goto out;
239
240 /* wait for the command to be accepted by the PHY */
241 for (i = 0; i < 10; i++) {
242 ret = mcs7830_get_reg(dev, HIF_REG_PHY_CMD1, 2, cmd);
243 if ((ret < 0) || (cmd[1] & HIF_REG_PHY_CMD2_READY_FLAG_BIT))
244 break;
245 ret = -EIO;
246 msleep(1);
247 }
248 if (ret < 0)
249 goto out;
250
251 ret = 0;
252 dev_dbg(&dev->udev->dev, "write PHY reg %02x: %04x (%d tries)\n",
253 index, val, i);
254out:
255 mutex_unlock(&dev->phy_mutex);
256 return ret;
257}
258
259/*
260 * This algorithm comes from the original mcs7830 version 1.4 driver,
261 * not sure if it is needed.
262 */
263static int mcs7830_set_autoneg(struct usbnet *dev, int ptrUserPhyMode)
264{
265 int ret;
266 /* Enable all media types */
267 ret = mcs7830_write_phy(dev, MII_ADVERTISE, MCS7830_MII_ADVERTISE);
268
269 /* First reset BMCR */
270 if (!ret)
271 ret = mcs7830_write_phy(dev, MII_BMCR, 0x0000);
272 /* Enable Auto Neg */
273 if (!ret)
274 ret = mcs7830_write_phy(dev, MII_BMCR, BMCR_ANENABLE);
275 /* Restart Auto Neg (Keep the Enable Auto Neg Bit Set) */
276 if (!ret)
277 ret = mcs7830_write_phy(dev, MII_BMCR,
278 BMCR_ANENABLE | BMCR_ANRESTART );
279 return ret < 0 ? : 0;
280}
281
282
283/*
284 * if we can read register 22, the chip revision is C or higher
285 */
286static int mcs7830_get_rev(struct usbnet *dev)
287{
288 u8 dummy[2];
289 int ret;
290 ret = mcs7830_get_reg(dev, HIF_REG_22, 2, dummy);
291 if (ret > 0)
292 return 2; /* Rev C or later */
293 return 1; /* earlier revision */
294}
295
296/*
297 * On rev. C we need to set the pause threshold
298 */
299static void mcs7830_rev_C_fixup(struct usbnet *dev)
300{
301 u8 pause_threshold = HIF_REG_PAUSE_THRESHOLD_DEFAULT;
302 int retry;
303
304 for (retry = 0; retry < 2; retry++) {
305 if (mcs7830_get_rev(dev) == 2) {
306 dev_info(&dev->udev->dev, "applying rev.C fixup\n");
307 mcs7830_set_reg(dev, HIF_REG_PAUSE_THRESHOLD,
308 1, &pause_threshold);
309 }
310 msleep(1);
311 }
312}
313
314static int mcs7830_init_dev(struct usbnet *dev)
315{
316 int ret;
317 int retry;
318
319 /* Read MAC address from EEPROM */
320 ret = -EINVAL;
321 for (retry = 0; retry < 5 && ret; retry++)
322 ret = mcs7830_get_address(dev);
323 if (ret) {
324 dev_warn(&dev->udev->dev, "Cannot read MAC address\n");
325 goto out;
326 }
327
328 /* Set up PHY */
329 ret = mcs7830_set_autoneg(dev, 0);
330 if (ret) {
331 dev_info(&dev->udev->dev, "Cannot set autoneg\n");
332 goto out;
333 }
334
335 mcs7830_rev_C_fixup(dev);
336 ret = 0;
337out:
338 return ret;
339}
340
341static int mcs7830_mdio_read(struct net_device *netdev, int phy_id,
342 int location)
343{
344 struct usbnet *dev = netdev->priv;
345 return mcs7830_read_phy(dev, location);
346}
347
348static void mcs7830_mdio_write(struct net_device *netdev, int phy_id,
349 int location, int val)
350{
351 struct usbnet *dev = netdev->priv;
352 mcs7830_write_phy(dev, location, val);
353}
354
355static int mcs7830_ioctl(struct net_device *net, struct ifreq *rq, int cmd)
356{
357 struct usbnet *dev = netdev_priv(net);
358 return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL);
359}
360
361/* credits go to asix_set_multicast */
362static void mcs7830_set_multicast(struct net_device *net)
363{
364 struct usbnet *dev = netdev_priv(net);
365 struct mcs7830_data *data = (struct mcs7830_data *)&dev->data;
366
367 data->config = HIF_REG_CONFIG_TXENABLE;
368
369 /* this should not be needed, but it doesn't work otherwise */
370 data->config |= HIF_REG_CONFIG_ALLMULTICAST;
371
372 if (net->flags & IFF_PROMISC) {
373 data->config |= HIF_REG_CONFIG_PROMISCIOUS;
374 } else if (net->flags & IFF_ALLMULTI
375 || net->mc_count > MCS7830_MAX_MCAST) {
376 data->config |= HIF_REG_CONFIG_ALLMULTICAST;
377 } else if (net->mc_count == 0) {
378 /* just broadcast and directed */
379 } else {
380 /* We use the 20 byte dev->data
381 * for our 8 byte filter buffer
382 * to avoid allocating memory that
383 * is tricky to free later */
384 struct dev_mc_list *mc_list = net->mc_list;
385 u32 crc_bits;
386 int i;
387
388 memset(data->multi_filter, 0, sizeof data->multi_filter);
389
390 /* Build the multicast hash filter. */
391 for (i = 0; i < net->mc_count; i++) {
392 crc_bits = ether_crc(ETH_ALEN, mc_list->dmi_addr) >> 26;
393 data->multi_filter[crc_bits >> 3] |= 1 << (crc_bits & 7);
394 mc_list = mc_list->next;
395 }
396
397 mcs7830_set_reg_async(dev, HIF_REG_MULTICAST_HASH,
398 sizeof data->multi_filter,
399 data->multi_filter);
400 }
401
402 mcs7830_set_reg_async(dev, HIF_REG_CONFIG, 1, &data->config);
403}
404
405static int mcs7830_get_regs_len(struct net_device *net)
406{
407 struct usbnet *dev = netdev_priv(net);
408
409 switch (mcs7830_get_rev(dev)) {
410 case 1:
411 return 21;
412 case 2:
413 return 32;
414 }
415 return 0;
416}
417
418static void mcs7830_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *drvinfo)
419{
420 usbnet_get_drvinfo(net, drvinfo);
421 drvinfo->regdump_len = mcs7830_get_regs_len(net);
422}
423
424static void mcs7830_get_regs(struct net_device *net, struct ethtool_regs *regs, void *data)
425{
426 struct usbnet *dev = netdev_priv(net);
427
428 regs->version = mcs7830_get_rev(dev);
429 mcs7830_get_reg(dev, 0, regs->len, data);
430}
431
432static struct ethtool_ops mcs7830_ethtool_ops = {
433 .get_drvinfo = mcs7830_get_drvinfo,
434 .get_regs_len = mcs7830_get_regs_len,
435 .get_regs = mcs7830_get_regs,
436
437 /* common usbnet calls */
438 .get_link = usbnet_get_link,
439 .get_msglevel = usbnet_get_msglevel,
440 .set_msglevel = usbnet_set_msglevel,
441 .get_settings = usbnet_get_settings,
442 .set_settings = usbnet_set_settings,
443 .nway_reset = usbnet_nway_reset,
444};
445
446static int mcs7830_bind(struct usbnet *dev, struct usb_interface *udev)
447{
448 struct net_device *net = dev->net;
449 int ret;
450
451 ret = mcs7830_init_dev(dev);
452 if (ret)
453 goto out;
454
455 net->do_ioctl = mcs7830_ioctl;
456 net->ethtool_ops = &mcs7830_ethtool_ops;
457 net->set_multicast_list = mcs7830_set_multicast;
458 mcs7830_set_multicast(net);
459
460 /* reserve space for the status byte on rx */
461 dev->rx_urb_size = ETH_FRAME_LEN + 1;
462
463 dev->mii.mdio_read = mcs7830_mdio_read;
464 dev->mii.mdio_write = mcs7830_mdio_write;
465 dev->mii.dev = net;
466 dev->mii.phy_id_mask = 0x3f;
467 dev->mii.reg_num_mask = 0x1f;
468 dev->mii.phy_id = *((u8 *) net->dev_addr + 1);
469
470 ret = usbnet_get_endpoints(dev, udev);
471out:
472 return ret;
473}
474
475/* The chip always appends a status bytes that we need to strip */
476static int mcs7830_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
477{
478 u8 status;
479
480 if (skb->len == 0) {
481 dev_err(&dev->udev->dev, "unexpected empty rx frame\n");
482 return 0;
483 }
484
485 skb_trim(skb, skb->len - 1);
486 status = skb->data[skb->len];
487
488 if (status != 0x20)
489 dev_dbg(&dev->udev->dev, "rx fixup status %x\n", status);
490
491 return skb->len > 0;
492}
493
494static const struct driver_info moschip_info = {
495 .description = "MOSCHIP 7830 usb-NET adapter",
496 .bind = mcs7830_bind,
497 .rx_fixup = mcs7830_rx_fixup,
498 .flags = FLAG_ETHER,
499 .in = 1,
500 .out = 2,
501};
502
503static const struct usb_device_id products[] = {
504 {
505 USB_DEVICE(MCS7830_VENDOR_ID, MCS7830_PRODUCT_ID),
506 .driver_info = (unsigned long) &moschip_info,
507 },
508 {},
509};
510MODULE_DEVICE_TABLE(usb, products);
511
512static struct usb_driver mcs7830_driver = {
513 .name = driver_name,
514 .id_table = products,
515 .probe = usbnet_probe,
516 .disconnect = usbnet_disconnect,
517 .suspend = usbnet_suspend,
518 .resume = usbnet_resume,
519};
520
521static int __init mcs7830_init(void)
522{
523 return usb_register(&mcs7830_driver);
524}
525module_init(mcs7830_init);
526
527static void __exit mcs7830_exit(void)
528{
529 usb_deregister(&mcs7830_driver);
530}
531module_exit(mcs7830_exit);
532
533MODULE_DESCRIPTION("USB to network adapter MCS7830)");
534MODULE_LICENSE("GPL");
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c
index 24bd3486ee63..760b5327b81b 100644
--- a/drivers/usb/net/usbnet.c
+++ b/drivers/usb/net/usbnet.c
@@ -554,7 +554,7 @@ static int usbnet_stop (struct net_device *net)
554{ 554{
555 struct usbnet *dev = netdev_priv(net); 555 struct usbnet *dev = netdev_priv(net);
556 int temp; 556 int temp;
557 DECLARE_WAIT_QUEUE_HEAD (unlink_wakeup); 557 DECLARE_WAIT_QUEUE_HEAD_ONSTACK (unlink_wakeup);
558 DECLARE_WAITQUEUE (wait, current); 558 DECLARE_WAITQUEUE (wait, current);
559 559
560 netif_stop_queue (net); 560 netif_stop_queue (net);
@@ -669,20 +669,40 @@ done:
669 * they'll probably want to use this base set. 669 * they'll probably want to use this base set.
670 */ 670 */
671 671
672void usbnet_get_drvinfo (struct net_device *net, struct ethtool_drvinfo *info) 672#if defined(CONFIG_MII) || defined(CONFIG_MII_MODULE)
673#define HAVE_MII
674
675int usbnet_get_settings (struct net_device *net, struct ethtool_cmd *cmd)
673{ 676{
674 struct usbnet *dev = netdev_priv(net); 677 struct usbnet *dev = netdev_priv(net);
675 678
676 /* REVISIT don't always return "usbnet" */ 679 if (!dev->mii.mdio_read)
677 strncpy (info->driver, driver_name, sizeof info->driver); 680 return -EOPNOTSUPP;
678 strncpy (info->version, DRIVER_VERSION, sizeof info->version); 681
679 strncpy (info->fw_version, dev->driver_info->description, 682 return mii_ethtool_gset(&dev->mii, cmd);
680 sizeof info->fw_version);
681 usb_make_path (dev->udev, info->bus_info, sizeof info->bus_info);
682} 683}
683EXPORT_SYMBOL_GPL(usbnet_get_drvinfo); 684EXPORT_SYMBOL_GPL(usbnet_get_settings);
685
686int usbnet_set_settings (struct net_device *net, struct ethtool_cmd *cmd)
687{
688 struct usbnet *dev = netdev_priv(net);
689 int retval;
690
691 if (!dev->mii.mdio_write)
692 return -EOPNOTSUPP;
684 693
685static u32 usbnet_get_link (struct net_device *net) 694 retval = mii_ethtool_sset(&dev->mii, cmd);
695
696 /* link speed/duplex might have changed */
697 if (dev->driver_info->link_reset)
698 dev->driver_info->link_reset(dev);
699
700 return retval;
701
702}
703EXPORT_SYMBOL_GPL(usbnet_set_settings);
704
705u32 usbnet_get_link (struct net_device *net)
686{ 706{
687 struct usbnet *dev = netdev_priv(net); 707 struct usbnet *dev = netdev_priv(net);
688 708
@@ -690,9 +710,40 @@ static u32 usbnet_get_link (struct net_device *net)
690 if (dev->driver_info->check_connect) 710 if (dev->driver_info->check_connect)
691 return dev->driver_info->check_connect (dev) == 0; 711 return dev->driver_info->check_connect (dev) == 0;
692 712
713 /* if the device has mii operations, use those */
714 if (dev->mii.mdio_read)
715 return mii_link_ok(&dev->mii);
716
693 /* Otherwise, say we're up (to avoid breaking scripts) */ 717 /* Otherwise, say we're up (to avoid breaking scripts) */
694 return 1; 718 return 1;
695} 719}
720EXPORT_SYMBOL_GPL(usbnet_get_link);
721
722int usbnet_nway_reset(struct net_device *net)
723{
724 struct usbnet *dev = netdev_priv(net);
725
726 if (!dev->mii.mdio_write)
727 return -EOPNOTSUPP;
728
729 return mii_nway_restart(&dev->mii);
730}
731EXPORT_SYMBOL_GPL(usbnet_nway_reset);
732
733#endif /* HAVE_MII */
734
735void usbnet_get_drvinfo (struct net_device *net, struct ethtool_drvinfo *info)
736{
737 struct usbnet *dev = netdev_priv(net);
738
739 /* REVISIT don't always return "usbnet" */
740 strncpy (info->driver, driver_name, sizeof info->driver);
741 strncpy (info->version, DRIVER_VERSION, sizeof info->version);
742 strncpy (info->fw_version, dev->driver_info->description,
743 sizeof info->fw_version);
744 usb_make_path (dev->udev, info->bus_info, sizeof info->bus_info);
745}
746EXPORT_SYMBOL_GPL(usbnet_get_drvinfo);
696 747
697u32 usbnet_get_msglevel (struct net_device *net) 748u32 usbnet_get_msglevel (struct net_device *net)
698{ 749{
@@ -712,8 +763,13 @@ EXPORT_SYMBOL_GPL(usbnet_set_msglevel);
712 763
713/* drivers may override default ethtool_ops in their bind() routine */ 764/* drivers may override default ethtool_ops in their bind() routine */
714static struct ethtool_ops usbnet_ethtool_ops = { 765static struct ethtool_ops usbnet_ethtool_ops = {
715 .get_drvinfo = usbnet_get_drvinfo, 766#ifdef HAVE_MII
767 .get_settings = usbnet_get_settings,
768 .set_settings = usbnet_set_settings,
716 .get_link = usbnet_get_link, 769 .get_link = usbnet_get_link,
770 .nway_reset = usbnet_nway_reset,
771#endif
772 .get_drvinfo = usbnet_get_drvinfo,
717 .get_msglevel = usbnet_get_msglevel, 773 .get_msglevel = usbnet_get_msglevel,
718 .set_msglevel = usbnet_set_msglevel, 774 .set_msglevel = usbnet_set_msglevel,
719}; 775};
@@ -1094,6 +1150,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
1094 dev->delay.function = usbnet_bh; 1150 dev->delay.function = usbnet_bh;
1095 dev->delay.data = (unsigned long) dev; 1151 dev->delay.data = (unsigned long) dev;
1096 init_timer (&dev->delay); 1152 init_timer (&dev->delay);
1153 mutex_init (&dev->phy_mutex);
1097 1154
1098 SET_MODULE_OWNER (net); 1155 SET_MODULE_OWNER (net);
1099 dev->net = net; 1156 dev->net = net;
@@ -1225,7 +1282,7 @@ EXPORT_SYMBOL_GPL(usbnet_resume);
1225static int __init usbnet_init(void) 1282static int __init usbnet_init(void)
1226{ 1283{
1227 /* compiler should optimize this out */ 1284 /* compiler should optimize this out */
1228 BUG_ON (sizeof (((struct sk_buff *)0)->cb) 1285 BUILD_BUG_ON (sizeof (((struct sk_buff *)0)->cb)
1229 < sizeof (struct skb_data)); 1286 < sizeof (struct skb_data));
1230 1287
1231 random_ether_addr(node_id); 1288 random_ether_addr(node_id);
diff --git a/drivers/usb/net/usbnet.h b/drivers/usb/net/usbnet.h
index c0746f0454af..07c70abbe0ec 100644
--- a/drivers/usb/net/usbnet.h
+++ b/drivers/usb/net/usbnet.h
@@ -30,6 +30,7 @@ struct usbnet {
30 struct usb_device *udev; 30 struct usb_device *udev;
31 struct driver_info *driver_info; 31 struct driver_info *driver_info;
32 wait_queue_head_t *wait; 32 wait_queue_head_t *wait;
33 struct mutex phy_mutex;
33 34
34 /* i/o info: pipes etc */ 35 /* i/o info: pipes etc */
35 unsigned in, out; 36 unsigned in, out;
@@ -168,9 +169,13 @@ extern void usbnet_defer_kevent (struct usbnet *, int);
168extern void usbnet_skb_return (struct usbnet *, struct sk_buff *); 169extern void usbnet_skb_return (struct usbnet *, struct sk_buff *);
169extern void usbnet_unlink_rx_urbs(struct usbnet *); 170extern void usbnet_unlink_rx_urbs(struct usbnet *);
170 171
172extern int usbnet_get_settings (struct net_device *net, struct ethtool_cmd *cmd);
173extern int usbnet_set_settings (struct net_device *net, struct ethtool_cmd *cmd);
174extern u32 usbnet_get_link (struct net_device *net);
171extern u32 usbnet_get_msglevel (struct net_device *); 175extern u32 usbnet_get_msglevel (struct net_device *);
172extern void usbnet_set_msglevel (struct net_device *, u32); 176extern void usbnet_set_msglevel (struct net_device *, u32);
173extern void usbnet_get_drvinfo (struct net_device *, struct ethtool_drvinfo *); 177extern void usbnet_get_drvinfo (struct net_device *, struct ethtool_drvinfo *);
178extern int usbnet_nway_reset(struct net_device *net);
174 179
175/* messaging support includes the interface name, so it must not be 180/* messaging support includes the interface name, so it must not be
176 * used before it has one ... notably, in minidriver bind() calls. 181 * used before it has one ... notably, in minidriver bind() calls.
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index 5076b9d97057..2a8dd4cc943d 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -54,10 +54,10 @@ config USB_SERIAL_GENERIC
54 properly. 54 properly.
55 55
56config USB_SERIAL_AIRCABLE 56config USB_SERIAL_AIRCABLE
57 tristate "AIRcable USB Bluetooth Dongle Driver (EXPERIMENTAL)" 57 tristate "USB AIRcable Bluetooth Dongle Driver (EXPERIMENTAL)"
58 depends on USB_SERIAL && EXPERIMENTAL 58 depends on USB_SERIAL && EXPERIMENTAL
59 help 59 help
60 Say Y here if you want to use AIRcable USB Bluetoot Dongle. 60 Say Y here if you want to use USB AIRcable Bluetooth Dongle.
61 61
62 To compile this driver as a module, choose M here: the module 62 To compile this driver as a module, choose M here: the module
63 will be called aircable. 63 will be called aircable.
@@ -422,6 +422,16 @@ config USB_SERIAL_MCT_U232
422 To compile this driver as a module, choose M here: the 422 To compile this driver as a module, choose M here: the
423 module will be called mct_u232. 423 module will be called mct_u232.
424 424
425config USB_SERIAL_MOS7720
426 tristate "USB Moschip 7720 Single Port Serial Driver"
427 depends on USB_SERIAL
428 ---help---
429 Say Y here if you want to use a USB Serial single port adapter from
430 Moschip Semiconductor Tech.
431
432 To compile this driver as a module, choose M here: the
433 module will be called mos7720.
434
425config USB_SERIAL_MOS7840 435config USB_SERIAL_MOS7840
426 tristate "USB Moschip 7840/7820 USB Serial Driver" 436 tristate "USB Moschip 7840/7820 USB Serial Driver"
427 depends on USB_SERIAL 437 depends on USB_SERIAL
@@ -527,8 +537,7 @@ config USB_SERIAL_OPTION
527 The USB bus on these cards is not accessible externally. 537 The USB bus on these cards is not accessible externally.
528 538
529 Supported devices include (some of?) those made by: 539 Supported devices include (some of?) those made by:
530 Option, Huawei, Audiovox, Sierra Wireless, Novatel Wireless, or 540 Option, Huawei, Audiovox, Novatel Wireless, or Anydata.
531 Anydata.
532 541
533 To compile this driver as a module, choose M here: the 542 To compile this driver as a module, choose M here: the
534 module will be called option. 543 module will be called option.
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index 8dce83340e31..a5047dc599bb 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_USB_SERIAL_KEYSPAN_PDA) += keyspan_pda.o
34obj-$(CONFIG_USB_SERIAL_KLSI) += kl5kusb105.o 34obj-$(CONFIG_USB_SERIAL_KLSI) += kl5kusb105.o
35obj-$(CONFIG_USB_SERIAL_KOBIL_SCT) += kobil_sct.o 35obj-$(CONFIG_USB_SERIAL_KOBIL_SCT) += kobil_sct.o
36obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o 36obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o
37obj-$(CONFIG_USB_SERIAL_MOS7720) += mos7720.o
37obj-$(CONFIG_USB_SERIAL_MOS7840) += mos7840.o 38obj-$(CONFIG_USB_SERIAL_MOS7840) += mos7840.o
38obj-$(CONFIG_USB_SERIAL_NAVMAN) += navman.o 39obj-$(CONFIG_USB_SERIAL_NAVMAN) += navman.o
39obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o 40obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c
index 2c19f19b255c..7f5d546da39a 100644
--- a/drivers/usb/serial/airprime.c
+++ b/drivers/usb/serial/airprime.c
@@ -18,12 +18,8 @@
18 18
19static struct usb_device_id id_table [] = { 19static struct usb_device_id id_table [] = {
20 { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */ 20 { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */
21 { USB_DEVICE(0x0f3d, 0x0112) }, /* AirPrime CDMA Wireless PC Card */
22 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
23 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */
24 { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless Aircard 580 */
25 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
26 { USB_DEVICE(0x1410, 0x1110) }, /* Novatel Wireless Merlin CDMA */ 21 { USB_DEVICE(0x1410, 0x1110) }, /* Novatel Wireless Merlin CDMA */
22 { USB_DEVICE(0x1410, 0x1100) }, /* ExpressCard34 Qualcomm 3G CDMA */
27 { }, 23 { },
28}; 24};
29MODULE_DEVICE_TABLE(usb, id_table); 25MODULE_DEVICE_TABLE(usb, id_table);
@@ -133,6 +129,7 @@ static int airprime_open(struct usb_serial_port *port, struct file *filp)
133 } 129 }
134 urb = usb_alloc_urb(0, GFP_KERNEL); 130 urb = usb_alloc_urb(0, GFP_KERNEL);
135 if (!urb) { 131 if (!urb) {
132 kfree(buffer);
136 dev_err(&port->dev, "%s - no more urbs?\n", 133 dev_err(&port->dev, "%s - no more urbs?\n",
137 __FUNCTION__); 134 __FUNCTION__);
138 result = -ENOMEM; 135 result = -ENOMEM;
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c
index 486c7411b9a7..f95d42c0d16a 100644
--- a/drivers/usb/serial/cp2101.c
+++ b/drivers/usb/serial/cp2101.c
@@ -64,7 +64,11 @@ static struct usb_device_id id_table [] = {
64 { USB_DEVICE(0x10C4, 0x80F6) }, /* Suunto sports instrument */ 64 { USB_DEVICE(0x10C4, 0x80F6) }, /* Suunto sports instrument */
65 { USB_DEVICE(0x10C4, 0x813D) }, /* Burnside Telecom Deskmobile */ 65 { USB_DEVICE(0x10C4, 0x813D) }, /* Burnside Telecom Deskmobile */
66 { USB_DEVICE(0x10C4, 0x815E) }, /* Helicomm IP-Link 1220-DVM */ 66 { USB_DEVICE(0x10C4, 0x815E) }, /* Helicomm IP-Link 1220-DVM */
67 { USB_DEVICE(0x10C4, 0x81C8) }, /* Lipowsky Industrie Elektronik GmbH, Baby-JTAG */
68 { USB_DEVICE(0x10C4, 0x81E2) }, /* Lipowsky Industrie Elektronik GmbH, Baby-LIN */
69 { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */
67 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ 70 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */
71 { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */
68 { USB_DEVICE(0x16D6, 0x0001) }, /* Jablotron serial interface */ 72 { USB_DEVICE(0x16D6, 0x0001) }, /* Jablotron serial interface */
69 { } /* Terminating Entry */ 73 { } /* Terminating Entry */
70}; 74};
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index d3dc1a15ec6c..c186b4e73c72 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1,16 +1,16 @@
1/* 1/*
2 * USB FTDI SIO driver 2 * USB FTDI SIO driver
3 * 3 *
4 * Copyright (C) 1999 - 2001 4 * Copyright (C) 1999 - 2001
5 * Greg Kroah-Hartman (greg@kroah.com) 5 * Greg Kroah-Hartman (greg@kroah.com)
6 * Bill Ryder (bryder@sgi.com) 6 * Bill Ryder (bryder@sgi.com)
7 * Copyright (C) 2002 7 * Copyright (C) 2002
8 * Kuba Ober (kuba@mareimbrium.org) 8 * Kuba Ober (kuba@mareimbrium.org)
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or 12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version. 13 * (at your option) any later version.
14 * 14 *
15 * See Documentation/usb/usb-serial.txt for more information on using this driver 15 * See Documentation/usb/usb-serial.txt for more information on using this driver
16 * 16 *
@@ -32,7 +32,7 @@
32 * Changed full name of USB-UIRT device to avoid "/" character. 32 * Changed full name of USB-UIRT device to avoid "/" character.
33 * Added FTDI's alternate PID (0x6006) for FT232/245 devices. 33 * Added FTDI's alternate PID (0x6006) for FT232/245 devices.
34 * Added PID for "ELV USB Module UO100" from Stefan Frings. 34 * Added PID for "ELV USB Module UO100" from Stefan Frings.
35 * 35 *
36 * (21/Oct/2003) Ian Abbott 36 * (21/Oct/2003) Ian Abbott
37 * Renamed some VID/PID macros for Matrix Orbital and Perle Systems 37 * Renamed some VID/PID macros for Matrix Orbital and Perle Systems
38 * devices. Removed Matrix Orbital and Perle Systems devices from the 38 * devices. Removed Matrix Orbital and Perle Systems devices from the
@@ -69,7 +69,7 @@
69 * does not incure any measurable overhead. This also relies on the fact 69 * does not incure any measurable overhead. This also relies on the fact
70 * that we have proper reference counting logic for urbs. I nicked this 70 * that we have proper reference counting logic for urbs. I nicked this
71 * from Greg KH's Visor driver. 71 * from Greg KH's Visor driver.
72 * 72 *
73 * (23/Jun/2003) Ian Abbott 73 * (23/Jun/2003) Ian Abbott
74 * Reduced flip buffer pushes and corrected a data length test in 74 * Reduced flip buffer pushes and corrected a data length test in
75 * ftdi_read_bulk_callback. 75 * ftdi_read_bulk_callback.
@@ -77,7 +77,7 @@
77 * 77 *
78 * (21/Jun/2003) Erik Nygren 78 * (21/Jun/2003) Erik Nygren
79 * Added support for Home Electronics Tira-1 IR transceiver using FT232BM chip. 79 * Added support for Home Electronics Tira-1 IR transceiver using FT232BM chip.
80 * See <http://www.home-electro.com/tira1.htm>. Only operates properly 80 * See <http://www.home-electro.com/tira1.htm>. Only operates properly
81 * at 100000 and RTS-CTS, so set custom divisor mode on startup. 81 * at 100000 and RTS-CTS, so set custom divisor mode on startup.
82 * Also force the Tira-1 and USB-UIRT to only use their custom baud rates. 82 * Also force the Tira-1 and USB-UIRT to only use their custom baud rates.
83 * 83 *
@@ -137,17 +137,17 @@
137 * (17/Feb/2003) Bill Ryder 137 * (17/Feb/2003) Bill Ryder
138 * Added write urb buffer pool on a per device basis 138 * Added write urb buffer pool on a per device basis
139 * Added more checking for open file on callbacks (fixed OOPS) 139 * Added more checking for open file on callbacks (fixed OOPS)
140 * Added CrystalFontz 632 and 634 PIDs 140 * Added CrystalFontz 632 and 634 PIDs
141 * (thanx to CrystalFontz for the sample devices - they flushed out 141 * (thanx to CrystalFontz for the sample devices - they flushed out
142 * some driver bugs) 142 * some driver bugs)
143 * Minor debugging message changes 143 * Minor debugging message changes
144 * Added throttle, unthrottle and chars_in_buffer functions 144 * Added throttle, unthrottle and chars_in_buffer functions
145 * Fixed FTDI_SIO (the original device) bug 145 * Fixed FTDI_SIO (the original device) bug
146 * Fixed some shutdown handling 146 * Fixed some shutdown handling
147 * 147 *
148 * 148 *
149 * 149 *
150 * 150 *
151 * (07/Jun/2002) Kuba Ober 151 * (07/Jun/2002) Kuba Ober
152 * Changed FTDI_SIO_BASE_BAUD_TO_DIVISOR macro into ftdi_baud_to_divisor 152 * Changed FTDI_SIO_BASE_BAUD_TO_DIVISOR macro into ftdi_baud_to_divisor
153 * function. It was getting too complex. 153 * function. It was getting too complex.
@@ -158,7 +158,7 @@
158 * 158 *
159 * (25/Jul/2002) Bill Ryder inserted Dmitri's TIOCMIWAIT patch 159 * (25/Jul/2002) Bill Ryder inserted Dmitri's TIOCMIWAIT patch
160 * Not tested by me but it doesn't break anything I use. 160 * Not tested by me but it doesn't break anything I use.
161 * 161 *
162 * (04/Jan/2002) Kuba Ober 162 * (04/Jan/2002) Kuba Ober
163 * Implemented 38400 baudrate kludge, where it can be substituted with other 163 * Implemented 38400 baudrate kludge, where it can be substituted with other
164 * values. That's the only way to set custom baudrates. 164 * values. That's the only way to set custom baudrates.
@@ -179,7 +179,7 @@
179 * (the previous version caused panics) 179 * (the previous version caused panics)
180 * Removed port iteration code since the device only has one I/O port and it 180 * Removed port iteration code since the device only has one I/O port and it
181 * was wrong anyway. 181 * was wrong anyway.
182 * 182 *
183 * (31/May/2001) gkh 183 * (31/May/2001) gkh
184 * Switched from using spinlock to a semaphore, which fixes lots of problems. 184 * Switched from using spinlock to a semaphore, which fixes lots of problems.
185 * 185 *
@@ -188,16 +188,16 @@
188 * Cleaned up comments for 8U232 188 * Cleaned up comments for 8U232
189 * Added parity, framing and overrun error handling 189 * Added parity, framing and overrun error handling
190 * Added receive break handling. 190 * Added receive break handling.
191 * 191 *
192 * (04/08/2001) gb 192 * (04/08/2001) gb
193 * Identify version on module load. 193 * Identify version on module load.
194 * 194 *
195 * (18/March/2001) Bill Ryder 195 * (18/March/2001) Bill Ryder
196 * (Not released) 196 * (Not released)
197 * Added send break handling. (requires kernel patch too) 197 * Added send break handling. (requires kernel patch too)
198 * Fixed 8U232AM hardware RTS/CTS etc status reporting. 198 * Fixed 8U232AM hardware RTS/CTS etc status reporting.
199 * Added flipbuf fix copied from generic device 199 * Added flipbuf fix copied from generic device
200 * 200 *
201 * (12/3/2000) Bill Ryder 201 * (12/3/2000) Bill Ryder
202 * Added support for 8U232AM device. 202 * Added support for 8U232AM device.
203 * Moved PID and VIDs into header file only. 203 * Moved PID and VIDs into header file only.
@@ -211,14 +211,14 @@
211 * Cleaned up comments. Removed multiple PID/VID definitions. 211 * Cleaned up comments. Removed multiple PID/VID definitions.
212 * Factorised cts/dtr code 212 * Factorised cts/dtr code
213 * Made use of __FUNCTION__ in dbg's 213 * Made use of __FUNCTION__ in dbg's
214 * 214 *
215 * (11/01/2000) Adam J. Richter 215 * (11/01/2000) Adam J. Richter
216 * usb_device_id table support 216 * usb_device_id table support
217 * 217 *
218 * (10/05/2000) gkh 218 * (10/05/2000) gkh
219 * Fixed bug with urb->dev not being set properly, now that the usb 219 * Fixed bug with urb->dev not being set properly, now that the usb
220 * core needs it. 220 * core needs it.
221 * 221 *
222 * (09/11/2000) gkh 222 * (09/11/2000) gkh
223 * Removed DEBUG #ifdefs with call to usb_serial_debug_data 223 * Removed DEBUG #ifdefs with call to usb_serial_debug_data
224 * 224 *
@@ -226,11 +226,11 @@
226 * Added module_init and module_exit functions to handle the fact that this 226 * Added module_init and module_exit functions to handle the fact that this
227 * driver is a loadable module now. 227 * driver is a loadable module now.
228 * 228 *
229 * (04/04/2000) Bill Ryder 229 * (04/04/2000) Bill Ryder
230 * Fixed bugs in TCGET/TCSET ioctls (by removing them - they are 230 * Fixed bugs in TCGET/TCSET ioctls (by removing them - they are
231 * handled elsewhere in the tty io driver chain). 231 * handled elsewhere in the tty io driver chain).
232 * 232 *
233 * (03/30/2000) Bill Ryder 233 * (03/30/2000) Bill Ryder
234 * Implemented lots of ioctls 234 * Implemented lots of ioctls
235 * Fixed a race condition in write 235 * Fixed a race condition in write
236 * Changed some dbg's to errs 236 * Changed some dbg's to errs
@@ -311,6 +311,7 @@ static struct usb_device_id id_table_combined [] = {
311 { USB_DEVICE(FTDI_VID, FTDI_ACTZWAVE_PID) }, 311 { USB_DEVICE(FTDI_VID, FTDI_ACTZWAVE_PID) },
312 { USB_DEVICE(FTDI_VID, FTDI_IRTRANS_PID) }, 312 { USB_DEVICE(FTDI_VID, FTDI_IRTRANS_PID) },
313 { USB_DEVICE(FTDI_VID, FTDI_IPLUS_PID) }, 313 { USB_DEVICE(FTDI_VID, FTDI_IPLUS_PID) },
314 { USB_DEVICE(FTDI_VID, FTDI_DMX4ALL) },
314 { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) }, 315 { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) },
315 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) }, 316 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) },
316 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) }, 317 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) },
@@ -444,13 +445,13 @@ static struct usb_device_id id_table_combined [] = {
444 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_WS300PC_PID) }, */ 445 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_WS300PC_PID) }, */
445 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_FHZ1300PC_PID) }, */ 446 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_FHZ1300PC_PID) }, */
446 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_WS500_PID) }, */ 447 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_WS500_PID) }, */
447 { USB_DEVICE(FTDI_VID, LINX_SDMUSBQSS_PID) }, 448 { USB_DEVICE(FTDI_VID, LINX_SDMUSBQSS_PID) },
448 { USB_DEVICE(FTDI_VID, LINX_MASTERDEVEL2_PID) }, 449 { USB_DEVICE(FTDI_VID, LINX_MASTERDEVEL2_PID) },
449 { USB_DEVICE(FTDI_VID, LINX_FUTURE_0_PID) }, 450 { USB_DEVICE(FTDI_VID, LINX_FUTURE_0_PID) },
450 { USB_DEVICE(FTDI_VID, LINX_FUTURE_1_PID) }, 451 { USB_DEVICE(FTDI_VID, LINX_FUTURE_1_PID) },
451 { USB_DEVICE(FTDI_VID, LINX_FUTURE_2_PID) }, 452 { USB_DEVICE(FTDI_VID, LINX_FUTURE_2_PID) },
452 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU20_0_PID) }, 453 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU20_0_PID) },
453 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU40_1_PID) }, 454 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU40_1_PID) },
454 { USB_DEVICE(FTDI_VID, INSIDE_ACCESSO) }, 455 { USB_DEVICE(FTDI_VID, INSIDE_ACCESSO) },
455 { USB_DEVICE(INTREPID_VID, INTREPID_VALUECAN_PID) }, 456 { USB_DEVICE(INTREPID_VID, INTREPID_VALUECAN_PID) },
456 { USB_DEVICE(INTREPID_VID, INTREPID_NEOVI_PID) }, 457 { USB_DEVICE(INTREPID_VID, INTREPID_NEOVI_PID) },
@@ -511,6 +512,7 @@ static struct usb_device_id id_table_combined [] = {
511 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13M_PID) }, 512 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13M_PID) },
512 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13S_PID) }, 513 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13S_PID) },
513 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13U_PID) }, 514 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13U_PID) },
515 { USB_DEVICE(ELEKTOR_VID, ELEKTOR_FT323R_PID) },
514 { }, /* Optional parameter entry */ 516 { }, /* Optional parameter entry */
515 { } /* Terminating entry */ 517 { } /* Terminating entry */
516}; 518};
@@ -522,7 +524,7 @@ static struct usb_driver ftdi_driver = {
522 .probe = usb_serial_probe, 524 .probe = usb_serial_probe,
523 .disconnect = usb_serial_disconnect, 525 .disconnect = usb_serial_disconnect,
524 .id_table = id_table_combined, 526 .id_table = id_table_combined,
525 .no_dynamic_id = 1, 527 .no_dynamic_id = 1,
526}; 528};
527 529
528static const char *ftdi_chip_name[] = { 530static const char *ftdi_chip_name[] = {
@@ -548,13 +550,13 @@ struct ftdi_private {
548 int custom_divisor; /* custom_divisor kludge, this is for baud_base (different from what goes to the chip!) */ 550 int custom_divisor; /* custom_divisor kludge, this is for baud_base (different from what goes to the chip!) */
549 __u16 last_set_data_urb_value ; 551 __u16 last_set_data_urb_value ;
550 /* the last data state set - needed for doing a break */ 552 /* the last data state set - needed for doing a break */
551 int write_offset; /* This is the offset in the usb data block to write the serial data - 553 int write_offset; /* This is the offset in the usb data block to write the serial data -
552 * it is different between devices 554 * it is different between devices
553 */ 555 */
554 int flags; /* some ASYNC_xxxx flags are supported */ 556 int flags; /* some ASYNC_xxxx flags are supported */
555 unsigned long last_dtr_rts; /* saved modem control outputs */ 557 unsigned long last_dtr_rts; /* saved modem control outputs */
556 wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */ 558 wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */
557 char prev_status, diff_status; /* Used for TIOCMIWAIT */ 559 char prev_status, diff_status; /* Used for TIOCMIWAIT */
558 __u8 rx_flags; /* receive state flags (throttling) */ 560 __u8 rx_flags; /* receive state flags (throttling) */
559 spinlock_t rx_lock; /* spinlock for receive state */ 561 spinlock_t rx_lock; /* spinlock for receive state */
560 struct work_struct rx_work; 562 struct work_struct rx_work;
@@ -721,7 +723,7 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set, unsigned
721 urb_value |= FTDI_SIO_SET_RTS_HIGH; 723 urb_value |= FTDI_SIO_SET_RTS_HIGH;
722 rv = usb_control_msg(port->serial->dev, 724 rv = usb_control_msg(port->serial->dev,
723 usb_sndctrlpipe(port->serial->dev, 0), 725 usb_sndctrlpipe(port->serial->dev, 0),
724 FTDI_SIO_SET_MODEM_CTRL_REQUEST, 726 FTDI_SIO_SET_MODEM_CTRL_REQUEST,
725 FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE, 727 FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE,
726 urb_value, priv->interface, 728 urb_value, priv->interface,
727 buf, 0, WDR_TIMEOUT); 729 buf, 0, WDR_TIMEOUT);
@@ -768,7 +770,7 @@ static int change_speed(struct usb_serial_port *port)
768 if (priv->interface) { /* FT2232C */ 770 if (priv->interface) { /* FT2232C */
769 urb_index = (__u16)((urb_index << 8) | priv->interface); 771 urb_index = (__u16)((urb_index << 8) | priv->interface);
770 } 772 }
771 773
772 rv = usb_control_msg(port->serial->dev, 774 rv = usb_control_msg(port->serial->dev,
773 usb_sndctrlpipe(port->serial->dev, 0), 775 usb_sndctrlpipe(port->serial->dev, 0),
774 FTDI_SIO_SET_BAUDRATE_REQUEST, 776 FTDI_SIO_SET_BAUDRATE_REQUEST,
@@ -827,7 +829,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port)
827 829
828 /* 3. Convert baudrate to device-specific divisor */ 830 /* 3. Convert baudrate to device-specific divisor */
829 831
830 if (!baud) baud = 9600; 832 if (!baud) baud = 9600;
831 switch(priv->chip_type) { 833 switch(priv->chip_type) {
832 case SIO: /* SIO chip */ 834 case SIO: /* SIO chip */
833 switch(baud) { 835 switch(baud) {
@@ -843,7 +845,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port)
843 case 115200: div_value = ftdi_sio_b115200; break; 845 case 115200: div_value = ftdi_sio_b115200; break;
844 } /* baud */ 846 } /* baud */
845 if (div_value == 0) { 847 if (div_value == 0) {
846 dbg("%s - Baudrate (%d) requested is not supported", __FUNCTION__, baud); 848 dbg("%s - Baudrate (%d) requested is not supported", __FUNCTION__, baud);
847 div_value = ftdi_sio_b9600; 849 div_value = ftdi_sio_b9600;
848 div_okay = 0; 850 div_okay = 0;
849 } 851 }
@@ -925,7 +927,7 @@ static int set_serial_info(struct usb_serial_port * port, struct serial_struct _
925 /* Make the changes - these are privileged changes! */ 927 /* Make the changes - these are privileged changes! */
926 928
927 priv->flags = ((priv->flags & ~ASYNC_FLAGS) | 929 priv->flags = ((priv->flags & ~ASYNC_FLAGS) |
928 (new_serial.flags & ASYNC_FLAGS)); 930 (new_serial.flags & ASYNC_FLAGS));
929 priv->custom_divisor = new_serial.custom_divisor; 931 priv->custom_divisor = new_serial.custom_divisor;
930 932
931 port->tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0; 933 port->tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
@@ -950,7 +952,7 @@ check_and_exit:
950 (old_priv.custom_divisor != priv->custom_divisor))) { 952 (old_priv.custom_divisor != priv->custom_divisor))) {
951 change_speed(port); 953 change_speed(port);
952 } 954 }
953 955
954 return (0); 956 return (0);
955 957
956} /* set_serial_info */ 958} /* set_serial_info */
@@ -1022,18 +1024,18 @@ static ssize_t show_latency_timer(struct device *dev, struct device_attribute *a
1022 struct usb_device *udev; 1024 struct usb_device *udev;
1023 unsigned short latency = 0; 1025 unsigned short latency = 0;
1024 int rv = 0; 1026 int rv = 0;
1025 1027
1026 udev = to_usb_device(dev); 1028 udev = to_usb_device(dev);
1027 1029
1028 dbg("%s",__FUNCTION__); 1030 dbg("%s",__FUNCTION__);
1029 1031
1030 rv = usb_control_msg(udev, 1032 rv = usb_control_msg(udev,
1031 usb_rcvctrlpipe(udev, 0), 1033 usb_rcvctrlpipe(udev, 0),
1032 FTDI_SIO_GET_LATENCY_TIMER_REQUEST, 1034 FTDI_SIO_GET_LATENCY_TIMER_REQUEST,
1033 FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE, 1035 FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE,
1034 0, priv->interface, 1036 0, priv->interface,
1035 (char*) &latency, 1, WDR_TIMEOUT); 1037 (char*) &latency, 1, WDR_TIMEOUT);
1036 1038
1037 if (rv < 0) { 1039 if (rv < 0) {
1038 dev_err(dev, "Unable to read latency timer: %i", rv); 1040 dev_err(dev, "Unable to read latency timer: %i", rv);
1039 return -EIO; 1041 return -EIO;
@@ -1051,23 +1053,23 @@ static ssize_t store_latency_timer(struct device *dev, struct device_attribute *
1051 char buf[1]; 1053 char buf[1];
1052 int v = simple_strtoul(valbuf, NULL, 10); 1054 int v = simple_strtoul(valbuf, NULL, 10);
1053 int rv = 0; 1055 int rv = 0;
1054 1056
1055 udev = to_usb_device(dev); 1057 udev = to_usb_device(dev);
1056 1058
1057 dbg("%s: setting latency timer = %i", __FUNCTION__, v); 1059 dbg("%s: setting latency timer = %i", __FUNCTION__, v);
1058 1060
1059 rv = usb_control_msg(udev, 1061 rv = usb_control_msg(udev,
1060 usb_sndctrlpipe(udev, 0), 1062 usb_sndctrlpipe(udev, 0),
1061 FTDI_SIO_SET_LATENCY_TIMER_REQUEST, 1063 FTDI_SIO_SET_LATENCY_TIMER_REQUEST,
1062 FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE, 1064 FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE,
1063 v, priv->interface, 1065 v, priv->interface,
1064 buf, 0, WDR_TIMEOUT); 1066 buf, 0, WDR_TIMEOUT);
1065 1067
1066 if (rv < 0) { 1068 if (rv < 0) {
1067 dev_err(dev, "Unable to write latency timer: %i", rv); 1069 dev_err(dev, "Unable to write latency timer: %i", rv);
1068 return -EIO; 1070 return -EIO;
1069 } 1071 }
1070 1072
1071 return count; 1073 return count;
1072} 1074}
1073 1075
@@ -1082,23 +1084,23 @@ static ssize_t store_event_char(struct device *dev, struct device_attribute *att
1082 char buf[1]; 1084 char buf[1];
1083 int v = simple_strtoul(valbuf, NULL, 10); 1085 int v = simple_strtoul(valbuf, NULL, 10);
1084 int rv = 0; 1086 int rv = 0;
1085 1087
1086 udev = to_usb_device(dev); 1088 udev = to_usb_device(dev);
1087 1089
1088 dbg("%s: setting event char = %i", __FUNCTION__, v); 1090 dbg("%s: setting event char = %i", __FUNCTION__, v);
1089 1091
1090 rv = usb_control_msg(udev, 1092 rv = usb_control_msg(udev,
1091 usb_sndctrlpipe(udev, 0), 1093 usb_sndctrlpipe(udev, 0),
1092 FTDI_SIO_SET_EVENT_CHAR_REQUEST, 1094 FTDI_SIO_SET_EVENT_CHAR_REQUEST,
1093 FTDI_SIO_SET_EVENT_CHAR_REQUEST_TYPE, 1095 FTDI_SIO_SET_EVENT_CHAR_REQUEST_TYPE,
1094 v, priv->interface, 1096 v, priv->interface,
1095 buf, 0, WDR_TIMEOUT); 1097 buf, 0, WDR_TIMEOUT);
1096 1098
1097 if (rv < 0) { 1099 if (rv < 0) {
1098 dbg("Unable to write event character: %i", rv); 1100 dbg("Unable to write event character: %i", rv);
1099 return -EIO; 1101 return -EIO;
1100 } 1102 }
1101 1103
1102 return count; 1104 return count;
1103} 1105}
1104 1106
@@ -1135,11 +1137,11 @@ static void remove_sysfs_attrs(struct usb_serial *serial)
1135 struct ftdi_private *priv; 1137 struct ftdi_private *priv;
1136 struct usb_device *udev; 1138 struct usb_device *udev;
1137 1139
1138 dbg("%s",__FUNCTION__); 1140 dbg("%s",__FUNCTION__);
1139 1141
1140 priv = usb_get_serial_port_data(serial->port[0]); 1142 priv = usb_get_serial_port_data(serial->port[0]);
1141 udev = serial->dev; 1143 udev = serial->dev;
1142 1144
1143 /* XXX see create_sysfs_attrs */ 1145 /* XXX see create_sysfs_attrs */
1144 if (priv->chip_type != SIO) { 1146 if (priv->chip_type != SIO) {
1145 device_remove_file(&udev->dev, &dev_attr_event_char); 1147 device_remove_file(&udev->dev, &dev_attr_event_char);
@@ -1147,7 +1149,7 @@ static void remove_sysfs_attrs(struct usb_serial *serial)
1147 device_remove_file(&udev->dev, &dev_attr_latency_timer); 1149 device_remove_file(&udev->dev, &dev_attr_latency_timer);
1148 } 1150 }
1149 } 1151 }
1150 1152
1151} 1153}
1152 1154
1153/* 1155/*
@@ -1258,7 +1260,7 @@ static void ftdi_HE_TIRA1_setup (struct usb_serial *serial)
1258} /* ftdi_HE_TIRA1_setup */ 1260} /* ftdi_HE_TIRA1_setup */
1259 1261
1260 1262
1261/* ftdi_shutdown is called from usbserial:usb_serial_disconnect 1263/* ftdi_shutdown is called from usbserial:usb_serial_disconnect
1262 * it is called when the usb device is disconnected 1264 * it is called when the usb device is disconnected
1263 * 1265 *
1264 * usbserial:usb_serial_disconnect 1266 * usbserial:usb_serial_disconnect
@@ -1269,16 +1271,16 @@ static void ftdi_HE_TIRA1_setup (struct usb_serial *serial)
1269 1271
1270static void ftdi_shutdown (struct usb_serial *serial) 1272static void ftdi_shutdown (struct usb_serial *serial)
1271{ /* ftdi_shutdown */ 1273{ /* ftdi_shutdown */
1272 1274
1273 struct usb_serial_port *port = serial->port[0]; 1275 struct usb_serial_port *port = serial->port[0];
1274 struct ftdi_private *priv = usb_get_serial_port_data(port); 1276 struct ftdi_private *priv = usb_get_serial_port_data(port);
1275 1277
1276 dbg("%s", __FUNCTION__); 1278 dbg("%s", __FUNCTION__);
1277 1279
1278 remove_sysfs_attrs(serial); 1280 remove_sysfs_attrs(serial);
1279 1281
1280 /* all open ports are closed at this point 1282 /* all open ports are closed at this point
1281 * (by usbserial.c:__serial_close, which calls ftdi_close) 1283 * (by usbserial.c:__serial_close, which calls ftdi_close)
1282 */ 1284 */
1283 1285
1284 if (priv) { 1286 if (priv) {
@@ -1293,7 +1295,7 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp)
1293 struct usb_device *dev = port->serial->dev; 1295 struct usb_device *dev = port->serial->dev;
1294 struct ftdi_private *priv = usb_get_serial_port_data(port); 1296 struct ftdi_private *priv = usb_get_serial_port_data(port);
1295 unsigned long flags; 1297 unsigned long flags;
1296 1298
1297 int result = 0; 1299 int result = 0;
1298 char buf[1]; /* Needed for the usb_control_msg I think */ 1300 char buf[1]; /* Needed for the usb_control_msg I think */
1299 1301
@@ -1312,8 +1314,8 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp)
1312 /* No error checking for this (will get errors later anyway) */ 1314 /* No error checking for this (will get errors later anyway) */
1313 /* See ftdi_sio.h for description of what is reset */ 1315 /* See ftdi_sio.h for description of what is reset */
1314 usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1316 usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
1315 FTDI_SIO_RESET_REQUEST, FTDI_SIO_RESET_REQUEST_TYPE, 1317 FTDI_SIO_RESET_REQUEST, FTDI_SIO_RESET_REQUEST_TYPE,
1316 FTDI_SIO_RESET_SIO, 1318 FTDI_SIO_RESET_SIO,
1317 priv->interface, buf, 0, WDR_TIMEOUT); 1319 priv->interface, buf, 0, WDR_TIMEOUT);
1318 1320
1319 /* Termios defaults are set by usb_serial_init. We don't change 1321 /* Termios defaults are set by usb_serial_init. We don't change
@@ -1350,12 +1352,12 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp)
1350 1352
1351 1353
1352 1354
1353/* 1355/*
1354 * usbserial:__serial_close only calls ftdi_close if the point is open 1356 * usbserial:__serial_close only calls ftdi_close if the point is open
1355 * 1357 *
1356 * This only gets called when it is the last close 1358 * This only gets called when it is the last close
1357 * 1359 *
1358 * 1360 *
1359 */ 1361 */
1360 1362
1361static void ftdi_close (struct usb_serial_port *port, struct file *filp) 1363static void ftdi_close (struct usb_serial_port *port, struct file *filp)
@@ -1368,14 +1370,14 @@ static void ftdi_close (struct usb_serial_port *port, struct file *filp)
1368 1370
1369 if (c_cflag & HUPCL){ 1371 if (c_cflag & HUPCL){
1370 /* Disable flow control */ 1372 /* Disable flow control */
1371 if (usb_control_msg(port->serial->dev, 1373 if (usb_control_msg(port->serial->dev,
1372 usb_sndctrlpipe(port->serial->dev, 0), 1374 usb_sndctrlpipe(port->serial->dev, 0),
1373 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 1375 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
1374 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 1376 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
1375 0, priv->interface, buf, 0, 1377 0, priv->interface, buf, 0,
1376 WDR_TIMEOUT) < 0) { 1378 WDR_TIMEOUT) < 0) {
1377 err("error from flowcontrol urb"); 1379 err("error from flowcontrol urb");
1378 } 1380 }
1379 1381
1380 /* drop RTS and DTR */ 1382 /* drop RTS and DTR */
1381 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); 1383 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
@@ -1384,14 +1386,14 @@ static void ftdi_close (struct usb_serial_port *port, struct file *filp)
1384 /* cancel any scheduled reading */ 1386 /* cancel any scheduled reading */
1385 cancel_delayed_work(&priv->rx_work); 1387 cancel_delayed_work(&priv->rx_work);
1386 flush_scheduled_work(); 1388 flush_scheduled_work();
1387 1389
1388 /* shutdown our bulk read */ 1390 /* shutdown our bulk read */
1389 if (port->read_urb) 1391 if (port->read_urb)
1390 usb_kill_urb(port->read_urb); 1392 usb_kill_urb(port->read_urb);
1391} /* ftdi_close */ 1393} /* ftdi_close */
1392 1394
1393 1395
1394 1396
1395/* The SIO requires the first byte to have: 1397/* The SIO requires the first byte to have:
1396 * B0 1 1398 * B0 1
1397 * B1 0 1399 * B1 0
@@ -1423,7 +1425,7 @@ static int ftdi_write (struct usb_serial_port *port,
1423 return 0; 1425 return 0;
1424 } 1426 }
1425 spin_unlock_irqrestore(&priv->tx_lock, flags); 1427 spin_unlock_irqrestore(&priv->tx_lock, flags);
1426 1428
1427 data_offset = priv->write_offset; 1429 data_offset = priv->write_offset;
1428 dbg("data_offset set to %d",data_offset); 1430 dbg("data_offset set to %d",data_offset);
1429 1431
@@ -1462,7 +1464,7 @@ static int ftdi_write (struct usb_serial_port *port,
1462 user_pktsz = todo; 1464 user_pktsz = todo;
1463 } 1465 }
1464 /* Write the control byte at the front of the packet*/ 1466 /* Write the control byte at the front of the packet*/
1465 *first_byte = 1 | ((user_pktsz) << 2); 1467 *first_byte = 1 | ((user_pktsz) << 2);
1466 /* Copy data for packet */ 1468 /* Copy data for packet */
1467 memcpy (first_byte + data_offset, 1469 memcpy (first_byte + data_offset,
1468 current_position, user_pktsz); 1470 current_position, user_pktsz);
@@ -1479,7 +1481,7 @@ static int ftdi_write (struct usb_serial_port *port,
1479 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, transfer_size, buffer); 1481 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, transfer_size, buffer);
1480 1482
1481 /* fill the buffer and send it */ 1483 /* fill the buffer and send it */
1482 usb_fill_bulk_urb(urb, port->serial->dev, 1484 usb_fill_bulk_urb(urb, port->serial->dev,
1483 usb_sndbulkpipe(port->serial->dev, port->bulk_out_endpointAddress), 1485 usb_sndbulkpipe(port->serial->dev, port->bulk_out_endpointAddress),
1484 buffer, transfer_size, 1486 buffer, transfer_size,
1485 ftdi_write_bulk_callback, port); 1487 ftdi_write_bulk_callback, port);
@@ -1520,7 +1522,7 @@ static void ftdi_write_bulk_callback (struct urb *urb)
1520 kfree (urb->transfer_buffer); 1522 kfree (urb->transfer_buffer);
1521 1523
1522 dbg("%s - port %d", __FUNCTION__, port->number); 1524 dbg("%s - port %d", __FUNCTION__, port->number);
1523 1525
1524 if (urb->status) { 1526 if (urb->status) {
1525 dbg("nonzero write bulk status received: %d", urb->status); 1527 dbg("nonzero write bulk status received: %d", urb->status);
1526 return; 1528 return;
@@ -1651,7 +1653,7 @@ static void ftdi_process_read (void *param)
1651 struct tty_struct *tty; 1653 struct tty_struct *tty;
1652 struct ftdi_private *priv; 1654 struct ftdi_private *priv;
1653 char error_flag; 1655 char error_flag;
1654 unsigned char *data; 1656 unsigned char *data;
1655 1657
1656 int i; 1658 int i;
1657 int result; 1659 int result;
@@ -1759,7 +1761,7 @@ static void ftdi_process_read (void *param)
1759 } 1761 }
1760 if (length > 0) { 1762 if (length > 0) {
1761 for (i = 2; i < length+2; i++) { 1763 for (i = 2; i < length+2; i++) {
1762 /* Note that the error flag is duplicated for 1764 /* Note that the error flag is duplicated for
1763 every character received since we don't know 1765 every character received since we don't know
1764 which character it applied to */ 1766 which character it applied to */
1765 tty_insert_flip_char(tty, data[packet_offset+i], error_flag); 1767 tty_insert_flip_char(tty, data[packet_offset+i], error_flag);
@@ -1773,7 +1775,7 @@ static void ftdi_process_read (void *param)
1773 This doesn't work well since the application receives a never 1775 This doesn't work well since the application receives a never
1774 ending stream of bad data - even though new data hasn't been sent. 1776 ending stream of bad data - even though new data hasn't been sent.
1775 Therefore I (bill) have taken this out. 1777 Therefore I (bill) have taken this out.
1776 However - this might make sense for framing errors and so on 1778 However - this might make sense for framing errors and so on
1777 so I am leaving the code in for now. 1779 so I am leaving the code in for now.
1778 */ 1780 */
1779 else { 1781 else {
@@ -1827,7 +1829,7 @@ static void ftdi_process_read (void *param)
1827 /* if the port is closed stop trying to read */ 1829 /* if the port is closed stop trying to read */
1828 if (port->open_count > 0){ 1830 if (port->open_count > 0){
1829 /* Continue trying to always read */ 1831 /* Continue trying to always read */
1830 usb_fill_bulk_urb(port->read_urb, port->serial->dev, 1832 usb_fill_bulk_urb(port->read_urb, port->serial->dev,
1831 usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), 1833 usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress),
1832 port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, 1834 port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length,
1833 ftdi_read_bulk_callback, port); 1835 ftdi_read_bulk_callback, port);
@@ -1844,9 +1846,9 @@ static void ftdi_process_read (void *param)
1844static void ftdi_break_ctl( struct usb_serial_port *port, int break_state ) 1846static void ftdi_break_ctl( struct usb_serial_port *port, int break_state )
1845{ 1847{
1846 struct ftdi_private *priv = usb_get_serial_port_data(port); 1848 struct ftdi_private *priv = usb_get_serial_port_data(port);
1847 __u16 urb_value = 0; 1849 __u16 urb_value = 0;
1848 char buf[1]; 1850 char buf[1];
1849 1851
1850 /* break_state = -1 to turn on break, and 0 to turn off break */ 1852 /* break_state = -1 to turn on break, and 0 to turn off break */
1851 /* see drivers/char/tty_io.c to see it used */ 1853 /* see drivers/char/tty_io.c to see it used */
1852 /* last_set_data_urb_value NEVER has the break bit set in it */ 1854 /* last_set_data_urb_value NEVER has the break bit set in it */
@@ -1854,20 +1856,20 @@ static void ftdi_break_ctl( struct usb_serial_port *port, int break_state )
1854 if (break_state) { 1856 if (break_state) {
1855 urb_value = priv->last_set_data_urb_value | FTDI_SIO_SET_BREAK; 1857 urb_value = priv->last_set_data_urb_value | FTDI_SIO_SET_BREAK;
1856 } else { 1858 } else {
1857 urb_value = priv->last_set_data_urb_value; 1859 urb_value = priv->last_set_data_urb_value;
1858 } 1860 }
1859 1861
1860 1862
1861 if (usb_control_msg(port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0), 1863 if (usb_control_msg(port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0),
1862 FTDI_SIO_SET_DATA_REQUEST, 1864 FTDI_SIO_SET_DATA_REQUEST,
1863 FTDI_SIO_SET_DATA_REQUEST_TYPE, 1865 FTDI_SIO_SET_DATA_REQUEST_TYPE,
1864 urb_value , priv->interface, 1866 urb_value , priv->interface,
1865 buf, 0, WDR_TIMEOUT) < 0) { 1867 buf, 0, WDR_TIMEOUT) < 0) {
1866 err("%s FAILED to enable/disable break state (state was %d)", __FUNCTION__,break_state); 1868 err("%s FAILED to enable/disable break state (state was %d)", __FUNCTION__,break_state);
1867 } 1869 }
1868 1870
1869 dbg("%s break state is %d - urb is %d", __FUNCTION__,break_state, urb_value); 1871 dbg("%s break state is %d - urb is %d", __FUNCTION__,break_state, urb_value);
1870 1872
1871} 1873}
1872 1874
1873 1875
@@ -1883,12 +1885,12 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct termios *old_
1883 struct ftdi_private *priv = usb_get_serial_port_data(port); 1885 struct ftdi_private *priv = usb_get_serial_port_data(port);
1884 __u16 urb_value; /* will hold the new flags */ 1886 __u16 urb_value; /* will hold the new flags */
1885 char buf[1]; /* Perhaps I should dynamically alloc this? */ 1887 char buf[1]; /* Perhaps I should dynamically alloc this? */
1886 1888
1887 // Added for xon/xoff support 1889 // Added for xon/xoff support
1888 unsigned int iflag = port->tty->termios->c_iflag; 1890 unsigned int iflag = port->tty->termios->c_iflag;
1889 unsigned char vstop; 1891 unsigned char vstop;
1890 unsigned char vstart; 1892 unsigned char vstart;
1891 1893
1892 dbg("%s", __FUNCTION__); 1894 dbg("%s", __FUNCTION__);
1893 1895
1894 /* Force baud rate if this device requires it, unless it is set to B0. */ 1896 /* Force baud rate if this device requires it, unless it is set to B0. */
@@ -1906,20 +1908,20 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct termios *old_
1906 1908
1907 cflag = port->tty->termios->c_cflag; 1909 cflag = port->tty->termios->c_cflag;
1908 1910
1909 /* FIXME -For this cut I don't care if the line is really changing or 1911 /* FIXME -For this cut I don't care if the line is really changing or
1910 not - so just do the change regardless - should be able to 1912 not - so just do the change regardless - should be able to
1911 compare old_termios and tty->termios */ 1913 compare old_termios and tty->termios */
1912 /* NOTE These routines can get interrupted by 1914 /* NOTE These routines can get interrupted by
1913 ftdi_sio_read_bulk_callback - need to examine what this 1915 ftdi_sio_read_bulk_callback - need to examine what this
1914 means - don't see any problems yet */ 1916 means - don't see any problems yet */
1915 1917
1916 /* Set number of data bits, parity, stop bits */ 1918 /* Set number of data bits, parity, stop bits */
1917 1919
1918 urb_value = 0; 1920 urb_value = 0;
1919 urb_value |= (cflag & CSTOPB ? FTDI_SIO_SET_DATA_STOP_BITS_2 : 1921 urb_value |= (cflag & CSTOPB ? FTDI_SIO_SET_DATA_STOP_BITS_2 :
1920 FTDI_SIO_SET_DATA_STOP_BITS_1); 1922 FTDI_SIO_SET_DATA_STOP_BITS_1);
1921 urb_value |= (cflag & PARENB ? 1923 urb_value |= (cflag & PARENB ?
1922 (cflag & PARODD ? FTDI_SIO_SET_DATA_PARITY_ODD : 1924 (cflag & PARODD ? FTDI_SIO_SET_DATA_PARITY_ODD :
1923 FTDI_SIO_SET_DATA_PARITY_EVEN) : 1925 FTDI_SIO_SET_DATA_PARITY_EVEN) :
1924 FTDI_SIO_SET_DATA_PARITY_NONE); 1926 FTDI_SIO_SET_DATA_PARITY_NONE);
1925 if (cflag & CSIZE) { 1927 if (cflag & CSIZE) {
@@ -1936,25 +1938,25 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct termios *old_
1936 /* This is needed by the break command since it uses the same command - but is 1938 /* This is needed by the break command since it uses the same command - but is
1937 * or'ed with this value */ 1939 * or'ed with this value */
1938 priv->last_set_data_urb_value = urb_value; 1940 priv->last_set_data_urb_value = urb_value;
1939 1941
1940 if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1942 if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
1941 FTDI_SIO_SET_DATA_REQUEST, 1943 FTDI_SIO_SET_DATA_REQUEST,
1942 FTDI_SIO_SET_DATA_REQUEST_TYPE, 1944 FTDI_SIO_SET_DATA_REQUEST_TYPE,
1943 urb_value , priv->interface, 1945 urb_value , priv->interface,
1944 buf, 0, WDR_SHORT_TIMEOUT) < 0) { 1946 buf, 0, WDR_SHORT_TIMEOUT) < 0) {
1945 err("%s FAILED to set databits/stopbits/parity", __FUNCTION__); 1947 err("%s FAILED to set databits/stopbits/parity", __FUNCTION__);
1946 } 1948 }
1947 1949
1948 /* Now do the baudrate */ 1950 /* Now do the baudrate */
1949 if ((cflag & CBAUD) == B0 ) { 1951 if ((cflag & CBAUD) == B0 ) {
1950 /* Disable flow control */ 1952 /* Disable flow control */
1951 if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1953 if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
1952 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 1954 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
1953 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 1955 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
1954 0, priv->interface, 1956 0, priv->interface,
1955 buf, 0, WDR_TIMEOUT) < 0) { 1957 buf, 0, WDR_TIMEOUT) < 0) {
1956 err("%s error from disable flowcontrol urb", __FUNCTION__); 1958 err("%s error from disable flowcontrol urb", __FUNCTION__);
1957 } 1959 }
1958 /* Drop RTS and DTR */ 1960 /* Drop RTS and DTR */
1959 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); 1961 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
1960 } else { 1962 } else {
@@ -1972,16 +1974,16 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct termios *old_
1972 /* Note device also supports DTR/CD (ugh) and Xon/Xoff in hardware */ 1974 /* Note device also supports DTR/CD (ugh) and Xon/Xoff in hardware */
1973 if (cflag & CRTSCTS) { 1975 if (cflag & CRTSCTS) {
1974 dbg("%s Setting to CRTSCTS flow control", __FUNCTION__); 1976 dbg("%s Setting to CRTSCTS flow control", __FUNCTION__);
1975 if (usb_control_msg(dev, 1977 if (usb_control_msg(dev,
1976 usb_sndctrlpipe(dev, 0), 1978 usb_sndctrlpipe(dev, 0),
1977 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 1979 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
1978 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 1980 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
1979 0 , (FTDI_SIO_RTS_CTS_HS | priv->interface), 1981 0 , (FTDI_SIO_RTS_CTS_HS | priv->interface),
1980 buf, 0, WDR_TIMEOUT) < 0) { 1982 buf, 0, WDR_TIMEOUT) < 0) {
1981 err("urb failed to set to rts/cts flow control"); 1983 err("urb failed to set to rts/cts flow control");
1982 } 1984 }
1983 1985
1984 } else { 1986 } else {
1985 /* 1987 /*
1986 * Xon/Xoff code 1988 * Xon/Xoff code
1987 * 1989 *
@@ -2011,16 +2013,16 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct termios *old_
2011 /* else clause to only run if cfag ! CRTSCTS and iflag ! XOFF */ 2013 /* else clause to only run if cfag ! CRTSCTS and iflag ! XOFF */
2012 /* CHECKME Assuming XON/XOFF handled by tty stack - not by device */ 2014 /* CHECKME Assuming XON/XOFF handled by tty stack - not by device */
2013 dbg("%s Turning off hardware flow control", __FUNCTION__); 2015 dbg("%s Turning off hardware flow control", __FUNCTION__);
2014 if (usb_control_msg(dev, 2016 if (usb_control_msg(dev,
2015 usb_sndctrlpipe(dev, 0), 2017 usb_sndctrlpipe(dev, 0),
2016 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 2018 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
2017 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2019 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
2018 0, priv->interface, 2020 0, priv->interface,
2019 buf, 0, WDR_TIMEOUT) < 0) { 2021 buf, 0, WDR_TIMEOUT) < 0) {
2020 err("urb failed to clear flow control"); 2022 err("urb failed to clear flow control");
2021 } 2023 }
2022 } 2024 }
2023 2025
2024 } 2026 }
2025 return; 2027 return;
2026} /* ftdi_termios */ 2028} /* ftdi_termios */
@@ -2036,11 +2038,11 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file)
2036 switch (priv->chip_type) { 2038 switch (priv->chip_type) {
2037 case SIO: 2039 case SIO:
2038 /* Request the status from the device */ 2040 /* Request the status from the device */
2039 if ((ret = usb_control_msg(port->serial->dev, 2041 if ((ret = usb_control_msg(port->serial->dev,
2040 usb_rcvctrlpipe(port->serial->dev, 0), 2042 usb_rcvctrlpipe(port->serial->dev, 0),
2041 FTDI_SIO_GET_MODEM_STATUS_REQUEST, 2043 FTDI_SIO_GET_MODEM_STATUS_REQUEST,
2042 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, 2044 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
2043 0, 0, 2045 0, 0,
2044 buf, 1, WDR_TIMEOUT)) < 0 ) { 2046 buf, 1, WDR_TIMEOUT)) < 0 ) {
2045 err("%s Could not get modem status of device - err: %d", __FUNCTION__, 2047 err("%s Could not get modem status of device - err: %d", __FUNCTION__,
2046 ret); 2048 ret);
@@ -2052,11 +2054,11 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file)
2052 case FT2232C: 2054 case FT2232C:
2053 /* the 8U232AM returns a two byte value (the sio is a 1 byte value) - in the same 2055 /* the 8U232AM returns a two byte value (the sio is a 1 byte value) - in the same
2054 format as the data returned from the in point */ 2056 format as the data returned from the in point */
2055 if ((ret = usb_control_msg(port->serial->dev, 2057 if ((ret = usb_control_msg(port->serial->dev,
2056 usb_rcvctrlpipe(port->serial->dev, 0), 2058 usb_rcvctrlpipe(port->serial->dev, 0),
2057 FTDI_SIO_GET_MODEM_STATUS_REQUEST, 2059 FTDI_SIO_GET_MODEM_STATUS_REQUEST,
2058 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, 2060 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
2059 0, priv->interface, 2061 0, priv->interface,
2060 buf, 2, WDR_TIMEOUT)) < 0 ) { 2062 buf, 2, WDR_TIMEOUT)) < 0 ) {
2061 err("%s Could not get modem status of device - err: %d", __FUNCTION__, 2063 err("%s Could not get modem status of device - err: %d", __FUNCTION__,
2062 ret); 2064 ret);
@@ -2067,12 +2069,12 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file)
2067 return -EFAULT; 2069 return -EFAULT;
2068 break; 2070 break;
2069 } 2071 }
2070 2072
2071 return (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) | 2073 return (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) |
2072 (buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) | 2074 (buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) |
2073 (buf[0] & FTDI_SIO_RI_MASK ? TIOCM_RI : 0) | 2075 (buf[0] & FTDI_SIO_RI_MASK ? TIOCM_RI : 0) |
2074 (buf[0] & FTDI_SIO_RLSD_MASK ? TIOCM_CD : 0) | 2076 (buf[0] & FTDI_SIO_RLSD_MASK ? TIOCM_CD : 0) |
2075 priv->last_dtr_rts; 2077 priv->last_dtr_rts;
2076} 2078}
2077 2079
2078static int ftdi_tiocmset(struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear) 2080static int ftdi_tiocmset(struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear)
@@ -2138,11 +2140,11 @@ static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigne
2138 break; 2140 break;
2139 default: 2141 default:
2140 break; 2142 break;
2141 2143
2142 } 2144 }
2143 2145
2144 2146
2145 /* This is not necessarily an error - turns out the higher layers will do 2147 /* This is not necessarily an error - turns out the higher layers will do
2146 * some ioctls itself (see comment above) 2148 * some ioctls itself (see comment above)
2147 */ 2149 */
2148 dbg("%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h", __FUNCTION__, cmd); 2150 dbg("%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h", __FUNCTION__, cmd);
@@ -2199,7 +2201,7 @@ static int __init ftdi_init (void)
2199 if (retval) 2201 if (retval)
2200 goto failed_sio_register; 2202 goto failed_sio_register;
2201 retval = usb_register(&ftdi_driver); 2203 retval = usb_register(&ftdi_driver);
2202 if (retval) 2204 if (retval)
2203 goto failed_usb_register; 2205 goto failed_usb_register;
2204 2206
2205 info(DRIVER_VERSION ":" DRIVER_DESC); 2207 info(DRIVER_VERSION ":" DRIVER_DESC);
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index f0edb87d2dd5..bae117d359af 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -55,6 +55,9 @@
55/* iPlus device */ 55/* iPlus device */
56#define FTDI_IPLUS_PID 0xD070 /* Product Id */ 56#define FTDI_IPLUS_PID 0xD070 /* Product Id */
57 57
58/* DMX4ALL DMX Interfaces */
59#define FTDI_DMX4ALL 0xC850
60
58/* www.crystalfontz.com devices - thanx for providing free devices for evaluation ! */ 61/* www.crystalfontz.com devices - thanx for providing free devices for evaluation ! */
59/* they use the ftdi chipset for the USB interface and the vendor id is the same */ 62/* they use the ftdi chipset for the USB interface and the vendor id is the same */
60#define FTDI_XF_632_PID 0xFC08 /* 632: 16x2 Character Display */ 63#define FTDI_XF_632_PID 0xFC08 /* 632: 16x2 Character Display */
@@ -175,9 +178,15 @@
175#define FTDI_ASK_RDR400_PID 0xC991 /* ASK RDR 400 series card reader */ 178#define FTDI_ASK_RDR400_PID 0xC991 /* ASK RDR 400 series card reader */
176 179
177/* 180/*
181 * FTDI USB UART chips used in construction projects from the
182 * Elektor Electronics magazine (http://elektor-electronics.co.uk)
183 */
184#define ELEKTOR_VID 0x0C7D
185#define ELEKTOR_FT323R_PID 0x0005 /* RFID-Reader, issue 09-2006 */
186
187/*
178 * DSS-20 Sync Station for Sony Ericsson P800 188 * DSS-20 Sync Station for Sony Ericsson P800
179 */ 189 */
180
181#define FTDI_DSS20_PID 0xFC82 190#define FTDI_DSS20_PID 0xFC82
182 191
183/* 192/*
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
index 6238aff1e772..d72cf8bc7f76 100644
--- a/drivers/usb/serial/ipaq.c
+++ b/drivers/usb/serial/ipaq.c
@@ -320,6 +320,7 @@ static struct usb_device_id ipaq_id_table [] = {
320 { USB_DEVICE(0x0B05, 0x9200) }, /* ASUS USB Sync */ 320 { USB_DEVICE(0x0B05, 0x9200) }, /* ASUS USB Sync */
321 { USB_DEVICE(0x0B05, 0x9202) }, /* ASUS USB Sync */ 321 { USB_DEVICE(0x0B05, 0x9202) }, /* ASUS USB Sync */
322 { USB_DEVICE(0x0BB4, 0x00CE) }, /* HTC USB Sync */ 322 { USB_DEVICE(0x0BB4, 0x00CE) }, /* HTC USB Sync */
323 { USB_DEVICE(0x0BB4, 0x00CF) }, /* HTC USB Modem */
323 { USB_DEVICE(0x0BB4, 0x0A01) }, /* PocketPC USB Sync */ 324 { USB_DEVICE(0x0BB4, 0x0A01) }, /* PocketPC USB Sync */
324 { USB_DEVICE(0x0BB4, 0x0A02) }, /* PocketPC USB Sync */ 325 { USB_DEVICE(0x0BB4, 0x0A02) }, /* PocketPC USB Sync */
325 { USB_DEVICE(0x0BB4, 0x0A03) }, /* PocketPC USB Sync */ 326 { USB_DEVICE(0x0BB4, 0x0A03) }, /* PocketPC USB Sync */
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
new file mode 100644
index 000000000000..82cd15b894b0
--- /dev/null
+++ b/drivers/usb/serial/mos7720.c
@@ -0,0 +1,1683 @@
1/*
2 * mos7720.c
3 * Controls the Moschip 7720 usb to dual port serial convertor
4 *
5 * Copyright 2006 Moschip Semiconductor Tech. Ltd.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, version 2 of the License.
10 *
11 * Developed by:
12 * VijayaKumar.G.N. <vijaykumar@aspirecom.net>
13 * AjayKumar <ajay@aspirecom.net>
14 * Gurudeva.N. <gurudev@aspirecom.net>
15 *
16 * Cleaned up from the original by:
17 * Greg Kroah-Hartman <gregkh@suse.de>
18 *
19 * Originally based on drivers/usb/serial/io_edgeport.c which is:
20 * Copyright (C) 2000 Inside Out Networks, All rights reserved.
21 * Copyright (C) 2001-2002 Greg Kroah-Hartman <greg@kroah.com>
22 */
23#include <linux/kernel.h>
24#include <linux/errno.h>
25#include <linux/init.h>
26#include <linux/slab.h>
27#include <linux/tty.h>
28#include <linux/tty_driver.h>
29#include <linux/tty_flip.h>
30#include <linux/module.h>
31#include <linux/spinlock.h>
32#include <linux/serial.h>
33#include <linux/serial_reg.h>
34#include <linux/usb.h>
35#include <linux/usb/serial.h>
36#include <asm/uaccess.h>
37
38
39/*
40 * Version Information
41 */
42#define DRIVER_VERSION "1.0.0.4F"
43#define DRIVER_AUTHOR "Aspire Communications pvt Ltd."
44#define DRIVER_DESC "Moschip USB Serial Driver"
45
46/* default urb timeout */
47#define MOS_WDR_TIMEOUT (HZ * 5)
48
49#define MOS_PORT1 0x0200
50#define MOS_PORT2 0x0300
51#define MOS_VENREG 0x0000
52#define MOS_MAX_PORT 0x02
53#define MOS_WRITE 0x0E
54#define MOS_READ 0x0D
55
56/* Interrupt Rotinue Defines */
57#define SERIAL_IIR_RLS 0x06
58#define SERIAL_IIR_RDA 0x04
59#define SERIAL_IIR_CTI 0x0c
60#define SERIAL_IIR_THR 0x02
61#define SERIAL_IIR_MS 0x00
62
63#define NUM_URBS 16 /* URB Count */
64#define URB_TRANSFER_BUFFER_SIZE 32 /* URB Size */
65
66/* This structure holds all of the local port information */
67struct moschip_port
68{
69 __u8 shadowLCR; /* last LCR value received */
70 __u8 shadowMCR; /* last MCR value received */
71 __u8 shadowMSR; /* last MSR value received */
72 char open;
73 struct async_icount icount;
74 struct usb_serial_port *port; /* loop back to the owner */
75 struct urb *write_urb_pool[NUM_URBS];
76};
77
78/* This structure holds all of the individual serial device information */
79struct moschip_serial
80{
81 int interrupt_started;
82};
83
84static int debug;
85
86#define USB_VENDOR_ID_MOSCHIP 0x9710
87#define MOSCHIP_DEVICE_ID_7720 0x7720
88#define MOSCHIP_DEVICE_ID_7715 0x7715
89
90static struct usb_device_id moschip_port_id_table [] = {
91 { USB_DEVICE(USB_VENDOR_ID_MOSCHIP,MOSCHIP_DEVICE_ID_7720) },
92 { } /* terminating entry */
93};
94MODULE_DEVICE_TABLE(usb, moschip_port_id_table);
95
96
97/*
98 * mos7720_interrupt_callback
99 * this is the callback function for when we have received data on the
100 * interrupt endpoint.
101 */
102static void mos7720_interrupt_callback(struct urb *urb)
103{
104 int result;
105 int length;
106 __u32 *data;
107 unsigned int status;
108 __u8 sp1;
109 __u8 sp2;
110 __u8 st;
111
112 dbg("%s"," : Entering\n");
113
114 if (!urb) {
115 dbg("%s","Invalid Pointer !!!!:\n");
116 return;
117 }
118
119 switch (urb->status) {
120 case 0:
121 /* success */
122 break;
123 case -ECONNRESET:
124 case -ENOENT:
125 case -ESHUTDOWN:
126 /* this urb is terminated, clean up */
127 dbg("%s - urb shutting down with status: %d", __FUNCTION__,
128 urb->status);
129 return;
130 default:
131 dbg("%s - nonzero urb status received: %d", __FUNCTION__,
132 urb->status);
133 goto exit;
134 }
135
136 length = urb->actual_length;
137 data = urb->transfer_buffer;
138
139 /* Moschip get 4 bytes
140 * Byte 1 IIR Port 1 (port.number is 0)
141 * Byte 2 IIR Port 2 (port.number is 1)
142 * Byte 3 --------------
143 * Byte 4 FIFO status for both */
144 if (length && length > 4) {
145 dbg("Wrong data !!!");
146 return;
147 }
148
149 status = *data;
150
151 sp1 = (status & 0xff000000)>>24;
152 sp2 = (status & 0x00ff0000)>>16;
153 st = status & 0x000000ff;
154
155 if ((sp1 & 0x01) || (sp2 & 0x01)) {
156 /* No Interrupt Pending in both the ports */
157 dbg("No Interrupt !!!");
158 } else {
159 switch (sp1 & 0x0f) {
160 case SERIAL_IIR_RLS:
161 dbg("Serial Port 1: Receiver status error or address "
162 "bit detected in 9-bit mode\n");
163 break;
164 case SERIAL_IIR_CTI:
165 dbg("Serial Port 1: Receiver time out");
166 break;
167 case SERIAL_IIR_MS:
168 dbg("Serial Port 1: Modem status change");
169 break;
170 }
171
172 switch (sp2 & 0x0f) {
173 case SERIAL_IIR_RLS:
174 dbg("Serial Port 2: Receiver status error or address "
175 "bit detected in 9-bit mode");
176 break;
177 case SERIAL_IIR_CTI:
178 dbg("Serial Port 2: Receiver time out");
179 break;
180 case SERIAL_IIR_MS:
181 dbg("Serial Port 2: Modem status change");
182 break;
183 }
184 }
185
186exit:
187 result = usb_submit_urb(urb, GFP_ATOMIC);
188 if (result)
189 dev_err(&urb->dev->dev,
190 "%s - Error %d submitting control urb\n",
191 __FUNCTION__, result);
192 return;
193}
194
195/*
196 * mos7720_bulk_in_callback
197 * this is the callback function for when we have received data on the
198 * bulk in endpoint.
199 */
200static void mos7720_bulk_in_callback(struct urb *urb)
201{
202 int status;
203 unsigned char *data ;
204 struct usb_serial_port *port;
205 struct moschip_port *mos7720_port;
206 struct tty_struct *tty;
207
208 if (urb->status) {
209 dbg("nonzero read bulk status received: %d",urb->status);
210 return;
211 }
212
213 mos7720_port = urb->context;
214 if (!mos7720_port) {
215 dbg("%s","NULL mos7720_port pointer \n");
216 return ;
217 }
218
219 port = mos7720_port->port;
220
221 dbg("Entering...%s", __FUNCTION__);
222
223 data = urb->transfer_buffer;
224
225 tty = port->tty;
226 if (tty && urb->actual_length) {
227 tty_buffer_request_room(tty, urb->actual_length);
228 tty_insert_flip_string(tty, data, urb->actual_length);
229 tty_flip_buffer_push(tty);
230 }
231
232 if (!port->read_urb) {
233 dbg("URB KILLED !!!");
234 return;
235 }
236
237 if (port->read_urb->status != -EINPROGRESS) {
238 port->read_urb->dev = port->serial->dev;
239
240 status = usb_submit_urb(port->read_urb, GFP_ATOMIC);
241 if (status)
242 dbg("usb_submit_urb(read bulk) failed, status = %d",
243 status);
244 }
245}
246
247/*
248 * mos7720_bulk_out_data_callback
249 * this is the callback function for when we have finished sending serial
250 * data on the bulk out endpoint.
251 */
252static void mos7720_bulk_out_data_callback(struct urb *urb)
253{
254 struct moschip_port *mos7720_port;
255 struct tty_struct *tty;
256
257 if (urb->status) {
258 dbg("nonzero write bulk status received:%d", urb->status);
259 return;
260 }
261
262 mos7720_port = urb->context;
263 if (!mos7720_port) {
264 dbg("NULL mos7720_port pointer");
265 return ;
266 }
267
268 dbg("Entering .........");
269
270 tty = mos7720_port->port->tty;
271
272 if (tty && mos7720_port->open) {
273 /* let the tty driver wakeup if it has a special *
274 * write_wakeup function */
275 if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
276 tty->ldisc.write_wakeup)
277 (tty->ldisc.write_wakeup)(tty);
278
279 /* tell the tty driver that something has changed */
280 wake_up_interruptible(&tty->write_wait);
281 }
282
283 /* schedule_work(&mos7720_port->port->work); */
284}
285
286/*
287 * send_mos_cmd
288 * this function will be used for sending command to device
289 */
290static int send_mos_cmd(struct usb_serial *serial, __u8 request, __u16 value,
291 __u16 index, void *data)
292{
293 int status;
294 unsigned int pipe;
295 u16 product = le16_to_cpu(serial->dev->descriptor.idProduct);
296 __u8 requesttype;
297 __u16 size = 0x0000;
298
299 if (value < MOS_MAX_PORT) {
300 if (product == MOSCHIP_DEVICE_ID_7715) {
301 value = value*0x100+0x100;
302 } else {
303 value = value*0x100+0x200;
304 }
305 } else {
306 value = 0x0000;
307 if ((product == MOSCHIP_DEVICE_ID_7715) &&
308 (index != 0x08)) {
309 dbg("serial->product== MOSCHIP_DEVICE_ID_7715");
310 //index = 0x01 ;
311 }
312 }
313
314 if (request == MOS_WRITE) {
315 request = (__u8)MOS_WRITE;
316 requesttype = (__u8)0x40;
317 value = value + (__u16)*((unsigned char *)data);
318 data = NULL;
319 pipe = usb_sndctrlpipe(serial->dev, 0);
320 } else {
321 request = (__u8)MOS_READ;
322 requesttype = (__u8)0xC0;
323 size = 0x01;
324 pipe = usb_rcvctrlpipe(serial->dev,0);
325 }
326
327 status = usb_control_msg(serial->dev, pipe, request, requesttype,
328 value, index, data, size, MOS_WDR_TIMEOUT);
329
330 if (status < 0)
331 dbg("Command Write failed Value %x index %x\n",value,index);
332
333 return status;
334}
335
336static int mos7720_open(struct usb_serial_port *port, struct file * filp)
337{
338 struct usb_serial *serial;
339 struct usb_serial_port *port0;
340 struct urb *urb;
341 struct moschip_serial *mos7720_serial;
342 struct moschip_port *mos7720_port;
343 int response;
344 int port_number;
345 char data;
346 int j;
347
348 serial = port->serial;
349
350 mos7720_port = usb_get_serial_port_data(port);
351 if (mos7720_port == NULL)
352 return -ENODEV;
353
354 port0 = serial->port[0];
355
356 mos7720_serial = usb_get_serial_data(serial);
357
358 if (mos7720_serial == NULL || port0 == NULL)
359 return -ENODEV;
360
361 usb_clear_halt(serial->dev, port->write_urb->pipe);
362 usb_clear_halt(serial->dev, port->read_urb->pipe);
363
364 /* Initialising the write urb pool */
365 for (j = 0; j < NUM_URBS; ++j) {
366 urb = usb_alloc_urb(0,SLAB_ATOMIC);
367 mos7720_port->write_urb_pool[j] = urb;
368
369 if (urb == NULL) {
370 err("No more urbs???");
371 continue;
372 }
373
374 urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE,
375 GFP_KERNEL);
376 if (!urb->transfer_buffer) {
377 err("%s-out of memory for urb buffers.", __FUNCTION__);
378 continue;
379 }
380 }
381
382 /* Initialize MCS7720 -- Write Init values to corresponding Registers
383 *
384 * Register Index
385 * 1 : IER
386 * 2 : FCR
387 * 3 : LCR
388 * 4 : MCR
389 *
390 * 0x08 : SP1/2 Control Reg
391 */
392 port_number = port->number - port->serial->minor;
393 send_mos_cmd(port->serial, MOS_READ, port_number, UART_LSR, &data);
394 dbg("SS::%p LSR:%x\n",mos7720_port, data);
395
396 dbg("Check:Sending Command ..........");
397
398 data = 0x02;
399 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x01, &data);
400 data = 0x02;
401 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x02, &data);
402
403 data = 0x00;
404 send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data);
405 data = 0x00;
406 send_mos_cmd(serial, MOS_WRITE, port_number, 0x02, &data);
407
408 data = 0xCF;
409 send_mos_cmd(serial, MOS_WRITE, port_number, 0x02, &data);
410 data = 0x03;
411 mos7720_port->shadowLCR = data;
412 send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data);
413 data = 0x0b;
414 mos7720_port->shadowMCR = data;
415 send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
416 data = 0x0b;
417 send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
418
419 data = 0x00;
420 send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, 0x08, &data);
421 data = 0x00;
422 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data);
423
424/* data = 0x00;
425 send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, port_number + 1, &data);
426 data = 0x03;
427 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, port_number + 1, &data);
428 data = 0x00;
429 send_mos_cmd(port->serial, MOS_WRITE, MOS_MAX_PORT, port_number + 1, &data);
430*/
431 data = 0x00;
432 send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, 0x08, &data);
433
434 data = data | (port->number - port->serial->minor + 1);
435 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data);
436
437 data = 0x83;
438 mos7720_port->shadowLCR = data;
439 send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data);
440 data = 0x0c;
441 send_mos_cmd(serial, MOS_WRITE, port_number, 0x00, &data);
442 data = 0x00;
443 send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data);
444 data = 0x03;
445 mos7720_port->shadowLCR = data;
446 send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data);
447 data = 0x0c;
448 send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data);
449 data = 0x0c;
450 send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data);
451
452//Matrix
453
454 /* force low_latency on so that our tty_push actually forces *
455 * the data through,otherwise it is scheduled, and with *
456 * high data rates (like with OHCI) data can get lost. */
457
458 if (port->tty)
459 port->tty->low_latency = 1;
460
461 /* see if we've set up our endpoint info yet *
462 * (can't set it up in mos7720_startup as the *
463 * structures were not set up at that time.) */
464 if (!mos7720_serial->interrupt_started) {
465 dbg("Interrupt buffer NULL !!!");
466
467 /* not set up yet, so do it now */
468 mos7720_serial->interrupt_started = 1;
469
470 dbg("To Submit URB !!!");
471
472 /* set up our interrupt urb */
473 usb_fill_int_urb(port0->interrupt_in_urb, serial->dev,
474 usb_rcvintpipe(serial->dev,
475 port->interrupt_in_endpointAddress),
476 port0->interrupt_in_buffer,
477 port0->interrupt_in_urb->transfer_buffer_length,
478 mos7720_interrupt_callback, mos7720_port,
479 port0->interrupt_in_urb->interval);
480
481 /* start interrupt read for this mos7720 this interrupt *
482 * will continue as long as the mos7720 is connected */
483 dbg("Submit URB over !!!");
484 response = usb_submit_urb(port0->interrupt_in_urb, GFP_KERNEL);
485 if (response)
486 dev_err(&port->dev,
487 "%s - Error %d submitting control urb",
488 __FUNCTION__, response);
489 }
490
491 /* set up our bulk in urb */
492 usb_fill_bulk_urb(port->read_urb, serial->dev,
493 usb_rcvbulkpipe(serial->dev,
494 port->bulk_in_endpointAddress),
495 port->bulk_in_buffer,
496 port->read_urb->transfer_buffer_length,
497 mos7720_bulk_in_callback, mos7720_port);
498 response = usb_submit_urb(port->read_urb, GFP_KERNEL);
499 if (response)
500 dev_err(&port->dev,
501 "%s - Error %d submitting read urb", __FUNCTION__, response);
502
503 /* initialize our icount structure */
504 memset(&(mos7720_port->icount), 0x00, sizeof(mos7720_port->icount));
505
506 /* initialize our port settings */
507 mos7720_port->shadowMCR = UART_MCR_OUT2; /* Must set to enable ints! */
508
509 /* send a open port command */
510 mos7720_port->open = 1;
511
512 return 0;
513}
514
515/*
516 * mos7720_chars_in_buffer
517 * this function is called by the tty driver when it wants to know how many
518 * bytes of data we currently have outstanding in the port (data that has
519 * been written, but hasn't made it out the port yet)
520 * If successful, we return the number of bytes left to be written in the
521 * system,
522 * Otherwise we return a negative error number.
523 */
524static int mos7720_chars_in_buffer(struct usb_serial_port *port)
525{
526 int i;
527 int chars = 0;
528 struct moschip_port *mos7720_port;
529
530 dbg("%s:entering ...........", __FUNCTION__);
531
532 mos7720_port = usb_get_serial_port_data(port);
533 if (mos7720_port == NULL) {
534 dbg("%s:leaving ...........", __FUNCTION__);
535 return -ENODEV;
536 }
537
538 for (i = 0; i < NUM_URBS; ++i) {
539 if (mos7720_port->write_urb_pool[i]->status == -EINPROGRESS)
540 chars += URB_TRANSFER_BUFFER_SIZE;
541 }
542 dbg("%s - returns %d", __FUNCTION__, chars);
543 return chars;
544}
545
546static void mos7720_close(struct usb_serial_port *port, struct file *filp)
547{
548 struct usb_serial *serial;
549 struct moschip_port *mos7720_port;
550 char data;
551 int j;
552
553 dbg("mos7720_close:entering...");
554
555 serial = port->serial;
556
557 mos7720_port = usb_get_serial_port_data(port);
558 if (mos7720_port == NULL)
559 return;
560
561 for (j = 0; j < NUM_URBS; ++j)
562 usb_kill_urb(mos7720_port->write_urb_pool[j]);
563
564 /* Freeing Write URBs */
565 for (j = 0; j < NUM_URBS; ++j) {
566 if (mos7720_port->write_urb_pool[j]) {
567 kfree(mos7720_port->write_urb_pool[j]->transfer_buffer);
568 usb_free_urb(mos7720_port->write_urb_pool[j]);
569 }
570 }
571
572 /* While closing port, shutdown all bulk read, write *
573 * and interrupt read if they exists */
574 if (serial->dev) {
575 dbg("Shutdown bulk write");
576 usb_kill_urb(port->write_urb);
577 dbg("Shutdown bulk read");
578 usb_kill_urb(port->read_urb);
579 }
580
581 data = 0x00;
582 send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor,
583 0x04, &data);
584
585 data = 0x00;
586 send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor,
587 0x01, &data);
588
589 mos7720_port->open = 0;
590
591 dbg("Leaving %s", __FUNCTION__);
592}
593
594static void mos7720_break(struct usb_serial_port *port, int break_state)
595{
596 unsigned char data;
597 struct usb_serial *serial;
598 struct moschip_port *mos7720_port;
599
600 dbg("Entering %s", __FUNCTION__);
601
602 serial = port->serial;
603
604 mos7720_port = usb_get_serial_port_data(port);
605 if (mos7720_port == NULL)
606 return;
607
608 if (break_state == -1)
609 data = mos7720_port->shadowLCR | UART_LCR_SBC;
610 else
611 data = mos7720_port->shadowLCR & ~UART_LCR_SBC;
612
613 mos7720_port->shadowLCR = data;
614 send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor,
615 0x03, &data);
616
617 return;
618}
619
620/*
621 * mos7720_write_room
622 * this function is called by the tty driver when it wants to know how many
623 * bytes of data we can accept for a specific port.
624 * If successful, we return the amount of room that we have for this port
625 * Otherwise we return a negative error number.
626 */
627static int mos7720_write_room(struct usb_serial_port *port)
628{
629 struct moschip_port *mos7720_port;
630 int room = 0;
631 int i;
632
633 dbg("%s:entering ...........", __FUNCTION__);
634
635 mos7720_port = usb_get_serial_port_data(port);
636 if (mos7720_port == NULL) {
637 dbg("%s:leaving ...........", __FUNCTION__);
638 return -ENODEV;
639 }
640
641 for (i = 0; i < NUM_URBS; ++i) {
642 if (mos7720_port->write_urb_pool[i]->status != -EINPROGRESS)
643 room += URB_TRANSFER_BUFFER_SIZE;
644 }
645
646 dbg("%s - returns %d", __FUNCTION__, room);
647 return room;
648}
649
650static int mos7720_write(struct usb_serial_port *port,
651 const unsigned char *data, int count)
652{
653 int status;
654 int i;
655 int bytes_sent = 0;
656 int transfer_size;
657
658 struct moschip_port *mos7720_port;
659 struct usb_serial *serial;
660 struct urb *urb;
661 const unsigned char *current_position = data;
662
663 dbg("%s:entering ...........", __FUNCTION__);
664
665 serial = port->serial;
666
667 mos7720_port = usb_get_serial_port_data(port);
668 if (mos7720_port == NULL) {
669 dbg("mos7720_port is NULL");
670 return -ENODEV;
671 }
672
673 /* try to find a free urb in the list */
674 urb = NULL;
675
676 for (i = 0; i < NUM_URBS; ++i) {
677 if (mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) {
678 urb = mos7720_port->write_urb_pool[i];
679 dbg("URB:%d",i);
680 break;
681 }
682 }
683
684 if (urb == NULL) {
685 dbg("%s - no more free urbs", __FUNCTION__);
686 goto exit;
687 }
688
689 if (urb->transfer_buffer == NULL) {
690 urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE,
691 GFP_KERNEL);
692 if (urb->transfer_buffer == NULL) {
693 err("%s no more kernel memory...", __FUNCTION__);
694 goto exit;
695 }
696 }
697 transfer_size = min (count, URB_TRANSFER_BUFFER_SIZE);
698
699 memcpy(urb->transfer_buffer, current_position, transfer_size);
700 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, transfer_size,
701 urb->transfer_buffer);
702
703 /* fill urb with data and submit */
704 usb_fill_bulk_urb(urb, serial->dev,
705 usb_sndbulkpipe(serial->dev,
706 port->bulk_out_endpointAddress),
707 urb->transfer_buffer, transfer_size,
708 mos7720_bulk_out_data_callback, mos7720_port);
709
710 /* send it down the pipe */
711 status = usb_submit_urb(urb,GFP_ATOMIC);
712 if (status) {
713 err("%s - usb_submit_urb(write bulk) failed with status = %d",
714 __FUNCTION__, status);
715 bytes_sent = status;
716 goto exit;
717 }
718 bytes_sent = transfer_size;
719
720exit:
721 return bytes_sent;
722}
723
724static void mos7720_throttle(struct usb_serial_port *port)
725{
726 struct moschip_port *mos7720_port;
727 struct tty_struct *tty;
728 int status;
729
730 dbg("%s- port %d\n", __FUNCTION__, port->number);
731
732 mos7720_port = usb_get_serial_port_data(port);
733
734 if (mos7720_port == NULL)
735 return;
736
737 if (!mos7720_port->open) {
738 dbg("port not opened");
739 return;
740 }
741
742 dbg("%s: Entering ..........", __FUNCTION__);
743
744 tty = port->tty;
745 if (!tty) {
746 dbg("%s - no tty available", __FUNCTION__);
747 return;
748 }
749
750 /* if we are implementing XON/XOFF, send the stop character */
751 if (I_IXOFF(tty)) {
752 unsigned char stop_char = STOP_CHAR(tty);
753 status = mos7720_write(port, &stop_char, 1);
754 if (status <= 0)
755 return;
756 }
757
758 /* if we are implementing RTS/CTS, toggle that line */
759 if (tty->termios->c_cflag & CRTSCTS) {
760 mos7720_port->shadowMCR &= ~UART_MCR_RTS;
761 status = send_mos_cmd(port->serial, MOS_WRITE,
762 port->number - port->serial->minor,
763 UART_MCR, &mos7720_port->shadowMCR);
764 if (status != 0)
765 return;
766 }
767}
768
769static void mos7720_unthrottle(struct usb_serial_port *port)
770{
771 struct tty_struct *tty;
772 int status;
773 struct moschip_port *mos7720_port = usb_get_serial_port_data(port);
774
775 if (mos7720_port == NULL)
776 return;
777
778 if (!mos7720_port->open) {
779 dbg("%s - port not opened", __FUNCTION__);
780 return;
781 }
782
783 dbg("%s: Entering ..........", __FUNCTION__);
784
785 tty = port->tty;
786 if (!tty) {
787 dbg("%s - no tty available", __FUNCTION__);
788 return;
789 }
790
791 /* if we are implementing XON/XOFF, send the start character */
792 if (I_IXOFF(tty)) {
793 unsigned char start_char = START_CHAR(tty);
794 status = mos7720_write(port, &start_char, 1);
795 if (status <= 0)
796 return;
797 }
798
799 /* if we are implementing RTS/CTS, toggle that line */
800 if (tty->termios->c_cflag & CRTSCTS) {
801 mos7720_port->shadowMCR |= UART_MCR_RTS;
802 status = send_mos_cmd(port->serial, MOS_WRITE,
803 port->number - port->serial->minor,
804 UART_MCR, &mos7720_port->shadowMCR);
805 if (status != 0)
806 return;
807 }
808}
809
810static int set_higher_rates(struct moschip_port *mos7720_port,
811 unsigned int baud)
812{
813 unsigned char data;
814 struct usb_serial_port *port;
815 struct usb_serial *serial;
816 int port_number;
817
818 if (mos7720_port == NULL)
819 return -EINVAL;
820
821 port = mos7720_port->port;
822 serial = port->serial;
823
824 /***********************************************
825 * Init Sequence for higher rates
826 ***********************************************/
827 dbg("Sending Setting Commands ..........");
828 port_number = port->number - port->serial->minor;
829
830 data = 0x000;
831 send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data);
832 data = 0x000;
833 send_mos_cmd(serial, MOS_WRITE, port_number, 0x02, &data);
834 data = 0x0CF;
835 send_mos_cmd(serial, MOS_WRITE, port->number, 0x02, &data);
836 data = 0x00b;
837 mos7720_port->shadowMCR = data;
838 send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
839 data = 0x00b;
840 send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
841
842 data = 0x000;
843 send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, 0x08, &data);
844 data = 0x000;
845 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data);
846
847
848 /***********************************************
849 * Set for higher rates *
850 ***********************************************/
851
852 data = baud * 0x10;
853 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, port_number + 1,&data);
854
855 data = 0x003;
856 send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, 0x08, &data);
857 data = 0x003;
858 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data);
859
860 data = 0x02b;
861 mos7720_port->shadowMCR = data;
862 send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
863 data = 0x02b;
864 send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
865
866 /***********************************************
867 * Set DLL/DLM
868 ***********************************************/
869
870 data = mos7720_port->shadowLCR | UART_LCR_DLAB;
871 mos7720_port->shadowLCR = data;
872 send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data);
873
874 data = 0x001; /* DLL */
875 send_mos_cmd(serial, MOS_WRITE, port_number, 0x00, &data);
876 data = 0x000; /* DLM */
877 send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data);
878
879 data = mos7720_port->shadowLCR & ~UART_LCR_DLAB;
880 mos7720_port->shadowLCR = data;
881 send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data);
882
883 return 0;
884}
885
886/* baud rate information */
887struct divisor_table_entry
888{
889 __u32 baudrate;
890 __u16 divisor;
891};
892
893/* Define table of divisors for moschip 7720 hardware *
894 * These assume a 3.6864MHz crystal, the standard /16, and *
895 * MCR.7 = 0. */
896static struct divisor_table_entry divisor_table[] = {
897 { 50, 2304},
898 { 110, 1047}, /* 2094.545455 => 230450 => .0217 % over */
899 { 134, 857}, /* 1713.011152 => 230398.5 => .00065% under */
900 { 150, 768},
901 { 300, 384},
902 { 600, 192},
903 { 1200, 96},
904 { 1800, 64},
905 { 2400, 48},
906 { 4800, 24},
907 { 7200, 16},
908 { 9600, 12},
909 { 19200, 6},
910 { 38400, 3},
911 { 57600, 2},
912 { 115200, 1},
913};
914
915/*****************************************************************************
916 * calc_baud_rate_divisor
917 * this function calculates the proper baud rate divisor for the specified
918 * baud rate.
919 *****************************************************************************/
920static int calc_baud_rate_divisor(int baudrate, int *divisor)
921{
922 int i;
923 __u16 custom;
924 __u16 round1;
925 __u16 round;
926
927
928 dbg("%s - %d", __FUNCTION__, baudrate);
929
930 for (i = 0; i < ARRAY_SIZE(divisor_table); i++) {
931 if (divisor_table[i].baudrate == baudrate) {
932 *divisor = divisor_table[i].divisor;
933 return 0;
934 }
935 }
936
937 /* After trying for all the standard baud rates *
938 * Try calculating the divisor for this baud rate */
939 if (baudrate > 75 && baudrate < 230400) {
940 /* get the divisor */
941 custom = (__u16)(230400L / baudrate);
942
943 /* Check for round off */
944 round1 = (__u16)(2304000L / baudrate);
945 round = (__u16)(round1 - (custom * 10));
946 if (round > 4)
947 custom++;
948 *divisor = custom;
949
950 dbg("Baud %d = %d",baudrate, custom);
951 return 0;
952 }
953
954 dbg("Baud calculation Failed...");
955 return -EINVAL;
956}
957
958/*
959 * send_cmd_write_baud_rate
960 * this function sends the proper command to change the baud rate of the
961 * specified port.
962 */
963static int send_cmd_write_baud_rate(struct moschip_port *mos7720_port,
964 int baudrate)
965{
966 struct usb_serial_port *port;
967 struct usb_serial *serial;
968 int divisor;
969 int status;
970 unsigned char data;
971 unsigned char number;
972
973 if (mos7720_port == NULL)
974 return -1;
975
976 port = mos7720_port->port;
977 serial = port->serial;
978
979 dbg("%s: Entering ..........", __FUNCTION__);
980
981 number = port->number - port->serial->minor;
982 dbg("%s - port = %d, baud = %d", __FUNCTION__, port->number, baudrate);
983
984 /* Calculate the Divisor */
985 status = calc_baud_rate_divisor(baudrate, &divisor);
986 if (status) {
987 err("%s - bad baud rate", __FUNCTION__);
988 return status;
989 }
990
991 /* Enable access to divisor latch */
992 data = mos7720_port->shadowLCR | UART_LCR_DLAB;
993 mos7720_port->shadowLCR = data;
994 send_mos_cmd(serial, MOS_WRITE, number, UART_LCR, &data);
995
996 /* Write the divisor */
997 data = ((unsigned char)(divisor & 0xff));
998 send_mos_cmd(serial, MOS_WRITE, number, 0x00, &data);
999
1000 data = ((unsigned char)((divisor & 0xff00) >> 8));
1001 send_mos_cmd(serial, MOS_WRITE, number, 0x01, &data);
1002
1003 /* Disable access to divisor latch */
1004 data = mos7720_port->shadowLCR & ~UART_LCR_DLAB;
1005 mos7720_port->shadowLCR = data;
1006 send_mos_cmd(serial, MOS_WRITE, number, 0x03, &data);
1007
1008 return status;
1009}
1010
1011/*
1012 * change_port_settings
1013 * This routine is called to set the UART on the device to match
1014 * the specified new settings.
1015 */
1016static void change_port_settings(struct moschip_port *mos7720_port,
1017 struct termios *old_termios)
1018{
1019 struct usb_serial_port *port;
1020 struct usb_serial *serial;
1021 struct tty_struct *tty;
1022 int baud;
1023 unsigned cflag;
1024 unsigned iflag;
1025 __u8 mask = 0xff;
1026 __u8 lData;
1027 __u8 lParity;
1028 __u8 lStop;
1029 int status;
1030 int port_number;
1031 char data;
1032
1033 if (mos7720_port == NULL)
1034 return ;
1035
1036 port = mos7720_port->port;
1037 serial = port->serial;
1038 port_number = port->number - port->serial->minor;
1039
1040 dbg("%s - port %d", __FUNCTION__, port->number);
1041
1042 if (!mos7720_port->open) {
1043 dbg("%s - port not opened", __FUNCTION__);
1044 return;
1045 }
1046
1047 tty = mos7720_port->port->tty;
1048
1049 if ((!tty) || (!tty->termios)) {
1050 dbg("%s - no tty structures", __FUNCTION__);
1051 return;
1052 }
1053
1054 dbg("%s: Entering ..........", __FUNCTION__);
1055
1056 lData = UART_LCR_WLEN8;
1057 lStop = 0x00; /* 1 stop bit */
1058 lParity = 0x00; /* No parity */
1059
1060 cflag = tty->termios->c_cflag;
1061 iflag = tty->termios->c_iflag;
1062
1063 /* Change the number of bits */
1064 switch (cflag & CSIZE) {
1065 case CS5:
1066 lData = UART_LCR_WLEN5;
1067 mask = 0x1f;
1068 break;
1069
1070 case CS6:
1071 lData = UART_LCR_WLEN6;
1072 mask = 0x3f;
1073 break;
1074
1075 case CS7:
1076 lData = UART_LCR_WLEN7;
1077 mask = 0x7f;
1078 break;
1079 default:
1080 case CS8:
1081 lData = UART_LCR_WLEN8;
1082 break;
1083 }
1084
1085 /* Change the Parity bit */
1086 if (cflag & PARENB) {
1087 if (cflag & PARODD) {
1088 lParity = UART_LCR_PARITY;
1089 dbg("%s - parity = odd", __FUNCTION__);
1090 } else {
1091 lParity = (UART_LCR_EPAR | UART_LCR_PARITY);
1092 dbg("%s - parity = even", __FUNCTION__);
1093 }
1094
1095 } else {
1096 dbg("%s - parity = none", __FUNCTION__);
1097 }
1098
1099 if (cflag & CMSPAR)
1100 lParity = lParity | 0x20;
1101
1102 /* Change the Stop bit */
1103 if (cflag & CSTOPB) {
1104 lStop = UART_LCR_STOP;
1105 dbg("%s - stop bits = 2", __FUNCTION__);
1106 } else {
1107 lStop = 0x00;
1108 dbg("%s - stop bits = 1", __FUNCTION__);
1109 }
1110
1111#define LCR_BITS_MASK 0x03 /* Mask for bits/char field */
1112#define LCR_STOP_MASK 0x04 /* Mask for stop bits field */
1113#define LCR_PAR_MASK 0x38 /* Mask for parity field */
1114
1115 /* Update the LCR with the correct value */
1116 mos7720_port->shadowLCR &= ~(LCR_BITS_MASK | LCR_STOP_MASK | LCR_PAR_MASK);
1117 mos7720_port->shadowLCR |= (lData | lParity | lStop);
1118
1119
1120 /* Disable Interrupts */
1121 data = 0x00;
1122 send_mos_cmd(serial,MOS_WRITE,port->number - port->serial->minor, UART_IER, &data);
1123
1124 data = 0x00;
1125 send_mos_cmd(serial, MOS_WRITE, port_number, UART_FCR, &data);
1126
1127 data = 0xcf;
1128 send_mos_cmd(serial, MOS_WRITE, port_number, UART_FCR, &data);
1129
1130 /* Send the updated LCR value to the mos7720 */
1131 data = mos7720_port->shadowLCR;
1132 send_mos_cmd(serial, MOS_WRITE, port_number, UART_LCR, &data);
1133
1134 data = 0x00b;
1135 mos7720_port->shadowMCR = data;
1136 send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
1137 data = 0x00b;
1138 send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
1139
1140 /* set up the MCR register and send it to the mos7720 */
1141 mos7720_port->shadowMCR = UART_MCR_OUT2;
1142 if (cflag & CBAUD)
1143 mos7720_port->shadowMCR |= (UART_MCR_DTR | UART_MCR_RTS);
1144
1145 if (cflag & CRTSCTS) {
1146 mos7720_port->shadowMCR |= (UART_MCR_XONANY);
1147
1148 /* To set hardware flow control to the specified *
1149 * serial port, in SP1/2_CONTROL_REG */
1150 if (port->number) {
1151 data = 0x001;
1152 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT,
1153 0x08, &data);
1154 } else {
1155 data = 0x002;
1156 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT,
1157 0x08, &data);
1158 }
1159 } else {
1160 mos7720_port->shadowMCR &= ~(UART_MCR_XONANY);
1161 }
1162
1163 data = mos7720_port->shadowMCR;
1164 send_mos_cmd(serial, MOS_WRITE, port_number, UART_MCR, &data);
1165
1166 /* Determine divisor based on baud rate */
1167 baud = tty_get_baud_rate(tty);
1168 if (!baud) {
1169 /* pick a default, any default... */
1170 dbg("Picked default baud...");
1171 baud = 9600;
1172 }
1173
1174 if (baud >= 230400) {
1175 set_higher_rates(mos7720_port, baud);
1176 /* Enable Interrupts */
1177 data = 0x0c;
1178 send_mos_cmd(serial, MOS_WRITE, port_number, UART_IER, &data);
1179 return;
1180 }
1181
1182 dbg("%s - baud rate = %d", __FUNCTION__, baud);
1183 status = send_cmd_write_baud_rate(mos7720_port, baud);
1184
1185 /* Enable Interrupts */
1186 data = 0x0c;
1187 send_mos_cmd(serial, MOS_WRITE, port_number, UART_IER, &data);
1188
1189 if (port->read_urb->status != -EINPROGRESS) {
1190 port->read_urb->dev = serial->dev;
1191
1192 status = usb_submit_urb(port->read_urb, GFP_ATOMIC);
1193 if (status)
1194 dbg("usb_submit_urb(read bulk) failed, status = %d",
1195 status);
1196 }
1197 return;
1198}
1199
1200/*
1201 * mos7720_set_termios
1202 * this function is called by the tty driver when it wants to change the
1203 * termios structure.
1204 */
1205static void mos7720_set_termios(struct usb_serial_port *port,
1206 struct termios *old_termios)
1207{
1208 int status;
1209 unsigned int cflag;
1210 struct usb_serial *serial;
1211 struct moschip_port *mos7720_port;
1212 struct tty_struct *tty;
1213
1214 serial = port->serial;
1215
1216 mos7720_port = usb_get_serial_port_data(port);
1217
1218 if (mos7720_port == NULL)
1219 return;
1220
1221 tty = port->tty;
1222
1223 if (!port->tty || !port->tty->termios) {
1224 dbg("%s - no tty or termios", __FUNCTION__);
1225 return;
1226 }
1227
1228 if (!mos7720_port->open) {
1229 dbg("%s - port not opened", __FUNCTION__);
1230 return;
1231 }
1232
1233 dbg("%s\n","setting termios - ASPIRE");
1234
1235 cflag = tty->termios->c_cflag;
1236
1237 if (!cflag) {
1238 printk("%s %s\n",__FUNCTION__,"cflag is NULL");
1239 return;
1240 }
1241
1242 /* check that they really want us to change something */
1243 if (old_termios) {
1244 if ((cflag == old_termios->c_cflag) &&
1245 (RELEVANT_IFLAG(tty->termios->c_iflag) ==
1246 RELEVANT_IFLAG(old_termios->c_iflag))) {
1247 dbg("Nothing to change");
1248 return;
1249 }
1250 }
1251
1252 dbg("%s - clfag %08x iflag %08x", __FUNCTION__,
1253 tty->termios->c_cflag,
1254 RELEVANT_IFLAG(tty->termios->c_iflag));
1255
1256 if (old_termios)
1257 dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__,
1258 old_termios->c_cflag,
1259 RELEVANT_IFLAG(old_termios->c_iflag));
1260
1261 dbg("%s - port %d", __FUNCTION__, port->number);
1262
1263 /* change the port settings to the new ones specified */
1264 change_port_settings(mos7720_port, old_termios);
1265
1266 if(!port->read_urb) {
1267 dbg("%s","URB KILLED !!!!!\n");
1268 return;
1269 }
1270
1271 if(port->read_urb->status != -EINPROGRESS) {
1272 port->read_urb->dev = serial->dev;
1273 status = usb_submit_urb(port->read_urb, GFP_ATOMIC);
1274 if (status)
1275 dbg("usb_submit_urb(read bulk) failed, status = %d",
1276 status);
1277 }
1278 return;
1279}
1280
1281/*
1282 * get_lsr_info - get line status register info
1283 *
1284 * Purpose: Let user call ioctl() to get info when the UART physically
1285 * is emptied. On bus types like RS485, the transmitter must
1286 * release the bus after transmitting. This must be done when
1287 * the transmit shift register is empty, not be done when the
1288 * transmit holding register is empty. This functionality
1289 * allows an RS485 driver to be written in user space.
1290 */
1291static int get_lsr_info(struct moschip_port *mos7720_port,
1292 unsigned int __user *value)
1293{
1294 int count;
1295 unsigned int result = 0;
1296
1297 count = mos7720_chars_in_buffer(mos7720_port->port);
1298 if (count == 0) {
1299 dbg("%s -- Empty", __FUNCTION__);
1300 result = TIOCSER_TEMT;
1301 }
1302
1303 if (copy_to_user(value, &result, sizeof(int)))
1304 return -EFAULT;
1305 return 0;
1306}
1307
1308/*
1309 * get_number_bytes_avail - get number of bytes available
1310 *
1311 * Purpose: Let user call ioctl to get the count of number of bytes available.
1312 */
1313static int get_number_bytes_avail(struct moschip_port *mos7720_port,
1314 unsigned int __user *value)
1315{
1316 unsigned int result = 0;
1317 struct tty_struct *tty = mos7720_port->port->tty;
1318
1319 if (!tty)
1320 return -ENOIOCTLCMD;
1321
1322 result = tty->read_cnt;
1323
1324 dbg("%s(%d) = %d", __FUNCTION__, mos7720_port->port->number, result);
1325 if (copy_to_user(value, &result, sizeof(int)))
1326 return -EFAULT;
1327
1328 return -ENOIOCTLCMD;
1329}
1330
1331static int set_modem_info(struct moschip_port *mos7720_port, unsigned int cmd,
1332 unsigned int __user *value)
1333{
1334 unsigned int mcr ;
1335 unsigned int arg;
1336 unsigned char data;
1337
1338 struct usb_serial_port *port;
1339
1340 if (mos7720_port == NULL)
1341 return -1;
1342
1343 port = (struct usb_serial_port*)mos7720_port->port;
1344 mcr = mos7720_port->shadowMCR;
1345
1346 if (copy_from_user(&arg, value, sizeof(int)))
1347 return -EFAULT;
1348
1349 switch (cmd) {
1350 case TIOCMBIS:
1351 if (arg & TIOCM_RTS)
1352 mcr |= UART_MCR_RTS;
1353 if (arg & TIOCM_DTR)
1354 mcr |= UART_MCR_RTS;
1355 if (arg & TIOCM_LOOP)
1356 mcr |= UART_MCR_LOOP;
1357 break;
1358
1359 case TIOCMBIC:
1360 if (arg & TIOCM_RTS)
1361 mcr &= ~UART_MCR_RTS;
1362 if (arg & TIOCM_DTR)
1363 mcr &= ~UART_MCR_RTS;
1364 if (arg & TIOCM_LOOP)
1365 mcr &= ~UART_MCR_LOOP;
1366 break;
1367
1368 case TIOCMSET:
1369 /* turn off the RTS and DTR and LOOPBACK
1370 * and then only turn on what was asked to */
1371 mcr &= ~(UART_MCR_RTS | UART_MCR_DTR | UART_MCR_LOOP);
1372 mcr |= ((arg & TIOCM_RTS) ? UART_MCR_RTS : 0);
1373 mcr |= ((arg & TIOCM_DTR) ? UART_MCR_DTR : 0);
1374 mcr |= ((arg & TIOCM_LOOP) ? UART_MCR_LOOP : 0);
1375 break;
1376 }
1377
1378 mos7720_port->shadowMCR = mcr;
1379
1380 data = mos7720_port->shadowMCR;
1381 send_mos_cmd(port->serial, MOS_WRITE,
1382 port->number - port->serial->minor, UART_MCR, &data);
1383
1384 return 0;
1385}
1386
1387static int get_modem_info(struct moschip_port *mos7720_port,
1388 unsigned int __user *value)
1389{
1390 unsigned int result = 0;
1391 unsigned int msr = mos7720_port->shadowMSR;
1392 unsigned int mcr = mos7720_port->shadowMCR;
1393
1394 result = ((mcr & UART_MCR_DTR) ? TIOCM_DTR: 0) /* 0x002 */
1395 | ((mcr & UART_MCR_RTS) ? TIOCM_RTS: 0) /* 0x004 */
1396 | ((msr & UART_MSR_CTS) ? TIOCM_CTS: 0) /* 0x020 */
1397 | ((msr & UART_MSR_DCD) ? TIOCM_CAR: 0) /* 0x040 */
1398 | ((msr & UART_MSR_RI) ? TIOCM_RI: 0) /* 0x080 */
1399 | ((msr & UART_MSR_DSR) ? TIOCM_DSR: 0); /* 0x100 */
1400
1401
1402 dbg("%s -- %x", __FUNCTION__, result);
1403
1404 if (copy_to_user(value, &result, sizeof(int)))
1405 return -EFAULT;
1406 return 0;
1407}
1408
1409static int get_serial_info(struct moschip_port *mos7720_port,
1410 struct serial_struct __user *retinfo)
1411{
1412 struct serial_struct tmp;
1413
1414 if (!retinfo)
1415 return -EFAULT;
1416
1417 memset(&tmp, 0, sizeof(tmp));
1418
1419 tmp.type = PORT_16550A;
1420 tmp.line = mos7720_port->port->serial->minor;
1421 tmp.port = mos7720_port->port->number;
1422 tmp.irq = 0;
1423 tmp.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ;
1424 tmp.xmit_fifo_size = NUM_URBS * URB_TRANSFER_BUFFER_SIZE;
1425 tmp.baud_base = 9600;
1426 tmp.close_delay = 5*HZ;
1427 tmp.closing_wait = 30*HZ;
1428
1429 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
1430 return -EFAULT;
1431 return 0;
1432}
1433
1434static int mos7720_ioctl(struct usb_serial_port *port, struct file *file,
1435 unsigned int cmd, unsigned long arg)
1436{
1437 struct moschip_port *mos7720_port;
1438 struct async_icount cnow;
1439 struct async_icount cprev;
1440 struct serial_icounter_struct icount;
1441
1442 mos7720_port = usb_get_serial_port_data(port);
1443 if (mos7720_port == NULL)
1444 return -ENODEV;
1445
1446 dbg("%s - port %d, cmd = 0x%x", __FUNCTION__, port->number, cmd);
1447
1448 switch (cmd) {
1449 case TIOCINQ:
1450 /* return number of bytes available */
1451 dbg("%s (%d) TIOCINQ", __FUNCTION__, port->number);
1452 return get_number_bytes_avail(mos7720_port,
1453 (unsigned int __user *)arg);
1454 break;
1455
1456 case TIOCSERGETLSR:
1457 dbg("%s (%d) TIOCSERGETLSR", __FUNCTION__, port->number);
1458 return get_lsr_info(mos7720_port, (unsigned int __user *)arg);
1459 return 0;
1460
1461 case TIOCMBIS:
1462 case TIOCMBIC:
1463 case TIOCMSET:
1464 dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __FUNCTION__,
1465 port->number);
1466 return set_modem_info(mos7720_port, cmd,
1467 (unsigned int __user *)arg);
1468
1469 case TIOCMGET:
1470 dbg("%s (%d) TIOCMGET", __FUNCTION__, port->number);
1471 return get_modem_info(mos7720_port,
1472 (unsigned int __user *)arg);
1473
1474 case TIOCGSERIAL:
1475 dbg("%s (%d) TIOCGSERIAL", __FUNCTION__, port->number);
1476 return get_serial_info(mos7720_port,
1477 (struct serial_struct __user *)arg);
1478
1479 case TIOCSSERIAL:
1480 dbg("%s (%d) TIOCSSERIAL", __FUNCTION__, port->number);
1481 break;
1482
1483 case TIOCMIWAIT:
1484 dbg("%s (%d) TIOCMIWAIT", __FUNCTION__, port->number);
1485 cprev = mos7720_port->icount;
1486 while (1) {
1487 if (signal_pending(current))
1488 return -ERESTARTSYS;
1489 cnow = mos7720_port->icount;
1490 if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
1491 cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
1492 return -EIO; /* no change => error */
1493 if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
1494 ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
1495 ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) ||
1496 ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)) ) {
1497 return 0;
1498 }
1499 cprev = cnow;
1500 }
1501 /* NOTREACHED */
1502 break;
1503
1504 case TIOCGICOUNT:
1505 cnow = mos7720_port->icount;
1506 icount.cts = cnow.cts;
1507 icount.dsr = cnow.dsr;
1508 icount.rng = cnow.rng;
1509 icount.dcd = cnow.dcd;
1510 icount.rx = cnow.rx;
1511 icount.tx = cnow.tx;
1512 icount.frame = cnow.frame;
1513 icount.overrun = cnow.overrun;
1514 icount.parity = cnow.parity;
1515 icount.brk = cnow.brk;
1516 icount.buf_overrun = cnow.buf_overrun;
1517
1518 dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __FUNCTION__,
1519 port->number, icount.rx, icount.tx );
1520 if (copy_to_user((void __user *)arg, &icount, sizeof(icount)))
1521 return -EFAULT;
1522 return 0;
1523 }
1524
1525 return -ENOIOCTLCMD;
1526}
1527
1528static int mos7720_startup(struct usb_serial *serial)
1529{
1530 struct moschip_serial *mos7720_serial;
1531 struct moschip_port *mos7720_port;
1532 struct usb_device *dev;
1533 int i;
1534 char data;
1535
1536 dbg("%s: Entering ..........", __FUNCTION__);
1537
1538 if (!serial) {
1539 dbg("Invalid Handler");
1540 return -ENODEV;
1541 }
1542
1543 dev = serial->dev;
1544
1545 /* create our private serial structure */
1546 mos7720_serial = kzalloc(sizeof(struct moschip_serial), GFP_KERNEL);
1547 if (mos7720_serial == NULL) {
1548 err("%s - Out of memory", __FUNCTION__);
1549 return -ENOMEM;
1550 }
1551
1552 usb_set_serial_data(serial, mos7720_serial);
1553
1554 /* we set up the pointers to the endpoints in the mos7720_open *
1555 * function, as the structures aren't created yet. */
1556
1557 /* set up port private structures */
1558 for (i = 0; i < serial->num_ports; ++i) {
1559 mos7720_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL);
1560 if (mos7720_port == NULL) {
1561 err("%s - Out of memory", __FUNCTION__);
1562 usb_set_serial_data(serial, NULL);
1563 kfree(mos7720_serial);
1564 return -ENOMEM;
1565 }
1566
1567 /* Initialize all port interrupt end point to port 0 int
1568 * endpoint. Our device has only one interrupt endpoint
1569 * comman to all ports */
1570 serial->port[i]->interrupt_in_endpointAddress = serial->port[0]->interrupt_in_endpointAddress;
1571
1572 mos7720_port->port = serial->port[i];
1573 usb_set_serial_port_data(serial->port[i], mos7720_port);
1574
1575 dbg("port number is %d", serial->port[i]->number);
1576 dbg("serial number is %d", serial->minor);
1577 }
1578
1579
1580 /* setting configuration feature to one */
1581 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
1582 (__u8)0x03, 0x00,0x01,0x00, NULL, 0x00, 5*HZ);
1583
1584 send_mos_cmd(serial,MOS_READ,0x00, UART_LSR, &data); // LSR For Port 1
1585 dbg("LSR:%x",data);
1586
1587 send_mos_cmd(serial,MOS_READ,0x01, UART_LSR, &data); // LSR For Port 2
1588 dbg("LSR:%x",data);
1589
1590 return 0;
1591}
1592
1593static void mos7720_shutdown(struct usb_serial *serial)
1594{
1595 int i;
1596
1597 /* free private structure allocated for serial port */
1598 for (i=0; i < serial->num_ports; ++i) {
1599 kfree(usb_get_serial_port_data(serial->port[i]));
1600 usb_set_serial_port_data(serial->port[i], NULL);
1601 }
1602
1603 /* free private structure allocated for serial device */
1604 kfree(usb_get_serial_data(serial));
1605 usb_set_serial_data(serial, NULL);
1606}
1607
1608static struct usb_serial_driver moschip7720_2port_driver = {
1609 .driver = {
1610 .owner = THIS_MODULE,
1611 .name = "moschip7720",
1612 },
1613 .description = "Moschip 2 port adapter",
1614 .id_table = moschip_port_id_table,
1615 .num_interrupt_in = 1,
1616 .num_bulk_in = 2,
1617 .num_bulk_out = 2,
1618 .num_ports = 2,
1619 .open = mos7720_open,
1620 .close = mos7720_close,
1621 .throttle = mos7720_throttle,
1622 .unthrottle = mos7720_unthrottle,
1623 .attach = mos7720_startup,
1624 .shutdown = mos7720_shutdown,
1625 .ioctl = mos7720_ioctl,
1626 .set_termios = mos7720_set_termios,
1627 .write = mos7720_write,
1628 .write_room = mos7720_write_room,
1629 .chars_in_buffer = mos7720_chars_in_buffer,
1630 .break_ctl = mos7720_break,
1631 .read_bulk_callback = mos7720_bulk_in_callback,
1632};
1633
1634static struct usb_driver usb_driver = {
1635 .name = "moschip7720",
1636 .probe = usb_serial_probe,
1637 .disconnect = usb_serial_disconnect,
1638 .id_table = moschip_port_id_table,
1639};
1640
1641static int __init moschip7720_init(void)
1642{
1643 int retval;
1644
1645 dbg("%s: Entering ..........", __FUNCTION__);
1646
1647 /* Register with the usb serial */
1648 retval = usb_serial_register(&moschip7720_2port_driver);
1649 if (retval)
1650 goto failed_port_device_register;
1651
1652 info(DRIVER_DESC " " DRIVER_VERSION);
1653
1654 /* Register with the usb */
1655 retval = usb_register(&usb_driver);
1656 if (retval)
1657 goto failed_usb_register;
1658
1659 return 0;
1660
1661failed_usb_register:
1662 usb_serial_deregister(&moschip7720_2port_driver);
1663
1664failed_port_device_register:
1665 return retval;
1666}
1667
1668static void __exit moschip7720_exit(void)
1669{
1670 usb_deregister(&usb_driver);
1671 usb_serial_deregister(&moschip7720_2port_driver);
1672}
1673
1674module_init(moschip7720_init);
1675module_exit(moschip7720_exit);
1676
1677/* Module information */
1678MODULE_AUTHOR( DRIVER_AUTHOR );
1679MODULE_DESCRIPTION( DRIVER_DESC );
1680MODULE_LICENSE("GPL");
1681
1682module_param(debug, bool, S_IRUGO | S_IWUSR);
1683MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 021be39fe16e..5b71962d0351 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -2413,11 +2413,12 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2413 } 2413 }
2414 2414
2415 mos7840_port = mos7840_get_port_private(port); 2415 mos7840_port = mos7840_get_port_private(port);
2416 tty = mos7840_port->port->tty;
2417 2416
2418 if (mos7840_port == NULL) 2417 if (mos7840_port == NULL)
2419 return -1; 2418 return -1;
2420 2419
2420 tty = mos7840_port->port->tty;
2421
2421 dbg("%s - port %d, cmd = 0x%x", __FUNCTION__, port->number, cmd); 2422 dbg("%s - port %d, cmd = 0x%x", __FUNCTION__, port->number, cmd);
2422 2423
2423 switch (cmd) { 2424 switch (cmd) {
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index d29638daa987..4b5097fa48d7 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -1,75 +1,713 @@
1/* 1/*
2 * Sierra Wireless CDMA Wireless Serial USB driver 2 USB Driver for Sierra Wireless
3 * 3
4 * Current Copy modified by: Kevin Lloyd <linux@sierrawireless.com> 4 Copyright (C) 2006 Kevin Lloyd <linux@sierrawireless.com>
5 * Original Copyright (C) 2005-2006 Greg Kroah-Hartman <gregkh@suse.de> 5
6 * 6 IMPORTANT DISCLAIMER: This driver is not commercially supported by
7 * This program is free software; you can redistribute it and/or 7 Sierra Wireless. Use at your own risk.
8 * modify it under the terms of the GNU General Public License version 8
9 * 2 as published by the Free Software Foundation. 9 This driver is free software; you can redistribute it and/or modify
10 */ 10 it under the terms of Version 2 of the GNU General Public License as
11 published by the Free Software Foundation.
12
13 Portions based on the option driver by Matthias Urlichs <smurf@smurf.noris.de>
14 Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org>
15
16 History:
17*/
18
19#define DRIVER_VERSION "v.1.0.5"
20#define DRIVER_AUTHOR "Kevin Lloyd <linux@sierrawireless.com>"
21#define DRIVER_DESC "USB Driver for Sierra Wireless USB modems"
11 22
12#include <linux/kernel.h> 23#include <linux/kernel.h>
13#include <linux/init.h> 24#include <linux/jiffies.h>
25#include <linux/errno.h>
14#include <linux/tty.h> 26#include <linux/tty.h>
27#include <linux/tty_flip.h>
15#include <linux/module.h> 28#include <linux/module.h>
16#include <linux/usb.h> 29#include <linux/usb.h>
17#include <linux/usb/serial.h> 30#include <linux/usb/serial.h>
18 31
32
19static struct usb_device_id id_table [] = { 33static struct usb_device_id id_table [] = {
20 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */ 34 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */
21 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */ 35 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
22 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */ 36 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
23 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */ 37 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */
38 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
24 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ 39 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */
25 { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */ 40 { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */
41 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 for Europe */
26 { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 */ 42 { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 */
27 { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */ 43 { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */
28 /* Following devices are supported in the airprime.c driver */ 44
29 /* { USB_DEVICE(0x1199, 0x0112) }, */ /* Sierra Wireless AirCard 580 */ 45 { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */
30 /* { USB_DEVICE(0x0F3D, 0x0112) }, */ /* AirPrime/Sierra PC 5220 */ 46 { USB_DEVICE(0x0F3D, 0x0112) }, /* AirPrime/Sierra PC 5220 */
31 { } 47 { }
32}; 48};
33MODULE_DEVICE_TABLE(usb, id_table); 49MODULE_DEVICE_TABLE(usb, id_table);
34 50
51static struct usb_device_id id_table_1port [] = {
52 { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */
53 { USB_DEVICE(0x0F3D, 0x0112) }, /* AirPrime/Sierra PC 5220 */
54 { }
55};
56
57static struct usb_device_id id_table_3port [] = {
58 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */
59 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
60 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
61 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */
62 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
63 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */
64 { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */
65 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 for Europe */
66 { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 */
67 { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */
68 { }
69};
70
35static struct usb_driver sierra_driver = { 71static struct usb_driver sierra_driver = {
36 .name = "sierra_wireless", 72 .name = "sierra",
37 .probe = usb_serial_probe, 73 .probe = usb_serial_probe,
38 .disconnect = usb_serial_disconnect, 74 .disconnect = usb_serial_disconnect,
39 .id_table = id_table, 75 .id_table = id_table,
76 .no_dynamic_id = 1,
77};
78
79
80static int debug;
81
82/* per port private data */
83#define N_IN_URB 4
84#define N_OUT_URB 1
85#define IN_BUFLEN 4096
86#define OUT_BUFLEN 128
87
88struct sierra_port_private {
89 /* Input endpoints and buffer for this port */
90 struct urb *in_urbs[N_IN_URB];
91 char in_buffer[N_IN_URB][IN_BUFLEN];
92 /* Output endpoints and buffer for this port */
93 struct urb *out_urbs[N_OUT_URB];
94 char out_buffer[N_OUT_URB][OUT_BUFLEN];
95
96 /* Settings for the port */
97 int rts_state; /* Handshaking pins (outputs) */
98 int dtr_state;
99 int cts_state; /* Handshaking pins (inputs) */
100 int dsr_state;
101 int dcd_state;
102 int ri_state;
103
104 unsigned long tx_start_time[N_OUT_URB];
105};
106
107static int sierra_send_setup(struct usb_serial_port *port)
108{
109 struct usb_serial *serial = port->serial;
110 struct sierra_port_private *portdata;
111
112 dbg("%s", __FUNCTION__);
113
114 portdata = usb_get_serial_port_data(port);
115
116 if (port->tty) {
117 int val = 0;
118 if (portdata->dtr_state)
119 val |= 0x01;
120 if (portdata->rts_state)
121 val |= 0x02;
122
123 return usb_control_msg(serial->dev,
124 usb_rcvctrlpipe(serial->dev, 0),
125 0x22,0x21,val,0,NULL,0,USB_CTRL_SET_TIMEOUT);
126 }
127
128 return 0;
129}
130
131static void sierra_rx_throttle(struct usb_serial_port *port)
132{
133 dbg("%s", __FUNCTION__);
134}
135
136static void sierra_rx_unthrottle(struct usb_serial_port *port)
137{
138 dbg("%s", __FUNCTION__);
139}
140
141static void sierra_break_ctl(struct usb_serial_port *port, int break_state)
142{
143 /* Unfortunately, I don't know how to send a break */
144 dbg("%s", __FUNCTION__);
145}
146
147static void sierra_set_termios(struct usb_serial_port *port,
148 struct termios *old_termios)
149{
150 dbg("%s", __FUNCTION__);
151
152 sierra_send_setup(port);
153}
154
155static int sierra_tiocmget(struct usb_serial_port *port, struct file *file)
156{
157 unsigned int value;
158 struct sierra_port_private *portdata;
159
160 portdata = usb_get_serial_port_data(port);
161
162 value = ((portdata->rts_state) ? TIOCM_RTS : 0) |
163 ((portdata->dtr_state) ? TIOCM_DTR : 0) |
164 ((portdata->cts_state) ? TIOCM_CTS : 0) |
165 ((portdata->dsr_state) ? TIOCM_DSR : 0) |
166 ((portdata->dcd_state) ? TIOCM_CAR : 0) |
167 ((portdata->ri_state) ? TIOCM_RNG : 0);
168
169 return value;
170}
171
172static int sierra_tiocmset(struct usb_serial_port *port, struct file *file,
173 unsigned int set, unsigned int clear)
174{
175 struct sierra_port_private *portdata;
176
177 portdata = usb_get_serial_port_data(port);
178
179 if (set & TIOCM_RTS)
180 portdata->rts_state = 1;
181 if (set & TIOCM_DTR)
182 portdata->dtr_state = 1;
183
184 if (clear & TIOCM_RTS)
185 portdata->rts_state = 0;
186 if (clear & TIOCM_DTR)
187 portdata->dtr_state = 0;
188 return sierra_send_setup(port);
189}
190
191static int sierra_ioctl(struct usb_serial_port *port, struct file *file,
192 unsigned int cmd, unsigned long arg)
193{
194 return -ENOIOCTLCMD;
195}
196
197/* Write */
198static int sierra_write(struct usb_serial_port *port,
199 const unsigned char *buf, int count)
200{
201 struct sierra_port_private *portdata;
202 int i;
203 int left, todo;
204 struct urb *this_urb = NULL; /* spurious */
205 int err;
206
207 portdata = usb_get_serial_port_data(port);
208
209 dbg("%s: write (%d chars)", __FUNCTION__, count);
210
211 i = 0;
212 left = count;
213 for (i=0; left > 0 && i < N_OUT_URB; i++) {
214 todo = left;
215 if (todo > OUT_BUFLEN)
216 todo = OUT_BUFLEN;
217
218 this_urb = portdata->out_urbs[i];
219 if (this_urb->status == -EINPROGRESS) {
220 if (time_before(jiffies,
221 portdata->tx_start_time[i] + 10 * HZ))
222 continue;
223 usb_unlink_urb(this_urb);
224 continue;
225 }
226 if (this_urb->status != 0)
227 dbg("usb_write %p failed (err=%d)",
228 this_urb, this_urb->status);
229
230 dbg("%s: endpoint %d buf %d", __FUNCTION__,
231 usb_pipeendpoint(this_urb->pipe), i);
232
233 /* send the data */
234 memcpy (this_urb->transfer_buffer, buf, todo);
235 this_urb->transfer_buffer_length = todo;
236
237 this_urb->dev = port->serial->dev;
238 err = usb_submit_urb(this_urb, GFP_ATOMIC);
239 if (err) {
240 dbg("usb_submit_urb %p (write bulk) failed "
241 "(%d, has %d)", this_urb,
242 err, this_urb->status);
243 continue;
244 }
245 portdata->tx_start_time[i] = jiffies;
246 buf += todo;
247 left -= todo;
248 }
249
250 count -= left;
251 dbg("%s: wrote (did %d)", __FUNCTION__, count);
252 return count;
253}
254
255static void sierra_indat_callback(struct urb *urb)
256{
257 int err;
258 int endpoint;
259 struct usb_serial_port *port;
260 struct tty_struct *tty;
261 unsigned char *data = urb->transfer_buffer;
262
263 dbg("%s: %p", __FUNCTION__, urb);
264
265 endpoint = usb_pipeendpoint(urb->pipe);
266 port = (struct usb_serial_port *) urb->context;
267
268 if (urb->status) {
269 dbg("%s: nonzero status: %d on endpoint %02x.",
270 __FUNCTION__, urb->status, endpoint);
271 } else {
272 tty = port->tty;
273 if (urb->actual_length) {
274 tty_buffer_request_room(tty, urb->actual_length);
275 tty_insert_flip_string(tty, data, urb->actual_length);
276 tty_flip_buffer_push(tty);
277 } else {
278 dbg("%s: empty read urb received", __FUNCTION__);
279 }
280
281 /* Resubmit urb so we continue receiving */
282 if (port->open_count && urb->status != -ESHUTDOWN) {
283 err = usb_submit_urb(urb, GFP_ATOMIC);
284 if (err)
285 printk(KERN_ERR "%s: resubmit read urb failed. "
286 "(%d)", __FUNCTION__, err);
287 }
288 }
289 return;
290}
291
292static void sierra_outdat_callback(struct urb *urb)
293{
294 struct usb_serial_port *port;
295
296 dbg("%s", __FUNCTION__);
297
298 port = (struct usb_serial_port *) urb->context;
299
300 usb_serial_port_softint(port);
301}
302
303static void sierra_instat_callback(struct urb *urb)
304{
305 int err;
306 struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
307 struct sierra_port_private *portdata = usb_get_serial_port_data(port);
308 struct usb_serial *serial = port->serial;
309
310 dbg("%s", __FUNCTION__);
311 dbg("%s: urb %p port %p has data %p", __FUNCTION__,urb,port,portdata);
312
313 if (urb->status == 0) {
314 struct usb_ctrlrequest *req_pkt =
315 (struct usb_ctrlrequest *)urb->transfer_buffer;
316
317 if (!req_pkt) {
318 dbg("%s: NULL req_pkt\n", __FUNCTION__);
319 return;
320 }
321 if ((req_pkt->bRequestType == 0xA1) &&
322 (req_pkt->bRequest == 0x20)) {
323 int old_dcd_state;
324 unsigned char signals = *((unsigned char *)
325 urb->transfer_buffer +
326 sizeof(struct usb_ctrlrequest));
327
328 dbg("%s: signal x%x", __FUNCTION__, signals);
329
330 old_dcd_state = portdata->dcd_state;
331 portdata->cts_state = 1;
332 portdata->dcd_state = ((signals & 0x01) ? 1 : 0);
333 portdata->dsr_state = ((signals & 0x02) ? 1 : 0);
334 portdata->ri_state = ((signals & 0x08) ? 1 : 0);
335
336 if (port->tty && !C_CLOCAL(port->tty) &&
337 old_dcd_state && !portdata->dcd_state)
338 tty_hangup(port->tty);
339 } else {
340 dbg("%s: type %x req %x", __FUNCTION__,
341 req_pkt->bRequestType,req_pkt->bRequest);
342 }
343 } else
344 dbg("%s: error %d", __FUNCTION__, urb->status);
345
346 /* Resubmit urb so we continue receiving IRQ data */
347 if (urb->status != -ESHUTDOWN) {
348 urb->dev = serial->dev;
349 err = usb_submit_urb(urb, GFP_ATOMIC);
350 if (err)
351 dbg("%s: resubmit intr urb failed. (%d)",
352 __FUNCTION__, err);
353 }
354}
355
356static int sierra_write_room(struct usb_serial_port *port)
357{
358 struct sierra_port_private *portdata;
359 int i;
360 int data_len = 0;
361 struct urb *this_urb;
362
363 portdata = usb_get_serial_port_data(port);
364
365 for (i=0; i < N_OUT_URB; i++) {
366 this_urb = portdata->out_urbs[i];
367 if (this_urb && this_urb->status != -EINPROGRESS)
368 data_len += OUT_BUFLEN;
369 }
370
371 dbg("%s: %d", __FUNCTION__, data_len);
372 return data_len;
373}
374
375static int sierra_chars_in_buffer(struct usb_serial_port *port)
376{
377 struct sierra_port_private *portdata;
378 int i;
379 int data_len = 0;
380 struct urb *this_urb;
381
382 portdata = usb_get_serial_port_data(port);
383
384 for (i=0; i < N_OUT_URB; i++) {
385 this_urb = portdata->out_urbs[i];
386 if (this_urb && this_urb->status == -EINPROGRESS)
387 data_len += this_urb->transfer_buffer_length;
388 }
389 dbg("%s: %d", __FUNCTION__, data_len);
390 return data_len;
391}
392
393static int sierra_open(struct usb_serial_port *port, struct file *filp)
394{
395 struct sierra_port_private *portdata;
396 struct usb_serial *serial = port->serial;
397 int i, err;
398 struct urb *urb;
399
400 portdata = usb_get_serial_port_data(port);
401
402 dbg("%s", __FUNCTION__);
403
404 /* Set some sane defaults */
405 portdata->rts_state = 1;
406 portdata->dtr_state = 1;
407
408 /* Reset low level data toggle and start reading from endpoints */
409 for (i = 0; i < N_IN_URB; i++) {
410 urb = portdata->in_urbs[i];
411 if (! urb)
412 continue;
413 if (urb->dev != serial->dev) {
414 dbg("%s: dev %p != %p", __FUNCTION__,
415 urb->dev, serial->dev);
416 continue;
417 }
418
419 /*
420 * make sure endpoint data toggle is synchronized with the
421 * device
422 */
423 usb_clear_halt(urb->dev, urb->pipe);
424
425 err = usb_submit_urb(urb, GFP_KERNEL);
426 if (err) {
427 dbg("%s: submit urb %d failed (%d) %d",
428 __FUNCTION__, i, err,
429 urb->transfer_buffer_length);
430 }
431 }
432
433 /* Reset low level data toggle on out endpoints */
434 for (i = 0; i < N_OUT_URB; i++) {
435 urb = portdata->out_urbs[i];
436 if (! urb)
437 continue;
438 urb->dev = serial->dev;
439 /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe),
440 usb_pipeout(urb->pipe), 0); */
441 }
442
443 port->tty->low_latency = 1;
444
445 sierra_send_setup(port);
446
447 return (0);
448}
449
450static inline void stop_urb(struct urb *urb)
451{
452 if (urb && urb->status == -EINPROGRESS)
453 usb_kill_urb(urb);
454}
455
456static void sierra_close(struct usb_serial_port *port, struct file *filp)
457{
458 int i;
459 struct usb_serial *serial = port->serial;
460 struct sierra_port_private *portdata;
461
462 dbg("%s", __FUNCTION__);
463 portdata = usb_get_serial_port_data(port);
464
465 portdata->rts_state = 0;
466 portdata->dtr_state = 0;
467
468 if (serial->dev) {
469 sierra_send_setup(port);
470
471 /* Stop reading/writing urbs */
472 for (i = 0; i < N_IN_URB; i++)
473 stop_urb(portdata->in_urbs[i]);
474 for (i = 0; i < N_OUT_URB; i++)
475 stop_urb(portdata->out_urbs[i]);
476 }
477 port->tty = NULL;
478}
479
480/* Helper functions used by sierra_setup_urbs */
481static struct urb *sierra_setup_urb(struct usb_serial *serial, int endpoint,
482 int dir, void *ctx, char *buf, int len,
483 usb_complete_t callback)
484{
485 struct urb *urb;
486
487 if (endpoint == -1)
488 return NULL; /* endpoint not needed */
489
490 urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */
491 if (urb == NULL) {
492 dbg("%s: alloc for endpoint %d failed.", __FUNCTION__, endpoint);
493 return NULL;
494 }
495
496 /* Fill URB using supplied data. */
497 usb_fill_bulk_urb(urb, serial->dev,
498 usb_sndbulkpipe(serial->dev, endpoint) | dir,
499 buf, len, callback, ctx);
500
501 return urb;
502}
503
504/* Setup urbs */
505static void sierra_setup_urbs(struct usb_serial *serial)
506{
507 int i,j;
508 struct usb_serial_port *port;
509 struct sierra_port_private *portdata;
510
511 dbg("%s", __FUNCTION__);
512
513 for (i = 0; i < serial->num_ports; i++) {
514 port = serial->port[i];
515 portdata = usb_get_serial_port_data(port);
516
517 /* Do indat endpoints first */
518 for (j = 0; j < N_IN_URB; ++j) {
519 portdata->in_urbs[j] = sierra_setup_urb (serial,
520 port->bulk_in_endpointAddress, USB_DIR_IN, port,
521 portdata->in_buffer[j], IN_BUFLEN, sierra_indat_callback);
522 }
523
524 /* outdat endpoints */
525 for (j = 0; j < N_OUT_URB; ++j) {
526 portdata->out_urbs[j] = sierra_setup_urb (serial,
527 port->bulk_out_endpointAddress, USB_DIR_OUT, port,
528 portdata->out_buffer[j], OUT_BUFLEN, sierra_outdat_callback);
529 }
530 }
531}
532
533static int sierra_startup(struct usb_serial *serial)
534{
535 int i, err;
536 struct usb_serial_port *port;
537 struct sierra_port_private *portdata;
538
539 dbg("%s", __FUNCTION__);
540
541 /* Now setup per port private data */
542 for (i = 0; i < serial->num_ports; i++) {
543 port = serial->port[i];
544 portdata = kzalloc(sizeof(*portdata), GFP_KERNEL);
545 if (!portdata) {
546 dbg("%s: kmalloc for sierra_port_private (%d) failed!.",
547 __FUNCTION__, i);
548 return (1);
549 }
550
551 usb_set_serial_port_data(port, portdata);
552
553 if (! port->interrupt_in_urb)
554 continue;
555 err = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
556 if (err)
557 dbg("%s: submit irq_in urb failed %d",
558 __FUNCTION__, err);
559 }
560
561 sierra_setup_urbs(serial);
562
563 return (0);
564}
565
566static void sierra_shutdown(struct usb_serial *serial)
567{
568 int i, j;
569 struct usb_serial_port *port;
570 struct sierra_port_private *portdata;
571
572 dbg("%s", __FUNCTION__);
573
574 /* Stop reading/writing urbs */
575 for (i = 0; i < serial->num_ports; ++i) {
576 port = serial->port[i];
577 portdata = usb_get_serial_port_data(port);
578 for (j = 0; j < N_IN_URB; j++)
579 stop_urb(portdata->in_urbs[j]);
580 for (j = 0; j < N_OUT_URB; j++)
581 stop_urb(portdata->out_urbs[j]);
582 }
583
584 /* Now free them */
585 for (i = 0; i < serial->num_ports; ++i) {
586 port = serial->port[i];
587 portdata = usb_get_serial_port_data(port);
588
589 for (j = 0; j < N_IN_URB; j++) {
590 if (portdata->in_urbs[j]) {
591 usb_free_urb(portdata->in_urbs[j]);
592 portdata->in_urbs[j] = NULL;
593 }
594 }
595 for (j = 0; j < N_OUT_URB; j++) {
596 if (portdata->out_urbs[j]) {
597 usb_free_urb(portdata->out_urbs[j]);
598 portdata->out_urbs[j] = NULL;
599 }
600 }
601 }
602
603 /* Now free per port private data */
604 for (i = 0; i < serial->num_ports; i++) {
605 port = serial->port[i];
606 kfree(usb_get_serial_port_data(port));
607 }
608}
609
610static struct usb_serial_driver sierra_1port_device = {
611 .driver = {
612 .owner = THIS_MODULE,
613 .name = "sierra1",
614 },
615 .description = "Sierra USB modem (1 port)",
616 .id_table = id_table_1port,
617 .num_interrupt_in = NUM_DONT_CARE,
618 .num_bulk_in = 1,
619 .num_bulk_out = 1,
620 .num_ports = 1,
621 .open = sierra_open,
622 .close = sierra_close,
623 .write = sierra_write,
624 .write_room = sierra_write_room,
625 .chars_in_buffer = sierra_chars_in_buffer,
626 .throttle = sierra_rx_throttle,
627 .unthrottle = sierra_rx_unthrottle,
628 .ioctl = sierra_ioctl,
629 .set_termios = sierra_set_termios,
630 .break_ctl = sierra_break_ctl,
631 .tiocmget = sierra_tiocmget,
632 .tiocmset = sierra_tiocmset,
633 .attach = sierra_startup,
634 .shutdown = sierra_shutdown,
635 .read_int_callback = sierra_instat_callback,
40}; 636};
41 637
42static struct usb_serial_driver sierra_device = { 638static struct usb_serial_driver sierra_3port_device = {
43 .driver = { 639 .driver = {
44 .owner = THIS_MODULE, 640 .owner = THIS_MODULE,
45 .name = "Sierra_Wireless", 641 .name = "sierra3",
46 }, 642 },
47 .id_table = id_table, 643 .description = "Sierra USB modem (3 port)",
48 .num_interrupt_in = NUM_DONT_CARE, 644 .id_table = id_table_3port,
49 .num_bulk_in = NUM_DONT_CARE, 645 .num_interrupt_in = NUM_DONT_CARE,
50 .num_bulk_out = NUM_DONT_CARE, 646 .num_bulk_in = 3,
51 .num_ports = 3, 647 .num_bulk_out = 3,
648 .num_ports = 3,
649 .open = sierra_open,
650 .close = sierra_close,
651 .write = sierra_write,
652 .write_room = sierra_write_room,
653 .chars_in_buffer = sierra_chars_in_buffer,
654 .throttle = sierra_rx_throttle,
655 .unthrottle = sierra_rx_unthrottle,
656 .ioctl = sierra_ioctl,
657 .set_termios = sierra_set_termios,
658 .break_ctl = sierra_break_ctl,
659 .tiocmget = sierra_tiocmget,
660 .tiocmset = sierra_tiocmset,
661 .attach = sierra_startup,
662 .shutdown = sierra_shutdown,
663 .read_int_callback = sierra_instat_callback,
52}; 664};
53 665
666/* Functions used by new usb-serial code. */
54static int __init sierra_init(void) 667static int __init sierra_init(void)
55{ 668{
56 int retval; 669 int retval;
57 670 retval = usb_serial_register(&sierra_1port_device);
58 retval = usb_serial_register(&sierra_device); 671 if (retval)
672 goto failed_1port_device_register;
673 retval = usb_serial_register(&sierra_3port_device);
59 if (retval) 674 if (retval)
60 return retval; 675 goto failed_3port_device_register;
676
677
61 retval = usb_register(&sierra_driver); 678 retval = usb_register(&sierra_driver);
62 if (retval) 679 if (retval)
63 usb_serial_deregister(&sierra_device); 680 goto failed_driver_register;
681
682 info(DRIVER_DESC ": " DRIVER_VERSION);
683
684 return 0;
685
686failed_driver_register:
687 usb_serial_deregister(&sierra_3port_device);
688failed_3port_device_register:
689 usb_serial_deregister(&sierra_1port_device);
690failed_1port_device_register:
64 return retval; 691 return retval;
65} 692}
66 693
67static void __exit sierra_exit(void) 694static void __exit sierra_exit(void)
68{ 695{
69 usb_deregister(&sierra_driver); 696 usb_deregister (&sierra_driver);
70 usb_serial_deregister(&sierra_device); 697 usb_serial_deregister(&sierra_1port_device);
698 usb_serial_deregister(&sierra_3port_device);
71} 699}
72 700
73module_init(sierra_init); 701module_init(sierra_init);
74module_exit(sierra_exit); 702module_exit(sierra_exit);
703
704MODULE_AUTHOR(DRIVER_AUTHOR);
705MODULE_DESCRIPTION(DRIVER_DESC);
706MODULE_VERSION(DRIVER_VERSION);
75MODULE_LICENSE("GPL"); 707MODULE_LICENSE("GPL");
708
709#ifdef CONFIG_USB_DEBUG
710module_param(debug, bool, S_IRUGO | S_IWUSR);
711MODULE_PARM_DESC(debug, "Debug messages");
712#endif
713
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index c9a8d50106d1..efb047f431e8 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -55,7 +55,8 @@ UNUSUAL_DEV( 0x03eb, 0x2002, 0x0100, 0x0100,
55 US_SC_DEVICE, US_PR_DEVICE, NULL, 55 US_SC_DEVICE, US_PR_DEVICE, NULL,
56 US_FL_IGNORE_RESIDUE), 56 US_FL_IGNORE_RESIDUE),
57 57
58UNUSUAL_DEV( 0x03ee, 0x6901, 0x0000, 0x0100, 58/* modified by Tobias Lorenz <tobias.lorenz@gmx.net> */
59UNUSUAL_DEV( 0x03ee, 0x6901, 0x0000, 0x0200,
59 "Mitsumi", 60 "Mitsumi",
60 "USB FDD", 61 "USB FDD",
61 US_SC_DEVICE, US_PR_DEVICE, NULL, 62 US_SC_DEVICE, US_PR_DEVICE, NULL,
@@ -182,6 +183,20 @@ UNUSUAL_DEV( 0x0421, 0x044e, 0x0100, 0x0100,
182 US_SC_DEVICE, US_PR_DEVICE, NULL, 183 US_SC_DEVICE, US_PR_DEVICE, NULL,
183 US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ), 184 US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ),
184 185
186/* Reported by Bardur Arantsson <bardur@scientician.net> */
187UNUSUAL_DEV( 0x0421, 0x047c, 0x0370, 0x0370,
188 "Nokia",
189 "6131",
190 US_SC_DEVICE, US_PR_DEVICE, NULL,
191 US_FL_MAX_SECTORS_64 ),
192
193/* Reported by Alex Corcoles <alex@corcoles.net> */
194UNUSUAL_DEV( 0x0421, 0x0495, 0x0370, 0x0370,
195 "Nokia",
196 "6234",
197 US_SC_DEVICE, US_PR_DEVICE, NULL,
198 US_FL_MAX_SECTORS_64 ),
199
185/* Reported by Olaf Hering <olh@suse.de> from novell bug #105878 */ 200/* Reported by Olaf Hering <olh@suse.de> from novell bug #105878 */
186UNUSUAL_DEV( 0x0424, 0x0fdc, 0x0210, 0x0210, 201UNUSUAL_DEV( 0x0424, 0x0fdc, 0x0210, 0x0210,
187 "SMSC", 202 "SMSC",
@@ -1221,7 +1236,7 @@ UNUSUAL_DEV( 0x0e21, 0x0520, 0x0100, 0x0100,
1221 "Cowon Systems", 1236 "Cowon Systems",
1222 "iAUDIO M5", 1237 "iAUDIO M5",
1223 US_SC_DEVICE, US_PR_BULK, NULL, 1238 US_SC_DEVICE, US_PR_BULK, NULL,
1224 0 ), 1239 US_FL_NEED_OVERRIDE ),
1225 1240
1226/* Submitted by Antoine Mairesse <antoine.mairesse@free.fr> */ 1241/* Submitted by Antoine Mairesse <antoine.mairesse@free.fr> */
1227UNUSUAL_DEV( 0x0ed1, 0x6660, 0x0100, 0x0300, 1242UNUSUAL_DEV( 0x0ed1, 0x6660, 0x0100, 0x0300,
@@ -1294,8 +1309,10 @@ UNUSUAL_DEV( 0x0fce, 0xe030, 0x0000, 0x0000,
1294/* Reported by Kevin Cernekee <kpc-usbdev@gelato.uiuc.edu> 1309/* Reported by Kevin Cernekee <kpc-usbdev@gelato.uiuc.edu>
1295 * Tested on hardware version 1.10. 1310 * Tested on hardware version 1.10.
1296 * Entry is needed only for the initializer function override. 1311 * Entry is needed only for the initializer function override.
1312 * Devices with bcd > 110 seem to not need it while those
1313 * with bcd < 110 appear to need it.
1297 */ 1314 */
1298UNUSUAL_DEV( 0x1019, 0x0c55, 0x0110, 0x0110, 1315UNUSUAL_DEV( 0x1019, 0x0c55, 0x0000, 0x0110,
1299 "Desknote", 1316 "Desknote",
1300 "UCR-61S2B", 1317 "UCR-61S2B",
1301 US_SC_DEVICE, US_PR_DEVICE, usb_stor_ucr61s2b_init, 1318 US_SC_DEVICE, US_PR_DEVICE, usb_stor_ucr61s2b_init,
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index daaa486159cf..7a43020fa583 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -701,7 +701,6 @@ config FB_NVIDIA
701 depends on FB && PCI 701 depends on FB && PCI
702 select I2C_ALGOBIT if FB_NVIDIA_I2C 702 select I2C_ALGOBIT if FB_NVIDIA_I2C
703 select I2C if FB_NVIDIA_I2C 703 select I2C if FB_NVIDIA_I2C
704 select FB_DDC if FB_NVIDIA_I2C
705 select FB_MODE_HELPERS 704 select FB_MODE_HELPERS
706 select FB_CFB_FILLRECT 705 select FB_CFB_FILLRECT
707 select FB_CFB_COPYAREA 706 select FB_CFB_COPYAREA
diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
index b77b30923928..e815b354c09d 100644
--- a/drivers/video/aty/atyfb_base.c
+++ b/drivers/video/aty/atyfb_base.c
@@ -406,7 +406,7 @@ static struct {
406 { PCI_CHIP_MACH64LB, "3D RAGE LT PRO (Mach64 LB, AGP)", 236, 75, 100, 135, ATI_CHIP_264LTPRO }, 406 { PCI_CHIP_MACH64LB, "3D RAGE LT PRO (Mach64 LB, AGP)", 236, 75, 100, 135, ATI_CHIP_264LTPRO },
407 { PCI_CHIP_MACH64LD, "3D RAGE LT PRO (Mach64 LD, AGP)", 230, 100, 100, 135, ATI_CHIP_264LTPRO }, 407 { PCI_CHIP_MACH64LD, "3D RAGE LT PRO (Mach64 LD, AGP)", 230, 100, 100, 135, ATI_CHIP_264LTPRO },
408 { PCI_CHIP_MACH64LI, "3D RAGE LT PRO (Mach64 LI, PCI)", 230, 100, 100, 135, ATI_CHIP_264LTPRO | M64F_G3_PB_1_1 | M64F_G3_PB_1024x768 }, 408 { PCI_CHIP_MACH64LI, "3D RAGE LT PRO (Mach64 LI, PCI)", 230, 100, 100, 135, ATI_CHIP_264LTPRO | M64F_G3_PB_1_1 | M64F_G3_PB_1024x768 },
409 { PCI_CHIP_MACH64LP, "3D RAGE LT PRO (Mach64 LP, PCI)", 230, 100, 100, 135, ATI_CHIP_264LTPRO }, 409 { PCI_CHIP_MACH64LP, "3D RAGE LT PRO (Mach64 LP, PCI)", 230, 100, 100, 135, ATI_CHIP_264LTPRO | M64F_G3_PB_1024x768 },
410 { PCI_CHIP_MACH64LQ, "3D RAGE LT PRO (Mach64 LQ, PCI)", 230, 100, 100, 135, ATI_CHIP_264LTPRO }, 410 { PCI_CHIP_MACH64LQ, "3D RAGE LT PRO (Mach64 LQ, PCI)", 230, 100, 100, 135, ATI_CHIP_264LTPRO },
411 411
412 { PCI_CHIP_MACH64GM, "3D RAGE XL (Mach64 GM, AGP 2x)", 230, 83, 63, 135, ATI_CHIP_264XL }, 412 { PCI_CHIP_MACH64GM, "3D RAGE XL (Mach64 GM, AGP 2x)", 230, 83, 63, 135, ATI_CHIP_264XL },
diff --git a/drivers/video/aty/radeon_i2c.c b/drivers/video/aty/radeon_i2c.c
index 676754520099..869725a13c21 100644
--- a/drivers/video/aty/radeon_i2c.c
+++ b/drivers/video/aty/radeon_i2c.c
@@ -139,7 +139,13 @@ void radeon_delete_i2c_busses(struct radeonfb_info *rinfo)
139int radeon_probe_i2c_connector(struct radeonfb_info *rinfo, int conn, 139int radeon_probe_i2c_connector(struct radeonfb_info *rinfo, int conn,
140 u8 **out_edid) 140 u8 **out_edid)
141{ 141{
142 u8 *edid = fb_ddc_read(&rinfo->i2c[conn-1].adapter); 142 u32 reg = rinfo->i2c[conn-1].ddc_reg;
143 u8 *edid;
144
145 OUTREG(reg, INREG(reg) &
146 ~(VGA_DDC_DATA_OUTPUT | VGA_DDC_CLK_OUTPUT));
147
148 edid = fb_ddc_read(&rinfo->i2c[conn-1].adapter);
143 149
144 if (out_edid) 150 if (out_edid)
145 *out_edid = edid; 151 *out_edid = edid;
diff --git a/drivers/video/backlight/corgi_bl.c b/drivers/video/backlight/corgi_bl.c
index 2ebbfd95145f..d07ecb53c68b 100644
--- a/drivers/video/backlight/corgi_bl.c
+++ b/drivers/video/backlight/corgi_bl.c
@@ -111,7 +111,7 @@ static struct backlight_properties corgibl_data = {
111 .update_status = corgibl_set_intensity, 111 .update_status = corgibl_set_intensity,
112}; 112};
113 113
114static int __init corgibl_probe(struct platform_device *pdev) 114static int corgibl_probe(struct platform_device *pdev)
115{ 115{
116 struct corgibl_machinfo *machinfo = pdev->dev.platform_data; 116 struct corgibl_machinfo *machinfo = pdev->dev.platform_data;
117 117
@@ -166,4 +166,4 @@ module_exit(corgibl_exit);
166 166
167MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>"); 167MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>");
168MODULE_DESCRIPTION("Corgi Backlight Driver"); 168MODULE_DESCRIPTION("Corgi Backlight Driver");
169MODULE_LICENSE("GPLv2"); 169MODULE_LICENSE("GPL");
diff --git a/drivers/video/backlight/hp680_bl.c b/drivers/video/backlight/hp680_bl.c
index fe1488374f62..e3993213d10e 100644
--- a/drivers/video/backlight/hp680_bl.c
+++ b/drivers/video/backlight/hp680_bl.c
@@ -19,7 +19,7 @@
19#include <linux/backlight.h> 19#include <linux/backlight.h>
20 20
21#include <asm/cpu/dac.h> 21#include <asm/cpu/dac.h>
22#include <asm/hp6xx/hp6xx.h> 22#include <asm/hp6xx.h>
23#include <asm/hd64461.h> 23#include <asm/hd64461.h>
24 24
25#define HP680_MAX_INTENSITY 255 25#define HP680_MAX_INTENSITY 255
diff --git a/drivers/video/controlfb.c b/drivers/video/controlfb.c
index 8cc6c0e2d27a..04c6d928189b 100644
--- a/drivers/video/controlfb.c
+++ b/drivers/video/controlfb.c
@@ -415,13 +415,15 @@ static int __init init_control(struct fb_info_control *p)
415 full = p->total_vram == 0x400000; 415 full = p->total_vram == 0x400000;
416 416
417 /* Try to pick a video mode out of NVRAM if we have one. */ 417 /* Try to pick a video mode out of NVRAM if we have one. */
418#ifdef CONFIG_NVRAM
418 if (default_cmode == CMODE_NVRAM){ 419 if (default_cmode == CMODE_NVRAM){
419 cmode = nvram_read_byte(NV_CMODE); 420 cmode = nvram_read_byte(NV_CMODE);
420 if(cmode < CMODE_8 || cmode > CMODE_32) 421 if(cmode < CMODE_8 || cmode > CMODE_32)
421 cmode = CMODE_8; 422 cmode = CMODE_8;
422 } else 423 } else
424#endif
423 cmode=default_cmode; 425 cmode=default_cmode;
424 426#ifdef CONFIG_NVRAM
425 if (default_vmode == VMODE_NVRAM) { 427 if (default_vmode == VMODE_NVRAM) {
426 vmode = nvram_read_byte(NV_VMODE); 428 vmode = nvram_read_byte(NV_VMODE);
427 if (vmode < 1 || vmode > VMODE_MAX || 429 if (vmode < 1 || vmode > VMODE_MAX ||
@@ -432,7 +434,9 @@ static int __init init_control(struct fb_info_control *p)
432 if (control_mac_modes[vmode - 1].m[full] < cmode) 434 if (control_mac_modes[vmode - 1].m[full] < cmode)
433 vmode = VMODE_640_480_60; 435 vmode = VMODE_640_480_60;
434 } 436 }
435 } else { 437 } else
438#endif
439 {
436 vmode=default_vmode; 440 vmode=default_vmode;
437 if (control_mac_modes[vmode - 1].m[full] < cmode) { 441 if (control_mac_modes[vmode - 1].m[full] < cmode) {
438 if (cmode > CMODE_8) 442 if (cmode > CMODE_8)
diff --git a/drivers/video/fb_ddc.c b/drivers/video/fb_ddc.c
index 3aa6ebf68f17..f836137a0eda 100644
--- a/drivers/video/fb_ddc.c
+++ b/drivers/video/fb_ddc.c
@@ -20,26 +20,26 @@
20static unsigned char *fb_do_probe_ddc_edid(struct i2c_adapter *adapter) 20static unsigned char *fb_do_probe_ddc_edid(struct i2c_adapter *adapter)
21{ 21{
22 unsigned char start = 0x0; 22 unsigned char start = 0x0;
23 unsigned char *buf = kmalloc(EDID_LENGTH, GFP_KERNEL);
23 struct i2c_msg msgs[] = { 24 struct i2c_msg msgs[] = {
24 { 25 {
25 .addr = DDC_ADDR, 26 .addr = DDC_ADDR,
27 .flags = 0,
26 .len = 1, 28 .len = 1,
27 .buf = &start, 29 .buf = &start,
28 }, { 30 }, {
29 .addr = DDC_ADDR, 31 .addr = DDC_ADDR,
30 .flags = I2C_M_RD, 32 .flags = I2C_M_RD,
31 .len = EDID_LENGTH, 33 .len = EDID_LENGTH,
34 .buf = buf,
32 } 35 }
33 }; 36 };
34 unsigned char *buf;
35 37
36 buf = kmalloc(EDID_LENGTH, GFP_KERNEL);
37 if (!buf) { 38 if (!buf) {
38 dev_warn(&adapter->dev, "unable to allocate memory for EDID " 39 dev_warn(&adapter->dev, "unable to allocate memory for EDID "
39 "block.\n"); 40 "block.\n");
40 return NULL; 41 return NULL;
41 } 42 }
42 msgs[1].buf = buf;
43 43
44 if (i2c_transfer(adapter, msgs, 2) == 2) 44 if (i2c_transfer(adapter, msgs, 2) == 2)
45 return buf; 45 return buf;
diff --git a/drivers/video/hitfb.c b/drivers/video/hitfb.c
index 3afb472763c0..3dc49424dc75 100644
--- a/drivers/video/hitfb.c
+++ b/drivers/video/hitfb.c
@@ -29,7 +29,6 @@
29#include <asm/io.h> 29#include <asm/io.h>
30#include <asm/hd64461.h> 30#include <asm/hd64461.h>
31#include <asm/cpu/dac.h> 31#include <asm/cpu/dac.h>
32#include <asm/hp6xx/hp6xx.h>
33 32
34#define WIDTH 640 33#define WIDTH 640
35 34
diff --git a/drivers/video/igafb.c b/drivers/video/igafb.c
index 67f384f86758..e6df492c22a5 100644
--- a/drivers/video/igafb.c
+++ b/drivers/video/igafb.c
@@ -573,3 +573,10 @@ int __init igafb_setup(char *options)
573 573
574module_init(igafb_init); 574module_init(igafb_init);
575MODULE_LICENSE("GPL"); 575MODULE_LICENSE("GPL");
576static struct pci_device_id igafb_pci_tbl[] __devinitdata = {
577 { PCI_VENDOR_ID_INTERG, PCI_DEVICE_ID_INTERG_1682,
578 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
579 { }
580};
581
582MODULE_DEVICE_TABLE(pci, igafb_pci_tbl);
diff --git a/drivers/video/intelfb/intelfbhw.c b/drivers/video/intelfb/intelfbhw.c
index eeeeff9a09eb..a95836839e1e 100644
--- a/drivers/video/intelfb/intelfbhw.c
+++ b/drivers/video/intelfb/intelfbhw.c
@@ -161,7 +161,7 @@ intelfbhw_get_memory(struct pci_dev *pdev, int *aperture_size,
161 return 1; 161 return 1;
162 162
163 /* Find the bridge device. It is always 0:0.0 */ 163 /* Find the bridge device. It is always 0:0.0 */
164 if (!(bridge_dev = pci_find_slot(0, PCI_DEVFN(0, 0)))) { 164 if (!(bridge_dev = pci_get_bus_and_slot(0, PCI_DEVFN(0, 0)))) {
165 ERR_MSG("cannot find bridge device\n"); 165 ERR_MSG("cannot find bridge device\n");
166 return 1; 166 return 1;
167 } 167 }
@@ -169,6 +169,8 @@ intelfbhw_get_memory(struct pci_dev *pdev, int *aperture_size,
169 /* Get the fb aperture size and "stolen" memory amount. */ 169 /* Get the fb aperture size and "stolen" memory amount. */
170 tmp = 0; 170 tmp = 0;
171 pci_read_config_word(bridge_dev, INTEL_GMCH_CTRL, &tmp); 171 pci_read_config_word(bridge_dev, INTEL_GMCH_CTRL, &tmp);
172 pci_dev_put(bridge_dev);
173
172 switch (pdev->device) { 174 switch (pdev->device) {
173 case PCI_DEVICE_ID_INTEL_915G: 175 case PCI_DEVICE_ID_INTEL_915G:
174 case PCI_DEVICE_ID_INTEL_915GM: 176 case PCI_DEVICE_ID_INTEL_915GM:
@@ -662,7 +664,7 @@ intelfbhw_print_hw_state(struct intelfb_info *dinfo, struct intelfb_hwstate *hw)
662 int index = dinfo->pll_index; 664 int index = dinfo->pll_index;
663 DBG_MSG("intelfbhw_print_hw_state\n"); 665 DBG_MSG("intelfbhw_print_hw_state\n");
664 666
665 if (!hw || !dinfo) 667 if (!hw)
666 return; 668 return;
667 /* Read in as much of the HW state as possible. */ 669 /* Read in as much of the HW state as possible. */
668 printk("hw state dump start\n"); 670 printk("hw state dump start\n");
diff --git a/drivers/video/nvidia/nv_hw.c b/drivers/video/nvidia/nv_hw.c
index 9ed640d35728..ea426115c6f9 100644
--- a/drivers/video/nvidia/nv_hw.c
+++ b/drivers/video/nvidia/nv_hw.c
@@ -145,12 +145,18 @@ static void nvGetClocks(struct nvidia_par *par, unsigned int *MClk,
145 145
146 if (par->Architecture >= NV_ARCH_40) { 146 if (par->Architecture >= NV_ARCH_40) {
147 pll = NV_RD32(par->PMC, 0x4020); 147 pll = NV_RD32(par->PMC, 0x4020);
148 P = (pll >> 16) & 0x03; 148 P = (pll >> 16) & 0x07;
149 pll = NV_RD32(par->PMC, 0x4024); 149 pll = NV_RD32(par->PMC, 0x4024);
150 M = pll & 0xFF; 150 M = pll & 0xFF;
151 N = (pll >> 8) & 0xFF; 151 N = (pll >> 8) & 0xFF;
152 MB = (pll >> 16) & 0xFF; 152 if (((par->Chipset & 0xfff0) == 0x0290) ||
153 NB = (pll >> 24) & 0xFF; 153 ((par->Chipset & 0xfff0) == 0x0390)) {
154 MB = 1;
155 NB = 1;
156 } else {
157 MB = (pll >> 16) & 0xFF;
158 NB = (pll >> 24) & 0xFF;
159 }
154 *MClk = ((N * NB * par->CrystalFreqKHz) / (M * MB)) >> P; 160 *MClk = ((N * NB * par->CrystalFreqKHz) / (M * MB)) >> P;
155 161
156 pll = NV_RD32(par->PMC, 0x4000); 162 pll = NV_RD32(par->PMC, 0x4000);
diff --git a/drivers/video/nvidia/nv_i2c.c b/drivers/video/nvidia/nv_i2c.c
index e48de3c9fd13..19eef3a09023 100644
--- a/drivers/video/nvidia/nv_i2c.c
+++ b/drivers/video/nvidia/nv_i2c.c
@@ -160,12 +160,51 @@ void nvidia_delete_i2c_busses(struct nvidia_par *par)
160 160
161} 161}
162 162
163static u8 *nvidia_do_probe_i2c_edid(struct nvidia_i2c_chan *chan)
164{
165 u8 start = 0x0;
166 struct i2c_msg msgs[] = {
167 {
168 .addr = 0x50,
169 .len = 1,
170 .buf = &start,
171 }, {
172 .addr = 0x50,
173 .flags = I2C_M_RD,
174 .len = EDID_LENGTH,
175 },
176 };
177 u8 *buf;
178
179 if (!chan->par)
180 return NULL;
181
182 buf = kmalloc(EDID_LENGTH, GFP_KERNEL);
183 if (!buf) {
184 dev_warn(&chan->par->pci_dev->dev, "Out of memory!\n");
185 return NULL;
186 }
187 msgs[1].buf = buf;
188
189 if (i2c_transfer(&chan->adapter, msgs, 2) == 2)
190 return buf;
191 dev_dbg(&chan->par->pci_dev->dev, "Unable to read EDID block.\n");
192 kfree(buf);
193 return NULL;
194}
195
163int nvidia_probe_i2c_connector(struct fb_info *info, int conn, u8 **out_edid) 196int nvidia_probe_i2c_connector(struct fb_info *info, int conn, u8 **out_edid)
164{ 197{
165 struct nvidia_par *par = info->par; 198 struct nvidia_par *par = info->par;
166 u8 *edid; 199 u8 *edid = NULL;
167 200 int i;
168 edid = fb_ddc_read(&par->chan[conn - 1].adapter); 201
202 for (i = 0; i < 3; i++) {
203 /* Do the real work */
204 edid = nvidia_do_probe_i2c_edid(&par->chan[conn - 1]);
205 if (edid)
206 break;
207 }
169 208
170 if (!edid && conn == 1) { 209 if (!edid && conn == 1) {
171 /* try to get from firmware */ 210 /* try to get from firmware */
diff --git a/drivers/video/nvidia/nv_setup.c b/drivers/video/nvidia/nv_setup.c
index a18a9aebf05f..eab3e282a4de 100644
--- a/drivers/video/nvidia/nv_setup.c
+++ b/drivers/video/nvidia/nv_setup.c
@@ -262,7 +262,7 @@ static void nv10GetConfig(struct nvidia_par *par)
262#endif 262#endif
263 263
264 dev = pci_find_slot(0, 1); 264 dev = pci_find_slot(0, 1);
265 if ((par->Chipset && 0xffff) == 0x01a0) { 265 if ((par->Chipset & 0xffff) == 0x01a0) {
266 int amt = 0; 266 int amt = 0;
267 267
268 pci_read_config_dword(dev, 0x7c, &amt); 268 pci_read_config_dword(dev, 0x7c, &amt);
@@ -359,6 +359,7 @@ int NVCommonSetup(struct fb_info *info)
359 case 0x0186: 359 case 0x0186:
360 case 0x0187: 360 case 0x0187:
361 case 0x018D: 361 case 0x018D:
362 case 0x0228:
362 case 0x0286: 363 case 0x0286:
363 case 0x028C: 364 case 0x028C:
364 case 0x0316: 365 case 0x0316:
@@ -382,6 +383,10 @@ int NVCommonSetup(struct fb_info *info)
382 case 0x034C: 383 case 0x034C:
383 case 0x0160: 384 case 0x0160:
384 case 0x0166: 385 case 0x0166:
386 case 0x0169:
387 case 0x016B:
388 case 0x016C:
389 case 0x016D:
385 case 0x00C8: 390 case 0x00C8:
386 case 0x00CC: 391 case 0x00CC:
387 case 0x0144: 392 case 0x0144:
@@ -639,12 +644,23 @@ int NVCommonSetup(struct fb_info *info)
639 par->fpHeight = NV_RD32(par->PRAMDAC, 0x0800) + 1; 644 par->fpHeight = NV_RD32(par->PRAMDAC, 0x0800) + 1;
640 par->fpSyncs = NV_RD32(par->PRAMDAC, 0x0848) & 0x30000033; 645 par->fpSyncs = NV_RD32(par->PRAMDAC, 0x0848) & 0x30000033;
641 646
642 printk("Panel size is %i x %i\n", par->fpWidth, par->fpHeight); 647 printk("nvidiafb: Panel size is %i x %i\n", par->fpWidth, par->fpHeight);
643 } 648 }
644 649
645 if (monA) 650 if (monA)
646 info->monspecs = *monA; 651 info->monspecs = *monA;
647 652
653 if (!par->FlatPanel || !par->twoHeads)
654 par->FPDither = 0;
655
656 par->LVDS = 0;
657 if (par->FlatPanel && par->twoHeads) {
658 NV_WR32(par->PRAMDAC0, 0x08B0, 0x00010004);
659 if (par->PRAMDAC0[0x08b4] & 1)
660 par->LVDS = 1;
661 printk("nvidiafb: Panel is %s\n", par->LVDS ? "LVDS" : "TMDS");
662 }
663
648 kfree(edidA); 664 kfree(edidA);
649 kfree(edidB); 665 kfree(edidB);
650done: 666done:
diff --git a/drivers/video/nvidia/nv_type.h b/drivers/video/nvidia/nv_type.h
index acdc26693402..86e65dea60d3 100644
--- a/drivers/video/nvidia/nv_type.h
+++ b/drivers/video/nvidia/nv_type.h
@@ -129,6 +129,7 @@ struct nvidia_par {
129 int fpHeight; 129 int fpHeight;
130 int PanelTweak; 130 int PanelTweak;
131 int paneltweak; 131 int paneltweak;
132 int LVDS;
132 int pm_state; 133 int pm_state;
133 u32 crtcSync_read; 134 u32 crtcSync_read;
134 u32 fpSyncs; 135 u32 fpSyncs;
diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
index eb24107bcc81..538e947610e1 100644
--- a/drivers/video/nvidia/nvidia.c
+++ b/drivers/video/nvidia/nvidia.c
@@ -1160,20 +1160,20 @@ static u32 __devinit nvidia_get_arch(struct fb_info *info)
1160 case 0x0340: /* GeForceFX 5700 */ 1160 case 0x0340: /* GeForceFX 5700 */
1161 arch = NV_ARCH_30; 1161 arch = NV_ARCH_30;
1162 break; 1162 break;
1163 case 0x0040: 1163 case 0x0040: /* GeForce 6800 */
1164 case 0x00C0: 1164 case 0x00C0: /* GeForce 6800 */
1165 case 0x0120: 1165 case 0x0120: /* GeForce 6800 */
1166 case 0x0130: 1166 case 0x0130:
1167 case 0x0140: 1167 case 0x0140: /* GeForce 6600 */
1168 case 0x0160: 1168 case 0x0160: /* GeForce 6200 */
1169 case 0x01D0: 1169 case 0x01D0: /* GeForce 7200, 7300, 7400 */
1170 case 0x0090: 1170 case 0x0090: /* GeForce 7800 */
1171 case 0x0210: 1171 case 0x0210: /* GeForce 6800 */
1172 case 0x0220: 1172 case 0x0220: /* GeForce 6200 */
1173 case 0x0230: 1173 case 0x0230:
1174 case 0x0240: 1174 case 0x0240: /* GeForce 6100 */
1175 case 0x0290: 1175 case 0x0290: /* GeForce 7900 */
1176 case 0x0390: 1176 case 0x0390: /* GeForce 7600 */
1177 arch = NV_ARCH_40; 1177 arch = NV_ARCH_40;
1178 break; 1178 break;
1179 case 0x0020: /* TNT, TNT2 */ 1179 case 0x0020: /* TNT, TNT2 */
diff --git a/drivers/video/offb.c b/drivers/video/offb.c
index bad0e98fb3b6..9a40bbecf76b 100644
--- a/drivers/video/offb.c
+++ b/drivers/video/offb.c
@@ -157,7 +157,7 @@ static int offb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
157 out_le32(par->cmap_adr + 0xb4, (red << 16 | green << 8 | blue)); 157 out_le32(par->cmap_adr + 0xb4, (red << 16 | green << 8 | blue));
158 break; 158 break;
159 case cmap_gxt2000: 159 case cmap_gxt2000:
160 out_le32((unsigned __iomem *) par->cmap_adr + regno, 160 out_le32(((unsigned __iomem *) par->cmap_adr) + regno,
161 (red << 16 | green << 8 | blue)); 161 (red << 16 | green << 8 | blue));
162 break; 162 break;
163 } 163 }
@@ -213,7 +213,7 @@ static int offb_blank(int blank, struct fb_info *info)
213 out_le32(par->cmap_adr + 0xb4, 0); 213 out_le32(par->cmap_adr + 0xb4, 0);
214 break; 214 break;
215 case cmap_gxt2000: 215 case cmap_gxt2000:
216 out_le32((unsigned __iomem *) par->cmap_adr + i, 216 out_le32(((unsigned __iomem *) par->cmap_adr) + i,
217 0); 217 0);
218 break; 218 break;
219 } 219 }
@@ -226,13 +226,23 @@ static int offb_blank(int blank, struct fb_info *info)
226static void __iomem *offb_map_reg(struct device_node *np, int index, 226static void __iomem *offb_map_reg(struct device_node *np, int index,
227 unsigned long offset, unsigned long size) 227 unsigned long offset, unsigned long size)
228{ 228{
229 struct resource r; 229 const u32 *addrp;
230 230 u64 asize, taddr;
231 if (of_address_to_resource(np, index, &r)) 231 unsigned int flags;
232 return 0; 232
233 if ((r.start + offset + size) > r.end) 233 addrp = of_get_pci_address(np, index, &asize, &flags);
234 return 0; 234 if (addrp == NULL)
235 return ioremap(r.start + offset, size); 235 addrp = of_get_address(np, index, &asize, &flags);
236 if (addrp == NULL)
237 return NULL;
238 if ((flags & (IORESOURCE_IO | IORESOURCE_MEM)) == 0)
239 return NULL;
240 if ((offset + size) > asize)
241 return NULL;
242 taddr = of_translate_address(np, addrp);
243 if (taddr == OF_BAD_ADDR)
244 return NULL;
245 return ioremap(taddr + offset, size);
236} 246}
237 247
238static void __init offb_init_fb(const char *name, const char *full_name, 248static void __init offb_init_fb(const char *name, const char *full_name,
@@ -289,7 +299,6 @@ static void __init offb_init_fb(const char *name, const char *full_name,
289 299
290 par->cmap_type = cmap_unknown; 300 par->cmap_type = cmap_unknown;
291 if (depth == 8) { 301 if (depth == 8) {
292 /* Palette hacks disabled for now */
293 if (dp && !strncmp(name, "ATY,Rage128", 11)) { 302 if (dp && !strncmp(name, "ATY,Rage128", 11)) {
294 par->cmap_adr = offb_map_reg(dp, 2, 0, 0x1fff); 303 par->cmap_adr = offb_map_reg(dp, 2, 0, 0x1fff);
295 if (par->cmap_adr) 304 if (par->cmap_adr)
@@ -313,7 +322,8 @@ static void __init offb_init_fb(const char *name, const char *full_name,
313 ioremap(base + 0x7ff000, 0x1000) + 0xcc0; 322 ioremap(base + 0x7ff000, 0x1000) + 0xcc0;
314 par->cmap_data = par->cmap_adr + 1; 323 par->cmap_data = par->cmap_adr + 1;
315 par->cmap_type = cmap_m64; 324 par->cmap_type = cmap_m64;
316 } else if (dp && device_is_compatible(dp, "pci1014,b7")) { 325 } else if (dp && (device_is_compatible(dp, "pci1014,b7") ||
326 device_is_compatible(dp, "pci1014,21c"))) {
317 par->cmap_adr = offb_map_reg(dp, 0, 0x6000, 0x1000); 327 par->cmap_adr = offb_map_reg(dp, 0, 0x6000, 0x1000);
318 if (par->cmap_adr) 328 if (par->cmap_adr)
319 par->cmap_type = cmap_gxt2000; 329 par->cmap_type = cmap_gxt2000;
@@ -433,7 +443,7 @@ static void __init offb_init_nodriver(struct device_node *dp, int no_real_node)
433 pp = get_property(dp, "linux,bootx-linebytes", &len); 443 pp = get_property(dp, "linux,bootx-linebytes", &len);
434 if (pp == NULL) 444 if (pp == NULL)
435 pp = get_property(dp, "linebytes", &len); 445 pp = get_property(dp, "linebytes", &len);
436 if (pp && len == sizeof(u32)) 446 if (pp && len == sizeof(u32) && (*pp != 0xffffffffu))
437 pitch = *pp; 447 pitch = *pp;
438 else 448 else
439 pitch = width * ((depth + 7) / 8); 449 pitch = width * ((depth + 7) / 8);
@@ -496,7 +506,7 @@ static void __init offb_init_nodriver(struct device_node *dp, int no_real_node)
496 offb_init_fb(no_real_node ? "bootx" : dp->name, 506 offb_init_fb(no_real_node ? "bootx" : dp->name,
497 no_real_node ? "display" : dp->full_name, 507 no_real_node ? "display" : dp->full_name,
498 width, height, depth, pitch, address, 508 width, height, depth, pitch, address,
499 no_real_node ? dp : NULL); 509 no_real_node ? NULL : dp);
500 } 510 }
501} 511}
502 512
diff --git a/drivers/video/platinumfb.c b/drivers/video/platinumfb.c
index 983be3ec2345..fdb33cd21a27 100644
--- a/drivers/video/platinumfb.c
+++ b/drivers/video/platinumfb.c
@@ -339,11 +339,12 @@ static int __devinit platinum_init_fb(struct fb_info *info)
339 339
340 sense = read_platinum_sense(pinfo); 340 sense = read_platinum_sense(pinfo);
341 printk(KERN_INFO "platinumfb: Monitor sense value = 0x%x, ", sense); 341 printk(KERN_INFO "platinumfb: Monitor sense value = 0x%x, ", sense);
342
343 if (default_vmode == VMODE_NVRAM) { 342 if (default_vmode == VMODE_NVRAM) {
343#ifdef CONFIG_NVRAM
344 default_vmode = nvram_read_byte(NV_VMODE); 344 default_vmode = nvram_read_byte(NV_VMODE);
345 if (default_vmode <= 0 || default_vmode > VMODE_MAX || 345 if (default_vmode <= 0 || default_vmode > VMODE_MAX ||
346 !platinum_reg_init[default_vmode-1]) 346 !platinum_reg_init[default_vmode-1])
347#endif
347 default_vmode = VMODE_CHOOSE; 348 default_vmode = VMODE_CHOOSE;
348 } 349 }
349 if (default_vmode == VMODE_CHOOSE) { 350 if (default_vmode == VMODE_CHOOSE) {
@@ -351,8 +352,10 @@ static int __devinit platinum_init_fb(struct fb_info *info)
351 } 352 }
352 if (default_vmode <= 0 || default_vmode > VMODE_MAX) 353 if (default_vmode <= 0 || default_vmode > VMODE_MAX)
353 default_vmode = VMODE_640_480_60; 354 default_vmode = VMODE_640_480_60;
355#ifdef CONFIG_NVRAM
354 if (default_cmode == CMODE_NVRAM) 356 if (default_cmode == CMODE_NVRAM)
355 default_cmode = nvram_read_byte(NV_CMODE); 357 default_cmode = nvram_read_byte(NV_CMODE);
358#endif
356 if (default_cmode < CMODE_8 || default_cmode > CMODE_32) 359 if (default_cmode < CMODE_8 || default_cmode > CMODE_32)
357 default_cmode = CMODE_8; 360 default_cmode = CMODE_8;
358 /* 361 /*
diff --git a/drivers/video/pnx4008/pnxrgbfb.c b/drivers/video/pnx4008/pnxrgbfb.c
index 7d9453c91a42..f29e66e2d774 100644
--- a/drivers/video/pnx4008/pnxrgbfb.c
+++ b/drivers/video/pnx4008/pnxrgbfb.c
@@ -154,7 +154,8 @@ static int __devinit rgbfb_probe(struct platform_device *pdev)
154 goto err1; 154 goto err1;
155 } 155 }
156 156
157 if (!fb_get_options("pnxrgbfb", &option) && !strcmp(option, "nocursor")) 157 if (!fb_get_options("pnxrgbfb", &option) && option &&
158 !strcmp(option, "nocursor"))
158 rgbfb_ops.fb_cursor = no_cursor; 159 rgbfb_ops.fb_cursor = no_cursor;
159 160
160 info->node = -1; 161 info->node = -1;
@@ -191,7 +192,7 @@ err:
191 192
192static struct platform_driver rgbfb_driver = { 193static struct platform_driver rgbfb_driver = {
193 .driver = { 194 .driver = {
194 .name = "rgbfb", 195 .name = "pnx4008-rgbfb",
195 }, 196 },
196 .probe = rgbfb_probe, 197 .probe = rgbfb_probe,
197 .remove = rgbfb_remove, 198 .remove = rgbfb_remove,
diff --git a/drivers/video/pnx4008/sdum.c b/drivers/video/pnx4008/sdum.c
index 51f0ecc2a511..d23bf0d659b6 100644
--- a/drivers/video/pnx4008/sdum.c
+++ b/drivers/video/pnx4008/sdum.c
@@ -848,7 +848,7 @@ static int sdum_remove(struct platform_device *pdev)
848 848
849static struct platform_driver sdum_driver = { 849static struct platform_driver sdum_driver = {
850 .driver = { 850 .driver = {
851 .name = "sdum", 851 .name = "pnx4008-sdum",
852 }, 852 },
853 .probe = sdum_probe, 853 .probe = sdum_probe,
854 .remove = sdum_remove, 854 .remove = sdum_remove,
diff --git a/drivers/video/valkyriefb.c b/drivers/video/valkyriefb.c
index 47f27924a7d7..06fc19a61192 100644
--- a/drivers/video/valkyriefb.c
+++ b/drivers/video/valkyriefb.c
@@ -284,7 +284,7 @@ static void __init valkyrie_choose_mode(struct fb_info_valkyrie *p)
284 printk(KERN_INFO "Monitor sense value = 0x%x\n", p->sense); 284 printk(KERN_INFO "Monitor sense value = 0x%x\n", p->sense);
285 285
286 /* Try to pick a video mode out of NVRAM if we have one. */ 286 /* Try to pick a video mode out of NVRAM if we have one. */
287#ifndef CONFIG_MAC 287#if !defined(CONFIG_MAC) && defined(CONFIG_NVRAM)
288 if (default_vmode == VMODE_NVRAM) { 288 if (default_vmode == VMODE_NVRAM) {
289 default_vmode = nvram_read_byte(NV_VMODE); 289 default_vmode = nvram_read_byte(NV_VMODE);
290 if (default_vmode <= 0 290 if (default_vmode <= 0
@@ -297,7 +297,7 @@ static void __init valkyrie_choose_mode(struct fb_info_valkyrie *p)
297 default_vmode = mac_map_monitor_sense(p->sense); 297 default_vmode = mac_map_monitor_sense(p->sense);
298 if (!valkyrie_reg_init[default_vmode - 1]) 298 if (!valkyrie_reg_init[default_vmode - 1])
299 default_vmode = VMODE_640_480_67; 299 default_vmode = VMODE_640_480_67;
300#ifndef CONFIG_MAC 300#if !defined(CONFIG_MAC) && defined(CONFIG_NVRAM)
301 if (default_cmode == CMODE_NVRAM) 301 if (default_cmode == CMODE_NVRAM)
302 default_cmode = nvram_read_byte(NV_CMODE); 302 default_cmode = nvram_read_byte(NV_CMODE);
303#endif 303#endif
diff --git a/drivers/w1/Kconfig b/drivers/w1/Kconfig
index 27c9d05d03ef..c287a9ae4fdd 100644
--- a/drivers/w1/Kconfig
+++ b/drivers/w1/Kconfig
@@ -2,7 +2,6 @@ menu "Dallas's 1-wire bus"
2 2
3config W1 3config W1
4 tristate "Dallas's 1-wire support" 4 tristate "Dallas's 1-wire support"
5 depends on CONNECTOR
6 ---help--- 5 ---help---
7 Dallas' 1-wire bus is useful to connect slow 1-pin devices 6 Dallas' 1-wire bus is useful to connect slow 1-pin devices
8 such as iButtons and thermal sensors. 7 such as iButtons and thermal sensors.
diff --git a/drivers/w1/masters/matrox_w1.c b/drivers/w1/masters/matrox_w1.c
index 2788b8ca9bb1..6f9d880ab2e9 100644
--- a/drivers/w1/masters/matrox_w1.c
+++ b/drivers/w1/masters/matrox_w1.c
@@ -215,6 +215,8 @@ static int __devinit matrox_w1_probe(struct pci_dev *pdev, const struct pci_devi
215 return 0; 215 return 0;
216 216
217err_out_free_device: 217err_out_free_device:
218 if (dev->virt_addr)
219 iounmap(dev->virt_addr);
218 kfree(dev); 220 kfree(dev);
219 221
220 return err; 222 return err;
diff --git a/fs/Kconfig b/fs/Kconfig
index 599de54451af..7b1511d50b05 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -140,6 +140,73 @@ config EXT3_FS_SECURITY
140 If you are not using a security module that requires using 140 If you are not using a security module that requires using
141 extended attributes for file security labels, say N. 141 extended attributes for file security labels, say N.
142 142
143config EXT4DEV_FS
144 tristate "Ext4dev/ext4 extended fs support development (EXPERIMENTAL)"
145 depends on EXPERIMENTAL
146 select JBD2
147 help
148 Ext4dev is a predecessor filesystem of the next generation
149 extended fs ext4, based on ext3 filesystem code. It will be
150 renamed ext4 fs later, once ext4dev is mature and stabilized.
151
152 Unlike the change from ext2 filesystem to ext3 filesystem,
153 the on-disk format of ext4dev is not the same as ext3 any more:
154 it is based on extent maps and it supports 48-bit physical block
155 numbers. These combined on-disk format changes will allow
156 ext4dev/ext4 to handle more than 16 TB filesystem volumes --
157 a hard limit that ext3 cannot overcome without changing the
158 on-disk format.
159
160 Other than extent maps and 48-bit block numbers, ext4dev also is
161 likely to have other new features such as persistent preallocation,
162 high resolution time stamps, and larger file support etc. These
163 features will be added to ext4dev gradually.
164
165 To compile this file system support as a module, choose M here. The
166 module will be called ext4dev. Be aware, however, that the filesystem
167 of your root partition (the one containing the directory /) cannot
168 be compiled as a module, and so this could be dangerous.
169
170 If unsure, say N.
171
172config EXT4DEV_FS_XATTR
173 bool "Ext4dev extended attributes"
174 depends on EXT4DEV_FS
175 default y
176 help
177 Extended attributes are name:value pairs associated with inodes by
178 the kernel or by users (see the attr(5) manual page, or visit
179 <http://acl.bestbits.at/> for details).
180
181 If unsure, say N.
182
183 You need this for POSIX ACL support on ext4dev/ext4.
184
185config EXT4DEV_FS_POSIX_ACL
186 bool "Ext4dev POSIX Access Control Lists"
187 depends on EXT4DEV_FS_XATTR
188 select FS_POSIX_ACL
189 help
190 POSIX Access Control Lists (ACLs) support permissions for users and
191 groups beyond the owner/group/world scheme.
192
193 To learn more about Access Control Lists, visit the POSIX ACLs for
194 Linux website <http://acl.bestbits.at/>.
195
196 If you don't know what Access Control Lists are, say N
197
198config EXT4DEV_FS_SECURITY
199 bool "Ext4dev Security Labels"
200 depends on EXT4DEV_FS_XATTR
201 help
202 Security labels support alternative access control models
203 implemented by security modules like SELinux. This option
204 enables an extended attribute handler for file security
205 labels in the ext4dev/ext4 filesystem.
206
207 If you are not using a security module that requires using
208 extended attributes for file security labels, say N.
209
143config JBD 210config JBD
144 tristate 211 tristate
145 help 212 help
@@ -172,12 +239,44 @@ config JBD_DEBUG
172 generated. To turn debugging off again, do 239 generated. To turn debugging off again, do
173 "echo 0 > /proc/sys/fs/jbd-debug". 240 "echo 0 > /proc/sys/fs/jbd-debug".
174 241
242config JBD2
243 tristate
244 help
245 This is a generic journaling layer for block devices that support
246 both 32-bit and 64-bit block numbers. It is currently used by
247 the ext4dev/ext4 filesystem, but it could also be used to add
248 journal support to other file systems or block devices such
249 as RAID or LVM.
250
251 If you are using ext4dev/ext4, you need to say Y here. If you are not
252 using ext4dev/ext4 then you will probably want to say N.
253
254 To compile this device as a module, choose M here. The module will be
255 called jbd2. If you are compiling ext4dev/ext4 into the kernel,
256 you cannot compile this code as a module.
257
258config JBD2_DEBUG
259 bool "JBD2 (ext4dev/ext4) debugging support"
260 depends on JBD2
261 help
262 If you are using the ext4dev/ext4 journaled file system (or
263 potentially any other filesystem/device using JBD2), this option
264 allows you to enable debugging output while the system is running,
265 in order to help track down any problems you are having.
266 By default, the debugging output will be turned off.
267
268 If you select Y here, then you will be able to turn on debugging
269 with "echo N > /proc/sys/fs/jbd2-debug", where N is a number between
270 1 and 5. The higher the number, the more debugging output is
271 generated. To turn debugging off again, do
272 "echo 0 > /proc/sys/fs/jbd2-debug".
273
175config FS_MBCACHE 274config FS_MBCACHE
176# Meta block cache for Extended Attributes (ext2/ext3) 275# Meta block cache for Extended Attributes (ext2/ext3/ext4)
177 tristate 276 tristate
178 depends on EXT2_FS_XATTR || EXT3_FS_XATTR 277 depends on EXT2_FS_XATTR || EXT3_FS_XATTR || EXT4DEV_FS_XATTR
179 default y if EXT2_FS=y || EXT3_FS=y 278 default y if EXT2_FS=y || EXT3_FS=y || EXT4DEV_FS=y
180 default m if EXT2_FS=m || EXT3_FS=m 279 default m if EXT2_FS=m || EXT3_FS=m || EXT4DEV_FS=m
181 280
182config REISERFS_FS 281config REISERFS_FS
183 tristate "Reiserfs support" 282 tristate "Reiserfs support"
@@ -535,6 +634,10 @@ config FUSE_FS
535 If you want to develop a userspace FS, or if you want to use 634 If you want to develop a userspace FS, or if you want to use
536 a filesystem based on FUSE, answer Y or M. 635 a filesystem based on FUSE, answer Y or M.
537 636
637config GENERIC_ACL
638 bool
639 select FS_POSIX_ACL
640
538if BLOCK 641if BLOCK
539menu "CD-ROM/DVD Filesystems" 642menu "CD-ROM/DVD Filesystems"
540 643
@@ -1674,6 +1777,7 @@ config RPCSEC_GSS_KRB5
1674 select CRYPTO 1777 select CRYPTO
1675 select CRYPTO_MD5 1778 select CRYPTO_MD5
1676 select CRYPTO_DES 1779 select CRYPTO_DES
1780 select CRYPTO_CBC
1677 help 1781 help
1678 Provides for secure RPC calls by means of a gss-api 1782 Provides for secure RPC calls by means of a gss-api
1679 mechanism based on Kerberos V5. This is required for 1783 mechanism based on Kerberos V5. This is required for
@@ -1692,6 +1796,7 @@ config RPCSEC_GSS_SPKM3
1692 select CRYPTO_MD5 1796 select CRYPTO_MD5
1693 select CRYPTO_DES 1797 select CRYPTO_DES
1694 select CRYPTO_CAST5 1798 select CRYPTO_CAST5
1799 select CRYPTO_CBC
1695 help 1800 help
1696 Provides for secure RPC calls by means of a gss-api 1801 Provides for secure RPC calls by means of a gss-api
1697 mechanism based on the SPKM3 public-key mechanism. 1802 mechanism based on the SPKM3 public-key mechanism.
@@ -1887,7 +1992,7 @@ config CIFS_EXPERIMENTAL
1887config CIFS_UPCALL 1992config CIFS_UPCALL
1888 bool "Kerberos/SPNEGO advanced session setup (EXPERIMENTAL)" 1993 bool "Kerberos/SPNEGO advanced session setup (EXPERIMENTAL)"
1889 depends on CIFS_EXPERIMENTAL 1994 depends on CIFS_EXPERIMENTAL
1890 select CONNECTOR 1995 depends on CONNECTOR
1891 help 1996 help
1892 Enables an upcall mechanism for CIFS which will be used to contact 1997 Enables an upcall mechanism for CIFS which will be used to contact
1893 userspace helper utilities to provide SPNEGO packaged Kerberos 1998 userspace helper utilities to provide SPNEGO packaged Kerberos
@@ -1955,8 +2060,7 @@ config CODA_FS_OLD_API
1955 For most cases you probably want to say N. 2060 For most cases you probably want to say N.
1956 2061
1957config AFS_FS 2062config AFS_FS
1958# for fs/nls/Config.in 2063 tristate "Andrew File System support (AFS) (EXPERIMENTAL)"
1959 tristate "Andrew File System support (AFS) (Experimental)"
1960 depends on INET && EXPERIMENTAL 2064 depends on INET && EXPERIMENTAL
1961 select RXRPC 2065 select RXRPC
1962 help 2066 help
@@ -1981,10 +2085,6 @@ config 9P_FS
1981 2085
1982 If unsure, say N. 2086 If unsure, say N.
1983 2087
1984config GENERIC_ACL
1985 bool
1986 select FS_POSIX_ACL
1987
1988endmenu 2088endmenu
1989 2089
1990if BLOCK 2090if BLOCK
diff --git a/fs/Makefile b/fs/Makefile
index df614eacee86..9a5ce9323bfd 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -62,7 +62,9 @@ obj-$(CONFIG_DLM) += dlm/
62# Do not add any filesystems before this line 62# Do not add any filesystems before this line
63obj-$(CONFIG_REISERFS_FS) += reiserfs/ 63obj-$(CONFIG_REISERFS_FS) += reiserfs/
64obj-$(CONFIG_EXT3_FS) += ext3/ # Before ext2 so root fs can be ext3 64obj-$(CONFIG_EXT3_FS) += ext3/ # Before ext2 so root fs can be ext3
65obj-$(CONFIG_EXT4DEV_FS) += ext4/ # Before ext2 so root fs can be ext4dev
65obj-$(CONFIG_JBD) += jbd/ 66obj-$(CONFIG_JBD) += jbd/
67obj-$(CONFIG_JBD2) += jbd2/
66obj-$(CONFIG_EXT2_FS) += ext2/ 68obj-$(CONFIG_EXT2_FS) += ext2/
67obj-$(CONFIG_CRAMFS) += cramfs/ 69obj-$(CONFIG_CRAMFS) += cramfs/
68obj-$(CONFIG_RAMFS) += ramfs/ 70obj-$(CONFIG_RAMFS) += ramfs/
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index cf8a2cb28505..a6ec75c56fcf 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -211,8 +211,8 @@ static int afs_dir_open(struct inode *inode, struct file *file)
211{ 211{
212 _enter("{%lu}", inode->i_ino); 212 _enter("{%lu}", inode->i_ino);
213 213
214 BUG_ON(sizeof(union afs_dir_block) != 2048); 214 BUILD_BUG_ON(sizeof(union afs_dir_block) != 2048);
215 BUG_ON(sizeof(union afs_dirent) != 32); 215 BUILD_BUG_ON(sizeof(union afs_dirent) != 32);
216 216
217 if (AFS_FS_I(inode)->flags & AFS_VNODE_DELETED) 217 if (AFS_FS_I(inode)->flags & AFS_VNODE_DELETED)
218 return -ENOENT; 218 return -ENOENT;
@@ -446,8 +446,8 @@ static struct dentry *afs_dir_lookup(struct inode *dir, struct dentry *dentry,
446 _enter("{%lu},%p{%s}", dir->i_ino, dentry, dentry->d_name.name); 446 _enter("{%lu},%p{%s}", dir->i_ino, dentry, dentry->d_name.name);
447 447
448 /* insanity checks first */ 448 /* insanity checks first */
449 BUG_ON(sizeof(union afs_dir_block) != 2048); 449 BUILD_BUG_ON(sizeof(union afs_dir_block) != 2048);
450 BUG_ON(sizeof(union afs_dirent) != 32); 450 BUILD_BUG_ON(sizeof(union afs_dirent) != 32);
451 451
452 if (dentry->d_name.len > 255) { 452 if (dentry->d_name.len > 255) {
453 _leave(" = -ENAMETOOLONG"); 453 _leave(" = -ENAMETOOLONG");
diff --git a/fs/autofs/autofs_i.h b/fs/autofs/autofs_i.h
index c7700d9b3f96..906ba5ce2261 100644
--- a/fs/autofs/autofs_i.h
+++ b/fs/autofs/autofs_i.h
@@ -149,6 +149,7 @@ extern const struct file_operations autofs_root_operations;
149/* Initializing function */ 149/* Initializing function */
150 150
151int autofs_fill_super(struct super_block *, void *, int); 151int autofs_fill_super(struct super_block *, void *, int);
152void autofs_kill_sb(struct super_block *sb);
152 153
153/* Queue management functions */ 154/* Queue management functions */
154 155
diff --git a/fs/autofs/dirhash.c b/fs/autofs/dirhash.c
index 3fded389d06b..bf8c8af98004 100644
--- a/fs/autofs/dirhash.c
+++ b/fs/autofs/dirhash.c
@@ -246,5 +246,4 @@ void autofs_hash_nuke(struct autofs_sb_info *sbi)
246 kfree(ent); 246 kfree(ent);
247 } 247 }
248 } 248 }
249 shrink_dcache_sb(sbi->sb);
250} 249}
diff --git a/fs/autofs/init.c b/fs/autofs/init.c
index aca123752406..cea5219b4f37 100644
--- a/fs/autofs/init.c
+++ b/fs/autofs/init.c
@@ -24,7 +24,7 @@ static struct file_system_type autofs_fs_type = {
24 .owner = THIS_MODULE, 24 .owner = THIS_MODULE,
25 .name = "autofs", 25 .name = "autofs",
26 .get_sb = autofs_get_sb, 26 .get_sb = autofs_get_sb,
27 .kill_sb = kill_anon_super, 27 .kill_sb = autofs_kill_sb,
28}; 28};
29 29
30static int __init init_autofs_fs(void) 30static int __init init_autofs_fs(void)
diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c
index 2c9759baad61..38ede5c9d6fd 100644
--- a/fs/autofs/inode.c
+++ b/fs/autofs/inode.c
@@ -20,11 +20,19 @@
20#include "autofs_i.h" 20#include "autofs_i.h"
21#include <linux/module.h> 21#include <linux/module.h>
22 22
23static void autofs_put_super(struct super_block *sb) 23void autofs_kill_sb(struct super_block *sb)
24{ 24{
25 struct autofs_sb_info *sbi = autofs_sbi(sb); 25 struct autofs_sb_info *sbi = autofs_sbi(sb);
26 unsigned int n; 26 unsigned int n;
27 27
28 /*
29 * In the event of a failure in get_sb_nodev the superblock
30 * info is not present so nothing else has been setup, so
31 * just exit when we are called from deactivate_super.
32 */
33 if (!sbi)
34 return;
35
28 if ( !sbi->catatonic ) 36 if ( !sbi->catatonic )
29 autofs_catatonic_mode(sbi); /* Free wait queues, close pipe */ 37 autofs_catatonic_mode(sbi); /* Free wait queues, close pipe */
30 38
@@ -37,13 +45,13 @@ static void autofs_put_super(struct super_block *sb)
37 kfree(sb->s_fs_info); 45 kfree(sb->s_fs_info);
38 46
39 DPRINTK(("autofs: shutting down\n")); 47 DPRINTK(("autofs: shutting down\n"));
48 kill_anon_super(sb);
40} 49}
41 50
42static void autofs_read_inode(struct inode *inode); 51static void autofs_read_inode(struct inode *inode);
43 52
44static struct super_operations autofs_sops = { 53static struct super_operations autofs_sops = {
45 .read_inode = autofs_read_inode, 54 .read_inode = autofs_read_inode,
46 .put_super = autofs_put_super,
47 .statfs = simple_statfs, 55 .statfs = simple_statfs,
48}; 56};
49 57
@@ -136,7 +144,8 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
136 144
137 s->s_fs_info = sbi; 145 s->s_fs_info = sbi;
138 sbi->magic = AUTOFS_SBI_MAGIC; 146 sbi->magic = AUTOFS_SBI_MAGIC;
139 sbi->catatonic = 0; 147 sbi->pipe = NULL;
148 sbi->catatonic = 1;
140 sbi->exp_timeout = 0; 149 sbi->exp_timeout = 0;
141 sbi->oz_pgrp = process_group(current); 150 sbi->oz_pgrp = process_group(current);
142 autofs_initialize_hash(&sbi->dirhash); 151 autofs_initialize_hash(&sbi->dirhash);
@@ -180,6 +189,7 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
180 if ( !pipe->f_op || !pipe->f_op->write ) 189 if ( !pipe->f_op || !pipe->f_op->write )
181 goto fail_fput; 190 goto fail_fput;
182 sbi->pipe = pipe; 191 sbi->pipe = pipe;
192 sbi->catatonic = 0;
183 193
184 /* 194 /*
185 * Success! Install the root dentry now to indicate completion. 195 * Success! Install the root dentry now to indicate completion.
@@ -198,6 +208,8 @@ fail_iput:
198 iput(root_inode); 208 iput(root_inode);
199fail_free: 209fail_free:
200 kfree(sbi); 210 kfree(sbi);
211 s->s_fs_info = NULL;
212 kill_anon_super(s);
201fail_unlock: 213fail_unlock:
202 return -EINVAL; 214 return -EINVAL;
203} 215}
diff --git a/fs/autofs/waitq.c b/fs/autofs/waitq.c
index 633f628005b4..19a9cafb5ddf 100644
--- a/fs/autofs/waitq.c
+++ b/fs/autofs/waitq.c
@@ -41,6 +41,7 @@ void autofs_catatonic_mode(struct autofs_sb_info *sbi)
41 wq = nwq; 41 wq = nwq;
42 } 42 }
43 fput(sbi->pipe); /* Close the pipe */ 43 fput(sbi->pipe); /* Close the pipe */
44 sbi->pipe = NULL;
44 autofs_hash_dputall(&sbi->dirhash); /* Remove all dentry pointers */ 45 autofs_hash_dputall(&sbi->dirhash); /* Remove all dentry pointers */
45} 46}
46 47
diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h
index 480ab178cba5..b13f32c8aeee 100644
--- a/fs/autofs4/autofs_i.h
+++ b/fs/autofs4/autofs_i.h
@@ -94,7 +94,6 @@ struct autofs_wait_queue {
94 94
95struct autofs_sb_info { 95struct autofs_sb_info {
96 u32 magic; 96 u32 magic;
97 struct dentry *root;
98 int pipefd; 97 int pipefd;
99 struct file *pipe; 98 struct file *pipe;
100 pid_t oz_pgrp; 99 pid_t oz_pgrp;
@@ -229,4 +228,4 @@ out:
229} 228}
230 229
231void autofs4_dentry_release(struct dentry *); 230void autofs4_dentry_release(struct dentry *);
232 231extern void autofs4_kill_sb(struct super_block *);
diff --git a/fs/autofs4/init.c b/fs/autofs4/init.c
index 5d9193332bef..723a1c5e361b 100644
--- a/fs/autofs4/init.c
+++ b/fs/autofs4/init.c
@@ -24,7 +24,7 @@ static struct file_system_type autofs_fs_type = {
24 .owner = THIS_MODULE, 24 .owner = THIS_MODULE,
25 .name = "autofs", 25 .name = "autofs",
26 .get_sb = autofs_get_sb, 26 .get_sb = autofs_get_sb,
27 .kill_sb = kill_anon_super, 27 .kill_sb = autofs4_kill_sb,
28}; 28};
29 29
30static int __init init_autofs4_fs(void) 30static int __init init_autofs4_fs(void)
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c
index 800ce876caec..ce7c0f1dd529 100644
--- a/fs/autofs4/inode.c
+++ b/fs/autofs4/inode.c
@@ -96,9 +96,12 @@ void autofs4_free_ino(struct autofs_info *ino)
96 */ 96 */
97static void autofs4_force_release(struct autofs_sb_info *sbi) 97static void autofs4_force_release(struct autofs_sb_info *sbi)
98{ 98{
99 struct dentry *this_parent = sbi->root; 99 struct dentry *this_parent = sbi->sb->s_root;
100 struct list_head *next; 100 struct list_head *next;
101 101
102 if (!sbi->sb->s_root)
103 return;
104
102 spin_lock(&dcache_lock); 105 spin_lock(&dcache_lock);
103repeat: 106repeat:
104 next = this_parent->d_subdirs.next; 107 next = this_parent->d_subdirs.next;
@@ -127,7 +130,7 @@ resume:
127 spin_lock(&dcache_lock); 130 spin_lock(&dcache_lock);
128 } 131 }
129 132
130 if (this_parent != sbi->root) { 133 if (this_parent != sbi->sb->s_root) {
131 struct dentry *dentry = this_parent; 134 struct dentry *dentry = this_parent;
132 135
133 next = this_parent->d_u.d_child.next; 136 next = this_parent->d_u.d_child.next;
@@ -140,18 +143,20 @@ resume:
140 goto resume; 143 goto resume;
141 } 144 }
142 spin_unlock(&dcache_lock); 145 spin_unlock(&dcache_lock);
143
144 dput(sbi->root);
145 sbi->root = NULL;
146 shrink_dcache_sb(sbi->sb);
147
148 return;
149} 146}
150 147
151static void autofs4_put_super(struct super_block *sb) 148void autofs4_kill_sb(struct super_block *sb)
152{ 149{
153 struct autofs_sb_info *sbi = autofs4_sbi(sb); 150 struct autofs_sb_info *sbi = autofs4_sbi(sb);
154 151
152 /*
153 * In the event of a failure in get_sb_nodev the superblock
154 * info is not present so nothing else has been setup, so
155 * just exit when we are called from deactivate_super.
156 */
157 if (!sbi)
158 return;
159
155 sb->s_fs_info = NULL; 160 sb->s_fs_info = NULL;
156 161
157 if ( !sbi->catatonic ) 162 if ( !sbi->catatonic )
@@ -163,6 +168,7 @@ static void autofs4_put_super(struct super_block *sb)
163 kfree(sbi); 168 kfree(sbi);
164 169
165 DPRINTK("shutting down"); 170 DPRINTK("shutting down");
171 kill_anon_super(sb);
166} 172}
167 173
168static int autofs4_show_options(struct seq_file *m, struct vfsmount *mnt) 174static int autofs4_show_options(struct seq_file *m, struct vfsmount *mnt)
@@ -189,7 +195,6 @@ static int autofs4_show_options(struct seq_file *m, struct vfsmount *mnt)
189} 195}
190 196
191static struct super_operations autofs4_sops = { 197static struct super_operations autofs4_sops = {
192 .put_super = autofs4_put_super,
193 .statfs = simple_statfs, 198 .statfs = simple_statfs,
194 .show_options = autofs4_show_options, 199 .show_options = autofs4_show_options,
195}; 200};
@@ -315,9 +320,9 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
315 320
316 s->s_fs_info = sbi; 321 s->s_fs_info = sbi;
317 sbi->magic = AUTOFS_SBI_MAGIC; 322 sbi->magic = AUTOFS_SBI_MAGIC;
318 sbi->root = NULL;
319 sbi->pipefd = -1; 323 sbi->pipefd = -1;
320 sbi->catatonic = 0; 324 sbi->pipe = NULL;
325 sbi->catatonic = 1;
321 sbi->exp_timeout = 0; 326 sbi->exp_timeout = 0;
322 sbi->oz_pgrp = process_group(current); 327 sbi->oz_pgrp = process_group(current);
323 sbi->sb = s; 328 sbi->sb = s;
@@ -395,13 +400,7 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
395 goto fail_fput; 400 goto fail_fput;
396 sbi->pipe = pipe; 401 sbi->pipe = pipe;
397 sbi->pipefd = pipefd; 402 sbi->pipefd = pipefd;
398 403 sbi->catatonic = 0;
399 /*
400 * Take a reference to the root dentry so we get a chance to
401 * clean up the dentry tree on umount.
402 * See autofs4_force_release.
403 */
404 sbi->root = dget(root);
405 404
406 /* 405 /*
407 * Success! Install the root dentry now to indicate completion. 406 * Success! Install the root dentry now to indicate completion.
@@ -426,6 +425,8 @@ fail_ino:
426 kfree(ino); 425 kfree(ino);
427fail_free: 426fail_free:
428 kfree(sbi); 427 kfree(sbi);
428 s->s_fs_info = NULL;
429 kill_anon_super(s);
429fail_unlock: 430fail_unlock:
430 return -EINVAL; 431 return -EINVAL;
431} 432}
diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
index ce103e7b0bc3..1e4a539f4417 100644
--- a/fs/autofs4/waitq.c
+++ b/fs/autofs4/waitq.c
@@ -41,11 +41,8 @@ void autofs4_catatonic_mode(struct autofs_sb_info *sbi)
41 wake_up_interruptible(&wq->queue); 41 wake_up_interruptible(&wq->queue);
42 wq = nwq; 42 wq = nwq;
43 } 43 }
44 if (sbi->pipe) { 44 fput(sbi->pipe); /* Close the pipe */
45 fput(sbi->pipe); /* Close the pipe */ 45 sbi->pipe = NULL;
46 sbi->pipe = NULL;
47 }
48 shrink_dcache_sb(sbi->sb);
49} 46}
50 47
51static int autofs4_write(struct file *file, const void *addr, int bytes) 48static int autofs4_write(struct file *file, const void *addr, int bytes)
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 06435f3665f4..79b05a1a4365 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1152,7 +1152,7 @@ static int dump_write(struct file *file, const void *addr, int nr)
1152static int dump_seek(struct file *file, loff_t off) 1152static int dump_seek(struct file *file, loff_t off)
1153{ 1153{
1154 if (file->f_op->llseek && file->f_op->llseek != no_llseek) { 1154 if (file->f_op->llseek && file->f_op->llseek != no_llseek) {
1155 if (file->f_op->llseek(file, off, 1) != off) 1155 if (file->f_op->llseek(file, off, SEEK_CUR) < 0)
1156 return 0; 1156 return 0;
1157 } else { 1157 } else {
1158 char *buf = (char *)get_zeroed_page(GFP_KERNEL); 1158 char *buf = (char *)get_zeroed_page(GFP_KERNEL);
@@ -1220,7 +1220,7 @@ static int notesize(struct memelfnote *en)
1220 1220
1221static int alignfile(struct file *file, loff_t *foffset) 1221static int alignfile(struct file *file, loff_t *foffset)
1222{ 1222{
1223 char buf[4] = { 0, }; 1223 static const char buf[4] = { 0, };
1224 DUMP_WRITE(buf, roundup(*foffset, 4) - *foffset, foffset); 1224 DUMP_WRITE(buf, roundup(*foffset, 4) - *foffset, foffset);
1225 return 1; 1225 return 1;
1226} 1226}
@@ -1569,7 +1569,8 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file)
1569 1569
1570 DUMP_WRITE(elf, sizeof(*elf)); 1570 DUMP_WRITE(elf, sizeof(*elf));
1571 offset += sizeof(*elf); /* Elf header */ 1571 offset += sizeof(*elf); /* Elf header */
1572 offset += (segs+1) * sizeof(struct elf_phdr); /* Program headers */ 1572 offset += (segs + 1) * sizeof(struct elf_phdr); /* Program headers */
1573 foffset = offset;
1573 1574
1574 /* Write notes phdr entry */ 1575 /* Write notes phdr entry */
1575 { 1576 {
@@ -1586,8 +1587,6 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file)
1586 DUMP_WRITE(&phdr, sizeof(phdr)); 1587 DUMP_WRITE(&phdr, sizeof(phdr));
1587 } 1588 }
1588 1589
1589 foffset = offset;
1590
1591 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE); 1590 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
1592 1591
1593 /* Write program headers for segments dump */ 1592 /* Write program headers for segments dump */
@@ -1612,7 +1611,6 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file)
1612 phdr.p_align = ELF_EXEC_PAGESIZE; 1611 phdr.p_align = ELF_EXEC_PAGESIZE;
1613 1612
1614 DUMP_WRITE(&phdr, sizeof(phdr)); 1613 DUMP_WRITE(&phdr, sizeof(phdr));
1615 foffset += sizeof(phdr);
1616 } 1614 }
1617 1615
1618#ifdef ELF_CORE_WRITE_EXTRA_PHDRS 1616#ifdef ELF_CORE_WRITE_EXTRA_PHDRS
diff --git a/fs/bio.c b/fs/bio.c
index 8f93e939f213..f95c8749499f 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -79,7 +79,6 @@ static struct bio_set *fs_bio_set;
79static inline struct bio_vec *bvec_alloc_bs(gfp_t gfp_mask, int nr, unsigned long *idx, struct bio_set *bs) 79static inline struct bio_vec *bvec_alloc_bs(gfp_t gfp_mask, int nr, unsigned long *idx, struct bio_set *bs)
80{ 80{
81 struct bio_vec *bvl; 81 struct bio_vec *bvl;
82 struct biovec_slab *bp;
83 82
84 /* 83 /*
85 * see comment near bvec_array define! 84 * see comment near bvec_array define!
@@ -98,10 +97,12 @@ static inline struct bio_vec *bvec_alloc_bs(gfp_t gfp_mask, int nr, unsigned lon
98 * idx now points to the pool we want to allocate from 97 * idx now points to the pool we want to allocate from
99 */ 98 */
100 99
101 bp = bvec_slabs + *idx;
102 bvl = mempool_alloc(bs->bvec_pools[*idx], gfp_mask); 100 bvl = mempool_alloc(bs->bvec_pools[*idx], gfp_mask);
103 if (bvl) 101 if (bvl) {
102 struct biovec_slab *bp = bvec_slabs + *idx;
103
104 memset(bvl, 0, bp->nr_vecs * sizeof(struct bio_vec)); 104 memset(bvl, 0, bp->nr_vecs * sizeof(struct bio_vec));
105 }
105 106
106 return bvl; 107 return bvl;
107} 108}
@@ -166,7 +167,7 @@ struct bio *bio_alloc_bioset(gfp_t gfp_mask, int nr_iovecs, struct bio_set *bs)
166 167
167 bio_init(bio); 168 bio_init(bio);
168 if (likely(nr_iovecs)) { 169 if (likely(nr_iovecs)) {
169 unsigned long idx; 170 unsigned long idx = 0; /* shut up gcc */
170 171
171 bvl = bvec_alloc_bs(gfp_mask, nr_iovecs, &idx, bs); 172 bvl = bvec_alloc_bs(gfp_mask, nr_iovecs, &idx, bs);
172 if (unlikely(!bvl)) { 173 if (unlikely(!bvl)) {
diff --git a/fs/block_dev.c b/fs/block_dev.c
index bc8f27cc4483..36c0e7af9d0f 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -642,34 +642,47 @@ static void free_bd_holder(struct bd_holder *bo)
642} 642}
643 643
644/** 644/**
645 * find_bd_holder - find matching struct bd_holder from the block device
646 *
647 * @bdev: struct block device to be searched
648 * @bo: target struct bd_holder
649 *
650 * Returns matching entry with @bo in @bdev->bd_holder_list.
651 * If found, increment the reference count and return the pointer.
652 * If not found, returns NULL.
653 */
654static struct bd_holder *find_bd_holder(struct block_device *bdev,
655 struct bd_holder *bo)
656{
657 struct bd_holder *tmp;
658
659 list_for_each_entry(tmp, &bdev->bd_holder_list, list)
660 if (tmp->sdir == bo->sdir) {
661 tmp->count++;
662 return tmp;
663 }
664
665 return NULL;
666}
667
668/**
645 * add_bd_holder - create sysfs symlinks for bd_claim() relationship 669 * add_bd_holder - create sysfs symlinks for bd_claim() relationship
646 * 670 *
647 * @bdev: block device to be bd_claimed 671 * @bdev: block device to be bd_claimed
648 * @bo: preallocated and initialized by alloc_bd_holder() 672 * @bo: preallocated and initialized by alloc_bd_holder()
649 * 673 *
650 * If there is no matching entry with @bo in @bdev->bd_holder_list, 674 * Add @bo to @bdev->bd_holder_list, create symlinks.
651 * add @bo to the list, create symlinks.
652 * 675 *
653 * Returns 0 if symlinks are created or already there. 676 * Returns 0 if symlinks are created.
654 * Returns -ve if something fails and @bo can be freed. 677 * Returns -ve if something fails.
655 */ 678 */
656static int add_bd_holder(struct block_device *bdev, struct bd_holder *bo) 679static int add_bd_holder(struct block_device *bdev, struct bd_holder *bo)
657{ 680{
658 struct bd_holder *tmp;
659 int ret; 681 int ret;
660 682
661 if (!bo) 683 if (!bo)
662 return -EINVAL; 684 return -EINVAL;
663 685
664 list_for_each_entry(tmp, &bdev->bd_holder_list, list) {
665 if (tmp->sdir == bo->sdir) {
666 tmp->count++;
667 /* We've already done what we need to do here. */
668 free_bd_holder(bo);
669 return 0;
670 }
671 }
672
673 if (!bd_holder_grab_dirs(bdev, bo)) 686 if (!bd_holder_grab_dirs(bdev, bo))
674 return -EBUSY; 687 return -EBUSY;
675 688
@@ -740,7 +753,7 @@ static int bd_claim_by_kobject(struct block_device *bdev, void *holder,
740 struct kobject *kobj) 753 struct kobject *kobj)
741{ 754{
742 int res; 755 int res;
743 struct bd_holder *bo; 756 struct bd_holder *bo, *found;
744 757
745 if (!kobj) 758 if (!kobj)
746 return -EINVAL; 759 return -EINVAL;
@@ -751,9 +764,16 @@ static int bd_claim_by_kobject(struct block_device *bdev, void *holder,
751 764
752 mutex_lock_nested(&bdev->bd_mutex, BD_MUTEX_PARTITION); 765 mutex_lock_nested(&bdev->bd_mutex, BD_MUTEX_PARTITION);
753 res = bd_claim(bdev, holder); 766 res = bd_claim(bdev, holder);
754 if (res == 0) 767 if (res == 0) {
755 res = add_bd_holder(bdev, bo); 768 found = find_bd_holder(bdev, bo);
756 if (res) 769 if (found == NULL) {
770 res = add_bd_holder(bdev, bo);
771 if (res)
772 bd_release(bdev);
773 }
774 }
775
776 if (res || found)
757 free_bd_holder(bo); 777 free_bd_holder(bo);
758 mutex_unlock(&bdev->bd_mutex); 778 mutex_unlock(&bdev->bd_mutex);
759 779
@@ -1131,6 +1151,8 @@ static int blkdev_open(struct inode * inode, struct file * filp)
1131 filp->f_flags |= O_LARGEFILE; 1151 filp->f_flags |= O_LARGEFILE;
1132 1152
1133 bdev = bd_acquire(inode); 1153 bdev = bd_acquire(inode);
1154 if (bdev == NULL)
1155 return -ENOMEM;
1134 1156
1135 res = do_open(bdev, filp, BD_MUTEX_NORMAL); 1157 res = do_open(bdev, filp, BD_MUTEX_NORMAL);
1136 if (res) 1158 if (res)
diff --git a/fs/buffer.c b/fs/buffer.c
index eeb8ac1aa856..35527dca1dbc 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -452,6 +452,7 @@ static void end_buffer_async_write(struct buffer_head *bh, int uptodate)
452 bdevname(bh->b_bdev, b)); 452 bdevname(bh->b_bdev, b));
453 } 453 }
454 set_bit(AS_EIO, &page->mapping->flags); 454 set_bit(AS_EIO, &page->mapping->flags);
455 set_buffer_write_io_error(bh);
455 clear_buffer_uptodate(bh); 456 clear_buffer_uptodate(bh);
456 SetPageError(page); 457 SetPageError(page);
457 } 458 }
@@ -571,6 +572,10 @@ EXPORT_SYMBOL(mark_buffer_async_write);
571static inline void __remove_assoc_queue(struct buffer_head *bh) 572static inline void __remove_assoc_queue(struct buffer_head *bh)
572{ 573{
573 list_del_init(&bh->b_assoc_buffers); 574 list_del_init(&bh->b_assoc_buffers);
575 WARN_ON(!bh->b_assoc_map);
576 if (buffer_write_io_error(bh))
577 set_bit(AS_EIO, &bh->b_assoc_map->flags);
578 bh->b_assoc_map = NULL;
574} 579}
575 580
576int inode_has_buffers(struct inode *inode) 581int inode_has_buffers(struct inode *inode)
@@ -669,6 +674,7 @@ void mark_buffer_dirty_inode(struct buffer_head *bh, struct inode *inode)
669 spin_lock(&buffer_mapping->private_lock); 674 spin_lock(&buffer_mapping->private_lock);
670 list_move_tail(&bh->b_assoc_buffers, 675 list_move_tail(&bh->b_assoc_buffers,
671 &mapping->private_list); 676 &mapping->private_list);
677 bh->b_assoc_map = mapping;
672 spin_unlock(&buffer_mapping->private_lock); 678 spin_unlock(&buffer_mapping->private_lock);
673 } 679 }
674} 680}
@@ -765,7 +771,7 @@ static int fsync_buffers_list(spinlock_t *lock, struct list_head *list)
765 spin_lock(lock); 771 spin_lock(lock);
766 while (!list_empty(list)) { 772 while (!list_empty(list)) {
767 bh = BH_ENTRY(list->next); 773 bh = BH_ENTRY(list->next);
768 list_del_init(&bh->b_assoc_buffers); 774 __remove_assoc_queue(bh);
769 if (buffer_dirty(bh) || buffer_locked(bh)) { 775 if (buffer_dirty(bh) || buffer_locked(bh)) {
770 list_add(&bh->b_assoc_buffers, &tmp); 776 list_add(&bh->b_assoc_buffers, &tmp);
771 if (buffer_dirty(bh)) { 777 if (buffer_dirty(bh)) {
@@ -786,7 +792,7 @@ static int fsync_buffers_list(spinlock_t *lock, struct list_head *list)
786 792
787 while (!list_empty(&tmp)) { 793 while (!list_empty(&tmp)) {
788 bh = BH_ENTRY(tmp.prev); 794 bh = BH_ENTRY(tmp.prev);
789 __remove_assoc_queue(bh); 795 list_del_init(&bh->b_assoc_buffers);
790 get_bh(bh); 796 get_bh(bh);
791 spin_unlock(lock); 797 spin_unlock(lock);
792 wait_on_buffer(bh); 798 wait_on_buffer(bh);
@@ -1042,8 +1048,21 @@ grow_buffers(struct block_device *bdev, sector_t block, int size)
1042 } while ((size << sizebits) < PAGE_SIZE); 1048 } while ((size << sizebits) < PAGE_SIZE);
1043 1049
1044 index = block >> sizebits; 1050 index = block >> sizebits;
1045 block = index << sizebits;
1046 1051
1052 /*
1053 * Check for a block which wants to lie outside our maximum possible
1054 * pagecache index. (this comparison is done using sector_t types).
1055 */
1056 if (unlikely(index != block >> sizebits)) {
1057 char b[BDEVNAME_SIZE];
1058
1059 printk(KERN_ERR "%s: requested out-of-range block %llu for "
1060 "device %s\n",
1061 __FUNCTION__, (unsigned long long)block,
1062 bdevname(bdev, b));
1063 return -EIO;
1064 }
1065 block = index << sizebits;
1047 /* Create a page with the proper size buffers.. */ 1066 /* Create a page with the proper size buffers.. */
1048 page = grow_dev_page(bdev, block, index, size); 1067 page = grow_dev_page(bdev, block, index, size);
1049 if (!page) 1068 if (!page)
@@ -1070,12 +1089,16 @@ __getblk_slow(struct block_device *bdev, sector_t block, int size)
1070 1089
1071 for (;;) { 1090 for (;;) {
1072 struct buffer_head * bh; 1091 struct buffer_head * bh;
1092 int ret;
1073 1093
1074 bh = __find_get_block(bdev, block, size); 1094 bh = __find_get_block(bdev, block, size);
1075 if (bh) 1095 if (bh)
1076 return bh; 1096 return bh;
1077 1097
1078 if (!grow_buffers(bdev, block, size)) 1098 ret = grow_buffers(bdev, block, size);
1099 if (ret < 0)
1100 return NULL;
1101 if (ret == 0)
1079 free_more_memory(); 1102 free_more_memory();
1080 } 1103 }
1081} 1104}
@@ -1150,6 +1173,7 @@ void __bforget(struct buffer_head *bh)
1150 1173
1151 spin_lock(&buffer_mapping->private_lock); 1174 spin_lock(&buffer_mapping->private_lock);
1152 list_del_init(&bh->b_assoc_buffers); 1175 list_del_init(&bh->b_assoc_buffers);
1176 bh->b_assoc_map = NULL;
1153 spin_unlock(&buffer_mapping->private_lock); 1177 spin_unlock(&buffer_mapping->private_lock);
1154 } 1178 }
1155 __brelse(bh); 1179 __brelse(bh);
@@ -1837,6 +1861,7 @@ static int __block_prepare_write(struct inode *inode, struct page *page,
1837 clear_buffer_new(bh); 1861 clear_buffer_new(bh);
1838 kaddr = kmap_atomic(page, KM_USER0); 1862 kaddr = kmap_atomic(page, KM_USER0);
1839 memset(kaddr+block_start, 0, bh->b_size); 1863 memset(kaddr+block_start, 0, bh->b_size);
1864 flush_dcache_page(page);
1840 kunmap_atomic(kaddr, KM_USER0); 1865 kunmap_atomic(kaddr, KM_USER0);
1841 set_buffer_uptodate(bh); 1866 set_buffer_uptodate(bh);
1842 mark_buffer_dirty(bh); 1867 mark_buffer_dirty(bh);
@@ -2343,6 +2368,7 @@ failed:
2343 */ 2368 */
2344 kaddr = kmap_atomic(page, KM_USER0); 2369 kaddr = kmap_atomic(page, KM_USER0);
2345 memset(kaddr, 0, PAGE_CACHE_SIZE); 2370 memset(kaddr, 0, PAGE_CACHE_SIZE);
2371 flush_dcache_page(page);
2346 kunmap_atomic(kaddr, KM_USER0); 2372 kunmap_atomic(kaddr, KM_USER0);
2347 SetPageUptodate(page); 2373 SetPageUptodate(page);
2348 set_page_dirty(page); 2374 set_page_dirty(page);
diff --git a/fs/cifs/CHANGES b/fs/cifs/CHANGES
index 1eb9a2ec0a3b..0b3c37ef52e0 100644
--- a/fs/cifs/CHANGES
+++ b/fs/cifs/CHANGES
@@ -1,6 +1,11 @@
1Version 1.46 1Version 1.46
2------------ 2------------
3Support deep tree mounts. Better support OS/2, Win9x (DOS) time stamps. 3Support deep tree mounts. Better support OS/2, Win9x (DOS) time stamps.
4Allow null user to be specified on mount ("username="). Do not return
5EINVAL on readdir when filldir fails due to overwritten blocksize
6(fixes FC problem). Return error in rename 2nd attempt retry (ie report
7if rename by handle also fails, after rename by path fails, we were
8not reporting whether the retry worked or not).
4 9
5Version 1.45 10Version 1.45
6------------ 11------------
diff --git a/fs/cifs/cifsacl.h b/fs/cifs/cifsacl.h
index d0776ac2b804..5eff35d6e564 100644
--- a/fs/cifs/cifsacl.h
+++ b/fs/cifs/cifsacl.h
@@ -31,8 +31,8 @@ struct cifs_sid {
31} __attribute__((packed)); 31} __attribute__((packed));
32 32
33/* everyone */ 33/* everyone */
34extern const struct cifs_sid sid_everyone; 34/* extern const struct cifs_sid sid_everyone;*/
35/* group users */ 35/* group users */
36extern const struct cifs_sid sid_user; 36/* extern const struct cifs_sid sid_user;*/
37 37
38#endif /* _CIFSACL_H */ 38#endif /* _CIFSACL_H */
diff --git a/fs/cifs/cifsencrypt.h b/fs/cifs/cifsencrypt.h
index 03e359b32861..152fa2dcfc6c 100644
--- a/fs/cifs/cifsencrypt.h
+++ b/fs/cifs/cifsencrypt.h
@@ -27,8 +27,6 @@ extern void mdfour(unsigned char *out, unsigned char *in, int n);
27/* smbdes.c */ 27/* smbdes.c */
28extern void E_P16(unsigned char *p14, unsigned char *p16); 28extern void E_P16(unsigned char *p14, unsigned char *p16);
29extern void E_P24(unsigned char *p21, unsigned char *c8, unsigned char *p24); 29extern void E_P24(unsigned char *p21, unsigned char *c8, unsigned char *p24);
30extern void D_P16(unsigned char *p14, unsigned char *in, unsigned char *out);
31extern void E_old_pw_hash(unsigned char *, unsigned char *, unsigned char *);
32 30
33 31
34 32
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index c00c654f2e11..84976cdbe713 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -63,6 +63,7 @@ extern struct task_struct * oplockThread; /* remove sparse warning */
63struct task_struct * oplockThread = NULL; 63struct task_struct * oplockThread = NULL;
64extern struct task_struct * dnotifyThread; /* remove sparse warning */ 64extern struct task_struct * dnotifyThread; /* remove sparse warning */
65struct task_struct * dnotifyThread = NULL; 65struct task_struct * dnotifyThread = NULL;
66static struct super_operations cifs_super_ops;
66unsigned int CIFSMaxBufSize = CIFS_MAX_MSGSIZE; 67unsigned int CIFSMaxBufSize = CIFS_MAX_MSGSIZE;
67module_param(CIFSMaxBufSize, int, 0); 68module_param(CIFSMaxBufSize, int, 0);
68MODULE_PARM_DESC(CIFSMaxBufSize,"Network buffer size (not including header). Default: 16384 Range: 8192 to 130048"); 69MODULE_PARM_DESC(CIFSMaxBufSize,"Network buffer size (not including header). Default: 16384 Range: 8192 to 130048");
@@ -198,10 +199,12 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
198 /* Only need to call the old QFSInfo if failed 199 /* Only need to call the old QFSInfo if failed
199 on newer one */ 200 on newer one */
200 if(rc) 201 if(rc)
201 rc = CIFSSMBQFSInfo(xid, pTcon, buf); 202 if(pTcon->ses->capabilities & CAP_NT_SMBS)
203 rc = CIFSSMBQFSInfo(xid, pTcon, buf); /* not supported by OS2 */
202 204
203 /* Old Windows servers do not support level 103, retry with level 205 /* Some old Windows servers also do not support level 103, retry with
204 one if old server failed the previous call */ 206 older level one if old server failed the previous call or we
207 bypassed it because we detected that this was an older LANMAN sess */
205 if(rc) 208 if(rc)
206 rc = SMBOldQFSInfo(xid, pTcon, buf); 209 rc = SMBOldQFSInfo(xid, pTcon, buf);
207 /* 210 /*
@@ -435,13 +438,21 @@ static void cifs_umount_begin(struct vfsmount * vfsmnt, int flags)
435 return; 438 return;
436} 439}
437 440
441#ifdef CONFIG_CIFS_STATS2
442static int cifs_show_stats(struct seq_file *s, struct vfsmount *mnt)
443{
444 /* BB FIXME */
445 return 0;
446}
447#endif
448
438static int cifs_remount(struct super_block *sb, int *flags, char *data) 449static int cifs_remount(struct super_block *sb, int *flags, char *data)
439{ 450{
440 *flags |= MS_NODIRATIME; 451 *flags |= MS_NODIRATIME;
441 return 0; 452 return 0;
442} 453}
443 454
444struct super_operations cifs_super_ops = { 455static struct super_operations cifs_super_ops = {
445 .read_inode = cifs_read_inode, 456 .read_inode = cifs_read_inode,
446 .put_super = cifs_put_super, 457 .put_super = cifs_put_super,
447 .statfs = cifs_statfs, 458 .statfs = cifs_statfs,
@@ -454,6 +465,9 @@ struct super_operations cifs_super_ops = {
454 .show_options = cifs_show_options, 465 .show_options = cifs_show_options,
455 .umount_begin = cifs_umount_begin, 466 .umount_begin = cifs_umount_begin,
456 .remount_fs = cifs_remount, 467 .remount_fs = cifs_remount,
468#ifdef CONFIG_CIFS_STATS2
469 .show_stats = cifs_show_stats,
470#endif
457}; 471};
458 472
459static int 473static int
@@ -495,7 +509,7 @@ static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
495static loff_t cifs_llseek(struct file *file, loff_t offset, int origin) 509static loff_t cifs_llseek(struct file *file, loff_t offset, int origin)
496{ 510{
497 /* origin == SEEK_END => we must revalidate the cached file length */ 511 /* origin == SEEK_END => we must revalidate the cached file length */
498 if (origin == 2) { 512 if (origin == SEEK_END) {
499 int retval = cifs_revalidate(file->f_dentry); 513 int retval = cifs_revalidate(file->f_dentry);
500 if (retval < 0) 514 if (retval < 0)
501 return (loff_t)retval; 515 return (loff_t)retval;
@@ -903,7 +917,7 @@ init_cifs(void)
903#ifdef CONFIG_PROC_FS 917#ifdef CONFIG_PROC_FS
904 cifs_proc_init(); 918 cifs_proc_init();
905#endif 919#endif
906 INIT_LIST_HEAD(&GlobalServerList); /* BB not implemented yet */ 920/* INIT_LIST_HEAD(&GlobalServerList);*/ /* BB not implemented yet */
907 INIT_LIST_HEAD(&GlobalSMBSessionList); 921 INIT_LIST_HEAD(&GlobalSMBSessionList);
908 INIT_LIST_HEAD(&GlobalTreeConnectionList); 922 INIT_LIST_HEAD(&GlobalTreeConnectionList);
909 INIT_LIST_HEAD(&GlobalOplock_Q); 923 INIT_LIST_HEAD(&GlobalOplock_Q);
@@ -931,6 +945,7 @@ init_cifs(void)
931 GlobalCurrentXid = 0; 945 GlobalCurrentXid = 0;
932 GlobalTotalActiveXid = 0; 946 GlobalTotalActiveXid = 0;
933 GlobalMaxActiveXid = 0; 947 GlobalMaxActiveXid = 0;
948 memset(Local_System_Name, 0, 15);
934 rwlock_init(&GlobalSMBSeslock); 949 rwlock_init(&GlobalSMBSeslock);
935 spin_lock_init(&GlobalMid_Lock); 950 spin_lock_init(&GlobalMid_Lock);
936 951
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h
index bea875d9a46a..a243f779b363 100644
--- a/fs/cifs/cifsfs.h
+++ b/fs/cifs/cifsfs.h
@@ -36,7 +36,7 @@ extern const struct address_space_operations cifs_addr_ops;
36extern const struct address_space_operations cifs_addr_ops_smallbuf; 36extern const struct address_space_operations cifs_addr_ops_smallbuf;
37 37
38/* Functions related to super block operations */ 38/* Functions related to super block operations */
39extern struct super_operations cifs_super_ops; 39/* extern struct super_operations cifs_super_ops;*/
40extern void cifs_read_inode(struct inode *); 40extern void cifs_read_inode(struct inode *);
41extern void cifs_delete_inode(struct inode *); 41extern void cifs_delete_inode(struct inode *);
42/* extern void cifs_write_inode(struct inode *); *//* BB not needed yet */ 42/* extern void cifs_write_inode(struct inode *); *//* BB not needed yet */
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index b24006c47df1..74d3ccbb103b 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -153,7 +153,7 @@ struct TCP_Server_Info {
153 char sessid[4]; /* unique token id for this session */ 153 char sessid[4]; /* unique token id for this session */
154 /* (returned on Negotiate */ 154 /* (returned on Negotiate */
155 int capabilities; /* allow selective disabling of caps by smb sess */ 155 int capabilities; /* allow selective disabling of caps by smb sess */
156 __u16 timeZone; 156 int timeAdj; /* Adjust for difference in server time zone in sec */
157 __u16 CurrentMid; /* multiplex id - rotating counter */ 157 __u16 CurrentMid; /* multiplex id - rotating counter */
158 char cryptKey[CIFS_CRYPTO_KEY_SIZE]; 158 char cryptKey[CIFS_CRYPTO_KEY_SIZE];
159 /* 16th byte of RFC1001 workstation name is always null */ 159 /* 16th byte of RFC1001 workstation name is always null */
@@ -203,9 +203,14 @@ struct cifsSesInfo {
203 char * domainName; 203 char * domainName;
204 char * password; 204 char * password;
205}; 205};
206/* session flags */ 206/* no more than one of the following three session flags may be set */
207#define CIFS_SES_NT4 1 207#define CIFS_SES_NT4 1
208 208#define CIFS_SES_OS2 2
209#define CIFS_SES_W9X 4
210/* following flag is set for old servers such as OS2 (and Win95?)
211 which do not negotiate NTLM or POSIX dialects, but instead
212 negotiate one of the older LANMAN dialects */
213#define CIFS_SES_LANMAN 8
209/* 214/*
210 * there is one of these for each connection to a resource on a particular 215 * there is one of these for each connection to a resource on a particular
211 * session 216 * session
@@ -512,7 +517,8 @@ require use of the stronger protocol */
512 * This list helps improve performance and eliminate the messages indicating 517 * This list helps improve performance and eliminate the messages indicating
513 * that we had a communications error talking to the server in this list. 518 * that we had a communications error talking to the server in this list.
514 */ 519 */
515GLOBAL_EXTERN struct servers_not_supported *NotSuppList; /*@z4a */ 520/* Feature not supported */
521/* GLOBAL_EXTERN struct servers_not_supported *NotSuppList; */
516 522
517/* 523/*
518 * The following is a hash table of all the users we know about. 524 * The following is a hash table of all the users we know about.
@@ -568,7 +574,6 @@ GLOBAL_EXTERN unsigned int lookupCacheEnabled;
568GLOBAL_EXTERN unsigned int extended_security; /* if on, session setup sent 574GLOBAL_EXTERN unsigned int extended_security; /* if on, session setup sent
569 with more secure ntlmssp2 challenge/resp */ 575 with more secure ntlmssp2 challenge/resp */
570GLOBAL_EXTERN unsigned int sign_CIFS_PDUs; /* enable smb packet signing */ 576GLOBAL_EXTERN unsigned int sign_CIFS_PDUs; /* enable smb packet signing */
571GLOBAL_EXTERN unsigned int secFlags;
572GLOBAL_EXTERN unsigned int linuxExtEnabled;/*enable Linux/Unix CIFS extensions*/ 577GLOBAL_EXTERN unsigned int linuxExtEnabled;/*enable Linux/Unix CIFS extensions*/
573GLOBAL_EXTERN unsigned int CIFSMaxBufSize; /* max size not including hdr */ 578GLOBAL_EXTERN unsigned int CIFSMaxBufSize; /* max size not including hdr */
574GLOBAL_EXTERN unsigned int cifs_min_rcv; /* min size of big ntwrk buf pool */ 579GLOBAL_EXTERN unsigned int cifs_min_rcv; /* min size of big ntwrk buf pool */
diff --git a/fs/cifs/cifspdu.h b/fs/cifs/cifspdu.h
index 81df2bf8e75a..6df9dadba647 100644
--- a/fs/cifs/cifspdu.h
+++ b/fs/cifs/cifspdu.h
@@ -26,7 +26,8 @@
26 26
27#ifdef CONFIG_CIFS_WEAK_PW_HASH 27#ifdef CONFIG_CIFS_WEAK_PW_HASH
28#define LANMAN_PROT 0 28#define LANMAN_PROT 0
29#define CIFS_PROT 1 29#define LANMAN2_PROT 1
30#define CIFS_PROT 2
30#else 31#else
31#define CIFS_PROT 0 32#define CIFS_PROT 0
32#endif 33#endif
@@ -408,6 +409,8 @@ typedef struct negotiate_req {
408 409
409/* Dialect index is 13 for LANMAN */ 410/* Dialect index is 13 for LANMAN */
410 411
412#define MIN_TZ_ADJ (15 * 60) /* minimum grid for timezones in seconds */
413
411typedef struct lanman_neg_rsp { 414typedef struct lanman_neg_rsp {
412 struct smb_hdr hdr; /* wct = 13 */ 415 struct smb_hdr hdr; /* wct = 13 */
413 __le16 DialectIndex; 416 __le16 DialectIndex;
@@ -417,7 +420,10 @@ typedef struct lanman_neg_rsp {
417 __le16 MaxNumberVcs; 420 __le16 MaxNumberVcs;
418 __le16 RawMode; 421 __le16 RawMode;
419 __le32 SessionKey; 422 __le32 SessionKey;
420 __le32 ServerTime; 423 struct {
424 __le16 Time;
425 __le16 Date;
426 } __attribute__((packed)) SrvTime;
421 __le16 ServerTimeZone; 427 __le16 ServerTimeZone;
422 __le16 EncryptionKeyLength; 428 __le16 EncryptionKeyLength;
423 __le16 Reserved; 429 __le16 Reserved;
@@ -674,7 +680,7 @@ typedef union smb_com_tree_disconnect { /* as an altetnative can use flag on
674typedef struct smb_com_close_req { 680typedef struct smb_com_close_req {
675 struct smb_hdr hdr; /* wct = 3 */ 681 struct smb_hdr hdr; /* wct = 3 */
676 __u16 FileID; 682 __u16 FileID;
677 __u32 LastWriteTime; /* should be zero */ 683 __u32 LastWriteTime; /* should be zero or -1 */
678 __u16 ByteCount; /* 0 */ 684 __u16 ByteCount; /* 0 */
679} __attribute__((packed)) CLOSE_REQ; 685} __attribute__((packed)) CLOSE_REQ;
680 686
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index b35c55c3c8bb..f1f8225102f0 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -50,12 +50,12 @@ extern int SendReceive(const unsigned int /* xid */ , struct cifsSesInfo *,
50extern int SendReceive2(const unsigned int /* xid */ , struct cifsSesInfo *, 50extern int SendReceive2(const unsigned int /* xid */ , struct cifsSesInfo *,
51 struct kvec *, int /* nvec to send */, 51 struct kvec *, int /* nvec to send */,
52 int * /* type of buf returned */ , const int long_op); 52 int * /* type of buf returned */ , const int long_op);
53extern int SendReceiveBlockingLock(const unsigned int /* xid */ , struct cifsTconInfo *, 53extern int SendReceiveBlockingLock(const unsigned int /* xid */ ,
54 struct cifsTconInfo *,
54 struct smb_hdr * /* input */ , 55 struct smb_hdr * /* input */ ,
55 struct smb_hdr * /* out */ , 56 struct smb_hdr * /* out */ ,
56 int * /* bytes returned */); 57 int * /* bytes returned */);
57extern int checkSMBhdr(struct smb_hdr *smb, __u16 mid); 58extern int checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length);
58extern int checkSMB(struct smb_hdr *smb, __u16 mid, int length);
59extern int is_valid_oplock_break(struct smb_hdr *smb, struct TCP_Server_Info *); 59extern int is_valid_oplock_break(struct smb_hdr *smb, struct TCP_Server_Info *);
60extern int is_size_safe_to_change(struct cifsInodeInfo *); 60extern int is_size_safe_to_change(struct cifsInodeInfo *);
61extern struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *); 61extern struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *);
@@ -80,6 +80,9 @@ extern struct oplock_q_entry * AllocOplockQEntry(struct inode *, u16,
80extern void DeleteOplockQEntry(struct oplock_q_entry *); 80extern void DeleteOplockQEntry(struct oplock_q_entry *);
81extern struct timespec cifs_NTtimeToUnix(u64 /* utc nanoseconds since 1601 */ ); 81extern struct timespec cifs_NTtimeToUnix(u64 /* utc nanoseconds since 1601 */ );
82extern u64 cifs_UnixTimeToNT(struct timespec); 82extern u64 cifs_UnixTimeToNT(struct timespec);
83extern __le64 cnvrtDosCifsTm(__u16 date, __u16 time);
84extern struct timespec cnvrtDosUnixTm(__u16 date, __u16 time);
85
83extern int cifs_get_inode_info(struct inode **pinode, 86extern int cifs_get_inode_info(struct inode **pinode,
84 const unsigned char *search_path, 87 const unsigned char *search_path,
85 FILE_ALL_INFO * pfile_info, 88 FILE_ALL_INFO * pfile_info,
@@ -116,6 +119,7 @@ extern int CIFSFindClose(const int, struct cifsTconInfo *tcon,
116extern int CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon, 119extern int CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon,
117 const unsigned char *searchName, 120 const unsigned char *searchName,
118 FILE_ALL_INFO * findData, 121 FILE_ALL_INFO * findData,
122 int legacy /* whether to use old info level */,
119 const struct nls_table *nls_codepage, int remap); 123 const struct nls_table *nls_codepage, int remap);
120extern int SMBQueryInformation(const int xid, struct cifsTconInfo *tcon, 124extern int SMBQueryInformation(const int xid, struct cifsTconInfo *tcon,
121 const unsigned char *searchName, 125 const unsigned char *searchName,
@@ -279,8 +283,6 @@ extern void sesInfoFree(struct cifsSesInfo *);
279extern struct cifsTconInfo *tconInfoAlloc(void); 283extern struct cifsTconInfo *tconInfoAlloc(void);
280extern void tconInfoFree(struct cifsTconInfo *); 284extern void tconInfoFree(struct cifsTconInfo *);
281 285
282extern int cifs_reconnect(struct TCP_Server_Info *server);
283
284extern int cifs_sign_smb(struct smb_hdr *, struct TCP_Server_Info *,__u32 *); 286extern int cifs_sign_smb(struct smb_hdr *, struct TCP_Server_Info *,__u32 *);
285extern int cifs_sign_smb2(struct kvec *iov, int n_vec, struct TCP_Server_Info *, 287extern int cifs_sign_smb2(struct kvec *iov, int n_vec, struct TCP_Server_Info *,
286 __u32 *); 288 __u32 *);
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 075d8fb3d376..098790eb2aa1 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -46,6 +46,7 @@ static struct {
46} protocols[] = { 46} protocols[] = {
47#ifdef CONFIG_CIFS_WEAK_PW_HASH 47#ifdef CONFIG_CIFS_WEAK_PW_HASH
48 {LANMAN_PROT, "\2LM1.2X002"}, 48 {LANMAN_PROT, "\2LM1.2X002"},
49 {LANMAN2_PROT, "\2LANMAN2.1"},
49#endif /* weak password hashing for legacy clients */ 50#endif /* weak password hashing for legacy clients */
50 {CIFS_PROT, "\2NT LM 0.12"}, 51 {CIFS_PROT, "\2NT LM 0.12"},
51 {POSIX_PROT, "\2POSIX 2"}, 52 {POSIX_PROT, "\2POSIX 2"},
@@ -58,6 +59,7 @@ static struct {
58} protocols[] = { 59} protocols[] = {
59#ifdef CONFIG_CIFS_WEAK_PW_HASH 60#ifdef CONFIG_CIFS_WEAK_PW_HASH
60 {LANMAN_PROT, "\2LM1.2X002"}, 61 {LANMAN_PROT, "\2LM1.2X002"},
62 {LANMAN2_PROT, "\2LANMAN2.1"},
61#endif /* weak password hashing for legacy clients */ 63#endif /* weak password hashing for legacy clients */
62 {CIFS_PROT, "\2NT LM 0.12"}, 64 {CIFS_PROT, "\2NT LM 0.12"},
63 {BAD_PROT, "\2"} 65 {BAD_PROT, "\2"}
@@ -67,13 +69,13 @@ static struct {
67/* define the number of elements in the cifs dialect array */ 69/* define the number of elements in the cifs dialect array */
68#ifdef CONFIG_CIFS_POSIX 70#ifdef CONFIG_CIFS_POSIX
69#ifdef CONFIG_CIFS_WEAK_PW_HASH 71#ifdef CONFIG_CIFS_WEAK_PW_HASH
70#define CIFS_NUM_PROT 3 72#define CIFS_NUM_PROT 4
71#else 73#else
72#define CIFS_NUM_PROT 2 74#define CIFS_NUM_PROT 2
73#endif /* CIFS_WEAK_PW_HASH */ 75#endif /* CIFS_WEAK_PW_HASH */
74#else /* not posix */ 76#else /* not posix */
75#ifdef CONFIG_CIFS_WEAK_PW_HASH 77#ifdef CONFIG_CIFS_WEAK_PW_HASH
76#define CIFS_NUM_PROT 2 78#define CIFS_NUM_PROT 3
77#else 79#else
78#define CIFS_NUM_PROT 1 80#define CIFS_NUM_PROT 1
79#endif /* CONFIG_CIFS_WEAK_PW_HASH */ 81#endif /* CONFIG_CIFS_WEAK_PW_HASH */
@@ -397,6 +399,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
397 struct TCP_Server_Info * server; 399 struct TCP_Server_Info * server;
398 u16 count; 400 u16 count;
399 unsigned int secFlags; 401 unsigned int secFlags;
402 u16 dialect;
400 403
401 if(ses->server) 404 if(ses->server)
402 server = ses->server; 405 server = ses->server;
@@ -436,9 +439,10 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
436 if (rc != 0) 439 if (rc != 0)
437 goto neg_err_exit; 440 goto neg_err_exit;
438 441
439 cFYI(1,("Dialect: %d", pSMBr->DialectIndex)); 442 dialect = le16_to_cpu(pSMBr->DialectIndex);
443 cFYI(1,("Dialect: %d", dialect));
440 /* Check wct = 1 error case */ 444 /* Check wct = 1 error case */
441 if((pSMBr->hdr.WordCount < 13) || (pSMBr->DialectIndex == BAD_PROT)) { 445 if((pSMBr->hdr.WordCount < 13) || (dialect == BAD_PROT)) {
442 /* core returns wct = 1, but we do not ask for core - otherwise 446 /* core returns wct = 1, but we do not ask for core - otherwise
443 small wct just comes when dialect index is -1 indicating we 447 small wct just comes when dialect index is -1 indicating we
444 could not negotiate a common dialect */ 448 could not negotiate a common dialect */
@@ -446,7 +450,9 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
446 goto neg_err_exit; 450 goto neg_err_exit;
447#ifdef CONFIG_CIFS_WEAK_PW_HASH 451#ifdef CONFIG_CIFS_WEAK_PW_HASH
448 } else if((pSMBr->hdr.WordCount == 13) 452 } else if((pSMBr->hdr.WordCount == 13)
449 && (pSMBr->DialectIndex == LANMAN_PROT)) { 453 && ((dialect == LANMAN_PROT)
454 || (dialect == LANMAN2_PROT))) {
455 __s16 tmp;
450 struct lanman_neg_rsp * rsp = (struct lanman_neg_rsp *)pSMBr; 456 struct lanman_neg_rsp * rsp = (struct lanman_neg_rsp *)pSMBr;
451 457
452 if((secFlags & CIFSSEC_MAY_LANMAN) || 458 if((secFlags & CIFSSEC_MAY_LANMAN) ||
@@ -472,12 +478,44 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
472 server->maxRw = 0;/* we do not need to use raw anyway */ 478 server->maxRw = 0;/* we do not need to use raw anyway */
473 server->capabilities = CAP_MPX_MODE; 479 server->capabilities = CAP_MPX_MODE;
474 } 480 }
475 server->timeZone = le16_to_cpu(rsp->ServerTimeZone); 481 tmp = (__s16)le16_to_cpu(rsp->ServerTimeZone);
482 if (tmp == -1) {
483 /* OS/2 often does not set timezone therefore
484 * we must use server time to calc time zone.
485 * Could deviate slightly from the right zone.
486 * Smallest defined timezone difference is 15 minutes
487 * (i.e. Nepal). Rounding up/down is done to match
488 * this requirement.
489 */
490 int val, seconds, remain, result;
491 struct timespec ts, utc;
492 utc = CURRENT_TIME;
493 ts = cnvrtDosUnixTm(le16_to_cpu(rsp->SrvTime.Date),
494 le16_to_cpu(rsp->SrvTime.Time));
495 cFYI(1,("SrvTime: %d sec since 1970 (utc: %d) diff: %d",
496 (int)ts.tv_sec, (int)utc.tv_sec,
497 (int)(utc.tv_sec - ts.tv_sec)));
498 val = (int)(utc.tv_sec - ts.tv_sec);
499 seconds = val < 0 ? -val : val;
500 result = (seconds / MIN_TZ_ADJ) * MIN_TZ_ADJ;
501 remain = seconds % MIN_TZ_ADJ;
502 if(remain >= (MIN_TZ_ADJ / 2))
503 result += MIN_TZ_ADJ;
504 if(val < 0)
505 result = - result;
506 server->timeAdj = result;
507 } else {
508 server->timeAdj = (int)tmp;
509 server->timeAdj *= 60; /* also in seconds */
510 }
511 cFYI(1,("server->timeAdj: %d seconds", server->timeAdj));
512
476 513
477 /* BB get server time for time conversions and add 514 /* BB get server time for time conversions and add
478 code to use it and timezone since this is not UTC */ 515 code to use it and timezone since this is not UTC */
479 516
480 if (rsp->EncryptionKeyLength == cpu_to_le16(CIFS_CRYPTO_KEY_SIZE)) { 517 if (rsp->EncryptionKeyLength ==
518 cpu_to_le16(CIFS_CRYPTO_KEY_SIZE)) {
481 memcpy(server->cryptKey, rsp->EncryptionKey, 519 memcpy(server->cryptKey, rsp->EncryptionKey,
482 CIFS_CRYPTO_KEY_SIZE); 520 CIFS_CRYPTO_KEY_SIZE);
483 } else if (server->secMode & SECMODE_PW_ENCRYPT) { 521 } else if (server->secMode & SECMODE_PW_ENCRYPT) {
@@ -531,7 +569,8 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
531 cFYI(0, ("Max buf = %d", ses->server->maxBuf)); 569 cFYI(0, ("Max buf = %d", ses->server->maxBuf));
532 GETU32(ses->server->sessid) = le32_to_cpu(pSMBr->SessionKey); 570 GETU32(ses->server->sessid) = le32_to_cpu(pSMBr->SessionKey);
533 server->capabilities = le32_to_cpu(pSMBr->Capabilities); 571 server->capabilities = le32_to_cpu(pSMBr->Capabilities);
534 server->timeZone = le16_to_cpu(pSMBr->ServerTimeZone); 572 server->timeAdj = (int)(__s16)le16_to_cpu(pSMBr->ServerTimeZone);
573 server->timeAdj *= 60;
535 if (pSMBr->EncryptionKeyLength == CIFS_CRYPTO_KEY_SIZE) { 574 if (pSMBr->EncryptionKeyLength == CIFS_CRYPTO_KEY_SIZE) {
536 memcpy(server->cryptKey, pSMBr->u.EncryptionKey, 575 memcpy(server->cryptKey, pSMBr->u.EncryptionKey,
537 CIFS_CRYPTO_KEY_SIZE); 576 CIFS_CRYPTO_KEY_SIZE);
@@ -1617,7 +1656,7 @@ CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, int smb_file_id)
1617 pSMBr = (CLOSE_RSP *)pSMB; /* BB removeme BB */ 1656 pSMBr = (CLOSE_RSP *)pSMB; /* BB removeme BB */
1618 1657
1619 pSMB->FileID = (__u16) smb_file_id; 1658 pSMB->FileID = (__u16) smb_file_id;
1620 pSMB->LastWriteTime = 0; 1659 pSMB->LastWriteTime = 0xFFFFFFFF;
1621 pSMB->ByteCount = 0; 1660 pSMB->ByteCount = 0;
1622 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 1661 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
1623 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 1662 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
@@ -2773,9 +2812,11 @@ GetExtAttrOut:
2773 2812
2774 2813
2775/* security id for everyone */ 2814/* security id for everyone */
2776const struct cifs_sid sid_everyone = {1, 1, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0}}; 2815const static struct cifs_sid sid_everyone =
2816 {1, 1, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0}};
2777/* group users */ 2817/* group users */
2778const struct cifs_sid sid_user = {1, 2 , {0, 0, 0, 0, 0, 5}, {32, 545, 0, 0}}; 2818const static struct cifs_sid sid_user =
2819 {1, 2 , {0, 0, 0, 0, 0, 5}, {32, 545, 0, 0}};
2779 2820
2780/* Convert CIFS ACL to POSIX form */ 2821/* Convert CIFS ACL to POSIX form */
2781static int parse_sec_desc(struct cifs_sid * psec_desc, int acl_len) 2822static int parse_sec_desc(struct cifs_sid * psec_desc, int acl_len)
@@ -2856,7 +2897,6 @@ qsec_out:
2856 return rc; 2897 return rc;
2857} 2898}
2858 2899
2859
2860/* Legacy Query Path Information call for lookup to old servers such 2900/* Legacy Query Path Information call for lookup to old servers such
2861 as Win9x/WinME */ 2901 as Win9x/WinME */
2862int SMBQueryInformation(const int xid, struct cifsTconInfo *tcon, 2902int SMBQueryInformation(const int xid, struct cifsTconInfo *tcon,
@@ -2898,7 +2938,16 @@ QInfRetry:
2898 if (rc) { 2938 if (rc) {
2899 cFYI(1, ("Send error in QueryInfo = %d", rc)); 2939 cFYI(1, ("Send error in QueryInfo = %d", rc));
2900 } else if (pFinfo) { /* decode response */ 2940 } else if (pFinfo) { /* decode response */
2941 struct timespec ts;
2942 __u32 time = le32_to_cpu(pSMBr->last_write_time);
2943 /* BB FIXME - add time zone adjustment BB */
2901 memset(pFinfo, 0, sizeof(FILE_ALL_INFO)); 2944 memset(pFinfo, 0, sizeof(FILE_ALL_INFO));
2945 ts.tv_nsec = 0;
2946 ts.tv_sec = time;
2947 /* decode time fields */
2948 pFinfo->ChangeTime = cpu_to_le64(cifs_UnixTimeToNT(ts));
2949 pFinfo->LastWriteTime = pFinfo->ChangeTime;
2950 pFinfo->LastAccessTime = 0;
2902 pFinfo->AllocationSize = 2951 pFinfo->AllocationSize =
2903 cpu_to_le64(le32_to_cpu(pSMBr->size)); 2952 cpu_to_le64(le32_to_cpu(pSMBr->size));
2904 pFinfo->EndOfFile = pFinfo->AllocationSize; 2953 pFinfo->EndOfFile = pFinfo->AllocationSize;
@@ -2922,6 +2971,7 @@ int
2922CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon, 2971CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon,
2923 const unsigned char *searchName, 2972 const unsigned char *searchName,
2924 FILE_ALL_INFO * pFindData, 2973 FILE_ALL_INFO * pFindData,
2974 int legacy /* old style infolevel */,
2925 const struct nls_table *nls_codepage, int remap) 2975 const struct nls_table *nls_codepage, int remap)
2926{ 2976{
2927/* level 263 SMB_QUERY_FILE_ALL_INFO */ 2977/* level 263 SMB_QUERY_FILE_ALL_INFO */
@@ -2970,7 +3020,10 @@ QPathInfoRetry:
2970 byte_count = params + 1 /* pad */ ; 3020 byte_count = params + 1 /* pad */ ;
2971 pSMB->TotalParameterCount = cpu_to_le16(params); 3021 pSMB->TotalParameterCount = cpu_to_le16(params);
2972 pSMB->ParameterCount = pSMB->TotalParameterCount; 3022 pSMB->ParameterCount = pSMB->TotalParameterCount;
2973 pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_ALL_INFO); 3023 if(legacy)
3024 pSMB->InformationLevel = cpu_to_le16(SMB_INFO_STANDARD);
3025 else
3026 pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_ALL_INFO);
2974 pSMB->Reserved4 = 0; 3027 pSMB->Reserved4 = 0;
2975 pSMB->hdr.smb_buf_length += byte_count; 3028 pSMB->hdr.smb_buf_length += byte_count;
2976 pSMB->ByteCount = cpu_to_le16(byte_count); 3029 pSMB->ByteCount = cpu_to_le16(byte_count);
@@ -2982,13 +3035,24 @@ QPathInfoRetry:
2982 } else { /* decode response */ 3035 } else { /* decode response */
2983 rc = validate_t2((struct smb_t2_rsp *)pSMBr); 3036 rc = validate_t2((struct smb_t2_rsp *)pSMBr);
2984 3037
2985 if (rc || (pSMBr->ByteCount < 40)) 3038 if (rc) /* BB add auto retry on EOPNOTSUPP? */
3039 rc = -EIO;
3040 else if (!legacy && (pSMBr->ByteCount < 40))
2986 rc = -EIO; /* bad smb */ 3041 rc = -EIO; /* bad smb */
3042 else if(legacy && (pSMBr->ByteCount < 24))
3043 rc = -EIO; /* 24 or 26 expected but we do not read last field */
2987 else if (pFindData){ 3044 else if (pFindData){
3045 int size;
2988 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); 3046 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
3047 if(legacy) /* we do not read the last field, EAsize, fortunately
3048 since it varies by subdialect and on Set vs. Get, is
3049 two bytes or 4 bytes depending but we don't care here */
3050 size = sizeof(FILE_INFO_STANDARD);
3051 else
3052 size = sizeof(FILE_ALL_INFO);
2989 memcpy((char *) pFindData, 3053 memcpy((char *) pFindData,
2990 (char *) &pSMBr->hdr.Protocol + 3054 (char *) &pSMBr->hdr.Protocol +
2991 data_offset, sizeof (FILE_ALL_INFO)); 3055 data_offset, size);
2992 } else 3056 } else
2993 rc = -ENOMEM; 3057 rc = -ENOMEM;
2994 } 3058 }
@@ -3613,6 +3677,14 @@ getDFSRetry:
3613 strncpy(pSMB->RequestFileName, searchName, name_len); 3677 strncpy(pSMB->RequestFileName, searchName, name_len);
3614 } 3678 }
3615 3679
3680 if(ses->server) {
3681 if(ses->server->secMode &
3682 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
3683 pSMB->hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
3684 }
3685
3686 pSMB->hdr.Uid = ses->Suid;
3687
3616 params = 2 /* level */ + name_len /*includes null */ ; 3688 params = 2 /* level */ + name_len /*includes null */ ;
3617 pSMB->TotalDataCount = 0; 3689 pSMB->TotalDataCount = 0;
3618 pSMB->DataCount = 0; 3690 pSMB->DataCount = 0;
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index c78762051da4..71f77914ce93 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -109,7 +109,7 @@ static int ipv6_connect(struct sockaddr_in6 *psin_server,
109 * wake up waiters on reconnection? - (not needed currently) 109 * wake up waiters on reconnection? - (not needed currently)
110 */ 110 */
111 111
112int 112static int
113cifs_reconnect(struct TCP_Server_Info *server) 113cifs_reconnect(struct TCP_Server_Info *server)
114{ 114{
115 int rc = 0; 115 int rc = 0;
@@ -771,13 +771,18 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
771 separator[0] = ','; 771 separator[0] = ',';
772 separator[1] = 0; 772 separator[1] = 0;
773 773
774 memset(vol->source_rfc1001_name,0x20,15); 774 if (Local_System_Name[0] != 0)
775 for(i=0;i < strnlen(utsname()->nodename,15);i++) { 775 memcpy(vol->source_rfc1001_name, Local_System_Name,15);
776 /* does not have to be a perfect mapping since the field is 776 else {
777 informational, only used for servers that do not support 777 char *nodename = utsname()->nodename;
778 port 445 and it can be overridden at mount time */ 778 int n = strnlen(nodename,15);
779 vol->source_rfc1001_name[i] = 779 memset(vol->source_rfc1001_name,0x20,15);
780 toupper(utsname()->nodename[i]); 780 for(i=0 ; i < n ; i++) {
781 /* does not have to be perfect mapping since field is
782 informational, only used for servers that do not support
783 port 445 and it can be overridden at mount time */
784 vol->source_rfc1001_name[i] = toupper(nodename[i]);
785 }
781 } 786 }
782 vol->source_rfc1001_name[15] = 0; 787 vol->source_rfc1001_name[15] = 0;
783 /* null target name indicates to use *SMBSERVR default called name 788 /* null target name indicates to use *SMBSERVR default called name
@@ -817,10 +822,13 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
817 } else if (strnicmp(data, "nouser_xattr",12) == 0) { 822 } else if (strnicmp(data, "nouser_xattr",12) == 0) {
818 vol->no_xattr = 1; 823 vol->no_xattr = 1;
819 } else if (strnicmp(data, "user", 4) == 0) { 824 } else if (strnicmp(data, "user", 4) == 0) {
820 if (!value || !*value) { 825 if (!value) {
821 printk(KERN_WARNING 826 printk(KERN_WARNING
822 "CIFS: invalid or missing username\n"); 827 "CIFS: invalid or missing username\n");
823 return 1; /* needs_arg; */ 828 return 1; /* needs_arg; */
829 } else if(!*value) {
830 /* null user, ie anonymous, authentication */
831 vol->nullauth = 1;
824 } 832 }
825 if (strnlen(value, 200) < 200) { 833 if (strnlen(value, 200) < 200) {
826 vol->username = value; 834 vol->username = value;
@@ -1637,6 +1645,8 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
1637 /* BB fixme parse for domain name here */ 1645 /* BB fixme parse for domain name here */
1638 cFYI(1, ("Username: %s ", volume_info.username)); 1646 cFYI(1, ("Username: %s ", volume_info.username));
1639 1647
1648 } else if (volume_info.nullauth) {
1649 cFYI(1,("null user"));
1640 } else { 1650 } else {
1641 cifserror("No username specified"); 1651 cifserror("No username specified");
1642 /* In userspace mount helper we can get user name from alternate 1652 /* In userspace mount helper we can get user name from alternate
@@ -3215,7 +3225,9 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
3215 } 3225 }
3216 /* else do not bother copying these informational fields */ 3226 /* else do not bother copying these informational fields */
3217 } 3227 }
3218 if(smb_buffer_response->WordCount == 3) 3228 if((smb_buffer_response->WordCount == 3) ||
3229 (smb_buffer_response->WordCount == 7))
3230 /* field is in same location */
3219 tcon->Flags = le16_to_cpu(pSMBr->OptionalSupport); 3231 tcon->Flags = le16_to_cpu(pSMBr->OptionalSupport);
3220 else 3232 else
3221 tcon->Flags = 0; 3233 tcon->Flags = 0;
@@ -3312,19 +3324,21 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo,
3312 first_time = 1; 3324 first_time = 1;
3313 } 3325 }
3314 if (!rc) { 3326 if (!rc) {
3327 pSesInfo->flags = 0;
3315 pSesInfo->capabilities = pSesInfo->server->capabilities; 3328 pSesInfo->capabilities = pSesInfo->server->capabilities;
3316 if(linuxExtEnabled == 0) 3329 if(linuxExtEnabled == 0)
3317 pSesInfo->capabilities &= (~CAP_UNIX); 3330 pSesInfo->capabilities &= (~CAP_UNIX);
3318 /* pSesInfo->sequence_number = 0;*/ 3331 /* pSesInfo->sequence_number = 0;*/
3319 cFYI(1,("Security Mode: 0x%x Capabilities: 0x%x Time Zone: %d", 3332 cFYI(1,("Security Mode: 0x%x Capabilities: 0x%x TimeAdjust: %d",
3320 pSesInfo->server->secMode, 3333 pSesInfo->server->secMode,
3321 pSesInfo->server->capabilities, 3334 pSesInfo->server->capabilities,
3322 pSesInfo->server->timeZone)); 3335 pSesInfo->server->timeAdj));
3323 if(experimEnabled < 2) 3336 if(experimEnabled < 2)
3324 rc = CIFS_SessSetup(xid, pSesInfo, 3337 rc = CIFS_SessSetup(xid, pSesInfo,
3325 first_time, nls_info); 3338 first_time, nls_info);
3326 else if (extended_security 3339 else if (extended_security
3327 && (pSesInfo->capabilities & CAP_EXTENDED_SECURITY) 3340 && (pSesInfo->capabilities
3341 & CAP_EXTENDED_SECURITY)
3328 && (pSesInfo->server->secType == NTLMSSP)) { 3342 && (pSesInfo->server->secType == NTLMSSP)) {
3329 rc = -EOPNOTSUPP; 3343 rc = -EOPNOTSUPP;
3330 } else if (extended_security 3344 } else if (extended_security
@@ -3338,7 +3352,7 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo,
3338 if (!rc) { 3352 if (!rc) {
3339 if(ntlmv2_flag) { 3353 if(ntlmv2_flag) {
3340 char * v2_response; 3354 char * v2_response;
3341 cFYI(1,("Can use more secure NTLM version 2 password hash")); 3355 cFYI(1,("more secure NTLM ver2 hash"));
3342 if(CalcNTLMv2_partial_mac_key(pSesInfo, 3356 if(CalcNTLMv2_partial_mac_key(pSesInfo,
3343 nls_info)) { 3357 nls_info)) {
3344 rc = -ENOMEM; 3358 rc = -ENOMEM;
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 976a691c5a68..2436ed8fc840 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -492,10 +492,14 @@ int cifs_close(struct inode *inode, struct file *file)
492 the struct would be in each open file, 492 the struct would be in each open file,
493 but this should give enough time to 493 but this should give enough time to
494 clear the socket */ 494 clear the socket */
495 cERROR(1,("close with pending writes")); 495#ifdef CONFIG_CIFS_DEBUG2
496 cFYI(1,("close delay, write pending"));
497#endif /* DEBUG2 */
496 msleep(timeout); 498 msleep(timeout);
497 timeout *= 4; 499 timeout *= 4;
498 } 500 }
501 if(atomic_read(&pSMBFile->wrtPending))
502 cERROR(1,("close with pending writes"));
499 rc = CIFSSMBClose(xid, pTcon, 503 rc = CIFSSMBClose(xid, pTcon,
500 pSMBFile->netfid); 504 pSMBFile->netfid);
501 } 505 }
@@ -1806,13 +1810,6 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
1806 } 1810 }
1807 if ((rc < 0) || (smb_read_data == NULL)) { 1811 if ((rc < 0) || (smb_read_data == NULL)) {
1808 cFYI(1, ("Read error in readpages: %d", rc)); 1812 cFYI(1, ("Read error in readpages: %d", rc));
1809 /* clean up remaing pages off list */
1810 while (!list_empty(page_list) && (i < num_pages)) {
1811 page = list_entry(page_list->prev, struct page,
1812 lru);
1813 list_del(&page->lru);
1814 page_cache_release(page);
1815 }
1816 break; 1813 break;
1817 } else if (bytes_read > 0) { 1814 } else if (bytes_read > 0) {
1818 pSMBr = (struct smb_com_read_rsp *)smb_read_data; 1815 pSMBr = (struct smb_com_read_rsp *)smb_read_data;
@@ -1831,13 +1828,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
1831 this case is ok - if we are at server EOF 1828 this case is ok - if we are at server EOF
1832 we will hit it on next read */ 1829 we will hit it on next read */
1833 1830
1834 /* while (!list_empty(page_list) && (i < num_pages)) { 1831 /* break; */
1835 page = list_entry(page_list->prev,
1836 struct page, list);
1837 list_del(&page->list);
1838 page_cache_release(page);
1839 }
1840 break; */
1841 } 1832 }
1842 } else { 1833 } else {
1843 cFYI(1, ("No bytes read (%d) at offset %lld . " 1834 cFYI(1, ("No bytes read (%d) at offset %lld . "
@@ -1845,14 +1836,6 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
1845 bytes_read, offset)); 1836 bytes_read, offset));
1846 /* BB turn off caching and do new lookup on 1837 /* BB turn off caching and do new lookup on
1847 file size at server? */ 1838 file size at server? */
1848 while (!list_empty(page_list) && (i < num_pages)) {
1849 page = list_entry(page_list->prev, struct page,
1850 lru);
1851 list_del(&page->lru);
1852
1853 /* BB removeme - replace with zero of page? */
1854 page_cache_release(page);
1855 }
1856 break; 1839 break;
1857 } 1840 }
1858 if (smb_read_data) { 1841 if (smb_read_data) {
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 6b90ef98e4cf..1ad8c9fcc742 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -337,6 +337,7 @@ int cifs_get_inode_info(struct inode **pinode,
337 pfindData = (FILE_ALL_INFO *)buf; 337 pfindData = (FILE_ALL_INFO *)buf;
338 /* could do find first instead but this returns more info */ 338 /* could do find first instead but this returns more info */
339 rc = CIFSSMBQPathInfo(xid, pTcon, search_path, pfindData, 339 rc = CIFSSMBQPathInfo(xid, pTcon, search_path, pfindData,
340 0 /* not legacy */,
340 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & 341 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
341 CIFS_MOUNT_MAP_SPECIAL_CHR); 342 CIFS_MOUNT_MAP_SPECIAL_CHR);
342 /* BB optimize code so we do not make the above call 343 /* BB optimize code so we do not make the above call
@@ -384,8 +385,10 @@ int cifs_get_inode_info(struct inode **pinode,
384 /* get new inode */ 385 /* get new inode */
385 if (*pinode == NULL) { 386 if (*pinode == NULL) {
386 *pinode = new_inode(sb); 387 *pinode = new_inode(sb);
387 if (*pinode == NULL) 388 if (*pinode == NULL) {
389 kfree(buf);
388 return -ENOMEM; 390 return -ENOMEM;
391 }
389 /* Is an i_ino of zero legal? Can we use that to check 392 /* Is an i_ino of zero legal? Can we use that to check
390 if the server supports returning inode numbers? Are 393 if the server supports returning inode numbers? Are
391 there other sanity checks we can use to ensure that 394 there other sanity checks we can use to ensure that
@@ -431,8 +434,11 @@ int cifs_get_inode_info(struct inode **pinode,
431 (pTcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) & 0xFFFFFE00;*/ 434 (pTcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) & 0xFFFFFE00;*/
432 435
433 /* Linux can not store file creation time so ignore it */ 436 /* Linux can not store file creation time so ignore it */
434 inode->i_atime = 437 if(pfindData->LastAccessTime)
435 cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastAccessTime)); 438 inode->i_atime = cifs_NTtimeToUnix
439 (le64_to_cpu(pfindData->LastAccessTime));
440 else /* do not need to use current_fs_time - time not stored */
441 inode->i_atime = CURRENT_TIME;
436 inode->i_mtime = 442 inode->i_mtime =
437 cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastWriteTime)); 443 cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastWriteTime));
438 inode->i_ctime = 444 inode->i_ctime =
@@ -879,10 +885,14 @@ int cifs_rename(struct inode *source_inode, struct dentry *source_direntry,
879 kmalloc(2 * sizeof(FILE_UNIX_BASIC_INFO), GFP_KERNEL); 885 kmalloc(2 * sizeof(FILE_UNIX_BASIC_INFO), GFP_KERNEL);
880 if (info_buf_source != NULL) { 886 if (info_buf_source != NULL) {
881 info_buf_target = info_buf_source + 1; 887 info_buf_target = info_buf_source + 1;
882 rc = CIFSSMBUnixQPathInfo(xid, pTcon, fromName, 888 if (pTcon->ses->capabilities & CAP_UNIX)
883 info_buf_source, cifs_sb_source->local_nls, 889 rc = CIFSSMBUnixQPathInfo(xid, pTcon, fromName,
884 cifs_sb_source->mnt_cifs_flags & 890 info_buf_source,
885 CIFS_MOUNT_MAP_SPECIAL_CHR); 891 cifs_sb_source->local_nls,
892 cifs_sb_source->mnt_cifs_flags &
893 CIFS_MOUNT_MAP_SPECIAL_CHR);
894 /* else rc is still EEXIST so will fall through to
895 unlink the target and retry rename */
886 if (rc == 0) { 896 if (rc == 0) {
887 rc = CIFSSMBUnixQPathInfo(xid, pTcon, toName, 897 rc = CIFSSMBUnixQPathInfo(xid, pTcon, toName,
888 info_buf_target, 898 info_buf_target,
@@ -931,7 +941,7 @@ int cifs_rename(struct inode *source_inode, struct dentry *source_direntry,
931 cifs_sb_source->mnt_cifs_flags & 941 cifs_sb_source->mnt_cifs_flags &
932 CIFS_MOUNT_MAP_SPECIAL_CHR); 942 CIFS_MOUNT_MAP_SPECIAL_CHR);
933 if (rc==0) { 943 if (rc==0) {
934 CIFSSMBRenameOpenFile(xid, pTcon, netfid, toName, 944 rc = CIFSSMBRenameOpenFile(xid, pTcon, netfid, toName,
935 cifs_sb_source->local_nls, 945 cifs_sb_source->local_nls,
936 cifs_sb_source->mnt_cifs_flags & 946 cifs_sb_source->mnt_cifs_flags &
937 CIFS_MOUNT_MAP_SPECIAL_CHR); 947 CIFS_MOUNT_MAP_SPECIAL_CHR);
@@ -1079,8 +1089,10 @@ int cifs_getattr(struct vfsmount *mnt, struct dentry *dentry,
1079 struct kstat *stat) 1089 struct kstat *stat)
1080{ 1090{
1081 int err = cifs_revalidate(dentry); 1091 int err = cifs_revalidate(dentry);
1082 if (!err) 1092 if (!err) {
1083 generic_fillattr(dentry->d_inode, stat); 1093 generic_fillattr(dentry->d_inode, stat);
1094 stat->blksize = CIFS_MAX_MSGSIZE;
1095 }
1084 return err; 1096 return err;
1085} 1097}
1086 1098
diff --git a/fs/cifs/link.c b/fs/cifs/link.c
index a57f5d6e6213..0bee8b7e521a 100644
--- a/fs/cifs/link.c
+++ b/fs/cifs/link.c
@@ -254,7 +254,11 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen)
254 tmpbuffer, 254 tmpbuffer,
255 len - 1, 255 len - 1,
256 cifs_sb->local_nls); 256 cifs_sb->local_nls);
257 else { 257 else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) {
258 cERROR(1,("SFU style symlinks not implemented yet"));
259 /* add open and read as in fs/cifs/inode.c */
260
261 } else {
258 rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, GENERIC_READ, 262 rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, GENERIC_READ,
259 OPEN_REPARSE_POINT,&fid, &oplock, NULL, 263 OPEN_REPARSE_POINT,&fid, &oplock, NULL,
260 cifs_sb->local_nls, 264 cifs_sb->local_nls,
diff --git a/fs/cifs/md5.c b/fs/cifs/md5.c
index 7aa23490541f..ccebf9b7eb86 100644
--- a/fs/cifs/md5.c
+++ b/fs/cifs/md5.c
@@ -252,10 +252,11 @@ MD5Transform(__u32 buf[4], __u32 const in[16])
252 buf[3] += d; 252 buf[3] += d;
253} 253}
254 254
255#if 0 /* currently unused */
255/*********************************************************************** 256/***********************************************************************
256 the rfc 2104 version of hmac_md5 initialisation. 257 the rfc 2104 version of hmac_md5 initialisation.
257***********************************************************************/ 258***********************************************************************/
258void 259static void
259hmac_md5_init_rfc2104(unsigned char *key, int key_len, 260hmac_md5_init_rfc2104(unsigned char *key, int key_len,
260 struct HMACMD5Context *ctx) 261 struct HMACMD5Context *ctx)
261{ 262{
@@ -289,6 +290,7 @@ hmac_md5_init_rfc2104(unsigned char *key, int key_len,
289 MD5Init(&ctx->ctx); 290 MD5Init(&ctx->ctx);
290 MD5Update(&ctx->ctx, ctx->k_ipad, 64); 291 MD5Update(&ctx->ctx, ctx->k_ipad, 64);
291} 292}
293#endif
292 294
293/*********************************************************************** 295/***********************************************************************
294 the microsoft version of hmac_md5 initialisation. 296 the microsoft version of hmac_md5 initialisation.
@@ -350,7 +352,8 @@ hmac_md5_final(unsigned char *digest, struct HMACMD5Context *ctx)
350 single function to calculate an HMAC MD5 digest from data. 352 single function to calculate an HMAC MD5 digest from data.
351 use the microsoft hmacmd5 init method because the key is 16 bytes. 353 use the microsoft hmacmd5 init method because the key is 16 bytes.
352************************************************************/ 354************************************************************/
353void 355#if 0 /* currently unused */
356static void
354hmac_md5(unsigned char key[16], unsigned char *data, int data_len, 357hmac_md5(unsigned char key[16], unsigned char *data, int data_len,
355 unsigned char *digest) 358 unsigned char *digest)
356{ 359{
@@ -361,3 +364,4 @@ hmac_md5(unsigned char key[16], unsigned char *data, int data_len,
361 } 364 }
362 hmac_md5_final(digest, &ctx); 365 hmac_md5_final(digest, &ctx);
363} 366}
367#endif
diff --git a/fs/cifs/md5.h b/fs/cifs/md5.h
index 00e1c5394fe1..f7d4f4197bac 100644
--- a/fs/cifs/md5.h
+++ b/fs/cifs/md5.h
@@ -27,12 +27,12 @@ void MD5Final(unsigned char digest[16], struct MD5Context *context);
27 27
28/* The following definitions come from lib/hmacmd5.c */ 28/* The following definitions come from lib/hmacmd5.c */
29 29
30void hmac_md5_init_rfc2104(unsigned char *key, int key_len, 30/* void hmac_md5_init_rfc2104(unsigned char *key, int key_len,
31 struct HMACMD5Context *ctx); 31 struct HMACMD5Context *ctx);*/
32void hmac_md5_init_limK_to_64(const unsigned char *key, int key_len, 32void hmac_md5_init_limK_to_64(const unsigned char *key, int key_len,
33 struct HMACMD5Context *ctx); 33 struct HMACMD5Context *ctx);
34void hmac_md5_update(const unsigned char *text, int text_len, 34void hmac_md5_update(const unsigned char *text, int text_len,
35 struct HMACMD5Context *ctx); 35 struct HMACMD5Context *ctx);
36void hmac_md5_final(unsigned char *digest, struct HMACMD5Context *ctx); 36void hmac_md5_final(unsigned char *digest, struct HMACMD5Context *ctx);
37void hmac_md5(unsigned char key[16], unsigned char *data, int data_len, 37/* void hmac_md5(unsigned char key[16], unsigned char *data, int data_len,
38 unsigned char *digest); 38 unsigned char *digest);*/
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index 22c937e5884f..bbc9cd34b6ea 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -389,7 +389,7 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
389 return; 389 return;
390} 390}
391 391
392int 392static int
393checkSMBhdr(struct smb_hdr *smb, __u16 mid) 393checkSMBhdr(struct smb_hdr *smb, __u16 mid)
394{ 394{
395 /* Make sure that this really is an SMB, that it is a response, 395 /* Make sure that this really is an SMB, that it is a response,
@@ -418,26 +418,42 @@ checkSMBhdr(struct smb_hdr *smb, __u16 mid)
418} 418}
419 419
420int 420int
421checkSMB(struct smb_hdr *smb, __u16 mid, int length) 421checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length)
422{ 422{
423 __u32 len = smb->smb_buf_length; 423 __u32 len = smb->smb_buf_length;
424 __u32 clc_len; /* calculated length */ 424 __u32 clc_len; /* calculated length */
425 cFYI(0, ("checkSMB Length: 0x%x, smb_buf_length: 0x%x", length, len)); 425 cFYI(0, ("checkSMB Length: 0x%x, smb_buf_length: 0x%x", length, len));
426 if (((unsigned int)length < 2 + sizeof (struct smb_hdr)) || 426
427 (len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4)) { 427 if (length < 2 + sizeof (struct smb_hdr)) {
428 if ((unsigned int)length < 2 + sizeof (struct smb_hdr)) { 428 if ((length >= sizeof (struct smb_hdr) - 1)
429 if (((unsigned int)length >=
430 sizeof (struct smb_hdr) - 1)
431 && (smb->Status.CifsError != 0)) { 429 && (smb->Status.CifsError != 0)) {
432 smb->WordCount = 0; 430 smb->WordCount = 0;
433 /* some error cases do not return wct and bcc */ 431 /* some error cases do not return wct and bcc */
432 return 0;
433 } else if ((length == sizeof(struct smb_hdr) + 1) &&
434 (smb->WordCount == 0)) {
435 char * tmp = (char *)smb;
436 /* Need to work around a bug in two servers here */
437 /* First, check if the part of bcc they sent was zero */
438 if (tmp[sizeof(struct smb_hdr)] == 0) {
439 /* some servers return only half of bcc
440 * on simple responses (wct, bcc both zero)
441 * in particular have seen this on
442 * ulogoffX and FindClose. This leaves
443 * one byte of bcc potentially unitialized
444 */
445 /* zero rest of bcc */
446 tmp[sizeof(struct smb_hdr)+1] = 0;
434 return 0; 447 return 0;
435 } else {
436 cERROR(1, ("Length less than smb header size"));
437 } 448 }
449 cERROR(1,("rcvd invalid byte count (bcc)"));
450 } else {
451 cERROR(1, ("Length less than smb header size"));
438 } 452 }
439 if (len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) 453 return 1;
440 cERROR(1, ("smb length greater than MaxBufSize, mid=%d", 454 }
455 if (len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) {
456 cERROR(1, ("smb length greater than MaxBufSize, mid=%d",
441 smb->Mid)); 457 smb->Mid));
442 return 1; 458 return 1;
443 } 459 }
@@ -446,7 +462,7 @@ checkSMB(struct smb_hdr *smb, __u16 mid, int length)
446 return 1; 462 return 1;
447 clc_len = smbCalcSize_LE(smb); 463 clc_len = smbCalcSize_LE(smb);
448 464
449 if(4 + len != (unsigned int)length) { 465 if(4 + len != length) {
450 cERROR(1, ("Length read does not match RFC1001 length %d",len)); 466 cERROR(1, ("Length read does not match RFC1001 length %d",len));
451 return 1; 467 return 1;
452 } 468 }
diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c
index ce87550e918f..992e80edc720 100644
--- a/fs/cifs/netmisc.c
+++ b/fs/cifs/netmisc.c
@@ -909,3 +909,61 @@ cifs_UnixTimeToNT(struct timespec t)
909 /* Convert to 100ns intervals and then add the NTFS time offset. */ 909 /* Convert to 100ns intervals and then add the NTFS time offset. */
910 return (u64) t.tv_sec * 10000000 + t.tv_nsec/100 + NTFS_TIME_OFFSET; 910 return (u64) t.tv_sec * 10000000 + t.tv_nsec/100 + NTFS_TIME_OFFSET;
911} 911}
912
913static int total_days_of_prev_months[] =
914{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
915
916
917__le64 cnvrtDosCifsTm(__u16 date, __u16 time)
918{
919 return cpu_to_le64(cifs_UnixTimeToNT(cnvrtDosUnixTm(date, time)));
920}
921
922struct timespec cnvrtDosUnixTm(__u16 date, __u16 time)
923{
924 struct timespec ts;
925 int sec, min, days, month, year;
926 SMB_TIME * st = (SMB_TIME *)&time;
927 SMB_DATE * sd = (SMB_DATE *)&date;
928
929 cFYI(1,("date %d time %d",date, time));
930
931 sec = 2 * st->TwoSeconds;
932 min = st->Minutes;
933 if((sec > 59) || (min > 59))
934 cERROR(1,("illegal time min %d sec %d", min, sec));
935 sec += (min * 60);
936 sec += 60 * 60 * st->Hours;
937 if(st->Hours > 24)
938 cERROR(1,("illegal hours %d",st->Hours));
939 days = sd->Day;
940 month = sd->Month;
941 if((days > 31) || (month > 12))
942 cERROR(1,("illegal date, month %d day: %d", month, days));
943 month -= 1;
944 days += total_days_of_prev_months[month];
945 days += 3652; /* account for difference in days between 1980 and 1970 */
946 year = sd->Year;
947 days += year * 365;
948 days += (year/4); /* leap year */
949 /* generalized leap year calculation is more complex, ie no leap year
950 for years/100 except for years/400, but since the maximum number for DOS
951 year is 2**7, the last year is 1980+127, which means we need only
952 consider 2 special case years, ie the years 2000 and 2100, and only
953 adjust for the lack of leap year for the year 2100, as 2000 was a
954 leap year (divisable by 400) */
955 if(year >= 120) /* the year 2100 */
956 days = days - 1; /* do not count leap year for the year 2100 */
957
958 /* adjust for leap year where we are still before leap day */
959 if(year != 120)
960 days -= ((year & 0x03) == 0) && (month < 2 ? 1 : 0);
961 sec += 24 * 60 * 60 * days;
962
963 ts.tv_sec = sec;
964
965 /* cFYI(1,("sec after cnvrt dos to unix time %d",sec)); */
966
967 ts.tv_nsec = 0;
968 return ts;
969}
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index b27b34537bf2..ed18c3965f7b 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -106,6 +106,17 @@ static int construct_dentry(struct qstr *qstring, struct file *file,
106 return rc; 106 return rc;
107} 107}
108 108
109static void AdjustForTZ(struct cifsTconInfo * tcon, struct inode * inode)
110{
111 if((tcon) && (tcon->ses) && (tcon->ses->server)) {
112 inode->i_ctime.tv_sec += tcon->ses->server->timeAdj;
113 inode->i_mtime.tv_sec += tcon->ses->server->timeAdj;
114 inode->i_atime.tv_sec += tcon->ses->server->timeAdj;
115 }
116 return;
117}
118
119
109static void fill_in_inode(struct inode *tmp_inode, int new_buf_type, 120static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
110 char * buf, int *pobject_type, int isNewInode) 121 char * buf, int *pobject_type, int isNewInode)
111{ 122{
@@ -135,16 +146,23 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
135 tmp_inode->i_ctime = 146 tmp_inode->i_ctime =
136 cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime)); 147 cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime));
137 } else { /* legacy, OS2 and DOS style */ 148 } else { /* legacy, OS2 and DOS style */
149/* struct timespec ts;*/
138 FIND_FILE_STANDARD_INFO * pfindData = 150 FIND_FILE_STANDARD_INFO * pfindData =
139 (FIND_FILE_STANDARD_INFO *)buf; 151 (FIND_FILE_STANDARD_INFO *)buf;
140 152
153 tmp_inode->i_mtime = cnvrtDosUnixTm(
154 le16_to_cpu(pfindData->LastWriteDate),
155 le16_to_cpu(pfindData->LastWriteTime));
156 tmp_inode->i_atime = cnvrtDosUnixTm(
157 le16_to_cpu(pfindData->LastAccessDate),
158 le16_to_cpu(pfindData->LastAccessTime));
159 tmp_inode->i_ctime = cnvrtDosUnixTm(
160 le16_to_cpu(pfindData->LastWriteDate),
161 le16_to_cpu(pfindData->LastWriteTime));
162 AdjustForTZ(cifs_sb->tcon, tmp_inode);
141 attr = le16_to_cpu(pfindData->Attributes); 163 attr = le16_to_cpu(pfindData->Attributes);
142 allocation_size = le32_to_cpu(pfindData->AllocationSize); 164 allocation_size = le32_to_cpu(pfindData->AllocationSize);
143 end_of_file = le32_to_cpu(pfindData->DataSize); 165 end_of_file = le32_to_cpu(pfindData->DataSize);
144 tmp_inode->i_atime = CURRENT_TIME;
145 /* tmp_inode->i_mtime = BB FIXME - add dos time handling
146 tmp_inode->i_ctime = 0; BB FIXME */
147
148 } 166 }
149 167
150 /* Linux can not store file creation time unfortunately so ignore it */ 168 /* Linux can not store file creation time unfortunately so ignore it */
@@ -878,6 +896,10 @@ static int cifs_filldir(char *pfindEntry, struct file *file,
878 tmp_inode->i_ino,obj_type); 896 tmp_inode->i_ino,obj_type);
879 if(rc) { 897 if(rc) {
880 cFYI(1,("filldir rc = %d",rc)); 898 cFYI(1,("filldir rc = %d",rc));
899 /* we can not return filldir errors to the caller
900 since they are "normal" when the stat blocksize
901 is too small - we return remapped error instead */
902 rc = -EOVERFLOW;
881 } 903 }
882 904
883 dput(tmp_dentry); 905 dput(tmp_dentry);
@@ -938,6 +960,7 @@ static int cifs_save_resume_key(const char *current_entry,
938 filename = &pFindData->FileName[0]; 960 filename = &pFindData->FileName[0];
939 /* one byte length, no name conversion */ 961 /* one byte length, no name conversion */
940 len = (unsigned int)pFindData->FileNameLength; 962 len = (unsigned int)pFindData->FileNameLength;
963 cifsFile->srch_inf.resume_key = pFindData->ResumeKey;
941 } else { 964 } else {
942 cFYI(1,("Unknown findfirst level %d",level)); 965 cFYI(1,("Unknown findfirst level %d",level));
943 return -EINVAL; 966 return -EINVAL;
@@ -1055,6 +1078,11 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
1055 we want to check for that here? */ 1078 we want to check for that here? */
1056 rc = cifs_filldir(current_entry, file, 1079 rc = cifs_filldir(current_entry, file,
1057 filldir, direntry, tmp_buf, max_len); 1080 filldir, direntry, tmp_buf, max_len);
1081 if(rc == -EOVERFLOW) {
1082 rc = 0;
1083 break;
1084 }
1085
1058 file->f_pos++; 1086 file->f_pos++;
1059 if(file->f_pos == 1087 if(file->f_pos ==
1060 cifsFile->srch_inf.index_of_last_entry) { 1088 cifsFile->srch_inf.index_of_last_entry) {
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
index 22b4c35dcfe3..bbdda99dce61 100644
--- a/fs/cifs/sess.c
+++ b/fs/cifs/sess.c
@@ -90,7 +90,9 @@ static void unicode_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses,
90 } */ 90 } */
91 /* copy user */ 91 /* copy user */
92 if(ses->userName == NULL) { 92 if(ses->userName == NULL) {
93 /* BB what about null user mounts - check that we do this BB */ 93 /* null user mount */
94 *bcc_ptr = 0;
95 *(bcc_ptr+1) = 0;
94 } else { /* 300 should be long enough for any conceivable user name */ 96 } else { /* 300 should be long enough for any conceivable user name */
95 bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, ses->userName, 97 bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, ses->userName,
96 300, nls_cp); 98 300, nls_cp);
@@ -98,10 +100,13 @@ static void unicode_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses,
98 bcc_ptr += 2 * bytes_ret; 100 bcc_ptr += 2 * bytes_ret;
99 bcc_ptr += 2; /* account for null termination */ 101 bcc_ptr += 2; /* account for null termination */
100 /* copy domain */ 102 /* copy domain */
101 if(ses->domainName == NULL) 103 if(ses->domainName == NULL) {
102 bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, 104 /* Sending null domain better than using a bogus domain name (as
103 "CIFS_LINUX_DOM", 32, nls_cp); 105 we did briefly in 2.6.18) since server will use its default */
104 else 106 *bcc_ptr = 0;
107 *(bcc_ptr+1) = 0;
108 bytes_ret = 0;
109 } else
105 bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, ses->domainName, 110 bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, ses->domainName,
106 256, nls_cp); 111 256, nls_cp);
107 bcc_ptr += 2 * bytes_ret; 112 bcc_ptr += 2 * bytes_ret;
@@ -144,13 +149,11 @@ static void ascii_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses,
144 149
145 /* copy domain */ 150 /* copy domain */
146 151
147 if(ses->domainName == NULL) { 152 if(ses->domainName != NULL) {
148 strcpy(bcc_ptr, "CIFS_LINUX_DOM");
149 bcc_ptr += 14; /* strlen(CIFS_LINUX_DOM) */
150 } else {
151 strncpy(bcc_ptr, ses->domainName, 256); 153 strncpy(bcc_ptr, ses->domainName, 256);
152 bcc_ptr += strnlen(ses->domainName, 256); 154 bcc_ptr += strnlen(ses->domainName, 256);
153 } 155 } /* else we will send a null domain name
156 so the server will default to its own domain */
154 *bcc_ptr = 0; 157 *bcc_ptr = 0;
155 bcc_ptr++; 158 bcc_ptr++;
156 159
@@ -268,6 +271,10 @@ static int decode_ascii_ssetup(char ** pbcc_area, int bleft, struct cifsSesInfo
268 ses->serverOS = kzalloc(len + 1, GFP_KERNEL); 271 ses->serverOS = kzalloc(len + 1, GFP_KERNEL);
269 if(ses->serverOS) 272 if(ses->serverOS)
270 strncpy(ses->serverOS, bcc_ptr, len); 273 strncpy(ses->serverOS, bcc_ptr, len);
274 if(strncmp(ses->serverOS, "OS/2",4) == 0) {
275 cFYI(1,("OS/2 server"));
276 ses->flags |= CIFS_SES_OS2;
277 }
271 278
272 bcc_ptr += len + 1; 279 bcc_ptr += len + 1;
273 bleft -= len + 1; 280 bleft -= len + 1;
@@ -290,16 +297,11 @@ static int decode_ascii_ssetup(char ** pbcc_area, int bleft, struct cifsSesInfo
290 if(len > bleft) 297 if(len > bleft)
291 return rc; 298 return rc;
292 299
293 if(ses->serverDomain) 300 /* No domain field in LANMAN case. Domain is
294 kfree(ses->serverDomain); 301 returned by old servers in the SMB negprot response */
295 302 /* BB For newer servers which do not support Unicode,
296 ses->serverDomain = kzalloc(len + 1, GFP_KERNEL); 303 but thus do return domain here we could add parsing
297 if(ses->serverOS) 304 for it later, but it is not very important */
298 strncpy(ses->serverOS, bcc_ptr, len);
299
300 bcc_ptr += len + 1;
301 bleft -= len + 1;
302
303 cFYI(1,("ascii: bytes left %d",bleft)); 305 cFYI(1,("ascii: bytes left %d",bleft));
304 306
305 return rc; 307 return rc;
@@ -366,6 +368,8 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
366 str_area = kmalloc(2000, GFP_KERNEL); 368 str_area = kmalloc(2000, GFP_KERNEL);
367 bcc_ptr = str_area; 369 bcc_ptr = str_area;
368 370
371 ses->flags &= ~CIFS_SES_LANMAN;
372
369 if(type == LANMAN) { 373 if(type == LANMAN) {
370#ifdef CONFIG_CIFS_WEAK_PW_HASH 374#ifdef CONFIG_CIFS_WEAK_PW_HASH
371 char lnm_session_key[CIFS_SESS_KEY_SIZE]; 375 char lnm_session_key[CIFS_SESS_KEY_SIZE];
@@ -377,7 +381,7 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
377 /* and copy into bcc */ 381 /* and copy into bcc */
378 382
379 calc_lanman_hash(ses, lnm_session_key); 383 calc_lanman_hash(ses, lnm_session_key);
380 384 ses->flags |= CIFS_SES_LANMAN;
381/* #ifdef CONFIG_CIFS_DEBUG2 385/* #ifdef CONFIG_CIFS_DEBUG2
382 cifs_dump_mem("cryptkey: ",ses->server->cryptKey, 386 cifs_dump_mem("cryptkey: ",ses->server->cryptKey,
383 CIFS_SESS_KEY_SIZE); 387 CIFS_SESS_KEY_SIZE);
diff --git a/fs/cifs/smbdes.c b/fs/cifs/smbdes.c
index efaa044523a7..7a1b2b961ec8 100644
--- a/fs/cifs/smbdes.c
+++ b/fs/cifs/smbdes.c
@@ -364,20 +364,20 @@ E_P24(unsigned char *p21, unsigned char *c8, unsigned char *p24)
364 smbhash(p24 + 16, c8, p21 + 14, 1); 364 smbhash(p24 + 16, c8, p21 + 14, 1);
365} 365}
366 366
367void 367#if 0 /* currently unsued */
368static void
368D_P16(unsigned char *p14, unsigned char *in, unsigned char *out) 369D_P16(unsigned char *p14, unsigned char *in, unsigned char *out)
369{ 370{
370 smbhash(out, in, p14, 0); 371 smbhash(out, in, p14, 0);
371 smbhash(out + 8, in + 8, p14 + 7, 0); 372 smbhash(out + 8, in + 8, p14 + 7, 0);
372} 373}
373 374
374void 375static void
375E_old_pw_hash(unsigned char *p14, unsigned char *in, unsigned char *out) 376E_old_pw_hash(unsigned char *p14, unsigned char *in, unsigned char *out)
376{ 377{
377 smbhash(out, in, p14, 1); 378 smbhash(out, in, p14, 1);
378 smbhash(out + 8, in + 8, p14 + 7, 1); 379 smbhash(out + 8, in + 8, p14 + 7, 1);
379} 380}
380#if 0
381/* these routines are currently unneeded, but may be 381/* these routines are currently unneeded, but may be
382 needed later */ 382 needed later */
383void 383void
diff --git a/fs/cifs/smbencrypt.c b/fs/cifs/smbencrypt.c
index f518c5e45035..4b25ba92180d 100644
--- a/fs/cifs/smbencrypt.c
+++ b/fs/cifs/smbencrypt.c
@@ -51,11 +51,8 @@
51 51
52void SMBencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24); 52void SMBencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24);
53void E_md4hash(const unsigned char *passwd, unsigned char *p16); 53void E_md4hash(const unsigned char *passwd, unsigned char *p16);
54void nt_lm_owf_gen(char *pwd, unsigned char nt_p16[16], unsigned char p16[16]);
55static void SMBOWFencrypt(unsigned char passwd[16], unsigned char *c8, 54static void SMBOWFencrypt(unsigned char passwd[16], unsigned char *c8,
56 unsigned char p24[24]); 55 unsigned char p24[24]);
57void NTLMSSPOWFencrypt(unsigned char passwd[8],
58 unsigned char *ntlmchalresp, unsigned char p24[24]);
59void SMBNTencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24); 56void SMBNTencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24);
60 57
61/* 58/*
@@ -144,8 +141,9 @@ E_md4hash(const unsigned char *passwd, unsigned char *p16)
144 memset(wpwd,0,129 * 2); 141 memset(wpwd,0,129 * 2);
145} 142}
146 143
144#if 0 /* currently unused */
147/* Does both the NT and LM owfs of a user's password */ 145/* Does both the NT and LM owfs of a user's password */
148void 146static void
149nt_lm_owf_gen(char *pwd, unsigned char nt_p16[16], unsigned char p16[16]) 147nt_lm_owf_gen(char *pwd, unsigned char nt_p16[16], unsigned char p16[16])
150{ 148{
151 char passwd[514]; 149 char passwd[514];
@@ -171,6 +169,7 @@ nt_lm_owf_gen(char *pwd, unsigned char nt_p16[16], unsigned char p16[16])
171 /* clear out local copy of user's password (just being paranoid). */ 169 /* clear out local copy of user's password (just being paranoid). */
172 memset(passwd, '\0', sizeof (passwd)); 170 memset(passwd, '\0', sizeof (passwd));
173} 171}
172#endif
174 173
175/* Does the NTLMv2 owfs of a user's password */ 174/* Does the NTLMv2 owfs of a user's password */
176#if 0 /* function not needed yet - but will be soon */ 175#if 0 /* function not needed yet - but will be soon */
@@ -223,7 +222,8 @@ SMBOWFencrypt(unsigned char passwd[16], unsigned char *c8,
223} 222}
224 223
225/* Does the des encryption from the FIRST 8 BYTES of the NT or LM MD4 hash. */ 224/* Does the des encryption from the FIRST 8 BYTES of the NT or LM MD4 hash. */
226void 225#if 0 /* currently unused */
226static void
227NTLMSSPOWFencrypt(unsigned char passwd[8], 227NTLMSSPOWFencrypt(unsigned char passwd[8],
228 unsigned char *ntlmchalresp, unsigned char p24[24]) 228 unsigned char *ntlmchalresp, unsigned char p24[24])
229{ 229{
@@ -235,6 +235,7 @@ NTLMSSPOWFencrypt(unsigned char passwd[8],
235 235
236 E_P24(p21, ntlmchalresp, p24); 236 E_P24(p21, ntlmchalresp, p24);
237} 237}
238#endif
238 239
239/* Does the NT MD4 hash then des encryption. */ 240/* Does the NT MD4 hash then des encryption. */
240 241
diff --git a/fs/compat.c b/fs/compat.c
index 50624d4a70c6..8d0a0018a7d2 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -1835,9 +1835,12 @@ asmlinkage long compat_sys_pselect7(int n, compat_ulong_t __user *inp,
1835 1835
1836 } while (!ret && !timeout && tsp && (ts.tv_sec || ts.tv_nsec)); 1836 } while (!ret && !timeout && tsp && (ts.tv_sec || ts.tv_nsec));
1837 1837
1838 if (ret == 0 && tsp && !(current->personality & STICKY_TIMEOUTS)) { 1838 if (tsp) {
1839 struct compat_timespec rts; 1839 struct compat_timespec rts;
1840 1840
1841 if (current->personality & STICKY_TIMEOUTS)
1842 goto sticky;
1843
1841 rts.tv_sec = timeout / HZ; 1844 rts.tv_sec = timeout / HZ;
1842 rts.tv_nsec = (timeout % HZ) * (NSEC_PER_SEC/HZ); 1845 rts.tv_nsec = (timeout % HZ) * (NSEC_PER_SEC/HZ);
1843 if (rts.tv_nsec >= NSEC_PER_SEC) { 1846 if (rts.tv_nsec >= NSEC_PER_SEC) {
@@ -1846,8 +1849,19 @@ asmlinkage long compat_sys_pselect7(int n, compat_ulong_t __user *inp,
1846 } 1849 }
1847 if (compat_timespec_compare(&rts, &ts) >= 0) 1850 if (compat_timespec_compare(&rts, &ts) >= 0)
1848 rts = ts; 1851 rts = ts;
1849 if (copy_to_user(tsp, &rts, sizeof(rts))) 1852 if (copy_to_user(tsp, &rts, sizeof(rts))) {
1850 ret = -EFAULT; 1853sticky:
1854 /*
1855 * If an application puts its timeval in read-only
1856 * memory, we don't want the Linux-specific update to
1857 * the timeval to cause a fault after the select has
1858 * completed successfully. However, because we're not
1859 * updating the timeval, we can't restart the system
1860 * call.
1861 */
1862 if (ret == -ERESTARTNOHAND)
1863 ret = -EINTR;
1864 }
1851 } 1865 }
1852 1866
1853 if (ret == -ERESTARTNOHAND) { 1867 if (ret == -ERESTARTNOHAND) {
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 27ca1aa30562..a91f2628c981 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -2438,13 +2438,17 @@ HANDLE_IOCTL(0x1260, broken_blkgetsize)
2438HANDLE_IOCTL(BLKFRAGET, w_long) 2438HANDLE_IOCTL(BLKFRAGET, w_long)
2439HANDLE_IOCTL(BLKSECTGET, w_long) 2439HANDLE_IOCTL(BLKSECTGET, w_long)
2440HANDLE_IOCTL(BLKPG, blkpg_ioctl_trans) 2440HANDLE_IOCTL(BLKPG, blkpg_ioctl_trans)
2441HANDLE_IOCTL(HDIO_GET_KEEPSETTINGS, hdio_ioctl_trans)
2442HANDLE_IOCTL(HDIO_GET_UNMASKINTR, hdio_ioctl_trans) 2441HANDLE_IOCTL(HDIO_GET_UNMASKINTR, hdio_ioctl_trans)
2443HANDLE_IOCTL(HDIO_GET_DMA, hdio_ioctl_trans)
2444HANDLE_IOCTL(HDIO_GET_32BIT, hdio_ioctl_trans)
2445HANDLE_IOCTL(HDIO_GET_MULTCOUNT, hdio_ioctl_trans) 2442HANDLE_IOCTL(HDIO_GET_MULTCOUNT, hdio_ioctl_trans)
2443HANDLE_IOCTL(HDIO_GET_KEEPSETTINGS, hdio_ioctl_trans)
2444HANDLE_IOCTL(HDIO_GET_32BIT, hdio_ioctl_trans)
2446HANDLE_IOCTL(HDIO_GET_NOWERR, hdio_ioctl_trans) 2445HANDLE_IOCTL(HDIO_GET_NOWERR, hdio_ioctl_trans)
2446HANDLE_IOCTL(HDIO_GET_DMA, hdio_ioctl_trans)
2447HANDLE_IOCTL(HDIO_GET_NICE, hdio_ioctl_trans) 2447HANDLE_IOCTL(HDIO_GET_NICE, hdio_ioctl_trans)
2448HANDLE_IOCTL(HDIO_GET_WCACHE, hdio_ioctl_trans)
2449HANDLE_IOCTL(HDIO_GET_ACOUSTIC, hdio_ioctl_trans)
2450HANDLE_IOCTL(HDIO_GET_ADDRESS, hdio_ioctl_trans)
2451HANDLE_IOCTL(HDIO_GET_BUSSTATE, hdio_ioctl_trans)
2448HANDLE_IOCTL(FDSETPRM32, fd_ioctl_trans) 2452HANDLE_IOCTL(FDSETPRM32, fd_ioctl_trans)
2449HANDLE_IOCTL(FDDEFPRM32, fd_ioctl_trans) 2453HANDLE_IOCTL(FDDEFPRM32, fd_ioctl_trans)
2450HANDLE_IOCTL(FDGETPRM32, fd_ioctl_trans) 2454HANDLE_IOCTL(FDGETPRM32, fd_ioctl_trans)
diff --git a/fs/configfs/file.c b/fs/configfs/file.c
index e6d5754a715e..cf33fac68c84 100644
--- a/fs/configfs/file.c
+++ b/fs/configfs/file.c
@@ -275,13 +275,14 @@ static int check_perm(struct inode * inode, struct file * file)
275 * it in file->private_data for easy access. 275 * it in file->private_data for easy access.
276 */ 276 */
277 buffer = kzalloc(sizeof(struct configfs_buffer),GFP_KERNEL); 277 buffer = kzalloc(sizeof(struct configfs_buffer),GFP_KERNEL);
278 if (buffer) { 278 if (!buffer) {
279 init_MUTEX(&buffer->sem);
280 buffer->needs_read_fill = 1;
281 buffer->ops = ops;
282 file->private_data = buffer;
283 } else
284 error = -ENOMEM; 279 error = -ENOMEM;
280 goto Enomem;
281 }
282 init_MUTEX(&buffer->sem);
283 buffer->needs_read_fill = 1;
284 buffer->ops = ops;
285 file->private_data = buffer;
285 goto Done; 286 goto Done;
286 287
287 Einval: 288 Einval:
@@ -289,6 +290,7 @@ static int check_perm(struct inode * inode, struct file * file)
289 goto Done; 290 goto Done;
290 Eaccess: 291 Eaccess:
291 error = -EACCES; 292 error = -EACCES;
293 Enomem:
292 module_put(attr->ca_owner); 294 module_put(attr->ca_owner);
293 Done: 295 Done:
294 if (error && item) 296 if (error && item)
diff --git a/fs/dcache.c b/fs/dcache.c
index 2355bddad8de..fd4a428998ef 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -478,11 +478,12 @@ static void prune_dcache(int count, struct super_block *sb)
478 up_read(s_umount); 478 up_read(s_umount);
479 } 479 }
480 spin_unlock(&dentry->d_lock); 480 spin_unlock(&dentry->d_lock);
481 /* Cannot remove the first dentry, and it isn't appropriate 481 /*
482 * to move it to the head of the list, so give up, and try 482 * Insert dentry at the head of the list as inserting at the
483 * later 483 * tail leads to a cycle.
484 */ 484 */
485 break; 485 list_add(&dentry->d_lru, &dentry_unused);
486 dentry_stat.nr_unused++;
486 } 487 }
487 spin_unlock(&dcache_lock); 488 spin_unlock(&dcache_lock);
488} 489}
@@ -549,6 +550,142 @@ repeat:
549} 550}
550 551
551/* 552/*
553 * destroy a single subtree of dentries for unmount
554 * - see the comments on shrink_dcache_for_umount() for a description of the
555 * locking
556 */
557static void shrink_dcache_for_umount_subtree(struct dentry *dentry)
558{
559 struct dentry *parent;
560 unsigned detached = 0;
561
562 BUG_ON(!IS_ROOT(dentry));
563
564 /* detach this root from the system */
565 spin_lock(&dcache_lock);
566 if (!list_empty(&dentry->d_lru)) {
567 dentry_stat.nr_unused--;
568 list_del_init(&dentry->d_lru);
569 }
570 __d_drop(dentry);
571 spin_unlock(&dcache_lock);
572
573 for (;;) {
574 /* descend to the first leaf in the current subtree */
575 while (!list_empty(&dentry->d_subdirs)) {
576 struct dentry *loop;
577
578 /* this is a branch with children - detach all of them
579 * from the system in one go */
580 spin_lock(&dcache_lock);
581 list_for_each_entry(loop, &dentry->d_subdirs,
582 d_u.d_child) {
583 if (!list_empty(&loop->d_lru)) {
584 dentry_stat.nr_unused--;
585 list_del_init(&loop->d_lru);
586 }
587
588 __d_drop(loop);
589 cond_resched_lock(&dcache_lock);
590 }
591 spin_unlock(&dcache_lock);
592
593 /* move to the first child */
594 dentry = list_entry(dentry->d_subdirs.next,
595 struct dentry, d_u.d_child);
596 }
597
598 /* consume the dentries from this leaf up through its parents
599 * until we find one with children or run out altogether */
600 do {
601 struct inode *inode;
602
603 if (atomic_read(&dentry->d_count) != 0) {
604 printk(KERN_ERR
605 "BUG: Dentry %p{i=%lx,n=%s}"
606 " still in use (%d)"
607 " [unmount of %s %s]\n",
608 dentry,
609 dentry->d_inode ?
610 dentry->d_inode->i_ino : 0UL,
611 dentry->d_name.name,
612 atomic_read(&dentry->d_count),
613 dentry->d_sb->s_type->name,
614 dentry->d_sb->s_id);
615 BUG();
616 }
617
618 parent = dentry->d_parent;
619 if (parent == dentry)
620 parent = NULL;
621 else
622 atomic_dec(&parent->d_count);
623
624 list_del(&dentry->d_u.d_child);
625 detached++;
626
627 inode = dentry->d_inode;
628 if (inode) {
629 dentry->d_inode = NULL;
630 list_del_init(&dentry->d_alias);
631 if (dentry->d_op && dentry->d_op->d_iput)
632 dentry->d_op->d_iput(dentry, inode);
633 else
634 iput(inode);
635 }
636
637 d_free(dentry);
638
639 /* finished when we fall off the top of the tree,
640 * otherwise we ascend to the parent and move to the
641 * next sibling if there is one */
642 if (!parent)
643 goto out;
644
645 dentry = parent;
646
647 } while (list_empty(&dentry->d_subdirs));
648
649 dentry = list_entry(dentry->d_subdirs.next,
650 struct dentry, d_u.d_child);
651 }
652out:
653 /* several dentries were freed, need to correct nr_dentry */
654 spin_lock(&dcache_lock);
655 dentry_stat.nr_dentry -= detached;
656 spin_unlock(&dcache_lock);
657}
658
659/*
660 * destroy the dentries attached to a superblock on unmounting
661 * - we don't need to use dentry->d_lock, and only need dcache_lock when
662 * removing the dentry from the system lists and hashes because:
663 * - the superblock is detached from all mountings and open files, so the
664 * dentry trees will not be rearranged by the VFS
665 * - s_umount is write-locked, so the memory pressure shrinker will ignore
666 * any dentries belonging to this superblock that it comes across
667 * - the filesystem itself is no longer permitted to rearrange the dentries
668 * in this superblock
669 */
670void shrink_dcache_for_umount(struct super_block *sb)
671{
672 struct dentry *dentry;
673
674 if (down_read_trylock(&sb->s_umount))
675 BUG();
676
677 dentry = sb->s_root;
678 sb->s_root = NULL;
679 atomic_dec(&dentry->d_count);
680 shrink_dcache_for_umount_subtree(dentry);
681
682 while (!hlist_empty(&sb->s_anon)) {
683 dentry = hlist_entry(sb->s_anon.first, struct dentry, d_hash);
684 shrink_dcache_for_umount_subtree(dentry);
685 }
686}
687
688/*
552 * Search for at least 1 mount point in the dentry's subdirs. 689 * Search for at least 1 mount point in the dentry's subdirs.
553 * We descend to the next level whenever the d_subdirs 690 * We descend to the next level whenever the d_subdirs
554 * list is non-empty and continue searching. 691 * list is non-empty and continue searching.
@@ -1339,23 +1476,21 @@ static void switch_names(struct dentry *dentry, struct dentry *target)
1339 * deleted it. 1476 * deleted it.
1340 */ 1477 */
1341 1478
1342/** 1479/*
1343 * d_move - move a dentry 1480 * d_move_locked - move a dentry
1344 * @dentry: entry to move 1481 * @dentry: entry to move
1345 * @target: new dentry 1482 * @target: new dentry
1346 * 1483 *
1347 * Update the dcache to reflect the move of a file name. Negative 1484 * Update the dcache to reflect the move of a file name. Negative
1348 * dcache entries should not be moved in this way. 1485 * dcache entries should not be moved in this way.
1349 */ 1486 */
1350 1487static void d_move_locked(struct dentry * dentry, struct dentry * target)
1351void d_move(struct dentry * dentry, struct dentry * target)
1352{ 1488{
1353 struct hlist_head *list; 1489 struct hlist_head *list;
1354 1490
1355 if (!dentry->d_inode) 1491 if (!dentry->d_inode)
1356 printk(KERN_WARNING "VFS: moving negative dcache entry\n"); 1492 printk(KERN_WARNING "VFS: moving negative dcache entry\n");
1357 1493
1358 spin_lock(&dcache_lock);
1359 write_seqlock(&rename_lock); 1494 write_seqlock(&rename_lock);
1360 /* 1495 /*
1361 * XXXX: do we really need to take target->d_lock? 1496 * XXXX: do we really need to take target->d_lock?
@@ -1406,7 +1541,81 @@ already_unhashed:
1406 fsnotify_d_move(dentry); 1541 fsnotify_d_move(dentry);
1407 spin_unlock(&dentry->d_lock); 1542 spin_unlock(&dentry->d_lock);
1408 write_sequnlock(&rename_lock); 1543 write_sequnlock(&rename_lock);
1544}
1545
1546/**
1547 * d_move - move a dentry
1548 * @dentry: entry to move
1549 * @target: new dentry
1550 *
1551 * Update the dcache to reflect the move of a file name. Negative
1552 * dcache entries should not be moved in this way.
1553 */
1554
1555void d_move(struct dentry * dentry, struct dentry * target)
1556{
1557 spin_lock(&dcache_lock);
1558 d_move_locked(dentry, target);
1559 spin_unlock(&dcache_lock);
1560}
1561
1562/*
1563 * Helper that returns 1 if p1 is a parent of p2, else 0
1564 */
1565static int d_isparent(struct dentry *p1, struct dentry *p2)
1566{
1567 struct dentry *p;
1568
1569 for (p = p2; p->d_parent != p; p = p->d_parent) {
1570 if (p->d_parent == p1)
1571 return 1;
1572 }
1573 return 0;
1574}
1575
1576/*
1577 * This helper attempts to cope with remotely renamed directories
1578 *
1579 * It assumes that the caller is already holding
1580 * dentry->d_parent->d_inode->i_mutex and the dcache_lock
1581 *
1582 * Note: If ever the locking in lock_rename() changes, then please
1583 * remember to update this too...
1584 *
1585 * On return, dcache_lock will have been unlocked.
1586 */
1587static struct dentry *__d_unalias(struct dentry *dentry, struct dentry *alias)
1588{
1589 struct mutex *m1 = NULL, *m2 = NULL;
1590 struct dentry *ret;
1591
1592 /* If alias and dentry share a parent, then no extra locks required */
1593 if (alias->d_parent == dentry->d_parent)
1594 goto out_unalias;
1595
1596 /* Check for loops */
1597 ret = ERR_PTR(-ELOOP);
1598 if (d_isparent(alias, dentry))
1599 goto out_err;
1600
1601 /* See lock_rename() */
1602 ret = ERR_PTR(-EBUSY);
1603 if (!mutex_trylock(&dentry->d_sb->s_vfs_rename_mutex))
1604 goto out_err;
1605 m1 = &dentry->d_sb->s_vfs_rename_mutex;
1606 if (!mutex_trylock(&alias->d_parent->d_inode->i_mutex))
1607 goto out_err;
1608 m2 = &alias->d_parent->d_inode->i_mutex;
1609out_unalias:
1610 d_move_locked(alias, dentry);
1611 ret = alias;
1612out_err:
1409 spin_unlock(&dcache_lock); 1613 spin_unlock(&dcache_lock);
1614 if (m2)
1615 mutex_unlock(m2);
1616 if (m1)
1617 mutex_unlock(m1);
1618 return ret;
1410} 1619}
1411 1620
1412/* 1621/*
@@ -1451,7 +1660,7 @@ static void __d_materialise_dentry(struct dentry *dentry, struct dentry *anon)
1451 */ 1660 */
1452struct dentry *d_materialise_unique(struct dentry *dentry, struct inode *inode) 1661struct dentry *d_materialise_unique(struct dentry *dentry, struct inode *inode)
1453{ 1662{
1454 struct dentry *alias, *actual; 1663 struct dentry *actual;
1455 1664
1456 BUG_ON(!d_unhashed(dentry)); 1665 BUG_ON(!d_unhashed(dentry));
1457 1666
@@ -1463,26 +1672,27 @@ struct dentry *d_materialise_unique(struct dentry *dentry, struct inode *inode)
1463 goto found_lock; 1672 goto found_lock;
1464 } 1673 }
1465 1674
1466 /* See if a disconnected directory already exists as an anonymous root 1675 if (S_ISDIR(inode->i_mode)) {
1467 * that we should splice into the tree instead */ 1676 struct dentry *alias;
1468 if (S_ISDIR(inode->i_mode) && (alias = __d_find_alias(inode, 1))) { 1677
1469 spin_lock(&alias->d_lock); 1678 /* Does an aliased dentry already exist? */
1470 1679 alias = __d_find_alias(inode, 0);
1471 /* Is this a mountpoint that we could splice into our tree? */ 1680 if (alias) {
1472 if (IS_ROOT(alias)) 1681 actual = alias;
1473 goto connect_mountpoint; 1682 /* Is this an anonymous mountpoint that we could splice
1474 1683 * into our tree? */
1475 if (alias->d_name.len == dentry->d_name.len && 1684 if (IS_ROOT(alias)) {
1476 alias->d_parent == dentry->d_parent && 1685 spin_lock(&alias->d_lock);
1477 memcmp(alias->d_name.name, 1686 __d_materialise_dentry(dentry, alias);
1478 dentry->d_name.name, 1687 __d_drop(alias);
1479 dentry->d_name.len) == 0) 1688 goto found;
1480 goto replace_with_alias; 1689 }
1481 1690 /* Nope, but we must(!) avoid directory aliasing */
1482 spin_unlock(&alias->d_lock); 1691 actual = __d_unalias(dentry, alias);
1483 1692 if (IS_ERR(actual))
1484 /* Doh! Seem to be aliasing directories for some reason... */ 1693 dput(alias);
1485 dput(alias); 1694 goto out_nolock;
1695 }
1486 } 1696 }
1487 1697
1488 /* Add a unique reference */ 1698 /* Add a unique reference */
@@ -1498,7 +1708,7 @@ found:
1498 _d_rehash(actual); 1708 _d_rehash(actual);
1499 spin_unlock(&actual->d_lock); 1709 spin_unlock(&actual->d_lock);
1500 spin_unlock(&dcache_lock); 1710 spin_unlock(&dcache_lock);
1501 1711out_nolock:
1502 if (actual == dentry) { 1712 if (actual == dentry) {
1503 security_d_instantiate(dentry, inode); 1713 security_d_instantiate(dentry, inode);
1504 return NULL; 1714 return NULL;
@@ -1507,16 +1717,6 @@ found:
1507 iput(inode); 1717 iput(inode);
1508 return actual; 1718 return actual;
1509 1719
1510 /* Convert the anonymous/root alias into an ordinary dentry */
1511connect_mountpoint:
1512 __d_materialise_dentry(dentry, alias);
1513
1514 /* Replace the candidate dentry with the alias in the tree */
1515replace_with_alias:
1516 __d_drop(alias);
1517 actual = alias;
1518 goto found;
1519
1520shouldnt_be_hashed: 1720shouldnt_be_hashed:
1521 spin_unlock(&dcache_lock); 1721 spin_unlock(&dcache_lock);
1522 BUG(); 1722 BUG();
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index e77676df6713..a736d44989c4 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -147,13 +147,13 @@ static int debugfs_create_by_name(const char *name, mode_t mode,
147 *dentry = NULL; 147 *dentry = NULL;
148 mutex_lock(&parent->d_inode->i_mutex); 148 mutex_lock(&parent->d_inode->i_mutex);
149 *dentry = lookup_one_len(name, parent, strlen(name)); 149 *dentry = lookup_one_len(name, parent, strlen(name));
150 if (!IS_ERR(dentry)) { 150 if (!IS_ERR(*dentry)) {
151 if ((mode & S_IFMT) == S_IFDIR) 151 if ((mode & S_IFMT) == S_IFDIR)
152 error = debugfs_mkdir(parent->d_inode, *dentry, mode); 152 error = debugfs_mkdir(parent->d_inode, *dentry, mode);
153 else 153 else
154 error = debugfs_create(parent->d_inode, *dentry, mode); 154 error = debugfs_create(parent->d_inode, *dentry, mode);
155 } else 155 } else
156 error = PTR_ERR(dentry); 156 error = PTR_ERR(*dentry);
157 mutex_unlock(&parent->d_inode->i_mutex); 157 mutex_unlock(&parent->d_inode->i_mutex);
158 158
159 return error; 159 return error;
diff --git a/fs/dlm/Kconfig b/fs/dlm/Kconfig
index 490f85b3fa59..81b2c6465eeb 100644
--- a/fs/dlm/Kconfig
+++ b/fs/dlm/Kconfig
@@ -1,10 +1,9 @@
1menu "Distributed Lock Manager" 1menu "Distributed Lock Manager"
2 depends on INET && EXPERIMENTAL 2 depends on INET && IP_SCTP && EXPERIMENTAL
3 3
4config DLM 4config DLM
5 tristate "Distributed Lock Manager (DLM)" 5 tristate "Distributed Lock Manager (DLM)"
6 depends on IPV6 || IPV6=n 6 depends on IPV6 || IPV6=n
7 depends on IP_SCTP
8 select CONFIGFS_FS 7 select CONFIGFS_FS
9 help 8 help
10 A general purpose distributed lock manager for kernel or userspace 9 A general purpose distributed lock manager for kernel or userspace
diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
index 109333c8ecb9..f8842ca443c2 100644
--- a/fs/dlm/lockspace.c
+++ b/fs/dlm/lockspace.c
@@ -43,6 +43,10 @@ static ssize_t dlm_control_store(struct dlm_ls *ls, const char *buf, size_t len)
43 ssize_t ret = len; 43 ssize_t ret = len;
44 int n = simple_strtol(buf, NULL, 0); 44 int n = simple_strtol(buf, NULL, 0);
45 45
46 ls = dlm_find_lockspace_local(ls->ls_local_handle);
47 if (!ls)
48 return -EINVAL;
49
46 switch (n) { 50 switch (n) {
47 case 0: 51 case 0:
48 dlm_ls_stop(ls); 52 dlm_ls_stop(ls);
@@ -53,6 +57,7 @@ static ssize_t dlm_control_store(struct dlm_ls *ls, const char *buf, size_t len)
53 default: 57 default:
54 ret = -EINVAL; 58 ret = -EINVAL;
55 } 59 }
60 dlm_put_lockspace(ls);
56 return ret; 61 return ret;
57} 62}
58 63
@@ -143,6 +148,12 @@ static ssize_t dlm_attr_store(struct kobject *kobj, struct attribute *attr,
143 return a->store ? a->store(ls, buf, len) : len; 148 return a->store ? a->store(ls, buf, len) : len;
144} 149}
145 150
151static void lockspace_kobj_release(struct kobject *k)
152{
153 struct dlm_ls *ls = container_of(k, struct dlm_ls, ls_kobj);
154 kfree(ls);
155}
156
146static struct sysfs_ops dlm_attr_ops = { 157static struct sysfs_ops dlm_attr_ops = {
147 .show = dlm_attr_show, 158 .show = dlm_attr_show,
148 .store = dlm_attr_store, 159 .store = dlm_attr_store,
@@ -151,6 +162,7 @@ static struct sysfs_ops dlm_attr_ops = {
151static struct kobj_type dlm_ktype = { 162static struct kobj_type dlm_ktype = {
152 .default_attrs = dlm_attrs, 163 .default_attrs = dlm_attrs,
153 .sysfs_ops = &dlm_attr_ops, 164 .sysfs_ops = &dlm_attr_ops,
165 .release = lockspace_kobj_release,
154}; 166};
155 167
156static struct kset dlm_kset = { 168static struct kset dlm_kset = {
@@ -678,7 +690,7 @@ static int release_lockspace(struct dlm_ls *ls, int force)
678 dlm_clear_members_gone(ls); 690 dlm_clear_members_gone(ls);
679 kfree(ls->ls_node_array); 691 kfree(ls->ls_node_array);
680 kobject_unregister(&ls->ls_kobj); 692 kobject_unregister(&ls->ls_kobj);
681 kfree(ls); 693 /* The ls structure will be freed when the kobject is done with */
682 694
683 mutex_lock(&ls_lock); 695 mutex_lock(&ls_lock);
684 ls_count--; 696 ls_count--;
diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
index 7bcea7c5addb..6da6b14d5a61 100644
--- a/fs/dlm/lowcomms.c
+++ b/fs/dlm/lowcomms.c
@@ -519,6 +519,7 @@ static int receive_from_sock(void)
519 msg.msg_flags = 0; 519 msg.msg_flags = 0;
520 msg.msg_control = incmsg; 520 msg.msg_control = incmsg;
521 msg.msg_controllen = sizeof(incmsg); 521 msg.msg_controllen = sizeof(incmsg);
522 msg.msg_iovlen = 1;
522 523
523 /* I don't see why this circular buffer stuff is necessary for SCTP 524 /* I don't see why this circular buffer stuff is necessary for SCTP
524 * which is a packet-based protocol, but the whole thing breaks under 525 * which is a packet-based protocol, but the whole thing breaks under
@@ -548,7 +549,7 @@ static int receive_from_sock(void)
548 } 549 }
549 len = iov[0].iov_len + iov[1].iov_len; 550 len = iov[0].iov_len + iov[1].iov_len;
550 551
551 r = ret = kernel_recvmsg(sctp_con.sock, &msg, iov, 1, len, 552 r = ret = kernel_recvmsg(sctp_con.sock, &msg, iov, msg.msg_iovlen, len,
552 MSG_NOSIGNAL | MSG_DONTWAIT); 553 MSG_NOSIGNAL | MSG_DONTWAIT);
553 if (ret <= 0) 554 if (ret <= 0)
554 goto out_close; 555 goto out_close;
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index ed35a9712fa1..136175a69332 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -94,25 +94,53 @@ static int ecryptfs_calculate_md5(char *dst,
94 struct ecryptfs_crypt_stat *crypt_stat, 94 struct ecryptfs_crypt_stat *crypt_stat,
95 char *src, int len) 95 char *src, int len)
96{ 96{
97 int rc = 0;
98 struct scatterlist sg; 97 struct scatterlist sg;
98 struct hash_desc desc = {
99 .tfm = crypt_stat->hash_tfm,
100 .flags = CRYPTO_TFM_REQ_MAY_SLEEP
101 };
102 int rc = 0;
99 103
100 mutex_lock(&crypt_stat->cs_md5_tfm_mutex); 104 mutex_lock(&crypt_stat->cs_hash_tfm_mutex);
101 sg_init_one(&sg, (u8 *)src, len); 105 sg_init_one(&sg, (u8 *)src, len);
102 if (!crypt_stat->md5_tfm) { 106 if (!desc.tfm) {
103 crypt_stat->md5_tfm = 107 desc.tfm = crypto_alloc_hash(ECRYPTFS_DEFAULT_HASH, 0,
104 crypto_alloc_tfm("md5", CRYPTO_TFM_REQ_MAY_SLEEP); 108 CRYPTO_ALG_ASYNC);
105 if (!crypt_stat->md5_tfm) { 109 if (IS_ERR(desc.tfm)) {
106 rc = -ENOMEM; 110 rc = PTR_ERR(desc.tfm);
107 ecryptfs_printk(KERN_ERR, "Error attempting to " 111 ecryptfs_printk(KERN_ERR, "Error attempting to "
108 "allocate crypto context\n"); 112 "allocate crypto context; rc = [%d]\n",
113 rc);
109 goto out; 114 goto out;
110 } 115 }
116 crypt_stat->hash_tfm = desc.tfm;
111 } 117 }
112 crypto_digest_init(crypt_stat->md5_tfm); 118 crypto_hash_init(&desc);
113 crypto_digest_update(crypt_stat->md5_tfm, &sg, 1); 119 crypto_hash_update(&desc, &sg, len);
114 crypto_digest_final(crypt_stat->md5_tfm, dst); 120 crypto_hash_final(&desc, dst);
115 mutex_unlock(&crypt_stat->cs_md5_tfm_mutex); 121 mutex_unlock(&crypt_stat->cs_hash_tfm_mutex);
122out:
123 return rc;
124}
125
126int ecryptfs_crypto_api_algify_cipher_name(char **algified_name,
127 char *cipher_name,
128 char *chaining_modifier)
129{
130 int cipher_name_len = strlen(cipher_name);
131 int chaining_modifier_len = strlen(chaining_modifier);
132 int algified_name_len;
133 int rc;
134
135 algified_name_len = (chaining_modifier_len + cipher_name_len + 3);
136 (*algified_name) = kmalloc(algified_name_len, GFP_KERNEL);
137 if (!(*algified_name)) {
138 rc = -ENOMEM;
139 goto out;
140 }
141 snprintf((*algified_name), algified_name_len, "%s(%s)",
142 chaining_modifier, cipher_name);
143 rc = 0;
116out: 144out:
117 return rc; 145 return rc;
118} 146}
@@ -178,7 +206,7 @@ ecryptfs_init_crypt_stat(struct ecryptfs_crypt_stat *crypt_stat)
178 memset((void *)crypt_stat, 0, sizeof(struct ecryptfs_crypt_stat)); 206 memset((void *)crypt_stat, 0, sizeof(struct ecryptfs_crypt_stat));
179 mutex_init(&crypt_stat->cs_mutex); 207 mutex_init(&crypt_stat->cs_mutex);
180 mutex_init(&crypt_stat->cs_tfm_mutex); 208 mutex_init(&crypt_stat->cs_tfm_mutex);
181 mutex_init(&crypt_stat->cs_md5_tfm_mutex); 209 mutex_init(&crypt_stat->cs_hash_tfm_mutex);
182 ECRYPTFS_SET_FLAG(crypt_stat->flags, ECRYPTFS_STRUCT_INITIALIZED); 210 ECRYPTFS_SET_FLAG(crypt_stat->flags, ECRYPTFS_STRUCT_INITIALIZED);
183} 211}
184 212
@@ -191,9 +219,9 @@ ecryptfs_init_crypt_stat(struct ecryptfs_crypt_stat *crypt_stat)
191void ecryptfs_destruct_crypt_stat(struct ecryptfs_crypt_stat *crypt_stat) 219void ecryptfs_destruct_crypt_stat(struct ecryptfs_crypt_stat *crypt_stat)
192{ 220{
193 if (crypt_stat->tfm) 221 if (crypt_stat->tfm)
194 crypto_free_tfm(crypt_stat->tfm); 222 crypto_free_blkcipher(crypt_stat->tfm);
195 if (crypt_stat->md5_tfm) 223 if (crypt_stat->hash_tfm)
196 crypto_free_tfm(crypt_stat->md5_tfm); 224 crypto_free_hash(crypt_stat->hash_tfm);
197 memset(crypt_stat, 0, sizeof(struct ecryptfs_crypt_stat)); 225 memset(crypt_stat, 0, sizeof(struct ecryptfs_crypt_stat));
198} 226}
199 227
@@ -203,7 +231,7 @@ void ecryptfs_destruct_mount_crypt_stat(
203 if (mount_crypt_stat->global_auth_tok_key) 231 if (mount_crypt_stat->global_auth_tok_key)
204 key_put(mount_crypt_stat->global_auth_tok_key); 232 key_put(mount_crypt_stat->global_auth_tok_key);
205 if (mount_crypt_stat->global_key_tfm) 233 if (mount_crypt_stat->global_key_tfm)
206 crypto_free_tfm(mount_crypt_stat->global_key_tfm); 234 crypto_free_blkcipher(mount_crypt_stat->global_key_tfm);
207 memset(mount_crypt_stat, 0, sizeof(struct ecryptfs_mount_crypt_stat)); 235 memset(mount_crypt_stat, 0, sizeof(struct ecryptfs_mount_crypt_stat));
208} 236}
209 237
@@ -269,6 +297,11 @@ static int encrypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat,
269 struct scatterlist *src_sg, int size, 297 struct scatterlist *src_sg, int size,
270 unsigned char *iv) 298 unsigned char *iv)
271{ 299{
300 struct blkcipher_desc desc = {
301 .tfm = crypt_stat->tfm,
302 .info = iv,
303 .flags = CRYPTO_TFM_REQ_MAY_SLEEP
304 };
272 int rc = 0; 305 int rc = 0;
273 306
274 BUG_ON(!crypt_stat || !crypt_stat->tfm 307 BUG_ON(!crypt_stat || !crypt_stat->tfm
@@ -282,8 +315,8 @@ static int encrypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat,
282 } 315 }
283 /* Consider doing this once, when the file is opened */ 316 /* Consider doing this once, when the file is opened */
284 mutex_lock(&crypt_stat->cs_tfm_mutex); 317 mutex_lock(&crypt_stat->cs_tfm_mutex);
285 rc = crypto_cipher_setkey(crypt_stat->tfm, crypt_stat->key, 318 rc = crypto_blkcipher_setkey(crypt_stat->tfm, crypt_stat->key,
286 crypt_stat->key_size); 319 crypt_stat->key_size);
287 if (rc) { 320 if (rc) {
288 ecryptfs_printk(KERN_ERR, "Error setting key; rc = [%d]\n", 321 ecryptfs_printk(KERN_ERR, "Error setting key; rc = [%d]\n",
289 rc); 322 rc);
@@ -292,7 +325,7 @@ static int encrypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat,
292 goto out; 325 goto out;
293 } 326 }
294 ecryptfs_printk(KERN_DEBUG, "Encrypting [%d] bytes.\n", size); 327 ecryptfs_printk(KERN_DEBUG, "Encrypting [%d] bytes.\n", size);
295 crypto_cipher_encrypt_iv(crypt_stat->tfm, dest_sg, src_sg, size, iv); 328 crypto_blkcipher_encrypt_iv(&desc, dest_sg, src_sg, size);
296 mutex_unlock(&crypt_stat->cs_tfm_mutex); 329 mutex_unlock(&crypt_stat->cs_tfm_mutex);
297out: 330out:
298 return rc; 331 return rc;
@@ -675,12 +708,17 @@ static int decrypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat,
675 struct scatterlist *src_sg, int size, 708 struct scatterlist *src_sg, int size,
676 unsigned char *iv) 709 unsigned char *iv)
677{ 710{
711 struct blkcipher_desc desc = {
712 .tfm = crypt_stat->tfm,
713 .info = iv,
714 .flags = CRYPTO_TFM_REQ_MAY_SLEEP
715 };
678 int rc = 0; 716 int rc = 0;
679 717
680 /* Consider doing this once, when the file is opened */ 718 /* Consider doing this once, when the file is opened */
681 mutex_lock(&crypt_stat->cs_tfm_mutex); 719 mutex_lock(&crypt_stat->cs_tfm_mutex);
682 rc = crypto_cipher_setkey(crypt_stat->tfm, crypt_stat->key, 720 rc = crypto_blkcipher_setkey(crypt_stat->tfm, crypt_stat->key,
683 crypt_stat->key_size); 721 crypt_stat->key_size);
684 if (rc) { 722 if (rc) {
685 ecryptfs_printk(KERN_ERR, "Error setting key; rc = [%d]\n", 723 ecryptfs_printk(KERN_ERR, "Error setting key; rc = [%d]\n",
686 rc); 724 rc);
@@ -689,8 +727,7 @@ static int decrypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat,
689 goto out; 727 goto out;
690 } 728 }
691 ecryptfs_printk(KERN_DEBUG, "Decrypting [%d] bytes.\n", size); 729 ecryptfs_printk(KERN_DEBUG, "Decrypting [%d] bytes.\n", size);
692 rc = crypto_cipher_decrypt_iv(crypt_stat->tfm, dest_sg, src_sg, size, 730 rc = crypto_blkcipher_decrypt_iv(&desc, dest_sg, src_sg, size);
693 iv);
694 mutex_unlock(&crypt_stat->cs_tfm_mutex); 731 mutex_unlock(&crypt_stat->cs_tfm_mutex);
695 if (rc) { 732 if (rc) {
696 ecryptfs_printk(KERN_ERR, "Error decrypting; rc = [%d]\n", 733 ecryptfs_printk(KERN_ERR, "Error decrypting; rc = [%d]\n",
@@ -759,6 +796,7 @@ ecryptfs_decrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat,
759 */ 796 */
760int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat) 797int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat)
761{ 798{
799 char *full_alg_name;
762 int rc = -EINVAL; 800 int rc = -EINVAL;
763 801
764 if (!crypt_stat->cipher) { 802 if (!crypt_stat->cipher) {
@@ -775,16 +813,24 @@ int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat)
775 goto out; 813 goto out;
776 } 814 }
777 mutex_lock(&crypt_stat->cs_tfm_mutex); 815 mutex_lock(&crypt_stat->cs_tfm_mutex);
778 crypt_stat->tfm = crypto_alloc_tfm(crypt_stat->cipher, 816 rc = ecryptfs_crypto_api_algify_cipher_name(&full_alg_name,
779 ECRYPTFS_DEFAULT_CHAINING_MODE 817 crypt_stat->cipher, "cbc");
780 | CRYPTO_TFM_REQ_WEAK_KEY); 818 if (rc)
781 mutex_unlock(&crypt_stat->cs_tfm_mutex); 819 goto out;
820 crypt_stat->tfm = crypto_alloc_blkcipher(full_alg_name, 0,
821 CRYPTO_ALG_ASYNC);
822 kfree(full_alg_name);
782 if (!crypt_stat->tfm) { 823 if (!crypt_stat->tfm) {
783 ecryptfs_printk(KERN_ERR, "cryptfs: init_crypt_ctx(): " 824 ecryptfs_printk(KERN_ERR, "cryptfs: init_crypt_ctx(): "
784 "Error initializing cipher [%s]\n", 825 "Error initializing cipher [%s]\n",
785 crypt_stat->cipher); 826 crypt_stat->cipher);
827 mutex_unlock(&crypt_stat->cs_tfm_mutex);
786 goto out; 828 goto out;
787 } 829 }
830 crypto_blkcipher_set_flags(crypt_stat->tfm,
831 (ECRYPTFS_DEFAULT_CHAINING_MODE
832 | CRYPTO_TFM_REQ_WEAK_KEY));
833 mutex_unlock(&crypt_stat->cs_tfm_mutex);
788 rc = 0; 834 rc = 0;
789out: 835out:
790 return rc; 836 return rc;
@@ -1145,28 +1191,28 @@ int ecryptfs_cipher_code_to_string(char *str, u16 cipher_code)
1145int ecryptfs_read_header_region(char *data, struct dentry *dentry, 1191int ecryptfs_read_header_region(char *data, struct dentry *dentry,
1146 struct vfsmount *mnt) 1192 struct vfsmount *mnt)
1147{ 1193{
1148 struct file *file; 1194 struct file *lower_file;
1149 mm_segment_t oldfs; 1195 mm_segment_t oldfs;
1150 int rc; 1196 int rc;
1151 1197
1152 mnt = mntget(mnt); 1198 if ((rc = ecryptfs_open_lower_file(&lower_file, dentry, mnt,
1153 file = dentry_open(dentry, mnt, O_RDONLY); 1199 O_RDONLY))) {
1154 if (IS_ERR(file)) { 1200 printk(KERN_ERR
1155 ecryptfs_printk(KERN_DEBUG, "Error opening file to " 1201 "Error opening lower_file to read header region\n");
1156 "read header region\n");
1157 mntput(mnt);
1158 rc = PTR_ERR(file);
1159 goto out; 1202 goto out;
1160 } 1203 }
1161 file->f_pos = 0; 1204 lower_file->f_pos = 0;
1162 oldfs = get_fs(); 1205 oldfs = get_fs();
1163 set_fs(get_ds()); 1206 set_fs(get_ds());
1164 /* For releases 0.1 and 0.2, all of the header information 1207 /* For releases 0.1 and 0.2, all of the header information
1165 * fits in the first data extent-sized region. */ 1208 * fits in the first data extent-sized region. */
1166 rc = file->f_op->read(file, (char __user *)data, 1209 rc = lower_file->f_op->read(lower_file, (char __user *)data,
1167 ECRYPTFS_DEFAULT_EXTENT_SIZE, &file->f_pos); 1210 ECRYPTFS_DEFAULT_EXTENT_SIZE, &lower_file->f_pos);
1168 set_fs(oldfs); 1211 set_fs(oldfs);
1169 fput(file); 1212 if ((rc = ecryptfs_close_lower_file(lower_file))) {
1213 printk(KERN_ERR "Error closing lower_file\n");
1214 goto out;
1215 }
1170 rc = 0; 1216 rc = 0;
1171out: 1217out:
1172 return rc; 1218 return rc;
@@ -1573,84 +1619,52 @@ out:
1573 1619
1574/** 1620/**
1575 * ecryptfs_process_cipher - Perform cipher initialization. 1621 * ecryptfs_process_cipher - Perform cipher initialization.
1576 * @tfm: Crypto context set by this function
1577 * @key_tfm: Crypto context for key material, set by this function 1622 * @key_tfm: Crypto context for key material, set by this function
1578 * @cipher_name: Name of the cipher. 1623 * @cipher_name: Name of the cipher
1579 * @key_size: Size of the key in bytes. 1624 * @key_size: Size of the key in bytes
1580 * 1625 *
1581 * Returns zero on success. Any crypto_tfm structs allocated here 1626 * Returns zero on success. Any crypto_tfm structs allocated here
1582 * should be released by other functions, such as on a superblock put 1627 * should be released by other functions, such as on a superblock put
1583 * event, regardless of whether this function succeeds for fails. 1628 * event, regardless of whether this function succeeds for fails.
1584 */ 1629 */
1585int 1630int
1586ecryptfs_process_cipher(struct crypto_tfm **tfm, struct crypto_tfm **key_tfm, 1631ecryptfs_process_cipher(struct crypto_blkcipher **key_tfm, char *cipher_name,
1587 char *cipher_name, size_t key_size) 1632 size_t *key_size)
1588{ 1633{
1589 char dummy_key[ECRYPTFS_MAX_KEY_BYTES]; 1634 char dummy_key[ECRYPTFS_MAX_KEY_BYTES];
1635 char *full_alg_name;
1590 int rc; 1636 int rc;
1591 1637
1592 *tfm = *key_tfm = NULL; 1638 *key_tfm = NULL;
1593 if (key_size > ECRYPTFS_MAX_KEY_BYTES) { 1639 if (*key_size > ECRYPTFS_MAX_KEY_BYTES) {
1594 rc = -EINVAL; 1640 rc = -EINVAL;
1595 printk(KERN_ERR "Requested key size is [%Zd] bytes; maximum " 1641 printk(KERN_ERR "Requested key size is [%Zd] bytes; maximum "
1596 "allowable is [%d]\n", key_size, ECRYPTFS_MAX_KEY_BYTES); 1642 "allowable is [%d]\n", *key_size, ECRYPTFS_MAX_KEY_BYTES);
1597 goto out; 1643 goto out;
1598 } 1644 }
1599 *tfm = crypto_alloc_tfm(cipher_name, (ECRYPTFS_DEFAULT_CHAINING_MODE 1645 rc = ecryptfs_crypto_api_algify_cipher_name(&full_alg_name, cipher_name,
1600 | CRYPTO_TFM_REQ_WEAK_KEY)); 1646 "ecb");
1601 if (!(*tfm)) { 1647 if (rc)
1602 rc = -EINVAL;
1603 printk(KERN_ERR "Unable to allocate crypto cipher with name "
1604 "[%s]\n", cipher_name);
1605 goto out; 1648 goto out;
1606 } 1649 *key_tfm = crypto_alloc_blkcipher(full_alg_name, 0, CRYPTO_ALG_ASYNC);
1607 *key_tfm = crypto_alloc_tfm(cipher_name, CRYPTO_TFM_REQ_WEAK_KEY); 1650 kfree(full_alg_name);
1608 if (!(*key_tfm)) { 1651 if (IS_ERR(*key_tfm)) {
1609 rc = -EINVAL; 1652 rc = PTR_ERR(*key_tfm);
1610 printk(KERN_ERR "Unable to allocate crypto cipher with name " 1653 printk(KERN_ERR "Unable to allocate crypto cipher with name "
1611 "[%s]\n", cipher_name); 1654 "[%s]; rc = [%d]\n", cipher_name, rc);
1612 goto out;
1613 }
1614 if (key_size < crypto_tfm_alg_min_keysize(*tfm)) {
1615 rc = -EINVAL;
1616 printk(KERN_ERR "Request key size is [%Zd]; minimum key size "
1617 "supported by cipher [%s] is [%d]\n", key_size,
1618 cipher_name, crypto_tfm_alg_min_keysize(*tfm));
1619 goto out;
1620 }
1621 if (key_size < crypto_tfm_alg_min_keysize(*key_tfm)) {
1622 rc = -EINVAL;
1623 printk(KERN_ERR "Request key size is [%Zd]; minimum key size "
1624 "supported by cipher [%s] is [%d]\n", key_size,
1625 cipher_name, crypto_tfm_alg_min_keysize(*key_tfm));
1626 goto out; 1655 goto out;
1627 } 1656 }
1628 if (key_size > crypto_tfm_alg_max_keysize(*tfm)) { 1657 crypto_blkcipher_set_flags(*key_tfm, CRYPTO_TFM_REQ_WEAK_KEY);
1629 rc = -EINVAL; 1658 if (*key_size == 0) {
1630 printk(KERN_ERR "Request key size is [%Zd]; maximum key size " 1659 struct blkcipher_alg *alg = crypto_blkcipher_alg(*key_tfm);
1631 "supported by cipher [%s] is [%d]\n", key_size, 1660
1632 cipher_name, crypto_tfm_alg_min_keysize(*tfm)); 1661 *key_size = alg->max_keysize;
1633 goto out;
1634 }
1635 if (key_size > crypto_tfm_alg_max_keysize(*key_tfm)) {
1636 rc = -EINVAL;
1637 printk(KERN_ERR "Request key size is [%Zd]; maximum key size "
1638 "supported by cipher [%s] is [%d]\n", key_size,
1639 cipher_name, crypto_tfm_alg_min_keysize(*key_tfm));
1640 goto out;
1641 }
1642 get_random_bytes(dummy_key, key_size);
1643 rc = crypto_cipher_setkey(*tfm, dummy_key, key_size);
1644 if (rc) {
1645 printk(KERN_ERR "Error attempting to set key of size [%Zd] for "
1646 "cipher [%s]; rc = [%d]\n", key_size, cipher_name, rc);
1647 rc = -EINVAL;
1648 goto out;
1649 } 1662 }
1650 rc = crypto_cipher_setkey(*key_tfm, dummy_key, key_size); 1663 get_random_bytes(dummy_key, *key_size);
1664 rc = crypto_blkcipher_setkey(*key_tfm, dummy_key, *key_size);
1651 if (rc) { 1665 if (rc) {
1652 printk(KERN_ERR "Error attempting to set key of size [%Zd] for " 1666 printk(KERN_ERR "Error attempting to set key of size [%Zd] for "
1653 "cipher [%s]; rc = [%d]\n", key_size, cipher_name, rc); 1667 "cipher [%s]; rc = [%d]\n", *key_size, cipher_name, rc);
1654 rc = -EINVAL; 1668 rc = -EINVAL;
1655 goto out; 1669 goto out;
1656 } 1670 }
diff --git a/fs/ecryptfs/dentry.c b/fs/ecryptfs/dentry.c
index f0d2a433242b..52d1e36dc746 100644
--- a/fs/ecryptfs/dentry.c
+++ b/fs/ecryptfs/dentry.c
@@ -24,6 +24,7 @@
24 24
25#include <linux/dcache.h> 25#include <linux/dcache.h>
26#include <linux/namei.h> 26#include <linux/namei.h>
27#include <linux/mount.h>
27#include "ecryptfs_kernel.h" 28#include "ecryptfs_kernel.h"
28 29
29/** 30/**
@@ -56,6 +57,12 @@ static int ecryptfs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
56 rc = lower_dentry->d_op->d_revalidate(lower_dentry, nd); 57 rc = lower_dentry->d_op->d_revalidate(lower_dentry, nd);
57 nd->dentry = dentry_save; 58 nd->dentry = dentry_save;
58 nd->mnt = vfsmount_save; 59 nd->mnt = vfsmount_save;
60 if (dentry->d_inode) {
61 struct inode *lower_inode =
62 ecryptfs_inode_to_lower(dentry->d_inode);
63
64 ecryptfs_copy_attr_all(dentry->d_inode, lower_inode);
65 }
59out: 66out:
60 return rc; 67 return rc;
61} 68}
@@ -76,8 +83,13 @@ static void ecryptfs_d_release(struct dentry *dentry)
76 if (ecryptfs_dentry_to_private(dentry)) 83 if (ecryptfs_dentry_to_private(dentry))
77 kmem_cache_free(ecryptfs_dentry_info_cache, 84 kmem_cache_free(ecryptfs_dentry_info_cache,
78 ecryptfs_dentry_to_private(dentry)); 85 ecryptfs_dentry_to_private(dentry));
79 if (lower_dentry) 86 if (lower_dentry) {
87 struct vfsmount *lower_mnt =
88 ecryptfs_dentry_to_lower_mnt(dentry);
89
90 mntput(lower_mnt);
80 dput(lower_dentry); 91 dput(lower_dentry);
92 }
81 return; 93 return;
82} 94}
83 95
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h
index 872c9958531a..f992533d1692 100644
--- a/fs/ecryptfs/ecryptfs_kernel.h
+++ b/fs/ecryptfs/ecryptfs_kernel.h
@@ -175,6 +175,7 @@ ecryptfs_get_key_payload_data(struct key *key)
175#define ECRYPTFS_DEFAULT_CIPHER "aes" 175#define ECRYPTFS_DEFAULT_CIPHER "aes"
176#define ECRYPTFS_DEFAULT_KEY_BYTES 16 176#define ECRYPTFS_DEFAULT_KEY_BYTES 16
177#define ECRYPTFS_DEFAULT_CHAINING_MODE CRYPTO_TFM_MODE_CBC 177#define ECRYPTFS_DEFAULT_CHAINING_MODE CRYPTO_TFM_MODE_CBC
178#define ECRYPTFS_DEFAULT_HASH "md5"
178#define ECRYPTFS_TAG_3_PACKET_TYPE 0x8C 179#define ECRYPTFS_TAG_3_PACKET_TYPE 0x8C
179#define ECRYPTFS_TAG_11_PACKET_TYPE 0xED 180#define ECRYPTFS_TAG_11_PACKET_TYPE 0xED
180#define MD5_DIGEST_SIZE 16 181#define MD5_DIGEST_SIZE 16
@@ -204,15 +205,15 @@ struct ecryptfs_crypt_stat {
204 size_t extent_shift; 205 size_t extent_shift;
205 unsigned int extent_mask; 206 unsigned int extent_mask;
206 struct ecryptfs_mount_crypt_stat *mount_crypt_stat; 207 struct ecryptfs_mount_crypt_stat *mount_crypt_stat;
207 struct crypto_tfm *tfm; 208 struct crypto_blkcipher *tfm;
208 struct crypto_tfm *md5_tfm; /* Crypto context for generating 209 struct crypto_hash *hash_tfm; /* Crypto context for generating
209 * the initialization vectors */ 210 * the initialization vectors */
210 unsigned char cipher[ECRYPTFS_MAX_CIPHER_NAME_SIZE]; 211 unsigned char cipher[ECRYPTFS_MAX_CIPHER_NAME_SIZE];
211 unsigned char key[ECRYPTFS_MAX_KEY_BYTES]; 212 unsigned char key[ECRYPTFS_MAX_KEY_BYTES];
212 unsigned char root_iv[ECRYPTFS_MAX_IV_BYTES]; 213 unsigned char root_iv[ECRYPTFS_MAX_IV_BYTES];
213 unsigned char keysigs[ECRYPTFS_MAX_NUM_KEYSIGS][ECRYPTFS_SIG_SIZE_HEX]; 214 unsigned char keysigs[ECRYPTFS_MAX_NUM_KEYSIGS][ECRYPTFS_SIG_SIZE_HEX];
214 struct mutex cs_tfm_mutex; 215 struct mutex cs_tfm_mutex;
215 struct mutex cs_md5_tfm_mutex; 216 struct mutex cs_hash_tfm_mutex;
216 struct mutex cs_mutex; 217 struct mutex cs_mutex;
217}; 218};
218 219
@@ -244,7 +245,7 @@ struct ecryptfs_mount_crypt_stat {
244 struct ecryptfs_auth_tok *global_auth_tok; 245 struct ecryptfs_auth_tok *global_auth_tok;
245 struct key *global_auth_tok_key; 246 struct key *global_auth_tok_key;
246 size_t global_default_cipher_key_size; 247 size_t global_default_cipher_key_size;
247 struct crypto_tfm *global_key_tfm; 248 struct crypto_blkcipher *global_key_tfm;
248 struct mutex global_key_tfm_mutex; 249 struct mutex global_key_tfm_mutex;
249 unsigned char global_default_cipher_name[ECRYPTFS_MAX_CIPHER_NAME_SIZE 250 unsigned char global_default_cipher_name[ECRYPTFS_MAX_CIPHER_NAME_SIZE
250 + 1]; 251 + 1];
@@ -425,6 +426,9 @@ void ecryptfs_destruct_crypt_stat(struct ecryptfs_crypt_stat *crypt_stat);
425void ecryptfs_destruct_mount_crypt_stat( 426void ecryptfs_destruct_mount_crypt_stat(
426 struct ecryptfs_mount_crypt_stat *mount_crypt_stat); 427 struct ecryptfs_mount_crypt_stat *mount_crypt_stat);
427int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat); 428int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat);
429int ecryptfs_crypto_api_algify_cipher_name(char **algified_name,
430 char *cipher_name,
431 char *chaining_modifier);
428int ecryptfs_write_inode_size_to_header(struct file *lower_file, 432int ecryptfs_write_inode_size_to_header(struct file *lower_file,
429 struct inode *lower_inode, 433 struct inode *lower_inode,
430 struct inode *inode); 434 struct inode *inode);
@@ -473,10 +477,14 @@ ecryptfs_parse_packet_set(struct ecryptfs_crypt_stat *crypt_stat,
473 unsigned char *src, struct dentry *ecryptfs_dentry); 477 unsigned char *src, struct dentry *ecryptfs_dentry);
474int ecryptfs_truncate(struct dentry *dentry, loff_t new_length); 478int ecryptfs_truncate(struct dentry *dentry, loff_t new_length);
475int 479int
476ecryptfs_process_cipher(struct crypto_tfm **tfm, struct crypto_tfm **key_tfm, 480ecryptfs_process_cipher(struct crypto_blkcipher **key_tfm, char *cipher_name,
477 char *cipher_name, size_t key_size); 481 size_t *key_size);
478int ecryptfs_inode_test(struct inode *inode, void *candidate_lower_inode); 482int ecryptfs_inode_test(struct inode *inode, void *candidate_lower_inode);
479int ecryptfs_inode_set(struct inode *inode, void *lower_inode); 483int ecryptfs_inode_set(struct inode *inode, void *lower_inode);
480void ecryptfs_init_inode(struct inode *inode, struct inode *lower_inode); 484void ecryptfs_init_inode(struct inode *inode, struct inode *lower_inode);
485int ecryptfs_open_lower_file(struct file **lower_file,
486 struct dentry *lower_dentry,
487 struct vfsmount *lower_mnt, int flags);
488int ecryptfs_close_lower_file(struct file *lower_file);
481 489
482#endif /* #ifndef ECRYPTFS_KERNEL_H */ 490#endif /* #ifndef ECRYPTFS_KERNEL_H */
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
index c8550c9f9cd2..a92ef05eff8f 100644
--- a/fs/ecryptfs/file.c
+++ b/fs/ecryptfs/file.c
@@ -198,6 +198,33 @@ retry:
198 198
199struct kmem_cache *ecryptfs_file_info_cache; 199struct kmem_cache *ecryptfs_file_info_cache;
200 200
201int ecryptfs_open_lower_file(struct file **lower_file,
202 struct dentry *lower_dentry,
203 struct vfsmount *lower_mnt, int flags)
204{
205 int rc = 0;
206
207 dget(lower_dentry);
208 mntget(lower_mnt);
209 *lower_file = dentry_open(lower_dentry, lower_mnt, flags);
210 if (IS_ERR(*lower_file)) {
211 printk(KERN_ERR "Error opening lower file for lower_dentry "
212 "[0x%p], lower_mnt [0x%p], and flags [0x%x]\n",
213 lower_dentry, lower_mnt, flags);
214 rc = PTR_ERR(*lower_file);
215 *lower_file = NULL;
216 goto out;
217 }
218out:
219 return rc;
220}
221
222int ecryptfs_close_lower_file(struct file *lower_file)
223{
224 fput(lower_file);
225 return 0;
226}
227
201/** 228/**
202 * ecryptfs_open 229 * ecryptfs_open
203 * @inode: inode speciying file to open 230 * @inode: inode speciying file to open
@@ -244,19 +271,15 @@ static int ecryptfs_open(struct inode *inode, struct file *file)
244 ECRYPTFS_SET_FLAG(crypt_stat->flags, ECRYPTFS_ENCRYPTED); 271 ECRYPTFS_SET_FLAG(crypt_stat->flags, ECRYPTFS_ENCRYPTED);
245 } 272 }
246 mutex_unlock(&crypt_stat->cs_mutex); 273 mutex_unlock(&crypt_stat->cs_mutex);
247 /* This mntget & dget is undone via fput when the file is released */
248 dget(lower_dentry);
249 lower_flags = file->f_flags; 274 lower_flags = file->f_flags;
250 if ((lower_flags & O_ACCMODE) == O_WRONLY) 275 if ((lower_flags & O_ACCMODE) == O_WRONLY)
251 lower_flags = (lower_flags & O_ACCMODE) | O_RDWR; 276 lower_flags = (lower_flags & O_ACCMODE) | O_RDWR;
252 if (file->f_flags & O_APPEND) 277 if (file->f_flags & O_APPEND)
253 lower_flags &= ~O_APPEND; 278 lower_flags &= ~O_APPEND;
254 lower_mnt = ecryptfs_dentry_to_lower_mnt(ecryptfs_dentry); 279 lower_mnt = ecryptfs_dentry_to_lower_mnt(ecryptfs_dentry);
255 mntget(lower_mnt);
256 /* Corresponding fput() in ecryptfs_release() */ 280 /* Corresponding fput() in ecryptfs_release() */
257 lower_file = dentry_open(lower_dentry, lower_mnt, lower_flags); 281 if ((rc = ecryptfs_open_lower_file(&lower_file, lower_dentry, lower_mnt,
258 if (IS_ERR(lower_file)) { 282 lower_flags))) {
259 rc = PTR_ERR(lower_file);
260 ecryptfs_printk(KERN_ERR, "Error opening lower file\n"); 283 ecryptfs_printk(KERN_ERR, "Error opening lower file\n");
261 goto out_puts; 284 goto out_puts;
262 } 285 }
@@ -341,11 +364,16 @@ static int ecryptfs_release(struct inode *inode, struct file *file)
341 struct file *lower_file = ecryptfs_file_to_lower(file); 364 struct file *lower_file = ecryptfs_file_to_lower(file);
342 struct ecryptfs_file_info *file_info = ecryptfs_file_to_private(file); 365 struct ecryptfs_file_info *file_info = ecryptfs_file_to_private(file);
343 struct inode *lower_inode = ecryptfs_inode_to_lower(inode); 366 struct inode *lower_inode = ecryptfs_inode_to_lower(inode);
367 int rc;
344 368
345 fput(lower_file); 369 if ((rc = ecryptfs_close_lower_file(lower_file))) {
370 printk(KERN_ERR "Error closing lower_file\n");
371 goto out;
372 }
346 inode->i_blocks = lower_inode->i_blocks; 373 inode->i_blocks = lower_inode->i_blocks;
347 kmem_cache_free(ecryptfs_file_info_cache, file_info); 374 kmem_cache_free(ecryptfs_file_info_cache, file_info);
348 return 0; 375out:
376 return rc;
349} 377}
350 378
351static int 379static int
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index efdd2b7b62d7..dfcc68484f47 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -231,7 +231,6 @@ static int ecryptfs_initialize_file(struct dentry *ecryptfs_dentry)
231 int lower_flags; 231 int lower_flags;
232 struct ecryptfs_crypt_stat *crypt_stat; 232 struct ecryptfs_crypt_stat *crypt_stat;
233 struct dentry *lower_dentry; 233 struct dentry *lower_dentry;
234 struct dentry *tlower_dentry = NULL;
235 struct file *lower_file; 234 struct file *lower_file;
236 struct inode *inode, *lower_inode; 235 struct inode *inode, *lower_inode;
237 struct vfsmount *lower_mnt; 236 struct vfsmount *lower_mnt;
@@ -241,30 +240,19 @@ static int ecryptfs_initialize_file(struct dentry *ecryptfs_dentry)
241 lower_dentry->d_name.name); 240 lower_dentry->d_name.name);
242 inode = ecryptfs_dentry->d_inode; 241 inode = ecryptfs_dentry->d_inode;
243 crypt_stat = &ecryptfs_inode_to_private(inode)->crypt_stat; 242 crypt_stat = &ecryptfs_inode_to_private(inode)->crypt_stat;
244 tlower_dentry = dget(lower_dentry);
245 if (!tlower_dentry) {
246 rc = -ENOMEM;
247 ecryptfs_printk(KERN_ERR, "Error dget'ing lower_dentry\n");
248 goto out;
249 }
250 lower_flags = ((O_CREAT | O_WRONLY | O_TRUNC) & O_ACCMODE) | O_RDWR; 243 lower_flags = ((O_CREAT | O_WRONLY | O_TRUNC) & O_ACCMODE) | O_RDWR;
251#if BITS_PER_LONG != 32 244#if BITS_PER_LONG != 32
252 lower_flags |= O_LARGEFILE; 245 lower_flags |= O_LARGEFILE;
253#endif 246#endif
254 lower_mnt = ecryptfs_dentry_to_lower_mnt(ecryptfs_dentry); 247 lower_mnt = ecryptfs_dentry_to_lower_mnt(ecryptfs_dentry);
255 mntget(lower_mnt);
256 /* Corresponding fput() at end of this function */ 248 /* Corresponding fput() at end of this function */
257 lower_file = dentry_open(tlower_dentry, lower_mnt, lower_flags); 249 if ((rc = ecryptfs_open_lower_file(&lower_file, lower_dentry, lower_mnt,
258 if (IS_ERR(lower_file)) { 250 lower_flags))) {
259 rc = PTR_ERR(lower_file);
260 ecryptfs_printk(KERN_ERR, 251 ecryptfs_printk(KERN_ERR,
261 "Error opening dentry; rc = [%i]\n", rc); 252 "Error opening dentry; rc = [%i]\n", rc);
262 goto out; 253 goto out;
263 } 254 }
264 /* fput(lower_file) should handle the puts if we do this */ 255 lower_inode = lower_dentry->d_inode;
265 lower_file->f_dentry = tlower_dentry;
266 lower_file->f_vfsmnt = lower_mnt;
267 lower_inode = tlower_dentry->d_inode;
268 if (S_ISDIR(ecryptfs_dentry->d_inode->i_mode)) { 256 if (S_ISDIR(ecryptfs_dentry->d_inode->i_mode)) {
269 ecryptfs_printk(KERN_DEBUG, "This is a directory\n"); 257 ecryptfs_printk(KERN_DEBUG, "This is a directory\n");
270 ECRYPTFS_CLEAR_FLAG(crypt_stat->flags, ECRYPTFS_ENCRYPTED); 258 ECRYPTFS_CLEAR_FLAG(crypt_stat->flags, ECRYPTFS_ENCRYPTED);
@@ -285,7 +273,8 @@ static int ecryptfs_initialize_file(struct dentry *ecryptfs_dentry)
285 } 273 }
286 rc = grow_file(ecryptfs_dentry, lower_file, inode, lower_inode); 274 rc = grow_file(ecryptfs_dentry, lower_file, inode, lower_inode);
287out_fput: 275out_fput:
288 fput(lower_file); 276 if ((rc = ecryptfs_close_lower_file(lower_file)))
277 printk(KERN_ERR "Error closing lower_file\n");
289out: 278out:
290 return rc; 279 return rc;
291} 280}
@@ -336,7 +325,6 @@ static struct dentry *ecryptfs_lookup(struct inode *dir, struct dentry *dentry,
336 struct dentry *lower_dir_dentry; 325 struct dentry *lower_dir_dentry;
337 struct dentry *lower_dentry; 326 struct dentry *lower_dentry;
338 struct vfsmount *lower_mnt; 327 struct vfsmount *lower_mnt;
339 struct dentry *tlower_dentry = NULL;
340 char *encoded_name; 328 char *encoded_name;
341 unsigned int encoded_namelen; 329 unsigned int encoded_namelen;
342 struct ecryptfs_crypt_stat *crypt_stat = NULL; 330 struct ecryptfs_crypt_stat *crypt_stat = NULL;
@@ -347,27 +335,32 @@ static struct dentry *ecryptfs_lookup(struct inode *dir, struct dentry *dentry,
347 lower_dir_dentry = ecryptfs_dentry_to_lower(dentry->d_parent); 335 lower_dir_dentry = ecryptfs_dentry_to_lower(dentry->d_parent);
348 dentry->d_op = &ecryptfs_dops; 336 dentry->d_op = &ecryptfs_dops;
349 if ((dentry->d_name.len == 1 && !strcmp(dentry->d_name.name, ".")) 337 if ((dentry->d_name.len == 1 && !strcmp(dentry->d_name.name, "."))
350 || (dentry->d_name.len == 2 && !strcmp(dentry->d_name.name, ".."))) 338 || (dentry->d_name.len == 2
351 goto out_drop; 339 && !strcmp(dentry->d_name.name, ".."))) {
340 d_drop(dentry);
341 goto out;
342 }
352 encoded_namelen = ecryptfs_encode_filename(crypt_stat, 343 encoded_namelen = ecryptfs_encode_filename(crypt_stat,
353 dentry->d_name.name, 344 dentry->d_name.name,
354 dentry->d_name.len, 345 dentry->d_name.len,
355 &encoded_name); 346 &encoded_name);
356 if (encoded_namelen < 0) { 347 if (encoded_namelen < 0) {
357 rc = encoded_namelen; 348 rc = encoded_namelen;
358 goto out_drop; 349 d_drop(dentry);
350 goto out;
359 } 351 }
360 ecryptfs_printk(KERN_DEBUG, "encoded_name = [%s]; encoded_namelen " 352 ecryptfs_printk(KERN_DEBUG, "encoded_name = [%s]; encoded_namelen "
361 "= [%d]\n", encoded_name, encoded_namelen); 353 "= [%d]\n", encoded_name, encoded_namelen);
362 lower_dentry = lookup_one_len(encoded_name, lower_dir_dentry, 354 lower_dentry = lookup_one_len(encoded_name, lower_dir_dentry,
363 encoded_namelen - 1); 355 encoded_namelen - 1);
364 kfree(encoded_name); 356 kfree(encoded_name);
365 lower_mnt = mntget(ecryptfs_dentry_to_lower_mnt(dentry->d_parent));
366 if (IS_ERR(lower_dentry)) { 357 if (IS_ERR(lower_dentry)) {
367 ecryptfs_printk(KERN_ERR, "ERR from lower_dentry\n"); 358 ecryptfs_printk(KERN_ERR, "ERR from lower_dentry\n");
368 rc = PTR_ERR(lower_dentry); 359 rc = PTR_ERR(lower_dentry);
369 goto out_drop; 360 d_drop(dentry);
361 goto out;
370 } 362 }
363 lower_mnt = mntget(ecryptfs_dentry_to_lower_mnt(dentry->d_parent));
371 ecryptfs_printk(KERN_DEBUG, "lower_dentry = [%p]; lower_dentry->" 364 ecryptfs_printk(KERN_DEBUG, "lower_dentry = [%p]; lower_dentry->"
372 "d_name.name = [%s]\n", lower_dentry, 365 "d_name.name = [%s]\n", lower_dentry,
373 lower_dentry->d_name.name); 366 lower_dentry->d_name.name);
@@ -408,12 +401,6 @@ static struct dentry *ecryptfs_lookup(struct inode *dir, struct dentry *dentry,
408 "as we *think* we are about to unlink\n"); 401 "as we *think* we are about to unlink\n");
409 goto out; 402 goto out;
410 } 403 }
411 tlower_dentry = dget(lower_dentry);
412 if (!tlower_dentry || IS_ERR(tlower_dentry)) {
413 rc = -ENOMEM;
414 ecryptfs_printk(KERN_ERR, "Cannot dget lower_dentry\n");
415 goto out_dput;
416 }
417 /* Released in this function */ 404 /* Released in this function */
418 page_virt = 405 page_virt =
419 (char *)kmem_cache_alloc(ecryptfs_header_cache_2, 406 (char *)kmem_cache_alloc(ecryptfs_header_cache_2,
@@ -425,7 +412,7 @@ static struct dentry *ecryptfs_lookup(struct inode *dir, struct dentry *dentry,
425 goto out_dput; 412 goto out_dput;
426 } 413 }
427 memset(page_virt, 0, PAGE_CACHE_SIZE); 414 memset(page_virt, 0, PAGE_CACHE_SIZE);
428 rc = ecryptfs_read_header_region(page_virt, tlower_dentry, nd->mnt); 415 rc = ecryptfs_read_header_region(page_virt, lower_dentry, nd->mnt);
429 crypt_stat = &ecryptfs_inode_to_private(dentry->d_inode)->crypt_stat; 416 crypt_stat = &ecryptfs_inode_to_private(dentry->d_inode)->crypt_stat;
430 if (!ECRYPTFS_CHECK_FLAG(crypt_stat->flags, ECRYPTFS_POLICY_APPLIED)) 417 if (!ECRYPTFS_CHECK_FLAG(crypt_stat->flags, ECRYPTFS_POLICY_APPLIED))
431 ecryptfs_set_default_sizes(crypt_stat); 418 ecryptfs_set_default_sizes(crypt_stat);
@@ -448,9 +435,6 @@ static struct dentry *ecryptfs_lookup(struct inode *dir, struct dentry *dentry,
448 435
449out_dput: 436out_dput:
450 dput(lower_dentry); 437 dput(lower_dentry);
451 if (tlower_dentry)
452 dput(tlower_dentry);
453out_drop:
454 d_drop(dentry); 438 d_drop(dentry);
455out: 439out:
456 return ERR_PTR(rc); 440 return ERR_PTR(rc);
@@ -486,8 +470,9 @@ out_lock:
486 unlock_dir(lower_dir_dentry); 470 unlock_dir(lower_dir_dentry);
487 dput(lower_new_dentry); 471 dput(lower_new_dentry);
488 dput(lower_old_dentry); 472 dput(lower_old_dentry);
489 if (!new_dentry->d_inode) 473 d_drop(lower_old_dentry);
490 d_drop(new_dentry); 474 d_drop(new_dentry);
475 d_drop(old_dentry);
491 return rc; 476 return rc;
492} 477}
493 478
@@ -500,7 +485,7 @@ static int ecryptfs_unlink(struct inode *dir, struct dentry *dentry)
500 lock_parent(lower_dentry); 485 lock_parent(lower_dentry);
501 rc = vfs_unlink(lower_dir_inode, lower_dentry); 486 rc = vfs_unlink(lower_dir_inode, lower_dentry);
502 if (rc) { 487 if (rc) {
503 ecryptfs_printk(KERN_ERR, "Error in vfs_unlink\n"); 488 printk(KERN_ERR "Error in vfs_unlink; rc = [%d]\n", rc);
504 goto out_unlock; 489 goto out_unlock;
505 } 490 }
506 ecryptfs_copy_attr_times(dir, lower_dir_inode); 491 ecryptfs_copy_attr_times(dir, lower_dir_inode);
@@ -576,41 +561,24 @@ out:
576 561
577static int ecryptfs_rmdir(struct inode *dir, struct dentry *dentry) 562static int ecryptfs_rmdir(struct inode *dir, struct dentry *dentry)
578{ 563{
579 int rc = 0;
580 struct dentry *tdentry = NULL;
581 struct dentry *lower_dentry; 564 struct dentry *lower_dentry;
582 struct dentry *tlower_dentry = NULL;
583 struct dentry *lower_dir_dentry; 565 struct dentry *lower_dir_dentry;
566 int rc;
584 567
585 lower_dentry = ecryptfs_dentry_to_lower(dentry); 568 lower_dentry = ecryptfs_dentry_to_lower(dentry);
586 if (!(tdentry = dget(dentry))) { 569 dget(dentry);
587 rc = -EINVAL;
588 ecryptfs_printk(KERN_ERR, "Error dget'ing dentry [%p]\n",
589 dentry);
590 goto out;
591 }
592 lower_dir_dentry = lock_parent(lower_dentry); 570 lower_dir_dentry = lock_parent(lower_dentry);
593 if (!(tlower_dentry = dget(lower_dentry))) { 571 dget(lower_dentry);
594 rc = -EINVAL;
595 ecryptfs_printk(KERN_ERR, "Error dget'ing lower_dentry "
596 "[%p]\n", lower_dentry);
597 goto out;
598 }
599 rc = vfs_rmdir(lower_dir_dentry->d_inode, lower_dentry); 572 rc = vfs_rmdir(lower_dir_dentry->d_inode, lower_dentry);
600 if (!rc) { 573 dput(lower_dentry);
601 d_delete(tlower_dentry); 574 if (!rc)
602 tlower_dentry = NULL; 575 d_delete(lower_dentry);
603 }
604 ecryptfs_copy_attr_times(dir, lower_dir_dentry->d_inode); 576 ecryptfs_copy_attr_times(dir, lower_dir_dentry->d_inode);
605 dir->i_nlink = lower_dir_dentry->d_inode->i_nlink; 577 dir->i_nlink = lower_dir_dentry->d_inode->i_nlink;
606 unlock_dir(lower_dir_dentry); 578 unlock_dir(lower_dir_dentry);
607 if (!rc) 579 if (!rc)
608 d_drop(dentry); 580 d_drop(dentry);
609out: 581 dput(dentry);
610 if (tdentry)
611 dput(tdentry);
612 if (tlower_dentry)
613 dput(tlower_dentry);
614 return rc; 582 return rc;
615} 583}
616 584
@@ -663,6 +631,8 @@ ecryptfs_rename(struct inode *old_dir, struct dentry *old_dentry,
663 ecryptfs_copy_attr_all(old_dir, lower_old_dir_dentry->d_inode); 631 ecryptfs_copy_attr_all(old_dir, lower_old_dir_dentry->d_inode);
664out_lock: 632out_lock:
665 unlock_rename(lower_old_dir_dentry, lower_new_dir_dentry); 633 unlock_rename(lower_old_dir_dentry, lower_new_dir_dentry);
634 dput(lower_new_dentry->d_parent);
635 dput(lower_old_dentry->d_parent);
666 dput(lower_new_dentry); 636 dput(lower_new_dentry);
667 dput(lower_old_dentry); 637 dput(lower_old_dentry);
668 return rc; 638 return rc;
@@ -832,12 +802,11 @@ int ecryptfs_truncate(struct dentry *dentry, loff_t new_length)
832 } 802 }
833 lower_dentry = ecryptfs_dentry_to_lower(dentry); 803 lower_dentry = ecryptfs_dentry_to_lower(dentry);
834 /* This dget & mntget is released through fput at out_fput: */ 804 /* This dget & mntget is released through fput at out_fput: */
835 dget(lower_dentry);
836 lower_mnt = ecryptfs_dentry_to_lower_mnt(dentry); 805 lower_mnt = ecryptfs_dentry_to_lower_mnt(dentry);
837 mntget(lower_mnt); 806 if ((rc = ecryptfs_open_lower_file(&lower_file, lower_dentry, lower_mnt,
838 lower_file = dentry_open(lower_dentry, lower_mnt, O_RDWR); 807 O_RDWR))) {
839 if (unlikely(IS_ERR(lower_file))) { 808 ecryptfs_printk(KERN_ERR,
840 rc = PTR_ERR(lower_file); 809 "Error opening dentry; rc = [%i]\n", rc);
841 goto out_free; 810 goto out_free;
842 } 811 }
843 ecryptfs_set_file_lower(&fake_ecryptfs_file, lower_file); 812 ecryptfs_set_file_lower(&fake_ecryptfs_file, lower_file);
@@ -879,7 +848,8 @@ int ecryptfs_truncate(struct dentry *dentry, loff_t new_length)
879 = CURRENT_TIME; 848 = CURRENT_TIME;
880 mark_inode_dirty_sync(inode); 849 mark_inode_dirty_sync(inode);
881out_fput: 850out_fput:
882 fput(lower_file); 851 if ((rc = ecryptfs_close_lower_file(lower_file)))
852 printk(KERN_ERR "Error closing lower_file\n");
883out_free: 853out_free:
884 if (ecryptfs_file_to_private(&fake_ecryptfs_file)) 854 if (ecryptfs_file_to_private(&fake_ecryptfs_file))
885 kmem_cache_free(ecryptfs_file_info_cache, 855 kmem_cache_free(ecryptfs_file_info_cache,
diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
index ba454785a0c5..c3746f56d162 100644
--- a/fs/ecryptfs/keystore.c
+++ b/fs/ecryptfs/keystore.c
@@ -458,14 +458,16 @@ out:
458static int decrypt_session_key(struct ecryptfs_auth_tok *auth_tok, 458static int decrypt_session_key(struct ecryptfs_auth_tok *auth_tok,
459 struct ecryptfs_crypt_stat *crypt_stat) 459 struct ecryptfs_crypt_stat *crypt_stat)
460{ 460{
461 int rc = 0;
462 struct ecryptfs_password *password_s_ptr; 461 struct ecryptfs_password *password_s_ptr;
463 struct crypto_tfm *tfm = NULL;
464 struct scatterlist src_sg[2], dst_sg[2]; 462 struct scatterlist src_sg[2], dst_sg[2];
465 struct mutex *tfm_mutex = NULL; 463 struct mutex *tfm_mutex = NULL;
466 /* TODO: Use virt_to_scatterlist for these */ 464 /* TODO: Use virt_to_scatterlist for these */
467 char *encrypted_session_key; 465 char *encrypted_session_key;
468 char *session_key; 466 char *session_key;
467 struct blkcipher_desc desc = {
468 .flags = CRYPTO_TFM_REQ_MAY_SLEEP
469 };
470 int rc = 0;
469 471
470 password_s_ptr = &auth_tok->token.password; 472 password_s_ptr = &auth_tok->token.password;
471 if (ECRYPTFS_CHECK_FLAG(password_s_ptr->flags, 473 if (ECRYPTFS_CHECK_FLAG(password_s_ptr->flags,
@@ -482,30 +484,37 @@ static int decrypt_session_key(struct ecryptfs_auth_tok *auth_tok,
482 if (!strcmp(crypt_stat->cipher, 484 if (!strcmp(crypt_stat->cipher,
483 crypt_stat->mount_crypt_stat->global_default_cipher_name) 485 crypt_stat->mount_crypt_stat->global_default_cipher_name)
484 && crypt_stat->mount_crypt_stat->global_key_tfm) { 486 && crypt_stat->mount_crypt_stat->global_key_tfm) {
485 tfm = crypt_stat->mount_crypt_stat->global_key_tfm; 487 desc.tfm = crypt_stat->mount_crypt_stat->global_key_tfm;
486 tfm_mutex = &crypt_stat->mount_crypt_stat->global_key_tfm_mutex; 488 tfm_mutex = &crypt_stat->mount_crypt_stat->global_key_tfm_mutex;
487 } else { 489 } else {
488 tfm = crypto_alloc_tfm(crypt_stat->cipher, 490 char *full_alg_name;
489 CRYPTO_TFM_REQ_WEAK_KEY); 491
490 if (!tfm) { 492 rc = ecryptfs_crypto_api_algify_cipher_name(&full_alg_name,
491 printk(KERN_ERR "Error allocating crypto context\n"); 493 crypt_stat->cipher,
492 rc = -ENOMEM; 494 "ecb");
495 if (rc)
496 goto out;
497 desc.tfm = crypto_alloc_blkcipher(full_alg_name, 0,
498 CRYPTO_ALG_ASYNC);
499 kfree(full_alg_name);
500 if (IS_ERR(desc.tfm)) {
501 rc = PTR_ERR(desc.tfm);
502 printk(KERN_ERR "Error allocating crypto context; "
503 "rc = [%d]\n", rc);
493 goto out; 504 goto out;
494 } 505 }
495 } 506 crypto_blkcipher_set_flags(desc.tfm, CRYPTO_TFM_REQ_WEAK_KEY);
496 if (password_s_ptr->session_key_encryption_key_bytes
497 < crypto_tfm_alg_min_keysize(tfm)) {
498 printk(KERN_WARNING "Session key encryption key is [%d] bytes; "
499 "minimum keysize for selected cipher is [%d] bytes.\n",
500 password_s_ptr->session_key_encryption_key_bytes,
501 crypto_tfm_alg_min_keysize(tfm));
502 rc = -EINVAL;
503 goto out;
504 } 507 }
505 if (tfm_mutex) 508 if (tfm_mutex)
506 mutex_lock(tfm_mutex); 509 mutex_lock(tfm_mutex);
507 crypto_cipher_setkey(tfm, password_s_ptr->session_key_encryption_key, 510 rc = crypto_blkcipher_setkey(desc.tfm,
508 crypt_stat->key_size); 511 password_s_ptr->session_key_encryption_key,
512 crypt_stat->key_size);
513 if (rc < 0) {
514 printk(KERN_ERR "Error setting key for crypto context\n");
515 rc = -EINVAL;
516 goto out_free_tfm;
517 }
509 /* TODO: virt_to_scatterlist */ 518 /* TODO: virt_to_scatterlist */
510 encrypted_session_key = (char *)__get_free_page(GFP_KERNEL); 519 encrypted_session_key = (char *)__get_free_page(GFP_KERNEL);
511 if (!encrypted_session_key) { 520 if (!encrypted_session_key) {
@@ -531,9 +540,12 @@ static int decrypt_session_key(struct ecryptfs_auth_tok *auth_tok,
531 auth_tok->session_key.decrypted_key_size = 540 auth_tok->session_key.decrypted_key_size =
532 auth_tok->session_key.encrypted_key_size; 541 auth_tok->session_key.encrypted_key_size;
533 dst_sg[0].length = auth_tok->session_key.encrypted_key_size; 542 dst_sg[0].length = auth_tok->session_key.encrypted_key_size;
534 /* TODO: Handle error condition */ 543 rc = crypto_blkcipher_decrypt(&desc, dst_sg, src_sg,
535 crypto_cipher_decrypt(tfm, dst_sg, src_sg, 544 auth_tok->session_key.encrypted_key_size);
536 auth_tok->session_key.encrypted_key_size); 545 if (rc) {
546 printk(KERN_ERR "Error decrypting; rc = [%d]\n", rc);
547 goto out_free_memory;
548 }
537 auth_tok->session_key.decrypted_key_size = 549 auth_tok->session_key.decrypted_key_size =
538 auth_tok->session_key.encrypted_key_size; 550 auth_tok->session_key.encrypted_key_size;
539 memcpy(auth_tok->session_key.decrypted_key, session_key, 551 memcpy(auth_tok->session_key.decrypted_key, session_key,
@@ -546,6 +558,7 @@ static int decrypt_session_key(struct ecryptfs_auth_tok *auth_tok,
546 if (ecryptfs_verbosity > 0) 558 if (ecryptfs_verbosity > 0)
547 ecryptfs_dump_hex(crypt_stat->key, 559 ecryptfs_dump_hex(crypt_stat->key,
548 crypt_stat->key_size); 560 crypt_stat->key_size);
561out_free_memory:
549 memset(encrypted_session_key, 0, PAGE_CACHE_SIZE); 562 memset(encrypted_session_key, 0, PAGE_CACHE_SIZE);
550 free_page((unsigned long)encrypted_session_key); 563 free_page((unsigned long)encrypted_session_key);
551 memset(session_key, 0, PAGE_CACHE_SIZE); 564 memset(session_key, 0, PAGE_CACHE_SIZE);
@@ -554,7 +567,7 @@ out_free_tfm:
554 if (tfm_mutex) 567 if (tfm_mutex)
555 mutex_unlock(tfm_mutex); 568 mutex_unlock(tfm_mutex);
556 else 569 else
557 crypto_free_tfm(tfm); 570 crypto_free_blkcipher(desc.tfm);
558out: 571out:
559 return rc; 572 return rc;
560} 573}
@@ -803,19 +816,21 @@ write_tag_3_packet(char *dest, size_t max, struct ecryptfs_auth_tok *auth_tok,
803 struct ecryptfs_crypt_stat *crypt_stat, 816 struct ecryptfs_crypt_stat *crypt_stat,
804 struct ecryptfs_key_record *key_rec, size_t *packet_size) 817 struct ecryptfs_key_record *key_rec, size_t *packet_size)
805{ 818{
806 int rc = 0;
807
808 size_t i; 819 size_t i;
809 size_t signature_is_valid = 0; 820 size_t signature_is_valid = 0;
810 size_t encrypted_session_key_valid = 0; 821 size_t encrypted_session_key_valid = 0;
811 char session_key_encryption_key[ECRYPTFS_MAX_KEY_BYTES]; 822 char session_key_encryption_key[ECRYPTFS_MAX_KEY_BYTES];
812 struct scatterlist dest_sg[2]; 823 struct scatterlist dest_sg[2];
813 struct scatterlist src_sg[2]; 824 struct scatterlist src_sg[2];
814 struct crypto_tfm *tfm = NULL;
815 struct mutex *tfm_mutex = NULL; 825 struct mutex *tfm_mutex = NULL;
816 size_t key_rec_size; 826 size_t key_rec_size;
817 size_t packet_size_length; 827 size_t packet_size_length;
818 size_t cipher_code; 828 size_t cipher_code;
829 struct blkcipher_desc desc = {
830 .tfm = NULL,
831 .flags = CRYPTO_TFM_REQ_MAY_SLEEP
832 };
833 int rc = 0;
819 834
820 (*packet_size) = 0; 835 (*packet_size) = 0;
821 /* Check for a valid signature on the auth_tok */ 836 /* Check for a valid signature on the auth_tok */
@@ -882,33 +897,48 @@ write_tag_3_packet(char *dest, size_t max, struct ecryptfs_auth_tok *auth_tok,
882 if (!strcmp(crypt_stat->cipher, 897 if (!strcmp(crypt_stat->cipher,
883 crypt_stat->mount_crypt_stat->global_default_cipher_name) 898 crypt_stat->mount_crypt_stat->global_default_cipher_name)
884 && crypt_stat->mount_crypt_stat->global_key_tfm) { 899 && crypt_stat->mount_crypt_stat->global_key_tfm) {
885 tfm = crypt_stat->mount_crypt_stat->global_key_tfm; 900 desc.tfm = crypt_stat->mount_crypt_stat->global_key_tfm;
886 tfm_mutex = &crypt_stat->mount_crypt_stat->global_key_tfm_mutex; 901 tfm_mutex = &crypt_stat->mount_crypt_stat->global_key_tfm_mutex;
887 } else 902 } else {
888 tfm = crypto_alloc_tfm(crypt_stat->cipher, 0); 903 char *full_alg_name;
889 if (!tfm) { 904
890 ecryptfs_printk(KERN_ERR, "Could not initialize crypto " 905 rc = ecryptfs_crypto_api_algify_cipher_name(&full_alg_name,
891 "context for cipher [%s]\n", 906 crypt_stat->cipher,
892 crypt_stat->cipher); 907 "ecb");
893 rc = -EINVAL; 908 if (rc)
894 goto out; 909 goto out;
910 desc.tfm = crypto_alloc_blkcipher(full_alg_name, 0,
911 CRYPTO_ALG_ASYNC);
912 kfree(full_alg_name);
913 if (IS_ERR(desc.tfm)) {
914 rc = PTR_ERR(desc.tfm);
915 ecryptfs_printk(KERN_ERR, "Could not initialize crypto "
916 "context for cipher [%s]; rc = [%d]\n",
917 crypt_stat->cipher, rc);
918 goto out;
919 }
920 crypto_blkcipher_set_flags(desc.tfm, CRYPTO_TFM_REQ_WEAK_KEY);
895 } 921 }
896 if (tfm_mutex) 922 if (tfm_mutex)
897 mutex_lock(tfm_mutex); 923 mutex_lock(tfm_mutex);
898 rc = crypto_cipher_setkey(tfm, session_key_encryption_key, 924 rc = crypto_blkcipher_setkey(desc.tfm, session_key_encryption_key,
899 crypt_stat->key_size); 925 crypt_stat->key_size);
900 if (rc < 0) { 926 if (rc < 0) {
901 if (tfm_mutex) 927 if (tfm_mutex)
902 mutex_unlock(tfm_mutex); 928 mutex_unlock(tfm_mutex);
903 ecryptfs_printk(KERN_ERR, "Error setting key for crypto " 929 ecryptfs_printk(KERN_ERR, "Error setting key for crypto "
904 "context\n"); 930 "context; rc = [%d]\n", rc);
905 goto out; 931 goto out;
906 } 932 }
907 rc = 0; 933 rc = 0;
908 ecryptfs_printk(KERN_DEBUG, "Encrypting [%d] bytes of the key\n", 934 ecryptfs_printk(KERN_DEBUG, "Encrypting [%d] bytes of the key\n",
909 crypt_stat->key_size); 935 crypt_stat->key_size);
910 crypto_cipher_encrypt(tfm, dest_sg, src_sg, 936 rc = crypto_blkcipher_encrypt(&desc, dest_sg, src_sg,
911 (*key_rec).enc_key_size); 937 (*key_rec).enc_key_size);
938 if (rc) {
939 printk(KERN_ERR "Error encrypting; rc = [%d]\n", rc);
940 goto out;
941 }
912 if (tfm_mutex) 942 if (tfm_mutex)
913 mutex_unlock(tfm_mutex); 943 mutex_unlock(tfm_mutex);
914 ecryptfs_printk(KERN_DEBUG, "This should be the encrypted key:\n"); 944 ecryptfs_printk(KERN_DEBUG, "This should be the encrypted key:\n");
@@ -971,8 +1001,8 @@ encrypted_session_key_set:
971 (*key_rec).enc_key_size); 1001 (*key_rec).enc_key_size);
972 (*packet_size) += (*key_rec).enc_key_size; 1002 (*packet_size) += (*key_rec).enc_key_size;
973out: 1003out:
974 if (tfm && !tfm_mutex) 1004 if (desc.tfm && !tfm_mutex)
975 crypto_free_tfm(tfm); 1005 crypto_free_blkcipher(desc.tfm);
976 if (rc) 1006 if (rc)
977 (*packet_size) = 0; 1007 (*packet_size) = 0;
978 return rc; 1008 return rc;
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index 7a11b8ae6644..a78d87d14baf 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -104,10 +104,7 @@ int ecryptfs_interpose(struct dentry *lower_dentry, struct dentry *dentry,
104 inode->i_op = &ecryptfs_dir_iops; 104 inode->i_op = &ecryptfs_dir_iops;
105 if (S_ISDIR(lower_inode->i_mode)) 105 if (S_ISDIR(lower_inode->i_mode))
106 inode->i_fop = &ecryptfs_dir_fops; 106 inode->i_fop = &ecryptfs_dir_fops;
107 /* TODO: Is there a better way to identify if the inode is 107 if (special_file(lower_inode->i_mode))
108 * special? */
109 if (S_ISBLK(lower_inode->i_mode) || S_ISCHR(lower_inode->i_mode) ||
110 S_ISFIFO(lower_inode->i_mode) || S_ISSOCK(lower_inode->i_mode))
111 init_special_inode(inode, lower_inode->i_mode, 108 init_special_inode(inode, lower_inode->i_mode,
112 lower_inode->i_rdev); 109 lower_inode->i_rdev);
113 dentry->d_op = &ecryptfs_dops; 110 dentry->d_op = &ecryptfs_dops;
@@ -211,7 +208,6 @@ static int ecryptfs_parse_options(struct super_block *sb, char *options)
211 char *cipher_name_dst; 208 char *cipher_name_dst;
212 char *cipher_name_src; 209 char *cipher_name_src;
213 char *cipher_key_bytes_src; 210 char *cipher_key_bytes_src;
214 struct crypto_tfm *tmp_tfm;
215 int cipher_name_len; 211 int cipher_name_len;
216 212
217 if (!options) { 213 if (!options) {
@@ -308,25 +304,19 @@ static int ecryptfs_parse_options(struct super_block *sb, char *options)
308 = '\0'; 304 = '\0';
309 } 305 }
310 if (!cipher_key_bytes_set) { 306 if (!cipher_key_bytes_set) {
311 mount_crypt_stat->global_default_cipher_key_size = 307 mount_crypt_stat->global_default_cipher_key_size = 0;
312 ECRYPTFS_DEFAULT_KEY_BYTES;
313 ecryptfs_printk(KERN_DEBUG, "Cipher key size was not "
314 "specified. Defaulting to [%d]\n",
315 mount_crypt_stat->
316 global_default_cipher_key_size);
317 } 308 }
318 rc = ecryptfs_process_cipher( 309 rc = ecryptfs_process_cipher(
319 &tmp_tfm,
320 &mount_crypt_stat->global_key_tfm, 310 &mount_crypt_stat->global_key_tfm,
321 mount_crypt_stat->global_default_cipher_name, 311 mount_crypt_stat->global_default_cipher_name,
322 mount_crypt_stat->global_default_cipher_key_size); 312 &mount_crypt_stat->global_default_cipher_key_size);
323 if (tmp_tfm)
324 crypto_free_tfm(tmp_tfm);
325 if (rc) { 313 if (rc) {
326 printk(KERN_ERR "Error attempting to initialize cipher [%s] " 314 printk(KERN_ERR "Error attempting to initialize cipher [%s] "
327 "with key size [%Zd] bytes; rc = [%d]\n", 315 "with key size [%Zd] bytes; rc = [%d]\n",
328 mount_crypt_stat->global_default_cipher_name, 316 mount_crypt_stat->global_default_cipher_name,
329 mount_crypt_stat->global_default_cipher_key_size, rc); 317 mount_crypt_stat->global_default_cipher_key_size, rc);
318 mount_crypt_stat->global_key_tfm = NULL;
319 mount_crypt_stat->global_auth_tok_key = NULL;
330 rc = -EINVAL; 320 rc = -EINVAL;
331 goto out; 321 goto out;
332 } 322 }
diff --git a/fs/ecryptfs/super.c b/fs/ecryptfs/super.c
index c337c0410fb1..825757ae4867 100644
--- a/fs/ecryptfs/super.c
+++ b/fs/ecryptfs/super.c
@@ -138,23 +138,6 @@ static void ecryptfs_clear_inode(struct inode *inode)
138} 138}
139 139
140/** 140/**
141 * ecryptfs_umount_begin
142 *
143 * Called in do_umount().
144 */
145static void ecryptfs_umount_begin(struct vfsmount *vfsmnt, int flags)
146{
147 struct vfsmount *lower_mnt =
148 ecryptfs_dentry_to_lower_mnt(vfsmnt->mnt_sb->s_root);
149 struct super_block *lower_sb;
150
151 mntput(lower_mnt);
152 lower_sb = lower_mnt->mnt_sb;
153 if (lower_sb->s_op->umount_begin)
154 lower_sb->s_op->umount_begin(lower_mnt, flags);
155}
156
157/**
158 * ecryptfs_show_options 141 * ecryptfs_show_options
159 * 142 *
160 * Prints the directory we are currently mounted over. 143 * Prints the directory we are currently mounted over.
@@ -193,6 +176,5 @@ struct super_operations ecryptfs_sops = {
193 .statfs = ecryptfs_statfs, 176 .statfs = ecryptfs_statfs,
194 .remount_fs = NULL, 177 .remount_fs = NULL,
195 .clear_inode = ecryptfs_clear_inode, 178 .clear_inode = ecryptfs_clear_inode,
196 .umount_begin = ecryptfs_umount_begin,
197 .show_options = ecryptfs_show_options 179 .show_options = ecryptfs_show_options
198}; 180};
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 557d5b614fae..ae228ec54e94 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -105,6 +105,8 @@
105/* Maximum msec timeout value storeable in a long int */ 105/* Maximum msec timeout value storeable in a long int */
106#define EP_MAX_MSTIMEO min(1000ULL * MAX_SCHEDULE_TIMEOUT / HZ, (LONG_MAX - 999ULL) / HZ) 106#define EP_MAX_MSTIMEO min(1000ULL * MAX_SCHEDULE_TIMEOUT / HZ, (LONG_MAX - 999ULL) / HZ)
107 107
108#define EP_MAX_EVENTS (INT_MAX / sizeof(struct epoll_event))
109
108 110
109struct epoll_filefd { 111struct epoll_filefd {
110 struct file *file; 112 struct file *file;
@@ -497,7 +499,7 @@ void eventpoll_release_file(struct file *file)
497 */ 499 */
498asmlinkage long sys_epoll_create(int size) 500asmlinkage long sys_epoll_create(int size)
499{ 501{
500 int error, fd; 502 int error, fd = -1;
501 struct eventpoll *ep; 503 struct eventpoll *ep;
502 struct inode *inode; 504 struct inode *inode;
503 struct file *file; 505 struct file *file;
@@ -640,7 +642,6 @@ eexit_1:
640 return error; 642 return error;
641} 643}
642 644
643#define MAX_EVENTS (INT_MAX / sizeof(struct epoll_event))
644 645
645/* 646/*
646 * Implement the event wait interface for the eventpoll file. It is the kernel 647 * Implement the event wait interface for the eventpoll file. It is the kernel
@@ -657,7 +658,7 @@ asmlinkage long sys_epoll_wait(int epfd, struct epoll_event __user *events,
657 current, epfd, events, maxevents, timeout)); 658 current, epfd, events, maxevents, timeout));
658 659
659 /* The maximum number of event must be greater than zero */ 660 /* The maximum number of event must be greater than zero */
660 if (maxevents <= 0 || maxevents > MAX_EVENTS) 661 if (maxevents <= 0 || maxevents > EP_MAX_EVENTS)
661 return -EINVAL; 662 return -EINVAL;
662 663
663 /* Verify that the area passed by the user is writeable */ 664 /* Verify that the area passed by the user is writeable */
@@ -699,6 +700,55 @@ eexit_1:
699} 700}
700 701
701 702
703#ifdef TIF_RESTORE_SIGMASK
704
705/*
706 * Implement the event wait interface for the eventpoll file. It is the kernel
707 * part of the user space epoll_pwait(2).
708 */
709asmlinkage long sys_epoll_pwait(int epfd, struct epoll_event __user *events,
710 int maxevents, int timeout, const sigset_t __user *sigmask,
711 size_t sigsetsize)
712{
713 int error;
714 sigset_t ksigmask, sigsaved;
715
716 /*
717 * If the caller wants a certain signal mask to be set during the wait,
718 * we apply it here.
719 */
720 if (sigmask) {
721 if (sigsetsize != sizeof(sigset_t))
722 return -EINVAL;
723 if (copy_from_user(&ksigmask, sigmask, sizeof(ksigmask)))
724 return -EFAULT;
725 sigdelsetmask(&ksigmask, sigmask(SIGKILL) | sigmask(SIGSTOP));
726 sigprocmask(SIG_SETMASK, &ksigmask, &sigsaved);
727 }
728
729 error = sys_epoll_wait(epfd, events, maxevents, timeout);
730
731 /*
732 * If we changed the signal mask, we need to restore the original one.
733 * In case we've got a signal while waiting, we do not restore the
734 * signal mask yet, and we allow do_signal() to deliver the signal on
735 * the way back to userspace, before the signal mask is restored.
736 */
737 if (sigmask) {
738 if (error == -EINTR) {
739 memcpy(&current->saved_sigmask, &sigsaved,
740 sizeof(sigsaved));
741 set_thread_flag(TIF_RESTORE_SIGMASK);
742 } else
743 sigprocmask(SIG_SETMASK, &sigsaved, NULL);
744 }
745
746 return error;
747}
748
749#endif /* #ifdef TIF_RESTORE_SIGMASK */
750
751
702/* 752/*
703 * Creates the file descriptor to be used by the epoll interface. 753 * Creates the file descriptor to be used by the epoll interface.
704 */ 754 */
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 513cd421ac0b..d8b9abd95d07 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -364,7 +364,6 @@ static int parse_options (char * options,
364{ 364{
365 char * p; 365 char * p;
366 substring_t args[MAX_OPT_ARGS]; 366 substring_t args[MAX_OPT_ARGS];
367 unsigned long kind = EXT2_MOUNT_ERRORS_CONT;
368 int option; 367 int option;
369 368
370 if (!options) 369 if (!options)
@@ -404,13 +403,19 @@ static int parse_options (char * options,
404 /* *sb_block = match_int(&args[0]); */ 403 /* *sb_block = match_int(&args[0]); */
405 break; 404 break;
406 case Opt_err_panic: 405 case Opt_err_panic:
407 kind = EXT2_MOUNT_ERRORS_PANIC; 406 clear_opt (sbi->s_mount_opt, ERRORS_CONT);
407 clear_opt (sbi->s_mount_opt, ERRORS_RO);
408 set_opt (sbi->s_mount_opt, ERRORS_PANIC);
408 break; 409 break;
409 case Opt_err_ro: 410 case Opt_err_ro:
410 kind = EXT2_MOUNT_ERRORS_RO; 411 clear_opt (sbi->s_mount_opt, ERRORS_CONT);
412 clear_opt (sbi->s_mount_opt, ERRORS_PANIC);
413 set_opt (sbi->s_mount_opt, ERRORS_RO);
411 break; 414 break;
412 case Opt_err_cont: 415 case Opt_err_cont:
413 kind = EXT2_MOUNT_ERRORS_CONT; 416 clear_opt (sbi->s_mount_opt, ERRORS_RO);
417 clear_opt (sbi->s_mount_opt, ERRORS_PANIC);
418 set_opt (sbi->s_mount_opt, ERRORS_CONT);
414 break; 419 break;
415 case Opt_nouid32: 420 case Opt_nouid32:
416 set_opt (sbi->s_mount_opt, NO_UID32); 421 set_opt (sbi->s_mount_opt, NO_UID32);
@@ -489,7 +494,6 @@ static int parse_options (char * options,
489 return 0; 494 return 0;
490 } 495 }
491 } 496 }
492 sbi->s_mount_opt |= kind;
493 return 1; 497 return 1;
494} 498}
495 499
@@ -715,6 +719,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
715 set_opt(sbi->s_mount_opt, ERRORS_PANIC); 719 set_opt(sbi->s_mount_opt, ERRORS_PANIC);
716 else if (le16_to_cpu(sbi->s_es->s_errors) == EXT2_ERRORS_RO) 720 else if (le16_to_cpu(sbi->s_es->s_errors) == EXT2_ERRORS_RO)
717 set_opt(sbi->s_mount_opt, ERRORS_RO); 721 set_opt(sbi->s_mount_opt, ERRORS_RO);
722 else
723 set_opt(sbi->s_mount_opt, ERRORS_CONT);
718 724
719 sbi->s_resuid = le16_to_cpu(es->s_def_resuid); 725 sbi->s_resuid = le16_to_cpu(es->s_def_resuid);
720 sbi->s_resgid = le16_to_cpu(es->s_def_resgid); 726 sbi->s_resgid = le16_to_cpu(es->s_def_resgid);
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 8bfd56ef18ca..afc2d4f42d77 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -1470,6 +1470,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1470 set_opt(sbi->s_mount_opt, ERRORS_PANIC); 1470 set_opt(sbi->s_mount_opt, ERRORS_PANIC);
1471 else if (le16_to_cpu(sbi->s_es->s_errors) == EXT3_ERRORS_RO) 1471 else if (le16_to_cpu(sbi->s_es->s_errors) == EXT3_ERRORS_RO)
1472 set_opt(sbi->s_mount_opt, ERRORS_RO); 1472 set_opt(sbi->s_mount_opt, ERRORS_RO);
1473 else
1474 set_opt(sbi->s_mount_opt, ERRORS_CONT);
1473 1475
1474 sbi->s_resuid = le16_to_cpu(es->s_def_resuid); 1476 sbi->s_resuid = le16_to_cpu(es->s_def_resuid);
1475 sbi->s_resgid = le16_to_cpu(es->s_def_resgid); 1477 sbi->s_resgid = le16_to_cpu(es->s_def_resgid);
diff --git a/fs/ext4/Makefile b/fs/ext4/Makefile
new file mode 100644
index 000000000000..a6acb96ebeb9
--- /dev/null
+++ b/fs/ext4/Makefile
@@ -0,0 +1,12 @@
1#
2# Makefile for the linux ext4-filesystem routines.
3#
4
5obj-$(CONFIG_EXT4DEV_FS) += ext4dev.o
6
7ext4dev-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
8 ioctl.o namei.o super.o symlink.o hash.o resize.o extents.o
9
10ext4dev-$(CONFIG_EXT4DEV_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o
11ext4dev-$(CONFIG_EXT4DEV_FS_POSIX_ACL) += acl.o
12ext4dev-$(CONFIG_EXT4DEV_FS_SECURITY) += xattr_security.o
diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c
new file mode 100644
index 000000000000..9e882546d91a
--- /dev/null
+++ b/fs/ext4/acl.c
@@ -0,0 +1,551 @@
1/*
2 * linux/fs/ext4/acl.c
3 *
4 * Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de>
5 */
6
7#include <linux/init.h>
8#include <linux/sched.h>
9#include <linux/slab.h>
10#include <linux/capability.h>
11#include <linux/fs.h>
12#include <linux/ext4_jbd2.h>
13#include <linux/ext4_fs.h>
14#include "xattr.h"
15#include "acl.h"
16
17/*
18 * Convert from filesystem to in-memory representation.
19 */
20static struct posix_acl *
21ext4_acl_from_disk(const void *value, size_t size)
22{
23 const char *end = (char *)value + size;
24 int n, count;
25 struct posix_acl *acl;
26
27 if (!value)
28 return NULL;
29 if (size < sizeof(ext4_acl_header))
30 return ERR_PTR(-EINVAL);
31 if (((ext4_acl_header *)value)->a_version !=
32 cpu_to_le32(EXT4_ACL_VERSION))
33 return ERR_PTR(-EINVAL);
34 value = (char *)value + sizeof(ext4_acl_header);
35 count = ext4_acl_count(size);
36 if (count < 0)
37 return ERR_PTR(-EINVAL);
38 if (count == 0)
39 return NULL;
40 acl = posix_acl_alloc(count, GFP_KERNEL);
41 if (!acl)
42 return ERR_PTR(-ENOMEM);
43 for (n=0; n < count; n++) {
44 ext4_acl_entry *entry =
45 (ext4_acl_entry *)value;
46 if ((char *)value + sizeof(ext4_acl_entry_short) > end)
47 goto fail;
48 acl->a_entries[n].e_tag = le16_to_cpu(entry->e_tag);
49 acl->a_entries[n].e_perm = le16_to_cpu(entry->e_perm);
50 switch(acl->a_entries[n].e_tag) {
51 case ACL_USER_OBJ:
52 case ACL_GROUP_OBJ:
53 case ACL_MASK:
54 case ACL_OTHER:
55 value = (char *)value +
56 sizeof(ext4_acl_entry_short);
57 acl->a_entries[n].e_id = ACL_UNDEFINED_ID;
58 break;
59
60 case ACL_USER:
61 case ACL_GROUP:
62 value = (char *)value + sizeof(ext4_acl_entry);
63 if ((char *)value > end)
64 goto fail;
65 acl->a_entries[n].e_id =
66 le32_to_cpu(entry->e_id);
67 break;
68
69 default:
70 goto fail;
71 }
72 }
73 if (value != end)
74 goto fail;
75 return acl;
76
77fail:
78 posix_acl_release(acl);
79 return ERR_PTR(-EINVAL);
80}
81
82/*
83 * Convert from in-memory to filesystem representation.
84 */
85static void *
86ext4_acl_to_disk(const struct posix_acl *acl, size_t *size)
87{
88 ext4_acl_header *ext_acl;
89 char *e;
90 size_t n;
91
92 *size = ext4_acl_size(acl->a_count);
93 ext_acl = kmalloc(sizeof(ext4_acl_header) + acl->a_count *
94 sizeof(ext4_acl_entry), GFP_KERNEL);
95 if (!ext_acl)
96 return ERR_PTR(-ENOMEM);
97 ext_acl->a_version = cpu_to_le32(EXT4_ACL_VERSION);
98 e = (char *)ext_acl + sizeof(ext4_acl_header);
99 for (n=0; n < acl->a_count; n++) {
100 ext4_acl_entry *entry = (ext4_acl_entry *)e;
101 entry->e_tag = cpu_to_le16(acl->a_entries[n].e_tag);
102 entry->e_perm = cpu_to_le16(acl->a_entries[n].e_perm);
103 switch(acl->a_entries[n].e_tag) {
104 case ACL_USER:
105 case ACL_GROUP:
106 entry->e_id =
107 cpu_to_le32(acl->a_entries[n].e_id);
108 e += sizeof(ext4_acl_entry);
109 break;
110
111 case ACL_USER_OBJ:
112 case ACL_GROUP_OBJ:
113 case ACL_MASK:
114 case ACL_OTHER:
115 e += sizeof(ext4_acl_entry_short);
116 break;
117
118 default:
119 goto fail;
120 }
121 }
122 return (char *)ext_acl;
123
124fail:
125 kfree(ext_acl);
126 return ERR_PTR(-EINVAL);
127}
128
129static inline struct posix_acl *
130ext4_iget_acl(struct inode *inode, struct posix_acl **i_acl)
131{
132 struct posix_acl *acl = EXT4_ACL_NOT_CACHED;
133
134 spin_lock(&inode->i_lock);
135 if (*i_acl != EXT4_ACL_NOT_CACHED)
136 acl = posix_acl_dup(*i_acl);
137 spin_unlock(&inode->i_lock);
138
139 return acl;
140}
141
142static inline void
143ext4_iset_acl(struct inode *inode, struct posix_acl **i_acl,
144 struct posix_acl *acl)
145{
146 spin_lock(&inode->i_lock);
147 if (*i_acl != EXT4_ACL_NOT_CACHED)
148 posix_acl_release(*i_acl);
149 *i_acl = posix_acl_dup(acl);
150 spin_unlock(&inode->i_lock);
151}
152
153/*
154 * Inode operation get_posix_acl().
155 *
156 * inode->i_mutex: don't care
157 */
158static struct posix_acl *
159ext4_get_acl(struct inode *inode, int type)
160{
161 struct ext4_inode_info *ei = EXT4_I(inode);
162 int name_index;
163 char *value = NULL;
164 struct posix_acl *acl;
165 int retval;
166
167 if (!test_opt(inode->i_sb, POSIX_ACL))
168 return NULL;
169
170 switch(type) {
171 case ACL_TYPE_ACCESS:
172 acl = ext4_iget_acl(inode, &ei->i_acl);
173 if (acl != EXT4_ACL_NOT_CACHED)
174 return acl;
175 name_index = EXT4_XATTR_INDEX_POSIX_ACL_ACCESS;
176 break;
177
178 case ACL_TYPE_DEFAULT:
179 acl = ext4_iget_acl(inode, &ei->i_default_acl);
180 if (acl != EXT4_ACL_NOT_CACHED)
181 return acl;
182 name_index = EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT;
183 break;
184
185 default:
186 return ERR_PTR(-EINVAL);
187 }
188 retval = ext4_xattr_get(inode, name_index, "", NULL, 0);
189 if (retval > 0) {
190 value = kmalloc(retval, GFP_KERNEL);
191 if (!value)
192 return ERR_PTR(-ENOMEM);
193 retval = ext4_xattr_get(inode, name_index, "", value, retval);
194 }
195 if (retval > 0)
196 acl = ext4_acl_from_disk(value, retval);
197 else if (retval == -ENODATA || retval == -ENOSYS)
198 acl = NULL;
199 else
200 acl = ERR_PTR(retval);
201 kfree(value);
202
203 if (!IS_ERR(acl)) {
204 switch(type) {
205 case ACL_TYPE_ACCESS:
206 ext4_iset_acl(inode, &ei->i_acl, acl);
207 break;
208
209 case ACL_TYPE_DEFAULT:
210 ext4_iset_acl(inode, &ei->i_default_acl, acl);
211 break;
212 }
213 }
214 return acl;
215}
216
217/*
218 * Set the access or default ACL of an inode.
219 *
220 * inode->i_mutex: down unless called from ext4_new_inode
221 */
222static int
223ext4_set_acl(handle_t *handle, struct inode *inode, int type,
224 struct posix_acl *acl)
225{
226 struct ext4_inode_info *ei = EXT4_I(inode);
227 int name_index;
228 void *value = NULL;
229 size_t size = 0;
230 int error;
231
232 if (S_ISLNK(inode->i_mode))
233 return -EOPNOTSUPP;
234
235 switch(type) {
236 case ACL_TYPE_ACCESS:
237 name_index = EXT4_XATTR_INDEX_POSIX_ACL_ACCESS;
238 if (acl) {
239 mode_t mode = inode->i_mode;
240 error = posix_acl_equiv_mode(acl, &mode);
241 if (error < 0)
242 return error;
243 else {
244 inode->i_mode = mode;
245 ext4_mark_inode_dirty(handle, inode);
246 if (error == 0)
247 acl = NULL;
248 }
249 }
250 break;
251
252 case ACL_TYPE_DEFAULT:
253 name_index = EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT;
254 if (!S_ISDIR(inode->i_mode))
255 return acl ? -EACCES : 0;
256 break;
257
258 default:
259 return -EINVAL;
260 }
261 if (acl) {
262 value = ext4_acl_to_disk(acl, &size);
263 if (IS_ERR(value))
264 return (int)PTR_ERR(value);
265 }
266
267 error = ext4_xattr_set_handle(handle, inode, name_index, "",
268 value, size, 0);
269
270 kfree(value);
271 if (!error) {
272 switch(type) {
273 case ACL_TYPE_ACCESS:
274 ext4_iset_acl(inode, &ei->i_acl, acl);
275 break;
276
277 case ACL_TYPE_DEFAULT:
278 ext4_iset_acl(inode, &ei->i_default_acl, acl);
279 break;
280 }
281 }
282 return error;
283}
284
285static int
286ext4_check_acl(struct inode *inode, int mask)
287{
288 struct posix_acl *acl = ext4_get_acl(inode, ACL_TYPE_ACCESS);
289
290 if (IS_ERR(acl))
291 return PTR_ERR(acl);
292 if (acl) {
293 int error = posix_acl_permission(inode, acl, mask);
294 posix_acl_release(acl);
295 return error;
296 }
297
298 return -EAGAIN;
299}
300
301int
302ext4_permission(struct inode *inode, int mask, struct nameidata *nd)
303{
304 return generic_permission(inode, mask, ext4_check_acl);
305}
306
307/*
308 * Initialize the ACLs of a new inode. Called from ext4_new_inode.
309 *
310 * dir->i_mutex: down
311 * inode->i_mutex: up (access to inode is still exclusive)
312 */
313int
314ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
315{
316 struct posix_acl *acl = NULL;
317 int error = 0;
318
319 if (!S_ISLNK(inode->i_mode)) {
320 if (test_opt(dir->i_sb, POSIX_ACL)) {
321 acl = ext4_get_acl(dir, ACL_TYPE_DEFAULT);
322 if (IS_ERR(acl))
323 return PTR_ERR(acl);
324 }
325 if (!acl)
326 inode->i_mode &= ~current->fs->umask;
327 }
328 if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
329 struct posix_acl *clone;
330 mode_t mode;
331
332 if (S_ISDIR(inode->i_mode)) {
333 error = ext4_set_acl(handle, inode,
334 ACL_TYPE_DEFAULT, acl);
335 if (error)
336 goto cleanup;
337 }
338 clone = posix_acl_clone(acl, GFP_KERNEL);
339 error = -ENOMEM;
340 if (!clone)
341 goto cleanup;
342
343 mode = inode->i_mode;
344 error = posix_acl_create_masq(clone, &mode);
345 if (error >= 0) {
346 inode->i_mode = mode;
347 if (error > 0) {
348 /* This is an extended ACL */
349 error = ext4_set_acl(handle, inode,
350 ACL_TYPE_ACCESS, clone);
351 }
352 }
353 posix_acl_release(clone);
354 }
355cleanup:
356 posix_acl_release(acl);
357 return error;
358}
359
360/*
361 * Does chmod for an inode that may have an Access Control List. The
362 * inode->i_mode field must be updated to the desired value by the caller
363 * before calling this function.
364 * Returns 0 on success, or a negative error number.
365 *
366 * We change the ACL rather than storing some ACL entries in the file
367 * mode permission bits (which would be more efficient), because that
368 * would break once additional permissions (like ACL_APPEND, ACL_DELETE
369 * for directories) are added. There are no more bits available in the
370 * file mode.
371 *
372 * inode->i_mutex: down
373 */
374int
375ext4_acl_chmod(struct inode *inode)
376{
377 struct posix_acl *acl, *clone;
378 int error;
379
380 if (S_ISLNK(inode->i_mode))
381 return -EOPNOTSUPP;
382 if (!test_opt(inode->i_sb, POSIX_ACL))
383 return 0;
384 acl = ext4_get_acl(inode, ACL_TYPE_ACCESS);
385 if (IS_ERR(acl) || !acl)
386 return PTR_ERR(acl);
387 clone = posix_acl_clone(acl, GFP_KERNEL);
388 posix_acl_release(acl);
389 if (!clone)
390 return -ENOMEM;
391 error = posix_acl_chmod_masq(clone, inode->i_mode);
392 if (!error) {
393 handle_t *handle;
394 int retries = 0;
395
396 retry:
397 handle = ext4_journal_start(inode,
398 EXT4_DATA_TRANS_BLOCKS(inode->i_sb));
399 if (IS_ERR(handle)) {
400 error = PTR_ERR(handle);
401 ext4_std_error(inode->i_sb, error);
402 goto out;
403 }
404 error = ext4_set_acl(handle, inode, ACL_TYPE_ACCESS, clone);
405 ext4_journal_stop(handle);
406 if (error == -ENOSPC &&
407 ext4_should_retry_alloc(inode->i_sb, &retries))
408 goto retry;
409 }
410out:
411 posix_acl_release(clone);
412 return error;
413}
414
415/*
416 * Extended attribute handlers
417 */
418static size_t
419ext4_xattr_list_acl_access(struct inode *inode, char *list, size_t list_len,
420 const char *name, size_t name_len)
421{
422 const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS);
423
424 if (!test_opt(inode->i_sb, POSIX_ACL))
425 return 0;
426 if (list && size <= list_len)
427 memcpy(list, POSIX_ACL_XATTR_ACCESS, size);
428 return size;
429}
430
431static size_t
432ext4_xattr_list_acl_default(struct inode *inode, char *list, size_t list_len,
433 const char *name, size_t name_len)
434{
435 const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT);
436
437 if (!test_opt(inode->i_sb, POSIX_ACL))
438 return 0;
439 if (list && size <= list_len)
440 memcpy(list, POSIX_ACL_XATTR_DEFAULT, size);
441 return size;
442}
443
444static int
445ext4_xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size)
446{
447 struct posix_acl *acl;
448 int error;
449
450 if (!test_opt(inode->i_sb, POSIX_ACL))
451 return -EOPNOTSUPP;
452
453 acl = ext4_get_acl(inode, type);
454 if (IS_ERR(acl))
455 return PTR_ERR(acl);
456 if (acl == NULL)
457 return -ENODATA;
458 error = posix_acl_to_xattr(acl, buffer, size);
459 posix_acl_release(acl);
460
461 return error;
462}
463
464static int
465ext4_xattr_get_acl_access(struct inode *inode, const char *name,
466 void *buffer, size_t size)
467{
468 if (strcmp(name, "") != 0)
469 return -EINVAL;
470 return ext4_xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size);
471}
472
473static int
474ext4_xattr_get_acl_default(struct inode *inode, const char *name,
475 void *buffer, size_t size)
476{
477 if (strcmp(name, "") != 0)
478 return -EINVAL;
479 return ext4_xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size);
480}
481
482static int
483ext4_xattr_set_acl(struct inode *inode, int type, const void *value,
484 size_t size)
485{
486 handle_t *handle;
487 struct posix_acl *acl;
488 int error, retries = 0;
489
490 if (!test_opt(inode->i_sb, POSIX_ACL))
491 return -EOPNOTSUPP;
492 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
493 return -EPERM;
494
495 if (value) {
496 acl = posix_acl_from_xattr(value, size);
497 if (IS_ERR(acl))
498 return PTR_ERR(acl);
499 else if (acl) {
500 error = posix_acl_valid(acl);
501 if (error)
502 goto release_and_out;
503 }
504 } else
505 acl = NULL;
506
507retry:
508 handle = ext4_journal_start(inode, EXT4_DATA_TRANS_BLOCKS(inode->i_sb));
509 if (IS_ERR(handle))
510 return PTR_ERR(handle);
511 error = ext4_set_acl(handle, inode, type, acl);
512 ext4_journal_stop(handle);
513 if (error == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
514 goto retry;
515
516release_and_out:
517 posix_acl_release(acl);
518 return error;
519}
520
521static int
522ext4_xattr_set_acl_access(struct inode *inode, const char *name,
523 const void *value, size_t size, int flags)
524{
525 if (strcmp(name, "") != 0)
526 return -EINVAL;
527 return ext4_xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size);
528}
529
530static int
531ext4_xattr_set_acl_default(struct inode *inode, const char *name,
532 const void *value, size_t size, int flags)
533{
534 if (strcmp(name, "") != 0)
535 return -EINVAL;
536 return ext4_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size);
537}
538
539struct xattr_handler ext4_xattr_acl_access_handler = {
540 .prefix = POSIX_ACL_XATTR_ACCESS,
541 .list = ext4_xattr_list_acl_access,
542 .get = ext4_xattr_get_acl_access,
543 .set = ext4_xattr_set_acl_access,
544};
545
546struct xattr_handler ext4_xattr_acl_default_handler = {
547 .prefix = POSIX_ACL_XATTR_DEFAULT,
548 .list = ext4_xattr_list_acl_default,
549 .get = ext4_xattr_get_acl_default,
550 .set = ext4_xattr_set_acl_default,
551};
diff --git a/fs/ext4/acl.h b/fs/ext4/acl.h
new file mode 100644
index 000000000000..26a5c1abf147
--- /dev/null
+++ b/fs/ext4/acl.h
@@ -0,0 +1,81 @@
1/*
2 File: fs/ext4/acl.h
3
4 (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
5*/
6
7#include <linux/posix_acl_xattr.h>
8
9#define EXT4_ACL_VERSION 0x0001
10
11typedef struct {
12 __le16 e_tag;
13 __le16 e_perm;
14 __le32 e_id;
15} ext4_acl_entry;
16
17typedef struct {
18 __le16 e_tag;
19 __le16 e_perm;
20} ext4_acl_entry_short;
21
22typedef struct {
23 __le32 a_version;
24} ext4_acl_header;
25
26static inline size_t ext4_acl_size(int count)
27{
28 if (count <= 4) {
29 return sizeof(ext4_acl_header) +
30 count * sizeof(ext4_acl_entry_short);
31 } else {
32 return sizeof(ext4_acl_header) +
33 4 * sizeof(ext4_acl_entry_short) +
34 (count - 4) * sizeof(ext4_acl_entry);
35 }
36}
37
38static inline int ext4_acl_count(size_t size)
39{
40 ssize_t s;
41 size -= sizeof(ext4_acl_header);
42 s = size - 4 * sizeof(ext4_acl_entry_short);
43 if (s < 0) {
44 if (size % sizeof(ext4_acl_entry_short))
45 return -1;
46 return size / sizeof(ext4_acl_entry_short);
47 } else {
48 if (s % sizeof(ext4_acl_entry))
49 return -1;
50 return s / sizeof(ext4_acl_entry) + 4;
51 }
52}
53
54#ifdef CONFIG_EXT4DEV_FS_POSIX_ACL
55
56/* Value for inode->u.ext4_i.i_acl and inode->u.ext4_i.i_default_acl
57 if the ACL has not been cached */
58#define EXT4_ACL_NOT_CACHED ((void *)-1)
59
60/* acl.c */
61extern int ext4_permission (struct inode *, int, struct nameidata *);
62extern int ext4_acl_chmod (struct inode *);
63extern int ext4_init_acl (handle_t *, struct inode *, struct inode *);
64
65#else /* CONFIG_EXT4DEV_FS_POSIX_ACL */
66#include <linux/sched.h>
67#define ext4_permission NULL
68
69static inline int
70ext4_acl_chmod(struct inode *inode)
71{
72 return 0;
73}
74
75static inline int
76ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
77{
78 return 0;
79}
80#endif /* CONFIG_EXT4DEV_FS_POSIX_ACL */
81
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
new file mode 100644
index 000000000000..5d45582f9517
--- /dev/null
+++ b/fs/ext4/balloc.c
@@ -0,0 +1,1833 @@
1/*
2 * linux/fs/ext4/balloc.c
3 *
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 *
9 * Enhanced block allocation by Stephen Tweedie (sct@redhat.com), 1993
10 * Big-endian to little-endian byte-swapping/bitmaps by
11 * David S. Miller (davem@caip.rutgers.edu), 1995
12 */
13
14#include <linux/time.h>
15#include <linux/capability.h>
16#include <linux/fs.h>
17#include <linux/jbd2.h>
18#include <linux/ext4_fs.h>
19#include <linux/ext4_jbd2.h>
20#include <linux/quotaops.h>
21#include <linux/buffer_head.h>
22
23/*
24 * balloc.c contains the blocks allocation and deallocation routines
25 */
26
27/*
28 * Calculate the block group number and offset, given a block number
29 */
30void ext4_get_group_no_and_offset(struct super_block *sb, ext4_fsblk_t blocknr,
31 unsigned long *blockgrpp, ext4_grpblk_t *offsetp)
32{
33 struct ext4_super_block *es = EXT4_SB(sb)->s_es;
34 ext4_grpblk_t offset;
35
36 blocknr = blocknr - le32_to_cpu(es->s_first_data_block);
37 offset = do_div(blocknr, EXT4_BLOCKS_PER_GROUP(sb));
38 if (offsetp)
39 *offsetp = offset;
40 if (blockgrpp)
41 *blockgrpp = blocknr;
42
43}
44
45/*
46 * The free blocks are managed by bitmaps. A file system contains several
47 * blocks groups. Each group contains 1 bitmap block for blocks, 1 bitmap
48 * block for inodes, N blocks for the inode table and data blocks.
49 *
50 * The file system contains group descriptors which are located after the
51 * super block. Each descriptor contains the number of the bitmap block and
52 * the free blocks count in the block. The descriptors are loaded in memory
53 * when a file system is mounted (see ext4_read_super).
54 */
55
56
57#define in_range(b, first, len) ((b) >= (first) && (b) <= (first) + (len) - 1)
58
59/**
60 * ext4_get_group_desc() -- load group descriptor from disk
61 * @sb: super block
62 * @block_group: given block group
63 * @bh: pointer to the buffer head to store the block
64 * group descriptor
65 */
66struct ext4_group_desc * ext4_get_group_desc(struct super_block * sb,
67 unsigned int block_group,
68 struct buffer_head ** bh)
69{
70 unsigned long group_desc;
71 unsigned long offset;
72 struct ext4_group_desc * desc;
73 struct ext4_sb_info *sbi = EXT4_SB(sb);
74
75 if (block_group >= sbi->s_groups_count) {
76 ext4_error (sb, "ext4_get_group_desc",
77 "block_group >= groups_count - "
78 "block_group = %d, groups_count = %lu",
79 block_group, sbi->s_groups_count);
80
81 return NULL;
82 }
83 smp_rmb();
84
85 group_desc = block_group >> EXT4_DESC_PER_BLOCK_BITS(sb);
86 offset = block_group & (EXT4_DESC_PER_BLOCK(sb) - 1);
87 if (!sbi->s_group_desc[group_desc]) {
88 ext4_error (sb, "ext4_get_group_desc",
89 "Group descriptor not loaded - "
90 "block_group = %d, group_desc = %lu, desc = %lu",
91 block_group, group_desc, offset);
92 return NULL;
93 }
94
95 desc = (struct ext4_group_desc *)(
96 (__u8 *)sbi->s_group_desc[group_desc]->b_data +
97 offset * EXT4_DESC_SIZE(sb));
98 if (bh)
99 *bh = sbi->s_group_desc[group_desc];
100 return desc;
101}
102
103/**
104 * read_block_bitmap()
105 * @sb: super block
106 * @block_group: given block group
107 *
108 * Read the bitmap for a given block_group, reading into the specified
109 * slot in the superblock's bitmap cache.
110 *
111 * Return buffer_head on success or NULL in case of failure.
112 */
113static struct buffer_head *
114read_block_bitmap(struct super_block *sb, unsigned int block_group)
115{
116 struct ext4_group_desc * desc;
117 struct buffer_head * bh = NULL;
118
119 desc = ext4_get_group_desc (sb, block_group, NULL);
120 if (!desc)
121 goto error_out;
122 bh = sb_bread(sb, ext4_block_bitmap(sb, desc));
123 if (!bh)
124 ext4_error (sb, "read_block_bitmap",
125 "Cannot read block bitmap - "
126 "block_group = %d, block_bitmap = %llu",
127 block_group,
128 ext4_block_bitmap(sb, desc));
129error_out:
130 return bh;
131}
132/*
133 * The reservation window structure operations
134 * --------------------------------------------
135 * Operations include:
136 * dump, find, add, remove, is_empty, find_next_reservable_window, etc.
137 *
138 * We use a red-black tree to represent per-filesystem reservation
139 * windows.
140 *
141 */
142
143/**
144 * __rsv_window_dump() -- Dump the filesystem block allocation reservation map
145 * @rb_root: root of per-filesystem reservation rb tree
146 * @verbose: verbose mode
147 * @fn: function which wishes to dump the reservation map
148 *
149 * If verbose is turned on, it will print the whole block reservation
150 * windows(start, end). Otherwise, it will only print out the "bad" windows,
151 * those windows that overlap with their immediate neighbors.
152 */
153#if 1
154static void __rsv_window_dump(struct rb_root *root, int verbose,
155 const char *fn)
156{
157 struct rb_node *n;
158 struct ext4_reserve_window_node *rsv, *prev;
159 int bad;
160
161restart:
162 n = rb_first(root);
163 bad = 0;
164 prev = NULL;
165
166 printk("Block Allocation Reservation Windows Map (%s):\n", fn);
167 while (n) {
168 rsv = list_entry(n, struct ext4_reserve_window_node, rsv_node);
169 if (verbose)
170 printk("reservation window 0x%p "
171 "start: %llu, end: %llu\n",
172 rsv, rsv->rsv_start, rsv->rsv_end);
173 if (rsv->rsv_start && rsv->rsv_start >= rsv->rsv_end) {
174 printk("Bad reservation %p (start >= end)\n",
175 rsv);
176 bad = 1;
177 }
178 if (prev && prev->rsv_end >= rsv->rsv_start) {
179 printk("Bad reservation %p (prev->end >= start)\n",
180 rsv);
181 bad = 1;
182 }
183 if (bad) {
184 if (!verbose) {
185 printk("Restarting reservation walk in verbose mode\n");
186 verbose = 1;
187 goto restart;
188 }
189 }
190 n = rb_next(n);
191 prev = rsv;
192 }
193 printk("Window map complete.\n");
194 if (bad)
195 BUG();
196}
197#define rsv_window_dump(root, verbose) \
198 __rsv_window_dump((root), (verbose), __FUNCTION__)
199#else
200#define rsv_window_dump(root, verbose) do {} while (0)
201#endif
202
203/**
204 * goal_in_my_reservation()
205 * @rsv: inode's reservation window
206 * @grp_goal: given goal block relative to the allocation block group
207 * @group: the current allocation block group
208 * @sb: filesystem super block
209 *
210 * Test if the given goal block (group relative) is within the file's
211 * own block reservation window range.
212 *
213 * If the reservation window is outside the goal allocation group, return 0;
214 * grp_goal (given goal block) could be -1, which means no specific
215 * goal block. In this case, always return 1.
216 * If the goal block is within the reservation window, return 1;
217 * otherwise, return 0;
218 */
219static int
220goal_in_my_reservation(struct ext4_reserve_window *rsv, ext4_grpblk_t grp_goal,
221 unsigned int group, struct super_block * sb)
222{
223 ext4_fsblk_t group_first_block, group_last_block;
224
225 group_first_block = ext4_group_first_block_no(sb, group);
226 group_last_block = group_first_block + (EXT4_BLOCKS_PER_GROUP(sb) - 1);
227
228 if ((rsv->_rsv_start > group_last_block) ||
229 (rsv->_rsv_end < group_first_block))
230 return 0;
231 if ((grp_goal >= 0) && ((grp_goal + group_first_block < rsv->_rsv_start)
232 || (grp_goal + group_first_block > rsv->_rsv_end)))
233 return 0;
234 return 1;
235}
236
237/**
238 * search_reserve_window()
239 * @rb_root: root of reservation tree
240 * @goal: target allocation block
241 *
242 * Find the reserved window which includes the goal, or the previous one
243 * if the goal is not in any window.
244 * Returns NULL if there are no windows or if all windows start after the goal.
245 */
246static struct ext4_reserve_window_node *
247search_reserve_window(struct rb_root *root, ext4_fsblk_t goal)
248{
249 struct rb_node *n = root->rb_node;
250 struct ext4_reserve_window_node *rsv;
251
252 if (!n)
253 return NULL;
254
255 do {
256 rsv = rb_entry(n, struct ext4_reserve_window_node, rsv_node);
257
258 if (goal < rsv->rsv_start)
259 n = n->rb_left;
260 else if (goal > rsv->rsv_end)
261 n = n->rb_right;
262 else
263 return rsv;
264 } while (n);
265 /*
266 * We've fallen off the end of the tree: the goal wasn't inside
267 * any particular node. OK, the previous node must be to one
268 * side of the interval containing the goal. If it's the RHS,
269 * we need to back up one.
270 */
271 if (rsv->rsv_start > goal) {
272 n = rb_prev(&rsv->rsv_node);
273 rsv = rb_entry(n, struct ext4_reserve_window_node, rsv_node);
274 }
275 return rsv;
276}
277
278/**
279 * ext4_rsv_window_add() -- Insert a window to the block reservation rb tree.
280 * @sb: super block
281 * @rsv: reservation window to add
282 *
283 * Must be called with rsv_lock hold.
284 */
285void ext4_rsv_window_add(struct super_block *sb,
286 struct ext4_reserve_window_node *rsv)
287{
288 struct rb_root *root = &EXT4_SB(sb)->s_rsv_window_root;
289 struct rb_node *node = &rsv->rsv_node;
290 ext4_fsblk_t start = rsv->rsv_start;
291
292 struct rb_node ** p = &root->rb_node;
293 struct rb_node * parent = NULL;
294 struct ext4_reserve_window_node *this;
295
296 while (*p)
297 {
298 parent = *p;
299 this = rb_entry(parent, struct ext4_reserve_window_node, rsv_node);
300
301 if (start < this->rsv_start)
302 p = &(*p)->rb_left;
303 else if (start > this->rsv_end)
304 p = &(*p)->rb_right;
305 else {
306 rsv_window_dump(root, 1);
307 BUG();
308 }
309 }
310
311 rb_link_node(node, parent, p);
312 rb_insert_color(node, root);
313}
314
315/**
316 * ext4_rsv_window_remove() -- unlink a window from the reservation rb tree
317 * @sb: super block
318 * @rsv: reservation window to remove
319 *
320 * Mark the block reservation window as not allocated, and unlink it
321 * from the filesystem reservation window rb tree. Must be called with
322 * rsv_lock hold.
323 */
324static void rsv_window_remove(struct super_block *sb,
325 struct ext4_reserve_window_node *rsv)
326{
327 rsv->rsv_start = EXT4_RESERVE_WINDOW_NOT_ALLOCATED;
328 rsv->rsv_end = EXT4_RESERVE_WINDOW_NOT_ALLOCATED;
329 rsv->rsv_alloc_hit = 0;
330 rb_erase(&rsv->rsv_node, &EXT4_SB(sb)->s_rsv_window_root);
331}
332
333/*
334 * rsv_is_empty() -- Check if the reservation window is allocated.
335 * @rsv: given reservation window to check
336 *
337 * returns 1 if the end block is EXT4_RESERVE_WINDOW_NOT_ALLOCATED.
338 */
339static inline int rsv_is_empty(struct ext4_reserve_window *rsv)
340{
341 /* a valid reservation end block could not be 0 */
342 return rsv->_rsv_end == EXT4_RESERVE_WINDOW_NOT_ALLOCATED;
343}
344
345/**
346 * ext4_init_block_alloc_info()
347 * @inode: file inode structure
348 *
349 * Allocate and initialize the reservation window structure, and
350 * link the window to the ext4 inode structure at last
351 *
352 * The reservation window structure is only dynamically allocated
353 * and linked to ext4 inode the first time the open file
354 * needs a new block. So, before every ext4_new_block(s) call, for
355 * regular files, we should check whether the reservation window
356 * structure exists or not. In the latter case, this function is called.
357 * Fail to do so will result in block reservation being turned off for that
358 * open file.
359 *
360 * This function is called from ext4_get_blocks_handle(), also called
361 * when setting the reservation window size through ioctl before the file
362 * is open for write (needs block allocation).
363 *
364 * Needs truncate_mutex protection prior to call this function.
365 */
366void ext4_init_block_alloc_info(struct inode *inode)
367{
368 struct ext4_inode_info *ei = EXT4_I(inode);
369 struct ext4_block_alloc_info *block_i = ei->i_block_alloc_info;
370 struct super_block *sb = inode->i_sb;
371
372 block_i = kmalloc(sizeof(*block_i), GFP_NOFS);
373 if (block_i) {
374 struct ext4_reserve_window_node *rsv = &block_i->rsv_window_node;
375
376 rsv->rsv_start = EXT4_RESERVE_WINDOW_NOT_ALLOCATED;
377 rsv->rsv_end = EXT4_RESERVE_WINDOW_NOT_ALLOCATED;
378
379 /*
380 * if filesystem is mounted with NORESERVATION, the goal
381 * reservation window size is set to zero to indicate
382 * block reservation is off
383 */
384 if (!test_opt(sb, RESERVATION))
385 rsv->rsv_goal_size = 0;
386 else
387 rsv->rsv_goal_size = EXT4_DEFAULT_RESERVE_BLOCKS;
388 rsv->rsv_alloc_hit = 0;
389 block_i->last_alloc_logical_block = 0;
390 block_i->last_alloc_physical_block = 0;
391 }
392 ei->i_block_alloc_info = block_i;
393}
394
395/**
396 * ext4_discard_reservation()
397 * @inode: inode
398 *
399 * Discard(free) block reservation window on last file close, or truncate
400 * or at last iput().
401 *
402 * It is being called in three cases:
403 * ext4_release_file(): last writer close the file
404 * ext4_clear_inode(): last iput(), when nobody link to this file.
405 * ext4_truncate(): when the block indirect map is about to change.
406 *
407 */
408void ext4_discard_reservation(struct inode *inode)
409{
410 struct ext4_inode_info *ei = EXT4_I(inode);
411 struct ext4_block_alloc_info *block_i = ei->i_block_alloc_info;
412 struct ext4_reserve_window_node *rsv;
413 spinlock_t *rsv_lock = &EXT4_SB(inode->i_sb)->s_rsv_window_lock;
414
415 if (!block_i)
416 return;
417
418 rsv = &block_i->rsv_window_node;
419 if (!rsv_is_empty(&rsv->rsv_window)) {
420 spin_lock(rsv_lock);
421 if (!rsv_is_empty(&rsv->rsv_window))
422 rsv_window_remove(inode->i_sb, rsv);
423 spin_unlock(rsv_lock);
424 }
425}
426
427/**
428 * ext4_free_blocks_sb() -- Free given blocks and update quota
429 * @handle: handle to this transaction
430 * @sb: super block
431 * @block: start physcial block to free
432 * @count: number of blocks to free
433 * @pdquot_freed_blocks: pointer to quota
434 */
435void ext4_free_blocks_sb(handle_t *handle, struct super_block *sb,
436 ext4_fsblk_t block, unsigned long count,
437 unsigned long *pdquot_freed_blocks)
438{
439 struct buffer_head *bitmap_bh = NULL;
440 struct buffer_head *gd_bh;
441 unsigned long block_group;
442 ext4_grpblk_t bit;
443 unsigned long i;
444 unsigned long overflow;
445 struct ext4_group_desc * desc;
446 struct ext4_super_block * es;
447 struct ext4_sb_info *sbi;
448 int err = 0, ret;
449 ext4_grpblk_t group_freed;
450
451 *pdquot_freed_blocks = 0;
452 sbi = EXT4_SB(sb);
453 es = sbi->s_es;
454 if (block < le32_to_cpu(es->s_first_data_block) ||
455 block + count < block ||
456 block + count > ext4_blocks_count(es)) {
457 ext4_error (sb, "ext4_free_blocks",
458 "Freeing blocks not in datazone - "
459 "block = %llu, count = %lu", block, count);
460 goto error_return;
461 }
462
463 ext4_debug ("freeing block(s) %llu-%llu\n", block, block + count - 1);
464
465do_more:
466 overflow = 0;
467 ext4_get_group_no_and_offset(sb, block, &block_group, &bit);
468 /*
469 * Check to see if we are freeing blocks across a group
470 * boundary.
471 */
472 if (bit + count > EXT4_BLOCKS_PER_GROUP(sb)) {
473 overflow = bit + count - EXT4_BLOCKS_PER_GROUP(sb);
474 count -= overflow;
475 }
476 brelse(bitmap_bh);
477 bitmap_bh = read_block_bitmap(sb, block_group);
478 if (!bitmap_bh)
479 goto error_return;
480 desc = ext4_get_group_desc (sb, block_group, &gd_bh);
481 if (!desc)
482 goto error_return;
483
484 if (in_range(ext4_block_bitmap(sb, desc), block, count) ||
485 in_range(ext4_inode_bitmap(sb, desc), block, count) ||
486 in_range(block, ext4_inode_table(sb, desc), sbi->s_itb_per_group) ||
487 in_range(block + count - 1, ext4_inode_table(sb, desc),
488 sbi->s_itb_per_group))
489 ext4_error (sb, "ext4_free_blocks",
490 "Freeing blocks in system zones - "
491 "Block = %llu, count = %lu",
492 block, count);
493
494 /*
495 * We are about to start releasing blocks in the bitmap,
496 * so we need undo access.
497 */
498 /* @@@ check errors */
499 BUFFER_TRACE(bitmap_bh, "getting undo access");
500 err = ext4_journal_get_undo_access(handle, bitmap_bh);
501 if (err)
502 goto error_return;
503
504 /*
505 * We are about to modify some metadata. Call the journal APIs
506 * to unshare ->b_data if a currently-committing transaction is
507 * using it
508 */
509 BUFFER_TRACE(gd_bh, "get_write_access");
510 err = ext4_journal_get_write_access(handle, gd_bh);
511 if (err)
512 goto error_return;
513
514 jbd_lock_bh_state(bitmap_bh);
515
516 for (i = 0, group_freed = 0; i < count; i++) {
517 /*
518 * An HJ special. This is expensive...
519 */
520#ifdef CONFIG_JBD_DEBUG
521 jbd_unlock_bh_state(bitmap_bh);
522 {
523 struct buffer_head *debug_bh;
524 debug_bh = sb_find_get_block(sb, block + i);
525 if (debug_bh) {
526 BUFFER_TRACE(debug_bh, "Deleted!");
527 if (!bh2jh(bitmap_bh)->b_committed_data)
528 BUFFER_TRACE(debug_bh,
529 "No commited data in bitmap");
530 BUFFER_TRACE2(debug_bh, bitmap_bh, "bitmap");
531 __brelse(debug_bh);
532 }
533 }
534 jbd_lock_bh_state(bitmap_bh);
535#endif
536 if (need_resched()) {
537 jbd_unlock_bh_state(bitmap_bh);
538 cond_resched();
539 jbd_lock_bh_state(bitmap_bh);
540 }
541 /* @@@ This prevents newly-allocated data from being
542 * freed and then reallocated within the same
543 * transaction.
544 *
545 * Ideally we would want to allow that to happen, but to
546 * do so requires making jbd2_journal_forget() capable of
547 * revoking the queued write of a data block, which
548 * implies blocking on the journal lock. *forget()
549 * cannot block due to truncate races.
550 *
551 * Eventually we can fix this by making jbd2_journal_forget()
552 * return a status indicating whether or not it was able
553 * to revoke the buffer. On successful revoke, it is
554 * safe not to set the allocation bit in the committed
555 * bitmap, because we know that there is no outstanding
556 * activity on the buffer any more and so it is safe to
557 * reallocate it.
558 */
559 BUFFER_TRACE(bitmap_bh, "set in b_committed_data");
560 J_ASSERT_BH(bitmap_bh,
561 bh2jh(bitmap_bh)->b_committed_data != NULL);
562 ext4_set_bit_atomic(sb_bgl_lock(sbi, block_group), bit + i,
563 bh2jh(bitmap_bh)->b_committed_data);
564
565 /*
566 * We clear the bit in the bitmap after setting the committed
567 * data bit, because this is the reverse order to that which
568 * the allocator uses.
569 */
570 BUFFER_TRACE(bitmap_bh, "clear bit");
571 if (!ext4_clear_bit_atomic(sb_bgl_lock(sbi, block_group),
572 bit + i, bitmap_bh->b_data)) {
573 jbd_unlock_bh_state(bitmap_bh);
574 ext4_error(sb, __FUNCTION__,
575 "bit already cleared for block %llu",
576 (ext4_fsblk_t)(block + i));
577 jbd_lock_bh_state(bitmap_bh);
578 BUFFER_TRACE(bitmap_bh, "bit already cleared");
579 } else {
580 group_freed++;
581 }
582 }
583 jbd_unlock_bh_state(bitmap_bh);
584
585 spin_lock(sb_bgl_lock(sbi, block_group));
586 desc->bg_free_blocks_count =
587 cpu_to_le16(le16_to_cpu(desc->bg_free_blocks_count) +
588 group_freed);
589 spin_unlock(sb_bgl_lock(sbi, block_group));
590 percpu_counter_mod(&sbi->s_freeblocks_counter, count);
591
592 /* We dirtied the bitmap block */
593 BUFFER_TRACE(bitmap_bh, "dirtied bitmap block");
594 err = ext4_journal_dirty_metadata(handle, bitmap_bh);
595
596 /* And the group descriptor block */
597 BUFFER_TRACE(gd_bh, "dirtied group descriptor block");
598 ret = ext4_journal_dirty_metadata(handle, gd_bh);
599 if (!err) err = ret;
600 *pdquot_freed_blocks += group_freed;
601
602 if (overflow && !err) {
603 block += count;
604 count = overflow;
605 goto do_more;
606 }
607 sb->s_dirt = 1;
608error_return:
609 brelse(bitmap_bh);
610 ext4_std_error(sb, err);
611 return;
612}
613
614/**
615 * ext4_free_blocks() -- Free given blocks and update quota
616 * @handle: handle for this transaction
617 * @inode: inode
618 * @block: start physical block to free
619 * @count: number of blocks to count
620 */
621void ext4_free_blocks(handle_t *handle, struct inode *inode,
622 ext4_fsblk_t block, unsigned long count)
623{
624 struct super_block * sb;
625 unsigned long dquot_freed_blocks;
626
627 sb = inode->i_sb;
628 if (!sb) {
629 printk ("ext4_free_blocks: nonexistent device");
630 return;
631 }
632 ext4_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);
633 if (dquot_freed_blocks)
634 DQUOT_FREE_BLOCK(inode, dquot_freed_blocks);
635 return;
636}
637
638/**
639 * ext4_test_allocatable()
640 * @nr: given allocation block group
641 * @bh: bufferhead contains the bitmap of the given block group
642 *
643 * For ext4 allocations, we must not reuse any blocks which are
644 * allocated in the bitmap buffer's "last committed data" copy. This
645 * prevents deletes from freeing up the page for reuse until we have
646 * committed the delete transaction.
647 *
648 * If we didn't do this, then deleting something and reallocating it as
649 * data would allow the old block to be overwritten before the
650 * transaction committed (because we force data to disk before commit).
651 * This would lead to corruption if we crashed between overwriting the
652 * data and committing the delete.
653 *
654 * @@@ We may want to make this allocation behaviour conditional on
655 * data-writes at some point, and disable it for metadata allocations or
656 * sync-data inodes.
657 */
658static int ext4_test_allocatable(ext4_grpblk_t nr, struct buffer_head *bh)
659{
660 int ret;
661 struct journal_head *jh = bh2jh(bh);
662
663 if (ext4_test_bit(nr, bh->b_data))
664 return 0;
665
666 jbd_lock_bh_state(bh);
667 if (!jh->b_committed_data)
668 ret = 1;
669 else
670 ret = !ext4_test_bit(nr, jh->b_committed_data);
671 jbd_unlock_bh_state(bh);
672 return ret;
673}
674
675/**
676 * bitmap_search_next_usable_block()
677 * @start: the starting block (group relative) of the search
678 * @bh: bufferhead contains the block group bitmap
679 * @maxblocks: the ending block (group relative) of the reservation
680 *
681 * The bitmap search --- search forward alternately through the actual
682 * bitmap on disk and the last-committed copy in journal, until we find a
683 * bit free in both bitmaps.
684 */
685static ext4_grpblk_t
686bitmap_search_next_usable_block(ext4_grpblk_t start, struct buffer_head *bh,
687 ext4_grpblk_t maxblocks)
688{
689 ext4_grpblk_t next;
690 struct journal_head *jh = bh2jh(bh);
691
692 while (start < maxblocks) {
693 next = ext4_find_next_zero_bit(bh->b_data, maxblocks, start);
694 if (next >= maxblocks)
695 return -1;
696 if (ext4_test_allocatable(next, bh))
697 return next;
698 jbd_lock_bh_state(bh);
699 if (jh->b_committed_data)
700 start = ext4_find_next_zero_bit(jh->b_committed_data,
701 maxblocks, next);
702 jbd_unlock_bh_state(bh);
703 }
704 return -1;
705}
706
707/**
708 * find_next_usable_block()
709 * @start: the starting block (group relative) to find next
710 * allocatable block in bitmap.
711 * @bh: bufferhead contains the block group bitmap
712 * @maxblocks: the ending block (group relative) for the search
713 *
714 * Find an allocatable block in a bitmap. We honor both the bitmap and
715 * its last-committed copy (if that exists), and perform the "most
716 * appropriate allocation" algorithm of looking for a free block near
717 * the initial goal; then for a free byte somewhere in the bitmap; then
718 * for any free bit in the bitmap.
719 */
720static ext4_grpblk_t
721find_next_usable_block(ext4_grpblk_t start, struct buffer_head *bh,
722 ext4_grpblk_t maxblocks)
723{
724 ext4_grpblk_t here, next;
725 char *p, *r;
726
727 if (start > 0) {
728 /*
729 * The goal was occupied; search forward for a free
730 * block within the next XX blocks.
731 *
732 * end_goal is more or less random, but it has to be
733 * less than EXT4_BLOCKS_PER_GROUP. Aligning up to the
734 * next 64-bit boundary is simple..
735 */
736 ext4_grpblk_t end_goal = (start + 63) & ~63;
737 if (end_goal > maxblocks)
738 end_goal = maxblocks;
739 here = ext4_find_next_zero_bit(bh->b_data, end_goal, start);
740 if (here < end_goal && ext4_test_allocatable(here, bh))
741 return here;
742 ext4_debug("Bit not found near goal\n");
743 }
744
745 here = start;
746 if (here < 0)
747 here = 0;
748
749 p = ((char *)bh->b_data) + (here >> 3);
750 r = memscan(p, 0, (maxblocks - here + 7) >> 3);
751 next = (r - ((char *)bh->b_data)) << 3;
752
753 if (next < maxblocks && next >= start && ext4_test_allocatable(next, bh))
754 return next;
755
756 /*
757 * The bitmap search --- search forward alternately through the actual
758 * bitmap and the last-committed copy until we find a bit free in
759 * both
760 */
761 here = bitmap_search_next_usable_block(here, bh, maxblocks);
762 return here;
763}
764
765/**
766 * claim_block()
767 * @block: the free block (group relative) to allocate
768 * @bh: the bufferhead containts the block group bitmap
769 *
770 * We think we can allocate this block in this bitmap. Try to set the bit.
771 * If that succeeds then check that nobody has allocated and then freed the
772 * block since we saw that is was not marked in b_committed_data. If it _was_
773 * allocated and freed then clear the bit in the bitmap again and return
774 * zero (failure).
775 */
776static inline int
777claim_block(spinlock_t *lock, ext4_grpblk_t block, struct buffer_head *bh)
778{
779 struct journal_head *jh = bh2jh(bh);
780 int ret;
781
782 if (ext4_set_bit_atomic(lock, block, bh->b_data))
783 return 0;
784 jbd_lock_bh_state(bh);
785 if (jh->b_committed_data && ext4_test_bit(block,jh->b_committed_data)) {
786 ext4_clear_bit_atomic(lock, block, bh->b_data);
787 ret = 0;
788 } else {
789 ret = 1;
790 }
791 jbd_unlock_bh_state(bh);
792 return ret;
793}
794
795/**
796 * ext4_try_to_allocate()
797 * @sb: superblock
798 * @handle: handle to this transaction
799 * @group: given allocation block group
800 * @bitmap_bh: bufferhead holds the block bitmap
801 * @grp_goal: given target block within the group
802 * @count: target number of blocks to allocate
803 * @my_rsv: reservation window
804 *
805 * Attempt to allocate blocks within a give range. Set the range of allocation
806 * first, then find the first free bit(s) from the bitmap (within the range),
807 * and at last, allocate the blocks by claiming the found free bit as allocated.
808 *
809 * To set the range of this allocation:
810 * if there is a reservation window, only try to allocate block(s) from the
811 * file's own reservation window;
812 * Otherwise, the allocation range starts from the give goal block, ends at
813 * the block group's last block.
814 *
815 * If we failed to allocate the desired block then we may end up crossing to a
816 * new bitmap. In that case we must release write access to the old one via
817 * ext4_journal_release_buffer(), else we'll run out of credits.
818 */
819static ext4_grpblk_t
820ext4_try_to_allocate(struct super_block *sb, handle_t *handle, int group,
821 struct buffer_head *bitmap_bh, ext4_grpblk_t grp_goal,
822 unsigned long *count, struct ext4_reserve_window *my_rsv)
823{
824 ext4_fsblk_t group_first_block;
825 ext4_grpblk_t start, end;
826 unsigned long num = 0;
827
828 /* we do allocation within the reservation window if we have a window */
829 if (my_rsv) {
830 group_first_block = ext4_group_first_block_no(sb, group);
831 if (my_rsv->_rsv_start >= group_first_block)
832 start = my_rsv->_rsv_start - group_first_block;
833 else
834 /* reservation window cross group boundary */
835 start = 0;
836 end = my_rsv->_rsv_end - group_first_block + 1;
837 if (end > EXT4_BLOCKS_PER_GROUP(sb))
838 /* reservation window crosses group boundary */
839 end = EXT4_BLOCKS_PER_GROUP(sb);
840 if ((start <= grp_goal) && (grp_goal < end))
841 start = grp_goal;
842 else
843 grp_goal = -1;
844 } else {
845 if (grp_goal > 0)
846 start = grp_goal;
847 else
848 start = 0;
849 end = EXT4_BLOCKS_PER_GROUP(sb);
850 }
851
852 BUG_ON(start > EXT4_BLOCKS_PER_GROUP(sb));
853
854repeat:
855 if (grp_goal < 0 || !ext4_test_allocatable(grp_goal, bitmap_bh)) {
856 grp_goal = find_next_usable_block(start, bitmap_bh, end);
857 if (grp_goal < 0)
858 goto fail_access;
859 if (!my_rsv) {
860 int i;
861
862 for (i = 0; i < 7 && grp_goal > start &&
863 ext4_test_allocatable(grp_goal - 1,
864 bitmap_bh);
865 i++, grp_goal--)
866 ;
867 }
868 }
869 start = grp_goal;
870
871 if (!claim_block(sb_bgl_lock(EXT4_SB(sb), group),
872 grp_goal, bitmap_bh)) {
873 /*
874 * The block was allocated by another thread, or it was
875 * allocated and then freed by another thread
876 */
877 start++;
878 grp_goal++;
879 if (start >= end)
880 goto fail_access;
881 goto repeat;
882 }
883 num++;
884 grp_goal++;
885 while (num < *count && grp_goal < end
886 && ext4_test_allocatable(grp_goal, bitmap_bh)
887 && claim_block(sb_bgl_lock(EXT4_SB(sb), group),
888 grp_goal, bitmap_bh)) {
889 num++;
890 grp_goal++;
891 }
892 *count = num;
893 return grp_goal - num;
894fail_access:
895 *count = num;
896 return -1;
897}
898
899/**
900 * find_next_reservable_window():
901 * find a reservable space within the given range.
902 * It does not allocate the reservation window for now:
903 * alloc_new_reservation() will do the work later.
904 *
905 * @search_head: the head of the searching list;
906 * This is not necessarily the list head of the whole filesystem
907 *
908 * We have both head and start_block to assist the search
909 * for the reservable space. The list starts from head,
910 * but we will shift to the place where start_block is,
911 * then start from there, when looking for a reservable space.
912 *
913 * @size: the target new reservation window size
914 *
915 * @group_first_block: the first block we consider to start
916 * the real search from
917 *
918 * @last_block:
919 * the maximum block number that our goal reservable space
920 * could start from. This is normally the last block in this
921 * group. The search will end when we found the start of next
922 * possible reservable space is out of this boundary.
923 * This could handle the cross boundary reservation window
924 * request.
925 *
926 * basically we search from the given range, rather than the whole
927 * reservation double linked list, (start_block, last_block)
928 * to find a free region that is of my size and has not
929 * been reserved.
930 *
931 */
932static int find_next_reservable_window(
933 struct ext4_reserve_window_node *search_head,
934 struct ext4_reserve_window_node *my_rsv,
935 struct super_block * sb,
936 ext4_fsblk_t start_block,
937 ext4_fsblk_t last_block)
938{
939 struct rb_node *next;
940 struct ext4_reserve_window_node *rsv, *prev;
941 ext4_fsblk_t cur;
942 int size = my_rsv->rsv_goal_size;
943
944 /* TODO: make the start of the reservation window byte-aligned */
945 /* cur = *start_block & ~7;*/
946 cur = start_block;
947 rsv = search_head;
948 if (!rsv)
949 return -1;
950
951 while (1) {
952 if (cur <= rsv->rsv_end)
953 cur = rsv->rsv_end + 1;
954
955 /* TODO?
956 * in the case we could not find a reservable space
957 * that is what is expected, during the re-search, we could
958 * remember what's the largest reservable space we could have
959 * and return that one.
960 *
961 * For now it will fail if we could not find the reservable
962 * space with expected-size (or more)...
963 */
964 if (cur > last_block)
965 return -1; /* fail */
966
967 prev = rsv;
968 next = rb_next(&rsv->rsv_node);
969 rsv = list_entry(next,struct ext4_reserve_window_node,rsv_node);
970
971 /*
972 * Reached the last reservation, we can just append to the
973 * previous one.
974 */
975 if (!next)
976 break;
977
978 if (cur + size <= rsv->rsv_start) {
979 /*
980 * Found a reserveable space big enough. We could
981 * have a reservation across the group boundary here
982 */
983 break;
984 }
985 }
986 /*
987 * we come here either :
988 * when we reach the end of the whole list,
989 * and there is empty reservable space after last entry in the list.
990 * append it to the end of the list.
991 *
992 * or we found one reservable space in the middle of the list,
993 * return the reservation window that we could append to.
994 * succeed.
995 */
996
997 if ((prev != my_rsv) && (!rsv_is_empty(&my_rsv->rsv_window)))
998 rsv_window_remove(sb, my_rsv);
999
1000 /*
1001 * Let's book the whole avaliable window for now. We will check the
1002 * disk bitmap later and then, if there are free blocks then we adjust
1003 * the window size if it's larger than requested.
1004 * Otherwise, we will remove this node from the tree next time
1005 * call find_next_reservable_window.
1006 */
1007 my_rsv->rsv_start = cur;
1008 my_rsv->rsv_end = cur + size - 1;
1009 my_rsv->rsv_alloc_hit = 0;
1010
1011 if (prev != my_rsv)
1012 ext4_rsv_window_add(sb, my_rsv);
1013
1014 return 0;
1015}
1016
1017/**
1018 * alloc_new_reservation()--allocate a new reservation window
1019 *
1020 * To make a new reservation, we search part of the filesystem
1021 * reservation list (the list that inside the group). We try to
1022 * allocate a new reservation window near the allocation goal,
1023 * or the beginning of the group, if there is no goal.
1024 *
1025 * We first find a reservable space after the goal, then from
1026 * there, we check the bitmap for the first free block after
1027 * it. If there is no free block until the end of group, then the
1028 * whole group is full, we failed. Otherwise, check if the free
1029 * block is inside the expected reservable space, if so, we
1030 * succeed.
1031 * If the first free block is outside the reservable space, then
1032 * start from the first free block, we search for next available
1033 * space, and go on.
1034 *
1035 * on succeed, a new reservation will be found and inserted into the list
1036 * It contains at least one free block, and it does not overlap with other
1037 * reservation windows.
1038 *
1039 * failed: we failed to find a reservation window in this group
1040 *
1041 * @rsv: the reservation
1042 *
1043 * @grp_goal: The goal (group-relative). It is where the search for a
1044 * free reservable space should start from.
1045 * if we have a grp_goal(grp_goal >0 ), then start from there,
1046 * no grp_goal(grp_goal = -1), we start from the first block
1047 * of the group.
1048 *
1049 * @sb: the super block
1050 * @group: the group we are trying to allocate in
1051 * @bitmap_bh: the block group block bitmap
1052 *
1053 */
1054static int alloc_new_reservation(struct ext4_reserve_window_node *my_rsv,
1055 ext4_grpblk_t grp_goal, struct super_block *sb,
1056 unsigned int group, struct buffer_head *bitmap_bh)
1057{
1058 struct ext4_reserve_window_node *search_head;
1059 ext4_fsblk_t group_first_block, group_end_block, start_block;
1060 ext4_grpblk_t first_free_block;
1061 struct rb_root *fs_rsv_root = &EXT4_SB(sb)->s_rsv_window_root;
1062 unsigned long size;
1063 int ret;
1064 spinlock_t *rsv_lock = &EXT4_SB(sb)->s_rsv_window_lock;
1065
1066 group_first_block = ext4_group_first_block_no(sb, group);
1067 group_end_block = group_first_block + (EXT4_BLOCKS_PER_GROUP(sb) - 1);
1068
1069 if (grp_goal < 0)
1070 start_block = group_first_block;
1071 else
1072 start_block = grp_goal + group_first_block;
1073
1074 size = my_rsv->rsv_goal_size;
1075
1076 if (!rsv_is_empty(&my_rsv->rsv_window)) {
1077 /*
1078 * if the old reservation is cross group boundary
1079 * and if the goal is inside the old reservation window,
1080 * we will come here when we just failed to allocate from
1081 * the first part of the window. We still have another part
1082 * that belongs to the next group. In this case, there is no
1083 * point to discard our window and try to allocate a new one
1084 * in this group(which will fail). we should
1085 * keep the reservation window, just simply move on.
1086 *
1087 * Maybe we could shift the start block of the reservation
1088 * window to the first block of next group.
1089 */
1090
1091 if ((my_rsv->rsv_start <= group_end_block) &&
1092 (my_rsv->rsv_end > group_end_block) &&
1093 (start_block >= my_rsv->rsv_start))
1094 return -1;
1095
1096 if ((my_rsv->rsv_alloc_hit >
1097 (my_rsv->rsv_end - my_rsv->rsv_start + 1) / 2)) {
1098 /*
1099 * if the previously allocation hit ratio is
1100 * greater than 1/2, then we double the size of
1101 * the reservation window the next time,
1102 * otherwise we keep the same size window
1103 */
1104 size = size * 2;
1105 if (size > EXT4_MAX_RESERVE_BLOCKS)
1106 size = EXT4_MAX_RESERVE_BLOCKS;
1107 my_rsv->rsv_goal_size= size;
1108 }
1109 }
1110
1111 spin_lock(rsv_lock);
1112 /*
1113 * shift the search start to the window near the goal block
1114 */
1115 search_head = search_reserve_window(fs_rsv_root, start_block);
1116
1117 /*
1118 * find_next_reservable_window() simply finds a reservable window
1119 * inside the given range(start_block, group_end_block).
1120 *
1121 * To make sure the reservation window has a free bit inside it, we
1122 * need to check the bitmap after we found a reservable window.
1123 */
1124retry:
1125 ret = find_next_reservable_window(search_head, my_rsv, sb,
1126 start_block, group_end_block);
1127
1128 if (ret == -1) {
1129 if (!rsv_is_empty(&my_rsv->rsv_window))
1130 rsv_window_remove(sb, my_rsv);
1131 spin_unlock(rsv_lock);
1132 return -1;
1133 }
1134
1135 /*
1136 * On success, find_next_reservable_window() returns the
1137 * reservation window where there is a reservable space after it.
1138 * Before we reserve this reservable space, we need
1139 * to make sure there is at least a free block inside this region.
1140 *
1141 * searching the first free bit on the block bitmap and copy of
1142 * last committed bitmap alternatively, until we found a allocatable
1143 * block. Search start from the start block of the reservable space
1144 * we just found.
1145 */
1146 spin_unlock(rsv_lock);
1147 first_free_block = bitmap_search_next_usable_block(
1148 my_rsv->rsv_start - group_first_block,
1149 bitmap_bh, group_end_block - group_first_block + 1);
1150
1151 if (first_free_block < 0) {
1152 /*
1153 * no free block left on the bitmap, no point
1154 * to reserve the space. return failed.
1155 */
1156 spin_lock(rsv_lock);
1157 if (!rsv_is_empty(&my_rsv->rsv_window))
1158 rsv_window_remove(sb, my_rsv);
1159 spin_unlock(rsv_lock);
1160 return -1; /* failed */
1161 }
1162
1163 start_block = first_free_block + group_first_block;
1164 /*
1165 * check if the first free block is within the
1166 * free space we just reserved
1167 */
1168 if (start_block >= my_rsv->rsv_start && start_block < my_rsv->rsv_end)
1169 return 0; /* success */
1170 /*
1171 * if the first free bit we found is out of the reservable space
1172 * continue search for next reservable space,
1173 * start from where the free block is,
1174 * we also shift the list head to where we stopped last time
1175 */
1176 search_head = my_rsv;
1177 spin_lock(rsv_lock);
1178 goto retry;
1179}
1180
1181/**
1182 * try_to_extend_reservation()
1183 * @my_rsv: given reservation window
1184 * @sb: super block
1185 * @size: the delta to extend
1186 *
1187 * Attempt to expand the reservation window large enough to have
1188 * required number of free blocks
1189 *
1190 * Since ext4_try_to_allocate() will always allocate blocks within
1191 * the reservation window range, if the window size is too small,
1192 * multiple blocks allocation has to stop at the end of the reservation
1193 * window. To make this more efficient, given the total number of
1194 * blocks needed and the current size of the window, we try to
1195 * expand the reservation window size if necessary on a best-effort
1196 * basis before ext4_new_blocks() tries to allocate blocks,
1197 */
1198static void try_to_extend_reservation(struct ext4_reserve_window_node *my_rsv,
1199 struct super_block *sb, int size)
1200{
1201 struct ext4_reserve_window_node *next_rsv;
1202 struct rb_node *next;
1203 spinlock_t *rsv_lock = &EXT4_SB(sb)->s_rsv_window_lock;
1204
1205 if (!spin_trylock(rsv_lock))
1206 return;
1207
1208 next = rb_next(&my_rsv->rsv_node);
1209
1210 if (!next)
1211 my_rsv->rsv_end += size;
1212 else {
1213 next_rsv = list_entry(next, struct ext4_reserve_window_node, rsv_node);
1214
1215 if ((next_rsv->rsv_start - my_rsv->rsv_end - 1) >= size)
1216 my_rsv->rsv_end += size;
1217 else
1218 my_rsv->rsv_end = next_rsv->rsv_start - 1;
1219 }
1220 spin_unlock(rsv_lock);
1221}
1222
1223/**
1224 * ext4_try_to_allocate_with_rsv()
1225 * @sb: superblock
1226 * @handle: handle to this transaction
1227 * @group: given allocation block group
1228 * @bitmap_bh: bufferhead holds the block bitmap
1229 * @grp_goal: given target block within the group
1230 * @count: target number of blocks to allocate
1231 * @my_rsv: reservation window
1232 * @errp: pointer to store the error code
1233 *
1234 * This is the main function used to allocate a new block and its reservation
1235 * window.
1236 *
1237 * Each time when a new block allocation is need, first try to allocate from
1238 * its own reservation. If it does not have a reservation window, instead of
1239 * looking for a free bit on bitmap first, then look up the reservation list to
1240 * see if it is inside somebody else's reservation window, we try to allocate a
1241 * reservation window for it starting from the goal first. Then do the block
1242 * allocation within the reservation window.
1243 *
1244 * This will avoid keeping on searching the reservation list again and
1245 * again when somebody is looking for a free block (without
1246 * reservation), and there are lots of free blocks, but they are all
1247 * being reserved.
1248 *
1249 * We use a red-black tree for the per-filesystem reservation list.
1250 *
1251 */
1252static ext4_grpblk_t
1253ext4_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle,
1254 unsigned int group, struct buffer_head *bitmap_bh,
1255 ext4_grpblk_t grp_goal,
1256 struct ext4_reserve_window_node * my_rsv,
1257 unsigned long *count, int *errp)
1258{
1259 ext4_fsblk_t group_first_block, group_last_block;
1260 ext4_grpblk_t ret = 0;
1261 int fatal;
1262 unsigned long num = *count;
1263
1264 *errp = 0;
1265
1266 /*
1267 * Make sure we use undo access for the bitmap, because it is critical
1268 * that we do the frozen_data COW on bitmap buffers in all cases even
1269 * if the buffer is in BJ_Forget state in the committing transaction.
1270 */
1271 BUFFER_TRACE(bitmap_bh, "get undo access for new block");
1272 fatal = ext4_journal_get_undo_access(handle, bitmap_bh);
1273 if (fatal) {
1274 *errp = fatal;
1275 return -1;
1276 }
1277
1278 /*
1279 * we don't deal with reservation when
1280 * filesystem is mounted without reservation
1281 * or the file is not a regular file
1282 * or last attempt to allocate a block with reservation turned on failed
1283 */
1284 if (my_rsv == NULL ) {
1285 ret = ext4_try_to_allocate(sb, handle, group, bitmap_bh,
1286 grp_goal, count, NULL);
1287 goto out;
1288 }
1289 /*
1290 * grp_goal is a group relative block number (if there is a goal)
1291 * 0 < grp_goal < EXT4_BLOCKS_PER_GROUP(sb)
1292 * first block is a filesystem wide block number
1293 * first block is the block number of the first block in this group
1294 */
1295 group_first_block = ext4_group_first_block_no(sb, group);
1296 group_last_block = group_first_block + (EXT4_BLOCKS_PER_GROUP(sb) - 1);
1297
1298 /*
1299 * Basically we will allocate a new block from inode's reservation
1300 * window.
1301 *
1302 * We need to allocate a new reservation window, if:
1303 * a) inode does not have a reservation window; or
1304 * b) last attempt to allocate a block from existing reservation
1305 * failed; or
1306 * c) we come here with a goal and with a reservation window
1307 *
1308 * We do not need to allocate a new reservation window if we come here
1309 * at the beginning with a goal and the goal is inside the window, or
1310 * we don't have a goal but already have a reservation window.
1311 * then we could go to allocate from the reservation window directly.
1312 */
1313 while (1) {
1314 if (rsv_is_empty(&my_rsv->rsv_window) || (ret < 0) ||
1315 !goal_in_my_reservation(&my_rsv->rsv_window,
1316 grp_goal, group, sb)) {
1317 if (my_rsv->rsv_goal_size < *count)
1318 my_rsv->rsv_goal_size = *count;
1319 ret = alloc_new_reservation(my_rsv, grp_goal, sb,
1320 group, bitmap_bh);
1321 if (ret < 0)
1322 break; /* failed */
1323
1324 if (!goal_in_my_reservation(&my_rsv->rsv_window,
1325 grp_goal, group, sb))
1326 grp_goal = -1;
1327 } else if (grp_goal > 0 &&
1328 (my_rsv->rsv_end-grp_goal+1) < *count)
1329 try_to_extend_reservation(my_rsv, sb,
1330 *count-my_rsv->rsv_end + grp_goal - 1);
1331
1332 if ((my_rsv->rsv_start > group_last_block) ||
1333 (my_rsv->rsv_end < group_first_block)) {
1334 rsv_window_dump(&EXT4_SB(sb)->s_rsv_window_root, 1);
1335 BUG();
1336 }
1337 ret = ext4_try_to_allocate(sb, handle, group, bitmap_bh,
1338 grp_goal, &num, &my_rsv->rsv_window);
1339 if (ret >= 0) {
1340 my_rsv->rsv_alloc_hit += num;
1341 *count = num;
1342 break; /* succeed */
1343 }
1344 num = *count;
1345 }
1346out:
1347 if (ret >= 0) {
1348 BUFFER_TRACE(bitmap_bh, "journal_dirty_metadata for "
1349 "bitmap block");
1350 fatal = ext4_journal_dirty_metadata(handle, bitmap_bh);
1351 if (fatal) {
1352 *errp = fatal;
1353 return -1;
1354 }
1355 return ret;
1356 }
1357
1358 BUFFER_TRACE(bitmap_bh, "journal_release_buffer");
1359 ext4_journal_release_buffer(handle, bitmap_bh);
1360 return ret;
1361}
1362
1363/**
1364 * ext4_has_free_blocks()
1365 * @sbi: in-core super block structure.
1366 *
1367 * Check if filesystem has at least 1 free block available for allocation.
1368 */
1369static int ext4_has_free_blocks(struct ext4_sb_info *sbi)
1370{
1371 ext4_fsblk_t free_blocks, root_blocks;
1372
1373 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
1374 root_blocks = ext4_r_blocks_count(sbi->s_es);
1375 if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
1376 sbi->s_resuid != current->fsuid &&
1377 (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) {
1378 return 0;
1379 }
1380 return 1;
1381}
1382
1383/**
1384 * ext4_should_retry_alloc()
1385 * @sb: super block
1386 * @retries number of attemps has been made
1387 *
1388 * ext4_should_retry_alloc() is called when ENOSPC is returned, and if
1389 * it is profitable to retry the operation, this function will wait
1390 * for the current or commiting transaction to complete, and then
1391 * return TRUE.
1392 *
1393 * if the total number of retries exceed three times, return FALSE.
1394 */
1395int ext4_should_retry_alloc(struct super_block *sb, int *retries)
1396{
1397 if (!ext4_has_free_blocks(EXT4_SB(sb)) || (*retries)++ > 3)
1398 return 0;
1399
1400 jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
1401
1402 return jbd2_journal_force_commit_nested(EXT4_SB(sb)->s_journal);
1403}
1404
1405/**
1406 * ext4_new_blocks() -- core block(s) allocation function
1407 * @handle: handle to this transaction
1408 * @inode: file inode
1409 * @goal: given target block(filesystem wide)
1410 * @count: target number of blocks to allocate
1411 * @errp: error code
1412 *
1413 * ext4_new_blocks uses a goal block to assist allocation. It tries to
1414 * allocate block(s) from the block group contains the goal block first. If that
1415 * fails, it will try to allocate block(s) from other block groups without
1416 * any specific goal block.
1417 *
1418 */
1419ext4_fsblk_t ext4_new_blocks(handle_t *handle, struct inode *inode,
1420 ext4_fsblk_t goal, unsigned long *count, int *errp)
1421{
1422 struct buffer_head *bitmap_bh = NULL;
1423 struct buffer_head *gdp_bh;
1424 unsigned long group_no;
1425 int goal_group;
1426 ext4_grpblk_t grp_target_blk; /* blockgroup relative goal block */
1427 ext4_grpblk_t grp_alloc_blk; /* blockgroup-relative allocated block*/
1428 ext4_fsblk_t ret_block; /* filesyetem-wide allocated block */
1429 int bgi; /* blockgroup iteration index */
1430 int fatal = 0, err;
1431 int performed_allocation = 0;
1432 ext4_grpblk_t free_blocks; /* number of free blocks in a group */
1433 struct super_block *sb;
1434 struct ext4_group_desc *gdp;
1435 struct ext4_super_block *es;
1436 struct ext4_sb_info *sbi;
1437 struct ext4_reserve_window_node *my_rsv = NULL;
1438 struct ext4_block_alloc_info *block_i;
1439 unsigned short windowsz = 0;
1440#ifdef EXT4FS_DEBUG
1441 static int goal_hits, goal_attempts;
1442#endif
1443 unsigned long ngroups;
1444 unsigned long num = *count;
1445
1446 *errp = -ENOSPC;
1447 sb = inode->i_sb;
1448 if (!sb) {
1449 printk("ext4_new_block: nonexistent device");
1450 return 0;
1451 }
1452
1453 /*
1454 * Check quota for allocation of this block.
1455 */
1456 if (DQUOT_ALLOC_BLOCK(inode, num)) {
1457 *errp = -EDQUOT;
1458 return 0;
1459 }
1460
1461 sbi = EXT4_SB(sb);
1462 es = EXT4_SB(sb)->s_es;
1463 ext4_debug("goal=%lu.\n", goal);
1464 /*
1465 * Allocate a block from reservation only when
1466 * filesystem is mounted with reservation(default,-o reservation), and
1467 * it's a regular file, and
1468 * the desired window size is greater than 0 (One could use ioctl
1469 * command EXT4_IOC_SETRSVSZ to set the window size to 0 to turn off
1470 * reservation on that particular file)
1471 */
1472 block_i = EXT4_I(inode)->i_block_alloc_info;
1473 if (block_i && ((windowsz = block_i->rsv_window_node.rsv_goal_size) > 0))
1474 my_rsv = &block_i->rsv_window_node;
1475
1476 if (!ext4_has_free_blocks(sbi)) {
1477 *errp = -ENOSPC;
1478 goto out;
1479 }
1480
1481 /*
1482 * First, test whether the goal block is free.
1483 */
1484 if (goal < le32_to_cpu(es->s_first_data_block) ||
1485 goal >= ext4_blocks_count(es))
1486 goal = le32_to_cpu(es->s_first_data_block);
1487 ext4_get_group_no_and_offset(sb, goal, &group_no, &grp_target_blk);
1488 goal_group = group_no;
1489retry_alloc:
1490 gdp = ext4_get_group_desc(sb, group_no, &gdp_bh);
1491 if (!gdp)
1492 goto io_error;
1493
1494 free_blocks = le16_to_cpu(gdp->bg_free_blocks_count);
1495 /*
1496 * if there is not enough free blocks to make a new resevation
1497 * turn off reservation for this allocation
1498 */
1499 if (my_rsv && (free_blocks < windowsz)
1500 && (rsv_is_empty(&my_rsv->rsv_window)))
1501 my_rsv = NULL;
1502
1503 if (free_blocks > 0) {
1504 bitmap_bh = read_block_bitmap(sb, group_no);
1505 if (!bitmap_bh)
1506 goto io_error;
1507 grp_alloc_blk = ext4_try_to_allocate_with_rsv(sb, handle,
1508 group_no, bitmap_bh, grp_target_blk,
1509 my_rsv, &num, &fatal);
1510 if (fatal)
1511 goto out;
1512 if (grp_alloc_blk >= 0)
1513 goto allocated;
1514 }
1515
1516 ngroups = EXT4_SB(sb)->s_groups_count;
1517 smp_rmb();
1518
1519 /*
1520 * Now search the rest of the groups. We assume that
1521 * i and gdp correctly point to the last group visited.
1522 */
1523 for (bgi = 0; bgi < ngroups; bgi++) {
1524 group_no++;
1525 if (group_no >= ngroups)
1526 group_no = 0;
1527 gdp = ext4_get_group_desc(sb, group_no, &gdp_bh);
1528 if (!gdp) {
1529 *errp = -EIO;
1530 goto out;
1531 }
1532 free_blocks = le16_to_cpu(gdp->bg_free_blocks_count);
1533 /*
1534 * skip this group if the number of
1535 * free blocks is less than half of the reservation
1536 * window size.
1537 */
1538 if (free_blocks <= (windowsz/2))
1539 continue;
1540
1541 brelse(bitmap_bh);
1542 bitmap_bh = read_block_bitmap(sb, group_no);
1543 if (!bitmap_bh)
1544 goto io_error;
1545 /*
1546 * try to allocate block(s) from this group, without a goal(-1).
1547 */
1548 grp_alloc_blk = ext4_try_to_allocate_with_rsv(sb, handle,
1549 group_no, bitmap_bh, -1, my_rsv,
1550 &num, &fatal);
1551 if (fatal)
1552 goto out;
1553 if (grp_alloc_blk >= 0)
1554 goto allocated;
1555 }
1556 /*
1557 * We may end up a bogus ealier ENOSPC error due to
1558 * filesystem is "full" of reservations, but
1559 * there maybe indeed free blocks avaliable on disk
1560 * In this case, we just forget about the reservations
1561 * just do block allocation as without reservations.
1562 */
1563 if (my_rsv) {
1564 my_rsv = NULL;
1565 group_no = goal_group;
1566 goto retry_alloc;
1567 }
1568 /* No space left on the device */
1569 *errp = -ENOSPC;
1570 goto out;
1571
1572allocated:
1573
1574 ext4_debug("using block group %d(%d)\n",
1575 group_no, gdp->bg_free_blocks_count);
1576
1577 BUFFER_TRACE(gdp_bh, "get_write_access");
1578 fatal = ext4_journal_get_write_access(handle, gdp_bh);
1579 if (fatal)
1580 goto out;
1581
1582 ret_block = grp_alloc_blk + ext4_group_first_block_no(sb, group_no);
1583
1584 if (in_range(ext4_block_bitmap(sb, gdp), ret_block, num) ||
1585 in_range(ext4_block_bitmap(sb, gdp), ret_block, num) ||
1586 in_range(ret_block, ext4_inode_table(sb, gdp),
1587 EXT4_SB(sb)->s_itb_per_group) ||
1588 in_range(ret_block + num - 1, ext4_inode_table(sb, gdp),
1589 EXT4_SB(sb)->s_itb_per_group))
1590 ext4_error(sb, "ext4_new_block",
1591 "Allocating block in system zone - "
1592 "blocks from %llu, length %lu",
1593 ret_block, num);
1594
1595 performed_allocation = 1;
1596
1597#ifdef CONFIG_JBD_DEBUG
1598 {
1599 struct buffer_head *debug_bh;
1600
1601 /* Record bitmap buffer state in the newly allocated block */
1602 debug_bh = sb_find_get_block(sb, ret_block);
1603 if (debug_bh) {
1604 BUFFER_TRACE(debug_bh, "state when allocated");
1605 BUFFER_TRACE2(debug_bh, bitmap_bh, "bitmap state");
1606 brelse(debug_bh);
1607 }
1608 }
1609 jbd_lock_bh_state(bitmap_bh);
1610 spin_lock(sb_bgl_lock(sbi, group_no));
1611 if (buffer_jbd(bitmap_bh) && bh2jh(bitmap_bh)->b_committed_data) {
1612 int i;
1613
1614 for (i = 0; i < num; i++) {
1615 if (ext4_test_bit(grp_alloc_blk+i,
1616 bh2jh(bitmap_bh)->b_committed_data)) {
1617 printk("%s: block was unexpectedly set in "
1618 "b_committed_data\n", __FUNCTION__);
1619 }
1620 }
1621 }
1622 ext4_debug("found bit %d\n", grp_alloc_blk);
1623 spin_unlock(sb_bgl_lock(sbi, group_no));
1624 jbd_unlock_bh_state(bitmap_bh);
1625#endif
1626
1627 if (ret_block + num - 1 >= ext4_blocks_count(es)) {
1628 ext4_error(sb, "ext4_new_block",
1629 "block(%llu) >= blocks count(%llu) - "
1630 "block_group = %lu, es == %p ", ret_block,
1631 ext4_blocks_count(es), group_no, es);
1632 goto out;
1633 }
1634
1635 /*
1636 * It is up to the caller to add the new buffer to a journal
1637 * list of some description. We don't know in advance whether
1638 * the caller wants to use it as metadata or data.
1639 */
1640 ext4_debug("allocating block %lu. Goal hits %d of %d.\n",
1641 ret_block, goal_hits, goal_attempts);
1642
1643 spin_lock(sb_bgl_lock(sbi, group_no));
1644 gdp->bg_free_blocks_count =
1645 cpu_to_le16(le16_to_cpu(gdp->bg_free_blocks_count)-num);
1646 spin_unlock(sb_bgl_lock(sbi, group_no));
1647 percpu_counter_mod(&sbi->s_freeblocks_counter, -num);
1648
1649 BUFFER_TRACE(gdp_bh, "journal_dirty_metadata for group descriptor");
1650 err = ext4_journal_dirty_metadata(handle, gdp_bh);
1651 if (!fatal)
1652 fatal = err;
1653
1654 sb->s_dirt = 1;
1655 if (fatal)
1656 goto out;
1657
1658 *errp = 0;
1659 brelse(bitmap_bh);
1660 DQUOT_FREE_BLOCK(inode, *count-num);
1661 *count = num;
1662 return ret_block;
1663
1664io_error:
1665 *errp = -EIO;
1666out:
1667 if (fatal) {
1668 *errp = fatal;
1669 ext4_std_error(sb, fatal);
1670 }
1671 /*
1672 * Undo the block allocation
1673 */
1674 if (!performed_allocation)
1675 DQUOT_FREE_BLOCK(inode, *count);
1676 brelse(bitmap_bh);
1677 return 0;
1678}
1679
1680ext4_fsblk_t ext4_new_block(handle_t *handle, struct inode *inode,
1681 ext4_fsblk_t goal, int *errp)
1682{
1683 unsigned long count = 1;
1684
1685 return ext4_new_blocks(handle, inode, goal, &count, errp);
1686}
1687
1688/**
1689 * ext4_count_free_blocks() -- count filesystem free blocks
1690 * @sb: superblock
1691 *
1692 * Adds up the number of free blocks from each block group.
1693 */
1694ext4_fsblk_t ext4_count_free_blocks(struct super_block *sb)
1695{
1696 ext4_fsblk_t desc_count;
1697 struct ext4_group_desc *gdp;
1698 int i;
1699 unsigned long ngroups = EXT4_SB(sb)->s_groups_count;
1700#ifdef EXT4FS_DEBUG
1701 struct ext4_super_block *es;
1702 ext4_fsblk_t bitmap_count;
1703 unsigned long x;
1704 struct buffer_head *bitmap_bh = NULL;
1705
1706 es = EXT4_SB(sb)->s_es;
1707 desc_count = 0;
1708 bitmap_count = 0;
1709 gdp = NULL;
1710
1711 smp_rmb();
1712 for (i = 0; i < ngroups; i++) {
1713 gdp = ext4_get_group_desc(sb, i, NULL);
1714 if (!gdp)
1715 continue;
1716 desc_count += le16_to_cpu(gdp->bg_free_blocks_count);
1717 brelse(bitmap_bh);
1718 bitmap_bh = read_block_bitmap(sb, i);
1719 if (bitmap_bh == NULL)
1720 continue;
1721
1722 x = ext4_count_free(bitmap_bh, sb->s_blocksize);
1723 printk("group %d: stored = %d, counted = %lu\n",
1724 i, le16_to_cpu(gdp->bg_free_blocks_count), x);
1725 bitmap_count += x;
1726 }
1727 brelse(bitmap_bh);
1728 printk("ext4_count_free_blocks: stored = %llu"
1729 ", computed = %llu, %llu\n",
1730 EXT4_FREE_BLOCKS_COUNT(es),
1731 desc_count, bitmap_count);
1732 return bitmap_count;
1733#else
1734 desc_count = 0;
1735 smp_rmb();
1736 for (i = 0; i < ngroups; i++) {
1737 gdp = ext4_get_group_desc(sb, i, NULL);
1738 if (!gdp)
1739 continue;
1740 desc_count += le16_to_cpu(gdp->bg_free_blocks_count);
1741 }
1742
1743 return desc_count;
1744#endif
1745}
1746
1747static inline int
1748block_in_use(ext4_fsblk_t block, struct super_block *sb, unsigned char *map)
1749{
1750 ext4_grpblk_t offset;
1751
1752 ext4_get_group_no_and_offset(sb, block, NULL, &offset);
1753 return ext4_test_bit (offset, map);
1754}
1755
1756static inline int test_root(int a, int b)
1757{
1758 int num = b;
1759
1760 while (a > num)
1761 num *= b;
1762 return num == a;
1763}
1764
1765static int ext4_group_sparse(int group)
1766{
1767 if (group <= 1)
1768 return 1;
1769 if (!(group & 1))
1770 return 0;
1771 return (test_root(group, 7) || test_root(group, 5) ||
1772 test_root(group, 3));
1773}
1774
1775/**
1776 * ext4_bg_has_super - number of blocks used by the superblock in group
1777 * @sb: superblock for filesystem
1778 * @group: group number to check
1779 *
1780 * Return the number of blocks used by the superblock (primary or backup)
1781 * in this group. Currently this will be only 0 or 1.
1782 */
1783int ext4_bg_has_super(struct super_block *sb, int group)
1784{
1785 if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
1786 EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER) &&
1787 !ext4_group_sparse(group))
1788 return 0;
1789 return 1;
1790}
1791
1792static unsigned long ext4_bg_num_gdb_meta(struct super_block *sb, int group)
1793{
1794 unsigned long metagroup = group / EXT4_DESC_PER_BLOCK(sb);
1795 unsigned long first = metagroup * EXT4_DESC_PER_BLOCK(sb);
1796 unsigned long last = first + EXT4_DESC_PER_BLOCK(sb) - 1;
1797
1798 if (group == first || group == first + 1 || group == last)
1799 return 1;
1800 return 0;
1801}
1802
1803static unsigned long ext4_bg_num_gdb_nometa(struct super_block *sb, int group)
1804{
1805 if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
1806 EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER) &&
1807 !ext4_group_sparse(group))
1808 return 0;
1809 return EXT4_SB(sb)->s_gdb_count;
1810}
1811
1812/**
1813 * ext4_bg_num_gdb - number of blocks used by the group table in group
1814 * @sb: superblock for filesystem
1815 * @group: group number to check
1816 *
1817 * Return the number of blocks used by the group descriptor table
1818 * (primary or backup) in this group. In the future there may be a
1819 * different number of descriptor blocks in each group.
1820 */
1821unsigned long ext4_bg_num_gdb(struct super_block *sb, int group)
1822{
1823 unsigned long first_meta_bg =
1824 le32_to_cpu(EXT4_SB(sb)->s_es->s_first_meta_bg);
1825 unsigned long metagroup = group / EXT4_DESC_PER_BLOCK(sb);
1826
1827 if (!EXT4_HAS_INCOMPAT_FEATURE(sb,EXT4_FEATURE_INCOMPAT_META_BG) ||
1828 metagroup < first_meta_bg)
1829 return ext4_bg_num_gdb_nometa(sb,group);
1830
1831 return ext4_bg_num_gdb_meta(sb,group);
1832
1833}
diff --git a/fs/ext4/bitmap.c b/fs/ext4/bitmap.c
new file mode 100644
index 000000000000..11e93c169bcf
--- /dev/null
+++ b/fs/ext4/bitmap.c
@@ -0,0 +1,32 @@
1/*
2 * linux/fs/ext4/bitmap.c
3 *
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 */
9
10#include <linux/buffer_head.h>
11#include <linux/jbd2.h>
12#include <linux/ext4_fs.h>
13
14#ifdef EXT4FS_DEBUG
15
16static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0};
17
18unsigned long ext4_count_free (struct buffer_head * map, unsigned int numchars)
19{
20 unsigned int i;
21 unsigned long sum = 0;
22
23 if (!map)
24 return (0);
25 for (i = 0; i < numchars; i++)
26 sum += nibblemap[map->b_data[i] & 0xf] +
27 nibblemap[(map->b_data[i] >> 4) & 0xf];
28 return (sum);
29}
30
31#endif /* EXT4FS_DEBUG */
32
diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
new file mode 100644
index 000000000000..f8595787a70e
--- /dev/null
+++ b/fs/ext4/dir.c
@@ -0,0 +1,518 @@
1/*
2 * linux/fs/ext4/dir.c
3 *
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 *
9 * from
10 *
11 * linux/fs/minix/dir.c
12 *
13 * Copyright (C) 1991, 1992 Linus Torvalds
14 *
15 * ext4 directory handling functions
16 *
17 * Big-endian to little-endian byte-swapping/bitmaps by
18 * David S. Miller (davem@caip.rutgers.edu), 1995
19 *
20 * Hash Tree Directory indexing (c) 2001 Daniel Phillips
21 *
22 */
23
24#include <linux/fs.h>
25#include <linux/jbd2.h>
26#include <linux/ext4_fs.h>
27#include <linux/buffer_head.h>
28#include <linux/smp_lock.h>
29#include <linux/slab.h>
30#include <linux/rbtree.h>
31
32static unsigned char ext4_filetype_table[] = {
33 DT_UNKNOWN, DT_REG, DT_DIR, DT_CHR, DT_BLK, DT_FIFO, DT_SOCK, DT_LNK
34};
35
36static int ext4_readdir(struct file *, void *, filldir_t);
37static int ext4_dx_readdir(struct file * filp,
38 void * dirent, filldir_t filldir);
39static int ext4_release_dir (struct inode * inode,
40 struct file * filp);
41
42const struct file_operations ext4_dir_operations = {
43 .llseek = generic_file_llseek,
44 .read = generic_read_dir,
45 .readdir = ext4_readdir, /* we take BKL. needed?*/
46 .ioctl = ext4_ioctl, /* BKL held */
47#ifdef CONFIG_COMPAT
48 .compat_ioctl = ext4_compat_ioctl,
49#endif
50 .fsync = ext4_sync_file, /* BKL held */
51#ifdef CONFIG_EXT4_INDEX
52 .release = ext4_release_dir,
53#endif
54};
55
56
57static unsigned char get_dtype(struct super_block *sb, int filetype)
58{
59 if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FILETYPE) ||
60 (filetype >= EXT4_FT_MAX))
61 return DT_UNKNOWN;
62
63 return (ext4_filetype_table[filetype]);
64}
65
66
67int ext4_check_dir_entry (const char * function, struct inode * dir,
68 struct ext4_dir_entry_2 * de,
69 struct buffer_head * bh,
70 unsigned long offset)
71{
72 const char * error_msg = NULL;
73 const int rlen = le16_to_cpu(de->rec_len);
74
75 if (rlen < EXT4_DIR_REC_LEN(1))
76 error_msg = "rec_len is smaller than minimal";
77 else if (rlen % 4 != 0)
78 error_msg = "rec_len % 4 != 0";
79 else if (rlen < EXT4_DIR_REC_LEN(de->name_len))
80 error_msg = "rec_len is too small for name_len";
81 else if (((char *) de - bh->b_data) + rlen > dir->i_sb->s_blocksize)
82 error_msg = "directory entry across blocks";
83 else if (le32_to_cpu(de->inode) >
84 le32_to_cpu(EXT4_SB(dir->i_sb)->s_es->s_inodes_count))
85 error_msg = "inode out of bounds";
86
87 if (error_msg != NULL)
88 ext4_error (dir->i_sb, function,
89 "bad entry in directory #%lu: %s - "
90 "offset=%lu, inode=%lu, rec_len=%d, name_len=%d",
91 dir->i_ino, error_msg, offset,
92 (unsigned long) le32_to_cpu(de->inode),
93 rlen, de->name_len);
94 return error_msg == NULL ? 1 : 0;
95}
96
97static int ext4_readdir(struct file * filp,
98 void * dirent, filldir_t filldir)
99{
100 int error = 0;
101 unsigned long offset;
102 int i, stored;
103 struct ext4_dir_entry_2 *de;
104 struct super_block *sb;
105 int err;
106 struct inode *inode = filp->f_dentry->d_inode;
107 int ret = 0;
108
109 sb = inode->i_sb;
110
111#ifdef CONFIG_EXT4_INDEX
112 if (EXT4_HAS_COMPAT_FEATURE(inode->i_sb,
113 EXT4_FEATURE_COMPAT_DIR_INDEX) &&
114 ((EXT4_I(inode)->i_flags & EXT4_INDEX_FL) ||
115 ((inode->i_size >> sb->s_blocksize_bits) == 1))) {
116 err = ext4_dx_readdir(filp, dirent, filldir);
117 if (err != ERR_BAD_DX_DIR) {
118 ret = err;
119 goto out;
120 }
121 /*
122 * We don't set the inode dirty flag since it's not
123 * critical that it get flushed back to the disk.
124 */
125 EXT4_I(filp->f_dentry->d_inode)->i_flags &= ~EXT4_INDEX_FL;
126 }
127#endif
128 stored = 0;
129 offset = filp->f_pos & (sb->s_blocksize - 1);
130
131 while (!error && !stored && filp->f_pos < inode->i_size) {
132 unsigned long blk = filp->f_pos >> EXT4_BLOCK_SIZE_BITS(sb);
133 struct buffer_head map_bh;
134 struct buffer_head *bh = NULL;
135
136 map_bh.b_state = 0;
137 err = ext4_get_blocks_wrap(NULL, inode, blk, 1, &map_bh, 0, 0);
138 if (err > 0) {
139 page_cache_readahead(sb->s_bdev->bd_inode->i_mapping,
140 &filp->f_ra,
141 filp,
142 map_bh.b_blocknr >>
143 (PAGE_CACHE_SHIFT - inode->i_blkbits),
144 1);
145 bh = ext4_bread(NULL, inode, blk, 0, &err);
146 }
147
148 /*
149 * We ignore I/O errors on directories so users have a chance
150 * of recovering data when there's a bad sector
151 */
152 if (!bh) {
153 ext4_error (sb, "ext4_readdir",
154 "directory #%lu contains a hole at offset %lu",
155 inode->i_ino, (unsigned long)filp->f_pos);
156 filp->f_pos += sb->s_blocksize - offset;
157 continue;
158 }
159
160revalidate:
161 /* If the dir block has changed since the last call to
162 * readdir(2), then we might be pointing to an invalid
163 * dirent right now. Scan from the start of the block
164 * to make sure. */
165 if (filp->f_version != inode->i_version) {
166 for (i = 0; i < sb->s_blocksize && i < offset; ) {
167 de = (struct ext4_dir_entry_2 *)
168 (bh->b_data + i);
169 /* It's too expensive to do a full
170 * dirent test each time round this
171 * loop, but we do have to test at
172 * least that it is non-zero. A
173 * failure will be detected in the
174 * dirent test below. */
175 if (le16_to_cpu(de->rec_len) <
176 EXT4_DIR_REC_LEN(1))
177 break;
178 i += le16_to_cpu(de->rec_len);
179 }
180 offset = i;
181 filp->f_pos = (filp->f_pos & ~(sb->s_blocksize - 1))
182 | offset;
183 filp->f_version = inode->i_version;
184 }
185
186 while (!error && filp->f_pos < inode->i_size
187 && offset < sb->s_blocksize) {
188 de = (struct ext4_dir_entry_2 *) (bh->b_data + offset);
189 if (!ext4_check_dir_entry ("ext4_readdir", inode, de,
190 bh, offset)) {
191 /*
192 * On error, skip the f_pos to the next block
193 */
194 filp->f_pos = (filp->f_pos |
195 (sb->s_blocksize - 1)) + 1;
196 brelse (bh);
197 ret = stored;
198 goto out;
199 }
200 offset += le16_to_cpu(de->rec_len);
201 if (le32_to_cpu(de->inode)) {
202 /* We might block in the next section
203 * if the data destination is
204 * currently swapped out. So, use a
205 * version stamp to detect whether or
206 * not the directory has been modified
207 * during the copy operation.
208 */
209 unsigned long version = filp->f_version;
210
211 error = filldir(dirent, de->name,
212 de->name_len,
213 filp->f_pos,
214 le32_to_cpu(de->inode),
215 get_dtype(sb, de->file_type));
216 if (error)
217 break;
218 if (version != filp->f_version)
219 goto revalidate;
220 stored ++;
221 }
222 filp->f_pos += le16_to_cpu(de->rec_len);
223 }
224 offset = 0;
225 brelse (bh);
226 }
227out:
228 return ret;
229}
230
231#ifdef CONFIG_EXT4_INDEX
232/*
233 * These functions convert from the major/minor hash to an f_pos
234 * value.
235 *
236 * Currently we only use major hash numer. This is unfortunate, but
237 * on 32-bit machines, the same VFS interface is used for lseek and
238 * llseek, so if we use the 64 bit offset, then the 32-bit versions of
239 * lseek/telldir/seekdir will blow out spectacularly, and from within
240 * the ext2 low-level routine, we don't know if we're being called by
241 * a 64-bit version of the system call or the 32-bit version of the
242 * system call. Worse yet, NFSv2 only allows for a 32-bit readdir
243 * cookie. Sigh.
244 */
245#define hash2pos(major, minor) (major >> 1)
246#define pos2maj_hash(pos) ((pos << 1) & 0xffffffff)
247#define pos2min_hash(pos) (0)
248
249/*
250 * This structure holds the nodes of the red-black tree used to store
251 * the directory entry in hash order.
252 */
253struct fname {
254 __u32 hash;
255 __u32 minor_hash;
256 struct rb_node rb_hash;
257 struct fname *next;
258 __u32 inode;
259 __u8 name_len;
260 __u8 file_type;
261 char name[0];
262};
263
264/*
265 * This functoin implements a non-recursive way of freeing all of the
266 * nodes in the red-black tree.
267 */
268static void free_rb_tree_fname(struct rb_root *root)
269{
270 struct rb_node *n = root->rb_node;
271 struct rb_node *parent;
272 struct fname *fname;
273
274 while (n) {
275 /* Do the node's children first */
276 if ((n)->rb_left) {
277 n = n->rb_left;
278 continue;
279 }
280 if (n->rb_right) {
281 n = n->rb_right;
282 continue;
283 }
284 /*
285 * The node has no children; free it, and then zero
286 * out parent's link to it. Finally go to the
287 * beginning of the loop and try to free the parent
288 * node.
289 */
290 parent = rb_parent(n);
291 fname = rb_entry(n, struct fname, rb_hash);
292 while (fname) {
293 struct fname * old = fname;
294 fname = fname->next;
295 kfree (old);
296 }
297 if (!parent)
298 root->rb_node = NULL;
299 else if (parent->rb_left == n)
300 parent->rb_left = NULL;
301 else if (parent->rb_right == n)
302 parent->rb_right = NULL;
303 n = parent;
304 }
305 root->rb_node = NULL;
306}
307
308
309static struct dir_private_info *create_dir_info(loff_t pos)
310{
311 struct dir_private_info *p;
312
313 p = kmalloc(sizeof(struct dir_private_info), GFP_KERNEL);
314 if (!p)
315 return NULL;
316 p->root.rb_node = NULL;
317 p->curr_node = NULL;
318 p->extra_fname = NULL;
319 p->last_pos = 0;
320 p->curr_hash = pos2maj_hash(pos);
321 p->curr_minor_hash = pos2min_hash(pos);
322 p->next_hash = 0;
323 return p;
324}
325
326void ext4_htree_free_dir_info(struct dir_private_info *p)
327{
328 free_rb_tree_fname(&p->root);
329 kfree(p);
330}
331
332/*
333 * Given a directory entry, enter it into the fname rb tree.
334 */
335int ext4_htree_store_dirent(struct file *dir_file, __u32 hash,
336 __u32 minor_hash,
337 struct ext4_dir_entry_2 *dirent)
338{
339 struct rb_node **p, *parent = NULL;
340 struct fname * fname, *new_fn;
341 struct dir_private_info *info;
342 int len;
343
344 info = (struct dir_private_info *) dir_file->private_data;
345 p = &info->root.rb_node;
346
347 /* Create and allocate the fname structure */
348 len = sizeof(struct fname) + dirent->name_len + 1;
349 new_fn = kzalloc(len, GFP_KERNEL);
350 if (!new_fn)
351 return -ENOMEM;
352 new_fn->hash = hash;
353 new_fn->minor_hash = minor_hash;
354 new_fn->inode = le32_to_cpu(dirent->inode);
355 new_fn->name_len = dirent->name_len;
356 new_fn->file_type = dirent->file_type;
357 memcpy(new_fn->name, dirent->name, dirent->name_len);
358 new_fn->name[dirent->name_len] = 0;
359
360 while (*p) {
361 parent = *p;
362 fname = rb_entry(parent, struct fname, rb_hash);
363
364 /*
365 * If the hash and minor hash match up, then we put
366 * them on a linked list. This rarely happens...
367 */
368 if ((new_fn->hash == fname->hash) &&
369 (new_fn->minor_hash == fname->minor_hash)) {
370 new_fn->next = fname->next;
371 fname->next = new_fn;
372 return 0;
373 }
374
375 if (new_fn->hash < fname->hash)
376 p = &(*p)->rb_left;
377 else if (new_fn->hash > fname->hash)
378 p = &(*p)->rb_right;
379 else if (new_fn->minor_hash < fname->minor_hash)
380 p = &(*p)->rb_left;
381 else /* if (new_fn->minor_hash > fname->minor_hash) */
382 p = &(*p)->rb_right;
383 }
384
385 rb_link_node(&new_fn->rb_hash, parent, p);
386 rb_insert_color(&new_fn->rb_hash, &info->root);
387 return 0;
388}
389
390
391
392/*
393 * This is a helper function for ext4_dx_readdir. It calls filldir
394 * for all entres on the fname linked list. (Normally there is only
395 * one entry on the linked list, unless there are 62 bit hash collisions.)
396 */
397static int call_filldir(struct file * filp, void * dirent,
398 filldir_t filldir, struct fname *fname)
399{
400 struct dir_private_info *info = filp->private_data;
401 loff_t curr_pos;
402 struct inode *inode = filp->f_dentry->d_inode;
403 struct super_block * sb;
404 int error;
405
406 sb = inode->i_sb;
407
408 if (!fname) {
409 printk("call_filldir: called with null fname?!?\n");
410 return 0;
411 }
412 curr_pos = hash2pos(fname->hash, fname->minor_hash);
413 while (fname) {
414 error = filldir(dirent, fname->name,
415 fname->name_len, curr_pos,
416 fname->inode,
417 get_dtype(sb, fname->file_type));
418 if (error) {
419 filp->f_pos = curr_pos;
420 info->extra_fname = fname->next;
421 return error;
422 }
423 fname = fname->next;
424 }
425 return 0;
426}
427
428static int ext4_dx_readdir(struct file * filp,
429 void * dirent, filldir_t filldir)
430{
431 struct dir_private_info *info = filp->private_data;
432 struct inode *inode = filp->f_dentry->d_inode;
433 struct fname *fname;
434 int ret;
435
436 if (!info) {
437 info = create_dir_info(filp->f_pos);
438 if (!info)
439 return -ENOMEM;
440 filp->private_data = info;
441 }
442
443 if (filp->f_pos == EXT4_HTREE_EOF)
444 return 0; /* EOF */
445
446 /* Some one has messed with f_pos; reset the world */
447 if (info->last_pos != filp->f_pos) {
448 free_rb_tree_fname(&info->root);
449 info->curr_node = NULL;
450 info->extra_fname = NULL;
451 info->curr_hash = pos2maj_hash(filp->f_pos);
452 info->curr_minor_hash = pos2min_hash(filp->f_pos);
453 }
454
455 /*
456 * If there are any leftover names on the hash collision
457 * chain, return them first.
458 */
459 if (info->extra_fname &&
460 call_filldir(filp, dirent, filldir, info->extra_fname))
461 goto finished;
462
463 if (!info->curr_node)
464 info->curr_node = rb_first(&info->root);
465
466 while (1) {
467 /*
468 * Fill the rbtree if we have no more entries,
469 * or the inode has changed since we last read in the
470 * cached entries.
471 */
472 if ((!info->curr_node) ||
473 (filp->f_version != inode->i_version)) {
474 info->curr_node = NULL;
475 free_rb_tree_fname(&info->root);
476 filp->f_version = inode->i_version;
477 ret = ext4_htree_fill_tree(filp, info->curr_hash,
478 info->curr_minor_hash,
479 &info->next_hash);
480 if (ret < 0)
481 return ret;
482 if (ret == 0) {
483 filp->f_pos = EXT4_HTREE_EOF;
484 break;
485 }
486 info->curr_node = rb_first(&info->root);
487 }
488
489 fname = rb_entry(info->curr_node, struct fname, rb_hash);
490 info->curr_hash = fname->hash;
491 info->curr_minor_hash = fname->minor_hash;
492 if (call_filldir(filp, dirent, filldir, fname))
493 break;
494
495 info->curr_node = rb_next(info->curr_node);
496 if (!info->curr_node) {
497 if (info->next_hash == ~0) {
498 filp->f_pos = EXT4_HTREE_EOF;
499 break;
500 }
501 info->curr_hash = info->next_hash;
502 info->curr_minor_hash = 0;
503 }
504 }
505finished:
506 info->last_pos = filp->f_pos;
507 return 0;
508}
509
510static int ext4_release_dir (struct inode * inode, struct file * filp)
511{
512 if (filp->private_data)
513 ext4_htree_free_dir_info(filp->private_data);
514
515 return 0;
516}
517
518#endif
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
new file mode 100644
index 000000000000..2608dce18f3e
--- /dev/null
+++ b/fs/ext4/extents.c
@@ -0,0 +1,2152 @@
1/*
2 * Copyright (c) 2003-2006, Cluster File Systems, Inc, info@clusterfs.com
3 * Written by Alex Tomas <alex@clusterfs.com>
4 *
5 * Architecture independence:
6 * Copyright (c) 2005, Bull S.A.
7 * Written by Pierre Peiffer <pierre.peiffer@bull.net>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public Licens
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-
21 */
22
23/*
24 * Extents support for EXT4
25 *
26 * TODO:
27 * - ext4*_error() should be used in some situations
28 * - analyze all BUG()/BUG_ON(), use -EIO where appropriate
29 * - smart tree reduction
30 */
31
32#include <linux/module.h>
33#include <linux/fs.h>
34#include <linux/time.h>
35#include <linux/ext4_jbd2.h>
36#include <linux/jbd.h>
37#include <linux/smp_lock.h>
38#include <linux/highuid.h>
39#include <linux/pagemap.h>
40#include <linux/quotaops.h>
41#include <linux/string.h>
42#include <linux/slab.h>
43#include <linux/ext4_fs_extents.h>
44#include <asm/uaccess.h>
45
46
47/*
48 * ext_pblock:
49 * combine low and high parts of physical block number into ext4_fsblk_t
50 */
51static inline ext4_fsblk_t ext_pblock(struct ext4_extent *ex)
52{
53 ext4_fsblk_t block;
54
55 block = le32_to_cpu(ex->ee_start);
56 block |= ((ext4_fsblk_t) le16_to_cpu(ex->ee_start_hi) << 31) << 1;
57 return block;
58}
59
60/*
61 * idx_pblock:
62 * combine low and high parts of a leaf physical block number into ext4_fsblk_t
63 */
64static inline ext4_fsblk_t idx_pblock(struct ext4_extent_idx *ix)
65{
66 ext4_fsblk_t block;
67
68 block = le32_to_cpu(ix->ei_leaf);
69 block |= ((ext4_fsblk_t) le16_to_cpu(ix->ei_leaf_hi) << 31) << 1;
70 return block;
71}
72
73/*
74 * ext4_ext_store_pblock:
75 * stores a large physical block number into an extent struct,
76 * breaking it into parts
77 */
78static inline void ext4_ext_store_pblock(struct ext4_extent *ex, ext4_fsblk_t pb)
79{
80 ex->ee_start = cpu_to_le32((unsigned long) (pb & 0xffffffff));
81 ex->ee_start_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) & 0xffff);
82}
83
84/*
85 * ext4_idx_store_pblock:
86 * stores a large physical block number into an index struct,
87 * breaking it into parts
88 */
89static inline void ext4_idx_store_pblock(struct ext4_extent_idx *ix, ext4_fsblk_t pb)
90{
91 ix->ei_leaf = cpu_to_le32((unsigned long) (pb & 0xffffffff));
92 ix->ei_leaf_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) & 0xffff);
93}
94
95static int ext4_ext_check_header(const char *function, struct inode *inode,
96 struct ext4_extent_header *eh)
97{
98 const char *error_msg = NULL;
99
100 if (unlikely(eh->eh_magic != EXT4_EXT_MAGIC)) {
101 error_msg = "invalid magic";
102 goto corrupted;
103 }
104 if (unlikely(eh->eh_max == 0)) {
105 error_msg = "invalid eh_max";
106 goto corrupted;
107 }
108 if (unlikely(le16_to_cpu(eh->eh_entries) > le16_to_cpu(eh->eh_max))) {
109 error_msg = "invalid eh_entries";
110 goto corrupted;
111 }
112 return 0;
113
114corrupted:
115 ext4_error(inode->i_sb, function,
116 "bad header in inode #%lu: %s - magic %x, "
117 "entries %u, max %u, depth %u",
118 inode->i_ino, error_msg, le16_to_cpu(eh->eh_magic),
119 le16_to_cpu(eh->eh_entries), le16_to_cpu(eh->eh_max),
120 le16_to_cpu(eh->eh_depth));
121
122 return -EIO;
123}
124
125static handle_t *ext4_ext_journal_restart(handle_t *handle, int needed)
126{
127 int err;
128
129 if (handle->h_buffer_credits > needed)
130 return handle;
131 if (!ext4_journal_extend(handle, needed))
132 return handle;
133 err = ext4_journal_restart(handle, needed);
134
135 return handle;
136}
137
138/*
139 * could return:
140 * - EROFS
141 * - ENOMEM
142 */
143static int ext4_ext_get_access(handle_t *handle, struct inode *inode,
144 struct ext4_ext_path *path)
145{
146 if (path->p_bh) {
147 /* path points to block */
148 return ext4_journal_get_write_access(handle, path->p_bh);
149 }
150 /* path points to leaf/index in inode body */
151 /* we use in-core data, no need to protect them */
152 return 0;
153}
154
155/*
156 * could return:
157 * - EROFS
158 * - ENOMEM
159 * - EIO
160 */
161static int ext4_ext_dirty(handle_t *handle, struct inode *inode,
162 struct ext4_ext_path *path)
163{
164 int err;
165 if (path->p_bh) {
166 /* path points to block */
167 err = ext4_journal_dirty_metadata(handle, path->p_bh);
168 } else {
169 /* path points to leaf/index in inode body */
170 err = ext4_mark_inode_dirty(handle, inode);
171 }
172 return err;
173}
174
175static ext4_fsblk_t ext4_ext_find_goal(struct inode *inode,
176 struct ext4_ext_path *path,
177 ext4_fsblk_t block)
178{
179 struct ext4_inode_info *ei = EXT4_I(inode);
180 ext4_fsblk_t bg_start;
181 ext4_grpblk_t colour;
182 int depth;
183
184 if (path) {
185 struct ext4_extent *ex;
186 depth = path->p_depth;
187
188 /* try to predict block placement */
189 if ((ex = path[depth].p_ext))
190 return ext_pblock(ex)+(block-le32_to_cpu(ex->ee_block));
191
192 /* it looks like index is empty;
193 * try to find starting block from index itself */
194 if (path[depth].p_bh)
195 return path[depth].p_bh->b_blocknr;
196 }
197
198 /* OK. use inode's group */
199 bg_start = (ei->i_block_group * EXT4_BLOCKS_PER_GROUP(inode->i_sb)) +
200 le32_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_first_data_block);
201 colour = (current->pid % 16) *
202 (EXT4_BLOCKS_PER_GROUP(inode->i_sb) / 16);
203 return bg_start + colour + block;
204}
205
206static ext4_fsblk_t
207ext4_ext_new_block(handle_t *handle, struct inode *inode,
208 struct ext4_ext_path *path,
209 struct ext4_extent *ex, int *err)
210{
211 ext4_fsblk_t goal, newblock;
212
213 goal = ext4_ext_find_goal(inode, path, le32_to_cpu(ex->ee_block));
214 newblock = ext4_new_block(handle, inode, goal, err);
215 return newblock;
216}
217
218static inline int ext4_ext_space_block(struct inode *inode)
219{
220 int size;
221
222 size = (inode->i_sb->s_blocksize - sizeof(struct ext4_extent_header))
223 / sizeof(struct ext4_extent);
224#ifdef AGRESSIVE_TEST
225 if (size > 6)
226 size = 6;
227#endif
228 return size;
229}
230
231static inline int ext4_ext_space_block_idx(struct inode *inode)
232{
233 int size;
234
235 size = (inode->i_sb->s_blocksize - sizeof(struct ext4_extent_header))
236 / sizeof(struct ext4_extent_idx);
237#ifdef AGRESSIVE_TEST
238 if (size > 5)
239 size = 5;
240#endif
241 return size;
242}
243
244static inline int ext4_ext_space_root(struct inode *inode)
245{
246 int size;
247
248 size = sizeof(EXT4_I(inode)->i_data);
249 size -= sizeof(struct ext4_extent_header);
250 size /= sizeof(struct ext4_extent);
251#ifdef AGRESSIVE_TEST
252 if (size > 3)
253 size = 3;
254#endif
255 return size;
256}
257
258static inline int ext4_ext_space_root_idx(struct inode *inode)
259{
260 int size;
261
262 size = sizeof(EXT4_I(inode)->i_data);
263 size -= sizeof(struct ext4_extent_header);
264 size /= sizeof(struct ext4_extent_idx);
265#ifdef AGRESSIVE_TEST
266 if (size > 4)
267 size = 4;
268#endif
269 return size;
270}
271
272#ifdef EXT_DEBUG
273static void ext4_ext_show_path(struct inode *inode, struct ext4_ext_path *path)
274{
275 int k, l = path->p_depth;
276
277 ext_debug("path:");
278 for (k = 0; k <= l; k++, path++) {
279 if (path->p_idx) {
280 ext_debug(" %d->%llu", le32_to_cpu(path->p_idx->ei_block),
281 idx_pblock(path->p_idx));
282 } else if (path->p_ext) {
283 ext_debug(" %d:%d:%llu ",
284 le32_to_cpu(path->p_ext->ee_block),
285 le16_to_cpu(path->p_ext->ee_len),
286 ext_pblock(path->p_ext));
287 } else
288 ext_debug(" []");
289 }
290 ext_debug("\n");
291}
292
293static void ext4_ext_show_leaf(struct inode *inode, struct ext4_ext_path *path)
294{
295 int depth = ext_depth(inode);
296 struct ext4_extent_header *eh;
297 struct ext4_extent *ex;
298 int i;
299
300 if (!path)
301 return;
302
303 eh = path[depth].p_hdr;
304 ex = EXT_FIRST_EXTENT(eh);
305
306 for (i = 0; i < le16_to_cpu(eh->eh_entries); i++, ex++) {
307 ext_debug("%d:%d:%llu ", le32_to_cpu(ex->ee_block),
308 le16_to_cpu(ex->ee_len), ext_pblock(ex));
309 }
310 ext_debug("\n");
311}
312#else
313#define ext4_ext_show_path(inode,path)
314#define ext4_ext_show_leaf(inode,path)
315#endif
316
317static void ext4_ext_drop_refs(struct ext4_ext_path *path)
318{
319 int depth = path->p_depth;
320 int i;
321
322 for (i = 0; i <= depth; i++, path++)
323 if (path->p_bh) {
324 brelse(path->p_bh);
325 path->p_bh = NULL;
326 }
327}
328
329/*
330 * ext4_ext_binsearch_idx:
331 * binary search for the closest index of the given block
332 */
333static void
334ext4_ext_binsearch_idx(struct inode *inode, struct ext4_ext_path *path, int block)
335{
336 struct ext4_extent_header *eh = path->p_hdr;
337 struct ext4_extent_idx *r, *l, *m;
338
339 BUG_ON(eh->eh_magic != EXT4_EXT_MAGIC);
340 BUG_ON(le16_to_cpu(eh->eh_entries) > le16_to_cpu(eh->eh_max));
341 BUG_ON(le16_to_cpu(eh->eh_entries) <= 0);
342
343 ext_debug("binsearch for %d(idx): ", block);
344
345 l = EXT_FIRST_INDEX(eh) + 1;
346 r = EXT_FIRST_INDEX(eh) + le16_to_cpu(eh->eh_entries) - 1;
347 while (l <= r) {
348 m = l + (r - l) / 2;
349 if (block < le32_to_cpu(m->ei_block))
350 r = m - 1;
351 else
352 l = m + 1;
353 ext_debug("%p(%u):%p(%u):%p(%u) ", l, l->ei_block,
354 m, m->ei_block, r, r->ei_block);
355 }
356
357 path->p_idx = l - 1;
358 ext_debug(" -> %d->%lld ", le32_to_cpu(path->p_idx->ei_block),
359 idx_block(path->p_idx));
360
361#ifdef CHECK_BINSEARCH
362 {
363 struct ext4_extent_idx *chix, *ix;
364 int k;
365
366 chix = ix = EXT_FIRST_INDEX(eh);
367 for (k = 0; k < le16_to_cpu(eh->eh_entries); k++, ix++) {
368 if (k != 0 &&
369 le32_to_cpu(ix->ei_block) <= le32_to_cpu(ix[-1].ei_block)) {
370 printk("k=%d, ix=0x%p, first=0x%p\n", k,
371 ix, EXT_FIRST_INDEX(eh));
372 printk("%u <= %u\n",
373 le32_to_cpu(ix->ei_block),
374 le32_to_cpu(ix[-1].ei_block));
375 }
376 BUG_ON(k && le32_to_cpu(ix->ei_block)
377 <= le32_to_cpu(ix[-1].ei_block));
378 if (block < le32_to_cpu(ix->ei_block))
379 break;
380 chix = ix;
381 }
382 BUG_ON(chix != path->p_idx);
383 }
384#endif
385
386}
387
388/*
389 * ext4_ext_binsearch:
390 * binary search for closest extent of the given block
391 */
392static void
393ext4_ext_binsearch(struct inode *inode, struct ext4_ext_path *path, int block)
394{
395 struct ext4_extent_header *eh = path->p_hdr;
396 struct ext4_extent *r, *l, *m;
397
398 BUG_ON(eh->eh_magic != EXT4_EXT_MAGIC);
399 BUG_ON(le16_to_cpu(eh->eh_entries) > le16_to_cpu(eh->eh_max));
400
401 if (eh->eh_entries == 0) {
402 /*
403 * this leaf is empty:
404 * we get such a leaf in split/add case
405 */
406 return;
407 }
408
409 ext_debug("binsearch for %d: ", block);
410
411 l = EXT_FIRST_EXTENT(eh) + 1;
412 r = EXT_FIRST_EXTENT(eh) + le16_to_cpu(eh->eh_entries) - 1;
413
414 while (l <= r) {
415 m = l + (r - l) / 2;
416 if (block < le32_to_cpu(m->ee_block))
417 r = m - 1;
418 else
419 l = m + 1;
420 ext_debug("%p(%u):%p(%u):%p(%u) ", l, l->ee_block,
421 m, m->ee_block, r, r->ee_block);
422 }
423
424 path->p_ext = l - 1;
425 ext_debug(" -> %d:%llu:%d ",
426 le32_to_cpu(path->p_ext->ee_block),
427 ext_pblock(path->p_ext),
428 le16_to_cpu(path->p_ext->ee_len));
429
430#ifdef CHECK_BINSEARCH
431 {
432 struct ext4_extent *chex, *ex;
433 int k;
434
435 chex = ex = EXT_FIRST_EXTENT(eh);
436 for (k = 0; k < le16_to_cpu(eh->eh_entries); k++, ex++) {
437 BUG_ON(k && le32_to_cpu(ex->ee_block)
438 <= le32_to_cpu(ex[-1].ee_block));
439 if (block < le32_to_cpu(ex->ee_block))
440 break;
441 chex = ex;
442 }
443 BUG_ON(chex != path->p_ext);
444 }
445#endif
446
447}
448
449int ext4_ext_tree_init(handle_t *handle, struct inode *inode)
450{
451 struct ext4_extent_header *eh;
452
453 eh = ext_inode_hdr(inode);
454 eh->eh_depth = 0;
455 eh->eh_entries = 0;
456 eh->eh_magic = EXT4_EXT_MAGIC;
457 eh->eh_max = cpu_to_le16(ext4_ext_space_root(inode));
458 ext4_mark_inode_dirty(handle, inode);
459 ext4_ext_invalidate_cache(inode);
460 return 0;
461}
462
463struct ext4_ext_path *
464ext4_ext_find_extent(struct inode *inode, int block, struct ext4_ext_path *path)
465{
466 struct ext4_extent_header *eh;
467 struct buffer_head *bh;
468 short int depth, i, ppos = 0, alloc = 0;
469
470 eh = ext_inode_hdr(inode);
471 BUG_ON(eh == NULL);
472 if (ext4_ext_check_header(__FUNCTION__, inode, eh))
473 return ERR_PTR(-EIO);
474
475 i = depth = ext_depth(inode);
476
477 /* account possible depth increase */
478 if (!path) {
479 path = kmalloc(sizeof(struct ext4_ext_path) * (depth + 2),
480 GFP_NOFS);
481 if (!path)
482 return ERR_PTR(-ENOMEM);
483 alloc = 1;
484 }
485 memset(path, 0, sizeof(struct ext4_ext_path) * (depth + 1));
486 path[0].p_hdr = eh;
487
488 /* walk through the tree */
489 while (i) {
490 ext_debug("depth %d: num %d, max %d\n",
491 ppos, le16_to_cpu(eh->eh_entries), le16_to_cpu(eh->eh_max));
492 ext4_ext_binsearch_idx(inode, path + ppos, block);
493 path[ppos].p_block = idx_pblock(path[ppos].p_idx);
494 path[ppos].p_depth = i;
495 path[ppos].p_ext = NULL;
496
497 bh = sb_bread(inode->i_sb, path[ppos].p_block);
498 if (!bh)
499 goto err;
500
501 eh = ext_block_hdr(bh);
502 ppos++;
503 BUG_ON(ppos > depth);
504 path[ppos].p_bh = bh;
505 path[ppos].p_hdr = eh;
506 i--;
507
508 if (ext4_ext_check_header(__FUNCTION__, inode, eh))
509 goto err;
510 }
511
512 path[ppos].p_depth = i;
513 path[ppos].p_hdr = eh;
514 path[ppos].p_ext = NULL;
515 path[ppos].p_idx = NULL;
516
517 if (ext4_ext_check_header(__FUNCTION__, inode, eh))
518 goto err;
519
520 /* find extent */
521 ext4_ext_binsearch(inode, path + ppos, block);
522
523 ext4_ext_show_path(inode, path);
524
525 return path;
526
527err:
528 ext4_ext_drop_refs(path);
529 if (alloc)
530 kfree(path);
531 return ERR_PTR(-EIO);
532}
533
534/*
535 * ext4_ext_insert_index:
536 * insert new index [@logical;@ptr] into the block at @curp;
537 * check where to insert: before @curp or after @curp
538 */
539static int ext4_ext_insert_index(handle_t *handle, struct inode *inode,
540 struct ext4_ext_path *curp,
541 int logical, ext4_fsblk_t ptr)
542{
543 struct ext4_extent_idx *ix;
544 int len, err;
545
546 if ((err = ext4_ext_get_access(handle, inode, curp)))
547 return err;
548
549 BUG_ON(logical == le32_to_cpu(curp->p_idx->ei_block));
550 len = EXT_MAX_INDEX(curp->p_hdr) - curp->p_idx;
551 if (logical > le32_to_cpu(curp->p_idx->ei_block)) {
552 /* insert after */
553 if (curp->p_idx != EXT_LAST_INDEX(curp->p_hdr)) {
554 len = (len - 1) * sizeof(struct ext4_extent_idx);
555 len = len < 0 ? 0 : len;
556 ext_debug("insert new index %d after: %d. "
557 "move %d from 0x%p to 0x%p\n",
558 logical, ptr, len,
559 (curp->p_idx + 1), (curp->p_idx + 2));
560 memmove(curp->p_idx + 2, curp->p_idx + 1, len);
561 }
562 ix = curp->p_idx + 1;
563 } else {
564 /* insert before */
565 len = len * sizeof(struct ext4_extent_idx);
566 len = len < 0 ? 0 : len;
567 ext_debug("insert new index %d before: %d. "
568 "move %d from 0x%p to 0x%p\n",
569 logical, ptr, len,
570 curp->p_idx, (curp->p_idx + 1));
571 memmove(curp->p_idx + 1, curp->p_idx, len);
572 ix = curp->p_idx;
573 }
574
575 ix->ei_block = cpu_to_le32(logical);
576 ext4_idx_store_pblock(ix, ptr);
577 curp->p_hdr->eh_entries = cpu_to_le16(le16_to_cpu(curp->p_hdr->eh_entries)+1);
578
579 BUG_ON(le16_to_cpu(curp->p_hdr->eh_entries)
580 > le16_to_cpu(curp->p_hdr->eh_max));
581 BUG_ON(ix > EXT_LAST_INDEX(curp->p_hdr));
582
583 err = ext4_ext_dirty(handle, inode, curp);
584 ext4_std_error(inode->i_sb, err);
585
586 return err;
587}
588
589/*
590 * ext4_ext_split:
591 * inserts new subtree into the path, using free index entry
592 * at depth @at:
593 * - allocates all needed blocks (new leaf and all intermediate index blocks)
594 * - makes decision where to split
595 * - moves remaining extents and index entries (right to the split point)
596 * into the newly allocated blocks
597 * - initializes subtree
598 */
599static int ext4_ext_split(handle_t *handle, struct inode *inode,
600 struct ext4_ext_path *path,
601 struct ext4_extent *newext, int at)
602{
603 struct buffer_head *bh = NULL;
604 int depth = ext_depth(inode);
605 struct ext4_extent_header *neh;
606 struct ext4_extent_idx *fidx;
607 struct ext4_extent *ex;
608 int i = at, k, m, a;
609 ext4_fsblk_t newblock, oldblock;
610 __le32 border;
611 ext4_fsblk_t *ablocks = NULL; /* array of allocated blocks */
612 int err = 0;
613
614 /* make decision: where to split? */
615 /* FIXME: now decision is simplest: at current extent */
616
617 /* if current leaf will be split, then we should use
618 * border from split point */
619 BUG_ON(path[depth].p_ext > EXT_MAX_EXTENT(path[depth].p_hdr));
620 if (path[depth].p_ext != EXT_MAX_EXTENT(path[depth].p_hdr)) {
621 border = path[depth].p_ext[1].ee_block;
622 ext_debug("leaf will be split."
623 " next leaf starts at %d\n",
624 le32_to_cpu(border));
625 } else {
626 border = newext->ee_block;
627 ext_debug("leaf will be added."
628 " next leaf starts at %d\n",
629 le32_to_cpu(border));
630 }
631
632 /*
633 * If error occurs, then we break processing
634 * and mark filesystem read-only. index won't
635 * be inserted and tree will be in consistent
636 * state. Next mount will repair buffers too.
637 */
638
639 /*
640 * Get array to track all allocated blocks.
641 * We need this to handle errors and free blocks
642 * upon them.
643 */
644 ablocks = kmalloc(sizeof(ext4_fsblk_t) * depth, GFP_NOFS);
645 if (!ablocks)
646 return -ENOMEM;
647 memset(ablocks, 0, sizeof(ext4_fsblk_t) * depth);
648
649 /* allocate all needed blocks */
650 ext_debug("allocate %d blocks for indexes/leaf\n", depth - at);
651 for (a = 0; a < depth - at; a++) {
652 newblock = ext4_ext_new_block(handle, inode, path, newext, &err);
653 if (newblock == 0)
654 goto cleanup;
655 ablocks[a] = newblock;
656 }
657
658 /* initialize new leaf */
659 newblock = ablocks[--a];
660 BUG_ON(newblock == 0);
661 bh = sb_getblk(inode->i_sb, newblock);
662 if (!bh) {
663 err = -EIO;
664 goto cleanup;
665 }
666 lock_buffer(bh);
667
668 if ((err = ext4_journal_get_create_access(handle, bh)))
669 goto cleanup;
670
671 neh = ext_block_hdr(bh);
672 neh->eh_entries = 0;
673 neh->eh_max = cpu_to_le16(ext4_ext_space_block(inode));
674 neh->eh_magic = EXT4_EXT_MAGIC;
675 neh->eh_depth = 0;
676 ex = EXT_FIRST_EXTENT(neh);
677
678 /* move remainder of path[depth] to the new leaf */
679 BUG_ON(path[depth].p_hdr->eh_entries != path[depth].p_hdr->eh_max);
680 /* start copy from next extent */
681 /* TODO: we could do it by single memmove */
682 m = 0;
683 path[depth].p_ext++;
684 while (path[depth].p_ext <=
685 EXT_MAX_EXTENT(path[depth].p_hdr)) {
686 ext_debug("move %d:%llu:%d in new leaf %llu\n",
687 le32_to_cpu(path[depth].p_ext->ee_block),
688 ext_pblock(path[depth].p_ext),
689 le16_to_cpu(path[depth].p_ext->ee_len),
690 newblock);
691 /*memmove(ex++, path[depth].p_ext++,
692 sizeof(struct ext4_extent));
693 neh->eh_entries++;*/
694 path[depth].p_ext++;
695 m++;
696 }
697 if (m) {
698 memmove(ex, path[depth].p_ext-m, sizeof(struct ext4_extent)*m);
699 neh->eh_entries = cpu_to_le16(le16_to_cpu(neh->eh_entries)+m);
700 }
701
702 set_buffer_uptodate(bh);
703 unlock_buffer(bh);
704
705 if ((err = ext4_journal_dirty_metadata(handle, bh)))
706 goto cleanup;
707 brelse(bh);
708 bh = NULL;
709
710 /* correct old leaf */
711 if (m) {
712 if ((err = ext4_ext_get_access(handle, inode, path + depth)))
713 goto cleanup;
714 path[depth].p_hdr->eh_entries =
715 cpu_to_le16(le16_to_cpu(path[depth].p_hdr->eh_entries)-m);
716 if ((err = ext4_ext_dirty(handle, inode, path + depth)))
717 goto cleanup;
718
719 }
720
721 /* create intermediate indexes */
722 k = depth - at - 1;
723 BUG_ON(k < 0);
724 if (k)
725 ext_debug("create %d intermediate indices\n", k);
726 /* insert new index into current index block */
727 /* current depth stored in i var */
728 i = depth - 1;
729 while (k--) {
730 oldblock = newblock;
731 newblock = ablocks[--a];
732 bh = sb_getblk(inode->i_sb, (ext4_fsblk_t)newblock);
733 if (!bh) {
734 err = -EIO;
735 goto cleanup;
736 }
737 lock_buffer(bh);
738
739 if ((err = ext4_journal_get_create_access(handle, bh)))
740 goto cleanup;
741
742 neh = ext_block_hdr(bh);
743 neh->eh_entries = cpu_to_le16(1);
744 neh->eh_magic = EXT4_EXT_MAGIC;
745 neh->eh_max = cpu_to_le16(ext4_ext_space_block_idx(inode));
746 neh->eh_depth = cpu_to_le16(depth - i);
747 fidx = EXT_FIRST_INDEX(neh);
748 fidx->ei_block = border;
749 ext4_idx_store_pblock(fidx, oldblock);
750
751 ext_debug("int.index at %d (block %llu): %lu -> %llu\n", i,
752 newblock, (unsigned long) le32_to_cpu(border),
753 oldblock);
754 /* copy indexes */
755 m = 0;
756 path[i].p_idx++;
757
758 ext_debug("cur 0x%p, last 0x%p\n", path[i].p_idx,
759 EXT_MAX_INDEX(path[i].p_hdr));
760 BUG_ON(EXT_MAX_INDEX(path[i].p_hdr) !=
761 EXT_LAST_INDEX(path[i].p_hdr));
762 while (path[i].p_idx <= EXT_MAX_INDEX(path[i].p_hdr)) {
763 ext_debug("%d: move %d:%d in new index %llu\n", i,
764 le32_to_cpu(path[i].p_idx->ei_block),
765 idx_pblock(path[i].p_idx),
766 newblock);
767 /*memmove(++fidx, path[i].p_idx++,
768 sizeof(struct ext4_extent_idx));
769 neh->eh_entries++;
770 BUG_ON(neh->eh_entries > neh->eh_max);*/
771 path[i].p_idx++;
772 m++;
773 }
774 if (m) {
775 memmove(++fidx, path[i].p_idx - m,
776 sizeof(struct ext4_extent_idx) * m);
777 neh->eh_entries =
778 cpu_to_le16(le16_to_cpu(neh->eh_entries) + m);
779 }
780 set_buffer_uptodate(bh);
781 unlock_buffer(bh);
782
783 if ((err = ext4_journal_dirty_metadata(handle, bh)))
784 goto cleanup;
785 brelse(bh);
786 bh = NULL;
787
788 /* correct old index */
789 if (m) {
790 err = ext4_ext_get_access(handle, inode, path + i);
791 if (err)
792 goto cleanup;
793 path[i].p_hdr->eh_entries = cpu_to_le16(le16_to_cpu(path[i].p_hdr->eh_entries)-m);
794 err = ext4_ext_dirty(handle, inode, path + i);
795 if (err)
796 goto cleanup;
797 }
798
799 i--;
800 }
801
802 /* insert new index */
803 if (err)
804 goto cleanup;
805
806 err = ext4_ext_insert_index(handle, inode, path + at,
807 le32_to_cpu(border), newblock);
808
809cleanup:
810 if (bh) {
811 if (buffer_locked(bh))
812 unlock_buffer(bh);
813 brelse(bh);
814 }
815
816 if (err) {
817 /* free all allocated blocks in error case */
818 for (i = 0; i < depth; i++) {
819 if (!ablocks[i])
820 continue;
821 ext4_free_blocks(handle, inode, ablocks[i], 1);
822 }
823 }
824 kfree(ablocks);
825
826 return err;
827}
828
829/*
830 * ext4_ext_grow_indepth:
831 * implements tree growing procedure:
832 * - allocates new block
833 * - moves top-level data (index block or leaf) into the new block
834 * - initializes new top-level, creating index that points to the
835 * just created block
836 */
837static int ext4_ext_grow_indepth(handle_t *handle, struct inode *inode,
838 struct ext4_ext_path *path,
839 struct ext4_extent *newext)
840{
841 struct ext4_ext_path *curp = path;
842 struct ext4_extent_header *neh;
843 struct ext4_extent_idx *fidx;
844 struct buffer_head *bh;
845 ext4_fsblk_t newblock;
846 int err = 0;
847
848 newblock = ext4_ext_new_block(handle, inode, path, newext, &err);
849 if (newblock == 0)
850 return err;
851
852 bh = sb_getblk(inode->i_sb, newblock);
853 if (!bh) {
854 err = -EIO;
855 ext4_std_error(inode->i_sb, err);
856 return err;
857 }
858 lock_buffer(bh);
859
860 if ((err = ext4_journal_get_create_access(handle, bh))) {
861 unlock_buffer(bh);
862 goto out;
863 }
864
865 /* move top-level index/leaf into new block */
866 memmove(bh->b_data, curp->p_hdr, sizeof(EXT4_I(inode)->i_data));
867
868 /* set size of new block */
869 neh = ext_block_hdr(bh);
870 /* old root could have indexes or leaves
871 * so calculate e_max right way */
872 if (ext_depth(inode))
873 neh->eh_max = cpu_to_le16(ext4_ext_space_block_idx(inode));
874 else
875 neh->eh_max = cpu_to_le16(ext4_ext_space_block(inode));
876 neh->eh_magic = EXT4_EXT_MAGIC;
877 set_buffer_uptodate(bh);
878 unlock_buffer(bh);
879
880 if ((err = ext4_journal_dirty_metadata(handle, bh)))
881 goto out;
882
883 /* create index in new top-level index: num,max,pointer */
884 if ((err = ext4_ext_get_access(handle, inode, curp)))
885 goto out;
886
887 curp->p_hdr->eh_magic = EXT4_EXT_MAGIC;
888 curp->p_hdr->eh_max = cpu_to_le16(ext4_ext_space_root_idx(inode));
889 curp->p_hdr->eh_entries = cpu_to_le16(1);
890 curp->p_idx = EXT_FIRST_INDEX(curp->p_hdr);
891 /* FIXME: it works, but actually path[0] can be index */
892 curp->p_idx->ei_block = EXT_FIRST_EXTENT(path[0].p_hdr)->ee_block;
893 ext4_idx_store_pblock(curp->p_idx, newblock);
894
895 neh = ext_inode_hdr(inode);
896 fidx = EXT_FIRST_INDEX(neh);
897 ext_debug("new root: num %d(%d), lblock %d, ptr %llu\n",
898 le16_to_cpu(neh->eh_entries), le16_to_cpu(neh->eh_max),
899 le32_to_cpu(fidx->ei_block), idx_pblock(fidx));
900
901 neh->eh_depth = cpu_to_le16(path->p_depth + 1);
902 err = ext4_ext_dirty(handle, inode, curp);
903out:
904 brelse(bh);
905
906 return err;
907}
908
909/*
910 * ext4_ext_create_new_leaf:
911 * finds empty index and adds new leaf.
912 * if no free index is found, then it requests in-depth growing.
913 */
914static int ext4_ext_create_new_leaf(handle_t *handle, struct inode *inode,
915 struct ext4_ext_path *path,
916 struct ext4_extent *newext)
917{
918 struct ext4_ext_path *curp;
919 int depth, i, err = 0;
920
921repeat:
922 i = depth = ext_depth(inode);
923
924 /* walk up to the tree and look for free index entry */
925 curp = path + depth;
926 while (i > 0 && !EXT_HAS_FREE_INDEX(curp)) {
927 i--;
928 curp--;
929 }
930
931 /* we use already allocated block for index block,
932 * so subsequent data blocks should be contiguous */
933 if (EXT_HAS_FREE_INDEX(curp)) {
934 /* if we found index with free entry, then use that
935 * entry: create all needed subtree and add new leaf */
936 err = ext4_ext_split(handle, inode, path, newext, i);
937
938 /* refill path */
939 ext4_ext_drop_refs(path);
940 path = ext4_ext_find_extent(inode,
941 le32_to_cpu(newext->ee_block),
942 path);
943 if (IS_ERR(path))
944 err = PTR_ERR(path);
945 } else {
946 /* tree is full, time to grow in depth */
947 err = ext4_ext_grow_indepth(handle, inode, path, newext);
948 if (err)
949 goto out;
950
951 /* refill path */
952 ext4_ext_drop_refs(path);
953 path = ext4_ext_find_extent(inode,
954 le32_to_cpu(newext->ee_block),
955 path);
956 if (IS_ERR(path)) {
957 err = PTR_ERR(path);
958 goto out;
959 }
960
961 /*
962 * only first (depth 0 -> 1) produces free space;
963 * in all other cases we have to split the grown tree
964 */
965 depth = ext_depth(inode);
966 if (path[depth].p_hdr->eh_entries == path[depth].p_hdr->eh_max) {
967 /* now we need to split */
968 goto repeat;
969 }
970 }
971
972out:
973 return err;
974}
975
976/*
977 * ext4_ext_next_allocated_block:
978 * returns allocated block in subsequent extent or EXT_MAX_BLOCK.
979 * NOTE: it considers block number from index entry as
980 * allocated block. Thus, index entries have to be consistent
981 * with leaves.
982 */
983static unsigned long
984ext4_ext_next_allocated_block(struct ext4_ext_path *path)
985{
986 int depth;
987
988 BUG_ON(path == NULL);
989 depth = path->p_depth;
990
991 if (depth == 0 && path->p_ext == NULL)
992 return EXT_MAX_BLOCK;
993
994 while (depth >= 0) {
995 if (depth == path->p_depth) {
996 /* leaf */
997 if (path[depth].p_ext !=
998 EXT_LAST_EXTENT(path[depth].p_hdr))
999 return le32_to_cpu(path[depth].p_ext[1].ee_block);
1000 } else {
1001 /* index */
1002 if (path[depth].p_idx !=
1003 EXT_LAST_INDEX(path[depth].p_hdr))
1004 return le32_to_cpu(path[depth].p_idx[1].ei_block);
1005 }
1006 depth--;
1007 }
1008
1009 return EXT_MAX_BLOCK;
1010}
1011
1012/*
1013 * ext4_ext_next_leaf_block:
1014 * returns first allocated block from next leaf or EXT_MAX_BLOCK
1015 */
1016static unsigned ext4_ext_next_leaf_block(struct inode *inode,
1017 struct ext4_ext_path *path)
1018{
1019 int depth;
1020
1021 BUG_ON(path == NULL);
1022 depth = path->p_depth;
1023
1024 /* zero-tree has no leaf blocks at all */
1025 if (depth == 0)
1026 return EXT_MAX_BLOCK;
1027
1028 /* go to index block */
1029 depth--;
1030
1031 while (depth >= 0) {
1032 if (path[depth].p_idx !=
1033 EXT_LAST_INDEX(path[depth].p_hdr))
1034 return le32_to_cpu(path[depth].p_idx[1].ei_block);
1035 depth--;
1036 }
1037
1038 return EXT_MAX_BLOCK;
1039}
1040
1041/*
1042 * ext4_ext_correct_indexes:
1043 * if leaf gets modified and modified extent is first in the leaf,
1044 * then we have to correct all indexes above.
1045 * TODO: do we need to correct tree in all cases?
1046 */
1047int ext4_ext_correct_indexes(handle_t *handle, struct inode *inode,
1048 struct ext4_ext_path *path)
1049{
1050 struct ext4_extent_header *eh;
1051 int depth = ext_depth(inode);
1052 struct ext4_extent *ex;
1053 __le32 border;
1054 int k, err = 0;
1055
1056 eh = path[depth].p_hdr;
1057 ex = path[depth].p_ext;
1058 BUG_ON(ex == NULL);
1059 BUG_ON(eh == NULL);
1060
1061 if (depth == 0) {
1062 /* there is no tree at all */
1063 return 0;
1064 }
1065
1066 if (ex != EXT_FIRST_EXTENT(eh)) {
1067 /* we correct tree if first leaf got modified only */
1068 return 0;
1069 }
1070
1071 /*
1072 * TODO: we need correction if border is smaller than current one
1073 */
1074 k = depth - 1;
1075 border = path[depth].p_ext->ee_block;
1076 if ((err = ext4_ext_get_access(handle, inode, path + k)))
1077 return err;
1078 path[k].p_idx->ei_block = border;
1079 if ((err = ext4_ext_dirty(handle, inode, path + k)))
1080 return err;
1081
1082 while (k--) {
1083 /* change all left-side indexes */
1084 if (path[k+1].p_idx != EXT_FIRST_INDEX(path[k+1].p_hdr))
1085 break;
1086 if ((err = ext4_ext_get_access(handle, inode, path + k)))
1087 break;
1088 path[k].p_idx->ei_block = border;
1089 if ((err = ext4_ext_dirty(handle, inode, path + k)))
1090 break;
1091 }
1092
1093 return err;
1094}
1095
1096static int inline
1097ext4_can_extents_be_merged(struct inode *inode, struct ext4_extent *ex1,
1098 struct ext4_extent *ex2)
1099{
1100 if (le32_to_cpu(ex1->ee_block) + le16_to_cpu(ex1->ee_len) !=
1101 le32_to_cpu(ex2->ee_block))
1102 return 0;
1103
1104 /*
1105 * To allow future support for preallocated extents to be added
1106 * as an RO_COMPAT feature, refuse to merge to extents if
1107 * this can result in the top bit of ee_len being set.
1108 */
1109 if (le16_to_cpu(ex1->ee_len) + le16_to_cpu(ex2->ee_len) > EXT_MAX_LEN)
1110 return 0;
1111#ifdef AGRESSIVE_TEST
1112 if (le16_to_cpu(ex1->ee_len) >= 4)
1113 return 0;
1114#endif
1115
1116 if (ext_pblock(ex1) + le16_to_cpu(ex1->ee_len) == ext_pblock(ex2))
1117 return 1;
1118 return 0;
1119}
1120
1121/*
1122 * ext4_ext_insert_extent:
1123 * tries to merge requsted extent into the existing extent or
1124 * inserts requested extent as new one into the tree,
1125 * creating new leaf in the no-space case.
1126 */
1127int ext4_ext_insert_extent(handle_t *handle, struct inode *inode,
1128 struct ext4_ext_path *path,
1129 struct ext4_extent *newext)
1130{
1131 struct ext4_extent_header * eh;
1132 struct ext4_extent *ex, *fex;
1133 struct ext4_extent *nearex; /* nearest extent */
1134 struct ext4_ext_path *npath = NULL;
1135 int depth, len, err, next;
1136
1137 BUG_ON(newext->ee_len == 0);
1138 depth = ext_depth(inode);
1139 ex = path[depth].p_ext;
1140 BUG_ON(path[depth].p_hdr == NULL);
1141
1142 /* try to insert block into found extent and return */
1143 if (ex && ext4_can_extents_be_merged(inode, ex, newext)) {
1144 ext_debug("append %d block to %d:%d (from %llu)\n",
1145 le16_to_cpu(newext->ee_len),
1146 le32_to_cpu(ex->ee_block),
1147 le16_to_cpu(ex->ee_len), ext_pblock(ex));
1148 if ((err = ext4_ext_get_access(handle, inode, path + depth)))
1149 return err;
1150 ex->ee_len = cpu_to_le16(le16_to_cpu(ex->ee_len)
1151 + le16_to_cpu(newext->ee_len));
1152 eh = path[depth].p_hdr;
1153 nearex = ex;
1154 goto merge;
1155 }
1156
1157repeat:
1158 depth = ext_depth(inode);
1159 eh = path[depth].p_hdr;
1160 if (le16_to_cpu(eh->eh_entries) < le16_to_cpu(eh->eh_max))
1161 goto has_space;
1162
1163 /* probably next leaf has space for us? */
1164 fex = EXT_LAST_EXTENT(eh);
1165 next = ext4_ext_next_leaf_block(inode, path);
1166 if (le32_to_cpu(newext->ee_block) > le32_to_cpu(fex->ee_block)
1167 && next != EXT_MAX_BLOCK) {
1168 ext_debug("next leaf block - %d\n", next);
1169 BUG_ON(npath != NULL);
1170 npath = ext4_ext_find_extent(inode, next, NULL);
1171 if (IS_ERR(npath))
1172 return PTR_ERR(npath);
1173 BUG_ON(npath->p_depth != path->p_depth);
1174 eh = npath[depth].p_hdr;
1175 if (le16_to_cpu(eh->eh_entries) < le16_to_cpu(eh->eh_max)) {
1176 ext_debug("next leaf isnt full(%d)\n",
1177 le16_to_cpu(eh->eh_entries));
1178 path = npath;
1179 goto repeat;
1180 }
1181 ext_debug("next leaf has no free space(%d,%d)\n",
1182 le16_to_cpu(eh->eh_entries), le16_to_cpu(eh->eh_max));
1183 }
1184
1185 /*
1186 * There is no free space in the found leaf.
1187 * We're gonna add a new leaf in the tree.
1188 */
1189 err = ext4_ext_create_new_leaf(handle, inode, path, newext);
1190 if (err)
1191 goto cleanup;
1192 depth = ext_depth(inode);
1193 eh = path[depth].p_hdr;
1194
1195has_space:
1196 nearex = path[depth].p_ext;
1197
1198 if ((err = ext4_ext_get_access(handle, inode, path + depth)))
1199 goto cleanup;
1200
1201 if (!nearex) {
1202 /* there is no extent in this leaf, create first one */
1203 ext_debug("first extent in the leaf: %d:%llu:%d\n",
1204 le32_to_cpu(newext->ee_block),
1205 ext_pblock(newext),
1206 le16_to_cpu(newext->ee_len));
1207 path[depth].p_ext = EXT_FIRST_EXTENT(eh);
1208 } else if (le32_to_cpu(newext->ee_block)
1209 > le32_to_cpu(nearex->ee_block)) {
1210/* BUG_ON(newext->ee_block == nearex->ee_block); */
1211 if (nearex != EXT_LAST_EXTENT(eh)) {
1212 len = EXT_MAX_EXTENT(eh) - nearex;
1213 len = (len - 1) * sizeof(struct ext4_extent);
1214 len = len < 0 ? 0 : len;
1215 ext_debug("insert %d:%llu:%d after: nearest 0x%p, "
1216 "move %d from 0x%p to 0x%p\n",
1217 le32_to_cpu(newext->ee_block),
1218 ext_pblock(newext),
1219 le16_to_cpu(newext->ee_len),
1220 nearex, len, nearex + 1, nearex + 2);
1221 memmove(nearex + 2, nearex + 1, len);
1222 }
1223 path[depth].p_ext = nearex + 1;
1224 } else {
1225 BUG_ON(newext->ee_block == nearex->ee_block);
1226 len = (EXT_MAX_EXTENT(eh) - nearex) * sizeof(struct ext4_extent);
1227 len = len < 0 ? 0 : len;
1228 ext_debug("insert %d:%llu:%d before: nearest 0x%p, "
1229 "move %d from 0x%p to 0x%p\n",
1230 le32_to_cpu(newext->ee_block),
1231 ext_pblock(newext),
1232 le16_to_cpu(newext->ee_len),
1233 nearex, len, nearex + 1, nearex + 2);
1234 memmove(nearex + 1, nearex, len);
1235 path[depth].p_ext = nearex;
1236 }
1237
1238 eh->eh_entries = cpu_to_le16(le16_to_cpu(eh->eh_entries)+1);
1239 nearex = path[depth].p_ext;
1240 nearex->ee_block = newext->ee_block;
1241 nearex->ee_start = newext->ee_start;
1242 nearex->ee_start_hi = newext->ee_start_hi;
1243 nearex->ee_len = newext->ee_len;
1244
1245merge:
1246 /* try to merge extents to the right */
1247 while (nearex < EXT_LAST_EXTENT(eh)) {
1248 if (!ext4_can_extents_be_merged(inode, nearex, nearex + 1))
1249 break;
1250 /* merge with next extent! */
1251 nearex->ee_len = cpu_to_le16(le16_to_cpu(nearex->ee_len)
1252 + le16_to_cpu(nearex[1].ee_len));
1253 if (nearex + 1 < EXT_LAST_EXTENT(eh)) {
1254 len = (EXT_LAST_EXTENT(eh) - nearex - 1)
1255 * sizeof(struct ext4_extent);
1256 memmove(nearex + 1, nearex + 2, len);
1257 }
1258 eh->eh_entries = cpu_to_le16(le16_to_cpu(eh->eh_entries)-1);
1259 BUG_ON(eh->eh_entries == 0);
1260 }
1261
1262 /* try to merge extents to the left */
1263
1264 /* time to correct all indexes above */
1265 err = ext4_ext_correct_indexes(handle, inode, path);
1266 if (err)
1267 goto cleanup;
1268
1269 err = ext4_ext_dirty(handle, inode, path + depth);
1270
1271cleanup:
1272 if (npath) {
1273 ext4_ext_drop_refs(npath);
1274 kfree(npath);
1275 }
1276 ext4_ext_tree_changed(inode);
1277 ext4_ext_invalidate_cache(inode);
1278 return err;
1279}
1280
1281int ext4_ext_walk_space(struct inode *inode, unsigned long block,
1282 unsigned long num, ext_prepare_callback func,
1283 void *cbdata)
1284{
1285 struct ext4_ext_path *path = NULL;
1286 struct ext4_ext_cache cbex;
1287 struct ext4_extent *ex;
1288 unsigned long next, start = 0, end = 0;
1289 unsigned long last = block + num;
1290 int depth, exists, err = 0;
1291
1292 BUG_ON(func == NULL);
1293 BUG_ON(inode == NULL);
1294
1295 while (block < last && block != EXT_MAX_BLOCK) {
1296 num = last - block;
1297 /* find extent for this block */
1298 path = ext4_ext_find_extent(inode, block, path);
1299 if (IS_ERR(path)) {
1300 err = PTR_ERR(path);
1301 path = NULL;
1302 break;
1303 }
1304
1305 depth = ext_depth(inode);
1306 BUG_ON(path[depth].p_hdr == NULL);
1307 ex = path[depth].p_ext;
1308 next = ext4_ext_next_allocated_block(path);
1309
1310 exists = 0;
1311 if (!ex) {
1312 /* there is no extent yet, so try to allocate
1313 * all requested space */
1314 start = block;
1315 end = block + num;
1316 } else if (le32_to_cpu(ex->ee_block) > block) {
1317 /* need to allocate space before found extent */
1318 start = block;
1319 end = le32_to_cpu(ex->ee_block);
1320 if (block + num < end)
1321 end = block + num;
1322 } else if (block >=
1323 le32_to_cpu(ex->ee_block) + le16_to_cpu(ex->ee_len)) {
1324 /* need to allocate space after found extent */
1325 start = block;
1326 end = block + num;
1327 if (end >= next)
1328 end = next;
1329 } else if (block >= le32_to_cpu(ex->ee_block)) {
1330 /*
1331 * some part of requested space is covered
1332 * by found extent
1333 */
1334 start = block;
1335 end = le32_to_cpu(ex->ee_block) + le16_to_cpu(ex->ee_len);
1336 if (block + num < end)
1337 end = block + num;
1338 exists = 1;
1339 } else {
1340 BUG();
1341 }
1342 BUG_ON(end <= start);
1343
1344 if (!exists) {
1345 cbex.ec_block = start;
1346 cbex.ec_len = end - start;
1347 cbex.ec_start = 0;
1348 cbex.ec_type = EXT4_EXT_CACHE_GAP;
1349 } else {
1350 cbex.ec_block = le32_to_cpu(ex->ee_block);
1351 cbex.ec_len = le16_to_cpu(ex->ee_len);
1352 cbex.ec_start = ext_pblock(ex);
1353 cbex.ec_type = EXT4_EXT_CACHE_EXTENT;
1354 }
1355
1356 BUG_ON(cbex.ec_len == 0);
1357 err = func(inode, path, &cbex, cbdata);
1358 ext4_ext_drop_refs(path);
1359
1360 if (err < 0)
1361 break;
1362 if (err == EXT_REPEAT)
1363 continue;
1364 else if (err == EXT_BREAK) {
1365 err = 0;
1366 break;
1367 }
1368
1369 if (ext_depth(inode) != depth) {
1370 /* depth was changed. we have to realloc path */
1371 kfree(path);
1372 path = NULL;
1373 }
1374
1375 block = cbex.ec_block + cbex.ec_len;
1376 }
1377
1378 if (path) {
1379 ext4_ext_drop_refs(path);
1380 kfree(path);
1381 }
1382
1383 return err;
1384}
1385
1386static inline void
1387ext4_ext_put_in_cache(struct inode *inode, __u32 block,
1388 __u32 len, __u32 start, int type)
1389{
1390 struct ext4_ext_cache *cex;
1391 BUG_ON(len == 0);
1392 cex = &EXT4_I(inode)->i_cached_extent;
1393 cex->ec_type = type;
1394 cex->ec_block = block;
1395 cex->ec_len = len;
1396 cex->ec_start = start;
1397}
1398
1399/*
1400 * ext4_ext_put_gap_in_cache:
1401 * calculate boundaries of the gap that the requested block fits into
1402 * and cache this gap
1403 */
1404static inline void
1405ext4_ext_put_gap_in_cache(struct inode *inode, struct ext4_ext_path *path,
1406 unsigned long block)
1407{
1408 int depth = ext_depth(inode);
1409 unsigned long lblock, len;
1410 struct ext4_extent *ex;
1411
1412 ex = path[depth].p_ext;
1413 if (ex == NULL) {
1414 /* there is no extent yet, so gap is [0;-] */
1415 lblock = 0;
1416 len = EXT_MAX_BLOCK;
1417 ext_debug("cache gap(whole file):");
1418 } else if (block < le32_to_cpu(ex->ee_block)) {
1419 lblock = block;
1420 len = le32_to_cpu(ex->ee_block) - block;
1421 ext_debug("cache gap(before): %lu [%lu:%lu]",
1422 (unsigned long) block,
1423 (unsigned long) le32_to_cpu(ex->ee_block),
1424 (unsigned long) le16_to_cpu(ex->ee_len));
1425 } else if (block >= le32_to_cpu(ex->ee_block)
1426 + le16_to_cpu(ex->ee_len)) {
1427 lblock = le32_to_cpu(ex->ee_block)
1428 + le16_to_cpu(ex->ee_len);
1429 len = ext4_ext_next_allocated_block(path);
1430 ext_debug("cache gap(after): [%lu:%lu] %lu",
1431 (unsigned long) le32_to_cpu(ex->ee_block),
1432 (unsigned long) le16_to_cpu(ex->ee_len),
1433 (unsigned long) block);
1434 BUG_ON(len == lblock);
1435 len = len - lblock;
1436 } else {
1437 lblock = len = 0;
1438 BUG();
1439 }
1440
1441 ext_debug(" -> %lu:%lu\n", (unsigned long) lblock, len);
1442 ext4_ext_put_in_cache(inode, lblock, len, 0, EXT4_EXT_CACHE_GAP);
1443}
1444
1445static inline int
1446ext4_ext_in_cache(struct inode *inode, unsigned long block,
1447 struct ext4_extent *ex)
1448{
1449 struct ext4_ext_cache *cex;
1450
1451 cex = &EXT4_I(inode)->i_cached_extent;
1452
1453 /* has cache valid data? */
1454 if (cex->ec_type == EXT4_EXT_CACHE_NO)
1455 return EXT4_EXT_CACHE_NO;
1456
1457 BUG_ON(cex->ec_type != EXT4_EXT_CACHE_GAP &&
1458 cex->ec_type != EXT4_EXT_CACHE_EXTENT);
1459 if (block >= cex->ec_block && block < cex->ec_block + cex->ec_len) {
1460 ex->ee_block = cpu_to_le32(cex->ec_block);
1461 ext4_ext_store_pblock(ex, cex->ec_start);
1462 ex->ee_len = cpu_to_le16(cex->ec_len);
1463 ext_debug("%lu cached by %lu:%lu:%llu\n",
1464 (unsigned long) block,
1465 (unsigned long) cex->ec_block,
1466 (unsigned long) cex->ec_len,
1467 cex->ec_start);
1468 return cex->ec_type;
1469 }
1470
1471 /* not in cache */
1472 return EXT4_EXT_CACHE_NO;
1473}
1474
1475/*
1476 * ext4_ext_rm_idx:
1477 * removes index from the index block.
1478 * It's used in truncate case only, thus all requests are for
1479 * last index in the block only.
1480 */
1481int ext4_ext_rm_idx(handle_t *handle, struct inode *inode,
1482 struct ext4_ext_path *path)
1483{
1484 struct buffer_head *bh;
1485 int err;
1486 ext4_fsblk_t leaf;
1487
1488 /* free index block */
1489 path--;
1490 leaf = idx_pblock(path->p_idx);
1491 BUG_ON(path->p_hdr->eh_entries == 0);
1492 if ((err = ext4_ext_get_access(handle, inode, path)))
1493 return err;
1494 path->p_hdr->eh_entries = cpu_to_le16(le16_to_cpu(path->p_hdr->eh_entries)-1);
1495 if ((err = ext4_ext_dirty(handle, inode, path)))
1496 return err;
1497 ext_debug("index is empty, remove it, free block %llu\n", leaf);
1498 bh = sb_find_get_block(inode->i_sb, leaf);
1499 ext4_forget(handle, 1, inode, bh, leaf);
1500 ext4_free_blocks(handle, inode, leaf, 1);
1501 return err;
1502}
1503
1504/*
1505 * ext4_ext_calc_credits_for_insert:
1506 * This routine returns max. credits that the extent tree can consume.
1507 * It should be OK for low-performance paths like ->writepage()
1508 * To allow many writing processes to fit into a single transaction,
1509 * the caller should calculate credits under truncate_mutex and
1510 * pass the actual path.
1511 */
1512int inline ext4_ext_calc_credits_for_insert(struct inode *inode,
1513 struct ext4_ext_path *path)
1514{
1515 int depth, needed;
1516
1517 if (path) {
1518 /* probably there is space in leaf? */
1519 depth = ext_depth(inode);
1520 if (le16_to_cpu(path[depth].p_hdr->eh_entries)
1521 < le16_to_cpu(path[depth].p_hdr->eh_max))
1522 return 1;
1523 }
1524
1525 /*
1526 * given 32-bit logical block (4294967296 blocks), max. tree
1527 * can be 4 levels in depth -- 4 * 340^4 == 53453440000.
1528 * Let's also add one more level for imbalance.
1529 */
1530 depth = 5;
1531
1532 /* allocation of new data block(s) */
1533 needed = 2;
1534
1535 /*
1536 * tree can be full, so it would need to grow in depth:
1537 * allocation + old root + new root
1538 */
1539 needed += 2 + 1 + 1;
1540
1541 /*
1542 * Index split can happen, we would need:
1543 * allocate intermediate indexes (bitmap + group)
1544 * + change two blocks at each level, but root (already included)
1545 */
1546 needed = (depth * 2) + (depth * 2);
1547
1548 /* any allocation modifies superblock */
1549 needed += 1;
1550
1551 return needed;
1552}
1553
1554static int ext4_remove_blocks(handle_t *handle, struct inode *inode,
1555 struct ext4_extent *ex,
1556 unsigned long from, unsigned long to)
1557{
1558 struct buffer_head *bh;
1559 int i;
1560
1561#ifdef EXTENTS_STATS
1562 {
1563 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
1564 unsigned short ee_len = le16_to_cpu(ex->ee_len);
1565 spin_lock(&sbi->s_ext_stats_lock);
1566 sbi->s_ext_blocks += ee_len;
1567 sbi->s_ext_extents++;
1568 if (ee_len < sbi->s_ext_min)
1569 sbi->s_ext_min = ee_len;
1570 if (ee_len > sbi->s_ext_max)
1571 sbi->s_ext_max = ee_len;
1572 if (ext_depth(inode) > sbi->s_depth_max)
1573 sbi->s_depth_max = ext_depth(inode);
1574 spin_unlock(&sbi->s_ext_stats_lock);
1575 }
1576#endif
1577 if (from >= le32_to_cpu(ex->ee_block)
1578 && to == le32_to_cpu(ex->ee_block) + le16_to_cpu(ex->ee_len) - 1) {
1579 /* tail removal */
1580 unsigned long num;
1581 ext4_fsblk_t start;
1582 num = le32_to_cpu(ex->ee_block) + le16_to_cpu(ex->ee_len) - from;
1583 start = ext_pblock(ex) + le16_to_cpu(ex->ee_len) - num;
1584 ext_debug("free last %lu blocks starting %llu\n", num, start);
1585 for (i = 0; i < num; i++) {
1586 bh = sb_find_get_block(inode->i_sb, start + i);
1587 ext4_forget(handle, 0, inode, bh, start + i);
1588 }
1589 ext4_free_blocks(handle, inode, start, num);
1590 } else if (from == le32_to_cpu(ex->ee_block)
1591 && to <= le32_to_cpu(ex->ee_block) + le16_to_cpu(ex->ee_len) - 1) {
1592 printk("strange request: removal %lu-%lu from %u:%u\n",
1593 from, to, le32_to_cpu(ex->ee_block), le16_to_cpu(ex->ee_len));
1594 } else {
1595 printk("strange request: removal(2) %lu-%lu from %u:%u\n",
1596 from, to, le32_to_cpu(ex->ee_block), le16_to_cpu(ex->ee_len));
1597 }
1598 return 0;
1599}
1600
1601static int
1602ext4_ext_rm_leaf(handle_t *handle, struct inode *inode,
1603 struct ext4_ext_path *path, unsigned long start)
1604{
1605 int err = 0, correct_index = 0;
1606 int depth = ext_depth(inode), credits;
1607 struct ext4_extent_header *eh;
1608 unsigned a, b, block, num;
1609 unsigned long ex_ee_block;
1610 unsigned short ex_ee_len;
1611 struct ext4_extent *ex;
1612
1613 ext_debug("truncate since %lu in leaf\n", start);
1614 if (!path[depth].p_hdr)
1615 path[depth].p_hdr = ext_block_hdr(path[depth].p_bh);
1616 eh = path[depth].p_hdr;
1617 BUG_ON(eh == NULL);
1618 BUG_ON(le16_to_cpu(eh->eh_entries) > le16_to_cpu(eh->eh_max));
1619 BUG_ON(eh->eh_magic != EXT4_EXT_MAGIC);
1620
1621 /* find where to start removing */
1622 ex = EXT_LAST_EXTENT(eh);
1623
1624 ex_ee_block = le32_to_cpu(ex->ee_block);
1625 ex_ee_len = le16_to_cpu(ex->ee_len);
1626
1627 while (ex >= EXT_FIRST_EXTENT(eh) &&
1628 ex_ee_block + ex_ee_len > start) {
1629 ext_debug("remove ext %lu:%u\n", ex_ee_block, ex_ee_len);
1630 path[depth].p_ext = ex;
1631
1632 a = ex_ee_block > start ? ex_ee_block : start;
1633 b = ex_ee_block + ex_ee_len - 1 < EXT_MAX_BLOCK ?
1634 ex_ee_block + ex_ee_len - 1 : EXT_MAX_BLOCK;
1635
1636 ext_debug(" border %u:%u\n", a, b);
1637
1638 if (a != ex_ee_block && b != ex_ee_block + ex_ee_len - 1) {
1639 block = 0;
1640 num = 0;
1641 BUG();
1642 } else if (a != ex_ee_block) {
1643 /* remove tail of the extent */
1644 block = ex_ee_block;
1645 num = a - block;
1646 } else if (b != ex_ee_block + ex_ee_len - 1) {
1647 /* remove head of the extent */
1648 block = a;
1649 num = b - a;
1650 /* there is no "make a hole" API yet */
1651 BUG();
1652 } else {
1653 /* remove whole extent: excellent! */
1654 block = ex_ee_block;
1655 num = 0;
1656 BUG_ON(a != ex_ee_block);
1657 BUG_ON(b != ex_ee_block + ex_ee_len - 1);
1658 }
1659
1660 /* at present, extent can't cross block group: */
1661 /* leaf + bitmap + group desc + sb + inode */
1662 credits = 5;
1663 if (ex == EXT_FIRST_EXTENT(eh)) {
1664 correct_index = 1;
1665 credits += (ext_depth(inode)) + 1;
1666 }
1667#ifdef CONFIG_QUOTA
1668 credits += 2 * EXT4_QUOTA_TRANS_BLOCKS(inode->i_sb);
1669#endif
1670
1671 handle = ext4_ext_journal_restart(handle, credits);
1672 if (IS_ERR(handle)) {
1673 err = PTR_ERR(handle);
1674 goto out;
1675 }
1676
1677 err = ext4_ext_get_access(handle, inode, path + depth);
1678 if (err)
1679 goto out;
1680
1681 err = ext4_remove_blocks(handle, inode, ex, a, b);
1682 if (err)
1683 goto out;
1684
1685 if (num == 0) {
1686 /* this extent is removed; mark slot entirely unused */
1687 ext4_ext_store_pblock(ex, 0);
1688 eh->eh_entries = cpu_to_le16(le16_to_cpu(eh->eh_entries)-1);
1689 }
1690
1691 ex->ee_block = cpu_to_le32(block);
1692 ex->ee_len = cpu_to_le16(num);
1693
1694 err = ext4_ext_dirty(handle, inode, path + depth);
1695 if (err)
1696 goto out;
1697
1698 ext_debug("new extent: %u:%u:%llu\n", block, num,
1699 ext_pblock(ex));
1700 ex--;
1701 ex_ee_block = le32_to_cpu(ex->ee_block);
1702 ex_ee_len = le16_to_cpu(ex->ee_len);
1703 }
1704
1705 if (correct_index && eh->eh_entries)
1706 err = ext4_ext_correct_indexes(handle, inode, path);
1707
1708 /* if this leaf is free, then we should
1709 * remove it from index block above */
1710 if (err == 0 && eh->eh_entries == 0 && path[depth].p_bh != NULL)
1711 err = ext4_ext_rm_idx(handle, inode, path + depth);
1712
1713out:
1714 return err;
1715}
1716
1717/*
1718 * ext4_ext_more_to_rm:
1719 * returns 1 if current index has to be freed (even partial)
1720 */
1721static int inline
1722ext4_ext_more_to_rm(struct ext4_ext_path *path)
1723{
1724 BUG_ON(path->p_idx == NULL);
1725
1726 if (path->p_idx < EXT_FIRST_INDEX(path->p_hdr))
1727 return 0;
1728
1729 /*
1730 * if truncate on deeper level happened, it wasn't partial,
1731 * so we have to consider current index for truncation
1732 */
1733 if (le16_to_cpu(path->p_hdr->eh_entries) == path->p_block)
1734 return 0;
1735 return 1;
1736}
1737
1738int ext4_ext_remove_space(struct inode *inode, unsigned long start)
1739{
1740 struct super_block *sb = inode->i_sb;
1741 int depth = ext_depth(inode);
1742 struct ext4_ext_path *path;
1743 handle_t *handle;
1744 int i = 0, err = 0;
1745
1746 ext_debug("truncate since %lu\n", start);
1747
1748 /* probably first extent we're gonna free will be last in block */
1749 handle = ext4_journal_start(inode, depth + 1);
1750 if (IS_ERR(handle))
1751 return PTR_ERR(handle);
1752
1753 ext4_ext_invalidate_cache(inode);
1754
1755 /*
1756 * We start scanning from right side, freeing all the blocks
1757 * after i_size and walking into the tree depth-wise.
1758 */
1759 path = kmalloc(sizeof(struct ext4_ext_path) * (depth + 1), GFP_KERNEL);
1760 if (path == NULL) {
1761 ext4_journal_stop(handle);
1762 return -ENOMEM;
1763 }
1764 memset(path, 0, sizeof(struct ext4_ext_path) * (depth + 1));
1765 path[0].p_hdr = ext_inode_hdr(inode);
1766 if (ext4_ext_check_header(__FUNCTION__, inode, path[0].p_hdr)) {
1767 err = -EIO;
1768 goto out;
1769 }
1770 path[0].p_depth = depth;
1771
1772 while (i >= 0 && err == 0) {
1773 if (i == depth) {
1774 /* this is leaf block */
1775 err = ext4_ext_rm_leaf(handle, inode, path, start);
1776 /* root level has p_bh == NULL, brelse() eats this */
1777 brelse(path[i].p_bh);
1778 path[i].p_bh = NULL;
1779 i--;
1780 continue;
1781 }
1782
1783 /* this is index block */
1784 if (!path[i].p_hdr) {
1785 ext_debug("initialize header\n");
1786 path[i].p_hdr = ext_block_hdr(path[i].p_bh);
1787 if (ext4_ext_check_header(__FUNCTION__, inode,
1788 path[i].p_hdr)) {
1789 err = -EIO;
1790 goto out;
1791 }
1792 }
1793
1794 BUG_ON(le16_to_cpu(path[i].p_hdr->eh_entries)
1795 > le16_to_cpu(path[i].p_hdr->eh_max));
1796 BUG_ON(path[i].p_hdr->eh_magic != EXT4_EXT_MAGIC);
1797
1798 if (!path[i].p_idx) {
1799 /* this level hasn't been touched yet */
1800 path[i].p_idx = EXT_LAST_INDEX(path[i].p_hdr);
1801 path[i].p_block = le16_to_cpu(path[i].p_hdr->eh_entries)+1;
1802 ext_debug("init index ptr: hdr 0x%p, num %d\n",
1803 path[i].p_hdr,
1804 le16_to_cpu(path[i].p_hdr->eh_entries));
1805 } else {
1806 /* we were already here, see at next index */
1807 path[i].p_idx--;
1808 }
1809
1810 ext_debug("level %d - index, first 0x%p, cur 0x%p\n",
1811 i, EXT_FIRST_INDEX(path[i].p_hdr),
1812 path[i].p_idx);
1813 if (ext4_ext_more_to_rm(path + i)) {
1814 /* go to the next level */
1815 ext_debug("move to level %d (block %llu)\n",
1816 i + 1, idx_pblock(path[i].p_idx));
1817 memset(path + i + 1, 0, sizeof(*path));
1818 path[i+1].p_bh =
1819 sb_bread(sb, idx_pblock(path[i].p_idx));
1820 if (!path[i+1].p_bh) {
1821 /* should we reset i_size? */
1822 err = -EIO;
1823 break;
1824 }
1825
1826 /* save actual number of indexes since this
1827 * number is changed at the next iteration */
1828 path[i].p_block = le16_to_cpu(path[i].p_hdr->eh_entries);
1829 i++;
1830 } else {
1831 /* we finished processing this index, go up */
1832 if (path[i].p_hdr->eh_entries == 0 && i > 0) {
1833 /* index is empty, remove it;
1834 * handle must be already prepared by the
1835 * truncatei_leaf() */
1836 err = ext4_ext_rm_idx(handle, inode, path + i);
1837 }
1838 /* root level has p_bh == NULL, brelse() eats this */
1839 brelse(path[i].p_bh);
1840 path[i].p_bh = NULL;
1841 i--;
1842 ext_debug("return to level %d\n", i);
1843 }
1844 }
1845
1846 /* TODO: flexible tree reduction should be here */
1847 if (path->p_hdr->eh_entries == 0) {
1848 /*
1849 * truncate to zero freed all the tree,
1850 * so we need to correct eh_depth
1851 */
1852 err = ext4_ext_get_access(handle, inode, path);
1853 if (err == 0) {
1854 ext_inode_hdr(inode)->eh_depth = 0;
1855 ext_inode_hdr(inode)->eh_max =
1856 cpu_to_le16(ext4_ext_space_root(inode));
1857 err = ext4_ext_dirty(handle, inode, path);
1858 }
1859 }
1860out:
1861 ext4_ext_tree_changed(inode);
1862 ext4_ext_drop_refs(path);
1863 kfree(path);
1864 ext4_journal_stop(handle);
1865
1866 return err;
1867}
1868
1869/*
1870 * called at mount time
1871 */
1872void ext4_ext_init(struct super_block *sb)
1873{
1874 /*
1875 * possible initialization would be here
1876 */
1877
1878 if (test_opt(sb, EXTENTS)) {
1879 printk("EXT4-fs: file extents enabled");
1880#ifdef AGRESSIVE_TEST
1881 printk(", agressive tests");
1882#endif
1883#ifdef CHECK_BINSEARCH
1884 printk(", check binsearch");
1885#endif
1886#ifdef EXTENTS_STATS
1887 printk(", stats");
1888#endif
1889 printk("\n");
1890#ifdef EXTENTS_STATS
1891 spin_lock_init(&EXT4_SB(sb)->s_ext_stats_lock);
1892 EXT4_SB(sb)->s_ext_min = 1 << 30;
1893 EXT4_SB(sb)->s_ext_max = 0;
1894#endif
1895 }
1896}
1897
1898/*
1899 * called at umount time
1900 */
1901void ext4_ext_release(struct super_block *sb)
1902{
1903 if (!test_opt(sb, EXTENTS))
1904 return;
1905
1906#ifdef EXTENTS_STATS
1907 if (EXT4_SB(sb)->s_ext_blocks && EXT4_SB(sb)->s_ext_extents) {
1908 struct ext4_sb_info *sbi = EXT4_SB(sb);
1909 printk(KERN_ERR "EXT4-fs: %lu blocks in %lu extents (%lu ave)\n",
1910 sbi->s_ext_blocks, sbi->s_ext_extents,
1911 sbi->s_ext_blocks / sbi->s_ext_extents);
1912 printk(KERN_ERR "EXT4-fs: extents: %lu min, %lu max, max depth %lu\n",
1913 sbi->s_ext_min, sbi->s_ext_max, sbi->s_depth_max);
1914 }
1915#endif
1916}
1917
1918int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
1919 ext4_fsblk_t iblock,
1920 unsigned long max_blocks, struct buffer_head *bh_result,
1921 int create, int extend_disksize)
1922{
1923 struct ext4_ext_path *path = NULL;
1924 struct ext4_extent newex, *ex;
1925 ext4_fsblk_t goal, newblock;
1926 int err = 0, depth;
1927 unsigned long allocated = 0;
1928
1929 __clear_bit(BH_New, &bh_result->b_state);
1930 ext_debug("blocks %d/%lu requested for inode %u\n", (int) iblock,
1931 max_blocks, (unsigned) inode->i_ino);
1932 mutex_lock(&EXT4_I(inode)->truncate_mutex);
1933
1934 /* check in cache */
1935 if ((goal = ext4_ext_in_cache(inode, iblock, &newex))) {
1936 if (goal == EXT4_EXT_CACHE_GAP) {
1937 if (!create) {
1938 /* block isn't allocated yet and
1939 * user doesn't want to allocate it */
1940 goto out2;
1941 }
1942 /* we should allocate requested block */
1943 } else if (goal == EXT4_EXT_CACHE_EXTENT) {
1944 /* block is already allocated */
1945 newblock = iblock
1946 - le32_to_cpu(newex.ee_block)
1947 + ext_pblock(&newex);
1948 /* number of remaining blocks in the extent */
1949 allocated = le16_to_cpu(newex.ee_len) -
1950 (iblock - le32_to_cpu(newex.ee_block));
1951 goto out;
1952 } else {
1953 BUG();
1954 }
1955 }
1956
1957 /* find extent for this block */
1958 path = ext4_ext_find_extent(inode, iblock, NULL);
1959 if (IS_ERR(path)) {
1960 err = PTR_ERR(path);
1961 path = NULL;
1962 goto out2;
1963 }
1964
1965 depth = ext_depth(inode);
1966
1967 /*
1968 * consistent leaf must not be empty;
1969 * this situation is possible, though, _during_ tree modification;
1970 * this is why assert can't be put in ext4_ext_find_extent()
1971 */
1972 BUG_ON(path[depth].p_ext == NULL && depth != 0);
1973
1974 if ((ex = path[depth].p_ext)) {
1975 unsigned long ee_block = le32_to_cpu(ex->ee_block);
1976 ext4_fsblk_t ee_start = ext_pblock(ex);
1977 unsigned short ee_len = le16_to_cpu(ex->ee_len);
1978
1979 /*
1980 * Allow future support for preallocated extents to be added
1981 * as an RO_COMPAT feature:
1982 * Uninitialized extents are treated as holes, except that
1983 * we avoid (fail) allocating new blocks during a write.
1984 */
1985 if (ee_len > EXT_MAX_LEN)
1986 goto out2;
1987 /* if found extent covers block, simply return it */
1988 if (iblock >= ee_block && iblock < ee_block + ee_len) {
1989 newblock = iblock - ee_block + ee_start;
1990 /* number of remaining blocks in the extent */
1991 allocated = ee_len - (iblock - ee_block);
1992 ext_debug("%d fit into %lu:%d -> %llu\n", (int) iblock,
1993 ee_block, ee_len, newblock);
1994 ext4_ext_put_in_cache(inode, ee_block, ee_len,
1995 ee_start, EXT4_EXT_CACHE_EXTENT);
1996 goto out;
1997 }
1998 }
1999
2000 /*
2001 * requested block isn't allocated yet;
2002 * we couldn't try to create block if create flag is zero
2003 */
2004 if (!create) {
2005 /* put just found gap into cache to speed up
2006 * subsequent requests */
2007 ext4_ext_put_gap_in_cache(inode, path, iblock);
2008 goto out2;
2009 }
2010 /*
2011 * Okay, we need to do block allocation. Lazily initialize the block
2012 * allocation info here if necessary.
2013 */
2014 if (S_ISREG(inode->i_mode) && (!EXT4_I(inode)->i_block_alloc_info))
2015 ext4_init_block_alloc_info(inode);
2016
2017 /* allocate new block */
2018 goal = ext4_ext_find_goal(inode, path, iblock);
2019 allocated = max_blocks;
2020 newblock = ext4_new_blocks(handle, inode, goal, &allocated, &err);
2021 if (!newblock)
2022 goto out2;
2023 ext_debug("allocate new block: goal %llu, found %llu/%lu\n",
2024 goal, newblock, allocated);
2025
2026 /* try to insert new extent into found leaf and return */
2027 newex.ee_block = cpu_to_le32(iblock);
2028 ext4_ext_store_pblock(&newex, newblock);
2029 newex.ee_len = cpu_to_le16(allocated);
2030 err = ext4_ext_insert_extent(handle, inode, path, &newex);
2031 if (err)
2032 goto out2;
2033
2034 if (extend_disksize && inode->i_size > EXT4_I(inode)->i_disksize)
2035 EXT4_I(inode)->i_disksize = inode->i_size;
2036
2037 /* previous routine could use block we allocated */
2038 newblock = ext_pblock(&newex);
2039 __set_bit(BH_New, &bh_result->b_state);
2040
2041 ext4_ext_put_in_cache(inode, iblock, allocated, newblock,
2042 EXT4_EXT_CACHE_EXTENT);
2043out:
2044 if (allocated > max_blocks)
2045 allocated = max_blocks;
2046 ext4_ext_show_leaf(inode, path);
2047 __set_bit(BH_Mapped, &bh_result->b_state);
2048 bh_result->b_bdev = inode->i_sb->s_bdev;
2049 bh_result->b_blocknr = newblock;
2050out2:
2051 if (path) {
2052 ext4_ext_drop_refs(path);
2053 kfree(path);
2054 }
2055 mutex_unlock(&EXT4_I(inode)->truncate_mutex);
2056
2057 return err ? err : allocated;
2058}
2059
2060void ext4_ext_truncate(struct inode * inode, struct page *page)
2061{
2062 struct address_space *mapping = inode->i_mapping;
2063 struct super_block *sb = inode->i_sb;
2064 unsigned long last_block;
2065 handle_t *handle;
2066 int err = 0;
2067
2068 /*
2069 * probably first extent we're gonna free will be last in block
2070 */
2071 err = ext4_writepage_trans_blocks(inode) + 3;
2072 handle = ext4_journal_start(inode, err);
2073 if (IS_ERR(handle)) {
2074 if (page) {
2075 clear_highpage(page);
2076 flush_dcache_page(page);
2077 unlock_page(page);
2078 page_cache_release(page);
2079 }
2080 return;
2081 }
2082
2083 if (page)
2084 ext4_block_truncate_page(handle, page, mapping, inode->i_size);
2085
2086 mutex_lock(&EXT4_I(inode)->truncate_mutex);
2087 ext4_ext_invalidate_cache(inode);
2088
2089 /*
2090 * TODO: optimization is possible here.
2091 * Probably we need not scan at all,
2092 * because page truncation is enough.
2093 */
2094 if (ext4_orphan_add(handle, inode))
2095 goto out_stop;
2096
2097 /* we have to know where to truncate from in crash case */
2098 EXT4_I(inode)->i_disksize = inode->i_size;
2099 ext4_mark_inode_dirty(handle, inode);
2100
2101 last_block = (inode->i_size + sb->s_blocksize - 1)
2102 >> EXT4_BLOCK_SIZE_BITS(sb);
2103 err = ext4_ext_remove_space(inode, last_block);
2104
2105 /* In a multi-transaction truncate, we only make the final
2106 * transaction synchronous. */
2107 if (IS_SYNC(inode))
2108 handle->h_sync = 1;
2109
2110out_stop:
2111 /*
2112 * If this was a simple ftruncate() and the file will remain alive,
2113 * then we need to clear up the orphan record which we created above.
2114 * However, if this was a real unlink then we were called by
2115 * ext4_delete_inode(), and we allow that function to clean up the
2116 * orphan info for us.
2117 */
2118 if (inode->i_nlink)
2119 ext4_orphan_del(handle, inode);
2120
2121 mutex_unlock(&EXT4_I(inode)->truncate_mutex);
2122 ext4_journal_stop(handle);
2123}
2124
2125/*
2126 * ext4_ext_writepage_trans_blocks:
2127 * calculate max number of blocks we could modify
2128 * in order to allocate new block for an inode
2129 */
2130int ext4_ext_writepage_trans_blocks(struct inode *inode, int num)
2131{
2132 int needed;
2133
2134 needed = ext4_ext_calc_credits_for_insert(inode, NULL);
2135
2136 /* caller wants to allocate num blocks, but note it includes sb */
2137 needed = needed * num - (num - 1);
2138
2139#ifdef CONFIG_QUOTA
2140 needed += 2 * EXT4_QUOTA_TRANS_BLOCKS(inode->i_sb);
2141#endif
2142
2143 return needed;
2144}
2145
2146EXPORT_SYMBOL(ext4_mark_inode_dirty);
2147EXPORT_SYMBOL(ext4_ext_invalidate_cache);
2148EXPORT_SYMBOL(ext4_ext_insert_extent);
2149EXPORT_SYMBOL(ext4_ext_walk_space);
2150EXPORT_SYMBOL(ext4_ext_find_goal);
2151EXPORT_SYMBOL(ext4_ext_calc_credits_for_insert);
2152
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
new file mode 100644
index 000000000000..0b622c0624b7
--- /dev/null
+++ b/fs/ext4/file.c
@@ -0,0 +1,139 @@
1/*
2 * linux/fs/ext4/file.c
3 *
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 *
9 * from
10 *
11 * linux/fs/minix/file.c
12 *
13 * Copyright (C) 1991, 1992 Linus Torvalds
14 *
15 * ext4 fs regular file handling primitives
16 *
17 * 64-bit file support on 64-bit platforms by Jakub Jelinek
18 * (jj@sunsite.ms.mff.cuni.cz)
19 */
20
21#include <linux/time.h>
22#include <linux/fs.h>
23#include <linux/jbd2.h>
24#include <linux/ext4_fs.h>
25#include <linux/ext4_jbd2.h>
26#include "xattr.h"
27#include "acl.h"
28
29/*
30 * Called when an inode is released. Note that this is different
31 * from ext4_file_open: open gets called at every open, but release
32 * gets called only when /all/ the files are closed.
33 */
34static int ext4_release_file (struct inode * inode, struct file * filp)
35{
36 /* if we are the last writer on the inode, drop the block reservation */
37 if ((filp->f_mode & FMODE_WRITE) &&
38 (atomic_read(&inode->i_writecount) == 1))
39 {
40 mutex_lock(&EXT4_I(inode)->truncate_mutex);
41 ext4_discard_reservation(inode);
42 mutex_unlock(&EXT4_I(inode)->truncate_mutex);
43 }
44 if (is_dx(inode) && filp->private_data)
45 ext4_htree_free_dir_info(filp->private_data);
46
47 return 0;
48}
49
50static ssize_t
51ext4_file_write(struct kiocb *iocb, const struct iovec *iov,
52 unsigned long nr_segs, loff_t pos)
53{
54 struct file *file = iocb->ki_filp;
55 struct inode *inode = file->f_dentry->d_inode;
56 ssize_t ret;
57 int err;
58
59 ret = generic_file_aio_write(iocb, iov, nr_segs, pos);
60
61 /*
62 * Skip flushing if there was an error, or if nothing was written.
63 */
64 if (ret <= 0)
65 return ret;
66
67 /*
68 * If the inode is IS_SYNC, or is O_SYNC and we are doing data
69 * journalling then we need to make sure that we force the transaction
70 * to disk to keep all metadata uptodate synchronously.
71 */
72 if (file->f_flags & O_SYNC) {
73 /*
74 * If we are non-data-journaled, then the dirty data has
75 * already been flushed to backing store by generic_osync_inode,
76 * and the inode has been flushed too if there have been any
77 * modifications other than mere timestamp updates.
78 *
79 * Open question --- do we care about flushing timestamps too
80 * if the inode is IS_SYNC?
81 */
82 if (!ext4_should_journal_data(inode))
83 return ret;
84
85 goto force_commit;
86 }
87
88 /*
89 * So we know that there has been no forced data flush. If the inode
90 * is marked IS_SYNC, we need to force one ourselves.
91 */
92 if (!IS_SYNC(inode))
93 return ret;
94
95 /*
96 * Open question #2 --- should we force data to disk here too? If we
97 * don't, the only impact is that data=writeback filesystems won't
98 * flush data to disk automatically on IS_SYNC, only metadata (but
99 * historically, that is what ext2 has done.)
100 */
101
102force_commit:
103 err = ext4_force_commit(inode->i_sb);
104 if (err)
105 return err;
106 return ret;
107}
108
109const struct file_operations ext4_file_operations = {
110 .llseek = generic_file_llseek,
111 .read = do_sync_read,
112 .write = do_sync_write,
113 .aio_read = generic_file_aio_read,
114 .aio_write = ext4_file_write,
115 .ioctl = ext4_ioctl,
116#ifdef CONFIG_COMPAT
117 .compat_ioctl = ext4_compat_ioctl,
118#endif
119 .mmap = generic_file_mmap,
120 .open = generic_file_open,
121 .release = ext4_release_file,
122 .fsync = ext4_sync_file,
123 .sendfile = generic_file_sendfile,
124 .splice_read = generic_file_splice_read,
125 .splice_write = generic_file_splice_write,
126};
127
128struct inode_operations ext4_file_inode_operations = {
129 .truncate = ext4_truncate,
130 .setattr = ext4_setattr,
131#ifdef CONFIG_EXT4DEV_FS_XATTR
132 .setxattr = generic_setxattr,
133 .getxattr = generic_getxattr,
134 .listxattr = ext4_listxattr,
135 .removexattr = generic_removexattr,
136#endif
137 .permission = ext4_permission,
138};
139
diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c
new file mode 100644
index 000000000000..2a167d7131fa
--- /dev/null
+++ b/fs/ext4/fsync.c
@@ -0,0 +1,88 @@
1/*
2 * linux/fs/ext4/fsync.c
3 *
4 * Copyright (C) 1993 Stephen Tweedie (sct@redhat.com)
5 * from
6 * Copyright (C) 1992 Remy Card (card@masi.ibp.fr)
7 * Laboratoire MASI - Institut Blaise Pascal
8 * Universite Pierre et Marie Curie (Paris VI)
9 * from
10 * linux/fs/minix/truncate.c Copyright (C) 1991, 1992 Linus Torvalds
11 *
12 * ext4fs fsync primitive
13 *
14 * Big-endian to little-endian byte-swapping/bitmaps by
15 * David S. Miller (davem@caip.rutgers.edu), 1995
16 *
17 * Removed unnecessary code duplication for little endian machines
18 * and excessive __inline__s.
19 * Andi Kleen, 1997
20 *
21 * Major simplications and cleanup - we only need to do the metadata, because
22 * we can depend on generic_block_fdatasync() to sync the data blocks.
23 */
24
25#include <linux/time.h>
26#include <linux/fs.h>
27#include <linux/sched.h>
28#include <linux/writeback.h>
29#include <linux/jbd2.h>
30#include <linux/ext4_fs.h>
31#include <linux/ext4_jbd2.h>
32
33/*
34 * akpm: A new design for ext4_sync_file().
35 *
36 * This is only called from sys_fsync(), sys_fdatasync() and sys_msync().
37 * There cannot be a transaction open by this task.
38 * Another task could have dirtied this inode. Its data can be in any
39 * state in the journalling system.
40 *
41 * What we do is just kick off a commit and wait on it. This will snapshot the
42 * inode to disk.
43 */
44
45int ext4_sync_file(struct file * file, struct dentry *dentry, int datasync)
46{
47 struct inode *inode = dentry->d_inode;
48 int ret = 0;
49
50 J_ASSERT(ext4_journal_current_handle() == 0);
51
52 /*
53 * data=writeback:
54 * The caller's filemap_fdatawrite()/wait will sync the data.
55 * sync_inode() will sync the metadata
56 *
57 * data=ordered:
58 * The caller's filemap_fdatawrite() will write the data and
59 * sync_inode() will write the inode if it is dirty. Then the caller's
60 * filemap_fdatawait() will wait on the pages.
61 *
62 * data=journal:
63 * filemap_fdatawrite won't do anything (the buffers are clean).
64 * ext4_force_commit will write the file data into the journal and
65 * will wait on that.
66 * filemap_fdatawait() will encounter a ton of newly-dirtied pages
67 * (they were dirtied by commit). But that's OK - the blocks are
68 * safe in-journal, which is all fsync() needs to ensure.
69 */
70 if (ext4_should_journal_data(inode)) {
71 ret = ext4_force_commit(inode->i_sb);
72 goto out;
73 }
74
75 /*
76 * The VFS has written the file data. If the inode is unaltered
77 * then we need not start a commit.
78 */
79 if (inode->i_state & (I_DIRTY_SYNC|I_DIRTY_DATASYNC)) {
80 struct writeback_control wbc = {
81 .sync_mode = WB_SYNC_ALL,
82 .nr_to_write = 0, /* sys_fsync did this */
83 };
84 ret = sync_inode(inode, &wbc);
85 }
86out:
87 return ret;
88}
diff --git a/fs/ext4/hash.c b/fs/ext4/hash.c
new file mode 100644
index 000000000000..a67966385e06
--- /dev/null
+++ b/fs/ext4/hash.c
@@ -0,0 +1,152 @@
1/*
2 * linux/fs/ext4/hash.c
3 *
4 * Copyright (C) 2002 by Theodore Ts'o
5 *
6 * This file is released under the GPL v2.
7 *
8 * This file may be redistributed under the terms of the GNU Public
9 * License.
10 */
11
12#include <linux/fs.h>
13#include <linux/jbd2.h>
14#include <linux/sched.h>
15#include <linux/ext4_fs.h>
16#include <linux/cryptohash.h>
17
18#define DELTA 0x9E3779B9
19
20static void TEA_transform(__u32 buf[4], __u32 const in[])
21{
22 __u32 sum = 0;
23 __u32 b0 = buf[0], b1 = buf[1];
24 __u32 a = in[0], b = in[1], c = in[2], d = in[3];
25 int n = 16;
26
27 do {
28 sum += DELTA;
29 b0 += ((b1 << 4)+a) ^ (b1+sum) ^ ((b1 >> 5)+b);
30 b1 += ((b0 << 4)+c) ^ (b0+sum) ^ ((b0 >> 5)+d);
31 } while(--n);
32
33 buf[0] += b0;
34 buf[1] += b1;
35}
36
37
38/* The old legacy hash */
39static __u32 dx_hack_hash (const char *name, int len)
40{
41 __u32 hash0 = 0x12a3fe2d, hash1 = 0x37abe8f9;
42 while (len--) {
43 __u32 hash = hash1 + (hash0 ^ (*name++ * 7152373));
44
45 if (hash & 0x80000000) hash -= 0x7fffffff;
46 hash1 = hash0;
47 hash0 = hash;
48 }
49 return (hash0 << 1);
50}
51
52static void str2hashbuf(const char *msg, int len, __u32 *buf, int num)
53{
54 __u32 pad, val;
55 int i;
56
57 pad = (__u32)len | ((__u32)len << 8);
58 pad |= pad << 16;
59
60 val = pad;
61 if (len > num*4)
62 len = num * 4;
63 for (i=0; i < len; i++) {
64 if ((i % 4) == 0)
65 val = pad;
66 val = msg[i] + (val << 8);
67 if ((i % 4) == 3) {
68 *buf++ = val;
69 val = pad;
70 num--;
71 }
72 }
73 if (--num >= 0)
74 *buf++ = val;
75 while (--num >= 0)
76 *buf++ = pad;
77}
78
79/*
80 * Returns the hash of a filename. If len is 0 and name is NULL, then
81 * this function can be used to test whether or not a hash version is
82 * supported.
83 *
84 * The seed is an 4 longword (32 bits) "secret" which can be used to
85 * uniquify a hash. If the seed is all zero's, then some default seed
86 * may be used.
87 *
88 * A particular hash version specifies whether or not the seed is
89 * represented, and whether or not the returned hash is 32 bits or 64
90 * bits. 32 bit hashes will return 0 for the minor hash.
91 */
92int ext4fs_dirhash(const char *name, int len, struct dx_hash_info *hinfo)
93{
94 __u32 hash;
95 __u32 minor_hash = 0;
96 const char *p;
97 int i;
98 __u32 in[8], buf[4];
99
100 /* Initialize the default seed for the hash checksum functions */
101 buf[0] = 0x67452301;
102 buf[1] = 0xefcdab89;
103 buf[2] = 0x98badcfe;
104 buf[3] = 0x10325476;
105
106 /* Check to see if the seed is all zero's */
107 if (hinfo->seed) {
108 for (i=0; i < 4; i++) {
109 if (hinfo->seed[i])
110 break;
111 }
112 if (i < 4)
113 memcpy(buf, hinfo->seed, sizeof(buf));
114 }
115
116 switch (hinfo->hash_version) {
117 case DX_HASH_LEGACY:
118 hash = dx_hack_hash(name, len);
119 break;
120 case DX_HASH_HALF_MD4:
121 p = name;
122 while (len > 0) {
123 str2hashbuf(p, len, in, 8);
124 half_md4_transform(buf, in);
125 len -= 32;
126 p += 32;
127 }
128 minor_hash = buf[2];
129 hash = buf[1];
130 break;
131 case DX_HASH_TEA:
132 p = name;
133 while (len > 0) {
134 str2hashbuf(p, len, in, 4);
135 TEA_transform(buf, in);
136 len -= 16;
137 p += 16;
138 }
139 hash = buf[0];
140 minor_hash = buf[1];
141 break;
142 default:
143 hinfo->hash = 0;
144 return -1;
145 }
146 hash = hash & ~1;
147 if (hash == (EXT4_HTREE_EOF << 1))
148 hash = (EXT4_HTREE_EOF-1) << 1;
149 hinfo->hash = hash;
150 hinfo->minor_hash = minor_hash;
151 return 0;
152}
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
new file mode 100644
index 000000000000..c88b439ba5cd
--- /dev/null
+++ b/fs/ext4/ialloc.c
@@ -0,0 +1,772 @@
1/*
2 * linux/fs/ext4/ialloc.c
3 *
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 *
9 * BSD ufs-inspired inode and directory allocation by
10 * Stephen Tweedie (sct@redhat.com), 1993
11 * Big-endian to little-endian byte-swapping/bitmaps by
12 * David S. Miller (davem@caip.rutgers.edu), 1995
13 */
14
15#include <linux/time.h>
16#include <linux/fs.h>
17#include <linux/jbd2.h>
18#include <linux/ext4_fs.h>
19#include <linux/ext4_jbd2.h>
20#include <linux/stat.h>
21#include <linux/string.h>
22#include <linux/quotaops.h>
23#include <linux/buffer_head.h>
24#include <linux/random.h>
25#include <linux/bitops.h>
26#include <linux/blkdev.h>
27#include <asm/byteorder.h>
28
29#include "xattr.h"
30#include "acl.h"
31
32/*
33 * ialloc.c contains the inodes allocation and deallocation routines
34 */
35
36/*
37 * The free inodes are managed by bitmaps. A file system contains several
38 * blocks groups. Each group contains 1 bitmap block for blocks, 1 bitmap
39 * block for inodes, N blocks for the inode table and data blocks.
40 *
41 * The file system contains group descriptors which are located after the
42 * super block. Each descriptor contains the number of the bitmap block and
43 * the free blocks count in the block.
44 */
45
46
47/*
48 * Read the inode allocation bitmap for a given block_group, reading
49 * into the specified slot in the superblock's bitmap cache.
50 *
51 * Return buffer_head of bitmap on success or NULL.
52 */
53static struct buffer_head *
54read_inode_bitmap(struct super_block * sb, unsigned long block_group)
55{
56 struct ext4_group_desc *desc;
57 struct buffer_head *bh = NULL;
58
59 desc = ext4_get_group_desc(sb, block_group, NULL);
60 if (!desc)
61 goto error_out;
62
63 bh = sb_bread(sb, ext4_inode_bitmap(sb, desc));
64 if (!bh)
65 ext4_error(sb, "read_inode_bitmap",
66 "Cannot read inode bitmap - "
67 "block_group = %lu, inode_bitmap = %llu",
68 block_group, ext4_inode_bitmap(sb, desc));
69error_out:
70 return bh;
71}
72
73/*
74 * NOTE! When we get the inode, we're the only people
75 * that have access to it, and as such there are no
76 * race conditions we have to worry about. The inode
77 * is not on the hash-lists, and it cannot be reached
78 * through the filesystem because the directory entry
79 * has been deleted earlier.
80 *
81 * HOWEVER: we must make sure that we get no aliases,
82 * which means that we have to call "clear_inode()"
83 * _before_ we mark the inode not in use in the inode
84 * bitmaps. Otherwise a newly created file might use
85 * the same inode number (not actually the same pointer
86 * though), and then we'd have two inodes sharing the
87 * same inode number and space on the harddisk.
88 */
89void ext4_free_inode (handle_t *handle, struct inode * inode)
90{
91 struct super_block * sb = inode->i_sb;
92 int is_directory;
93 unsigned long ino;
94 struct buffer_head *bitmap_bh = NULL;
95 struct buffer_head *bh2;
96 unsigned long block_group;
97 unsigned long bit;
98 struct ext4_group_desc * gdp;
99 struct ext4_super_block * es;
100 struct ext4_sb_info *sbi;
101 int fatal = 0, err;
102
103 if (atomic_read(&inode->i_count) > 1) {
104 printk ("ext4_free_inode: inode has count=%d\n",
105 atomic_read(&inode->i_count));
106 return;
107 }
108 if (inode->i_nlink) {
109 printk ("ext4_free_inode: inode has nlink=%d\n",
110 inode->i_nlink);
111 return;
112 }
113 if (!sb) {
114 printk("ext4_free_inode: inode on nonexistent device\n");
115 return;
116 }
117 sbi = EXT4_SB(sb);
118
119 ino = inode->i_ino;
120 ext4_debug ("freeing inode %lu\n", ino);
121
122 /*
123 * Note: we must free any quota before locking the superblock,
124 * as writing the quota to disk may need the lock as well.
125 */
126 DQUOT_INIT(inode);
127 ext4_xattr_delete_inode(handle, inode);
128 DQUOT_FREE_INODE(inode);
129 DQUOT_DROP(inode);
130
131 is_directory = S_ISDIR(inode->i_mode);
132
133 /* Do this BEFORE marking the inode not in use or returning an error */
134 clear_inode (inode);
135
136 es = EXT4_SB(sb)->s_es;
137 if (ino < EXT4_FIRST_INO(sb) || ino > le32_to_cpu(es->s_inodes_count)) {
138 ext4_error (sb, "ext4_free_inode",
139 "reserved or nonexistent inode %lu", ino);
140 goto error_return;
141 }
142 block_group = (ino - 1) / EXT4_INODES_PER_GROUP(sb);
143 bit = (ino - 1) % EXT4_INODES_PER_GROUP(sb);
144 bitmap_bh = read_inode_bitmap(sb, block_group);
145 if (!bitmap_bh)
146 goto error_return;
147
148 BUFFER_TRACE(bitmap_bh, "get_write_access");
149 fatal = ext4_journal_get_write_access(handle, bitmap_bh);
150 if (fatal)
151 goto error_return;
152
153 /* Ok, now we can actually update the inode bitmaps.. */
154 if (!ext4_clear_bit_atomic(sb_bgl_lock(sbi, block_group),
155 bit, bitmap_bh->b_data))
156 ext4_error (sb, "ext4_free_inode",
157 "bit already cleared for inode %lu", ino);
158 else {
159 gdp = ext4_get_group_desc (sb, block_group, &bh2);
160
161 BUFFER_TRACE(bh2, "get_write_access");
162 fatal = ext4_journal_get_write_access(handle, bh2);
163 if (fatal) goto error_return;
164
165 if (gdp) {
166 spin_lock(sb_bgl_lock(sbi, block_group));
167 gdp->bg_free_inodes_count = cpu_to_le16(
168 le16_to_cpu(gdp->bg_free_inodes_count) + 1);
169 if (is_directory)
170 gdp->bg_used_dirs_count = cpu_to_le16(
171 le16_to_cpu(gdp->bg_used_dirs_count) - 1);
172 spin_unlock(sb_bgl_lock(sbi, block_group));
173 percpu_counter_inc(&sbi->s_freeinodes_counter);
174 if (is_directory)
175 percpu_counter_dec(&sbi->s_dirs_counter);
176
177 }
178 BUFFER_TRACE(bh2, "call ext4_journal_dirty_metadata");
179 err = ext4_journal_dirty_metadata(handle, bh2);
180 if (!fatal) fatal = err;
181 }
182 BUFFER_TRACE(bitmap_bh, "call ext4_journal_dirty_metadata");
183 err = ext4_journal_dirty_metadata(handle, bitmap_bh);
184 if (!fatal)
185 fatal = err;
186 sb->s_dirt = 1;
187error_return:
188 brelse(bitmap_bh);
189 ext4_std_error(sb, fatal);
190}
191
192/*
193 * There are two policies for allocating an inode. If the new inode is
194 * a directory, then a forward search is made for a block group with both
195 * free space and a low directory-to-inode ratio; if that fails, then of
196 * the groups with above-average free space, that group with the fewest
197 * directories already is chosen.
198 *
199 * For other inodes, search forward from the parent directory\'s block
200 * group to find a free inode.
201 */
202static int find_group_dir(struct super_block *sb, struct inode *parent)
203{
204 int ngroups = EXT4_SB(sb)->s_groups_count;
205 unsigned int freei, avefreei;
206 struct ext4_group_desc *desc, *best_desc = NULL;
207 struct buffer_head *bh;
208 int group, best_group = -1;
209
210 freei = percpu_counter_read_positive(&EXT4_SB(sb)->s_freeinodes_counter);
211 avefreei = freei / ngroups;
212
213 for (group = 0; group < ngroups; group++) {
214 desc = ext4_get_group_desc (sb, group, &bh);
215 if (!desc || !desc->bg_free_inodes_count)
216 continue;
217 if (le16_to_cpu(desc->bg_free_inodes_count) < avefreei)
218 continue;
219 if (!best_desc ||
220 (le16_to_cpu(desc->bg_free_blocks_count) >
221 le16_to_cpu(best_desc->bg_free_blocks_count))) {
222 best_group = group;
223 best_desc = desc;
224 }
225 }
226 return best_group;
227}
228
229/*
230 * Orlov's allocator for directories.
231 *
232 * We always try to spread first-level directories.
233 *
234 * If there are blockgroups with both free inodes and free blocks counts
235 * not worse than average we return one with smallest directory count.
236 * Otherwise we simply return a random group.
237 *
238 * For the rest rules look so:
239 *
240 * It's OK to put directory into a group unless
241 * it has too many directories already (max_dirs) or
242 * it has too few free inodes left (min_inodes) or
243 * it has too few free blocks left (min_blocks) or
244 * it's already running too large debt (max_debt).
245 * Parent's group is prefered, if it doesn't satisfy these
246 * conditions we search cyclically through the rest. If none
247 * of the groups look good we just look for a group with more
248 * free inodes than average (starting at parent's group).
249 *
250 * Debt is incremented each time we allocate a directory and decremented
251 * when we allocate an inode, within 0--255.
252 */
253
254#define INODE_COST 64
255#define BLOCK_COST 256
256
257static int find_group_orlov(struct super_block *sb, struct inode *parent)
258{
259 int parent_group = EXT4_I(parent)->i_block_group;
260 struct ext4_sb_info *sbi = EXT4_SB(sb);
261 struct ext4_super_block *es = sbi->s_es;
262 int ngroups = sbi->s_groups_count;
263 int inodes_per_group = EXT4_INODES_PER_GROUP(sb);
264 unsigned int freei, avefreei;
265 ext4_fsblk_t freeb, avefreeb;
266 ext4_fsblk_t blocks_per_dir;
267 unsigned int ndirs;
268 int max_debt, max_dirs, min_inodes;
269 ext4_grpblk_t min_blocks;
270 int group = -1, i;
271 struct ext4_group_desc *desc;
272 struct buffer_head *bh;
273
274 freei = percpu_counter_read_positive(&sbi->s_freeinodes_counter);
275 avefreei = freei / ngroups;
276 freeb = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
277 avefreeb = freeb;
278 do_div(avefreeb, ngroups);
279 ndirs = percpu_counter_read_positive(&sbi->s_dirs_counter);
280
281 if ((parent == sb->s_root->d_inode) ||
282 (EXT4_I(parent)->i_flags & EXT4_TOPDIR_FL)) {
283 int best_ndir = inodes_per_group;
284 int best_group = -1;
285
286 get_random_bytes(&group, sizeof(group));
287 parent_group = (unsigned)group % ngroups;
288 for (i = 0; i < ngroups; i++) {
289 group = (parent_group + i) % ngroups;
290 desc = ext4_get_group_desc (sb, group, &bh);
291 if (!desc || !desc->bg_free_inodes_count)
292 continue;
293 if (le16_to_cpu(desc->bg_used_dirs_count) >= best_ndir)
294 continue;
295 if (le16_to_cpu(desc->bg_free_inodes_count) < avefreei)
296 continue;
297 if (le16_to_cpu(desc->bg_free_blocks_count) < avefreeb)
298 continue;
299 best_group = group;
300 best_ndir = le16_to_cpu(desc->bg_used_dirs_count);
301 }
302 if (best_group >= 0)
303 return best_group;
304 goto fallback;
305 }
306
307 blocks_per_dir = ext4_blocks_count(es) - freeb;
308 do_div(blocks_per_dir, ndirs);
309
310 max_dirs = ndirs / ngroups + inodes_per_group / 16;
311 min_inodes = avefreei - inodes_per_group / 4;
312 min_blocks = avefreeb - EXT4_BLOCKS_PER_GROUP(sb) / 4;
313
314 max_debt = EXT4_BLOCKS_PER_GROUP(sb);
315 max_debt /= max_t(int, blocks_per_dir, BLOCK_COST);
316 if (max_debt * INODE_COST > inodes_per_group)
317 max_debt = inodes_per_group / INODE_COST;
318 if (max_debt > 255)
319 max_debt = 255;
320 if (max_debt == 0)
321 max_debt = 1;
322
323 for (i = 0; i < ngroups; i++) {
324 group = (parent_group + i) % ngroups;
325 desc = ext4_get_group_desc (sb, group, &bh);
326 if (!desc || !desc->bg_free_inodes_count)
327 continue;
328 if (le16_to_cpu(desc->bg_used_dirs_count) >= max_dirs)
329 continue;
330 if (le16_to_cpu(desc->bg_free_inodes_count) < min_inodes)
331 continue;
332 if (le16_to_cpu(desc->bg_free_blocks_count) < min_blocks)
333 continue;
334 return group;
335 }
336
337fallback:
338 for (i = 0; i < ngroups; i++) {
339 group = (parent_group + i) % ngroups;
340 desc = ext4_get_group_desc (sb, group, &bh);
341 if (!desc || !desc->bg_free_inodes_count)
342 continue;
343 if (le16_to_cpu(desc->bg_free_inodes_count) >= avefreei)
344 return group;
345 }
346
347 if (avefreei) {
348 /*
349 * The free-inodes counter is approximate, and for really small
350 * filesystems the above test can fail to find any blockgroups
351 */
352 avefreei = 0;
353 goto fallback;
354 }
355
356 return -1;
357}
358
359static int find_group_other(struct super_block *sb, struct inode *parent)
360{
361 int parent_group = EXT4_I(parent)->i_block_group;
362 int ngroups = EXT4_SB(sb)->s_groups_count;
363 struct ext4_group_desc *desc;
364 struct buffer_head *bh;
365 int group, i;
366
367 /*
368 * Try to place the inode in its parent directory
369 */
370 group = parent_group;
371 desc = ext4_get_group_desc (sb, group, &bh);
372 if (desc && le16_to_cpu(desc->bg_free_inodes_count) &&
373 le16_to_cpu(desc->bg_free_blocks_count))
374 return group;
375
376 /*
377 * We're going to place this inode in a different blockgroup from its
378 * parent. We want to cause files in a common directory to all land in
379 * the same blockgroup. But we want files which are in a different
380 * directory which shares a blockgroup with our parent to land in a
381 * different blockgroup.
382 *
383 * So add our directory's i_ino into the starting point for the hash.
384 */
385 group = (group + parent->i_ino) % ngroups;
386
387 /*
388 * Use a quadratic hash to find a group with a free inode and some free
389 * blocks.
390 */
391 for (i = 1; i < ngroups; i <<= 1) {
392 group += i;
393 if (group >= ngroups)
394 group -= ngroups;
395 desc = ext4_get_group_desc (sb, group, &bh);
396 if (desc && le16_to_cpu(desc->bg_free_inodes_count) &&
397 le16_to_cpu(desc->bg_free_blocks_count))
398 return group;
399 }
400
401 /*
402 * That failed: try linear search for a free inode, even if that group
403 * has no free blocks.
404 */
405 group = parent_group;
406 for (i = 0; i < ngroups; i++) {
407 if (++group >= ngroups)
408 group = 0;
409 desc = ext4_get_group_desc (sb, group, &bh);
410 if (desc && le16_to_cpu(desc->bg_free_inodes_count))
411 return group;
412 }
413
414 return -1;
415}
416
417/*
418 * There are two policies for allocating an inode. If the new inode is
419 * a directory, then a forward search is made for a block group with both
420 * free space and a low directory-to-inode ratio; if that fails, then of
421 * the groups with above-average free space, that group with the fewest
422 * directories already is chosen.
423 *
424 * For other inodes, search forward from the parent directory's block
425 * group to find a free inode.
426 */
427struct inode *ext4_new_inode(handle_t *handle, struct inode * dir, int mode)
428{
429 struct super_block *sb;
430 struct buffer_head *bitmap_bh = NULL;
431 struct buffer_head *bh2;
432 int group;
433 unsigned long ino = 0;
434 struct inode * inode;
435 struct ext4_group_desc * gdp = NULL;
436 struct ext4_super_block * es;
437 struct ext4_inode_info *ei;
438 struct ext4_sb_info *sbi;
439 int err = 0;
440 struct inode *ret;
441 int i;
442
443 /* Cannot create files in a deleted directory */
444 if (!dir || !dir->i_nlink)
445 return ERR_PTR(-EPERM);
446
447 sb = dir->i_sb;
448 inode = new_inode(sb);
449 if (!inode)
450 return ERR_PTR(-ENOMEM);
451 ei = EXT4_I(inode);
452
453 sbi = EXT4_SB(sb);
454 es = sbi->s_es;
455 if (S_ISDIR(mode)) {
456 if (test_opt (sb, OLDALLOC))
457 group = find_group_dir(sb, dir);
458 else
459 group = find_group_orlov(sb, dir);
460 } else
461 group = find_group_other(sb, dir);
462
463 err = -ENOSPC;
464 if (group == -1)
465 goto out;
466
467 for (i = 0; i < sbi->s_groups_count; i++) {
468 err = -EIO;
469
470 gdp = ext4_get_group_desc(sb, group, &bh2);
471 if (!gdp)
472 goto fail;
473
474 brelse(bitmap_bh);
475 bitmap_bh = read_inode_bitmap(sb, group);
476 if (!bitmap_bh)
477 goto fail;
478
479 ino = 0;
480
481repeat_in_this_group:
482 ino = ext4_find_next_zero_bit((unsigned long *)
483 bitmap_bh->b_data, EXT4_INODES_PER_GROUP(sb), ino);
484 if (ino < EXT4_INODES_PER_GROUP(sb)) {
485
486 BUFFER_TRACE(bitmap_bh, "get_write_access");
487 err = ext4_journal_get_write_access(handle, bitmap_bh);
488 if (err)
489 goto fail;
490
491 if (!ext4_set_bit_atomic(sb_bgl_lock(sbi, group),
492 ino, bitmap_bh->b_data)) {
493 /* we won it */
494 BUFFER_TRACE(bitmap_bh,
495 "call ext4_journal_dirty_metadata");
496 err = ext4_journal_dirty_metadata(handle,
497 bitmap_bh);
498 if (err)
499 goto fail;
500 goto got;
501 }
502 /* we lost it */
503 jbd2_journal_release_buffer(handle, bitmap_bh);
504
505 if (++ino < EXT4_INODES_PER_GROUP(sb))
506 goto repeat_in_this_group;
507 }
508
509 /*
510 * This case is possible in concurrent environment. It is very
511 * rare. We cannot repeat the find_group_xxx() call because
512 * that will simply return the same blockgroup, because the
513 * group descriptor metadata has not yet been updated.
514 * So we just go onto the next blockgroup.
515 */
516 if (++group == sbi->s_groups_count)
517 group = 0;
518 }
519 err = -ENOSPC;
520 goto out;
521
522got:
523 ino += group * EXT4_INODES_PER_GROUP(sb) + 1;
524 if (ino < EXT4_FIRST_INO(sb) || ino > le32_to_cpu(es->s_inodes_count)) {
525 ext4_error (sb, "ext4_new_inode",
526 "reserved inode or inode > inodes count - "
527 "block_group = %d, inode=%lu", group, ino);
528 err = -EIO;
529 goto fail;
530 }
531
532 BUFFER_TRACE(bh2, "get_write_access");
533 err = ext4_journal_get_write_access(handle, bh2);
534 if (err) goto fail;
535 spin_lock(sb_bgl_lock(sbi, group));
536 gdp->bg_free_inodes_count =
537 cpu_to_le16(le16_to_cpu(gdp->bg_free_inodes_count) - 1);
538 if (S_ISDIR(mode)) {
539 gdp->bg_used_dirs_count =
540 cpu_to_le16(le16_to_cpu(gdp->bg_used_dirs_count) + 1);
541 }
542 spin_unlock(sb_bgl_lock(sbi, group));
543 BUFFER_TRACE(bh2, "call ext4_journal_dirty_metadata");
544 err = ext4_journal_dirty_metadata(handle, bh2);
545 if (err) goto fail;
546
547 percpu_counter_dec(&sbi->s_freeinodes_counter);
548 if (S_ISDIR(mode))
549 percpu_counter_inc(&sbi->s_dirs_counter);
550 sb->s_dirt = 1;
551
552 inode->i_uid = current->fsuid;
553 if (test_opt (sb, GRPID))
554 inode->i_gid = dir->i_gid;
555 else if (dir->i_mode & S_ISGID) {
556 inode->i_gid = dir->i_gid;
557 if (S_ISDIR(mode))
558 mode |= S_ISGID;
559 } else
560 inode->i_gid = current->fsgid;
561 inode->i_mode = mode;
562
563 inode->i_ino = ino;
564 /* This is the optimal IO size (for stat), not the fs block size */
565 inode->i_blocks = 0;
566 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
567
568 memset(ei->i_data, 0, sizeof(ei->i_data));
569 ei->i_dir_start_lookup = 0;
570 ei->i_disksize = 0;
571
572 ei->i_flags = EXT4_I(dir)->i_flags & ~EXT4_INDEX_FL;
573 if (S_ISLNK(mode))
574 ei->i_flags &= ~(EXT4_IMMUTABLE_FL|EXT4_APPEND_FL);
575 /* dirsync only applies to directories */
576 if (!S_ISDIR(mode))
577 ei->i_flags &= ~EXT4_DIRSYNC_FL;
578#ifdef EXT4_FRAGMENTS
579 ei->i_faddr = 0;
580 ei->i_frag_no = 0;
581 ei->i_frag_size = 0;
582#endif
583 ei->i_file_acl = 0;
584 ei->i_dir_acl = 0;
585 ei->i_dtime = 0;
586 ei->i_block_alloc_info = NULL;
587 ei->i_block_group = group;
588
589 ext4_set_inode_flags(inode);
590 if (IS_DIRSYNC(inode))
591 handle->h_sync = 1;
592 insert_inode_hash(inode);
593 spin_lock(&sbi->s_next_gen_lock);
594 inode->i_generation = sbi->s_next_generation++;
595 spin_unlock(&sbi->s_next_gen_lock);
596
597 ei->i_state = EXT4_STATE_NEW;
598 ei->i_extra_isize =
599 (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) ?
600 sizeof(struct ext4_inode) - EXT4_GOOD_OLD_INODE_SIZE : 0;
601
602 ret = inode;
603 if(DQUOT_ALLOC_INODE(inode)) {
604 err = -EDQUOT;
605 goto fail_drop;
606 }
607
608 err = ext4_init_acl(handle, inode, dir);
609 if (err)
610 goto fail_free_drop;
611
612 err = ext4_init_security(handle,inode, dir);
613 if (err)
614 goto fail_free_drop;
615
616 err = ext4_mark_inode_dirty(handle, inode);
617 if (err) {
618 ext4_std_error(sb, err);
619 goto fail_free_drop;
620 }
621 if (test_opt(sb, EXTENTS)) {
622 EXT4_I(inode)->i_flags |= EXT4_EXTENTS_FL;
623 ext4_ext_tree_init(handle, inode);
624 if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS)) {
625 err = ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh);
626 if (err) goto fail;
627 EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS);
628 BUFFER_TRACE(EXT4_SB(sb)->s_sbh, "call ext4_journal_dirty_metadata");
629 err = ext4_journal_dirty_metadata(handle, EXT4_SB(sb)->s_sbh);
630 }
631 }
632
633 ext4_debug("allocating inode %lu\n", inode->i_ino);
634 goto really_out;
635fail:
636 ext4_std_error(sb, err);
637out:
638 iput(inode);
639 ret = ERR_PTR(err);
640really_out:
641 brelse(bitmap_bh);
642 return ret;
643
644fail_free_drop:
645 DQUOT_FREE_INODE(inode);
646
647fail_drop:
648 DQUOT_DROP(inode);
649 inode->i_flags |= S_NOQUOTA;
650 inode->i_nlink = 0;
651 iput(inode);
652 brelse(bitmap_bh);
653 return ERR_PTR(err);
654}
655
656/* Verify that we are loading a valid orphan from disk */
657struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino)
658{
659 unsigned long max_ino = le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count);
660 unsigned long block_group;
661 int bit;
662 struct buffer_head *bitmap_bh = NULL;
663 struct inode *inode = NULL;
664
665 /* Error cases - e2fsck has already cleaned up for us */
666 if (ino > max_ino) {
667 ext4_warning(sb, __FUNCTION__,
668 "bad orphan ino %lu! e2fsck was run?", ino);
669 goto out;
670 }
671
672 block_group = (ino - 1) / EXT4_INODES_PER_GROUP(sb);
673 bit = (ino - 1) % EXT4_INODES_PER_GROUP(sb);
674 bitmap_bh = read_inode_bitmap(sb, block_group);
675 if (!bitmap_bh) {
676 ext4_warning(sb, __FUNCTION__,
677 "inode bitmap error for orphan %lu", ino);
678 goto out;
679 }
680
681 /* Having the inode bit set should be a 100% indicator that this
682 * is a valid orphan (no e2fsck run on fs). Orphans also include
683 * inodes that were being truncated, so we can't check i_nlink==0.
684 */
685 if (!ext4_test_bit(bit, bitmap_bh->b_data) ||
686 !(inode = iget(sb, ino)) || is_bad_inode(inode) ||
687 NEXT_ORPHAN(inode) > max_ino) {
688 ext4_warning(sb, __FUNCTION__,
689 "bad orphan inode %lu! e2fsck was run?", ino);
690 printk(KERN_NOTICE "ext4_test_bit(bit=%d, block=%llu) = %d\n",
691 bit, (unsigned long long)bitmap_bh->b_blocknr,
692 ext4_test_bit(bit, bitmap_bh->b_data));
693 printk(KERN_NOTICE "inode=%p\n", inode);
694 if (inode) {
695 printk(KERN_NOTICE "is_bad_inode(inode)=%d\n",
696 is_bad_inode(inode));
697 printk(KERN_NOTICE "NEXT_ORPHAN(inode)=%u\n",
698 NEXT_ORPHAN(inode));
699 printk(KERN_NOTICE "max_ino=%lu\n", max_ino);
700 }
701 /* Avoid freeing blocks if we got a bad deleted inode */
702 if (inode && inode->i_nlink == 0)
703 inode->i_blocks = 0;
704 iput(inode);
705 inode = NULL;
706 }
707out:
708 brelse(bitmap_bh);
709 return inode;
710}
711
712unsigned long ext4_count_free_inodes (struct super_block * sb)
713{
714 unsigned long desc_count;
715 struct ext4_group_desc *gdp;
716 int i;
717#ifdef EXT4FS_DEBUG
718 struct ext4_super_block *es;
719 unsigned long bitmap_count, x;
720 struct buffer_head *bitmap_bh = NULL;
721
722 es = EXT4_SB(sb)->s_es;
723 desc_count = 0;
724 bitmap_count = 0;
725 gdp = NULL;
726 for (i = 0; i < EXT4_SB(sb)->s_groups_count; i++) {
727 gdp = ext4_get_group_desc (sb, i, NULL);
728 if (!gdp)
729 continue;
730 desc_count += le16_to_cpu(gdp->bg_free_inodes_count);
731 brelse(bitmap_bh);
732 bitmap_bh = read_inode_bitmap(sb, i);
733 if (!bitmap_bh)
734 continue;
735
736 x = ext4_count_free(bitmap_bh, EXT4_INODES_PER_GROUP(sb) / 8);
737 printk("group %d: stored = %d, counted = %lu\n",
738 i, le16_to_cpu(gdp->bg_free_inodes_count), x);
739 bitmap_count += x;
740 }
741 brelse(bitmap_bh);
742 printk("ext4_count_free_inodes: stored = %u, computed = %lu, %lu\n",
743 le32_to_cpu(es->s_free_inodes_count), desc_count, bitmap_count);
744 return desc_count;
745#else
746 desc_count = 0;
747 for (i = 0; i < EXT4_SB(sb)->s_groups_count; i++) {
748 gdp = ext4_get_group_desc (sb, i, NULL);
749 if (!gdp)
750 continue;
751 desc_count += le16_to_cpu(gdp->bg_free_inodes_count);
752 cond_resched();
753 }
754 return desc_count;
755#endif
756}
757
758/* Called at mount-time, super-block is locked */
759unsigned long ext4_count_dirs (struct super_block * sb)
760{
761 unsigned long count = 0;
762 int i;
763
764 for (i = 0; i < EXT4_SB(sb)->s_groups_count; i++) {
765 struct ext4_group_desc *gdp = ext4_get_group_desc (sb, i, NULL);
766 if (!gdp)
767 continue;
768 count += le16_to_cpu(gdp->bg_used_dirs_count);
769 }
770 return count;
771}
772
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
new file mode 100644
index 000000000000..0a60ec5a16db
--- /dev/null
+++ b/fs/ext4/inode.c
@@ -0,0 +1,3233 @@
1/*
2 * linux/fs/ext4/inode.c
3 *
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 *
9 * from
10 *
11 * linux/fs/minix/inode.c
12 *
13 * Copyright (C) 1991, 1992 Linus Torvalds
14 *
15 * Goal-directed block allocation by Stephen Tweedie
16 * (sct@redhat.com), 1993, 1998
17 * Big-endian to little-endian byte-swapping/bitmaps by
18 * David S. Miller (davem@caip.rutgers.edu), 1995
19 * 64-bit file support on 64-bit platforms by Jakub Jelinek
20 * (jj@sunsite.ms.mff.cuni.cz)
21 *
22 * Assorted race fixes, rewrite of ext4_get_block() by Al Viro, 2000
23 */
24
25#include <linux/module.h>
26#include <linux/fs.h>
27#include <linux/time.h>
28#include <linux/ext4_jbd2.h>
29#include <linux/jbd2.h>
30#include <linux/smp_lock.h>
31#include <linux/highuid.h>
32#include <linux/pagemap.h>
33#include <linux/quotaops.h>
34#include <linux/string.h>
35#include <linux/buffer_head.h>
36#include <linux/writeback.h>
37#include <linux/mpage.h>
38#include <linux/uio.h>
39#include <linux/bio.h>
40#include "xattr.h"
41#include "acl.h"
42
43/*
44 * Test whether an inode is a fast symlink.
45 */
46static int ext4_inode_is_fast_symlink(struct inode *inode)
47{
48 int ea_blocks = EXT4_I(inode)->i_file_acl ?
49 (inode->i_sb->s_blocksize >> 9) : 0;
50
51 return (S_ISLNK(inode->i_mode) && inode->i_blocks - ea_blocks == 0);
52}
53
54/*
55 * The ext4 forget function must perform a revoke if we are freeing data
56 * which has been journaled. Metadata (eg. indirect blocks) must be
57 * revoked in all cases.
58 *
59 * "bh" may be NULL: a metadata block may have been freed from memory
60 * but there may still be a record of it in the journal, and that record
61 * still needs to be revoked.
62 */
63int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode,
64 struct buffer_head *bh, ext4_fsblk_t blocknr)
65{
66 int err;
67
68 might_sleep();
69
70 BUFFER_TRACE(bh, "enter");
71
72 jbd_debug(4, "forgetting bh %p: is_metadata = %d, mode %o, "
73 "data mode %lx\n",
74 bh, is_metadata, inode->i_mode,
75 test_opt(inode->i_sb, DATA_FLAGS));
76
77 /* Never use the revoke function if we are doing full data
78 * journaling: there is no need to, and a V1 superblock won't
79 * support it. Otherwise, only skip the revoke on un-journaled
80 * data blocks. */
81
82 if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA ||
83 (!is_metadata && !ext4_should_journal_data(inode))) {
84 if (bh) {
85 BUFFER_TRACE(bh, "call jbd2_journal_forget");
86 return ext4_journal_forget(handle, bh);
87 }
88 return 0;
89 }
90
91 /*
92 * data!=journal && (is_metadata || should_journal_data(inode))
93 */
94 BUFFER_TRACE(bh, "call ext4_journal_revoke");
95 err = ext4_journal_revoke(handle, blocknr, bh);
96 if (err)
97 ext4_abort(inode->i_sb, __FUNCTION__,
98 "error %d when attempting revoke", err);
99 BUFFER_TRACE(bh, "exit");
100 return err;
101}
102
103/*
104 * Work out how many blocks we need to proceed with the next chunk of a
105 * truncate transaction.
106 */
107static unsigned long blocks_for_truncate(struct inode *inode)
108{
109 unsigned long needed;
110
111 needed = inode->i_blocks >> (inode->i_sb->s_blocksize_bits - 9);
112
113 /* Give ourselves just enough room to cope with inodes in which
114 * i_blocks is corrupt: we've seen disk corruptions in the past
115 * which resulted in random data in an inode which looked enough
116 * like a regular file for ext4 to try to delete it. Things
117 * will go a bit crazy if that happens, but at least we should
118 * try not to panic the whole kernel. */
119 if (needed < 2)
120 needed = 2;
121
122 /* But we need to bound the transaction so we don't overflow the
123 * journal. */
124 if (needed > EXT4_MAX_TRANS_DATA)
125 needed = EXT4_MAX_TRANS_DATA;
126
127 return EXT4_DATA_TRANS_BLOCKS(inode->i_sb) + needed;
128}
129
130/*
131 * Truncate transactions can be complex and absolutely huge. So we need to
132 * be able to restart the transaction at a conventient checkpoint to make
133 * sure we don't overflow the journal.
134 *
135 * start_transaction gets us a new handle for a truncate transaction,
136 * and extend_transaction tries to extend the existing one a bit. If
137 * extend fails, we need to propagate the failure up and restart the
138 * transaction in the top-level truncate loop. --sct
139 */
140static handle_t *start_transaction(struct inode *inode)
141{
142 handle_t *result;
143
144 result = ext4_journal_start(inode, blocks_for_truncate(inode));
145 if (!IS_ERR(result))
146 return result;
147
148 ext4_std_error(inode->i_sb, PTR_ERR(result));
149 return result;
150}
151
152/*
153 * Try to extend this transaction for the purposes of truncation.
154 *
155 * Returns 0 if we managed to create more room. If we can't create more
156 * room, and the transaction must be restarted we return 1.
157 */
158static int try_to_extend_transaction(handle_t *handle, struct inode *inode)
159{
160 if (handle->h_buffer_credits > EXT4_RESERVE_TRANS_BLOCKS)
161 return 0;
162 if (!ext4_journal_extend(handle, blocks_for_truncate(inode)))
163 return 0;
164 return 1;
165}
166
167/*
168 * Restart the transaction associated with *handle. This does a commit,
169 * so before we call here everything must be consistently dirtied against
170 * this transaction.
171 */
172static int ext4_journal_test_restart(handle_t *handle, struct inode *inode)
173{
174 jbd_debug(2, "restarting handle %p\n", handle);
175 return ext4_journal_restart(handle, blocks_for_truncate(inode));
176}
177
178/*
179 * Called at the last iput() if i_nlink is zero.
180 */
181void ext4_delete_inode (struct inode * inode)
182{
183 handle_t *handle;
184
185 truncate_inode_pages(&inode->i_data, 0);
186
187 if (is_bad_inode(inode))
188 goto no_delete;
189
190 handle = start_transaction(inode);
191 if (IS_ERR(handle)) {
192 /*
193 * If we're going to skip the normal cleanup, we still need to
194 * make sure that the in-core orphan linked list is properly
195 * cleaned up.
196 */
197 ext4_orphan_del(NULL, inode);
198 goto no_delete;
199 }
200
201 if (IS_SYNC(inode))
202 handle->h_sync = 1;
203 inode->i_size = 0;
204 if (inode->i_blocks)
205 ext4_truncate(inode);
206 /*
207 * Kill off the orphan record which ext4_truncate created.
208 * AKPM: I think this can be inside the above `if'.
209 * Note that ext4_orphan_del() has to be able to cope with the
210 * deletion of a non-existent orphan - this is because we don't
211 * know if ext4_truncate() actually created an orphan record.
212 * (Well, we could do this if we need to, but heck - it works)
213 */
214 ext4_orphan_del(handle, inode);
215 EXT4_I(inode)->i_dtime = get_seconds();
216
217 /*
218 * One subtle ordering requirement: if anything has gone wrong
219 * (transaction abort, IO errors, whatever), then we can still
220 * do these next steps (the fs will already have been marked as
221 * having errors), but we can't free the inode if the mark_dirty
222 * fails.
223 */
224 if (ext4_mark_inode_dirty(handle, inode))
225 /* If that failed, just do the required in-core inode clear. */
226 clear_inode(inode);
227 else
228 ext4_free_inode(handle, inode);
229 ext4_journal_stop(handle);
230 return;
231no_delete:
232 clear_inode(inode); /* We must guarantee clearing of inode... */
233}
234
235typedef struct {
236 __le32 *p;
237 __le32 key;
238 struct buffer_head *bh;
239} Indirect;
240
241static inline void add_chain(Indirect *p, struct buffer_head *bh, __le32 *v)
242{
243 p->key = *(p->p = v);
244 p->bh = bh;
245}
246
247static int verify_chain(Indirect *from, Indirect *to)
248{
249 while (from <= to && from->key == *from->p)
250 from++;
251 return (from > to);
252}
253
254/**
255 * ext4_block_to_path - parse the block number into array of offsets
256 * @inode: inode in question (we are only interested in its superblock)
257 * @i_block: block number to be parsed
258 * @offsets: array to store the offsets in
259 * @boundary: set this non-zero if the referred-to block is likely to be
260 * followed (on disk) by an indirect block.
261 *
262 * To store the locations of file's data ext4 uses a data structure common
263 * for UNIX filesystems - tree of pointers anchored in the inode, with
264 * data blocks at leaves and indirect blocks in intermediate nodes.
265 * This function translates the block number into path in that tree -
266 * return value is the path length and @offsets[n] is the offset of
267 * pointer to (n+1)th node in the nth one. If @block is out of range
268 * (negative or too large) warning is printed and zero returned.
269 *
270 * Note: function doesn't find node addresses, so no IO is needed. All
271 * we need to know is the capacity of indirect blocks (taken from the
272 * inode->i_sb).
273 */
274
275/*
276 * Portability note: the last comparison (check that we fit into triple
277 * indirect block) is spelled differently, because otherwise on an
278 * architecture with 32-bit longs and 8Kb pages we might get into trouble
279 * if our filesystem had 8Kb blocks. We might use long long, but that would
280 * kill us on x86. Oh, well, at least the sign propagation does not matter -
281 * i_block would have to be negative in the very beginning, so we would not
282 * get there at all.
283 */
284
285static int ext4_block_to_path(struct inode *inode,
286 long i_block, int offsets[4], int *boundary)
287{
288 int ptrs = EXT4_ADDR_PER_BLOCK(inode->i_sb);
289 int ptrs_bits = EXT4_ADDR_PER_BLOCK_BITS(inode->i_sb);
290 const long direct_blocks = EXT4_NDIR_BLOCKS,
291 indirect_blocks = ptrs,
292 double_blocks = (1 << (ptrs_bits * 2));
293 int n = 0;
294 int final = 0;
295
296 if (i_block < 0) {
297 ext4_warning (inode->i_sb, "ext4_block_to_path", "block < 0");
298 } else if (i_block < direct_blocks) {
299 offsets[n++] = i_block;
300 final = direct_blocks;
301 } else if ( (i_block -= direct_blocks) < indirect_blocks) {
302 offsets[n++] = EXT4_IND_BLOCK;
303 offsets[n++] = i_block;
304 final = ptrs;
305 } else if ((i_block -= indirect_blocks) < double_blocks) {
306 offsets[n++] = EXT4_DIND_BLOCK;
307 offsets[n++] = i_block >> ptrs_bits;
308 offsets[n++] = i_block & (ptrs - 1);
309 final = ptrs;
310 } else if (((i_block -= double_blocks) >> (ptrs_bits * 2)) < ptrs) {
311 offsets[n++] = EXT4_TIND_BLOCK;
312 offsets[n++] = i_block >> (ptrs_bits * 2);
313 offsets[n++] = (i_block >> ptrs_bits) & (ptrs - 1);
314 offsets[n++] = i_block & (ptrs - 1);
315 final = ptrs;
316 } else {
317 ext4_warning(inode->i_sb, "ext4_block_to_path", "block > big");
318 }
319 if (boundary)
320 *boundary = final - 1 - (i_block & (ptrs - 1));
321 return n;
322}
323
324/**
325 * ext4_get_branch - read the chain of indirect blocks leading to data
326 * @inode: inode in question
327 * @depth: depth of the chain (1 - direct pointer, etc.)
328 * @offsets: offsets of pointers in inode/indirect blocks
329 * @chain: place to store the result
330 * @err: here we store the error value
331 *
332 * Function fills the array of triples <key, p, bh> and returns %NULL
333 * if everything went OK or the pointer to the last filled triple
334 * (incomplete one) otherwise. Upon the return chain[i].key contains
335 * the number of (i+1)-th block in the chain (as it is stored in memory,
336 * i.e. little-endian 32-bit), chain[i].p contains the address of that
337 * number (it points into struct inode for i==0 and into the bh->b_data
338 * for i>0) and chain[i].bh points to the buffer_head of i-th indirect
339 * block for i>0 and NULL for i==0. In other words, it holds the block
340 * numbers of the chain, addresses they were taken from (and where we can
341 * verify that chain did not change) and buffer_heads hosting these
342 * numbers.
343 *
344 * Function stops when it stumbles upon zero pointer (absent block)
345 * (pointer to last triple returned, *@err == 0)
346 * or when it gets an IO error reading an indirect block
347 * (ditto, *@err == -EIO)
348 * or when it notices that chain had been changed while it was reading
349 * (ditto, *@err == -EAGAIN)
350 * or when it reads all @depth-1 indirect blocks successfully and finds
351 * the whole chain, all way to the data (returns %NULL, *err == 0).
352 */
353static Indirect *ext4_get_branch(struct inode *inode, int depth, int *offsets,
354 Indirect chain[4], int *err)
355{
356 struct super_block *sb = inode->i_sb;
357 Indirect *p = chain;
358 struct buffer_head *bh;
359
360 *err = 0;
361 /* i_data is not going away, no lock needed */
362 add_chain (chain, NULL, EXT4_I(inode)->i_data + *offsets);
363 if (!p->key)
364 goto no_block;
365 while (--depth) {
366 bh = sb_bread(sb, le32_to_cpu(p->key));
367 if (!bh)
368 goto failure;
369 /* Reader: pointers */
370 if (!verify_chain(chain, p))
371 goto changed;
372 add_chain(++p, bh, (__le32*)bh->b_data + *++offsets);
373 /* Reader: end */
374 if (!p->key)
375 goto no_block;
376 }
377 return NULL;
378
379changed:
380 brelse(bh);
381 *err = -EAGAIN;
382 goto no_block;
383failure:
384 *err = -EIO;
385no_block:
386 return p;
387}
388
389/**
390 * ext4_find_near - find a place for allocation with sufficient locality
391 * @inode: owner
392 * @ind: descriptor of indirect block.
393 *
394 * This function returns the prefered place for block allocation.
395 * It is used when heuristic for sequential allocation fails.
396 * Rules are:
397 * + if there is a block to the left of our position - allocate near it.
398 * + if pointer will live in indirect block - allocate near that block.
399 * + if pointer will live in inode - allocate in the same
400 * cylinder group.
401 *
402 * In the latter case we colour the starting block by the callers PID to
403 * prevent it from clashing with concurrent allocations for a different inode
404 * in the same block group. The PID is used here so that functionally related
405 * files will be close-by on-disk.
406 *
407 * Caller must make sure that @ind is valid and will stay that way.
408 */
409static ext4_fsblk_t ext4_find_near(struct inode *inode, Indirect *ind)
410{
411 struct ext4_inode_info *ei = EXT4_I(inode);
412 __le32 *start = ind->bh ? (__le32*) ind->bh->b_data : ei->i_data;
413 __le32 *p;
414 ext4_fsblk_t bg_start;
415 ext4_grpblk_t colour;
416
417 /* Try to find previous block */
418 for (p = ind->p - 1; p >= start; p--) {
419 if (*p)
420 return le32_to_cpu(*p);
421 }
422
423 /* No such thing, so let's try location of indirect block */
424 if (ind->bh)
425 return ind->bh->b_blocknr;
426
427 /*
428 * It is going to be referred to from the inode itself? OK, just put it
429 * into the same cylinder group then.
430 */
431 bg_start = ext4_group_first_block_no(inode->i_sb, ei->i_block_group);
432 colour = (current->pid % 16) *
433 (EXT4_BLOCKS_PER_GROUP(inode->i_sb) / 16);
434 return bg_start + colour;
435}
436
437/**
438 * ext4_find_goal - find a prefered place for allocation.
439 * @inode: owner
440 * @block: block we want
441 * @chain: chain of indirect blocks
442 * @partial: pointer to the last triple within a chain
443 * @goal: place to store the result.
444 *
445 * Normally this function find the prefered place for block allocation,
446 * stores it in *@goal and returns zero.
447 */
448
449static ext4_fsblk_t ext4_find_goal(struct inode *inode, long block,
450 Indirect chain[4], Indirect *partial)
451{
452 struct ext4_block_alloc_info *block_i;
453
454 block_i = EXT4_I(inode)->i_block_alloc_info;
455
456 /*
457 * try the heuristic for sequential allocation,
458 * failing that at least try to get decent locality.
459 */
460 if (block_i && (block == block_i->last_alloc_logical_block + 1)
461 && (block_i->last_alloc_physical_block != 0)) {
462 return block_i->last_alloc_physical_block + 1;
463 }
464
465 return ext4_find_near(inode, partial);
466}
467
468/**
469 * ext4_blks_to_allocate: Look up the block map and count the number
470 * of direct blocks need to be allocated for the given branch.
471 *
472 * @branch: chain of indirect blocks
473 * @k: number of blocks need for indirect blocks
474 * @blks: number of data blocks to be mapped.
475 * @blocks_to_boundary: the offset in the indirect block
476 *
477 * return the total number of blocks to be allocate, including the
478 * direct and indirect blocks.
479 */
480static int ext4_blks_to_allocate(Indirect *branch, int k, unsigned long blks,
481 int blocks_to_boundary)
482{
483 unsigned long count = 0;
484
485 /*
486 * Simple case, [t,d]Indirect block(s) has not allocated yet
487 * then it's clear blocks on that path have not allocated
488 */
489 if (k > 0) {
490 /* right now we don't handle cross boundary allocation */
491 if (blks < blocks_to_boundary + 1)
492 count += blks;
493 else
494 count += blocks_to_boundary + 1;
495 return count;
496 }
497
498 count++;
499 while (count < blks && count <= blocks_to_boundary &&
500 le32_to_cpu(*(branch[0].p + count)) == 0) {
501 count++;
502 }
503 return count;
504}
505
506/**
507 * ext4_alloc_blocks: multiple allocate blocks needed for a branch
508 * @indirect_blks: the number of blocks need to allocate for indirect
509 * blocks
510 *
511 * @new_blocks: on return it will store the new block numbers for
512 * the indirect blocks(if needed) and the first direct block,
513 * @blks: on return it will store the total number of allocated
514 * direct blocks
515 */
516static int ext4_alloc_blocks(handle_t *handle, struct inode *inode,
517 ext4_fsblk_t goal, int indirect_blks, int blks,
518 ext4_fsblk_t new_blocks[4], int *err)
519{
520 int target, i;
521 unsigned long count = 0;
522 int index = 0;
523 ext4_fsblk_t current_block = 0;
524 int ret = 0;
525
526 /*
527 * Here we try to allocate the requested multiple blocks at once,
528 * on a best-effort basis.
529 * To build a branch, we should allocate blocks for
530 * the indirect blocks(if not allocated yet), and at least
531 * the first direct block of this branch. That's the
532 * minimum number of blocks need to allocate(required)
533 */
534 target = blks + indirect_blks;
535
536 while (1) {
537 count = target;
538 /* allocating blocks for indirect blocks and direct blocks */
539 current_block = ext4_new_blocks(handle,inode,goal,&count,err);
540 if (*err)
541 goto failed_out;
542
543 target -= count;
544 /* allocate blocks for indirect blocks */
545 while (index < indirect_blks && count) {
546 new_blocks[index++] = current_block++;
547 count--;
548 }
549
550 if (count > 0)
551 break;
552 }
553
554 /* save the new block number for the first direct block */
555 new_blocks[index] = current_block;
556
557 /* total number of blocks allocated for direct blocks */
558 ret = count;
559 *err = 0;
560 return ret;
561failed_out:
562 for (i = 0; i <index; i++)
563 ext4_free_blocks(handle, inode, new_blocks[i], 1);
564 return ret;
565}
566
567/**
568 * ext4_alloc_branch - allocate and set up a chain of blocks.
569 * @inode: owner
570 * @indirect_blks: number of allocated indirect blocks
571 * @blks: number of allocated direct blocks
572 * @offsets: offsets (in the blocks) to store the pointers to next.
573 * @branch: place to store the chain in.
574 *
575 * This function allocates blocks, zeroes out all but the last one,
576 * links them into chain and (if we are synchronous) writes them to disk.
577 * In other words, it prepares a branch that can be spliced onto the
578 * inode. It stores the information about that chain in the branch[], in
579 * the same format as ext4_get_branch() would do. We are calling it after
580 * we had read the existing part of chain and partial points to the last
581 * triple of that (one with zero ->key). Upon the exit we have the same
582 * picture as after the successful ext4_get_block(), except that in one
583 * place chain is disconnected - *branch->p is still zero (we did not
584 * set the last link), but branch->key contains the number that should
585 * be placed into *branch->p to fill that gap.
586 *
587 * If allocation fails we free all blocks we've allocated (and forget
588 * their buffer_heads) and return the error value the from failed
589 * ext4_alloc_block() (normally -ENOSPC). Otherwise we set the chain
590 * as described above and return 0.
591 */
592static int ext4_alloc_branch(handle_t *handle, struct inode *inode,
593 int indirect_blks, int *blks, ext4_fsblk_t goal,
594 int *offsets, Indirect *branch)
595{
596 int blocksize = inode->i_sb->s_blocksize;
597 int i, n = 0;
598 int err = 0;
599 struct buffer_head *bh;
600 int num;
601 ext4_fsblk_t new_blocks[4];
602 ext4_fsblk_t current_block;
603
604 num = ext4_alloc_blocks(handle, inode, goal, indirect_blks,
605 *blks, new_blocks, &err);
606 if (err)
607 return err;
608
609 branch[0].key = cpu_to_le32(new_blocks[0]);
610 /*
611 * metadata blocks and data blocks are allocated.
612 */
613 for (n = 1; n <= indirect_blks; n++) {
614 /*
615 * Get buffer_head for parent block, zero it out
616 * and set the pointer to new one, then send
617 * parent to disk.
618 */
619 bh = sb_getblk(inode->i_sb, new_blocks[n-1]);
620 branch[n].bh = bh;
621 lock_buffer(bh);
622 BUFFER_TRACE(bh, "call get_create_access");
623 err = ext4_journal_get_create_access(handle, bh);
624 if (err) {
625 unlock_buffer(bh);
626 brelse(bh);
627 goto failed;
628 }
629
630 memset(bh->b_data, 0, blocksize);
631 branch[n].p = (__le32 *) bh->b_data + offsets[n];
632 branch[n].key = cpu_to_le32(new_blocks[n]);
633 *branch[n].p = branch[n].key;
634 if ( n == indirect_blks) {
635 current_block = new_blocks[n];
636 /*
637 * End of chain, update the last new metablock of
638 * the chain to point to the new allocated
639 * data blocks numbers
640 */
641 for (i=1; i < num; i++)
642 *(branch[n].p + i) = cpu_to_le32(++current_block);
643 }
644 BUFFER_TRACE(bh, "marking uptodate");
645 set_buffer_uptodate(bh);
646 unlock_buffer(bh);
647
648 BUFFER_TRACE(bh, "call ext4_journal_dirty_metadata");
649 err = ext4_journal_dirty_metadata(handle, bh);
650 if (err)
651 goto failed;
652 }
653 *blks = num;
654 return err;
655failed:
656 /* Allocation failed, free what we already allocated */
657 for (i = 1; i <= n ; i++) {
658 BUFFER_TRACE(branch[i].bh, "call jbd2_journal_forget");
659 ext4_journal_forget(handle, branch[i].bh);
660 }
661 for (i = 0; i <indirect_blks; i++)
662 ext4_free_blocks(handle, inode, new_blocks[i], 1);
663
664 ext4_free_blocks(handle, inode, new_blocks[i], num);
665
666 return err;
667}
668
669/**
670 * ext4_splice_branch - splice the allocated branch onto inode.
671 * @inode: owner
672 * @block: (logical) number of block we are adding
673 * @chain: chain of indirect blocks (with a missing link - see
674 * ext4_alloc_branch)
675 * @where: location of missing link
676 * @num: number of indirect blocks we are adding
677 * @blks: number of direct blocks we are adding
678 *
679 * This function fills the missing link and does all housekeeping needed in
680 * inode (->i_blocks, etc.). In case of success we end up with the full
681 * chain to new block and return 0.
682 */
683static int ext4_splice_branch(handle_t *handle, struct inode *inode,
684 long block, Indirect *where, int num, int blks)
685{
686 int i;
687 int err = 0;
688 struct ext4_block_alloc_info *block_i;
689 ext4_fsblk_t current_block;
690
691 block_i = EXT4_I(inode)->i_block_alloc_info;
692 /*
693 * If we're splicing into a [td]indirect block (as opposed to the
694 * inode) then we need to get write access to the [td]indirect block
695 * before the splice.
696 */
697 if (where->bh) {
698 BUFFER_TRACE(where->bh, "get_write_access");
699 err = ext4_journal_get_write_access(handle, where->bh);
700 if (err)
701 goto err_out;
702 }
703 /* That's it */
704
705 *where->p = where->key;
706
707 /*
708 * Update the host buffer_head or inode to point to more just allocated
709 * direct blocks blocks
710 */
711 if (num == 0 && blks > 1) {
712 current_block = le32_to_cpu(where->key) + 1;
713 for (i = 1; i < blks; i++)
714 *(where->p + i ) = cpu_to_le32(current_block++);
715 }
716
717 /*
718 * update the most recently allocated logical & physical block
719 * in i_block_alloc_info, to assist find the proper goal block for next
720 * allocation
721 */
722 if (block_i) {
723 block_i->last_alloc_logical_block = block + blks - 1;
724 block_i->last_alloc_physical_block =
725 le32_to_cpu(where[num].key) + blks - 1;
726 }
727
728 /* We are done with atomic stuff, now do the rest of housekeeping */
729
730 inode->i_ctime = CURRENT_TIME_SEC;
731 ext4_mark_inode_dirty(handle, inode);
732
733 /* had we spliced it onto indirect block? */
734 if (where->bh) {
735 /*
736 * If we spliced it onto an indirect block, we haven't
737 * altered the inode. Note however that if it is being spliced
738 * onto an indirect block at the very end of the file (the
739 * file is growing) then we *will* alter the inode to reflect
740 * the new i_size. But that is not done here - it is done in
741 * generic_commit_write->__mark_inode_dirty->ext4_dirty_inode.
742 */
743 jbd_debug(5, "splicing indirect only\n");
744 BUFFER_TRACE(where->bh, "call ext4_journal_dirty_metadata");
745 err = ext4_journal_dirty_metadata(handle, where->bh);
746 if (err)
747 goto err_out;
748 } else {
749 /*
750 * OK, we spliced it into the inode itself on a direct block.
751 * Inode was dirtied above.
752 */
753 jbd_debug(5, "splicing direct\n");
754 }
755 return err;
756
757err_out:
758 for (i = 1; i <= num; i++) {
759 BUFFER_TRACE(where[i].bh, "call jbd2_journal_forget");
760 ext4_journal_forget(handle, where[i].bh);
761 ext4_free_blocks(handle,inode,le32_to_cpu(where[i-1].key),1);
762 }
763 ext4_free_blocks(handle, inode, le32_to_cpu(where[num].key), blks);
764
765 return err;
766}
767
768/*
769 * Allocation strategy is simple: if we have to allocate something, we will
770 * have to go the whole way to leaf. So let's do it before attaching anything
771 * to tree, set linkage between the newborn blocks, write them if sync is
772 * required, recheck the path, free and repeat if check fails, otherwise
773 * set the last missing link (that will protect us from any truncate-generated
774 * removals - all blocks on the path are immune now) and possibly force the
775 * write on the parent block.
776 * That has a nice additional property: no special recovery from the failed
777 * allocations is needed - we simply release blocks and do not touch anything
778 * reachable from inode.
779 *
780 * `handle' can be NULL if create == 0.
781 *
782 * The BKL may not be held on entry here. Be sure to take it early.
783 * return > 0, # of blocks mapped or allocated.
784 * return = 0, if plain lookup failed.
785 * return < 0, error case.
786 */
787int ext4_get_blocks_handle(handle_t *handle, struct inode *inode,
788 sector_t iblock, unsigned long maxblocks,
789 struct buffer_head *bh_result,
790 int create, int extend_disksize)
791{
792 int err = -EIO;
793 int offsets[4];
794 Indirect chain[4];
795 Indirect *partial;
796 ext4_fsblk_t goal;
797 int indirect_blks;
798 int blocks_to_boundary = 0;
799 int depth;
800 struct ext4_inode_info *ei = EXT4_I(inode);
801 int count = 0;
802 ext4_fsblk_t first_block = 0;
803
804
805 J_ASSERT(!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL));
806 J_ASSERT(handle != NULL || create == 0);
807 depth = ext4_block_to_path(inode,iblock,offsets,&blocks_to_boundary);
808
809 if (depth == 0)
810 goto out;
811
812 partial = ext4_get_branch(inode, depth, offsets, chain, &err);
813
814 /* Simplest case - block found, no allocation needed */
815 if (!partial) {
816 first_block = le32_to_cpu(chain[depth - 1].key);
817 clear_buffer_new(bh_result);
818 count++;
819 /*map more blocks*/
820 while (count < maxblocks && count <= blocks_to_boundary) {
821 ext4_fsblk_t blk;
822
823 if (!verify_chain(chain, partial)) {
824 /*
825 * Indirect block might be removed by
826 * truncate while we were reading it.
827 * Handling of that case: forget what we've
828 * got now. Flag the err as EAGAIN, so it
829 * will reread.
830 */
831 err = -EAGAIN;
832 count = 0;
833 break;
834 }
835 blk = le32_to_cpu(*(chain[depth-1].p + count));
836
837 if (blk == first_block + count)
838 count++;
839 else
840 break;
841 }
842 if (err != -EAGAIN)
843 goto got_it;
844 }
845
846 /* Next simple case - plain lookup or failed read of indirect block */
847 if (!create || err == -EIO)
848 goto cleanup;
849
850 mutex_lock(&ei->truncate_mutex);
851
852 /*
853 * If the indirect block is missing while we are reading
854 * the chain(ext4_get_branch() returns -EAGAIN err), or
855 * if the chain has been changed after we grab the semaphore,
856 * (either because another process truncated this branch, or
857 * another get_block allocated this branch) re-grab the chain to see if
858 * the request block has been allocated or not.
859 *
860 * Since we already block the truncate/other get_block
861 * at this point, we will have the current copy of the chain when we
862 * splice the branch into the tree.
863 */
864 if (err == -EAGAIN || !verify_chain(chain, partial)) {
865 while (partial > chain) {
866 brelse(partial->bh);
867 partial--;
868 }
869 partial = ext4_get_branch(inode, depth, offsets, chain, &err);
870 if (!partial) {
871 count++;
872 mutex_unlock(&ei->truncate_mutex);
873 if (err)
874 goto cleanup;
875 clear_buffer_new(bh_result);
876 goto got_it;
877 }
878 }
879
880 /*
881 * Okay, we need to do block allocation. Lazily initialize the block
882 * allocation info here if necessary
883 */
884 if (S_ISREG(inode->i_mode) && (!ei->i_block_alloc_info))
885 ext4_init_block_alloc_info(inode);
886
887 goal = ext4_find_goal(inode, iblock, chain, partial);
888
889 /* the number of blocks need to allocate for [d,t]indirect blocks */
890 indirect_blks = (chain + depth) - partial - 1;
891
892 /*
893 * Next look up the indirect map to count the totoal number of
894 * direct blocks to allocate for this branch.
895 */
896 count = ext4_blks_to_allocate(partial, indirect_blks,
897 maxblocks, blocks_to_boundary);
898 /*
899 * Block out ext4_truncate while we alter the tree
900 */
901 err = ext4_alloc_branch(handle, inode, indirect_blks, &count, goal,
902 offsets + (partial - chain), partial);
903
904 /*
905 * The ext4_splice_branch call will free and forget any buffers
906 * on the new chain if there is a failure, but that risks using
907 * up transaction credits, especially for bitmaps where the
908 * credits cannot be returned. Can we handle this somehow? We
909 * may need to return -EAGAIN upwards in the worst case. --sct
910 */
911 if (!err)
912 err = ext4_splice_branch(handle, inode, iblock,
913 partial, indirect_blks, count);
914 /*
915 * i_disksize growing is protected by truncate_mutex. Don't forget to
916 * protect it if you're about to implement concurrent
917 * ext4_get_block() -bzzz
918 */
919 if (!err && extend_disksize && inode->i_size > ei->i_disksize)
920 ei->i_disksize = inode->i_size;
921 mutex_unlock(&ei->truncate_mutex);
922 if (err)
923 goto cleanup;
924
925 set_buffer_new(bh_result);
926got_it:
927 map_bh(bh_result, inode->i_sb, le32_to_cpu(chain[depth-1].key));
928 if (count > blocks_to_boundary)
929 set_buffer_boundary(bh_result);
930 err = count;
931 /* Clean up and exit */
932 partial = chain + depth - 1; /* the whole chain */
933cleanup:
934 while (partial > chain) {
935 BUFFER_TRACE(partial->bh, "call brelse");
936 brelse(partial->bh);
937 partial--;
938 }
939 BUFFER_TRACE(bh_result, "returned");
940out:
941 return err;
942}
943
944#define DIO_CREDITS (EXT4_RESERVE_TRANS_BLOCKS + 32)
945
946static int ext4_get_block(struct inode *inode, sector_t iblock,
947 struct buffer_head *bh_result, int create)
948{
949 handle_t *handle = journal_current_handle();
950 int ret = 0;
951 unsigned max_blocks = bh_result->b_size >> inode->i_blkbits;
952
953 if (!create)
954 goto get_block; /* A read */
955
956 if (max_blocks == 1)
957 goto get_block; /* A single block get */
958
959 if (handle->h_transaction->t_state == T_LOCKED) {
960 /*
961 * Huge direct-io writes can hold off commits for long
962 * periods of time. Let this commit run.
963 */
964 ext4_journal_stop(handle);
965 handle = ext4_journal_start(inode, DIO_CREDITS);
966 if (IS_ERR(handle))
967 ret = PTR_ERR(handle);
968 goto get_block;
969 }
970
971 if (handle->h_buffer_credits <= EXT4_RESERVE_TRANS_BLOCKS) {
972 /*
973 * Getting low on buffer credits...
974 */
975 ret = ext4_journal_extend(handle, DIO_CREDITS);
976 if (ret > 0) {
977 /*
978 * Couldn't extend the transaction. Start a new one.
979 */
980 ret = ext4_journal_restart(handle, DIO_CREDITS);
981 }
982 }
983
984get_block:
985 if (ret == 0) {
986 ret = ext4_get_blocks_wrap(handle, inode, iblock,
987 max_blocks, bh_result, create, 0);
988 if (ret > 0) {
989 bh_result->b_size = (ret << inode->i_blkbits);
990 ret = 0;
991 }
992 }
993 return ret;
994}
995
996/*
997 * `handle' can be NULL if create is zero
998 */
999struct buffer_head *ext4_getblk(handle_t *handle, struct inode *inode,
1000 long block, int create, int *errp)
1001{
1002 struct buffer_head dummy;
1003 int fatal = 0, err;
1004
1005 J_ASSERT(handle != NULL || create == 0);
1006
1007 dummy.b_state = 0;
1008 dummy.b_blocknr = -1000;
1009 buffer_trace_init(&dummy.b_history);
1010 err = ext4_get_blocks_wrap(handle, inode, block, 1,
1011 &dummy, create, 1);
1012 /*
1013 * ext4_get_blocks_handle() returns number of blocks
1014 * mapped. 0 in case of a HOLE.
1015 */
1016 if (err > 0) {
1017 if (err > 1)
1018 WARN_ON(1);
1019 err = 0;
1020 }
1021 *errp = err;
1022 if (!err && buffer_mapped(&dummy)) {
1023 struct buffer_head *bh;
1024 bh = sb_getblk(inode->i_sb, dummy.b_blocknr);
1025 if (!bh) {
1026 *errp = -EIO;
1027 goto err;
1028 }
1029 if (buffer_new(&dummy)) {
1030 J_ASSERT(create != 0);
1031 J_ASSERT(handle != 0);
1032
1033 /*
1034 * Now that we do not always journal data, we should
1035 * keep in mind whether this should always journal the
1036 * new buffer as metadata. For now, regular file
1037 * writes use ext4_get_block instead, so it's not a
1038 * problem.
1039 */
1040 lock_buffer(bh);
1041 BUFFER_TRACE(bh, "call get_create_access");
1042 fatal = ext4_journal_get_create_access(handle, bh);
1043 if (!fatal && !buffer_uptodate(bh)) {
1044 memset(bh->b_data,0,inode->i_sb->s_blocksize);
1045 set_buffer_uptodate(bh);
1046 }
1047 unlock_buffer(bh);
1048 BUFFER_TRACE(bh, "call ext4_journal_dirty_metadata");
1049 err = ext4_journal_dirty_metadata(handle, bh);
1050 if (!fatal)
1051 fatal = err;
1052 } else {
1053 BUFFER_TRACE(bh, "not a new buffer");
1054 }
1055 if (fatal) {
1056 *errp = fatal;
1057 brelse(bh);
1058 bh = NULL;
1059 }
1060 return bh;
1061 }
1062err:
1063 return NULL;
1064}
1065
1066struct buffer_head *ext4_bread(handle_t *handle, struct inode *inode,
1067 int block, int create, int *err)
1068{
1069 struct buffer_head * bh;
1070
1071 bh = ext4_getblk(handle, inode, block, create, err);
1072 if (!bh)
1073 return bh;
1074 if (buffer_uptodate(bh))
1075 return bh;
1076 ll_rw_block(READ_META, 1, &bh);
1077 wait_on_buffer(bh);
1078 if (buffer_uptodate(bh))
1079 return bh;
1080 put_bh(bh);
1081 *err = -EIO;
1082 return NULL;
1083}
1084
1085static int walk_page_buffers( handle_t *handle,
1086 struct buffer_head *head,
1087 unsigned from,
1088 unsigned to,
1089 int *partial,
1090 int (*fn)( handle_t *handle,
1091 struct buffer_head *bh))
1092{
1093 struct buffer_head *bh;
1094 unsigned block_start, block_end;
1095 unsigned blocksize = head->b_size;
1096 int err, ret = 0;
1097 struct buffer_head *next;
1098
1099 for ( bh = head, block_start = 0;
1100 ret == 0 && (bh != head || !block_start);
1101 block_start = block_end, bh = next)
1102 {
1103 next = bh->b_this_page;
1104 block_end = block_start + blocksize;
1105 if (block_end <= from || block_start >= to) {
1106 if (partial && !buffer_uptodate(bh))
1107 *partial = 1;
1108 continue;
1109 }
1110 err = (*fn)(handle, bh);
1111 if (!ret)
1112 ret = err;
1113 }
1114 return ret;
1115}
1116
1117/*
1118 * To preserve ordering, it is essential that the hole instantiation and
1119 * the data write be encapsulated in a single transaction. We cannot
1120 * close off a transaction and start a new one between the ext4_get_block()
1121 * and the commit_write(). So doing the jbd2_journal_start at the start of
1122 * prepare_write() is the right place.
1123 *
1124 * Also, this function can nest inside ext4_writepage() ->
1125 * block_write_full_page(). In that case, we *know* that ext4_writepage()
1126 * has generated enough buffer credits to do the whole page. So we won't
1127 * block on the journal in that case, which is good, because the caller may
1128 * be PF_MEMALLOC.
1129 *
1130 * By accident, ext4 can be reentered when a transaction is open via
1131 * quota file writes. If we were to commit the transaction while thus
1132 * reentered, there can be a deadlock - we would be holding a quota
1133 * lock, and the commit would never complete if another thread had a
1134 * transaction open and was blocking on the quota lock - a ranking
1135 * violation.
1136 *
1137 * So what we do is to rely on the fact that jbd2_journal_stop/journal_start
1138 * will _not_ run commit under these circumstances because handle->h_ref
1139 * is elevated. We'll still have enough credits for the tiny quotafile
1140 * write.
1141 */
1142static int do_journal_get_write_access(handle_t *handle,
1143 struct buffer_head *bh)
1144{
1145 if (!buffer_mapped(bh) || buffer_freed(bh))
1146 return 0;
1147 return ext4_journal_get_write_access(handle, bh);
1148}
1149
1150static int ext4_prepare_write(struct file *file, struct page *page,
1151 unsigned from, unsigned to)
1152{
1153 struct inode *inode = page->mapping->host;
1154 int ret, needed_blocks = ext4_writepage_trans_blocks(inode);
1155 handle_t *handle;
1156 int retries = 0;
1157
1158retry:
1159 handle = ext4_journal_start(inode, needed_blocks);
1160 if (IS_ERR(handle)) {
1161 ret = PTR_ERR(handle);
1162 goto out;
1163 }
1164 if (test_opt(inode->i_sb, NOBH) && ext4_should_writeback_data(inode))
1165 ret = nobh_prepare_write(page, from, to, ext4_get_block);
1166 else
1167 ret = block_prepare_write(page, from, to, ext4_get_block);
1168 if (ret)
1169 goto prepare_write_failed;
1170
1171 if (ext4_should_journal_data(inode)) {
1172 ret = walk_page_buffers(handle, page_buffers(page),
1173 from, to, NULL, do_journal_get_write_access);
1174 }
1175prepare_write_failed:
1176 if (ret)
1177 ext4_journal_stop(handle);
1178 if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
1179 goto retry;
1180out:
1181 return ret;
1182}
1183
1184int ext4_journal_dirty_data(handle_t *handle, struct buffer_head *bh)
1185{
1186 int err = jbd2_journal_dirty_data(handle, bh);
1187 if (err)
1188 ext4_journal_abort_handle(__FUNCTION__, __FUNCTION__,
1189 bh, handle,err);
1190 return err;
1191}
1192
1193/* For commit_write() in data=journal mode */
1194static int commit_write_fn(handle_t *handle, struct buffer_head *bh)
1195{
1196 if (!buffer_mapped(bh) || buffer_freed(bh))
1197 return 0;
1198 set_buffer_uptodate(bh);
1199 return ext4_journal_dirty_metadata(handle, bh);
1200}
1201
1202/*
1203 * We need to pick up the new inode size which generic_commit_write gave us
1204 * `file' can be NULL - eg, when called from page_symlink().
1205 *
1206 * ext4 never places buffers on inode->i_mapping->private_list. metadata
1207 * buffers are managed internally.
1208 */
1209static int ext4_ordered_commit_write(struct file *file, struct page *page,
1210 unsigned from, unsigned to)
1211{
1212 handle_t *handle = ext4_journal_current_handle();
1213 struct inode *inode = page->mapping->host;
1214 int ret = 0, ret2;
1215
1216 ret = walk_page_buffers(handle, page_buffers(page),
1217 from, to, NULL, ext4_journal_dirty_data);
1218
1219 if (ret == 0) {
1220 /*
1221 * generic_commit_write() will run mark_inode_dirty() if i_size
1222 * changes. So let's piggyback the i_disksize mark_inode_dirty
1223 * into that.
1224 */
1225 loff_t new_i_size;
1226
1227 new_i_size = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to;
1228 if (new_i_size > EXT4_I(inode)->i_disksize)
1229 EXT4_I(inode)->i_disksize = new_i_size;
1230 ret = generic_commit_write(file, page, from, to);
1231 }
1232 ret2 = ext4_journal_stop(handle);
1233 if (!ret)
1234 ret = ret2;
1235 return ret;
1236}
1237
1238static int ext4_writeback_commit_write(struct file *file, struct page *page,
1239 unsigned from, unsigned to)
1240{
1241 handle_t *handle = ext4_journal_current_handle();
1242 struct inode *inode = page->mapping->host;
1243 int ret = 0, ret2;
1244 loff_t new_i_size;
1245
1246 new_i_size = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to;
1247 if (new_i_size > EXT4_I(inode)->i_disksize)
1248 EXT4_I(inode)->i_disksize = new_i_size;
1249
1250 if (test_opt(inode->i_sb, NOBH) && ext4_should_writeback_data(inode))
1251 ret = nobh_commit_write(file, page, from, to);
1252 else
1253 ret = generic_commit_write(file, page, from, to);
1254
1255 ret2 = ext4_journal_stop(handle);
1256 if (!ret)
1257 ret = ret2;
1258 return ret;
1259}
1260
1261static int ext4_journalled_commit_write(struct file *file,
1262 struct page *page, unsigned from, unsigned to)
1263{
1264 handle_t *handle = ext4_journal_current_handle();
1265 struct inode *inode = page->mapping->host;
1266 int ret = 0, ret2;
1267 int partial = 0;
1268 loff_t pos;
1269
1270 /*
1271 * Here we duplicate the generic_commit_write() functionality
1272 */
1273 pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to;
1274
1275 ret = walk_page_buffers(handle, page_buffers(page), from,
1276 to, &partial, commit_write_fn);
1277 if (!partial)
1278 SetPageUptodate(page);
1279 if (pos > inode->i_size)
1280 i_size_write(inode, pos);
1281 EXT4_I(inode)->i_state |= EXT4_STATE_JDATA;
1282 if (inode->i_size > EXT4_I(inode)->i_disksize) {
1283 EXT4_I(inode)->i_disksize = inode->i_size;
1284 ret2 = ext4_mark_inode_dirty(handle, inode);
1285 if (!ret)
1286 ret = ret2;
1287 }
1288 ret2 = ext4_journal_stop(handle);
1289 if (!ret)
1290 ret = ret2;
1291 return ret;
1292}
1293
1294/*
1295 * bmap() is special. It gets used by applications such as lilo and by
1296 * the swapper to find the on-disk block of a specific piece of data.
1297 *
1298 * Naturally, this is dangerous if the block concerned is still in the
1299 * journal. If somebody makes a swapfile on an ext4 data-journaling
1300 * filesystem and enables swap, then they may get a nasty shock when the
1301 * data getting swapped to that swapfile suddenly gets overwritten by
1302 * the original zero's written out previously to the journal and
1303 * awaiting writeback in the kernel's buffer cache.
1304 *
1305 * So, if we see any bmap calls here on a modified, data-journaled file,
1306 * take extra steps to flush any blocks which might be in the cache.
1307 */
1308static sector_t ext4_bmap(struct address_space *mapping, sector_t block)
1309{
1310 struct inode *inode = mapping->host;
1311 journal_t *journal;
1312 int err;
1313
1314 if (EXT4_I(inode)->i_state & EXT4_STATE_JDATA) {
1315 /*
1316 * This is a REALLY heavyweight approach, but the use of
1317 * bmap on dirty files is expected to be extremely rare:
1318 * only if we run lilo or swapon on a freshly made file
1319 * do we expect this to happen.
1320 *
1321 * (bmap requires CAP_SYS_RAWIO so this does not
1322 * represent an unprivileged user DOS attack --- we'd be
1323 * in trouble if mortal users could trigger this path at
1324 * will.)
1325 *
1326 * NB. EXT4_STATE_JDATA is not set on files other than
1327 * regular files. If somebody wants to bmap a directory
1328 * or symlink and gets confused because the buffer
1329 * hasn't yet been flushed to disk, they deserve
1330 * everything they get.
1331 */
1332
1333 EXT4_I(inode)->i_state &= ~EXT4_STATE_JDATA;
1334 journal = EXT4_JOURNAL(inode);
1335 jbd2_journal_lock_updates(journal);
1336 err = jbd2_journal_flush(journal);
1337 jbd2_journal_unlock_updates(journal);
1338
1339 if (err)
1340 return 0;
1341 }
1342
1343 return generic_block_bmap(mapping,block,ext4_get_block);
1344}
1345
1346static int bget_one(handle_t *handle, struct buffer_head *bh)
1347{
1348 get_bh(bh);
1349 return 0;
1350}
1351
1352static int bput_one(handle_t *handle, struct buffer_head *bh)
1353{
1354 put_bh(bh);
1355 return 0;
1356}
1357
1358static int jbd2_journal_dirty_data_fn(handle_t *handle, struct buffer_head *bh)
1359{
1360 if (buffer_mapped(bh))
1361 return ext4_journal_dirty_data(handle, bh);
1362 return 0;
1363}
1364
1365/*
1366 * Note that we always start a transaction even if we're not journalling
1367 * data. This is to preserve ordering: any hole instantiation within
1368 * __block_write_full_page -> ext4_get_block() should be journalled
1369 * along with the data so we don't crash and then get metadata which
1370 * refers to old data.
1371 *
1372 * In all journalling modes block_write_full_page() will start the I/O.
1373 *
1374 * Problem:
1375 *
1376 * ext4_writepage() -> kmalloc() -> __alloc_pages() -> page_launder() ->
1377 * ext4_writepage()
1378 *
1379 * Similar for:
1380 *
1381 * ext4_file_write() -> generic_file_write() -> __alloc_pages() -> ...
1382 *
1383 * Same applies to ext4_get_block(). We will deadlock on various things like
1384 * lock_journal and i_truncate_mutex.
1385 *
1386 * Setting PF_MEMALLOC here doesn't work - too many internal memory
1387 * allocations fail.
1388 *
1389 * 16May01: If we're reentered then journal_current_handle() will be
1390 * non-zero. We simply *return*.
1391 *
1392 * 1 July 2001: @@@ FIXME:
1393 * In journalled data mode, a data buffer may be metadata against the
1394 * current transaction. But the same file is part of a shared mapping
1395 * and someone does a writepage() on it.
1396 *
1397 * We will move the buffer onto the async_data list, but *after* it has
1398 * been dirtied. So there's a small window where we have dirty data on
1399 * BJ_Metadata.
1400 *
1401 * Note that this only applies to the last partial page in the file. The
1402 * bit which block_write_full_page() uses prepare/commit for. (That's
1403 * broken code anyway: it's wrong for msync()).
1404 *
1405 * It's a rare case: affects the final partial page, for journalled data
1406 * where the file is subject to bith write() and writepage() in the same
1407 * transction. To fix it we'll need a custom block_write_full_page().
1408 * We'll probably need that anyway for journalling writepage() output.
1409 *
1410 * We don't honour synchronous mounts for writepage(). That would be
1411 * disastrous. Any write() or metadata operation will sync the fs for
1412 * us.
1413 *
1414 * AKPM2: if all the page's buffers are mapped to disk and !data=journal,
1415 * we don't need to open a transaction here.
1416 */
1417static int ext4_ordered_writepage(struct page *page,
1418 struct writeback_control *wbc)
1419{
1420 struct inode *inode = page->mapping->host;
1421 struct buffer_head *page_bufs;
1422 handle_t *handle = NULL;
1423 int ret = 0;
1424 int err;
1425
1426 J_ASSERT(PageLocked(page));
1427
1428 /*
1429 * We give up here if we're reentered, because it might be for a
1430 * different filesystem.
1431 */
1432 if (ext4_journal_current_handle())
1433 goto out_fail;
1434
1435 handle = ext4_journal_start(inode, ext4_writepage_trans_blocks(inode));
1436
1437 if (IS_ERR(handle)) {
1438 ret = PTR_ERR(handle);
1439 goto out_fail;
1440 }
1441
1442 if (!page_has_buffers(page)) {
1443 create_empty_buffers(page, inode->i_sb->s_blocksize,
1444 (1 << BH_Dirty)|(1 << BH_Uptodate));
1445 }
1446 page_bufs = page_buffers(page);
1447 walk_page_buffers(handle, page_bufs, 0,
1448 PAGE_CACHE_SIZE, NULL, bget_one);
1449
1450 ret = block_write_full_page(page, ext4_get_block, wbc);
1451
1452 /*
1453 * The page can become unlocked at any point now, and
1454 * truncate can then come in and change things. So we
1455 * can't touch *page from now on. But *page_bufs is
1456 * safe due to elevated refcount.
1457 */
1458
1459 /*
1460 * And attach them to the current transaction. But only if
1461 * block_write_full_page() succeeded. Otherwise they are unmapped,
1462 * and generally junk.
1463 */
1464 if (ret == 0) {
1465 err = walk_page_buffers(handle, page_bufs, 0, PAGE_CACHE_SIZE,
1466 NULL, jbd2_journal_dirty_data_fn);
1467 if (!ret)
1468 ret = err;
1469 }
1470 walk_page_buffers(handle, page_bufs, 0,
1471 PAGE_CACHE_SIZE, NULL, bput_one);
1472 err = ext4_journal_stop(handle);
1473 if (!ret)
1474 ret = err;
1475 return ret;
1476
1477out_fail:
1478 redirty_page_for_writepage(wbc, page);
1479 unlock_page(page);
1480 return ret;
1481}
1482
1483static int ext4_writeback_writepage(struct page *page,
1484 struct writeback_control *wbc)
1485{
1486 struct inode *inode = page->mapping->host;
1487 handle_t *handle = NULL;
1488 int ret = 0;
1489 int err;
1490
1491 if (ext4_journal_current_handle())
1492 goto out_fail;
1493
1494 handle = ext4_journal_start(inode, ext4_writepage_trans_blocks(inode));
1495 if (IS_ERR(handle)) {
1496 ret = PTR_ERR(handle);
1497 goto out_fail;
1498 }
1499
1500 if (test_opt(inode->i_sb, NOBH) && ext4_should_writeback_data(inode))
1501 ret = nobh_writepage(page, ext4_get_block, wbc);
1502 else
1503 ret = block_write_full_page(page, ext4_get_block, wbc);
1504
1505 err = ext4_journal_stop(handle);
1506 if (!ret)
1507 ret = err;
1508 return ret;
1509
1510out_fail:
1511 redirty_page_for_writepage(wbc, page);
1512 unlock_page(page);
1513 return ret;
1514}
1515
1516static int ext4_journalled_writepage(struct page *page,
1517 struct writeback_control *wbc)
1518{
1519 struct inode *inode = page->mapping->host;
1520 handle_t *handle = NULL;
1521 int ret = 0;
1522 int err;
1523
1524 if (ext4_journal_current_handle())
1525 goto no_write;
1526
1527 handle = ext4_journal_start(inode, ext4_writepage_trans_blocks(inode));
1528 if (IS_ERR(handle)) {
1529 ret = PTR_ERR(handle);
1530 goto no_write;
1531 }
1532
1533 if (!page_has_buffers(page) || PageChecked(page)) {
1534 /*
1535 * It's mmapped pagecache. Add buffers and journal it. There
1536 * doesn't seem much point in redirtying the page here.
1537 */
1538 ClearPageChecked(page);
1539 ret = block_prepare_write(page, 0, PAGE_CACHE_SIZE,
1540 ext4_get_block);
1541 if (ret != 0) {
1542 ext4_journal_stop(handle);
1543 goto out_unlock;
1544 }
1545 ret = walk_page_buffers(handle, page_buffers(page), 0,
1546 PAGE_CACHE_SIZE, NULL, do_journal_get_write_access);
1547
1548 err = walk_page_buffers(handle, page_buffers(page), 0,
1549 PAGE_CACHE_SIZE, NULL, commit_write_fn);
1550 if (ret == 0)
1551 ret = err;
1552 EXT4_I(inode)->i_state |= EXT4_STATE_JDATA;
1553 unlock_page(page);
1554 } else {
1555 /*
1556 * It may be a page full of checkpoint-mode buffers. We don't
1557 * really know unless we go poke around in the buffer_heads.
1558 * But block_write_full_page will do the right thing.
1559 */
1560 ret = block_write_full_page(page, ext4_get_block, wbc);
1561 }
1562 err = ext4_journal_stop(handle);
1563 if (!ret)
1564 ret = err;
1565out:
1566 return ret;
1567
1568no_write:
1569 redirty_page_for_writepage(wbc, page);
1570out_unlock:
1571 unlock_page(page);
1572 goto out;
1573}
1574
1575static int ext4_readpage(struct file *file, struct page *page)
1576{
1577 return mpage_readpage(page, ext4_get_block);
1578}
1579
1580static int
1581ext4_readpages(struct file *file, struct address_space *mapping,
1582 struct list_head *pages, unsigned nr_pages)
1583{
1584 return mpage_readpages(mapping, pages, nr_pages, ext4_get_block);
1585}
1586
1587static void ext4_invalidatepage(struct page *page, unsigned long offset)
1588{
1589 journal_t *journal = EXT4_JOURNAL(page->mapping->host);
1590
1591 /*
1592 * If it's a full truncate we just forget about the pending dirtying
1593 */
1594 if (offset == 0)
1595 ClearPageChecked(page);
1596
1597 jbd2_journal_invalidatepage(journal, page, offset);
1598}
1599
1600static int ext4_releasepage(struct page *page, gfp_t wait)
1601{
1602 journal_t *journal = EXT4_JOURNAL(page->mapping->host);
1603
1604 WARN_ON(PageChecked(page));
1605 if (!page_has_buffers(page))
1606 return 0;
1607 return jbd2_journal_try_to_free_buffers(journal, page, wait);
1608}
1609
1610/*
1611 * If the O_DIRECT write will extend the file then add this inode to the
1612 * orphan list. So recovery will truncate it back to the original size
1613 * if the machine crashes during the write.
1614 *
1615 * If the O_DIRECT write is intantiating holes inside i_size and the machine
1616 * crashes then stale disk data _may_ be exposed inside the file.
1617 */
1618static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb,
1619 const struct iovec *iov, loff_t offset,
1620 unsigned long nr_segs)
1621{
1622 struct file *file = iocb->ki_filp;
1623 struct inode *inode = file->f_mapping->host;
1624 struct ext4_inode_info *ei = EXT4_I(inode);
1625 handle_t *handle = NULL;
1626 ssize_t ret;
1627 int orphan = 0;
1628 size_t count = iov_length(iov, nr_segs);
1629
1630 if (rw == WRITE) {
1631 loff_t final_size = offset + count;
1632
1633 handle = ext4_journal_start(inode, DIO_CREDITS);
1634 if (IS_ERR(handle)) {
1635 ret = PTR_ERR(handle);
1636 goto out;
1637 }
1638 if (final_size > inode->i_size) {
1639 ret = ext4_orphan_add(handle, inode);
1640 if (ret)
1641 goto out_stop;
1642 orphan = 1;
1643 ei->i_disksize = inode->i_size;
1644 }
1645 }
1646
1647 ret = blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
1648 offset, nr_segs,
1649 ext4_get_block, NULL);
1650
1651 /*
1652 * Reacquire the handle: ext4_get_block() can restart the transaction
1653 */
1654 handle = journal_current_handle();
1655
1656out_stop:
1657 if (handle) {
1658 int err;
1659
1660 if (orphan && inode->i_nlink)
1661 ext4_orphan_del(handle, inode);
1662 if (orphan && ret > 0) {
1663 loff_t end = offset + ret;
1664 if (end > inode->i_size) {
1665 ei->i_disksize = end;
1666 i_size_write(inode, end);
1667 /*
1668 * We're going to return a positive `ret'
1669 * here due to non-zero-length I/O, so there's
1670 * no way of reporting error returns from
1671 * ext4_mark_inode_dirty() to userspace. So
1672 * ignore it.
1673 */
1674 ext4_mark_inode_dirty(handle, inode);
1675 }
1676 }
1677 err = ext4_journal_stop(handle);
1678 if (ret == 0)
1679 ret = err;
1680 }
1681out:
1682 return ret;
1683}
1684
1685/*
1686 * Pages can be marked dirty completely asynchronously from ext4's journalling
1687 * activity. By filemap_sync_pte(), try_to_unmap_one(), etc. We cannot do
1688 * much here because ->set_page_dirty is called under VFS locks. The page is
1689 * not necessarily locked.
1690 *
1691 * We cannot just dirty the page and leave attached buffers clean, because the
1692 * buffers' dirty state is "definitive". We cannot just set the buffers dirty
1693 * or jbddirty because all the journalling code will explode.
1694 *
1695 * So what we do is to mark the page "pending dirty" and next time writepage
1696 * is called, propagate that into the buffers appropriately.
1697 */
1698static int ext4_journalled_set_page_dirty(struct page *page)
1699{
1700 SetPageChecked(page);
1701 return __set_page_dirty_nobuffers(page);
1702}
1703
1704static const struct address_space_operations ext4_ordered_aops = {
1705 .readpage = ext4_readpage,
1706 .readpages = ext4_readpages,
1707 .writepage = ext4_ordered_writepage,
1708 .sync_page = block_sync_page,
1709 .prepare_write = ext4_prepare_write,
1710 .commit_write = ext4_ordered_commit_write,
1711 .bmap = ext4_bmap,
1712 .invalidatepage = ext4_invalidatepage,
1713 .releasepage = ext4_releasepage,
1714 .direct_IO = ext4_direct_IO,
1715 .migratepage = buffer_migrate_page,
1716};
1717
1718static const struct address_space_operations ext4_writeback_aops = {
1719 .readpage = ext4_readpage,
1720 .readpages = ext4_readpages,
1721 .writepage = ext4_writeback_writepage,
1722 .sync_page = block_sync_page,
1723 .prepare_write = ext4_prepare_write,
1724 .commit_write = ext4_writeback_commit_write,
1725 .bmap = ext4_bmap,
1726 .invalidatepage = ext4_invalidatepage,
1727 .releasepage = ext4_releasepage,
1728 .direct_IO = ext4_direct_IO,
1729 .migratepage = buffer_migrate_page,
1730};
1731
1732static const struct address_space_operations ext4_journalled_aops = {
1733 .readpage = ext4_readpage,
1734 .readpages = ext4_readpages,
1735 .writepage = ext4_journalled_writepage,
1736 .sync_page = block_sync_page,
1737 .prepare_write = ext4_prepare_write,
1738 .commit_write = ext4_journalled_commit_write,
1739 .set_page_dirty = ext4_journalled_set_page_dirty,
1740 .bmap = ext4_bmap,
1741 .invalidatepage = ext4_invalidatepage,
1742 .releasepage = ext4_releasepage,
1743};
1744
1745void ext4_set_aops(struct inode *inode)
1746{
1747 if (ext4_should_order_data(inode))
1748 inode->i_mapping->a_ops = &ext4_ordered_aops;
1749 else if (ext4_should_writeback_data(inode))
1750 inode->i_mapping->a_ops = &ext4_writeback_aops;
1751 else
1752 inode->i_mapping->a_ops = &ext4_journalled_aops;
1753}
1754
1755/*
1756 * ext4_block_truncate_page() zeroes out a mapping from file offset `from'
1757 * up to the end of the block which corresponds to `from'.
1758 * This required during truncate. We need to physically zero the tail end
1759 * of that block so it doesn't yield old data if the file is later grown.
1760 */
1761int ext4_block_truncate_page(handle_t *handle, struct page *page,
1762 struct address_space *mapping, loff_t from)
1763{
1764 ext4_fsblk_t index = from >> PAGE_CACHE_SHIFT;
1765 unsigned offset = from & (PAGE_CACHE_SIZE-1);
1766 unsigned blocksize, iblock, length, pos;
1767 struct inode *inode = mapping->host;
1768 struct buffer_head *bh;
1769 int err = 0;
1770 void *kaddr;
1771
1772 blocksize = inode->i_sb->s_blocksize;
1773 length = blocksize - (offset & (blocksize - 1));
1774 iblock = index << (PAGE_CACHE_SHIFT - inode->i_sb->s_blocksize_bits);
1775
1776 /*
1777 * For "nobh" option, we can only work if we don't need to
1778 * read-in the page - otherwise we create buffers to do the IO.
1779 */
1780 if (!page_has_buffers(page) && test_opt(inode->i_sb, NOBH) &&
1781 ext4_should_writeback_data(inode) && PageUptodate(page)) {
1782 kaddr = kmap_atomic(page, KM_USER0);
1783 memset(kaddr + offset, 0, length);
1784 flush_dcache_page(page);
1785 kunmap_atomic(kaddr, KM_USER0);
1786 set_page_dirty(page);
1787 goto unlock;
1788 }
1789
1790 if (!page_has_buffers(page))
1791 create_empty_buffers(page, blocksize, 0);
1792
1793 /* Find the buffer that contains "offset" */
1794 bh = page_buffers(page);
1795 pos = blocksize;
1796 while (offset >= pos) {
1797 bh = bh->b_this_page;
1798 iblock++;
1799 pos += blocksize;
1800 }
1801
1802 err = 0;
1803 if (buffer_freed(bh)) {
1804 BUFFER_TRACE(bh, "freed: skip");
1805 goto unlock;
1806 }
1807
1808 if (!buffer_mapped(bh)) {
1809 BUFFER_TRACE(bh, "unmapped");
1810 ext4_get_block(inode, iblock, bh, 0);
1811 /* unmapped? It's a hole - nothing to do */
1812 if (!buffer_mapped(bh)) {
1813 BUFFER_TRACE(bh, "still unmapped");
1814 goto unlock;
1815 }
1816 }
1817
1818 /* Ok, it's mapped. Make sure it's up-to-date */
1819 if (PageUptodate(page))
1820 set_buffer_uptodate(bh);
1821
1822 if (!buffer_uptodate(bh)) {
1823 err = -EIO;
1824 ll_rw_block(READ, 1, &bh);
1825 wait_on_buffer(bh);
1826 /* Uhhuh. Read error. Complain and punt. */
1827 if (!buffer_uptodate(bh))
1828 goto unlock;
1829 }
1830
1831 if (ext4_should_journal_data(inode)) {
1832 BUFFER_TRACE(bh, "get write access");
1833 err = ext4_journal_get_write_access(handle, bh);
1834 if (err)
1835 goto unlock;
1836 }
1837
1838 kaddr = kmap_atomic(page, KM_USER0);
1839 memset(kaddr + offset, 0, length);
1840 flush_dcache_page(page);
1841 kunmap_atomic(kaddr, KM_USER0);
1842
1843 BUFFER_TRACE(bh, "zeroed end of block");
1844
1845 err = 0;
1846 if (ext4_should_journal_data(inode)) {
1847 err = ext4_journal_dirty_metadata(handle, bh);
1848 } else {
1849 if (ext4_should_order_data(inode))
1850 err = ext4_journal_dirty_data(handle, bh);
1851 mark_buffer_dirty(bh);
1852 }
1853
1854unlock:
1855 unlock_page(page);
1856 page_cache_release(page);
1857 return err;
1858}
1859
1860/*
1861 * Probably it should be a library function... search for first non-zero word
1862 * or memcmp with zero_page, whatever is better for particular architecture.
1863 * Linus?
1864 */
1865static inline int all_zeroes(__le32 *p, __le32 *q)
1866{
1867 while (p < q)
1868 if (*p++)
1869 return 0;
1870 return 1;
1871}
1872
1873/**
1874 * ext4_find_shared - find the indirect blocks for partial truncation.
1875 * @inode: inode in question
1876 * @depth: depth of the affected branch
1877 * @offsets: offsets of pointers in that branch (see ext4_block_to_path)
1878 * @chain: place to store the pointers to partial indirect blocks
1879 * @top: place to the (detached) top of branch
1880 *
1881 * This is a helper function used by ext4_truncate().
1882 *
1883 * When we do truncate() we may have to clean the ends of several
1884 * indirect blocks but leave the blocks themselves alive. Block is
1885 * partially truncated if some data below the new i_size is refered
1886 * from it (and it is on the path to the first completely truncated
1887 * data block, indeed). We have to free the top of that path along
1888 * with everything to the right of the path. Since no allocation
1889 * past the truncation point is possible until ext4_truncate()
1890 * finishes, we may safely do the latter, but top of branch may
1891 * require special attention - pageout below the truncation point
1892 * might try to populate it.
1893 *
1894 * We atomically detach the top of branch from the tree, store the
1895 * block number of its root in *@top, pointers to buffer_heads of
1896 * partially truncated blocks - in @chain[].bh and pointers to
1897 * their last elements that should not be removed - in
1898 * @chain[].p. Return value is the pointer to last filled element
1899 * of @chain.
1900 *
1901 * The work left to caller to do the actual freeing of subtrees:
1902 * a) free the subtree starting from *@top
1903 * b) free the subtrees whose roots are stored in
1904 * (@chain[i].p+1 .. end of @chain[i].bh->b_data)
1905 * c) free the subtrees growing from the inode past the @chain[0].
1906 * (no partially truncated stuff there). */
1907
1908static Indirect *ext4_find_shared(struct inode *inode, int depth,
1909 int offsets[4], Indirect chain[4], __le32 *top)
1910{
1911 Indirect *partial, *p;
1912 int k, err;
1913
1914 *top = 0;
1915 /* Make k index the deepest non-null offest + 1 */
1916 for (k = depth; k > 1 && !offsets[k-1]; k--)
1917 ;
1918 partial = ext4_get_branch(inode, k, offsets, chain, &err);
1919 /* Writer: pointers */
1920 if (!partial)
1921 partial = chain + k-1;
1922 /*
1923 * If the branch acquired continuation since we've looked at it -
1924 * fine, it should all survive and (new) top doesn't belong to us.
1925 */
1926 if (!partial->key && *partial->p)
1927 /* Writer: end */
1928 goto no_top;
1929 for (p=partial; p>chain && all_zeroes((__le32*)p->bh->b_data,p->p); p--)
1930 ;
1931 /*
1932 * OK, we've found the last block that must survive. The rest of our
1933 * branch should be detached before unlocking. However, if that rest
1934 * of branch is all ours and does not grow immediately from the inode
1935 * it's easier to cheat and just decrement partial->p.
1936 */
1937 if (p == chain + k - 1 && p > chain) {
1938 p->p--;
1939 } else {
1940 *top = *p->p;
1941 /* Nope, don't do this in ext4. Must leave the tree intact */
1942#if 0
1943 *p->p = 0;
1944#endif
1945 }
1946 /* Writer: end */
1947
1948 while(partial > p) {
1949 brelse(partial->bh);
1950 partial--;
1951 }
1952no_top:
1953 return partial;
1954}
1955
1956/*
1957 * Zero a number of block pointers in either an inode or an indirect block.
1958 * If we restart the transaction we must again get write access to the
1959 * indirect block for further modification.
1960 *
1961 * We release `count' blocks on disk, but (last - first) may be greater
1962 * than `count' because there can be holes in there.
1963 */
1964static void ext4_clear_blocks(handle_t *handle, struct inode *inode,
1965 struct buffer_head *bh, ext4_fsblk_t block_to_free,
1966 unsigned long count, __le32 *first, __le32 *last)
1967{
1968 __le32 *p;
1969 if (try_to_extend_transaction(handle, inode)) {
1970 if (bh) {
1971 BUFFER_TRACE(bh, "call ext4_journal_dirty_metadata");
1972 ext4_journal_dirty_metadata(handle, bh);
1973 }
1974 ext4_mark_inode_dirty(handle, inode);
1975 ext4_journal_test_restart(handle, inode);
1976 if (bh) {
1977 BUFFER_TRACE(bh, "retaking write access");
1978 ext4_journal_get_write_access(handle, bh);
1979 }
1980 }
1981
1982 /*
1983 * Any buffers which are on the journal will be in memory. We find
1984 * them on the hash table so jbd2_journal_revoke() will run jbd2_journal_forget()
1985 * on them. We've already detached each block from the file, so
1986 * bforget() in jbd2_journal_forget() should be safe.
1987 *
1988 * AKPM: turn on bforget in jbd2_journal_forget()!!!
1989 */
1990 for (p = first; p < last; p++) {
1991 u32 nr = le32_to_cpu(*p);
1992 if (nr) {
1993 struct buffer_head *bh;
1994
1995 *p = 0;
1996 bh = sb_find_get_block(inode->i_sb, nr);
1997 ext4_forget(handle, 0, inode, bh, nr);
1998 }
1999 }
2000
2001 ext4_free_blocks(handle, inode, block_to_free, count);
2002}
2003
2004/**
2005 * ext4_free_data - free a list of data blocks
2006 * @handle: handle for this transaction
2007 * @inode: inode we are dealing with
2008 * @this_bh: indirect buffer_head which contains *@first and *@last
2009 * @first: array of block numbers
2010 * @last: points immediately past the end of array
2011 *
2012 * We are freeing all blocks refered from that array (numbers are stored as
2013 * little-endian 32-bit) and updating @inode->i_blocks appropriately.
2014 *
2015 * We accumulate contiguous runs of blocks to free. Conveniently, if these
2016 * blocks are contiguous then releasing them at one time will only affect one
2017 * or two bitmap blocks (+ group descriptor(s) and superblock) and we won't
2018 * actually use a lot of journal space.
2019 *
2020 * @this_bh will be %NULL if @first and @last point into the inode's direct
2021 * block pointers.
2022 */
2023static void ext4_free_data(handle_t *handle, struct inode *inode,
2024 struct buffer_head *this_bh,
2025 __le32 *first, __le32 *last)
2026{
2027 ext4_fsblk_t block_to_free = 0; /* Starting block # of a run */
2028 unsigned long count = 0; /* Number of blocks in the run */
2029 __le32 *block_to_free_p = NULL; /* Pointer into inode/ind
2030 corresponding to
2031 block_to_free */
2032 ext4_fsblk_t nr; /* Current block # */
2033 __le32 *p; /* Pointer into inode/ind
2034 for current block */
2035 int err;
2036
2037 if (this_bh) { /* For indirect block */
2038 BUFFER_TRACE(this_bh, "get_write_access");
2039 err = ext4_journal_get_write_access(handle, this_bh);
2040 /* Important: if we can't update the indirect pointers
2041 * to the blocks, we can't free them. */
2042 if (err)
2043 return;
2044 }
2045
2046 for (p = first; p < last; p++) {
2047 nr = le32_to_cpu(*p);
2048 if (nr) {
2049 /* accumulate blocks to free if they're contiguous */
2050 if (count == 0) {
2051 block_to_free = nr;
2052 block_to_free_p = p;
2053 count = 1;
2054 } else if (nr == block_to_free + count) {
2055 count++;
2056 } else {
2057 ext4_clear_blocks(handle, inode, this_bh,
2058 block_to_free,
2059 count, block_to_free_p, p);
2060 block_to_free = nr;
2061 block_to_free_p = p;
2062 count = 1;
2063 }
2064 }
2065 }
2066
2067 if (count > 0)
2068 ext4_clear_blocks(handle, inode, this_bh, block_to_free,
2069 count, block_to_free_p, p);
2070
2071 if (this_bh) {
2072 BUFFER_TRACE(this_bh, "call ext4_journal_dirty_metadata");
2073 ext4_journal_dirty_metadata(handle, this_bh);
2074 }
2075}
2076
2077/**
2078 * ext4_free_branches - free an array of branches
2079 * @handle: JBD handle for this transaction
2080 * @inode: inode we are dealing with
2081 * @parent_bh: the buffer_head which contains *@first and *@last
2082 * @first: array of block numbers
2083 * @last: pointer immediately past the end of array
2084 * @depth: depth of the branches to free
2085 *
2086 * We are freeing all blocks refered from these branches (numbers are
2087 * stored as little-endian 32-bit) and updating @inode->i_blocks
2088 * appropriately.
2089 */
2090static void ext4_free_branches(handle_t *handle, struct inode *inode,
2091 struct buffer_head *parent_bh,
2092 __le32 *first, __le32 *last, int depth)
2093{
2094 ext4_fsblk_t nr;
2095 __le32 *p;
2096
2097 if (is_handle_aborted(handle))
2098 return;
2099
2100 if (depth--) {
2101 struct buffer_head *bh;
2102 int addr_per_block = EXT4_ADDR_PER_BLOCK(inode->i_sb);
2103 p = last;
2104 while (--p >= first) {
2105 nr = le32_to_cpu(*p);
2106 if (!nr)
2107 continue; /* A hole */
2108
2109 /* Go read the buffer for the next level down */
2110 bh = sb_bread(inode->i_sb, nr);
2111
2112 /*
2113 * A read failure? Report error and clear slot
2114 * (should be rare).
2115 */
2116 if (!bh) {
2117 ext4_error(inode->i_sb, "ext4_free_branches",
2118 "Read failure, inode=%lu, block=%llu",
2119 inode->i_ino, nr);
2120 continue;
2121 }
2122
2123 /* This zaps the entire block. Bottom up. */
2124 BUFFER_TRACE(bh, "free child branches");
2125 ext4_free_branches(handle, inode, bh,
2126 (__le32*)bh->b_data,
2127 (__le32*)bh->b_data + addr_per_block,
2128 depth);
2129
2130 /*
2131 * We've probably journalled the indirect block several
2132 * times during the truncate. But it's no longer
2133 * needed and we now drop it from the transaction via
2134 * jbd2_journal_revoke().
2135 *
2136 * That's easy if it's exclusively part of this
2137 * transaction. But if it's part of the committing
2138 * transaction then jbd2_journal_forget() will simply
2139 * brelse() it. That means that if the underlying
2140 * block is reallocated in ext4_get_block(),
2141 * unmap_underlying_metadata() will find this block
2142 * and will try to get rid of it. damn, damn.
2143 *
2144 * If this block has already been committed to the
2145 * journal, a revoke record will be written. And
2146 * revoke records must be emitted *before* clearing
2147 * this block's bit in the bitmaps.
2148 */
2149 ext4_forget(handle, 1, inode, bh, bh->b_blocknr);
2150
2151 /*
2152 * Everything below this this pointer has been
2153 * released. Now let this top-of-subtree go.
2154 *
2155 * We want the freeing of this indirect block to be
2156 * atomic in the journal with the updating of the
2157 * bitmap block which owns it. So make some room in
2158 * the journal.
2159 *
2160 * We zero the parent pointer *after* freeing its
2161 * pointee in the bitmaps, so if extend_transaction()
2162 * for some reason fails to put the bitmap changes and
2163 * the release into the same transaction, recovery
2164 * will merely complain about releasing a free block,
2165 * rather than leaking blocks.
2166 */
2167 if (is_handle_aborted(handle))
2168 return;
2169 if (try_to_extend_transaction(handle, inode)) {
2170 ext4_mark_inode_dirty(handle, inode);
2171 ext4_journal_test_restart(handle, inode);
2172 }
2173
2174 ext4_free_blocks(handle, inode, nr, 1);
2175
2176 if (parent_bh) {
2177 /*
2178 * The block which we have just freed is
2179 * pointed to by an indirect block: journal it
2180 */
2181 BUFFER_TRACE(parent_bh, "get_write_access");
2182 if (!ext4_journal_get_write_access(handle,
2183 parent_bh)){
2184 *p = 0;
2185 BUFFER_TRACE(parent_bh,
2186 "call ext4_journal_dirty_metadata");
2187 ext4_journal_dirty_metadata(handle,
2188 parent_bh);
2189 }
2190 }
2191 }
2192 } else {
2193 /* We have reached the bottom of the tree. */
2194 BUFFER_TRACE(parent_bh, "free data blocks");
2195 ext4_free_data(handle, inode, parent_bh, first, last);
2196 }
2197}
2198
2199/*
2200 * ext4_truncate()
2201 *
2202 * We block out ext4_get_block() block instantiations across the entire
2203 * transaction, and VFS/VM ensures that ext4_truncate() cannot run
2204 * simultaneously on behalf of the same inode.
2205 *
2206 * As we work through the truncate and commmit bits of it to the journal there
2207 * is one core, guiding principle: the file's tree must always be consistent on
2208 * disk. We must be able to restart the truncate after a crash.
2209 *
2210 * The file's tree may be transiently inconsistent in memory (although it
2211 * probably isn't), but whenever we close off and commit a journal transaction,
2212 * the contents of (the filesystem + the journal) must be consistent and
2213 * restartable. It's pretty simple, really: bottom up, right to left (although
2214 * left-to-right works OK too).
2215 *
2216 * Note that at recovery time, journal replay occurs *before* the restart of
2217 * truncate against the orphan inode list.
2218 *
2219 * The committed inode has the new, desired i_size (which is the same as
2220 * i_disksize in this case). After a crash, ext4_orphan_cleanup() will see
2221 * that this inode's truncate did not complete and it will again call
2222 * ext4_truncate() to have another go. So there will be instantiated blocks
2223 * to the right of the truncation point in a crashed ext4 filesystem. But
2224 * that's fine - as long as they are linked from the inode, the post-crash
2225 * ext4_truncate() run will find them and release them.
2226 */
2227void ext4_truncate(struct inode *inode)
2228{
2229 handle_t *handle;
2230 struct ext4_inode_info *ei = EXT4_I(inode);
2231 __le32 *i_data = ei->i_data;
2232 int addr_per_block = EXT4_ADDR_PER_BLOCK(inode->i_sb);
2233 struct address_space *mapping = inode->i_mapping;
2234 int offsets[4];
2235 Indirect chain[4];
2236 Indirect *partial;
2237 __le32 nr = 0;
2238 int n;
2239 long last_block;
2240 unsigned blocksize = inode->i_sb->s_blocksize;
2241 struct page *page;
2242
2243 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
2244 S_ISLNK(inode->i_mode)))
2245 return;
2246 if (ext4_inode_is_fast_symlink(inode))
2247 return;
2248 if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2249 return;
2250
2251 /*
2252 * We have to lock the EOF page here, because lock_page() nests
2253 * outside jbd2_journal_start().
2254 */
2255 if ((inode->i_size & (blocksize - 1)) == 0) {
2256 /* Block boundary? Nothing to do */
2257 page = NULL;
2258 } else {
2259 page = grab_cache_page(mapping,
2260 inode->i_size >> PAGE_CACHE_SHIFT);
2261 if (!page)
2262 return;
2263 }
2264
2265 if (EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)
2266 return ext4_ext_truncate(inode, page);
2267
2268 handle = start_transaction(inode);
2269 if (IS_ERR(handle)) {
2270 if (page) {
2271 clear_highpage(page);
2272 flush_dcache_page(page);
2273 unlock_page(page);
2274 page_cache_release(page);
2275 }
2276 return; /* AKPM: return what? */
2277 }
2278
2279 last_block = (inode->i_size + blocksize-1)
2280 >> EXT4_BLOCK_SIZE_BITS(inode->i_sb);
2281
2282 if (page)
2283 ext4_block_truncate_page(handle, page, mapping, inode->i_size);
2284
2285 n = ext4_block_to_path(inode, last_block, offsets, NULL);
2286 if (n == 0)
2287 goto out_stop; /* error */
2288
2289 /*
2290 * OK. This truncate is going to happen. We add the inode to the
2291 * orphan list, so that if this truncate spans multiple transactions,
2292 * and we crash, we will resume the truncate when the filesystem
2293 * recovers. It also marks the inode dirty, to catch the new size.
2294 *
2295 * Implication: the file must always be in a sane, consistent
2296 * truncatable state while each transaction commits.
2297 */
2298 if (ext4_orphan_add(handle, inode))
2299 goto out_stop;
2300
2301 /*
2302 * The orphan list entry will now protect us from any crash which
2303 * occurs before the truncate completes, so it is now safe to propagate
2304 * the new, shorter inode size (held for now in i_size) into the
2305 * on-disk inode. We do this via i_disksize, which is the value which
2306 * ext4 *really* writes onto the disk inode.
2307 */
2308 ei->i_disksize = inode->i_size;
2309
2310 /*
2311 * From here we block out all ext4_get_block() callers who want to
2312 * modify the block allocation tree.
2313 */
2314 mutex_lock(&ei->truncate_mutex);
2315
2316 if (n == 1) { /* direct blocks */
2317 ext4_free_data(handle, inode, NULL, i_data+offsets[0],
2318 i_data + EXT4_NDIR_BLOCKS);
2319 goto do_indirects;
2320 }
2321
2322 partial = ext4_find_shared(inode, n, offsets, chain, &nr);
2323 /* Kill the top of shared branch (not detached) */
2324 if (nr) {
2325 if (partial == chain) {
2326 /* Shared branch grows from the inode */
2327 ext4_free_branches(handle, inode, NULL,
2328 &nr, &nr+1, (chain+n-1) - partial);
2329 *partial->p = 0;
2330 /*
2331 * We mark the inode dirty prior to restart,
2332 * and prior to stop. No need for it here.
2333 */
2334 } else {
2335 /* Shared branch grows from an indirect block */
2336 BUFFER_TRACE(partial->bh, "get_write_access");
2337 ext4_free_branches(handle, inode, partial->bh,
2338 partial->p,
2339 partial->p+1, (chain+n-1) - partial);
2340 }
2341 }
2342 /* Clear the ends of indirect blocks on the shared branch */
2343 while (partial > chain) {
2344 ext4_free_branches(handle, inode, partial->bh, partial->p + 1,
2345 (__le32*)partial->bh->b_data+addr_per_block,
2346 (chain+n-1) - partial);
2347 BUFFER_TRACE(partial->bh, "call brelse");
2348 brelse (partial->bh);
2349 partial--;
2350 }
2351do_indirects:
2352 /* Kill the remaining (whole) subtrees */
2353 switch (offsets[0]) {
2354 default:
2355 nr = i_data[EXT4_IND_BLOCK];
2356 if (nr) {
2357 ext4_free_branches(handle, inode, NULL, &nr, &nr+1, 1);
2358 i_data[EXT4_IND_BLOCK] = 0;
2359 }
2360 case EXT4_IND_BLOCK:
2361 nr = i_data[EXT4_DIND_BLOCK];
2362 if (nr) {
2363 ext4_free_branches(handle, inode, NULL, &nr, &nr+1, 2);
2364 i_data[EXT4_DIND_BLOCK] = 0;
2365 }
2366 case EXT4_DIND_BLOCK:
2367 nr = i_data[EXT4_TIND_BLOCK];
2368 if (nr) {
2369 ext4_free_branches(handle, inode, NULL, &nr, &nr+1, 3);
2370 i_data[EXT4_TIND_BLOCK] = 0;
2371 }
2372 case EXT4_TIND_BLOCK:
2373 ;
2374 }
2375
2376 ext4_discard_reservation(inode);
2377
2378 mutex_unlock(&ei->truncate_mutex);
2379 inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
2380 ext4_mark_inode_dirty(handle, inode);
2381
2382 /*
2383 * In a multi-transaction truncate, we only make the final transaction
2384 * synchronous
2385 */
2386 if (IS_SYNC(inode))
2387 handle->h_sync = 1;
2388out_stop:
2389 /*
2390 * If this was a simple ftruncate(), and the file will remain alive
2391 * then we need to clear up the orphan record which we created above.
2392 * However, if this was a real unlink then we were called by
2393 * ext4_delete_inode(), and we allow that function to clean up the
2394 * orphan info for us.
2395 */
2396 if (inode->i_nlink)
2397 ext4_orphan_del(handle, inode);
2398
2399 ext4_journal_stop(handle);
2400}
2401
2402static ext4_fsblk_t ext4_get_inode_block(struct super_block *sb,
2403 unsigned long ino, struct ext4_iloc *iloc)
2404{
2405 unsigned long desc, group_desc, block_group;
2406 unsigned long offset;
2407 ext4_fsblk_t block;
2408 struct buffer_head *bh;
2409 struct ext4_group_desc * gdp;
2410
2411 if (!ext4_valid_inum(sb, ino)) {
2412 /*
2413 * This error is already checked for in namei.c unless we are
2414 * looking at an NFS filehandle, in which case no error
2415 * report is needed
2416 */
2417 return 0;
2418 }
2419
2420 block_group = (ino - 1) / EXT4_INODES_PER_GROUP(sb);
2421 if (block_group >= EXT4_SB(sb)->s_groups_count) {
2422 ext4_error(sb,"ext4_get_inode_block","group >= groups count");
2423 return 0;
2424 }
2425 smp_rmb();
2426 group_desc = block_group >> EXT4_DESC_PER_BLOCK_BITS(sb);
2427 desc = block_group & (EXT4_DESC_PER_BLOCK(sb) - 1);
2428 bh = EXT4_SB(sb)->s_group_desc[group_desc];
2429 if (!bh) {
2430 ext4_error (sb, "ext4_get_inode_block",
2431 "Descriptor not loaded");
2432 return 0;
2433 }
2434
2435 gdp = (struct ext4_group_desc *)((__u8 *)bh->b_data +
2436 desc * EXT4_DESC_SIZE(sb));
2437 /*
2438 * Figure out the offset within the block group inode table
2439 */
2440 offset = ((ino - 1) % EXT4_INODES_PER_GROUP(sb)) *
2441 EXT4_INODE_SIZE(sb);
2442 block = ext4_inode_table(sb, gdp) +
2443 (offset >> EXT4_BLOCK_SIZE_BITS(sb));
2444
2445 iloc->block_group = block_group;
2446 iloc->offset = offset & (EXT4_BLOCK_SIZE(sb) - 1);
2447 return block;
2448}
2449
2450/*
2451 * ext4_get_inode_loc returns with an extra refcount against the inode's
2452 * underlying buffer_head on success. If 'in_mem' is true, we have all
2453 * data in memory that is needed to recreate the on-disk version of this
2454 * inode.
2455 */
2456static int __ext4_get_inode_loc(struct inode *inode,
2457 struct ext4_iloc *iloc, int in_mem)
2458{
2459 ext4_fsblk_t block;
2460 struct buffer_head *bh;
2461
2462 block = ext4_get_inode_block(inode->i_sb, inode->i_ino, iloc);
2463 if (!block)
2464 return -EIO;
2465
2466 bh = sb_getblk(inode->i_sb, block);
2467 if (!bh) {
2468 ext4_error (inode->i_sb, "ext4_get_inode_loc",
2469 "unable to read inode block - "
2470 "inode=%lu, block=%llu",
2471 inode->i_ino, block);
2472 return -EIO;
2473 }
2474 if (!buffer_uptodate(bh)) {
2475 lock_buffer(bh);
2476 if (buffer_uptodate(bh)) {
2477 /* someone brought it uptodate while we waited */
2478 unlock_buffer(bh);
2479 goto has_buffer;
2480 }
2481
2482 /*
2483 * If we have all information of the inode in memory and this
2484 * is the only valid inode in the block, we need not read the
2485 * block.
2486 */
2487 if (in_mem) {
2488 struct buffer_head *bitmap_bh;
2489 struct ext4_group_desc *desc;
2490 int inodes_per_buffer;
2491 int inode_offset, i;
2492 int block_group;
2493 int start;
2494
2495 block_group = (inode->i_ino - 1) /
2496 EXT4_INODES_PER_GROUP(inode->i_sb);
2497 inodes_per_buffer = bh->b_size /
2498 EXT4_INODE_SIZE(inode->i_sb);
2499 inode_offset = ((inode->i_ino - 1) %
2500 EXT4_INODES_PER_GROUP(inode->i_sb));
2501 start = inode_offset & ~(inodes_per_buffer - 1);
2502
2503 /* Is the inode bitmap in cache? */
2504 desc = ext4_get_group_desc(inode->i_sb,
2505 block_group, NULL);
2506 if (!desc)
2507 goto make_io;
2508
2509 bitmap_bh = sb_getblk(inode->i_sb,
2510 ext4_inode_bitmap(inode->i_sb, desc));
2511 if (!bitmap_bh)
2512 goto make_io;
2513
2514 /*
2515 * If the inode bitmap isn't in cache then the
2516 * optimisation may end up performing two reads instead
2517 * of one, so skip it.
2518 */
2519 if (!buffer_uptodate(bitmap_bh)) {
2520 brelse(bitmap_bh);
2521 goto make_io;
2522 }
2523 for (i = start; i < start + inodes_per_buffer; i++) {
2524 if (i == inode_offset)
2525 continue;
2526 if (ext4_test_bit(i, bitmap_bh->b_data))
2527 break;
2528 }
2529 brelse(bitmap_bh);
2530 if (i == start + inodes_per_buffer) {
2531 /* all other inodes are free, so skip I/O */
2532 memset(bh->b_data, 0, bh->b_size);
2533 set_buffer_uptodate(bh);
2534 unlock_buffer(bh);
2535 goto has_buffer;
2536 }
2537 }
2538
2539make_io:
2540 /*
2541 * There are other valid inodes in the buffer, this inode
2542 * has in-inode xattrs, or we don't have this inode in memory.
2543 * Read the block from disk.
2544 */
2545 get_bh(bh);
2546 bh->b_end_io = end_buffer_read_sync;
2547 submit_bh(READ_META, bh);
2548 wait_on_buffer(bh);
2549 if (!buffer_uptodate(bh)) {
2550 ext4_error(inode->i_sb, "ext4_get_inode_loc",
2551 "unable to read inode block - "
2552 "inode=%lu, block=%llu",
2553 inode->i_ino, block);
2554 brelse(bh);
2555 return -EIO;
2556 }
2557 }
2558has_buffer:
2559 iloc->bh = bh;
2560 return 0;
2561}
2562
2563int ext4_get_inode_loc(struct inode *inode, struct ext4_iloc *iloc)
2564{
2565 /* We have all inode data except xattrs in memory here. */
2566 return __ext4_get_inode_loc(inode, iloc,
2567 !(EXT4_I(inode)->i_state & EXT4_STATE_XATTR));
2568}
2569
2570void ext4_set_inode_flags(struct inode *inode)
2571{
2572 unsigned int flags = EXT4_I(inode)->i_flags;
2573
2574 inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2575 if (flags & EXT4_SYNC_FL)
2576 inode->i_flags |= S_SYNC;
2577 if (flags & EXT4_APPEND_FL)
2578 inode->i_flags |= S_APPEND;
2579 if (flags & EXT4_IMMUTABLE_FL)
2580 inode->i_flags |= S_IMMUTABLE;
2581 if (flags & EXT4_NOATIME_FL)
2582 inode->i_flags |= S_NOATIME;
2583 if (flags & EXT4_DIRSYNC_FL)
2584 inode->i_flags |= S_DIRSYNC;
2585}
2586
2587void ext4_read_inode(struct inode * inode)
2588{
2589 struct ext4_iloc iloc;
2590 struct ext4_inode *raw_inode;
2591 struct ext4_inode_info *ei = EXT4_I(inode);
2592 struct buffer_head *bh;
2593 int block;
2594
2595#ifdef CONFIG_EXT4DEV_FS_POSIX_ACL
2596 ei->i_acl = EXT4_ACL_NOT_CACHED;
2597 ei->i_default_acl = EXT4_ACL_NOT_CACHED;
2598#endif
2599 ei->i_block_alloc_info = NULL;
2600
2601 if (__ext4_get_inode_loc(inode, &iloc, 0))
2602 goto bad_inode;
2603 bh = iloc.bh;
2604 raw_inode = ext4_raw_inode(&iloc);
2605 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2606 inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2607 inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2608 if(!(test_opt (inode->i_sb, NO_UID32))) {
2609 inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2610 inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2611 }
2612 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
2613 inode->i_size = le32_to_cpu(raw_inode->i_size);
2614 inode->i_atime.tv_sec = le32_to_cpu(raw_inode->i_atime);
2615 inode->i_ctime.tv_sec = le32_to_cpu(raw_inode->i_ctime);
2616 inode->i_mtime.tv_sec = le32_to_cpu(raw_inode->i_mtime);
2617 inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec = inode->i_mtime.tv_nsec = 0;
2618
2619 ei->i_state = 0;
2620 ei->i_dir_start_lookup = 0;
2621 ei->i_dtime = le32_to_cpu(raw_inode->i_dtime);
2622 /* We now have enough fields to check if the inode was active or not.
2623 * This is needed because nfsd might try to access dead inodes
2624 * the test is that same one that e2fsck uses
2625 * NeilBrown 1999oct15
2626 */
2627 if (inode->i_nlink == 0) {
2628 if (inode->i_mode == 0 ||
2629 !(EXT4_SB(inode->i_sb)->s_mount_state & EXT4_ORPHAN_FS)) {
2630 /* this inode is deleted */
2631 brelse (bh);
2632 goto bad_inode;
2633 }
2634 /* The only unlinked inodes we let through here have
2635 * valid i_mode and are being read by the orphan
2636 * recovery code: that's fine, we're about to complete
2637 * the process of deleting those. */
2638 }
2639 inode->i_blocks = le32_to_cpu(raw_inode->i_blocks);
2640 ei->i_flags = le32_to_cpu(raw_inode->i_flags);
2641#ifdef EXT4_FRAGMENTS
2642 ei->i_faddr = le32_to_cpu(raw_inode->i_faddr);
2643 ei->i_frag_no = raw_inode->i_frag;
2644 ei->i_frag_size = raw_inode->i_fsize;
2645#endif
2646 ei->i_file_acl = le32_to_cpu(raw_inode->i_file_acl);
2647 if (EXT4_SB(inode->i_sb)->s_es->s_creator_os !=
2648 cpu_to_le32(EXT4_OS_HURD))
2649 ei->i_file_acl |=
2650 ((__u64)le16_to_cpu(raw_inode->i_file_acl_high)) << 32;
2651 if (!S_ISREG(inode->i_mode)) {
2652 ei->i_dir_acl = le32_to_cpu(raw_inode->i_dir_acl);
2653 } else {
2654 inode->i_size |=
2655 ((__u64)le32_to_cpu(raw_inode->i_size_high)) << 32;
2656 }
2657 ei->i_disksize = inode->i_size;
2658 inode->i_generation = le32_to_cpu(raw_inode->i_generation);
2659 ei->i_block_group = iloc.block_group;
2660 /*
2661 * NOTE! The in-memory inode i_data array is in little-endian order
2662 * even on big-endian machines: we do NOT byteswap the block numbers!
2663 */
2664 for (block = 0; block < EXT4_N_BLOCKS; block++)
2665 ei->i_data[block] = raw_inode->i_block[block];
2666 INIT_LIST_HEAD(&ei->i_orphan);
2667
2668 if (inode->i_ino >= EXT4_FIRST_INO(inode->i_sb) + 1 &&
2669 EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) {
2670 /*
2671 * When mke2fs creates big inodes it does not zero out
2672 * the unused bytes above EXT4_GOOD_OLD_INODE_SIZE,
2673 * so ignore those first few inodes.
2674 */
2675 ei->i_extra_isize = le16_to_cpu(raw_inode->i_extra_isize);
2676 if (EXT4_GOOD_OLD_INODE_SIZE + ei->i_extra_isize >
2677 EXT4_INODE_SIZE(inode->i_sb))
2678 goto bad_inode;
2679 if (ei->i_extra_isize == 0) {
2680 /* The extra space is currently unused. Use it. */
2681 ei->i_extra_isize = sizeof(struct ext4_inode) -
2682 EXT4_GOOD_OLD_INODE_SIZE;
2683 } else {
2684 __le32 *magic = (void *)raw_inode +
2685 EXT4_GOOD_OLD_INODE_SIZE +
2686 ei->i_extra_isize;
2687 if (*magic == cpu_to_le32(EXT4_XATTR_MAGIC))
2688 ei->i_state |= EXT4_STATE_XATTR;
2689 }
2690 } else
2691 ei->i_extra_isize = 0;
2692
2693 if (S_ISREG(inode->i_mode)) {
2694 inode->i_op = &ext4_file_inode_operations;
2695 inode->i_fop = &ext4_file_operations;
2696 ext4_set_aops(inode);
2697 } else if (S_ISDIR(inode->i_mode)) {
2698 inode->i_op = &ext4_dir_inode_operations;
2699 inode->i_fop = &ext4_dir_operations;
2700 } else if (S_ISLNK(inode->i_mode)) {
2701 if (ext4_inode_is_fast_symlink(inode))
2702 inode->i_op = &ext4_fast_symlink_inode_operations;
2703 else {
2704 inode->i_op = &ext4_symlink_inode_operations;
2705 ext4_set_aops(inode);
2706 }
2707 } else {
2708 inode->i_op = &ext4_special_inode_operations;
2709 if (raw_inode->i_block[0])
2710 init_special_inode(inode, inode->i_mode,
2711 old_decode_dev(le32_to_cpu(raw_inode->i_block[0])));
2712 else
2713 init_special_inode(inode, inode->i_mode,
2714 new_decode_dev(le32_to_cpu(raw_inode->i_block[1])));
2715 }
2716 brelse (iloc.bh);
2717 ext4_set_inode_flags(inode);
2718 return;
2719
2720bad_inode:
2721 make_bad_inode(inode);
2722 return;
2723}
2724
2725/*
2726 * Post the struct inode info into an on-disk inode location in the
2727 * buffer-cache. This gobbles the caller's reference to the
2728 * buffer_head in the inode location struct.
2729 *
2730 * The caller must have write access to iloc->bh.
2731 */
2732static int ext4_do_update_inode(handle_t *handle,
2733 struct inode *inode,
2734 struct ext4_iloc *iloc)
2735{
2736 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
2737 struct ext4_inode_info *ei = EXT4_I(inode);
2738 struct buffer_head *bh = iloc->bh;
2739 int err = 0, rc, block;
2740
2741 /* For fields not not tracking in the in-memory inode,
2742 * initialise them to zero for new inodes. */
2743 if (ei->i_state & EXT4_STATE_NEW)
2744 memset(raw_inode, 0, EXT4_SB(inode->i_sb)->s_inode_size);
2745
2746 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
2747 if(!(test_opt(inode->i_sb, NO_UID32))) {
2748 raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
2749 raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
2750/*
2751 * Fix up interoperability with old kernels. Otherwise, old inodes get
2752 * re-used with the upper 16 bits of the uid/gid intact
2753 */
2754 if(!ei->i_dtime) {
2755 raw_inode->i_uid_high =
2756 cpu_to_le16(high_16_bits(inode->i_uid));
2757 raw_inode->i_gid_high =
2758 cpu_to_le16(high_16_bits(inode->i_gid));
2759 } else {
2760 raw_inode->i_uid_high = 0;
2761 raw_inode->i_gid_high = 0;
2762 }
2763 } else {
2764 raw_inode->i_uid_low =
2765 cpu_to_le16(fs_high2lowuid(inode->i_uid));
2766 raw_inode->i_gid_low =
2767 cpu_to_le16(fs_high2lowgid(inode->i_gid));
2768 raw_inode->i_uid_high = 0;
2769 raw_inode->i_gid_high = 0;
2770 }
2771 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2772 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
2773 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2774 raw_inode->i_ctime = cpu_to_le32(inode->i_ctime.tv_sec);
2775 raw_inode->i_mtime = cpu_to_le32(inode->i_mtime.tv_sec);
2776 raw_inode->i_blocks = cpu_to_le32(inode->i_blocks);
2777 raw_inode->i_dtime = cpu_to_le32(ei->i_dtime);
2778 raw_inode->i_flags = cpu_to_le32(ei->i_flags);
2779#ifdef EXT4_FRAGMENTS
2780 raw_inode->i_faddr = cpu_to_le32(ei->i_faddr);
2781 raw_inode->i_frag = ei->i_frag_no;
2782 raw_inode->i_fsize = ei->i_frag_size;
2783#endif
2784 if (EXT4_SB(inode->i_sb)->s_es->s_creator_os !=
2785 cpu_to_le32(EXT4_OS_HURD))
2786 raw_inode->i_file_acl_high =
2787 cpu_to_le16(ei->i_file_acl >> 32);
2788 raw_inode->i_file_acl = cpu_to_le32(ei->i_file_acl);
2789 if (!S_ISREG(inode->i_mode)) {
2790 raw_inode->i_dir_acl = cpu_to_le32(ei->i_dir_acl);
2791 } else {
2792 raw_inode->i_size_high =
2793 cpu_to_le32(ei->i_disksize >> 32);
2794 if (ei->i_disksize > 0x7fffffffULL) {
2795 struct super_block *sb = inode->i_sb;
2796 if (!EXT4_HAS_RO_COMPAT_FEATURE(sb,
2797 EXT4_FEATURE_RO_COMPAT_LARGE_FILE) ||
2798 EXT4_SB(sb)->s_es->s_rev_level ==
2799 cpu_to_le32(EXT4_GOOD_OLD_REV)) {
2800 /* If this is the first large file
2801 * created, add a flag to the superblock.
2802 */
2803 err = ext4_journal_get_write_access(handle,
2804 EXT4_SB(sb)->s_sbh);
2805 if (err)
2806 goto out_brelse;
2807 ext4_update_dynamic_rev(sb);
2808 EXT4_SET_RO_COMPAT_FEATURE(sb,
2809 EXT4_FEATURE_RO_COMPAT_LARGE_FILE);
2810 sb->s_dirt = 1;
2811 handle->h_sync = 1;
2812 err = ext4_journal_dirty_metadata(handle,
2813 EXT4_SB(sb)->s_sbh);
2814 }
2815 }
2816 }
2817 raw_inode->i_generation = cpu_to_le32(inode->i_generation);
2818 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) {
2819 if (old_valid_dev(inode->i_rdev)) {
2820 raw_inode->i_block[0] =
2821 cpu_to_le32(old_encode_dev(inode->i_rdev));
2822 raw_inode->i_block[1] = 0;
2823 } else {
2824 raw_inode->i_block[0] = 0;
2825 raw_inode->i_block[1] =
2826 cpu_to_le32(new_encode_dev(inode->i_rdev));
2827 raw_inode->i_block[2] = 0;
2828 }
2829 } else for (block = 0; block < EXT4_N_BLOCKS; block++)
2830 raw_inode->i_block[block] = ei->i_data[block];
2831
2832 if (ei->i_extra_isize)
2833 raw_inode->i_extra_isize = cpu_to_le16(ei->i_extra_isize);
2834
2835 BUFFER_TRACE(bh, "call ext4_journal_dirty_metadata");
2836 rc = ext4_journal_dirty_metadata(handle, bh);
2837 if (!err)
2838 err = rc;
2839 ei->i_state &= ~EXT4_STATE_NEW;
2840
2841out_brelse:
2842 brelse (bh);
2843 ext4_std_error(inode->i_sb, err);
2844 return err;
2845}
2846
2847/*
2848 * ext4_write_inode()
2849 *
2850 * We are called from a few places:
2851 *
2852 * - Within generic_file_write() for O_SYNC files.
2853 * Here, there will be no transaction running. We wait for any running
2854 * trasnaction to commit.
2855 *
2856 * - Within sys_sync(), kupdate and such.
2857 * We wait on commit, if tol to.
2858 *
2859 * - Within prune_icache() (PF_MEMALLOC == true)
2860 * Here we simply return. We can't afford to block kswapd on the
2861 * journal commit.
2862 *
2863 * In all cases it is actually safe for us to return without doing anything,
2864 * because the inode has been copied into a raw inode buffer in
2865 * ext4_mark_inode_dirty(). This is a correctness thing for O_SYNC and for
2866 * knfsd.
2867 *
2868 * Note that we are absolutely dependent upon all inode dirtiers doing the
2869 * right thing: they *must* call mark_inode_dirty() after dirtying info in
2870 * which we are interested.
2871 *
2872 * It would be a bug for them to not do this. The code:
2873 *
2874 * mark_inode_dirty(inode)
2875 * stuff();
2876 * inode->i_size = expr;
2877 *
2878 * is in error because a kswapd-driven write_inode() could occur while
2879 * `stuff()' is running, and the new i_size will be lost. Plus the inode
2880 * will no longer be on the superblock's dirty inode list.
2881 */
2882int ext4_write_inode(struct inode *inode, int wait)
2883{
2884 if (current->flags & PF_MEMALLOC)
2885 return 0;
2886
2887 if (ext4_journal_current_handle()) {
2888 jbd_debug(0, "called recursively, non-PF_MEMALLOC!\n");
2889 dump_stack();
2890 return -EIO;
2891 }
2892
2893 if (!wait)
2894 return 0;
2895
2896 return ext4_force_commit(inode->i_sb);
2897}
2898
2899/*
2900 * ext4_setattr()
2901 *
2902 * Called from notify_change.
2903 *
2904 * We want to trap VFS attempts to truncate the file as soon as
2905 * possible. In particular, we want to make sure that when the VFS
2906 * shrinks i_size, we put the inode on the orphan list and modify
2907 * i_disksize immediately, so that during the subsequent flushing of
2908 * dirty pages and freeing of disk blocks, we can guarantee that any
2909 * commit will leave the blocks being flushed in an unused state on
2910 * disk. (On recovery, the inode will get truncated and the blocks will
2911 * be freed, so we have a strong guarantee that no future commit will
2912 * leave these blocks visible to the user.)
2913 *
2914 * Called with inode->sem down.
2915 */
2916int ext4_setattr(struct dentry *dentry, struct iattr *attr)
2917{
2918 struct inode *inode = dentry->d_inode;
2919 int error, rc = 0;
2920 const unsigned int ia_valid = attr->ia_valid;
2921
2922 error = inode_change_ok(inode, attr);
2923 if (error)
2924 return error;
2925
2926 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
2927 (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
2928 handle_t *handle;
2929
2930 /* (user+group)*(old+new) structure, inode write (sb,
2931 * inode block, ? - but truncate inode update has it) */
2932 handle = ext4_journal_start(inode, 2*(EXT4_QUOTA_INIT_BLOCKS(inode->i_sb)+
2933 EXT4_QUOTA_DEL_BLOCKS(inode->i_sb))+3);
2934 if (IS_ERR(handle)) {
2935 error = PTR_ERR(handle);
2936 goto err_out;
2937 }
2938 error = DQUOT_TRANSFER(inode, attr) ? -EDQUOT : 0;
2939 if (error) {
2940 ext4_journal_stop(handle);
2941 return error;
2942 }
2943 /* Update corresponding info in inode so that everything is in
2944 * one transaction */
2945 if (attr->ia_valid & ATTR_UID)
2946 inode->i_uid = attr->ia_uid;
2947 if (attr->ia_valid & ATTR_GID)
2948 inode->i_gid = attr->ia_gid;
2949 error = ext4_mark_inode_dirty(handle, inode);
2950 ext4_journal_stop(handle);
2951 }
2952
2953 if (S_ISREG(inode->i_mode) &&
2954 attr->ia_valid & ATTR_SIZE && attr->ia_size < inode->i_size) {
2955 handle_t *handle;
2956
2957 handle = ext4_journal_start(inode, 3);
2958 if (IS_ERR(handle)) {
2959 error = PTR_ERR(handle);
2960 goto err_out;
2961 }
2962
2963 error = ext4_orphan_add(handle, inode);
2964 EXT4_I(inode)->i_disksize = attr->ia_size;
2965 rc = ext4_mark_inode_dirty(handle, inode);
2966 if (!error)
2967 error = rc;
2968 ext4_journal_stop(handle);
2969 }
2970
2971 rc = inode_setattr(inode, attr);
2972
2973 /* If inode_setattr's call to ext4_truncate failed to get a
2974 * transaction handle at all, we need to clean up the in-core
2975 * orphan list manually. */
2976 if (inode->i_nlink)
2977 ext4_orphan_del(NULL, inode);
2978
2979 if (!rc && (ia_valid & ATTR_MODE))
2980 rc = ext4_acl_chmod(inode);
2981
2982err_out:
2983 ext4_std_error(inode->i_sb, error);
2984 if (!error)
2985 error = rc;
2986 return error;
2987}
2988
2989
2990/*
2991 * How many blocks doth make a writepage()?
2992 *
2993 * With N blocks per page, it may be:
2994 * N data blocks
2995 * 2 indirect block
2996 * 2 dindirect
2997 * 1 tindirect
2998 * N+5 bitmap blocks (from the above)
2999 * N+5 group descriptor summary blocks
3000 * 1 inode block
3001 * 1 superblock.
3002 * 2 * EXT4_SINGLEDATA_TRANS_BLOCKS for the quote files
3003 *
3004 * 3 * (N + 5) + 2 + 2 * EXT4_SINGLEDATA_TRANS_BLOCKS
3005 *
3006 * With ordered or writeback data it's the same, less the N data blocks.
3007 *
3008 * If the inode's direct blocks can hold an integral number of pages then a
3009 * page cannot straddle two indirect blocks, and we can only touch one indirect
3010 * and dindirect block, and the "5" above becomes "3".
3011 *
3012 * This still overestimates under most circumstances. If we were to pass the
3013 * start and end offsets in here as well we could do block_to_path() on each
3014 * block and work out the exact number of indirects which are touched. Pah.
3015 */
3016
3017int ext4_writepage_trans_blocks(struct inode *inode)
3018{
3019 int bpp = ext4_journal_blocks_per_page(inode);
3020 int indirects = (EXT4_NDIR_BLOCKS % bpp) ? 5 : 3;
3021 int ret;
3022
3023 if (EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)
3024 return ext4_ext_writepage_trans_blocks(inode, bpp);
3025
3026 if (ext4_should_journal_data(inode))
3027 ret = 3 * (bpp + indirects) + 2;
3028 else
3029 ret = 2 * (bpp + indirects) + 2;
3030
3031#ifdef CONFIG_QUOTA
3032 /* We know that structure was already allocated during DQUOT_INIT so
3033 * we will be updating only the data blocks + inodes */
3034 ret += 2*EXT4_QUOTA_TRANS_BLOCKS(inode->i_sb);
3035#endif
3036
3037 return ret;
3038}
3039
3040/*
3041 * The caller must have previously called ext4_reserve_inode_write().
3042 * Give this, we know that the caller already has write access to iloc->bh.
3043 */
3044int ext4_mark_iloc_dirty(handle_t *handle,
3045 struct inode *inode, struct ext4_iloc *iloc)
3046{
3047 int err = 0;
3048
3049 /* the do_update_inode consumes one bh->b_count */
3050 get_bh(iloc->bh);
3051
3052 /* ext4_do_update_inode() does jbd2_journal_dirty_metadata */
3053 err = ext4_do_update_inode(handle, inode, iloc);
3054 put_bh(iloc->bh);
3055 return err;
3056}
3057
3058/*
3059 * On success, We end up with an outstanding reference count against
3060 * iloc->bh. This _must_ be cleaned up later.
3061 */
3062
3063int
3064ext4_reserve_inode_write(handle_t *handle, struct inode *inode,
3065 struct ext4_iloc *iloc)
3066{
3067 int err = 0;
3068 if (handle) {
3069 err = ext4_get_inode_loc(inode, iloc);
3070 if (!err) {
3071 BUFFER_TRACE(iloc->bh, "get_write_access");
3072 err = ext4_journal_get_write_access(handle, iloc->bh);
3073 if (err) {
3074 brelse(iloc->bh);
3075 iloc->bh = NULL;
3076 }
3077 }
3078 }
3079 ext4_std_error(inode->i_sb, err);
3080 return err;
3081}
3082
3083/*
3084 * What we do here is to mark the in-core inode as clean with respect to inode
3085 * dirtiness (it may still be data-dirty).
3086 * This means that the in-core inode may be reaped by prune_icache
3087 * without having to perform any I/O. This is a very good thing,
3088 * because *any* task may call prune_icache - even ones which
3089 * have a transaction open against a different journal.
3090 *
3091 * Is this cheating? Not really. Sure, we haven't written the
3092 * inode out, but prune_icache isn't a user-visible syncing function.
3093 * Whenever the user wants stuff synced (sys_sync, sys_msync, sys_fsync)
3094 * we start and wait on commits.
3095 *
3096 * Is this efficient/effective? Well, we're being nice to the system
3097 * by cleaning up our inodes proactively so they can be reaped
3098 * without I/O. But we are potentially leaving up to five seconds'
3099 * worth of inodes floating about which prune_icache wants us to
3100 * write out. One way to fix that would be to get prune_icache()
3101 * to do a write_super() to free up some memory. It has the desired
3102 * effect.
3103 */
3104int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode)
3105{
3106 struct ext4_iloc iloc;
3107 int err;
3108
3109 might_sleep();
3110 err = ext4_reserve_inode_write(handle, inode, &iloc);
3111 if (!err)
3112 err = ext4_mark_iloc_dirty(handle, inode, &iloc);
3113 return err;
3114}
3115
3116/*
3117 * ext4_dirty_inode() is called from __mark_inode_dirty()
3118 *
3119 * We're really interested in the case where a file is being extended.
3120 * i_size has been changed by generic_commit_write() and we thus need
3121 * to include the updated inode in the current transaction.
3122 *
3123 * Also, DQUOT_ALLOC_SPACE() will always dirty the inode when blocks
3124 * are allocated to the file.
3125 *
3126 * If the inode is marked synchronous, we don't honour that here - doing
3127 * so would cause a commit on atime updates, which we don't bother doing.
3128 * We handle synchronous inodes at the highest possible level.
3129 */
3130void ext4_dirty_inode(struct inode *inode)
3131{
3132 handle_t *current_handle = ext4_journal_current_handle();
3133 handle_t *handle;
3134
3135 handle = ext4_journal_start(inode, 2);
3136 if (IS_ERR(handle))
3137 goto out;
3138 if (current_handle &&
3139 current_handle->h_transaction != handle->h_transaction) {
3140 /* This task has a transaction open against a different fs */
3141 printk(KERN_EMERG "%s: transactions do not match!\n",
3142 __FUNCTION__);
3143 } else {
3144 jbd_debug(5, "marking dirty. outer handle=%p\n",
3145 current_handle);
3146 ext4_mark_inode_dirty(handle, inode);
3147 }
3148 ext4_journal_stop(handle);
3149out:
3150 return;
3151}
3152
3153#if 0
3154/*
3155 * Bind an inode's backing buffer_head into this transaction, to prevent
3156 * it from being flushed to disk early. Unlike
3157 * ext4_reserve_inode_write, this leaves behind no bh reference and
3158 * returns no iloc structure, so the caller needs to repeat the iloc
3159 * lookup to mark the inode dirty later.
3160 */
3161static int ext4_pin_inode(handle_t *handle, struct inode *inode)
3162{
3163 struct ext4_iloc iloc;
3164
3165 int err = 0;
3166 if (handle) {
3167 err = ext4_get_inode_loc(inode, &iloc);
3168 if (!err) {
3169 BUFFER_TRACE(iloc.bh, "get_write_access");
3170 err = jbd2_journal_get_write_access(handle, iloc.bh);
3171 if (!err)
3172 err = ext4_journal_dirty_metadata(handle,
3173 iloc.bh);
3174 brelse(iloc.bh);
3175 }
3176 }
3177 ext4_std_error(inode->i_sb, err);
3178 return err;
3179}
3180#endif
3181
3182int ext4_change_inode_journal_flag(struct inode *inode, int val)
3183{
3184 journal_t *journal;
3185 handle_t *handle;
3186 int err;
3187
3188 /*
3189 * We have to be very careful here: changing a data block's
3190 * journaling status dynamically is dangerous. If we write a
3191 * data block to the journal, change the status and then delete
3192 * that block, we risk forgetting to revoke the old log record
3193 * from the journal and so a subsequent replay can corrupt data.
3194 * So, first we make sure that the journal is empty and that
3195 * nobody is changing anything.
3196 */
3197
3198 journal = EXT4_JOURNAL(inode);
3199 if (is_journal_aborted(journal) || IS_RDONLY(inode))
3200 return -EROFS;
3201
3202 jbd2_journal_lock_updates(journal);
3203 jbd2_journal_flush(journal);
3204
3205 /*
3206 * OK, there are no updates running now, and all cached data is
3207 * synced to disk. We are now in a completely consistent state
3208 * which doesn't have anything in the journal, and we know that
3209 * no filesystem updates are running, so it is safe to modify
3210 * the inode's in-core data-journaling state flag now.
3211 */
3212
3213 if (val)
3214 EXT4_I(inode)->i_flags |= EXT4_JOURNAL_DATA_FL;
3215 else
3216 EXT4_I(inode)->i_flags &= ~EXT4_JOURNAL_DATA_FL;
3217 ext4_set_aops(inode);
3218
3219 jbd2_journal_unlock_updates(journal);
3220
3221 /* Finally we can mark the inode as dirty. */
3222
3223 handle = ext4_journal_start(inode, 1);
3224 if (IS_ERR(handle))
3225 return PTR_ERR(handle);
3226
3227 err = ext4_mark_inode_dirty(handle, inode);
3228 handle->h_sync = 1;
3229 ext4_journal_stop(handle);
3230 ext4_std_error(inode->i_sb, err);
3231
3232 return err;
3233}
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
new file mode 100644
index 000000000000..22a737c306c7
--- /dev/null
+++ b/fs/ext4/ioctl.c
@@ -0,0 +1,306 @@
1/*
2 * linux/fs/ext4/ioctl.c
3 *
4 * Copyright (C) 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 */
9
10#include <linux/fs.h>
11#include <linux/jbd2.h>
12#include <linux/capability.h>
13#include <linux/ext4_fs.h>
14#include <linux/ext4_jbd2.h>
15#include <linux/time.h>
16#include <linux/compat.h>
17#include <linux/smp_lock.h>
18#include <asm/uaccess.h>
19
20int ext4_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
21 unsigned long arg)
22{
23 struct ext4_inode_info *ei = EXT4_I(inode);
24 unsigned int flags;
25 unsigned short rsv_window_size;
26
27 ext4_debug ("cmd = %u, arg = %lu\n", cmd, arg);
28
29 switch (cmd) {
30 case EXT4_IOC_GETFLAGS:
31 flags = ei->i_flags & EXT4_FL_USER_VISIBLE;
32 return put_user(flags, (int __user *) arg);
33 case EXT4_IOC_SETFLAGS: {
34 handle_t *handle = NULL;
35 int err;
36 struct ext4_iloc iloc;
37 unsigned int oldflags;
38 unsigned int jflag;
39
40 if (IS_RDONLY(inode))
41 return -EROFS;
42
43 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
44 return -EACCES;
45
46 if (get_user(flags, (int __user *) arg))
47 return -EFAULT;
48
49 if (!S_ISDIR(inode->i_mode))
50 flags &= ~EXT4_DIRSYNC_FL;
51
52 mutex_lock(&inode->i_mutex);
53 oldflags = ei->i_flags;
54
55 /* The JOURNAL_DATA flag is modifiable only by root */
56 jflag = flags & EXT4_JOURNAL_DATA_FL;
57
58 /*
59 * The IMMUTABLE and APPEND_ONLY flags can only be changed by
60 * the relevant capability.
61 *
62 * This test looks nicer. Thanks to Pauline Middelink
63 */
64 if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
65 if (!capable(CAP_LINUX_IMMUTABLE)) {
66 mutex_unlock(&inode->i_mutex);
67 return -EPERM;
68 }
69 }
70
71 /*
72 * The JOURNAL_DATA flag can only be changed by
73 * the relevant capability.
74 */
75 if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL)) {
76 if (!capable(CAP_SYS_RESOURCE)) {
77 mutex_unlock(&inode->i_mutex);
78 return -EPERM;
79 }
80 }
81
82
83 handle = ext4_journal_start(inode, 1);
84 if (IS_ERR(handle)) {
85 mutex_unlock(&inode->i_mutex);
86 return PTR_ERR(handle);
87 }
88 if (IS_SYNC(inode))
89 handle->h_sync = 1;
90 err = ext4_reserve_inode_write(handle, inode, &iloc);
91 if (err)
92 goto flags_err;
93
94 flags = flags & EXT4_FL_USER_MODIFIABLE;
95 flags |= oldflags & ~EXT4_FL_USER_MODIFIABLE;
96 ei->i_flags = flags;
97
98 ext4_set_inode_flags(inode);
99 inode->i_ctime = CURRENT_TIME_SEC;
100
101 err = ext4_mark_iloc_dirty(handle, inode, &iloc);
102flags_err:
103 ext4_journal_stop(handle);
104 if (err) {
105 mutex_unlock(&inode->i_mutex);
106 return err;
107 }
108
109 if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL))
110 err = ext4_change_inode_journal_flag(inode, jflag);
111 mutex_unlock(&inode->i_mutex);
112 return err;
113 }
114 case EXT4_IOC_GETVERSION:
115 case EXT4_IOC_GETVERSION_OLD:
116 return put_user(inode->i_generation, (int __user *) arg);
117 case EXT4_IOC_SETVERSION:
118 case EXT4_IOC_SETVERSION_OLD: {
119 handle_t *handle;
120 struct ext4_iloc iloc;
121 __u32 generation;
122 int err;
123
124 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
125 return -EPERM;
126 if (IS_RDONLY(inode))
127 return -EROFS;
128 if (get_user(generation, (int __user *) arg))
129 return -EFAULT;
130
131 handle = ext4_journal_start(inode, 1);
132 if (IS_ERR(handle))
133 return PTR_ERR(handle);
134 err = ext4_reserve_inode_write(handle, inode, &iloc);
135 if (err == 0) {
136 inode->i_ctime = CURRENT_TIME_SEC;
137 inode->i_generation = generation;
138 err = ext4_mark_iloc_dirty(handle, inode, &iloc);
139 }
140 ext4_journal_stop(handle);
141 return err;
142 }
143#ifdef CONFIG_JBD_DEBUG
144 case EXT4_IOC_WAIT_FOR_READONLY:
145 /*
146 * This is racy - by the time we're woken up and running,
147 * the superblock could be released. And the module could
148 * have been unloaded. So sue me.
149 *
150 * Returns 1 if it slept, else zero.
151 */
152 {
153 struct super_block *sb = inode->i_sb;
154 DECLARE_WAITQUEUE(wait, current);
155 int ret = 0;
156
157 set_current_state(TASK_INTERRUPTIBLE);
158 add_wait_queue(&EXT4_SB(sb)->ro_wait_queue, &wait);
159 if (timer_pending(&EXT4_SB(sb)->turn_ro_timer)) {
160 schedule();
161 ret = 1;
162 }
163 remove_wait_queue(&EXT4_SB(sb)->ro_wait_queue, &wait);
164 return ret;
165 }
166#endif
167 case EXT4_IOC_GETRSVSZ:
168 if (test_opt(inode->i_sb, RESERVATION)
169 && S_ISREG(inode->i_mode)
170 && ei->i_block_alloc_info) {
171 rsv_window_size = ei->i_block_alloc_info->rsv_window_node.rsv_goal_size;
172 return put_user(rsv_window_size, (int __user *)arg);
173 }
174 return -ENOTTY;
175 case EXT4_IOC_SETRSVSZ: {
176
177 if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode))
178 return -ENOTTY;
179
180 if (IS_RDONLY(inode))
181 return -EROFS;
182
183 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
184 return -EACCES;
185
186 if (get_user(rsv_window_size, (int __user *)arg))
187 return -EFAULT;
188
189 if (rsv_window_size > EXT4_MAX_RESERVE_BLOCKS)
190 rsv_window_size = EXT4_MAX_RESERVE_BLOCKS;
191
192 /*
193 * need to allocate reservation structure for this inode
194 * before set the window size
195 */
196 mutex_lock(&ei->truncate_mutex);
197 if (!ei->i_block_alloc_info)
198 ext4_init_block_alloc_info(inode);
199
200 if (ei->i_block_alloc_info){
201 struct ext4_reserve_window_node *rsv = &ei->i_block_alloc_info->rsv_window_node;
202 rsv->rsv_goal_size = rsv_window_size;
203 }
204 mutex_unlock(&ei->truncate_mutex);
205 return 0;
206 }
207 case EXT4_IOC_GROUP_EXTEND: {
208 ext4_fsblk_t n_blocks_count;
209 struct super_block *sb = inode->i_sb;
210 int err;
211
212 if (!capable(CAP_SYS_RESOURCE))
213 return -EPERM;
214
215 if (IS_RDONLY(inode))
216 return -EROFS;
217
218 if (get_user(n_blocks_count, (__u32 __user *)arg))
219 return -EFAULT;
220
221 err = ext4_group_extend(sb, EXT4_SB(sb)->s_es, n_blocks_count);
222 jbd2_journal_lock_updates(EXT4_SB(sb)->s_journal);
223 jbd2_journal_flush(EXT4_SB(sb)->s_journal);
224 jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal);
225
226 return err;
227 }
228 case EXT4_IOC_GROUP_ADD: {
229 struct ext4_new_group_data input;
230 struct super_block *sb = inode->i_sb;
231 int err;
232
233 if (!capable(CAP_SYS_RESOURCE))
234 return -EPERM;
235
236 if (IS_RDONLY(inode))
237 return -EROFS;
238
239 if (copy_from_user(&input, (struct ext4_new_group_input __user *)arg,
240 sizeof(input)))
241 return -EFAULT;
242
243 err = ext4_group_add(sb, &input);
244 jbd2_journal_lock_updates(EXT4_SB(sb)->s_journal);
245 jbd2_journal_flush(EXT4_SB(sb)->s_journal);
246 jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal);
247
248 return err;
249 }
250
251 default:
252 return -ENOTTY;
253 }
254}
255
256#ifdef CONFIG_COMPAT
257long ext4_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
258{
259 struct inode *inode = file->f_dentry->d_inode;
260 int ret;
261
262 /* These are just misnamed, they actually get/put from/to user an int */
263 switch (cmd) {
264 case EXT4_IOC32_GETFLAGS:
265 cmd = EXT4_IOC_GETFLAGS;
266 break;
267 case EXT4_IOC32_SETFLAGS:
268 cmd = EXT4_IOC_SETFLAGS;
269 break;
270 case EXT4_IOC32_GETVERSION:
271 cmd = EXT4_IOC_GETVERSION;
272 break;
273 case EXT4_IOC32_SETVERSION:
274 cmd = EXT4_IOC_SETVERSION;
275 break;
276 case EXT4_IOC32_GROUP_EXTEND:
277 cmd = EXT4_IOC_GROUP_EXTEND;
278 break;
279 case EXT4_IOC32_GETVERSION_OLD:
280 cmd = EXT4_IOC_GETVERSION_OLD;
281 break;
282 case EXT4_IOC32_SETVERSION_OLD:
283 cmd = EXT4_IOC_SETVERSION_OLD;
284 break;
285#ifdef CONFIG_JBD_DEBUG
286 case EXT4_IOC32_WAIT_FOR_READONLY:
287 cmd = EXT4_IOC_WAIT_FOR_READONLY;
288 break;
289#endif
290 case EXT4_IOC32_GETRSVSZ:
291 cmd = EXT4_IOC_GETRSVSZ;
292 break;
293 case EXT4_IOC32_SETRSVSZ:
294 cmd = EXT4_IOC_SETRSVSZ;
295 break;
296 case EXT4_IOC_GROUP_ADD:
297 break;
298 default:
299 return -ENOIOCTLCMD;
300 }
301 lock_kernel();
302 ret = ext4_ioctl(inode, file, cmd, (unsigned long) compat_ptr(arg));
303 unlock_kernel();
304 return ret;
305}
306#endif
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
new file mode 100644
index 000000000000..8b1bd03d20f5
--- /dev/null
+++ b/fs/ext4/namei.c
@@ -0,0 +1,2395 @@
1/*
2 * linux/fs/ext4/namei.c
3 *
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 *
9 * from
10 *
11 * linux/fs/minix/namei.c
12 *
13 * Copyright (C) 1991, 1992 Linus Torvalds
14 *
15 * Big-endian to little-endian byte-swapping/bitmaps by
16 * David S. Miller (davem@caip.rutgers.edu), 1995
17 * Directory entry file type support and forward compatibility hooks
18 * for B-tree directories by Theodore Ts'o (tytso@mit.edu), 1998
19 * Hash Tree Directory indexing (c)
20 * Daniel Phillips, 2001
21 * Hash Tree Directory indexing porting
22 * Christopher Li, 2002
23 * Hash Tree Directory indexing cleanup
24 * Theodore Ts'o, 2002
25 */
26
27#include <linux/fs.h>
28#include <linux/pagemap.h>
29#include <linux/jbd2.h>
30#include <linux/time.h>
31#include <linux/ext4_fs.h>
32#include <linux/ext4_jbd2.h>
33#include <linux/fcntl.h>
34#include <linux/stat.h>
35#include <linux/string.h>
36#include <linux/quotaops.h>
37#include <linux/buffer_head.h>
38#include <linux/bio.h>
39#include <linux/smp_lock.h>
40
41#include "namei.h"
42#include "xattr.h"
43#include "acl.h"
44
45/*
46 * define how far ahead to read directories while searching them.
47 */
48#define NAMEI_RA_CHUNKS 2
49#define NAMEI_RA_BLOCKS 4
50#define NAMEI_RA_SIZE (NAMEI_RA_CHUNKS * NAMEI_RA_BLOCKS)
51#define NAMEI_RA_INDEX(c,b) (((c) * NAMEI_RA_BLOCKS) + (b))
52
53static struct buffer_head *ext4_append(handle_t *handle,
54 struct inode *inode,
55 u32 *block, int *err)
56{
57 struct buffer_head *bh;
58
59 *block = inode->i_size >> inode->i_sb->s_blocksize_bits;
60
61 if ((bh = ext4_bread(handle, inode, *block, 1, err))) {
62 inode->i_size += inode->i_sb->s_blocksize;
63 EXT4_I(inode)->i_disksize = inode->i_size;
64 ext4_journal_get_write_access(handle,bh);
65 }
66 return bh;
67}
68
69#ifndef assert
70#define assert(test) J_ASSERT(test)
71#endif
72
73#ifndef swap
74#define swap(x, y) do { typeof(x) z = x; x = y; y = z; } while (0)
75#endif
76
77#ifdef DX_DEBUG
78#define dxtrace(command) command
79#else
80#define dxtrace(command)
81#endif
82
83struct fake_dirent
84{
85 __le32 inode;
86 __le16 rec_len;
87 u8 name_len;
88 u8 file_type;
89};
90
91struct dx_countlimit
92{
93 __le16 limit;
94 __le16 count;
95};
96
97struct dx_entry
98{
99 __le32 hash;
100 __le32 block;
101};
102
103/*
104 * dx_root_info is laid out so that if it should somehow get overlaid by a
105 * dirent the two low bits of the hash version will be zero. Therefore, the
106 * hash version mod 4 should never be 0. Sincerely, the paranoia department.
107 */
108
109struct dx_root
110{
111 struct fake_dirent dot;
112 char dot_name[4];
113 struct fake_dirent dotdot;
114 char dotdot_name[4];
115 struct dx_root_info
116 {
117 __le32 reserved_zero;
118 u8 hash_version;
119 u8 info_length; /* 8 */
120 u8 indirect_levels;
121 u8 unused_flags;
122 }
123 info;
124 struct dx_entry entries[0];
125};
126
127struct dx_node
128{
129 struct fake_dirent fake;
130 struct dx_entry entries[0];
131};
132
133
134struct dx_frame
135{
136 struct buffer_head *bh;
137 struct dx_entry *entries;
138 struct dx_entry *at;
139};
140
141struct dx_map_entry
142{
143 u32 hash;
144 u32 offs;
145};
146
147#ifdef CONFIG_EXT4_INDEX
148static inline unsigned dx_get_block (struct dx_entry *entry);
149static void dx_set_block (struct dx_entry *entry, unsigned value);
150static inline unsigned dx_get_hash (struct dx_entry *entry);
151static void dx_set_hash (struct dx_entry *entry, unsigned value);
152static unsigned dx_get_count (struct dx_entry *entries);
153static unsigned dx_get_limit (struct dx_entry *entries);
154static void dx_set_count (struct dx_entry *entries, unsigned value);
155static void dx_set_limit (struct dx_entry *entries, unsigned value);
156static unsigned dx_root_limit (struct inode *dir, unsigned infosize);
157static unsigned dx_node_limit (struct inode *dir);
158static struct dx_frame *dx_probe(struct dentry *dentry,
159 struct inode *dir,
160 struct dx_hash_info *hinfo,
161 struct dx_frame *frame,
162 int *err);
163static void dx_release (struct dx_frame *frames);
164static int dx_make_map (struct ext4_dir_entry_2 *de, int size,
165 struct dx_hash_info *hinfo, struct dx_map_entry map[]);
166static void dx_sort_map(struct dx_map_entry *map, unsigned count);
167static struct ext4_dir_entry_2 *dx_move_dirents (char *from, char *to,
168 struct dx_map_entry *offsets, int count);
169static struct ext4_dir_entry_2* dx_pack_dirents (char *base, int size);
170static void dx_insert_block (struct dx_frame *frame, u32 hash, u32 block);
171static int ext4_htree_next_block(struct inode *dir, __u32 hash,
172 struct dx_frame *frame,
173 struct dx_frame *frames,
174 __u32 *start_hash);
175static struct buffer_head * ext4_dx_find_entry(struct dentry *dentry,
176 struct ext4_dir_entry_2 **res_dir, int *err);
177static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry,
178 struct inode *inode);
179
180/*
181 * Future: use high four bits of block for coalesce-on-delete flags
182 * Mask them off for now.
183 */
184
185static inline unsigned dx_get_block (struct dx_entry *entry)
186{
187 return le32_to_cpu(entry->block) & 0x00ffffff;
188}
189
190static inline void dx_set_block (struct dx_entry *entry, unsigned value)
191{
192 entry->block = cpu_to_le32(value);
193}
194
195static inline unsigned dx_get_hash (struct dx_entry *entry)
196{
197 return le32_to_cpu(entry->hash);
198}
199
200static inline void dx_set_hash (struct dx_entry *entry, unsigned value)
201{
202 entry->hash = cpu_to_le32(value);
203}
204
205static inline unsigned dx_get_count (struct dx_entry *entries)
206{
207 return le16_to_cpu(((struct dx_countlimit *) entries)->count);
208}
209
210static inline unsigned dx_get_limit (struct dx_entry *entries)
211{
212 return le16_to_cpu(((struct dx_countlimit *) entries)->limit);
213}
214
215static inline void dx_set_count (struct dx_entry *entries, unsigned value)
216{
217 ((struct dx_countlimit *) entries)->count = cpu_to_le16(value);
218}
219
220static inline void dx_set_limit (struct dx_entry *entries, unsigned value)
221{
222 ((struct dx_countlimit *) entries)->limit = cpu_to_le16(value);
223}
224
225static inline unsigned dx_root_limit (struct inode *dir, unsigned infosize)
226{
227 unsigned entry_space = dir->i_sb->s_blocksize - EXT4_DIR_REC_LEN(1) -
228 EXT4_DIR_REC_LEN(2) - infosize;
229 return 0? 20: entry_space / sizeof(struct dx_entry);
230}
231
232static inline unsigned dx_node_limit (struct inode *dir)
233{
234 unsigned entry_space = dir->i_sb->s_blocksize - EXT4_DIR_REC_LEN(0);
235 return 0? 22: entry_space / sizeof(struct dx_entry);
236}
237
238/*
239 * Debug
240 */
241#ifdef DX_DEBUG
242static void dx_show_index (char * label, struct dx_entry *entries)
243{
244 int i, n = dx_get_count (entries);
245 printk("%s index ", label);
246 for (i = 0; i < n; i++) {
247 printk("%x->%u ", i? dx_get_hash(entries + i) :
248 0, dx_get_block(entries + i));
249 }
250 printk("\n");
251}
252
253struct stats
254{
255 unsigned names;
256 unsigned space;
257 unsigned bcount;
258};
259
260static struct stats dx_show_leaf(struct dx_hash_info *hinfo, struct ext4_dir_entry_2 *de,
261 int size, int show_names)
262{
263 unsigned names = 0, space = 0;
264 char *base = (char *) de;
265 struct dx_hash_info h = *hinfo;
266
267 printk("names: ");
268 while ((char *) de < base + size)
269 {
270 if (de->inode)
271 {
272 if (show_names)
273 {
274 int len = de->name_len;
275 char *name = de->name;
276 while (len--) printk("%c", *name++);
277 ext4fs_dirhash(de->name, de->name_len, &h);
278 printk(":%x.%u ", h.hash,
279 ((char *) de - base));
280 }
281 space += EXT4_DIR_REC_LEN(de->name_len);
282 names++;
283 }
284 de = (struct ext4_dir_entry_2 *) ((char *) de + le16_to_cpu(de->rec_len));
285 }
286 printk("(%i)\n", names);
287 return (struct stats) { names, space, 1 };
288}
289
290struct stats dx_show_entries(struct dx_hash_info *hinfo, struct inode *dir,
291 struct dx_entry *entries, int levels)
292{
293 unsigned blocksize = dir->i_sb->s_blocksize;
294 unsigned count = dx_get_count (entries), names = 0, space = 0, i;
295 unsigned bcount = 0;
296 struct buffer_head *bh;
297 int err;
298 printk("%i indexed blocks...\n", count);
299 for (i = 0; i < count; i++, entries++)
300 {
301 u32 block = dx_get_block(entries), hash = i? dx_get_hash(entries): 0;
302 u32 range = i < count - 1? (dx_get_hash(entries + 1) - hash): ~hash;
303 struct stats stats;
304 printk("%s%3u:%03u hash %8x/%8x ",levels?"":" ", i, block, hash, range);
305 if (!(bh = ext4_bread (NULL,dir, block, 0,&err))) continue;
306 stats = levels?
307 dx_show_entries(hinfo, dir, ((struct dx_node *) bh->b_data)->entries, levels - 1):
308 dx_show_leaf(hinfo, (struct ext4_dir_entry_2 *) bh->b_data, blocksize, 0);
309 names += stats.names;
310 space += stats.space;
311 bcount += stats.bcount;
312 brelse (bh);
313 }
314 if (bcount)
315 printk("%snames %u, fullness %u (%u%%)\n", levels?"":" ",
316 names, space/bcount,(space/bcount)*100/blocksize);
317 return (struct stats) { names, space, bcount};
318}
319#endif /* DX_DEBUG */
320
321/*
322 * Probe for a directory leaf block to search.
323 *
324 * dx_probe can return ERR_BAD_DX_DIR, which means there was a format
325 * error in the directory index, and the caller should fall back to
326 * searching the directory normally. The callers of dx_probe **MUST**
327 * check for this error code, and make sure it never gets reflected
328 * back to userspace.
329 */
330static struct dx_frame *
331dx_probe(struct dentry *dentry, struct inode *dir,
332 struct dx_hash_info *hinfo, struct dx_frame *frame_in, int *err)
333{
334 unsigned count, indirect;
335 struct dx_entry *at, *entries, *p, *q, *m;
336 struct dx_root *root;
337 struct buffer_head *bh;
338 struct dx_frame *frame = frame_in;
339 u32 hash;
340
341 frame->bh = NULL;
342 if (dentry)
343 dir = dentry->d_parent->d_inode;
344 if (!(bh = ext4_bread (NULL,dir, 0, 0, err)))
345 goto fail;
346 root = (struct dx_root *) bh->b_data;
347 if (root->info.hash_version != DX_HASH_TEA &&
348 root->info.hash_version != DX_HASH_HALF_MD4 &&
349 root->info.hash_version != DX_HASH_LEGACY) {
350 ext4_warning(dir->i_sb, __FUNCTION__,
351 "Unrecognised inode hash code %d",
352 root->info.hash_version);
353 brelse(bh);
354 *err = ERR_BAD_DX_DIR;
355 goto fail;
356 }
357 hinfo->hash_version = root->info.hash_version;
358 hinfo->seed = EXT4_SB(dir->i_sb)->s_hash_seed;
359 if (dentry)
360 ext4fs_dirhash(dentry->d_name.name, dentry->d_name.len, hinfo);
361 hash = hinfo->hash;
362
363 if (root->info.unused_flags & 1) {
364 ext4_warning(dir->i_sb, __FUNCTION__,
365 "Unimplemented inode hash flags: %#06x",
366 root->info.unused_flags);
367 brelse(bh);
368 *err = ERR_BAD_DX_DIR;
369 goto fail;
370 }
371
372 if ((indirect = root->info.indirect_levels) > 1) {
373 ext4_warning(dir->i_sb, __FUNCTION__,
374 "Unimplemented inode hash depth: %#06x",
375 root->info.indirect_levels);
376 brelse(bh);
377 *err = ERR_BAD_DX_DIR;
378 goto fail;
379 }
380
381 entries = (struct dx_entry *) (((char *)&root->info) +
382 root->info.info_length);
383 assert(dx_get_limit(entries) == dx_root_limit(dir,
384 root->info.info_length));
385 dxtrace (printk("Look up %x", hash));
386 while (1)
387 {
388 count = dx_get_count(entries);
389 assert (count && count <= dx_get_limit(entries));
390 p = entries + 1;
391 q = entries + count - 1;
392 while (p <= q)
393 {
394 m = p + (q - p)/2;
395 dxtrace(printk("."));
396 if (dx_get_hash(m) > hash)
397 q = m - 1;
398 else
399 p = m + 1;
400 }
401
402 if (0) // linear search cross check
403 {
404 unsigned n = count - 1;
405 at = entries;
406 while (n--)
407 {
408 dxtrace(printk(","));
409 if (dx_get_hash(++at) > hash)
410 {
411 at--;
412 break;
413 }
414 }
415 assert (at == p - 1);
416 }
417
418 at = p - 1;
419 dxtrace(printk(" %x->%u\n", at == entries? 0: dx_get_hash(at), dx_get_block(at)));
420 frame->bh = bh;
421 frame->entries = entries;
422 frame->at = at;
423 if (!indirect--) return frame;
424 if (!(bh = ext4_bread (NULL,dir, dx_get_block(at), 0, err)))
425 goto fail2;
426 at = entries = ((struct dx_node *) bh->b_data)->entries;
427 assert (dx_get_limit(entries) == dx_node_limit (dir));
428 frame++;
429 }
430fail2:
431 while (frame >= frame_in) {
432 brelse(frame->bh);
433 frame--;
434 }
435fail:
436 return NULL;
437}
438
439static void dx_release (struct dx_frame *frames)
440{
441 if (frames[0].bh == NULL)
442 return;
443
444 if (((struct dx_root *) frames[0].bh->b_data)->info.indirect_levels)
445 brelse(frames[1].bh);
446 brelse(frames[0].bh);
447}
448
449/*
450 * This function increments the frame pointer to search the next leaf
451 * block, and reads in the necessary intervening nodes if the search
452 * should be necessary. Whether or not the search is necessary is
453 * controlled by the hash parameter. If the hash value is even, then
454 * the search is only continued if the next block starts with that
455 * hash value. This is used if we are searching for a specific file.
456 *
457 * If the hash value is HASH_NB_ALWAYS, then always go to the next block.
458 *
459 * This function returns 1 if the caller should continue to search,
460 * or 0 if it should not. If there is an error reading one of the
461 * index blocks, it will a negative error code.
462 *
463 * If start_hash is non-null, it will be filled in with the starting
464 * hash of the next page.
465 */
466static int ext4_htree_next_block(struct inode *dir, __u32 hash,
467 struct dx_frame *frame,
468 struct dx_frame *frames,
469 __u32 *start_hash)
470{
471 struct dx_frame *p;
472 struct buffer_head *bh;
473 int err, num_frames = 0;
474 __u32 bhash;
475
476 p = frame;
477 /*
478 * Find the next leaf page by incrementing the frame pointer.
479 * If we run out of entries in the interior node, loop around and
480 * increment pointer in the parent node. When we break out of
481 * this loop, num_frames indicates the number of interior
482 * nodes need to be read.
483 */
484 while (1) {
485 if (++(p->at) < p->entries + dx_get_count(p->entries))
486 break;
487 if (p == frames)
488 return 0;
489 num_frames++;
490 p--;
491 }
492
493 /*
494 * If the hash is 1, then continue only if the next page has a
495 * continuation hash of any value. This is used for readdir
496 * handling. Otherwise, check to see if the hash matches the
497 * desired contiuation hash. If it doesn't, return since
498 * there's no point to read in the successive index pages.
499 */
500 bhash = dx_get_hash(p->at);
501 if (start_hash)
502 *start_hash = bhash;
503 if ((hash & 1) == 0) {
504 if ((bhash & ~1) != hash)
505 return 0;
506 }
507 /*
508 * If the hash is HASH_NB_ALWAYS, we always go to the next
509 * block so no check is necessary
510 */
511 while (num_frames--) {
512 if (!(bh = ext4_bread(NULL, dir, dx_get_block(p->at),
513 0, &err)))
514 return err; /* Failure */
515 p++;
516 brelse (p->bh);
517 p->bh = bh;
518 p->at = p->entries = ((struct dx_node *) bh->b_data)->entries;
519 }
520 return 1;
521}
522
523
524/*
525 * p is at least 6 bytes before the end of page
526 */
527static inline struct ext4_dir_entry_2 *ext4_next_entry(struct ext4_dir_entry_2 *p)
528{
529 return (struct ext4_dir_entry_2 *)((char*)p + le16_to_cpu(p->rec_len));
530}
531
532/*
533 * This function fills a red-black tree with information from a
534 * directory block. It returns the number directory entries loaded
535 * into the tree. If there is an error it is returned in err.
536 */
537static int htree_dirblock_to_tree(struct file *dir_file,
538 struct inode *dir, int block,
539 struct dx_hash_info *hinfo,
540 __u32 start_hash, __u32 start_minor_hash)
541{
542 struct buffer_head *bh;
543 struct ext4_dir_entry_2 *de, *top;
544 int err, count = 0;
545
546 dxtrace(printk("In htree dirblock_to_tree: block %d\n", block));
547 if (!(bh = ext4_bread (NULL, dir, block, 0, &err)))
548 return err;
549
550 de = (struct ext4_dir_entry_2 *) bh->b_data;
551 top = (struct ext4_dir_entry_2 *) ((char *) de +
552 dir->i_sb->s_blocksize -
553 EXT4_DIR_REC_LEN(0));
554 for (; de < top; de = ext4_next_entry(de)) {
555 ext4fs_dirhash(de->name, de->name_len, hinfo);
556 if ((hinfo->hash < start_hash) ||
557 ((hinfo->hash == start_hash) &&
558 (hinfo->minor_hash < start_minor_hash)))
559 continue;
560 if (de->inode == 0)
561 continue;
562 if ((err = ext4_htree_store_dirent(dir_file,
563 hinfo->hash, hinfo->minor_hash, de)) != 0) {
564 brelse(bh);
565 return err;
566 }
567 count++;
568 }
569 brelse(bh);
570 return count;
571}
572
573
574/*
575 * This function fills a red-black tree with information from a
576 * directory. We start scanning the directory in hash order, starting
577 * at start_hash and start_minor_hash.
578 *
579 * This function returns the number of entries inserted into the tree,
580 * or a negative error code.
581 */
582int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash,
583 __u32 start_minor_hash, __u32 *next_hash)
584{
585 struct dx_hash_info hinfo;
586 struct ext4_dir_entry_2 *de;
587 struct dx_frame frames[2], *frame;
588 struct inode *dir;
589 int block, err;
590 int count = 0;
591 int ret;
592 __u32 hashval;
593
594 dxtrace(printk("In htree_fill_tree, start hash: %x:%x\n", start_hash,
595 start_minor_hash));
596 dir = dir_file->f_dentry->d_inode;
597 if (!(EXT4_I(dir)->i_flags & EXT4_INDEX_FL)) {
598 hinfo.hash_version = EXT4_SB(dir->i_sb)->s_def_hash_version;
599 hinfo.seed = EXT4_SB(dir->i_sb)->s_hash_seed;
600 count = htree_dirblock_to_tree(dir_file, dir, 0, &hinfo,
601 start_hash, start_minor_hash);
602 *next_hash = ~0;
603 return count;
604 }
605 hinfo.hash = start_hash;
606 hinfo.minor_hash = 0;
607 frame = dx_probe(NULL, dir_file->f_dentry->d_inode, &hinfo, frames, &err);
608 if (!frame)
609 return err;
610
611 /* Add '.' and '..' from the htree header */
612 if (!start_hash && !start_minor_hash) {
613 de = (struct ext4_dir_entry_2 *) frames[0].bh->b_data;
614 if ((err = ext4_htree_store_dirent(dir_file, 0, 0, de)) != 0)
615 goto errout;
616 count++;
617 }
618 if (start_hash < 2 || (start_hash ==2 && start_minor_hash==0)) {
619 de = (struct ext4_dir_entry_2 *) frames[0].bh->b_data;
620 de = ext4_next_entry(de);
621 if ((err = ext4_htree_store_dirent(dir_file, 2, 0, de)) != 0)
622 goto errout;
623 count++;
624 }
625
626 while (1) {
627 block = dx_get_block(frame->at);
628 ret = htree_dirblock_to_tree(dir_file, dir, block, &hinfo,
629 start_hash, start_minor_hash);
630 if (ret < 0) {
631 err = ret;
632 goto errout;
633 }
634 count += ret;
635 hashval = ~0;
636 ret = ext4_htree_next_block(dir, HASH_NB_ALWAYS,
637 frame, frames, &hashval);
638 *next_hash = hashval;
639 if (ret < 0) {
640 err = ret;
641 goto errout;
642 }
643 /*
644 * Stop if: (a) there are no more entries, or
645 * (b) we have inserted at least one entry and the
646 * next hash value is not a continuation
647 */
648 if ((ret == 0) ||
649 (count && ((hashval & 1) == 0)))
650 break;
651 }
652 dx_release(frames);
653 dxtrace(printk("Fill tree: returned %d entries, next hash: %x\n",
654 count, *next_hash));
655 return count;
656errout:
657 dx_release(frames);
658 return (err);
659}
660
661
662/*
663 * Directory block splitting, compacting
664 */
665
666static int dx_make_map (struct ext4_dir_entry_2 *de, int size,
667 struct dx_hash_info *hinfo, struct dx_map_entry *map_tail)
668{
669 int count = 0;
670 char *base = (char *) de;
671 struct dx_hash_info h = *hinfo;
672
673 while ((char *) de < base + size)
674 {
675 if (de->name_len && de->inode) {
676 ext4fs_dirhash(de->name, de->name_len, &h);
677 map_tail--;
678 map_tail->hash = h.hash;
679 map_tail->offs = (u32) ((char *) de - base);
680 count++;
681 cond_resched();
682 }
683 /* XXX: do we need to check rec_len == 0 case? -Chris */
684 de = (struct ext4_dir_entry_2 *) ((char *) de + le16_to_cpu(de->rec_len));
685 }
686 return count;
687}
688
689static void dx_sort_map (struct dx_map_entry *map, unsigned count)
690{
691 struct dx_map_entry *p, *q, *top = map + count - 1;
692 int more;
693 /* Combsort until bubble sort doesn't suck */
694 while (count > 2) {
695 count = count*10/13;
696 if (count - 9 < 2) /* 9, 10 -> 11 */
697 count = 11;
698 for (p = top, q = p - count; q >= map; p--, q--)
699 if (p->hash < q->hash)
700 swap(*p, *q);
701 }
702 /* Garden variety bubble sort */
703 do {
704 more = 0;
705 q = top;
706 while (q-- > map) {
707 if (q[1].hash >= q[0].hash)
708 continue;
709 swap(*(q+1), *q);
710 more = 1;
711 }
712 } while(more);
713}
714
715static void dx_insert_block(struct dx_frame *frame, u32 hash, u32 block)
716{
717 struct dx_entry *entries = frame->entries;
718 struct dx_entry *old = frame->at, *new = old + 1;
719 int count = dx_get_count(entries);
720
721 assert(count < dx_get_limit(entries));
722 assert(old < entries + count);
723 memmove(new + 1, new, (char *)(entries + count) - (char *)(new));
724 dx_set_hash(new, hash);
725 dx_set_block(new, block);
726 dx_set_count(entries, count + 1);
727}
728#endif
729
730
731static void ext4_update_dx_flag(struct inode *inode)
732{
733 if (!EXT4_HAS_COMPAT_FEATURE(inode->i_sb,
734 EXT4_FEATURE_COMPAT_DIR_INDEX))
735 EXT4_I(inode)->i_flags &= ~EXT4_INDEX_FL;
736}
737
738/*
739 * NOTE! unlike strncmp, ext4_match returns 1 for success, 0 for failure.
740 *
741 * `len <= EXT4_NAME_LEN' is guaranteed by caller.
742 * `de != NULL' is guaranteed by caller.
743 */
744static inline int ext4_match (int len, const char * const name,
745 struct ext4_dir_entry_2 * de)
746{
747 if (len != de->name_len)
748 return 0;
749 if (!de->inode)
750 return 0;
751 return !memcmp(name, de->name, len);
752}
753
754/*
755 * Returns 0 if not found, -1 on failure, and 1 on success
756 */
757static inline int search_dirblock(struct buffer_head * bh,
758 struct inode *dir,
759 struct dentry *dentry,
760 unsigned long offset,
761 struct ext4_dir_entry_2 ** res_dir)
762{
763 struct ext4_dir_entry_2 * de;
764 char * dlimit;
765 int de_len;
766 const char *name = dentry->d_name.name;
767 int namelen = dentry->d_name.len;
768
769 de = (struct ext4_dir_entry_2 *) bh->b_data;
770 dlimit = bh->b_data + dir->i_sb->s_blocksize;
771 while ((char *) de < dlimit) {
772 /* this code is executed quadratically often */
773 /* do minimal checking `by hand' */
774
775 if ((char *) de + namelen <= dlimit &&
776 ext4_match (namelen, name, de)) {
777 /* found a match - just to be sure, do a full check */
778 if (!ext4_check_dir_entry("ext4_find_entry",
779 dir, de, bh, offset))
780 return -1;
781 *res_dir = de;
782 return 1;
783 }
784 /* prevent looping on a bad block */
785 de_len = le16_to_cpu(de->rec_len);
786 if (de_len <= 0)
787 return -1;
788 offset += de_len;
789 de = (struct ext4_dir_entry_2 *) ((char *) de + de_len);
790 }
791 return 0;
792}
793
794
795/*
796 * ext4_find_entry()
797 *
798 * finds an entry in the specified directory with the wanted name. It
799 * returns the cache buffer in which the entry was found, and the entry
800 * itself (as a parameter - res_dir). It does NOT read the inode of the
801 * entry - you'll have to do that yourself if you want to.
802 *
803 * The returned buffer_head has ->b_count elevated. The caller is expected
804 * to brelse() it when appropriate.
805 */
806static struct buffer_head * ext4_find_entry (struct dentry *dentry,
807 struct ext4_dir_entry_2 ** res_dir)
808{
809 struct super_block * sb;
810 struct buffer_head * bh_use[NAMEI_RA_SIZE];
811 struct buffer_head * bh, *ret = NULL;
812 unsigned long start, block, b;
813 int ra_max = 0; /* Number of bh's in the readahead
814 buffer, bh_use[] */
815 int ra_ptr = 0; /* Current index into readahead
816 buffer */
817 int num = 0;
818 int nblocks, i, err;
819 struct inode *dir = dentry->d_parent->d_inode;
820 int namelen;
821 const u8 *name;
822 unsigned blocksize;
823
824 *res_dir = NULL;
825 sb = dir->i_sb;
826 blocksize = sb->s_blocksize;
827 namelen = dentry->d_name.len;
828 name = dentry->d_name.name;
829 if (namelen > EXT4_NAME_LEN)
830 return NULL;
831#ifdef CONFIG_EXT4_INDEX
832 if (is_dx(dir)) {
833 bh = ext4_dx_find_entry(dentry, res_dir, &err);
834 /*
835 * On success, or if the error was file not found,
836 * return. Otherwise, fall back to doing a search the
837 * old fashioned way.
838 */
839 if (bh || (err != ERR_BAD_DX_DIR))
840 return bh;
841 dxtrace(printk("ext4_find_entry: dx failed, falling back\n"));
842 }
843#endif
844 nblocks = dir->i_size >> EXT4_BLOCK_SIZE_BITS(sb);
845 start = EXT4_I(dir)->i_dir_start_lookup;
846 if (start >= nblocks)
847 start = 0;
848 block = start;
849restart:
850 do {
851 /*
852 * We deal with the read-ahead logic here.
853 */
854 if (ra_ptr >= ra_max) {
855 /* Refill the readahead buffer */
856 ra_ptr = 0;
857 b = block;
858 for (ra_max = 0; ra_max < NAMEI_RA_SIZE; ra_max++) {
859 /*
860 * Terminate if we reach the end of the
861 * directory and must wrap, or if our
862 * search has finished at this block.
863 */
864 if (b >= nblocks || (num && block == start)) {
865 bh_use[ra_max] = NULL;
866 break;
867 }
868 num++;
869 bh = ext4_getblk(NULL, dir, b++, 0, &err);
870 bh_use[ra_max] = bh;
871 if (bh)
872 ll_rw_block(READ_META, 1, &bh);
873 }
874 }
875 if ((bh = bh_use[ra_ptr++]) == NULL)
876 goto next;
877 wait_on_buffer(bh);
878 if (!buffer_uptodate(bh)) {
879 /* read error, skip block & hope for the best */
880 ext4_error(sb, __FUNCTION__, "reading directory #%lu "
881 "offset %lu", dir->i_ino, block);
882 brelse(bh);
883 goto next;
884 }
885 i = search_dirblock(bh, dir, dentry,
886 block << EXT4_BLOCK_SIZE_BITS(sb), res_dir);
887 if (i == 1) {
888 EXT4_I(dir)->i_dir_start_lookup = block;
889 ret = bh;
890 goto cleanup_and_exit;
891 } else {
892 brelse(bh);
893 if (i < 0)
894 goto cleanup_and_exit;
895 }
896 next:
897 if (++block >= nblocks)
898 block = 0;
899 } while (block != start);
900
901 /*
902 * If the directory has grown while we were searching, then
903 * search the last part of the directory before giving up.
904 */
905 block = nblocks;
906 nblocks = dir->i_size >> EXT4_BLOCK_SIZE_BITS(sb);
907 if (block < nblocks) {
908 start = 0;
909 goto restart;
910 }
911
912cleanup_and_exit:
913 /* Clean up the read-ahead blocks */
914 for (; ra_ptr < ra_max; ra_ptr++)
915 brelse (bh_use[ra_ptr]);
916 return ret;
917}
918
919#ifdef CONFIG_EXT4_INDEX
920static struct buffer_head * ext4_dx_find_entry(struct dentry *dentry,
921 struct ext4_dir_entry_2 **res_dir, int *err)
922{
923 struct super_block * sb;
924 struct dx_hash_info hinfo;
925 u32 hash;
926 struct dx_frame frames[2], *frame;
927 struct ext4_dir_entry_2 *de, *top;
928 struct buffer_head *bh;
929 unsigned long block;
930 int retval;
931 int namelen = dentry->d_name.len;
932 const u8 *name = dentry->d_name.name;
933 struct inode *dir = dentry->d_parent->d_inode;
934
935 sb = dir->i_sb;
936 /* NFS may look up ".." - look at dx_root directory block */
937 if (namelen > 2 || name[0] != '.'||(name[1] != '.' && name[1] != '\0')){
938 if (!(frame = dx_probe(dentry, NULL, &hinfo, frames, err)))
939 return NULL;
940 } else {
941 frame = frames;
942 frame->bh = NULL; /* for dx_release() */
943 frame->at = (struct dx_entry *)frames; /* hack for zero entry*/
944 dx_set_block(frame->at, 0); /* dx_root block is 0 */
945 }
946 hash = hinfo.hash;
947 do {
948 block = dx_get_block(frame->at);
949 if (!(bh = ext4_bread (NULL,dir, block, 0, err)))
950 goto errout;
951 de = (struct ext4_dir_entry_2 *) bh->b_data;
952 top = (struct ext4_dir_entry_2 *) ((char *) de + sb->s_blocksize -
953 EXT4_DIR_REC_LEN(0));
954 for (; de < top; de = ext4_next_entry(de))
955 if (ext4_match (namelen, name, de)) {
956 if (!ext4_check_dir_entry("ext4_find_entry",
957 dir, de, bh,
958 (block<<EXT4_BLOCK_SIZE_BITS(sb))
959 +((char *)de - bh->b_data))) {
960 brelse (bh);
961 goto errout;
962 }
963 *res_dir = de;
964 dx_release (frames);
965 return bh;
966 }
967 brelse (bh);
968 /* Check to see if we should continue to search */
969 retval = ext4_htree_next_block(dir, hash, frame,
970 frames, NULL);
971 if (retval < 0) {
972 ext4_warning(sb, __FUNCTION__,
973 "error reading index page in directory #%lu",
974 dir->i_ino);
975 *err = retval;
976 goto errout;
977 }
978 } while (retval == 1);
979
980 *err = -ENOENT;
981errout:
982 dxtrace(printk("%s not found\n", name));
983 dx_release (frames);
984 return NULL;
985}
986#endif
987
988static struct dentry *ext4_lookup(struct inode * dir, struct dentry *dentry, struct nameidata *nd)
989{
990 struct inode * inode;
991 struct ext4_dir_entry_2 * de;
992 struct buffer_head * bh;
993
994 if (dentry->d_name.len > EXT4_NAME_LEN)
995 return ERR_PTR(-ENAMETOOLONG);
996
997 bh = ext4_find_entry(dentry, &de);
998 inode = NULL;
999 if (bh) {
1000 unsigned long ino = le32_to_cpu(de->inode);
1001 brelse (bh);
1002 if (!ext4_valid_inum(dir->i_sb, ino)) {
1003 ext4_error(dir->i_sb, "ext4_lookup",
1004 "bad inode number: %lu", ino);
1005 inode = NULL;
1006 } else
1007 inode = iget(dir->i_sb, ino);
1008
1009 if (!inode)
1010 return ERR_PTR(-EACCES);
1011 }
1012 return d_splice_alias(inode, dentry);
1013}
1014
1015
1016struct dentry *ext4_get_parent(struct dentry *child)
1017{
1018 unsigned long ino;
1019 struct dentry *parent;
1020 struct inode *inode;
1021 struct dentry dotdot;
1022 struct ext4_dir_entry_2 * de;
1023 struct buffer_head *bh;
1024
1025 dotdot.d_name.name = "..";
1026 dotdot.d_name.len = 2;
1027 dotdot.d_parent = child; /* confusing, isn't it! */
1028
1029 bh = ext4_find_entry(&dotdot, &de);
1030 inode = NULL;
1031 if (!bh)
1032 return ERR_PTR(-ENOENT);
1033 ino = le32_to_cpu(de->inode);
1034 brelse(bh);
1035
1036 if (!ext4_valid_inum(child->d_inode->i_sb, ino)) {
1037 ext4_error(child->d_inode->i_sb, "ext4_get_parent",
1038 "bad inode number: %lu", ino);
1039 inode = NULL;
1040 } else
1041 inode = iget(child->d_inode->i_sb, ino);
1042
1043 if (!inode)
1044 return ERR_PTR(-EACCES);
1045
1046 parent = d_alloc_anon(inode);
1047 if (!parent) {
1048 iput(inode);
1049 parent = ERR_PTR(-ENOMEM);
1050 }
1051 return parent;
1052}
1053
1054#define S_SHIFT 12
1055static unsigned char ext4_type_by_mode[S_IFMT >> S_SHIFT] = {
1056 [S_IFREG >> S_SHIFT] = EXT4_FT_REG_FILE,
1057 [S_IFDIR >> S_SHIFT] = EXT4_FT_DIR,
1058 [S_IFCHR >> S_SHIFT] = EXT4_FT_CHRDEV,
1059 [S_IFBLK >> S_SHIFT] = EXT4_FT_BLKDEV,
1060 [S_IFIFO >> S_SHIFT] = EXT4_FT_FIFO,
1061 [S_IFSOCK >> S_SHIFT] = EXT4_FT_SOCK,
1062 [S_IFLNK >> S_SHIFT] = EXT4_FT_SYMLINK,
1063};
1064
1065static inline void ext4_set_de_type(struct super_block *sb,
1066 struct ext4_dir_entry_2 *de,
1067 umode_t mode) {
1068 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FILETYPE))
1069 de->file_type = ext4_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
1070}
1071
1072#ifdef CONFIG_EXT4_INDEX
1073static struct ext4_dir_entry_2 *
1074dx_move_dirents(char *from, char *to, struct dx_map_entry *map, int count)
1075{
1076 unsigned rec_len = 0;
1077
1078 while (count--) {
1079 struct ext4_dir_entry_2 *de = (struct ext4_dir_entry_2 *) (from + map->offs);
1080 rec_len = EXT4_DIR_REC_LEN(de->name_len);
1081 memcpy (to, de, rec_len);
1082 ((struct ext4_dir_entry_2 *) to)->rec_len =
1083 cpu_to_le16(rec_len);
1084 de->inode = 0;
1085 map++;
1086 to += rec_len;
1087 }
1088 return (struct ext4_dir_entry_2 *) (to - rec_len);
1089}
1090
1091static struct ext4_dir_entry_2* dx_pack_dirents(char *base, int size)
1092{
1093 struct ext4_dir_entry_2 *next, *to, *prev, *de = (struct ext4_dir_entry_2 *) base;
1094 unsigned rec_len = 0;
1095
1096 prev = to = de;
1097 while ((char*)de < base + size) {
1098 next = (struct ext4_dir_entry_2 *) ((char *) de +
1099 le16_to_cpu(de->rec_len));
1100 if (de->inode && de->name_len) {
1101 rec_len = EXT4_DIR_REC_LEN(de->name_len);
1102 if (de > to)
1103 memmove(to, de, rec_len);
1104 to->rec_len = cpu_to_le16(rec_len);
1105 prev = to;
1106 to = (struct ext4_dir_entry_2 *) (((char *) to) + rec_len);
1107 }
1108 de = next;
1109 }
1110 return prev;
1111}
1112
1113static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir,
1114 struct buffer_head **bh,struct dx_frame *frame,
1115 struct dx_hash_info *hinfo, int *error)
1116{
1117 unsigned blocksize = dir->i_sb->s_blocksize;
1118 unsigned count, continued;
1119 struct buffer_head *bh2;
1120 u32 newblock;
1121 u32 hash2;
1122 struct dx_map_entry *map;
1123 char *data1 = (*bh)->b_data, *data2;
1124 unsigned split;
1125 struct ext4_dir_entry_2 *de = NULL, *de2;
1126 int err;
1127
1128 bh2 = ext4_append (handle, dir, &newblock, error);
1129 if (!(bh2)) {
1130 brelse(*bh);
1131 *bh = NULL;
1132 goto errout;
1133 }
1134
1135 BUFFER_TRACE(*bh, "get_write_access");
1136 err = ext4_journal_get_write_access(handle, *bh);
1137 if (err) {
1138 journal_error:
1139 brelse(*bh);
1140 brelse(bh2);
1141 *bh = NULL;
1142 ext4_std_error(dir->i_sb, err);
1143 goto errout;
1144 }
1145 BUFFER_TRACE(frame->bh, "get_write_access");
1146 err = ext4_journal_get_write_access(handle, frame->bh);
1147 if (err)
1148 goto journal_error;
1149
1150 data2 = bh2->b_data;
1151
1152 /* create map in the end of data2 block */
1153 map = (struct dx_map_entry *) (data2 + blocksize);
1154 count = dx_make_map ((struct ext4_dir_entry_2 *) data1,
1155 blocksize, hinfo, map);
1156 map -= count;
1157 split = count/2; // need to adjust to actual middle
1158 dx_sort_map (map, count);
1159 hash2 = map[split].hash;
1160 continued = hash2 == map[split - 1].hash;
1161 dxtrace(printk("Split block %i at %x, %i/%i\n",
1162 dx_get_block(frame->at), hash2, split, count-split));
1163
1164 /* Fancy dance to stay within two buffers */
1165 de2 = dx_move_dirents(data1, data2, map + split, count - split);
1166 de = dx_pack_dirents(data1,blocksize);
1167 de->rec_len = cpu_to_le16(data1 + blocksize - (char *) de);
1168 de2->rec_len = cpu_to_le16(data2 + blocksize - (char *) de2);
1169 dxtrace(dx_show_leaf (hinfo, (struct ext4_dir_entry_2 *) data1, blocksize, 1));
1170 dxtrace(dx_show_leaf (hinfo, (struct ext4_dir_entry_2 *) data2, blocksize, 1));
1171
1172 /* Which block gets the new entry? */
1173 if (hinfo->hash >= hash2)
1174 {
1175 swap(*bh, bh2);
1176 de = de2;
1177 }
1178 dx_insert_block (frame, hash2 + continued, newblock);
1179 err = ext4_journal_dirty_metadata (handle, bh2);
1180 if (err)
1181 goto journal_error;
1182 err = ext4_journal_dirty_metadata (handle, frame->bh);
1183 if (err)
1184 goto journal_error;
1185 brelse (bh2);
1186 dxtrace(dx_show_index ("frame", frame->entries));
1187errout:
1188 return de;
1189}
1190#endif
1191
1192
1193/*
1194 * Add a new entry into a directory (leaf) block. If de is non-NULL,
1195 * it points to a directory entry which is guaranteed to be large
1196 * enough for new directory entry. If de is NULL, then
1197 * add_dirent_to_buf will attempt search the directory block for
1198 * space. It will return -ENOSPC if no space is available, and -EIO
1199 * and -EEXIST if directory entry already exists.
1200 *
1201 * NOTE! bh is NOT released in the case where ENOSPC is returned. In
1202 * all other cases bh is released.
1203 */
1204static int add_dirent_to_buf(handle_t *handle, struct dentry *dentry,
1205 struct inode *inode, struct ext4_dir_entry_2 *de,
1206 struct buffer_head * bh)
1207{
1208 struct inode *dir = dentry->d_parent->d_inode;
1209 const char *name = dentry->d_name.name;
1210 int namelen = dentry->d_name.len;
1211 unsigned long offset = 0;
1212 unsigned short reclen;
1213 int nlen, rlen, err;
1214 char *top;
1215
1216 reclen = EXT4_DIR_REC_LEN(namelen);
1217 if (!de) {
1218 de = (struct ext4_dir_entry_2 *)bh->b_data;
1219 top = bh->b_data + dir->i_sb->s_blocksize - reclen;
1220 while ((char *) de <= top) {
1221 if (!ext4_check_dir_entry("ext4_add_entry", dir, de,
1222 bh, offset)) {
1223 brelse (bh);
1224 return -EIO;
1225 }
1226 if (ext4_match (namelen, name, de)) {
1227 brelse (bh);
1228 return -EEXIST;
1229 }
1230 nlen = EXT4_DIR_REC_LEN(de->name_len);
1231 rlen = le16_to_cpu(de->rec_len);
1232 if ((de->inode? rlen - nlen: rlen) >= reclen)
1233 break;
1234 de = (struct ext4_dir_entry_2 *)((char *)de + rlen);
1235 offset += rlen;
1236 }
1237 if ((char *) de > top)
1238 return -ENOSPC;
1239 }
1240 BUFFER_TRACE(bh, "get_write_access");
1241 err = ext4_journal_get_write_access(handle, bh);
1242 if (err) {
1243 ext4_std_error(dir->i_sb, err);
1244 brelse(bh);
1245 return err;
1246 }
1247
1248 /* By now the buffer is marked for journaling */
1249 nlen = EXT4_DIR_REC_LEN(de->name_len);
1250 rlen = le16_to_cpu(de->rec_len);
1251 if (de->inode) {
1252 struct ext4_dir_entry_2 *de1 = (struct ext4_dir_entry_2 *)((char *)de + nlen);
1253 de1->rec_len = cpu_to_le16(rlen - nlen);
1254 de->rec_len = cpu_to_le16(nlen);
1255 de = de1;
1256 }
1257 de->file_type = EXT4_FT_UNKNOWN;
1258 if (inode) {
1259 de->inode = cpu_to_le32(inode->i_ino);
1260 ext4_set_de_type(dir->i_sb, de, inode->i_mode);
1261 } else
1262 de->inode = 0;
1263 de->name_len = namelen;
1264 memcpy (de->name, name, namelen);
1265 /*
1266 * XXX shouldn't update any times until successful
1267 * completion of syscall, but too many callers depend
1268 * on this.
1269 *
1270 * XXX similarly, too many callers depend on
1271 * ext4_new_inode() setting the times, but error
1272 * recovery deletes the inode, so the worst that can
1273 * happen is that the times are slightly out of date
1274 * and/or different from the directory change time.
1275 */
1276 dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
1277 ext4_update_dx_flag(dir);
1278 dir->i_version++;
1279 ext4_mark_inode_dirty(handle, dir);
1280 BUFFER_TRACE(bh, "call ext4_journal_dirty_metadata");
1281 err = ext4_journal_dirty_metadata(handle, bh);
1282 if (err)
1283 ext4_std_error(dir->i_sb, err);
1284 brelse(bh);
1285 return 0;
1286}
1287
1288#ifdef CONFIG_EXT4_INDEX
1289/*
1290 * This converts a one block unindexed directory to a 3 block indexed
1291 * directory, and adds the dentry to the indexed directory.
1292 */
1293static int make_indexed_dir(handle_t *handle, struct dentry *dentry,
1294 struct inode *inode, struct buffer_head *bh)
1295{
1296 struct inode *dir = dentry->d_parent->d_inode;
1297 const char *name = dentry->d_name.name;
1298 int namelen = dentry->d_name.len;
1299 struct buffer_head *bh2;
1300 struct dx_root *root;
1301 struct dx_frame frames[2], *frame;
1302 struct dx_entry *entries;
1303 struct ext4_dir_entry_2 *de, *de2;
1304 char *data1, *top;
1305 unsigned len;
1306 int retval;
1307 unsigned blocksize;
1308 struct dx_hash_info hinfo;
1309 u32 block;
1310 struct fake_dirent *fde;
1311
1312 blocksize = dir->i_sb->s_blocksize;
1313 dxtrace(printk("Creating index\n"));
1314 retval = ext4_journal_get_write_access(handle, bh);
1315 if (retval) {
1316 ext4_std_error(dir->i_sb, retval);
1317 brelse(bh);
1318 return retval;
1319 }
1320 root = (struct dx_root *) bh->b_data;
1321
1322 bh2 = ext4_append (handle, dir, &block, &retval);
1323 if (!(bh2)) {
1324 brelse(bh);
1325 return retval;
1326 }
1327 EXT4_I(dir)->i_flags |= EXT4_INDEX_FL;
1328 data1 = bh2->b_data;
1329
1330 /* The 0th block becomes the root, move the dirents out */
1331 fde = &root->dotdot;
1332 de = (struct ext4_dir_entry_2 *)((char *)fde + le16_to_cpu(fde->rec_len));
1333 len = ((char *) root) + blocksize - (char *) de;
1334 memcpy (data1, de, len);
1335 de = (struct ext4_dir_entry_2 *) data1;
1336 top = data1 + len;
1337 while ((char *)(de2=(void*)de+le16_to_cpu(de->rec_len)) < top)
1338 de = de2;
1339 de->rec_len = cpu_to_le16(data1 + blocksize - (char *) de);
1340 /* Initialize the root; the dot dirents already exist */
1341 de = (struct ext4_dir_entry_2 *) (&root->dotdot);
1342 de->rec_len = cpu_to_le16(blocksize - EXT4_DIR_REC_LEN(2));
1343 memset (&root->info, 0, sizeof(root->info));
1344 root->info.info_length = sizeof(root->info);
1345 root->info.hash_version = EXT4_SB(dir->i_sb)->s_def_hash_version;
1346 entries = root->entries;
1347 dx_set_block (entries, 1);
1348 dx_set_count (entries, 1);
1349 dx_set_limit (entries, dx_root_limit(dir, sizeof(root->info)));
1350
1351 /* Initialize as for dx_probe */
1352 hinfo.hash_version = root->info.hash_version;
1353 hinfo.seed = EXT4_SB(dir->i_sb)->s_hash_seed;
1354 ext4fs_dirhash(name, namelen, &hinfo);
1355 frame = frames;
1356 frame->entries = entries;
1357 frame->at = entries;
1358 frame->bh = bh;
1359 bh = bh2;
1360 de = do_split(handle,dir, &bh, frame, &hinfo, &retval);
1361 dx_release (frames);
1362 if (!(de))
1363 return retval;
1364
1365 return add_dirent_to_buf(handle, dentry, inode, de, bh);
1366}
1367#endif
1368
1369/*
1370 * ext4_add_entry()
1371 *
1372 * adds a file entry to the specified directory, using the same
1373 * semantics as ext4_find_entry(). It returns NULL if it failed.
1374 *
1375 * NOTE!! The inode part of 'de' is left at 0 - which means you
1376 * may not sleep between calling this and putting something into
1377 * the entry, as someone else might have used it while you slept.
1378 */
1379static int ext4_add_entry (handle_t *handle, struct dentry *dentry,
1380 struct inode *inode)
1381{
1382 struct inode *dir = dentry->d_parent->d_inode;
1383 unsigned long offset;
1384 struct buffer_head * bh;
1385 struct ext4_dir_entry_2 *de;
1386 struct super_block * sb;
1387 int retval;
1388#ifdef CONFIG_EXT4_INDEX
1389 int dx_fallback=0;
1390#endif
1391 unsigned blocksize;
1392 u32 block, blocks;
1393
1394 sb = dir->i_sb;
1395 blocksize = sb->s_blocksize;
1396 if (!dentry->d_name.len)
1397 return -EINVAL;
1398#ifdef CONFIG_EXT4_INDEX
1399 if (is_dx(dir)) {
1400 retval = ext4_dx_add_entry(handle, dentry, inode);
1401 if (!retval || (retval != ERR_BAD_DX_DIR))
1402 return retval;
1403 EXT4_I(dir)->i_flags &= ~EXT4_INDEX_FL;
1404 dx_fallback++;
1405 ext4_mark_inode_dirty(handle, dir);
1406 }
1407#endif
1408 blocks = dir->i_size >> sb->s_blocksize_bits;
1409 for (block = 0, offset = 0; block < blocks; block++) {
1410 bh = ext4_bread(handle, dir, block, 0, &retval);
1411 if(!bh)
1412 return retval;
1413 retval = add_dirent_to_buf(handle, dentry, inode, NULL, bh);
1414 if (retval != -ENOSPC)
1415 return retval;
1416
1417#ifdef CONFIG_EXT4_INDEX
1418 if (blocks == 1 && !dx_fallback &&
1419 EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_DIR_INDEX))
1420 return make_indexed_dir(handle, dentry, inode, bh);
1421#endif
1422 brelse(bh);
1423 }
1424 bh = ext4_append(handle, dir, &block, &retval);
1425 if (!bh)
1426 return retval;
1427 de = (struct ext4_dir_entry_2 *) bh->b_data;
1428 de->inode = 0;
1429 de->rec_len = cpu_to_le16(blocksize);
1430 return add_dirent_to_buf(handle, dentry, inode, de, bh);
1431}
1432
1433#ifdef CONFIG_EXT4_INDEX
1434/*
1435 * Returns 0 for success, or a negative error value
1436 */
1437static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry,
1438 struct inode *inode)
1439{
1440 struct dx_frame frames[2], *frame;
1441 struct dx_entry *entries, *at;
1442 struct dx_hash_info hinfo;
1443 struct buffer_head * bh;
1444 struct inode *dir = dentry->d_parent->d_inode;
1445 struct super_block * sb = dir->i_sb;
1446 struct ext4_dir_entry_2 *de;
1447 int err;
1448
1449 frame = dx_probe(dentry, NULL, &hinfo, frames, &err);
1450 if (!frame)
1451 return err;
1452 entries = frame->entries;
1453 at = frame->at;
1454
1455 if (!(bh = ext4_bread(handle,dir, dx_get_block(frame->at), 0, &err)))
1456 goto cleanup;
1457
1458 BUFFER_TRACE(bh, "get_write_access");
1459 err = ext4_journal_get_write_access(handle, bh);
1460 if (err)
1461 goto journal_error;
1462
1463 err = add_dirent_to_buf(handle, dentry, inode, NULL, bh);
1464 if (err != -ENOSPC) {
1465 bh = NULL;
1466 goto cleanup;
1467 }
1468
1469 /* Block full, should compress but for now just split */
1470 dxtrace(printk("using %u of %u node entries\n",
1471 dx_get_count(entries), dx_get_limit(entries)));
1472 /* Need to split index? */
1473 if (dx_get_count(entries) == dx_get_limit(entries)) {
1474 u32 newblock;
1475 unsigned icount = dx_get_count(entries);
1476 int levels = frame - frames;
1477 struct dx_entry *entries2;
1478 struct dx_node *node2;
1479 struct buffer_head *bh2;
1480
1481 if (levels && (dx_get_count(frames->entries) ==
1482 dx_get_limit(frames->entries))) {
1483 ext4_warning(sb, __FUNCTION__,
1484 "Directory index full!");
1485 err = -ENOSPC;
1486 goto cleanup;
1487 }
1488 bh2 = ext4_append (handle, dir, &newblock, &err);
1489 if (!(bh2))
1490 goto cleanup;
1491 node2 = (struct dx_node *)(bh2->b_data);
1492 entries2 = node2->entries;
1493 node2->fake.rec_len = cpu_to_le16(sb->s_blocksize);
1494 node2->fake.inode = 0;
1495 BUFFER_TRACE(frame->bh, "get_write_access");
1496 err = ext4_journal_get_write_access(handle, frame->bh);
1497 if (err)
1498 goto journal_error;
1499 if (levels) {
1500 unsigned icount1 = icount/2, icount2 = icount - icount1;
1501 unsigned hash2 = dx_get_hash(entries + icount1);
1502 dxtrace(printk("Split index %i/%i\n", icount1, icount2));
1503
1504 BUFFER_TRACE(frame->bh, "get_write_access"); /* index root */
1505 err = ext4_journal_get_write_access(handle,
1506 frames[0].bh);
1507 if (err)
1508 goto journal_error;
1509
1510 memcpy ((char *) entries2, (char *) (entries + icount1),
1511 icount2 * sizeof(struct dx_entry));
1512 dx_set_count (entries, icount1);
1513 dx_set_count (entries2, icount2);
1514 dx_set_limit (entries2, dx_node_limit(dir));
1515
1516 /* Which index block gets the new entry? */
1517 if (at - entries >= icount1) {
1518 frame->at = at = at - entries - icount1 + entries2;
1519 frame->entries = entries = entries2;
1520 swap(frame->bh, bh2);
1521 }
1522 dx_insert_block (frames + 0, hash2, newblock);
1523 dxtrace(dx_show_index ("node", frames[1].entries));
1524 dxtrace(dx_show_index ("node",
1525 ((struct dx_node *) bh2->b_data)->entries));
1526 err = ext4_journal_dirty_metadata(handle, bh2);
1527 if (err)
1528 goto journal_error;
1529 brelse (bh2);
1530 } else {
1531 dxtrace(printk("Creating second level index...\n"));
1532 memcpy((char *) entries2, (char *) entries,
1533 icount * sizeof(struct dx_entry));
1534 dx_set_limit(entries2, dx_node_limit(dir));
1535
1536 /* Set up root */
1537 dx_set_count(entries, 1);
1538 dx_set_block(entries + 0, newblock);
1539 ((struct dx_root *) frames[0].bh->b_data)->info.indirect_levels = 1;
1540
1541 /* Add new access path frame */
1542 frame = frames + 1;
1543 frame->at = at = at - entries + entries2;
1544 frame->entries = entries = entries2;
1545 frame->bh = bh2;
1546 err = ext4_journal_get_write_access(handle,
1547 frame->bh);
1548 if (err)
1549 goto journal_error;
1550 }
1551 ext4_journal_dirty_metadata(handle, frames[0].bh);
1552 }
1553 de = do_split(handle, dir, &bh, frame, &hinfo, &err);
1554 if (!de)
1555 goto cleanup;
1556 err = add_dirent_to_buf(handle, dentry, inode, de, bh);
1557 bh = NULL;
1558 goto cleanup;
1559
1560journal_error:
1561 ext4_std_error(dir->i_sb, err);
1562cleanup:
1563 if (bh)
1564 brelse(bh);
1565 dx_release(frames);
1566 return err;
1567}
1568#endif
1569
1570/*
1571 * ext4_delete_entry deletes a directory entry by merging it with the
1572 * previous entry
1573 */
1574static int ext4_delete_entry (handle_t *handle,
1575 struct inode * dir,
1576 struct ext4_dir_entry_2 * de_del,
1577 struct buffer_head * bh)
1578{
1579 struct ext4_dir_entry_2 * de, * pde;
1580 int i;
1581
1582 i = 0;
1583 pde = NULL;
1584 de = (struct ext4_dir_entry_2 *) bh->b_data;
1585 while (i < bh->b_size) {
1586 if (!ext4_check_dir_entry("ext4_delete_entry", dir, de, bh, i))
1587 return -EIO;
1588 if (de == de_del) {
1589 BUFFER_TRACE(bh, "get_write_access");
1590 ext4_journal_get_write_access(handle, bh);
1591 if (pde)
1592 pde->rec_len =
1593 cpu_to_le16(le16_to_cpu(pde->rec_len) +
1594 le16_to_cpu(de->rec_len));
1595 else
1596 de->inode = 0;
1597 dir->i_version++;
1598 BUFFER_TRACE(bh, "call ext4_journal_dirty_metadata");
1599 ext4_journal_dirty_metadata(handle, bh);
1600 return 0;
1601 }
1602 i += le16_to_cpu(de->rec_len);
1603 pde = de;
1604 de = (struct ext4_dir_entry_2 *)
1605 ((char *) de + le16_to_cpu(de->rec_len));
1606 }
1607 return -ENOENT;
1608}
1609
1610/*
1611 * ext4_mark_inode_dirty is somewhat expensive, so unlike ext2 we
1612 * do not perform it in these functions. We perform it at the call site,
1613 * if it is needed.
1614 */
1615static inline void ext4_inc_count(handle_t *handle, struct inode *inode)
1616{
1617 inc_nlink(inode);
1618}
1619
1620static inline void ext4_dec_count(handle_t *handle, struct inode *inode)
1621{
1622 drop_nlink(inode);
1623}
1624
1625static int ext4_add_nondir(handle_t *handle,
1626 struct dentry *dentry, struct inode *inode)
1627{
1628 int err = ext4_add_entry(handle, dentry, inode);
1629 if (!err) {
1630 ext4_mark_inode_dirty(handle, inode);
1631 d_instantiate(dentry, inode);
1632 return 0;
1633 }
1634 ext4_dec_count(handle, inode);
1635 iput(inode);
1636 return err;
1637}
1638
1639/*
1640 * By the time this is called, we already have created
1641 * the directory cache entry for the new file, but it
1642 * is so far negative - it has no inode.
1643 *
1644 * If the create succeeds, we fill in the inode information
1645 * with d_instantiate().
1646 */
1647static int ext4_create (struct inode * dir, struct dentry * dentry, int mode,
1648 struct nameidata *nd)
1649{
1650 handle_t *handle;
1651 struct inode * inode;
1652 int err, retries = 0;
1653
1654retry:
1655 handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
1656 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
1657 2*EXT4_QUOTA_INIT_BLOCKS(dir->i_sb));
1658 if (IS_ERR(handle))
1659 return PTR_ERR(handle);
1660
1661 if (IS_DIRSYNC(dir))
1662 handle->h_sync = 1;
1663
1664 inode = ext4_new_inode (handle, dir, mode);
1665 err = PTR_ERR(inode);
1666 if (!IS_ERR(inode)) {
1667 inode->i_op = &ext4_file_inode_operations;
1668 inode->i_fop = &ext4_file_operations;
1669 ext4_set_aops(inode);
1670 err = ext4_add_nondir(handle, dentry, inode);
1671 }
1672 ext4_journal_stop(handle);
1673 if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries))
1674 goto retry;
1675 return err;
1676}
1677
1678static int ext4_mknod (struct inode * dir, struct dentry *dentry,
1679 int mode, dev_t rdev)
1680{
1681 handle_t *handle;
1682 struct inode *inode;
1683 int err, retries = 0;
1684
1685 if (!new_valid_dev(rdev))
1686 return -EINVAL;
1687
1688retry:
1689 handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
1690 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
1691 2*EXT4_QUOTA_INIT_BLOCKS(dir->i_sb));
1692 if (IS_ERR(handle))
1693 return PTR_ERR(handle);
1694
1695 if (IS_DIRSYNC(dir))
1696 handle->h_sync = 1;
1697
1698 inode = ext4_new_inode (handle, dir, mode);
1699 err = PTR_ERR(inode);
1700 if (!IS_ERR(inode)) {
1701 init_special_inode(inode, inode->i_mode, rdev);
1702#ifdef CONFIG_EXT4DEV_FS_XATTR
1703 inode->i_op = &ext4_special_inode_operations;
1704#endif
1705 err = ext4_add_nondir(handle, dentry, inode);
1706 }
1707 ext4_journal_stop(handle);
1708 if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries))
1709 goto retry;
1710 return err;
1711}
1712
1713static int ext4_mkdir(struct inode * dir, struct dentry * dentry, int mode)
1714{
1715 handle_t *handle;
1716 struct inode * inode;
1717 struct buffer_head * dir_block;
1718 struct ext4_dir_entry_2 * de;
1719 int err, retries = 0;
1720
1721 if (dir->i_nlink >= EXT4_LINK_MAX)
1722 return -EMLINK;
1723
1724retry:
1725 handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
1726 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
1727 2*EXT4_QUOTA_INIT_BLOCKS(dir->i_sb));
1728 if (IS_ERR(handle))
1729 return PTR_ERR(handle);
1730
1731 if (IS_DIRSYNC(dir))
1732 handle->h_sync = 1;
1733
1734 inode = ext4_new_inode (handle, dir, S_IFDIR | mode);
1735 err = PTR_ERR(inode);
1736 if (IS_ERR(inode))
1737 goto out_stop;
1738
1739 inode->i_op = &ext4_dir_inode_operations;
1740 inode->i_fop = &ext4_dir_operations;
1741 inode->i_size = EXT4_I(inode)->i_disksize = inode->i_sb->s_blocksize;
1742 dir_block = ext4_bread (handle, inode, 0, 1, &err);
1743 if (!dir_block) {
1744 drop_nlink(inode); /* is this nlink == 0? */
1745 ext4_mark_inode_dirty(handle, inode);
1746 iput (inode);
1747 goto out_stop;
1748 }
1749 BUFFER_TRACE(dir_block, "get_write_access");
1750 ext4_journal_get_write_access(handle, dir_block);
1751 de = (struct ext4_dir_entry_2 *) dir_block->b_data;
1752 de->inode = cpu_to_le32(inode->i_ino);
1753 de->name_len = 1;
1754 de->rec_len = cpu_to_le16(EXT4_DIR_REC_LEN(de->name_len));
1755 strcpy (de->name, ".");
1756 ext4_set_de_type(dir->i_sb, de, S_IFDIR);
1757 de = (struct ext4_dir_entry_2 *)
1758 ((char *) de + le16_to_cpu(de->rec_len));
1759 de->inode = cpu_to_le32(dir->i_ino);
1760 de->rec_len = cpu_to_le16(inode->i_sb->s_blocksize-EXT4_DIR_REC_LEN(1));
1761 de->name_len = 2;
1762 strcpy (de->name, "..");
1763 ext4_set_de_type(dir->i_sb, de, S_IFDIR);
1764 inode->i_nlink = 2;
1765 BUFFER_TRACE(dir_block, "call ext4_journal_dirty_metadata");
1766 ext4_journal_dirty_metadata(handle, dir_block);
1767 brelse (dir_block);
1768 ext4_mark_inode_dirty(handle, inode);
1769 err = ext4_add_entry (handle, dentry, inode);
1770 if (err) {
1771 inode->i_nlink = 0;
1772 ext4_mark_inode_dirty(handle, inode);
1773 iput (inode);
1774 goto out_stop;
1775 }
1776 inc_nlink(dir);
1777 ext4_update_dx_flag(dir);
1778 ext4_mark_inode_dirty(handle, dir);
1779 d_instantiate(dentry, inode);
1780out_stop:
1781 ext4_journal_stop(handle);
1782 if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries))
1783 goto retry;
1784 return err;
1785}
1786
1787/*
1788 * routine to check that the specified directory is empty (for rmdir)
1789 */
1790static int empty_dir (struct inode * inode)
1791{
1792 unsigned long offset;
1793 struct buffer_head * bh;
1794 struct ext4_dir_entry_2 * de, * de1;
1795 struct super_block * sb;
1796 int err = 0;
1797
1798 sb = inode->i_sb;
1799 if (inode->i_size < EXT4_DIR_REC_LEN(1) + EXT4_DIR_REC_LEN(2) ||
1800 !(bh = ext4_bread (NULL, inode, 0, 0, &err))) {
1801 if (err)
1802 ext4_error(inode->i_sb, __FUNCTION__,
1803 "error %d reading directory #%lu offset 0",
1804 err, inode->i_ino);
1805 else
1806 ext4_warning(inode->i_sb, __FUNCTION__,
1807 "bad directory (dir #%lu) - no data block",
1808 inode->i_ino);
1809 return 1;
1810 }
1811 de = (struct ext4_dir_entry_2 *) bh->b_data;
1812 de1 = (struct ext4_dir_entry_2 *)
1813 ((char *) de + le16_to_cpu(de->rec_len));
1814 if (le32_to_cpu(de->inode) != inode->i_ino ||
1815 !le32_to_cpu(de1->inode) ||
1816 strcmp (".", de->name) ||
1817 strcmp ("..", de1->name)) {
1818 ext4_warning (inode->i_sb, "empty_dir",
1819 "bad directory (dir #%lu) - no `.' or `..'",
1820 inode->i_ino);
1821 brelse (bh);
1822 return 1;
1823 }
1824 offset = le16_to_cpu(de->rec_len) + le16_to_cpu(de1->rec_len);
1825 de = (struct ext4_dir_entry_2 *)
1826 ((char *) de1 + le16_to_cpu(de1->rec_len));
1827 while (offset < inode->i_size ) {
1828 if (!bh ||
1829 (void *) de >= (void *) (bh->b_data+sb->s_blocksize)) {
1830 err = 0;
1831 brelse (bh);
1832 bh = ext4_bread (NULL, inode,
1833 offset >> EXT4_BLOCK_SIZE_BITS(sb), 0, &err);
1834 if (!bh) {
1835 if (err)
1836 ext4_error(sb, __FUNCTION__,
1837 "error %d reading directory"
1838 " #%lu offset %lu",
1839 err, inode->i_ino, offset);
1840 offset += sb->s_blocksize;
1841 continue;
1842 }
1843 de = (struct ext4_dir_entry_2 *) bh->b_data;
1844 }
1845 if (!ext4_check_dir_entry("empty_dir", inode, de, bh, offset)) {
1846 de = (struct ext4_dir_entry_2 *)(bh->b_data +
1847 sb->s_blocksize);
1848 offset = (offset | (sb->s_blocksize - 1)) + 1;
1849 continue;
1850 }
1851 if (le32_to_cpu(de->inode)) {
1852 brelse (bh);
1853 return 0;
1854 }
1855 offset += le16_to_cpu(de->rec_len);
1856 de = (struct ext4_dir_entry_2 *)
1857 ((char *) de + le16_to_cpu(de->rec_len));
1858 }
1859 brelse (bh);
1860 return 1;
1861}
1862
1863/* ext4_orphan_add() links an unlinked or truncated inode into a list of
1864 * such inodes, starting at the superblock, in case we crash before the
1865 * file is closed/deleted, or in case the inode truncate spans multiple
1866 * transactions and the last transaction is not recovered after a crash.
1867 *
1868 * At filesystem recovery time, we walk this list deleting unlinked
1869 * inodes and truncating linked inodes in ext4_orphan_cleanup().
1870 */
1871int ext4_orphan_add(handle_t *handle, struct inode *inode)
1872{
1873 struct super_block *sb = inode->i_sb;
1874 struct ext4_iloc iloc;
1875 int err = 0, rc;
1876
1877 lock_super(sb);
1878 if (!list_empty(&EXT4_I(inode)->i_orphan))
1879 goto out_unlock;
1880
1881 /* Orphan handling is only valid for files with data blocks
1882 * being truncated, or files being unlinked. */
1883
1884 /* @@@ FIXME: Observation from aviro:
1885 * I think I can trigger J_ASSERT in ext4_orphan_add(). We block
1886 * here (on lock_super()), so race with ext4_link() which might bump
1887 * ->i_nlink. For, say it, character device. Not a regular file,
1888 * not a directory, not a symlink and ->i_nlink > 0.
1889 */
1890 J_ASSERT ((S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
1891 S_ISLNK(inode->i_mode)) || inode->i_nlink == 0);
1892
1893 BUFFER_TRACE(EXT4_SB(sb)->s_sbh, "get_write_access");
1894 err = ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh);
1895 if (err)
1896 goto out_unlock;
1897
1898 err = ext4_reserve_inode_write(handle, inode, &iloc);
1899 if (err)
1900 goto out_unlock;
1901
1902 /* Insert this inode at the head of the on-disk orphan list... */
1903 NEXT_ORPHAN(inode) = le32_to_cpu(EXT4_SB(sb)->s_es->s_last_orphan);
1904 EXT4_SB(sb)->s_es->s_last_orphan = cpu_to_le32(inode->i_ino);
1905 err = ext4_journal_dirty_metadata(handle, EXT4_SB(sb)->s_sbh);
1906 rc = ext4_mark_iloc_dirty(handle, inode, &iloc);
1907 if (!err)
1908 err = rc;
1909
1910 /* Only add to the head of the in-memory list if all the
1911 * previous operations succeeded. If the orphan_add is going to
1912 * fail (possibly taking the journal offline), we can't risk
1913 * leaving the inode on the orphan list: stray orphan-list
1914 * entries can cause panics at unmount time.
1915 *
1916 * This is safe: on error we're going to ignore the orphan list
1917 * anyway on the next recovery. */
1918 if (!err)
1919 list_add(&EXT4_I(inode)->i_orphan, &EXT4_SB(sb)->s_orphan);
1920
1921 jbd_debug(4, "superblock will point to %lu\n", inode->i_ino);
1922 jbd_debug(4, "orphan inode %lu will point to %d\n",
1923 inode->i_ino, NEXT_ORPHAN(inode));
1924out_unlock:
1925 unlock_super(sb);
1926 ext4_std_error(inode->i_sb, err);
1927 return err;
1928}
1929
1930/*
1931 * ext4_orphan_del() removes an unlinked or truncated inode from the list
1932 * of such inodes stored on disk, because it is finally being cleaned up.
1933 */
1934int ext4_orphan_del(handle_t *handle, struct inode *inode)
1935{
1936 struct list_head *prev;
1937 struct ext4_inode_info *ei = EXT4_I(inode);
1938 struct ext4_sb_info *sbi;
1939 unsigned long ino_next;
1940 struct ext4_iloc iloc;
1941 int err = 0;
1942
1943 lock_super(inode->i_sb);
1944 if (list_empty(&ei->i_orphan)) {
1945 unlock_super(inode->i_sb);
1946 return 0;
1947 }
1948
1949 ino_next = NEXT_ORPHAN(inode);
1950 prev = ei->i_orphan.prev;
1951 sbi = EXT4_SB(inode->i_sb);
1952
1953 jbd_debug(4, "remove inode %lu from orphan list\n", inode->i_ino);
1954
1955 list_del_init(&ei->i_orphan);
1956
1957 /* If we're on an error path, we may not have a valid
1958 * transaction handle with which to update the orphan list on
1959 * disk, but we still need to remove the inode from the linked
1960 * list in memory. */
1961 if (!handle)
1962 goto out;
1963
1964 err = ext4_reserve_inode_write(handle, inode, &iloc);
1965 if (err)
1966 goto out_err;
1967
1968 if (prev == &sbi->s_orphan) {
1969 jbd_debug(4, "superblock will point to %lu\n", ino_next);
1970 BUFFER_TRACE(sbi->s_sbh, "get_write_access");
1971 err = ext4_journal_get_write_access(handle, sbi->s_sbh);
1972 if (err)
1973 goto out_brelse;
1974 sbi->s_es->s_last_orphan = cpu_to_le32(ino_next);
1975 err = ext4_journal_dirty_metadata(handle, sbi->s_sbh);
1976 } else {
1977 struct ext4_iloc iloc2;
1978 struct inode *i_prev =
1979 &list_entry(prev, struct ext4_inode_info, i_orphan)->vfs_inode;
1980
1981 jbd_debug(4, "orphan inode %lu will point to %lu\n",
1982 i_prev->i_ino, ino_next);
1983 err = ext4_reserve_inode_write(handle, i_prev, &iloc2);
1984 if (err)
1985 goto out_brelse;
1986 NEXT_ORPHAN(i_prev) = ino_next;
1987 err = ext4_mark_iloc_dirty(handle, i_prev, &iloc2);
1988 }
1989 if (err)
1990 goto out_brelse;
1991 NEXT_ORPHAN(inode) = 0;
1992 err = ext4_mark_iloc_dirty(handle, inode, &iloc);
1993
1994out_err:
1995 ext4_std_error(inode->i_sb, err);
1996out:
1997 unlock_super(inode->i_sb);
1998 return err;
1999
2000out_brelse:
2001 brelse(iloc.bh);
2002 goto out_err;
2003}
2004
2005static int ext4_rmdir (struct inode * dir, struct dentry *dentry)
2006{
2007 int retval;
2008 struct inode * inode;
2009 struct buffer_head * bh;
2010 struct ext4_dir_entry_2 * de;
2011 handle_t *handle;
2012
2013 /* Initialize quotas before so that eventual writes go in
2014 * separate transaction */
2015 DQUOT_INIT(dentry->d_inode);
2016 handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb));
2017 if (IS_ERR(handle))
2018 return PTR_ERR(handle);
2019
2020 retval = -ENOENT;
2021 bh = ext4_find_entry (dentry, &de);
2022 if (!bh)
2023 goto end_rmdir;
2024
2025 if (IS_DIRSYNC(dir))
2026 handle->h_sync = 1;
2027
2028 inode = dentry->d_inode;
2029
2030 retval = -EIO;
2031 if (le32_to_cpu(de->inode) != inode->i_ino)
2032 goto end_rmdir;
2033
2034 retval = -ENOTEMPTY;
2035 if (!empty_dir (inode))
2036 goto end_rmdir;
2037
2038 retval = ext4_delete_entry(handle, dir, de, bh);
2039 if (retval)
2040 goto end_rmdir;
2041 if (inode->i_nlink != 2)
2042 ext4_warning (inode->i_sb, "ext4_rmdir",
2043 "empty directory has nlink!=2 (%d)",
2044 inode->i_nlink);
2045 inode->i_version++;
2046 clear_nlink(inode);
2047 /* There's no need to set i_disksize: the fact that i_nlink is
2048 * zero will ensure that the right thing happens during any
2049 * recovery. */
2050 inode->i_size = 0;
2051 ext4_orphan_add(handle, inode);
2052 inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
2053 ext4_mark_inode_dirty(handle, inode);
2054 drop_nlink(dir);
2055 ext4_update_dx_flag(dir);
2056 ext4_mark_inode_dirty(handle, dir);
2057
2058end_rmdir:
2059 ext4_journal_stop(handle);
2060 brelse (bh);
2061 return retval;
2062}
2063
2064static int ext4_unlink(struct inode * dir, struct dentry *dentry)
2065{
2066 int retval;
2067 struct inode * inode;
2068 struct buffer_head * bh;
2069 struct ext4_dir_entry_2 * de;
2070 handle_t *handle;
2071
2072 /* Initialize quotas before so that eventual writes go
2073 * in separate transaction */
2074 DQUOT_INIT(dentry->d_inode);
2075 handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb));
2076 if (IS_ERR(handle))
2077 return PTR_ERR(handle);
2078
2079 if (IS_DIRSYNC(dir))
2080 handle->h_sync = 1;
2081
2082 retval = -ENOENT;
2083 bh = ext4_find_entry (dentry, &de);
2084 if (!bh)
2085 goto end_unlink;
2086
2087 inode = dentry->d_inode;
2088
2089 retval = -EIO;
2090 if (le32_to_cpu(de->inode) != inode->i_ino)
2091 goto end_unlink;
2092
2093 if (!inode->i_nlink) {
2094 ext4_warning (inode->i_sb, "ext4_unlink",
2095 "Deleting nonexistent file (%lu), %d",
2096 inode->i_ino, inode->i_nlink);
2097 inode->i_nlink = 1;
2098 }
2099 retval = ext4_delete_entry(handle, dir, de, bh);
2100 if (retval)
2101 goto end_unlink;
2102 dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
2103 ext4_update_dx_flag(dir);
2104 ext4_mark_inode_dirty(handle, dir);
2105 drop_nlink(inode);
2106 if (!inode->i_nlink)
2107 ext4_orphan_add(handle, inode);
2108 inode->i_ctime = dir->i_ctime;
2109 ext4_mark_inode_dirty(handle, inode);
2110 retval = 0;
2111
2112end_unlink:
2113 ext4_journal_stop(handle);
2114 brelse (bh);
2115 return retval;
2116}
2117
2118static int ext4_symlink (struct inode * dir,
2119 struct dentry *dentry, const char * symname)
2120{
2121 handle_t *handle;
2122 struct inode * inode;
2123 int l, err, retries = 0;
2124
2125 l = strlen(symname)+1;
2126 if (l > dir->i_sb->s_blocksize)
2127 return -ENAMETOOLONG;
2128
2129retry:
2130 handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
2131 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 5 +
2132 2*EXT4_QUOTA_INIT_BLOCKS(dir->i_sb));
2133 if (IS_ERR(handle))
2134 return PTR_ERR(handle);
2135
2136 if (IS_DIRSYNC(dir))
2137 handle->h_sync = 1;
2138
2139 inode = ext4_new_inode (handle, dir, S_IFLNK|S_IRWXUGO);
2140 err = PTR_ERR(inode);
2141 if (IS_ERR(inode))
2142 goto out_stop;
2143
2144 if (l > sizeof (EXT4_I(inode)->i_data)) {
2145 inode->i_op = &ext4_symlink_inode_operations;
2146 ext4_set_aops(inode);
2147 /*
2148 * page_symlink() calls into ext4_prepare/commit_write.
2149 * We have a transaction open. All is sweetness. It also sets
2150 * i_size in generic_commit_write().
2151 */
2152 err = __page_symlink(inode, symname, l,
2153 mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS);
2154 if (err) {
2155 ext4_dec_count(handle, inode);
2156 ext4_mark_inode_dirty(handle, inode);
2157 iput (inode);
2158 goto out_stop;
2159 }
2160 } else {
2161 inode->i_op = &ext4_fast_symlink_inode_operations;
2162 memcpy((char*)&EXT4_I(inode)->i_data,symname,l);
2163 inode->i_size = l-1;
2164 }
2165 EXT4_I(inode)->i_disksize = inode->i_size;
2166 err = ext4_add_nondir(handle, dentry, inode);
2167out_stop:
2168 ext4_journal_stop(handle);
2169 if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries))
2170 goto retry;
2171 return err;
2172}
2173
2174static int ext4_link (struct dentry * old_dentry,
2175 struct inode * dir, struct dentry *dentry)
2176{
2177 handle_t *handle;
2178 struct inode *inode = old_dentry->d_inode;
2179 int err, retries = 0;
2180
2181 if (inode->i_nlink >= EXT4_LINK_MAX)
2182 return -EMLINK;
2183
2184retry:
2185 handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
2186 EXT4_INDEX_EXTRA_TRANS_BLOCKS);
2187 if (IS_ERR(handle))
2188 return PTR_ERR(handle);
2189
2190 if (IS_DIRSYNC(dir))
2191 handle->h_sync = 1;
2192
2193 inode->i_ctime = CURRENT_TIME_SEC;
2194 ext4_inc_count(handle, inode);
2195 atomic_inc(&inode->i_count);
2196
2197 err = ext4_add_nondir(handle, dentry, inode);
2198 ext4_journal_stop(handle);
2199 if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries))
2200 goto retry;
2201 return err;
2202}
2203
2204#define PARENT_INO(buffer) \
2205 ((struct ext4_dir_entry_2 *) ((char *) buffer + \
2206 le16_to_cpu(((struct ext4_dir_entry_2 *) buffer)->rec_len)))->inode
2207
2208/*
2209 * Anybody can rename anything with this: the permission checks are left to the
2210 * higher-level routines.
2211 */
2212static int ext4_rename (struct inode * old_dir, struct dentry *old_dentry,
2213 struct inode * new_dir,struct dentry *new_dentry)
2214{
2215 handle_t *handle;
2216 struct inode * old_inode, * new_inode;
2217 struct buffer_head * old_bh, * new_bh, * dir_bh;
2218 struct ext4_dir_entry_2 * old_de, * new_de;
2219 int retval;
2220
2221 old_bh = new_bh = dir_bh = NULL;
2222
2223 /* Initialize quotas before so that eventual writes go
2224 * in separate transaction */
2225 if (new_dentry->d_inode)
2226 DQUOT_INIT(new_dentry->d_inode);
2227 handle = ext4_journal_start(old_dir, 2 *
2228 EXT4_DATA_TRANS_BLOCKS(old_dir->i_sb) +
2229 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 2);
2230 if (IS_ERR(handle))
2231 return PTR_ERR(handle);
2232
2233 if (IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir))
2234 handle->h_sync = 1;
2235
2236 old_bh = ext4_find_entry (old_dentry, &old_de);
2237 /*
2238 * Check for inode number is _not_ due to possible IO errors.
2239 * We might rmdir the source, keep it as pwd of some process
2240 * and merrily kill the link to whatever was created under the
2241 * same name. Goodbye sticky bit ;-<
2242 */
2243 old_inode = old_dentry->d_inode;
2244 retval = -ENOENT;
2245 if (!old_bh || le32_to_cpu(old_de->inode) != old_inode->i_ino)
2246 goto end_rename;
2247
2248 new_inode = new_dentry->d_inode;
2249 new_bh = ext4_find_entry (new_dentry, &new_de);
2250 if (new_bh) {
2251 if (!new_inode) {
2252 brelse (new_bh);
2253 new_bh = NULL;
2254 }
2255 }
2256 if (S_ISDIR(old_inode->i_mode)) {
2257 if (new_inode) {
2258 retval = -ENOTEMPTY;
2259 if (!empty_dir (new_inode))
2260 goto end_rename;
2261 }
2262 retval = -EIO;
2263 dir_bh = ext4_bread (handle, old_inode, 0, 0, &retval);
2264 if (!dir_bh)
2265 goto end_rename;
2266 if (le32_to_cpu(PARENT_INO(dir_bh->b_data)) != old_dir->i_ino)
2267 goto end_rename;
2268 retval = -EMLINK;
2269 if (!new_inode && new_dir!=old_dir &&
2270 new_dir->i_nlink >= EXT4_LINK_MAX)
2271 goto end_rename;
2272 }
2273 if (!new_bh) {
2274 retval = ext4_add_entry (handle, new_dentry, old_inode);
2275 if (retval)
2276 goto end_rename;
2277 } else {
2278 BUFFER_TRACE(new_bh, "get write access");
2279 ext4_journal_get_write_access(handle, new_bh);
2280 new_de->inode = cpu_to_le32(old_inode->i_ino);
2281 if (EXT4_HAS_INCOMPAT_FEATURE(new_dir->i_sb,
2282 EXT4_FEATURE_INCOMPAT_FILETYPE))
2283 new_de->file_type = old_de->file_type;
2284 new_dir->i_version++;
2285 BUFFER_TRACE(new_bh, "call ext4_journal_dirty_metadata");
2286 ext4_journal_dirty_metadata(handle, new_bh);
2287 brelse(new_bh);
2288 new_bh = NULL;
2289 }
2290
2291 /*
2292 * Like most other Unix systems, set the ctime for inodes on a
2293 * rename.
2294 */
2295 old_inode->i_ctime = CURRENT_TIME_SEC;
2296 ext4_mark_inode_dirty(handle, old_inode);
2297
2298 /*
2299 * ok, that's it
2300 */
2301 if (le32_to_cpu(old_de->inode) != old_inode->i_ino ||
2302 old_de->name_len != old_dentry->d_name.len ||
2303 strncmp(old_de->name, old_dentry->d_name.name, old_de->name_len) ||
2304 (retval = ext4_delete_entry(handle, old_dir,
2305 old_de, old_bh)) == -ENOENT) {
2306 /* old_de could have moved from under us during htree split, so
2307 * make sure that we are deleting the right entry. We might
2308 * also be pointing to a stale entry in the unused part of
2309 * old_bh so just checking inum and the name isn't enough. */
2310 struct buffer_head *old_bh2;
2311 struct ext4_dir_entry_2 *old_de2;
2312
2313 old_bh2 = ext4_find_entry(old_dentry, &old_de2);
2314 if (old_bh2) {
2315 retval = ext4_delete_entry(handle, old_dir,
2316 old_de2, old_bh2);
2317 brelse(old_bh2);
2318 }
2319 }
2320 if (retval) {
2321 ext4_warning(old_dir->i_sb, "ext4_rename",
2322 "Deleting old file (%lu), %d, error=%d",
2323 old_dir->i_ino, old_dir->i_nlink, retval);
2324 }
2325
2326 if (new_inode) {
2327 drop_nlink(new_inode);
2328 new_inode->i_ctime = CURRENT_TIME_SEC;
2329 }
2330 old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME_SEC;
2331 ext4_update_dx_flag(old_dir);
2332 if (dir_bh) {
2333 BUFFER_TRACE(dir_bh, "get_write_access");
2334 ext4_journal_get_write_access(handle, dir_bh);
2335 PARENT_INO(dir_bh->b_data) = cpu_to_le32(new_dir->i_ino);
2336 BUFFER_TRACE(dir_bh, "call ext4_journal_dirty_metadata");
2337 ext4_journal_dirty_metadata(handle, dir_bh);
2338 drop_nlink(old_dir);
2339 if (new_inode) {
2340 drop_nlink(new_inode);
2341 } else {
2342 inc_nlink(new_dir);
2343 ext4_update_dx_flag(new_dir);
2344 ext4_mark_inode_dirty(handle, new_dir);
2345 }
2346 }
2347 ext4_mark_inode_dirty(handle, old_dir);
2348 if (new_inode) {
2349 ext4_mark_inode_dirty(handle, new_inode);
2350 if (!new_inode->i_nlink)
2351 ext4_orphan_add(handle, new_inode);
2352 }
2353 retval = 0;
2354
2355end_rename:
2356 brelse (dir_bh);
2357 brelse (old_bh);
2358 brelse (new_bh);
2359 ext4_journal_stop(handle);
2360 return retval;
2361}
2362
2363/*
2364 * directories can handle most operations...
2365 */
2366struct inode_operations ext4_dir_inode_operations = {
2367 .create = ext4_create,
2368 .lookup = ext4_lookup,
2369 .link = ext4_link,
2370 .unlink = ext4_unlink,
2371 .symlink = ext4_symlink,
2372 .mkdir = ext4_mkdir,
2373 .rmdir = ext4_rmdir,
2374 .mknod = ext4_mknod,
2375 .rename = ext4_rename,
2376 .setattr = ext4_setattr,
2377#ifdef CONFIG_EXT4DEV_FS_XATTR
2378 .setxattr = generic_setxattr,
2379 .getxattr = generic_getxattr,
2380 .listxattr = ext4_listxattr,
2381 .removexattr = generic_removexattr,
2382#endif
2383 .permission = ext4_permission,
2384};
2385
2386struct inode_operations ext4_special_inode_operations = {
2387 .setattr = ext4_setattr,
2388#ifdef CONFIG_EXT4DEV_FS_XATTR
2389 .setxattr = generic_setxattr,
2390 .getxattr = generic_getxattr,
2391 .listxattr = ext4_listxattr,
2392 .removexattr = generic_removexattr,
2393#endif
2394 .permission = ext4_permission,
2395};
diff --git a/fs/ext4/namei.h b/fs/ext4/namei.h
new file mode 100644
index 000000000000..5e4dfff36a00
--- /dev/null
+++ b/fs/ext4/namei.h
@@ -0,0 +1,8 @@
1/* linux/fs/ext4/namei.h
2 *
3 * Copyright (C) 2005 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 *
6*/
7
8extern struct dentry *ext4_get_parent(struct dentry *child);
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
new file mode 100644
index 000000000000..4fe49c3661b2
--- /dev/null
+++ b/fs/ext4/resize.c
@@ -0,0 +1,1050 @@
1/*
2 * linux/fs/ext4/resize.c
3 *
4 * Support for resizing an ext4 filesystem while it is mounted.
5 *
6 * Copyright (C) 2001, 2002 Andreas Dilger <adilger@clusterfs.com>
7 *
8 * This could probably be made into a module, because it is not often in use.
9 */
10
11
12#define EXT4FS_DEBUG
13
14#include <linux/sched.h>
15#include <linux/smp_lock.h>
16#include <linux/ext4_jbd2.h>
17
18#include <linux/errno.h>
19#include <linux/slab.h>
20
21
22#define outside(b, first, last) ((b) < (first) || (b) >= (last))
23#define inside(b, first, last) ((b) >= (first) && (b) < (last))
24
25static int verify_group_input(struct super_block *sb,
26 struct ext4_new_group_data *input)
27{
28 struct ext4_sb_info *sbi = EXT4_SB(sb);
29 struct ext4_super_block *es = sbi->s_es;
30 ext4_fsblk_t start = ext4_blocks_count(es);
31 ext4_fsblk_t end = start + input->blocks_count;
32 unsigned group = input->group;
33 ext4_fsblk_t itend = input->inode_table + sbi->s_itb_per_group;
34 unsigned overhead = ext4_bg_has_super(sb, group) ?
35 (1 + ext4_bg_num_gdb(sb, group) +
36 le16_to_cpu(es->s_reserved_gdt_blocks)) : 0;
37 ext4_fsblk_t metaend = start + overhead;
38 struct buffer_head *bh = NULL;
39 ext4_grpblk_t free_blocks_count, offset;
40 int err = -EINVAL;
41
42 input->free_blocks_count = free_blocks_count =
43 input->blocks_count - 2 - overhead - sbi->s_itb_per_group;
44
45 if (test_opt(sb, DEBUG))
46 printk(KERN_DEBUG "EXT4-fs: adding %s group %u: %u blocks "
47 "(%d free, %u reserved)\n",
48 ext4_bg_has_super(sb, input->group) ? "normal" :
49 "no-super", input->group, input->blocks_count,
50 free_blocks_count, input->reserved_blocks);
51
52 ext4_get_group_no_and_offset(sb, start, NULL, &offset);
53 if (group != sbi->s_groups_count)
54 ext4_warning(sb, __FUNCTION__,
55 "Cannot add at group %u (only %lu groups)",
56 input->group, sbi->s_groups_count);
57 else if (offset != 0)
58 ext4_warning(sb, __FUNCTION__, "Last group not full");
59 else if (input->reserved_blocks > input->blocks_count / 5)
60 ext4_warning(sb, __FUNCTION__, "Reserved blocks too high (%u)",
61 input->reserved_blocks);
62 else if (free_blocks_count < 0)
63 ext4_warning(sb, __FUNCTION__, "Bad blocks count %u",
64 input->blocks_count);
65 else if (!(bh = sb_bread(sb, end - 1)))
66 ext4_warning(sb, __FUNCTION__,
67 "Cannot read last block (%llu)",
68 end - 1);
69 else if (outside(input->block_bitmap, start, end))
70 ext4_warning(sb, __FUNCTION__,
71 "Block bitmap not in group (block %llu)",
72 (unsigned long long)input->block_bitmap);
73 else if (outside(input->inode_bitmap, start, end))
74 ext4_warning(sb, __FUNCTION__,
75 "Inode bitmap not in group (block %llu)",
76 (unsigned long long)input->inode_bitmap);
77 else if (outside(input->inode_table, start, end) ||
78 outside(itend - 1, start, end))
79 ext4_warning(sb, __FUNCTION__,
80 "Inode table not in group (blocks %llu-%llu)",
81 (unsigned long long)input->inode_table, itend - 1);
82 else if (input->inode_bitmap == input->block_bitmap)
83 ext4_warning(sb, __FUNCTION__,
84 "Block bitmap same as inode bitmap (%llu)",
85 (unsigned long long)input->block_bitmap);
86 else if (inside(input->block_bitmap, input->inode_table, itend))
87 ext4_warning(sb, __FUNCTION__,
88 "Block bitmap (%llu) in inode table (%llu-%llu)",
89 (unsigned long long)input->block_bitmap,
90 (unsigned long long)input->inode_table, itend - 1);
91 else if (inside(input->inode_bitmap, input->inode_table, itend))
92 ext4_warning(sb, __FUNCTION__,
93 "Inode bitmap (%llu) in inode table (%llu-%llu)",
94 (unsigned long long)input->inode_bitmap,
95 (unsigned long long)input->inode_table, itend - 1);
96 else if (inside(input->block_bitmap, start, metaend))
97 ext4_warning(sb, __FUNCTION__,
98 "Block bitmap (%llu) in GDT table"
99 " (%llu-%llu)",
100 (unsigned long long)input->block_bitmap,
101 start, metaend - 1);
102 else if (inside(input->inode_bitmap, start, metaend))
103 ext4_warning(sb, __FUNCTION__,
104 "Inode bitmap (%llu) in GDT table"
105 " (%llu-%llu)",
106 (unsigned long long)input->inode_bitmap,
107 start, metaend - 1);
108 else if (inside(input->inode_table, start, metaend) ||
109 inside(itend - 1, start, metaend))
110 ext4_warning(sb, __FUNCTION__,
111 "Inode table (%llu-%llu) overlaps"
112 "GDT table (%llu-%llu)",
113 (unsigned long long)input->inode_table,
114 itend - 1, start, metaend - 1);
115 else
116 err = 0;
117 brelse(bh);
118
119 return err;
120}
121
122static struct buffer_head *bclean(handle_t *handle, struct super_block *sb,
123 ext4_fsblk_t blk)
124{
125 struct buffer_head *bh;
126 int err;
127
128 bh = sb_getblk(sb, blk);
129 if (!bh)
130 return ERR_PTR(-EIO);
131 if ((err = ext4_journal_get_write_access(handle, bh))) {
132 brelse(bh);
133 bh = ERR_PTR(err);
134 } else {
135 lock_buffer(bh);
136 memset(bh->b_data, 0, sb->s_blocksize);
137 set_buffer_uptodate(bh);
138 unlock_buffer(bh);
139 }
140
141 return bh;
142}
143
144/*
145 * To avoid calling the atomic setbit hundreds or thousands of times, we only
146 * need to use it within a single byte (to ensure we get endianness right).
147 * We can use memset for the rest of the bitmap as there are no other users.
148 */
149static void mark_bitmap_end(int start_bit, int end_bit, char *bitmap)
150{
151 int i;
152
153 if (start_bit >= end_bit)
154 return;
155
156 ext4_debug("mark end bits +%d through +%d used\n", start_bit, end_bit);
157 for (i = start_bit; i < ((start_bit + 7) & ~7UL); i++)
158 ext4_set_bit(i, bitmap);
159 if (i < end_bit)
160 memset(bitmap + (i >> 3), 0xff, (end_bit - i) >> 3);
161}
162
163/*
164 * Set up the block and inode bitmaps, and the inode table for the new group.
165 * This doesn't need to be part of the main transaction, since we are only
166 * changing blocks outside the actual filesystem. We still do journaling to
167 * ensure the recovery is correct in case of a failure just after resize.
168 * If any part of this fails, we simply abort the resize.
169 */
170static int setup_new_group_blocks(struct super_block *sb,
171 struct ext4_new_group_data *input)
172{
173 struct ext4_sb_info *sbi = EXT4_SB(sb);
174 ext4_fsblk_t start = ext4_group_first_block_no(sb, input->group);
175 int reserved_gdb = ext4_bg_has_super(sb, input->group) ?
176 le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks) : 0;
177 unsigned long gdblocks = ext4_bg_num_gdb(sb, input->group);
178 struct buffer_head *bh;
179 handle_t *handle;
180 ext4_fsblk_t block;
181 ext4_grpblk_t bit;
182 int i;
183 int err = 0, err2;
184
185 handle = ext4_journal_start_sb(sb, reserved_gdb + gdblocks +
186 2 + sbi->s_itb_per_group);
187 if (IS_ERR(handle))
188 return PTR_ERR(handle);
189
190 lock_super(sb);
191 if (input->group != sbi->s_groups_count) {
192 err = -EBUSY;
193 goto exit_journal;
194 }
195
196 if (IS_ERR(bh = bclean(handle, sb, input->block_bitmap))) {
197 err = PTR_ERR(bh);
198 goto exit_journal;
199 }
200
201 if (ext4_bg_has_super(sb, input->group)) {
202 ext4_debug("mark backup superblock %#04lx (+0)\n", start);
203 ext4_set_bit(0, bh->b_data);
204 }
205
206 /* Copy all of the GDT blocks into the backup in this group */
207 for (i = 0, bit = 1, block = start + 1;
208 i < gdblocks; i++, block++, bit++) {
209 struct buffer_head *gdb;
210
211 ext4_debug("update backup group %#04lx (+%d)\n", block, bit);
212
213 gdb = sb_getblk(sb, block);
214 if (!gdb) {
215 err = -EIO;
216 goto exit_bh;
217 }
218 if ((err = ext4_journal_get_write_access(handle, gdb))) {
219 brelse(gdb);
220 goto exit_bh;
221 }
222 lock_buffer(bh);
223 memcpy(gdb->b_data, sbi->s_group_desc[i]->b_data, bh->b_size);
224 set_buffer_uptodate(gdb);
225 unlock_buffer(bh);
226 ext4_journal_dirty_metadata(handle, gdb);
227 ext4_set_bit(bit, bh->b_data);
228 brelse(gdb);
229 }
230
231 /* Zero out all of the reserved backup group descriptor table blocks */
232 for (i = 0, bit = gdblocks + 1, block = start + bit;
233 i < reserved_gdb; i++, block++, bit++) {
234 struct buffer_head *gdb;
235
236 ext4_debug("clear reserved block %#04lx (+%d)\n", block, bit);
237
238 if (IS_ERR(gdb = bclean(handle, sb, block))) {
239 err = PTR_ERR(bh);
240 goto exit_bh;
241 }
242 ext4_journal_dirty_metadata(handle, gdb);
243 ext4_set_bit(bit, bh->b_data);
244 brelse(gdb);
245 }
246 ext4_debug("mark block bitmap %#04x (+%ld)\n", input->block_bitmap,
247 input->block_bitmap - start);
248 ext4_set_bit(input->block_bitmap - start, bh->b_data);
249 ext4_debug("mark inode bitmap %#04x (+%ld)\n", input->inode_bitmap,
250 input->inode_bitmap - start);
251 ext4_set_bit(input->inode_bitmap - start, bh->b_data);
252
253 /* Zero out all of the inode table blocks */
254 for (i = 0, block = input->inode_table, bit = block - start;
255 i < sbi->s_itb_per_group; i++, bit++, block++) {
256 struct buffer_head *it;
257
258 ext4_debug("clear inode block %#04lx (+%d)\n", block, bit);
259 if (IS_ERR(it = bclean(handle, sb, block))) {
260 err = PTR_ERR(it);
261 goto exit_bh;
262 }
263 ext4_journal_dirty_metadata(handle, it);
264 brelse(it);
265 ext4_set_bit(bit, bh->b_data);
266 }
267 mark_bitmap_end(input->blocks_count, EXT4_BLOCKS_PER_GROUP(sb),
268 bh->b_data);
269 ext4_journal_dirty_metadata(handle, bh);
270 brelse(bh);
271
272 /* Mark unused entries in inode bitmap used */
273 ext4_debug("clear inode bitmap %#04x (+%ld)\n",
274 input->inode_bitmap, input->inode_bitmap - start);
275 if (IS_ERR(bh = bclean(handle, sb, input->inode_bitmap))) {
276 err = PTR_ERR(bh);
277 goto exit_journal;
278 }
279
280 mark_bitmap_end(EXT4_INODES_PER_GROUP(sb), EXT4_BLOCKS_PER_GROUP(sb),
281 bh->b_data);
282 ext4_journal_dirty_metadata(handle, bh);
283exit_bh:
284 brelse(bh);
285
286exit_journal:
287 unlock_super(sb);
288 if ((err2 = ext4_journal_stop(handle)) && !err)
289 err = err2;
290
291 return err;
292}
293
294
295/*
296 * Iterate through the groups which hold BACKUP superblock/GDT copies in an
297 * ext4 filesystem. The counters should be initialized to 1, 5, and 7 before
298 * calling this for the first time. In a sparse filesystem it will be the
299 * sequence of powers of 3, 5, and 7: 1, 3, 5, 7, 9, 25, 27, 49, 81, ...
300 * For a non-sparse filesystem it will be every group: 1, 2, 3, 4, ...
301 */
302static unsigned ext4_list_backups(struct super_block *sb, unsigned *three,
303 unsigned *five, unsigned *seven)
304{
305 unsigned *min = three;
306 int mult = 3;
307 unsigned ret;
308
309 if (!EXT4_HAS_RO_COMPAT_FEATURE(sb,
310 EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER)) {
311 ret = *min;
312 *min += 1;
313 return ret;
314 }
315
316 if (*five < *min) {
317 min = five;
318 mult = 5;
319 }
320 if (*seven < *min) {
321 min = seven;
322 mult = 7;
323 }
324
325 ret = *min;
326 *min *= mult;
327
328 return ret;
329}
330
331/*
332 * Check that all of the backup GDT blocks are held in the primary GDT block.
333 * It is assumed that they are stored in group order. Returns the number of
334 * groups in current filesystem that have BACKUPS, or -ve error code.
335 */
336static int verify_reserved_gdb(struct super_block *sb,
337 struct buffer_head *primary)
338{
339 const ext4_fsblk_t blk = primary->b_blocknr;
340 const unsigned long end = EXT4_SB(sb)->s_groups_count;
341 unsigned three = 1;
342 unsigned five = 5;
343 unsigned seven = 7;
344 unsigned grp;
345 __le32 *p = (__le32 *)primary->b_data;
346 int gdbackups = 0;
347
348 while ((grp = ext4_list_backups(sb, &three, &five, &seven)) < end) {
349 if (le32_to_cpu(*p++) !=
350 grp * EXT4_BLOCKS_PER_GROUP(sb) + blk){
351 ext4_warning(sb, __FUNCTION__,
352 "reserved GDT %llu"
353 " missing grp %d (%llu)",
354 blk, grp,
355 grp *
356 (ext4_fsblk_t)EXT4_BLOCKS_PER_GROUP(sb) +
357 blk);
358 return -EINVAL;
359 }
360 if (++gdbackups > EXT4_ADDR_PER_BLOCK(sb))
361 return -EFBIG;
362 }
363
364 return gdbackups;
365}
366
367/*
368 * Called when we need to bring a reserved group descriptor table block into
369 * use from the resize inode. The primary copy of the new GDT block currently
370 * is an indirect block (under the double indirect block in the resize inode).
371 * The new backup GDT blocks will be stored as leaf blocks in this indirect
372 * block, in group order. Even though we know all the block numbers we need,
373 * we check to ensure that the resize inode has actually reserved these blocks.
374 *
375 * Don't need to update the block bitmaps because the blocks are still in use.
376 *
377 * We get all of the error cases out of the way, so that we are sure to not
378 * fail once we start modifying the data on disk, because JBD has no rollback.
379 */
380static int add_new_gdb(handle_t *handle, struct inode *inode,
381 struct ext4_new_group_data *input,
382 struct buffer_head **primary)
383{
384 struct super_block *sb = inode->i_sb;
385 struct ext4_super_block *es = EXT4_SB(sb)->s_es;
386 unsigned long gdb_num = input->group / EXT4_DESC_PER_BLOCK(sb);
387 ext4_fsblk_t gdblock = EXT4_SB(sb)->s_sbh->b_blocknr + 1 + gdb_num;
388 struct buffer_head **o_group_desc, **n_group_desc;
389 struct buffer_head *dind;
390 int gdbackups;
391 struct ext4_iloc iloc;
392 __le32 *data;
393 int err;
394
395 if (test_opt(sb, DEBUG))
396 printk(KERN_DEBUG
397 "EXT4-fs: ext4_add_new_gdb: adding group block %lu\n",
398 gdb_num);
399
400 /*
401 * If we are not using the primary superblock/GDT copy don't resize,
402 * because the user tools have no way of handling this. Probably a
403 * bad time to do it anyways.
404 */
405 if (EXT4_SB(sb)->s_sbh->b_blocknr !=
406 le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block)) {
407 ext4_warning(sb, __FUNCTION__,
408 "won't resize using backup superblock at %llu",
409 (unsigned long long)EXT4_SB(sb)->s_sbh->b_blocknr);
410 return -EPERM;
411 }
412
413 *primary = sb_bread(sb, gdblock);
414 if (!*primary)
415 return -EIO;
416
417 if ((gdbackups = verify_reserved_gdb(sb, *primary)) < 0) {
418 err = gdbackups;
419 goto exit_bh;
420 }
421
422 data = EXT4_I(inode)->i_data + EXT4_DIND_BLOCK;
423 dind = sb_bread(sb, le32_to_cpu(*data));
424 if (!dind) {
425 err = -EIO;
426 goto exit_bh;
427 }
428
429 data = (__le32 *)dind->b_data;
430 if (le32_to_cpu(data[gdb_num % EXT4_ADDR_PER_BLOCK(sb)]) != gdblock) {
431 ext4_warning(sb, __FUNCTION__,
432 "new group %u GDT block %llu not reserved",
433 input->group, gdblock);
434 err = -EINVAL;
435 goto exit_dind;
436 }
437
438 if ((err = ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh)))
439 goto exit_dind;
440
441 if ((err = ext4_journal_get_write_access(handle, *primary)))
442 goto exit_sbh;
443
444 if ((err = ext4_journal_get_write_access(handle, dind)))
445 goto exit_primary;
446
447 /* ext4_reserve_inode_write() gets a reference on the iloc */
448 if ((err = ext4_reserve_inode_write(handle, inode, &iloc)))
449 goto exit_dindj;
450
451 n_group_desc = kmalloc((gdb_num + 1) * sizeof(struct buffer_head *),
452 GFP_KERNEL);
453 if (!n_group_desc) {
454 err = -ENOMEM;
455 ext4_warning (sb, __FUNCTION__,
456 "not enough memory for %lu groups", gdb_num + 1);
457 goto exit_inode;
458 }
459
460 /*
461 * Finally, we have all of the possible failures behind us...
462 *
463 * Remove new GDT block from inode double-indirect block and clear out
464 * the new GDT block for use (which also "frees" the backup GDT blocks
465 * from the reserved inode). We don't need to change the bitmaps for
466 * these blocks, because they are marked as in-use from being in the
467 * reserved inode, and will become GDT blocks (primary and backup).
468 */
469 data[gdb_num % EXT4_ADDR_PER_BLOCK(sb)] = 0;
470 ext4_journal_dirty_metadata(handle, dind);
471 brelse(dind);
472 inode->i_blocks -= (gdbackups + 1) * sb->s_blocksize >> 9;
473 ext4_mark_iloc_dirty(handle, inode, &iloc);
474 memset((*primary)->b_data, 0, sb->s_blocksize);
475 ext4_journal_dirty_metadata(handle, *primary);
476
477 o_group_desc = EXT4_SB(sb)->s_group_desc;
478 memcpy(n_group_desc, o_group_desc,
479 EXT4_SB(sb)->s_gdb_count * sizeof(struct buffer_head *));
480 n_group_desc[gdb_num] = *primary;
481 EXT4_SB(sb)->s_group_desc = n_group_desc;
482 EXT4_SB(sb)->s_gdb_count++;
483 kfree(o_group_desc);
484
485 es->s_reserved_gdt_blocks =
486 cpu_to_le16(le16_to_cpu(es->s_reserved_gdt_blocks) - 1);
487 ext4_journal_dirty_metadata(handle, EXT4_SB(sb)->s_sbh);
488
489 return 0;
490
491exit_inode:
492 //ext4_journal_release_buffer(handle, iloc.bh);
493 brelse(iloc.bh);
494exit_dindj:
495 //ext4_journal_release_buffer(handle, dind);
496exit_primary:
497 //ext4_journal_release_buffer(handle, *primary);
498exit_sbh:
499 //ext4_journal_release_buffer(handle, *primary);
500exit_dind:
501 brelse(dind);
502exit_bh:
503 brelse(*primary);
504
505 ext4_debug("leaving with error %d\n", err);
506 return err;
507}
508
509/*
510 * Called when we are adding a new group which has a backup copy of each of
511 * the GDT blocks (i.e. sparse group) and there are reserved GDT blocks.
512 * We need to add these reserved backup GDT blocks to the resize inode, so
513 * that they are kept for future resizing and not allocated to files.
514 *
515 * Each reserved backup GDT block will go into a different indirect block.
516 * The indirect blocks are actually the primary reserved GDT blocks,
517 * so we know in advance what their block numbers are. We only get the
518 * double-indirect block to verify it is pointing to the primary reserved
519 * GDT blocks so we don't overwrite a data block by accident. The reserved
520 * backup GDT blocks are stored in their reserved primary GDT block.
521 */
522static int reserve_backup_gdb(handle_t *handle, struct inode *inode,
523 struct ext4_new_group_data *input)
524{
525 struct super_block *sb = inode->i_sb;
526 int reserved_gdb =le16_to_cpu(EXT4_SB(sb)->s_es->s_reserved_gdt_blocks);
527 struct buffer_head **primary;
528 struct buffer_head *dind;
529 struct ext4_iloc iloc;
530 ext4_fsblk_t blk;
531 __le32 *data, *end;
532 int gdbackups = 0;
533 int res, i;
534 int err;
535
536 primary = kmalloc(reserved_gdb * sizeof(*primary), GFP_KERNEL);
537 if (!primary)
538 return -ENOMEM;
539
540 data = EXT4_I(inode)->i_data + EXT4_DIND_BLOCK;
541 dind = sb_bread(sb, le32_to_cpu(*data));
542 if (!dind) {
543 err = -EIO;
544 goto exit_free;
545 }
546
547 blk = EXT4_SB(sb)->s_sbh->b_blocknr + 1 + EXT4_SB(sb)->s_gdb_count;
548 data = (__le32 *)dind->b_data + EXT4_SB(sb)->s_gdb_count;
549 end = (__le32 *)dind->b_data + EXT4_ADDR_PER_BLOCK(sb);
550
551 /* Get each reserved primary GDT block and verify it holds backups */
552 for (res = 0; res < reserved_gdb; res++, blk++) {
553 if (le32_to_cpu(*data) != blk) {
554 ext4_warning(sb, __FUNCTION__,
555 "reserved block %llu"
556 " not at offset %ld",
557 blk,
558 (long)(data - (__le32 *)dind->b_data));
559 err = -EINVAL;
560 goto exit_bh;
561 }
562 primary[res] = sb_bread(sb, blk);
563 if (!primary[res]) {
564 err = -EIO;
565 goto exit_bh;
566 }
567 if ((gdbackups = verify_reserved_gdb(sb, primary[res])) < 0) {
568 brelse(primary[res]);
569 err = gdbackups;
570 goto exit_bh;
571 }
572 if (++data >= end)
573 data = (__le32 *)dind->b_data;
574 }
575
576 for (i = 0; i < reserved_gdb; i++) {
577 if ((err = ext4_journal_get_write_access(handle, primary[i]))) {
578 /*
579 int j;
580 for (j = 0; j < i; j++)
581 ext4_journal_release_buffer(handle, primary[j]);
582 */
583 goto exit_bh;
584 }
585 }
586
587 if ((err = ext4_reserve_inode_write(handle, inode, &iloc)))
588 goto exit_bh;
589
590 /*
591 * Finally we can add each of the reserved backup GDT blocks from
592 * the new group to its reserved primary GDT block.
593 */
594 blk = input->group * EXT4_BLOCKS_PER_GROUP(sb);
595 for (i = 0; i < reserved_gdb; i++) {
596 int err2;
597 data = (__le32 *)primary[i]->b_data;
598 /* printk("reserving backup %lu[%u] = %lu\n",
599 primary[i]->b_blocknr, gdbackups,
600 blk + primary[i]->b_blocknr); */
601 data[gdbackups] = cpu_to_le32(blk + primary[i]->b_blocknr);
602 err2 = ext4_journal_dirty_metadata(handle, primary[i]);
603 if (!err)
604 err = err2;
605 }
606 inode->i_blocks += reserved_gdb * sb->s_blocksize >> 9;
607 ext4_mark_iloc_dirty(handle, inode, &iloc);
608
609exit_bh:
610 while (--res >= 0)
611 brelse(primary[res]);
612 brelse(dind);
613
614exit_free:
615 kfree(primary);
616
617 return err;
618}
619
620/*
621 * Update the backup copies of the ext4 metadata. These don't need to be part
622 * of the main resize transaction, because e2fsck will re-write them if there
623 * is a problem (basically only OOM will cause a problem). However, we
624 * _should_ update the backups if possible, in case the primary gets trashed
625 * for some reason and we need to run e2fsck from a backup superblock. The
626 * important part is that the new block and inode counts are in the backup
627 * superblocks, and the location of the new group metadata in the GDT backups.
628 *
629 * We do not need lock_super() for this, because these blocks are not
630 * otherwise touched by the filesystem code when it is mounted. We don't
631 * need to worry about last changing from sbi->s_groups_count, because the
632 * worst that can happen is that we do not copy the full number of backups
633 * at this time. The resize which changed s_groups_count will backup again.
634 */
635static void update_backups(struct super_block *sb,
636 int blk_off, char *data, int size)
637{
638 struct ext4_sb_info *sbi = EXT4_SB(sb);
639 const unsigned long last = sbi->s_groups_count;
640 const int bpg = EXT4_BLOCKS_PER_GROUP(sb);
641 unsigned three = 1;
642 unsigned five = 5;
643 unsigned seven = 7;
644 unsigned group;
645 int rest = sb->s_blocksize - size;
646 handle_t *handle;
647 int err = 0, err2;
648
649 handle = ext4_journal_start_sb(sb, EXT4_MAX_TRANS_DATA);
650 if (IS_ERR(handle)) {
651 group = 1;
652 err = PTR_ERR(handle);
653 goto exit_err;
654 }
655
656 while ((group = ext4_list_backups(sb, &three, &five, &seven)) < last) {
657 struct buffer_head *bh;
658
659 /* Out of journal space, and can't get more - abort - so sad */
660 if (handle->h_buffer_credits == 0 &&
661 ext4_journal_extend(handle, EXT4_MAX_TRANS_DATA) &&
662 (err = ext4_journal_restart(handle, EXT4_MAX_TRANS_DATA)))
663 break;
664
665 bh = sb_getblk(sb, group * bpg + blk_off);
666 if (!bh) {
667 err = -EIO;
668 break;
669 }
670 ext4_debug("update metadata backup %#04lx\n",
671 (unsigned long)bh->b_blocknr);
672 if ((err = ext4_journal_get_write_access(handle, bh)))
673 break;
674 lock_buffer(bh);
675 memcpy(bh->b_data, data, size);
676 if (rest)
677 memset(bh->b_data + size, 0, rest);
678 set_buffer_uptodate(bh);
679 unlock_buffer(bh);
680 ext4_journal_dirty_metadata(handle, bh);
681 brelse(bh);
682 }
683 if ((err2 = ext4_journal_stop(handle)) && !err)
684 err = err2;
685
686 /*
687 * Ugh! Need to have e2fsck write the backup copies. It is too
688 * late to revert the resize, we shouldn't fail just because of
689 * the backup copies (they are only needed in case of corruption).
690 *
691 * However, if we got here we have a journal problem too, so we
692 * can't really start a transaction to mark the superblock.
693 * Chicken out and just set the flag on the hope it will be written
694 * to disk, and if not - we will simply wait until next fsck.
695 */
696exit_err:
697 if (err) {
698 ext4_warning(sb, __FUNCTION__,
699 "can't update backup for group %d (err %d), "
700 "forcing fsck on next reboot", group, err);
701 sbi->s_mount_state &= ~EXT4_VALID_FS;
702 sbi->s_es->s_state &= cpu_to_le16(~EXT4_VALID_FS);
703 mark_buffer_dirty(sbi->s_sbh);
704 }
705}
706
707/* Add group descriptor data to an existing or new group descriptor block.
708 * Ensure we handle all possible error conditions _before_ we start modifying
709 * the filesystem, because we cannot abort the transaction and not have it
710 * write the data to disk.
711 *
712 * If we are on a GDT block boundary, we need to get the reserved GDT block.
713 * Otherwise, we may need to add backup GDT blocks for a sparse group.
714 *
715 * We only need to hold the superblock lock while we are actually adding
716 * in the new group's counts to the superblock. Prior to that we have
717 * not really "added" the group at all. We re-check that we are still
718 * adding in the last group in case things have changed since verifying.
719 */
720int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input)
721{
722 struct ext4_sb_info *sbi = EXT4_SB(sb);
723 struct ext4_super_block *es = sbi->s_es;
724 int reserved_gdb = ext4_bg_has_super(sb, input->group) ?
725 le16_to_cpu(es->s_reserved_gdt_blocks) : 0;
726 struct buffer_head *primary = NULL;
727 struct ext4_group_desc *gdp;
728 struct inode *inode = NULL;
729 handle_t *handle;
730 int gdb_off, gdb_num;
731 int err, err2;
732
733 gdb_num = input->group / EXT4_DESC_PER_BLOCK(sb);
734 gdb_off = input->group % EXT4_DESC_PER_BLOCK(sb);
735
736 if (gdb_off == 0 && !EXT4_HAS_RO_COMPAT_FEATURE(sb,
737 EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER)) {
738 ext4_warning(sb, __FUNCTION__,
739 "Can't resize non-sparse filesystem further");
740 return -EPERM;
741 }
742
743 if (ext4_blocks_count(es) + input->blocks_count <
744 ext4_blocks_count(es)) {
745 ext4_warning(sb, __FUNCTION__, "blocks_count overflow\n");
746 return -EINVAL;
747 }
748
749 if (le32_to_cpu(es->s_inodes_count) + EXT4_INODES_PER_GROUP(sb) <
750 le32_to_cpu(es->s_inodes_count)) {
751 ext4_warning(sb, __FUNCTION__, "inodes_count overflow\n");
752 return -EINVAL;
753 }
754
755 if (reserved_gdb || gdb_off == 0) {
756 if (!EXT4_HAS_COMPAT_FEATURE(sb,
757 EXT4_FEATURE_COMPAT_RESIZE_INODE)){
758 ext4_warning(sb, __FUNCTION__,
759 "No reserved GDT blocks, can't resize");
760 return -EPERM;
761 }
762 inode = iget(sb, EXT4_RESIZE_INO);
763 if (!inode || is_bad_inode(inode)) {
764 ext4_warning(sb, __FUNCTION__,
765 "Error opening resize inode");
766 iput(inode);
767 return -ENOENT;
768 }
769 }
770
771 if ((err = verify_group_input(sb, input)))
772 goto exit_put;
773
774 if ((err = setup_new_group_blocks(sb, input)))
775 goto exit_put;
776
777 /*
778 * We will always be modifying at least the superblock and a GDT
779 * block. If we are adding a group past the last current GDT block,
780 * we will also modify the inode and the dindirect block. If we
781 * are adding a group with superblock/GDT backups we will also
782 * modify each of the reserved GDT dindirect blocks.
783 */
784 handle = ext4_journal_start_sb(sb,
785 ext4_bg_has_super(sb, input->group) ?
786 3 + reserved_gdb : 4);
787 if (IS_ERR(handle)) {
788 err = PTR_ERR(handle);
789 goto exit_put;
790 }
791
792 lock_super(sb);
793 if (input->group != sbi->s_groups_count) {
794 ext4_warning(sb, __FUNCTION__,
795 "multiple resizers run on filesystem!");
796 err = -EBUSY;
797 goto exit_journal;
798 }
799
800 if ((err = ext4_journal_get_write_access(handle, sbi->s_sbh)))
801 goto exit_journal;
802
803 /*
804 * We will only either add reserved group blocks to a backup group
805 * or remove reserved blocks for the first group in a new group block.
806 * Doing both would be mean more complex code, and sane people don't
807 * use non-sparse filesystems anymore. This is already checked above.
808 */
809 if (gdb_off) {
810 primary = sbi->s_group_desc[gdb_num];
811 if ((err = ext4_journal_get_write_access(handle, primary)))
812 goto exit_journal;
813
814 if (reserved_gdb && ext4_bg_num_gdb(sb, input->group) &&
815 (err = reserve_backup_gdb(handle, inode, input)))
816 goto exit_journal;
817 } else if ((err = add_new_gdb(handle, inode, input, &primary)))
818 goto exit_journal;
819
820 /*
821 * OK, now we've set up the new group. Time to make it active.
822 *
823 * Current kernels don't lock all allocations via lock_super(),
824 * so we have to be safe wrt. concurrent accesses the group
825 * data. So we need to be careful to set all of the relevant
826 * group descriptor data etc. *before* we enable the group.
827 *
828 * The key field here is sbi->s_groups_count: as long as
829 * that retains its old value, nobody is going to access the new
830 * group.
831 *
832 * So first we update all the descriptor metadata for the new
833 * group; then we update the total disk blocks count; then we
834 * update the groups count to enable the group; then finally we
835 * update the free space counts so that the system can start
836 * using the new disk blocks.
837 */
838
839 /* Update group descriptor block for new group */
840 gdp = (struct ext4_group_desc *)primary->b_data + gdb_off;
841
842 ext4_block_bitmap_set(sb, gdp, input->block_bitmap); /* LV FIXME */
843 ext4_inode_bitmap_set(sb, gdp, input->inode_bitmap); /* LV FIXME */
844 ext4_inode_table_set(sb, gdp, input->inode_table); /* LV FIXME */
845 gdp->bg_free_blocks_count = cpu_to_le16(input->free_blocks_count);
846 gdp->bg_free_inodes_count = cpu_to_le16(EXT4_INODES_PER_GROUP(sb));
847
848 /*
849 * Make the new blocks and inodes valid next. We do this before
850 * increasing the group count so that once the group is enabled,
851 * all of its blocks and inodes are already valid.
852 *
853 * We always allocate group-by-group, then block-by-block or
854 * inode-by-inode within a group, so enabling these
855 * blocks/inodes before the group is live won't actually let us
856 * allocate the new space yet.
857 */
858 ext4_blocks_count_set(es, ext4_blocks_count(es) +
859 input->blocks_count);
860 es->s_inodes_count = cpu_to_le32(le32_to_cpu(es->s_inodes_count) +
861 EXT4_INODES_PER_GROUP(sb));
862
863 /*
864 * We need to protect s_groups_count against other CPUs seeing
865 * inconsistent state in the superblock.
866 *
867 * The precise rules we use are:
868 *
869 * * Writers of s_groups_count *must* hold lock_super
870 * AND
871 * * Writers must perform a smp_wmb() after updating all dependent
872 * data and before modifying the groups count
873 *
874 * * Readers must hold lock_super() over the access
875 * OR
876 * * Readers must perform an smp_rmb() after reading the groups count
877 * and before reading any dependent data.
878 *
879 * NB. These rules can be relaxed when checking the group count
880 * while freeing data, as we can only allocate from a block
881 * group after serialising against the group count, and we can
882 * only then free after serialising in turn against that
883 * allocation.
884 */
885 smp_wmb();
886
887 /* Update the global fs size fields */
888 sbi->s_groups_count++;
889
890 ext4_journal_dirty_metadata(handle, primary);
891
892 /* Update the reserved block counts only once the new group is
893 * active. */
894 ext4_r_blocks_count_set(es, ext4_r_blocks_count(es) +
895 input->reserved_blocks);
896
897 /* Update the free space counts */
898 percpu_counter_mod(&sbi->s_freeblocks_counter,
899 input->free_blocks_count);
900 percpu_counter_mod(&sbi->s_freeinodes_counter,
901 EXT4_INODES_PER_GROUP(sb));
902
903 ext4_journal_dirty_metadata(handle, sbi->s_sbh);
904 sb->s_dirt = 1;
905
906exit_journal:
907 unlock_super(sb);
908 if ((err2 = ext4_journal_stop(handle)) && !err)
909 err = err2;
910 if (!err) {
911 update_backups(sb, sbi->s_sbh->b_blocknr, (char *)es,
912 sizeof(struct ext4_super_block));
913 update_backups(sb, primary->b_blocknr, primary->b_data,
914 primary->b_size);
915 }
916exit_put:
917 iput(inode);
918 return err;
919} /* ext4_group_add */
920
921/* Extend the filesystem to the new number of blocks specified. This entry
922 * point is only used to extend the current filesystem to the end of the last
923 * existing group. It can be accessed via ioctl, or by "remount,resize=<size>"
924 * for emergencies (because it has no dependencies on reserved blocks).
925 *
926 * If we _really_ wanted, we could use default values to call ext4_group_add()
927 * allow the "remount" trick to work for arbitrary resizing, assuming enough
928 * GDT blocks are reserved to grow to the desired size.
929 */
930int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es,
931 ext4_fsblk_t n_blocks_count)
932{
933 ext4_fsblk_t o_blocks_count;
934 unsigned long o_groups_count;
935 ext4_grpblk_t last;
936 ext4_grpblk_t add;
937 struct buffer_head * bh;
938 handle_t *handle;
939 int err;
940 unsigned long freed_blocks;
941
942 /* We don't need to worry about locking wrt other resizers just
943 * yet: we're going to revalidate es->s_blocks_count after
944 * taking lock_super() below. */
945 o_blocks_count = ext4_blocks_count(es);
946 o_groups_count = EXT4_SB(sb)->s_groups_count;
947
948 if (test_opt(sb, DEBUG))
949 printk(KERN_DEBUG "EXT4-fs: extending last group from %llu uto %llu blocks\n",
950 o_blocks_count, n_blocks_count);
951
952 if (n_blocks_count == 0 || n_blocks_count == o_blocks_count)
953 return 0;
954
955 if (n_blocks_count > (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) {
956 printk(KERN_ERR "EXT4-fs: filesystem on %s:"
957 " too large to resize to %llu blocks safely\n",
958 sb->s_id, n_blocks_count);
959 if (sizeof(sector_t) < 8)
960 ext4_warning(sb, __FUNCTION__,
961 "CONFIG_LBD not enabled\n");
962 return -EINVAL;
963 }
964
965 if (n_blocks_count < o_blocks_count) {
966 ext4_warning(sb, __FUNCTION__,
967 "can't shrink FS - resize aborted");
968 return -EBUSY;
969 }
970
971 /* Handle the remaining blocks in the last group only. */
972 ext4_get_group_no_and_offset(sb, o_blocks_count, NULL, &last);
973
974 if (last == 0) {
975 ext4_warning(sb, __FUNCTION__,
976 "need to use ext2online to resize further");
977 return -EPERM;
978 }
979
980 add = EXT4_BLOCKS_PER_GROUP(sb) - last;
981
982 if (o_blocks_count + add < o_blocks_count) {
983 ext4_warning(sb, __FUNCTION__, "blocks_count overflow");
984 return -EINVAL;
985 }
986
987 if (o_blocks_count + add > n_blocks_count)
988 add = n_blocks_count - o_blocks_count;
989
990 if (o_blocks_count + add < n_blocks_count)
991 ext4_warning(sb, __FUNCTION__,
992 "will only finish group (%llu"
993 " blocks, %u new)",
994 o_blocks_count + add, add);
995
996 /* See if the device is actually as big as what was requested */
997 bh = sb_bread(sb, o_blocks_count + add -1);
998 if (!bh) {
999 ext4_warning(sb, __FUNCTION__,
1000 "can't read last block, resize aborted");
1001 return -ENOSPC;
1002 }
1003 brelse(bh);
1004
1005 /* We will update the superblock, one block bitmap, and
1006 * one group descriptor via ext4_free_blocks().
1007 */
1008 handle = ext4_journal_start_sb(sb, 3);
1009 if (IS_ERR(handle)) {
1010 err = PTR_ERR(handle);
1011 ext4_warning(sb, __FUNCTION__, "error %d on journal start",err);
1012 goto exit_put;
1013 }
1014
1015 lock_super(sb);
1016 if (o_blocks_count != ext4_blocks_count(es)) {
1017 ext4_warning(sb, __FUNCTION__,
1018 "multiple resizers run on filesystem!");
1019 unlock_super(sb);
1020 err = -EBUSY;
1021 goto exit_put;
1022 }
1023
1024 if ((err = ext4_journal_get_write_access(handle,
1025 EXT4_SB(sb)->s_sbh))) {
1026 ext4_warning(sb, __FUNCTION__,
1027 "error %d on journal write access", err);
1028 unlock_super(sb);
1029 ext4_journal_stop(handle);
1030 goto exit_put;
1031 }
1032 ext4_blocks_count_set(es, o_blocks_count + add);
1033 ext4_journal_dirty_metadata(handle, EXT4_SB(sb)->s_sbh);
1034 sb->s_dirt = 1;
1035 unlock_super(sb);
1036 ext4_debug("freeing blocks %lu through %llu\n", o_blocks_count,
1037 o_blocks_count + add);
1038 ext4_free_blocks_sb(handle, sb, o_blocks_count, add, &freed_blocks);
1039 ext4_debug("freed blocks %llu through %llu\n", o_blocks_count,
1040 o_blocks_count + add);
1041 if ((err = ext4_journal_stop(handle)))
1042 goto exit_put;
1043 if (test_opt(sb, DEBUG))
1044 printk(KERN_DEBUG "EXT4-fs: extended group to %llu blocks\n",
1045 ext4_blocks_count(es));
1046 update_backups(sb, EXT4_SB(sb)->s_sbh->b_blocknr, (char *)es,
1047 sizeof(struct ext4_super_block));
1048exit_put:
1049 return err;
1050} /* ext4_group_extend */
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
new file mode 100644
index 000000000000..b4b022aa2bc2
--- /dev/null
+++ b/fs/ext4/super.c
@@ -0,0 +1,2829 @@
1/*
2 * linux/fs/ext4/super.c
3 *
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 *
9 * from
10 *
11 * linux/fs/minix/inode.c
12 *
13 * Copyright (C) 1991, 1992 Linus Torvalds
14 *
15 * Big-endian to little-endian byte-swapping/bitmaps by
16 * David S. Miller (davem@caip.rutgers.edu), 1995
17 */
18
19#include <linux/module.h>
20#include <linux/string.h>
21#include <linux/fs.h>
22#include <linux/time.h>
23#include <linux/jbd2.h>
24#include <linux/ext4_fs.h>
25#include <linux/ext4_jbd2.h>
26#include <linux/slab.h>
27#include <linux/init.h>
28#include <linux/blkdev.h>
29#include <linux/parser.h>
30#include <linux/smp_lock.h>
31#include <linux/buffer_head.h>
32#include <linux/vfs.h>
33#include <linux/random.h>
34#include <linux/mount.h>
35#include <linux/namei.h>
36#include <linux/quotaops.h>
37#include <linux/seq_file.h>
38
39#include <asm/uaccess.h>
40
41#include "xattr.h"
42#include "acl.h"
43#include "namei.h"
44
45static int ext4_load_journal(struct super_block *, struct ext4_super_block *,
46 unsigned long journal_devnum);
47static int ext4_create_journal(struct super_block *, struct ext4_super_block *,
48 unsigned int);
49static void ext4_commit_super (struct super_block * sb,
50 struct ext4_super_block * es,
51 int sync);
52static void ext4_mark_recovery_complete(struct super_block * sb,
53 struct ext4_super_block * es);
54static void ext4_clear_journal_err(struct super_block * sb,
55 struct ext4_super_block * es);
56static int ext4_sync_fs(struct super_block *sb, int wait);
57static const char *ext4_decode_error(struct super_block * sb, int errno,
58 char nbuf[16]);
59static int ext4_remount (struct super_block * sb, int * flags, char * data);
60static int ext4_statfs (struct dentry * dentry, struct kstatfs * buf);
61static void ext4_unlockfs(struct super_block *sb);
62static void ext4_write_super (struct super_block * sb);
63static void ext4_write_super_lockfs(struct super_block *sb);
64
65
66ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,
67 struct ext4_group_desc *bg)
68{
69 return le32_to_cpu(bg->bg_block_bitmap) |
70 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
71 (ext4_fsblk_t)le32_to_cpu(bg->bg_block_bitmap_hi) << 32 : 0);
72}
73
74ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb,
75 struct ext4_group_desc *bg)
76{
77 return le32_to_cpu(bg->bg_inode_bitmap) |
78 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
79 (ext4_fsblk_t)le32_to_cpu(bg->bg_inode_bitmap_hi) << 32 : 0);
80}
81
82ext4_fsblk_t ext4_inode_table(struct super_block *sb,
83 struct ext4_group_desc *bg)
84{
85 return le32_to_cpu(bg->bg_inode_table) |
86 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
87 (ext4_fsblk_t)le32_to_cpu(bg->bg_inode_table_hi) << 32 : 0);
88}
89
90void ext4_block_bitmap_set(struct super_block *sb,
91 struct ext4_group_desc *bg, ext4_fsblk_t blk)
92{
93 bg->bg_block_bitmap = cpu_to_le32((u32)blk);
94 if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT)
95 bg->bg_block_bitmap_hi = cpu_to_le32(blk >> 32);
96}
97
98void ext4_inode_bitmap_set(struct super_block *sb,
99 struct ext4_group_desc *bg, ext4_fsblk_t blk)
100{
101 bg->bg_inode_bitmap = cpu_to_le32((u32)blk);
102 if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT)
103 bg->bg_inode_bitmap_hi = cpu_to_le32(blk >> 32);
104}
105
106void ext4_inode_table_set(struct super_block *sb,
107 struct ext4_group_desc *bg, ext4_fsblk_t blk)
108{
109 bg->bg_inode_table = cpu_to_le32((u32)blk);
110 if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT)
111 bg->bg_inode_table_hi = cpu_to_le32(blk >> 32);
112}
113
114/*
115 * Wrappers for jbd2_journal_start/end.
116 *
117 * The only special thing we need to do here is to make sure that all
118 * journal_end calls result in the superblock being marked dirty, so
119 * that sync() will call the filesystem's write_super callback if
120 * appropriate.
121 */
122handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks)
123{
124 journal_t *journal;
125
126 if (sb->s_flags & MS_RDONLY)
127 return ERR_PTR(-EROFS);
128
129 /* Special case here: if the journal has aborted behind our
130 * backs (eg. EIO in the commit thread), then we still need to
131 * take the FS itself readonly cleanly. */
132 journal = EXT4_SB(sb)->s_journal;
133 if (is_journal_aborted(journal)) {
134 ext4_abort(sb, __FUNCTION__,
135 "Detected aborted journal");
136 return ERR_PTR(-EROFS);
137 }
138
139 return jbd2_journal_start(journal, nblocks);
140}
141
142/*
143 * The only special thing we need to do here is to make sure that all
144 * jbd2_journal_stop calls result in the superblock being marked dirty, so
145 * that sync() will call the filesystem's write_super callback if
146 * appropriate.
147 */
148int __ext4_journal_stop(const char *where, handle_t *handle)
149{
150 struct super_block *sb;
151 int err;
152 int rc;
153
154 sb = handle->h_transaction->t_journal->j_private;
155 err = handle->h_err;
156 rc = jbd2_journal_stop(handle);
157
158 if (!err)
159 err = rc;
160 if (err)
161 __ext4_std_error(sb, where, err);
162 return err;
163}
164
165void ext4_journal_abort_handle(const char *caller, const char *err_fn,
166 struct buffer_head *bh, handle_t *handle, int err)
167{
168 char nbuf[16];
169 const char *errstr = ext4_decode_error(NULL, err, nbuf);
170
171 if (bh)
172 BUFFER_TRACE(bh, "abort");
173
174 if (!handle->h_err)
175 handle->h_err = err;
176
177 if (is_handle_aborted(handle))
178 return;
179
180 printk(KERN_ERR "%s: aborting transaction: %s in %s\n",
181 caller, errstr, err_fn);
182
183 jbd2_journal_abort_handle(handle);
184}
185
186/* Deal with the reporting of failure conditions on a filesystem such as
187 * inconsistencies detected or read IO failures.
188 *
189 * On ext2, we can store the error state of the filesystem in the
190 * superblock. That is not possible on ext4, because we may have other
191 * write ordering constraints on the superblock which prevent us from
192 * writing it out straight away; and given that the journal is about to
193 * be aborted, we can't rely on the current, or future, transactions to
194 * write out the superblock safely.
195 *
196 * We'll just use the jbd2_journal_abort() error code to record an error in
197 * the journal instead. On recovery, the journal will compain about
198 * that error until we've noted it down and cleared it.
199 */
200
201static void ext4_handle_error(struct super_block *sb)
202{
203 struct ext4_super_block *es = EXT4_SB(sb)->s_es;
204
205 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS;
206 es->s_state |= cpu_to_le16(EXT4_ERROR_FS);
207
208 if (sb->s_flags & MS_RDONLY)
209 return;
210
211 if (!test_opt (sb, ERRORS_CONT)) {
212 journal_t *journal = EXT4_SB(sb)->s_journal;
213
214 EXT4_SB(sb)->s_mount_opt |= EXT4_MOUNT_ABORT;
215 if (journal)
216 jbd2_journal_abort(journal, -EIO);
217 }
218 if (test_opt (sb, ERRORS_RO)) {
219 printk (KERN_CRIT "Remounting filesystem read-only\n");
220 sb->s_flags |= MS_RDONLY;
221 }
222 ext4_commit_super(sb, es, 1);
223 if (test_opt(sb, ERRORS_PANIC))
224 panic("EXT4-fs (device %s): panic forced after error\n",
225 sb->s_id);
226}
227
228void ext4_error (struct super_block * sb, const char * function,
229 const char * fmt, ...)
230{
231 va_list args;
232
233 va_start(args, fmt);
234 printk(KERN_CRIT "EXT4-fs error (device %s): %s: ",sb->s_id, function);
235 vprintk(fmt, args);
236 printk("\n");
237 va_end(args);
238
239 ext4_handle_error(sb);
240}
241
242static const char *ext4_decode_error(struct super_block * sb, int errno,
243 char nbuf[16])
244{
245 char *errstr = NULL;
246
247 switch (errno) {
248 case -EIO:
249 errstr = "IO failure";
250 break;
251 case -ENOMEM:
252 errstr = "Out of memory";
253 break;
254 case -EROFS:
255 if (!sb || EXT4_SB(sb)->s_journal->j_flags & JBD2_ABORT)
256 errstr = "Journal has aborted";
257 else
258 errstr = "Readonly filesystem";
259 break;
260 default:
261 /* If the caller passed in an extra buffer for unknown
262 * errors, textualise them now. Else we just return
263 * NULL. */
264 if (nbuf) {
265 /* Check for truncated error codes... */
266 if (snprintf(nbuf, 16, "error %d", -errno) >= 0)
267 errstr = nbuf;
268 }
269 break;
270 }
271
272 return errstr;
273}
274
275/* __ext4_std_error decodes expected errors from journaling functions
276 * automatically and invokes the appropriate error response. */
277
278void __ext4_std_error (struct super_block * sb, const char * function,
279 int errno)
280{
281 char nbuf[16];
282 const char *errstr;
283
284 /* Special case: if the error is EROFS, and we're not already
285 * inside a transaction, then there's really no point in logging
286 * an error. */
287 if (errno == -EROFS && journal_current_handle() == NULL &&
288 (sb->s_flags & MS_RDONLY))
289 return;
290
291 errstr = ext4_decode_error(sb, errno, nbuf);
292 printk (KERN_CRIT "EXT4-fs error (device %s) in %s: %s\n",
293 sb->s_id, function, errstr);
294
295 ext4_handle_error(sb);
296}
297
298/*
299 * ext4_abort is a much stronger failure handler than ext4_error. The
300 * abort function may be used to deal with unrecoverable failures such
301 * as journal IO errors or ENOMEM at a critical moment in log management.
302 *
303 * We unconditionally force the filesystem into an ABORT|READONLY state,
304 * unless the error response on the fs has been set to panic in which
305 * case we take the easy way out and panic immediately.
306 */
307
308void ext4_abort (struct super_block * sb, const char * function,
309 const char * fmt, ...)
310{
311 va_list args;
312
313 printk (KERN_CRIT "ext4_abort called.\n");
314
315 va_start(args, fmt);
316 printk(KERN_CRIT "EXT4-fs error (device %s): %s: ",sb->s_id, function);
317 vprintk(fmt, args);
318 printk("\n");
319 va_end(args);
320
321 if (test_opt(sb, ERRORS_PANIC))
322 panic("EXT4-fs panic from previous error\n");
323
324 if (sb->s_flags & MS_RDONLY)
325 return;
326
327 printk(KERN_CRIT "Remounting filesystem read-only\n");
328 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS;
329 sb->s_flags |= MS_RDONLY;
330 EXT4_SB(sb)->s_mount_opt |= EXT4_MOUNT_ABORT;
331 jbd2_journal_abort(EXT4_SB(sb)->s_journal, -EIO);
332}
333
334void ext4_warning (struct super_block * sb, const char * function,
335 const char * fmt, ...)
336{
337 va_list args;
338
339 va_start(args, fmt);
340 printk(KERN_WARNING "EXT4-fs warning (device %s): %s: ",
341 sb->s_id, function);
342 vprintk(fmt, args);
343 printk("\n");
344 va_end(args);
345}
346
347void ext4_update_dynamic_rev(struct super_block *sb)
348{
349 struct ext4_super_block *es = EXT4_SB(sb)->s_es;
350
351 if (le32_to_cpu(es->s_rev_level) > EXT4_GOOD_OLD_REV)
352 return;
353
354 ext4_warning(sb, __FUNCTION__,
355 "updating to rev %d because of new feature flag, "
356 "running e2fsck is recommended",
357 EXT4_DYNAMIC_REV);
358
359 es->s_first_ino = cpu_to_le32(EXT4_GOOD_OLD_FIRST_INO);
360 es->s_inode_size = cpu_to_le16(EXT4_GOOD_OLD_INODE_SIZE);
361 es->s_rev_level = cpu_to_le32(EXT4_DYNAMIC_REV);
362 /* leave es->s_feature_*compat flags alone */
363 /* es->s_uuid will be set by e2fsck if empty */
364
365 /*
366 * The rest of the superblock fields should be zero, and if not it
367 * means they are likely already in use, so leave them alone. We
368 * can leave it up to e2fsck to clean up any inconsistencies there.
369 */
370}
371
372/*
373 * Open the external journal device
374 */
375static struct block_device *ext4_blkdev_get(dev_t dev)
376{
377 struct block_device *bdev;
378 char b[BDEVNAME_SIZE];
379
380 bdev = open_by_devnum(dev, FMODE_READ|FMODE_WRITE);
381 if (IS_ERR(bdev))
382 goto fail;
383 return bdev;
384
385fail:
386 printk(KERN_ERR "EXT4: failed to open journal device %s: %ld\n",
387 __bdevname(dev, b), PTR_ERR(bdev));
388 return NULL;
389}
390
391/*
392 * Release the journal device
393 */
394static int ext4_blkdev_put(struct block_device *bdev)
395{
396 bd_release(bdev);
397 return blkdev_put(bdev);
398}
399
400static int ext4_blkdev_remove(struct ext4_sb_info *sbi)
401{
402 struct block_device *bdev;
403 int ret = -ENODEV;
404
405 bdev = sbi->journal_bdev;
406 if (bdev) {
407 ret = ext4_blkdev_put(bdev);
408 sbi->journal_bdev = NULL;
409 }
410 return ret;
411}
412
413static inline struct inode *orphan_list_entry(struct list_head *l)
414{
415 return &list_entry(l, struct ext4_inode_info, i_orphan)->vfs_inode;
416}
417
418static void dump_orphan_list(struct super_block *sb, struct ext4_sb_info *sbi)
419{
420 struct list_head *l;
421
422 printk(KERN_ERR "sb orphan head is %d\n",
423 le32_to_cpu(sbi->s_es->s_last_orphan));
424
425 printk(KERN_ERR "sb_info orphan list:\n");
426 list_for_each(l, &sbi->s_orphan) {
427 struct inode *inode = orphan_list_entry(l);
428 printk(KERN_ERR " "
429 "inode %s:%lu at %p: mode %o, nlink %d, next %d\n",
430 inode->i_sb->s_id, inode->i_ino, inode,
431 inode->i_mode, inode->i_nlink,
432 NEXT_ORPHAN(inode));
433 }
434}
435
436static void ext4_put_super (struct super_block * sb)
437{
438 struct ext4_sb_info *sbi = EXT4_SB(sb);
439 struct ext4_super_block *es = sbi->s_es;
440 int i;
441
442 ext4_ext_release(sb);
443 ext4_xattr_put_super(sb);
444 jbd2_journal_destroy(sbi->s_journal);
445 if (!(sb->s_flags & MS_RDONLY)) {
446 EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
447 es->s_state = cpu_to_le16(sbi->s_mount_state);
448 BUFFER_TRACE(sbi->s_sbh, "marking dirty");
449 mark_buffer_dirty(sbi->s_sbh);
450 ext4_commit_super(sb, es, 1);
451 }
452
453 for (i = 0; i < sbi->s_gdb_count; i++)
454 brelse(sbi->s_group_desc[i]);
455 kfree(sbi->s_group_desc);
456 percpu_counter_destroy(&sbi->s_freeblocks_counter);
457 percpu_counter_destroy(&sbi->s_freeinodes_counter);
458 percpu_counter_destroy(&sbi->s_dirs_counter);
459 brelse(sbi->s_sbh);
460#ifdef CONFIG_QUOTA
461 for (i = 0; i < MAXQUOTAS; i++)
462 kfree(sbi->s_qf_names[i]);
463#endif
464
465 /* Debugging code just in case the in-memory inode orphan list
466 * isn't empty. The on-disk one can be non-empty if we've
467 * detected an error and taken the fs readonly, but the
468 * in-memory list had better be clean by this point. */
469 if (!list_empty(&sbi->s_orphan))
470 dump_orphan_list(sb, sbi);
471 J_ASSERT(list_empty(&sbi->s_orphan));
472
473 invalidate_bdev(sb->s_bdev, 0);
474 if (sbi->journal_bdev && sbi->journal_bdev != sb->s_bdev) {
475 /*
476 * Invalidate the journal device's buffers. We don't want them
477 * floating about in memory - the physical journal device may
478 * hotswapped, and it breaks the `ro-after' testing code.
479 */
480 sync_blockdev(sbi->journal_bdev);
481 invalidate_bdev(sbi->journal_bdev, 0);
482 ext4_blkdev_remove(sbi);
483 }
484 sb->s_fs_info = NULL;
485 kfree(sbi);
486 return;
487}
488
489static kmem_cache_t *ext4_inode_cachep;
490
491/*
492 * Called inside transaction, so use GFP_NOFS
493 */
494static struct inode *ext4_alloc_inode(struct super_block *sb)
495{
496 struct ext4_inode_info *ei;
497
498 ei = kmem_cache_alloc(ext4_inode_cachep, SLAB_NOFS);
499 if (!ei)
500 return NULL;
501#ifdef CONFIG_EXT4DEV_FS_POSIX_ACL
502 ei->i_acl = EXT4_ACL_NOT_CACHED;
503 ei->i_default_acl = EXT4_ACL_NOT_CACHED;
504#endif
505 ei->i_block_alloc_info = NULL;
506 ei->vfs_inode.i_version = 1;
507 memset(&ei->i_cached_extent, 0, sizeof(struct ext4_ext_cache));
508 return &ei->vfs_inode;
509}
510
511static void ext4_destroy_inode(struct inode *inode)
512{
513 kmem_cache_free(ext4_inode_cachep, EXT4_I(inode));
514}
515
516static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
517{
518 struct ext4_inode_info *ei = (struct ext4_inode_info *) foo;
519
520 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
521 SLAB_CTOR_CONSTRUCTOR) {
522 INIT_LIST_HEAD(&ei->i_orphan);
523#ifdef CONFIG_EXT4DEV_FS_XATTR
524 init_rwsem(&ei->xattr_sem);
525#endif
526 mutex_init(&ei->truncate_mutex);
527 inode_init_once(&ei->vfs_inode);
528 }
529}
530
531static int init_inodecache(void)
532{
533 ext4_inode_cachep = kmem_cache_create("ext4_inode_cache",
534 sizeof(struct ext4_inode_info),
535 0, (SLAB_RECLAIM_ACCOUNT|
536 SLAB_MEM_SPREAD),
537 init_once, NULL);
538 if (ext4_inode_cachep == NULL)
539 return -ENOMEM;
540 return 0;
541}
542
543static void destroy_inodecache(void)
544{
545 kmem_cache_destroy(ext4_inode_cachep);
546}
547
548static void ext4_clear_inode(struct inode *inode)
549{
550 struct ext4_block_alloc_info *rsv = EXT4_I(inode)->i_block_alloc_info;
551#ifdef CONFIG_EXT4DEV_FS_POSIX_ACL
552 if (EXT4_I(inode)->i_acl &&
553 EXT4_I(inode)->i_acl != EXT4_ACL_NOT_CACHED) {
554 posix_acl_release(EXT4_I(inode)->i_acl);
555 EXT4_I(inode)->i_acl = EXT4_ACL_NOT_CACHED;
556 }
557 if (EXT4_I(inode)->i_default_acl &&
558 EXT4_I(inode)->i_default_acl != EXT4_ACL_NOT_CACHED) {
559 posix_acl_release(EXT4_I(inode)->i_default_acl);
560 EXT4_I(inode)->i_default_acl = EXT4_ACL_NOT_CACHED;
561 }
562#endif
563 ext4_discard_reservation(inode);
564 EXT4_I(inode)->i_block_alloc_info = NULL;
565 if (unlikely(rsv))
566 kfree(rsv);
567}
568
569static inline void ext4_show_quota_options(struct seq_file *seq, struct super_block *sb)
570{
571#if defined(CONFIG_QUOTA)
572 struct ext4_sb_info *sbi = EXT4_SB(sb);
573
574 if (sbi->s_jquota_fmt)
575 seq_printf(seq, ",jqfmt=%s",
576 (sbi->s_jquota_fmt == QFMT_VFS_OLD) ? "vfsold": "vfsv0");
577
578 if (sbi->s_qf_names[USRQUOTA])
579 seq_printf(seq, ",usrjquota=%s", sbi->s_qf_names[USRQUOTA]);
580
581 if (sbi->s_qf_names[GRPQUOTA])
582 seq_printf(seq, ",grpjquota=%s", sbi->s_qf_names[GRPQUOTA]);
583
584 if (sbi->s_mount_opt & EXT4_MOUNT_USRQUOTA)
585 seq_puts(seq, ",usrquota");
586
587 if (sbi->s_mount_opt & EXT4_MOUNT_GRPQUOTA)
588 seq_puts(seq, ",grpquota");
589#endif
590}
591
592static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs)
593{
594 struct super_block *sb = vfs->mnt_sb;
595
596 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA)
597 seq_puts(seq, ",data=journal");
598 else if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA)
599 seq_puts(seq, ",data=ordered");
600 else if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)
601 seq_puts(seq, ",data=writeback");
602
603 ext4_show_quota_options(seq, sb);
604
605 return 0;
606}
607
608
609static struct dentry *ext4_get_dentry(struct super_block *sb, void *vobjp)
610{
611 __u32 *objp = vobjp;
612 unsigned long ino = objp[0];
613 __u32 generation = objp[1];
614 struct inode *inode;
615 struct dentry *result;
616
617 if (ino < EXT4_FIRST_INO(sb) && ino != EXT4_ROOT_INO)
618 return ERR_PTR(-ESTALE);
619 if (ino > le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count))
620 return ERR_PTR(-ESTALE);
621
622 /* iget isn't really right if the inode is currently unallocated!!
623 *
624 * ext4_read_inode will return a bad_inode if the inode had been
625 * deleted, so we should be safe.
626 *
627 * Currently we don't know the generation for parent directory, so
628 * a generation of 0 means "accept any"
629 */
630 inode = iget(sb, ino);
631 if (inode == NULL)
632 return ERR_PTR(-ENOMEM);
633 if (is_bad_inode(inode) ||
634 (generation && inode->i_generation != generation)) {
635 iput(inode);
636 return ERR_PTR(-ESTALE);
637 }
638 /* now to find a dentry.
639 * If possible, get a well-connected one
640 */
641 result = d_alloc_anon(inode);
642 if (!result) {
643 iput(inode);
644 return ERR_PTR(-ENOMEM);
645 }
646 return result;
647}
648
649#ifdef CONFIG_QUOTA
650#define QTYPE2NAME(t) ((t)==USRQUOTA?"user":"group")
651#define QTYPE2MOPT(on, t) ((t)==USRQUOTA?((on)##USRJQUOTA):((on)##GRPJQUOTA))
652
653static int ext4_dquot_initialize(struct inode *inode, int type);
654static int ext4_dquot_drop(struct inode *inode);
655static int ext4_write_dquot(struct dquot *dquot);
656static int ext4_acquire_dquot(struct dquot *dquot);
657static int ext4_release_dquot(struct dquot *dquot);
658static int ext4_mark_dquot_dirty(struct dquot *dquot);
659static int ext4_write_info(struct super_block *sb, int type);
660static int ext4_quota_on(struct super_block *sb, int type, int format_id, char *path);
661static int ext4_quota_on_mount(struct super_block *sb, int type);
662static ssize_t ext4_quota_read(struct super_block *sb, int type, char *data,
663 size_t len, loff_t off);
664static ssize_t ext4_quota_write(struct super_block *sb, int type,
665 const char *data, size_t len, loff_t off);
666
667static struct dquot_operations ext4_quota_operations = {
668 .initialize = ext4_dquot_initialize,
669 .drop = ext4_dquot_drop,
670 .alloc_space = dquot_alloc_space,
671 .alloc_inode = dquot_alloc_inode,
672 .free_space = dquot_free_space,
673 .free_inode = dquot_free_inode,
674 .transfer = dquot_transfer,
675 .write_dquot = ext4_write_dquot,
676 .acquire_dquot = ext4_acquire_dquot,
677 .release_dquot = ext4_release_dquot,
678 .mark_dirty = ext4_mark_dquot_dirty,
679 .write_info = ext4_write_info
680};
681
682static struct quotactl_ops ext4_qctl_operations = {
683 .quota_on = ext4_quota_on,
684 .quota_off = vfs_quota_off,
685 .quota_sync = vfs_quota_sync,
686 .get_info = vfs_get_dqinfo,
687 .set_info = vfs_set_dqinfo,
688 .get_dqblk = vfs_get_dqblk,
689 .set_dqblk = vfs_set_dqblk
690};
691#endif
692
693static struct super_operations ext4_sops = {
694 .alloc_inode = ext4_alloc_inode,
695 .destroy_inode = ext4_destroy_inode,
696 .read_inode = ext4_read_inode,
697 .write_inode = ext4_write_inode,
698 .dirty_inode = ext4_dirty_inode,
699 .delete_inode = ext4_delete_inode,
700 .put_super = ext4_put_super,
701 .write_super = ext4_write_super,
702 .sync_fs = ext4_sync_fs,
703 .write_super_lockfs = ext4_write_super_lockfs,
704 .unlockfs = ext4_unlockfs,
705 .statfs = ext4_statfs,
706 .remount_fs = ext4_remount,
707 .clear_inode = ext4_clear_inode,
708 .show_options = ext4_show_options,
709#ifdef CONFIG_QUOTA
710 .quota_read = ext4_quota_read,
711 .quota_write = ext4_quota_write,
712#endif
713};
714
715static struct export_operations ext4_export_ops = {
716 .get_parent = ext4_get_parent,
717 .get_dentry = ext4_get_dentry,
718};
719
720enum {
721 Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid,
722 Opt_resgid, Opt_resuid, Opt_sb, Opt_err_cont, Opt_err_panic, Opt_err_ro,
723 Opt_nouid32, Opt_nocheck, Opt_debug, Opt_oldalloc, Opt_orlov,
724 Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl,
725 Opt_reservation, Opt_noreservation, Opt_noload, Opt_nobh, Opt_bh,
726 Opt_commit, Opt_journal_update, Opt_journal_inum, Opt_journal_dev,
727 Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback,
728 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
729 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
730 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
731 Opt_grpquota, Opt_extents,
732};
733
734static match_table_t tokens = {
735 {Opt_bsd_df, "bsddf"},
736 {Opt_minix_df, "minixdf"},
737 {Opt_grpid, "grpid"},
738 {Opt_grpid, "bsdgroups"},
739 {Opt_nogrpid, "nogrpid"},
740 {Opt_nogrpid, "sysvgroups"},
741 {Opt_resgid, "resgid=%u"},
742 {Opt_resuid, "resuid=%u"},
743 {Opt_sb, "sb=%u"},
744 {Opt_err_cont, "errors=continue"},
745 {Opt_err_panic, "errors=panic"},
746 {Opt_err_ro, "errors=remount-ro"},
747 {Opt_nouid32, "nouid32"},
748 {Opt_nocheck, "nocheck"},
749 {Opt_nocheck, "check=none"},
750 {Opt_debug, "debug"},
751 {Opt_oldalloc, "oldalloc"},
752 {Opt_orlov, "orlov"},
753 {Opt_user_xattr, "user_xattr"},
754 {Opt_nouser_xattr, "nouser_xattr"},
755 {Opt_acl, "acl"},
756 {Opt_noacl, "noacl"},
757 {Opt_reservation, "reservation"},
758 {Opt_noreservation, "noreservation"},
759 {Opt_noload, "noload"},
760 {Opt_nobh, "nobh"},
761 {Opt_bh, "bh"},
762 {Opt_commit, "commit=%u"},
763 {Opt_journal_update, "journal=update"},
764 {Opt_journal_inum, "journal=%u"},
765 {Opt_journal_dev, "journal_dev=%u"},
766 {Opt_abort, "abort"},
767 {Opt_data_journal, "data=journal"},
768 {Opt_data_ordered, "data=ordered"},
769 {Opt_data_writeback, "data=writeback"},
770 {Opt_offusrjquota, "usrjquota="},
771 {Opt_usrjquota, "usrjquota=%s"},
772 {Opt_offgrpjquota, "grpjquota="},
773 {Opt_grpjquota, "grpjquota=%s"},
774 {Opt_jqfmt_vfsold, "jqfmt=vfsold"},
775 {Opt_jqfmt_vfsv0, "jqfmt=vfsv0"},
776 {Opt_grpquota, "grpquota"},
777 {Opt_noquota, "noquota"},
778 {Opt_quota, "quota"},
779 {Opt_usrquota, "usrquota"},
780 {Opt_barrier, "barrier=%u"},
781 {Opt_extents, "extents"},
782 {Opt_err, NULL},
783 {Opt_resize, "resize"},
784};
785
786static ext4_fsblk_t get_sb_block(void **data)
787{
788 ext4_fsblk_t sb_block;
789 char *options = (char *) *data;
790
791 if (!options || strncmp(options, "sb=", 3) != 0)
792 return 1; /* Default location */
793 options += 3;
794 /*todo: use simple_strtoll with >32bit ext4 */
795 sb_block = simple_strtoul(options, &options, 0);
796 if (*options && *options != ',') {
797 printk("EXT4-fs: Invalid sb specification: %s\n",
798 (char *) *data);
799 return 1;
800 }
801 if (*options == ',')
802 options++;
803 *data = (void *) options;
804 return sb_block;
805}
806
807static int parse_options (char *options, struct super_block *sb,
808 unsigned int *inum, unsigned long *journal_devnum,
809 ext4_fsblk_t *n_blocks_count, int is_remount)
810{
811 struct ext4_sb_info *sbi = EXT4_SB(sb);
812 char * p;
813 substring_t args[MAX_OPT_ARGS];
814 int data_opt = 0;
815 int option;
816#ifdef CONFIG_QUOTA
817 int qtype;
818 char *qname;
819#endif
820
821 if (!options)
822 return 1;
823
824 while ((p = strsep (&options, ",")) != NULL) {
825 int token;
826 if (!*p)
827 continue;
828
829 token = match_token(p, tokens, args);
830 switch (token) {
831 case Opt_bsd_df:
832 clear_opt (sbi->s_mount_opt, MINIX_DF);
833 break;
834 case Opt_minix_df:
835 set_opt (sbi->s_mount_opt, MINIX_DF);
836 break;
837 case Opt_grpid:
838 set_opt (sbi->s_mount_opt, GRPID);
839 break;
840 case Opt_nogrpid:
841 clear_opt (sbi->s_mount_opt, GRPID);
842 break;
843 case Opt_resuid:
844 if (match_int(&args[0], &option))
845 return 0;
846 sbi->s_resuid = option;
847 break;
848 case Opt_resgid:
849 if (match_int(&args[0], &option))
850 return 0;
851 sbi->s_resgid = option;
852 break;
853 case Opt_sb:
854 /* handled by get_sb_block() instead of here */
855 /* *sb_block = match_int(&args[0]); */
856 break;
857 case Opt_err_panic:
858 clear_opt (sbi->s_mount_opt, ERRORS_CONT);
859 clear_opt (sbi->s_mount_opt, ERRORS_RO);
860 set_opt (sbi->s_mount_opt, ERRORS_PANIC);
861 break;
862 case Opt_err_ro:
863 clear_opt (sbi->s_mount_opt, ERRORS_CONT);
864 clear_opt (sbi->s_mount_opt, ERRORS_PANIC);
865 set_opt (sbi->s_mount_opt, ERRORS_RO);
866 break;
867 case Opt_err_cont:
868 clear_opt (sbi->s_mount_opt, ERRORS_RO);
869 clear_opt (sbi->s_mount_opt, ERRORS_PANIC);
870 set_opt (sbi->s_mount_opt, ERRORS_CONT);
871 break;
872 case Opt_nouid32:
873 set_opt (sbi->s_mount_opt, NO_UID32);
874 break;
875 case Opt_nocheck:
876 clear_opt (sbi->s_mount_opt, CHECK);
877 break;
878 case Opt_debug:
879 set_opt (sbi->s_mount_opt, DEBUG);
880 break;
881 case Opt_oldalloc:
882 set_opt (sbi->s_mount_opt, OLDALLOC);
883 break;
884 case Opt_orlov:
885 clear_opt (sbi->s_mount_opt, OLDALLOC);
886 break;
887#ifdef CONFIG_EXT4DEV_FS_XATTR
888 case Opt_user_xattr:
889 set_opt (sbi->s_mount_opt, XATTR_USER);
890 break;
891 case Opt_nouser_xattr:
892 clear_opt (sbi->s_mount_opt, XATTR_USER);
893 break;
894#else
895 case Opt_user_xattr:
896 case Opt_nouser_xattr:
897 printk("EXT4 (no)user_xattr options not supported\n");
898 break;
899#endif
900#ifdef CONFIG_EXT4DEV_FS_POSIX_ACL
901 case Opt_acl:
902 set_opt(sbi->s_mount_opt, POSIX_ACL);
903 break;
904 case Opt_noacl:
905 clear_opt(sbi->s_mount_opt, POSIX_ACL);
906 break;
907#else
908 case Opt_acl:
909 case Opt_noacl:
910 printk("EXT4 (no)acl options not supported\n");
911 break;
912#endif
913 case Opt_reservation:
914 set_opt(sbi->s_mount_opt, RESERVATION);
915 break;
916 case Opt_noreservation:
917 clear_opt(sbi->s_mount_opt, RESERVATION);
918 break;
919 case Opt_journal_update:
920 /* @@@ FIXME */
921 /* Eventually we will want to be able to create
922 a journal file here. For now, only allow the
923 user to specify an existing inode to be the
924 journal file. */
925 if (is_remount) {
926 printk(KERN_ERR "EXT4-fs: cannot specify "
927 "journal on remount\n");
928 return 0;
929 }
930 set_opt (sbi->s_mount_opt, UPDATE_JOURNAL);
931 break;
932 case Opt_journal_inum:
933 if (is_remount) {
934 printk(KERN_ERR "EXT4-fs: cannot specify "
935 "journal on remount\n");
936 return 0;
937 }
938 if (match_int(&args[0], &option))
939 return 0;
940 *inum = option;
941 break;
942 case Opt_journal_dev:
943 if (is_remount) {
944 printk(KERN_ERR "EXT4-fs: cannot specify "
945 "journal on remount\n");
946 return 0;
947 }
948 if (match_int(&args[0], &option))
949 return 0;
950 *journal_devnum = option;
951 break;
952 case Opt_noload:
953 set_opt (sbi->s_mount_opt, NOLOAD);
954 break;
955 case Opt_commit:
956 if (match_int(&args[0], &option))
957 return 0;
958 if (option < 0)
959 return 0;
960 if (option == 0)
961 option = JBD_DEFAULT_MAX_COMMIT_AGE;
962 sbi->s_commit_interval = HZ * option;
963 break;
964 case Opt_data_journal:
965 data_opt = EXT4_MOUNT_JOURNAL_DATA;
966 goto datacheck;
967 case Opt_data_ordered:
968 data_opt = EXT4_MOUNT_ORDERED_DATA;
969 goto datacheck;
970 case Opt_data_writeback:
971 data_opt = EXT4_MOUNT_WRITEBACK_DATA;
972 datacheck:
973 if (is_remount) {
974 if ((sbi->s_mount_opt & EXT4_MOUNT_DATA_FLAGS)
975 != data_opt) {
976 printk(KERN_ERR
977 "EXT4-fs: cannot change data "
978 "mode on remount\n");
979 return 0;
980 }
981 } else {
982 sbi->s_mount_opt &= ~EXT4_MOUNT_DATA_FLAGS;
983 sbi->s_mount_opt |= data_opt;
984 }
985 break;
986#ifdef CONFIG_QUOTA
987 case Opt_usrjquota:
988 qtype = USRQUOTA;
989 goto set_qf_name;
990 case Opt_grpjquota:
991 qtype = GRPQUOTA;
992set_qf_name:
993 if (sb_any_quota_enabled(sb)) {
994 printk(KERN_ERR
995 "EXT4-fs: Cannot change journalled "
996 "quota options when quota turned on.\n");
997 return 0;
998 }
999 qname = match_strdup(&args[0]);
1000 if (!qname) {
1001 printk(KERN_ERR
1002 "EXT4-fs: not enough memory for "
1003 "storing quotafile name.\n");
1004 return 0;
1005 }
1006 if (sbi->s_qf_names[qtype] &&
1007 strcmp(sbi->s_qf_names[qtype], qname)) {
1008 printk(KERN_ERR
1009 "EXT4-fs: %s quota file already "
1010 "specified.\n", QTYPE2NAME(qtype));
1011 kfree(qname);
1012 return 0;
1013 }
1014 sbi->s_qf_names[qtype] = qname;
1015 if (strchr(sbi->s_qf_names[qtype], '/')) {
1016 printk(KERN_ERR
1017 "EXT4-fs: quotafile must be on "
1018 "filesystem root.\n");
1019 kfree(sbi->s_qf_names[qtype]);
1020 sbi->s_qf_names[qtype] = NULL;
1021 return 0;
1022 }
1023 set_opt(sbi->s_mount_opt, QUOTA);
1024 break;
1025 case Opt_offusrjquota:
1026 qtype = USRQUOTA;
1027 goto clear_qf_name;
1028 case Opt_offgrpjquota:
1029 qtype = GRPQUOTA;
1030clear_qf_name:
1031 if (sb_any_quota_enabled(sb)) {
1032 printk(KERN_ERR "EXT4-fs: Cannot change "
1033 "journalled quota options when "
1034 "quota turned on.\n");
1035 return 0;
1036 }
1037 /*
1038 * The space will be released later when all options
1039 * are confirmed to be correct
1040 */
1041 sbi->s_qf_names[qtype] = NULL;
1042 break;
1043 case Opt_jqfmt_vfsold:
1044 sbi->s_jquota_fmt = QFMT_VFS_OLD;
1045 break;
1046 case Opt_jqfmt_vfsv0:
1047 sbi->s_jquota_fmt = QFMT_VFS_V0;
1048 break;
1049 case Opt_quota:
1050 case Opt_usrquota:
1051 set_opt(sbi->s_mount_opt, QUOTA);
1052 set_opt(sbi->s_mount_opt, USRQUOTA);
1053 break;
1054 case Opt_grpquota:
1055 set_opt(sbi->s_mount_opt, QUOTA);
1056 set_opt(sbi->s_mount_opt, GRPQUOTA);
1057 break;
1058 case Opt_noquota:
1059 if (sb_any_quota_enabled(sb)) {
1060 printk(KERN_ERR "EXT4-fs: Cannot change quota "
1061 "options when quota turned on.\n");
1062 return 0;
1063 }
1064 clear_opt(sbi->s_mount_opt, QUOTA);
1065 clear_opt(sbi->s_mount_opt, USRQUOTA);
1066 clear_opt(sbi->s_mount_opt, GRPQUOTA);
1067 break;
1068#else
1069 case Opt_quota:
1070 case Opt_usrquota:
1071 case Opt_grpquota:
1072 case Opt_usrjquota:
1073 case Opt_grpjquota:
1074 case Opt_offusrjquota:
1075 case Opt_offgrpjquota:
1076 case Opt_jqfmt_vfsold:
1077 case Opt_jqfmt_vfsv0:
1078 printk(KERN_ERR
1079 "EXT4-fs: journalled quota options not "
1080 "supported.\n");
1081 break;
1082 case Opt_noquota:
1083 break;
1084#endif
1085 case Opt_abort:
1086 set_opt(sbi->s_mount_opt, ABORT);
1087 break;
1088 case Opt_barrier:
1089 if (match_int(&args[0], &option))
1090 return 0;
1091 if (option)
1092 set_opt(sbi->s_mount_opt, BARRIER);
1093 else
1094 clear_opt(sbi->s_mount_opt, BARRIER);
1095 break;
1096 case Opt_ignore:
1097 break;
1098 case Opt_resize:
1099 if (!is_remount) {
1100 printk("EXT4-fs: resize option only available "
1101 "for remount\n");
1102 return 0;
1103 }
1104 if (match_int(&args[0], &option) != 0)
1105 return 0;
1106 *n_blocks_count = option;
1107 break;
1108 case Opt_nobh:
1109 set_opt(sbi->s_mount_opt, NOBH);
1110 break;
1111 case Opt_bh:
1112 clear_opt(sbi->s_mount_opt, NOBH);
1113 break;
1114 case Opt_extents:
1115 set_opt (sbi->s_mount_opt, EXTENTS);
1116 break;
1117 default:
1118 printk (KERN_ERR
1119 "EXT4-fs: Unrecognized mount option \"%s\" "
1120 "or missing value\n", p);
1121 return 0;
1122 }
1123 }
1124#ifdef CONFIG_QUOTA
1125 if (sbi->s_qf_names[USRQUOTA] || sbi->s_qf_names[GRPQUOTA]) {
1126 if ((sbi->s_mount_opt & EXT4_MOUNT_USRQUOTA) &&
1127 sbi->s_qf_names[USRQUOTA])
1128 clear_opt(sbi->s_mount_opt, USRQUOTA);
1129
1130 if ((sbi->s_mount_opt & EXT4_MOUNT_GRPQUOTA) &&
1131 sbi->s_qf_names[GRPQUOTA])
1132 clear_opt(sbi->s_mount_opt, GRPQUOTA);
1133
1134 if ((sbi->s_qf_names[USRQUOTA] &&
1135 (sbi->s_mount_opt & EXT4_MOUNT_GRPQUOTA)) ||
1136 (sbi->s_qf_names[GRPQUOTA] &&
1137 (sbi->s_mount_opt & EXT4_MOUNT_USRQUOTA))) {
1138 printk(KERN_ERR "EXT4-fs: old and new quota "
1139 "format mixing.\n");
1140 return 0;
1141 }
1142
1143 if (!sbi->s_jquota_fmt) {
1144 printk(KERN_ERR "EXT4-fs: journalled quota format "
1145 "not specified.\n");
1146 return 0;
1147 }
1148 } else {
1149 if (sbi->s_jquota_fmt) {
1150 printk(KERN_ERR "EXT4-fs: journalled quota format "
1151 "specified with no journalling "
1152 "enabled.\n");
1153 return 0;
1154 }
1155 }
1156#endif
1157 return 1;
1158}
1159
1160static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es,
1161 int read_only)
1162{
1163 struct ext4_sb_info *sbi = EXT4_SB(sb);
1164 int res = 0;
1165
1166 if (le32_to_cpu(es->s_rev_level) > EXT4_MAX_SUPP_REV) {
1167 printk (KERN_ERR "EXT4-fs warning: revision level too high, "
1168 "forcing read-only mode\n");
1169 res = MS_RDONLY;
1170 }
1171 if (read_only)
1172 return res;
1173 if (!(sbi->s_mount_state & EXT4_VALID_FS))
1174 printk (KERN_WARNING "EXT4-fs warning: mounting unchecked fs, "
1175 "running e2fsck is recommended\n");
1176 else if ((sbi->s_mount_state & EXT4_ERROR_FS))
1177 printk (KERN_WARNING
1178 "EXT4-fs warning: mounting fs with errors, "
1179 "running e2fsck is recommended\n");
1180 else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 &&
1181 le16_to_cpu(es->s_mnt_count) >=
1182 (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count))
1183 printk (KERN_WARNING
1184 "EXT4-fs warning: maximal mount count reached, "
1185 "running e2fsck is recommended\n");
1186 else if (le32_to_cpu(es->s_checkinterval) &&
1187 (le32_to_cpu(es->s_lastcheck) +
1188 le32_to_cpu(es->s_checkinterval) <= get_seconds()))
1189 printk (KERN_WARNING
1190 "EXT4-fs warning: checktime reached, "
1191 "running e2fsck is recommended\n");
1192#if 0
1193 /* @@@ We _will_ want to clear the valid bit if we find
1194 * inconsistencies, to force a fsck at reboot. But for
1195 * a plain journaled filesystem we can keep it set as
1196 * valid forever! :)
1197 */
1198 es->s_state = cpu_to_le16(le16_to_cpu(es->s_state) & ~EXT4_VALID_FS);
1199#endif
1200 if (!(__s16) le16_to_cpu(es->s_max_mnt_count))
1201 es->s_max_mnt_count = cpu_to_le16(EXT4_DFL_MAX_MNT_COUNT);
1202 es->s_mnt_count=cpu_to_le16(le16_to_cpu(es->s_mnt_count) + 1);
1203 es->s_mtime = cpu_to_le32(get_seconds());
1204 ext4_update_dynamic_rev(sb);
1205 EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
1206
1207 ext4_commit_super(sb, es, 1);
1208 if (test_opt(sb, DEBUG))
1209 printk(KERN_INFO "[EXT4 FS bs=%lu, gc=%lu, "
1210 "bpg=%lu, ipg=%lu, mo=%04lx]\n",
1211 sb->s_blocksize,
1212 sbi->s_groups_count,
1213 EXT4_BLOCKS_PER_GROUP(sb),
1214 EXT4_INODES_PER_GROUP(sb),
1215 sbi->s_mount_opt);
1216
1217 printk(KERN_INFO "EXT4 FS on %s, ", sb->s_id);
1218 if (EXT4_SB(sb)->s_journal->j_inode == NULL) {
1219 char b[BDEVNAME_SIZE];
1220
1221 printk("external journal on %s\n",
1222 bdevname(EXT4_SB(sb)->s_journal->j_dev, b));
1223 } else {
1224 printk("internal journal\n");
1225 }
1226 return res;
1227}
1228
1229/* Called at mount-time, super-block is locked */
1230static int ext4_check_descriptors (struct super_block * sb)
1231{
1232 struct ext4_sb_info *sbi = EXT4_SB(sb);
1233 ext4_fsblk_t first_block = le32_to_cpu(sbi->s_es->s_first_data_block);
1234 ext4_fsblk_t last_block;
1235 ext4_fsblk_t block_bitmap;
1236 ext4_fsblk_t inode_bitmap;
1237 ext4_fsblk_t inode_table;
1238 struct ext4_group_desc * gdp = NULL;
1239 int desc_block = 0;
1240 int i;
1241
1242 ext4_debug ("Checking group descriptors");
1243
1244 for (i = 0; i < sbi->s_groups_count; i++)
1245 {
1246 if (i == sbi->s_groups_count - 1)
1247 last_block = ext4_blocks_count(sbi->s_es) - 1;
1248 else
1249 last_block = first_block +
1250 (EXT4_BLOCKS_PER_GROUP(sb) - 1);
1251
1252 if ((i % EXT4_DESC_PER_BLOCK(sb)) == 0)
1253 gdp = (struct ext4_group_desc *)
1254 sbi->s_group_desc[desc_block++]->b_data;
1255 block_bitmap = ext4_block_bitmap(sb, gdp);
1256 if (block_bitmap < first_block || block_bitmap > last_block)
1257 {
1258 ext4_error (sb, "ext4_check_descriptors",
1259 "Block bitmap for group %d"
1260 " not in group (block %llu)!",
1261 i, block_bitmap);
1262 return 0;
1263 }
1264 inode_bitmap = ext4_inode_bitmap(sb, gdp);
1265 if (inode_bitmap < first_block || inode_bitmap > last_block)
1266 {
1267 ext4_error (sb, "ext4_check_descriptors",
1268 "Inode bitmap for group %d"
1269 " not in group (block %llu)!",
1270 i, inode_bitmap);
1271 return 0;
1272 }
1273 inode_table = ext4_inode_table(sb, gdp);
1274 if (inode_table < first_block ||
1275 inode_table + sbi->s_itb_per_group > last_block)
1276 {
1277 ext4_error (sb, "ext4_check_descriptors",
1278 "Inode table for group %d"
1279 " not in group (block %llu)!",
1280 i, inode_table);
1281 return 0;
1282 }
1283 first_block += EXT4_BLOCKS_PER_GROUP(sb);
1284 gdp = (struct ext4_group_desc *)
1285 ((__u8 *)gdp + EXT4_DESC_SIZE(sb));
1286 }
1287
1288 ext4_free_blocks_count_set(sbi->s_es, ext4_count_free_blocks(sb));
1289 sbi->s_es->s_free_inodes_count=cpu_to_le32(ext4_count_free_inodes(sb));
1290 return 1;
1291}
1292
1293
1294/* ext4_orphan_cleanup() walks a singly-linked list of inodes (starting at
1295 * the superblock) which were deleted from all directories, but held open by
1296 * a process at the time of a crash. We walk the list and try to delete these
1297 * inodes at recovery time (only with a read-write filesystem).
1298 *
1299 * In order to keep the orphan inode chain consistent during traversal (in
1300 * case of crash during recovery), we link each inode into the superblock
1301 * orphan list_head and handle it the same way as an inode deletion during
1302 * normal operation (which journals the operations for us).
1303 *
1304 * We only do an iget() and an iput() on each inode, which is very safe if we
1305 * accidentally point at an in-use or already deleted inode. The worst that
1306 * can happen in this case is that we get a "bit already cleared" message from
1307 * ext4_free_inode(). The only reason we would point at a wrong inode is if
1308 * e2fsck was run on this filesystem, and it must have already done the orphan
1309 * inode cleanup for us, so we can safely abort without any further action.
1310 */
1311static void ext4_orphan_cleanup (struct super_block * sb,
1312 struct ext4_super_block * es)
1313{
1314 unsigned int s_flags = sb->s_flags;
1315 int nr_orphans = 0, nr_truncates = 0;
1316#ifdef CONFIG_QUOTA
1317 int i;
1318#endif
1319 if (!es->s_last_orphan) {
1320 jbd_debug(4, "no orphan inodes to clean up\n");
1321 return;
1322 }
1323
1324 if (EXT4_SB(sb)->s_mount_state & EXT4_ERROR_FS) {
1325 if (es->s_last_orphan)
1326 jbd_debug(1, "Errors on filesystem, "
1327 "clearing orphan list.\n");
1328 es->s_last_orphan = 0;
1329 jbd_debug(1, "Skipping orphan recovery on fs with errors.\n");
1330 return;
1331 }
1332
1333 if (s_flags & MS_RDONLY) {
1334 printk(KERN_INFO "EXT4-fs: %s: orphan cleanup on readonly fs\n",
1335 sb->s_id);
1336 sb->s_flags &= ~MS_RDONLY;
1337 }
1338#ifdef CONFIG_QUOTA
1339 /* Needed for iput() to work correctly and not trash data */
1340 sb->s_flags |= MS_ACTIVE;
1341 /* Turn on quotas so that they are updated correctly */
1342 for (i = 0; i < MAXQUOTAS; i++) {
1343 if (EXT4_SB(sb)->s_qf_names[i]) {
1344 int ret = ext4_quota_on_mount(sb, i);
1345 if (ret < 0)
1346 printk(KERN_ERR
1347 "EXT4-fs: Cannot turn on journalled "
1348 "quota: error %d\n", ret);
1349 }
1350 }
1351#endif
1352
1353 while (es->s_last_orphan) {
1354 struct inode *inode;
1355
1356 if (!(inode =
1357 ext4_orphan_get(sb, le32_to_cpu(es->s_last_orphan)))) {
1358 es->s_last_orphan = 0;
1359 break;
1360 }
1361
1362 list_add(&EXT4_I(inode)->i_orphan, &EXT4_SB(sb)->s_orphan);
1363 DQUOT_INIT(inode);
1364 if (inode->i_nlink) {
1365 printk(KERN_DEBUG
1366 "%s: truncating inode %lu to %Ld bytes\n",
1367 __FUNCTION__, inode->i_ino, inode->i_size);
1368 jbd_debug(2, "truncating inode %lu to %Ld bytes\n",
1369 inode->i_ino, inode->i_size);
1370 ext4_truncate(inode);
1371 nr_truncates++;
1372 } else {
1373 printk(KERN_DEBUG
1374 "%s: deleting unreferenced inode %lu\n",
1375 __FUNCTION__, inode->i_ino);
1376 jbd_debug(2, "deleting unreferenced inode %lu\n",
1377 inode->i_ino);
1378 nr_orphans++;
1379 }
1380 iput(inode); /* The delete magic happens here! */
1381 }
1382
1383#define PLURAL(x) (x), ((x)==1) ? "" : "s"
1384
1385 if (nr_orphans)
1386 printk(KERN_INFO "EXT4-fs: %s: %d orphan inode%s deleted\n",
1387 sb->s_id, PLURAL(nr_orphans));
1388 if (nr_truncates)
1389 printk(KERN_INFO "EXT4-fs: %s: %d truncate%s cleaned up\n",
1390 sb->s_id, PLURAL(nr_truncates));
1391#ifdef CONFIG_QUOTA
1392 /* Turn quotas off */
1393 for (i = 0; i < MAXQUOTAS; i++) {
1394 if (sb_dqopt(sb)->files[i])
1395 vfs_quota_off(sb, i);
1396 }
1397#endif
1398 sb->s_flags = s_flags; /* Restore MS_RDONLY status */
1399}
1400
1401#define log2(n) ffz(~(n))
1402
1403/*
1404 * Maximal file size. There is a direct, and {,double-,triple-}indirect
1405 * block limit, and also a limit of (2^32 - 1) 512-byte sectors in i_blocks.
1406 * We need to be 1 filesystem block less than the 2^32 sector limit.
1407 */
1408static loff_t ext4_max_size(int bits)
1409{
1410 loff_t res = EXT4_NDIR_BLOCKS;
1411 /* This constant is calculated to be the largest file size for a
1412 * dense, 4k-blocksize file such that the total number of
1413 * sectors in the file, including data and all indirect blocks,
1414 * does not exceed 2^32. */
1415 const loff_t upper_limit = 0x1ff7fffd000LL;
1416
1417 res += 1LL << (bits-2);
1418 res += 1LL << (2*(bits-2));
1419 res += 1LL << (3*(bits-2));
1420 res <<= bits;
1421 if (res > upper_limit)
1422 res = upper_limit;
1423 return res;
1424}
1425
1426static ext4_fsblk_t descriptor_loc(struct super_block *sb,
1427 ext4_fsblk_t logical_sb_block, int nr)
1428{
1429 struct ext4_sb_info *sbi = EXT4_SB(sb);
1430 unsigned long bg, first_meta_bg;
1431 int has_super = 0;
1432
1433 first_meta_bg = le32_to_cpu(sbi->s_es->s_first_meta_bg);
1434
1435 if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_META_BG) ||
1436 nr < first_meta_bg)
1437 return logical_sb_block + nr + 1;
1438 bg = sbi->s_desc_per_block * nr;
1439 if (ext4_bg_has_super(sb, bg))
1440 has_super = 1;
1441 return (has_super + ext4_group_first_block_no(sb, bg));
1442}
1443
1444
1445static int ext4_fill_super (struct super_block *sb, void *data, int silent)
1446{
1447 struct buffer_head * bh;
1448 struct ext4_super_block *es = NULL;
1449 struct ext4_sb_info *sbi;
1450 ext4_fsblk_t block;
1451 ext4_fsblk_t sb_block = get_sb_block(&data);
1452 ext4_fsblk_t logical_sb_block;
1453 unsigned long offset = 0;
1454 unsigned int journal_inum = 0;
1455 unsigned long journal_devnum = 0;
1456 unsigned long def_mount_opts;
1457 struct inode *root;
1458 int blocksize;
1459 int hblock;
1460 int db_count;
1461 int i;
1462 int needs_recovery;
1463 __le32 features;
1464 __u64 blocks_count;
1465
1466 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
1467 if (!sbi)
1468 return -ENOMEM;
1469 sb->s_fs_info = sbi;
1470 sbi->s_mount_opt = 0;
1471 sbi->s_resuid = EXT4_DEF_RESUID;
1472 sbi->s_resgid = EXT4_DEF_RESGID;
1473
1474 unlock_kernel();
1475
1476 blocksize = sb_min_blocksize(sb, EXT4_MIN_BLOCK_SIZE);
1477 if (!blocksize) {
1478 printk(KERN_ERR "EXT4-fs: unable to set blocksize\n");
1479 goto out_fail;
1480 }
1481
1482 /*
1483 * The ext4 superblock will not be buffer aligned for other than 1kB
1484 * block sizes. We need to calculate the offset from buffer start.
1485 */
1486 if (blocksize != EXT4_MIN_BLOCK_SIZE) {
1487 logical_sb_block = sb_block * EXT4_MIN_BLOCK_SIZE;
1488 offset = do_div(logical_sb_block, blocksize);
1489 } else {
1490 logical_sb_block = sb_block;
1491 }
1492
1493 if (!(bh = sb_bread(sb, logical_sb_block))) {
1494 printk (KERN_ERR "EXT4-fs: unable to read superblock\n");
1495 goto out_fail;
1496 }
1497 /*
1498 * Note: s_es must be initialized as soon as possible because
1499 * some ext4 macro-instructions depend on its value
1500 */
1501 es = (struct ext4_super_block *) (((char *)bh->b_data) + offset);
1502 sbi->s_es = es;
1503 sb->s_magic = le16_to_cpu(es->s_magic);
1504 if (sb->s_magic != EXT4_SUPER_MAGIC)
1505 goto cantfind_ext4;
1506
1507 /* Set defaults before we parse the mount options */
1508 def_mount_opts = le32_to_cpu(es->s_default_mount_opts);
1509 if (def_mount_opts & EXT4_DEFM_DEBUG)
1510 set_opt(sbi->s_mount_opt, DEBUG);
1511 if (def_mount_opts & EXT4_DEFM_BSDGROUPS)
1512 set_opt(sbi->s_mount_opt, GRPID);
1513 if (def_mount_opts & EXT4_DEFM_UID16)
1514 set_opt(sbi->s_mount_opt, NO_UID32);
1515 if (def_mount_opts & EXT4_DEFM_XATTR_USER)
1516 set_opt(sbi->s_mount_opt, XATTR_USER);
1517 if (def_mount_opts & EXT4_DEFM_ACL)
1518 set_opt(sbi->s_mount_opt, POSIX_ACL);
1519 if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_DATA)
1520 sbi->s_mount_opt |= EXT4_MOUNT_JOURNAL_DATA;
1521 else if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_ORDERED)
1522 sbi->s_mount_opt |= EXT4_MOUNT_ORDERED_DATA;
1523 else if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_WBACK)
1524 sbi->s_mount_opt |= EXT4_MOUNT_WRITEBACK_DATA;
1525
1526 if (le16_to_cpu(sbi->s_es->s_errors) == EXT4_ERRORS_PANIC)
1527 set_opt(sbi->s_mount_opt, ERRORS_PANIC);
1528 else if (le16_to_cpu(sbi->s_es->s_errors) == EXT4_ERRORS_RO)
1529 set_opt(sbi->s_mount_opt, ERRORS_RO);
1530 else
1531 set_opt(sbi->s_mount_opt, ERRORS_CONT);
1532
1533 sbi->s_resuid = le16_to_cpu(es->s_def_resuid);
1534 sbi->s_resgid = le16_to_cpu(es->s_def_resgid);
1535
1536 set_opt(sbi->s_mount_opt, RESERVATION);
1537
1538 if (!parse_options ((char *) data, sb, &journal_inum, &journal_devnum,
1539 NULL, 0))
1540 goto failed_mount;
1541
1542 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
1543 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
1544
1545 if (le32_to_cpu(es->s_rev_level) == EXT4_GOOD_OLD_REV &&
1546 (EXT4_HAS_COMPAT_FEATURE(sb, ~0U) ||
1547 EXT4_HAS_RO_COMPAT_FEATURE(sb, ~0U) ||
1548 EXT4_HAS_INCOMPAT_FEATURE(sb, ~0U)))
1549 printk(KERN_WARNING
1550 "EXT4-fs warning: feature flags set on rev 0 fs, "
1551 "running e2fsck is recommended\n");
1552 /*
1553 * Check feature flags regardless of the revision level, since we
1554 * previously didn't change the revision level when setting the flags,
1555 * so there is a chance incompat flags are set on a rev 0 filesystem.
1556 */
1557 features = EXT4_HAS_INCOMPAT_FEATURE(sb, ~EXT4_FEATURE_INCOMPAT_SUPP);
1558 if (features) {
1559 printk(KERN_ERR "EXT4-fs: %s: couldn't mount because of "
1560 "unsupported optional features (%x).\n",
1561 sb->s_id, le32_to_cpu(features));
1562 goto failed_mount;
1563 }
1564 features = EXT4_HAS_RO_COMPAT_FEATURE(sb, ~EXT4_FEATURE_RO_COMPAT_SUPP);
1565 if (!(sb->s_flags & MS_RDONLY) && features) {
1566 printk(KERN_ERR "EXT4-fs: %s: couldn't mount RDWR because of "
1567 "unsupported optional features (%x).\n",
1568 sb->s_id, le32_to_cpu(features));
1569 goto failed_mount;
1570 }
1571 blocksize = BLOCK_SIZE << le32_to_cpu(es->s_log_block_size);
1572
1573 if (blocksize < EXT4_MIN_BLOCK_SIZE ||
1574 blocksize > EXT4_MAX_BLOCK_SIZE) {
1575 printk(KERN_ERR
1576 "EXT4-fs: Unsupported filesystem blocksize %d on %s.\n",
1577 blocksize, sb->s_id);
1578 goto failed_mount;
1579 }
1580
1581 hblock = bdev_hardsect_size(sb->s_bdev);
1582 if (sb->s_blocksize != blocksize) {
1583 /*
1584 * Make sure the blocksize for the filesystem is larger
1585 * than the hardware sectorsize for the machine.
1586 */
1587 if (blocksize < hblock) {
1588 printk(KERN_ERR "EXT4-fs: blocksize %d too small for "
1589 "device blocksize %d.\n", blocksize, hblock);
1590 goto failed_mount;
1591 }
1592
1593 brelse (bh);
1594 sb_set_blocksize(sb, blocksize);
1595 logical_sb_block = sb_block * EXT4_MIN_BLOCK_SIZE;
1596 offset = do_div(logical_sb_block, blocksize);
1597 bh = sb_bread(sb, logical_sb_block);
1598 if (!bh) {
1599 printk(KERN_ERR
1600 "EXT4-fs: Can't read superblock on 2nd try.\n");
1601 goto failed_mount;
1602 }
1603 es = (struct ext4_super_block *)(((char *)bh->b_data) + offset);
1604 sbi->s_es = es;
1605 if (es->s_magic != cpu_to_le16(EXT4_SUPER_MAGIC)) {
1606 printk (KERN_ERR
1607 "EXT4-fs: Magic mismatch, very weird !\n");
1608 goto failed_mount;
1609 }
1610 }
1611
1612 sb->s_maxbytes = ext4_max_size(sb->s_blocksize_bits);
1613
1614 if (le32_to_cpu(es->s_rev_level) == EXT4_GOOD_OLD_REV) {
1615 sbi->s_inode_size = EXT4_GOOD_OLD_INODE_SIZE;
1616 sbi->s_first_ino = EXT4_GOOD_OLD_FIRST_INO;
1617 } else {
1618 sbi->s_inode_size = le16_to_cpu(es->s_inode_size);
1619 sbi->s_first_ino = le32_to_cpu(es->s_first_ino);
1620 if ((sbi->s_inode_size < EXT4_GOOD_OLD_INODE_SIZE) ||
1621 (sbi->s_inode_size & (sbi->s_inode_size - 1)) ||
1622 (sbi->s_inode_size > blocksize)) {
1623 printk (KERN_ERR
1624 "EXT4-fs: unsupported inode size: %d\n",
1625 sbi->s_inode_size);
1626 goto failed_mount;
1627 }
1628 }
1629 sbi->s_frag_size = EXT4_MIN_FRAG_SIZE <<
1630 le32_to_cpu(es->s_log_frag_size);
1631 if (blocksize != sbi->s_frag_size) {
1632 printk(KERN_ERR
1633 "EXT4-fs: fragsize %lu != blocksize %u (unsupported)\n",
1634 sbi->s_frag_size, blocksize);
1635 goto failed_mount;
1636 }
1637 sbi->s_desc_size = le16_to_cpu(es->s_desc_size);
1638 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_64BIT)) {
1639 if (sbi->s_desc_size < EXT4_MIN_DESC_SIZE_64BIT ||
1640 sbi->s_desc_size > EXT4_MAX_DESC_SIZE ||
1641 sbi->s_desc_size & (sbi->s_desc_size - 1)) {
1642 printk(KERN_ERR
1643 "EXT4-fs: unsupported descriptor size %lu\n",
1644 sbi->s_desc_size);
1645 goto failed_mount;
1646 }
1647 } else
1648 sbi->s_desc_size = EXT4_MIN_DESC_SIZE;
1649 sbi->s_blocks_per_group = le32_to_cpu(es->s_blocks_per_group);
1650 sbi->s_frags_per_group = le32_to_cpu(es->s_frags_per_group);
1651 sbi->s_inodes_per_group = le32_to_cpu(es->s_inodes_per_group);
1652 if (EXT4_INODE_SIZE(sb) == 0)
1653 goto cantfind_ext4;
1654 sbi->s_inodes_per_block = blocksize / EXT4_INODE_SIZE(sb);
1655 if (sbi->s_inodes_per_block == 0)
1656 goto cantfind_ext4;
1657 sbi->s_itb_per_group = sbi->s_inodes_per_group /
1658 sbi->s_inodes_per_block;
1659 sbi->s_desc_per_block = blocksize / EXT4_DESC_SIZE(sb);
1660 sbi->s_sbh = bh;
1661 sbi->s_mount_state = le16_to_cpu(es->s_state);
1662 sbi->s_addr_per_block_bits = log2(EXT4_ADDR_PER_BLOCK(sb));
1663 sbi->s_desc_per_block_bits = log2(EXT4_DESC_PER_BLOCK(sb));
1664 for (i=0; i < 4; i++)
1665 sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]);
1666 sbi->s_def_hash_version = es->s_def_hash_version;
1667
1668 if (sbi->s_blocks_per_group > blocksize * 8) {
1669 printk (KERN_ERR
1670 "EXT4-fs: #blocks per group too big: %lu\n",
1671 sbi->s_blocks_per_group);
1672 goto failed_mount;
1673 }
1674 if (sbi->s_frags_per_group > blocksize * 8) {
1675 printk (KERN_ERR
1676 "EXT4-fs: #fragments per group too big: %lu\n",
1677 sbi->s_frags_per_group);
1678 goto failed_mount;
1679 }
1680 if (sbi->s_inodes_per_group > blocksize * 8) {
1681 printk (KERN_ERR
1682 "EXT4-fs: #inodes per group too big: %lu\n",
1683 sbi->s_inodes_per_group);
1684 goto failed_mount;
1685 }
1686
1687 if (ext4_blocks_count(es) >
1688 (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) {
1689 printk(KERN_ERR "EXT4-fs: filesystem on %s:"
1690 " too large to mount safely\n", sb->s_id);
1691 if (sizeof(sector_t) < 8)
1692 printk(KERN_WARNING "EXT4-fs: CONFIG_LBD not "
1693 "enabled\n");
1694 goto failed_mount;
1695 }
1696
1697 if (EXT4_BLOCKS_PER_GROUP(sb) == 0)
1698 goto cantfind_ext4;
1699 blocks_count = (ext4_blocks_count(es) -
1700 le32_to_cpu(es->s_first_data_block) +
1701 EXT4_BLOCKS_PER_GROUP(sb) - 1);
1702 do_div(blocks_count, EXT4_BLOCKS_PER_GROUP(sb));
1703 sbi->s_groups_count = blocks_count;
1704 db_count = (sbi->s_groups_count + EXT4_DESC_PER_BLOCK(sb) - 1) /
1705 EXT4_DESC_PER_BLOCK(sb);
1706 sbi->s_group_desc = kmalloc(db_count * sizeof (struct buffer_head *),
1707 GFP_KERNEL);
1708 if (sbi->s_group_desc == NULL) {
1709 printk (KERN_ERR "EXT4-fs: not enough memory\n");
1710 goto failed_mount;
1711 }
1712
1713 bgl_lock_init(&sbi->s_blockgroup_lock);
1714
1715 for (i = 0; i < db_count; i++) {
1716 block = descriptor_loc(sb, logical_sb_block, i);
1717 sbi->s_group_desc[i] = sb_bread(sb, block);
1718 if (!sbi->s_group_desc[i]) {
1719 printk (KERN_ERR "EXT4-fs: "
1720 "can't read group descriptor %d\n", i);
1721 db_count = i;
1722 goto failed_mount2;
1723 }
1724 }
1725 if (!ext4_check_descriptors (sb)) {
1726 printk(KERN_ERR "EXT4-fs: group descriptors corrupted!\n");
1727 goto failed_mount2;
1728 }
1729 sbi->s_gdb_count = db_count;
1730 get_random_bytes(&sbi->s_next_generation, sizeof(u32));
1731 spin_lock_init(&sbi->s_next_gen_lock);
1732
1733 percpu_counter_init(&sbi->s_freeblocks_counter,
1734 ext4_count_free_blocks(sb));
1735 percpu_counter_init(&sbi->s_freeinodes_counter,
1736 ext4_count_free_inodes(sb));
1737 percpu_counter_init(&sbi->s_dirs_counter,
1738 ext4_count_dirs(sb));
1739
1740 /* per fileystem reservation list head & lock */
1741 spin_lock_init(&sbi->s_rsv_window_lock);
1742 sbi->s_rsv_window_root = RB_ROOT;
1743 /* Add a single, static dummy reservation to the start of the
1744 * reservation window list --- it gives us a placeholder for
1745 * append-at-start-of-list which makes the allocation logic
1746 * _much_ simpler. */
1747 sbi->s_rsv_window_head.rsv_start = EXT4_RESERVE_WINDOW_NOT_ALLOCATED;
1748 sbi->s_rsv_window_head.rsv_end = EXT4_RESERVE_WINDOW_NOT_ALLOCATED;
1749 sbi->s_rsv_window_head.rsv_alloc_hit = 0;
1750 sbi->s_rsv_window_head.rsv_goal_size = 0;
1751 ext4_rsv_window_add(sb, &sbi->s_rsv_window_head);
1752
1753 /*
1754 * set up enough so that it can read an inode
1755 */
1756 sb->s_op = &ext4_sops;
1757 sb->s_export_op = &ext4_export_ops;
1758 sb->s_xattr = ext4_xattr_handlers;
1759#ifdef CONFIG_QUOTA
1760 sb->s_qcop = &ext4_qctl_operations;
1761 sb->dq_op = &ext4_quota_operations;
1762#endif
1763 INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */
1764
1765 sb->s_root = NULL;
1766
1767 needs_recovery = (es->s_last_orphan != 0 ||
1768 EXT4_HAS_INCOMPAT_FEATURE(sb,
1769 EXT4_FEATURE_INCOMPAT_RECOVER));
1770
1771 /*
1772 * The first inode we look at is the journal inode. Don't try
1773 * root first: it may be modified in the journal!
1774 */
1775 if (!test_opt(sb, NOLOAD) &&
1776 EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) {
1777 if (ext4_load_journal(sb, es, journal_devnum))
1778 goto failed_mount3;
1779 } else if (journal_inum) {
1780 if (ext4_create_journal(sb, es, journal_inum))
1781 goto failed_mount3;
1782 } else {
1783 if (!silent)
1784 printk (KERN_ERR
1785 "ext4: No journal on filesystem on %s\n",
1786 sb->s_id);
1787 goto failed_mount3;
1788 }
1789
1790 /* We have now updated the journal if required, so we can
1791 * validate the data journaling mode. */
1792 switch (test_opt(sb, DATA_FLAGS)) {
1793 case 0:
1794 /* No mode set, assume a default based on the journal
1795 * capabilities: ORDERED_DATA if the journal can
1796 * cope, else JOURNAL_DATA
1797 */
1798 if (jbd2_journal_check_available_features
1799 (sbi->s_journal, 0, 0, JBD2_FEATURE_INCOMPAT_REVOKE))
1800 set_opt(sbi->s_mount_opt, ORDERED_DATA);
1801 else
1802 set_opt(sbi->s_mount_opt, JOURNAL_DATA);
1803 break;
1804
1805 case EXT4_MOUNT_ORDERED_DATA:
1806 case EXT4_MOUNT_WRITEBACK_DATA:
1807 if (!jbd2_journal_check_available_features
1808 (sbi->s_journal, 0, 0, JBD2_FEATURE_INCOMPAT_REVOKE)) {
1809 printk(KERN_ERR "EXT4-fs: Journal does not support "
1810 "requested data journaling mode\n");
1811 goto failed_mount4;
1812 }
1813 default:
1814 break;
1815 }
1816
1817 if (test_opt(sb, NOBH)) {
1818 if (!(test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)) {
1819 printk(KERN_WARNING "EXT4-fs: Ignoring nobh option - "
1820 "its supported only with writeback mode\n");
1821 clear_opt(sbi->s_mount_opt, NOBH);
1822 }
1823 }
1824 /*
1825 * The jbd2_journal_load will have done any necessary log recovery,
1826 * so we can safely mount the rest of the filesystem now.
1827 */
1828
1829 root = iget(sb, EXT4_ROOT_INO);
1830 sb->s_root = d_alloc_root(root);
1831 if (!sb->s_root) {
1832 printk(KERN_ERR "EXT4-fs: get root inode failed\n");
1833 iput(root);
1834 goto failed_mount4;
1835 }
1836 if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) {
1837 dput(sb->s_root);
1838 sb->s_root = NULL;
1839 printk(KERN_ERR "EXT4-fs: corrupt root inode, run e2fsck\n");
1840 goto failed_mount4;
1841 }
1842
1843 ext4_setup_super (sb, es, sb->s_flags & MS_RDONLY);
1844 /*
1845 * akpm: core read_super() calls in here with the superblock locked.
1846 * That deadlocks, because orphan cleanup needs to lock the superblock
1847 * in numerous places. Here we just pop the lock - it's relatively
1848 * harmless, because we are now ready to accept write_super() requests,
1849 * and aviro says that's the only reason for hanging onto the
1850 * superblock lock.
1851 */
1852 EXT4_SB(sb)->s_mount_state |= EXT4_ORPHAN_FS;
1853 ext4_orphan_cleanup(sb, es);
1854 EXT4_SB(sb)->s_mount_state &= ~EXT4_ORPHAN_FS;
1855 if (needs_recovery)
1856 printk (KERN_INFO "EXT4-fs: recovery complete.\n");
1857 ext4_mark_recovery_complete(sb, es);
1858 printk (KERN_INFO "EXT4-fs: mounted filesystem with %s data mode.\n",
1859 test_opt(sb,DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA ? "journal":
1860 test_opt(sb,DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA ? "ordered":
1861 "writeback");
1862
1863 ext4_ext_init(sb);
1864
1865 lock_kernel();
1866 return 0;
1867
1868cantfind_ext4:
1869 if (!silent)
1870 printk(KERN_ERR "VFS: Can't find ext4 filesystem on dev %s.\n",
1871 sb->s_id);
1872 goto failed_mount;
1873
1874failed_mount4:
1875 jbd2_journal_destroy(sbi->s_journal);
1876failed_mount3:
1877 percpu_counter_destroy(&sbi->s_freeblocks_counter);
1878 percpu_counter_destroy(&sbi->s_freeinodes_counter);
1879 percpu_counter_destroy(&sbi->s_dirs_counter);
1880failed_mount2:
1881 for (i = 0; i < db_count; i++)
1882 brelse(sbi->s_group_desc[i]);
1883 kfree(sbi->s_group_desc);
1884failed_mount:
1885#ifdef CONFIG_QUOTA
1886 for (i = 0; i < MAXQUOTAS; i++)
1887 kfree(sbi->s_qf_names[i]);
1888#endif
1889 ext4_blkdev_remove(sbi);
1890 brelse(bh);
1891out_fail:
1892 sb->s_fs_info = NULL;
1893 kfree(sbi);
1894 lock_kernel();
1895 return -EINVAL;
1896}
1897
1898/*
1899 * Setup any per-fs journal parameters now. We'll do this both on
1900 * initial mount, once the journal has been initialised but before we've
1901 * done any recovery; and again on any subsequent remount.
1902 */
1903static void ext4_init_journal_params(struct super_block *sb, journal_t *journal)
1904{
1905 struct ext4_sb_info *sbi = EXT4_SB(sb);
1906
1907 if (sbi->s_commit_interval)
1908 journal->j_commit_interval = sbi->s_commit_interval;
1909 /* We could also set up an ext4-specific default for the commit
1910 * interval here, but for now we'll just fall back to the jbd
1911 * default. */
1912
1913 spin_lock(&journal->j_state_lock);
1914 if (test_opt(sb, BARRIER))
1915 journal->j_flags |= JBD2_BARRIER;
1916 else
1917 journal->j_flags &= ~JBD2_BARRIER;
1918 spin_unlock(&journal->j_state_lock);
1919}
1920
1921static journal_t *ext4_get_journal(struct super_block *sb,
1922 unsigned int journal_inum)
1923{
1924 struct inode *journal_inode;
1925 journal_t *journal;
1926
1927 /* First, test for the existence of a valid inode on disk. Bad
1928 * things happen if we iget() an unused inode, as the subsequent
1929 * iput() will try to delete it. */
1930
1931 journal_inode = iget(sb, journal_inum);
1932 if (!journal_inode) {
1933 printk(KERN_ERR "EXT4-fs: no journal found.\n");
1934 return NULL;
1935 }
1936 if (!journal_inode->i_nlink) {
1937 make_bad_inode(journal_inode);
1938 iput(journal_inode);
1939 printk(KERN_ERR "EXT4-fs: journal inode is deleted.\n");
1940 return NULL;
1941 }
1942
1943 jbd_debug(2, "Journal inode found at %p: %Ld bytes\n",
1944 journal_inode, journal_inode->i_size);
1945 if (is_bad_inode(journal_inode) || !S_ISREG(journal_inode->i_mode)) {
1946 printk(KERN_ERR "EXT4-fs: invalid journal inode.\n");
1947 iput(journal_inode);
1948 return NULL;
1949 }
1950
1951 journal = jbd2_journal_init_inode(journal_inode);
1952 if (!journal) {
1953 printk(KERN_ERR "EXT4-fs: Could not load journal inode\n");
1954 iput(journal_inode);
1955 return NULL;
1956 }
1957 journal->j_private = sb;
1958 ext4_init_journal_params(sb, journal);
1959 return journal;
1960}
1961
1962static journal_t *ext4_get_dev_journal(struct super_block *sb,
1963 dev_t j_dev)
1964{
1965 struct buffer_head * bh;
1966 journal_t *journal;
1967 ext4_fsblk_t start;
1968 ext4_fsblk_t len;
1969 int hblock, blocksize;
1970 ext4_fsblk_t sb_block;
1971 unsigned long offset;
1972 struct ext4_super_block * es;
1973 struct block_device *bdev;
1974
1975 bdev = ext4_blkdev_get(j_dev);
1976 if (bdev == NULL)
1977 return NULL;
1978
1979 if (bd_claim(bdev, sb)) {
1980 printk(KERN_ERR
1981 "EXT4: failed to claim external journal device.\n");
1982 blkdev_put(bdev);
1983 return NULL;
1984 }
1985
1986 blocksize = sb->s_blocksize;
1987 hblock = bdev_hardsect_size(bdev);
1988 if (blocksize < hblock) {
1989 printk(KERN_ERR
1990 "EXT4-fs: blocksize too small for journal device.\n");
1991 goto out_bdev;
1992 }
1993
1994 sb_block = EXT4_MIN_BLOCK_SIZE / blocksize;
1995 offset = EXT4_MIN_BLOCK_SIZE % blocksize;
1996 set_blocksize(bdev, blocksize);
1997 if (!(bh = __bread(bdev, sb_block, blocksize))) {
1998 printk(KERN_ERR "EXT4-fs: couldn't read superblock of "
1999 "external journal\n");
2000 goto out_bdev;
2001 }
2002
2003 es = (struct ext4_super_block *) (((char *)bh->b_data) + offset);
2004 if ((le16_to_cpu(es->s_magic) != EXT4_SUPER_MAGIC) ||
2005 !(le32_to_cpu(es->s_feature_incompat) &
2006 EXT4_FEATURE_INCOMPAT_JOURNAL_DEV)) {
2007 printk(KERN_ERR "EXT4-fs: external journal has "
2008 "bad superblock\n");
2009 brelse(bh);
2010 goto out_bdev;
2011 }
2012
2013 if (memcmp(EXT4_SB(sb)->s_es->s_journal_uuid, es->s_uuid, 16)) {
2014 printk(KERN_ERR "EXT4-fs: journal UUID does not match\n");
2015 brelse(bh);
2016 goto out_bdev;
2017 }
2018
2019 len = ext4_blocks_count(es);
2020 start = sb_block + 1;
2021 brelse(bh); /* we're done with the superblock */
2022
2023 journal = jbd2_journal_init_dev(bdev, sb->s_bdev,
2024 start, len, blocksize);
2025 if (!journal) {
2026 printk(KERN_ERR "EXT4-fs: failed to create device journal\n");
2027 goto out_bdev;
2028 }
2029 journal->j_private = sb;
2030 ll_rw_block(READ, 1, &journal->j_sb_buffer);
2031 wait_on_buffer(journal->j_sb_buffer);
2032 if (!buffer_uptodate(journal->j_sb_buffer)) {
2033 printk(KERN_ERR "EXT4-fs: I/O error on journal device\n");
2034 goto out_journal;
2035 }
2036 if (be32_to_cpu(journal->j_superblock->s_nr_users) != 1) {
2037 printk(KERN_ERR "EXT4-fs: External journal has more than one "
2038 "user (unsupported) - %d\n",
2039 be32_to_cpu(journal->j_superblock->s_nr_users));
2040 goto out_journal;
2041 }
2042 EXT4_SB(sb)->journal_bdev = bdev;
2043 ext4_init_journal_params(sb, journal);
2044 return journal;
2045out_journal:
2046 jbd2_journal_destroy(journal);
2047out_bdev:
2048 ext4_blkdev_put(bdev);
2049 return NULL;
2050}
2051
2052static int ext4_load_journal(struct super_block *sb,
2053 struct ext4_super_block *es,
2054 unsigned long journal_devnum)
2055{
2056 journal_t *journal;
2057 unsigned int journal_inum = le32_to_cpu(es->s_journal_inum);
2058 dev_t journal_dev;
2059 int err = 0;
2060 int really_read_only;
2061
2062 if (journal_devnum &&
2063 journal_devnum != le32_to_cpu(es->s_journal_dev)) {
2064 printk(KERN_INFO "EXT4-fs: external journal device major/minor "
2065 "numbers have changed\n");
2066 journal_dev = new_decode_dev(journal_devnum);
2067 } else
2068 journal_dev = new_decode_dev(le32_to_cpu(es->s_journal_dev));
2069
2070 really_read_only = bdev_read_only(sb->s_bdev);
2071
2072 /*
2073 * Are we loading a blank journal or performing recovery after a
2074 * crash? For recovery, we need to check in advance whether we
2075 * can get read-write access to the device.
2076 */
2077
2078 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) {
2079 if (sb->s_flags & MS_RDONLY) {
2080 printk(KERN_INFO "EXT4-fs: INFO: recovery "
2081 "required on readonly filesystem.\n");
2082 if (really_read_only) {
2083 printk(KERN_ERR "EXT4-fs: write access "
2084 "unavailable, cannot proceed.\n");
2085 return -EROFS;
2086 }
2087 printk (KERN_INFO "EXT4-fs: write access will "
2088 "be enabled during recovery.\n");
2089 }
2090 }
2091
2092 if (journal_inum && journal_dev) {
2093 printk(KERN_ERR "EXT4-fs: filesystem has both journal "
2094 "and inode journals!\n");
2095 return -EINVAL;
2096 }
2097
2098 if (journal_inum) {
2099 if (!(journal = ext4_get_journal(sb, journal_inum)))
2100 return -EINVAL;
2101 } else {
2102 if (!(journal = ext4_get_dev_journal(sb, journal_dev)))
2103 return -EINVAL;
2104 }
2105
2106 if (!really_read_only && test_opt(sb, UPDATE_JOURNAL)) {
2107 err = jbd2_journal_update_format(journal);
2108 if (err) {
2109 printk(KERN_ERR "EXT4-fs: error updating journal.\n");
2110 jbd2_journal_destroy(journal);
2111 return err;
2112 }
2113 }
2114
2115 if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER))
2116 err = jbd2_journal_wipe(journal, !really_read_only);
2117 if (!err)
2118 err = jbd2_journal_load(journal);
2119
2120 if (err) {
2121 printk(KERN_ERR "EXT4-fs: error loading journal.\n");
2122 jbd2_journal_destroy(journal);
2123 return err;
2124 }
2125
2126 EXT4_SB(sb)->s_journal = journal;
2127 ext4_clear_journal_err(sb, es);
2128
2129 if (journal_devnum &&
2130 journal_devnum != le32_to_cpu(es->s_journal_dev)) {
2131 es->s_journal_dev = cpu_to_le32(journal_devnum);
2132 sb->s_dirt = 1;
2133
2134 /* Make sure we flush the recovery flag to disk. */
2135 ext4_commit_super(sb, es, 1);
2136 }
2137
2138 return 0;
2139}
2140
2141static int ext4_create_journal(struct super_block * sb,
2142 struct ext4_super_block * es,
2143 unsigned int journal_inum)
2144{
2145 journal_t *journal;
2146
2147 if (sb->s_flags & MS_RDONLY) {
2148 printk(KERN_ERR "EXT4-fs: readonly filesystem when trying to "
2149 "create journal.\n");
2150 return -EROFS;
2151 }
2152
2153 if (!(journal = ext4_get_journal(sb, journal_inum)))
2154 return -EINVAL;
2155
2156 printk(KERN_INFO "EXT4-fs: creating new journal on inode %u\n",
2157 journal_inum);
2158
2159 if (jbd2_journal_create(journal)) {
2160 printk(KERN_ERR "EXT4-fs: error creating journal.\n");
2161 jbd2_journal_destroy(journal);
2162 return -EIO;
2163 }
2164
2165 EXT4_SB(sb)->s_journal = journal;
2166
2167 ext4_update_dynamic_rev(sb);
2168 EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
2169 EXT4_SET_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL);
2170
2171 es->s_journal_inum = cpu_to_le32(journal_inum);
2172 sb->s_dirt = 1;
2173
2174 /* Make sure we flush the recovery flag to disk. */
2175 ext4_commit_super(sb, es, 1);
2176
2177 return 0;
2178}
2179
2180static void ext4_commit_super (struct super_block * sb,
2181 struct ext4_super_block * es,
2182 int sync)
2183{
2184 struct buffer_head *sbh = EXT4_SB(sb)->s_sbh;
2185
2186 if (!sbh)
2187 return;
2188 es->s_wtime = cpu_to_le32(get_seconds());
2189 ext4_free_blocks_count_set(es, ext4_count_free_blocks(sb));
2190 es->s_free_inodes_count = cpu_to_le32(ext4_count_free_inodes(sb));
2191 BUFFER_TRACE(sbh, "marking dirty");
2192 mark_buffer_dirty(sbh);
2193 if (sync)
2194 sync_dirty_buffer(sbh);
2195}
2196
2197
2198/*
2199 * Have we just finished recovery? If so, and if we are mounting (or
2200 * remounting) the filesystem readonly, then we will end up with a
2201 * consistent fs on disk. Record that fact.
2202 */
2203static void ext4_mark_recovery_complete(struct super_block * sb,
2204 struct ext4_super_block * es)
2205{
2206 journal_t *journal = EXT4_SB(sb)->s_journal;
2207
2208 jbd2_journal_lock_updates(journal);
2209 jbd2_journal_flush(journal);
2210 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER) &&
2211 sb->s_flags & MS_RDONLY) {
2212 EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
2213 sb->s_dirt = 0;
2214 ext4_commit_super(sb, es, 1);
2215 }
2216 jbd2_journal_unlock_updates(journal);
2217}
2218
2219/*
2220 * If we are mounting (or read-write remounting) a filesystem whose journal
2221 * has recorded an error from a previous lifetime, move that error to the
2222 * main filesystem now.
2223 */
2224static void ext4_clear_journal_err(struct super_block * sb,
2225 struct ext4_super_block * es)
2226{
2227 journal_t *journal;
2228 int j_errno;
2229 const char *errstr;
2230
2231 journal = EXT4_SB(sb)->s_journal;
2232
2233 /*
2234 * Now check for any error status which may have been recorded in the
2235 * journal by a prior ext4_error() or ext4_abort()
2236 */
2237
2238 j_errno = jbd2_journal_errno(journal);
2239 if (j_errno) {
2240 char nbuf[16];
2241
2242 errstr = ext4_decode_error(sb, j_errno, nbuf);
2243 ext4_warning(sb, __FUNCTION__, "Filesystem error recorded "
2244 "from previous mount: %s", errstr);
2245 ext4_warning(sb, __FUNCTION__, "Marking fs in need of "
2246 "filesystem check.");
2247
2248 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS;
2249 es->s_state |= cpu_to_le16(EXT4_ERROR_FS);
2250 ext4_commit_super (sb, es, 1);
2251
2252 jbd2_journal_clear_err(journal);
2253 }
2254}
2255
2256/*
2257 * Force the running and committing transactions to commit,
2258 * and wait on the commit.
2259 */
2260int ext4_force_commit(struct super_block *sb)
2261{
2262 journal_t *journal;
2263 int ret;
2264
2265 if (sb->s_flags & MS_RDONLY)
2266 return 0;
2267
2268 journal = EXT4_SB(sb)->s_journal;
2269 sb->s_dirt = 0;
2270 ret = ext4_journal_force_commit(journal);
2271 return ret;
2272}
2273
2274/*
2275 * Ext4 always journals updates to the superblock itself, so we don't
2276 * have to propagate any other updates to the superblock on disk at this
2277 * point. Just start an async writeback to get the buffers on their way
2278 * to the disk.
2279 *
2280 * This implicitly triggers the writebehind on sync().
2281 */
2282
2283static void ext4_write_super (struct super_block * sb)
2284{
2285 if (mutex_trylock(&sb->s_lock) != 0)
2286 BUG();
2287 sb->s_dirt = 0;
2288}
2289
2290static int ext4_sync_fs(struct super_block *sb, int wait)
2291{
2292 tid_t target;
2293
2294 sb->s_dirt = 0;
2295 if (jbd2_journal_start_commit(EXT4_SB(sb)->s_journal, &target)) {
2296 if (wait)
2297 jbd2_log_wait_commit(EXT4_SB(sb)->s_journal, target);
2298 }
2299 return 0;
2300}
2301
2302/*
2303 * LVM calls this function before a (read-only) snapshot is created. This
2304 * gives us a chance to flush the journal completely and mark the fs clean.
2305 */
2306static void ext4_write_super_lockfs(struct super_block *sb)
2307{
2308 sb->s_dirt = 0;
2309
2310 if (!(sb->s_flags & MS_RDONLY)) {
2311 journal_t *journal = EXT4_SB(sb)->s_journal;
2312
2313 /* Now we set up the journal barrier. */
2314 jbd2_journal_lock_updates(journal);
2315 jbd2_journal_flush(journal);
2316
2317 /* Journal blocked and flushed, clear needs_recovery flag. */
2318 EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
2319 ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1);
2320 }
2321}
2322
2323/*
2324 * Called by LVM after the snapshot is done. We need to reset the RECOVER
2325 * flag here, even though the filesystem is not technically dirty yet.
2326 */
2327static void ext4_unlockfs(struct super_block *sb)
2328{
2329 if (!(sb->s_flags & MS_RDONLY)) {
2330 lock_super(sb);
2331 /* Reser the needs_recovery flag before the fs is unlocked. */
2332 EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
2333 ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1);
2334 unlock_super(sb);
2335 jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal);
2336 }
2337}
2338
2339static int ext4_remount (struct super_block * sb, int * flags, char * data)
2340{
2341 struct ext4_super_block * es;
2342 struct ext4_sb_info *sbi = EXT4_SB(sb);
2343 ext4_fsblk_t n_blocks_count = 0;
2344 unsigned long old_sb_flags;
2345 struct ext4_mount_options old_opts;
2346 int err;
2347#ifdef CONFIG_QUOTA
2348 int i;
2349#endif
2350
2351 /* Store the original options */
2352 old_sb_flags = sb->s_flags;
2353 old_opts.s_mount_opt = sbi->s_mount_opt;
2354 old_opts.s_resuid = sbi->s_resuid;
2355 old_opts.s_resgid = sbi->s_resgid;
2356 old_opts.s_commit_interval = sbi->s_commit_interval;
2357#ifdef CONFIG_QUOTA
2358 old_opts.s_jquota_fmt = sbi->s_jquota_fmt;
2359 for (i = 0; i < MAXQUOTAS; i++)
2360 old_opts.s_qf_names[i] = sbi->s_qf_names[i];
2361#endif
2362
2363 /*
2364 * Allow the "check" option to be passed as a remount option.
2365 */
2366 if (!parse_options(data, sb, NULL, NULL, &n_blocks_count, 1)) {
2367 err = -EINVAL;
2368 goto restore_opts;
2369 }
2370
2371 if (sbi->s_mount_opt & EXT4_MOUNT_ABORT)
2372 ext4_abort(sb, __FUNCTION__, "Abort forced by user");
2373
2374 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2375 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
2376
2377 es = sbi->s_es;
2378
2379 ext4_init_journal_params(sb, sbi->s_journal);
2380
2381 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY) ||
2382 n_blocks_count > ext4_blocks_count(es)) {
2383 if (sbi->s_mount_opt & EXT4_MOUNT_ABORT) {
2384 err = -EROFS;
2385 goto restore_opts;
2386 }
2387
2388 if (*flags & MS_RDONLY) {
2389 /*
2390 * First of all, the unconditional stuff we have to do
2391 * to disable replay of the journal when we next remount
2392 */
2393 sb->s_flags |= MS_RDONLY;
2394
2395 /*
2396 * OK, test if we are remounting a valid rw partition
2397 * readonly, and if so set the rdonly flag and then
2398 * mark the partition as valid again.
2399 */
2400 if (!(es->s_state & cpu_to_le16(EXT4_VALID_FS)) &&
2401 (sbi->s_mount_state & EXT4_VALID_FS))
2402 es->s_state = cpu_to_le16(sbi->s_mount_state);
2403
2404 ext4_mark_recovery_complete(sb, es);
2405 } else {
2406 __le32 ret;
2407 if ((ret = EXT4_HAS_RO_COMPAT_FEATURE(sb,
2408 ~EXT4_FEATURE_RO_COMPAT_SUPP))) {
2409 printk(KERN_WARNING "EXT4-fs: %s: couldn't "
2410 "remount RDWR because of unsupported "
2411 "optional features (%x).\n",
2412 sb->s_id, le32_to_cpu(ret));
2413 err = -EROFS;
2414 goto restore_opts;
2415 }
2416 /*
2417 * Mounting a RDONLY partition read-write, so reread
2418 * and store the current valid flag. (It may have
2419 * been changed by e2fsck since we originally mounted
2420 * the partition.)
2421 */
2422 ext4_clear_journal_err(sb, es);
2423 sbi->s_mount_state = le16_to_cpu(es->s_state);
2424 if ((err = ext4_group_extend(sb, es, n_blocks_count)))
2425 goto restore_opts;
2426 if (!ext4_setup_super (sb, es, 0))
2427 sb->s_flags &= ~MS_RDONLY;
2428 }
2429 }
2430#ifdef CONFIG_QUOTA
2431 /* Release old quota file names */
2432 for (i = 0; i < MAXQUOTAS; i++)
2433 if (old_opts.s_qf_names[i] &&
2434 old_opts.s_qf_names[i] != sbi->s_qf_names[i])
2435 kfree(old_opts.s_qf_names[i]);
2436#endif
2437 return 0;
2438restore_opts:
2439 sb->s_flags = old_sb_flags;
2440 sbi->s_mount_opt = old_opts.s_mount_opt;
2441 sbi->s_resuid = old_opts.s_resuid;
2442 sbi->s_resgid = old_opts.s_resgid;
2443 sbi->s_commit_interval = old_opts.s_commit_interval;
2444#ifdef CONFIG_QUOTA
2445 sbi->s_jquota_fmt = old_opts.s_jquota_fmt;
2446 for (i = 0; i < MAXQUOTAS; i++) {
2447 if (sbi->s_qf_names[i] &&
2448 old_opts.s_qf_names[i] != sbi->s_qf_names[i])
2449 kfree(sbi->s_qf_names[i]);
2450 sbi->s_qf_names[i] = old_opts.s_qf_names[i];
2451 }
2452#endif
2453 return err;
2454}
2455
2456static int ext4_statfs (struct dentry * dentry, struct kstatfs * buf)
2457{
2458 struct super_block *sb = dentry->d_sb;
2459 struct ext4_sb_info *sbi = EXT4_SB(sb);
2460 struct ext4_super_block *es = sbi->s_es;
2461 ext4_fsblk_t overhead;
2462 int i;
2463
2464 if (test_opt (sb, MINIX_DF))
2465 overhead = 0;
2466 else {
2467 unsigned long ngroups;
2468 ngroups = EXT4_SB(sb)->s_groups_count;
2469 smp_rmb();
2470
2471 /*
2472 * Compute the overhead (FS structures)
2473 */
2474
2475 /*
2476 * All of the blocks before first_data_block are
2477 * overhead
2478 */
2479 overhead = le32_to_cpu(es->s_first_data_block);
2480
2481 /*
2482 * Add the overhead attributed to the superblock and
2483 * block group descriptors. If the sparse superblocks
2484 * feature is turned on, then not all groups have this.
2485 */
2486 for (i = 0; i < ngroups; i++) {
2487 overhead += ext4_bg_has_super(sb, i) +
2488 ext4_bg_num_gdb(sb, i);
2489 cond_resched();
2490 }
2491
2492 /*
2493 * Every block group has an inode bitmap, a block
2494 * bitmap, and an inode table.
2495 */
2496 overhead += (ngroups * (2 + EXT4_SB(sb)->s_itb_per_group));
2497 }
2498
2499 buf->f_type = EXT4_SUPER_MAGIC;
2500 buf->f_bsize = sb->s_blocksize;
2501 buf->f_blocks = ext4_blocks_count(es) - overhead;
2502 buf->f_bfree = percpu_counter_sum(&sbi->s_freeblocks_counter);
2503 buf->f_bavail = buf->f_bfree - ext4_r_blocks_count(es);
2504 if (buf->f_bfree < ext4_r_blocks_count(es))
2505 buf->f_bavail = 0;
2506 buf->f_files = le32_to_cpu(es->s_inodes_count);
2507 buf->f_ffree = percpu_counter_sum(&sbi->s_freeinodes_counter);
2508 buf->f_namelen = EXT4_NAME_LEN;
2509 return 0;
2510}
2511
2512/* Helper function for writing quotas on sync - we need to start transaction before quota file
2513 * is locked for write. Otherwise the are possible deadlocks:
2514 * Process 1 Process 2
2515 * ext4_create() quota_sync()
2516 * jbd2_journal_start() write_dquot()
2517 * DQUOT_INIT() down(dqio_mutex)
2518 * down(dqio_mutex) jbd2_journal_start()
2519 *
2520 */
2521
2522#ifdef CONFIG_QUOTA
2523
2524static inline struct inode *dquot_to_inode(struct dquot *dquot)
2525{
2526 return sb_dqopt(dquot->dq_sb)->files[dquot->dq_type];
2527}
2528
2529static int ext4_dquot_initialize(struct inode *inode, int type)
2530{
2531 handle_t *handle;
2532 int ret, err;
2533
2534 /* We may create quota structure so we need to reserve enough blocks */
2535 handle = ext4_journal_start(inode, 2*EXT4_QUOTA_INIT_BLOCKS(inode->i_sb));
2536 if (IS_ERR(handle))
2537 return PTR_ERR(handle);
2538 ret = dquot_initialize(inode, type);
2539 err = ext4_journal_stop(handle);
2540 if (!ret)
2541 ret = err;
2542 return ret;
2543}
2544
2545static int ext4_dquot_drop(struct inode *inode)
2546{
2547 handle_t *handle;
2548 int ret, err;
2549
2550 /* We may delete quota structure so we need to reserve enough blocks */
2551 handle = ext4_journal_start(inode, 2*EXT4_QUOTA_DEL_BLOCKS(inode->i_sb));
2552 if (IS_ERR(handle))
2553 return PTR_ERR(handle);
2554 ret = dquot_drop(inode);
2555 err = ext4_journal_stop(handle);
2556 if (!ret)
2557 ret = err;
2558 return ret;
2559}
2560
2561static int ext4_write_dquot(struct dquot *dquot)
2562{
2563 int ret, err;
2564 handle_t *handle;
2565 struct inode *inode;
2566
2567 inode = dquot_to_inode(dquot);
2568 handle = ext4_journal_start(inode,
2569 EXT4_QUOTA_TRANS_BLOCKS(dquot->dq_sb));
2570 if (IS_ERR(handle))
2571 return PTR_ERR(handle);
2572 ret = dquot_commit(dquot);
2573 err = ext4_journal_stop(handle);
2574 if (!ret)
2575 ret = err;
2576 return ret;
2577}
2578
2579static int ext4_acquire_dquot(struct dquot *dquot)
2580{
2581 int ret, err;
2582 handle_t *handle;
2583
2584 handle = ext4_journal_start(dquot_to_inode(dquot),
2585 EXT4_QUOTA_INIT_BLOCKS(dquot->dq_sb));
2586 if (IS_ERR(handle))
2587 return PTR_ERR(handle);
2588 ret = dquot_acquire(dquot);
2589 err = ext4_journal_stop(handle);
2590 if (!ret)
2591 ret = err;
2592 return ret;
2593}
2594
2595static int ext4_release_dquot(struct dquot *dquot)
2596{
2597 int ret, err;
2598 handle_t *handle;
2599
2600 handle = ext4_journal_start(dquot_to_inode(dquot),
2601 EXT4_QUOTA_DEL_BLOCKS(dquot->dq_sb));
2602 if (IS_ERR(handle))
2603 return PTR_ERR(handle);
2604 ret = dquot_release(dquot);
2605 err = ext4_journal_stop(handle);
2606 if (!ret)
2607 ret = err;
2608 return ret;
2609}
2610
2611static int ext4_mark_dquot_dirty(struct dquot *dquot)
2612{
2613 /* Are we journalling quotas? */
2614 if (EXT4_SB(dquot->dq_sb)->s_qf_names[USRQUOTA] ||
2615 EXT4_SB(dquot->dq_sb)->s_qf_names[GRPQUOTA]) {
2616 dquot_mark_dquot_dirty(dquot);
2617 return ext4_write_dquot(dquot);
2618 } else {
2619 return dquot_mark_dquot_dirty(dquot);
2620 }
2621}
2622
2623static int ext4_write_info(struct super_block *sb, int type)
2624{
2625 int ret, err;
2626 handle_t *handle;
2627
2628 /* Data block + inode block */
2629 handle = ext4_journal_start(sb->s_root->d_inode, 2);
2630 if (IS_ERR(handle))
2631 return PTR_ERR(handle);
2632 ret = dquot_commit_info(sb, type);
2633 err = ext4_journal_stop(handle);
2634 if (!ret)
2635 ret = err;
2636 return ret;
2637}
2638
2639/*
2640 * Turn on quotas during mount time - we need to find
2641 * the quota file and such...
2642 */
2643static int ext4_quota_on_mount(struct super_block *sb, int type)
2644{
2645 return vfs_quota_on_mount(sb, EXT4_SB(sb)->s_qf_names[type],
2646 EXT4_SB(sb)->s_jquota_fmt, type);
2647}
2648
2649/*
2650 * Standard function to be called on quota_on
2651 */
2652static int ext4_quota_on(struct super_block *sb, int type, int format_id,
2653 char *path)
2654{
2655 int err;
2656 struct nameidata nd;
2657
2658 if (!test_opt(sb, QUOTA))
2659 return -EINVAL;
2660 /* Not journalling quota? */
2661 if (!EXT4_SB(sb)->s_qf_names[USRQUOTA] &&
2662 !EXT4_SB(sb)->s_qf_names[GRPQUOTA])
2663 return vfs_quota_on(sb, type, format_id, path);
2664 err = path_lookup(path, LOOKUP_FOLLOW, &nd);
2665 if (err)
2666 return err;
2667 /* Quotafile not on the same filesystem? */
2668 if (nd.mnt->mnt_sb != sb) {
2669 path_release(&nd);
2670 return -EXDEV;
2671 }
2672 /* Quotafile not of fs root? */
2673 if (nd.dentry->d_parent->d_inode != sb->s_root->d_inode)
2674 printk(KERN_WARNING
2675 "EXT4-fs: Quota file not on filesystem root. "
2676 "Journalled quota will not work.\n");
2677 path_release(&nd);
2678 return vfs_quota_on(sb, type, format_id, path);
2679}
2680
2681/* Read data from quotafile - avoid pagecache and such because we cannot afford
2682 * acquiring the locks... As quota files are never truncated and quota code
2683 * itself serializes the operations (and noone else should touch the files)
2684 * we don't have to be afraid of races */
2685static ssize_t ext4_quota_read(struct super_block *sb, int type, char *data,
2686 size_t len, loff_t off)
2687{
2688 struct inode *inode = sb_dqopt(sb)->files[type];
2689 sector_t blk = off >> EXT4_BLOCK_SIZE_BITS(sb);
2690 int err = 0;
2691 int offset = off & (sb->s_blocksize - 1);
2692 int tocopy;
2693 size_t toread;
2694 struct buffer_head *bh;
2695 loff_t i_size = i_size_read(inode);
2696
2697 if (off > i_size)
2698 return 0;
2699 if (off+len > i_size)
2700 len = i_size-off;
2701 toread = len;
2702 while (toread > 0) {
2703 tocopy = sb->s_blocksize - offset < toread ?
2704 sb->s_blocksize - offset : toread;
2705 bh = ext4_bread(NULL, inode, blk, 0, &err);
2706 if (err)
2707 return err;
2708 if (!bh) /* A hole? */
2709 memset(data, 0, tocopy);
2710 else
2711 memcpy(data, bh->b_data+offset, tocopy);
2712 brelse(bh);
2713 offset = 0;
2714 toread -= tocopy;
2715 data += tocopy;
2716 blk++;
2717 }
2718 return len;
2719}
2720
2721/* Write to quotafile (we know the transaction is already started and has
2722 * enough credits) */
2723static ssize_t ext4_quota_write(struct super_block *sb, int type,
2724 const char *data, size_t len, loff_t off)
2725{
2726 struct inode *inode = sb_dqopt(sb)->files[type];
2727 sector_t blk = off >> EXT4_BLOCK_SIZE_BITS(sb);
2728 int err = 0;
2729 int offset = off & (sb->s_blocksize - 1);
2730 int tocopy;
2731 int journal_quota = EXT4_SB(sb)->s_qf_names[type] != NULL;
2732 size_t towrite = len;
2733 struct buffer_head *bh;
2734 handle_t *handle = journal_current_handle();
2735
2736 mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA);
2737 while (towrite > 0) {
2738 tocopy = sb->s_blocksize - offset < towrite ?
2739 sb->s_blocksize - offset : towrite;
2740 bh = ext4_bread(handle, inode, blk, 1, &err);
2741 if (!bh)
2742 goto out;
2743 if (journal_quota) {
2744 err = ext4_journal_get_write_access(handle, bh);
2745 if (err) {
2746 brelse(bh);
2747 goto out;
2748 }
2749 }
2750 lock_buffer(bh);
2751 memcpy(bh->b_data+offset, data, tocopy);
2752 flush_dcache_page(bh->b_page);
2753 unlock_buffer(bh);
2754 if (journal_quota)
2755 err = ext4_journal_dirty_metadata(handle, bh);
2756 else {
2757 /* Always do at least ordered writes for quotas */
2758 err = ext4_journal_dirty_data(handle, bh);
2759 mark_buffer_dirty(bh);
2760 }
2761 brelse(bh);
2762 if (err)
2763 goto out;
2764 offset = 0;
2765 towrite -= tocopy;
2766 data += tocopy;
2767 blk++;
2768 }
2769out:
2770 if (len == towrite)
2771 return err;
2772 if (inode->i_size < off+len-towrite) {
2773 i_size_write(inode, off+len-towrite);
2774 EXT4_I(inode)->i_disksize = inode->i_size;
2775 }
2776 inode->i_version++;
2777 inode->i_mtime = inode->i_ctime = CURRENT_TIME;
2778 ext4_mark_inode_dirty(handle, inode);
2779 mutex_unlock(&inode->i_mutex);
2780 return len - towrite;
2781}
2782
2783#endif
2784
2785static int ext4_get_sb(struct file_system_type *fs_type,
2786 int flags, const char *dev_name, void *data, struct vfsmount *mnt)
2787{
2788 return get_sb_bdev(fs_type, flags, dev_name, data, ext4_fill_super, mnt);
2789}
2790
2791static struct file_system_type ext4dev_fs_type = {
2792 .owner = THIS_MODULE,
2793 .name = "ext4dev",
2794 .get_sb = ext4_get_sb,
2795 .kill_sb = kill_block_super,
2796 .fs_flags = FS_REQUIRES_DEV,
2797};
2798
2799static int __init init_ext4_fs(void)
2800{
2801 int err = init_ext4_xattr();
2802 if (err)
2803 return err;
2804 err = init_inodecache();
2805 if (err)
2806 goto out1;
2807 err = register_filesystem(&ext4dev_fs_type);
2808 if (err)
2809 goto out;
2810 return 0;
2811out:
2812 destroy_inodecache();
2813out1:
2814 exit_ext4_xattr();
2815 return err;
2816}
2817
2818static void __exit exit_ext4_fs(void)
2819{
2820 unregister_filesystem(&ext4dev_fs_type);
2821 destroy_inodecache();
2822 exit_ext4_xattr();
2823}
2824
2825MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others");
2826MODULE_DESCRIPTION("Fourth Extended Filesystem with extents");
2827MODULE_LICENSE("GPL");
2828module_init(init_ext4_fs)
2829module_exit(exit_ext4_fs)
diff --git a/fs/ext4/symlink.c b/fs/ext4/symlink.c
new file mode 100644
index 000000000000..fcf527286d75
--- /dev/null
+++ b/fs/ext4/symlink.c
@@ -0,0 +1,54 @@
1/*
2 * linux/fs/ext4/symlink.c
3 *
4 * Only fast symlinks left here - the rest is done by generic code. AV, 1999
5 *
6 * Copyright (C) 1992, 1993, 1994, 1995
7 * Remy Card (card@masi.ibp.fr)
8 * Laboratoire MASI - Institut Blaise Pascal
9 * Universite Pierre et Marie Curie (Paris VI)
10 *
11 * from
12 *
13 * linux/fs/minix/symlink.c
14 *
15 * Copyright (C) 1991, 1992 Linus Torvalds
16 *
17 * ext4 symlink handling code
18 */
19
20#include <linux/fs.h>
21#include <linux/jbd2.h>
22#include <linux/ext4_fs.h>
23#include <linux/namei.h>
24#include "xattr.h"
25
26static void * ext4_follow_link(struct dentry *dentry, struct nameidata *nd)
27{
28 struct ext4_inode_info *ei = EXT4_I(dentry->d_inode);
29 nd_set_link(nd, (char*)ei->i_data);
30 return NULL;
31}
32
33struct inode_operations ext4_symlink_inode_operations = {
34 .readlink = generic_readlink,
35 .follow_link = page_follow_link_light,
36 .put_link = page_put_link,
37#ifdef CONFIG_EXT4DEV_FS_XATTR
38 .setxattr = generic_setxattr,
39 .getxattr = generic_getxattr,
40 .listxattr = ext4_listxattr,
41 .removexattr = generic_removexattr,
42#endif
43};
44
45struct inode_operations ext4_fast_symlink_inode_operations = {
46 .readlink = generic_readlink,
47 .follow_link = ext4_follow_link,
48#ifdef CONFIG_EXT4DEV_FS_XATTR
49 .setxattr = generic_setxattr,
50 .getxattr = generic_getxattr,
51 .listxattr = ext4_listxattr,
52 .removexattr = generic_removexattr,
53#endif
54};
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
new file mode 100644
index 000000000000..63233cd946a7
--- /dev/null
+++ b/fs/ext4/xattr.c
@@ -0,0 +1,1317 @@
1/*
2 * linux/fs/ext4/xattr.c
3 *
4 * Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de>
5 *
6 * Fix by Harrison Xing <harrison@mountainviewdata.com>.
7 * Ext4 code with a lot of help from Eric Jarman <ejarman@acm.org>.
8 * Extended attributes for symlinks and special files added per
9 * suggestion of Luka Renko <luka.renko@hermes.si>.
10 * xattr consolidation Copyright (c) 2004 James Morris <jmorris@redhat.com>,
11 * Red Hat Inc.
12 * ea-in-inode support by Alex Tomas <alex@clusterfs.com> aka bzzz
13 * and Andreas Gruenbacher <agruen@suse.de>.
14 */
15
16/*
17 * Extended attributes are stored directly in inodes (on file systems with
18 * inodes bigger than 128 bytes) and on additional disk blocks. The i_file_acl
19 * field contains the block number if an inode uses an additional block. All
20 * attributes must fit in the inode and one additional block. Blocks that
21 * contain the identical set of attributes may be shared among several inodes.
22 * Identical blocks are detected by keeping a cache of blocks that have
23 * recently been accessed.
24 *
25 * The attributes in inodes and on blocks have a different header; the entries
26 * are stored in the same format:
27 *
28 * +------------------+
29 * | header |
30 * | entry 1 | |
31 * | entry 2 | | growing downwards
32 * | entry 3 | v
33 * | four null bytes |
34 * | . . . |
35 * | value 1 | ^
36 * | value 3 | | growing upwards
37 * | value 2 | |
38 * +------------------+
39 *
40 * The header is followed by multiple entry descriptors. In disk blocks, the
41 * entry descriptors are kept sorted. In inodes, they are unsorted. The
42 * attribute values are aligned to the end of the block in no specific order.
43 *
44 * Locking strategy
45 * ----------------
46 * EXT4_I(inode)->i_file_acl is protected by EXT4_I(inode)->xattr_sem.
47 * EA blocks are only changed if they are exclusive to an inode, so
48 * holding xattr_sem also means that nothing but the EA block's reference
49 * count can change. Multiple writers to the same block are synchronized
50 * by the buffer lock.
51 */
52
53#include <linux/init.h>
54#include <linux/fs.h>
55#include <linux/slab.h>
56#include <linux/ext4_jbd2.h>
57#include <linux/ext4_fs.h>
58#include <linux/mbcache.h>
59#include <linux/quotaops.h>
60#include <linux/rwsem.h>
61#include "xattr.h"
62#include "acl.h"
63
64#define BHDR(bh) ((struct ext4_xattr_header *)((bh)->b_data))
65#define ENTRY(ptr) ((struct ext4_xattr_entry *)(ptr))
66#define BFIRST(bh) ENTRY(BHDR(bh)+1)
67#define IS_LAST_ENTRY(entry) (*(__u32 *)(entry) == 0)
68
69#define IHDR(inode, raw_inode) \
70 ((struct ext4_xattr_ibody_header *) \
71 ((void *)raw_inode + \
72 EXT4_GOOD_OLD_INODE_SIZE + \
73 EXT4_I(inode)->i_extra_isize))
74#define IFIRST(hdr) ((struct ext4_xattr_entry *)((hdr)+1))
75
76#ifdef EXT4_XATTR_DEBUG
77# define ea_idebug(inode, f...) do { \
78 printk(KERN_DEBUG "inode %s:%lu: ", \
79 inode->i_sb->s_id, inode->i_ino); \
80 printk(f); \
81 printk("\n"); \
82 } while (0)
83# define ea_bdebug(bh, f...) do { \
84 char b[BDEVNAME_SIZE]; \
85 printk(KERN_DEBUG "block %s:%lu: ", \
86 bdevname(bh->b_bdev, b), \
87 (unsigned long) bh->b_blocknr); \
88 printk(f); \
89 printk("\n"); \
90 } while (0)
91#else
92# define ea_idebug(f...)
93# define ea_bdebug(f...)
94#endif
95
96static void ext4_xattr_cache_insert(struct buffer_head *);
97static struct buffer_head *ext4_xattr_cache_find(struct inode *,
98 struct ext4_xattr_header *,
99 struct mb_cache_entry **);
100static void ext4_xattr_rehash(struct ext4_xattr_header *,
101 struct ext4_xattr_entry *);
102
103static struct mb_cache *ext4_xattr_cache;
104
105static struct xattr_handler *ext4_xattr_handler_map[] = {
106 [EXT4_XATTR_INDEX_USER] = &ext4_xattr_user_handler,
107#ifdef CONFIG_EXT4DEV_FS_POSIX_ACL
108 [EXT4_XATTR_INDEX_POSIX_ACL_ACCESS] = &ext4_xattr_acl_access_handler,
109 [EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT] = &ext4_xattr_acl_default_handler,
110#endif
111 [EXT4_XATTR_INDEX_TRUSTED] = &ext4_xattr_trusted_handler,
112#ifdef CONFIG_EXT4DEV_FS_SECURITY
113 [EXT4_XATTR_INDEX_SECURITY] = &ext4_xattr_security_handler,
114#endif
115};
116
117struct xattr_handler *ext4_xattr_handlers[] = {
118 &ext4_xattr_user_handler,
119 &ext4_xattr_trusted_handler,
120#ifdef CONFIG_EXT4DEV_FS_POSIX_ACL
121 &ext4_xattr_acl_access_handler,
122 &ext4_xattr_acl_default_handler,
123#endif
124#ifdef CONFIG_EXT4DEV_FS_SECURITY
125 &ext4_xattr_security_handler,
126#endif
127 NULL
128};
129
130static inline struct xattr_handler *
131ext4_xattr_handler(int name_index)
132{
133 struct xattr_handler *handler = NULL;
134
135 if (name_index > 0 && name_index < ARRAY_SIZE(ext4_xattr_handler_map))
136 handler = ext4_xattr_handler_map[name_index];
137 return handler;
138}
139
140/*
141 * Inode operation listxattr()
142 *
143 * dentry->d_inode->i_mutex: don't care
144 */
145ssize_t
146ext4_listxattr(struct dentry *dentry, char *buffer, size_t size)
147{
148 return ext4_xattr_list(dentry->d_inode, buffer, size);
149}
150
151static int
152ext4_xattr_check_names(struct ext4_xattr_entry *entry, void *end)
153{
154 while (!IS_LAST_ENTRY(entry)) {
155 struct ext4_xattr_entry *next = EXT4_XATTR_NEXT(entry);
156 if ((void *)next >= end)
157 return -EIO;
158 entry = next;
159 }
160 return 0;
161}
162
163static inline int
164ext4_xattr_check_block(struct buffer_head *bh)
165{
166 int error;
167
168 if (BHDR(bh)->h_magic != cpu_to_le32(EXT4_XATTR_MAGIC) ||
169 BHDR(bh)->h_blocks != cpu_to_le32(1))
170 return -EIO;
171 error = ext4_xattr_check_names(BFIRST(bh), bh->b_data + bh->b_size);
172 return error;
173}
174
175static inline int
176ext4_xattr_check_entry(struct ext4_xattr_entry *entry, size_t size)
177{
178 size_t value_size = le32_to_cpu(entry->e_value_size);
179
180 if (entry->e_value_block != 0 || value_size > size ||
181 le16_to_cpu(entry->e_value_offs) + value_size > size)
182 return -EIO;
183 return 0;
184}
185
186static int
187ext4_xattr_find_entry(struct ext4_xattr_entry **pentry, int name_index,
188 const char *name, size_t size, int sorted)
189{
190 struct ext4_xattr_entry *entry;
191 size_t name_len;
192 int cmp = 1;
193
194 if (name == NULL)
195 return -EINVAL;
196 name_len = strlen(name);
197 entry = *pentry;
198 for (; !IS_LAST_ENTRY(entry); entry = EXT4_XATTR_NEXT(entry)) {
199 cmp = name_index - entry->e_name_index;
200 if (!cmp)
201 cmp = name_len - entry->e_name_len;
202 if (!cmp)
203 cmp = memcmp(name, entry->e_name, name_len);
204 if (cmp <= 0 && (sorted || cmp == 0))
205 break;
206 }
207 *pentry = entry;
208 if (!cmp && ext4_xattr_check_entry(entry, size))
209 return -EIO;
210 return cmp ? -ENODATA : 0;
211}
212
213static int
214ext4_xattr_block_get(struct inode *inode, int name_index, const char *name,
215 void *buffer, size_t buffer_size)
216{
217 struct buffer_head *bh = NULL;
218 struct ext4_xattr_entry *entry;
219 size_t size;
220 int error;
221
222 ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld",
223 name_index, name, buffer, (long)buffer_size);
224
225 error = -ENODATA;
226 if (!EXT4_I(inode)->i_file_acl)
227 goto cleanup;
228 ea_idebug(inode, "reading block %u", EXT4_I(inode)->i_file_acl);
229 bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);
230 if (!bh)
231 goto cleanup;
232 ea_bdebug(bh, "b_count=%d, refcount=%d",
233 atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount));
234 if (ext4_xattr_check_block(bh)) {
235bad_block: ext4_error(inode->i_sb, __FUNCTION__,
236 "inode %lu: bad block %llu", inode->i_ino,
237 EXT4_I(inode)->i_file_acl);
238 error = -EIO;
239 goto cleanup;
240 }
241 ext4_xattr_cache_insert(bh);
242 entry = BFIRST(bh);
243 error = ext4_xattr_find_entry(&entry, name_index, name, bh->b_size, 1);
244 if (error == -EIO)
245 goto bad_block;
246 if (error)
247 goto cleanup;
248 size = le32_to_cpu(entry->e_value_size);
249 if (buffer) {
250 error = -ERANGE;
251 if (size > buffer_size)
252 goto cleanup;
253 memcpy(buffer, bh->b_data + le16_to_cpu(entry->e_value_offs),
254 size);
255 }
256 error = size;
257
258cleanup:
259 brelse(bh);
260 return error;
261}
262
263static int
264ext4_xattr_ibody_get(struct inode *inode, int name_index, const char *name,
265 void *buffer, size_t buffer_size)
266{
267 struct ext4_xattr_ibody_header *header;
268 struct ext4_xattr_entry *entry;
269 struct ext4_inode *raw_inode;
270 struct ext4_iloc iloc;
271 size_t size;
272 void *end;
273 int error;
274
275 if (!(EXT4_I(inode)->i_state & EXT4_STATE_XATTR))
276 return -ENODATA;
277 error = ext4_get_inode_loc(inode, &iloc);
278 if (error)
279 return error;
280 raw_inode = ext4_raw_inode(&iloc);
281 header = IHDR(inode, raw_inode);
282 entry = IFIRST(header);
283 end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size;
284 error = ext4_xattr_check_names(entry, end);
285 if (error)
286 goto cleanup;
287 error = ext4_xattr_find_entry(&entry, name_index, name,
288 end - (void *)entry, 0);
289 if (error)
290 goto cleanup;
291 size = le32_to_cpu(entry->e_value_size);
292 if (buffer) {
293 error = -ERANGE;
294 if (size > buffer_size)
295 goto cleanup;
296 memcpy(buffer, (void *)IFIRST(header) +
297 le16_to_cpu(entry->e_value_offs), size);
298 }
299 error = size;
300
301cleanup:
302 brelse(iloc.bh);
303 return error;
304}
305
306/*
307 * ext4_xattr_get()
308 *
309 * Copy an extended attribute into the buffer
310 * provided, or compute the buffer size required.
311 * Buffer is NULL to compute the size of the buffer required.
312 *
313 * Returns a negative error number on failure, or the number of bytes
314 * used / required on success.
315 */
316int
317ext4_xattr_get(struct inode *inode, int name_index, const char *name,
318 void *buffer, size_t buffer_size)
319{
320 int error;
321
322 down_read(&EXT4_I(inode)->xattr_sem);
323 error = ext4_xattr_ibody_get(inode, name_index, name, buffer,
324 buffer_size);
325 if (error == -ENODATA)
326 error = ext4_xattr_block_get(inode, name_index, name, buffer,
327 buffer_size);
328 up_read(&EXT4_I(inode)->xattr_sem);
329 return error;
330}
331
332static int
333ext4_xattr_list_entries(struct inode *inode, struct ext4_xattr_entry *entry,
334 char *buffer, size_t buffer_size)
335{
336 size_t rest = buffer_size;
337
338 for (; !IS_LAST_ENTRY(entry); entry = EXT4_XATTR_NEXT(entry)) {
339 struct xattr_handler *handler =
340 ext4_xattr_handler(entry->e_name_index);
341
342 if (handler) {
343 size_t size = handler->list(inode, buffer, rest,
344 entry->e_name,
345 entry->e_name_len);
346 if (buffer) {
347 if (size > rest)
348 return -ERANGE;
349 buffer += size;
350 }
351 rest -= size;
352 }
353 }
354 return buffer_size - rest;
355}
356
357static int
358ext4_xattr_block_list(struct inode *inode, char *buffer, size_t buffer_size)
359{
360 struct buffer_head *bh = NULL;
361 int error;
362
363 ea_idebug(inode, "buffer=%p, buffer_size=%ld",
364 buffer, (long)buffer_size);
365
366 error = 0;
367 if (!EXT4_I(inode)->i_file_acl)
368 goto cleanup;
369 ea_idebug(inode, "reading block %u", EXT4_I(inode)->i_file_acl);
370 bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);
371 error = -EIO;
372 if (!bh)
373 goto cleanup;
374 ea_bdebug(bh, "b_count=%d, refcount=%d",
375 atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount));
376 if (ext4_xattr_check_block(bh)) {
377 ext4_error(inode->i_sb, __FUNCTION__,
378 "inode %lu: bad block %llu", inode->i_ino,
379 EXT4_I(inode)->i_file_acl);
380 error = -EIO;
381 goto cleanup;
382 }
383 ext4_xattr_cache_insert(bh);
384 error = ext4_xattr_list_entries(inode, BFIRST(bh), buffer, buffer_size);
385
386cleanup:
387 brelse(bh);
388
389 return error;
390}
391
392static int
393ext4_xattr_ibody_list(struct inode *inode, char *buffer, size_t buffer_size)
394{
395 struct ext4_xattr_ibody_header *header;
396 struct ext4_inode *raw_inode;
397 struct ext4_iloc iloc;
398 void *end;
399 int error;
400
401 if (!(EXT4_I(inode)->i_state & EXT4_STATE_XATTR))
402 return 0;
403 error = ext4_get_inode_loc(inode, &iloc);
404 if (error)
405 return error;
406 raw_inode = ext4_raw_inode(&iloc);
407 header = IHDR(inode, raw_inode);
408 end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size;
409 error = ext4_xattr_check_names(IFIRST(header), end);
410 if (error)
411 goto cleanup;
412 error = ext4_xattr_list_entries(inode, IFIRST(header),
413 buffer, buffer_size);
414
415cleanup:
416 brelse(iloc.bh);
417 return error;
418}
419
420/*
421 * ext4_xattr_list()
422 *
423 * Copy a list of attribute names into the buffer
424 * provided, or compute the buffer size required.
425 * Buffer is NULL to compute the size of the buffer required.
426 *
427 * Returns a negative error number on failure, or the number of bytes
428 * used / required on success.
429 */
430int
431ext4_xattr_list(struct inode *inode, char *buffer, size_t buffer_size)
432{
433 int i_error, b_error;
434
435 down_read(&EXT4_I(inode)->xattr_sem);
436 i_error = ext4_xattr_ibody_list(inode, buffer, buffer_size);
437 if (i_error < 0) {
438 b_error = 0;
439 } else {
440 if (buffer) {
441 buffer += i_error;
442 buffer_size -= i_error;
443 }
444 b_error = ext4_xattr_block_list(inode, buffer, buffer_size);
445 if (b_error < 0)
446 i_error = 0;
447 }
448 up_read(&EXT4_I(inode)->xattr_sem);
449 return i_error + b_error;
450}
451
452/*
453 * If the EXT4_FEATURE_COMPAT_EXT_ATTR feature of this file system is
454 * not set, set it.
455 */
456static void ext4_xattr_update_super_block(handle_t *handle,
457 struct super_block *sb)
458{
459 if (EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_EXT_ATTR))
460 return;
461
462 lock_super(sb);
463 if (ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh) == 0) {
464 EXT4_SB(sb)->s_es->s_feature_compat |=
465 cpu_to_le32(EXT4_FEATURE_COMPAT_EXT_ATTR);
466 sb->s_dirt = 1;
467 ext4_journal_dirty_metadata(handle, EXT4_SB(sb)->s_sbh);
468 }
469 unlock_super(sb);
470}
471
472/*
473 * Release the xattr block BH: If the reference count is > 1, decrement
474 * it; otherwise free the block.
475 */
476static void
477ext4_xattr_release_block(handle_t *handle, struct inode *inode,
478 struct buffer_head *bh)
479{
480 struct mb_cache_entry *ce = NULL;
481
482 ce = mb_cache_entry_get(ext4_xattr_cache, bh->b_bdev, bh->b_blocknr);
483 if (BHDR(bh)->h_refcount == cpu_to_le32(1)) {
484 ea_bdebug(bh, "refcount now=0; freeing");
485 if (ce)
486 mb_cache_entry_free(ce);
487 ext4_free_blocks(handle, inode, bh->b_blocknr, 1);
488 get_bh(bh);
489 ext4_forget(handle, 1, inode, bh, bh->b_blocknr);
490 } else {
491 if (ext4_journal_get_write_access(handle, bh) == 0) {
492 lock_buffer(bh);
493 BHDR(bh)->h_refcount = cpu_to_le32(
494 le32_to_cpu(BHDR(bh)->h_refcount) - 1);
495 ext4_journal_dirty_metadata(handle, bh);
496 if (IS_SYNC(inode))
497 handle->h_sync = 1;
498 DQUOT_FREE_BLOCK(inode, 1);
499 unlock_buffer(bh);
500 ea_bdebug(bh, "refcount now=%d; releasing",
501 le32_to_cpu(BHDR(bh)->h_refcount));
502 }
503 if (ce)
504 mb_cache_entry_release(ce);
505 }
506}
507
508struct ext4_xattr_info {
509 int name_index;
510 const char *name;
511 const void *value;
512 size_t value_len;
513};
514
515struct ext4_xattr_search {
516 struct ext4_xattr_entry *first;
517 void *base;
518 void *end;
519 struct ext4_xattr_entry *here;
520 int not_found;
521};
522
523static int
524ext4_xattr_set_entry(struct ext4_xattr_info *i, struct ext4_xattr_search *s)
525{
526 struct ext4_xattr_entry *last;
527 size_t free, min_offs = s->end - s->base, name_len = strlen(i->name);
528
529 /* Compute min_offs and last. */
530 last = s->first;
531 for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) {
532 if (!last->e_value_block && last->e_value_size) {
533 size_t offs = le16_to_cpu(last->e_value_offs);
534 if (offs < min_offs)
535 min_offs = offs;
536 }
537 }
538 free = min_offs - ((void *)last - s->base) - sizeof(__u32);
539 if (!s->not_found) {
540 if (!s->here->e_value_block && s->here->e_value_size) {
541 size_t size = le32_to_cpu(s->here->e_value_size);
542 free += EXT4_XATTR_SIZE(size);
543 }
544 free += EXT4_XATTR_LEN(name_len);
545 }
546 if (i->value) {
547 if (free < EXT4_XATTR_SIZE(i->value_len) ||
548 free < EXT4_XATTR_LEN(name_len) +
549 EXT4_XATTR_SIZE(i->value_len))
550 return -ENOSPC;
551 }
552
553 if (i->value && s->not_found) {
554 /* Insert the new name. */
555 size_t size = EXT4_XATTR_LEN(name_len);
556 size_t rest = (void *)last - (void *)s->here + sizeof(__u32);
557 memmove((void *)s->here + size, s->here, rest);
558 memset(s->here, 0, size);
559 s->here->e_name_index = i->name_index;
560 s->here->e_name_len = name_len;
561 memcpy(s->here->e_name, i->name, name_len);
562 } else {
563 if (!s->here->e_value_block && s->here->e_value_size) {
564 void *first_val = s->base + min_offs;
565 size_t offs = le16_to_cpu(s->here->e_value_offs);
566 void *val = s->base + offs;
567 size_t size = EXT4_XATTR_SIZE(
568 le32_to_cpu(s->here->e_value_size));
569
570 if (i->value && size == EXT4_XATTR_SIZE(i->value_len)) {
571 /* The old and the new value have the same
572 size. Just replace. */
573 s->here->e_value_size =
574 cpu_to_le32(i->value_len);
575 memset(val + size - EXT4_XATTR_PAD, 0,
576 EXT4_XATTR_PAD); /* Clear pad bytes. */
577 memcpy(val, i->value, i->value_len);
578 return 0;
579 }
580
581 /* Remove the old value. */
582 memmove(first_val + size, first_val, val - first_val);
583 memset(first_val, 0, size);
584 s->here->e_value_size = 0;
585 s->here->e_value_offs = 0;
586 min_offs += size;
587
588 /* Adjust all value offsets. */
589 last = s->first;
590 while (!IS_LAST_ENTRY(last)) {
591 size_t o = le16_to_cpu(last->e_value_offs);
592 if (!last->e_value_block &&
593 last->e_value_size && o < offs)
594 last->e_value_offs =
595 cpu_to_le16(o + size);
596 last = EXT4_XATTR_NEXT(last);
597 }
598 }
599 if (!i->value) {
600 /* Remove the old name. */
601 size_t size = EXT4_XATTR_LEN(name_len);
602 last = ENTRY((void *)last - size);
603 memmove(s->here, (void *)s->here + size,
604 (void *)last - (void *)s->here + sizeof(__u32));
605 memset(last, 0, size);
606 }
607 }
608
609 if (i->value) {
610 /* Insert the new value. */
611 s->here->e_value_size = cpu_to_le32(i->value_len);
612 if (i->value_len) {
613 size_t size = EXT4_XATTR_SIZE(i->value_len);
614 void *val = s->base + min_offs - size;
615 s->here->e_value_offs = cpu_to_le16(min_offs - size);
616 memset(val + size - EXT4_XATTR_PAD, 0,
617 EXT4_XATTR_PAD); /* Clear the pad bytes. */
618 memcpy(val, i->value, i->value_len);
619 }
620 }
621 return 0;
622}
623
624struct ext4_xattr_block_find {
625 struct ext4_xattr_search s;
626 struct buffer_head *bh;
627};
628
629static int
630ext4_xattr_block_find(struct inode *inode, struct ext4_xattr_info *i,
631 struct ext4_xattr_block_find *bs)
632{
633 struct super_block *sb = inode->i_sb;
634 int error;
635
636 ea_idebug(inode, "name=%d.%s, value=%p, value_len=%ld",
637 i->name_index, i->name, i->value, (long)i->value_len);
638
639 if (EXT4_I(inode)->i_file_acl) {
640 /* The inode already has an extended attribute block. */
641 bs->bh = sb_bread(sb, EXT4_I(inode)->i_file_acl);
642 error = -EIO;
643 if (!bs->bh)
644 goto cleanup;
645 ea_bdebug(bs->bh, "b_count=%d, refcount=%d",
646 atomic_read(&(bs->bh->b_count)),
647 le32_to_cpu(BHDR(bs->bh)->h_refcount));
648 if (ext4_xattr_check_block(bs->bh)) {
649 ext4_error(sb, __FUNCTION__,
650 "inode %lu: bad block %llu", inode->i_ino,
651 EXT4_I(inode)->i_file_acl);
652 error = -EIO;
653 goto cleanup;
654 }
655 /* Find the named attribute. */
656 bs->s.base = BHDR(bs->bh);
657 bs->s.first = BFIRST(bs->bh);
658 bs->s.end = bs->bh->b_data + bs->bh->b_size;
659 bs->s.here = bs->s.first;
660 error = ext4_xattr_find_entry(&bs->s.here, i->name_index,
661 i->name, bs->bh->b_size, 1);
662 if (error && error != -ENODATA)
663 goto cleanup;
664 bs->s.not_found = error;
665 }
666 error = 0;
667
668cleanup:
669 return error;
670}
671
672static int
673ext4_xattr_block_set(handle_t *handle, struct inode *inode,
674 struct ext4_xattr_info *i,
675 struct ext4_xattr_block_find *bs)
676{
677 struct super_block *sb = inode->i_sb;
678 struct buffer_head *new_bh = NULL;
679 struct ext4_xattr_search *s = &bs->s;
680 struct mb_cache_entry *ce = NULL;
681 int error;
682
683#define header(x) ((struct ext4_xattr_header *)(x))
684
685 if (i->value && i->value_len > sb->s_blocksize)
686 return -ENOSPC;
687 if (s->base) {
688 ce = mb_cache_entry_get(ext4_xattr_cache, bs->bh->b_bdev,
689 bs->bh->b_blocknr);
690 if (header(s->base)->h_refcount == cpu_to_le32(1)) {
691 if (ce) {
692 mb_cache_entry_free(ce);
693 ce = NULL;
694 }
695 ea_bdebug(bs->bh, "modifying in-place");
696 error = ext4_journal_get_write_access(handle, bs->bh);
697 if (error)
698 goto cleanup;
699 lock_buffer(bs->bh);
700 error = ext4_xattr_set_entry(i, s);
701 if (!error) {
702 if (!IS_LAST_ENTRY(s->first))
703 ext4_xattr_rehash(header(s->base),
704 s->here);
705 ext4_xattr_cache_insert(bs->bh);
706 }
707 unlock_buffer(bs->bh);
708 if (error == -EIO)
709 goto bad_block;
710 if (!error)
711 error = ext4_journal_dirty_metadata(handle,
712 bs->bh);
713 if (error)
714 goto cleanup;
715 goto inserted;
716 } else {
717 int offset = (char *)s->here - bs->bh->b_data;
718
719 if (ce) {
720 mb_cache_entry_release(ce);
721 ce = NULL;
722 }
723 ea_bdebug(bs->bh, "cloning");
724 s->base = kmalloc(bs->bh->b_size, GFP_KERNEL);
725 error = -ENOMEM;
726 if (s->base == NULL)
727 goto cleanup;
728 memcpy(s->base, BHDR(bs->bh), bs->bh->b_size);
729 s->first = ENTRY(header(s->base)+1);
730 header(s->base)->h_refcount = cpu_to_le32(1);
731 s->here = ENTRY(s->base + offset);
732 s->end = s->base + bs->bh->b_size;
733 }
734 } else {
735 /* Allocate a buffer where we construct the new block. */
736 s->base = kmalloc(sb->s_blocksize, GFP_KERNEL);
737 /* assert(header == s->base) */
738 error = -ENOMEM;
739 if (s->base == NULL)
740 goto cleanup;
741 memset(s->base, 0, sb->s_blocksize);
742 header(s->base)->h_magic = cpu_to_le32(EXT4_XATTR_MAGIC);
743 header(s->base)->h_blocks = cpu_to_le32(1);
744 header(s->base)->h_refcount = cpu_to_le32(1);
745 s->first = ENTRY(header(s->base)+1);
746 s->here = ENTRY(header(s->base)+1);
747 s->end = s->base + sb->s_blocksize;
748 }
749
750 error = ext4_xattr_set_entry(i, s);
751 if (error == -EIO)
752 goto bad_block;
753 if (error)
754 goto cleanup;
755 if (!IS_LAST_ENTRY(s->first))
756 ext4_xattr_rehash(header(s->base), s->here);
757
758inserted:
759 if (!IS_LAST_ENTRY(s->first)) {
760 new_bh = ext4_xattr_cache_find(inode, header(s->base), &ce);
761 if (new_bh) {
762 /* We found an identical block in the cache. */
763 if (new_bh == bs->bh)
764 ea_bdebug(new_bh, "keeping");
765 else {
766 /* The old block is released after updating
767 the inode. */
768 error = -EDQUOT;
769 if (DQUOT_ALLOC_BLOCK(inode, 1))
770 goto cleanup;
771 error = ext4_journal_get_write_access(handle,
772 new_bh);
773 if (error)
774 goto cleanup_dquot;
775 lock_buffer(new_bh);
776 BHDR(new_bh)->h_refcount = cpu_to_le32(1 +
777 le32_to_cpu(BHDR(new_bh)->h_refcount));
778 ea_bdebug(new_bh, "reusing; refcount now=%d",
779 le32_to_cpu(BHDR(new_bh)->h_refcount));
780 unlock_buffer(new_bh);
781 error = ext4_journal_dirty_metadata(handle,
782 new_bh);
783 if (error)
784 goto cleanup_dquot;
785 }
786 mb_cache_entry_release(ce);
787 ce = NULL;
788 } else if (bs->bh && s->base == bs->bh->b_data) {
789 /* We were modifying this block in-place. */
790 ea_bdebug(bs->bh, "keeping this block");
791 new_bh = bs->bh;
792 get_bh(new_bh);
793 } else {
794 /* We need to allocate a new block */
795 ext4_fsblk_t goal = le32_to_cpu(
796 EXT4_SB(sb)->s_es->s_first_data_block) +
797 (ext4_fsblk_t)EXT4_I(inode)->i_block_group *
798 EXT4_BLOCKS_PER_GROUP(sb);
799 ext4_fsblk_t block = ext4_new_block(handle, inode,
800 goal, &error);
801 if (error)
802 goto cleanup;
803 ea_idebug(inode, "creating block %d", block);
804
805 new_bh = sb_getblk(sb, block);
806 if (!new_bh) {
807getblk_failed:
808 ext4_free_blocks(handle, inode, block, 1);
809 error = -EIO;
810 goto cleanup;
811 }
812 lock_buffer(new_bh);
813 error = ext4_journal_get_create_access(handle, new_bh);
814 if (error) {
815 unlock_buffer(new_bh);
816 goto getblk_failed;
817 }
818 memcpy(new_bh->b_data, s->base, new_bh->b_size);
819 set_buffer_uptodate(new_bh);
820 unlock_buffer(new_bh);
821 ext4_xattr_cache_insert(new_bh);
822 error = ext4_journal_dirty_metadata(handle, new_bh);
823 if (error)
824 goto cleanup;
825 }
826 }
827
828 /* Update the inode. */
829 EXT4_I(inode)->i_file_acl = new_bh ? new_bh->b_blocknr : 0;
830
831 /* Drop the previous xattr block. */
832 if (bs->bh && bs->bh != new_bh)
833 ext4_xattr_release_block(handle, inode, bs->bh);
834 error = 0;
835
836cleanup:
837 if (ce)
838 mb_cache_entry_release(ce);
839 brelse(new_bh);
840 if (!(bs->bh && s->base == bs->bh->b_data))
841 kfree(s->base);
842
843 return error;
844
845cleanup_dquot:
846 DQUOT_FREE_BLOCK(inode, 1);
847 goto cleanup;
848
849bad_block:
850 ext4_error(inode->i_sb, __FUNCTION__,
851 "inode %lu: bad block %llu", inode->i_ino,
852 EXT4_I(inode)->i_file_acl);
853 goto cleanup;
854
855#undef header
856}
857
858struct ext4_xattr_ibody_find {
859 struct ext4_xattr_search s;
860 struct ext4_iloc iloc;
861};
862
863static int
864ext4_xattr_ibody_find(struct inode *inode, struct ext4_xattr_info *i,
865 struct ext4_xattr_ibody_find *is)
866{
867 struct ext4_xattr_ibody_header *header;
868 struct ext4_inode *raw_inode;
869 int error;
870
871 if (EXT4_I(inode)->i_extra_isize == 0)
872 return 0;
873 raw_inode = ext4_raw_inode(&is->iloc);
874 header = IHDR(inode, raw_inode);
875 is->s.base = is->s.first = IFIRST(header);
876 is->s.here = is->s.first;
877 is->s.end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size;
878 if (EXT4_I(inode)->i_state & EXT4_STATE_XATTR) {
879 error = ext4_xattr_check_names(IFIRST(header), is->s.end);
880 if (error)
881 return error;
882 /* Find the named attribute. */
883 error = ext4_xattr_find_entry(&is->s.here, i->name_index,
884 i->name, is->s.end -
885 (void *)is->s.base, 0);
886 if (error && error != -ENODATA)
887 return error;
888 is->s.not_found = error;
889 }
890 return 0;
891}
892
893static int
894ext4_xattr_ibody_set(handle_t *handle, struct inode *inode,
895 struct ext4_xattr_info *i,
896 struct ext4_xattr_ibody_find *is)
897{
898 struct ext4_xattr_ibody_header *header;
899 struct ext4_xattr_search *s = &is->s;
900 int error;
901
902 if (EXT4_I(inode)->i_extra_isize == 0)
903 return -ENOSPC;
904 error = ext4_xattr_set_entry(i, s);
905 if (error)
906 return error;
907 header = IHDR(inode, ext4_raw_inode(&is->iloc));
908 if (!IS_LAST_ENTRY(s->first)) {
909 header->h_magic = cpu_to_le32(EXT4_XATTR_MAGIC);
910 EXT4_I(inode)->i_state |= EXT4_STATE_XATTR;
911 } else {
912 header->h_magic = cpu_to_le32(0);
913 EXT4_I(inode)->i_state &= ~EXT4_STATE_XATTR;
914 }
915 return 0;
916}
917
918/*
919 * ext4_xattr_set_handle()
920 *
921 * Create, replace or remove an extended attribute for this inode. Buffer
922 * is NULL to remove an existing extended attribute, and non-NULL to
923 * either replace an existing extended attribute, or create a new extended
924 * attribute. The flags XATTR_REPLACE and XATTR_CREATE
925 * specify that an extended attribute must exist and must not exist
926 * previous to the call, respectively.
927 *
928 * Returns 0, or a negative error number on failure.
929 */
930int
931ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
932 const char *name, const void *value, size_t value_len,
933 int flags)
934{
935 struct ext4_xattr_info i = {
936 .name_index = name_index,
937 .name = name,
938 .value = value,
939 .value_len = value_len,
940
941 };
942 struct ext4_xattr_ibody_find is = {
943 .s = { .not_found = -ENODATA, },
944 };
945 struct ext4_xattr_block_find bs = {
946 .s = { .not_found = -ENODATA, },
947 };
948 int error;
949
950 if (!name)
951 return -EINVAL;
952 if (strlen(name) > 255)
953 return -ERANGE;
954 down_write(&EXT4_I(inode)->xattr_sem);
955 error = ext4_get_inode_loc(inode, &is.iloc);
956 if (error)
957 goto cleanup;
958
959 if (EXT4_I(inode)->i_state & EXT4_STATE_NEW) {
960 struct ext4_inode *raw_inode = ext4_raw_inode(&is.iloc);
961 memset(raw_inode, 0, EXT4_SB(inode->i_sb)->s_inode_size);
962 EXT4_I(inode)->i_state &= ~EXT4_STATE_NEW;
963 }
964
965 error = ext4_xattr_ibody_find(inode, &i, &is);
966 if (error)
967 goto cleanup;
968 if (is.s.not_found)
969 error = ext4_xattr_block_find(inode, &i, &bs);
970 if (error)
971 goto cleanup;
972 if (is.s.not_found && bs.s.not_found) {
973 error = -ENODATA;
974 if (flags & XATTR_REPLACE)
975 goto cleanup;
976 error = 0;
977 if (!value)
978 goto cleanup;
979 } else {
980 error = -EEXIST;
981 if (flags & XATTR_CREATE)
982 goto cleanup;
983 }
984 error = ext4_journal_get_write_access(handle, is.iloc.bh);
985 if (error)
986 goto cleanup;
987 if (!value) {
988 if (!is.s.not_found)
989 error = ext4_xattr_ibody_set(handle, inode, &i, &is);
990 else if (!bs.s.not_found)
991 error = ext4_xattr_block_set(handle, inode, &i, &bs);
992 } else {
993 error = ext4_xattr_ibody_set(handle, inode, &i, &is);
994 if (!error && !bs.s.not_found) {
995 i.value = NULL;
996 error = ext4_xattr_block_set(handle, inode, &i, &bs);
997 } else if (error == -ENOSPC) {
998 error = ext4_xattr_block_set(handle, inode, &i, &bs);
999 if (error)
1000 goto cleanup;
1001 if (!is.s.not_found) {
1002 i.value = NULL;
1003 error = ext4_xattr_ibody_set(handle, inode, &i,
1004 &is);
1005 }
1006 }
1007 }
1008 if (!error) {
1009 ext4_xattr_update_super_block(handle, inode->i_sb);
1010 inode->i_ctime = CURRENT_TIME_SEC;
1011 error = ext4_mark_iloc_dirty(handle, inode, &is.iloc);
1012 /*
1013 * The bh is consumed by ext4_mark_iloc_dirty, even with
1014 * error != 0.
1015 */
1016 is.iloc.bh = NULL;
1017 if (IS_SYNC(inode))
1018 handle->h_sync = 1;
1019 }
1020
1021cleanup:
1022 brelse(is.iloc.bh);
1023 brelse(bs.bh);
1024 up_write(&EXT4_I(inode)->xattr_sem);
1025 return error;
1026}
1027
1028/*
1029 * ext4_xattr_set()
1030 *
1031 * Like ext4_xattr_set_handle, but start from an inode. This extended
1032 * attribute modification is a filesystem transaction by itself.
1033 *
1034 * Returns 0, or a negative error number on failure.
1035 */
1036int
1037ext4_xattr_set(struct inode *inode, int name_index, const char *name,
1038 const void *value, size_t value_len, int flags)
1039{
1040 handle_t *handle;
1041 int error, retries = 0;
1042
1043retry:
1044 handle = ext4_journal_start(inode, EXT4_DATA_TRANS_BLOCKS(inode->i_sb));
1045 if (IS_ERR(handle)) {
1046 error = PTR_ERR(handle);
1047 } else {
1048 int error2;
1049
1050 error = ext4_xattr_set_handle(handle, inode, name_index, name,
1051 value, value_len, flags);
1052 error2 = ext4_journal_stop(handle);
1053 if (error == -ENOSPC &&
1054 ext4_should_retry_alloc(inode->i_sb, &retries))
1055 goto retry;
1056 if (error == 0)
1057 error = error2;
1058 }
1059
1060 return error;
1061}
1062
1063/*
1064 * ext4_xattr_delete_inode()
1065 *
1066 * Free extended attribute resources associated with this inode. This
1067 * is called immediately before an inode is freed. We have exclusive
1068 * access to the inode.
1069 */
1070void
1071ext4_xattr_delete_inode(handle_t *handle, struct inode *inode)
1072{
1073 struct buffer_head *bh = NULL;
1074
1075 if (!EXT4_I(inode)->i_file_acl)
1076 goto cleanup;
1077 bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);
1078 if (!bh) {
1079 ext4_error(inode->i_sb, __FUNCTION__,
1080 "inode %lu: block %llu read error", inode->i_ino,
1081 EXT4_I(inode)->i_file_acl);
1082 goto cleanup;
1083 }
1084 if (BHDR(bh)->h_magic != cpu_to_le32(EXT4_XATTR_MAGIC) ||
1085 BHDR(bh)->h_blocks != cpu_to_le32(1)) {
1086 ext4_error(inode->i_sb, __FUNCTION__,
1087 "inode %lu: bad block %llu", inode->i_ino,
1088 EXT4_I(inode)->i_file_acl);
1089 goto cleanup;
1090 }
1091 ext4_xattr_release_block(handle, inode, bh);
1092 EXT4_I(inode)->i_file_acl = 0;
1093
1094cleanup:
1095 brelse(bh);
1096}
1097
1098/*
1099 * ext4_xattr_put_super()
1100 *
1101 * This is called when a file system is unmounted.
1102 */
1103void
1104ext4_xattr_put_super(struct super_block *sb)
1105{
1106 mb_cache_shrink(sb->s_bdev);
1107}
1108
1109/*
1110 * ext4_xattr_cache_insert()
1111 *
1112 * Create a new entry in the extended attribute cache, and insert
1113 * it unless such an entry is already in the cache.
1114 *
1115 * Returns 0, or a negative error number on failure.
1116 */
1117static void
1118ext4_xattr_cache_insert(struct buffer_head *bh)
1119{
1120 __u32 hash = le32_to_cpu(BHDR(bh)->h_hash);
1121 struct mb_cache_entry *ce;
1122 int error;
1123
1124 ce = mb_cache_entry_alloc(ext4_xattr_cache);
1125 if (!ce) {
1126 ea_bdebug(bh, "out of memory");
1127 return;
1128 }
1129 error = mb_cache_entry_insert(ce, bh->b_bdev, bh->b_blocknr, &hash);
1130 if (error) {
1131 mb_cache_entry_free(ce);
1132 if (error == -EBUSY) {
1133 ea_bdebug(bh, "already in cache");
1134 error = 0;
1135 }
1136 } else {
1137 ea_bdebug(bh, "inserting [%x]", (int)hash);
1138 mb_cache_entry_release(ce);
1139 }
1140}
1141
1142/*
1143 * ext4_xattr_cmp()
1144 *
1145 * Compare two extended attribute blocks for equality.
1146 *
1147 * Returns 0 if the blocks are equal, 1 if they differ, and
1148 * a negative error number on errors.
1149 */
1150static int
1151ext4_xattr_cmp(struct ext4_xattr_header *header1,
1152 struct ext4_xattr_header *header2)
1153{
1154 struct ext4_xattr_entry *entry1, *entry2;
1155
1156 entry1 = ENTRY(header1+1);
1157 entry2 = ENTRY(header2+1);
1158 while (!IS_LAST_ENTRY(entry1)) {
1159 if (IS_LAST_ENTRY(entry2))
1160 return 1;
1161 if (entry1->e_hash != entry2->e_hash ||
1162 entry1->e_name_index != entry2->e_name_index ||
1163 entry1->e_name_len != entry2->e_name_len ||
1164 entry1->e_value_size != entry2->e_value_size ||
1165 memcmp(entry1->e_name, entry2->e_name, entry1->e_name_len))
1166 return 1;
1167 if (entry1->e_value_block != 0 || entry2->e_value_block != 0)
1168 return -EIO;
1169 if (memcmp((char *)header1 + le16_to_cpu(entry1->e_value_offs),
1170 (char *)header2 + le16_to_cpu(entry2->e_value_offs),
1171 le32_to_cpu(entry1->e_value_size)))
1172 return 1;
1173
1174 entry1 = EXT4_XATTR_NEXT(entry1);
1175 entry2 = EXT4_XATTR_NEXT(entry2);
1176 }
1177 if (!IS_LAST_ENTRY(entry2))
1178 return 1;
1179 return 0;
1180}
1181
1182/*
1183 * ext4_xattr_cache_find()
1184 *
1185 * Find an identical extended attribute block.
1186 *
1187 * Returns a pointer to the block found, or NULL if such a block was
1188 * not found or an error occurred.
1189 */
1190static struct buffer_head *
1191ext4_xattr_cache_find(struct inode *inode, struct ext4_xattr_header *header,
1192 struct mb_cache_entry **pce)
1193{
1194 __u32 hash = le32_to_cpu(header->h_hash);
1195 struct mb_cache_entry *ce;
1196
1197 if (!header->h_hash)
1198 return NULL; /* never share */
1199 ea_idebug(inode, "looking for cached blocks [%x]", (int)hash);
1200again:
1201 ce = mb_cache_entry_find_first(ext4_xattr_cache, 0,
1202 inode->i_sb->s_bdev, hash);
1203 while (ce) {
1204 struct buffer_head *bh;
1205
1206 if (IS_ERR(ce)) {
1207 if (PTR_ERR(ce) == -EAGAIN)
1208 goto again;
1209 break;
1210 }
1211 bh = sb_bread(inode->i_sb, ce->e_block);
1212 if (!bh) {
1213 ext4_error(inode->i_sb, __FUNCTION__,
1214 "inode %lu: block %lu read error",
1215 inode->i_ino, (unsigned long) ce->e_block);
1216 } else if (le32_to_cpu(BHDR(bh)->h_refcount) >=
1217 EXT4_XATTR_REFCOUNT_MAX) {
1218 ea_idebug(inode, "block %lu refcount %d>=%d",
1219 (unsigned long) ce->e_block,
1220 le32_to_cpu(BHDR(bh)->h_refcount),
1221 EXT4_XATTR_REFCOUNT_MAX);
1222 } else if (ext4_xattr_cmp(header, BHDR(bh)) == 0) {
1223 *pce = ce;
1224 return bh;
1225 }
1226 brelse(bh);
1227 ce = mb_cache_entry_find_next(ce, 0, inode->i_sb->s_bdev, hash);
1228 }
1229 return NULL;
1230}
1231
1232#define NAME_HASH_SHIFT 5
1233#define VALUE_HASH_SHIFT 16
1234
1235/*
1236 * ext4_xattr_hash_entry()
1237 *
1238 * Compute the hash of an extended attribute.
1239 */
1240static inline void ext4_xattr_hash_entry(struct ext4_xattr_header *header,
1241 struct ext4_xattr_entry *entry)
1242{
1243 __u32 hash = 0;
1244 char *name = entry->e_name;
1245 int n;
1246
1247 for (n=0; n < entry->e_name_len; n++) {
1248 hash = (hash << NAME_HASH_SHIFT) ^
1249 (hash >> (8*sizeof(hash) - NAME_HASH_SHIFT)) ^
1250 *name++;
1251 }
1252
1253 if (entry->e_value_block == 0 && entry->e_value_size != 0) {
1254 __le32 *value = (__le32 *)((char *)header +
1255 le16_to_cpu(entry->e_value_offs));
1256 for (n = (le32_to_cpu(entry->e_value_size) +
1257 EXT4_XATTR_ROUND) >> EXT4_XATTR_PAD_BITS; n; n--) {
1258 hash = (hash << VALUE_HASH_SHIFT) ^
1259 (hash >> (8*sizeof(hash) - VALUE_HASH_SHIFT)) ^
1260 le32_to_cpu(*value++);
1261 }
1262 }
1263 entry->e_hash = cpu_to_le32(hash);
1264}
1265
1266#undef NAME_HASH_SHIFT
1267#undef VALUE_HASH_SHIFT
1268
1269#define BLOCK_HASH_SHIFT 16
1270
1271/*
1272 * ext4_xattr_rehash()
1273 *
1274 * Re-compute the extended attribute hash value after an entry has changed.
1275 */
1276static void ext4_xattr_rehash(struct ext4_xattr_header *header,
1277 struct ext4_xattr_entry *entry)
1278{
1279 struct ext4_xattr_entry *here;
1280 __u32 hash = 0;
1281
1282 ext4_xattr_hash_entry(header, entry);
1283 here = ENTRY(header+1);
1284 while (!IS_LAST_ENTRY(here)) {
1285 if (!here->e_hash) {
1286 /* Block is not shared if an entry's hash value == 0 */
1287 hash = 0;
1288 break;
1289 }
1290 hash = (hash << BLOCK_HASH_SHIFT) ^
1291 (hash >> (8*sizeof(hash) - BLOCK_HASH_SHIFT)) ^
1292 le32_to_cpu(here->e_hash);
1293 here = EXT4_XATTR_NEXT(here);
1294 }
1295 header->h_hash = cpu_to_le32(hash);
1296}
1297
1298#undef BLOCK_HASH_SHIFT
1299
1300int __init
1301init_ext4_xattr(void)
1302{
1303 ext4_xattr_cache = mb_cache_create("ext4_xattr", NULL,
1304 sizeof(struct mb_cache_entry) +
1305 sizeof(((struct mb_cache_entry *) 0)->e_indexes[0]), 1, 6);
1306 if (!ext4_xattr_cache)
1307 return -ENOMEM;
1308 return 0;
1309}
1310
1311void
1312exit_ext4_xattr(void)
1313{
1314 if (ext4_xattr_cache)
1315 mb_cache_destroy(ext4_xattr_cache);
1316 ext4_xattr_cache = NULL;
1317}
diff --git a/fs/ext4/xattr.h b/fs/ext4/xattr.h
new file mode 100644
index 000000000000..79432b35398f
--- /dev/null
+++ b/fs/ext4/xattr.h
@@ -0,0 +1,145 @@
1/*
2 File: fs/ext4/xattr.h
3
4 On-disk format of extended attributes for the ext4 filesystem.
5
6 (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
7*/
8
9#include <linux/xattr.h>
10
11/* Magic value in attribute blocks */
12#define EXT4_XATTR_MAGIC 0xEA020000
13
14/* Maximum number of references to one attribute block */
15#define EXT4_XATTR_REFCOUNT_MAX 1024
16
17/* Name indexes */
18#define EXT4_XATTR_INDEX_USER 1
19#define EXT4_XATTR_INDEX_POSIX_ACL_ACCESS 2
20#define EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT 3
21#define EXT4_XATTR_INDEX_TRUSTED 4
22#define EXT4_XATTR_INDEX_LUSTRE 5
23#define EXT4_XATTR_INDEX_SECURITY 6
24
25struct ext4_xattr_header {
26 __le32 h_magic; /* magic number for identification */
27 __le32 h_refcount; /* reference count */
28 __le32 h_blocks; /* number of disk blocks used */
29 __le32 h_hash; /* hash value of all attributes */
30 __u32 h_reserved[4]; /* zero right now */
31};
32
33struct ext4_xattr_ibody_header {
34 __le32 h_magic; /* magic number for identification */
35};
36
37struct ext4_xattr_entry {
38 __u8 e_name_len; /* length of name */
39 __u8 e_name_index; /* attribute name index */
40 __le16 e_value_offs; /* offset in disk block of value */
41 __le32 e_value_block; /* disk block attribute is stored on (n/i) */
42 __le32 e_value_size; /* size of attribute value */
43 __le32 e_hash; /* hash value of name and value */
44 char e_name[0]; /* attribute name */
45};
46
47#define EXT4_XATTR_PAD_BITS 2
48#define EXT4_XATTR_PAD (1<<EXT4_XATTR_PAD_BITS)
49#define EXT4_XATTR_ROUND (EXT4_XATTR_PAD-1)
50#define EXT4_XATTR_LEN(name_len) \
51 (((name_len) + EXT4_XATTR_ROUND + \
52 sizeof(struct ext4_xattr_entry)) & ~EXT4_XATTR_ROUND)
53#define EXT4_XATTR_NEXT(entry) \
54 ( (struct ext4_xattr_entry *)( \
55 (char *)(entry) + EXT4_XATTR_LEN((entry)->e_name_len)) )
56#define EXT4_XATTR_SIZE(size) \
57 (((size) + EXT4_XATTR_ROUND) & ~EXT4_XATTR_ROUND)
58
59# ifdef CONFIG_EXT4DEV_FS_XATTR
60
61extern struct xattr_handler ext4_xattr_user_handler;
62extern struct xattr_handler ext4_xattr_trusted_handler;
63extern struct xattr_handler ext4_xattr_acl_access_handler;
64extern struct xattr_handler ext4_xattr_acl_default_handler;
65extern struct xattr_handler ext4_xattr_security_handler;
66
67extern ssize_t ext4_listxattr(struct dentry *, char *, size_t);
68
69extern int ext4_xattr_get(struct inode *, int, const char *, void *, size_t);
70extern int ext4_xattr_list(struct inode *, char *, size_t);
71extern int ext4_xattr_set(struct inode *, int, const char *, const void *, size_t, int);
72extern int ext4_xattr_set_handle(handle_t *, struct inode *, int, const char *, const void *, size_t, int);
73
74extern void ext4_xattr_delete_inode(handle_t *, struct inode *);
75extern void ext4_xattr_put_super(struct super_block *);
76
77extern int init_ext4_xattr(void);
78extern void exit_ext4_xattr(void);
79
80extern struct xattr_handler *ext4_xattr_handlers[];
81
82# else /* CONFIG_EXT4DEV_FS_XATTR */
83
84static inline int
85ext4_xattr_get(struct inode *inode, int name_index, const char *name,
86 void *buffer, size_t size, int flags)
87{
88 return -EOPNOTSUPP;
89}
90
91static inline int
92ext4_xattr_list(struct inode *inode, void *buffer, size_t size)
93{
94 return -EOPNOTSUPP;
95}
96
97static inline int
98ext4_xattr_set(struct inode *inode, int name_index, const char *name,
99 const void *value, size_t size, int flags)
100{
101 return -EOPNOTSUPP;
102}
103
104static inline int
105ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
106 const char *name, const void *value, size_t size, int flags)
107{
108 return -EOPNOTSUPP;
109}
110
111static inline void
112ext4_xattr_delete_inode(handle_t *handle, struct inode *inode)
113{
114}
115
116static inline void
117ext4_xattr_put_super(struct super_block *sb)
118{
119}
120
121static inline int
122init_ext4_xattr(void)
123{
124 return 0;
125}
126
127static inline void
128exit_ext4_xattr(void)
129{
130}
131
132#define ext4_xattr_handlers NULL
133
134# endif /* CONFIG_EXT4DEV_FS_XATTR */
135
136#ifdef CONFIG_EXT4DEV_FS_SECURITY
137extern int ext4_init_security(handle_t *handle, struct inode *inode,
138 struct inode *dir);
139#else
140static inline int ext4_init_security(handle_t *handle, struct inode *inode,
141 struct inode *dir)
142{
143 return 0;
144}
145#endif
diff --git a/fs/ext4/xattr_security.c b/fs/ext4/xattr_security.c
new file mode 100644
index 000000000000..b6a6861951f9
--- /dev/null
+++ b/fs/ext4/xattr_security.c
@@ -0,0 +1,77 @@
1/*
2 * linux/fs/ext4/xattr_security.c
3 * Handler for storing security labels as extended attributes.
4 */
5
6#include <linux/module.h>
7#include <linux/string.h>
8#include <linux/fs.h>
9#include <linux/smp_lock.h>
10#include <linux/ext4_jbd2.h>
11#include <linux/ext4_fs.h>
12#include <linux/security.h>
13#include "xattr.h"
14
15static size_t
16ext4_xattr_security_list(struct inode *inode, char *list, size_t list_size,
17 const char *name, size_t name_len)
18{
19 const size_t prefix_len = sizeof(XATTR_SECURITY_PREFIX)-1;
20 const size_t total_len = prefix_len + name_len + 1;
21
22
23 if (list && total_len <= list_size) {
24 memcpy(list, XATTR_SECURITY_PREFIX, prefix_len);
25 memcpy(list+prefix_len, name, name_len);
26 list[prefix_len + name_len] = '\0';
27 }
28 return total_len;
29}
30
31static int
32ext4_xattr_security_get(struct inode *inode, const char *name,
33 void *buffer, size_t size)
34{
35 if (strcmp(name, "") == 0)
36 return -EINVAL;
37 return ext4_xattr_get(inode, EXT4_XATTR_INDEX_SECURITY, name,
38 buffer, size);
39}
40
41static int
42ext4_xattr_security_set(struct inode *inode, const char *name,
43 const void *value, size_t size, int flags)
44{
45 if (strcmp(name, "") == 0)
46 return -EINVAL;
47 return ext4_xattr_set(inode, EXT4_XATTR_INDEX_SECURITY, name,
48 value, size, flags);
49}
50
51int
52ext4_init_security(handle_t *handle, struct inode *inode, struct inode *dir)
53{
54 int err;
55 size_t len;
56 void *value;
57 char *name;
58
59 err = security_inode_init_security(inode, dir, &name, &value, &len);
60 if (err) {
61 if (err == -EOPNOTSUPP)
62 return 0;
63 return err;
64 }
65 err = ext4_xattr_set_handle(handle, inode, EXT4_XATTR_INDEX_SECURITY,
66 name, value, len, 0);
67 kfree(name);
68 kfree(value);
69 return err;
70}
71
72struct xattr_handler ext4_xattr_security_handler = {
73 .prefix = XATTR_SECURITY_PREFIX,
74 .list = ext4_xattr_security_list,
75 .get = ext4_xattr_security_get,
76 .set = ext4_xattr_security_set,
77};
diff --git a/fs/ext4/xattr_trusted.c b/fs/ext4/xattr_trusted.c
new file mode 100644
index 000000000000..b76f2dbc82da
--- /dev/null
+++ b/fs/ext4/xattr_trusted.c
@@ -0,0 +1,62 @@
1/*
2 * linux/fs/ext4/xattr_trusted.c
3 * Handler for trusted extended attributes.
4 *
5 * Copyright (C) 2003 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
6 */
7
8#include <linux/module.h>
9#include <linux/string.h>
10#include <linux/capability.h>
11#include <linux/fs.h>
12#include <linux/smp_lock.h>
13#include <linux/ext4_jbd2.h>
14#include <linux/ext4_fs.h>
15#include "xattr.h"
16
17#define XATTR_TRUSTED_PREFIX "trusted."
18
19static size_t
20ext4_xattr_trusted_list(struct inode *inode, char *list, size_t list_size,
21 const char *name, size_t name_len)
22{
23 const size_t prefix_len = sizeof(XATTR_TRUSTED_PREFIX)-1;
24 const size_t total_len = prefix_len + name_len + 1;
25
26 if (!capable(CAP_SYS_ADMIN))
27 return 0;
28
29 if (list && total_len <= list_size) {
30 memcpy(list, XATTR_TRUSTED_PREFIX, prefix_len);
31 memcpy(list+prefix_len, name, name_len);
32 list[prefix_len + name_len] = '\0';
33 }
34 return total_len;
35}
36
37static int
38ext4_xattr_trusted_get(struct inode *inode, const char *name,
39 void *buffer, size_t size)
40{
41 if (strcmp(name, "") == 0)
42 return -EINVAL;
43 return ext4_xattr_get(inode, EXT4_XATTR_INDEX_TRUSTED, name,
44 buffer, size);
45}
46
47static int
48ext4_xattr_trusted_set(struct inode *inode, const char *name,
49 const void *value, size_t size, int flags)
50{
51 if (strcmp(name, "") == 0)
52 return -EINVAL;
53 return ext4_xattr_set(inode, EXT4_XATTR_INDEX_TRUSTED, name,
54 value, size, flags);
55}
56
57struct xattr_handler ext4_xattr_trusted_handler = {
58 .prefix = XATTR_TRUSTED_PREFIX,
59 .list = ext4_xattr_trusted_list,
60 .get = ext4_xattr_trusted_get,
61 .set = ext4_xattr_trusted_set,
62};
diff --git a/fs/ext4/xattr_user.c b/fs/ext4/xattr_user.c
new file mode 100644
index 000000000000..c53cded0761a
--- /dev/null
+++ b/fs/ext4/xattr_user.c
@@ -0,0 +1,64 @@
1/*
2 * linux/fs/ext4/xattr_user.c
3 * Handler for extended user attributes.
4 *
5 * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
6 */
7
8#include <linux/module.h>
9#include <linux/string.h>
10#include <linux/fs.h>
11#include <linux/smp_lock.h>
12#include <linux/ext4_jbd2.h>
13#include <linux/ext4_fs.h>
14#include "xattr.h"
15
16#define XATTR_USER_PREFIX "user."
17
18static size_t
19ext4_xattr_user_list(struct inode *inode, char *list, size_t list_size,
20 const char *name, size_t name_len)
21{
22 const size_t prefix_len = sizeof(XATTR_USER_PREFIX)-1;
23 const size_t total_len = prefix_len + name_len + 1;
24
25 if (!test_opt(inode->i_sb, XATTR_USER))
26 return 0;
27
28 if (list && total_len <= list_size) {
29 memcpy(list, XATTR_USER_PREFIX, prefix_len);
30 memcpy(list+prefix_len, name, name_len);
31 list[prefix_len + name_len] = '\0';
32 }
33 return total_len;
34}
35
36static int
37ext4_xattr_user_get(struct inode *inode, const char *name,
38 void *buffer, size_t size)
39{
40 if (strcmp(name, "") == 0)
41 return -EINVAL;
42 if (!test_opt(inode->i_sb, XATTR_USER))
43 return -EOPNOTSUPP;
44 return ext4_xattr_get(inode, EXT4_XATTR_INDEX_USER, name, buffer, size);
45}
46
47static int
48ext4_xattr_user_set(struct inode *inode, const char *name,
49 const void *value, size_t size, int flags)
50{
51 if (strcmp(name, "") == 0)
52 return -EINVAL;
53 if (!test_opt(inode->i_sb, XATTR_USER))
54 return -EOPNOTSUPP;
55 return ext4_xattr_set(inode, EXT4_XATTR_INDEX_USER, name,
56 value, size, flags);
57}
58
59struct xattr_handler ext4_xattr_user_handler = {
60 .prefix = XATTR_USER_PREFIX,
61 .list = ext4_xattr_user_list,
62 .get = ext4_xattr_user_get,
63 .set = ext4_xattr_user_set,
64};
diff --git a/fs/fat/file.c b/fs/fat/file.c
index f4b8f8b3fbdd..0aa813d944a6 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -13,6 +13,7 @@
13#include <linux/smp_lock.h> 13#include <linux/smp_lock.h>
14#include <linux/buffer_head.h> 14#include <linux/buffer_head.h>
15#include <linux/writeback.h> 15#include <linux/writeback.h>
16#include <linux/backing-dev.h>
16#include <linux/blkdev.h> 17#include <linux/blkdev.h>
17 18
18int fat_generic_ioctl(struct inode *inode, struct file *filp, 19int fat_generic_ioctl(struct inode *inode, struct file *filp,
@@ -118,7 +119,7 @@ static int fat_file_release(struct inode *inode, struct file *filp)
118 if ((filp->f_mode & FMODE_WRITE) && 119 if ((filp->f_mode & FMODE_WRITE) &&
119 MSDOS_SB(inode->i_sb)->options.flush) { 120 MSDOS_SB(inode->i_sb)->options.flush) {
120 fat_flush_inodes(inode->i_sb, inode, NULL); 121 fat_flush_inodes(inode->i_sb, inode, NULL);
121 blk_congestion_wait(WRITE, HZ/10); 122 congestion_wait(WRITE, HZ/10);
122 } 123 }
123 return 0; 124 return 0;
124} 125}
@@ -302,7 +303,17 @@ void fat_truncate(struct inode *inode)
302 fat_flush_inodes(inode->i_sb, inode, NULL); 303 fat_flush_inodes(inode->i_sb, inode, NULL);
303} 304}
304 305
306int fat_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
307{
308 struct inode *inode = dentry->d_inode;
309 generic_fillattr(inode, stat);
310 stat->blksize = MSDOS_SB(inode->i_sb)->cluster_size;
311 return 0;
312}
313EXPORT_SYMBOL_GPL(fat_getattr);
314
305struct inode_operations fat_file_inode_operations = { 315struct inode_operations fat_file_inode_operations = {
306 .truncate = fat_truncate, 316 .truncate = fat_truncate,
307 .setattr = fat_notify_change, 317 .setattr = fat_notify_change,
318 .getattr = fat_getattr,
308}; 319};
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 4613cb202170..78945b53b0f8 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -1472,7 +1472,7 @@ int fat_flush_inodes(struct super_block *sb, struct inode *i1, struct inode *i2)
1472 ret = writeback_inode(i1); 1472 ret = writeback_inode(i1);
1473 if (!ret && i2) 1473 if (!ret && i2)
1474 ret = writeback_inode(i2); 1474 ret = writeback_inode(i2);
1475 if (!ret && sb) { 1475 if (!ret) {
1476 struct address_space *mapping = sb->s_bdev->bd_inode->i_mapping; 1476 struct address_space *mapping = sb->s_bdev->bd_inode->i_mapping;
1477 ret = filemap_flush(mapping); 1477 ret = filemap_flush(mapping);
1478 } 1478 }
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 8605155db171..cfc8f81e60d0 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -138,6 +138,7 @@ static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd)
138 struct fuse_entry_out outarg; 138 struct fuse_entry_out outarg;
139 struct fuse_conn *fc; 139 struct fuse_conn *fc;
140 struct fuse_req *req; 140 struct fuse_req *req;
141 struct dentry *parent;
141 142
142 /* Doesn't hurt to "reset" the validity timeout */ 143 /* Doesn't hurt to "reset" the validity timeout */
143 fuse_invalidate_entry_cache(entry); 144 fuse_invalidate_entry_cache(entry);
@@ -151,8 +152,10 @@ static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd)
151 if (IS_ERR(req)) 152 if (IS_ERR(req))
152 return 0; 153 return 0;
153 154
154 fuse_lookup_init(req, entry->d_parent->d_inode, entry, &outarg); 155 parent = dget_parent(entry);
156 fuse_lookup_init(req, parent->d_inode, entry, &outarg);
155 request_send(fc, req); 157 request_send(fc, req);
158 dput(parent);
156 err = req->out.h.error; 159 err = req->out.h.error;
157 /* Zero nodeid is same as -ENOENT */ 160 /* Zero nodeid is same as -ENOENT */
158 if (!err && !outarg.nodeid) 161 if (!err && !outarg.nodeid)
@@ -163,7 +166,9 @@ static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd)
163 fuse_send_forget(fc, req, outarg.nodeid, 1); 166 fuse_send_forget(fc, req, outarg.nodeid, 1);
164 return 0; 167 return 0;
165 } 168 }
169 spin_lock(&fc->lock);
166 fi->nlookup ++; 170 fi->nlookup ++;
171 spin_unlock(&fc->lock);
167 } 172 }
168 fuse_put_request(fc, req); 173 fuse_put_request(fc, req);
169 if (err || (outarg.attr.mode ^ inode->i_mode) & S_IFMT) 174 if (err || (outarg.attr.mode ^ inode->i_mode) & S_IFMT)
@@ -175,22 +180,6 @@ static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd)
175 return 1; 180 return 1;
176} 181}
177 182
178/*
179 * Check if there's already a hashed alias of this directory inode.
180 * If yes, then lookup and mkdir must not create a new alias.
181 */
182static int dir_alias(struct inode *inode)
183{
184 if (S_ISDIR(inode->i_mode)) {
185 struct dentry *alias = d_find_alias(inode);
186 if (alias) {
187 dput(alias);
188 return 1;
189 }
190 }
191 return 0;
192}
193
194static int invalid_nodeid(u64 nodeid) 183static int invalid_nodeid(u64 nodeid)
195{ 184{
196 return !nodeid || nodeid == FUSE_ROOT_ID; 185 return !nodeid || nodeid == FUSE_ROOT_ID;
@@ -206,6 +195,24 @@ static int valid_mode(int m)
206 S_ISBLK(m) || S_ISFIFO(m) || S_ISSOCK(m); 195 S_ISBLK(m) || S_ISFIFO(m) || S_ISSOCK(m);
207} 196}
208 197
198/*
199 * Add a directory inode to a dentry, ensuring that no other dentry
200 * refers to this inode. Called with fc->inst_mutex.
201 */
202static int fuse_d_add_directory(struct dentry *entry, struct inode *inode)
203{
204 struct dentry *alias = d_find_alias(inode);
205 if (alias) {
206 /* This tries to shrink the subtree below alias */
207 fuse_invalidate_entry(alias);
208 dput(alias);
209 if (!list_empty(&inode->i_dentry))
210 return -EBUSY;
211 }
212 d_add(entry, inode);
213 return 0;
214}
215
209static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry, 216static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry,
210 struct nameidata *nd) 217 struct nameidata *nd)
211{ 218{
@@ -241,11 +248,17 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry,
241 if (err && err != -ENOENT) 248 if (err && err != -ENOENT)
242 return ERR_PTR(err); 249 return ERR_PTR(err);
243 250
244 if (inode && dir_alias(inode)) { 251 if (inode && S_ISDIR(inode->i_mode)) {
245 iput(inode); 252 mutex_lock(&fc->inst_mutex);
246 return ERR_PTR(-EIO); 253 err = fuse_d_add_directory(entry, inode);
247 } 254 mutex_unlock(&fc->inst_mutex);
248 d_add(entry, inode); 255 if (err) {
256 iput(inode);
257 return ERR_PTR(err);
258 }
259 } else
260 d_add(entry, inode);
261
249 entry->d_op = &fuse_dentry_operations; 262 entry->d_op = &fuse_dentry_operations;
250 if (!err) 263 if (!err)
251 fuse_change_timeout(entry, &outarg); 264 fuse_change_timeout(entry, &outarg);
@@ -401,12 +414,22 @@ static int create_new_entry(struct fuse_conn *fc, struct fuse_req *req,
401 } 414 }
402 fuse_put_request(fc, req); 415 fuse_put_request(fc, req);
403 416
404 if (dir_alias(inode)) { 417 if (S_ISDIR(inode->i_mode)) {
405 iput(inode); 418 struct dentry *alias;
406 return -EIO; 419 mutex_lock(&fc->inst_mutex);
407 } 420 alias = d_find_alias(inode);
421 if (alias) {
422 /* New directory must have moved since mkdir */
423 mutex_unlock(&fc->inst_mutex);
424 dput(alias);
425 iput(inode);
426 return -EBUSY;
427 }
428 d_instantiate(entry, inode);
429 mutex_unlock(&fc->inst_mutex);
430 } else
431 d_instantiate(entry, inode);
408 432
409 d_instantiate(entry, inode);
410 fuse_change_timeout(entry, &outarg); 433 fuse_change_timeout(entry, &outarg);
411 fuse_invalidate_attr(dir); 434 fuse_invalidate_attr(dir);
412 return 0; 435 return 0;
@@ -935,14 +958,30 @@ static void iattr_to_fattr(struct iattr *iattr, struct fuse_setattr_in *arg)
935 } 958 }
936} 959}
937 960
961static void fuse_vmtruncate(struct inode *inode, loff_t offset)
962{
963 struct fuse_conn *fc = get_fuse_conn(inode);
964 int need_trunc;
965
966 spin_lock(&fc->lock);
967 need_trunc = inode->i_size > offset;
968 i_size_write(inode, offset);
969 spin_unlock(&fc->lock);
970
971 if (need_trunc) {
972 struct address_space *mapping = inode->i_mapping;
973 unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1);
974 truncate_inode_pages(mapping, offset);
975 }
976}
977
938/* 978/*
939 * Set attributes, and at the same time refresh them. 979 * Set attributes, and at the same time refresh them.
940 * 980 *
941 * Truncation is slightly complicated, because the 'truncate' request 981 * Truncation is slightly complicated, because the 'truncate' request
942 * may fail, in which case we don't want to touch the mapping. 982 * may fail, in which case we don't want to touch the mapping.
943 * vmtruncate() doesn't allow for this case. So do the rlimit 983 * vmtruncate() doesn't allow for this case, so do the rlimit checking
944 * checking by hand and call vmtruncate() only after the file has 984 * and the actual truncation by hand.
945 * actually been truncated.
946 */ 985 */
947static int fuse_setattr(struct dentry *entry, struct iattr *attr) 986static int fuse_setattr(struct dentry *entry, struct iattr *attr)
948{ 987{
@@ -993,12 +1032,8 @@ static int fuse_setattr(struct dentry *entry, struct iattr *attr)
993 make_bad_inode(inode); 1032 make_bad_inode(inode);
994 err = -EIO; 1033 err = -EIO;
995 } else { 1034 } else {
996 if (is_truncate) { 1035 if (is_truncate)
997 loff_t origsize = i_size_read(inode); 1036 fuse_vmtruncate(inode, outarg.attr.size);
998 i_size_write(inode, outarg.attr.size);
999 if (origsize > outarg.attr.size)
1000 vmtruncate(inode, outarg.attr.size);
1001 }
1002 fuse_change_attributes(inode, &outarg.attr); 1037 fuse_change_attributes(inode, &outarg.attr);
1003 fi->i_time = time_to_jiffies(outarg.attr_valid, 1038 fi->i_time = time_to_jiffies(outarg.attr_valid,
1004 outarg.attr_valid_nsec); 1039 outarg.attr_valid_nsec);
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 183626868eea..763a50daf1c0 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -397,14 +397,14 @@ static int fuse_readpages(struct file *file, struct address_space *mapping,
397 397
398 err = -EIO; 398 err = -EIO;
399 if (is_bad_inode(inode)) 399 if (is_bad_inode(inode))
400 goto clean_pages_up; 400 goto out;
401 401
402 data.file = file; 402 data.file = file;
403 data.inode = inode; 403 data.inode = inode;
404 data.req = fuse_get_req(fc); 404 data.req = fuse_get_req(fc);
405 err = PTR_ERR(data.req); 405 err = PTR_ERR(data.req);
406 if (IS_ERR(data.req)) 406 if (IS_ERR(data.req))
407 goto clean_pages_up; 407 goto out;
408 408
409 err = read_cache_pages(mapping, pages, fuse_readpages_fill, &data); 409 err = read_cache_pages(mapping, pages, fuse_readpages_fill, &data);
410 if (!err) { 410 if (!err) {
@@ -413,10 +413,7 @@ static int fuse_readpages(struct file *file, struct address_space *mapping,
413 else 413 else
414 fuse_put_request(fc, data.req); 414 fuse_put_request(fc, data.req);
415 } 415 }
416 return err; 416out:
417
418clean_pages_up:
419 put_pages_list(pages);
420 return err; 417 return err;
421} 418}
422 419
@@ -481,8 +478,10 @@ static int fuse_commit_write(struct file *file, struct page *page,
481 err = -EIO; 478 err = -EIO;
482 if (!err) { 479 if (!err) {
483 pos += count; 480 pos += count;
484 if (pos > i_size_read(inode)) 481 spin_lock(&fc->lock);
482 if (pos > inode->i_size)
485 i_size_write(inode, pos); 483 i_size_write(inode, pos);
484 spin_unlock(&fc->lock);
486 485
487 if (offset == 0 && to == PAGE_CACHE_SIZE) { 486 if (offset == 0 && to == PAGE_CACHE_SIZE) {
488 clear_page_dirty(page); 487 clear_page_dirty(page);
@@ -586,8 +585,12 @@ static ssize_t fuse_direct_io(struct file *file, const char __user *buf,
586 } 585 }
587 fuse_put_request(fc, req); 586 fuse_put_request(fc, req);
588 if (res > 0) { 587 if (res > 0) {
589 if (write && pos > i_size_read(inode)) 588 if (write) {
590 i_size_write(inode, pos); 589 spin_lock(&fc->lock);
590 if (pos > inode->i_size)
591 i_size_write(inode, pos);
592 spin_unlock(&fc->lock);
593 }
591 *ppos = pos; 594 *ppos = pos;
592 } 595 }
593 fuse_invalidate_attr(inode); 596 fuse_invalidate_attr(inode);
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 69c7750d55b8..91edb8932d90 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -239,6 +239,9 @@ struct fuse_conn {
239 /** Lock protecting accessess to members of this structure */ 239 /** Lock protecting accessess to members of this structure */
240 spinlock_t lock; 240 spinlock_t lock;
241 241
242 /** Mutex protecting against directory alias creation */
243 struct mutex inst_mutex;
244
242 /** Refcount */ 245 /** Refcount */
243 atomic_t count; 246 atomic_t count;
244 247
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 7d0a9aee01f2..fc4203570370 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -109,6 +109,7 @@ static int fuse_remount_fs(struct super_block *sb, int *flags, char *data)
109 109
110void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr) 110void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr)
111{ 111{
112 struct fuse_conn *fc = get_fuse_conn(inode);
112 if (S_ISREG(inode->i_mode) && i_size_read(inode) != attr->size) 113 if (S_ISREG(inode->i_mode) && i_size_read(inode) != attr->size)
113 invalidate_inode_pages(inode->i_mapping); 114 invalidate_inode_pages(inode->i_mapping);
114 115
@@ -117,7 +118,9 @@ void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr)
117 inode->i_nlink = attr->nlink; 118 inode->i_nlink = attr->nlink;
118 inode->i_uid = attr->uid; 119 inode->i_uid = attr->uid;
119 inode->i_gid = attr->gid; 120 inode->i_gid = attr->gid;
121 spin_lock(&fc->lock);
120 i_size_write(inode, attr->size); 122 i_size_write(inode, attr->size);
123 spin_unlock(&fc->lock);
121 inode->i_blocks = attr->blocks; 124 inode->i_blocks = attr->blocks;
122 inode->i_atime.tv_sec = attr->atime; 125 inode->i_atime.tv_sec = attr->atime;
123 inode->i_atime.tv_nsec = attr->atimensec; 126 inode->i_atime.tv_nsec = attr->atimensec;
@@ -130,7 +133,7 @@ void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr)
130static void fuse_init_inode(struct inode *inode, struct fuse_attr *attr) 133static void fuse_init_inode(struct inode *inode, struct fuse_attr *attr)
131{ 134{
132 inode->i_mode = attr->mode & S_IFMT; 135 inode->i_mode = attr->mode & S_IFMT;
133 i_size_write(inode, attr->size); 136 inode->i_size = attr->size;
134 if (S_ISREG(inode->i_mode)) { 137 if (S_ISREG(inode->i_mode)) {
135 fuse_init_common(inode); 138 fuse_init_common(inode);
136 fuse_init_file_inode(inode); 139 fuse_init_file_inode(inode);
@@ -169,7 +172,6 @@ struct inode *fuse_iget(struct super_block *sb, unsigned long nodeid,
169 struct inode *inode; 172 struct inode *inode;
170 struct fuse_inode *fi; 173 struct fuse_inode *fi;
171 struct fuse_conn *fc = get_fuse_conn_super(sb); 174 struct fuse_conn *fc = get_fuse_conn_super(sb);
172 int retried = 0;
173 175
174 retry: 176 retry:
175 inode = iget5_locked(sb, nodeid, fuse_inode_eq, fuse_inode_set, &nodeid); 177 inode = iget5_locked(sb, nodeid, fuse_inode_eq, fuse_inode_set, &nodeid);
@@ -183,16 +185,16 @@ struct inode *fuse_iget(struct super_block *sb, unsigned long nodeid,
183 fuse_init_inode(inode, attr); 185 fuse_init_inode(inode, attr);
184 unlock_new_inode(inode); 186 unlock_new_inode(inode);
185 } else if ((inode->i_mode ^ attr->mode) & S_IFMT) { 187 } else if ((inode->i_mode ^ attr->mode) & S_IFMT) {
186 BUG_ON(retried);
187 /* Inode has changed type, any I/O on the old should fail */ 188 /* Inode has changed type, any I/O on the old should fail */
188 make_bad_inode(inode); 189 make_bad_inode(inode);
189 iput(inode); 190 iput(inode);
190 retried = 1;
191 goto retry; 191 goto retry;
192 } 192 }
193 193
194 fi = get_fuse_inode(inode); 194 fi = get_fuse_inode(inode);
195 spin_lock(&fc->lock);
195 fi->nlookup ++; 196 fi->nlookup ++;
197 spin_unlock(&fc->lock);
196 fuse_change_attributes(inode, attr); 198 fuse_change_attributes(inode, attr);
197 return inode; 199 return inode;
198} 200}
@@ -377,6 +379,7 @@ static struct fuse_conn *new_conn(void)
377 fc = kzalloc(sizeof(*fc), GFP_KERNEL); 379 fc = kzalloc(sizeof(*fc), GFP_KERNEL);
378 if (fc) { 380 if (fc) {
379 spin_lock_init(&fc->lock); 381 spin_lock_init(&fc->lock);
382 mutex_init(&fc->inst_mutex);
380 atomic_set(&fc->count, 1); 383 atomic_set(&fc->count, 1);
381 init_waitqueue_head(&fc->waitq); 384 init_waitqueue_head(&fc->waitq);
382 init_waitqueue_head(&fc->blocked_waitq); 385 init_waitqueue_head(&fc->blocked_waitq);
@@ -396,8 +399,10 @@ static struct fuse_conn *new_conn(void)
396 399
397void fuse_conn_put(struct fuse_conn *fc) 400void fuse_conn_put(struct fuse_conn *fc)
398{ 401{
399 if (atomic_dec_and_test(&fc->count)) 402 if (atomic_dec_and_test(&fc->count)) {
403 mutex_destroy(&fc->inst_mutex);
400 kfree(fc); 404 kfree(fc);
405 }
401} 406}
402 407
403struct fuse_conn *fuse_conn_get(struct fuse_conn *fc) 408struct fuse_conn *fuse_conn_get(struct fuse_conn *fc)
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index cc57f2ecd219..06e9a8cb45e9 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -434,8 +434,7 @@ static int lookup_block(struct gfs2_inode *ip, struct buffer_head *bh,
434 */ 434 */
435 435
436static int gfs2_block_pointers(struct inode *inode, u64 lblock, int create, 436static int gfs2_block_pointers(struct inode *inode, u64 lblock, int create,
437 struct buffer_head *bh_map, struct metapath *mp, 437 struct buffer_head *bh_map, struct metapath *mp)
438 unsigned int maxlen)
439{ 438{
440 struct gfs2_inode *ip = GFS2_I(inode); 439 struct gfs2_inode *ip = GFS2_I(inode);
441 struct gfs2_sbd *sdp = GFS2_SB(inode); 440 struct gfs2_sbd *sdp = GFS2_SB(inode);
@@ -448,6 +447,7 @@ static int gfs2_block_pointers(struct inode *inode, u64 lblock, int create,
448 int new = 0; 447 int new = 0;
449 u64 dblock = 0; 448 u64 dblock = 0;
450 int boundary; 449 int boundary;
450 unsigned int maxlen = bh_map->b_size >> inode->i_blkbits;
451 451
452 BUG_ON(maxlen == 0); 452 BUG_ON(maxlen == 0);
453 453
@@ -541,13 +541,13 @@ static inline void bmap_unlock(struct inode *inode, int create)
541} 541}
542 542
543int gfs2_block_map(struct inode *inode, u64 lblock, int create, 543int gfs2_block_map(struct inode *inode, u64 lblock, int create,
544 struct buffer_head *bh, unsigned int maxlen) 544 struct buffer_head *bh)
545{ 545{
546 struct metapath mp; 546 struct metapath mp;
547 int ret; 547 int ret;
548 548
549 bmap_lock(inode, create); 549 bmap_lock(inode, create);
550 ret = gfs2_block_pointers(inode, lblock, create, bh, &mp, maxlen); 550 ret = gfs2_block_pointers(inode, lblock, create, bh, &mp);
551 bmap_unlock(inode, create); 551 bmap_unlock(inode, create);
552 return ret; 552 return ret;
553} 553}
@@ -555,7 +555,7 @@ int gfs2_block_map(struct inode *inode, u64 lblock, int create,
555int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsigned *extlen) 555int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsigned *extlen)
556{ 556{
557 struct metapath mp; 557 struct metapath mp;
558 struct buffer_head bh = { .b_state = 0, .b_blocknr = 0, .b_size = 0 }; 558 struct buffer_head bh = { .b_state = 0, .b_blocknr = 0 };
559 int ret; 559 int ret;
560 int create = *new; 560 int create = *new;
561 561
@@ -563,8 +563,9 @@ int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsi
563 BUG_ON(!dblock); 563 BUG_ON(!dblock);
564 BUG_ON(!new); 564 BUG_ON(!new);
565 565
566 bh.b_size = 1 << (inode->i_blkbits + 5);
566 bmap_lock(inode, create); 567 bmap_lock(inode, create);
567 ret = gfs2_block_pointers(inode, lblock, create, &bh, &mp, 32); 568 ret = gfs2_block_pointers(inode, lblock, create, &bh, &mp);
568 bmap_unlock(inode, create); 569 bmap_unlock(inode, create);
569 *extlen = bh.b_size >> inode->i_blkbits; 570 *extlen = bh.b_size >> inode->i_blkbits;
570 *dblock = bh.b_blocknr; 571 *dblock = bh.b_blocknr;
diff --git a/fs/gfs2/bmap.h b/fs/gfs2/bmap.h
index 0fd379b4cd9e..ac2fd04370dc 100644
--- a/fs/gfs2/bmap.h
+++ b/fs/gfs2/bmap.h
@@ -15,7 +15,7 @@ struct gfs2_inode;
15struct page; 15struct page;
16 16
17int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page); 17int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page);
18int gfs2_block_map(struct inode *inode, u64 lblock, int create, struct buffer_head *bh, unsigned int maxlen); 18int gfs2_block_map(struct inode *inode, u64 lblock, int create, struct buffer_head *bh);
19int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsigned *extlen); 19int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsigned *extlen);
20 20
21int gfs2_truncatei(struct gfs2_inode *ip, u64 size); 21int gfs2_truncatei(struct gfs2_inode *ip, u64 size);
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
index 459498cac93b..e24af28b1a12 100644
--- a/fs/gfs2/dir.c
+++ b/fs/gfs2/dir.c
@@ -184,7 +184,7 @@ static int gfs2_dir_write_data(struct gfs2_inode *ip, const char *buf,
184 while (copied < size) { 184 while (copied < size) {
185 unsigned int amount; 185 unsigned int amount;
186 struct buffer_head *bh; 186 struct buffer_head *bh;
187 int new; 187 int new = 0;
188 188
189 amount = size - copied; 189 amount = size - copied;
190 if (amount > sdp->sd_sb.sb_bsize - o) 190 if (amount > sdp->sd_sb.sb_bsize - o)
@@ -212,8 +212,6 @@ static int gfs2_dir_write_data(struct gfs2_inode *ip, const char *buf,
212 gfs2_trans_add_bh(ip->i_gl, bh, 1); 212 gfs2_trans_add_bh(ip->i_gl, bh, 1);
213 memcpy(bh->b_data + o, buf, amount); 213 memcpy(bh->b_data + o, buf, amount);
214 brelse(bh); 214 brelse(bh);
215 if (error)
216 goto fail;
217 215
218 buf += amount; 216 buf += amount;
219 copied += amount; 217 copied += amount;
@@ -317,8 +315,7 @@ static int gfs2_dir_read_data(struct gfs2_inode *ip, char *buf, u64 offset,
317 if (!ra) 315 if (!ra)
318 extlen = 1; 316 extlen = 1;
319 bh = gfs2_meta_ra(ip->i_gl, dblock, extlen); 317 bh = gfs2_meta_ra(ip->i_gl, dblock, extlen);
320 } 318 } else {
321 if (!bh) {
322 error = gfs2_meta_read(ip->i_gl, dblock, DIO_WAIT, &bh); 319 error = gfs2_meta_read(ip->i_gl, dblock, DIO_WAIT, &bh);
323 if (error) 320 if (error)
324 goto fail; 321 goto fail;
@@ -332,7 +329,6 @@ static int gfs2_dir_read_data(struct gfs2_inode *ip, char *buf, u64 offset,
332 extlen--; 329 extlen--;
333 memcpy(buf, bh->b_data + o, amount); 330 memcpy(buf, bh->b_data + o, amount);
334 brelse(bh); 331 brelse(bh);
335 bh = NULL;
336 buf += amount; 332 buf += amount;
337 copied += amount; 333 copied += amount;
338 lblock++; 334 lblock++;
@@ -815,7 +811,7 @@ static struct gfs2_leaf *new_leaf(struct inode *inode, struct buffer_head **pbh,
815 leaf = (struct gfs2_leaf *)bh->b_data; 811 leaf = (struct gfs2_leaf *)bh->b_data;
816 leaf->lf_depth = cpu_to_be16(depth); 812 leaf->lf_depth = cpu_to_be16(depth);
817 leaf->lf_entries = 0; 813 leaf->lf_entries = 0;
818 leaf->lf_dirent_format = cpu_to_be16(GFS2_FORMAT_DE); 814 leaf->lf_dirent_format = cpu_to_be32(GFS2_FORMAT_DE);
819 leaf->lf_next = 0; 815 leaf->lf_next = 0;
820 memset(leaf->lf_reserved, 0, sizeof(leaf->lf_reserved)); 816 memset(leaf->lf_reserved, 0, sizeof(leaf->lf_reserved));
821 dent = (struct gfs2_dirent *)(leaf+1); 817 dent = (struct gfs2_dirent *)(leaf+1);
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 57c43ac47925..d470e5286ecd 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -157,6 +157,9 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, struct gfs2_inum *inum,
157 struct gfs2_glock *io_gl; 157 struct gfs2_glock *io_gl;
158 int error; 158 int error;
159 159
160 if (!inode)
161 return ERR_PTR(-ENOBUFS);
162
160 if (inode->i_state & I_NEW) { 163 if (inode->i_state & I_NEW) {
161 struct gfs2_sbd *sdp = GFS2_SB(inode); 164 struct gfs2_sbd *sdp = GFS2_SB(inode);
162 umode_t mode = DT2IF(type); 165 umode_t mode = DT2IF(type);
diff --git a/fs/gfs2/locking/dlm/mount.c b/fs/gfs2/locking/dlm/mount.c
index 1f94dd35a943..cdd1694e889b 100644
--- a/fs/gfs2/locking/dlm/mount.c
+++ b/fs/gfs2/locking/dlm/mount.c
@@ -45,7 +45,7 @@ static struct gdlm_ls *init_gdlm(lm_callback_t cb, struct gfs2_sbd *sdp,
45 strncpy(buf, table_name, 256); 45 strncpy(buf, table_name, 256);
46 buf[255] = '\0'; 46 buf[255] = '\0';
47 47
48 p = strstr(buf, ":"); 48 p = strchr(buf, ':');
49 if (!p) { 49 if (!p) {
50 log_info("invalid table_name \"%s\"", table_name); 50 log_info("invalid table_name \"%s\"", table_name);
51 kfree(ls); 51 kfree(ls);
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index 554fe5bd1b72..0cace3da9dbb 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -312,10 +312,12 @@ void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks)
312 312
313static u64 log_bmap(struct gfs2_sbd *sdp, unsigned int lbn) 313static u64 log_bmap(struct gfs2_sbd *sdp, unsigned int lbn)
314{ 314{
315 struct inode *inode = sdp->sd_jdesc->jd_inode;
315 int error; 316 int error;
316 struct buffer_head bh_map; 317 struct buffer_head bh_map = { .b_state = 0, .b_blocknr = 0 };
317 318
318 error = gfs2_block_map(sdp->sd_jdesc->jd_inode, lbn, 0, &bh_map, 1); 319 bh_map.b_size = 1 << inode->i_blkbits;
320 error = gfs2_block_map(inode, lbn, 0, &bh_map);
319 if (error || !bh_map.b_blocknr) 321 if (error || !bh_map.b_blocknr)
320 printk(KERN_INFO "error=%d, dbn=%llu lbn=%u", error, bh_map.b_blocknr, lbn); 322 printk(KERN_INFO "error=%d, dbn=%llu lbn=%u", error, bh_map.b_blocknr, lbn);
321 gfs2_assert_withdraw(sdp, !error && bh_map.b_blocknr); 323 gfs2_assert_withdraw(sdp, !error && bh_map.b_blocknr);
@@ -569,16 +571,15 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl)
569 else if (sdp->sd_log_tail != current_tail(sdp) && !sdp->sd_log_idle) 571 else if (sdp->sd_log_tail != current_tail(sdp) && !sdp->sd_log_idle)
570 log_write_header(sdp, 0, PULL); 572 log_write_header(sdp, 0, PULL);
571 lops_after_commit(sdp, ai); 573 lops_after_commit(sdp, ai);
572 sdp->sd_log_head = sdp->sd_log_flush_head;
573 574
575 gfs2_log_lock(sdp);
576 sdp->sd_log_head = sdp->sd_log_flush_head;
574 sdp->sd_log_blks_free -= sdp->sd_log_num_hdrs; 577 sdp->sd_log_blks_free -= sdp->sd_log_num_hdrs;
575
576 sdp->sd_log_blks_reserved = 0; 578 sdp->sd_log_blks_reserved = 0;
577 sdp->sd_log_commited_buf = 0; 579 sdp->sd_log_commited_buf = 0;
578 sdp->sd_log_num_hdrs = 0; 580 sdp->sd_log_num_hdrs = 0;
579 sdp->sd_log_commited_revoke = 0; 581 sdp->sd_log_commited_revoke = 0;
580 582
581 gfs2_log_lock(sdp);
582 if (!list_empty(&ai->ai_ail1_list)) { 583 if (!list_empty(&ai->ai_ail1_list)) {
583 list_add(&ai->ai_list, &sdp->sd_ail1_list); 584 list_add(&ai->ai_list, &sdp->sd_ail1_list);
584 ai = NULL; 585 ai = NULL;
diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
index 881e337b6a70..ab6d1115f95d 100644
--- a/fs/gfs2/lops.c
+++ b/fs/gfs2/lops.c
@@ -492,7 +492,7 @@ static int gfs2_check_magic(struct buffer_head *bh)
492 ptr = kaddr + bh_offset(bh); 492 ptr = kaddr + bh_offset(bh);
493 if (*ptr == cpu_to_be32(GFS2_MAGIC)) 493 if (*ptr == cpu_to_be32(GFS2_MAGIC))
494 rv = 1; 494 rv = 1;
495 kunmap_atomic(page, KM_USER0); 495 kunmap_atomic(kaddr, KM_USER0);
496 496
497 return rv; 497 return rv;
498} 498}
@@ -626,7 +626,7 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
626 memcpy(bh->b_data, 626 memcpy(bh->b_data,
627 kaddr + bh_offset(bd2->bd_bh), 627 kaddr + bh_offset(bd2->bd_bh),
628 sdp->sd_sb.sb_bsize); 628 sdp->sd_sb.sb_bsize);
629 kunmap_atomic(page, KM_USER0); 629 kunmap_atomic(kaddr, KM_USER0);
630 *(__be32 *)bh->b_data = 0; 630 *(__be32 *)bh->b_data = 0;
631 } else { 631 } else {
632 bh = gfs2_log_fake_buf(sdp, bd2->bd_bh); 632 bh = gfs2_log_fake_buf(sdp, bd2->bd_bh);
diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c
index 21508a13bb78..9889c1eacec1 100644
--- a/fs/gfs2/main.c
+++ b/fs/gfs2/main.c
@@ -84,8 +84,8 @@ static int __init init_gfs2_fs(void)
84 84
85 gfs2_inode_cachep = kmem_cache_create("gfs2_inode", 85 gfs2_inode_cachep = kmem_cache_create("gfs2_inode",
86 sizeof(struct gfs2_inode), 86 sizeof(struct gfs2_inode),
87 0, (SLAB_RECLAIM_ACCOUNT| 87 0, SLAB_RECLAIM_ACCOUNT|
88 SLAB_PANIC|SLAB_MEM_SPREAD), 88 SLAB_MEM_SPREAD,
89 gfs2_init_inode_once, NULL); 89 gfs2_init_inode_once, NULL);
90 if (!gfs2_inode_cachep) 90 if (!gfs2_inode_cachep)
91 goto fail; 91 goto fail;
diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c
index 4fb743f4e4a4..015640b3f123 100644
--- a/fs/gfs2/ops_address.c
+++ b/fs/gfs2/ops_address.c
@@ -65,7 +65,7 @@ static void gfs2_page_add_databufs(struct gfs2_inode *ip, struct page *page,
65int gfs2_get_block(struct inode *inode, sector_t lblock, 65int gfs2_get_block(struct inode *inode, sector_t lblock,
66 struct buffer_head *bh_result, int create) 66 struct buffer_head *bh_result, int create)
67{ 67{
68 return gfs2_block_map(inode, lblock, create, bh_result, 32); 68 return gfs2_block_map(inode, lblock, create, bh_result);
69} 69}
70 70
71/** 71/**
@@ -83,7 +83,7 @@ static int gfs2_get_block_noalloc(struct inode *inode, sector_t lblock,
83{ 83{
84 int error; 84 int error;
85 85
86 error = gfs2_block_map(inode, lblock, 0, bh_result, 1); 86 error = gfs2_block_map(inode, lblock, 0, bh_result);
87 if (error) 87 if (error)
88 return error; 88 return error;
89 if (bh_result->b_blocknr == 0) 89 if (bh_result->b_blocknr == 0)
@@ -94,7 +94,7 @@ static int gfs2_get_block_noalloc(struct inode *inode, sector_t lblock,
94static int gfs2_get_block_direct(struct inode *inode, sector_t lblock, 94static int gfs2_get_block_direct(struct inode *inode, sector_t lblock,
95 struct buffer_head *bh_result, int create) 95 struct buffer_head *bh_result, int create)
96{ 96{
97 return gfs2_block_map(inode, lblock, 0, bh_result, 32); 97 return gfs2_block_map(inode, lblock, 0, bh_result);
98} 98}
99 99
100/** 100/**
@@ -162,7 +162,7 @@ static int zero_readpage(struct page *page)
162 162
163 kaddr = kmap_atomic(page, KM_USER0); 163 kaddr = kmap_atomic(page, KM_USER0);
164 memset(kaddr, 0, PAGE_CACHE_SIZE); 164 memset(kaddr, 0, PAGE_CACHE_SIZE);
165 kunmap_atomic(page, KM_USER0); 165 kunmap_atomic(kaddr, KM_USER0);
166 166
167 SetPageUptodate(page); 167 SetPageUptodate(page);
168 168
@@ -195,7 +195,7 @@ static int stuffed_readpage(struct gfs2_inode *ip, struct page *page)
195 memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode), 195 memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode),
196 ip->i_di.di_size); 196 ip->i_di.di_size);
197 memset(kaddr + ip->i_di.di_size, 0, PAGE_CACHE_SIZE - ip->i_di.di_size); 197 memset(kaddr + ip->i_di.di_size, 0, PAGE_CACHE_SIZE - ip->i_di.di_size);
198 kunmap_atomic(page, KM_USER0); 198 kunmap_atomic(kaddr, KM_USER0);
199 199
200 brelse(dibh); 200 brelse(dibh);
201 201
@@ -337,13 +337,6 @@ out:
337out_noerror: 337out_noerror:
338 ret = 0; 338 ret = 0;
339out_unlock: 339out_unlock:
340 /* unlock all pages, we can't do any I/O right now */
341 for (page_idx = 0; page_idx < nr_pages; page_idx++) {
342 struct page *page = list_entry(pages->prev, struct page, lru);
343 list_del(&page->lru);
344 unlock_page(page);
345 page_cache_release(page);
346 }
347 if (do_unlock) 340 if (do_unlock)
348 gfs2_holder_uninit(&gh); 341 gfs2_holder_uninit(&gh);
349 goto out; 342 goto out;
@@ -370,19 +363,22 @@ static int gfs2_prepare_write(struct file *file, struct page *page,
370 loff_t pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + from; 363 loff_t pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + from;
371 loff_t end = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to; 364 loff_t end = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to;
372 struct gfs2_alloc *al; 365 struct gfs2_alloc *al;
366 unsigned int write_len = to - from;
367
373 368
374 gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_ATIME|GL_AOP, &ip->i_gh); 369 gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_ATIME|GL_AOP, &ip->i_gh);
375 error = gfs2_glock_nq_m_atime(1, &ip->i_gh); 370 error = gfs2_glock_nq_m_atime(1, &ip->i_gh);
376 if (error) 371 if (error)
377 goto out_uninit; 372 goto out_uninit;
378 373
379 gfs2_write_calc_reserv(ip, to - from, &data_blocks, &ind_blocks); 374 gfs2_write_calc_reserv(ip, write_len, &data_blocks, &ind_blocks);
380 375
381 error = gfs2_write_alloc_required(ip, pos, from - to, &alloc_required); 376 error = gfs2_write_alloc_required(ip, pos, write_len, &alloc_required);
382 if (error) 377 if (error)
383 goto out_unlock; 378 goto out_unlock;
384 379
385 380
381 ip->i_alloc.al_requested = 0;
386 if (alloc_required) { 382 if (alloc_required) {
387 al = gfs2_alloc_get(ip); 383 al = gfs2_alloc_get(ip);
388 384
@@ -482,7 +478,7 @@ static int gfs2_commit_write(struct file *file, struct page *page,
482 kaddr = kmap_atomic(page, KM_USER0); 478 kaddr = kmap_atomic(page, KM_USER0);
483 memcpy(dibh->b_data + sizeof(struct gfs2_dinode) + from, 479 memcpy(dibh->b_data + sizeof(struct gfs2_dinode) + from,
484 kaddr + from, to - from); 480 kaddr + from, to - from);
485 kunmap_atomic(page, KM_USER0); 481 kunmap_atomic(kaddr, KM_USER0);
486 482
487 SetPageUptodate(page); 483 SetPageUptodate(page);
488 484
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index 178b33911843..882873a6bd69 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -794,8 +794,8 @@ static int fill_super_meta(struct super_block *sb, struct super_block *new,
794 fs_err(sdp, "can't get root dentry\n"); 794 fs_err(sdp, "can't get root dentry\n");
795 error = -ENOMEM; 795 error = -ENOMEM;
796 iput(inode); 796 iput(inode);
797 } 797 } else
798 new->s_root->d_op = &gfs2_dops; 798 new->s_root->d_op = &gfs2_dops;
799 799
800 return error; 800 return error;
801} 801}
@@ -854,7 +854,6 @@ static int gfs2_get_sb_meta(struct file_system_type *fs_type, int flags,
854 int error = 0; 854 int error = 0;
855 struct super_block *sb = NULL, *new; 855 struct super_block *sb = NULL, *new;
856 struct gfs2_sbd *sdp; 856 struct gfs2_sbd *sdp;
857 char *gfs2mnt = NULL;
858 857
859 sb = get_gfs2_sb(dev_name); 858 sb = get_gfs2_sb(dev_name);
860 if (!sb) { 859 if (!sb) {
@@ -892,8 +891,6 @@ static int gfs2_get_sb_meta(struct file_system_type *fs_type, int flags,
892 atomic_inc(&sdp->sd_gfs2mnt->mnt_count); 891 atomic_inc(&sdp->sd_gfs2mnt->mnt_count);
893 return simple_set_mnt(mnt, new); 892 return simple_set_mnt(mnt, new);
894error: 893error:
895 if (gfs2mnt)
896 kfree(gfs2mnt);
897 return error; 894 return error;
898} 895}
899 896
diff --git a/fs/gfs2/ops_super.c b/fs/gfs2/ops_super.c
index 06f06f7773d0..b47d9598c047 100644
--- a/fs/gfs2/ops_super.c
+++ b/fs/gfs2/ops_super.c
@@ -138,16 +138,27 @@ static void gfs2_put_super(struct super_block *sb)
138} 138}
139 139
140/** 140/**
141 * gfs2_write_super - disk commit all incore transactions 141 * gfs2_write_super
142 * @sb: the filesystem 142 * @sb: the superblock
143 * 143 *
144 * This function is called every time sync(2) is called.
145 * After this exits, all dirty buffers are synced.
146 */ 144 */
147 145
148static void gfs2_write_super(struct super_block *sb) 146static void gfs2_write_super(struct super_block *sb)
149{ 147{
148 sb->s_dirt = 0;
149}
150
151/**
152 * gfs2_sync_fs - sync the filesystem
153 * @sb: the superblock
154 *
155 * Flushes the log to disk.
156 */
157static int gfs2_sync_fs(struct super_block *sb, int wait)
158{
159 sb->s_dirt = 0;
150 gfs2_log_flush(sb->s_fs_info, NULL); 160 gfs2_log_flush(sb->s_fs_info, NULL);
161 return 0;
151} 162}
152 163
153/** 164/**
@@ -452,17 +463,18 @@ static void gfs2_destroy_inode(struct inode *inode)
452} 463}
453 464
454struct super_operations gfs2_super_ops = { 465struct super_operations gfs2_super_ops = {
455 .alloc_inode = gfs2_alloc_inode, 466 .alloc_inode = gfs2_alloc_inode,
456 .destroy_inode = gfs2_destroy_inode, 467 .destroy_inode = gfs2_destroy_inode,
457 .write_inode = gfs2_write_inode, 468 .write_inode = gfs2_write_inode,
458 .delete_inode = gfs2_delete_inode, 469 .delete_inode = gfs2_delete_inode,
459 .put_super = gfs2_put_super, 470 .put_super = gfs2_put_super,
460 .write_super = gfs2_write_super, 471 .write_super = gfs2_write_super,
461 .write_super_lockfs = gfs2_write_super_lockfs, 472 .sync_fs = gfs2_sync_fs,
462 .unlockfs = gfs2_unlockfs, 473 .write_super_lockfs = gfs2_write_super_lockfs,
463 .statfs = gfs2_statfs, 474 .unlockfs = gfs2_unlockfs,
464 .remount_fs = gfs2_remount_fs, 475 .statfs = gfs2_statfs,
465 .clear_inode = gfs2_clear_inode, 476 .remount_fs = gfs2_remount_fs,
466 .show_options = gfs2_show_options, 477 .clear_inode = gfs2_clear_inode,
478 .show_options = gfs2_show_options,
467}; 479};
468 480
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
index c69b94a55588..a3deae7416c9 100644
--- a/fs/gfs2/quota.c
+++ b/fs/gfs2/quota.c
@@ -251,7 +251,7 @@ static int bh_get(struct gfs2_quota_data *qd)
251 unsigned int block, offset; 251 unsigned int block, offset;
252 struct buffer_head *bh; 252 struct buffer_head *bh;
253 int error; 253 int error;
254 struct buffer_head bh_map; 254 struct buffer_head bh_map = { .b_state = 0, .b_blocknr = 0 };
255 255
256 mutex_lock(&sdp->sd_quota_mutex); 256 mutex_lock(&sdp->sd_quota_mutex);
257 257
@@ -263,7 +263,8 @@ static int bh_get(struct gfs2_quota_data *qd)
263 block = qd->qd_slot / sdp->sd_qc_per_block; 263 block = qd->qd_slot / sdp->sd_qc_per_block;
264 offset = qd->qd_slot % sdp->sd_qc_per_block;; 264 offset = qd->qd_slot % sdp->sd_qc_per_block;;
265 265
266 error = gfs2_block_map(&ip->i_inode, block, 0, &bh_map, 1); 266 bh_map.b_size = 1 << ip->i_inode.i_blkbits;
267 error = gfs2_block_map(&ip->i_inode, block, 0, &bh_map);
267 if (error) 268 if (error)
268 goto fail; 269 goto fail;
269 error = gfs2_meta_read(ip->i_gl, bh_map.b_blocknr, DIO_WAIT, &bh); 270 error = gfs2_meta_read(ip->i_gl, bh_map.b_blocknr, DIO_WAIT, &bh);
diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c
index 0a8a4b87dcc6..62cd223819b7 100644
--- a/fs/gfs2/recovery.c
+++ b/fs/gfs2/recovery.c
@@ -372,11 +372,12 @@ static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header *head)
372 u32 hash; 372 u32 hash;
373 struct buffer_head *bh; 373 struct buffer_head *bh;
374 int error; 374 int error;
375 struct buffer_head bh_map; 375 struct buffer_head bh_map = { .b_state = 0, .b_blocknr = 0 };
376 376
377 lblock = head->lh_blkno; 377 lblock = head->lh_blkno;
378 gfs2_replay_incr_blk(sdp, &lblock); 378 gfs2_replay_incr_blk(sdp, &lblock);
379 error = gfs2_block_map(&ip->i_inode, lblock, 0, &bh_map, 1); 379 bh_map.b_size = 1 << ip->i_inode.i_blkbits;
380 error = gfs2_block_map(&ip->i_inode, lblock, 0, &bh_map);
380 if (error) 381 if (error)
381 return error; 382 return error;
382 if (!bh_map.b_blocknr) { 383 if (!bh_map.b_blocknr) {
diff --git a/fs/gfs2/rgrp.h b/fs/gfs2/rgrp.h
index 9eedfd12bfff..b01e0cfc99b5 100644
--- a/fs/gfs2/rgrp.h
+++ b/fs/gfs2/rgrp.h
@@ -32,7 +32,7 @@ void gfs2_rgrp_repolish_clones(struct gfs2_rgrpd *rgd);
32struct gfs2_alloc *gfs2_alloc_get(struct gfs2_inode *ip); 32struct gfs2_alloc *gfs2_alloc_get(struct gfs2_inode *ip);
33static inline void gfs2_alloc_put(struct gfs2_inode *ip) 33static inline void gfs2_alloc_put(struct gfs2_inode *ip)
34{ 34{
35 return; /* Se we can see where ip->i_alloc is used */ 35 return; /* So we can see where ip->i_alloc is used */
36} 36}
37 37
38int gfs2_inplace_reserve_i(struct gfs2_inode *ip, 38int gfs2_inplace_reserve_i(struct gfs2_inode *ip,
diff --git a/fs/hfs/super.c b/fs/hfs/super.c
index d43b4fcc8ad3..85b17b3fa4a0 100644
--- a/fs/hfs/super.c
+++ b/fs/hfs/super.c
@@ -390,11 +390,13 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent)
390 hfs_find_exit(&fd); 390 hfs_find_exit(&fd);
391 goto bail_no_root; 391 goto bail_no_root;
392 } 392 }
393 res = -EINVAL;
393 root_inode = hfs_iget(sb, &fd.search_key->cat, &rec); 394 root_inode = hfs_iget(sb, &fd.search_key->cat, &rec);
394 hfs_find_exit(&fd); 395 hfs_find_exit(&fd);
395 if (!root_inode) 396 if (!root_inode)
396 goto bail_no_root; 397 goto bail_no_root;
397 398
399 res = -ENOMEM;
398 sb->s_root = d_alloc_root(root_inode); 400 sb->s_root = d_alloc_root(root_inode);
399 if (!sb->s_root) 401 if (!sb->s_root)
400 goto bail_iput; 402 goto bail_iput;
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 5e03b2f67b93..7f4756963d05 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -62,24 +62,19 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma)
62 loff_t len, vma_len; 62 loff_t len, vma_len;
63 int ret; 63 int ret;
64 64
65 if (vma->vm_pgoff & (HPAGE_SIZE / PAGE_SIZE - 1)) 65 /*
66 return -EINVAL; 66 * vma alignment has already been checked by prepare_hugepage_range.
67 67 * If you add any error returns here, do so after setting VM_HUGETLB,
68 if (vma->vm_start & ~HPAGE_MASK) 68 * so is_vm_hugetlb_page tests below unmap_region go the right way
69 return -EINVAL; 69 * when do_mmap_pgoff unwinds (may be important on powerpc and ia64).
70 70 */
71 if (vma->vm_end & ~HPAGE_MASK) 71 vma->vm_flags |= VM_HUGETLB | VM_RESERVED;
72 return -EINVAL; 72 vma->vm_ops = &hugetlb_vm_ops;
73
74 if (vma->vm_end - vma->vm_start < HPAGE_SIZE)
75 return -EINVAL;
76 73
77 vma_len = (loff_t)(vma->vm_end - vma->vm_start); 74 vma_len = (loff_t)(vma->vm_end - vma->vm_start);
78 75
79 mutex_lock(&inode->i_mutex); 76 mutex_lock(&inode->i_mutex);
80 file_accessed(file); 77 file_accessed(file);
81 vma->vm_flags |= VM_HUGETLB | VM_RESERVED;
82 vma->vm_ops = &hugetlb_vm_ops;
83 78
84 ret = -ENOMEM; 79 ret = -ENOMEM;
85 len = vma_len + ((loff_t)vma->vm_pgoff << PAGE_SHIFT); 80 len = vma_len + ((loff_t)vma->vm_pgoff << PAGE_SHIFT);
@@ -271,29 +266,27 @@ static void hugetlbfs_drop_inode(struct inode *inode)
271 hugetlbfs_forget_inode(inode); 266 hugetlbfs_forget_inode(inode);
272} 267}
273 268
274/*
275 * h_pgoff is in HPAGE_SIZE units.
276 * vma->vm_pgoff is in PAGE_SIZE units.
277 */
278static inline void 269static inline void
279hugetlb_vmtruncate_list(struct prio_tree_root *root, unsigned long h_pgoff) 270hugetlb_vmtruncate_list(struct prio_tree_root *root, pgoff_t pgoff)
280{ 271{
281 struct vm_area_struct *vma; 272 struct vm_area_struct *vma;
282 struct prio_tree_iter iter; 273 struct prio_tree_iter iter;
283 274
284 vma_prio_tree_foreach(vma, &iter, root, h_pgoff, ULONG_MAX) { 275 vma_prio_tree_foreach(vma, &iter, root, pgoff, ULONG_MAX) {
285 unsigned long h_vm_pgoff;
286 unsigned long v_offset; 276 unsigned long v_offset;
287 277
288 h_vm_pgoff = vma->vm_pgoff >> (HPAGE_SHIFT - PAGE_SHIFT);
289 v_offset = (h_pgoff - h_vm_pgoff) << HPAGE_SHIFT;
290 /* 278 /*
291 * Is this VMA fully outside the truncation point? 279 * Can the expression below overflow on 32-bit arches?
280 * No, because the prio_tree returns us only those vmas
281 * which overlap the truncated area starting at pgoff,
282 * and no vma on a 32-bit arch can span beyond the 4GB.
292 */ 283 */
293 if (h_vm_pgoff >= h_pgoff) 284 if (vma->vm_pgoff < pgoff)
285 v_offset = (pgoff - vma->vm_pgoff) << PAGE_SHIFT;
286 else
294 v_offset = 0; 287 v_offset = 0;
295 288
296 unmap_hugepage_range(vma, 289 __unmap_hugepage_range(vma,
297 vma->vm_start + v_offset, vma->vm_end); 290 vma->vm_start + v_offset, vma->vm_end);
298 } 291 }
299} 292}
@@ -303,14 +296,14 @@ hugetlb_vmtruncate_list(struct prio_tree_root *root, unsigned long h_pgoff)
303 */ 296 */
304static int hugetlb_vmtruncate(struct inode *inode, loff_t offset) 297static int hugetlb_vmtruncate(struct inode *inode, loff_t offset)
305{ 298{
306 unsigned long pgoff; 299 pgoff_t pgoff;
307 struct address_space *mapping = inode->i_mapping; 300 struct address_space *mapping = inode->i_mapping;
308 301
309 if (offset > inode->i_size) 302 if (offset > inode->i_size)
310 return -EINVAL; 303 return -EINVAL;
311 304
312 BUG_ON(offset & ~HPAGE_MASK); 305 BUG_ON(offset & ~HPAGE_MASK);
313 pgoff = offset >> HPAGE_SHIFT; 306 pgoff = offset >> PAGE_SHIFT;
314 307
315 inode->i_size = offset; 308 inode->i_size = offset;
316 spin_lock(&mapping->i_mmap_lock); 309 spin_lock(&mapping->i_mmap_lock);
@@ -624,7 +617,6 @@ hugetlbfs_parse_options(char *options, struct hugetlbfs_config *pconfig)
624 do_div(size, 100); 617 do_div(size, 100);
625 rest++; 618 rest++;
626 } 619 }
627 size &= HPAGE_MASK;
628 pconfig->nr_blocks = (size >> HPAGE_SHIFT); 620 pconfig->nr_blocks = (size >> HPAGE_SHIFT);
629 value = rest; 621 value = rest;
630 } else if (!strcmp(opt,"nr_inodes")) { 622 } else if (!strcmp(opt,"nr_inodes")) {
diff --git a/fs/inode.c b/fs/inode.c
index d9a21d122926..26cdb115ce67 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1306,6 +1306,42 @@ void wake_up_inode(struct inode *inode)
1306 wake_up_bit(&inode->i_state, __I_LOCK); 1306 wake_up_bit(&inode->i_state, __I_LOCK);
1307} 1307}
1308 1308
1309/*
1310 * We rarely want to lock two inodes that do not have a parent/child
1311 * relationship (such as directory, child inode) simultaneously. The
1312 * vast majority of file systems should be able to get along fine
1313 * without this. Do not use these functions except as a last resort.
1314 */
1315void inode_double_lock(struct inode *inode1, struct inode *inode2)
1316{
1317 if (inode1 == NULL || inode2 == NULL || inode1 == inode2) {
1318 if (inode1)
1319 mutex_lock(&inode1->i_mutex);
1320 else if (inode2)
1321 mutex_lock(&inode2->i_mutex);
1322 return;
1323 }
1324
1325 if (inode1 < inode2) {
1326 mutex_lock_nested(&inode1->i_mutex, I_MUTEX_PARENT);
1327 mutex_lock_nested(&inode2->i_mutex, I_MUTEX_CHILD);
1328 } else {
1329 mutex_lock_nested(&inode2->i_mutex, I_MUTEX_PARENT);
1330 mutex_lock_nested(&inode1->i_mutex, I_MUTEX_CHILD);
1331 }
1332}
1333EXPORT_SYMBOL(inode_double_lock);
1334
1335void inode_double_unlock(struct inode *inode1, struct inode *inode2)
1336{
1337 if (inode1)
1338 mutex_unlock(&inode1->i_mutex);
1339
1340 if (inode2 && inode2 != inode1)
1341 mutex_unlock(&inode2->i_mutex);
1342}
1343EXPORT_SYMBOL(inode_double_unlock);
1344
1309static __initdata unsigned long ihash_entries; 1345static __initdata unsigned long ihash_entries;
1310static int __init set_ihash_entries(char *str) 1346static int __init set_ihash_entries(char *str)
1311{ 1347{
diff --git a/fs/ioprio.c b/fs/ioprio.c
index 6dc6721d9e82..89e8da112a75 100644
--- a/fs/ioprio.c
+++ b/fs/ioprio.c
@@ -150,11 +150,6 @@ int ioprio_best(unsigned short aprio, unsigned short bprio)
150 unsigned short aclass = IOPRIO_PRIO_CLASS(aprio); 150 unsigned short aclass = IOPRIO_PRIO_CLASS(aprio);
151 unsigned short bclass = IOPRIO_PRIO_CLASS(bprio); 151 unsigned short bclass = IOPRIO_PRIO_CLASS(bprio);
152 152
153 if (!ioprio_valid(aprio))
154 return bprio;
155 if (!ioprio_valid(bprio))
156 return aprio;
157
158 if (aclass == IOPRIO_CLASS_NONE) 153 if (aclass == IOPRIO_CLASS_NONE)
159 aclass = IOPRIO_CLASS_BE; 154 aclass = IOPRIO_CLASS_BE;
160 if (bclass == IOPRIO_CLASS_NONE) 155 if (bclass == IOPRIO_CLASS_NONE)
diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c
index c518dd8fe60a..b85c686b60db 100644
--- a/fs/jbd/journal.c
+++ b/fs/jbd/journal.c
@@ -725,6 +725,7 @@ journal_t * journal_init_dev(struct block_device *bdev,
725 __FUNCTION__); 725 __FUNCTION__);
726 kfree(journal); 726 kfree(journal);
727 journal = NULL; 727 journal = NULL;
728 goto out;
728 } 729 }
729 journal->j_dev = bdev; 730 journal->j_dev = bdev;
730 journal->j_fs_dev = fs_dev; 731 journal->j_fs_dev = fs_dev;
@@ -735,7 +736,7 @@ journal_t * journal_init_dev(struct block_device *bdev,
735 J_ASSERT(bh != NULL); 736 J_ASSERT(bh != NULL);
736 journal->j_sb_buffer = bh; 737 journal->j_sb_buffer = bh;
737 journal->j_superblock = (journal_superblock_t *)bh->b_data; 738 journal->j_superblock = (journal_superblock_t *)bh->b_data;
738 739out:
739 return journal; 740 return journal;
740} 741}
741 742
diff --git a/fs/jbd/transaction.c b/fs/jbd/transaction.c
index e1b3c8af4d17..4f82bcd63e48 100644
--- a/fs/jbd/transaction.c
+++ b/fs/jbd/transaction.c
@@ -967,6 +967,13 @@ int journal_dirty_data(handle_t *handle, struct buffer_head *bh)
967 */ 967 */
968 jbd_lock_bh_state(bh); 968 jbd_lock_bh_state(bh);
969 spin_lock(&journal->j_list_lock); 969 spin_lock(&journal->j_list_lock);
970
971 /* Now that we have bh_state locked, are we really still mapped? */
972 if (!buffer_mapped(bh)) {
973 JBUFFER_TRACE(jh, "unmapped buffer, bailing out");
974 goto no_journal;
975 }
976
970 if (jh->b_transaction) { 977 if (jh->b_transaction) {
971 JBUFFER_TRACE(jh, "has transaction"); 978 JBUFFER_TRACE(jh, "has transaction");
972 if (jh->b_transaction != handle->h_transaction) { 979 if (jh->b_transaction != handle->h_transaction) {
@@ -1028,6 +1035,11 @@ int journal_dirty_data(handle_t *handle, struct buffer_head *bh)
1028 sync_dirty_buffer(bh); 1035 sync_dirty_buffer(bh);
1029 jbd_lock_bh_state(bh); 1036 jbd_lock_bh_state(bh);
1030 spin_lock(&journal->j_list_lock); 1037 spin_lock(&journal->j_list_lock);
1038 /* Since we dropped the lock... */
1039 if (!buffer_mapped(bh)) {
1040 JBUFFER_TRACE(jh, "buffer got unmapped");
1041 goto no_journal;
1042 }
1031 /* The buffer may become locked again at any 1043 /* The buffer may become locked again at any
1032 time if it is redirtied */ 1044 time if it is redirtied */
1033 } 1045 }
@@ -1314,13 +1326,14 @@ int journal_stop(handle_t *handle)
1314 int old_handle_count, err; 1326 int old_handle_count, err;
1315 pid_t pid; 1327 pid_t pid;
1316 1328
1317 J_ASSERT(transaction->t_updates > 0);
1318 J_ASSERT(journal_current_handle() == handle); 1329 J_ASSERT(journal_current_handle() == handle);
1319 1330
1320 if (is_handle_aborted(handle)) 1331 if (is_handle_aborted(handle))
1321 err = -EIO; 1332 err = -EIO;
1322 else 1333 else {
1334 J_ASSERT(transaction->t_updates > 0);
1323 err = 0; 1335 err = 0;
1336 }
1324 1337
1325 if (--handle->h_ref > 0) { 1338 if (--handle->h_ref > 0) {
1326 jbd_debug(4, "h_ref %d -> %d\n", handle->h_ref + 1, 1339 jbd_debug(4, "h_ref %d -> %d\n", handle->h_ref + 1,
@@ -1823,6 +1836,7 @@ static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh)
1823 } 1836 }
1824 } 1837 }
1825 } else if (transaction == journal->j_committing_transaction) { 1838 } else if (transaction == journal->j_committing_transaction) {
1839 JBUFFER_TRACE(jh, "on committing transaction");
1826 if (jh->b_jlist == BJ_Locked) { 1840 if (jh->b_jlist == BJ_Locked) {
1827 /* 1841 /*
1828 * The buffer is on the committing transaction's locked 1842 * The buffer is on the committing transaction's locked
@@ -1837,7 +1851,6 @@ static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh)
1837 * can remove it's next_transaction pointer from the 1851 * can remove it's next_transaction pointer from the
1838 * running transaction if that is set, but nothing 1852 * running transaction if that is set, but nothing
1839 * else. */ 1853 * else. */
1840 JBUFFER_TRACE(jh, "on committing transaction");
1841 set_buffer_freed(bh); 1854 set_buffer_freed(bh);
1842 if (jh->b_next_transaction) { 1855 if (jh->b_next_transaction) {
1843 J_ASSERT(jh->b_next_transaction == 1856 J_ASSERT(jh->b_next_transaction ==
@@ -1857,6 +1870,7 @@ static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh)
1857 * i_size already for this truncate so recovery will not 1870 * i_size already for this truncate so recovery will not
1858 * expose the disk blocks we are discarding here.) */ 1871 * expose the disk blocks we are discarding here.) */
1859 J_ASSERT_JH(jh, transaction == journal->j_running_transaction); 1872 J_ASSERT_JH(jh, transaction == journal->j_running_transaction);
1873 JBUFFER_TRACE(jh, "on running transaction");
1860 may_free = __dispose_buffer(jh, transaction); 1874 may_free = __dispose_buffer(jh, transaction);
1861 } 1875 }
1862 1876
diff --git a/fs/jbd2/Makefile b/fs/jbd2/Makefile
new file mode 100644
index 000000000000..802a3413872a
--- /dev/null
+++ b/fs/jbd2/Makefile
@@ -0,0 +1,7 @@
1#
2# Makefile for the linux journaling routines.
3#
4
5obj-$(CONFIG_JBD2) += jbd2.o
6
7jbd2-objs := transaction.o commit.o recovery.o checkpoint.o revoke.o journal.o
diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c
new file mode 100644
index 000000000000..68039fa9a566
--- /dev/null
+++ b/fs/jbd2/checkpoint.c
@@ -0,0 +1,697 @@
1/*
2 * linux/fs/checkpoint.c
3 *
4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1999
5 *
6 * Copyright 1999 Red Hat Software --- All Rights Reserved
7 *
8 * This file is part of the Linux kernel and is made available under
9 * the terms of the GNU General Public License, version 2, or at your
10 * option, any later version, incorporated herein by reference.
11 *
12 * Checkpoint routines for the generic filesystem journaling code.
13 * Part of the ext2fs journaling system.
14 *
15 * Checkpointing is the process of ensuring that a section of the log is
16 * committed fully to disk, so that that portion of the log can be
17 * reused.
18 */
19
20#include <linux/time.h>
21#include <linux/fs.h>
22#include <linux/jbd2.h>
23#include <linux/errno.h>
24#include <linux/slab.h>
25
26/*
27 * Unlink a buffer from a transaction checkpoint list.
28 *
29 * Called with j_list_lock held.
30 */
31static inline void __buffer_unlink_first(struct journal_head *jh)
32{
33 transaction_t *transaction = jh->b_cp_transaction;
34
35 jh->b_cpnext->b_cpprev = jh->b_cpprev;
36 jh->b_cpprev->b_cpnext = jh->b_cpnext;
37 if (transaction->t_checkpoint_list == jh) {
38 transaction->t_checkpoint_list = jh->b_cpnext;
39 if (transaction->t_checkpoint_list == jh)
40 transaction->t_checkpoint_list = NULL;
41 }
42}
43
44/*
45 * Unlink a buffer from a transaction checkpoint(io) list.
46 *
47 * Called with j_list_lock held.
48 */
49static inline void __buffer_unlink(struct journal_head *jh)
50{
51 transaction_t *transaction = jh->b_cp_transaction;
52
53 __buffer_unlink_first(jh);
54 if (transaction->t_checkpoint_io_list == jh) {
55 transaction->t_checkpoint_io_list = jh->b_cpnext;
56 if (transaction->t_checkpoint_io_list == jh)
57 transaction->t_checkpoint_io_list = NULL;
58 }
59}
60
61/*
62 * Move a buffer from the checkpoint list to the checkpoint io list
63 *
64 * Called with j_list_lock held
65 */
66static inline void __buffer_relink_io(struct journal_head *jh)
67{
68 transaction_t *transaction = jh->b_cp_transaction;
69
70 __buffer_unlink_first(jh);
71
72 if (!transaction->t_checkpoint_io_list) {
73 jh->b_cpnext = jh->b_cpprev = jh;
74 } else {
75 jh->b_cpnext = transaction->t_checkpoint_io_list;
76 jh->b_cpprev = transaction->t_checkpoint_io_list->b_cpprev;
77 jh->b_cpprev->b_cpnext = jh;
78 jh->b_cpnext->b_cpprev = jh;
79 }
80 transaction->t_checkpoint_io_list = jh;
81}
82
83/*
84 * Try to release a checkpointed buffer from its transaction.
85 * Returns 1 if we released it and 2 if we also released the
86 * whole transaction.
87 *
88 * Requires j_list_lock
89 * Called under jbd_lock_bh_state(jh2bh(jh)), and drops it
90 */
91static int __try_to_free_cp_buf(struct journal_head *jh)
92{
93 int ret = 0;
94 struct buffer_head *bh = jh2bh(jh);
95
96 if (jh->b_jlist == BJ_None && !buffer_locked(bh) && !buffer_dirty(bh)) {
97 JBUFFER_TRACE(jh, "remove from checkpoint list");
98 ret = __jbd2_journal_remove_checkpoint(jh) + 1;
99 jbd_unlock_bh_state(bh);
100 jbd2_journal_remove_journal_head(bh);
101 BUFFER_TRACE(bh, "release");
102 __brelse(bh);
103 } else {
104 jbd_unlock_bh_state(bh);
105 }
106 return ret;
107}
108
109/*
110 * __jbd2_log_wait_for_space: wait until there is space in the journal.
111 *
112 * Called under j-state_lock *only*. It will be unlocked if we have to wait
113 * for a checkpoint to free up some space in the log.
114 */
115void __jbd2_log_wait_for_space(journal_t *journal)
116{
117 int nblocks;
118 assert_spin_locked(&journal->j_state_lock);
119
120 nblocks = jbd_space_needed(journal);
121 while (__jbd2_log_space_left(journal) < nblocks) {
122 if (journal->j_flags & JBD2_ABORT)
123 return;
124 spin_unlock(&journal->j_state_lock);
125 mutex_lock(&journal->j_checkpoint_mutex);
126
127 /*
128 * Test again, another process may have checkpointed while we
129 * were waiting for the checkpoint lock
130 */
131 spin_lock(&journal->j_state_lock);
132 nblocks = jbd_space_needed(journal);
133 if (__jbd2_log_space_left(journal) < nblocks) {
134 spin_unlock(&journal->j_state_lock);
135 jbd2_log_do_checkpoint(journal);
136 spin_lock(&journal->j_state_lock);
137 }
138 mutex_unlock(&journal->j_checkpoint_mutex);
139 }
140}
141
142/*
143 * We were unable to perform jbd_trylock_bh_state() inside j_list_lock.
144 * The caller must restart a list walk. Wait for someone else to run
145 * jbd_unlock_bh_state().
146 */
147static void jbd_sync_bh(journal_t *journal, struct buffer_head *bh)
148 __releases(journal->j_list_lock)
149{
150 get_bh(bh);
151 spin_unlock(&journal->j_list_lock);
152 jbd_lock_bh_state(bh);
153 jbd_unlock_bh_state(bh);
154 put_bh(bh);
155}
156
157/*
158 * Clean up transaction's list of buffers submitted for io.
159 * We wait for any pending IO to complete and remove any clean
160 * buffers. Note that we take the buffers in the opposite ordering
161 * from the one in which they were submitted for IO.
162 *
163 * Called with j_list_lock held.
164 */
165static void __wait_cp_io(journal_t *journal, transaction_t *transaction)
166{
167 struct journal_head *jh;
168 struct buffer_head *bh;
169 tid_t this_tid;
170 int released = 0;
171
172 this_tid = transaction->t_tid;
173restart:
174 /* Did somebody clean up the transaction in the meanwhile? */
175 if (journal->j_checkpoint_transactions != transaction ||
176 transaction->t_tid != this_tid)
177 return;
178 while (!released && transaction->t_checkpoint_io_list) {
179 jh = transaction->t_checkpoint_io_list;
180 bh = jh2bh(jh);
181 if (!jbd_trylock_bh_state(bh)) {
182 jbd_sync_bh(journal, bh);
183 spin_lock(&journal->j_list_lock);
184 goto restart;
185 }
186 if (buffer_locked(bh)) {
187 atomic_inc(&bh->b_count);
188 spin_unlock(&journal->j_list_lock);
189 jbd_unlock_bh_state(bh);
190 wait_on_buffer(bh);
191 /* the journal_head may have gone by now */
192 BUFFER_TRACE(bh, "brelse");
193 __brelse(bh);
194 spin_lock(&journal->j_list_lock);
195 goto restart;
196 }
197 /*
198 * Now in whatever state the buffer currently is, we know that
199 * it has been written out and so we can drop it from the list
200 */
201 released = __jbd2_journal_remove_checkpoint(jh);
202 jbd_unlock_bh_state(bh);
203 jbd2_journal_remove_journal_head(bh);
204 __brelse(bh);
205 }
206}
207
208#define NR_BATCH 64
209
210static void
211__flush_batch(journal_t *journal, struct buffer_head **bhs, int *batch_count)
212{
213 int i;
214
215 ll_rw_block(SWRITE, *batch_count, bhs);
216 for (i = 0; i < *batch_count; i++) {
217 struct buffer_head *bh = bhs[i];
218 clear_buffer_jwrite(bh);
219 BUFFER_TRACE(bh, "brelse");
220 __brelse(bh);
221 }
222 *batch_count = 0;
223}
224
225/*
226 * Try to flush one buffer from the checkpoint list to disk.
227 *
228 * Return 1 if something happened which requires us to abort the current
229 * scan of the checkpoint list.
230 *
231 * Called with j_list_lock held and drops it if 1 is returned
232 * Called under jbd_lock_bh_state(jh2bh(jh)), and drops it
233 */
234static int __process_buffer(journal_t *journal, struct journal_head *jh,
235 struct buffer_head **bhs, int *batch_count)
236{
237 struct buffer_head *bh = jh2bh(jh);
238 int ret = 0;
239
240 if (buffer_locked(bh)) {
241 atomic_inc(&bh->b_count);
242 spin_unlock(&journal->j_list_lock);
243 jbd_unlock_bh_state(bh);
244 wait_on_buffer(bh);
245 /* the journal_head may have gone by now */
246 BUFFER_TRACE(bh, "brelse");
247 __brelse(bh);
248 ret = 1;
249 } else if (jh->b_transaction != NULL) {
250 transaction_t *t = jh->b_transaction;
251 tid_t tid = t->t_tid;
252
253 spin_unlock(&journal->j_list_lock);
254 jbd_unlock_bh_state(bh);
255 jbd2_log_start_commit(journal, tid);
256 jbd2_log_wait_commit(journal, tid);
257 ret = 1;
258 } else if (!buffer_dirty(bh)) {
259 J_ASSERT_JH(jh, !buffer_jbddirty(bh));
260 BUFFER_TRACE(bh, "remove from checkpoint");
261 __jbd2_journal_remove_checkpoint(jh);
262 spin_unlock(&journal->j_list_lock);
263 jbd_unlock_bh_state(bh);
264 jbd2_journal_remove_journal_head(bh);
265 __brelse(bh);
266 ret = 1;
267 } else {
268 /*
269 * Important: we are about to write the buffer, and
270 * possibly block, while still holding the journal lock.
271 * We cannot afford to let the transaction logic start
272 * messing around with this buffer before we write it to
273 * disk, as that would break recoverability.
274 */
275 BUFFER_TRACE(bh, "queue");
276 get_bh(bh);
277 J_ASSERT_BH(bh, !buffer_jwrite(bh));
278 set_buffer_jwrite(bh);
279 bhs[*batch_count] = bh;
280 __buffer_relink_io(jh);
281 jbd_unlock_bh_state(bh);
282 (*batch_count)++;
283 if (*batch_count == NR_BATCH) {
284 spin_unlock(&journal->j_list_lock);
285 __flush_batch(journal, bhs, batch_count);
286 ret = 1;
287 }
288 }
289 return ret;
290}
291
292/*
293 * Perform an actual checkpoint. We take the first transaction on the
294 * list of transactions to be checkpointed and send all its buffers
295 * to disk. We submit larger chunks of data at once.
296 *
297 * The journal should be locked before calling this function.
298 */
299int jbd2_log_do_checkpoint(journal_t *journal)
300{
301 transaction_t *transaction;
302 tid_t this_tid;
303 int result;
304
305 jbd_debug(1, "Start checkpoint\n");
306
307 /*
308 * First thing: if there are any transactions in the log which
309 * don't need checkpointing, just eliminate them from the
310 * journal straight away.
311 */
312 result = jbd2_cleanup_journal_tail(journal);
313 jbd_debug(1, "cleanup_journal_tail returned %d\n", result);
314 if (result <= 0)
315 return result;
316
317 /*
318 * OK, we need to start writing disk blocks. Take one transaction
319 * and write it.
320 */
321 spin_lock(&journal->j_list_lock);
322 if (!journal->j_checkpoint_transactions)
323 goto out;
324 transaction = journal->j_checkpoint_transactions;
325 this_tid = transaction->t_tid;
326restart:
327 /*
328 * If someone cleaned up this transaction while we slept, we're
329 * done (maybe it's a new transaction, but it fell at the same
330 * address).
331 */
332 if (journal->j_checkpoint_transactions == transaction &&
333 transaction->t_tid == this_tid) {
334 int batch_count = 0;
335 struct buffer_head *bhs[NR_BATCH];
336 struct journal_head *jh;
337 int retry = 0;
338
339 while (!retry && transaction->t_checkpoint_list) {
340 struct buffer_head *bh;
341
342 jh = transaction->t_checkpoint_list;
343 bh = jh2bh(jh);
344 if (!jbd_trylock_bh_state(bh)) {
345 jbd_sync_bh(journal, bh);
346 retry = 1;
347 break;
348 }
349 retry = __process_buffer(journal, jh, bhs,&batch_count);
350 if (!retry && lock_need_resched(&journal->j_list_lock)){
351 spin_unlock(&journal->j_list_lock);
352 retry = 1;
353 break;
354 }
355 }
356
357 if (batch_count) {
358 if (!retry) {
359 spin_unlock(&journal->j_list_lock);
360 retry = 1;
361 }
362 __flush_batch(journal, bhs, &batch_count);
363 }
364
365 if (retry) {
366 spin_lock(&journal->j_list_lock);
367 goto restart;
368 }
369 /*
370 * Now we have cleaned up the first transaction's checkpoint
371 * list. Let's clean up the second one
372 */
373 __wait_cp_io(journal, transaction);
374 }
375out:
376 spin_unlock(&journal->j_list_lock);
377 result = jbd2_cleanup_journal_tail(journal);
378 if (result < 0)
379 return result;
380 return 0;
381}
382
383/*
384 * Check the list of checkpoint transactions for the journal to see if
385 * we have already got rid of any since the last update of the log tail
386 * in the journal superblock. If so, we can instantly roll the
387 * superblock forward to remove those transactions from the log.
388 *
389 * Return <0 on error, 0 on success, 1 if there was nothing to clean up.
390 *
391 * Called with the journal lock held.
392 *
393 * This is the only part of the journaling code which really needs to be
394 * aware of transaction aborts. Checkpointing involves writing to the
395 * main filesystem area rather than to the journal, so it can proceed
396 * even in abort state, but we must not update the journal superblock if
397 * we have an abort error outstanding.
398 */
399
400int jbd2_cleanup_journal_tail(journal_t *journal)
401{
402 transaction_t * transaction;
403 tid_t first_tid;
404 unsigned long blocknr, freed;
405
406 /* OK, work out the oldest transaction remaining in the log, and
407 * the log block it starts at.
408 *
409 * If the log is now empty, we need to work out which is the
410 * next transaction ID we will write, and where it will
411 * start. */
412
413 spin_lock(&journal->j_state_lock);
414 spin_lock(&journal->j_list_lock);
415 transaction = journal->j_checkpoint_transactions;
416 if (transaction) {
417 first_tid = transaction->t_tid;
418 blocknr = transaction->t_log_start;
419 } else if ((transaction = journal->j_committing_transaction) != NULL) {
420 first_tid = transaction->t_tid;
421 blocknr = transaction->t_log_start;
422 } else if ((transaction = journal->j_running_transaction) != NULL) {
423 first_tid = transaction->t_tid;
424 blocknr = journal->j_head;
425 } else {
426 first_tid = journal->j_transaction_sequence;
427 blocknr = journal->j_head;
428 }
429 spin_unlock(&journal->j_list_lock);
430 J_ASSERT(blocknr != 0);
431
432 /* If the oldest pinned transaction is at the tail of the log
433 already then there's not much we can do right now. */
434 if (journal->j_tail_sequence == first_tid) {
435 spin_unlock(&journal->j_state_lock);
436 return 1;
437 }
438
439 /* OK, update the superblock to recover the freed space.
440 * Physical blocks come first: have we wrapped beyond the end of
441 * the log? */
442 freed = blocknr - journal->j_tail;
443 if (blocknr < journal->j_tail)
444 freed = freed + journal->j_last - journal->j_first;
445
446 jbd_debug(1,
447 "Cleaning journal tail from %d to %d (offset %lu), "
448 "freeing %lu\n",
449 journal->j_tail_sequence, first_tid, blocknr, freed);
450
451 journal->j_free += freed;
452 journal->j_tail_sequence = first_tid;
453 journal->j_tail = blocknr;
454 spin_unlock(&journal->j_state_lock);
455 if (!(journal->j_flags & JBD2_ABORT))
456 jbd2_journal_update_superblock(journal, 1);
457 return 0;
458}
459
460
461/* Checkpoint list management */
462
463/*
464 * journal_clean_one_cp_list
465 *
466 * Find all the written-back checkpoint buffers in the given list and release them.
467 *
468 * Called with the journal locked.
469 * Called with j_list_lock held.
470 * Returns number of bufers reaped (for debug)
471 */
472
473static int journal_clean_one_cp_list(struct journal_head *jh, int *released)
474{
475 struct journal_head *last_jh;
476 struct journal_head *next_jh = jh;
477 int ret, freed = 0;
478
479 *released = 0;
480 if (!jh)
481 return 0;
482
483 last_jh = jh->b_cpprev;
484 do {
485 jh = next_jh;
486 next_jh = jh->b_cpnext;
487 /* Use trylock because of the ranking */
488 if (jbd_trylock_bh_state(jh2bh(jh))) {
489 ret = __try_to_free_cp_buf(jh);
490 if (ret) {
491 freed++;
492 if (ret == 2) {
493 *released = 1;
494 return freed;
495 }
496 }
497 }
498 /*
499 * This function only frees up some memory
500 * if possible so we dont have an obligation
501 * to finish processing. Bail out if preemption
502 * requested:
503 */
504 if (need_resched())
505 return freed;
506 } while (jh != last_jh);
507
508 return freed;
509}
510
511/*
512 * journal_clean_checkpoint_list
513 *
514 * Find all the written-back checkpoint buffers in the journal and release them.
515 *
516 * Called with the journal locked.
517 * Called with j_list_lock held.
518 * Returns number of buffers reaped (for debug)
519 */
520
521int __jbd2_journal_clean_checkpoint_list(journal_t *journal)
522{
523 transaction_t *transaction, *last_transaction, *next_transaction;
524 int ret = 0;
525 int released;
526
527 transaction = journal->j_checkpoint_transactions;
528 if (!transaction)
529 goto out;
530
531 last_transaction = transaction->t_cpprev;
532 next_transaction = transaction;
533 do {
534 transaction = next_transaction;
535 next_transaction = transaction->t_cpnext;
536 ret += journal_clean_one_cp_list(transaction->
537 t_checkpoint_list, &released);
538 /*
539 * This function only frees up some memory if possible so we
540 * dont have an obligation to finish processing. Bail out if
541 * preemption requested:
542 */
543 if (need_resched())
544 goto out;
545 if (released)
546 continue;
547 /*
548 * It is essential that we are as careful as in the case of
549 * t_checkpoint_list with removing the buffer from the list as
550 * we can possibly see not yet submitted buffers on io_list
551 */
552 ret += journal_clean_one_cp_list(transaction->
553 t_checkpoint_io_list, &released);
554 if (need_resched())
555 goto out;
556 } while (transaction != last_transaction);
557out:
558 return ret;
559}
560
561/*
562 * journal_remove_checkpoint: called after a buffer has been committed
563 * to disk (either by being write-back flushed to disk, or being
564 * committed to the log).
565 *
566 * We cannot safely clean a transaction out of the log until all of the
567 * buffer updates committed in that transaction have safely been stored
568 * elsewhere on disk. To achieve this, all of the buffers in a
569 * transaction need to be maintained on the transaction's checkpoint
570 * lists until they have been rewritten, at which point this function is
571 * called to remove the buffer from the existing transaction's
572 * checkpoint lists.
573 *
574 * The function returns 1 if it frees the transaction, 0 otherwise.
575 *
576 * This function is called with the journal locked.
577 * This function is called with j_list_lock held.
578 * This function is called with jbd_lock_bh_state(jh2bh(jh))
579 */
580
581int __jbd2_journal_remove_checkpoint(struct journal_head *jh)
582{
583 transaction_t *transaction;
584 journal_t *journal;
585 int ret = 0;
586
587 JBUFFER_TRACE(jh, "entry");
588
589 if ((transaction = jh->b_cp_transaction) == NULL) {
590 JBUFFER_TRACE(jh, "not on transaction");
591 goto out;
592 }
593 journal = transaction->t_journal;
594
595 __buffer_unlink(jh);
596 jh->b_cp_transaction = NULL;
597
598 if (transaction->t_checkpoint_list != NULL ||
599 transaction->t_checkpoint_io_list != NULL)
600 goto out;
601 JBUFFER_TRACE(jh, "transaction has no more buffers");
602
603 /*
604 * There is one special case to worry about: if we have just pulled the
605 * buffer off a committing transaction's forget list, then even if the
606 * checkpoint list is empty, the transaction obviously cannot be
607 * dropped!
608 *
609 * The locking here around j_committing_transaction is a bit sleazy.
610 * See the comment at the end of jbd2_journal_commit_transaction().
611 */
612 if (transaction == journal->j_committing_transaction) {
613 JBUFFER_TRACE(jh, "belongs to committing transaction");
614 goto out;
615 }
616
617 /* OK, that was the last buffer for the transaction: we can now
618 safely remove this transaction from the log */
619
620 __jbd2_journal_drop_transaction(journal, transaction);
621
622 /* Just in case anybody was waiting for more transactions to be
623 checkpointed... */
624 wake_up(&journal->j_wait_logspace);
625 ret = 1;
626out:
627 JBUFFER_TRACE(jh, "exit");
628 return ret;
629}
630
631/*
632 * journal_insert_checkpoint: put a committed buffer onto a checkpoint
633 * list so that we know when it is safe to clean the transaction out of
634 * the log.
635 *
636 * Called with the journal locked.
637 * Called with j_list_lock held.
638 */
639void __jbd2_journal_insert_checkpoint(struct journal_head *jh,
640 transaction_t *transaction)
641{
642 JBUFFER_TRACE(jh, "entry");
643 J_ASSERT_JH(jh, buffer_dirty(jh2bh(jh)) || buffer_jbddirty(jh2bh(jh)));
644 J_ASSERT_JH(jh, jh->b_cp_transaction == NULL);
645
646 jh->b_cp_transaction = transaction;
647
648 if (!transaction->t_checkpoint_list) {
649 jh->b_cpnext = jh->b_cpprev = jh;
650 } else {
651 jh->b_cpnext = transaction->t_checkpoint_list;
652 jh->b_cpprev = transaction->t_checkpoint_list->b_cpprev;
653 jh->b_cpprev->b_cpnext = jh;
654 jh->b_cpnext->b_cpprev = jh;
655 }
656 transaction->t_checkpoint_list = jh;
657}
658
659/*
660 * We've finished with this transaction structure: adios...
661 *
662 * The transaction must have no links except for the checkpoint by this
663 * point.
664 *
665 * Called with the journal locked.
666 * Called with j_list_lock held.
667 */
668
669void __jbd2_journal_drop_transaction(journal_t *journal, transaction_t *transaction)
670{
671 assert_spin_locked(&journal->j_list_lock);
672 if (transaction->t_cpnext) {
673 transaction->t_cpnext->t_cpprev = transaction->t_cpprev;
674 transaction->t_cpprev->t_cpnext = transaction->t_cpnext;
675 if (journal->j_checkpoint_transactions == transaction)
676 journal->j_checkpoint_transactions =
677 transaction->t_cpnext;
678 if (journal->j_checkpoint_transactions == transaction)
679 journal->j_checkpoint_transactions = NULL;
680 }
681
682 J_ASSERT(transaction->t_state == T_FINISHED);
683 J_ASSERT(transaction->t_buffers == NULL);
684 J_ASSERT(transaction->t_sync_datalist == NULL);
685 J_ASSERT(transaction->t_forget == NULL);
686 J_ASSERT(transaction->t_iobuf_list == NULL);
687 J_ASSERT(transaction->t_shadow_list == NULL);
688 J_ASSERT(transaction->t_log_list == NULL);
689 J_ASSERT(transaction->t_checkpoint_list == NULL);
690 J_ASSERT(transaction->t_checkpoint_io_list == NULL);
691 J_ASSERT(transaction->t_updates == 0);
692 J_ASSERT(journal->j_committing_transaction != transaction);
693 J_ASSERT(journal->j_running_transaction != transaction);
694
695 jbd_debug(1, "Dropping transaction %d, all done\n", transaction->t_tid);
696 kfree(transaction);
697}
diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
new file mode 100644
index 000000000000..70b2ae1ef281
--- /dev/null
+++ b/fs/jbd2/commit.c
@@ -0,0 +1,920 @@
1/*
2 * linux/fs/jbd2/commit.c
3 *
4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1998
5 *
6 * Copyright 1998 Red Hat corp --- All Rights Reserved
7 *
8 * This file is part of the Linux kernel and is made available under
9 * the terms of the GNU General Public License, version 2, or at your
10 * option, any later version, incorporated herein by reference.
11 *
12 * Journal commit routines for the generic filesystem journaling code;
13 * part of the ext2fs journaling system.
14 */
15
16#include <linux/time.h>
17#include <linux/fs.h>
18#include <linux/jbd2.h>
19#include <linux/errno.h>
20#include <linux/slab.h>
21#include <linux/mm.h>
22#include <linux/pagemap.h>
23#include <linux/smp_lock.h>
24
25/*
26 * Default IO end handler for temporary BJ_IO buffer_heads.
27 */
28static void journal_end_buffer_io_sync(struct buffer_head *bh, int uptodate)
29{
30 BUFFER_TRACE(bh, "");
31 if (uptodate)
32 set_buffer_uptodate(bh);
33 else
34 clear_buffer_uptodate(bh);
35 unlock_buffer(bh);
36}
37
38/*
39 * When an ext3-ordered file is truncated, it is possible that many pages are
40 * not sucessfully freed, because they are attached to a committing transaction.
41 * After the transaction commits, these pages are left on the LRU, with no
42 * ->mapping, and with attached buffers. These pages are trivially reclaimable
43 * by the VM, but their apparent absence upsets the VM accounting, and it makes
44 * the numbers in /proc/meminfo look odd.
45 *
46 * So here, we have a buffer which has just come off the forget list. Look to
47 * see if we can strip all buffers from the backing page.
48 *
49 * Called under lock_journal(), and possibly under journal_datalist_lock. The
50 * caller provided us with a ref against the buffer, and we drop that here.
51 */
52static void release_buffer_page(struct buffer_head *bh)
53{
54 struct page *page;
55
56 if (buffer_dirty(bh))
57 goto nope;
58 if (atomic_read(&bh->b_count) != 1)
59 goto nope;
60 page = bh->b_page;
61 if (!page)
62 goto nope;
63 if (page->mapping)
64 goto nope;
65
66 /* OK, it's a truncated page */
67 if (TestSetPageLocked(page))
68 goto nope;
69
70 page_cache_get(page);
71 __brelse(bh);
72 try_to_free_buffers(page);
73 unlock_page(page);
74 page_cache_release(page);
75 return;
76
77nope:
78 __brelse(bh);
79}
80
81/*
82 * Try to acquire jbd_lock_bh_state() against the buffer, when j_list_lock is
83 * held. For ranking reasons we must trylock. If we lose, schedule away and
84 * return 0. j_list_lock is dropped in this case.
85 */
86static int inverted_lock(journal_t *journal, struct buffer_head *bh)
87{
88 if (!jbd_trylock_bh_state(bh)) {
89 spin_unlock(&journal->j_list_lock);
90 schedule();
91 return 0;
92 }
93 return 1;
94}
95
96/* Done it all: now write the commit record. We should have
97 * cleaned up our previous buffers by now, so if we are in abort
98 * mode we can now just skip the rest of the journal write
99 * entirely.
100 *
101 * Returns 1 if the journal needs to be aborted or 0 on success
102 */
103static int journal_write_commit_record(journal_t *journal,
104 transaction_t *commit_transaction)
105{
106 struct journal_head *descriptor;
107 struct buffer_head *bh;
108 int i, ret;
109 int barrier_done = 0;
110
111 if (is_journal_aborted(journal))
112 return 0;
113
114 descriptor = jbd2_journal_get_descriptor_buffer(journal);
115 if (!descriptor)
116 return 1;
117
118 bh = jh2bh(descriptor);
119
120 /* AKPM: buglet - add `i' to tmp! */
121 for (i = 0; i < bh->b_size; i += 512) {
122 journal_header_t *tmp = (journal_header_t*)bh->b_data;
123 tmp->h_magic = cpu_to_be32(JBD2_MAGIC_NUMBER);
124 tmp->h_blocktype = cpu_to_be32(JBD2_COMMIT_BLOCK);
125 tmp->h_sequence = cpu_to_be32(commit_transaction->t_tid);
126 }
127
128 JBUFFER_TRACE(descriptor, "write commit block");
129 set_buffer_dirty(bh);
130 if (journal->j_flags & JBD2_BARRIER) {
131 set_buffer_ordered(bh);
132 barrier_done = 1;
133 }
134 ret = sync_dirty_buffer(bh);
135 /* is it possible for another commit to fail at roughly
136 * the same time as this one? If so, we don't want to
137 * trust the barrier flag in the super, but instead want
138 * to remember if we sent a barrier request
139 */
140 if (ret == -EOPNOTSUPP && barrier_done) {
141 char b[BDEVNAME_SIZE];
142
143 printk(KERN_WARNING
144 "JBD: barrier-based sync failed on %s - "
145 "disabling barriers\n",
146 bdevname(journal->j_dev, b));
147 spin_lock(&journal->j_state_lock);
148 journal->j_flags &= ~JBD2_BARRIER;
149 spin_unlock(&journal->j_state_lock);
150
151 /* And try again, without the barrier */
152 clear_buffer_ordered(bh);
153 set_buffer_uptodate(bh);
154 set_buffer_dirty(bh);
155 ret = sync_dirty_buffer(bh);
156 }
157 put_bh(bh); /* One for getblk() */
158 jbd2_journal_put_journal_head(descriptor);
159
160 return (ret == -EIO);
161}
162
163static void journal_do_submit_data(struct buffer_head **wbuf, int bufs)
164{
165 int i;
166
167 for (i = 0; i < bufs; i++) {
168 wbuf[i]->b_end_io = end_buffer_write_sync;
169 /* We use-up our safety reference in submit_bh() */
170 submit_bh(WRITE, wbuf[i]);
171 }
172}
173
174/*
175 * Submit all the data buffers to disk
176 */
177static void journal_submit_data_buffers(journal_t *journal,
178 transaction_t *commit_transaction)
179{
180 struct journal_head *jh;
181 struct buffer_head *bh;
182 int locked;
183 int bufs = 0;
184 struct buffer_head **wbuf = journal->j_wbuf;
185
186 /*
187 * Whenever we unlock the journal and sleep, things can get added
188 * onto ->t_sync_datalist, so we have to keep looping back to
189 * write_out_data until we *know* that the list is empty.
190 *
191 * Cleanup any flushed data buffers from the data list. Even in
192 * abort mode, we want to flush this out as soon as possible.
193 */
194write_out_data:
195 cond_resched();
196 spin_lock(&journal->j_list_lock);
197
198 while (commit_transaction->t_sync_datalist) {
199 jh = commit_transaction->t_sync_datalist;
200 bh = jh2bh(jh);
201 locked = 0;
202
203 /* Get reference just to make sure buffer does not disappear
204 * when we are forced to drop various locks */
205 get_bh(bh);
206 /* If the buffer is dirty, we need to submit IO and hence
207 * we need the buffer lock. We try to lock the buffer without
208 * blocking. If we fail, we need to drop j_list_lock and do
209 * blocking lock_buffer().
210 */
211 if (buffer_dirty(bh)) {
212 if (test_set_buffer_locked(bh)) {
213 BUFFER_TRACE(bh, "needs blocking lock");
214 spin_unlock(&journal->j_list_lock);
215 /* Write out all data to prevent deadlocks */
216 journal_do_submit_data(wbuf, bufs);
217 bufs = 0;
218 lock_buffer(bh);
219 spin_lock(&journal->j_list_lock);
220 }
221 locked = 1;
222 }
223 /* We have to get bh_state lock. Again out of order, sigh. */
224 if (!inverted_lock(journal, bh)) {
225 jbd_lock_bh_state(bh);
226 spin_lock(&journal->j_list_lock);
227 }
228 /* Someone already cleaned up the buffer? */
229 if (!buffer_jbd(bh)
230 || jh->b_transaction != commit_transaction
231 || jh->b_jlist != BJ_SyncData) {
232 jbd_unlock_bh_state(bh);
233 if (locked)
234 unlock_buffer(bh);
235 BUFFER_TRACE(bh, "already cleaned up");
236 put_bh(bh);
237 continue;
238 }
239 if (locked && test_clear_buffer_dirty(bh)) {
240 BUFFER_TRACE(bh, "needs writeout, adding to array");
241 wbuf[bufs++] = bh;
242 __jbd2_journal_file_buffer(jh, commit_transaction,
243 BJ_Locked);
244 jbd_unlock_bh_state(bh);
245 if (bufs == journal->j_wbufsize) {
246 spin_unlock(&journal->j_list_lock);
247 journal_do_submit_data(wbuf, bufs);
248 bufs = 0;
249 goto write_out_data;
250 }
251 }
252 else {
253 BUFFER_TRACE(bh, "writeout complete: unfile");
254 __jbd2_journal_unfile_buffer(jh);
255 jbd_unlock_bh_state(bh);
256 if (locked)
257 unlock_buffer(bh);
258 jbd2_journal_remove_journal_head(bh);
259 /* Once for our safety reference, once for
260 * jbd2_journal_remove_journal_head() */
261 put_bh(bh);
262 put_bh(bh);
263 }
264
265 if (lock_need_resched(&journal->j_list_lock)) {
266 spin_unlock(&journal->j_list_lock);
267 goto write_out_data;
268 }
269 }
270 spin_unlock(&journal->j_list_lock);
271 journal_do_submit_data(wbuf, bufs);
272}
273
274static inline void write_tag_block(int tag_bytes, journal_block_tag_t *tag,
275 unsigned long long block)
276{
277 tag->t_blocknr = cpu_to_be32(block & (u32)~0);
278 if (tag_bytes > JBD_TAG_SIZE32)
279 tag->t_blocknr_high = cpu_to_be32((block >> 31) >> 1);
280}
281
282/*
283 * jbd2_journal_commit_transaction
284 *
285 * The primary function for committing a transaction to the log. This
286 * function is called by the journal thread to begin a complete commit.
287 */
288void jbd2_journal_commit_transaction(journal_t *journal)
289{
290 transaction_t *commit_transaction;
291 struct journal_head *jh, *new_jh, *descriptor;
292 struct buffer_head **wbuf = journal->j_wbuf;
293 int bufs;
294 int flags;
295 int err;
296 unsigned long long blocknr;
297 char *tagp = NULL;
298 journal_header_t *header;
299 journal_block_tag_t *tag = NULL;
300 int space_left = 0;
301 int first_tag = 0;
302 int tag_flag;
303 int i;
304 int tag_bytes = journal_tag_bytes(journal);
305
306 /*
307 * First job: lock down the current transaction and wait for
308 * all outstanding updates to complete.
309 */
310
311#ifdef COMMIT_STATS
312 spin_lock(&journal->j_list_lock);
313 summarise_journal_usage(journal);
314 spin_unlock(&journal->j_list_lock);
315#endif
316
317 /* Do we need to erase the effects of a prior jbd2_journal_flush? */
318 if (journal->j_flags & JBD2_FLUSHED) {
319 jbd_debug(3, "super block updated\n");
320 jbd2_journal_update_superblock(journal, 1);
321 } else {
322 jbd_debug(3, "superblock not updated\n");
323 }
324
325 J_ASSERT(journal->j_running_transaction != NULL);
326 J_ASSERT(journal->j_committing_transaction == NULL);
327
328 commit_transaction = journal->j_running_transaction;
329 J_ASSERT(commit_transaction->t_state == T_RUNNING);
330
331 jbd_debug(1, "JBD: starting commit of transaction %d\n",
332 commit_transaction->t_tid);
333
334 spin_lock(&journal->j_state_lock);
335 commit_transaction->t_state = T_LOCKED;
336
337 spin_lock(&commit_transaction->t_handle_lock);
338 while (commit_transaction->t_updates) {
339 DEFINE_WAIT(wait);
340
341 prepare_to_wait(&journal->j_wait_updates, &wait,
342 TASK_UNINTERRUPTIBLE);
343 if (commit_transaction->t_updates) {
344 spin_unlock(&commit_transaction->t_handle_lock);
345 spin_unlock(&journal->j_state_lock);
346 schedule();
347 spin_lock(&journal->j_state_lock);
348 spin_lock(&commit_transaction->t_handle_lock);
349 }
350 finish_wait(&journal->j_wait_updates, &wait);
351 }
352 spin_unlock(&commit_transaction->t_handle_lock);
353
354 J_ASSERT (commit_transaction->t_outstanding_credits <=
355 journal->j_max_transaction_buffers);
356
357 /*
358 * First thing we are allowed to do is to discard any remaining
359 * BJ_Reserved buffers. Note, it is _not_ permissible to assume
360 * that there are no such buffers: if a large filesystem
361 * operation like a truncate needs to split itself over multiple
362 * transactions, then it may try to do a jbd2_journal_restart() while
363 * there are still BJ_Reserved buffers outstanding. These must
364 * be released cleanly from the current transaction.
365 *
366 * In this case, the filesystem must still reserve write access
367 * again before modifying the buffer in the new transaction, but
368 * we do not require it to remember exactly which old buffers it
369 * has reserved. This is consistent with the existing behaviour
370 * that multiple jbd2_journal_get_write_access() calls to the same
371 * buffer are perfectly permissable.
372 */
373 while (commit_transaction->t_reserved_list) {
374 jh = commit_transaction->t_reserved_list;
375 JBUFFER_TRACE(jh, "reserved, unused: refile");
376 /*
377 * A jbd2_journal_get_undo_access()+jbd2_journal_release_buffer() may
378 * leave undo-committed data.
379 */
380 if (jh->b_committed_data) {
381 struct buffer_head *bh = jh2bh(jh);
382
383 jbd_lock_bh_state(bh);
384 jbd2_slab_free(jh->b_committed_data, bh->b_size);
385 jh->b_committed_data = NULL;
386 jbd_unlock_bh_state(bh);
387 }
388 jbd2_journal_refile_buffer(journal, jh);
389 }
390
391 /*
392 * Now try to drop any written-back buffers from the journal's
393 * checkpoint lists. We do this *before* commit because it potentially
394 * frees some memory
395 */
396 spin_lock(&journal->j_list_lock);
397 __jbd2_journal_clean_checkpoint_list(journal);
398 spin_unlock(&journal->j_list_lock);
399
400 jbd_debug (3, "JBD: commit phase 1\n");
401
402 /*
403 * Switch to a new revoke table.
404 */
405 jbd2_journal_switch_revoke_table(journal);
406
407 commit_transaction->t_state = T_FLUSH;
408 journal->j_committing_transaction = commit_transaction;
409 journal->j_running_transaction = NULL;
410 commit_transaction->t_log_start = journal->j_head;
411 wake_up(&journal->j_wait_transaction_locked);
412 spin_unlock(&journal->j_state_lock);
413
414 jbd_debug (3, "JBD: commit phase 2\n");
415
416 /*
417 * First, drop modified flag: all accesses to the buffers
418 * will be tracked for a new trasaction only -bzzz
419 */
420 spin_lock(&journal->j_list_lock);
421 if (commit_transaction->t_buffers) {
422 new_jh = jh = commit_transaction->t_buffers->b_tnext;
423 do {
424 J_ASSERT_JH(new_jh, new_jh->b_modified == 1 ||
425 new_jh->b_modified == 0);
426 new_jh->b_modified = 0;
427 new_jh = new_jh->b_tnext;
428 } while (new_jh != jh);
429 }
430 spin_unlock(&journal->j_list_lock);
431
432 /*
433 * Now start flushing things to disk, in the order they appear
434 * on the transaction lists. Data blocks go first.
435 */
436 err = 0;
437 journal_submit_data_buffers(journal, commit_transaction);
438
439 /*
440 * Wait for all previously submitted IO to complete.
441 */
442 spin_lock(&journal->j_list_lock);
443 while (commit_transaction->t_locked_list) {
444 struct buffer_head *bh;
445
446 jh = commit_transaction->t_locked_list->b_tprev;
447 bh = jh2bh(jh);
448 get_bh(bh);
449 if (buffer_locked(bh)) {
450 spin_unlock(&journal->j_list_lock);
451 wait_on_buffer(bh);
452 if (unlikely(!buffer_uptodate(bh)))
453 err = -EIO;
454 spin_lock(&journal->j_list_lock);
455 }
456 if (!inverted_lock(journal, bh)) {
457 put_bh(bh);
458 spin_lock(&journal->j_list_lock);
459 continue;
460 }
461 if (buffer_jbd(bh) && jh->b_jlist == BJ_Locked) {
462 __jbd2_journal_unfile_buffer(jh);
463 jbd_unlock_bh_state(bh);
464 jbd2_journal_remove_journal_head(bh);
465 put_bh(bh);
466 } else {
467 jbd_unlock_bh_state(bh);
468 }
469 put_bh(bh);
470 cond_resched_lock(&journal->j_list_lock);
471 }
472 spin_unlock(&journal->j_list_lock);
473
474 if (err)
475 __jbd2_journal_abort_hard(journal);
476
477 jbd2_journal_write_revoke_records(journal, commit_transaction);
478
479 jbd_debug(3, "JBD: commit phase 2\n");
480
481 /*
482 * If we found any dirty or locked buffers, then we should have
483 * looped back up to the write_out_data label. If there weren't
484 * any then journal_clean_data_list should have wiped the list
485 * clean by now, so check that it is in fact empty.
486 */
487 J_ASSERT (commit_transaction->t_sync_datalist == NULL);
488
489 jbd_debug (3, "JBD: commit phase 3\n");
490
491 /*
492 * Way to go: we have now written out all of the data for a
493 * transaction! Now comes the tricky part: we need to write out
494 * metadata. Loop over the transaction's entire buffer list:
495 */
496 commit_transaction->t_state = T_COMMIT;
497
498 descriptor = NULL;
499 bufs = 0;
500 while (commit_transaction->t_buffers) {
501
502 /* Find the next buffer to be journaled... */
503
504 jh = commit_transaction->t_buffers;
505
506 /* If we're in abort mode, we just un-journal the buffer and
507 release it for background writing. */
508
509 if (is_journal_aborted(journal)) {
510 JBUFFER_TRACE(jh, "journal is aborting: refile");
511 jbd2_journal_refile_buffer(journal, jh);
512 /* If that was the last one, we need to clean up
513 * any descriptor buffers which may have been
514 * already allocated, even if we are now
515 * aborting. */
516 if (!commit_transaction->t_buffers)
517 goto start_journal_io;
518 continue;
519 }
520
521 /* Make sure we have a descriptor block in which to
522 record the metadata buffer. */
523
524 if (!descriptor) {
525 struct buffer_head *bh;
526
527 J_ASSERT (bufs == 0);
528
529 jbd_debug(4, "JBD: get descriptor\n");
530
531 descriptor = jbd2_journal_get_descriptor_buffer(journal);
532 if (!descriptor) {
533 __jbd2_journal_abort_hard(journal);
534 continue;
535 }
536
537 bh = jh2bh(descriptor);
538 jbd_debug(4, "JBD: got buffer %llu (%p)\n",
539 (unsigned long long)bh->b_blocknr, bh->b_data);
540 header = (journal_header_t *)&bh->b_data[0];
541 header->h_magic = cpu_to_be32(JBD2_MAGIC_NUMBER);
542 header->h_blocktype = cpu_to_be32(JBD2_DESCRIPTOR_BLOCK);
543 header->h_sequence = cpu_to_be32(commit_transaction->t_tid);
544
545 tagp = &bh->b_data[sizeof(journal_header_t)];
546 space_left = bh->b_size - sizeof(journal_header_t);
547 first_tag = 1;
548 set_buffer_jwrite(bh);
549 set_buffer_dirty(bh);
550 wbuf[bufs++] = bh;
551
552 /* Record it so that we can wait for IO
553 completion later */
554 BUFFER_TRACE(bh, "ph3: file as descriptor");
555 jbd2_journal_file_buffer(descriptor, commit_transaction,
556 BJ_LogCtl);
557 }
558
559 /* Where is the buffer to be written? */
560
561 err = jbd2_journal_next_log_block(journal, &blocknr);
562 /* If the block mapping failed, just abandon the buffer
563 and repeat this loop: we'll fall into the
564 refile-on-abort condition above. */
565 if (err) {
566 __jbd2_journal_abort_hard(journal);
567 continue;
568 }
569
570 /*
571 * start_this_handle() uses t_outstanding_credits to determine
572 * the free space in the log, but this counter is changed
573 * by jbd2_journal_next_log_block() also.
574 */
575 commit_transaction->t_outstanding_credits--;
576
577 /* Bump b_count to prevent truncate from stumbling over
578 the shadowed buffer! @@@ This can go if we ever get
579 rid of the BJ_IO/BJ_Shadow pairing of buffers. */
580 atomic_inc(&jh2bh(jh)->b_count);
581
582 /* Make a temporary IO buffer with which to write it out
583 (this will requeue both the metadata buffer and the
584 temporary IO buffer). new_bh goes on BJ_IO*/
585
586 set_bit(BH_JWrite, &jh2bh(jh)->b_state);
587 /*
588 * akpm: jbd2_journal_write_metadata_buffer() sets
589 * new_bh->b_transaction to commit_transaction.
590 * We need to clean this up before we release new_bh
591 * (which is of type BJ_IO)
592 */
593 JBUFFER_TRACE(jh, "ph3: write metadata");
594 flags = jbd2_journal_write_metadata_buffer(commit_transaction,
595 jh, &new_jh, blocknr);
596 set_bit(BH_JWrite, &jh2bh(new_jh)->b_state);
597 wbuf[bufs++] = jh2bh(new_jh);
598
599 /* Record the new block's tag in the current descriptor
600 buffer */
601
602 tag_flag = 0;
603 if (flags & 1)
604 tag_flag |= JBD2_FLAG_ESCAPE;
605 if (!first_tag)
606 tag_flag |= JBD2_FLAG_SAME_UUID;
607
608 tag = (journal_block_tag_t *) tagp;
609 write_tag_block(tag_bytes, tag, jh2bh(jh)->b_blocknr);
610 tag->t_flags = cpu_to_be32(tag_flag);
611 tagp += tag_bytes;
612 space_left -= tag_bytes;
613
614 if (first_tag) {
615 memcpy (tagp, journal->j_uuid, 16);
616 tagp += 16;
617 space_left -= 16;
618 first_tag = 0;
619 }
620
621 /* If there's no more to do, or if the descriptor is full,
622 let the IO rip! */
623
624 if (bufs == journal->j_wbufsize ||
625 commit_transaction->t_buffers == NULL ||
626 space_left < tag_bytes + 16) {
627
628 jbd_debug(4, "JBD: Submit %d IOs\n", bufs);
629
630 /* Write an end-of-descriptor marker before
631 submitting the IOs. "tag" still points to
632 the last tag we set up. */
633
634 tag->t_flags |= cpu_to_be32(JBD2_FLAG_LAST_TAG);
635
636start_journal_io:
637 for (i = 0; i < bufs; i++) {
638 struct buffer_head *bh = wbuf[i];
639 lock_buffer(bh);
640 clear_buffer_dirty(bh);
641 set_buffer_uptodate(bh);
642 bh->b_end_io = journal_end_buffer_io_sync;
643 submit_bh(WRITE, bh);
644 }
645 cond_resched();
646
647 /* Force a new descriptor to be generated next
648 time round the loop. */
649 descriptor = NULL;
650 bufs = 0;
651 }
652 }
653
654 /* Lo and behold: we have just managed to send a transaction to
655 the log. Before we can commit it, wait for the IO so far to
656 complete. Control buffers being written are on the
657 transaction's t_log_list queue, and metadata buffers are on
658 the t_iobuf_list queue.
659
660 Wait for the buffers in reverse order. That way we are
661 less likely to be woken up until all IOs have completed, and
662 so we incur less scheduling load.
663 */
664
665 jbd_debug(3, "JBD: commit phase 4\n");
666
667 /*
668 * akpm: these are BJ_IO, and j_list_lock is not needed.
669 * See __journal_try_to_free_buffer.
670 */
671wait_for_iobuf:
672 while (commit_transaction->t_iobuf_list != NULL) {
673 struct buffer_head *bh;
674
675 jh = commit_transaction->t_iobuf_list->b_tprev;
676 bh = jh2bh(jh);
677 if (buffer_locked(bh)) {
678 wait_on_buffer(bh);
679 goto wait_for_iobuf;
680 }
681 if (cond_resched())
682 goto wait_for_iobuf;
683
684 if (unlikely(!buffer_uptodate(bh)))
685 err = -EIO;
686
687 clear_buffer_jwrite(bh);
688
689 JBUFFER_TRACE(jh, "ph4: unfile after journal write");
690 jbd2_journal_unfile_buffer(journal, jh);
691
692 /*
693 * ->t_iobuf_list should contain only dummy buffer_heads
694 * which were created by jbd2_journal_write_metadata_buffer().
695 */
696 BUFFER_TRACE(bh, "dumping temporary bh");
697 jbd2_journal_put_journal_head(jh);
698 __brelse(bh);
699 J_ASSERT_BH(bh, atomic_read(&bh->b_count) == 0);
700 free_buffer_head(bh);
701
702 /* We also have to unlock and free the corresponding
703 shadowed buffer */
704 jh = commit_transaction->t_shadow_list->b_tprev;
705 bh = jh2bh(jh);
706 clear_bit(BH_JWrite, &bh->b_state);
707 J_ASSERT_BH(bh, buffer_jbddirty(bh));
708
709 /* The metadata is now released for reuse, but we need
710 to remember it against this transaction so that when
711 we finally commit, we can do any checkpointing
712 required. */
713 JBUFFER_TRACE(jh, "file as BJ_Forget");
714 jbd2_journal_file_buffer(jh, commit_transaction, BJ_Forget);
715 /* Wake up any transactions which were waiting for this
716 IO to complete */
717 wake_up_bit(&bh->b_state, BH_Unshadow);
718 JBUFFER_TRACE(jh, "brelse shadowed buffer");
719 __brelse(bh);
720 }
721
722 J_ASSERT (commit_transaction->t_shadow_list == NULL);
723
724 jbd_debug(3, "JBD: commit phase 5\n");
725
726 /* Here we wait for the revoke record and descriptor record buffers */
727 wait_for_ctlbuf:
728 while (commit_transaction->t_log_list != NULL) {
729 struct buffer_head *bh;
730
731 jh = commit_transaction->t_log_list->b_tprev;
732 bh = jh2bh(jh);
733 if (buffer_locked(bh)) {
734 wait_on_buffer(bh);
735 goto wait_for_ctlbuf;
736 }
737 if (cond_resched())
738 goto wait_for_ctlbuf;
739
740 if (unlikely(!buffer_uptodate(bh)))
741 err = -EIO;
742
743 BUFFER_TRACE(bh, "ph5: control buffer writeout done: unfile");
744 clear_buffer_jwrite(bh);
745 jbd2_journal_unfile_buffer(journal, jh);
746 jbd2_journal_put_journal_head(jh);
747 __brelse(bh); /* One for getblk */
748 /* AKPM: bforget here */
749 }
750
751 jbd_debug(3, "JBD: commit phase 6\n");
752
753 if (journal_write_commit_record(journal, commit_transaction))
754 err = -EIO;
755
756 if (err)
757 __jbd2_journal_abort_hard(journal);
758
759 /* End of a transaction! Finally, we can do checkpoint
760 processing: any buffers committed as a result of this
761 transaction can be removed from any checkpoint list it was on
762 before. */
763
764 jbd_debug(3, "JBD: commit phase 7\n");
765
766 J_ASSERT(commit_transaction->t_sync_datalist == NULL);
767 J_ASSERT(commit_transaction->t_buffers == NULL);
768 J_ASSERT(commit_transaction->t_checkpoint_list == NULL);
769 J_ASSERT(commit_transaction->t_iobuf_list == NULL);
770 J_ASSERT(commit_transaction->t_shadow_list == NULL);
771 J_ASSERT(commit_transaction->t_log_list == NULL);
772
773restart_loop:
774 /*
775 * As there are other places (journal_unmap_buffer()) adding buffers
776 * to this list we have to be careful and hold the j_list_lock.
777 */
778 spin_lock(&journal->j_list_lock);
779 while (commit_transaction->t_forget) {
780 transaction_t *cp_transaction;
781 struct buffer_head *bh;
782
783 jh = commit_transaction->t_forget;
784 spin_unlock(&journal->j_list_lock);
785 bh = jh2bh(jh);
786 jbd_lock_bh_state(bh);
787 J_ASSERT_JH(jh, jh->b_transaction == commit_transaction ||
788 jh->b_transaction == journal->j_running_transaction);
789
790 /*
791 * If there is undo-protected committed data against
792 * this buffer, then we can remove it now. If it is a
793 * buffer needing such protection, the old frozen_data
794 * field now points to a committed version of the
795 * buffer, so rotate that field to the new committed
796 * data.
797 *
798 * Otherwise, we can just throw away the frozen data now.
799 */
800 if (jh->b_committed_data) {
801 jbd2_slab_free(jh->b_committed_data, bh->b_size);
802 jh->b_committed_data = NULL;
803 if (jh->b_frozen_data) {
804 jh->b_committed_data = jh->b_frozen_data;
805 jh->b_frozen_data = NULL;
806 }
807 } else if (jh->b_frozen_data) {
808 jbd2_slab_free(jh->b_frozen_data, bh->b_size);
809 jh->b_frozen_data = NULL;
810 }
811
812 spin_lock(&journal->j_list_lock);
813 cp_transaction = jh->b_cp_transaction;
814 if (cp_transaction) {
815 JBUFFER_TRACE(jh, "remove from old cp transaction");
816 __jbd2_journal_remove_checkpoint(jh);
817 }
818
819 /* Only re-checkpoint the buffer_head if it is marked
820 * dirty. If the buffer was added to the BJ_Forget list
821 * by jbd2_journal_forget, it may no longer be dirty and
822 * there's no point in keeping a checkpoint record for
823 * it. */
824
825 /* A buffer which has been freed while still being
826 * journaled by a previous transaction may end up still
827 * being dirty here, but we want to avoid writing back
828 * that buffer in the future now that the last use has
829 * been committed. That's not only a performance gain,
830 * it also stops aliasing problems if the buffer is left
831 * behind for writeback and gets reallocated for another
832 * use in a different page. */
833 if (buffer_freed(bh)) {
834 clear_buffer_freed(bh);
835 clear_buffer_jbddirty(bh);
836 }
837
838 if (buffer_jbddirty(bh)) {
839 JBUFFER_TRACE(jh, "add to new checkpointing trans");
840 __jbd2_journal_insert_checkpoint(jh, commit_transaction);
841 JBUFFER_TRACE(jh, "refile for checkpoint writeback");
842 __jbd2_journal_refile_buffer(jh);
843 jbd_unlock_bh_state(bh);
844 } else {
845 J_ASSERT_BH(bh, !buffer_dirty(bh));
846 /* The buffer on BJ_Forget list and not jbddirty means
847 * it has been freed by this transaction and hence it
848 * could not have been reallocated until this
849 * transaction has committed. *BUT* it could be
850 * reallocated once we have written all the data to
851 * disk and before we process the buffer on BJ_Forget
852 * list. */
853 JBUFFER_TRACE(jh, "refile or unfile freed buffer");
854 __jbd2_journal_refile_buffer(jh);
855 if (!jh->b_transaction) {
856 jbd_unlock_bh_state(bh);
857 /* needs a brelse */
858 jbd2_journal_remove_journal_head(bh);
859 release_buffer_page(bh);
860 } else
861 jbd_unlock_bh_state(bh);
862 }
863 cond_resched_lock(&journal->j_list_lock);
864 }
865 spin_unlock(&journal->j_list_lock);
866 /*
867 * This is a bit sleazy. We borrow j_list_lock to protect
868 * journal->j_committing_transaction in __jbd2_journal_remove_checkpoint.
869 * Really, __jbd2_journal_remove_checkpoint should be using j_state_lock but
870 * it's a bit hassle to hold that across __jbd2_journal_remove_checkpoint
871 */
872 spin_lock(&journal->j_state_lock);
873 spin_lock(&journal->j_list_lock);
874 /*
875 * Now recheck if some buffers did not get attached to the transaction
876 * while the lock was dropped...
877 */
878 if (commit_transaction->t_forget) {
879 spin_unlock(&journal->j_list_lock);
880 spin_unlock(&journal->j_state_lock);
881 goto restart_loop;
882 }
883
884 /* Done with this transaction! */
885
886 jbd_debug(3, "JBD: commit phase 8\n");
887
888 J_ASSERT(commit_transaction->t_state == T_COMMIT);
889
890 commit_transaction->t_state = T_FINISHED;
891 J_ASSERT(commit_transaction == journal->j_committing_transaction);
892 journal->j_commit_sequence = commit_transaction->t_tid;
893 journal->j_committing_transaction = NULL;
894 spin_unlock(&journal->j_state_lock);
895
896 if (commit_transaction->t_checkpoint_list == NULL) {
897 __jbd2_journal_drop_transaction(journal, commit_transaction);
898 } else {
899 if (journal->j_checkpoint_transactions == NULL) {
900 journal->j_checkpoint_transactions = commit_transaction;
901 commit_transaction->t_cpnext = commit_transaction;
902 commit_transaction->t_cpprev = commit_transaction;
903 } else {
904 commit_transaction->t_cpnext =
905 journal->j_checkpoint_transactions;
906 commit_transaction->t_cpprev =
907 commit_transaction->t_cpnext->t_cpprev;
908 commit_transaction->t_cpnext->t_cpprev =
909 commit_transaction;
910 commit_transaction->t_cpprev->t_cpnext =
911 commit_transaction;
912 }
913 }
914 spin_unlock(&journal->j_list_lock);
915
916 jbd_debug(1, "JBD: commit %d complete, head %d\n",
917 journal->j_commit_sequence, journal->j_tail_sequence);
918
919 wake_up(&journal->j_wait_done_commit);
920}
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
new file mode 100644
index 000000000000..c60f378b0f76
--- /dev/null
+++ b/fs/jbd2/journal.c
@@ -0,0 +1,2084 @@
1/*
2 * linux/fs/jbd2/journal.c
3 *
4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1998
5 *
6 * Copyright 1998 Red Hat corp --- All Rights Reserved
7 *
8 * This file is part of the Linux kernel and is made available under
9 * the terms of the GNU General Public License, version 2, or at your
10 * option, any later version, incorporated herein by reference.
11 *
12 * Generic filesystem journal-writing code; part of the ext2fs
13 * journaling system.
14 *
15 * This file manages journals: areas of disk reserved for logging
16 * transactional updates. This includes the kernel journaling thread
17 * which is responsible for scheduling updates to the log.
18 *
19 * We do not actually manage the physical storage of the journal in this
20 * file: that is left to a per-journal policy function, which allows us
21 * to store the journal within a filesystem-specified area for ext2
22 * journaling (ext2 can use a reserved inode for storing the log).
23 */
24
25#include <linux/module.h>
26#include <linux/time.h>
27#include <linux/fs.h>
28#include <linux/jbd2.h>
29#include <linux/errno.h>
30#include <linux/slab.h>
31#include <linux/smp_lock.h>
32#include <linux/init.h>
33#include <linux/mm.h>
34#include <linux/suspend.h>
35#include <linux/pagemap.h>
36#include <linux/kthread.h>
37#include <linux/poison.h>
38#include <linux/proc_fs.h>
39
40#include <asm/uaccess.h>
41#include <asm/page.h>
42
43EXPORT_SYMBOL(jbd2_journal_start);
44EXPORT_SYMBOL(jbd2_journal_restart);
45EXPORT_SYMBOL(jbd2_journal_extend);
46EXPORT_SYMBOL(jbd2_journal_stop);
47EXPORT_SYMBOL(jbd2_journal_lock_updates);
48EXPORT_SYMBOL(jbd2_journal_unlock_updates);
49EXPORT_SYMBOL(jbd2_journal_get_write_access);
50EXPORT_SYMBOL(jbd2_journal_get_create_access);
51EXPORT_SYMBOL(jbd2_journal_get_undo_access);
52EXPORT_SYMBOL(jbd2_journal_dirty_data);
53EXPORT_SYMBOL(jbd2_journal_dirty_metadata);
54EXPORT_SYMBOL(jbd2_journal_release_buffer);
55EXPORT_SYMBOL(jbd2_journal_forget);
56#if 0
57EXPORT_SYMBOL(journal_sync_buffer);
58#endif
59EXPORT_SYMBOL(jbd2_journal_flush);
60EXPORT_SYMBOL(jbd2_journal_revoke);
61
62EXPORT_SYMBOL(jbd2_journal_init_dev);
63EXPORT_SYMBOL(jbd2_journal_init_inode);
64EXPORT_SYMBOL(jbd2_journal_update_format);
65EXPORT_SYMBOL(jbd2_journal_check_used_features);
66EXPORT_SYMBOL(jbd2_journal_check_available_features);
67EXPORT_SYMBOL(jbd2_journal_set_features);
68EXPORT_SYMBOL(jbd2_journal_create);
69EXPORT_SYMBOL(jbd2_journal_load);
70EXPORT_SYMBOL(jbd2_journal_destroy);
71EXPORT_SYMBOL(jbd2_journal_update_superblock);
72EXPORT_SYMBOL(jbd2_journal_abort);
73EXPORT_SYMBOL(jbd2_journal_errno);
74EXPORT_SYMBOL(jbd2_journal_ack_err);
75EXPORT_SYMBOL(jbd2_journal_clear_err);
76EXPORT_SYMBOL(jbd2_log_wait_commit);
77EXPORT_SYMBOL(jbd2_journal_start_commit);
78EXPORT_SYMBOL(jbd2_journal_force_commit_nested);
79EXPORT_SYMBOL(jbd2_journal_wipe);
80EXPORT_SYMBOL(jbd2_journal_blocks_per_page);
81EXPORT_SYMBOL(jbd2_journal_invalidatepage);
82EXPORT_SYMBOL(jbd2_journal_try_to_free_buffers);
83EXPORT_SYMBOL(jbd2_journal_force_commit);
84
85static int journal_convert_superblock_v1(journal_t *, journal_superblock_t *);
86static void __journal_abort_soft (journal_t *journal, int errno);
87static int jbd2_journal_create_jbd_slab(size_t slab_size);
88
89/*
90 * Helper function used to manage commit timeouts
91 */
92
93static void commit_timeout(unsigned long __data)
94{
95 struct task_struct * p = (struct task_struct *) __data;
96
97 wake_up_process(p);
98}
99
100/*
101 * kjournald2: The main thread function used to manage a logging device
102 * journal.
103 *
104 * This kernel thread is responsible for two things:
105 *
106 * 1) COMMIT: Every so often we need to commit the current state of the
107 * filesystem to disk. The journal thread is responsible for writing
108 * all of the metadata buffers to disk.
109 *
110 * 2) CHECKPOINT: We cannot reuse a used section of the log file until all
111 * of the data in that part of the log has been rewritten elsewhere on
112 * the disk. Flushing these old buffers to reclaim space in the log is
113 * known as checkpointing, and this thread is responsible for that job.
114 */
115
116static int kjournald2(void *arg)
117{
118 journal_t *journal = arg;
119 transaction_t *transaction;
120
121 /*
122 * Set up an interval timer which can be used to trigger a commit wakeup
123 * after the commit interval expires
124 */
125 setup_timer(&journal->j_commit_timer, commit_timeout,
126 (unsigned long)current);
127
128 /* Record that the journal thread is running */
129 journal->j_task = current;
130 wake_up(&journal->j_wait_done_commit);
131
132 printk(KERN_INFO "kjournald2 starting. Commit interval %ld seconds\n",
133 journal->j_commit_interval / HZ);
134
135 /*
136 * And now, wait forever for commit wakeup events.
137 */
138 spin_lock(&journal->j_state_lock);
139
140loop:
141 if (journal->j_flags & JBD2_UNMOUNT)
142 goto end_loop;
143
144 jbd_debug(1, "commit_sequence=%d, commit_request=%d\n",
145 journal->j_commit_sequence, journal->j_commit_request);
146
147 if (journal->j_commit_sequence != journal->j_commit_request) {
148 jbd_debug(1, "OK, requests differ\n");
149 spin_unlock(&journal->j_state_lock);
150 del_timer_sync(&journal->j_commit_timer);
151 jbd2_journal_commit_transaction(journal);
152 spin_lock(&journal->j_state_lock);
153 goto loop;
154 }
155
156 wake_up(&journal->j_wait_done_commit);
157 if (freezing(current)) {
158 /*
159 * The simpler the better. Flushing journal isn't a
160 * good idea, because that depends on threads that may
161 * be already stopped.
162 */
163 jbd_debug(1, "Now suspending kjournald2\n");
164 spin_unlock(&journal->j_state_lock);
165 refrigerator();
166 spin_lock(&journal->j_state_lock);
167 } else {
168 /*
169 * We assume on resume that commits are already there,
170 * so we don't sleep
171 */
172 DEFINE_WAIT(wait);
173 int should_sleep = 1;
174
175 prepare_to_wait(&journal->j_wait_commit, &wait,
176 TASK_INTERRUPTIBLE);
177 if (journal->j_commit_sequence != journal->j_commit_request)
178 should_sleep = 0;
179 transaction = journal->j_running_transaction;
180 if (transaction && time_after_eq(jiffies,
181 transaction->t_expires))
182 should_sleep = 0;
183 if (journal->j_flags & JBD2_UNMOUNT)
184 should_sleep = 0;
185 if (should_sleep) {
186 spin_unlock(&journal->j_state_lock);
187 schedule();
188 spin_lock(&journal->j_state_lock);
189 }
190 finish_wait(&journal->j_wait_commit, &wait);
191 }
192
193 jbd_debug(1, "kjournald2 wakes\n");
194
195 /*
196 * Were we woken up by a commit wakeup event?
197 */
198 transaction = journal->j_running_transaction;
199 if (transaction && time_after_eq(jiffies, transaction->t_expires)) {
200 journal->j_commit_request = transaction->t_tid;
201 jbd_debug(1, "woke because of timeout\n");
202 }
203 goto loop;
204
205end_loop:
206 spin_unlock(&journal->j_state_lock);
207 del_timer_sync(&journal->j_commit_timer);
208 journal->j_task = NULL;
209 wake_up(&journal->j_wait_done_commit);
210 jbd_debug(1, "Journal thread exiting.\n");
211 return 0;
212}
213
214static void jbd2_journal_start_thread(journal_t *journal)
215{
216 kthread_run(kjournald2, journal, "kjournald2");
217 wait_event(journal->j_wait_done_commit, journal->j_task != 0);
218}
219
220static void journal_kill_thread(journal_t *journal)
221{
222 spin_lock(&journal->j_state_lock);
223 journal->j_flags |= JBD2_UNMOUNT;
224
225 while (journal->j_task) {
226 wake_up(&journal->j_wait_commit);
227 spin_unlock(&journal->j_state_lock);
228 wait_event(journal->j_wait_done_commit, journal->j_task == 0);
229 spin_lock(&journal->j_state_lock);
230 }
231 spin_unlock(&journal->j_state_lock);
232}
233
234/*
235 * jbd2_journal_write_metadata_buffer: write a metadata buffer to the journal.
236 *
237 * Writes a metadata buffer to a given disk block. The actual IO is not
238 * performed but a new buffer_head is constructed which labels the data
239 * to be written with the correct destination disk block.
240 *
241 * Any magic-number escaping which needs to be done will cause a
242 * copy-out here. If the buffer happens to start with the
243 * JBD2_MAGIC_NUMBER, then we can't write it to the log directly: the
244 * magic number is only written to the log for descripter blocks. In
245 * this case, we copy the data and replace the first word with 0, and we
246 * return a result code which indicates that this buffer needs to be
247 * marked as an escaped buffer in the corresponding log descriptor
248 * block. The missing word can then be restored when the block is read
249 * during recovery.
250 *
251 * If the source buffer has already been modified by a new transaction
252 * since we took the last commit snapshot, we use the frozen copy of
253 * that data for IO. If we end up using the existing buffer_head's data
254 * for the write, then we *have* to lock the buffer to prevent anyone
255 * else from using and possibly modifying it while the IO is in
256 * progress.
257 *
258 * The function returns a pointer to the buffer_heads to be used for IO.
259 *
260 * We assume that the journal has already been locked in this function.
261 *
262 * Return value:
263 * <0: Error
264 * >=0: Finished OK
265 *
266 * On success:
267 * Bit 0 set == escape performed on the data
268 * Bit 1 set == buffer copy-out performed (kfree the data after IO)
269 */
270
271int jbd2_journal_write_metadata_buffer(transaction_t *transaction,
272 struct journal_head *jh_in,
273 struct journal_head **jh_out,
274 unsigned long long blocknr)
275{
276 int need_copy_out = 0;
277 int done_copy_out = 0;
278 int do_escape = 0;
279 char *mapped_data;
280 struct buffer_head *new_bh;
281 struct journal_head *new_jh;
282 struct page *new_page;
283 unsigned int new_offset;
284 struct buffer_head *bh_in = jh2bh(jh_in);
285
286 /*
287 * The buffer really shouldn't be locked: only the current committing
288 * transaction is allowed to write it, so nobody else is allowed
289 * to do any IO.
290 *
291 * akpm: except if we're journalling data, and write() output is
292 * also part of a shared mapping, and another thread has
293 * decided to launch a writepage() against this buffer.
294 */
295 J_ASSERT_BH(bh_in, buffer_jbddirty(bh_in));
296
297 new_bh = alloc_buffer_head(GFP_NOFS|__GFP_NOFAIL);
298
299 /*
300 * If a new transaction has already done a buffer copy-out, then
301 * we use that version of the data for the commit.
302 */
303 jbd_lock_bh_state(bh_in);
304repeat:
305 if (jh_in->b_frozen_data) {
306 done_copy_out = 1;
307 new_page = virt_to_page(jh_in->b_frozen_data);
308 new_offset = offset_in_page(jh_in->b_frozen_data);
309 } else {
310 new_page = jh2bh(jh_in)->b_page;
311 new_offset = offset_in_page(jh2bh(jh_in)->b_data);
312 }
313
314 mapped_data = kmap_atomic(new_page, KM_USER0);
315 /*
316 * Check for escaping
317 */
318 if (*((__be32 *)(mapped_data + new_offset)) ==
319 cpu_to_be32(JBD2_MAGIC_NUMBER)) {
320 need_copy_out = 1;
321 do_escape = 1;
322 }
323 kunmap_atomic(mapped_data, KM_USER0);
324
325 /*
326 * Do we need to do a data copy?
327 */
328 if (need_copy_out && !done_copy_out) {
329 char *tmp;
330
331 jbd_unlock_bh_state(bh_in);
332 tmp = jbd2_slab_alloc(bh_in->b_size, GFP_NOFS);
333 jbd_lock_bh_state(bh_in);
334 if (jh_in->b_frozen_data) {
335 jbd2_slab_free(tmp, bh_in->b_size);
336 goto repeat;
337 }
338
339 jh_in->b_frozen_data = tmp;
340 mapped_data = kmap_atomic(new_page, KM_USER0);
341 memcpy(tmp, mapped_data + new_offset, jh2bh(jh_in)->b_size);
342 kunmap_atomic(mapped_data, KM_USER0);
343
344 new_page = virt_to_page(tmp);
345 new_offset = offset_in_page(tmp);
346 done_copy_out = 1;
347 }
348
349 /*
350 * Did we need to do an escaping? Now we've done all the
351 * copying, we can finally do so.
352 */
353 if (do_escape) {
354 mapped_data = kmap_atomic(new_page, KM_USER0);
355 *((unsigned int *)(mapped_data + new_offset)) = 0;
356 kunmap_atomic(mapped_data, KM_USER0);
357 }
358
359 /* keep subsequent assertions sane */
360 new_bh->b_state = 0;
361 init_buffer(new_bh, NULL, NULL);
362 atomic_set(&new_bh->b_count, 1);
363 jbd_unlock_bh_state(bh_in);
364
365 new_jh = jbd2_journal_add_journal_head(new_bh); /* This sleeps */
366
367 set_bh_page(new_bh, new_page, new_offset);
368 new_jh->b_transaction = NULL;
369 new_bh->b_size = jh2bh(jh_in)->b_size;
370 new_bh->b_bdev = transaction->t_journal->j_dev;
371 new_bh->b_blocknr = blocknr;
372 set_buffer_mapped(new_bh);
373 set_buffer_dirty(new_bh);
374
375 *jh_out = new_jh;
376
377 /*
378 * The to-be-written buffer needs to get moved to the io queue,
379 * and the original buffer whose contents we are shadowing or
380 * copying is moved to the transaction's shadow queue.
381 */
382 JBUFFER_TRACE(jh_in, "file as BJ_Shadow");
383 jbd2_journal_file_buffer(jh_in, transaction, BJ_Shadow);
384 JBUFFER_TRACE(new_jh, "file as BJ_IO");
385 jbd2_journal_file_buffer(new_jh, transaction, BJ_IO);
386
387 return do_escape | (done_copy_out << 1);
388}
389
390/*
391 * Allocation code for the journal file. Manage the space left in the
392 * journal, so that we can begin checkpointing when appropriate.
393 */
394
395/*
396 * __jbd2_log_space_left: Return the number of free blocks left in the journal.
397 *
398 * Called with the journal already locked.
399 *
400 * Called under j_state_lock
401 */
402
403int __jbd2_log_space_left(journal_t *journal)
404{
405 int left = journal->j_free;
406
407 assert_spin_locked(&journal->j_state_lock);
408
409 /*
410 * Be pessimistic here about the number of those free blocks which
411 * might be required for log descriptor control blocks.
412 */
413
414#define MIN_LOG_RESERVED_BLOCKS 32 /* Allow for rounding errors */
415
416 left -= MIN_LOG_RESERVED_BLOCKS;
417
418 if (left <= 0)
419 return 0;
420 left -= (left >> 3);
421 return left;
422}
423
424/*
425 * Called under j_state_lock. Returns true if a transaction was started.
426 */
427int __jbd2_log_start_commit(journal_t *journal, tid_t target)
428{
429 /*
430 * Are we already doing a recent enough commit?
431 */
432 if (!tid_geq(journal->j_commit_request, target)) {
433 /*
434 * We want a new commit: OK, mark the request and wakup the
435 * commit thread. We do _not_ do the commit ourselves.
436 */
437
438 journal->j_commit_request = target;
439 jbd_debug(1, "JBD: requesting commit %d/%d\n",
440 journal->j_commit_request,
441 journal->j_commit_sequence);
442 wake_up(&journal->j_wait_commit);
443 return 1;
444 }
445 return 0;
446}
447
448int jbd2_log_start_commit(journal_t *journal, tid_t tid)
449{
450 int ret;
451
452 spin_lock(&journal->j_state_lock);
453 ret = __jbd2_log_start_commit(journal, tid);
454 spin_unlock(&journal->j_state_lock);
455 return ret;
456}
457
458/*
459 * Force and wait upon a commit if the calling process is not within
460 * transaction. This is used for forcing out undo-protected data which contains
461 * bitmaps, when the fs is running out of space.
462 *
463 * We can only force the running transaction if we don't have an active handle;
464 * otherwise, we will deadlock.
465 *
466 * Returns true if a transaction was started.
467 */
468int jbd2_journal_force_commit_nested(journal_t *journal)
469{
470 transaction_t *transaction = NULL;
471 tid_t tid;
472
473 spin_lock(&journal->j_state_lock);
474 if (journal->j_running_transaction && !current->journal_info) {
475 transaction = journal->j_running_transaction;
476 __jbd2_log_start_commit(journal, transaction->t_tid);
477 } else if (journal->j_committing_transaction)
478 transaction = journal->j_committing_transaction;
479
480 if (!transaction) {
481 spin_unlock(&journal->j_state_lock);
482 return 0; /* Nothing to retry */
483 }
484
485 tid = transaction->t_tid;
486 spin_unlock(&journal->j_state_lock);
487 jbd2_log_wait_commit(journal, tid);
488 return 1;
489}
490
491/*
492 * Start a commit of the current running transaction (if any). Returns true
493 * if a transaction was started, and fills its tid in at *ptid
494 */
495int jbd2_journal_start_commit(journal_t *journal, tid_t *ptid)
496{
497 int ret = 0;
498
499 spin_lock(&journal->j_state_lock);
500 if (journal->j_running_transaction) {
501 tid_t tid = journal->j_running_transaction->t_tid;
502
503 ret = __jbd2_log_start_commit(journal, tid);
504 if (ret && ptid)
505 *ptid = tid;
506 } else if (journal->j_committing_transaction && ptid) {
507 /*
508 * If ext3_write_super() recently started a commit, then we
509 * have to wait for completion of that transaction
510 */
511 *ptid = journal->j_committing_transaction->t_tid;
512 ret = 1;
513 }
514 spin_unlock(&journal->j_state_lock);
515 return ret;
516}
517
518/*
519 * Wait for a specified commit to complete.
520 * The caller may not hold the journal lock.
521 */
522int jbd2_log_wait_commit(journal_t *journal, tid_t tid)
523{
524 int err = 0;
525
526#ifdef CONFIG_JBD_DEBUG
527 spin_lock(&journal->j_state_lock);
528 if (!tid_geq(journal->j_commit_request, tid)) {
529 printk(KERN_EMERG
530 "%s: error: j_commit_request=%d, tid=%d\n",
531 __FUNCTION__, journal->j_commit_request, tid);
532 }
533 spin_unlock(&journal->j_state_lock);
534#endif
535 spin_lock(&journal->j_state_lock);
536 while (tid_gt(tid, journal->j_commit_sequence)) {
537 jbd_debug(1, "JBD: want %d, j_commit_sequence=%d\n",
538 tid, journal->j_commit_sequence);
539 wake_up(&journal->j_wait_commit);
540 spin_unlock(&journal->j_state_lock);
541 wait_event(journal->j_wait_done_commit,
542 !tid_gt(tid, journal->j_commit_sequence));
543 spin_lock(&journal->j_state_lock);
544 }
545 spin_unlock(&journal->j_state_lock);
546
547 if (unlikely(is_journal_aborted(journal))) {
548 printk(KERN_EMERG "journal commit I/O error\n");
549 err = -EIO;
550 }
551 return err;
552}
553
554/*
555 * Log buffer allocation routines:
556 */
557
558int jbd2_journal_next_log_block(journal_t *journal, unsigned long long *retp)
559{
560 unsigned long blocknr;
561
562 spin_lock(&journal->j_state_lock);
563 J_ASSERT(journal->j_free > 1);
564
565 blocknr = journal->j_head;
566 journal->j_head++;
567 journal->j_free--;
568 if (journal->j_head == journal->j_last)
569 journal->j_head = journal->j_first;
570 spin_unlock(&journal->j_state_lock);
571 return jbd2_journal_bmap(journal, blocknr, retp);
572}
573
574/*
575 * Conversion of logical to physical block numbers for the journal
576 *
577 * On external journals the journal blocks are identity-mapped, so
578 * this is a no-op. If needed, we can use j_blk_offset - everything is
579 * ready.
580 */
581int jbd2_journal_bmap(journal_t *journal, unsigned long blocknr,
582 unsigned long long *retp)
583{
584 int err = 0;
585 unsigned long long ret;
586
587 if (journal->j_inode) {
588 ret = bmap(journal->j_inode, blocknr);
589 if (ret)
590 *retp = ret;
591 else {
592 char b[BDEVNAME_SIZE];
593
594 printk(KERN_ALERT "%s: journal block not found "
595 "at offset %lu on %s\n",
596 __FUNCTION__,
597 blocknr,
598 bdevname(journal->j_dev, b));
599 err = -EIO;
600 __journal_abort_soft(journal, err);
601 }
602 } else {
603 *retp = blocknr; /* +journal->j_blk_offset */
604 }
605 return err;
606}
607
608/*
609 * We play buffer_head aliasing tricks to write data/metadata blocks to
610 * the journal without copying their contents, but for journal
611 * descriptor blocks we do need to generate bona fide buffers.
612 *
613 * After the caller of jbd2_journal_get_descriptor_buffer() has finished modifying
614 * the buffer's contents they really should run flush_dcache_page(bh->b_page).
615 * But we don't bother doing that, so there will be coherency problems with
616 * mmaps of blockdevs which hold live JBD-controlled filesystems.
617 */
618struct journal_head *jbd2_journal_get_descriptor_buffer(journal_t *journal)
619{
620 struct buffer_head *bh;
621 unsigned long long blocknr;
622 int err;
623
624 err = jbd2_journal_next_log_block(journal, &blocknr);
625
626 if (err)
627 return NULL;
628
629 bh = __getblk(journal->j_dev, blocknr, journal->j_blocksize);
630 lock_buffer(bh);
631 memset(bh->b_data, 0, journal->j_blocksize);
632 set_buffer_uptodate(bh);
633 unlock_buffer(bh);
634 BUFFER_TRACE(bh, "return this buffer");
635 return jbd2_journal_add_journal_head(bh);
636}
637
638/*
639 * Management for journal control blocks: functions to create and
640 * destroy journal_t structures, and to initialise and read existing
641 * journal blocks from disk. */
642
643/* First: create and setup a journal_t object in memory. We initialise
644 * very few fields yet: that has to wait until we have created the
645 * journal structures from from scratch, or loaded them from disk. */
646
647static journal_t * journal_init_common (void)
648{
649 journal_t *journal;
650 int err;
651
652 journal = jbd_kmalloc(sizeof(*journal), GFP_KERNEL);
653 if (!journal)
654 goto fail;
655 memset(journal, 0, sizeof(*journal));
656
657 init_waitqueue_head(&journal->j_wait_transaction_locked);
658 init_waitqueue_head(&journal->j_wait_logspace);
659 init_waitqueue_head(&journal->j_wait_done_commit);
660 init_waitqueue_head(&journal->j_wait_checkpoint);
661 init_waitqueue_head(&journal->j_wait_commit);
662 init_waitqueue_head(&journal->j_wait_updates);
663 mutex_init(&journal->j_barrier);
664 mutex_init(&journal->j_checkpoint_mutex);
665 spin_lock_init(&journal->j_revoke_lock);
666 spin_lock_init(&journal->j_list_lock);
667 spin_lock_init(&journal->j_state_lock);
668
669 journal->j_commit_interval = (HZ * JBD_DEFAULT_MAX_COMMIT_AGE);
670
671 /* The journal is marked for error until we succeed with recovery! */
672 journal->j_flags = JBD2_ABORT;
673
674 /* Set up a default-sized revoke table for the new mount. */
675 err = jbd2_journal_init_revoke(journal, JOURNAL_REVOKE_DEFAULT_HASH);
676 if (err) {
677 kfree(journal);
678 goto fail;
679 }
680 return journal;
681fail:
682 return NULL;
683}
684
685/* jbd2_journal_init_dev and jbd2_journal_init_inode:
686 *
687 * Create a journal structure assigned some fixed set of disk blocks to
688 * the journal. We don't actually touch those disk blocks yet, but we
689 * need to set up all of the mapping information to tell the journaling
690 * system where the journal blocks are.
691 *
692 */
693
694/**
695 * journal_t * jbd2_journal_init_dev() - creates an initialises a journal structure
696 * @bdev: Block device on which to create the journal
697 * @fs_dev: Device which hold journalled filesystem for this journal.
698 * @start: Block nr Start of journal.
699 * @len: Length of the journal in blocks.
700 * @blocksize: blocksize of journalling device
701 * @returns: a newly created journal_t *
702 *
703 * jbd2_journal_init_dev creates a journal which maps a fixed contiguous
704 * range of blocks on an arbitrary block device.
705 *
706 */
707journal_t * jbd2_journal_init_dev(struct block_device *bdev,
708 struct block_device *fs_dev,
709 unsigned long long start, int len, int blocksize)
710{
711 journal_t *journal = journal_init_common();
712 struct buffer_head *bh;
713 int n;
714
715 if (!journal)
716 return NULL;
717
718 /* journal descriptor can store up to n blocks -bzzz */
719 journal->j_blocksize = blocksize;
720 n = journal->j_blocksize / sizeof(journal_block_tag_t);
721 journal->j_wbufsize = n;
722 journal->j_wbuf = kmalloc(n * sizeof(struct buffer_head*), GFP_KERNEL);
723 if (!journal->j_wbuf) {
724 printk(KERN_ERR "%s: Cant allocate bhs for commit thread\n",
725 __FUNCTION__);
726 kfree(journal);
727 journal = NULL;
728 goto out;
729 }
730 journal->j_dev = bdev;
731 journal->j_fs_dev = fs_dev;
732 journal->j_blk_offset = start;
733 journal->j_maxlen = len;
734
735 bh = __getblk(journal->j_dev, start, journal->j_blocksize);
736 J_ASSERT(bh != NULL);
737 journal->j_sb_buffer = bh;
738 journal->j_superblock = (journal_superblock_t *)bh->b_data;
739out:
740 return journal;
741}
742
743/**
744 * journal_t * jbd2_journal_init_inode () - creates a journal which maps to a inode.
745 * @inode: An inode to create the journal in
746 *
747 * jbd2_journal_init_inode creates a journal which maps an on-disk inode as
748 * the journal. The inode must exist already, must support bmap() and
749 * must have all data blocks preallocated.
750 */
751journal_t * jbd2_journal_init_inode (struct inode *inode)
752{
753 struct buffer_head *bh;
754 journal_t *journal = journal_init_common();
755 int err;
756 int n;
757 unsigned long long blocknr;
758
759 if (!journal)
760 return NULL;
761
762 journal->j_dev = journal->j_fs_dev = inode->i_sb->s_bdev;
763 journal->j_inode = inode;
764 jbd_debug(1,
765 "journal %p: inode %s/%ld, size %Ld, bits %d, blksize %ld\n",
766 journal, inode->i_sb->s_id, inode->i_ino,
767 (long long) inode->i_size,
768 inode->i_sb->s_blocksize_bits, inode->i_sb->s_blocksize);
769
770 journal->j_maxlen = inode->i_size >> inode->i_sb->s_blocksize_bits;
771 journal->j_blocksize = inode->i_sb->s_blocksize;
772
773 /* journal descriptor can store up to n blocks -bzzz */
774 n = journal->j_blocksize / sizeof(journal_block_tag_t);
775 journal->j_wbufsize = n;
776 journal->j_wbuf = kmalloc(n * sizeof(struct buffer_head*), GFP_KERNEL);
777 if (!journal->j_wbuf) {
778 printk(KERN_ERR "%s: Cant allocate bhs for commit thread\n",
779 __FUNCTION__);
780 kfree(journal);
781 return NULL;
782 }
783
784 err = jbd2_journal_bmap(journal, 0, &blocknr);
785 /* If that failed, give up */
786 if (err) {
787 printk(KERN_ERR "%s: Cannnot locate journal superblock\n",
788 __FUNCTION__);
789 kfree(journal);
790 return NULL;
791 }
792
793 bh = __getblk(journal->j_dev, blocknr, journal->j_blocksize);
794 J_ASSERT(bh != NULL);
795 journal->j_sb_buffer = bh;
796 journal->j_superblock = (journal_superblock_t *)bh->b_data;
797
798 return journal;
799}
800
801/*
802 * If the journal init or create aborts, we need to mark the journal
803 * superblock as being NULL to prevent the journal destroy from writing
804 * back a bogus superblock.
805 */
806static void journal_fail_superblock (journal_t *journal)
807{
808 struct buffer_head *bh = journal->j_sb_buffer;
809 brelse(bh);
810 journal->j_sb_buffer = NULL;
811}
812
813/*
814 * Given a journal_t structure, initialise the various fields for
815 * startup of a new journaling session. We use this both when creating
816 * a journal, and after recovering an old journal to reset it for
817 * subsequent use.
818 */
819
820static int journal_reset(journal_t *journal)
821{
822 journal_superblock_t *sb = journal->j_superblock;
823 unsigned long long first, last;
824
825 first = be32_to_cpu(sb->s_first);
826 last = be32_to_cpu(sb->s_maxlen);
827
828 journal->j_first = first;
829 journal->j_last = last;
830
831 journal->j_head = first;
832 journal->j_tail = first;
833 journal->j_free = last - first;
834
835 journal->j_tail_sequence = journal->j_transaction_sequence;
836 journal->j_commit_sequence = journal->j_transaction_sequence - 1;
837 journal->j_commit_request = journal->j_commit_sequence;
838
839 journal->j_max_transaction_buffers = journal->j_maxlen / 4;
840
841 /* Add the dynamic fields and write it to disk. */
842 jbd2_journal_update_superblock(journal, 1);
843 jbd2_journal_start_thread(journal);
844 return 0;
845}
846
847/**
848 * int jbd2_journal_create() - Initialise the new journal file
849 * @journal: Journal to create. This structure must have been initialised
850 *
851 * Given a journal_t structure which tells us which disk blocks we can
852 * use, create a new journal superblock and initialise all of the
853 * journal fields from scratch.
854 **/
855int jbd2_journal_create(journal_t *journal)
856{
857 unsigned long long blocknr;
858 struct buffer_head *bh;
859 journal_superblock_t *sb;
860 int i, err;
861
862 if (journal->j_maxlen < JBD2_MIN_JOURNAL_BLOCKS) {
863 printk (KERN_ERR "Journal length (%d blocks) too short.\n",
864 journal->j_maxlen);
865 journal_fail_superblock(journal);
866 return -EINVAL;
867 }
868
869 if (journal->j_inode == NULL) {
870 /*
871 * We don't know what block to start at!
872 */
873 printk(KERN_EMERG
874 "%s: creation of journal on external device!\n",
875 __FUNCTION__);
876 BUG();
877 }
878
879 /* Zero out the entire journal on disk. We cannot afford to
880 have any blocks on disk beginning with JBD2_MAGIC_NUMBER. */
881 jbd_debug(1, "JBD: Zeroing out journal blocks...\n");
882 for (i = 0; i < journal->j_maxlen; i++) {
883 err = jbd2_journal_bmap(journal, i, &blocknr);
884 if (err)
885 return err;
886 bh = __getblk(journal->j_dev, blocknr, journal->j_blocksize);
887 lock_buffer(bh);
888 memset (bh->b_data, 0, journal->j_blocksize);
889 BUFFER_TRACE(bh, "marking dirty");
890 mark_buffer_dirty(bh);
891 BUFFER_TRACE(bh, "marking uptodate");
892 set_buffer_uptodate(bh);
893 unlock_buffer(bh);
894 __brelse(bh);
895 }
896
897 sync_blockdev(journal->j_dev);
898 jbd_debug(1, "JBD: journal cleared.\n");
899
900 /* OK, fill in the initial static fields in the new superblock */
901 sb = journal->j_superblock;
902
903 sb->s_header.h_magic = cpu_to_be32(JBD2_MAGIC_NUMBER);
904 sb->s_header.h_blocktype = cpu_to_be32(JBD2_SUPERBLOCK_V2);
905
906 sb->s_blocksize = cpu_to_be32(journal->j_blocksize);
907 sb->s_maxlen = cpu_to_be32(journal->j_maxlen);
908 sb->s_first = cpu_to_be32(1);
909
910 journal->j_transaction_sequence = 1;
911
912 journal->j_flags &= ~JBD2_ABORT;
913 journal->j_format_version = 2;
914
915 return journal_reset(journal);
916}
917
918/**
919 * void jbd2_journal_update_superblock() - Update journal sb on disk.
920 * @journal: The journal to update.
921 * @wait: Set to '0' if you don't want to wait for IO completion.
922 *
923 * Update a journal's dynamic superblock fields and write it to disk,
924 * optionally waiting for the IO to complete.
925 */
926void jbd2_journal_update_superblock(journal_t *journal, int wait)
927{
928 journal_superblock_t *sb = journal->j_superblock;
929 struct buffer_head *bh = journal->j_sb_buffer;
930
931 /*
932 * As a special case, if the on-disk copy is already marked as needing
933 * no recovery (s_start == 0) and there are no outstanding transactions
934 * in the filesystem, then we can safely defer the superblock update
935 * until the next commit by setting JBD2_FLUSHED. This avoids
936 * attempting a write to a potential-readonly device.
937 */
938 if (sb->s_start == 0 && journal->j_tail_sequence ==
939 journal->j_transaction_sequence) {
940 jbd_debug(1,"JBD: Skipping superblock update on recovered sb "
941 "(start %ld, seq %d, errno %d)\n",
942 journal->j_tail, journal->j_tail_sequence,
943 journal->j_errno);
944 goto out;
945 }
946
947 spin_lock(&journal->j_state_lock);
948 jbd_debug(1,"JBD: updating superblock (start %ld, seq %d, errno %d)\n",
949 journal->j_tail, journal->j_tail_sequence, journal->j_errno);
950
951 sb->s_sequence = cpu_to_be32(journal->j_tail_sequence);
952 sb->s_start = cpu_to_be32(journal->j_tail);
953 sb->s_errno = cpu_to_be32(journal->j_errno);
954 spin_unlock(&journal->j_state_lock);
955
956 BUFFER_TRACE(bh, "marking dirty");
957 mark_buffer_dirty(bh);
958 if (wait)
959 sync_dirty_buffer(bh);
960 else
961 ll_rw_block(SWRITE, 1, &bh);
962
963out:
964 /* If we have just flushed the log (by marking s_start==0), then
965 * any future commit will have to be careful to update the
966 * superblock again to re-record the true start of the log. */
967
968 spin_lock(&journal->j_state_lock);
969 if (sb->s_start)
970 journal->j_flags &= ~JBD2_FLUSHED;
971 else
972 journal->j_flags |= JBD2_FLUSHED;
973 spin_unlock(&journal->j_state_lock);
974}
975
976/*
977 * Read the superblock for a given journal, performing initial
978 * validation of the format.
979 */
980
981static int journal_get_superblock(journal_t *journal)
982{
983 struct buffer_head *bh;
984 journal_superblock_t *sb;
985 int err = -EIO;
986
987 bh = journal->j_sb_buffer;
988
989 J_ASSERT(bh != NULL);
990 if (!buffer_uptodate(bh)) {
991 ll_rw_block(READ, 1, &bh);
992 wait_on_buffer(bh);
993 if (!buffer_uptodate(bh)) {
994 printk (KERN_ERR
995 "JBD: IO error reading journal superblock\n");
996 goto out;
997 }
998 }
999
1000 sb = journal->j_superblock;
1001
1002 err = -EINVAL;
1003
1004 if (sb->s_header.h_magic != cpu_to_be32(JBD2_MAGIC_NUMBER) ||
1005 sb->s_blocksize != cpu_to_be32(journal->j_blocksize)) {
1006 printk(KERN_WARNING "JBD: no valid journal superblock found\n");
1007 goto out;
1008 }
1009
1010 switch(be32_to_cpu(sb->s_header.h_blocktype)) {
1011 case JBD2_SUPERBLOCK_V1:
1012 journal->j_format_version = 1;
1013 break;
1014 case JBD2_SUPERBLOCK_V2:
1015 journal->j_format_version = 2;
1016 break;
1017 default:
1018 printk(KERN_WARNING "JBD: unrecognised superblock format ID\n");
1019 goto out;
1020 }
1021
1022 if (be32_to_cpu(sb->s_maxlen) < journal->j_maxlen)
1023 journal->j_maxlen = be32_to_cpu(sb->s_maxlen);
1024 else if (be32_to_cpu(sb->s_maxlen) > journal->j_maxlen) {
1025 printk (KERN_WARNING "JBD: journal file too short\n");
1026 goto out;
1027 }
1028
1029 return 0;
1030
1031out:
1032 journal_fail_superblock(journal);
1033 return err;
1034}
1035
1036/*
1037 * Load the on-disk journal superblock and read the key fields into the
1038 * journal_t.
1039 */
1040
1041static int load_superblock(journal_t *journal)
1042{
1043 int err;
1044 journal_superblock_t *sb;
1045
1046 err = journal_get_superblock(journal);
1047 if (err)
1048 return err;
1049
1050 sb = journal->j_superblock;
1051
1052 journal->j_tail_sequence = be32_to_cpu(sb->s_sequence);
1053 journal->j_tail = be32_to_cpu(sb->s_start);
1054 journal->j_first = be32_to_cpu(sb->s_first);
1055 journal->j_last = be32_to_cpu(sb->s_maxlen);
1056 journal->j_errno = be32_to_cpu(sb->s_errno);
1057
1058 return 0;
1059}
1060
1061
1062/**
1063 * int jbd2_journal_load() - Read journal from disk.
1064 * @journal: Journal to act on.
1065 *
1066 * Given a journal_t structure which tells us which disk blocks contain
1067 * a journal, read the journal from disk to initialise the in-memory
1068 * structures.
1069 */
1070int jbd2_journal_load(journal_t *journal)
1071{
1072 int err;
1073 journal_superblock_t *sb;
1074
1075 err = load_superblock(journal);
1076 if (err)
1077 return err;
1078
1079 sb = journal->j_superblock;
1080 /* If this is a V2 superblock, then we have to check the
1081 * features flags on it. */
1082
1083 if (journal->j_format_version >= 2) {
1084 if ((sb->s_feature_ro_compat &
1085 ~cpu_to_be32(JBD2_KNOWN_ROCOMPAT_FEATURES)) ||
1086 (sb->s_feature_incompat &
1087 ~cpu_to_be32(JBD2_KNOWN_INCOMPAT_FEATURES))) {
1088 printk (KERN_WARNING
1089 "JBD: Unrecognised features on journal\n");
1090 return -EINVAL;
1091 }
1092 }
1093
1094 /*
1095 * Create a slab for this blocksize
1096 */
1097 err = jbd2_journal_create_jbd_slab(be32_to_cpu(sb->s_blocksize));
1098 if (err)
1099 return err;
1100
1101 /* Let the recovery code check whether it needs to recover any
1102 * data from the journal. */
1103 if (jbd2_journal_recover(journal))
1104 goto recovery_error;
1105
1106 /* OK, we've finished with the dynamic journal bits:
1107 * reinitialise the dynamic contents of the superblock in memory
1108 * and reset them on disk. */
1109 if (journal_reset(journal))
1110 goto recovery_error;
1111
1112 journal->j_flags &= ~JBD2_ABORT;
1113 journal->j_flags |= JBD2_LOADED;
1114 return 0;
1115
1116recovery_error:
1117 printk (KERN_WARNING "JBD: recovery failed\n");
1118 return -EIO;
1119}
1120
1121/**
1122 * void jbd2_journal_destroy() - Release a journal_t structure.
1123 * @journal: Journal to act on.
1124 *
1125 * Release a journal_t structure once it is no longer in use by the
1126 * journaled object.
1127 */
1128void jbd2_journal_destroy(journal_t *journal)
1129{
1130 /* Wait for the commit thread to wake up and die. */
1131 journal_kill_thread(journal);
1132
1133 /* Force a final log commit */
1134 if (journal->j_running_transaction)
1135 jbd2_journal_commit_transaction(journal);
1136
1137 /* Force any old transactions to disk */
1138
1139 /* Totally anal locking here... */
1140 spin_lock(&journal->j_list_lock);
1141 while (journal->j_checkpoint_transactions != NULL) {
1142 spin_unlock(&journal->j_list_lock);
1143 jbd2_log_do_checkpoint(journal);
1144 spin_lock(&journal->j_list_lock);
1145 }
1146
1147 J_ASSERT(journal->j_running_transaction == NULL);
1148 J_ASSERT(journal->j_committing_transaction == NULL);
1149 J_ASSERT(journal->j_checkpoint_transactions == NULL);
1150 spin_unlock(&journal->j_list_lock);
1151
1152 /* We can now mark the journal as empty. */
1153 journal->j_tail = 0;
1154 journal->j_tail_sequence = ++journal->j_transaction_sequence;
1155 if (journal->j_sb_buffer) {
1156 jbd2_journal_update_superblock(journal, 1);
1157 brelse(journal->j_sb_buffer);
1158 }
1159
1160 if (journal->j_inode)
1161 iput(journal->j_inode);
1162 if (journal->j_revoke)
1163 jbd2_journal_destroy_revoke(journal);
1164 kfree(journal->j_wbuf);
1165 kfree(journal);
1166}
1167
1168
1169/**
1170 *int jbd2_journal_check_used_features () - Check if features specified are used.
1171 * @journal: Journal to check.
1172 * @compat: bitmask of compatible features
1173 * @ro: bitmask of features that force read-only mount
1174 * @incompat: bitmask of incompatible features
1175 *
1176 * Check whether the journal uses all of a given set of
1177 * features. Return true (non-zero) if it does.
1178 **/
1179
1180int jbd2_journal_check_used_features (journal_t *journal, unsigned long compat,
1181 unsigned long ro, unsigned long incompat)
1182{
1183 journal_superblock_t *sb;
1184
1185 if (!compat && !ro && !incompat)
1186 return 1;
1187 if (journal->j_format_version == 1)
1188 return 0;
1189
1190 sb = journal->j_superblock;
1191
1192 if (((be32_to_cpu(sb->s_feature_compat) & compat) == compat) &&
1193 ((be32_to_cpu(sb->s_feature_ro_compat) & ro) == ro) &&
1194 ((be32_to_cpu(sb->s_feature_incompat) & incompat) == incompat))
1195 return 1;
1196
1197 return 0;
1198}
1199
1200/**
1201 * int jbd2_journal_check_available_features() - Check feature set in journalling layer
1202 * @journal: Journal to check.
1203 * @compat: bitmask of compatible features
1204 * @ro: bitmask of features that force read-only mount
1205 * @incompat: bitmask of incompatible features
1206 *
1207 * Check whether the journaling code supports the use of
1208 * all of a given set of features on this journal. Return true
1209 * (non-zero) if it can. */
1210
1211int jbd2_journal_check_available_features (journal_t *journal, unsigned long compat,
1212 unsigned long ro, unsigned long incompat)
1213{
1214 journal_superblock_t *sb;
1215
1216 if (!compat && !ro && !incompat)
1217 return 1;
1218
1219 sb = journal->j_superblock;
1220
1221 /* We can support any known requested features iff the
1222 * superblock is in version 2. Otherwise we fail to support any
1223 * extended sb features. */
1224
1225 if (journal->j_format_version != 2)
1226 return 0;
1227
1228 if ((compat & JBD2_KNOWN_COMPAT_FEATURES) == compat &&
1229 (ro & JBD2_KNOWN_ROCOMPAT_FEATURES) == ro &&
1230 (incompat & JBD2_KNOWN_INCOMPAT_FEATURES) == incompat)
1231 return 1;
1232
1233 return 0;
1234}
1235
1236/**
1237 * int jbd2_journal_set_features () - Mark a given journal feature in the superblock
1238 * @journal: Journal to act on.
1239 * @compat: bitmask of compatible features
1240 * @ro: bitmask of features that force read-only mount
1241 * @incompat: bitmask of incompatible features
1242 *
1243 * Mark a given journal feature as present on the
1244 * superblock. Returns true if the requested features could be set.
1245 *
1246 */
1247
1248int jbd2_journal_set_features (journal_t *journal, unsigned long compat,
1249 unsigned long ro, unsigned long incompat)
1250{
1251 journal_superblock_t *sb;
1252
1253 if (jbd2_journal_check_used_features(journal, compat, ro, incompat))
1254 return 1;
1255
1256 if (!jbd2_journal_check_available_features(journal, compat, ro, incompat))
1257 return 0;
1258
1259 jbd_debug(1, "Setting new features 0x%lx/0x%lx/0x%lx\n",
1260 compat, ro, incompat);
1261
1262 sb = journal->j_superblock;
1263
1264 sb->s_feature_compat |= cpu_to_be32(compat);
1265 sb->s_feature_ro_compat |= cpu_to_be32(ro);
1266 sb->s_feature_incompat |= cpu_to_be32(incompat);
1267
1268 return 1;
1269}
1270
1271
1272/**
1273 * int jbd2_journal_update_format () - Update on-disk journal structure.
1274 * @journal: Journal to act on.
1275 *
1276 * Given an initialised but unloaded journal struct, poke about in the
1277 * on-disk structure to update it to the most recent supported version.
1278 */
1279int jbd2_journal_update_format (journal_t *journal)
1280{
1281 journal_superblock_t *sb;
1282 int err;
1283
1284 err = journal_get_superblock(journal);
1285 if (err)
1286 return err;
1287
1288 sb = journal->j_superblock;
1289
1290 switch (be32_to_cpu(sb->s_header.h_blocktype)) {
1291 case JBD2_SUPERBLOCK_V2:
1292 return 0;
1293 case JBD2_SUPERBLOCK_V1:
1294 return journal_convert_superblock_v1(journal, sb);
1295 default:
1296 break;
1297 }
1298 return -EINVAL;
1299}
1300
1301static int journal_convert_superblock_v1(journal_t *journal,
1302 journal_superblock_t *sb)
1303{
1304 int offset, blocksize;
1305 struct buffer_head *bh;
1306
1307 printk(KERN_WARNING
1308 "JBD: Converting superblock from version 1 to 2.\n");
1309
1310 /* Pre-initialise new fields to zero */
1311 offset = ((char *) &(sb->s_feature_compat)) - ((char *) sb);
1312 blocksize = be32_to_cpu(sb->s_blocksize);
1313 memset(&sb->s_feature_compat, 0, blocksize-offset);
1314
1315 sb->s_nr_users = cpu_to_be32(1);
1316 sb->s_header.h_blocktype = cpu_to_be32(JBD2_SUPERBLOCK_V2);
1317 journal->j_format_version = 2;
1318
1319 bh = journal->j_sb_buffer;
1320 BUFFER_TRACE(bh, "marking dirty");
1321 mark_buffer_dirty(bh);
1322 sync_dirty_buffer(bh);
1323 return 0;
1324}
1325
1326
1327/**
1328 * int jbd2_journal_flush () - Flush journal
1329 * @journal: Journal to act on.
1330 *
1331 * Flush all data for a given journal to disk and empty the journal.
1332 * Filesystems can use this when remounting readonly to ensure that
1333 * recovery does not need to happen on remount.
1334 */
1335
1336int jbd2_journal_flush(journal_t *journal)
1337{
1338 int err = 0;
1339 transaction_t *transaction = NULL;
1340 unsigned long old_tail;
1341
1342 spin_lock(&journal->j_state_lock);
1343
1344 /* Force everything buffered to the log... */
1345 if (journal->j_running_transaction) {
1346 transaction = journal->j_running_transaction;
1347 __jbd2_log_start_commit(journal, transaction->t_tid);
1348 } else if (journal->j_committing_transaction)
1349 transaction = journal->j_committing_transaction;
1350
1351 /* Wait for the log commit to complete... */
1352 if (transaction) {
1353 tid_t tid = transaction->t_tid;
1354
1355 spin_unlock(&journal->j_state_lock);
1356 jbd2_log_wait_commit(journal, tid);
1357 } else {
1358 spin_unlock(&journal->j_state_lock);
1359 }
1360
1361 /* ...and flush everything in the log out to disk. */
1362 spin_lock(&journal->j_list_lock);
1363 while (!err && journal->j_checkpoint_transactions != NULL) {
1364 spin_unlock(&journal->j_list_lock);
1365 err = jbd2_log_do_checkpoint(journal);
1366 spin_lock(&journal->j_list_lock);
1367 }
1368 spin_unlock(&journal->j_list_lock);
1369 jbd2_cleanup_journal_tail(journal);
1370
1371 /* Finally, mark the journal as really needing no recovery.
1372 * This sets s_start==0 in the underlying superblock, which is
1373 * the magic code for a fully-recovered superblock. Any future
1374 * commits of data to the journal will restore the current
1375 * s_start value. */
1376 spin_lock(&journal->j_state_lock);
1377 old_tail = journal->j_tail;
1378 journal->j_tail = 0;
1379 spin_unlock(&journal->j_state_lock);
1380 jbd2_journal_update_superblock(journal, 1);
1381 spin_lock(&journal->j_state_lock);
1382 journal->j_tail = old_tail;
1383
1384 J_ASSERT(!journal->j_running_transaction);
1385 J_ASSERT(!journal->j_committing_transaction);
1386 J_ASSERT(!journal->j_checkpoint_transactions);
1387 J_ASSERT(journal->j_head == journal->j_tail);
1388 J_ASSERT(journal->j_tail_sequence == journal->j_transaction_sequence);
1389 spin_unlock(&journal->j_state_lock);
1390 return err;
1391}
1392
1393/**
1394 * int jbd2_journal_wipe() - Wipe journal contents
1395 * @journal: Journal to act on.
1396 * @write: flag (see below)
1397 *
1398 * Wipe out all of the contents of a journal, safely. This will produce
1399 * a warning if the journal contains any valid recovery information.
1400 * Must be called between journal_init_*() and jbd2_journal_load().
1401 *
1402 * If 'write' is non-zero, then we wipe out the journal on disk; otherwise
1403 * we merely suppress recovery.
1404 */
1405
1406int jbd2_journal_wipe(journal_t *journal, int write)
1407{
1408 journal_superblock_t *sb;
1409 int err = 0;
1410
1411 J_ASSERT (!(journal->j_flags & JBD2_LOADED));
1412
1413 err = load_superblock(journal);
1414 if (err)
1415 return err;
1416
1417 sb = journal->j_superblock;
1418
1419 if (!journal->j_tail)
1420 goto no_recovery;
1421
1422 printk (KERN_WARNING "JBD: %s recovery information on journal\n",
1423 write ? "Clearing" : "Ignoring");
1424
1425 err = jbd2_journal_skip_recovery(journal);
1426 if (write)
1427 jbd2_journal_update_superblock(journal, 1);
1428
1429 no_recovery:
1430 return err;
1431}
1432
1433/*
1434 * journal_dev_name: format a character string to describe on what
1435 * device this journal is present.
1436 */
1437
1438static const char *journal_dev_name(journal_t *journal, char *buffer)
1439{
1440 struct block_device *bdev;
1441
1442 if (journal->j_inode)
1443 bdev = journal->j_inode->i_sb->s_bdev;
1444 else
1445 bdev = journal->j_dev;
1446
1447 return bdevname(bdev, buffer);
1448}
1449
1450/*
1451 * Journal abort has very specific semantics, which we describe
1452 * for journal abort.
1453 *
1454 * Two internal function, which provide abort to te jbd layer
1455 * itself are here.
1456 */
1457
1458/*
1459 * Quick version for internal journal use (doesn't lock the journal).
1460 * Aborts hard --- we mark the abort as occurred, but do _nothing_ else,
1461 * and don't attempt to make any other journal updates.
1462 */
1463void __jbd2_journal_abort_hard(journal_t *journal)
1464{
1465 transaction_t *transaction;
1466 char b[BDEVNAME_SIZE];
1467
1468 if (journal->j_flags & JBD2_ABORT)
1469 return;
1470
1471 printk(KERN_ERR "Aborting journal on device %s.\n",
1472 journal_dev_name(journal, b));
1473
1474 spin_lock(&journal->j_state_lock);
1475 journal->j_flags |= JBD2_ABORT;
1476 transaction = journal->j_running_transaction;
1477 if (transaction)
1478 __jbd2_log_start_commit(journal, transaction->t_tid);
1479 spin_unlock(&journal->j_state_lock);
1480}
1481
1482/* Soft abort: record the abort error status in the journal superblock,
1483 * but don't do any other IO. */
1484static void __journal_abort_soft (journal_t *journal, int errno)
1485{
1486 if (journal->j_flags & JBD2_ABORT)
1487 return;
1488
1489 if (!journal->j_errno)
1490 journal->j_errno = errno;
1491
1492 __jbd2_journal_abort_hard(journal);
1493
1494 if (errno)
1495 jbd2_journal_update_superblock(journal, 1);
1496}
1497
1498/**
1499 * void jbd2_journal_abort () - Shutdown the journal immediately.
1500 * @journal: the journal to shutdown.
1501 * @errno: an error number to record in the journal indicating
1502 * the reason for the shutdown.
1503 *
1504 * Perform a complete, immediate shutdown of the ENTIRE
1505 * journal (not of a single transaction). This operation cannot be
1506 * undone without closing and reopening the journal.
1507 *
1508 * The jbd2_journal_abort function is intended to support higher level error
1509 * recovery mechanisms such as the ext2/ext3 remount-readonly error
1510 * mode.
1511 *
1512 * Journal abort has very specific semantics. Any existing dirty,
1513 * unjournaled buffers in the main filesystem will still be written to
1514 * disk by bdflush, but the journaling mechanism will be suspended
1515 * immediately and no further transaction commits will be honoured.
1516 *
1517 * Any dirty, journaled buffers will be written back to disk without
1518 * hitting the journal. Atomicity cannot be guaranteed on an aborted
1519 * filesystem, but we _do_ attempt to leave as much data as possible
1520 * behind for fsck to use for cleanup.
1521 *
1522 * Any attempt to get a new transaction handle on a journal which is in
1523 * ABORT state will just result in an -EROFS error return. A
1524 * jbd2_journal_stop on an existing handle will return -EIO if we have
1525 * entered abort state during the update.
1526 *
1527 * Recursive transactions are not disturbed by journal abort until the
1528 * final jbd2_journal_stop, which will receive the -EIO error.
1529 *
1530 * Finally, the jbd2_journal_abort call allows the caller to supply an errno
1531 * which will be recorded (if possible) in the journal superblock. This
1532 * allows a client to record failure conditions in the middle of a
1533 * transaction without having to complete the transaction to record the
1534 * failure to disk. ext3_error, for example, now uses this
1535 * functionality.
1536 *
1537 * Errors which originate from within the journaling layer will NOT
1538 * supply an errno; a null errno implies that absolutely no further
1539 * writes are done to the journal (unless there are any already in
1540 * progress).
1541 *
1542 */
1543
1544void jbd2_journal_abort(journal_t *journal, int errno)
1545{
1546 __journal_abort_soft(journal, errno);
1547}
1548
1549/**
1550 * int jbd2_journal_errno () - returns the journal's error state.
1551 * @journal: journal to examine.
1552 *
1553 * This is the errno numbet set with jbd2_journal_abort(), the last
1554 * time the journal was mounted - if the journal was stopped
1555 * without calling abort this will be 0.
1556 *
1557 * If the journal has been aborted on this mount time -EROFS will
1558 * be returned.
1559 */
1560int jbd2_journal_errno(journal_t *journal)
1561{
1562 int err;
1563
1564 spin_lock(&journal->j_state_lock);
1565 if (journal->j_flags & JBD2_ABORT)
1566 err = -EROFS;
1567 else
1568 err = journal->j_errno;
1569 spin_unlock(&journal->j_state_lock);
1570 return err;
1571}
1572
1573/**
1574 * int jbd2_journal_clear_err () - clears the journal's error state
1575 * @journal: journal to act on.
1576 *
1577 * An error must be cleared or Acked to take a FS out of readonly
1578 * mode.
1579 */
1580int jbd2_journal_clear_err(journal_t *journal)
1581{
1582 int err = 0;
1583
1584 spin_lock(&journal->j_state_lock);
1585 if (journal->j_flags & JBD2_ABORT)
1586 err = -EROFS;
1587 else
1588 journal->j_errno = 0;
1589 spin_unlock(&journal->j_state_lock);
1590 return err;
1591}
1592
1593/**
1594 * void jbd2_journal_ack_err() - Ack journal err.
1595 * @journal: journal to act on.
1596 *
1597 * An error must be cleared or Acked to take a FS out of readonly
1598 * mode.
1599 */
1600void jbd2_journal_ack_err(journal_t *journal)
1601{
1602 spin_lock(&journal->j_state_lock);
1603 if (journal->j_errno)
1604 journal->j_flags |= JBD2_ACK_ERR;
1605 spin_unlock(&journal->j_state_lock);
1606}
1607
1608int jbd2_journal_blocks_per_page(struct inode *inode)
1609{
1610 return 1 << (PAGE_CACHE_SHIFT - inode->i_sb->s_blocksize_bits);
1611}
1612
1613/*
1614 * helper functions to deal with 32 or 64bit block numbers.
1615 */
1616size_t journal_tag_bytes(journal_t *journal)
1617{
1618 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_64BIT))
1619 return JBD_TAG_SIZE64;
1620 else
1621 return JBD_TAG_SIZE32;
1622}
1623
1624/*
1625 * Simple support for retrying memory allocations. Introduced to help to
1626 * debug different VM deadlock avoidance strategies.
1627 */
1628void * __jbd2_kmalloc (const char *where, size_t size, gfp_t flags, int retry)
1629{
1630 return kmalloc(size, flags | (retry ? __GFP_NOFAIL : 0));
1631}
1632
1633/*
1634 * jbd slab management: create 1k, 2k, 4k, 8k slabs as needed
1635 * and allocate frozen and commit buffers from these slabs.
1636 *
1637 * Reason for doing this is to avoid, SLAB_DEBUG - since it could
1638 * cause bh to cross page boundary.
1639 */
1640
1641#define JBD_MAX_SLABS 5
1642#define JBD_SLAB_INDEX(size) (size >> 11)
1643
1644static kmem_cache_t *jbd_slab[JBD_MAX_SLABS];
1645static const char *jbd_slab_names[JBD_MAX_SLABS] = {
1646 "jbd2_1k", "jbd2_2k", "jbd2_4k", NULL, "jbd2_8k"
1647};
1648
1649static void jbd2_journal_destroy_jbd_slabs(void)
1650{
1651 int i;
1652
1653 for (i = 0; i < JBD_MAX_SLABS; i++) {
1654 if (jbd_slab[i])
1655 kmem_cache_destroy(jbd_slab[i]);
1656 jbd_slab[i] = NULL;
1657 }
1658}
1659
1660static int jbd2_journal_create_jbd_slab(size_t slab_size)
1661{
1662 int i = JBD_SLAB_INDEX(slab_size);
1663
1664 BUG_ON(i >= JBD_MAX_SLABS);
1665
1666 /*
1667 * Check if we already have a slab created for this size
1668 */
1669 if (jbd_slab[i])
1670 return 0;
1671
1672 /*
1673 * Create a slab and force alignment to be same as slabsize -
1674 * this will make sure that allocations won't cross the page
1675 * boundary.
1676 */
1677 jbd_slab[i] = kmem_cache_create(jbd_slab_names[i],
1678 slab_size, slab_size, 0, NULL, NULL);
1679 if (!jbd_slab[i]) {
1680 printk(KERN_EMERG "JBD: no memory for jbd_slab cache\n");
1681 return -ENOMEM;
1682 }
1683 return 0;
1684}
1685
1686void * jbd2_slab_alloc(size_t size, gfp_t flags)
1687{
1688 int idx;
1689
1690 idx = JBD_SLAB_INDEX(size);
1691 BUG_ON(jbd_slab[idx] == NULL);
1692 return kmem_cache_alloc(jbd_slab[idx], flags | __GFP_NOFAIL);
1693}
1694
1695void jbd2_slab_free(void *ptr, size_t size)
1696{
1697 int idx;
1698
1699 idx = JBD_SLAB_INDEX(size);
1700 BUG_ON(jbd_slab[idx] == NULL);
1701 kmem_cache_free(jbd_slab[idx], ptr);
1702}
1703
1704/*
1705 * Journal_head storage management
1706 */
1707static kmem_cache_t *jbd2_journal_head_cache;
1708#ifdef CONFIG_JBD_DEBUG
1709static atomic_t nr_journal_heads = ATOMIC_INIT(0);
1710#endif
1711
1712static int journal_init_jbd2_journal_head_cache(void)
1713{
1714 int retval;
1715
1716 J_ASSERT(jbd2_journal_head_cache == 0);
1717 jbd2_journal_head_cache = kmem_cache_create("jbd2_journal_head",
1718 sizeof(struct journal_head),
1719 0, /* offset */
1720 0, /* flags */
1721 NULL, /* ctor */
1722 NULL); /* dtor */
1723 retval = 0;
1724 if (jbd2_journal_head_cache == 0) {
1725 retval = -ENOMEM;
1726 printk(KERN_EMERG "JBD: no memory for journal_head cache\n");
1727 }
1728 return retval;
1729}
1730
1731static void jbd2_journal_destroy_jbd2_journal_head_cache(void)
1732{
1733 J_ASSERT(jbd2_journal_head_cache != NULL);
1734 kmem_cache_destroy(jbd2_journal_head_cache);
1735 jbd2_journal_head_cache = NULL;
1736}
1737
1738/*
1739 * journal_head splicing and dicing
1740 */
1741static struct journal_head *journal_alloc_journal_head(void)
1742{
1743 struct journal_head *ret;
1744 static unsigned long last_warning;
1745
1746#ifdef CONFIG_JBD_DEBUG
1747 atomic_inc(&nr_journal_heads);
1748#endif
1749 ret = kmem_cache_alloc(jbd2_journal_head_cache, GFP_NOFS);
1750 if (ret == 0) {
1751 jbd_debug(1, "out of memory for journal_head\n");
1752 if (time_after(jiffies, last_warning + 5*HZ)) {
1753 printk(KERN_NOTICE "ENOMEM in %s, retrying.\n",
1754 __FUNCTION__);
1755 last_warning = jiffies;
1756 }
1757 while (ret == 0) {
1758 yield();
1759 ret = kmem_cache_alloc(jbd2_journal_head_cache, GFP_NOFS);
1760 }
1761 }
1762 return ret;
1763}
1764
1765static void journal_free_journal_head(struct journal_head *jh)
1766{
1767#ifdef CONFIG_JBD_DEBUG
1768 atomic_dec(&nr_journal_heads);
1769 memset(jh, JBD_POISON_FREE, sizeof(*jh));
1770#endif
1771 kmem_cache_free(jbd2_journal_head_cache, jh);
1772}
1773
1774/*
1775 * A journal_head is attached to a buffer_head whenever JBD has an
1776 * interest in the buffer.
1777 *
1778 * Whenever a buffer has an attached journal_head, its ->b_state:BH_JBD bit
1779 * is set. This bit is tested in core kernel code where we need to take
1780 * JBD-specific actions. Testing the zeroness of ->b_private is not reliable
1781 * there.
1782 *
1783 * When a buffer has its BH_JBD bit set, its ->b_count is elevated by one.
1784 *
1785 * When a buffer has its BH_JBD bit set it is immune from being released by
1786 * core kernel code, mainly via ->b_count.
1787 *
1788 * A journal_head may be detached from its buffer_head when the journal_head's
1789 * b_transaction, b_cp_transaction and b_next_transaction pointers are NULL.
1790 * Various places in JBD call jbd2_journal_remove_journal_head() to indicate that the
1791 * journal_head can be dropped if needed.
1792 *
1793 * Various places in the kernel want to attach a journal_head to a buffer_head
1794 * _before_ attaching the journal_head to a transaction. To protect the
1795 * journal_head in this situation, jbd2_journal_add_journal_head elevates the
1796 * journal_head's b_jcount refcount by one. The caller must call
1797 * jbd2_journal_put_journal_head() to undo this.
1798 *
1799 * So the typical usage would be:
1800 *
1801 * (Attach a journal_head if needed. Increments b_jcount)
1802 * struct journal_head *jh = jbd2_journal_add_journal_head(bh);
1803 * ...
1804 * jh->b_transaction = xxx;
1805 * jbd2_journal_put_journal_head(jh);
1806 *
1807 * Now, the journal_head's b_jcount is zero, but it is safe from being released
1808 * because it has a non-zero b_transaction.
1809 */
1810
1811/*
1812 * Give a buffer_head a journal_head.
1813 *
1814 * Doesn't need the journal lock.
1815 * May sleep.
1816 */
1817struct journal_head *jbd2_journal_add_journal_head(struct buffer_head *bh)
1818{
1819 struct journal_head *jh;
1820 struct journal_head *new_jh = NULL;
1821
1822repeat:
1823 if (!buffer_jbd(bh)) {
1824 new_jh = journal_alloc_journal_head();
1825 memset(new_jh, 0, sizeof(*new_jh));
1826 }
1827
1828 jbd_lock_bh_journal_head(bh);
1829 if (buffer_jbd(bh)) {
1830 jh = bh2jh(bh);
1831 } else {
1832 J_ASSERT_BH(bh,
1833 (atomic_read(&bh->b_count) > 0) ||
1834 (bh->b_page && bh->b_page->mapping));
1835
1836 if (!new_jh) {
1837 jbd_unlock_bh_journal_head(bh);
1838 goto repeat;
1839 }
1840
1841 jh = new_jh;
1842 new_jh = NULL; /* We consumed it */
1843 set_buffer_jbd(bh);
1844 bh->b_private = jh;
1845 jh->b_bh = bh;
1846 get_bh(bh);
1847 BUFFER_TRACE(bh, "added journal_head");
1848 }
1849 jh->b_jcount++;
1850 jbd_unlock_bh_journal_head(bh);
1851 if (new_jh)
1852 journal_free_journal_head(new_jh);
1853 return bh->b_private;
1854}
1855
1856/*
1857 * Grab a ref against this buffer_head's journal_head. If it ended up not
1858 * having a journal_head, return NULL
1859 */
1860struct journal_head *jbd2_journal_grab_journal_head(struct buffer_head *bh)
1861{
1862 struct journal_head *jh = NULL;
1863
1864 jbd_lock_bh_journal_head(bh);
1865 if (buffer_jbd(bh)) {
1866 jh = bh2jh(bh);
1867 jh->b_jcount++;
1868 }
1869 jbd_unlock_bh_journal_head(bh);
1870 return jh;
1871}
1872
1873static void __journal_remove_journal_head(struct buffer_head *bh)
1874{
1875 struct journal_head *jh = bh2jh(bh);
1876
1877 J_ASSERT_JH(jh, jh->b_jcount >= 0);
1878
1879 get_bh(bh);
1880 if (jh->b_jcount == 0) {
1881 if (jh->b_transaction == NULL &&
1882 jh->b_next_transaction == NULL &&
1883 jh->b_cp_transaction == NULL) {
1884 J_ASSERT_JH(jh, jh->b_jlist == BJ_None);
1885 J_ASSERT_BH(bh, buffer_jbd(bh));
1886 J_ASSERT_BH(bh, jh2bh(jh) == bh);
1887 BUFFER_TRACE(bh, "remove journal_head");
1888 if (jh->b_frozen_data) {
1889 printk(KERN_WARNING "%s: freeing "
1890 "b_frozen_data\n",
1891 __FUNCTION__);
1892 jbd2_slab_free(jh->b_frozen_data, bh->b_size);
1893 }
1894 if (jh->b_committed_data) {
1895 printk(KERN_WARNING "%s: freeing "
1896 "b_committed_data\n",
1897 __FUNCTION__);
1898 jbd2_slab_free(jh->b_committed_data, bh->b_size);
1899 }
1900 bh->b_private = NULL;
1901 jh->b_bh = NULL; /* debug, really */
1902 clear_buffer_jbd(bh);
1903 __brelse(bh);
1904 journal_free_journal_head(jh);
1905 } else {
1906 BUFFER_TRACE(bh, "journal_head was locked");
1907 }
1908 }
1909}
1910
1911/*
1912 * jbd2_journal_remove_journal_head(): if the buffer isn't attached to a transaction
1913 * and has a zero b_jcount then remove and release its journal_head. If we did
1914 * see that the buffer is not used by any transaction we also "logically"
1915 * decrement ->b_count.
1916 *
1917 * We in fact take an additional increment on ->b_count as a convenience,
1918 * because the caller usually wants to do additional things with the bh
1919 * after calling here.
1920 * The caller of jbd2_journal_remove_journal_head() *must* run __brelse(bh) at some
1921 * time. Once the caller has run __brelse(), the buffer is eligible for
1922 * reaping by try_to_free_buffers().
1923 */
1924void jbd2_journal_remove_journal_head(struct buffer_head *bh)
1925{
1926 jbd_lock_bh_journal_head(bh);
1927 __journal_remove_journal_head(bh);
1928 jbd_unlock_bh_journal_head(bh);
1929}
1930
1931/*
1932 * Drop a reference on the passed journal_head. If it fell to zero then try to
1933 * release the journal_head from the buffer_head.
1934 */
1935void jbd2_journal_put_journal_head(struct journal_head *jh)
1936{
1937 struct buffer_head *bh = jh2bh(jh);
1938
1939 jbd_lock_bh_journal_head(bh);
1940 J_ASSERT_JH(jh, jh->b_jcount > 0);
1941 --jh->b_jcount;
1942 if (!jh->b_jcount && !jh->b_transaction) {
1943 __journal_remove_journal_head(bh);
1944 __brelse(bh);
1945 }
1946 jbd_unlock_bh_journal_head(bh);
1947}
1948
1949/*
1950 * /proc tunables
1951 */
1952#if defined(CONFIG_JBD_DEBUG)
1953int jbd2_journal_enable_debug;
1954EXPORT_SYMBOL(jbd2_journal_enable_debug);
1955#endif
1956
1957#if defined(CONFIG_JBD_DEBUG) && defined(CONFIG_PROC_FS)
1958
1959static struct proc_dir_entry *proc_jbd_debug;
1960
1961static int read_jbd_debug(char *page, char **start, off_t off,
1962 int count, int *eof, void *data)
1963{
1964 int ret;
1965
1966 ret = sprintf(page + off, "%d\n", jbd2_journal_enable_debug);
1967 *eof = 1;
1968 return ret;
1969}
1970
1971static int write_jbd_debug(struct file *file, const char __user *buffer,
1972 unsigned long count, void *data)
1973{
1974 char buf[32];
1975
1976 if (count > ARRAY_SIZE(buf) - 1)
1977 count = ARRAY_SIZE(buf) - 1;
1978 if (copy_from_user(buf, buffer, count))
1979 return -EFAULT;
1980 buf[ARRAY_SIZE(buf) - 1] = '\0';
1981 jbd2_journal_enable_debug = simple_strtoul(buf, NULL, 10);
1982 return count;
1983}
1984
1985#define JBD_PROC_NAME "sys/fs/jbd2-debug"
1986
1987static void __init create_jbd_proc_entry(void)
1988{
1989 proc_jbd_debug = create_proc_entry(JBD_PROC_NAME, 0644, NULL);
1990 if (proc_jbd_debug) {
1991 /* Why is this so hard? */
1992 proc_jbd_debug->read_proc = read_jbd_debug;
1993 proc_jbd_debug->write_proc = write_jbd_debug;
1994 }
1995}
1996
1997static void __exit jbd2_remove_jbd_proc_entry(void)
1998{
1999 if (proc_jbd_debug)
2000 remove_proc_entry(JBD_PROC_NAME, NULL);
2001}
2002
2003#else
2004
2005#define create_jbd_proc_entry() do {} while (0)
2006#define jbd2_remove_jbd_proc_entry() do {} while (0)
2007
2008#endif
2009
2010kmem_cache_t *jbd2_handle_cache;
2011
2012static int __init journal_init_handle_cache(void)
2013{
2014 jbd2_handle_cache = kmem_cache_create("jbd2_journal_handle",
2015 sizeof(handle_t),
2016 0, /* offset */
2017 0, /* flags */
2018 NULL, /* ctor */
2019 NULL); /* dtor */
2020 if (jbd2_handle_cache == NULL) {
2021 printk(KERN_EMERG "JBD: failed to create handle cache\n");
2022 return -ENOMEM;
2023 }
2024 return 0;
2025}
2026
2027static void jbd2_journal_destroy_handle_cache(void)
2028{
2029 if (jbd2_handle_cache)
2030 kmem_cache_destroy(jbd2_handle_cache);
2031}
2032
2033/*
2034 * Module startup and shutdown
2035 */
2036
2037static int __init journal_init_caches(void)
2038{
2039 int ret;
2040
2041 ret = jbd2_journal_init_revoke_caches();
2042 if (ret == 0)
2043 ret = journal_init_jbd2_journal_head_cache();
2044 if (ret == 0)
2045 ret = journal_init_handle_cache();
2046 return ret;
2047}
2048
2049static void jbd2_journal_destroy_caches(void)
2050{
2051 jbd2_journal_destroy_revoke_caches();
2052 jbd2_journal_destroy_jbd2_journal_head_cache();
2053 jbd2_journal_destroy_handle_cache();
2054 jbd2_journal_destroy_jbd_slabs();
2055}
2056
2057static int __init journal_init(void)
2058{
2059 int ret;
2060
2061 BUILD_BUG_ON(sizeof(struct journal_superblock_s) != 1024);
2062
2063 ret = journal_init_caches();
2064 if (ret != 0)
2065 jbd2_journal_destroy_caches();
2066 create_jbd_proc_entry();
2067 return ret;
2068}
2069
2070static void __exit journal_exit(void)
2071{
2072#ifdef CONFIG_JBD_DEBUG
2073 int n = atomic_read(&nr_journal_heads);
2074 if (n)
2075 printk(KERN_EMERG "JBD: leaked %d journal_heads!\n", n);
2076#endif
2077 jbd2_remove_jbd_proc_entry();
2078 jbd2_journal_destroy_caches();
2079}
2080
2081MODULE_LICENSE("GPL");
2082module_init(journal_init);
2083module_exit(journal_exit);
2084
diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c
new file mode 100644
index 000000000000..9f10acafaf70
--- /dev/null
+++ b/fs/jbd2/recovery.c
@@ -0,0 +1,609 @@
1/*
2 * linux/fs/recovery.c
3 *
4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1999
5 *
6 * Copyright 1999-2000 Red Hat Software --- All Rights Reserved
7 *
8 * This file is part of the Linux kernel and is made available under
9 * the terms of the GNU General Public License, version 2, or at your
10 * option, any later version, incorporated herein by reference.
11 *
12 * Journal recovery routines for the generic filesystem journaling code;
13 * part of the ext2fs journaling system.
14 */
15
16#ifndef __KERNEL__
17#include "jfs_user.h"
18#else
19#include <linux/time.h>
20#include <linux/fs.h>
21#include <linux/jbd2.h>
22#include <linux/errno.h>
23#include <linux/slab.h>
24#endif
25
26/*
27 * Maintain information about the progress of the recovery job, so that
28 * the different passes can carry information between them.
29 */
30struct recovery_info
31{
32 tid_t start_transaction;
33 tid_t end_transaction;
34
35 int nr_replays;
36 int nr_revokes;
37 int nr_revoke_hits;
38};
39
40enum passtype {PASS_SCAN, PASS_REVOKE, PASS_REPLAY};
41static int do_one_pass(journal_t *journal,
42 struct recovery_info *info, enum passtype pass);
43static int scan_revoke_records(journal_t *, struct buffer_head *,
44 tid_t, struct recovery_info *);
45
46#ifdef __KERNEL__
47
48/* Release readahead buffers after use */
49static void journal_brelse_array(struct buffer_head *b[], int n)
50{
51 while (--n >= 0)
52 brelse (b[n]);
53}
54
55
56/*
57 * When reading from the journal, we are going through the block device
58 * layer directly and so there is no readahead being done for us. We
59 * need to implement any readahead ourselves if we want it to happen at
60 * all. Recovery is basically one long sequential read, so make sure we
61 * do the IO in reasonably large chunks.
62 *
63 * This is not so critical that we need to be enormously clever about
64 * the readahead size, though. 128K is a purely arbitrary, good-enough
65 * fixed value.
66 */
67
68#define MAXBUF 8
69static int do_readahead(journal_t *journal, unsigned int start)
70{
71 int err;
72 unsigned int max, nbufs, next;
73 unsigned long long blocknr;
74 struct buffer_head *bh;
75
76 struct buffer_head * bufs[MAXBUF];
77
78 /* Do up to 128K of readahead */
79 max = start + (128 * 1024 / journal->j_blocksize);
80 if (max > journal->j_maxlen)
81 max = journal->j_maxlen;
82
83 /* Do the readahead itself. We'll submit MAXBUF buffer_heads at
84 * a time to the block device IO layer. */
85
86 nbufs = 0;
87
88 for (next = start; next < max; next++) {
89 err = jbd2_journal_bmap(journal, next, &blocknr);
90
91 if (err) {
92 printk (KERN_ERR "JBD: bad block at offset %u\n",
93 next);
94 goto failed;
95 }
96
97 bh = __getblk(journal->j_dev, blocknr, journal->j_blocksize);
98 if (!bh) {
99 err = -ENOMEM;
100 goto failed;
101 }
102
103 if (!buffer_uptodate(bh) && !buffer_locked(bh)) {
104 bufs[nbufs++] = bh;
105 if (nbufs == MAXBUF) {
106 ll_rw_block(READ, nbufs, bufs);
107 journal_brelse_array(bufs, nbufs);
108 nbufs = 0;
109 }
110 } else
111 brelse(bh);
112 }
113
114 if (nbufs)
115 ll_rw_block(READ, nbufs, bufs);
116 err = 0;
117
118failed:
119 if (nbufs)
120 journal_brelse_array(bufs, nbufs);
121 return err;
122}
123
124#endif /* __KERNEL__ */
125
126
127/*
128 * Read a block from the journal
129 */
130
131static int jread(struct buffer_head **bhp, journal_t *journal,
132 unsigned int offset)
133{
134 int err;
135 unsigned long long blocknr;
136 struct buffer_head *bh;
137
138 *bhp = NULL;
139
140 if (offset >= journal->j_maxlen) {
141 printk(KERN_ERR "JBD: corrupted journal superblock\n");
142 return -EIO;
143 }
144
145 err = jbd2_journal_bmap(journal, offset, &blocknr);
146
147 if (err) {
148 printk (KERN_ERR "JBD: bad block at offset %u\n",
149 offset);
150 return err;
151 }
152
153 bh = __getblk(journal->j_dev, blocknr, journal->j_blocksize);
154 if (!bh)
155 return -ENOMEM;
156
157 if (!buffer_uptodate(bh)) {
158 /* If this is a brand new buffer, start readahead.
159 Otherwise, we assume we are already reading it. */
160 if (!buffer_req(bh))
161 do_readahead(journal, offset);
162 wait_on_buffer(bh);
163 }
164
165 if (!buffer_uptodate(bh)) {
166 printk (KERN_ERR "JBD: Failed to read block at offset %u\n",
167 offset);
168 brelse(bh);
169 return -EIO;
170 }
171
172 *bhp = bh;
173 return 0;
174}
175
176
177/*
178 * Count the number of in-use tags in a journal descriptor block.
179 */
180
181static int count_tags(journal_t *journal, struct buffer_head *bh)
182{
183 char * tagp;
184 journal_block_tag_t * tag;
185 int nr = 0, size = journal->j_blocksize;
186 int tag_bytes = journal_tag_bytes(journal);
187
188 tagp = &bh->b_data[sizeof(journal_header_t)];
189
190 while ((tagp - bh->b_data + tag_bytes) <= size) {
191 tag = (journal_block_tag_t *) tagp;
192
193 nr++;
194 tagp += tag_bytes;
195 if (!(tag->t_flags & cpu_to_be32(JBD2_FLAG_SAME_UUID)))
196 tagp += 16;
197
198 if (tag->t_flags & cpu_to_be32(JBD2_FLAG_LAST_TAG))
199 break;
200 }
201
202 return nr;
203}
204
205
206/* Make sure we wrap around the log correctly! */
207#define wrap(journal, var) \
208do { \
209 if (var >= (journal)->j_last) \
210 var -= ((journal)->j_last - (journal)->j_first); \
211} while (0)
212
213/**
214 * jbd2_journal_recover - recovers a on-disk journal
215 * @journal: the journal to recover
216 *
217 * The primary function for recovering the log contents when mounting a
218 * journaled device.
219 *
220 * Recovery is done in three passes. In the first pass, we look for the
221 * end of the log. In the second, we assemble the list of revoke
222 * blocks. In the third and final pass, we replay any un-revoked blocks
223 * in the log.
224 */
225int jbd2_journal_recover(journal_t *journal)
226{
227 int err;
228 journal_superblock_t * sb;
229
230 struct recovery_info info;
231
232 memset(&info, 0, sizeof(info));
233 sb = journal->j_superblock;
234
235 /*
236 * The journal superblock's s_start field (the current log head)
237 * is always zero if, and only if, the journal was cleanly
238 * unmounted.
239 */
240
241 if (!sb->s_start) {
242 jbd_debug(1, "No recovery required, last transaction %d\n",
243 be32_to_cpu(sb->s_sequence));
244 journal->j_transaction_sequence = be32_to_cpu(sb->s_sequence) + 1;
245 return 0;
246 }
247
248 err = do_one_pass(journal, &info, PASS_SCAN);
249 if (!err)
250 err = do_one_pass(journal, &info, PASS_REVOKE);
251 if (!err)
252 err = do_one_pass(journal, &info, PASS_REPLAY);
253
254 jbd_debug(0, "JBD: recovery, exit status %d, "
255 "recovered transactions %u to %u\n",
256 err, info.start_transaction, info.end_transaction);
257 jbd_debug(0, "JBD: Replayed %d and revoked %d/%d blocks\n",
258 info.nr_replays, info.nr_revoke_hits, info.nr_revokes);
259
260 /* Restart the log at the next transaction ID, thus invalidating
261 * any existing commit records in the log. */
262 journal->j_transaction_sequence = ++info.end_transaction;
263
264 jbd2_journal_clear_revoke(journal);
265 sync_blockdev(journal->j_fs_dev);
266 return err;
267}
268
269/**
270 * jbd2_journal_skip_recovery - Start journal and wipe exiting records
271 * @journal: journal to startup
272 *
273 * Locate any valid recovery information from the journal and set up the
274 * journal structures in memory to ignore it (presumably because the
275 * caller has evidence that it is out of date).
276 * This function does'nt appear to be exorted..
277 *
278 * We perform one pass over the journal to allow us to tell the user how
279 * much recovery information is being erased, and to let us initialise
280 * the journal transaction sequence numbers to the next unused ID.
281 */
282int jbd2_journal_skip_recovery(journal_t *journal)
283{
284 int err;
285 journal_superblock_t * sb;
286
287 struct recovery_info info;
288
289 memset (&info, 0, sizeof(info));
290 sb = journal->j_superblock;
291
292 err = do_one_pass(journal, &info, PASS_SCAN);
293
294 if (err) {
295 printk(KERN_ERR "JBD: error %d scanning journal\n", err);
296 ++journal->j_transaction_sequence;
297 } else {
298#ifdef CONFIG_JBD_DEBUG
299 int dropped = info.end_transaction - be32_to_cpu(sb->s_sequence);
300#endif
301 jbd_debug(0,
302 "JBD: ignoring %d transaction%s from the journal.\n",
303 dropped, (dropped == 1) ? "" : "s");
304 journal->j_transaction_sequence = ++info.end_transaction;
305 }
306
307 journal->j_tail = 0;
308 return err;
309}
310
311static inline unsigned long long read_tag_block(int tag_bytes, journal_block_tag_t *tag)
312{
313 unsigned long long block = be32_to_cpu(tag->t_blocknr);
314 if (tag_bytes > JBD_TAG_SIZE32)
315 block |= (u64)be32_to_cpu(tag->t_blocknr_high) << 32;
316 return block;
317}
318
319static int do_one_pass(journal_t *journal,
320 struct recovery_info *info, enum passtype pass)
321{
322 unsigned int first_commit_ID, next_commit_ID;
323 unsigned long next_log_block;
324 int err, success = 0;
325 journal_superblock_t * sb;
326 journal_header_t * tmp;
327 struct buffer_head * bh;
328 unsigned int sequence;
329 int blocktype;
330 int tag_bytes = journal_tag_bytes(journal);
331
332 /* Precompute the maximum metadata descriptors in a descriptor block */
333 int MAX_BLOCKS_PER_DESC;
334 MAX_BLOCKS_PER_DESC = ((journal->j_blocksize-sizeof(journal_header_t))
335 / tag_bytes);
336
337 /*
338 * First thing is to establish what we expect to find in the log
339 * (in terms of transaction IDs), and where (in terms of log
340 * block offsets): query the superblock.
341 */
342
343 sb = journal->j_superblock;
344 next_commit_ID = be32_to_cpu(sb->s_sequence);
345 next_log_block = be32_to_cpu(sb->s_start);
346
347 first_commit_ID = next_commit_ID;
348 if (pass == PASS_SCAN)
349 info->start_transaction = first_commit_ID;
350
351 jbd_debug(1, "Starting recovery pass %d\n", pass);
352
353 /*
354 * Now we walk through the log, transaction by transaction,
355 * making sure that each transaction has a commit block in the
356 * expected place. Each complete transaction gets replayed back
357 * into the main filesystem.
358 */
359
360 while (1) {
361 int flags;
362 char * tagp;
363 journal_block_tag_t * tag;
364 struct buffer_head * obh;
365 struct buffer_head * nbh;
366
367 cond_resched(); /* We're under lock_kernel() */
368
369 /* If we already know where to stop the log traversal,
370 * check right now that we haven't gone past the end of
371 * the log. */
372
373 if (pass != PASS_SCAN)
374 if (tid_geq(next_commit_ID, info->end_transaction))
375 break;
376
377 jbd_debug(2, "Scanning for sequence ID %u at %lu/%lu\n",
378 next_commit_ID, next_log_block, journal->j_last);
379
380 /* Skip over each chunk of the transaction looking
381 * either the next descriptor block or the final commit
382 * record. */
383
384 jbd_debug(3, "JBD: checking block %ld\n", next_log_block);
385 err = jread(&bh, journal, next_log_block);
386 if (err)
387 goto failed;
388
389 next_log_block++;
390 wrap(journal, next_log_block);
391
392 /* What kind of buffer is it?
393 *
394 * If it is a descriptor block, check that it has the
395 * expected sequence number. Otherwise, we're all done
396 * here. */
397
398 tmp = (journal_header_t *)bh->b_data;
399
400 if (tmp->h_magic != cpu_to_be32(JBD2_MAGIC_NUMBER)) {
401 brelse(bh);
402 break;
403 }
404
405 blocktype = be32_to_cpu(tmp->h_blocktype);
406 sequence = be32_to_cpu(tmp->h_sequence);
407 jbd_debug(3, "Found magic %d, sequence %d\n",
408 blocktype, sequence);
409
410 if (sequence != next_commit_ID) {
411 brelse(bh);
412 break;
413 }
414
415 /* OK, we have a valid descriptor block which matches
416 * all of the sequence number checks. What are we going
417 * to do with it? That depends on the pass... */
418
419 switch(blocktype) {
420 case JBD2_DESCRIPTOR_BLOCK:
421 /* If it is a valid descriptor block, replay it
422 * in pass REPLAY; otherwise, just skip over the
423 * blocks it describes. */
424 if (pass != PASS_REPLAY) {
425 next_log_block += count_tags(journal, bh);
426 wrap(journal, next_log_block);
427 brelse(bh);
428 continue;
429 }
430
431 /* A descriptor block: we can now write all of
432 * the data blocks. Yay, useful work is finally
433 * getting done here! */
434
435 tagp = &bh->b_data[sizeof(journal_header_t)];
436 while ((tagp - bh->b_data + tag_bytes)
437 <= journal->j_blocksize) {
438 unsigned long io_block;
439
440 tag = (journal_block_tag_t *) tagp;
441 flags = be32_to_cpu(tag->t_flags);
442
443 io_block = next_log_block++;
444 wrap(journal, next_log_block);
445 err = jread(&obh, journal, io_block);
446 if (err) {
447 /* Recover what we can, but
448 * report failure at the end. */
449 success = err;
450 printk (KERN_ERR
451 "JBD: IO error %d recovering "
452 "block %ld in log\n",
453 err, io_block);
454 } else {
455 unsigned long long blocknr;
456
457 J_ASSERT(obh != NULL);
458 blocknr = read_tag_block(tag_bytes,
459 tag);
460
461 /* If the block has been
462 * revoked, then we're all done
463 * here. */
464 if (jbd2_journal_test_revoke
465 (journal, blocknr,
466 next_commit_ID)) {
467 brelse(obh);
468 ++info->nr_revoke_hits;
469 goto skip_write;
470 }
471
472 /* Find a buffer for the new
473 * data being restored */
474 nbh = __getblk(journal->j_fs_dev,
475 blocknr,
476 journal->j_blocksize);
477 if (nbh == NULL) {
478 printk(KERN_ERR
479 "JBD: Out of memory "
480 "during recovery.\n");
481 err = -ENOMEM;
482 brelse(bh);
483 brelse(obh);
484 goto failed;
485 }
486
487 lock_buffer(nbh);
488 memcpy(nbh->b_data, obh->b_data,
489 journal->j_blocksize);
490 if (flags & JBD2_FLAG_ESCAPE) {
491 *((__be32 *)bh->b_data) =
492 cpu_to_be32(JBD2_MAGIC_NUMBER);
493 }
494
495 BUFFER_TRACE(nbh, "marking dirty");
496 set_buffer_uptodate(nbh);
497 mark_buffer_dirty(nbh);
498 BUFFER_TRACE(nbh, "marking uptodate");
499 ++info->nr_replays;
500 /* ll_rw_block(WRITE, 1, &nbh); */
501 unlock_buffer(nbh);
502 brelse(obh);
503 brelse(nbh);
504 }
505
506 skip_write:
507 tagp += tag_bytes;
508 if (!(flags & JBD2_FLAG_SAME_UUID))
509 tagp += 16;
510
511 if (flags & JBD2_FLAG_LAST_TAG)
512 break;
513 }
514
515 brelse(bh);
516 continue;
517
518 case JBD2_COMMIT_BLOCK:
519 /* Found an expected commit block: not much to
520 * do other than move on to the next sequence
521 * number. */
522 brelse(bh);
523 next_commit_ID++;
524 continue;
525
526 case JBD2_REVOKE_BLOCK:
527 /* If we aren't in the REVOKE pass, then we can
528 * just skip over this block. */
529 if (pass != PASS_REVOKE) {
530 brelse(bh);
531 continue;
532 }
533
534 err = scan_revoke_records(journal, bh,
535 next_commit_ID, info);
536 brelse(bh);
537 if (err)
538 goto failed;
539 continue;
540
541 default:
542 jbd_debug(3, "Unrecognised magic %d, end of scan.\n",
543 blocktype);
544 brelse(bh);
545 goto done;
546 }
547 }
548
549 done:
550 /*
551 * We broke out of the log scan loop: either we came to the
552 * known end of the log or we found an unexpected block in the
553 * log. If the latter happened, then we know that the "current"
554 * transaction marks the end of the valid log.
555 */
556
557 if (pass == PASS_SCAN)
558 info->end_transaction = next_commit_ID;
559 else {
560 /* It's really bad news if different passes end up at
561 * different places (but possible due to IO errors). */
562 if (info->end_transaction != next_commit_ID) {
563 printk (KERN_ERR "JBD: recovery pass %d ended at "
564 "transaction %u, expected %u\n",
565 pass, next_commit_ID, info->end_transaction);
566 if (!success)
567 success = -EIO;
568 }
569 }
570
571 return success;
572
573 failed:
574 return err;
575}
576
577
578/* Scan a revoke record, marking all blocks mentioned as revoked. */
579
580static int scan_revoke_records(journal_t *journal, struct buffer_head *bh,
581 tid_t sequence, struct recovery_info *info)
582{
583 jbd2_journal_revoke_header_t *header;
584 int offset, max;
585 int record_len = 4;
586
587 header = (jbd2_journal_revoke_header_t *) bh->b_data;
588 offset = sizeof(jbd2_journal_revoke_header_t);
589 max = be32_to_cpu(header->r_count);
590
591 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_64BIT))
592 record_len = 8;
593
594 while (offset + record_len <= max) {
595 unsigned long long blocknr;
596 int err;
597
598 if (record_len == 4)
599 blocknr = be32_to_cpu(* ((__be32 *) (bh->b_data+offset)));
600 else
601 blocknr = be64_to_cpu(* ((__be64 *) (bh->b_data+offset)));
602 offset += record_len;
603 err = jbd2_journal_set_revoke(journal, blocknr, sequence);
604 if (err)
605 return err;
606 ++info->nr_revokes;
607 }
608 return 0;
609}
diff --git a/fs/jbd2/revoke.c b/fs/jbd2/revoke.c
new file mode 100644
index 000000000000..380d19917f37
--- /dev/null
+++ b/fs/jbd2/revoke.c
@@ -0,0 +1,712 @@
1/*
2 * linux/fs/revoke.c
3 *
4 * Written by Stephen C. Tweedie <sct@redhat.com>, 2000
5 *
6 * Copyright 2000 Red Hat corp --- All Rights Reserved
7 *
8 * This file is part of the Linux kernel and is made available under
9 * the terms of the GNU General Public License, version 2, or at your
10 * option, any later version, incorporated herein by reference.
11 *
12 * Journal revoke routines for the generic filesystem journaling code;
13 * part of the ext2fs journaling system.
14 *
15 * Revoke is the mechanism used to prevent old log records for deleted
16 * metadata from being replayed on top of newer data using the same
17 * blocks. The revoke mechanism is used in two separate places:
18 *
19 * + Commit: during commit we write the entire list of the current
20 * transaction's revoked blocks to the journal
21 *
22 * + Recovery: during recovery we record the transaction ID of all
23 * revoked blocks. If there are multiple revoke records in the log
24 * for a single block, only the last one counts, and if there is a log
25 * entry for a block beyond the last revoke, then that log entry still
26 * gets replayed.
27 *
28 * We can get interactions between revokes and new log data within a
29 * single transaction:
30 *
31 * Block is revoked and then journaled:
32 * The desired end result is the journaling of the new block, so we
33 * cancel the revoke before the transaction commits.
34 *
35 * Block is journaled and then revoked:
36 * The revoke must take precedence over the write of the block, so we
37 * need either to cancel the journal entry or to write the revoke
38 * later in the log than the log block. In this case, we choose the
39 * latter: journaling a block cancels any revoke record for that block
40 * in the current transaction, so any revoke for that block in the
41 * transaction must have happened after the block was journaled and so
42 * the revoke must take precedence.
43 *
44 * Block is revoked and then written as data:
45 * The data write is allowed to succeed, but the revoke is _not_
46 * cancelled. We still need to prevent old log records from
47 * overwriting the new data. We don't even need to clear the revoke
48 * bit here.
49 *
50 * Revoke information on buffers is a tri-state value:
51 *
52 * RevokeValid clear: no cached revoke status, need to look it up
53 * RevokeValid set, Revoked clear:
54 * buffer has not been revoked, and cancel_revoke
55 * need do nothing.
56 * RevokeValid set, Revoked set:
57 * buffer has been revoked.
58 */
59
60#ifndef __KERNEL__
61#include "jfs_user.h"
62#else
63#include <linux/time.h>
64#include <linux/fs.h>
65#include <linux/jbd2.h>
66#include <linux/errno.h>
67#include <linux/slab.h>
68#include <linux/list.h>
69#include <linux/smp_lock.h>
70#include <linux/init.h>
71#endif
72
73static kmem_cache_t *jbd2_revoke_record_cache;
74static kmem_cache_t *jbd2_revoke_table_cache;
75
76/* Each revoke record represents one single revoked block. During
77 journal replay, this involves recording the transaction ID of the
78 last transaction to revoke this block. */
79
80struct jbd2_revoke_record_s
81{
82 struct list_head hash;
83 tid_t sequence; /* Used for recovery only */
84 unsigned long long blocknr;
85};
86
87
88/* The revoke table is just a simple hash table of revoke records. */
89struct jbd2_revoke_table_s
90{
91 /* It is conceivable that we might want a larger hash table
92 * for recovery. Must be a power of two. */
93 int hash_size;
94 int hash_shift;
95 struct list_head *hash_table;
96};
97
98
99#ifdef __KERNEL__
100static void write_one_revoke_record(journal_t *, transaction_t *,
101 struct journal_head **, int *,
102 struct jbd2_revoke_record_s *);
103static void flush_descriptor(journal_t *, struct journal_head *, int);
104#endif
105
106/* Utility functions to maintain the revoke table */
107
108/* Borrowed from buffer.c: this is a tried and tested block hash function */
109static inline int hash(journal_t *journal, unsigned long long block)
110{
111 struct jbd2_revoke_table_s *table = journal->j_revoke;
112 int hash_shift = table->hash_shift;
113 int hash = (int)block ^ (int)((block >> 31) >> 1);
114
115 return ((hash << (hash_shift - 6)) ^
116 (hash >> 13) ^
117 (hash << (hash_shift - 12))) & (table->hash_size - 1);
118}
119
120static int insert_revoke_hash(journal_t *journal, unsigned long long blocknr,
121 tid_t seq)
122{
123 struct list_head *hash_list;
124 struct jbd2_revoke_record_s *record;
125
126repeat:
127 record = kmem_cache_alloc(jbd2_revoke_record_cache, GFP_NOFS);
128 if (!record)
129 goto oom;
130
131 record->sequence = seq;
132 record->blocknr = blocknr;
133 hash_list = &journal->j_revoke->hash_table[hash(journal, blocknr)];
134 spin_lock(&journal->j_revoke_lock);
135 list_add(&record->hash, hash_list);
136 spin_unlock(&journal->j_revoke_lock);
137 return 0;
138
139oom:
140 if (!journal_oom_retry)
141 return -ENOMEM;
142 jbd_debug(1, "ENOMEM in %s, retrying\n", __FUNCTION__);
143 yield();
144 goto repeat;
145}
146
147/* Find a revoke record in the journal's hash table. */
148
149static struct jbd2_revoke_record_s *find_revoke_record(journal_t *journal,
150 unsigned long long blocknr)
151{
152 struct list_head *hash_list;
153 struct jbd2_revoke_record_s *record;
154
155 hash_list = &journal->j_revoke->hash_table[hash(journal, blocknr)];
156
157 spin_lock(&journal->j_revoke_lock);
158 record = (struct jbd2_revoke_record_s *) hash_list->next;
159 while (&(record->hash) != hash_list) {
160 if (record->blocknr == blocknr) {
161 spin_unlock(&journal->j_revoke_lock);
162 return record;
163 }
164 record = (struct jbd2_revoke_record_s *) record->hash.next;
165 }
166 spin_unlock(&journal->j_revoke_lock);
167 return NULL;
168}
169
170int __init jbd2_journal_init_revoke_caches(void)
171{
172 jbd2_revoke_record_cache = kmem_cache_create("jbd2_revoke_record",
173 sizeof(struct jbd2_revoke_record_s),
174 0, SLAB_HWCACHE_ALIGN, NULL, NULL);
175 if (jbd2_revoke_record_cache == 0)
176 return -ENOMEM;
177
178 jbd2_revoke_table_cache = kmem_cache_create("jbd2_revoke_table",
179 sizeof(struct jbd2_revoke_table_s),
180 0, 0, NULL, NULL);
181 if (jbd2_revoke_table_cache == 0) {
182 kmem_cache_destroy(jbd2_revoke_record_cache);
183 jbd2_revoke_record_cache = NULL;
184 return -ENOMEM;
185 }
186 return 0;
187}
188
189void jbd2_journal_destroy_revoke_caches(void)
190{
191 kmem_cache_destroy(jbd2_revoke_record_cache);
192 jbd2_revoke_record_cache = NULL;
193 kmem_cache_destroy(jbd2_revoke_table_cache);
194 jbd2_revoke_table_cache = NULL;
195}
196
197/* Initialise the revoke table for a given journal to a given size. */
198
199int jbd2_journal_init_revoke(journal_t *journal, int hash_size)
200{
201 int shift, tmp;
202
203 J_ASSERT (journal->j_revoke_table[0] == NULL);
204
205 shift = 0;
206 tmp = hash_size;
207 while((tmp >>= 1UL) != 0UL)
208 shift++;
209
210 journal->j_revoke_table[0] = kmem_cache_alloc(jbd2_revoke_table_cache, GFP_KERNEL);
211 if (!journal->j_revoke_table[0])
212 return -ENOMEM;
213 journal->j_revoke = journal->j_revoke_table[0];
214
215 /* Check that the hash_size is a power of two */
216 J_ASSERT ((hash_size & (hash_size-1)) == 0);
217
218 journal->j_revoke->hash_size = hash_size;
219
220 journal->j_revoke->hash_shift = shift;
221
222 journal->j_revoke->hash_table =
223 kmalloc(hash_size * sizeof(struct list_head), GFP_KERNEL);
224 if (!journal->j_revoke->hash_table) {
225 kmem_cache_free(jbd2_revoke_table_cache, journal->j_revoke_table[0]);
226 journal->j_revoke = NULL;
227 return -ENOMEM;
228 }
229
230 for (tmp = 0; tmp < hash_size; tmp++)
231 INIT_LIST_HEAD(&journal->j_revoke->hash_table[tmp]);
232
233 journal->j_revoke_table[1] = kmem_cache_alloc(jbd2_revoke_table_cache, GFP_KERNEL);
234 if (!journal->j_revoke_table[1]) {
235 kfree(journal->j_revoke_table[0]->hash_table);
236 kmem_cache_free(jbd2_revoke_table_cache, journal->j_revoke_table[0]);
237 return -ENOMEM;
238 }
239
240 journal->j_revoke = journal->j_revoke_table[1];
241
242 /* Check that the hash_size is a power of two */
243 J_ASSERT ((hash_size & (hash_size-1)) == 0);
244
245 journal->j_revoke->hash_size = hash_size;
246
247 journal->j_revoke->hash_shift = shift;
248
249 journal->j_revoke->hash_table =
250 kmalloc(hash_size * sizeof(struct list_head), GFP_KERNEL);
251 if (!journal->j_revoke->hash_table) {
252 kfree(journal->j_revoke_table[0]->hash_table);
253 kmem_cache_free(jbd2_revoke_table_cache, journal->j_revoke_table[0]);
254 kmem_cache_free(jbd2_revoke_table_cache, journal->j_revoke_table[1]);
255 journal->j_revoke = NULL;
256 return -ENOMEM;
257 }
258
259 for (tmp = 0; tmp < hash_size; tmp++)
260 INIT_LIST_HEAD(&journal->j_revoke->hash_table[tmp]);
261
262 spin_lock_init(&journal->j_revoke_lock);
263
264 return 0;
265}
266
267/* Destoy a journal's revoke table. The table must already be empty! */
268
269void jbd2_journal_destroy_revoke(journal_t *journal)
270{
271 struct jbd2_revoke_table_s *table;
272 struct list_head *hash_list;
273 int i;
274
275 table = journal->j_revoke_table[0];
276 if (!table)
277 return;
278
279 for (i=0; i<table->hash_size; i++) {
280 hash_list = &table->hash_table[i];
281 J_ASSERT (list_empty(hash_list));
282 }
283
284 kfree(table->hash_table);
285 kmem_cache_free(jbd2_revoke_table_cache, table);
286 journal->j_revoke = NULL;
287
288 table = journal->j_revoke_table[1];
289 if (!table)
290 return;
291
292 for (i=0; i<table->hash_size; i++) {
293 hash_list = &table->hash_table[i];
294 J_ASSERT (list_empty(hash_list));
295 }
296
297 kfree(table->hash_table);
298 kmem_cache_free(jbd2_revoke_table_cache, table);
299 journal->j_revoke = NULL;
300}
301
302
303#ifdef __KERNEL__
304
305/*
306 * jbd2_journal_revoke: revoke a given buffer_head from the journal. This
307 * prevents the block from being replayed during recovery if we take a
308 * crash after this current transaction commits. Any subsequent
309 * metadata writes of the buffer in this transaction cancel the
310 * revoke.
311 *
312 * Note that this call may block --- it is up to the caller to make
313 * sure that there are no further calls to journal_write_metadata
314 * before the revoke is complete. In ext3, this implies calling the
315 * revoke before clearing the block bitmap when we are deleting
316 * metadata.
317 *
318 * Revoke performs a jbd2_journal_forget on any buffer_head passed in as a
319 * parameter, but does _not_ forget the buffer_head if the bh was only
320 * found implicitly.
321 *
322 * bh_in may not be a journalled buffer - it may have come off
323 * the hash tables without an attached journal_head.
324 *
325 * If bh_in is non-zero, jbd2_journal_revoke() will decrement its b_count
326 * by one.
327 */
328
329int jbd2_journal_revoke(handle_t *handle, unsigned long long blocknr,
330 struct buffer_head *bh_in)
331{
332 struct buffer_head *bh = NULL;
333 journal_t *journal;
334 struct block_device *bdev;
335 int err;
336
337 might_sleep();
338 if (bh_in)
339 BUFFER_TRACE(bh_in, "enter");
340
341 journal = handle->h_transaction->t_journal;
342 if (!jbd2_journal_set_features(journal, 0, 0, JBD2_FEATURE_INCOMPAT_REVOKE)){
343 J_ASSERT (!"Cannot set revoke feature!");
344 return -EINVAL;
345 }
346
347 bdev = journal->j_fs_dev;
348 bh = bh_in;
349
350 if (!bh) {
351 bh = __find_get_block(bdev, blocknr, journal->j_blocksize);
352 if (bh)
353 BUFFER_TRACE(bh, "found on hash");
354 }
355#ifdef JBD_EXPENSIVE_CHECKING
356 else {
357 struct buffer_head *bh2;
358
359 /* If there is a different buffer_head lying around in
360 * memory anywhere... */
361 bh2 = __find_get_block(bdev, blocknr, journal->j_blocksize);
362 if (bh2) {
363 /* ... and it has RevokeValid status... */
364 if (bh2 != bh && buffer_revokevalid(bh2))
365 /* ...then it better be revoked too,
366 * since it's illegal to create a revoke
367 * record against a buffer_head which is
368 * not marked revoked --- that would
369 * risk missing a subsequent revoke
370 * cancel. */
371 J_ASSERT_BH(bh2, buffer_revoked(bh2));
372 put_bh(bh2);
373 }
374 }
375#endif
376
377 /* We really ought not ever to revoke twice in a row without
378 first having the revoke cancelled: it's illegal to free a
379 block twice without allocating it in between! */
380 if (bh) {
381 if (!J_EXPECT_BH(bh, !buffer_revoked(bh),
382 "inconsistent data on disk")) {
383 if (!bh_in)
384 brelse(bh);
385 return -EIO;
386 }
387 set_buffer_revoked(bh);
388 set_buffer_revokevalid(bh);
389 if (bh_in) {
390 BUFFER_TRACE(bh_in, "call jbd2_journal_forget");
391 jbd2_journal_forget(handle, bh_in);
392 } else {
393 BUFFER_TRACE(bh, "call brelse");
394 __brelse(bh);
395 }
396 }
397
398 jbd_debug(2, "insert revoke for block %llu, bh_in=%p\n",blocknr, bh_in);
399 err = insert_revoke_hash(journal, blocknr,
400 handle->h_transaction->t_tid);
401 BUFFER_TRACE(bh_in, "exit");
402 return err;
403}
404
405/*
406 * Cancel an outstanding revoke. For use only internally by the
407 * journaling code (called from jbd2_journal_get_write_access).
408 *
409 * We trust buffer_revoked() on the buffer if the buffer is already
410 * being journaled: if there is no revoke pending on the buffer, then we
411 * don't do anything here.
412 *
413 * This would break if it were possible for a buffer to be revoked and
414 * discarded, and then reallocated within the same transaction. In such
415 * a case we would have lost the revoked bit, but when we arrived here
416 * the second time we would still have a pending revoke to cancel. So,
417 * do not trust the Revoked bit on buffers unless RevokeValid is also
418 * set.
419 *
420 * The caller must have the journal locked.
421 */
422int jbd2_journal_cancel_revoke(handle_t *handle, struct journal_head *jh)
423{
424 struct jbd2_revoke_record_s *record;
425 journal_t *journal = handle->h_transaction->t_journal;
426 int need_cancel;
427 int did_revoke = 0; /* akpm: debug */
428 struct buffer_head *bh = jh2bh(jh);
429
430 jbd_debug(4, "journal_head %p, cancelling revoke\n", jh);
431
432 /* Is the existing Revoke bit valid? If so, we trust it, and
433 * only perform the full cancel if the revoke bit is set. If
434 * not, we can't trust the revoke bit, and we need to do the
435 * full search for a revoke record. */
436 if (test_set_buffer_revokevalid(bh)) {
437 need_cancel = test_clear_buffer_revoked(bh);
438 } else {
439 need_cancel = 1;
440 clear_buffer_revoked(bh);
441 }
442
443 if (need_cancel) {
444 record = find_revoke_record(journal, bh->b_blocknr);
445 if (record) {
446 jbd_debug(4, "cancelled existing revoke on "
447 "blocknr %llu\n", (unsigned long long)bh->b_blocknr);
448 spin_lock(&journal->j_revoke_lock);
449 list_del(&record->hash);
450 spin_unlock(&journal->j_revoke_lock);
451 kmem_cache_free(jbd2_revoke_record_cache, record);
452 did_revoke = 1;
453 }
454 }
455
456#ifdef JBD_EXPENSIVE_CHECKING
457 /* There better not be one left behind by now! */
458 record = find_revoke_record(journal, bh->b_blocknr);
459 J_ASSERT_JH(jh, record == NULL);
460#endif
461
462 /* Finally, have we just cleared revoke on an unhashed
463 * buffer_head? If so, we'd better make sure we clear the
464 * revoked status on any hashed alias too, otherwise the revoke
465 * state machine will get very upset later on. */
466 if (need_cancel) {
467 struct buffer_head *bh2;
468 bh2 = __find_get_block(bh->b_bdev, bh->b_blocknr, bh->b_size);
469 if (bh2) {
470 if (bh2 != bh)
471 clear_buffer_revoked(bh2);
472 __brelse(bh2);
473 }
474 }
475 return did_revoke;
476}
477
478/* journal_switch_revoke table select j_revoke for next transaction
479 * we do not want to suspend any processing until all revokes are
480 * written -bzzz
481 */
482void jbd2_journal_switch_revoke_table(journal_t *journal)
483{
484 int i;
485
486 if (journal->j_revoke == journal->j_revoke_table[0])
487 journal->j_revoke = journal->j_revoke_table[1];
488 else
489 journal->j_revoke = journal->j_revoke_table[0];
490
491 for (i = 0; i < journal->j_revoke->hash_size; i++)
492 INIT_LIST_HEAD(&journal->j_revoke->hash_table[i]);
493}
494
495/*
496 * Write revoke records to the journal for all entries in the current
497 * revoke hash, deleting the entries as we go.
498 *
499 * Called with the journal lock held.
500 */
501
502void jbd2_journal_write_revoke_records(journal_t *journal,
503 transaction_t *transaction)
504{
505 struct journal_head *descriptor;
506 struct jbd2_revoke_record_s *record;
507 struct jbd2_revoke_table_s *revoke;
508 struct list_head *hash_list;
509 int i, offset, count;
510
511 descriptor = NULL;
512 offset = 0;
513 count = 0;
514
515 /* select revoke table for committing transaction */
516 revoke = journal->j_revoke == journal->j_revoke_table[0] ?
517 journal->j_revoke_table[1] : journal->j_revoke_table[0];
518
519 for (i = 0; i < revoke->hash_size; i++) {
520 hash_list = &revoke->hash_table[i];
521
522 while (!list_empty(hash_list)) {
523 record = (struct jbd2_revoke_record_s *)
524 hash_list->next;
525 write_one_revoke_record(journal, transaction,
526 &descriptor, &offset,
527 record);
528 count++;
529 list_del(&record->hash);
530 kmem_cache_free(jbd2_revoke_record_cache, record);
531 }
532 }
533 if (descriptor)
534 flush_descriptor(journal, descriptor, offset);
535 jbd_debug(1, "Wrote %d revoke records\n", count);
536}
537
538/*
539 * Write out one revoke record. We need to create a new descriptor
540 * block if the old one is full or if we have not already created one.
541 */
542
543static void write_one_revoke_record(journal_t *journal,
544 transaction_t *transaction,
545 struct journal_head **descriptorp,
546 int *offsetp,
547 struct jbd2_revoke_record_s *record)
548{
549 struct journal_head *descriptor;
550 int offset;
551 journal_header_t *header;
552
553 /* If we are already aborting, this all becomes a noop. We
554 still need to go round the loop in
555 jbd2_journal_write_revoke_records in order to free all of the
556 revoke records: only the IO to the journal is omitted. */
557 if (is_journal_aborted(journal))
558 return;
559
560 descriptor = *descriptorp;
561 offset = *offsetp;
562
563 /* Make sure we have a descriptor with space left for the record */
564 if (descriptor) {
565 if (offset == journal->j_blocksize) {
566 flush_descriptor(journal, descriptor, offset);
567 descriptor = NULL;
568 }
569 }
570
571 if (!descriptor) {
572 descriptor = jbd2_journal_get_descriptor_buffer(journal);
573 if (!descriptor)
574 return;
575 header = (journal_header_t *) &jh2bh(descriptor)->b_data[0];
576 header->h_magic = cpu_to_be32(JBD2_MAGIC_NUMBER);
577 header->h_blocktype = cpu_to_be32(JBD2_REVOKE_BLOCK);
578 header->h_sequence = cpu_to_be32(transaction->t_tid);
579
580 /* Record it so that we can wait for IO completion later */
581 JBUFFER_TRACE(descriptor, "file as BJ_LogCtl");
582 jbd2_journal_file_buffer(descriptor, transaction, BJ_LogCtl);
583
584 offset = sizeof(jbd2_journal_revoke_header_t);
585 *descriptorp = descriptor;
586 }
587
588 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_64BIT)) {
589 * ((__be64 *)(&jh2bh(descriptor)->b_data[offset])) =
590 cpu_to_be64(record->blocknr);
591 offset += 8;
592
593 } else {
594 * ((__be32 *)(&jh2bh(descriptor)->b_data[offset])) =
595 cpu_to_be32(record->blocknr);
596 offset += 4;
597 }
598
599 *offsetp = offset;
600}
601
602/*
603 * Flush a revoke descriptor out to the journal. If we are aborting,
604 * this is a noop; otherwise we are generating a buffer which needs to
605 * be waited for during commit, so it has to go onto the appropriate
606 * journal buffer list.
607 */
608
609static void flush_descriptor(journal_t *journal,
610 struct journal_head *descriptor,
611 int offset)
612{
613 jbd2_journal_revoke_header_t *header;
614 struct buffer_head *bh = jh2bh(descriptor);
615
616 if (is_journal_aborted(journal)) {
617 put_bh(bh);
618 return;
619 }
620
621 header = (jbd2_journal_revoke_header_t *) jh2bh(descriptor)->b_data;
622 header->r_count = cpu_to_be32(offset);
623 set_buffer_jwrite(bh);
624 BUFFER_TRACE(bh, "write");
625 set_buffer_dirty(bh);
626 ll_rw_block(SWRITE, 1, &bh);
627}
628#endif
629
630/*
631 * Revoke support for recovery.
632 *
633 * Recovery needs to be able to:
634 *
635 * record all revoke records, including the tid of the latest instance
636 * of each revoke in the journal
637 *
638 * check whether a given block in a given transaction should be replayed
639 * (ie. has not been revoked by a revoke record in that or a subsequent
640 * transaction)
641 *
642 * empty the revoke table after recovery.
643 */
644
645/*
646 * First, setting revoke records. We create a new revoke record for
647 * every block ever revoked in the log as we scan it for recovery, and
648 * we update the existing records if we find multiple revokes for a
649 * single block.
650 */
651
652int jbd2_journal_set_revoke(journal_t *journal,
653 unsigned long long blocknr,
654 tid_t sequence)
655{
656 struct jbd2_revoke_record_s *record;
657
658 record = find_revoke_record(journal, blocknr);
659 if (record) {
660 /* If we have multiple occurrences, only record the
661 * latest sequence number in the hashed record */
662 if (tid_gt(sequence, record->sequence))
663 record->sequence = sequence;
664 return 0;
665 }
666 return insert_revoke_hash(journal, blocknr, sequence);
667}
668
669/*
670 * Test revoke records. For a given block referenced in the log, has
671 * that block been revoked? A revoke record with a given transaction
672 * sequence number revokes all blocks in that transaction and earlier
673 * ones, but later transactions still need replayed.
674 */
675
676int jbd2_journal_test_revoke(journal_t *journal,
677 unsigned long long blocknr,
678 tid_t sequence)
679{
680 struct jbd2_revoke_record_s *record;
681
682 record = find_revoke_record(journal, blocknr);
683 if (!record)
684 return 0;
685 if (tid_gt(sequence, record->sequence))
686 return 0;
687 return 1;
688}
689
690/*
691 * Finally, once recovery is over, we need to clear the revoke table so
692 * that it can be reused by the running filesystem.
693 */
694
695void jbd2_journal_clear_revoke(journal_t *journal)
696{
697 int i;
698 struct list_head *hash_list;
699 struct jbd2_revoke_record_s *record;
700 struct jbd2_revoke_table_s *revoke;
701
702 revoke = journal->j_revoke;
703
704 for (i = 0; i < revoke->hash_size; i++) {
705 hash_list = &revoke->hash_table[i];
706 while (!list_empty(hash_list)) {
707 record = (struct jbd2_revoke_record_s*) hash_list->next;
708 list_del(&record->hash);
709 kmem_cache_free(jbd2_revoke_record_cache, record);
710 }
711 }
712}
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
new file mode 100644
index 000000000000..c051a94c8a97
--- /dev/null
+++ b/fs/jbd2/transaction.c
@@ -0,0 +1,2094 @@
1/*
2 * linux/fs/transaction.c
3 *
4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1998
5 *
6 * Copyright 1998 Red Hat corp --- All Rights Reserved
7 *
8 * This file is part of the Linux kernel and is made available under
9 * the terms of the GNU General Public License, version 2, or at your
10 * option, any later version, incorporated herein by reference.
11 *
12 * Generic filesystem transaction handling code; part of the ext2fs
13 * journaling system.
14 *
15 * This file manages transactions (compound commits managed by the
16 * journaling code) and handles (individual atomic operations by the
17 * filesystem).
18 */
19
20#include <linux/time.h>
21#include <linux/fs.h>
22#include <linux/jbd2.h>
23#include <linux/errno.h>
24#include <linux/slab.h>
25#include <linux/timer.h>
26#include <linux/smp_lock.h>
27#include <linux/mm.h>
28#include <linux/highmem.h>
29
30/*
31 * jbd2_get_transaction: obtain a new transaction_t object.
32 *
33 * Simply allocate and initialise a new transaction. Create it in
34 * RUNNING state and add it to the current journal (which should not
35 * have an existing running transaction: we only make a new transaction
36 * once we have started to commit the old one).
37 *
38 * Preconditions:
39 * The journal MUST be locked. We don't perform atomic mallocs on the
40 * new transaction and we can't block without protecting against other
41 * processes trying to touch the journal while it is in transition.
42 *
43 * Called under j_state_lock
44 */
45
46static transaction_t *
47jbd2_get_transaction(journal_t *journal, transaction_t *transaction)
48{
49 transaction->t_journal = journal;
50 transaction->t_state = T_RUNNING;
51 transaction->t_tid = journal->j_transaction_sequence++;
52 transaction->t_expires = jiffies + journal->j_commit_interval;
53 spin_lock_init(&transaction->t_handle_lock);
54
55 /* Set up the commit timer for the new transaction. */
56 journal->j_commit_timer.expires = transaction->t_expires;
57 add_timer(&journal->j_commit_timer);
58
59 J_ASSERT(journal->j_running_transaction == NULL);
60 journal->j_running_transaction = transaction;
61
62 return transaction;
63}
64
65/*
66 * Handle management.
67 *
68 * A handle_t is an object which represents a single atomic update to a
69 * filesystem, and which tracks all of the modifications which form part
70 * of that one update.
71 */
72
73/*
74 * start_this_handle: Given a handle, deal with any locking or stalling
75 * needed to make sure that there is enough journal space for the handle
76 * to begin. Attach the handle to a transaction and set up the
77 * transaction's buffer credits.
78 */
79
80static int start_this_handle(journal_t *journal, handle_t *handle)
81{
82 transaction_t *transaction;
83 int needed;
84 int nblocks = handle->h_buffer_credits;
85 transaction_t *new_transaction = NULL;
86 int ret = 0;
87
88 if (nblocks > journal->j_max_transaction_buffers) {
89 printk(KERN_ERR "JBD: %s wants too many credits (%d > %d)\n",
90 current->comm, nblocks,
91 journal->j_max_transaction_buffers);
92 ret = -ENOSPC;
93 goto out;
94 }
95
96alloc_transaction:
97 if (!journal->j_running_transaction) {
98 new_transaction = jbd_kmalloc(sizeof(*new_transaction),
99 GFP_NOFS);
100 if (!new_transaction) {
101 ret = -ENOMEM;
102 goto out;
103 }
104 memset(new_transaction, 0, sizeof(*new_transaction));
105 }
106
107 jbd_debug(3, "New handle %p going live.\n", handle);
108
109repeat:
110
111 /*
112 * We need to hold j_state_lock until t_updates has been incremented,
113 * for proper journal barrier handling
114 */
115 spin_lock(&journal->j_state_lock);
116repeat_locked:
117 if (is_journal_aborted(journal) ||
118 (journal->j_errno != 0 && !(journal->j_flags & JBD2_ACK_ERR))) {
119 spin_unlock(&journal->j_state_lock);
120 ret = -EROFS;
121 goto out;
122 }
123
124 /* Wait on the journal's transaction barrier if necessary */
125 if (journal->j_barrier_count) {
126 spin_unlock(&journal->j_state_lock);
127 wait_event(journal->j_wait_transaction_locked,
128 journal->j_barrier_count == 0);
129 goto repeat;
130 }
131
132 if (!journal->j_running_transaction) {
133 if (!new_transaction) {
134 spin_unlock(&journal->j_state_lock);
135 goto alloc_transaction;
136 }
137 jbd2_get_transaction(journal, new_transaction);
138 new_transaction = NULL;
139 }
140
141 transaction = journal->j_running_transaction;
142
143 /*
144 * If the current transaction is locked down for commit, wait for the
145 * lock to be released.
146 */
147 if (transaction->t_state == T_LOCKED) {
148 DEFINE_WAIT(wait);
149
150 prepare_to_wait(&journal->j_wait_transaction_locked,
151 &wait, TASK_UNINTERRUPTIBLE);
152 spin_unlock(&journal->j_state_lock);
153 schedule();
154 finish_wait(&journal->j_wait_transaction_locked, &wait);
155 goto repeat;
156 }
157
158 /*
159 * If there is not enough space left in the log to write all potential
160 * buffers requested by this operation, we need to stall pending a log
161 * checkpoint to free some more log space.
162 */
163 spin_lock(&transaction->t_handle_lock);
164 needed = transaction->t_outstanding_credits + nblocks;
165
166 if (needed > journal->j_max_transaction_buffers) {
167 /*
168 * If the current transaction is already too large, then start
169 * to commit it: we can then go back and attach this handle to
170 * a new transaction.
171 */
172 DEFINE_WAIT(wait);
173
174 jbd_debug(2, "Handle %p starting new commit...\n", handle);
175 spin_unlock(&transaction->t_handle_lock);
176 prepare_to_wait(&journal->j_wait_transaction_locked, &wait,
177 TASK_UNINTERRUPTIBLE);
178 __jbd2_log_start_commit(journal, transaction->t_tid);
179 spin_unlock(&journal->j_state_lock);
180 schedule();
181 finish_wait(&journal->j_wait_transaction_locked, &wait);
182 goto repeat;
183 }
184
185 /*
186 * The commit code assumes that it can get enough log space
187 * without forcing a checkpoint. This is *critical* for
188 * correctness: a checkpoint of a buffer which is also
189 * associated with a committing transaction creates a deadlock,
190 * so commit simply cannot force through checkpoints.
191 *
192 * We must therefore ensure the necessary space in the journal
193 * *before* starting to dirty potentially checkpointed buffers
194 * in the new transaction.
195 *
196 * The worst part is, any transaction currently committing can
197 * reduce the free space arbitrarily. Be careful to account for
198 * those buffers when checkpointing.
199 */
200
201 /*
202 * @@@ AKPM: This seems rather over-defensive. We're giving commit
203 * a _lot_ of headroom: 1/4 of the journal plus the size of
204 * the committing transaction. Really, we only need to give it
205 * committing_transaction->t_outstanding_credits plus "enough" for
206 * the log control blocks.
207 * Also, this test is inconsitent with the matching one in
208 * jbd2_journal_extend().
209 */
210 if (__jbd2_log_space_left(journal) < jbd_space_needed(journal)) {
211 jbd_debug(2, "Handle %p waiting for checkpoint...\n", handle);
212 spin_unlock(&transaction->t_handle_lock);
213 __jbd2_log_wait_for_space(journal);
214 goto repeat_locked;
215 }
216
217 /* OK, account for the buffers that this operation expects to
218 * use and add the handle to the running transaction. */
219
220 handle->h_transaction = transaction;
221 transaction->t_outstanding_credits += nblocks;
222 transaction->t_updates++;
223 transaction->t_handle_count++;
224 jbd_debug(4, "Handle %p given %d credits (total %d, free %d)\n",
225 handle, nblocks, transaction->t_outstanding_credits,
226 __jbd2_log_space_left(journal));
227 spin_unlock(&transaction->t_handle_lock);
228 spin_unlock(&journal->j_state_lock);
229out:
230 if (unlikely(new_transaction)) /* It's usually NULL */
231 kfree(new_transaction);
232 return ret;
233}
234
235/* Allocate a new handle. This should probably be in a slab... */
236static handle_t *new_handle(int nblocks)
237{
238 handle_t *handle = jbd_alloc_handle(GFP_NOFS);
239 if (!handle)
240 return NULL;
241 memset(handle, 0, sizeof(*handle));
242 handle->h_buffer_credits = nblocks;
243 handle->h_ref = 1;
244
245 return handle;
246}
247
248/**
249 * handle_t *jbd2_journal_start() - Obtain a new handle.
250 * @journal: Journal to start transaction on.
251 * @nblocks: number of block buffer we might modify
252 *
253 * We make sure that the transaction can guarantee at least nblocks of
254 * modified buffers in the log. We block until the log can guarantee
255 * that much space.
256 *
257 * This function is visible to journal users (like ext3fs), so is not
258 * called with the journal already locked.
259 *
260 * Return a pointer to a newly allocated handle, or NULL on failure
261 */
262handle_t *jbd2_journal_start(journal_t *journal, int nblocks)
263{
264 handle_t *handle = journal_current_handle();
265 int err;
266
267 if (!journal)
268 return ERR_PTR(-EROFS);
269
270 if (handle) {
271 J_ASSERT(handle->h_transaction->t_journal == journal);
272 handle->h_ref++;
273 return handle;
274 }
275
276 handle = new_handle(nblocks);
277 if (!handle)
278 return ERR_PTR(-ENOMEM);
279
280 current->journal_info = handle;
281
282 err = start_this_handle(journal, handle);
283 if (err < 0) {
284 jbd_free_handle(handle);
285 current->journal_info = NULL;
286 handle = ERR_PTR(err);
287 }
288 return handle;
289}
290
291/**
292 * int jbd2_journal_extend() - extend buffer credits.
293 * @handle: handle to 'extend'
294 * @nblocks: nr blocks to try to extend by.
295 *
296 * Some transactions, such as large extends and truncates, can be done
297 * atomically all at once or in several stages. The operation requests
298 * a credit for a number of buffer modications in advance, but can
299 * extend its credit if it needs more.
300 *
301 * jbd2_journal_extend tries to give the running handle more buffer credits.
302 * It does not guarantee that allocation - this is a best-effort only.
303 * The calling process MUST be able to deal cleanly with a failure to
304 * extend here.
305 *
306 * Return 0 on success, non-zero on failure.
307 *
308 * return code < 0 implies an error
309 * return code > 0 implies normal transaction-full status.
310 */
311int jbd2_journal_extend(handle_t *handle, int nblocks)
312{
313 transaction_t *transaction = handle->h_transaction;
314 journal_t *journal = transaction->t_journal;
315 int result;
316 int wanted;
317
318 result = -EIO;
319 if (is_handle_aborted(handle))
320 goto out;
321
322 result = 1;
323
324 spin_lock(&journal->j_state_lock);
325
326 /* Don't extend a locked-down transaction! */
327 if (handle->h_transaction->t_state != T_RUNNING) {
328 jbd_debug(3, "denied handle %p %d blocks: "
329 "transaction not running\n", handle, nblocks);
330 goto error_out;
331 }
332
333 spin_lock(&transaction->t_handle_lock);
334 wanted = transaction->t_outstanding_credits + nblocks;
335
336 if (wanted > journal->j_max_transaction_buffers) {
337 jbd_debug(3, "denied handle %p %d blocks: "
338 "transaction too large\n", handle, nblocks);
339 goto unlock;
340 }
341
342 if (wanted > __jbd2_log_space_left(journal)) {
343 jbd_debug(3, "denied handle %p %d blocks: "
344 "insufficient log space\n", handle, nblocks);
345 goto unlock;
346 }
347
348 handle->h_buffer_credits += nblocks;
349 transaction->t_outstanding_credits += nblocks;
350 result = 0;
351
352 jbd_debug(3, "extended handle %p by %d\n", handle, nblocks);
353unlock:
354 spin_unlock(&transaction->t_handle_lock);
355error_out:
356 spin_unlock(&journal->j_state_lock);
357out:
358 return result;
359}
360
361
362/**
363 * int jbd2_journal_restart() - restart a handle .
364 * @handle: handle to restart
365 * @nblocks: nr credits requested
366 *
367 * Restart a handle for a multi-transaction filesystem
368 * operation.
369 *
370 * If the jbd2_journal_extend() call above fails to grant new buffer credits
371 * to a running handle, a call to jbd2_journal_restart will commit the
372 * handle's transaction so far and reattach the handle to a new
373 * transaction capabable of guaranteeing the requested number of
374 * credits.
375 */
376
377int jbd2_journal_restart(handle_t *handle, int nblocks)
378{
379 transaction_t *transaction = handle->h_transaction;
380 journal_t *journal = transaction->t_journal;
381 int ret;
382
383 /* If we've had an abort of any type, don't even think about
384 * actually doing the restart! */
385 if (is_handle_aborted(handle))
386 return 0;
387
388 /*
389 * First unlink the handle from its current transaction, and start the
390 * commit on that.
391 */
392 J_ASSERT(transaction->t_updates > 0);
393 J_ASSERT(journal_current_handle() == handle);
394
395 spin_lock(&journal->j_state_lock);
396 spin_lock(&transaction->t_handle_lock);
397 transaction->t_outstanding_credits -= handle->h_buffer_credits;
398 transaction->t_updates--;
399
400 if (!transaction->t_updates)
401 wake_up(&journal->j_wait_updates);
402 spin_unlock(&transaction->t_handle_lock);
403
404 jbd_debug(2, "restarting handle %p\n", handle);
405 __jbd2_log_start_commit(journal, transaction->t_tid);
406 spin_unlock(&journal->j_state_lock);
407
408 handle->h_buffer_credits = nblocks;
409 ret = start_this_handle(journal, handle);
410 return ret;
411}
412
413
414/**
415 * void jbd2_journal_lock_updates () - establish a transaction barrier.
416 * @journal: Journal to establish a barrier on.
417 *
418 * This locks out any further updates from being started, and blocks
419 * until all existing updates have completed, returning only once the
420 * journal is in a quiescent state with no updates running.
421 *
422 * The journal lock should not be held on entry.
423 */
424void jbd2_journal_lock_updates(journal_t *journal)
425{
426 DEFINE_WAIT(wait);
427
428 spin_lock(&journal->j_state_lock);
429 ++journal->j_barrier_count;
430
431 /* Wait until there are no running updates */
432 while (1) {
433 transaction_t *transaction = journal->j_running_transaction;
434
435 if (!transaction)
436 break;
437
438 spin_lock(&transaction->t_handle_lock);
439 if (!transaction->t_updates) {
440 spin_unlock(&transaction->t_handle_lock);
441 break;
442 }
443 prepare_to_wait(&journal->j_wait_updates, &wait,
444 TASK_UNINTERRUPTIBLE);
445 spin_unlock(&transaction->t_handle_lock);
446 spin_unlock(&journal->j_state_lock);
447 schedule();
448 finish_wait(&journal->j_wait_updates, &wait);
449 spin_lock(&journal->j_state_lock);
450 }
451 spin_unlock(&journal->j_state_lock);
452
453 /*
454 * We have now established a barrier against other normal updates, but
455 * we also need to barrier against other jbd2_journal_lock_updates() calls
456 * to make sure that we serialise special journal-locked operations
457 * too.
458 */
459 mutex_lock(&journal->j_barrier);
460}
461
462/**
463 * void jbd2_journal_unlock_updates (journal_t* journal) - release barrier
464 * @journal: Journal to release the barrier on.
465 *
466 * Release a transaction barrier obtained with jbd2_journal_lock_updates().
467 *
468 * Should be called without the journal lock held.
469 */
470void jbd2_journal_unlock_updates (journal_t *journal)
471{
472 J_ASSERT(journal->j_barrier_count != 0);
473
474 mutex_unlock(&journal->j_barrier);
475 spin_lock(&journal->j_state_lock);
476 --journal->j_barrier_count;
477 spin_unlock(&journal->j_state_lock);
478 wake_up(&journal->j_wait_transaction_locked);
479}
480
481/*
482 * Report any unexpected dirty buffers which turn up. Normally those
483 * indicate an error, but they can occur if the user is running (say)
484 * tune2fs to modify the live filesystem, so we need the option of
485 * continuing as gracefully as possible. #
486 *
487 * The caller should already hold the journal lock and
488 * j_list_lock spinlock: most callers will need those anyway
489 * in order to probe the buffer's journaling state safely.
490 */
491static void jbd_unexpected_dirty_buffer(struct journal_head *jh)
492{
493 int jlist;
494
495 /* If this buffer is one which might reasonably be dirty
496 * --- ie. data, or not part of this journal --- then
497 * we're OK to leave it alone, but otherwise we need to
498 * move the dirty bit to the journal's own internal
499 * JBDDirty bit. */
500 jlist = jh->b_jlist;
501
502 if (jlist == BJ_Metadata || jlist == BJ_Reserved ||
503 jlist == BJ_Shadow || jlist == BJ_Forget) {
504 struct buffer_head *bh = jh2bh(jh);
505
506 if (test_clear_buffer_dirty(bh))
507 set_buffer_jbddirty(bh);
508 }
509}
510
511/*
512 * If the buffer is already part of the current transaction, then there
513 * is nothing we need to do. If it is already part of a prior
514 * transaction which we are still committing to disk, then we need to
515 * make sure that we do not overwrite the old copy: we do copy-out to
516 * preserve the copy going to disk. We also account the buffer against
517 * the handle's metadata buffer credits (unless the buffer is already
518 * part of the transaction, that is).
519 *
520 */
521static int
522do_get_write_access(handle_t *handle, struct journal_head *jh,
523 int force_copy)
524{
525 struct buffer_head *bh;
526 transaction_t *transaction;
527 journal_t *journal;
528 int error;
529 char *frozen_buffer = NULL;
530 int need_copy = 0;
531
532 if (is_handle_aborted(handle))
533 return -EROFS;
534
535 transaction = handle->h_transaction;
536 journal = transaction->t_journal;
537
538 jbd_debug(5, "buffer_head %p, force_copy %d\n", jh, force_copy);
539
540 JBUFFER_TRACE(jh, "entry");
541repeat:
542 bh = jh2bh(jh);
543
544 /* @@@ Need to check for errors here at some point. */
545
546 lock_buffer(bh);
547 jbd_lock_bh_state(bh);
548
549 /* We now hold the buffer lock so it is safe to query the buffer
550 * state. Is the buffer dirty?
551 *
552 * If so, there are two possibilities. The buffer may be
553 * non-journaled, and undergoing a quite legitimate writeback.
554 * Otherwise, it is journaled, and we don't expect dirty buffers
555 * in that state (the buffers should be marked JBD_Dirty
556 * instead.) So either the IO is being done under our own
557 * control and this is a bug, or it's a third party IO such as
558 * dump(8) (which may leave the buffer scheduled for read ---
559 * ie. locked but not dirty) or tune2fs (which may actually have
560 * the buffer dirtied, ugh.) */
561
562 if (buffer_dirty(bh)) {
563 /*
564 * First question: is this buffer already part of the current
565 * transaction or the existing committing transaction?
566 */
567 if (jh->b_transaction) {
568 J_ASSERT_JH(jh,
569 jh->b_transaction == transaction ||
570 jh->b_transaction ==
571 journal->j_committing_transaction);
572 if (jh->b_next_transaction)
573 J_ASSERT_JH(jh, jh->b_next_transaction ==
574 transaction);
575 }
576 /*
577 * In any case we need to clean the dirty flag and we must
578 * do it under the buffer lock to be sure we don't race
579 * with running write-out.
580 */
581 JBUFFER_TRACE(jh, "Unexpected dirty buffer");
582 jbd_unexpected_dirty_buffer(jh);
583 }
584
585 unlock_buffer(bh);
586
587 error = -EROFS;
588 if (is_handle_aborted(handle)) {
589 jbd_unlock_bh_state(bh);
590 goto out;
591 }
592 error = 0;
593
594 /*
595 * The buffer is already part of this transaction if b_transaction or
596 * b_next_transaction points to it
597 */
598 if (jh->b_transaction == transaction ||
599 jh->b_next_transaction == transaction)
600 goto done;
601
602 /*
603 * If there is already a copy-out version of this buffer, then we don't
604 * need to make another one
605 */
606 if (jh->b_frozen_data) {
607 JBUFFER_TRACE(jh, "has frozen data");
608 J_ASSERT_JH(jh, jh->b_next_transaction == NULL);
609 jh->b_next_transaction = transaction;
610 goto done;
611 }
612
613 /* Is there data here we need to preserve? */
614
615 if (jh->b_transaction && jh->b_transaction != transaction) {
616 JBUFFER_TRACE(jh, "owned by older transaction");
617 J_ASSERT_JH(jh, jh->b_next_transaction == NULL);
618 J_ASSERT_JH(jh, jh->b_transaction ==
619 journal->j_committing_transaction);
620
621 /* There is one case we have to be very careful about.
622 * If the committing transaction is currently writing
623 * this buffer out to disk and has NOT made a copy-out,
624 * then we cannot modify the buffer contents at all
625 * right now. The essence of copy-out is that it is the
626 * extra copy, not the primary copy, which gets
627 * journaled. If the primary copy is already going to
628 * disk then we cannot do copy-out here. */
629
630 if (jh->b_jlist == BJ_Shadow) {
631 DEFINE_WAIT_BIT(wait, &bh->b_state, BH_Unshadow);
632 wait_queue_head_t *wqh;
633
634 wqh = bit_waitqueue(&bh->b_state, BH_Unshadow);
635
636 JBUFFER_TRACE(jh, "on shadow: sleep");
637 jbd_unlock_bh_state(bh);
638 /* commit wakes up all shadow buffers after IO */
639 for ( ; ; ) {
640 prepare_to_wait(wqh, &wait.wait,
641 TASK_UNINTERRUPTIBLE);
642 if (jh->b_jlist != BJ_Shadow)
643 break;
644 schedule();
645 }
646 finish_wait(wqh, &wait.wait);
647 goto repeat;
648 }
649
650 /* Only do the copy if the currently-owning transaction
651 * still needs it. If it is on the Forget list, the
652 * committing transaction is past that stage. The
653 * buffer had better remain locked during the kmalloc,
654 * but that should be true --- we hold the journal lock
655 * still and the buffer is already on the BUF_JOURNAL
656 * list so won't be flushed.
657 *
658 * Subtle point, though: if this is a get_undo_access,
659 * then we will be relying on the frozen_data to contain
660 * the new value of the committed_data record after the
661 * transaction, so we HAVE to force the frozen_data copy
662 * in that case. */
663
664 if (jh->b_jlist != BJ_Forget || force_copy) {
665 JBUFFER_TRACE(jh, "generate frozen data");
666 if (!frozen_buffer) {
667 JBUFFER_TRACE(jh, "allocate memory for buffer");
668 jbd_unlock_bh_state(bh);
669 frozen_buffer =
670 jbd2_slab_alloc(jh2bh(jh)->b_size,
671 GFP_NOFS);
672 if (!frozen_buffer) {
673 printk(KERN_EMERG
674 "%s: OOM for frozen_buffer\n",
675 __FUNCTION__);
676 JBUFFER_TRACE(jh, "oom!");
677 error = -ENOMEM;
678 jbd_lock_bh_state(bh);
679 goto done;
680 }
681 goto repeat;
682 }
683 jh->b_frozen_data = frozen_buffer;
684 frozen_buffer = NULL;
685 need_copy = 1;
686 }
687 jh->b_next_transaction = transaction;
688 }
689
690
691 /*
692 * Finally, if the buffer is not journaled right now, we need to make
693 * sure it doesn't get written to disk before the caller actually
694 * commits the new data
695 */
696 if (!jh->b_transaction) {
697 JBUFFER_TRACE(jh, "no transaction");
698 J_ASSERT_JH(jh, !jh->b_next_transaction);
699 jh->b_transaction = transaction;
700 JBUFFER_TRACE(jh, "file as BJ_Reserved");
701 spin_lock(&journal->j_list_lock);
702 __jbd2_journal_file_buffer(jh, transaction, BJ_Reserved);
703 spin_unlock(&journal->j_list_lock);
704 }
705
706done:
707 if (need_copy) {
708 struct page *page;
709 int offset;
710 char *source;
711
712 J_EXPECT_JH(jh, buffer_uptodate(jh2bh(jh)),
713 "Possible IO failure.\n");
714 page = jh2bh(jh)->b_page;
715 offset = ((unsigned long) jh2bh(jh)->b_data) & ~PAGE_MASK;
716 source = kmap_atomic(page, KM_USER0);
717 memcpy(jh->b_frozen_data, source+offset, jh2bh(jh)->b_size);
718 kunmap_atomic(source, KM_USER0);
719 }
720 jbd_unlock_bh_state(bh);
721
722 /*
723 * If we are about to journal a buffer, then any revoke pending on it is
724 * no longer valid
725 */
726 jbd2_journal_cancel_revoke(handle, jh);
727
728out:
729 if (unlikely(frozen_buffer)) /* It's usually NULL */
730 jbd2_slab_free(frozen_buffer, bh->b_size);
731
732 JBUFFER_TRACE(jh, "exit");
733 return error;
734}
735
736/**
737 * int jbd2_journal_get_write_access() - notify intent to modify a buffer for metadata (not data) update.
738 * @handle: transaction to add buffer modifications to
739 * @bh: bh to be used for metadata writes
740 * @credits: variable that will receive credits for the buffer
741 *
742 * Returns an error code or 0 on success.
743 *
744 * In full data journalling mode the buffer may be of type BJ_AsyncData,
745 * because we're write()ing a buffer which is also part of a shared mapping.
746 */
747
748int jbd2_journal_get_write_access(handle_t *handle, struct buffer_head *bh)
749{
750 struct journal_head *jh = jbd2_journal_add_journal_head(bh);
751 int rc;
752
753 /* We do not want to get caught playing with fields which the
754 * log thread also manipulates. Make sure that the buffer
755 * completes any outstanding IO before proceeding. */
756 rc = do_get_write_access(handle, jh, 0);
757 jbd2_journal_put_journal_head(jh);
758 return rc;
759}
760
761
762/*
763 * When the user wants to journal a newly created buffer_head
764 * (ie. getblk() returned a new buffer and we are going to populate it
765 * manually rather than reading off disk), then we need to keep the
766 * buffer_head locked until it has been completely filled with new
767 * data. In this case, we should be able to make the assertion that
768 * the bh is not already part of an existing transaction.
769 *
770 * The buffer should already be locked by the caller by this point.
771 * There is no lock ranking violation: it was a newly created,
772 * unlocked buffer beforehand. */
773
774/**
775 * int jbd2_journal_get_create_access () - notify intent to use newly created bh
776 * @handle: transaction to new buffer to
777 * @bh: new buffer.
778 *
779 * Call this if you create a new bh.
780 */
781int jbd2_journal_get_create_access(handle_t *handle, struct buffer_head *bh)
782{
783 transaction_t *transaction = handle->h_transaction;
784 journal_t *journal = transaction->t_journal;
785 struct journal_head *jh = jbd2_journal_add_journal_head(bh);
786 int err;
787
788 jbd_debug(5, "journal_head %p\n", jh);
789 err = -EROFS;
790 if (is_handle_aborted(handle))
791 goto out;
792 err = 0;
793
794 JBUFFER_TRACE(jh, "entry");
795 /*
796 * The buffer may already belong to this transaction due to pre-zeroing
797 * in the filesystem's new_block code. It may also be on the previous,
798 * committing transaction's lists, but it HAS to be in Forget state in
799 * that case: the transaction must have deleted the buffer for it to be
800 * reused here.
801 */
802 jbd_lock_bh_state(bh);
803 spin_lock(&journal->j_list_lock);
804 J_ASSERT_JH(jh, (jh->b_transaction == transaction ||
805 jh->b_transaction == NULL ||
806 (jh->b_transaction == journal->j_committing_transaction &&
807 jh->b_jlist == BJ_Forget)));
808
809 J_ASSERT_JH(jh, jh->b_next_transaction == NULL);
810 J_ASSERT_JH(jh, buffer_locked(jh2bh(jh)));
811
812 if (jh->b_transaction == NULL) {
813 jh->b_transaction = transaction;
814 JBUFFER_TRACE(jh, "file as BJ_Reserved");
815 __jbd2_journal_file_buffer(jh, transaction, BJ_Reserved);
816 } else if (jh->b_transaction == journal->j_committing_transaction) {
817 JBUFFER_TRACE(jh, "set next transaction");
818 jh->b_next_transaction = transaction;
819 }
820 spin_unlock(&journal->j_list_lock);
821 jbd_unlock_bh_state(bh);
822
823 /*
824 * akpm: I added this. ext3_alloc_branch can pick up new indirect
825 * blocks which contain freed but then revoked metadata. We need
826 * to cancel the revoke in case we end up freeing it yet again
827 * and the reallocating as data - this would cause a second revoke,
828 * which hits an assertion error.
829 */
830 JBUFFER_TRACE(jh, "cancelling revoke");
831 jbd2_journal_cancel_revoke(handle, jh);
832 jbd2_journal_put_journal_head(jh);
833out:
834 return err;
835}
836
837/**
838 * int jbd2_journal_get_undo_access() - Notify intent to modify metadata with
839 * non-rewindable consequences
840 * @handle: transaction
841 * @bh: buffer to undo
842 * @credits: store the number of taken credits here (if not NULL)
843 *
844 * Sometimes there is a need to distinguish between metadata which has
845 * been committed to disk and that which has not. The ext3fs code uses
846 * this for freeing and allocating space, we have to make sure that we
847 * do not reuse freed space until the deallocation has been committed,
848 * since if we overwrote that space we would make the delete
849 * un-rewindable in case of a crash.
850 *
851 * To deal with that, jbd2_journal_get_undo_access requests write access to a
852 * buffer for parts of non-rewindable operations such as delete
853 * operations on the bitmaps. The journaling code must keep a copy of
854 * the buffer's contents prior to the undo_access call until such time
855 * as we know that the buffer has definitely been committed to disk.
856 *
857 * We never need to know which transaction the committed data is part
858 * of, buffers touched here are guaranteed to be dirtied later and so
859 * will be committed to a new transaction in due course, at which point
860 * we can discard the old committed data pointer.
861 *
862 * Returns error number or 0 on success.
863 */
864int jbd2_journal_get_undo_access(handle_t *handle, struct buffer_head *bh)
865{
866 int err;
867 struct journal_head *jh = jbd2_journal_add_journal_head(bh);
868 char *committed_data = NULL;
869
870 JBUFFER_TRACE(jh, "entry");
871
872 /*
873 * Do this first --- it can drop the journal lock, so we want to
874 * make sure that obtaining the committed_data is done
875 * atomically wrt. completion of any outstanding commits.
876 */
877 err = do_get_write_access(handle, jh, 1);
878 if (err)
879 goto out;
880
881repeat:
882 if (!jh->b_committed_data) {
883 committed_data = jbd2_slab_alloc(jh2bh(jh)->b_size, GFP_NOFS);
884 if (!committed_data) {
885 printk(KERN_EMERG "%s: No memory for committed data\n",
886 __FUNCTION__);
887 err = -ENOMEM;
888 goto out;
889 }
890 }
891
892 jbd_lock_bh_state(bh);
893 if (!jh->b_committed_data) {
894 /* Copy out the current buffer contents into the
895 * preserved, committed copy. */
896 JBUFFER_TRACE(jh, "generate b_committed data");
897 if (!committed_data) {
898 jbd_unlock_bh_state(bh);
899 goto repeat;
900 }
901
902 jh->b_committed_data = committed_data;
903 committed_data = NULL;
904 memcpy(jh->b_committed_data, bh->b_data, bh->b_size);
905 }
906 jbd_unlock_bh_state(bh);
907out:
908 jbd2_journal_put_journal_head(jh);
909 if (unlikely(committed_data))
910 jbd2_slab_free(committed_data, bh->b_size);
911 return err;
912}
913
914/**
915 * int jbd2_journal_dirty_data() - mark a buffer as containing dirty data which
916 * needs to be flushed before we can commit the
917 * current transaction.
918 * @handle: transaction
919 * @bh: bufferhead to mark
920 *
921 * The buffer is placed on the transaction's data list and is marked as
922 * belonging to the transaction.
923 *
924 * Returns error number or 0 on success.
925 *
926 * jbd2_journal_dirty_data() can be called via page_launder->ext3_writepage
927 * by kswapd.
928 */
929int jbd2_journal_dirty_data(handle_t *handle, struct buffer_head *bh)
930{
931 journal_t *journal = handle->h_transaction->t_journal;
932 int need_brelse = 0;
933 struct journal_head *jh;
934
935 if (is_handle_aborted(handle))
936 return 0;
937
938 jh = jbd2_journal_add_journal_head(bh);
939 JBUFFER_TRACE(jh, "entry");
940
941 /*
942 * The buffer could *already* be dirty. Writeout can start
943 * at any time.
944 */
945 jbd_debug(4, "jh: %p, tid:%d\n", jh, handle->h_transaction->t_tid);
946
947 /*
948 * What if the buffer is already part of a running transaction?
949 *
950 * There are two cases:
951 * 1) It is part of the current running transaction. Refile it,
952 * just in case we have allocated it as metadata, deallocated
953 * it, then reallocated it as data.
954 * 2) It is part of the previous, still-committing transaction.
955 * If all we want to do is to guarantee that the buffer will be
956 * written to disk before this new transaction commits, then
957 * being sure that the *previous* transaction has this same
958 * property is sufficient for us! Just leave it on its old
959 * transaction.
960 *
961 * In case (2), the buffer must not already exist as metadata
962 * --- that would violate write ordering (a transaction is free
963 * to write its data at any point, even before the previous
964 * committing transaction has committed). The caller must
965 * never, ever allow this to happen: there's nothing we can do
966 * about it in this layer.
967 */
968 jbd_lock_bh_state(bh);
969 spin_lock(&journal->j_list_lock);
970
971 /* Now that we have bh_state locked, are we really still mapped? */
972 if (!buffer_mapped(bh)) {
973 JBUFFER_TRACE(jh, "unmapped buffer, bailing out");
974 goto no_journal;
975 }
976
977 if (jh->b_transaction) {
978 JBUFFER_TRACE(jh, "has transaction");
979 if (jh->b_transaction != handle->h_transaction) {
980 JBUFFER_TRACE(jh, "belongs to older transaction");
981 J_ASSERT_JH(jh, jh->b_transaction ==
982 journal->j_committing_transaction);
983
984 /* @@@ IS THIS TRUE ? */
985 /*
986 * Not any more. Scenario: someone does a write()
987 * in data=journal mode. The buffer's transaction has
988 * moved into commit. Then someone does another
989 * write() to the file. We do the frozen data copyout
990 * and set b_next_transaction to point to j_running_t.
991 * And while we're in that state, someone does a
992 * writepage() in an attempt to pageout the same area
993 * of the file via a shared mapping. At present that
994 * calls jbd2_journal_dirty_data(), and we get right here.
995 * It may be too late to journal the data. Simply
996 * falling through to the next test will suffice: the
997 * data will be dirty and wil be checkpointed. The
998 * ordering comments in the next comment block still
999 * apply.
1000 */
1001 //J_ASSERT_JH(jh, jh->b_next_transaction == NULL);
1002
1003 /*
1004 * If we're journalling data, and this buffer was
1005 * subject to a write(), it could be metadata, forget
1006 * or shadow against the committing transaction. Now,
1007 * someone has dirtied the same darn page via a mapping
1008 * and it is being writepage()'d.
1009 * We *could* just steal the page from commit, with some
1010 * fancy locking there. Instead, we just skip it -
1011 * don't tie the page's buffers to the new transaction
1012 * at all.
1013 * Implication: if we crash before the writepage() data
1014 * is written into the filesystem, recovery will replay
1015 * the write() data.
1016 */
1017 if (jh->b_jlist != BJ_None &&
1018 jh->b_jlist != BJ_SyncData &&
1019 jh->b_jlist != BJ_Locked) {
1020 JBUFFER_TRACE(jh, "Not stealing");
1021 goto no_journal;
1022 }
1023
1024 /*
1025 * This buffer may be undergoing writeout in commit. We
1026 * can't return from here and let the caller dirty it
1027 * again because that can cause the write-out loop in
1028 * commit to never terminate.
1029 */
1030 if (buffer_dirty(bh)) {
1031 get_bh(bh);
1032 spin_unlock(&journal->j_list_lock);
1033 jbd_unlock_bh_state(bh);
1034 need_brelse = 1;
1035 sync_dirty_buffer(bh);
1036 jbd_lock_bh_state(bh);
1037 spin_lock(&journal->j_list_lock);
1038 /* Since we dropped the lock... */
1039 if (!buffer_mapped(bh)) {
1040 JBUFFER_TRACE(jh, "buffer got unmapped");
1041 goto no_journal;
1042 }
1043 /* The buffer may become locked again at any
1044 time if it is redirtied */
1045 }
1046
1047 /* journal_clean_data_list() may have got there first */
1048 if (jh->b_transaction != NULL) {
1049 JBUFFER_TRACE(jh, "unfile from commit");
1050 __jbd2_journal_temp_unlink_buffer(jh);
1051 /* It still points to the committing
1052 * transaction; move it to this one so
1053 * that the refile assert checks are
1054 * happy. */
1055 jh->b_transaction = handle->h_transaction;
1056 }
1057 /* The buffer will be refiled below */
1058
1059 }
1060 /*
1061 * Special case --- the buffer might actually have been
1062 * allocated and then immediately deallocated in the previous,
1063 * committing transaction, so might still be left on that
1064 * transaction's metadata lists.
1065 */
1066 if (jh->b_jlist != BJ_SyncData && jh->b_jlist != BJ_Locked) {
1067 JBUFFER_TRACE(jh, "not on correct data list: unfile");
1068 J_ASSERT_JH(jh, jh->b_jlist != BJ_Shadow);
1069 __jbd2_journal_temp_unlink_buffer(jh);
1070 jh->b_transaction = handle->h_transaction;
1071 JBUFFER_TRACE(jh, "file as data");
1072 __jbd2_journal_file_buffer(jh, handle->h_transaction,
1073 BJ_SyncData);
1074 }
1075 } else {
1076 JBUFFER_TRACE(jh, "not on a transaction");
1077 __jbd2_journal_file_buffer(jh, handle->h_transaction, BJ_SyncData);
1078 }
1079no_journal:
1080 spin_unlock(&journal->j_list_lock);
1081 jbd_unlock_bh_state(bh);
1082 if (need_brelse) {
1083 BUFFER_TRACE(bh, "brelse");
1084 __brelse(bh);
1085 }
1086 JBUFFER_TRACE(jh, "exit");
1087 jbd2_journal_put_journal_head(jh);
1088 return 0;
1089}
1090
1091/**
1092 * int jbd2_journal_dirty_metadata() - mark a buffer as containing dirty metadata
1093 * @handle: transaction to add buffer to.
1094 * @bh: buffer to mark
1095 *
1096 * mark dirty metadata which needs to be journaled as part of the current
1097 * transaction.
1098 *
1099 * The buffer is placed on the transaction's metadata list and is marked
1100 * as belonging to the transaction.
1101 *
1102 * Returns error number or 0 on success.
1103 *
1104 * Special care needs to be taken if the buffer already belongs to the
1105 * current committing transaction (in which case we should have frozen
1106 * data present for that commit). In that case, we don't relink the
1107 * buffer: that only gets done when the old transaction finally
1108 * completes its commit.
1109 */
1110int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh)
1111{
1112 transaction_t *transaction = handle->h_transaction;
1113 journal_t *journal = transaction->t_journal;
1114 struct journal_head *jh = bh2jh(bh);
1115
1116 jbd_debug(5, "journal_head %p\n", jh);
1117 JBUFFER_TRACE(jh, "entry");
1118 if (is_handle_aborted(handle))
1119 goto out;
1120
1121 jbd_lock_bh_state(bh);
1122
1123 if (jh->b_modified == 0) {
1124 /*
1125 * This buffer's got modified and becoming part
1126 * of the transaction. This needs to be done
1127 * once a transaction -bzzz
1128 */
1129 jh->b_modified = 1;
1130 J_ASSERT_JH(jh, handle->h_buffer_credits > 0);
1131 handle->h_buffer_credits--;
1132 }
1133
1134 /*
1135 * fastpath, to avoid expensive locking. If this buffer is already
1136 * on the running transaction's metadata list there is nothing to do.
1137 * Nobody can take it off again because there is a handle open.
1138 * I _think_ we're OK here with SMP barriers - a mistaken decision will
1139 * result in this test being false, so we go in and take the locks.
1140 */
1141 if (jh->b_transaction == transaction && jh->b_jlist == BJ_Metadata) {
1142 JBUFFER_TRACE(jh, "fastpath");
1143 J_ASSERT_JH(jh, jh->b_transaction ==
1144 journal->j_running_transaction);
1145 goto out_unlock_bh;
1146 }
1147
1148 set_buffer_jbddirty(bh);
1149
1150 /*
1151 * Metadata already on the current transaction list doesn't
1152 * need to be filed. Metadata on another transaction's list must
1153 * be committing, and will be refiled once the commit completes:
1154 * leave it alone for now.
1155 */
1156 if (jh->b_transaction != transaction) {
1157 JBUFFER_TRACE(jh, "already on other transaction");
1158 J_ASSERT_JH(jh, jh->b_transaction ==
1159 journal->j_committing_transaction);
1160 J_ASSERT_JH(jh, jh->b_next_transaction == transaction);
1161 /* And this case is illegal: we can't reuse another
1162 * transaction's data buffer, ever. */
1163 goto out_unlock_bh;
1164 }
1165
1166 /* That test should have eliminated the following case: */
1167 J_ASSERT_JH(jh, jh->b_frozen_data == 0);
1168
1169 JBUFFER_TRACE(jh, "file as BJ_Metadata");
1170 spin_lock(&journal->j_list_lock);
1171 __jbd2_journal_file_buffer(jh, handle->h_transaction, BJ_Metadata);
1172 spin_unlock(&journal->j_list_lock);
1173out_unlock_bh:
1174 jbd_unlock_bh_state(bh);
1175out:
1176 JBUFFER_TRACE(jh, "exit");
1177 return 0;
1178}
1179
1180/*
1181 * jbd2_journal_release_buffer: undo a get_write_access without any buffer
1182 * updates, if the update decided in the end that it didn't need access.
1183 *
1184 */
1185void
1186jbd2_journal_release_buffer(handle_t *handle, struct buffer_head *bh)
1187{
1188 BUFFER_TRACE(bh, "entry");
1189}
1190
1191/**
1192 * void jbd2_journal_forget() - bforget() for potentially-journaled buffers.
1193 * @handle: transaction handle
1194 * @bh: bh to 'forget'
1195 *
1196 * We can only do the bforget if there are no commits pending against the
1197 * buffer. If the buffer is dirty in the current running transaction we
1198 * can safely unlink it.
1199 *
1200 * bh may not be a journalled buffer at all - it may be a non-JBD
1201 * buffer which came off the hashtable. Check for this.
1202 *
1203 * Decrements bh->b_count by one.
1204 *
1205 * Allow this call even if the handle has aborted --- it may be part of
1206 * the caller's cleanup after an abort.
1207 */
1208int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh)
1209{
1210 transaction_t *transaction = handle->h_transaction;
1211 journal_t *journal = transaction->t_journal;
1212 struct journal_head *jh;
1213 int drop_reserve = 0;
1214 int err = 0;
1215
1216 BUFFER_TRACE(bh, "entry");
1217
1218 jbd_lock_bh_state(bh);
1219 spin_lock(&journal->j_list_lock);
1220
1221 if (!buffer_jbd(bh))
1222 goto not_jbd;
1223 jh = bh2jh(bh);
1224
1225 /* Critical error: attempting to delete a bitmap buffer, maybe?
1226 * Don't do any jbd operations, and return an error. */
1227 if (!J_EXPECT_JH(jh, !jh->b_committed_data,
1228 "inconsistent data on disk")) {
1229 err = -EIO;
1230 goto not_jbd;
1231 }
1232
1233 /*
1234 * The buffer's going from the transaction, we must drop
1235 * all references -bzzz
1236 */
1237 jh->b_modified = 0;
1238
1239 if (jh->b_transaction == handle->h_transaction) {
1240 J_ASSERT_JH(jh, !jh->b_frozen_data);
1241
1242 /* If we are forgetting a buffer which is already part
1243 * of this transaction, then we can just drop it from
1244 * the transaction immediately. */
1245 clear_buffer_dirty(bh);
1246 clear_buffer_jbddirty(bh);
1247
1248 JBUFFER_TRACE(jh, "belongs to current transaction: unfile");
1249
1250 drop_reserve = 1;
1251
1252 /*
1253 * We are no longer going to journal this buffer.
1254 * However, the commit of this transaction is still
1255 * important to the buffer: the delete that we are now
1256 * processing might obsolete an old log entry, so by
1257 * committing, we can satisfy the buffer's checkpoint.
1258 *
1259 * So, if we have a checkpoint on the buffer, we should
1260 * now refile the buffer on our BJ_Forget list so that
1261 * we know to remove the checkpoint after we commit.
1262 */
1263
1264 if (jh->b_cp_transaction) {
1265 __jbd2_journal_temp_unlink_buffer(jh);
1266 __jbd2_journal_file_buffer(jh, transaction, BJ_Forget);
1267 } else {
1268 __jbd2_journal_unfile_buffer(jh);
1269 jbd2_journal_remove_journal_head(bh);
1270 __brelse(bh);
1271 if (!buffer_jbd(bh)) {
1272 spin_unlock(&journal->j_list_lock);
1273 jbd_unlock_bh_state(bh);
1274 __bforget(bh);
1275 goto drop;
1276 }
1277 }
1278 } else if (jh->b_transaction) {
1279 J_ASSERT_JH(jh, (jh->b_transaction ==
1280 journal->j_committing_transaction));
1281 /* However, if the buffer is still owned by a prior
1282 * (committing) transaction, we can't drop it yet... */
1283 JBUFFER_TRACE(jh, "belongs to older transaction");
1284 /* ... but we CAN drop it from the new transaction if we
1285 * have also modified it since the original commit. */
1286
1287 if (jh->b_next_transaction) {
1288 J_ASSERT(jh->b_next_transaction == transaction);
1289 jh->b_next_transaction = NULL;
1290 drop_reserve = 1;
1291 }
1292 }
1293
1294not_jbd:
1295 spin_unlock(&journal->j_list_lock);
1296 jbd_unlock_bh_state(bh);
1297 __brelse(bh);
1298drop:
1299 if (drop_reserve) {
1300 /* no need to reserve log space for this block -bzzz */
1301 handle->h_buffer_credits++;
1302 }
1303 return err;
1304}
1305
1306/**
1307 * int jbd2_journal_stop() - complete a transaction
1308 * @handle: tranaction to complete.
1309 *
1310 * All done for a particular handle.
1311 *
1312 * There is not much action needed here. We just return any remaining
1313 * buffer credits to the transaction and remove the handle. The only
1314 * complication is that we need to start a commit operation if the
1315 * filesystem is marked for synchronous update.
1316 *
1317 * jbd2_journal_stop itself will not usually return an error, but it may
1318 * do so in unusual circumstances. In particular, expect it to
1319 * return -EIO if a jbd2_journal_abort has been executed since the
1320 * transaction began.
1321 */
1322int jbd2_journal_stop(handle_t *handle)
1323{
1324 transaction_t *transaction = handle->h_transaction;
1325 journal_t *journal = transaction->t_journal;
1326 int old_handle_count, err;
1327 pid_t pid;
1328
1329 J_ASSERT(journal_current_handle() == handle);
1330
1331 if (is_handle_aborted(handle))
1332 err = -EIO;
1333 else {
1334 J_ASSERT(transaction->t_updates > 0);
1335 err = 0;
1336 }
1337
1338 if (--handle->h_ref > 0) {
1339 jbd_debug(4, "h_ref %d -> %d\n", handle->h_ref + 1,
1340 handle->h_ref);
1341 return err;
1342 }
1343
1344 jbd_debug(4, "Handle %p going down\n", handle);
1345
1346 /*
1347 * Implement synchronous transaction batching. If the handle
1348 * was synchronous, don't force a commit immediately. Let's
1349 * yield and let another thread piggyback onto this transaction.
1350 * Keep doing that while new threads continue to arrive.
1351 * It doesn't cost much - we're about to run a commit and sleep
1352 * on IO anyway. Speeds up many-threaded, many-dir operations
1353 * by 30x or more...
1354 *
1355 * But don't do this if this process was the most recent one to
1356 * perform a synchronous write. We do this to detect the case where a
1357 * single process is doing a stream of sync writes. No point in waiting
1358 * for joiners in that case.
1359 */
1360 pid = current->pid;
1361 if (handle->h_sync && journal->j_last_sync_writer != pid) {
1362 journal->j_last_sync_writer = pid;
1363 do {
1364 old_handle_count = transaction->t_handle_count;
1365 schedule_timeout_uninterruptible(1);
1366 } while (old_handle_count != transaction->t_handle_count);
1367 }
1368
1369 current->journal_info = NULL;
1370 spin_lock(&journal->j_state_lock);
1371 spin_lock(&transaction->t_handle_lock);
1372 transaction->t_outstanding_credits -= handle->h_buffer_credits;
1373 transaction->t_updates--;
1374 if (!transaction->t_updates) {
1375 wake_up(&journal->j_wait_updates);
1376 if (journal->j_barrier_count)
1377 wake_up(&journal->j_wait_transaction_locked);
1378 }
1379
1380 /*
1381 * If the handle is marked SYNC, we need to set another commit
1382 * going! We also want to force a commit if the current
1383 * transaction is occupying too much of the log, or if the
1384 * transaction is too old now.
1385 */
1386 if (handle->h_sync ||
1387 transaction->t_outstanding_credits >
1388 journal->j_max_transaction_buffers ||
1389 time_after_eq(jiffies, transaction->t_expires)) {
1390 /* Do this even for aborted journals: an abort still
1391 * completes the commit thread, it just doesn't write
1392 * anything to disk. */
1393 tid_t tid = transaction->t_tid;
1394
1395 spin_unlock(&transaction->t_handle_lock);
1396 jbd_debug(2, "transaction too old, requesting commit for "
1397 "handle %p\n", handle);
1398 /* This is non-blocking */
1399 __jbd2_log_start_commit(journal, transaction->t_tid);
1400 spin_unlock(&journal->j_state_lock);
1401
1402 /*
1403 * Special case: JBD2_SYNC synchronous updates require us
1404 * to wait for the commit to complete.
1405 */
1406 if (handle->h_sync && !(current->flags & PF_MEMALLOC))
1407 err = jbd2_log_wait_commit(journal, tid);
1408 } else {
1409 spin_unlock(&transaction->t_handle_lock);
1410 spin_unlock(&journal->j_state_lock);
1411 }
1412
1413 jbd_free_handle(handle);
1414 return err;
1415}
1416
1417/**int jbd2_journal_force_commit() - force any uncommitted transactions
1418 * @journal: journal to force
1419 *
1420 * For synchronous operations: force any uncommitted transactions
1421 * to disk. May seem kludgy, but it reuses all the handle batching
1422 * code in a very simple manner.
1423 */
1424int jbd2_journal_force_commit(journal_t *journal)
1425{
1426 handle_t *handle;
1427 int ret;
1428
1429 handle = jbd2_journal_start(journal, 1);
1430 if (IS_ERR(handle)) {
1431 ret = PTR_ERR(handle);
1432 } else {
1433 handle->h_sync = 1;
1434 ret = jbd2_journal_stop(handle);
1435 }
1436 return ret;
1437}
1438
1439/*
1440 *
1441 * List management code snippets: various functions for manipulating the
1442 * transaction buffer lists.
1443 *
1444 */
1445
1446/*
1447 * Append a buffer to a transaction list, given the transaction's list head
1448 * pointer.
1449 *
1450 * j_list_lock is held.
1451 *
1452 * jbd_lock_bh_state(jh2bh(jh)) is held.
1453 */
1454
1455static inline void
1456__blist_add_buffer(struct journal_head **list, struct journal_head *jh)
1457{
1458 if (!*list) {
1459 jh->b_tnext = jh->b_tprev = jh;
1460 *list = jh;
1461 } else {
1462 /* Insert at the tail of the list to preserve order */
1463 struct journal_head *first = *list, *last = first->b_tprev;
1464 jh->b_tprev = last;
1465 jh->b_tnext = first;
1466 last->b_tnext = first->b_tprev = jh;
1467 }
1468}
1469
1470/*
1471 * Remove a buffer from a transaction list, given the transaction's list
1472 * head pointer.
1473 *
1474 * Called with j_list_lock held, and the journal may not be locked.
1475 *
1476 * jbd_lock_bh_state(jh2bh(jh)) is held.
1477 */
1478
1479static inline void
1480__blist_del_buffer(struct journal_head **list, struct journal_head *jh)
1481{
1482 if (*list == jh) {
1483 *list = jh->b_tnext;
1484 if (*list == jh)
1485 *list = NULL;
1486 }
1487 jh->b_tprev->b_tnext = jh->b_tnext;
1488 jh->b_tnext->b_tprev = jh->b_tprev;
1489}
1490
1491/*
1492 * Remove a buffer from the appropriate transaction list.
1493 *
1494 * Note that this function can *change* the value of
1495 * bh->b_transaction->t_sync_datalist, t_buffers, t_forget,
1496 * t_iobuf_list, t_shadow_list, t_log_list or t_reserved_list. If the caller
1497 * is holding onto a copy of one of thee pointers, it could go bad.
1498 * Generally the caller needs to re-read the pointer from the transaction_t.
1499 *
1500 * Called under j_list_lock. The journal may not be locked.
1501 */
1502void __jbd2_journal_temp_unlink_buffer(struct journal_head *jh)
1503{
1504 struct journal_head **list = NULL;
1505 transaction_t *transaction;
1506 struct buffer_head *bh = jh2bh(jh);
1507
1508 J_ASSERT_JH(jh, jbd_is_locked_bh_state(bh));
1509 transaction = jh->b_transaction;
1510 if (transaction)
1511 assert_spin_locked(&transaction->t_journal->j_list_lock);
1512
1513 J_ASSERT_JH(jh, jh->b_jlist < BJ_Types);
1514 if (jh->b_jlist != BJ_None)
1515 J_ASSERT_JH(jh, transaction != 0);
1516
1517 switch (jh->b_jlist) {
1518 case BJ_None:
1519 return;
1520 case BJ_SyncData:
1521 list = &transaction->t_sync_datalist;
1522 break;
1523 case BJ_Metadata:
1524 transaction->t_nr_buffers--;
1525 J_ASSERT_JH(jh, transaction->t_nr_buffers >= 0);
1526 list = &transaction->t_buffers;
1527 break;
1528 case BJ_Forget:
1529 list = &transaction->t_forget;
1530 break;
1531 case BJ_IO:
1532 list = &transaction->t_iobuf_list;
1533 break;
1534 case BJ_Shadow:
1535 list = &transaction->t_shadow_list;
1536 break;
1537 case BJ_LogCtl:
1538 list = &transaction->t_log_list;
1539 break;
1540 case BJ_Reserved:
1541 list = &transaction->t_reserved_list;
1542 break;
1543 case BJ_Locked:
1544 list = &transaction->t_locked_list;
1545 break;
1546 }
1547
1548 __blist_del_buffer(list, jh);
1549 jh->b_jlist = BJ_None;
1550 if (test_clear_buffer_jbddirty(bh))
1551 mark_buffer_dirty(bh); /* Expose it to the VM */
1552}
1553
1554void __jbd2_journal_unfile_buffer(struct journal_head *jh)
1555{
1556 __jbd2_journal_temp_unlink_buffer(jh);
1557 jh->b_transaction = NULL;
1558}
1559
1560void jbd2_journal_unfile_buffer(journal_t *journal, struct journal_head *jh)
1561{
1562 jbd_lock_bh_state(jh2bh(jh));
1563 spin_lock(&journal->j_list_lock);
1564 __jbd2_journal_unfile_buffer(jh);
1565 spin_unlock(&journal->j_list_lock);
1566 jbd_unlock_bh_state(jh2bh(jh));
1567}
1568
1569/*
1570 * Called from jbd2_journal_try_to_free_buffers().
1571 *
1572 * Called under jbd_lock_bh_state(bh)
1573 */
1574static void
1575__journal_try_to_free_buffer(journal_t *journal, struct buffer_head *bh)
1576{
1577 struct journal_head *jh;
1578
1579 jh = bh2jh(bh);
1580
1581 if (buffer_locked(bh) || buffer_dirty(bh))
1582 goto out;
1583
1584 if (jh->b_next_transaction != 0)
1585 goto out;
1586
1587 spin_lock(&journal->j_list_lock);
1588 if (jh->b_transaction != 0 && jh->b_cp_transaction == 0) {
1589 if (jh->b_jlist == BJ_SyncData || jh->b_jlist == BJ_Locked) {
1590 /* A written-back ordered data buffer */
1591 JBUFFER_TRACE(jh, "release data");
1592 __jbd2_journal_unfile_buffer(jh);
1593 jbd2_journal_remove_journal_head(bh);
1594 __brelse(bh);
1595 }
1596 } else if (jh->b_cp_transaction != 0 && jh->b_transaction == 0) {
1597 /* written-back checkpointed metadata buffer */
1598 if (jh->b_jlist == BJ_None) {
1599 JBUFFER_TRACE(jh, "remove from checkpoint list");
1600 __jbd2_journal_remove_checkpoint(jh);
1601 jbd2_journal_remove_journal_head(bh);
1602 __brelse(bh);
1603 }
1604 }
1605 spin_unlock(&journal->j_list_lock);
1606out:
1607 return;
1608}
1609
1610
1611/**
1612 * int jbd2_journal_try_to_free_buffers() - try to free page buffers.
1613 * @journal: journal for operation
1614 * @page: to try and free
1615 * @unused_gfp_mask: unused
1616 *
1617 *
1618 * For all the buffers on this page,
1619 * if they are fully written out ordered data, move them onto BUF_CLEAN
1620 * so try_to_free_buffers() can reap them.
1621 *
1622 * This function returns non-zero if we wish try_to_free_buffers()
1623 * to be called. We do this if the page is releasable by try_to_free_buffers().
1624 * We also do it if the page has locked or dirty buffers and the caller wants
1625 * us to perform sync or async writeout.
1626 *
1627 * This complicates JBD locking somewhat. We aren't protected by the
1628 * BKL here. We wish to remove the buffer from its committing or
1629 * running transaction's ->t_datalist via __jbd2_journal_unfile_buffer.
1630 *
1631 * This may *change* the value of transaction_t->t_datalist, so anyone
1632 * who looks at t_datalist needs to lock against this function.
1633 *
1634 * Even worse, someone may be doing a jbd2_journal_dirty_data on this
1635 * buffer. So we need to lock against that. jbd2_journal_dirty_data()
1636 * will come out of the lock with the buffer dirty, which makes it
1637 * ineligible for release here.
1638 *
1639 * Who else is affected by this? hmm... Really the only contender
1640 * is do_get_write_access() - it could be looking at the buffer while
1641 * journal_try_to_free_buffer() is changing its state. But that
1642 * cannot happen because we never reallocate freed data as metadata
1643 * while the data is part of a transaction. Yes?
1644 */
1645int jbd2_journal_try_to_free_buffers(journal_t *journal,
1646 struct page *page, gfp_t unused_gfp_mask)
1647{
1648 struct buffer_head *head;
1649 struct buffer_head *bh;
1650 int ret = 0;
1651
1652 J_ASSERT(PageLocked(page));
1653
1654 head = page_buffers(page);
1655 bh = head;
1656 do {
1657 struct journal_head *jh;
1658
1659 /*
1660 * We take our own ref against the journal_head here to avoid
1661 * having to add tons of locking around each instance of
1662 * jbd2_journal_remove_journal_head() and jbd2_journal_put_journal_head().
1663 */
1664 jh = jbd2_journal_grab_journal_head(bh);
1665 if (!jh)
1666 continue;
1667
1668 jbd_lock_bh_state(bh);
1669 __journal_try_to_free_buffer(journal, bh);
1670 jbd2_journal_put_journal_head(jh);
1671 jbd_unlock_bh_state(bh);
1672 if (buffer_jbd(bh))
1673 goto busy;
1674 } while ((bh = bh->b_this_page) != head);
1675 ret = try_to_free_buffers(page);
1676busy:
1677 return ret;
1678}
1679
1680/*
1681 * This buffer is no longer needed. If it is on an older transaction's
1682 * checkpoint list we need to record it on this transaction's forget list
1683 * to pin this buffer (and hence its checkpointing transaction) down until
1684 * this transaction commits. If the buffer isn't on a checkpoint list, we
1685 * release it.
1686 * Returns non-zero if JBD no longer has an interest in the buffer.
1687 *
1688 * Called under j_list_lock.
1689 *
1690 * Called under jbd_lock_bh_state(bh).
1691 */
1692static int __dispose_buffer(struct journal_head *jh, transaction_t *transaction)
1693{
1694 int may_free = 1;
1695 struct buffer_head *bh = jh2bh(jh);
1696
1697 __jbd2_journal_unfile_buffer(jh);
1698
1699 if (jh->b_cp_transaction) {
1700 JBUFFER_TRACE(jh, "on running+cp transaction");
1701 __jbd2_journal_file_buffer(jh, transaction, BJ_Forget);
1702 clear_buffer_jbddirty(bh);
1703 may_free = 0;
1704 } else {
1705 JBUFFER_TRACE(jh, "on running transaction");
1706 jbd2_journal_remove_journal_head(bh);
1707 __brelse(bh);
1708 }
1709 return may_free;
1710}
1711
1712/*
1713 * jbd2_journal_invalidatepage
1714 *
1715 * This code is tricky. It has a number of cases to deal with.
1716 *
1717 * There are two invariants which this code relies on:
1718 *
1719 * i_size must be updated on disk before we start calling invalidatepage on the
1720 * data.
1721 *
1722 * This is done in ext3 by defining an ext3_setattr method which
1723 * updates i_size before truncate gets going. By maintaining this
1724 * invariant, we can be sure that it is safe to throw away any buffers
1725 * attached to the current transaction: once the transaction commits,
1726 * we know that the data will not be needed.
1727 *
1728 * Note however that we can *not* throw away data belonging to the
1729 * previous, committing transaction!
1730 *
1731 * Any disk blocks which *are* part of the previous, committing
1732 * transaction (and which therefore cannot be discarded immediately) are
1733 * not going to be reused in the new running transaction
1734 *
1735 * The bitmap committed_data images guarantee this: any block which is
1736 * allocated in one transaction and removed in the next will be marked
1737 * as in-use in the committed_data bitmap, so cannot be reused until
1738 * the next transaction to delete the block commits. This means that
1739 * leaving committing buffers dirty is quite safe: the disk blocks
1740 * cannot be reallocated to a different file and so buffer aliasing is
1741 * not possible.
1742 *
1743 *
1744 * The above applies mainly to ordered data mode. In writeback mode we
1745 * don't make guarantees about the order in which data hits disk --- in
1746 * particular we don't guarantee that new dirty data is flushed before
1747 * transaction commit --- so it is always safe just to discard data
1748 * immediately in that mode. --sct
1749 */
1750
1751/*
1752 * The journal_unmap_buffer helper function returns zero if the buffer
1753 * concerned remains pinned as an anonymous buffer belonging to an older
1754 * transaction.
1755 *
1756 * We're outside-transaction here. Either or both of j_running_transaction
1757 * and j_committing_transaction may be NULL.
1758 */
1759static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh)
1760{
1761 transaction_t *transaction;
1762 struct journal_head *jh;
1763 int may_free = 1;
1764 int ret;
1765
1766 BUFFER_TRACE(bh, "entry");
1767
1768 /*
1769 * It is safe to proceed here without the j_list_lock because the
1770 * buffers cannot be stolen by try_to_free_buffers as long as we are
1771 * holding the page lock. --sct
1772 */
1773
1774 if (!buffer_jbd(bh))
1775 goto zap_buffer_unlocked;
1776
1777 spin_lock(&journal->j_state_lock);
1778 jbd_lock_bh_state(bh);
1779 spin_lock(&journal->j_list_lock);
1780
1781 jh = jbd2_journal_grab_journal_head(bh);
1782 if (!jh)
1783 goto zap_buffer_no_jh;
1784
1785 transaction = jh->b_transaction;
1786 if (transaction == NULL) {
1787 /* First case: not on any transaction. If it
1788 * has no checkpoint link, then we can zap it:
1789 * it's a writeback-mode buffer so we don't care
1790 * if it hits disk safely. */
1791 if (!jh->b_cp_transaction) {
1792 JBUFFER_TRACE(jh, "not on any transaction: zap");
1793 goto zap_buffer;
1794 }
1795
1796 if (!buffer_dirty(bh)) {
1797 /* bdflush has written it. We can drop it now */
1798 goto zap_buffer;
1799 }
1800
1801 /* OK, it must be in the journal but still not
1802 * written fully to disk: it's metadata or
1803 * journaled data... */
1804
1805 if (journal->j_running_transaction) {
1806 /* ... and once the current transaction has
1807 * committed, the buffer won't be needed any
1808 * longer. */
1809 JBUFFER_TRACE(jh, "checkpointed: add to BJ_Forget");
1810 ret = __dispose_buffer(jh,
1811 journal->j_running_transaction);
1812 jbd2_journal_put_journal_head(jh);
1813 spin_unlock(&journal->j_list_lock);
1814 jbd_unlock_bh_state(bh);
1815 spin_unlock(&journal->j_state_lock);
1816 return ret;
1817 } else {
1818 /* There is no currently-running transaction. So the
1819 * orphan record which we wrote for this file must have
1820 * passed into commit. We must attach this buffer to
1821 * the committing transaction, if it exists. */
1822 if (journal->j_committing_transaction) {
1823 JBUFFER_TRACE(jh, "give to committing trans");
1824 ret = __dispose_buffer(jh,
1825 journal->j_committing_transaction);
1826 jbd2_journal_put_journal_head(jh);
1827 spin_unlock(&journal->j_list_lock);
1828 jbd_unlock_bh_state(bh);
1829 spin_unlock(&journal->j_state_lock);
1830 return ret;
1831 } else {
1832 /* The orphan record's transaction has
1833 * committed. We can cleanse this buffer */
1834 clear_buffer_jbddirty(bh);
1835 goto zap_buffer;
1836 }
1837 }
1838 } else if (transaction == journal->j_committing_transaction) {
1839 JBUFFER_TRACE(jh, "on committing transaction");
1840 if (jh->b_jlist == BJ_Locked) {
1841 /*
1842 * The buffer is on the committing transaction's locked
1843 * list. We have the buffer locked, so I/O has
1844 * completed. So we can nail the buffer now.
1845 */
1846 may_free = __dispose_buffer(jh, transaction);
1847 goto zap_buffer;
1848 }
1849 /*
1850 * If it is committing, we simply cannot touch it. We
1851 * can remove it's next_transaction pointer from the
1852 * running transaction if that is set, but nothing
1853 * else. */
1854 set_buffer_freed(bh);
1855 if (jh->b_next_transaction) {
1856 J_ASSERT(jh->b_next_transaction ==
1857 journal->j_running_transaction);
1858 jh->b_next_transaction = NULL;
1859 }
1860 jbd2_journal_put_journal_head(jh);
1861 spin_unlock(&journal->j_list_lock);
1862 jbd_unlock_bh_state(bh);
1863 spin_unlock(&journal->j_state_lock);
1864 return 0;
1865 } else {
1866 /* Good, the buffer belongs to the running transaction.
1867 * We are writing our own transaction's data, not any
1868 * previous one's, so it is safe to throw it away
1869 * (remember that we expect the filesystem to have set
1870 * i_size already for this truncate so recovery will not
1871 * expose the disk blocks we are discarding here.) */
1872 J_ASSERT_JH(jh, transaction == journal->j_running_transaction);
1873 JBUFFER_TRACE(jh, "on running transaction");
1874 may_free = __dispose_buffer(jh, transaction);
1875 }
1876
1877zap_buffer:
1878 jbd2_journal_put_journal_head(jh);
1879zap_buffer_no_jh:
1880 spin_unlock(&journal->j_list_lock);
1881 jbd_unlock_bh_state(bh);
1882 spin_unlock(&journal->j_state_lock);
1883zap_buffer_unlocked:
1884 clear_buffer_dirty(bh);
1885 J_ASSERT_BH(bh, !buffer_jbddirty(bh));
1886 clear_buffer_mapped(bh);
1887 clear_buffer_req(bh);
1888 clear_buffer_new(bh);
1889 bh->b_bdev = NULL;
1890 return may_free;
1891}
1892
1893/**
1894 * void jbd2_journal_invalidatepage()
1895 * @journal: journal to use for flush...
1896 * @page: page to flush
1897 * @offset: length of page to invalidate.
1898 *
1899 * Reap page buffers containing data after offset in page.
1900 *
1901 */
1902void jbd2_journal_invalidatepage(journal_t *journal,
1903 struct page *page,
1904 unsigned long offset)
1905{
1906 struct buffer_head *head, *bh, *next;
1907 unsigned int curr_off = 0;
1908 int may_free = 1;
1909
1910 if (!PageLocked(page))
1911 BUG();
1912 if (!page_has_buffers(page))
1913 return;
1914
1915 /* We will potentially be playing with lists other than just the
1916 * data lists (especially for journaled data mode), so be
1917 * cautious in our locking. */
1918
1919 head = bh = page_buffers(page);
1920 do {
1921 unsigned int next_off = curr_off + bh->b_size;
1922 next = bh->b_this_page;
1923
1924 if (offset <= curr_off) {
1925 /* This block is wholly outside the truncation point */
1926 lock_buffer(bh);
1927 may_free &= journal_unmap_buffer(journal, bh);
1928 unlock_buffer(bh);
1929 }
1930 curr_off = next_off;
1931 bh = next;
1932
1933 } while (bh != head);
1934
1935 if (!offset) {
1936 if (may_free && try_to_free_buffers(page))
1937 J_ASSERT(!page_has_buffers(page));
1938 }
1939}
1940
1941/*
1942 * File a buffer on the given transaction list.
1943 */
1944void __jbd2_journal_file_buffer(struct journal_head *jh,
1945 transaction_t *transaction, int jlist)
1946{
1947 struct journal_head **list = NULL;
1948 int was_dirty = 0;
1949 struct buffer_head *bh = jh2bh(jh);
1950
1951 J_ASSERT_JH(jh, jbd_is_locked_bh_state(bh));
1952 assert_spin_locked(&transaction->t_journal->j_list_lock);
1953
1954 J_ASSERT_JH(jh, jh->b_jlist < BJ_Types);
1955 J_ASSERT_JH(jh, jh->b_transaction == transaction ||
1956 jh->b_transaction == 0);
1957
1958 if (jh->b_transaction && jh->b_jlist == jlist)
1959 return;
1960
1961 /* The following list of buffer states needs to be consistent
1962 * with __jbd_unexpected_dirty_buffer()'s handling of dirty
1963 * state. */
1964
1965 if (jlist == BJ_Metadata || jlist == BJ_Reserved ||
1966 jlist == BJ_Shadow || jlist == BJ_Forget) {
1967 if (test_clear_buffer_dirty(bh) ||
1968 test_clear_buffer_jbddirty(bh))
1969 was_dirty = 1;
1970 }
1971
1972 if (jh->b_transaction)
1973 __jbd2_journal_temp_unlink_buffer(jh);
1974 jh->b_transaction = transaction;
1975
1976 switch (jlist) {
1977 case BJ_None:
1978 J_ASSERT_JH(jh, !jh->b_committed_data);
1979 J_ASSERT_JH(jh, !jh->b_frozen_data);
1980 return;
1981 case BJ_SyncData:
1982 list = &transaction->t_sync_datalist;
1983 break;
1984 case BJ_Metadata:
1985 transaction->t_nr_buffers++;
1986 list = &transaction->t_buffers;
1987 break;
1988 case BJ_Forget:
1989 list = &transaction->t_forget;
1990 break;
1991 case BJ_IO:
1992 list = &transaction->t_iobuf_list;
1993 break;
1994 case BJ_Shadow:
1995 list = &transaction->t_shadow_list;
1996 break;
1997 case BJ_LogCtl:
1998 list = &transaction->t_log_list;
1999 break;
2000 case BJ_Reserved:
2001 list = &transaction->t_reserved_list;
2002 break;
2003 case BJ_Locked:
2004 list = &transaction->t_locked_list;
2005 break;
2006 }
2007
2008 __blist_add_buffer(list, jh);
2009 jh->b_jlist = jlist;
2010
2011 if (was_dirty)
2012 set_buffer_jbddirty(bh);
2013}
2014
2015void jbd2_journal_file_buffer(struct journal_head *jh,
2016 transaction_t *transaction, int jlist)
2017{
2018 jbd_lock_bh_state(jh2bh(jh));
2019 spin_lock(&transaction->t_journal->j_list_lock);
2020 __jbd2_journal_file_buffer(jh, transaction, jlist);
2021 spin_unlock(&transaction->t_journal->j_list_lock);
2022 jbd_unlock_bh_state(jh2bh(jh));
2023}
2024
2025/*
2026 * Remove a buffer from its current buffer list in preparation for
2027 * dropping it from its current transaction entirely. If the buffer has
2028 * already started to be used by a subsequent transaction, refile the
2029 * buffer on that transaction's metadata list.
2030 *
2031 * Called under journal->j_list_lock
2032 *
2033 * Called under jbd_lock_bh_state(jh2bh(jh))
2034 */
2035void __jbd2_journal_refile_buffer(struct journal_head *jh)
2036{
2037 int was_dirty;
2038 struct buffer_head *bh = jh2bh(jh);
2039
2040 J_ASSERT_JH(jh, jbd_is_locked_bh_state(bh));
2041 if (jh->b_transaction)
2042 assert_spin_locked(&jh->b_transaction->t_journal->j_list_lock);
2043
2044 /* If the buffer is now unused, just drop it. */
2045 if (jh->b_next_transaction == NULL) {
2046 __jbd2_journal_unfile_buffer(jh);
2047 return;
2048 }
2049
2050 /*
2051 * It has been modified by a later transaction: add it to the new
2052 * transaction's metadata list.
2053 */
2054
2055 was_dirty = test_clear_buffer_jbddirty(bh);
2056 __jbd2_journal_temp_unlink_buffer(jh);
2057 jh->b_transaction = jh->b_next_transaction;
2058 jh->b_next_transaction = NULL;
2059 __jbd2_journal_file_buffer(jh, jh->b_transaction,
2060 was_dirty ? BJ_Metadata : BJ_Reserved);
2061 J_ASSERT_JH(jh, jh->b_transaction->t_state == T_RUNNING);
2062
2063 if (was_dirty)
2064 set_buffer_jbddirty(bh);
2065}
2066
2067/*
2068 * For the unlocked version of this call, also make sure that any
2069 * hanging journal_head is cleaned up if necessary.
2070 *
2071 * __jbd2_journal_refile_buffer is usually called as part of a single locked
2072 * operation on a buffer_head, in which the caller is probably going to
2073 * be hooking the journal_head onto other lists. In that case it is up
2074 * to the caller to remove the journal_head if necessary. For the
2075 * unlocked jbd2_journal_refile_buffer call, the caller isn't going to be
2076 * doing anything else to the buffer so we need to do the cleanup
2077 * ourselves to avoid a jh leak.
2078 *
2079 * *** The journal_head may be freed by this call! ***
2080 */
2081void jbd2_journal_refile_buffer(journal_t *journal, struct journal_head *jh)
2082{
2083 struct buffer_head *bh = jh2bh(jh);
2084
2085 jbd_lock_bh_state(bh);
2086 spin_lock(&journal->j_list_lock);
2087
2088 __jbd2_journal_refile_buffer(jh);
2089 jbd_unlock_bh_state(bh);
2090 jbd2_journal_remove_journal_head(bh);
2091
2092 spin_unlock(&journal->j_list_lock);
2093 __brelse(bh);
2094}
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
index 6de374513c01..bc4b8106a490 100644
--- a/fs/jffs2/super.c
+++ b/fs/jffs2/super.c
@@ -334,10 +334,10 @@ static int __init init_jffs2_fs(void)
334 which means just 'no padding', without the alignment 334 which means just 'no padding', without the alignment
335 thing. But GCC doesn't have that -- we have to just 335 thing. But GCC doesn't have that -- we have to just
336 hope the structs are the right sizes, instead. */ 336 hope the structs are the right sizes, instead. */
337 BUG_ON(sizeof(struct jffs2_unknown_node) != 12); 337 BUILD_BUG_ON(sizeof(struct jffs2_unknown_node) != 12);
338 BUG_ON(sizeof(struct jffs2_raw_dirent) != 40); 338 BUILD_BUG_ON(sizeof(struct jffs2_raw_dirent) != 40);
339 BUG_ON(sizeof(struct jffs2_raw_inode) != 68); 339 BUILD_BUG_ON(sizeof(struct jffs2_raw_inode) != 68);
340 BUG_ON(sizeof(struct jffs2_raw_summary) != 32); 340 BUILD_BUG_ON(sizeof(struct jffs2_raw_summary) != 32);
341 341
342 printk(KERN_INFO "JFFS2 version 2.2." 342 printk(KERN_INFO "JFFS2 version 2.2."
343#ifdef CONFIG_JFFS2_FS_WRITEBUFFER 343#ifdef CONFIG_JFFS2_FS_WRITEBUFFER
diff --git a/fs/jfs/file.c b/fs/jfs/file.c
index 34181b8f5a0a..aa9132d04920 100644
--- a/fs/jfs/file.c
+++ b/fs/jfs/file.c
@@ -109,6 +109,8 @@ const struct file_operations jfs_file_operations = {
109 .aio_write = generic_file_aio_write, 109 .aio_write = generic_file_aio_write,
110 .mmap = generic_file_mmap, 110 .mmap = generic_file_mmap,
111 .sendfile = generic_file_sendfile, 111 .sendfile = generic_file_sendfile,
112 .splice_read = generic_file_splice_read,
113 .splice_write = generic_file_splice_write,
112 .fsync = jfs_fsync, 114 .fsync = jfs_fsync,
113 .release = jfs_release, 115 .release = jfs_release,
114 .ioctl = jfs_ioctl, 116 .ioctl = jfs_ioctl,
diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
index 489a3d63002d..ee9b473b7b80 100644
--- a/fs/jfs/jfs_imap.c
+++ b/fs/jfs/jfs_imap.c
@@ -318,7 +318,7 @@ int diRead(struct inode *ip)
318 struct inomap *imap; 318 struct inomap *imap;
319 int block_offset; 319 int block_offset;
320 int inodes_left; 320 int inodes_left;
321 uint pageno; 321 unsigned long pageno;
322 int rel_inode; 322 int rel_inode;
323 323
324 jfs_info("diRead: ino = %ld", ip->i_ino); 324 jfs_info("diRead: ino = %ld", ip->i_ino);
@@ -606,7 +606,7 @@ int diWrite(tid_t tid, struct inode *ip)
606 int block_offset; 606 int block_offset;
607 int inodes_left; 607 int inodes_left;
608 struct metapage *mp; 608 struct metapage *mp;
609 uint pageno; 609 unsigned long pageno;
610 int rel_inode; 610 int rel_inode;
611 int dioffset; 611 int dioffset;
612 struct inode *ipimap; 612 struct inode *ipimap;
diff --git a/fs/jfs/xattr.c b/fs/jfs/xattr.c
index 4c7985ebca92..b753ba216450 100644
--- a/fs/jfs/xattr.c
+++ b/fs/jfs/xattr.c
@@ -756,6 +756,11 @@ static int can_set_system_xattr(struct inode *inode, const char *name,
756 return -EOPNOTSUPP; 756 return -EOPNOTSUPP;
757} 757}
758 758
759/*
760 * Most of the permission checking is done by xattr_permission in the vfs.
761 * The local file system is responsible for handling the system.* namespace.
762 * We also need to verify that this is a namespace that we recognize.
763 */
759static int can_set_xattr(struct inode *inode, const char *name, 764static int can_set_xattr(struct inode *inode, const char *name,
760 const void *value, size_t value_len) 765 const void *value, size_t value_len)
761{ 766{
@@ -771,10 +776,6 @@ static int can_set_xattr(struct inode *inode, const char *name,
771 strncmp(name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN)) 776 strncmp(name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN))
772 return -EOPNOTSUPP; 777 return -EOPNOTSUPP;
773 778
774 if (!S_ISREG(inode->i_mode) &&
775 (!S_ISDIR(inode->i_mode) || inode->i_mode &S_ISVTX))
776 return -EPERM;
777
778 return 0; 779 return 0;
779} 780}
780 781
diff --git a/fs/lockd/clntlock.c b/fs/lockd/clntlock.c
index e8c7765419e8..b85a0ad2cfb6 100644
--- a/fs/lockd/clntlock.c
+++ b/fs/lockd/clntlock.c
@@ -100,12 +100,12 @@ int nlmclnt_block(struct nlm_wait *block, struct nlm_rqst *req, long timeout)
100/* 100/*
101 * The server lockd has called us back to tell us the lock was granted 101 * The server lockd has called us back to tell us the lock was granted
102 */ 102 */
103u32 nlmclnt_grant(const struct sockaddr_in *addr, const struct nlm_lock *lock) 103__be32 nlmclnt_grant(const struct sockaddr_in *addr, const struct nlm_lock *lock)
104{ 104{
105 const struct file_lock *fl = &lock->fl; 105 const struct file_lock *fl = &lock->fl;
106 const struct nfs_fh *fh = &lock->fh; 106 const struct nfs_fh *fh = &lock->fh;
107 struct nlm_wait *block; 107 struct nlm_wait *block;
108 u32 res = nlm_lck_denied; 108 __be32 res = nlm_lck_denied;
109 109
110 /* 110 /*
111 * Look up blocked request based on arguments. 111 * Look up blocked request based on arguments.
diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
index e0179f8c327f..eb243edf8932 100644
--- a/fs/lockd/mon.c
+++ b/fs/lockd/mon.c
@@ -148,8 +148,8 @@ nsm_create(void)
148 * XDR functions for NSM. 148 * XDR functions for NSM.
149 */ 149 */
150 150
151static u32 * 151static __be32 *
152xdr_encode_common(struct rpc_rqst *rqstp, u32 *p, struct nsm_args *argp) 152xdr_encode_common(struct rpc_rqst *rqstp, __be32 *p, struct nsm_args *argp)
153{ 153{
154 char buffer[20], *name; 154 char buffer[20], *name;
155 155
@@ -176,7 +176,7 @@ xdr_encode_common(struct rpc_rqst *rqstp, u32 *p, struct nsm_args *argp)
176} 176}
177 177
178static int 178static int
179xdr_encode_mon(struct rpc_rqst *rqstp, u32 *p, struct nsm_args *argp) 179xdr_encode_mon(struct rpc_rqst *rqstp, __be32 *p, struct nsm_args *argp)
180{ 180{
181 p = xdr_encode_common(rqstp, p, argp); 181 p = xdr_encode_common(rqstp, p, argp);
182 if (IS_ERR(p)) 182 if (IS_ERR(p))
@@ -192,7 +192,7 @@ xdr_encode_mon(struct rpc_rqst *rqstp, u32 *p, struct nsm_args *argp)
192} 192}
193 193
194static int 194static int
195xdr_encode_unmon(struct rpc_rqst *rqstp, u32 *p, struct nsm_args *argp) 195xdr_encode_unmon(struct rpc_rqst *rqstp, __be32 *p, struct nsm_args *argp)
196{ 196{
197 p = xdr_encode_common(rqstp, p, argp); 197 p = xdr_encode_common(rqstp, p, argp);
198 if (IS_ERR(p)) 198 if (IS_ERR(p))
@@ -202,7 +202,7 @@ xdr_encode_unmon(struct rpc_rqst *rqstp, u32 *p, struct nsm_args *argp)
202} 202}
203 203
204static int 204static int
205xdr_decode_stat_res(struct rpc_rqst *rqstp, u32 *p, struct nsm_res *resp) 205xdr_decode_stat_res(struct rpc_rqst *rqstp, __be32 *p, struct nsm_res *resp)
206{ 206{
207 resp->status = ntohl(*p++); 207 resp->status = ntohl(*p++);
208 resp->state = ntohl(*p++); 208 resp->state = ntohl(*p++);
@@ -212,7 +212,7 @@ xdr_decode_stat_res(struct rpc_rqst *rqstp, u32 *p, struct nsm_res *resp)
212} 212}
213 213
214static int 214static int
215xdr_decode_stat(struct rpc_rqst *rqstp, u32 *p, struct nsm_res *resp) 215xdr_decode_stat(struct rpc_rqst *rqstp, __be32 *p, struct nsm_res *resp)
216{ 216{
217 resp->state = ntohl(*p++); 217 resp->state = ntohl(*p++);
218 return 0; 218 return 0;
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
index 634139232aaf..8ca18085e68d 100644
--- a/fs/lockd/svc.c
+++ b/fs/lockd/svc.c
@@ -353,9 +353,6 @@ EXPORT_SYMBOL(lockd_down);
353 * Sysctl parameters (same as module parameters, different interface). 353 * Sysctl parameters (same as module parameters, different interface).
354 */ 354 */
355 355
356/* Something that isn't CTL_ANY, CTL_NONE or a value that may clash. */
357#define CTL_UNNUMBERED -2
358
359static ctl_table nlm_sysctls[] = { 356static ctl_table nlm_sysctls[] = {
360 { 357 {
361 .ctl_name = CTL_UNNUMBERED, 358 .ctl_name = CTL_UNNUMBERED,
diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c
index fa370f6eb07b..0ce5c81ff507 100644
--- a/fs/lockd/svc4proc.c
+++ b/fs/lockd/svc4proc.c
@@ -24,14 +24,14 @@
24/* 24/*
25 * Obtain client and file from arguments 25 * Obtain client and file from arguments
26 */ 26 */
27static u32 27static __be32
28nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp, 28nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
29 struct nlm_host **hostp, struct nlm_file **filp) 29 struct nlm_host **hostp, struct nlm_file **filp)
30{ 30{
31 struct nlm_host *host = NULL; 31 struct nlm_host *host = NULL;
32 struct nlm_file *file = NULL; 32 struct nlm_file *file = NULL;
33 struct nlm_lock *lock = &argp->lock; 33 struct nlm_lock *lock = &argp->lock;
34 u32 error = 0; 34 __be32 error = 0;
35 35
36 /* nfsd callbacks must have been installed for this procedure */ 36 /* nfsd callbacks must have been installed for this procedure */
37 if (!nlmsvc_ops) 37 if (!nlmsvc_ops)
@@ -68,7 +68,7 @@ no_locks:
68/* 68/*
69 * NULL: Test for presence of service 69 * NULL: Test for presence of service
70 */ 70 */
71static int 71static __be32
72nlm4svc_proc_null(struct svc_rqst *rqstp, void *argp, void *resp) 72nlm4svc_proc_null(struct svc_rqst *rqstp, void *argp, void *resp)
73{ 73{
74 dprintk("lockd: NULL called\n"); 74 dprintk("lockd: NULL called\n");
@@ -78,7 +78,7 @@ nlm4svc_proc_null(struct svc_rqst *rqstp, void *argp, void *resp)
78/* 78/*
79 * TEST: Check for conflicting lock 79 * TEST: Check for conflicting lock
80 */ 80 */
81static int 81static __be32
82nlm4svc_proc_test(struct svc_rqst *rqstp, struct nlm_args *argp, 82nlm4svc_proc_test(struct svc_rqst *rqstp, struct nlm_args *argp,
83 struct nlm_res *resp) 83 struct nlm_res *resp)
84{ 84{
@@ -96,7 +96,7 @@ nlm4svc_proc_test(struct svc_rqst *rqstp, struct nlm_args *argp,
96 96
97 /* Obtain client and file */ 97 /* Obtain client and file */
98 if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) 98 if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file)))
99 return rpc_success; 99 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
100 100
101 /* Now check for conflicting locks */ 101 /* Now check for conflicting locks */
102 resp->status = nlmsvc_testlock(file, &argp->lock, &resp->lock); 102 resp->status = nlmsvc_testlock(file, &argp->lock, &resp->lock);
@@ -107,7 +107,7 @@ nlm4svc_proc_test(struct svc_rqst *rqstp, struct nlm_args *argp,
107 return rpc_success; 107 return rpc_success;
108} 108}
109 109
110static int 110static __be32
111nlm4svc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp, 111nlm4svc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp,
112 struct nlm_res *resp) 112 struct nlm_res *resp)
113{ 113{
@@ -126,7 +126,7 @@ nlm4svc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp,
126 126
127 /* Obtain client and file */ 127 /* Obtain client and file */
128 if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) 128 if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file)))
129 return rpc_success; 129 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
130 130
131#if 0 131#if 0
132 /* If supplied state doesn't match current state, we assume it's 132 /* If supplied state doesn't match current state, we assume it's
@@ -150,7 +150,7 @@ nlm4svc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp,
150 return rpc_success; 150 return rpc_success;
151} 151}
152 152
153static int 153static __be32
154nlm4svc_proc_cancel(struct svc_rqst *rqstp, struct nlm_args *argp, 154nlm4svc_proc_cancel(struct svc_rqst *rqstp, struct nlm_args *argp,
155 struct nlm_res *resp) 155 struct nlm_res *resp)
156{ 156{
@@ -169,7 +169,7 @@ nlm4svc_proc_cancel(struct svc_rqst *rqstp, struct nlm_args *argp,
169 169
170 /* Obtain client and file */ 170 /* Obtain client and file */
171 if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) 171 if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file)))
172 return rpc_success; 172 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
173 173
174 /* Try to cancel request. */ 174 /* Try to cancel request. */
175 resp->status = nlmsvc_cancel_blocked(file, &argp->lock); 175 resp->status = nlmsvc_cancel_blocked(file, &argp->lock);
@@ -183,7 +183,7 @@ nlm4svc_proc_cancel(struct svc_rqst *rqstp, struct nlm_args *argp,
183/* 183/*
184 * UNLOCK: release a lock 184 * UNLOCK: release a lock
185 */ 185 */
186static int 186static __be32
187nlm4svc_proc_unlock(struct svc_rqst *rqstp, struct nlm_args *argp, 187nlm4svc_proc_unlock(struct svc_rqst *rqstp, struct nlm_args *argp,
188 struct nlm_res *resp) 188 struct nlm_res *resp)
189{ 189{
@@ -202,7 +202,7 @@ nlm4svc_proc_unlock(struct svc_rqst *rqstp, struct nlm_args *argp,
202 202
203 /* Obtain client and file */ 203 /* Obtain client and file */
204 if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) 204 if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file)))
205 return rpc_success; 205 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
206 206
207 /* Now try to remove the lock */ 207 /* Now try to remove the lock */
208 resp->status = nlmsvc_unlock(file, &argp->lock); 208 resp->status = nlmsvc_unlock(file, &argp->lock);
@@ -217,7 +217,7 @@ nlm4svc_proc_unlock(struct svc_rqst *rqstp, struct nlm_args *argp,
217 * GRANTED: A server calls us to tell that a process' lock request 217 * GRANTED: A server calls us to tell that a process' lock request
218 * was granted 218 * was granted
219 */ 219 */
220static int 220static __be32
221nlm4svc_proc_granted(struct svc_rqst *rqstp, struct nlm_args *argp, 221nlm4svc_proc_granted(struct svc_rqst *rqstp, struct nlm_args *argp,
222 struct nlm_res *resp) 222 struct nlm_res *resp)
223{ 223{
@@ -253,12 +253,12 @@ static const struct rpc_call_ops nlm4svc_callback_ops = {
253 * because we send the callback before the reply proper. I hope this 253 * because we send the callback before the reply proper. I hope this
254 * doesn't break any clients. 254 * doesn't break any clients.
255 */ 255 */
256static int nlm4svc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_args *argp, 256static __be32 nlm4svc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_args *argp,
257 int (*func)(struct svc_rqst *, struct nlm_args *, struct nlm_res *)) 257 __be32 (*func)(struct svc_rqst *, struct nlm_args *, struct nlm_res *))
258{ 258{
259 struct nlm_host *host; 259 struct nlm_host *host;
260 struct nlm_rqst *call; 260 struct nlm_rqst *call;
261 int stat; 261 __be32 stat;
262 262
263 host = nlmsvc_lookup_host(rqstp, 263 host = nlmsvc_lookup_host(rqstp,
264 argp->lock.caller, 264 argp->lock.caller,
@@ -282,35 +282,35 @@ static int nlm4svc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_args *a
282 return rpc_success; 282 return rpc_success;
283} 283}
284 284
285static int nlm4svc_proc_test_msg(struct svc_rqst *rqstp, struct nlm_args *argp, 285static __be32 nlm4svc_proc_test_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
286 void *resp) 286 void *resp)
287{ 287{
288 dprintk("lockd: TEST_MSG called\n"); 288 dprintk("lockd: TEST_MSG called\n");
289 return nlm4svc_callback(rqstp, NLMPROC_TEST_RES, argp, nlm4svc_proc_test); 289 return nlm4svc_callback(rqstp, NLMPROC_TEST_RES, argp, nlm4svc_proc_test);
290} 290}
291 291
292static int nlm4svc_proc_lock_msg(struct svc_rqst *rqstp, struct nlm_args *argp, 292static __be32 nlm4svc_proc_lock_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
293 void *resp) 293 void *resp)
294{ 294{
295 dprintk("lockd: LOCK_MSG called\n"); 295 dprintk("lockd: LOCK_MSG called\n");
296 return nlm4svc_callback(rqstp, NLMPROC_LOCK_RES, argp, nlm4svc_proc_lock); 296 return nlm4svc_callback(rqstp, NLMPROC_LOCK_RES, argp, nlm4svc_proc_lock);
297} 297}
298 298
299static int nlm4svc_proc_cancel_msg(struct svc_rqst *rqstp, struct nlm_args *argp, 299static __be32 nlm4svc_proc_cancel_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
300 void *resp) 300 void *resp)
301{ 301{
302 dprintk("lockd: CANCEL_MSG called\n"); 302 dprintk("lockd: CANCEL_MSG called\n");
303 return nlm4svc_callback(rqstp, NLMPROC_CANCEL_RES, argp, nlm4svc_proc_cancel); 303 return nlm4svc_callback(rqstp, NLMPROC_CANCEL_RES, argp, nlm4svc_proc_cancel);
304} 304}
305 305
306static int nlm4svc_proc_unlock_msg(struct svc_rqst *rqstp, struct nlm_args *argp, 306static __be32 nlm4svc_proc_unlock_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
307 void *resp) 307 void *resp)
308{ 308{
309 dprintk("lockd: UNLOCK_MSG called\n"); 309 dprintk("lockd: UNLOCK_MSG called\n");
310 return nlm4svc_callback(rqstp, NLMPROC_UNLOCK_RES, argp, nlm4svc_proc_unlock); 310 return nlm4svc_callback(rqstp, NLMPROC_UNLOCK_RES, argp, nlm4svc_proc_unlock);
311} 311}
312 312
313static int nlm4svc_proc_granted_msg(struct svc_rqst *rqstp, struct nlm_args *argp, 313static __be32 nlm4svc_proc_granted_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
314 void *resp) 314 void *resp)
315{ 315{
316 dprintk("lockd: GRANTED_MSG called\n"); 316 dprintk("lockd: GRANTED_MSG called\n");
@@ -320,7 +320,7 @@ static int nlm4svc_proc_granted_msg(struct svc_rqst *rqstp, struct nlm_args *arg
320/* 320/*
321 * SHARE: create a DOS share or alter existing share. 321 * SHARE: create a DOS share or alter existing share.
322 */ 322 */
323static int 323static __be32
324nlm4svc_proc_share(struct svc_rqst *rqstp, struct nlm_args *argp, 324nlm4svc_proc_share(struct svc_rqst *rqstp, struct nlm_args *argp,
325 struct nlm_res *resp) 325 struct nlm_res *resp)
326{ 326{
@@ -339,7 +339,7 @@ nlm4svc_proc_share(struct svc_rqst *rqstp, struct nlm_args *argp,
339 339
340 /* Obtain client and file */ 340 /* Obtain client and file */
341 if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) 341 if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file)))
342 return rpc_success; 342 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
343 343
344 /* Now try to create the share */ 344 /* Now try to create the share */
345 resp->status = nlmsvc_share_file(host, file, argp); 345 resp->status = nlmsvc_share_file(host, file, argp);
@@ -353,7 +353,7 @@ nlm4svc_proc_share(struct svc_rqst *rqstp, struct nlm_args *argp,
353/* 353/*
354 * UNSHARE: Release a DOS share. 354 * UNSHARE: Release a DOS share.
355 */ 355 */
356static int 356static __be32
357nlm4svc_proc_unshare(struct svc_rqst *rqstp, struct nlm_args *argp, 357nlm4svc_proc_unshare(struct svc_rqst *rqstp, struct nlm_args *argp,
358 struct nlm_res *resp) 358 struct nlm_res *resp)
359{ 359{
@@ -372,7 +372,7 @@ nlm4svc_proc_unshare(struct svc_rqst *rqstp, struct nlm_args *argp,
372 372
373 /* Obtain client and file */ 373 /* Obtain client and file */
374 if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) 374 if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file)))
375 return rpc_success; 375 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
376 376
377 /* Now try to lock the file */ 377 /* Now try to lock the file */
378 resp->status = nlmsvc_unshare_file(host, file, argp); 378 resp->status = nlmsvc_unshare_file(host, file, argp);
@@ -386,7 +386,7 @@ nlm4svc_proc_unshare(struct svc_rqst *rqstp, struct nlm_args *argp,
386/* 386/*
387 * NM_LOCK: Create an unmonitored lock 387 * NM_LOCK: Create an unmonitored lock
388 */ 388 */
389static int 389static __be32
390nlm4svc_proc_nm_lock(struct svc_rqst *rqstp, struct nlm_args *argp, 390nlm4svc_proc_nm_lock(struct svc_rqst *rqstp, struct nlm_args *argp,
391 struct nlm_res *resp) 391 struct nlm_res *resp)
392{ 392{
@@ -399,7 +399,7 @@ nlm4svc_proc_nm_lock(struct svc_rqst *rqstp, struct nlm_args *argp,
399/* 399/*
400 * FREE_ALL: Release all locks and shares held by client 400 * FREE_ALL: Release all locks and shares held by client
401 */ 401 */
402static int 402static __be32
403nlm4svc_proc_free_all(struct svc_rqst *rqstp, struct nlm_args *argp, 403nlm4svc_proc_free_all(struct svc_rqst *rqstp, struct nlm_args *argp,
404 void *resp) 404 void *resp)
405{ 405{
@@ -417,7 +417,7 @@ nlm4svc_proc_free_all(struct svc_rqst *rqstp, struct nlm_args *argp,
417/* 417/*
418 * SM_NOTIFY: private callback from statd (not part of official NLM proto) 418 * SM_NOTIFY: private callback from statd (not part of official NLM proto)
419 */ 419 */
420static int 420static __be32
421nlm4svc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp, 421nlm4svc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp,
422 void *resp) 422 void *resp)
423{ 423{
@@ -446,7 +446,7 @@ nlm4svc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp,
446/* 446/*
447 * client sent a GRANTED_RES, let's remove the associated block 447 * client sent a GRANTED_RES, let's remove the associated block
448 */ 448 */
449static int 449static __be32
450nlm4svc_proc_granted_res(struct svc_rqst *rqstp, struct nlm_res *argp, 450nlm4svc_proc_granted_res(struct svc_rqst *rqstp, struct nlm_res *argp,
451 void *resp) 451 void *resp)
452{ 452{
diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
index 814c6064c9e0..7e219b938552 100644
--- a/fs/lockd/svclock.c
+++ b/fs/lockd/svclock.c
@@ -334,13 +334,13 @@ static void nlmsvc_freegrantargs(struct nlm_rqst *call)
334 * Attempt to establish a lock, and if it can't be granted, block it 334 * Attempt to establish a lock, and if it can't be granted, block it
335 * if required. 335 * if required.
336 */ 336 */
337u32 337__be32
338nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file, 338nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
339 struct nlm_lock *lock, int wait, struct nlm_cookie *cookie) 339 struct nlm_lock *lock, int wait, struct nlm_cookie *cookie)
340{ 340{
341 struct nlm_block *block, *newblock = NULL; 341 struct nlm_block *block, *newblock = NULL;
342 int error; 342 int error;
343 u32 ret; 343 __be32 ret;
344 344
345 dprintk("lockd: nlmsvc_lock(%s/%ld, ty=%d, pi=%d, %Ld-%Ld, bl=%d)\n", 345 dprintk("lockd: nlmsvc_lock(%s/%ld, ty=%d, pi=%d, %Ld-%Ld, bl=%d)\n",
346 file->f_file->f_dentry->d_inode->i_sb->s_id, 346 file->f_file->f_dentry->d_inode->i_sb->s_id,
@@ -415,7 +415,7 @@ out:
415/* 415/*
416 * Test for presence of a conflicting lock. 416 * Test for presence of a conflicting lock.
417 */ 417 */
418u32 418__be32
419nlmsvc_testlock(struct nlm_file *file, struct nlm_lock *lock, 419nlmsvc_testlock(struct nlm_file *file, struct nlm_lock *lock,
420 struct nlm_lock *conflock) 420 struct nlm_lock *conflock)
421{ 421{
@@ -448,7 +448,7 @@ nlmsvc_testlock(struct nlm_file *file, struct nlm_lock *lock,
448 * afterwards. In this case the block will still be there, and hence 448 * afterwards. In this case the block will still be there, and hence
449 * must be removed. 449 * must be removed.
450 */ 450 */
451u32 451__be32
452nlmsvc_unlock(struct nlm_file *file, struct nlm_lock *lock) 452nlmsvc_unlock(struct nlm_file *file, struct nlm_lock *lock)
453{ 453{
454 int error; 454 int error;
@@ -476,7 +476,7 @@ nlmsvc_unlock(struct nlm_file *file, struct nlm_lock *lock)
476 * be in progress. 476 * be in progress.
477 * The calling procedure must check whether the file can be closed. 477 * The calling procedure must check whether the file can be closed.
478 */ 478 */
479u32 479__be32
480nlmsvc_cancel_blocked(struct nlm_file *file, struct nlm_lock *lock) 480nlmsvc_cancel_blocked(struct nlm_file *file, struct nlm_lock *lock)
481{ 481{
482 struct nlm_block *block; 482 struct nlm_block *block;
diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c
index 75b2c81bcb93..32e99a6e8dca 100644
--- a/fs/lockd/svcproc.c
+++ b/fs/lockd/svcproc.c
@@ -22,8 +22,8 @@
22#define NLMDBG_FACILITY NLMDBG_CLIENT 22#define NLMDBG_FACILITY NLMDBG_CLIENT
23 23
24#ifdef CONFIG_LOCKD_V4 24#ifdef CONFIG_LOCKD_V4
25static u32 25static __be32
26cast_to_nlm(u32 status, u32 vers) 26cast_to_nlm(__be32 status, u32 vers)
27{ 27{
28 /* Note: status is assumed to be in network byte order !!! */ 28 /* Note: status is assumed to be in network byte order !!! */
29 if (vers != 4){ 29 if (vers != 4){
@@ -52,14 +52,14 @@ cast_to_nlm(u32 status, u32 vers)
52/* 52/*
53 * Obtain client and file from arguments 53 * Obtain client and file from arguments
54 */ 54 */
55static u32 55static __be32
56nlmsvc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp, 56nlmsvc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
57 struct nlm_host **hostp, struct nlm_file **filp) 57 struct nlm_host **hostp, struct nlm_file **filp)
58{ 58{
59 struct nlm_host *host = NULL; 59 struct nlm_host *host = NULL;
60 struct nlm_file *file = NULL; 60 struct nlm_file *file = NULL;
61 struct nlm_lock *lock = &argp->lock; 61 struct nlm_lock *lock = &argp->lock;
62 u32 error; 62 __be32 error = 0;
63 63
64 /* nfsd callbacks must have been installed for this procedure */ 64 /* nfsd callbacks must have been installed for this procedure */
65 if (!nlmsvc_ops) 65 if (!nlmsvc_ops)
@@ -88,13 +88,15 @@ nlmsvc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
88no_locks: 88no_locks:
89 if (host) 89 if (host)
90 nlm_release_host(host); 90 nlm_release_host(host);
91 if (error)
92 return error;
91 return nlm_lck_denied_nolocks; 93 return nlm_lck_denied_nolocks;
92} 94}
93 95
94/* 96/*
95 * NULL: Test for presence of service 97 * NULL: Test for presence of service
96 */ 98 */
97static int 99static __be32
98nlmsvc_proc_null(struct svc_rqst *rqstp, void *argp, void *resp) 100nlmsvc_proc_null(struct svc_rqst *rqstp, void *argp, void *resp)
99{ 101{
100 dprintk("lockd: NULL called\n"); 102 dprintk("lockd: NULL called\n");
@@ -104,7 +106,7 @@ nlmsvc_proc_null(struct svc_rqst *rqstp, void *argp, void *resp)
104/* 106/*
105 * TEST: Check for conflicting lock 107 * TEST: Check for conflicting lock
106 */ 108 */
107static int 109static __be32
108nlmsvc_proc_test(struct svc_rqst *rqstp, struct nlm_args *argp, 110nlmsvc_proc_test(struct svc_rqst *rqstp, struct nlm_args *argp,
109 struct nlm_res *resp) 111 struct nlm_res *resp)
110{ 112{
@@ -122,7 +124,7 @@ nlmsvc_proc_test(struct svc_rqst *rqstp, struct nlm_args *argp,
122 124
123 /* Obtain client and file */ 125 /* Obtain client and file */
124 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file))) 126 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
125 return rpc_success; 127 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
126 128
127 /* Now check for conflicting locks */ 129 /* Now check for conflicting locks */
128 resp->status = cast_status(nlmsvc_testlock(file, &argp->lock, &resp->lock)); 130 resp->status = cast_status(nlmsvc_testlock(file, &argp->lock, &resp->lock));
@@ -134,7 +136,7 @@ nlmsvc_proc_test(struct svc_rqst *rqstp, struct nlm_args *argp,
134 return rpc_success; 136 return rpc_success;
135} 137}
136 138
137static int 139static __be32
138nlmsvc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp, 140nlmsvc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp,
139 struct nlm_res *resp) 141 struct nlm_res *resp)
140{ 142{
@@ -153,7 +155,7 @@ nlmsvc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp,
153 155
154 /* Obtain client and file */ 156 /* Obtain client and file */
155 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file))) 157 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
156 return rpc_success; 158 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
157 159
158#if 0 160#if 0
159 /* If supplied state doesn't match current state, we assume it's 161 /* If supplied state doesn't match current state, we assume it's
@@ -177,7 +179,7 @@ nlmsvc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp,
177 return rpc_success; 179 return rpc_success;
178} 180}
179 181
180static int 182static __be32
181nlmsvc_proc_cancel(struct svc_rqst *rqstp, struct nlm_args *argp, 183nlmsvc_proc_cancel(struct svc_rqst *rqstp, struct nlm_args *argp,
182 struct nlm_res *resp) 184 struct nlm_res *resp)
183{ 185{
@@ -196,7 +198,7 @@ nlmsvc_proc_cancel(struct svc_rqst *rqstp, struct nlm_args *argp,
196 198
197 /* Obtain client and file */ 199 /* Obtain client and file */
198 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file))) 200 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
199 return rpc_success; 201 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
200 202
201 /* Try to cancel request. */ 203 /* Try to cancel request. */
202 resp->status = cast_status(nlmsvc_cancel_blocked(file, &argp->lock)); 204 resp->status = cast_status(nlmsvc_cancel_blocked(file, &argp->lock));
@@ -210,7 +212,7 @@ nlmsvc_proc_cancel(struct svc_rqst *rqstp, struct nlm_args *argp,
210/* 212/*
211 * UNLOCK: release a lock 213 * UNLOCK: release a lock
212 */ 214 */
213static int 215static __be32
214nlmsvc_proc_unlock(struct svc_rqst *rqstp, struct nlm_args *argp, 216nlmsvc_proc_unlock(struct svc_rqst *rqstp, struct nlm_args *argp,
215 struct nlm_res *resp) 217 struct nlm_res *resp)
216{ 218{
@@ -229,7 +231,7 @@ nlmsvc_proc_unlock(struct svc_rqst *rqstp, struct nlm_args *argp,
229 231
230 /* Obtain client and file */ 232 /* Obtain client and file */
231 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file))) 233 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
232 return rpc_success; 234 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
233 235
234 /* Now try to remove the lock */ 236 /* Now try to remove the lock */
235 resp->status = cast_status(nlmsvc_unlock(file, &argp->lock)); 237 resp->status = cast_status(nlmsvc_unlock(file, &argp->lock));
@@ -244,7 +246,7 @@ nlmsvc_proc_unlock(struct svc_rqst *rqstp, struct nlm_args *argp,
244 * GRANTED: A server calls us to tell that a process' lock request 246 * GRANTED: A server calls us to tell that a process' lock request
245 * was granted 247 * was granted
246 */ 248 */
247static int 249static __be32
248nlmsvc_proc_granted(struct svc_rqst *rqstp, struct nlm_args *argp, 250nlmsvc_proc_granted(struct svc_rqst *rqstp, struct nlm_args *argp,
249 struct nlm_res *resp) 251 struct nlm_res *resp)
250{ 252{
@@ -280,12 +282,12 @@ static const struct rpc_call_ops nlmsvc_callback_ops = {
280 * because we send the callback before the reply proper. I hope this 282 * because we send the callback before the reply proper. I hope this
281 * doesn't break any clients. 283 * doesn't break any clients.
282 */ 284 */
283static int nlmsvc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_args *argp, 285static __be32 nlmsvc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_args *argp,
284 int (*func)(struct svc_rqst *, struct nlm_args *, struct nlm_res *)) 286 __be32 (*func)(struct svc_rqst *, struct nlm_args *, struct nlm_res *))
285{ 287{
286 struct nlm_host *host; 288 struct nlm_host *host;
287 struct nlm_rqst *call; 289 struct nlm_rqst *call;
288 int stat; 290 __be32 stat;
289 291
290 host = nlmsvc_lookup_host(rqstp, 292 host = nlmsvc_lookup_host(rqstp,
291 argp->lock.caller, 293 argp->lock.caller,
@@ -309,28 +311,28 @@ static int nlmsvc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_args *ar
309 return rpc_success; 311 return rpc_success;
310} 312}
311 313
312static int nlmsvc_proc_test_msg(struct svc_rqst *rqstp, struct nlm_args *argp, 314static __be32 nlmsvc_proc_test_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
313 void *resp) 315 void *resp)
314{ 316{
315 dprintk("lockd: TEST_MSG called\n"); 317 dprintk("lockd: TEST_MSG called\n");
316 return nlmsvc_callback(rqstp, NLMPROC_TEST_RES, argp, nlmsvc_proc_test); 318 return nlmsvc_callback(rqstp, NLMPROC_TEST_RES, argp, nlmsvc_proc_test);
317} 319}
318 320
319static int nlmsvc_proc_lock_msg(struct svc_rqst *rqstp, struct nlm_args *argp, 321static __be32 nlmsvc_proc_lock_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
320 void *resp) 322 void *resp)
321{ 323{
322 dprintk("lockd: LOCK_MSG called\n"); 324 dprintk("lockd: LOCK_MSG called\n");
323 return nlmsvc_callback(rqstp, NLMPROC_LOCK_RES, argp, nlmsvc_proc_lock); 325 return nlmsvc_callback(rqstp, NLMPROC_LOCK_RES, argp, nlmsvc_proc_lock);
324} 326}
325 327
326static int nlmsvc_proc_cancel_msg(struct svc_rqst *rqstp, struct nlm_args *argp, 328static __be32 nlmsvc_proc_cancel_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
327 void *resp) 329 void *resp)
328{ 330{
329 dprintk("lockd: CANCEL_MSG called\n"); 331 dprintk("lockd: CANCEL_MSG called\n");
330 return nlmsvc_callback(rqstp, NLMPROC_CANCEL_RES, argp, nlmsvc_proc_cancel); 332 return nlmsvc_callback(rqstp, NLMPROC_CANCEL_RES, argp, nlmsvc_proc_cancel);
331} 333}
332 334
333static int 335static __be32
334nlmsvc_proc_unlock_msg(struct svc_rqst *rqstp, struct nlm_args *argp, 336nlmsvc_proc_unlock_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
335 void *resp) 337 void *resp)
336{ 338{
@@ -338,7 +340,7 @@ nlmsvc_proc_unlock_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
338 return nlmsvc_callback(rqstp, NLMPROC_UNLOCK_RES, argp, nlmsvc_proc_unlock); 340 return nlmsvc_callback(rqstp, NLMPROC_UNLOCK_RES, argp, nlmsvc_proc_unlock);
339} 341}
340 342
341static int 343static __be32
342nlmsvc_proc_granted_msg(struct svc_rqst *rqstp, struct nlm_args *argp, 344nlmsvc_proc_granted_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
343 void *resp) 345 void *resp)
344{ 346{
@@ -349,7 +351,7 @@ nlmsvc_proc_granted_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
349/* 351/*
350 * SHARE: create a DOS share or alter existing share. 352 * SHARE: create a DOS share or alter existing share.
351 */ 353 */
352static int 354static __be32
353nlmsvc_proc_share(struct svc_rqst *rqstp, struct nlm_args *argp, 355nlmsvc_proc_share(struct svc_rqst *rqstp, struct nlm_args *argp,
354 struct nlm_res *resp) 356 struct nlm_res *resp)
355{ 357{
@@ -368,7 +370,7 @@ nlmsvc_proc_share(struct svc_rqst *rqstp, struct nlm_args *argp,
368 370
369 /* Obtain client and file */ 371 /* Obtain client and file */
370 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file))) 372 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
371 return rpc_success; 373 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
372 374
373 /* Now try to create the share */ 375 /* Now try to create the share */
374 resp->status = cast_status(nlmsvc_share_file(host, file, argp)); 376 resp->status = cast_status(nlmsvc_share_file(host, file, argp));
@@ -382,7 +384,7 @@ nlmsvc_proc_share(struct svc_rqst *rqstp, struct nlm_args *argp,
382/* 384/*
383 * UNSHARE: Release a DOS share. 385 * UNSHARE: Release a DOS share.
384 */ 386 */
385static int 387static __be32
386nlmsvc_proc_unshare(struct svc_rqst *rqstp, struct nlm_args *argp, 388nlmsvc_proc_unshare(struct svc_rqst *rqstp, struct nlm_args *argp,
387 struct nlm_res *resp) 389 struct nlm_res *resp)
388{ 390{
@@ -401,7 +403,7 @@ nlmsvc_proc_unshare(struct svc_rqst *rqstp, struct nlm_args *argp,
401 403
402 /* Obtain client and file */ 404 /* Obtain client and file */
403 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file))) 405 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
404 return rpc_success; 406 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
405 407
406 /* Now try to unshare the file */ 408 /* Now try to unshare the file */
407 resp->status = cast_status(nlmsvc_unshare_file(host, file, argp)); 409 resp->status = cast_status(nlmsvc_unshare_file(host, file, argp));
@@ -415,7 +417,7 @@ nlmsvc_proc_unshare(struct svc_rqst *rqstp, struct nlm_args *argp,
415/* 417/*
416 * NM_LOCK: Create an unmonitored lock 418 * NM_LOCK: Create an unmonitored lock
417 */ 419 */
418static int 420static __be32
419nlmsvc_proc_nm_lock(struct svc_rqst *rqstp, struct nlm_args *argp, 421nlmsvc_proc_nm_lock(struct svc_rqst *rqstp, struct nlm_args *argp,
420 struct nlm_res *resp) 422 struct nlm_res *resp)
421{ 423{
@@ -428,7 +430,7 @@ nlmsvc_proc_nm_lock(struct svc_rqst *rqstp, struct nlm_args *argp,
428/* 430/*
429 * FREE_ALL: Release all locks and shares held by client 431 * FREE_ALL: Release all locks and shares held by client
430 */ 432 */
431static int 433static __be32
432nlmsvc_proc_free_all(struct svc_rqst *rqstp, struct nlm_args *argp, 434nlmsvc_proc_free_all(struct svc_rqst *rqstp, struct nlm_args *argp,
433 void *resp) 435 void *resp)
434{ 436{
@@ -446,7 +448,7 @@ nlmsvc_proc_free_all(struct svc_rqst *rqstp, struct nlm_args *argp,
446/* 448/*
447 * SM_NOTIFY: private callback from statd (not part of official NLM proto) 449 * SM_NOTIFY: private callback from statd (not part of official NLM proto)
448 */ 450 */
449static int 451static __be32
450nlmsvc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp, 452nlmsvc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp,
451 void *resp) 453 void *resp)
452{ 454{
@@ -475,7 +477,7 @@ nlmsvc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp,
475/* 477/*
476 * client sent a GRANTED_RES, let's remove the associated block 478 * client sent a GRANTED_RES, let's remove the associated block
477 */ 479 */
478static int 480static __be32
479nlmsvc_proc_granted_res(struct svc_rqst *rqstp, struct nlm_res *argp, 481nlmsvc_proc_granted_res(struct svc_rqst *rqstp, struct nlm_res *argp,
480 void *resp) 482 void *resp)
481{ 483{
diff --git a/fs/lockd/svcshare.c b/fs/lockd/svcshare.c
index b9926ce8782e..6220dc2a3f2c 100644
--- a/fs/lockd/svcshare.c
+++ b/fs/lockd/svcshare.c
@@ -23,7 +23,7 @@ nlm_cmp_owner(struct nlm_share *share, struct xdr_netobj *oh)
23 && !memcmp(share->s_owner.data, oh->data, oh->len); 23 && !memcmp(share->s_owner.data, oh->data, oh->len);
24} 24}
25 25
26u32 26__be32
27nlmsvc_share_file(struct nlm_host *host, struct nlm_file *file, 27nlmsvc_share_file(struct nlm_host *host, struct nlm_file *file,
28 struct nlm_args *argp) 28 struct nlm_args *argp)
29{ 29{
@@ -64,7 +64,7 @@ update:
64/* 64/*
65 * Delete a share. 65 * Delete a share.
66 */ 66 */
67u32 67__be32
68nlmsvc_unshare_file(struct nlm_host *host, struct nlm_file *file, 68nlmsvc_unshare_file(struct nlm_host *host, struct nlm_file *file,
69 struct nlm_args *argp) 69 struct nlm_args *argp)
70{ 70{
diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c
index 514f5f20701e..e83024e16042 100644
--- a/fs/lockd/svcsubs.c
+++ b/fs/lockd/svcsubs.c
@@ -78,14 +78,14 @@ static inline unsigned int file_hash(struct nfs_fh *f)
78 * This is not quite right, but for now, we assume the client performs 78 * This is not quite right, but for now, we assume the client performs
79 * the proper R/W checking. 79 * the proper R/W checking.
80 */ 80 */
81u32 81__be32
82nlm_lookup_file(struct svc_rqst *rqstp, struct nlm_file **result, 82nlm_lookup_file(struct svc_rqst *rqstp, struct nlm_file **result,
83 struct nfs_fh *f) 83 struct nfs_fh *f)
84{ 84{
85 struct hlist_node *pos; 85 struct hlist_node *pos;
86 struct nlm_file *file; 86 struct nlm_file *file;
87 unsigned int hash; 87 unsigned int hash;
88 u32 nfserr; 88 __be32 nfserr;
89 89
90 nlm_debug_print_fh("nlm_file_lookup", f); 90 nlm_debug_print_fh("nlm_file_lookup", f);
91 91
@@ -135,12 +135,6 @@ out_unlock:
135 135
136out_free: 136out_free:
137 kfree(file); 137 kfree(file);
138#ifdef CONFIG_LOCKD_V4
139 if (nfserr == 1)
140 nfserr = nlm4_stale_fh;
141 else
142#endif
143 nfserr = nlm_lck_denied;
144 goto out_unlock; 138 goto out_unlock;
145} 139}
146 140
@@ -324,7 +318,16 @@ nlmsvc_same_host(struct nlm_host *host, struct nlm_host *other)
324static int 318static int
325nlmsvc_is_client(struct nlm_host *host, struct nlm_host *dummy) 319nlmsvc_is_client(struct nlm_host *host, struct nlm_host *dummy)
326{ 320{
327 return host->h_server; 321 if (host->h_server) {
322 /* we are destroying locks even though the client
323 * hasn't asked us too, so don't unmonitor the
324 * client
325 */
326 if (host->h_nsmhandle)
327 host->h_nsmhandle->sm_sticky = 1;
328 return 1;
329 } else
330 return 0;
328} 331}
329 332
330/* 333/*
diff --git a/fs/lockd/xdr.c b/fs/lockd/xdr.c
index 61c46facf257..b7c949256e5a 100644
--- a/fs/lockd/xdr.c
+++ b/fs/lockd/xdr.c
@@ -43,7 +43,7 @@ loff_t_to_s32(loff_t offset)
43/* 43/*
44 * XDR functions for basic NLM types 44 * XDR functions for basic NLM types
45 */ 45 */
46static u32 *nlm_decode_cookie(u32 *p, struct nlm_cookie *c) 46static __be32 *nlm_decode_cookie(__be32 *p, struct nlm_cookie *c)
47{ 47{
48 unsigned int len; 48 unsigned int len;
49 49
@@ -69,8 +69,8 @@ static u32 *nlm_decode_cookie(u32 *p, struct nlm_cookie *c)
69 return p; 69 return p;
70} 70}
71 71
72static inline u32 * 72static inline __be32 *
73nlm_encode_cookie(u32 *p, struct nlm_cookie *c) 73nlm_encode_cookie(__be32 *p, struct nlm_cookie *c)
74{ 74{
75 *p++ = htonl(c->len); 75 *p++ = htonl(c->len);
76 memcpy(p, c->data, c->len); 76 memcpy(p, c->data, c->len);
@@ -78,8 +78,8 @@ nlm_encode_cookie(u32 *p, struct nlm_cookie *c)
78 return p; 78 return p;
79} 79}
80 80
81static u32 * 81static __be32 *
82nlm_decode_fh(u32 *p, struct nfs_fh *f) 82nlm_decode_fh(__be32 *p, struct nfs_fh *f)
83{ 83{
84 unsigned int len; 84 unsigned int len;
85 85
@@ -95,8 +95,8 @@ nlm_decode_fh(u32 *p, struct nfs_fh *f)
95 return p + XDR_QUADLEN(NFS2_FHSIZE); 95 return p + XDR_QUADLEN(NFS2_FHSIZE);
96} 96}
97 97
98static inline u32 * 98static inline __be32 *
99nlm_encode_fh(u32 *p, struct nfs_fh *f) 99nlm_encode_fh(__be32 *p, struct nfs_fh *f)
100{ 100{
101 *p++ = htonl(NFS2_FHSIZE); 101 *p++ = htonl(NFS2_FHSIZE);
102 memcpy(p, f->data, NFS2_FHSIZE); 102 memcpy(p, f->data, NFS2_FHSIZE);
@@ -106,20 +106,20 @@ nlm_encode_fh(u32 *p, struct nfs_fh *f)
106/* 106/*
107 * Encode and decode owner handle 107 * Encode and decode owner handle
108 */ 108 */
109static inline u32 * 109static inline __be32 *
110nlm_decode_oh(u32 *p, struct xdr_netobj *oh) 110nlm_decode_oh(__be32 *p, struct xdr_netobj *oh)
111{ 111{
112 return xdr_decode_netobj(p, oh); 112 return xdr_decode_netobj(p, oh);
113} 113}
114 114
115static inline u32 * 115static inline __be32 *
116nlm_encode_oh(u32 *p, struct xdr_netobj *oh) 116nlm_encode_oh(__be32 *p, struct xdr_netobj *oh)
117{ 117{
118 return xdr_encode_netobj(p, oh); 118 return xdr_encode_netobj(p, oh);
119} 119}
120 120
121static u32 * 121static __be32 *
122nlm_decode_lock(u32 *p, struct nlm_lock *lock) 122nlm_decode_lock(__be32 *p, struct nlm_lock *lock)
123{ 123{
124 struct file_lock *fl = &lock->fl; 124 struct file_lock *fl = &lock->fl;
125 s32 start, len, end; 125 s32 start, len, end;
@@ -153,8 +153,8 @@ nlm_decode_lock(u32 *p, struct nlm_lock *lock)
153/* 153/*
154 * Encode a lock as part of an NLM call 154 * Encode a lock as part of an NLM call
155 */ 155 */
156static u32 * 156static __be32 *
157nlm_encode_lock(u32 *p, struct nlm_lock *lock) 157nlm_encode_lock(__be32 *p, struct nlm_lock *lock)
158{ 158{
159 struct file_lock *fl = &lock->fl; 159 struct file_lock *fl = &lock->fl;
160 __s32 start, len; 160 __s32 start, len;
@@ -184,8 +184,8 @@ nlm_encode_lock(u32 *p, struct nlm_lock *lock)
184/* 184/*
185 * Encode result of a TEST/TEST_MSG call 185 * Encode result of a TEST/TEST_MSG call
186 */ 186 */
187static u32 * 187static __be32 *
188nlm_encode_testres(u32 *p, struct nlm_res *resp) 188nlm_encode_testres(__be32 *p, struct nlm_res *resp)
189{ 189{
190 s32 start, len; 190 s32 start, len;
191 191
@@ -221,7 +221,7 @@ nlm_encode_testres(u32 *p, struct nlm_res *resp)
221 * First, the server side XDR functions 221 * First, the server side XDR functions
222 */ 222 */
223int 223int
224nlmsvc_decode_testargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp) 224nlmsvc_decode_testargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
225{ 225{
226 u32 exclusive; 226 u32 exclusive;
227 227
@@ -238,7 +238,7 @@ nlmsvc_decode_testargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp)
238} 238}
239 239
240int 240int
241nlmsvc_encode_testres(struct svc_rqst *rqstp, u32 *p, struct nlm_res *resp) 241nlmsvc_encode_testres(struct svc_rqst *rqstp, __be32 *p, struct nlm_res *resp)
242{ 242{
243 if (!(p = nlm_encode_testres(p, resp))) 243 if (!(p = nlm_encode_testres(p, resp)))
244 return 0; 244 return 0;
@@ -246,7 +246,7 @@ nlmsvc_encode_testres(struct svc_rqst *rqstp, u32 *p, struct nlm_res *resp)
246} 246}
247 247
248int 248int
249nlmsvc_decode_lockargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp) 249nlmsvc_decode_lockargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
250{ 250{
251 u32 exclusive; 251 u32 exclusive;
252 252
@@ -266,7 +266,7 @@ nlmsvc_decode_lockargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp)
266} 266}
267 267
268int 268int
269nlmsvc_decode_cancargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp) 269nlmsvc_decode_cancargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
270{ 270{
271 u32 exclusive; 271 u32 exclusive;
272 272
@@ -282,7 +282,7 @@ nlmsvc_decode_cancargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp)
282} 282}
283 283
284int 284int
285nlmsvc_decode_unlockargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp) 285nlmsvc_decode_unlockargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
286{ 286{
287 if (!(p = nlm_decode_cookie(p, &argp->cookie)) 287 if (!(p = nlm_decode_cookie(p, &argp->cookie))
288 || !(p = nlm_decode_lock(p, &argp->lock))) 288 || !(p = nlm_decode_lock(p, &argp->lock)))
@@ -292,7 +292,7 @@ nlmsvc_decode_unlockargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp)
292} 292}
293 293
294int 294int
295nlmsvc_decode_shareargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp) 295nlmsvc_decode_shareargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
296{ 296{
297 struct nlm_lock *lock = &argp->lock; 297 struct nlm_lock *lock = &argp->lock;
298 298
@@ -313,7 +313,7 @@ nlmsvc_decode_shareargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp)
313} 313}
314 314
315int 315int
316nlmsvc_encode_shareres(struct svc_rqst *rqstp, u32 *p, struct nlm_res *resp) 316nlmsvc_encode_shareres(struct svc_rqst *rqstp, __be32 *p, struct nlm_res *resp)
317{ 317{
318 if (!(p = nlm_encode_cookie(p, &resp->cookie))) 318 if (!(p = nlm_encode_cookie(p, &resp->cookie)))
319 return 0; 319 return 0;
@@ -323,7 +323,7 @@ nlmsvc_encode_shareres(struct svc_rqst *rqstp, u32 *p, struct nlm_res *resp)
323} 323}
324 324
325int 325int
326nlmsvc_encode_res(struct svc_rqst *rqstp, u32 *p, struct nlm_res *resp) 326nlmsvc_encode_res(struct svc_rqst *rqstp, __be32 *p, struct nlm_res *resp)
327{ 327{
328 if (!(p = nlm_encode_cookie(p, &resp->cookie))) 328 if (!(p = nlm_encode_cookie(p, &resp->cookie)))
329 return 0; 329 return 0;
@@ -332,7 +332,7 @@ nlmsvc_encode_res(struct svc_rqst *rqstp, u32 *p, struct nlm_res *resp)
332} 332}
333 333
334int 334int
335nlmsvc_decode_notify(struct svc_rqst *rqstp, u32 *p, struct nlm_args *argp) 335nlmsvc_decode_notify(struct svc_rqst *rqstp, __be32 *p, struct nlm_args *argp)
336{ 336{
337 struct nlm_lock *lock = &argp->lock; 337 struct nlm_lock *lock = &argp->lock;
338 338
@@ -344,7 +344,7 @@ nlmsvc_decode_notify(struct svc_rqst *rqstp, u32 *p, struct nlm_args *argp)
344} 344}
345 345
346int 346int
347nlmsvc_decode_reboot(struct svc_rqst *rqstp, u32 *p, struct nlm_reboot *argp) 347nlmsvc_decode_reboot(struct svc_rqst *rqstp, __be32 *p, struct nlm_reboot *argp)
348{ 348{
349 if (!(p = xdr_decode_string_inplace(p, &argp->mon, &argp->len, SM_MAXSTRLEN))) 349 if (!(p = xdr_decode_string_inplace(p, &argp->mon, &argp->len, SM_MAXSTRLEN)))
350 return 0; 350 return 0;
@@ -357,7 +357,7 @@ nlmsvc_decode_reboot(struct svc_rqst *rqstp, u32 *p, struct nlm_reboot *argp)
357} 357}
358 358
359int 359int
360nlmsvc_decode_res(struct svc_rqst *rqstp, u32 *p, struct nlm_res *resp) 360nlmsvc_decode_res(struct svc_rqst *rqstp, __be32 *p, struct nlm_res *resp)
361{ 361{
362 if (!(p = nlm_decode_cookie(p, &resp->cookie))) 362 if (!(p = nlm_decode_cookie(p, &resp->cookie)))
363 return 0; 363 return 0;
@@ -366,13 +366,13 @@ nlmsvc_decode_res(struct svc_rqst *rqstp, u32 *p, struct nlm_res *resp)
366} 366}
367 367
368int 368int
369nlmsvc_decode_void(struct svc_rqst *rqstp, u32 *p, void *dummy) 369nlmsvc_decode_void(struct svc_rqst *rqstp, __be32 *p, void *dummy)
370{ 370{
371 return xdr_argsize_check(rqstp, p); 371 return xdr_argsize_check(rqstp, p);
372} 372}
373 373
374int 374int
375nlmsvc_encode_void(struct svc_rqst *rqstp, u32 *p, void *dummy) 375nlmsvc_encode_void(struct svc_rqst *rqstp, __be32 *p, void *dummy)
376{ 376{
377 return xdr_ressize_check(rqstp, p); 377 return xdr_ressize_check(rqstp, p);
378} 378}
@@ -389,7 +389,7 @@ nlmclt_decode_void(struct rpc_rqst *req, u32 *p, void *ptr)
389#endif 389#endif
390 390
391static int 391static int
392nlmclt_encode_testargs(struct rpc_rqst *req, u32 *p, nlm_args *argp) 392nlmclt_encode_testargs(struct rpc_rqst *req, __be32 *p, nlm_args *argp)
393{ 393{
394 struct nlm_lock *lock = &argp->lock; 394 struct nlm_lock *lock = &argp->lock;
395 395
@@ -403,7 +403,7 @@ nlmclt_encode_testargs(struct rpc_rqst *req, u32 *p, nlm_args *argp)
403} 403}
404 404
405static int 405static int
406nlmclt_decode_testres(struct rpc_rqst *req, u32 *p, struct nlm_res *resp) 406nlmclt_decode_testres(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp)
407{ 407{
408 if (!(p = nlm_decode_cookie(p, &resp->cookie))) 408 if (!(p = nlm_decode_cookie(p, &resp->cookie)))
409 return -EIO; 409 return -EIO;
@@ -438,7 +438,7 @@ nlmclt_decode_testres(struct rpc_rqst *req, u32 *p, struct nlm_res *resp)
438 438
439 439
440static int 440static int
441nlmclt_encode_lockargs(struct rpc_rqst *req, u32 *p, nlm_args *argp) 441nlmclt_encode_lockargs(struct rpc_rqst *req, __be32 *p, nlm_args *argp)
442{ 442{
443 struct nlm_lock *lock = &argp->lock; 443 struct nlm_lock *lock = &argp->lock;
444 444
@@ -455,7 +455,7 @@ nlmclt_encode_lockargs(struct rpc_rqst *req, u32 *p, nlm_args *argp)
455} 455}
456 456
457static int 457static int
458nlmclt_encode_cancargs(struct rpc_rqst *req, u32 *p, nlm_args *argp) 458nlmclt_encode_cancargs(struct rpc_rqst *req, __be32 *p, nlm_args *argp)
459{ 459{
460 struct nlm_lock *lock = &argp->lock; 460 struct nlm_lock *lock = &argp->lock;
461 461
@@ -470,7 +470,7 @@ nlmclt_encode_cancargs(struct rpc_rqst *req, u32 *p, nlm_args *argp)
470} 470}
471 471
472static int 472static int
473nlmclt_encode_unlockargs(struct rpc_rqst *req, u32 *p, nlm_args *argp) 473nlmclt_encode_unlockargs(struct rpc_rqst *req, __be32 *p, nlm_args *argp)
474{ 474{
475 struct nlm_lock *lock = &argp->lock; 475 struct nlm_lock *lock = &argp->lock;
476 476
@@ -483,7 +483,7 @@ nlmclt_encode_unlockargs(struct rpc_rqst *req, u32 *p, nlm_args *argp)
483} 483}
484 484
485static int 485static int
486nlmclt_encode_res(struct rpc_rqst *req, u32 *p, struct nlm_res *resp) 486nlmclt_encode_res(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp)
487{ 487{
488 if (!(p = nlm_encode_cookie(p, &resp->cookie))) 488 if (!(p = nlm_encode_cookie(p, &resp->cookie)))
489 return -EIO; 489 return -EIO;
@@ -493,7 +493,7 @@ nlmclt_encode_res(struct rpc_rqst *req, u32 *p, struct nlm_res *resp)
493} 493}
494 494
495static int 495static int
496nlmclt_encode_testres(struct rpc_rqst *req, u32 *p, struct nlm_res *resp) 496nlmclt_encode_testres(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp)
497{ 497{
498 if (!(p = nlm_encode_testres(p, resp))) 498 if (!(p = nlm_encode_testres(p, resp)))
499 return -EIO; 499 return -EIO;
@@ -502,7 +502,7 @@ nlmclt_encode_testres(struct rpc_rqst *req, u32 *p, struct nlm_res *resp)
502} 502}
503 503
504static int 504static int
505nlmclt_decode_res(struct rpc_rqst *req, u32 *p, struct nlm_res *resp) 505nlmclt_decode_res(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp)
506{ 506{
507 if (!(p = nlm_decode_cookie(p, &resp->cookie))) 507 if (!(p = nlm_decode_cookie(p, &resp->cookie)))
508 return -EIO; 508 return -EIO;
diff --git a/fs/lockd/xdr4.c b/fs/lockd/xdr4.c
index 36eb175ec335..f4c0b2b9f75a 100644
--- a/fs/lockd/xdr4.c
+++ b/fs/lockd/xdr4.c
@@ -44,8 +44,8 @@ loff_t_to_s64(loff_t offset)
44/* 44/*
45 * XDR functions for basic NLM types 45 * XDR functions for basic NLM types
46 */ 46 */
47static u32 * 47static __be32 *
48nlm4_decode_cookie(u32 *p, struct nlm_cookie *c) 48nlm4_decode_cookie(__be32 *p, struct nlm_cookie *c)
49{ 49{
50 unsigned int len; 50 unsigned int len;
51 51
@@ -71,8 +71,8 @@ nlm4_decode_cookie(u32 *p, struct nlm_cookie *c)
71 return p; 71 return p;
72} 72}
73 73
74static u32 * 74static __be32 *
75nlm4_encode_cookie(u32 *p, struct nlm_cookie *c) 75nlm4_encode_cookie(__be32 *p, struct nlm_cookie *c)
76{ 76{
77 *p++ = htonl(c->len); 77 *p++ = htonl(c->len);
78 memcpy(p, c->data, c->len); 78 memcpy(p, c->data, c->len);
@@ -80,8 +80,8 @@ nlm4_encode_cookie(u32 *p, struct nlm_cookie *c)
80 return p; 80 return p;
81} 81}
82 82
83static u32 * 83static __be32 *
84nlm4_decode_fh(u32 *p, struct nfs_fh *f) 84nlm4_decode_fh(__be32 *p, struct nfs_fh *f)
85{ 85{
86 memset(f->data, 0, sizeof(f->data)); 86 memset(f->data, 0, sizeof(f->data));
87 f->size = ntohl(*p++); 87 f->size = ntohl(*p++);
@@ -95,8 +95,8 @@ nlm4_decode_fh(u32 *p, struct nfs_fh *f)
95 return p + XDR_QUADLEN(f->size); 95 return p + XDR_QUADLEN(f->size);
96} 96}
97 97
98static u32 * 98static __be32 *
99nlm4_encode_fh(u32 *p, struct nfs_fh *f) 99nlm4_encode_fh(__be32 *p, struct nfs_fh *f)
100{ 100{
101 *p++ = htonl(f->size); 101 *p++ = htonl(f->size);
102 if (f->size) p[XDR_QUADLEN(f->size)-1] = 0; /* don't leak anything */ 102 if (f->size) p[XDR_QUADLEN(f->size)-1] = 0; /* don't leak anything */
@@ -107,20 +107,20 @@ nlm4_encode_fh(u32 *p, struct nfs_fh *f)
107/* 107/*
108 * Encode and decode owner handle 108 * Encode and decode owner handle
109 */ 109 */
110static u32 * 110static __be32 *
111nlm4_decode_oh(u32 *p, struct xdr_netobj *oh) 111nlm4_decode_oh(__be32 *p, struct xdr_netobj *oh)
112{ 112{
113 return xdr_decode_netobj(p, oh); 113 return xdr_decode_netobj(p, oh);
114} 114}
115 115
116static u32 * 116static __be32 *
117nlm4_encode_oh(u32 *p, struct xdr_netobj *oh) 117nlm4_encode_oh(__be32 *p, struct xdr_netobj *oh)
118{ 118{
119 return xdr_encode_netobj(p, oh); 119 return xdr_encode_netobj(p, oh);
120} 120}
121 121
122static u32 * 122static __be32 *
123nlm4_decode_lock(u32 *p, struct nlm_lock *lock) 123nlm4_decode_lock(__be32 *p, struct nlm_lock *lock)
124{ 124{
125 struct file_lock *fl = &lock->fl; 125 struct file_lock *fl = &lock->fl;
126 __s64 len, start, end; 126 __s64 len, start, end;
@@ -153,8 +153,8 @@ nlm4_decode_lock(u32 *p, struct nlm_lock *lock)
153/* 153/*
154 * Encode a lock as part of an NLM call 154 * Encode a lock as part of an NLM call
155 */ 155 */
156static u32 * 156static __be32 *
157nlm4_encode_lock(u32 *p, struct nlm_lock *lock) 157nlm4_encode_lock(__be32 *p, struct nlm_lock *lock)
158{ 158{
159 struct file_lock *fl = &lock->fl; 159 struct file_lock *fl = &lock->fl;
160 __s64 start, len; 160 __s64 start, len;
@@ -185,8 +185,8 @@ nlm4_encode_lock(u32 *p, struct nlm_lock *lock)
185/* 185/*
186 * Encode result of a TEST/TEST_MSG call 186 * Encode result of a TEST/TEST_MSG call
187 */ 187 */
188static u32 * 188static __be32 *
189nlm4_encode_testres(u32 *p, struct nlm_res *resp) 189nlm4_encode_testres(__be32 *p, struct nlm_res *resp)
190{ 190{
191 s64 start, len; 191 s64 start, len;
192 192
@@ -227,7 +227,7 @@ nlm4_encode_testres(u32 *p, struct nlm_res *resp)
227 * First, the server side XDR functions 227 * First, the server side XDR functions
228 */ 228 */
229int 229int
230nlm4svc_decode_testargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp) 230nlm4svc_decode_testargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
231{ 231{
232 u32 exclusive; 232 u32 exclusive;
233 233
@@ -244,7 +244,7 @@ nlm4svc_decode_testargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp)
244} 244}
245 245
246int 246int
247nlm4svc_encode_testres(struct svc_rqst *rqstp, u32 *p, struct nlm_res *resp) 247nlm4svc_encode_testres(struct svc_rqst *rqstp, __be32 *p, struct nlm_res *resp)
248{ 248{
249 if (!(p = nlm4_encode_testres(p, resp))) 249 if (!(p = nlm4_encode_testres(p, resp)))
250 return 0; 250 return 0;
@@ -252,7 +252,7 @@ nlm4svc_encode_testres(struct svc_rqst *rqstp, u32 *p, struct nlm_res *resp)
252} 252}
253 253
254int 254int
255nlm4svc_decode_lockargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp) 255nlm4svc_decode_lockargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
256{ 256{
257 u32 exclusive; 257 u32 exclusive;
258 258
@@ -272,7 +272,7 @@ nlm4svc_decode_lockargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp)
272} 272}
273 273
274int 274int
275nlm4svc_decode_cancargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp) 275nlm4svc_decode_cancargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
276{ 276{
277 u32 exclusive; 277 u32 exclusive;
278 278
@@ -288,7 +288,7 @@ nlm4svc_decode_cancargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp)
288} 288}
289 289
290int 290int
291nlm4svc_decode_unlockargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp) 291nlm4svc_decode_unlockargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
292{ 292{
293 if (!(p = nlm4_decode_cookie(p, &argp->cookie)) 293 if (!(p = nlm4_decode_cookie(p, &argp->cookie))
294 || !(p = nlm4_decode_lock(p, &argp->lock))) 294 || !(p = nlm4_decode_lock(p, &argp->lock)))
@@ -298,7 +298,7 @@ nlm4svc_decode_unlockargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp)
298} 298}
299 299
300int 300int
301nlm4svc_decode_shareargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp) 301nlm4svc_decode_shareargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
302{ 302{
303 struct nlm_lock *lock = &argp->lock; 303 struct nlm_lock *lock = &argp->lock;
304 304
@@ -319,7 +319,7 @@ nlm4svc_decode_shareargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp)
319} 319}
320 320
321int 321int
322nlm4svc_encode_shareres(struct svc_rqst *rqstp, u32 *p, struct nlm_res *resp) 322nlm4svc_encode_shareres(struct svc_rqst *rqstp, __be32 *p, struct nlm_res *resp)
323{ 323{
324 if (!(p = nlm4_encode_cookie(p, &resp->cookie))) 324 if (!(p = nlm4_encode_cookie(p, &resp->cookie)))
325 return 0; 325 return 0;
@@ -329,7 +329,7 @@ nlm4svc_encode_shareres(struct svc_rqst *rqstp, u32 *p, struct nlm_res *resp)
329} 329}
330 330
331int 331int
332nlm4svc_encode_res(struct svc_rqst *rqstp, u32 *p, struct nlm_res *resp) 332nlm4svc_encode_res(struct svc_rqst *rqstp, __be32 *p, struct nlm_res *resp)
333{ 333{
334 if (!(p = nlm4_encode_cookie(p, &resp->cookie))) 334 if (!(p = nlm4_encode_cookie(p, &resp->cookie)))
335 return 0; 335 return 0;
@@ -338,7 +338,7 @@ nlm4svc_encode_res(struct svc_rqst *rqstp, u32 *p, struct nlm_res *resp)
338} 338}
339 339
340int 340int
341nlm4svc_decode_notify(struct svc_rqst *rqstp, u32 *p, struct nlm_args *argp) 341nlm4svc_decode_notify(struct svc_rqst *rqstp, __be32 *p, struct nlm_args *argp)
342{ 342{
343 struct nlm_lock *lock = &argp->lock; 343 struct nlm_lock *lock = &argp->lock;
344 344
@@ -350,7 +350,7 @@ nlm4svc_decode_notify(struct svc_rqst *rqstp, u32 *p, struct nlm_args *argp)
350} 350}
351 351
352int 352int
353nlm4svc_decode_reboot(struct svc_rqst *rqstp, u32 *p, struct nlm_reboot *argp) 353nlm4svc_decode_reboot(struct svc_rqst *rqstp, __be32 *p, struct nlm_reboot *argp)
354{ 354{
355 if (!(p = xdr_decode_string_inplace(p, &argp->mon, &argp->len, SM_MAXSTRLEN))) 355 if (!(p = xdr_decode_string_inplace(p, &argp->mon, &argp->len, SM_MAXSTRLEN)))
356 return 0; 356 return 0;
@@ -363,7 +363,7 @@ nlm4svc_decode_reboot(struct svc_rqst *rqstp, u32 *p, struct nlm_reboot *argp)
363} 363}
364 364
365int 365int
366nlm4svc_decode_res(struct svc_rqst *rqstp, u32 *p, struct nlm_res *resp) 366nlm4svc_decode_res(struct svc_rqst *rqstp, __be32 *p, struct nlm_res *resp)
367{ 367{
368 if (!(p = nlm4_decode_cookie(p, &resp->cookie))) 368 if (!(p = nlm4_decode_cookie(p, &resp->cookie)))
369 return 0; 369 return 0;
@@ -372,13 +372,13 @@ nlm4svc_decode_res(struct svc_rqst *rqstp, u32 *p, struct nlm_res *resp)
372} 372}
373 373
374int 374int
375nlm4svc_decode_void(struct svc_rqst *rqstp, u32 *p, void *dummy) 375nlm4svc_decode_void(struct svc_rqst *rqstp, __be32 *p, void *dummy)
376{ 376{
377 return xdr_argsize_check(rqstp, p); 377 return xdr_argsize_check(rqstp, p);
378} 378}
379 379
380int 380int
381nlm4svc_encode_void(struct svc_rqst *rqstp, u32 *p, void *dummy) 381nlm4svc_encode_void(struct svc_rqst *rqstp, __be32 *p, void *dummy)
382{ 382{
383 return xdr_ressize_check(rqstp, p); 383 return xdr_ressize_check(rqstp, p);
384} 384}
@@ -388,14 +388,14 @@ nlm4svc_encode_void(struct svc_rqst *rqstp, u32 *p, void *dummy)
388 */ 388 */
389#ifdef NLMCLNT_SUPPORT_SHARES 389#ifdef NLMCLNT_SUPPORT_SHARES
390static int 390static int
391nlm4clt_decode_void(struct rpc_rqst *req, u32 *p, void *ptr) 391nlm4clt_decode_void(struct rpc_rqst *req, __be32 *p, void *ptr)
392{ 392{
393 return 0; 393 return 0;
394} 394}
395#endif 395#endif
396 396
397static int 397static int
398nlm4clt_encode_testargs(struct rpc_rqst *req, u32 *p, nlm_args *argp) 398nlm4clt_encode_testargs(struct rpc_rqst *req, __be32 *p, nlm_args *argp)
399{ 399{
400 struct nlm_lock *lock = &argp->lock; 400 struct nlm_lock *lock = &argp->lock;
401 401
@@ -409,7 +409,7 @@ nlm4clt_encode_testargs(struct rpc_rqst *req, u32 *p, nlm_args *argp)
409} 409}
410 410
411static int 411static int
412nlm4clt_decode_testres(struct rpc_rqst *req, u32 *p, struct nlm_res *resp) 412nlm4clt_decode_testres(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp)
413{ 413{
414 if (!(p = nlm4_decode_cookie(p, &resp->cookie))) 414 if (!(p = nlm4_decode_cookie(p, &resp->cookie)))
415 return -EIO; 415 return -EIO;
@@ -444,7 +444,7 @@ nlm4clt_decode_testres(struct rpc_rqst *req, u32 *p, struct nlm_res *resp)
444 444
445 445
446static int 446static int
447nlm4clt_encode_lockargs(struct rpc_rqst *req, u32 *p, nlm_args *argp) 447nlm4clt_encode_lockargs(struct rpc_rqst *req, __be32 *p, nlm_args *argp)
448{ 448{
449 struct nlm_lock *lock = &argp->lock; 449 struct nlm_lock *lock = &argp->lock;
450 450
@@ -461,7 +461,7 @@ nlm4clt_encode_lockargs(struct rpc_rqst *req, u32 *p, nlm_args *argp)
461} 461}
462 462
463static int 463static int
464nlm4clt_encode_cancargs(struct rpc_rqst *req, u32 *p, nlm_args *argp) 464nlm4clt_encode_cancargs(struct rpc_rqst *req, __be32 *p, nlm_args *argp)
465{ 465{
466 struct nlm_lock *lock = &argp->lock; 466 struct nlm_lock *lock = &argp->lock;
467 467
@@ -476,7 +476,7 @@ nlm4clt_encode_cancargs(struct rpc_rqst *req, u32 *p, nlm_args *argp)
476} 476}
477 477
478static int 478static int
479nlm4clt_encode_unlockargs(struct rpc_rqst *req, u32 *p, nlm_args *argp) 479nlm4clt_encode_unlockargs(struct rpc_rqst *req, __be32 *p, nlm_args *argp)
480{ 480{
481 struct nlm_lock *lock = &argp->lock; 481 struct nlm_lock *lock = &argp->lock;
482 482
@@ -489,7 +489,7 @@ nlm4clt_encode_unlockargs(struct rpc_rqst *req, u32 *p, nlm_args *argp)
489} 489}
490 490
491static int 491static int
492nlm4clt_encode_res(struct rpc_rqst *req, u32 *p, struct nlm_res *resp) 492nlm4clt_encode_res(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp)
493{ 493{
494 if (!(p = nlm4_encode_cookie(p, &resp->cookie))) 494 if (!(p = nlm4_encode_cookie(p, &resp->cookie)))
495 return -EIO; 495 return -EIO;
@@ -499,7 +499,7 @@ nlm4clt_encode_res(struct rpc_rqst *req, u32 *p, struct nlm_res *resp)
499} 499}
500 500
501static int 501static int
502nlm4clt_encode_testres(struct rpc_rqst *req, u32 *p, struct nlm_res *resp) 502nlm4clt_encode_testres(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp)
503{ 503{
504 if (!(p = nlm4_encode_testres(p, resp))) 504 if (!(p = nlm4_encode_testres(p, resp)))
505 return -EIO; 505 return -EIO;
@@ -508,7 +508,7 @@ nlm4clt_encode_testres(struct rpc_rqst *req, u32 *p, struct nlm_res *resp)
508} 508}
509 509
510static int 510static int
511nlm4clt_decode_res(struct rpc_rqst *req, u32 *p, struct nlm_res *resp) 511nlm4clt_decode_res(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp)
512{ 512{
513 if (!(p = nlm4_decode_cookie(p, &resp->cookie))) 513 if (!(p = nlm4_decode_cookie(p, &resp->cookie)))
514 return -EIO; 514 return -EIO;
diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index c11a4b9fb863..1e36bae4d0eb 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -149,12 +149,8 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
149 return -ENOMEM; 149 return -ENOMEM;
150 s->s_fs_info = sbi; 150 s->s_fs_info = sbi;
151 151
152 /* N.B. These should be compile-time tests. 152 BUILD_BUG_ON(32 != sizeof (struct minix_inode));
153 Unfortunately that is impossible. */ 153 BUILD_BUG_ON(64 != sizeof(struct minix2_inode));
154 if (32 != sizeof (struct minix_inode))
155 panic("bad V1 i-node size");
156 if (64 != sizeof(struct minix2_inode))
157 panic("bad V2 i-node size");
158 154
159 if (!sb_set_blocksize(s, BLOCK_SIZE)) 155 if (!sb_set_blocksize(s, BLOCK_SIZE))
160 goto out_bad_hblock; 156 goto out_bad_hblock;
diff --git a/fs/msdos/namei.c b/fs/msdos/namei.c
index b0f01b3b0536..452461955cbd 100644
--- a/fs/msdos/namei.c
+++ b/fs/msdos/namei.c
@@ -654,6 +654,7 @@ static struct inode_operations msdos_dir_inode_operations = {
654 .rmdir = msdos_rmdir, 654 .rmdir = msdos_rmdir,
655 .rename = msdos_rename, 655 .rename = msdos_rename,
656 .setattr = fat_notify_change, 656 .setattr = fat_notify_change,
657 .getattr = fat_getattr,
657}; 658};
658 659
659static int msdos_fill_super(struct super_block *sb, void *data, int silent) 660static int msdos_fill_super(struct super_block *sb, void *data, int silent)
diff --git a/fs/nfs/callback.h b/fs/nfs/callback.h
index 5676163d26e8..db3d7919c601 100644
--- a/fs/nfs/callback.h
+++ b/fs/nfs/callback.h
@@ -31,10 +31,10 @@ struct cb_compound_hdr_arg {
31}; 31};
32 32
33struct cb_compound_hdr_res { 33struct cb_compound_hdr_res {
34 uint32_t *status; 34 __be32 *status;
35 int taglen; 35 int taglen;
36 const char *tag; 36 const char *tag;
37 uint32_t *nops; 37 __be32 *nops;
38}; 38};
39 39
40struct cb_getattrargs { 40struct cb_getattrargs {
@@ -44,7 +44,7 @@ struct cb_getattrargs {
44}; 44};
45 45
46struct cb_getattrres { 46struct cb_getattrres {
47 uint32_t status; 47 __be32 status;
48 uint32_t bitmap[2]; 48 uint32_t bitmap[2];
49 uint64_t size; 49 uint64_t size;
50 uint64_t change_attr; 50 uint64_t change_attr;
@@ -59,8 +59,8 @@ struct cb_recallargs {
59 uint32_t truncate; 59 uint32_t truncate;
60}; 60};
61 61
62extern unsigned nfs4_callback_getattr(struct cb_getattrargs *args, struct cb_getattrres *res); 62extern __be32 nfs4_callback_getattr(struct cb_getattrargs *args, struct cb_getattrres *res);
63extern unsigned nfs4_callback_recall(struct cb_recallargs *args, void *dummy); 63extern __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy);
64 64
65#ifdef CONFIG_NFS_V4 65#ifdef CONFIG_NFS_V4
66extern int nfs_callback_up(void); 66extern int nfs_callback_up(void);
diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index 97cf8f71451f..72e55d83756d 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -14,7 +14,7 @@
14 14
15#define NFSDBG_FACILITY NFSDBG_CALLBACK 15#define NFSDBG_FACILITY NFSDBG_CALLBACK
16 16
17unsigned nfs4_callback_getattr(struct cb_getattrargs *args, struct cb_getattrres *res) 17__be32 nfs4_callback_getattr(struct cb_getattrargs *args, struct cb_getattrres *res)
18{ 18{
19 struct nfs_client *clp; 19 struct nfs_client *clp;
20 struct nfs_delegation *delegation; 20 struct nfs_delegation *delegation;
@@ -55,11 +55,11 @@ out:
55 return res->status; 55 return res->status;
56} 56}
57 57
58unsigned nfs4_callback_recall(struct cb_recallargs *args, void *dummy) 58__be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy)
59{ 59{
60 struct nfs_client *clp; 60 struct nfs_client *clp;
61 struct inode *inode; 61 struct inode *inode;
62 unsigned res; 62 __be32 res;
63 63
64 res = htonl(NFS4ERR_BADHANDLE); 64 res = htonl(NFS4ERR_BADHANDLE);
65 clp = nfs_find_client(args->addr, 4); 65 clp = nfs_find_client(args->addr, 4);
diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
index 29f932192054..f8ea1f51f590 100644
--- a/fs/nfs/callback_xdr.c
+++ b/fs/nfs/callback_xdr.c
@@ -22,9 +22,9 @@
22 22
23#define NFSDBG_FACILITY NFSDBG_CALLBACK 23#define NFSDBG_FACILITY NFSDBG_CALLBACK
24 24
25typedef unsigned (*callback_process_op_t)(void *, void *); 25typedef __be32 (*callback_process_op_t)(void *, void *);
26typedef unsigned (*callback_decode_arg_t)(struct svc_rqst *, struct xdr_stream *, void *); 26typedef __be32 (*callback_decode_arg_t)(struct svc_rqst *, struct xdr_stream *, void *);
27typedef unsigned (*callback_encode_res_t)(struct svc_rqst *, struct xdr_stream *, void *); 27typedef __be32 (*callback_encode_res_t)(struct svc_rqst *, struct xdr_stream *, void *);
28 28
29 29
30struct callback_op { 30struct callback_op {
@@ -36,24 +36,24 @@ struct callback_op {
36 36
37static struct callback_op callback_ops[]; 37static struct callback_op callback_ops[];
38 38
39static int nfs4_callback_null(struct svc_rqst *rqstp, void *argp, void *resp) 39static __be32 nfs4_callback_null(struct svc_rqst *rqstp, void *argp, void *resp)
40{ 40{
41 return htonl(NFS4_OK); 41 return htonl(NFS4_OK);
42} 42}
43 43
44static int nfs4_decode_void(struct svc_rqst *rqstp, uint32_t *p, void *dummy) 44static int nfs4_decode_void(struct svc_rqst *rqstp, __be32 *p, void *dummy)
45{ 45{
46 return xdr_argsize_check(rqstp, p); 46 return xdr_argsize_check(rqstp, p);
47} 47}
48 48
49static int nfs4_encode_void(struct svc_rqst *rqstp, uint32_t *p, void *dummy) 49static int nfs4_encode_void(struct svc_rqst *rqstp, __be32 *p, void *dummy)
50{ 50{
51 return xdr_ressize_check(rqstp, p); 51 return xdr_ressize_check(rqstp, p);
52} 52}
53 53
54static uint32_t *read_buf(struct xdr_stream *xdr, int nbytes) 54static __be32 *read_buf(struct xdr_stream *xdr, int nbytes)
55{ 55{
56 uint32_t *p; 56 __be32 *p;
57 57
58 p = xdr_inline_decode(xdr, nbytes); 58 p = xdr_inline_decode(xdr, nbytes);
59 if (unlikely(p == NULL)) 59 if (unlikely(p == NULL))
@@ -61,9 +61,9 @@ static uint32_t *read_buf(struct xdr_stream *xdr, int nbytes)
61 return p; 61 return p;
62} 62}
63 63
64static unsigned decode_string(struct xdr_stream *xdr, unsigned int *len, const char **str) 64static __be32 decode_string(struct xdr_stream *xdr, unsigned int *len, const char **str)
65{ 65{
66 uint32_t *p; 66 __be32 *p;
67 67
68 p = read_buf(xdr, 4); 68 p = read_buf(xdr, 4);
69 if (unlikely(p == NULL)) 69 if (unlikely(p == NULL))
@@ -81,9 +81,9 @@ static unsigned decode_string(struct xdr_stream *xdr, unsigned int *len, const c
81 return 0; 81 return 0;
82} 82}
83 83
84static unsigned decode_fh(struct xdr_stream *xdr, struct nfs_fh *fh) 84static __be32 decode_fh(struct xdr_stream *xdr, struct nfs_fh *fh)
85{ 85{
86 uint32_t *p; 86 __be32 *p;
87 87
88 p = read_buf(xdr, 4); 88 p = read_buf(xdr, 4);
89 if (unlikely(p == NULL)) 89 if (unlikely(p == NULL))
@@ -99,9 +99,9 @@ static unsigned decode_fh(struct xdr_stream *xdr, struct nfs_fh *fh)
99 return 0; 99 return 0;
100} 100}
101 101
102static unsigned decode_bitmap(struct xdr_stream *xdr, uint32_t *bitmap) 102static __be32 decode_bitmap(struct xdr_stream *xdr, uint32_t *bitmap)
103{ 103{
104 uint32_t *p; 104 __be32 *p;
105 unsigned int attrlen; 105 unsigned int attrlen;
106 106
107 p = read_buf(xdr, 4); 107 p = read_buf(xdr, 4);
@@ -118,9 +118,9 @@ static unsigned decode_bitmap(struct xdr_stream *xdr, uint32_t *bitmap)
118 return 0; 118 return 0;
119} 119}
120 120
121static unsigned decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) 121static __be32 decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
122{ 122{
123 uint32_t *p; 123 __be32 *p;
124 124
125 p = read_buf(xdr, 16); 125 p = read_buf(xdr, 16);
126 if (unlikely(p == NULL)) 126 if (unlikely(p == NULL))
@@ -129,11 +129,11 @@ static unsigned decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
129 return 0; 129 return 0;
130} 130}
131 131
132static unsigned decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound_hdr_arg *hdr) 132static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound_hdr_arg *hdr)
133{ 133{
134 uint32_t *p; 134 __be32 *p;
135 unsigned int minor_version; 135 unsigned int minor_version;
136 unsigned status; 136 __be32 status;
137 137
138 status = decode_string(xdr, &hdr->taglen, &hdr->tag); 138 status = decode_string(xdr, &hdr->taglen, &hdr->tag);
139 if (unlikely(status != 0)) 139 if (unlikely(status != 0))
@@ -159,9 +159,9 @@ static unsigned decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compou
159 return 0; 159 return 0;
160} 160}
161 161
162static unsigned decode_op_hdr(struct xdr_stream *xdr, unsigned int *op) 162static __be32 decode_op_hdr(struct xdr_stream *xdr, unsigned int *op)
163{ 163{
164 uint32_t *p; 164 __be32 *p;
165 p = read_buf(xdr, 4); 165 p = read_buf(xdr, 4);
166 if (unlikely(p == NULL)) 166 if (unlikely(p == NULL))
167 return htonl(NFS4ERR_RESOURCE); 167 return htonl(NFS4ERR_RESOURCE);
@@ -169,9 +169,9 @@ static unsigned decode_op_hdr(struct xdr_stream *xdr, unsigned int *op)
169 return 0; 169 return 0;
170} 170}
171 171
172static unsigned decode_getattr_args(struct svc_rqst *rqstp, struct xdr_stream *xdr, struct cb_getattrargs *args) 172static __be32 decode_getattr_args(struct svc_rqst *rqstp, struct xdr_stream *xdr, struct cb_getattrargs *args)
173{ 173{
174 unsigned status; 174 __be32 status;
175 175
176 status = decode_fh(xdr, &args->fh); 176 status = decode_fh(xdr, &args->fh);
177 if (unlikely(status != 0)) 177 if (unlikely(status != 0))
@@ -183,10 +183,10 @@ out:
183 return status; 183 return status;
184} 184}
185 185
186static unsigned decode_recall_args(struct svc_rqst *rqstp, struct xdr_stream *xdr, struct cb_recallargs *args) 186static __be32 decode_recall_args(struct svc_rqst *rqstp, struct xdr_stream *xdr, struct cb_recallargs *args)
187{ 187{
188 uint32_t *p; 188 __be32 *p;
189 unsigned status; 189 __be32 status;
190 190
191 args->addr = &rqstp->rq_addr; 191 args->addr = &rqstp->rq_addr;
192 status = decode_stateid(xdr, &args->stateid); 192 status = decode_stateid(xdr, &args->stateid);
@@ -204,9 +204,9 @@ out:
204 return status; 204 return status;
205} 205}
206 206
207static unsigned encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) 207static __be32 encode_string(struct xdr_stream *xdr, unsigned int len, const char *str)
208{ 208{
209 uint32_t *p; 209 __be32 *p;
210 210
211 p = xdr_reserve_space(xdr, 4 + len); 211 p = xdr_reserve_space(xdr, 4 + len);
212 if (unlikely(p == NULL)) 212 if (unlikely(p == NULL))
@@ -217,10 +217,10 @@ static unsigned encode_string(struct xdr_stream *xdr, unsigned int len, const ch
217 217
218#define CB_SUPPORTED_ATTR0 (FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE) 218#define CB_SUPPORTED_ATTR0 (FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE)
219#define CB_SUPPORTED_ATTR1 (FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY) 219#define CB_SUPPORTED_ATTR1 (FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY)
220static unsigned encode_attr_bitmap(struct xdr_stream *xdr, const uint32_t *bitmap, uint32_t **savep) 220static __be32 encode_attr_bitmap(struct xdr_stream *xdr, const uint32_t *bitmap, __be32 **savep)
221{ 221{
222 uint32_t bm[2]; 222 __be32 bm[2];
223 uint32_t *p; 223 __be32 *p;
224 224
225 bm[0] = htonl(bitmap[0] & CB_SUPPORTED_ATTR0); 225 bm[0] = htonl(bitmap[0] & CB_SUPPORTED_ATTR0);
226 bm[1] = htonl(bitmap[1] & CB_SUPPORTED_ATTR1); 226 bm[1] = htonl(bitmap[1] & CB_SUPPORTED_ATTR1);
@@ -247,9 +247,9 @@ static unsigned encode_attr_bitmap(struct xdr_stream *xdr, const uint32_t *bitma
247 return 0; 247 return 0;
248} 248}
249 249
250static unsigned encode_attr_change(struct xdr_stream *xdr, const uint32_t *bitmap, uint64_t change) 250static __be32 encode_attr_change(struct xdr_stream *xdr, const uint32_t *bitmap, uint64_t change)
251{ 251{
252 uint32_t *p; 252 __be32 *p;
253 253
254 if (!(bitmap[0] & FATTR4_WORD0_CHANGE)) 254 if (!(bitmap[0] & FATTR4_WORD0_CHANGE))
255 return 0; 255 return 0;
@@ -260,9 +260,9 @@ static unsigned encode_attr_change(struct xdr_stream *xdr, const uint32_t *bitma
260 return 0; 260 return 0;
261} 261}
262 262
263static unsigned encode_attr_size(struct xdr_stream *xdr, const uint32_t *bitmap, uint64_t size) 263static __be32 encode_attr_size(struct xdr_stream *xdr, const uint32_t *bitmap, uint64_t size)
264{ 264{
265 uint32_t *p; 265 __be32 *p;
266 266
267 if (!(bitmap[0] & FATTR4_WORD0_SIZE)) 267 if (!(bitmap[0] & FATTR4_WORD0_SIZE))
268 return 0; 268 return 0;
@@ -273,9 +273,9 @@ static unsigned encode_attr_size(struct xdr_stream *xdr, const uint32_t *bitmap,
273 return 0; 273 return 0;
274} 274}
275 275
276static unsigned encode_attr_time(struct xdr_stream *xdr, const struct timespec *time) 276static __be32 encode_attr_time(struct xdr_stream *xdr, const struct timespec *time)
277{ 277{
278 uint32_t *p; 278 __be32 *p;
279 279
280 p = xdr_reserve_space(xdr, 12); 280 p = xdr_reserve_space(xdr, 12);
281 if (unlikely(p == 0)) 281 if (unlikely(p == 0))
@@ -285,23 +285,23 @@ static unsigned encode_attr_time(struct xdr_stream *xdr, const struct timespec *
285 return 0; 285 return 0;
286} 286}
287 287
288static unsigned encode_attr_ctime(struct xdr_stream *xdr, const uint32_t *bitmap, const struct timespec *time) 288static __be32 encode_attr_ctime(struct xdr_stream *xdr, const uint32_t *bitmap, const struct timespec *time)
289{ 289{
290 if (!(bitmap[1] & FATTR4_WORD1_TIME_METADATA)) 290 if (!(bitmap[1] & FATTR4_WORD1_TIME_METADATA))
291 return 0; 291 return 0;
292 return encode_attr_time(xdr,time); 292 return encode_attr_time(xdr,time);
293} 293}
294 294
295static unsigned encode_attr_mtime(struct xdr_stream *xdr, const uint32_t *bitmap, const struct timespec *time) 295static __be32 encode_attr_mtime(struct xdr_stream *xdr, const uint32_t *bitmap, const struct timespec *time)
296{ 296{
297 if (!(bitmap[1] & FATTR4_WORD1_TIME_MODIFY)) 297 if (!(bitmap[1] & FATTR4_WORD1_TIME_MODIFY))
298 return 0; 298 return 0;
299 return encode_attr_time(xdr,time); 299 return encode_attr_time(xdr,time);
300} 300}
301 301
302static unsigned encode_compound_hdr_res(struct xdr_stream *xdr, struct cb_compound_hdr_res *hdr) 302static __be32 encode_compound_hdr_res(struct xdr_stream *xdr, struct cb_compound_hdr_res *hdr)
303{ 303{
304 unsigned status; 304 __be32 status;
305 305
306 hdr->status = xdr_reserve_space(xdr, 4); 306 hdr->status = xdr_reserve_space(xdr, 4);
307 if (unlikely(hdr->status == NULL)) 307 if (unlikely(hdr->status == NULL))
@@ -315,9 +315,9 @@ static unsigned encode_compound_hdr_res(struct xdr_stream *xdr, struct cb_compou
315 return 0; 315 return 0;
316} 316}
317 317
318static unsigned encode_op_hdr(struct xdr_stream *xdr, uint32_t op, uint32_t res) 318static __be32 encode_op_hdr(struct xdr_stream *xdr, uint32_t op, __be32 res)
319{ 319{
320 uint32_t *p; 320 __be32 *p;
321 321
322 p = xdr_reserve_space(xdr, 8); 322 p = xdr_reserve_space(xdr, 8);
323 if (unlikely(p == NULL)) 323 if (unlikely(p == NULL))
@@ -327,10 +327,10 @@ static unsigned encode_op_hdr(struct xdr_stream *xdr, uint32_t op, uint32_t res)
327 return 0; 327 return 0;
328} 328}
329 329
330static unsigned encode_getattr_res(struct svc_rqst *rqstp, struct xdr_stream *xdr, const struct cb_getattrres *res) 330static __be32 encode_getattr_res(struct svc_rqst *rqstp, struct xdr_stream *xdr, const struct cb_getattrres *res)
331{ 331{
332 uint32_t *savep = NULL; 332 __be32 *savep = NULL;
333 unsigned status = res->status; 333 __be32 status = res->status;
334 334
335 if (unlikely(status != 0)) 335 if (unlikely(status != 0))
336 goto out; 336 goto out;
@@ -353,15 +353,15 @@ out:
353 return status; 353 return status;
354} 354}
355 355
356static unsigned process_op(struct svc_rqst *rqstp, 356static __be32 process_op(struct svc_rqst *rqstp,
357 struct xdr_stream *xdr_in, void *argp, 357 struct xdr_stream *xdr_in, void *argp,
358 struct xdr_stream *xdr_out, void *resp) 358 struct xdr_stream *xdr_out, void *resp)
359{ 359{
360 struct callback_op *op = &callback_ops[0]; 360 struct callback_op *op = &callback_ops[0];
361 unsigned int op_nr = OP_CB_ILLEGAL; 361 unsigned int op_nr = OP_CB_ILLEGAL;
362 unsigned int status = 0; 362 __be32 status = 0;
363 long maxlen; 363 long maxlen;
364 unsigned res; 364 __be32 res;
365 365
366 dprintk("%s: start\n", __FUNCTION__); 366 dprintk("%s: start\n", __FUNCTION__);
367 status = decode_op_hdr(xdr_in, &op_nr); 367 status = decode_op_hdr(xdr_in, &op_nr);
@@ -399,20 +399,20 @@ static unsigned process_op(struct svc_rqst *rqstp,
399/* 399/*
400 * Decode, process and encode a COMPOUND 400 * Decode, process and encode a COMPOUND
401 */ 401 */
402static int nfs4_callback_compound(struct svc_rqst *rqstp, void *argp, void *resp) 402static __be32 nfs4_callback_compound(struct svc_rqst *rqstp, void *argp, void *resp)
403{ 403{
404 struct cb_compound_hdr_arg hdr_arg; 404 struct cb_compound_hdr_arg hdr_arg;
405 struct cb_compound_hdr_res hdr_res; 405 struct cb_compound_hdr_res hdr_res;
406 struct xdr_stream xdr_in, xdr_out; 406 struct xdr_stream xdr_in, xdr_out;
407 uint32_t *p; 407 __be32 *p;
408 unsigned int status; 408 __be32 status;
409 unsigned int nops = 1; 409 unsigned int nops = 1;
410 410
411 dprintk("%s: start\n", __FUNCTION__); 411 dprintk("%s: start\n", __FUNCTION__);
412 412
413 xdr_init_decode(&xdr_in, &rqstp->rq_arg, rqstp->rq_arg.head[0].iov_base); 413 xdr_init_decode(&xdr_in, &rqstp->rq_arg, rqstp->rq_arg.head[0].iov_base);
414 414
415 p = (uint32_t*)((char *)rqstp->rq_res.head[0].iov_base + rqstp->rq_res.head[0].iov_len); 415 p = (__be32*)((char *)rqstp->rq_res.head[0].iov_base + rqstp->rq_res.head[0].iov_len);
416 xdr_init_encode(&xdr_out, &rqstp->rq_res, p); 416 xdr_init_encode(&xdr_out, &rqstp->rq_res, p);
417 417
418 decode_compound_hdr_arg(&xdr_in, &hdr_arg); 418 decode_compound_hdr_arg(&xdr_in, &hdr_arg);
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 34c3996bd0f5..5fea638743e4 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -232,11 +232,15 @@ void nfs_put_client(struct nfs_client *clp)
232 * Find a client by address 232 * Find a client by address
233 * - caller must hold nfs_client_lock 233 * - caller must hold nfs_client_lock
234 */ 234 */
235static struct nfs_client *__nfs_find_client(const struct sockaddr_in *addr, int nfsversion) 235static struct nfs_client *__nfs_find_client(const struct sockaddr_in *addr, int nfsversion, int match_port)
236{ 236{
237 struct nfs_client *clp; 237 struct nfs_client *clp;
238 238
239 list_for_each_entry(clp, &nfs_client_list, cl_share_link) { 239 list_for_each_entry(clp, &nfs_client_list, cl_share_link) {
240 /* Don't match clients that failed to initialise properly */
241 if (clp->cl_cons_state < 0)
242 continue;
243
240 /* Different NFS versions cannot share the same nfs_client */ 244 /* Different NFS versions cannot share the same nfs_client */
241 if (clp->cl_nfsversion != nfsversion) 245 if (clp->cl_nfsversion != nfsversion)
242 continue; 246 continue;
@@ -245,7 +249,7 @@ static struct nfs_client *__nfs_find_client(const struct sockaddr_in *addr, int
245 sizeof(clp->cl_addr.sin_addr)) != 0) 249 sizeof(clp->cl_addr.sin_addr)) != 0)
246 continue; 250 continue;
247 251
248 if (clp->cl_addr.sin_port == addr->sin_port) 252 if (!match_port || clp->cl_addr.sin_port == addr->sin_port)
249 goto found; 253 goto found;
250 } 254 }
251 255
@@ -265,11 +269,12 @@ struct nfs_client *nfs_find_client(const struct sockaddr_in *addr, int nfsversio
265 struct nfs_client *clp; 269 struct nfs_client *clp;
266 270
267 spin_lock(&nfs_client_lock); 271 spin_lock(&nfs_client_lock);
268 clp = __nfs_find_client(addr, nfsversion); 272 clp = __nfs_find_client(addr, nfsversion, 0);
269 spin_unlock(&nfs_client_lock); 273 spin_unlock(&nfs_client_lock);
270 274 if (clp != NULL && clp->cl_cons_state != NFS_CS_READY) {
271 BUG_ON(clp && clp->cl_cons_state == 0); 275 nfs_put_client(clp);
272 276 clp = NULL;
277 }
273 return clp; 278 return clp;
274} 279}
275 280
@@ -292,7 +297,7 @@ static struct nfs_client *nfs_get_client(const char *hostname,
292 do { 297 do {
293 spin_lock(&nfs_client_lock); 298 spin_lock(&nfs_client_lock);
294 299
295 clp = __nfs_find_client(addr, nfsversion); 300 clp = __nfs_find_client(addr, nfsversion, 1);
296 if (clp) 301 if (clp)
297 goto found_client; 302 goto found_client;
298 if (new) 303 if (new)
@@ -849,6 +854,7 @@ error:
849 */ 854 */
850static int nfs4_init_client(struct nfs_client *clp, 855static int nfs4_init_client(struct nfs_client *clp,
851 int proto, int timeo, int retrans, 856 int proto, int timeo, int retrans,
857 const char *ip_addr,
852 rpc_authflavor_t authflavour) 858 rpc_authflavor_t authflavour)
853{ 859{
854 int error; 860 int error;
@@ -865,6 +871,7 @@ static int nfs4_init_client(struct nfs_client *clp,
865 error = nfs_create_rpc_client(clp, proto, timeo, retrans, authflavour); 871 error = nfs_create_rpc_client(clp, proto, timeo, retrans, authflavour);
866 if (error < 0) 872 if (error < 0)
867 goto error; 873 goto error;
874 memcpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr));
868 875
869 error = nfs_idmap_new(clp); 876 error = nfs_idmap_new(clp);
870 if (error < 0) { 877 if (error < 0) {
@@ -888,6 +895,7 @@ error:
888 */ 895 */
889static int nfs4_set_client(struct nfs_server *server, 896static int nfs4_set_client(struct nfs_server *server,
890 const char *hostname, const struct sockaddr_in *addr, 897 const char *hostname, const struct sockaddr_in *addr,
898 const char *ip_addr,
891 rpc_authflavor_t authflavour, 899 rpc_authflavor_t authflavour,
892 int proto, int timeo, int retrans) 900 int proto, int timeo, int retrans)
893{ 901{
@@ -902,7 +910,7 @@ static int nfs4_set_client(struct nfs_server *server,
902 error = PTR_ERR(clp); 910 error = PTR_ERR(clp);
903 goto error; 911 goto error;
904 } 912 }
905 error = nfs4_init_client(clp, proto, timeo, retrans, authflavour); 913 error = nfs4_init_client(clp, proto, timeo, retrans, ip_addr, authflavour);
906 if (error < 0) 914 if (error < 0)
907 goto error_put; 915 goto error_put;
908 916
@@ -971,7 +979,7 @@ struct nfs_server *nfs4_create_server(const struct nfs4_mount_data *data,
971 return ERR_PTR(-ENOMEM); 979 return ERR_PTR(-ENOMEM);
972 980
973 /* Get a client record */ 981 /* Get a client record */
974 error = nfs4_set_client(server, hostname, addr, authflavour, 982 error = nfs4_set_client(server, hostname, addr, ip_addr, authflavour,
975 data->proto, data->timeo, data->retrans); 983 data->proto, data->timeo, data->retrans);
976 if (error < 0) 984 if (error < 0)
977 goto error; 985 goto error;
@@ -1041,6 +1049,7 @@ struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data,
1041 /* Get a client representation. 1049 /* Get a client representation.
1042 * Note: NFSv4 always uses TCP, */ 1050 * Note: NFSv4 always uses TCP, */
1043 error = nfs4_set_client(server, data->hostname, data->addr, 1051 error = nfs4_set_client(server, data->hostname, data->addr,
1052 parent_client->cl_ipaddr,
1044 data->authflavor, 1053 data->authflavor,
1045 parent_server->client->cl_xprt->prot, 1054 parent_server->client->cl_xprt->prot,
1046 parent_client->retrans_timeo, 1055 parent_client->retrans_timeo,
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 481f8892a919..b34cd16f472f 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -142,12 +142,12 @@ nfs_opendir(struct inode *inode, struct file *filp)
142 return res; 142 return res;
143} 143}
144 144
145typedef u32 * (*decode_dirent_t)(u32 *, struct nfs_entry *, int); 145typedef __be32 * (*decode_dirent_t)(__be32 *, struct nfs_entry *, int);
146typedef struct { 146typedef struct {
147 struct file *file; 147 struct file *file;
148 struct page *page; 148 struct page *page;
149 unsigned long page_index; 149 unsigned long page_index;
150 u32 *ptr; 150 __be32 *ptr;
151 u64 *dir_cookie; 151 u64 *dir_cookie;
152 loff_t current_index; 152 loff_t current_index;
153 struct nfs_entry *entry; 153 struct nfs_entry *entry;
@@ -203,8 +203,10 @@ int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page *page)
203 * Note: assumes we have exclusive access to this mapping either 203 * Note: assumes we have exclusive access to this mapping either
204 * through inode->i_mutex or some other mechanism. 204 * through inode->i_mutex or some other mechanism.
205 */ 205 */
206 if (page->index == 0) 206 if (page->index == 0 && invalidate_inode_pages2_range(inode->i_mapping, PAGE_CACHE_SIZE, -1) < 0) {
207 invalidate_inode_pages2_range(inode->i_mapping, PAGE_CACHE_SIZE, -1); 207 /* Should never happen */
208 nfs_zap_mapping(inode, inode->i_mapping);
209 }
208 unlock_page(page); 210 unlock_page(page);
209 return 0; 211 return 0;
210 error: 212 error:
@@ -218,7 +220,7 @@ int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page *page)
218static inline 220static inline
219int dir_decode(nfs_readdir_descriptor_t *desc) 221int dir_decode(nfs_readdir_descriptor_t *desc)
220{ 222{
221 u32 *p = desc->ptr; 223 __be32 *p = desc->ptr;
222 p = desc->decode(p, desc->entry, desc->plus); 224 p = desc->decode(p, desc->entry, desc->plus);
223 if (IS_ERR(p)) 225 if (IS_ERR(p))
224 return PTR_ERR(p); 226 return PTR_ERR(p);
@@ -933,8 +935,17 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru
933 935
934no_entry: 936no_entry:
935 res = d_materialise_unique(dentry, inode); 937 res = d_materialise_unique(dentry, inode);
936 if (res != NULL) 938 if (res != NULL) {
939 struct dentry *parent;
940 if (IS_ERR(res))
941 goto out_unlock;
942 /* Was a directory renamed! */
943 parent = dget_parent(res);
944 if (!IS_ROOT(parent))
945 nfs_mark_for_revalidate(parent->d_inode);
946 dput(parent);
937 dentry = res; 947 dentry = res;
948 }
938 nfs_renew_times(dentry); 949 nfs_renew_times(dentry);
939 nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); 950 nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
940out_unlock: 951out_unlock:
@@ -1130,6 +1141,8 @@ static struct dentry *nfs_readdir_lookup(nfs_readdir_descriptor_t *desc)
1130 alias = d_materialise_unique(dentry, inode); 1141 alias = d_materialise_unique(dentry, inode);
1131 if (alias != NULL) { 1142 if (alias != NULL) {
1132 dput(dentry); 1143 dput(dentry);
1144 if (IS_ERR(alias))
1145 return NULL;
1133 dentry = alias; 1146 dentry = alias;
1134 } 1147 }
1135 1148
@@ -1517,8 +1530,8 @@ static int nfs_symlink(struct inode *dir, struct dentry *dentry, const char *sym
1517 pagevec_init(&lru_pvec, 0); 1530 pagevec_init(&lru_pvec, 0);
1518 if (!add_to_page_cache(page, dentry->d_inode->i_mapping, 0, 1531 if (!add_to_page_cache(page, dentry->d_inode->i_mapping, 0,
1519 GFP_KERNEL)) { 1532 GFP_KERNEL)) {
1520 if (!pagevec_add(&lru_pvec, page)) 1533 pagevec_add(&lru_pvec, page);
1521 __pagevec_lru_add(&lru_pvec); 1534 pagevec_lru_add(&lru_pvec);
1522 SetPageUptodate(page); 1535 SetPageUptodate(page);
1523 unlock_page(page); 1536 unlock_page(page);
1524 } else 1537 } else
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 9f7f8b9ea1e2..bdfabf854a51 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -497,6 +497,7 @@ static void nfs_direct_write_complete(struct nfs_direct_req *dreq, struct inode
497 if (dreq->commit_data != NULL) 497 if (dreq->commit_data != NULL)
498 nfs_commit_free(dreq->commit_data); 498 nfs_commit_free(dreq->commit_data);
499 nfs_direct_free_writedata(dreq); 499 nfs_direct_free_writedata(dreq);
500 nfs_zap_mapping(inode, inode->i_mapping);
500 nfs_direct_complete(dreq); 501 nfs_direct_complete(dreq);
501 } 502 }
502} 503}
@@ -517,6 +518,7 @@ static void nfs_direct_write_complete(struct nfs_direct_req *dreq, struct inode
517{ 518{
518 nfs_end_data_update(inode); 519 nfs_end_data_update(inode);
519 nfs_direct_free_writedata(dreq); 520 nfs_direct_free_writedata(dreq);
521 nfs_zap_mapping(inode, inode->i_mapping);
520 nfs_direct_complete(dreq); 522 nfs_direct_complete(dreq);
521} 523}
522#endif 524#endif
@@ -532,10 +534,12 @@ static void nfs_direct_write_result(struct rpc_task *task, void *calldata)
532 534
533 spin_lock(&dreq->lock); 535 spin_lock(&dreq->lock);
534 536
535 if (likely(status >= 0)) 537 if (unlikely(status < 0)) {
536 dreq->count += data->res.count; 538 dreq->error = status;
537 else 539 goto out_unlock;
538 dreq->error = task->tk_status; 540 }
541
542 dreq->count += data->res.count;
539 543
540 if (data->res.verf->committed != NFS_FILE_SYNC) { 544 if (data->res.verf->committed != NFS_FILE_SYNC) {
541 switch (dreq->flags) { 545 switch (dreq->flags) {
@@ -550,7 +554,7 @@ static void nfs_direct_write_result(struct rpc_task *task, void *calldata)
550 } 554 }
551 } 555 }
552 } 556 }
553 557out_unlock:
554 spin_unlock(&dreq->lock); 558 spin_unlock(&dreq->lock);
555} 559}
556 560
@@ -828,17 +832,6 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, const struct iovec *iov,
828 832
829 retval = nfs_direct_write(iocb, (unsigned long) buf, count, pos); 833 retval = nfs_direct_write(iocb, (unsigned long) buf, count, pos);
830 834
831 /*
832 * XXX: nfs_end_data_update() already ensures this file's
833 * cached data is subsequently invalidated. Do we really
834 * need to call invalidate_inode_pages2() again here?
835 *
836 * For aio writes, this invalidation will almost certainly
837 * occur before the writes complete. Kind of racey.
838 */
839 if (mapping->nrpages)
840 invalidate_inode_pages2(mapping);
841
842 if (retval > 0) 835 if (retval > 0)
843 iocb->ki_pos = pos + retval; 836 iocb->ki_pos = pos + retval;
844 837
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index bc9376ca86cd..08cc4c5919ab 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -131,6 +131,15 @@ void nfs_zap_caches(struct inode *inode)
131 spin_unlock(&inode->i_lock); 131 spin_unlock(&inode->i_lock);
132} 132}
133 133
134void nfs_zap_mapping(struct inode *inode, struct address_space *mapping)
135{
136 if (mapping->nrpages != 0) {
137 spin_lock(&inode->i_lock);
138 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_DATA;
139 spin_unlock(&inode->i_lock);
140 }
141}
142
134static void nfs_zap_acl_cache(struct inode *inode) 143static void nfs_zap_acl_cache(struct inode *inode)
135{ 144{
136 void (*clear_acl_cache)(struct inode *); 145 void (*clear_acl_cache)(struct inode *);
@@ -574,7 +583,7 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode)
574 583
575 nfs_inc_stats(inode, NFSIOS_INODEREVALIDATE); 584 nfs_inc_stats(inode, NFSIOS_INODEREVALIDATE);
576 lock_kernel(); 585 lock_kernel();
577 if (!inode || is_bad_inode(inode)) 586 if (is_bad_inode(inode))
578 goto out_nowait; 587 goto out_nowait;
579 if (NFS_STALE(inode)) 588 if (NFS_STALE(inode))
580 goto out_nowait; 589 goto out_nowait;
@@ -671,13 +680,20 @@ int nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping)
671 if ((nfsi->cache_validity & NFS_INO_REVAL_PAGECACHE) 680 if ((nfsi->cache_validity & NFS_INO_REVAL_PAGECACHE)
672 || nfs_attribute_timeout(inode)) 681 || nfs_attribute_timeout(inode))
673 ret = __nfs_revalidate_inode(NFS_SERVER(inode), inode); 682 ret = __nfs_revalidate_inode(NFS_SERVER(inode), inode);
683 if (ret < 0)
684 goto out;
674 685
675 if (nfsi->cache_validity & NFS_INO_INVALID_DATA) { 686 if (nfsi->cache_validity & NFS_INO_INVALID_DATA) {
676 nfs_inc_stats(inode, NFSIOS_DATAINVALIDATE); 687 if (mapping->nrpages != 0) {
677 if (S_ISREG(inode->i_mode)) 688 if (S_ISREG(inode->i_mode)) {
678 nfs_sync_mapping(mapping); 689 ret = nfs_sync_mapping(mapping);
679 invalidate_inode_pages2(mapping); 690 if (ret < 0)
680 691 goto out;
692 }
693 ret = invalidate_inode_pages2(mapping);
694 if (ret < 0)
695 goto out;
696 }
681 spin_lock(&inode->i_lock); 697 spin_lock(&inode->i_lock);
682 nfsi->cache_validity &= ~NFS_INO_INVALID_DATA; 698 nfsi->cache_validity &= ~NFS_INO_INVALID_DATA;
683 if (S_ISDIR(inode->i_mode)) { 699 if (S_ISDIR(inode->i_mode)) {
@@ -687,10 +703,12 @@ int nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping)
687 } 703 }
688 spin_unlock(&inode->i_lock); 704 spin_unlock(&inode->i_lock);
689 705
706 nfs_inc_stats(inode, NFSIOS_DATAINVALIDATE);
690 dfprintk(PAGECACHE, "NFS: (%s/%Ld) data cache invalidated\n", 707 dfprintk(PAGECACHE, "NFS: (%s/%Ld) data cache invalidated\n",
691 inode->i_sb->s_id, 708 inode->i_sb->s_id,
692 (long long)NFS_FILEID(inode)); 709 (long long)NFS_FILEID(inode));
693 } 710 }
711out:
694 return ret; 712 return ret;
695} 713}
696 714
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index bea0b016bd70..d205466233f6 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -93,15 +93,15 @@ extern void nfs_destroy_directcache(void);
93/* nfs2xdr.c */ 93/* nfs2xdr.c */
94extern int nfs_stat_to_errno(int); 94extern int nfs_stat_to_errno(int);
95extern struct rpc_procinfo nfs_procedures[]; 95extern struct rpc_procinfo nfs_procedures[];
96extern u32 * nfs_decode_dirent(u32 *, struct nfs_entry *, int); 96extern __be32 * nfs_decode_dirent(__be32 *, struct nfs_entry *, int);
97 97
98/* nfs3xdr.c */ 98/* nfs3xdr.c */
99extern struct rpc_procinfo nfs3_procedures[]; 99extern struct rpc_procinfo nfs3_procedures[];
100extern u32 *nfs3_decode_dirent(u32 *, struct nfs_entry *, int); 100extern __be32 *nfs3_decode_dirent(__be32 *, struct nfs_entry *, int);
101 101
102/* nfs4xdr.c */ 102/* nfs4xdr.c */
103#ifdef CONFIG_NFS_V4 103#ifdef CONFIG_NFS_V4
104extern u32 *nfs4_decode_dirent(u32 *p, struct nfs_entry *entry, int plus); 104extern __be32 *nfs4_decode_dirent(__be32 *p, struct nfs_entry *entry, int plus);
105#endif 105#endif
106 106
107/* nfs4proc.c */ 107/* nfs4proc.c */
diff --git a/fs/nfs/mount_clnt.c b/fs/nfs/mount_clnt.c
index d507b021207f..f75fe72b4160 100644
--- a/fs/nfs/mount_clnt.c
+++ b/fs/nfs/mount_clnt.c
@@ -95,7 +95,7 @@ mnt_create(char *hostname, struct sockaddr_in *srvaddr, int version,
95 * XDR encode/decode functions for MOUNT 95 * XDR encode/decode functions for MOUNT
96 */ 96 */
97static int 97static int
98xdr_encode_dirpath(struct rpc_rqst *req, u32 *p, const char *path) 98xdr_encode_dirpath(struct rpc_rqst *req, __be32 *p, const char *path)
99{ 99{
100 p = xdr_encode_string(p, path); 100 p = xdr_encode_string(p, path);
101 101
@@ -104,7 +104,7 @@ xdr_encode_dirpath(struct rpc_rqst *req, u32 *p, const char *path)
104} 104}
105 105
106static int 106static int
107xdr_decode_fhstatus(struct rpc_rqst *req, u32 *p, struct mnt_fhstatus *res) 107xdr_decode_fhstatus(struct rpc_rqst *req, __be32 *p, struct mnt_fhstatus *res)
108{ 108{
109 struct nfs_fh *fh = res->fh; 109 struct nfs_fh *fh = res->fh;
110 110
@@ -116,7 +116,7 @@ xdr_decode_fhstatus(struct rpc_rqst *req, u32 *p, struct mnt_fhstatus *res)
116} 116}
117 117
118static int 118static int
119xdr_decode_fhstatus3(struct rpc_rqst *req, u32 *p, struct mnt_fhstatus *res) 119xdr_decode_fhstatus3(struct rpc_rqst *req, __be32 *p, struct mnt_fhstatus *res)
120{ 120{
121 struct nfs_fh *fh = res->fh; 121 struct nfs_fh *fh = res->fh;
122 122
diff --git a/fs/nfs/nfs2xdr.c b/fs/nfs/nfs2xdr.c
index b49501fc0a79..3be4e72a0227 100644
--- a/fs/nfs/nfs2xdr.c
+++ b/fs/nfs/nfs2xdr.c
@@ -66,15 +66,15 @@
66/* 66/*
67 * Common NFS XDR functions as inlines 67 * Common NFS XDR functions as inlines
68 */ 68 */
69static inline u32 * 69static inline __be32 *
70xdr_encode_fhandle(u32 *p, struct nfs_fh *fhandle) 70xdr_encode_fhandle(__be32 *p, struct nfs_fh *fhandle)
71{ 71{
72 memcpy(p, fhandle->data, NFS2_FHSIZE); 72 memcpy(p, fhandle->data, NFS2_FHSIZE);
73 return p + XDR_QUADLEN(NFS2_FHSIZE); 73 return p + XDR_QUADLEN(NFS2_FHSIZE);
74} 74}
75 75
76static inline u32 * 76static inline __be32 *
77xdr_decode_fhandle(u32 *p, struct nfs_fh *fhandle) 77xdr_decode_fhandle(__be32 *p, struct nfs_fh *fhandle)
78{ 78{
79 /* NFSv2 handles have a fixed length */ 79 /* NFSv2 handles have a fixed length */
80 fhandle->size = NFS2_FHSIZE; 80 fhandle->size = NFS2_FHSIZE;
@@ -82,8 +82,8 @@ xdr_decode_fhandle(u32 *p, struct nfs_fh *fhandle)
82 return p + XDR_QUADLEN(NFS2_FHSIZE); 82 return p + XDR_QUADLEN(NFS2_FHSIZE);
83} 83}
84 84
85static inline u32* 85static inline __be32*
86xdr_encode_time(u32 *p, struct timespec *timep) 86xdr_encode_time(__be32 *p, struct timespec *timep)
87{ 87{
88 *p++ = htonl(timep->tv_sec); 88 *p++ = htonl(timep->tv_sec);
89 /* Convert nanoseconds into microseconds */ 89 /* Convert nanoseconds into microseconds */
@@ -91,8 +91,8 @@ xdr_encode_time(u32 *p, struct timespec *timep)
91 return p; 91 return p;
92} 92}
93 93
94static inline u32* 94static inline __be32*
95xdr_encode_current_server_time(u32 *p, struct timespec *timep) 95xdr_encode_current_server_time(__be32 *p, struct timespec *timep)
96{ 96{
97 /* 97 /*
98 * Passing the invalid value useconds=1000000 is a 98 * Passing the invalid value useconds=1000000 is a
@@ -108,8 +108,8 @@ xdr_encode_current_server_time(u32 *p, struct timespec *timep)
108 return p; 108 return p;
109} 109}
110 110
111static inline u32* 111static inline __be32*
112xdr_decode_time(u32 *p, struct timespec *timep) 112xdr_decode_time(__be32 *p, struct timespec *timep)
113{ 113{
114 timep->tv_sec = ntohl(*p++); 114 timep->tv_sec = ntohl(*p++);
115 /* Convert microseconds into nanoseconds */ 115 /* Convert microseconds into nanoseconds */
@@ -117,8 +117,8 @@ xdr_decode_time(u32 *p, struct timespec *timep)
117 return p; 117 return p;
118} 118}
119 119
120static u32 * 120static __be32 *
121xdr_decode_fattr(u32 *p, struct nfs_fattr *fattr) 121xdr_decode_fattr(__be32 *p, struct nfs_fattr *fattr)
122{ 122{
123 u32 rdev; 123 u32 rdev;
124 fattr->type = (enum nfs_ftype) ntohl(*p++); 124 fattr->type = (enum nfs_ftype) ntohl(*p++);
@@ -146,10 +146,10 @@ xdr_decode_fattr(u32 *p, struct nfs_fattr *fattr)
146 return p; 146 return p;
147} 147}
148 148
149static inline u32 * 149static inline __be32 *
150xdr_encode_sattr(u32 *p, struct iattr *attr) 150xdr_encode_sattr(__be32 *p, struct iattr *attr)
151{ 151{
152 const u32 not_set = __constant_htonl(0xFFFFFFFF); 152 const __be32 not_set = __constant_htonl(0xFFFFFFFF);
153 153
154 *p++ = (attr->ia_valid & ATTR_MODE) ? htonl(attr->ia_mode) : not_set; 154 *p++ = (attr->ia_valid & ATTR_MODE) ? htonl(attr->ia_mode) : not_set;
155 *p++ = (attr->ia_valid & ATTR_UID) ? htonl(attr->ia_uid) : not_set; 155 *p++ = (attr->ia_valid & ATTR_UID) ? htonl(attr->ia_uid) : not_set;
@@ -184,7 +184,7 @@ xdr_encode_sattr(u32 *p, struct iattr *attr)
184 * GETATTR, READLINK, STATFS 184 * GETATTR, READLINK, STATFS
185 */ 185 */
186static int 186static int
187nfs_xdr_fhandle(struct rpc_rqst *req, u32 *p, struct nfs_fh *fh) 187nfs_xdr_fhandle(struct rpc_rqst *req, __be32 *p, struct nfs_fh *fh)
188{ 188{
189 p = xdr_encode_fhandle(p, fh); 189 p = xdr_encode_fhandle(p, fh);
190 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p); 190 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
@@ -195,7 +195,7 @@ nfs_xdr_fhandle(struct rpc_rqst *req, u32 *p, struct nfs_fh *fh)
195 * Encode SETATTR arguments 195 * Encode SETATTR arguments
196 */ 196 */
197static int 197static int
198nfs_xdr_sattrargs(struct rpc_rqst *req, u32 *p, struct nfs_sattrargs *args) 198nfs_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs_sattrargs *args)
199{ 199{
200 p = xdr_encode_fhandle(p, args->fh); 200 p = xdr_encode_fhandle(p, args->fh);
201 p = xdr_encode_sattr(p, args->sattr); 201 p = xdr_encode_sattr(p, args->sattr);
@@ -208,7 +208,7 @@ nfs_xdr_sattrargs(struct rpc_rqst *req, u32 *p, struct nfs_sattrargs *args)
208 * LOOKUP, REMOVE, RMDIR 208 * LOOKUP, REMOVE, RMDIR
209 */ 209 */
210static int 210static int
211nfs_xdr_diropargs(struct rpc_rqst *req, u32 *p, struct nfs_diropargs *args) 211nfs_xdr_diropargs(struct rpc_rqst *req, __be32 *p, struct nfs_diropargs *args)
212{ 212{
213 p = xdr_encode_fhandle(p, args->fh); 213 p = xdr_encode_fhandle(p, args->fh);
214 p = xdr_encode_array(p, args->name, args->len); 214 p = xdr_encode_array(p, args->name, args->len);
@@ -222,7 +222,7 @@ nfs_xdr_diropargs(struct rpc_rqst *req, u32 *p, struct nfs_diropargs *args)
222 * exactly to the page we want to fetch. 222 * exactly to the page we want to fetch.
223 */ 223 */
224static int 224static int
225nfs_xdr_readargs(struct rpc_rqst *req, u32 *p, struct nfs_readargs *args) 225nfs_xdr_readargs(struct rpc_rqst *req, __be32 *p, struct nfs_readargs *args)
226{ 226{
227 struct rpc_auth *auth = req->rq_task->tk_auth; 227 struct rpc_auth *auth = req->rq_task->tk_auth;
228 unsigned int replen; 228 unsigned int replen;
@@ -246,7 +246,7 @@ nfs_xdr_readargs(struct rpc_rqst *req, u32 *p, struct nfs_readargs *args)
246 * Decode READ reply 246 * Decode READ reply
247 */ 247 */
248static int 248static int
249nfs_xdr_readres(struct rpc_rqst *req, u32 *p, struct nfs_readres *res) 249nfs_xdr_readres(struct rpc_rqst *req, __be32 *p, struct nfs_readres *res)
250{ 250{
251 struct kvec *iov = req->rq_rcv_buf.head; 251 struct kvec *iov = req->rq_rcv_buf.head;
252 int status, count, recvd, hdrlen; 252 int status, count, recvd, hdrlen;
@@ -286,7 +286,7 @@ nfs_xdr_readres(struct rpc_rqst *req, u32 *p, struct nfs_readres *res)
286 * Write arguments. Splice the buffer to be written into the iovec. 286 * Write arguments. Splice the buffer to be written into the iovec.
287 */ 287 */
288static int 288static int
289nfs_xdr_writeargs(struct rpc_rqst *req, u32 *p, struct nfs_writeargs *args) 289nfs_xdr_writeargs(struct rpc_rqst *req, __be32 *p, struct nfs_writeargs *args)
290{ 290{
291 struct xdr_buf *sndbuf = &req->rq_snd_buf; 291 struct xdr_buf *sndbuf = &req->rq_snd_buf;
292 u32 offset = (u32)args->offset; 292 u32 offset = (u32)args->offset;
@@ -309,7 +309,7 @@ nfs_xdr_writeargs(struct rpc_rqst *req, u32 *p, struct nfs_writeargs *args)
309 * CREATE, MKDIR 309 * CREATE, MKDIR
310 */ 310 */
311static int 311static int
312nfs_xdr_createargs(struct rpc_rqst *req, u32 *p, struct nfs_createargs *args) 312nfs_xdr_createargs(struct rpc_rqst *req, __be32 *p, struct nfs_createargs *args)
313{ 313{
314 p = xdr_encode_fhandle(p, args->fh); 314 p = xdr_encode_fhandle(p, args->fh);
315 p = xdr_encode_array(p, args->name, args->len); 315 p = xdr_encode_array(p, args->name, args->len);
@@ -322,7 +322,7 @@ nfs_xdr_createargs(struct rpc_rqst *req, u32 *p, struct nfs_createargs *args)
322 * Encode RENAME arguments 322 * Encode RENAME arguments
323 */ 323 */
324static int 324static int
325nfs_xdr_renameargs(struct rpc_rqst *req, u32 *p, struct nfs_renameargs *args) 325nfs_xdr_renameargs(struct rpc_rqst *req, __be32 *p, struct nfs_renameargs *args)
326{ 326{
327 p = xdr_encode_fhandle(p, args->fromfh); 327 p = xdr_encode_fhandle(p, args->fromfh);
328 p = xdr_encode_array(p, args->fromname, args->fromlen); 328 p = xdr_encode_array(p, args->fromname, args->fromlen);
@@ -336,7 +336,7 @@ nfs_xdr_renameargs(struct rpc_rqst *req, u32 *p, struct nfs_renameargs *args)
336 * Encode LINK arguments 336 * Encode LINK arguments
337 */ 337 */
338static int 338static int
339nfs_xdr_linkargs(struct rpc_rqst *req, u32 *p, struct nfs_linkargs *args) 339nfs_xdr_linkargs(struct rpc_rqst *req, __be32 *p, struct nfs_linkargs *args)
340{ 340{
341 p = xdr_encode_fhandle(p, args->fromfh); 341 p = xdr_encode_fhandle(p, args->fromfh);
342 p = xdr_encode_fhandle(p, args->tofh); 342 p = xdr_encode_fhandle(p, args->tofh);
@@ -349,7 +349,7 @@ nfs_xdr_linkargs(struct rpc_rqst *req, u32 *p, struct nfs_linkargs *args)
349 * Encode SYMLINK arguments 349 * Encode SYMLINK arguments
350 */ 350 */
351static int 351static int
352nfs_xdr_symlinkargs(struct rpc_rqst *req, u32 *p, struct nfs_symlinkargs *args) 352nfs_xdr_symlinkargs(struct rpc_rqst *req, __be32 *p, struct nfs_symlinkargs *args)
353{ 353{
354 struct xdr_buf *sndbuf = &req->rq_snd_buf; 354 struct xdr_buf *sndbuf = &req->rq_snd_buf;
355 size_t pad; 355 size_t pad;
@@ -378,7 +378,7 @@ nfs_xdr_symlinkargs(struct rpc_rqst *req, u32 *p, struct nfs_symlinkargs *args)
378 * Encode arguments to readdir call 378 * Encode arguments to readdir call
379 */ 379 */
380static int 380static int
381nfs_xdr_readdirargs(struct rpc_rqst *req, u32 *p, struct nfs_readdirargs *args) 381nfs_xdr_readdirargs(struct rpc_rqst *req, __be32 *p, struct nfs_readdirargs *args)
382{ 382{
383 struct rpc_task *task = req->rq_task; 383 struct rpc_task *task = req->rq_task;
384 struct rpc_auth *auth = task->tk_auth; 384 struct rpc_auth *auth = task->tk_auth;
@@ -404,7 +404,7 @@ nfs_xdr_readdirargs(struct rpc_rqst *req, u32 *p, struct nfs_readdirargs *args)
404 * from nfs_readdir for each entry. 404 * from nfs_readdir for each entry.
405 */ 405 */
406static int 406static int
407nfs_xdr_readdirres(struct rpc_rqst *req, u32 *p, void *dummy) 407nfs_xdr_readdirres(struct rpc_rqst *req, __be32 *p, void *dummy)
408{ 408{
409 struct xdr_buf *rcvbuf = &req->rq_rcv_buf; 409 struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
410 struct kvec *iov = rcvbuf->head; 410 struct kvec *iov = rcvbuf->head;
@@ -412,7 +412,7 @@ nfs_xdr_readdirres(struct rpc_rqst *req, u32 *p, void *dummy)
412 int hdrlen, recvd; 412 int hdrlen, recvd;
413 int status, nr; 413 int status, nr;
414 unsigned int len, pglen; 414 unsigned int len, pglen;
415 u32 *end, *entry, *kaddr; 415 __be32 *end, *entry, *kaddr;
416 416
417 if ((status = ntohl(*p++))) 417 if ((status = ntohl(*p++)))
418 return -nfs_stat_to_errno(status); 418 return -nfs_stat_to_errno(status);
@@ -432,8 +432,8 @@ nfs_xdr_readdirres(struct rpc_rqst *req, u32 *p, void *dummy)
432 if (pglen > recvd) 432 if (pglen > recvd)
433 pglen = recvd; 433 pglen = recvd;
434 page = rcvbuf->pages; 434 page = rcvbuf->pages;
435 kaddr = p = (u32 *)kmap_atomic(*page, KM_USER0); 435 kaddr = p = kmap_atomic(*page, KM_USER0);
436 end = (u32 *)((char *)p + pglen); 436 end = (__be32 *)((char *)p + pglen);
437 entry = p; 437 entry = p;
438 for (nr = 0; *p++; nr++) { 438 for (nr = 0; *p++; nr++) {
439 if (p + 2 > end) 439 if (p + 2 > end)
@@ -468,8 +468,8 @@ err_unmap:
468 goto out; 468 goto out;
469} 469}
470 470
471u32 * 471__be32 *
472nfs_decode_dirent(u32 *p, struct nfs_entry *entry, int plus) 472nfs_decode_dirent(__be32 *p, struct nfs_entry *entry, int plus)
473{ 473{
474 if (!*p++) { 474 if (!*p++) {
475 if (!*p) 475 if (!*p)
@@ -496,7 +496,7 @@ nfs_decode_dirent(u32 *p, struct nfs_entry *entry, int plus)
496 * Decode simple status reply 496 * Decode simple status reply
497 */ 497 */
498static int 498static int
499nfs_xdr_stat(struct rpc_rqst *req, u32 *p, void *dummy) 499nfs_xdr_stat(struct rpc_rqst *req, __be32 *p, void *dummy)
500{ 500{
501 int status; 501 int status;
502 502
@@ -510,7 +510,7 @@ nfs_xdr_stat(struct rpc_rqst *req, u32 *p, void *dummy)
510 * GETATTR, SETATTR, WRITE 510 * GETATTR, SETATTR, WRITE
511 */ 511 */
512static int 512static int
513nfs_xdr_attrstat(struct rpc_rqst *req, u32 *p, struct nfs_fattr *fattr) 513nfs_xdr_attrstat(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
514{ 514{
515 int status; 515 int status;
516 516
@@ -525,7 +525,7 @@ nfs_xdr_attrstat(struct rpc_rqst *req, u32 *p, struct nfs_fattr *fattr)
525 * LOOKUP, CREATE, MKDIR 525 * LOOKUP, CREATE, MKDIR
526 */ 526 */
527static int 527static int
528nfs_xdr_diropres(struct rpc_rqst *req, u32 *p, struct nfs_diropok *res) 528nfs_xdr_diropres(struct rpc_rqst *req, __be32 *p, struct nfs_diropok *res)
529{ 529{
530 int status; 530 int status;
531 531
@@ -540,7 +540,7 @@ nfs_xdr_diropres(struct rpc_rqst *req, u32 *p, struct nfs_diropok *res)
540 * Encode READLINK args 540 * Encode READLINK args
541 */ 541 */
542static int 542static int
543nfs_xdr_readlinkargs(struct rpc_rqst *req, u32 *p, struct nfs_readlinkargs *args) 543nfs_xdr_readlinkargs(struct rpc_rqst *req, __be32 *p, struct nfs_readlinkargs *args)
544{ 544{
545 struct rpc_auth *auth = req->rq_task->tk_auth; 545 struct rpc_auth *auth = req->rq_task->tk_auth;
546 unsigned int replen; 546 unsigned int replen;
@@ -558,7 +558,7 @@ nfs_xdr_readlinkargs(struct rpc_rqst *req, u32 *p, struct nfs_readlinkargs *args
558 * Decode READLINK reply 558 * Decode READLINK reply
559 */ 559 */
560static int 560static int
561nfs_xdr_readlinkres(struct rpc_rqst *req, u32 *p, void *dummy) 561nfs_xdr_readlinkres(struct rpc_rqst *req, __be32 *p, void *dummy)
562{ 562{
563 struct xdr_buf *rcvbuf = &req->rq_rcv_buf; 563 struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
564 struct kvec *iov = rcvbuf->head; 564 struct kvec *iov = rcvbuf->head;
@@ -601,7 +601,7 @@ nfs_xdr_readlinkres(struct rpc_rqst *req, u32 *p, void *dummy)
601 * Decode WRITE reply 601 * Decode WRITE reply
602 */ 602 */
603static int 603static int
604nfs_xdr_writeres(struct rpc_rqst *req, u32 *p, struct nfs_writeres *res) 604nfs_xdr_writeres(struct rpc_rqst *req, __be32 *p, struct nfs_writeres *res)
605{ 605{
606 res->verf->committed = NFS_FILE_SYNC; 606 res->verf->committed = NFS_FILE_SYNC;
607 return nfs_xdr_attrstat(req, p, res->fattr); 607 return nfs_xdr_attrstat(req, p, res->fattr);
@@ -611,7 +611,7 @@ nfs_xdr_writeres(struct rpc_rqst *req, u32 *p, struct nfs_writeres *res)
611 * Decode STATFS reply 611 * Decode STATFS reply
612 */ 612 */
613static int 613static int
614nfs_xdr_statfsres(struct rpc_rqst *req, u32 *p, struct nfs2_fsstat *res) 614nfs_xdr_statfsres(struct rpc_rqst *req, __be32 *p, struct nfs2_fsstat *res)
615{ 615{
616 int status; 616 int status;
617 617
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
index 3b234d4601e7..e5f128ffc32d 100644
--- a/fs/nfs/nfs3proc.c
+++ b/fs/nfs/nfs3proc.c
@@ -668,7 +668,7 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
668{ 668{
669 struct inode *dir = dentry->d_inode; 669 struct inode *dir = dentry->d_inode;
670 struct nfs_fattr dir_attr; 670 struct nfs_fattr dir_attr;
671 u32 *verf = NFS_COOKIEVERF(dir); 671 __be32 *verf = NFS_COOKIEVERF(dir);
672 struct nfs3_readdirargs arg = { 672 struct nfs3_readdirargs arg = {
673 .fh = NFS_FH(dir), 673 .fh = NFS_FH(dir),
674 .cookie = cookie, 674 .cookie = cookie,
diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c
index 16556fa4effb..0ace092d126f 100644
--- a/fs/nfs/nfs3xdr.c
+++ b/fs/nfs/nfs3xdr.c
@@ -105,14 +105,14 @@ static struct {
105/* 105/*
106 * Common NFS XDR functions as inlines 106 * Common NFS XDR functions as inlines
107 */ 107 */
108static inline u32 * 108static inline __be32 *
109xdr_encode_fhandle(u32 *p, struct nfs_fh *fh) 109xdr_encode_fhandle(__be32 *p, struct nfs_fh *fh)
110{ 110{
111 return xdr_encode_array(p, fh->data, fh->size); 111 return xdr_encode_array(p, fh->data, fh->size);
112} 112}
113 113
114static inline u32 * 114static inline __be32 *
115xdr_decode_fhandle(u32 *p, struct nfs_fh *fh) 115xdr_decode_fhandle(__be32 *p, struct nfs_fh *fh)
116{ 116{
117 if ((fh->size = ntohl(*p++)) <= NFS3_FHSIZE) { 117 if ((fh->size = ntohl(*p++)) <= NFS3_FHSIZE) {
118 memcpy(fh->data, p, fh->size); 118 memcpy(fh->data, p, fh->size);
@@ -124,24 +124,24 @@ xdr_decode_fhandle(u32 *p, struct nfs_fh *fh)
124/* 124/*
125 * Encode/decode time. 125 * Encode/decode time.
126 */ 126 */
127static inline u32 * 127static inline __be32 *
128xdr_encode_time3(u32 *p, struct timespec *timep) 128xdr_encode_time3(__be32 *p, struct timespec *timep)
129{ 129{
130 *p++ = htonl(timep->tv_sec); 130 *p++ = htonl(timep->tv_sec);
131 *p++ = htonl(timep->tv_nsec); 131 *p++ = htonl(timep->tv_nsec);
132 return p; 132 return p;
133} 133}
134 134
135static inline u32 * 135static inline __be32 *
136xdr_decode_time3(u32 *p, struct timespec *timep) 136xdr_decode_time3(__be32 *p, struct timespec *timep)
137{ 137{
138 timep->tv_sec = ntohl(*p++); 138 timep->tv_sec = ntohl(*p++);
139 timep->tv_nsec = ntohl(*p++); 139 timep->tv_nsec = ntohl(*p++);
140 return p; 140 return p;
141} 141}
142 142
143static u32 * 143static __be32 *
144xdr_decode_fattr(u32 *p, struct nfs_fattr *fattr) 144xdr_decode_fattr(__be32 *p, struct nfs_fattr *fattr)
145{ 145{
146 unsigned int type, major, minor; 146 unsigned int type, major, minor;
147 int fmode; 147 int fmode;
@@ -177,8 +177,8 @@ xdr_decode_fattr(u32 *p, struct nfs_fattr *fattr)
177 return p; 177 return p;
178} 178}
179 179
180static inline u32 * 180static inline __be32 *
181xdr_encode_sattr(u32 *p, struct iattr *attr) 181xdr_encode_sattr(__be32 *p, struct iattr *attr)
182{ 182{
183 if (attr->ia_valid & ATTR_MODE) { 183 if (attr->ia_valid & ATTR_MODE) {
184 *p++ = xdr_one; 184 *p++ = xdr_one;
@@ -223,8 +223,8 @@ xdr_encode_sattr(u32 *p, struct iattr *attr)
223 return p; 223 return p;
224} 224}
225 225
226static inline u32 * 226static inline __be32 *
227xdr_decode_wcc_attr(u32 *p, struct nfs_fattr *fattr) 227xdr_decode_wcc_attr(__be32 *p, struct nfs_fattr *fattr)
228{ 228{
229 p = xdr_decode_hyper(p, &fattr->pre_size); 229 p = xdr_decode_hyper(p, &fattr->pre_size);
230 p = xdr_decode_time3(p, &fattr->pre_mtime); 230 p = xdr_decode_time3(p, &fattr->pre_mtime);
@@ -233,16 +233,16 @@ xdr_decode_wcc_attr(u32 *p, struct nfs_fattr *fattr)
233 return p; 233 return p;
234} 234}
235 235
236static inline u32 * 236static inline __be32 *
237xdr_decode_post_op_attr(u32 *p, struct nfs_fattr *fattr) 237xdr_decode_post_op_attr(__be32 *p, struct nfs_fattr *fattr)
238{ 238{
239 if (*p++) 239 if (*p++)
240 p = xdr_decode_fattr(p, fattr); 240 p = xdr_decode_fattr(p, fattr);
241 return p; 241 return p;
242} 242}
243 243
244static inline u32 * 244static inline __be32 *
245xdr_decode_pre_op_attr(u32 *p, struct nfs_fattr *fattr) 245xdr_decode_pre_op_attr(__be32 *p, struct nfs_fattr *fattr)
246{ 246{
247 if (*p++) 247 if (*p++)
248 return xdr_decode_wcc_attr(p, fattr); 248 return xdr_decode_wcc_attr(p, fattr);
@@ -250,8 +250,8 @@ xdr_decode_pre_op_attr(u32 *p, struct nfs_fattr *fattr)
250} 250}
251 251
252 252
253static inline u32 * 253static inline __be32 *
254xdr_decode_wcc_data(u32 *p, struct nfs_fattr *fattr) 254xdr_decode_wcc_data(__be32 *p, struct nfs_fattr *fattr)
255{ 255{
256 p = xdr_decode_pre_op_attr(p, fattr); 256 p = xdr_decode_pre_op_attr(p, fattr);
257 return xdr_decode_post_op_attr(p, fattr); 257 return xdr_decode_post_op_attr(p, fattr);
@@ -265,7 +265,7 @@ xdr_decode_wcc_data(u32 *p, struct nfs_fattr *fattr)
265 * Encode file handle argument 265 * Encode file handle argument
266 */ 266 */
267static int 267static int
268nfs3_xdr_fhandle(struct rpc_rqst *req, u32 *p, struct nfs_fh *fh) 268nfs3_xdr_fhandle(struct rpc_rqst *req, __be32 *p, struct nfs_fh *fh)
269{ 269{
270 p = xdr_encode_fhandle(p, fh); 270 p = xdr_encode_fhandle(p, fh);
271 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p); 271 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
@@ -276,7 +276,7 @@ nfs3_xdr_fhandle(struct rpc_rqst *req, u32 *p, struct nfs_fh *fh)
276 * Encode SETATTR arguments 276 * Encode SETATTR arguments
277 */ 277 */
278static int 278static int
279nfs3_xdr_sattrargs(struct rpc_rqst *req, u32 *p, struct nfs3_sattrargs *args) 279nfs3_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs3_sattrargs *args)
280{ 280{
281 p = xdr_encode_fhandle(p, args->fh); 281 p = xdr_encode_fhandle(p, args->fh);
282 p = xdr_encode_sattr(p, args->sattr); 282 p = xdr_encode_sattr(p, args->sattr);
@@ -291,7 +291,7 @@ nfs3_xdr_sattrargs(struct rpc_rqst *req, u32 *p, struct nfs3_sattrargs *args)
291 * Encode directory ops argument 291 * Encode directory ops argument
292 */ 292 */
293static int 293static int
294nfs3_xdr_diropargs(struct rpc_rqst *req, u32 *p, struct nfs3_diropargs *args) 294nfs3_xdr_diropargs(struct rpc_rqst *req, __be32 *p, struct nfs3_diropargs *args)
295{ 295{
296 p = xdr_encode_fhandle(p, args->fh); 296 p = xdr_encode_fhandle(p, args->fh);
297 p = xdr_encode_array(p, args->name, args->len); 297 p = xdr_encode_array(p, args->name, args->len);
@@ -303,7 +303,7 @@ nfs3_xdr_diropargs(struct rpc_rqst *req, u32 *p, struct nfs3_diropargs *args)
303 * Encode access() argument 303 * Encode access() argument
304 */ 304 */
305static int 305static int
306nfs3_xdr_accessargs(struct rpc_rqst *req, u32 *p, struct nfs3_accessargs *args) 306nfs3_xdr_accessargs(struct rpc_rqst *req, __be32 *p, struct nfs3_accessargs *args)
307{ 307{
308 p = xdr_encode_fhandle(p, args->fh); 308 p = xdr_encode_fhandle(p, args->fh);
309 *p++ = htonl(args->access); 309 *p++ = htonl(args->access);
@@ -317,7 +317,7 @@ nfs3_xdr_accessargs(struct rpc_rqst *req, u32 *p, struct nfs3_accessargs *args)
317 * exactly to the page we want to fetch. 317 * exactly to the page we want to fetch.
318 */ 318 */
319static int 319static int
320nfs3_xdr_readargs(struct rpc_rqst *req, u32 *p, struct nfs_readargs *args) 320nfs3_xdr_readargs(struct rpc_rqst *req, __be32 *p, struct nfs_readargs *args)
321{ 321{
322 struct rpc_auth *auth = req->rq_task->tk_auth; 322 struct rpc_auth *auth = req->rq_task->tk_auth;
323 unsigned int replen; 323 unsigned int replen;
@@ -339,7 +339,7 @@ nfs3_xdr_readargs(struct rpc_rqst *req, u32 *p, struct nfs_readargs *args)
339 * Write arguments. Splice the buffer to be written into the iovec. 339 * Write arguments. Splice the buffer to be written into the iovec.
340 */ 340 */
341static int 341static int
342nfs3_xdr_writeargs(struct rpc_rqst *req, u32 *p, struct nfs_writeargs *args) 342nfs3_xdr_writeargs(struct rpc_rqst *req, __be32 *p, struct nfs_writeargs *args)
343{ 343{
344 struct xdr_buf *sndbuf = &req->rq_snd_buf; 344 struct xdr_buf *sndbuf = &req->rq_snd_buf;
345 u32 count = args->count; 345 u32 count = args->count;
@@ -360,7 +360,7 @@ nfs3_xdr_writeargs(struct rpc_rqst *req, u32 *p, struct nfs_writeargs *args)
360 * Encode CREATE arguments 360 * Encode CREATE arguments
361 */ 361 */
362static int 362static int
363nfs3_xdr_createargs(struct rpc_rqst *req, u32 *p, struct nfs3_createargs *args) 363nfs3_xdr_createargs(struct rpc_rqst *req, __be32 *p, struct nfs3_createargs *args)
364{ 364{
365 p = xdr_encode_fhandle(p, args->fh); 365 p = xdr_encode_fhandle(p, args->fh);
366 p = xdr_encode_array(p, args->name, args->len); 366 p = xdr_encode_array(p, args->name, args->len);
@@ -380,7 +380,7 @@ nfs3_xdr_createargs(struct rpc_rqst *req, u32 *p, struct nfs3_createargs *args)
380 * Encode MKDIR arguments 380 * Encode MKDIR arguments
381 */ 381 */
382static int 382static int
383nfs3_xdr_mkdirargs(struct rpc_rqst *req, u32 *p, struct nfs3_mkdirargs *args) 383nfs3_xdr_mkdirargs(struct rpc_rqst *req, __be32 *p, struct nfs3_mkdirargs *args)
384{ 384{
385 p = xdr_encode_fhandle(p, args->fh); 385 p = xdr_encode_fhandle(p, args->fh);
386 p = xdr_encode_array(p, args->name, args->len); 386 p = xdr_encode_array(p, args->name, args->len);
@@ -393,7 +393,7 @@ nfs3_xdr_mkdirargs(struct rpc_rqst *req, u32 *p, struct nfs3_mkdirargs *args)
393 * Encode SYMLINK arguments 393 * Encode SYMLINK arguments
394 */ 394 */
395static int 395static int
396nfs3_xdr_symlinkargs(struct rpc_rqst *req, u32 *p, struct nfs3_symlinkargs *args) 396nfs3_xdr_symlinkargs(struct rpc_rqst *req, __be32 *p, struct nfs3_symlinkargs *args)
397{ 397{
398 p = xdr_encode_fhandle(p, args->fromfh); 398 p = xdr_encode_fhandle(p, args->fromfh);
399 p = xdr_encode_array(p, args->fromname, args->fromlen); 399 p = xdr_encode_array(p, args->fromname, args->fromlen);
@@ -410,7 +410,7 @@ nfs3_xdr_symlinkargs(struct rpc_rqst *req, u32 *p, struct nfs3_symlinkargs *args
410 * Encode MKNOD arguments 410 * Encode MKNOD arguments
411 */ 411 */
412static int 412static int
413nfs3_xdr_mknodargs(struct rpc_rqst *req, u32 *p, struct nfs3_mknodargs *args) 413nfs3_xdr_mknodargs(struct rpc_rqst *req, __be32 *p, struct nfs3_mknodargs *args)
414{ 414{
415 p = xdr_encode_fhandle(p, args->fh); 415 p = xdr_encode_fhandle(p, args->fh);
416 p = xdr_encode_array(p, args->name, args->len); 416 p = xdr_encode_array(p, args->name, args->len);
@@ -429,7 +429,7 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req, u32 *p, struct nfs3_mknodargs *args)
429 * Encode RENAME arguments 429 * Encode RENAME arguments
430 */ 430 */
431static int 431static int
432nfs3_xdr_renameargs(struct rpc_rqst *req, u32 *p, struct nfs3_renameargs *args) 432nfs3_xdr_renameargs(struct rpc_rqst *req, __be32 *p, struct nfs3_renameargs *args)
433{ 433{
434 p = xdr_encode_fhandle(p, args->fromfh); 434 p = xdr_encode_fhandle(p, args->fromfh);
435 p = xdr_encode_array(p, args->fromname, args->fromlen); 435 p = xdr_encode_array(p, args->fromname, args->fromlen);
@@ -443,7 +443,7 @@ nfs3_xdr_renameargs(struct rpc_rqst *req, u32 *p, struct nfs3_renameargs *args)
443 * Encode LINK arguments 443 * Encode LINK arguments
444 */ 444 */
445static int 445static int
446nfs3_xdr_linkargs(struct rpc_rqst *req, u32 *p, struct nfs3_linkargs *args) 446nfs3_xdr_linkargs(struct rpc_rqst *req, __be32 *p, struct nfs3_linkargs *args)
447{ 447{
448 p = xdr_encode_fhandle(p, args->fromfh); 448 p = xdr_encode_fhandle(p, args->fromfh);
449 p = xdr_encode_fhandle(p, args->tofh); 449 p = xdr_encode_fhandle(p, args->tofh);
@@ -456,7 +456,7 @@ nfs3_xdr_linkargs(struct rpc_rqst *req, u32 *p, struct nfs3_linkargs *args)
456 * Encode arguments to readdir call 456 * Encode arguments to readdir call
457 */ 457 */
458static int 458static int
459nfs3_xdr_readdirargs(struct rpc_rqst *req, u32 *p, struct nfs3_readdirargs *args) 459nfs3_xdr_readdirargs(struct rpc_rqst *req, __be32 *p, struct nfs3_readdirargs *args)
460{ 460{
461 struct rpc_auth *auth = req->rq_task->tk_auth; 461 struct rpc_auth *auth = req->rq_task->tk_auth;
462 unsigned int replen; 462 unsigned int replen;
@@ -485,7 +485,7 @@ nfs3_xdr_readdirargs(struct rpc_rqst *req, u32 *p, struct nfs3_readdirargs *args
485 * We just check for syntactical correctness. 485 * We just check for syntactical correctness.
486 */ 486 */
487static int 487static int
488nfs3_xdr_readdirres(struct rpc_rqst *req, u32 *p, struct nfs3_readdirres *res) 488nfs3_xdr_readdirres(struct rpc_rqst *req, __be32 *p, struct nfs3_readdirres *res)
489{ 489{
490 struct xdr_buf *rcvbuf = &req->rq_rcv_buf; 490 struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
491 struct kvec *iov = rcvbuf->head; 491 struct kvec *iov = rcvbuf->head;
@@ -493,7 +493,7 @@ nfs3_xdr_readdirres(struct rpc_rqst *req, u32 *p, struct nfs3_readdirres *res)
493 int hdrlen, recvd; 493 int hdrlen, recvd;
494 int status, nr; 494 int status, nr;
495 unsigned int len, pglen; 495 unsigned int len, pglen;
496 u32 *entry, *end, *kaddr; 496 __be32 *entry, *end, *kaddr;
497 497
498 status = ntohl(*p++); 498 status = ntohl(*p++);
499 /* Decode post_op_attrs */ 499 /* Decode post_op_attrs */
@@ -523,8 +523,8 @@ nfs3_xdr_readdirres(struct rpc_rqst *req, u32 *p, struct nfs3_readdirres *res)
523 if (pglen > recvd) 523 if (pglen > recvd)
524 pglen = recvd; 524 pglen = recvd;
525 page = rcvbuf->pages; 525 page = rcvbuf->pages;
526 kaddr = p = (u32 *)kmap_atomic(*page, KM_USER0); 526 kaddr = p = kmap_atomic(*page, KM_USER0);
527 end = (u32 *)((char *)p + pglen); 527 end = (__be32 *)((char *)p + pglen);
528 entry = p; 528 entry = p;
529 for (nr = 0; *p++; nr++) { 529 for (nr = 0; *p++; nr++) {
530 if (p + 3 > end) 530 if (p + 3 > end)
@@ -583,8 +583,8 @@ err_unmap:
583 goto out; 583 goto out;
584} 584}
585 585
586u32 * 586__be32 *
587nfs3_decode_dirent(u32 *p, struct nfs_entry *entry, int plus) 587nfs3_decode_dirent(__be32 *p, struct nfs_entry *entry, int plus)
588{ 588{
589 struct nfs_entry old = *entry; 589 struct nfs_entry old = *entry;
590 590
@@ -626,7 +626,7 @@ nfs3_decode_dirent(u32 *p, struct nfs_entry *entry, int plus)
626 * Encode COMMIT arguments 626 * Encode COMMIT arguments
627 */ 627 */
628static int 628static int
629nfs3_xdr_commitargs(struct rpc_rqst *req, u32 *p, struct nfs_writeargs *args) 629nfs3_xdr_commitargs(struct rpc_rqst *req, __be32 *p, struct nfs_writeargs *args)
630{ 630{
631 p = xdr_encode_fhandle(p, args->fh); 631 p = xdr_encode_fhandle(p, args->fh);
632 p = xdr_encode_hyper(p, args->offset); 632 p = xdr_encode_hyper(p, args->offset);
@@ -640,7 +640,7 @@ nfs3_xdr_commitargs(struct rpc_rqst *req, u32 *p, struct nfs_writeargs *args)
640 * Encode GETACL arguments 640 * Encode GETACL arguments
641 */ 641 */
642static int 642static int
643nfs3_xdr_getaclargs(struct rpc_rqst *req, u32 *p, 643nfs3_xdr_getaclargs(struct rpc_rqst *req, __be32 *p,
644 struct nfs3_getaclargs *args) 644 struct nfs3_getaclargs *args)
645{ 645{
646 struct rpc_auth *auth = req->rq_task->tk_auth; 646 struct rpc_auth *auth = req->rq_task->tk_auth;
@@ -664,7 +664,7 @@ nfs3_xdr_getaclargs(struct rpc_rqst *req, u32 *p,
664 * Encode SETACL arguments 664 * Encode SETACL arguments
665 */ 665 */
666static int 666static int
667nfs3_xdr_setaclargs(struct rpc_rqst *req, u32 *p, 667nfs3_xdr_setaclargs(struct rpc_rqst *req, __be32 *p,
668 struct nfs3_setaclargs *args) 668 struct nfs3_setaclargs *args)
669{ 669{
670 struct xdr_buf *buf = &req->rq_snd_buf; 670 struct xdr_buf *buf = &req->rq_snd_buf;
@@ -711,7 +711,7 @@ nfs3_xdr_setaclargs(struct rpc_rqst *req, u32 *p,
711 * Decode attrstat reply. 711 * Decode attrstat reply.
712 */ 712 */
713static int 713static int
714nfs3_xdr_attrstat(struct rpc_rqst *req, u32 *p, struct nfs_fattr *fattr) 714nfs3_xdr_attrstat(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
715{ 715{
716 int status; 716 int status;
717 717
@@ -726,7 +726,7 @@ nfs3_xdr_attrstat(struct rpc_rqst *req, u32 *p, struct nfs_fattr *fattr)
726 * SATTR, REMOVE, RMDIR 726 * SATTR, REMOVE, RMDIR
727 */ 727 */
728static int 728static int
729nfs3_xdr_wccstat(struct rpc_rqst *req, u32 *p, struct nfs_fattr *fattr) 729nfs3_xdr_wccstat(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
730{ 730{
731 int status; 731 int status;
732 732
@@ -740,7 +740,7 @@ nfs3_xdr_wccstat(struct rpc_rqst *req, u32 *p, struct nfs_fattr *fattr)
740 * Decode LOOKUP reply 740 * Decode LOOKUP reply
741 */ 741 */
742static int 742static int
743nfs3_xdr_lookupres(struct rpc_rqst *req, u32 *p, struct nfs3_diropres *res) 743nfs3_xdr_lookupres(struct rpc_rqst *req, __be32 *p, struct nfs3_diropres *res)
744{ 744{
745 int status; 745 int status;
746 746
@@ -759,7 +759,7 @@ nfs3_xdr_lookupres(struct rpc_rqst *req, u32 *p, struct nfs3_diropres *res)
759 * Decode ACCESS reply 759 * Decode ACCESS reply
760 */ 760 */
761static int 761static int
762nfs3_xdr_accessres(struct rpc_rqst *req, u32 *p, struct nfs3_accessres *res) 762nfs3_xdr_accessres(struct rpc_rqst *req, __be32 *p, struct nfs3_accessres *res)
763{ 763{
764 int status = ntohl(*p++); 764 int status = ntohl(*p++);
765 765
@@ -771,7 +771,7 @@ nfs3_xdr_accessres(struct rpc_rqst *req, u32 *p, struct nfs3_accessres *res)
771} 771}
772 772
773static int 773static int
774nfs3_xdr_readlinkargs(struct rpc_rqst *req, u32 *p, struct nfs3_readlinkargs *args) 774nfs3_xdr_readlinkargs(struct rpc_rqst *req, __be32 *p, struct nfs3_readlinkargs *args)
775{ 775{
776 struct rpc_auth *auth = req->rq_task->tk_auth; 776 struct rpc_auth *auth = req->rq_task->tk_auth;
777 unsigned int replen; 777 unsigned int replen;
@@ -789,7 +789,7 @@ nfs3_xdr_readlinkargs(struct rpc_rqst *req, u32 *p, struct nfs3_readlinkargs *ar
789 * Decode READLINK reply 789 * Decode READLINK reply
790 */ 790 */
791static int 791static int
792nfs3_xdr_readlinkres(struct rpc_rqst *req, u32 *p, struct nfs_fattr *fattr) 792nfs3_xdr_readlinkres(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
793{ 793{
794 struct xdr_buf *rcvbuf = &req->rq_rcv_buf; 794 struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
795 struct kvec *iov = rcvbuf->head; 795 struct kvec *iov = rcvbuf->head;
@@ -837,7 +837,7 @@ nfs3_xdr_readlinkres(struct rpc_rqst *req, u32 *p, struct nfs_fattr *fattr)
837 * Decode READ reply 837 * Decode READ reply
838 */ 838 */
839static int 839static int
840nfs3_xdr_readres(struct rpc_rqst *req, u32 *p, struct nfs_readres *res) 840nfs3_xdr_readres(struct rpc_rqst *req, __be32 *p, struct nfs_readres *res)
841{ 841{
842 struct kvec *iov = req->rq_rcv_buf.head; 842 struct kvec *iov = req->rq_rcv_buf.head;
843 int status, count, ocount, recvd, hdrlen; 843 int status, count, ocount, recvd, hdrlen;
@@ -888,7 +888,7 @@ nfs3_xdr_readres(struct rpc_rqst *req, u32 *p, struct nfs_readres *res)
888 * Decode WRITE response 888 * Decode WRITE response
889 */ 889 */
890static int 890static int
891nfs3_xdr_writeres(struct rpc_rqst *req, u32 *p, struct nfs_writeres *res) 891nfs3_xdr_writeres(struct rpc_rqst *req, __be32 *p, struct nfs_writeres *res)
892{ 892{
893 int status; 893 int status;
894 894
@@ -910,7 +910,7 @@ nfs3_xdr_writeres(struct rpc_rqst *req, u32 *p, struct nfs_writeres *res)
910 * Decode a CREATE response 910 * Decode a CREATE response
911 */ 911 */
912static int 912static int
913nfs3_xdr_createres(struct rpc_rqst *req, u32 *p, struct nfs3_diropres *res) 913nfs3_xdr_createres(struct rpc_rqst *req, __be32 *p, struct nfs3_diropres *res)
914{ 914{
915 int status; 915 int status;
916 916
@@ -937,7 +937,7 @@ nfs3_xdr_createres(struct rpc_rqst *req, u32 *p, struct nfs3_diropres *res)
937 * Decode RENAME reply 937 * Decode RENAME reply
938 */ 938 */
939static int 939static int
940nfs3_xdr_renameres(struct rpc_rqst *req, u32 *p, struct nfs3_renameres *res) 940nfs3_xdr_renameres(struct rpc_rqst *req, __be32 *p, struct nfs3_renameres *res)
941{ 941{
942 int status; 942 int status;
943 943
@@ -952,7 +952,7 @@ nfs3_xdr_renameres(struct rpc_rqst *req, u32 *p, struct nfs3_renameres *res)
952 * Decode LINK reply 952 * Decode LINK reply
953 */ 953 */
954static int 954static int
955nfs3_xdr_linkres(struct rpc_rqst *req, u32 *p, struct nfs3_linkres *res) 955nfs3_xdr_linkres(struct rpc_rqst *req, __be32 *p, struct nfs3_linkres *res)
956{ 956{
957 int status; 957 int status;
958 958
@@ -967,7 +967,7 @@ nfs3_xdr_linkres(struct rpc_rqst *req, u32 *p, struct nfs3_linkres *res)
967 * Decode FSSTAT reply 967 * Decode FSSTAT reply
968 */ 968 */
969static int 969static int
970nfs3_xdr_fsstatres(struct rpc_rqst *req, u32 *p, struct nfs_fsstat *res) 970nfs3_xdr_fsstatres(struct rpc_rqst *req, __be32 *p, struct nfs_fsstat *res)
971{ 971{
972 int status; 972 int status;
973 973
@@ -992,7 +992,7 @@ nfs3_xdr_fsstatres(struct rpc_rqst *req, u32 *p, struct nfs_fsstat *res)
992 * Decode FSINFO reply 992 * Decode FSINFO reply
993 */ 993 */
994static int 994static int
995nfs3_xdr_fsinfores(struct rpc_rqst *req, u32 *p, struct nfs_fsinfo *res) 995nfs3_xdr_fsinfores(struct rpc_rqst *req, __be32 *p, struct nfs_fsinfo *res)
996{ 996{
997 int status; 997 int status;
998 998
@@ -1020,7 +1020,7 @@ nfs3_xdr_fsinfores(struct rpc_rqst *req, u32 *p, struct nfs_fsinfo *res)
1020 * Decode PATHCONF reply 1020 * Decode PATHCONF reply
1021 */ 1021 */
1022static int 1022static int
1023nfs3_xdr_pathconfres(struct rpc_rqst *req, u32 *p, struct nfs_pathconf *res) 1023nfs3_xdr_pathconfres(struct rpc_rqst *req, __be32 *p, struct nfs_pathconf *res)
1024{ 1024{
1025 int status; 1025 int status;
1026 1026
@@ -1040,7 +1040,7 @@ nfs3_xdr_pathconfres(struct rpc_rqst *req, u32 *p, struct nfs_pathconf *res)
1040 * Decode COMMIT reply 1040 * Decode COMMIT reply
1041 */ 1041 */
1042static int 1042static int
1043nfs3_xdr_commitres(struct rpc_rqst *req, u32 *p, struct nfs_writeres *res) 1043nfs3_xdr_commitres(struct rpc_rqst *req, __be32 *p, struct nfs_writeres *res)
1044{ 1044{
1045 int status; 1045 int status;
1046 1046
@@ -1059,7 +1059,7 @@ nfs3_xdr_commitres(struct rpc_rqst *req, u32 *p, struct nfs_writeres *res)
1059 * Decode GETACL reply 1059 * Decode GETACL reply
1060 */ 1060 */
1061static int 1061static int
1062nfs3_xdr_getaclres(struct rpc_rqst *req, u32 *p, 1062nfs3_xdr_getaclres(struct rpc_rqst *req, __be32 *p,
1063 struct nfs3_getaclres *res) 1063 struct nfs3_getaclres *res)
1064{ 1064{
1065 struct xdr_buf *buf = &req->rq_rcv_buf; 1065 struct xdr_buf *buf = &req->rq_rcv_buf;
@@ -1091,7 +1091,7 @@ nfs3_xdr_getaclres(struct rpc_rqst *req, u32 *p,
1091 * Decode setacl reply. 1091 * Decode setacl reply.
1092 */ 1092 */
1093static int 1093static int
1094nfs3_xdr_setaclres(struct rpc_rqst *req, u32 *p, struct nfs_fattr *fattr) 1094nfs3_xdr_setaclres(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
1095{ 1095{
1096 int status = ntohl(*p++); 1096 int status = ntohl(*p++);
1097 1097
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index 61095fe4b5ca..6f346677332d 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -212,7 +212,7 @@ extern void nfs_free_seqid(struct nfs_seqid *seqid);
212extern const nfs4_stateid zero_stateid; 212extern const nfs4_stateid zero_stateid;
213 213
214/* nfs4xdr.c */ 214/* nfs4xdr.c */
215extern uint32_t *nfs4_decode_dirent(uint32_t *p, struct nfs_entry *entry, int plus); 215extern __be32 *nfs4_decode_dirent(__be32 *p, struct nfs_entry *entry, int plus);
216extern struct rpc_procinfo nfs4_procedures[]; 216extern struct rpc_procinfo nfs4_procedures[];
217 217
218struct nfs4_mount_data; 218struct nfs4_mount_data;
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 47c7e6e3910d..8118036cc449 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -138,10 +138,10 @@ const u32 nfs4_fs_locations_bitmap[2] = {
138 | FATTR4_WORD1_MOUNTED_ON_FILEID 138 | FATTR4_WORD1_MOUNTED_ON_FILEID
139}; 139};
140 140
141static void nfs4_setup_readdir(u64 cookie, u32 *verifier, struct dentry *dentry, 141static void nfs4_setup_readdir(u64 cookie, __be32 *verifier, struct dentry *dentry,
142 struct nfs4_readdir_arg *readdir) 142 struct nfs4_readdir_arg *readdir)
143{ 143{
144 u32 *start, *p; 144 __be32 *start, *p;
145 145
146 BUG_ON(readdir->count < 80); 146 BUG_ON(readdir->count < 80);
147 if (cookie > 2) { 147 if (cookie > 2) {
@@ -162,7 +162,7 @@ static void nfs4_setup_readdir(u64 cookie, u32 *verifier, struct dentry *dentry,
162 * when talking to the server, we always send cookie 0 162 * when talking to the server, we always send cookie 0
163 * instead of 1 or 2. 163 * instead of 1 or 2.
164 */ 164 */
165 start = p = (u32 *)kmap_atomic(*readdir->pages, KM_USER0); 165 start = p = kmap_atomic(*readdir->pages, KM_USER0);
166 166
167 if (cookie == 0) { 167 if (cookie == 0) {
168 *p++ = xdr_one; /* next */ 168 *p++ = xdr_one; /* next */
@@ -1314,11 +1314,9 @@ nfs4_open_revalidate(struct inode *dir, struct dentry *dentry, int openflags, st
1314 case -EROFS: 1314 case -EROFS:
1315 lookup_instantiate_filp(nd, (struct dentry *)state, NULL); 1315 lookup_instantiate_filp(nd, (struct dentry *)state, NULL);
1316 return 1; 1316 return 1;
1317 case -ENOENT: 1317 default:
1318 if (dentry->d_inode == NULL) 1318 goto out_drop;
1319 return 1;
1320 } 1319 }
1321 goto out_drop;
1322 } 1320 }
1323 if (state->inode == dentry->d_inode) { 1321 if (state->inode == dentry->d_inode) {
1324 nfs4_intent_set_file(nd, dentry, state); 1322 nfs4_intent_set_file(nd, dentry, state);
@@ -2917,11 +2915,11 @@ int nfs4_proc_setclientid(struct nfs_client *clp, u32 program, unsigned short po
2917 .rpc_resp = clp, 2915 .rpc_resp = clp,
2918 .rpc_cred = cred, 2916 .rpc_cred = cred,
2919 }; 2917 };
2920 u32 *p; 2918 __be32 *p;
2921 int loop = 0; 2919 int loop = 0;
2922 int status; 2920 int status;
2923 2921
2924 p = (u32*)sc_verifier.data; 2922 p = (__be32*)sc_verifier.data;
2925 *p++ = htonl((u32)clp->cl_boot_time.tv_sec); 2923 *p++ = htonl((u32)clp->cl_boot_time.tv_sec);
2926 *p = htonl((u32)clp->cl_boot_time.tv_nsec); 2924 *p = htonl((u32)clp->cl_boot_time.tv_nsec);
2927 2925
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 3dd413f52da1..0cf3fa312a33 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -471,7 +471,7 @@ struct compound_hdr {
471 471
472static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) 472static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str)
473{ 473{
474 uint32_t *p; 474 __be32 *p;
475 475
476 p = xdr_reserve_space(xdr, 4 + len); 476 p = xdr_reserve_space(xdr, 4 + len);
477 BUG_ON(p == NULL); 477 BUG_ON(p == NULL);
@@ -480,7 +480,7 @@ static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *
480 480
481static int encode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr) 481static int encode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr)
482{ 482{
483 uint32_t *p; 483 __be32 *p;
484 484
485 dprintk("encode_compound: tag=%.*s\n", (int)hdr->taglen, hdr->tag); 485 dprintk("encode_compound: tag=%.*s\n", (int)hdr->taglen, hdr->tag);
486 BUG_ON(hdr->taglen > NFS4_MAXTAGLEN); 486 BUG_ON(hdr->taglen > NFS4_MAXTAGLEN);
@@ -494,7 +494,7 @@ static int encode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr)
494 494
495static void encode_nfs4_verifier(struct xdr_stream *xdr, const nfs4_verifier *verf) 495static void encode_nfs4_verifier(struct xdr_stream *xdr, const nfs4_verifier *verf)
496{ 496{
497 uint32_t *p; 497 __be32 *p;
498 498
499 p = xdr_reserve_space(xdr, NFS4_VERIFIER_SIZE); 499 p = xdr_reserve_space(xdr, NFS4_VERIFIER_SIZE);
500 BUG_ON(p == NULL); 500 BUG_ON(p == NULL);
@@ -507,8 +507,8 @@ static int encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const s
507 char owner_group[IDMAP_NAMESZ]; 507 char owner_group[IDMAP_NAMESZ];
508 int owner_namelen = 0; 508 int owner_namelen = 0;
509 int owner_grouplen = 0; 509 int owner_grouplen = 0;
510 uint32_t *p; 510 __be32 *p;
511 uint32_t *q; 511 __be32 *q;
512 int len; 512 int len;
513 uint32_t bmval0 = 0; 513 uint32_t bmval0 = 0;
514 uint32_t bmval1 = 0; 514 uint32_t bmval1 = 0;
@@ -630,7 +630,7 @@ static int encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const s
630 630
631static int encode_access(struct xdr_stream *xdr, u32 access) 631static int encode_access(struct xdr_stream *xdr, u32 access)
632{ 632{
633 uint32_t *p; 633 __be32 *p;
634 634
635 RESERVE_SPACE(8); 635 RESERVE_SPACE(8);
636 WRITE32(OP_ACCESS); 636 WRITE32(OP_ACCESS);
@@ -641,7 +641,7 @@ static int encode_access(struct xdr_stream *xdr, u32 access)
641 641
642static int encode_close(struct xdr_stream *xdr, const struct nfs_closeargs *arg) 642static int encode_close(struct xdr_stream *xdr, const struct nfs_closeargs *arg)
643{ 643{
644 uint32_t *p; 644 __be32 *p;
645 645
646 RESERVE_SPACE(8+sizeof(arg->stateid->data)); 646 RESERVE_SPACE(8+sizeof(arg->stateid->data));
647 WRITE32(OP_CLOSE); 647 WRITE32(OP_CLOSE);
@@ -653,7 +653,7 @@ static int encode_close(struct xdr_stream *xdr, const struct nfs_closeargs *arg)
653 653
654static int encode_commit(struct xdr_stream *xdr, const struct nfs_writeargs *args) 654static int encode_commit(struct xdr_stream *xdr, const struct nfs_writeargs *args)
655{ 655{
656 uint32_t *p; 656 __be32 *p;
657 657
658 RESERVE_SPACE(16); 658 RESERVE_SPACE(16);
659 WRITE32(OP_COMMIT); 659 WRITE32(OP_COMMIT);
@@ -665,7 +665,7 @@ static int encode_commit(struct xdr_stream *xdr, const struct nfs_writeargs *arg
665 665
666static int encode_create(struct xdr_stream *xdr, const struct nfs4_create_arg *create) 666static int encode_create(struct xdr_stream *xdr, const struct nfs4_create_arg *create)
667{ 667{
668 uint32_t *p; 668 __be32 *p;
669 669
670 RESERVE_SPACE(8); 670 RESERVE_SPACE(8);
671 WRITE32(OP_CREATE); 671 WRITE32(OP_CREATE);
@@ -697,7 +697,7 @@ static int encode_create(struct xdr_stream *xdr, const struct nfs4_create_arg *c
697 697
698static int encode_getattr_one(struct xdr_stream *xdr, uint32_t bitmap) 698static int encode_getattr_one(struct xdr_stream *xdr, uint32_t bitmap)
699{ 699{
700 uint32_t *p; 700 __be32 *p;
701 701
702 RESERVE_SPACE(12); 702 RESERVE_SPACE(12);
703 WRITE32(OP_GETATTR); 703 WRITE32(OP_GETATTR);
@@ -708,7 +708,7 @@ static int encode_getattr_one(struct xdr_stream *xdr, uint32_t bitmap)
708 708
709static int encode_getattr_two(struct xdr_stream *xdr, uint32_t bm0, uint32_t bm1) 709static int encode_getattr_two(struct xdr_stream *xdr, uint32_t bm0, uint32_t bm1)
710{ 710{
711 uint32_t *p; 711 __be32 *p;
712 712
713 RESERVE_SPACE(16); 713 RESERVE_SPACE(16);
714 WRITE32(OP_GETATTR); 714 WRITE32(OP_GETATTR);
@@ -740,7 +740,7 @@ static int encode_fs_locations(struct xdr_stream *xdr, const u32* bitmask)
740 740
741static int encode_getfh(struct xdr_stream *xdr) 741static int encode_getfh(struct xdr_stream *xdr)
742{ 742{
743 uint32_t *p; 743 __be32 *p;
744 744
745 RESERVE_SPACE(4); 745 RESERVE_SPACE(4);
746 WRITE32(OP_GETFH); 746 WRITE32(OP_GETFH);
@@ -750,7 +750,7 @@ static int encode_getfh(struct xdr_stream *xdr)
750 750
751static int encode_link(struct xdr_stream *xdr, const struct qstr *name) 751static int encode_link(struct xdr_stream *xdr, const struct qstr *name)
752{ 752{
753 uint32_t *p; 753 __be32 *p;
754 754
755 RESERVE_SPACE(8 + name->len); 755 RESERVE_SPACE(8 + name->len);
756 WRITE32(OP_LINK); 756 WRITE32(OP_LINK);
@@ -780,7 +780,7 @@ static inline uint64_t nfs4_lock_length(struct file_lock *fl)
780 */ 780 */
781static int encode_lock(struct xdr_stream *xdr, const struct nfs_lock_args *args) 781static int encode_lock(struct xdr_stream *xdr, const struct nfs_lock_args *args)
782{ 782{
783 uint32_t *p; 783 __be32 *p;
784 784
785 RESERVE_SPACE(32); 785 RESERVE_SPACE(32);
786 WRITE32(OP_LOCK); 786 WRITE32(OP_LOCK);
@@ -809,7 +809,7 @@ static int encode_lock(struct xdr_stream *xdr, const struct nfs_lock_args *args)
809 809
810static int encode_lockt(struct xdr_stream *xdr, const struct nfs_lockt_args *args) 810static int encode_lockt(struct xdr_stream *xdr, const struct nfs_lockt_args *args)
811{ 811{
812 uint32_t *p; 812 __be32 *p;
813 813
814 RESERVE_SPACE(40); 814 RESERVE_SPACE(40);
815 WRITE32(OP_LOCKT); 815 WRITE32(OP_LOCKT);
@@ -825,7 +825,7 @@ static int encode_lockt(struct xdr_stream *xdr, const struct nfs_lockt_args *arg
825 825
826static int encode_locku(struct xdr_stream *xdr, const struct nfs_locku_args *args) 826static int encode_locku(struct xdr_stream *xdr, const struct nfs_locku_args *args)
827{ 827{
828 uint32_t *p; 828 __be32 *p;
829 829
830 RESERVE_SPACE(44); 830 RESERVE_SPACE(44);
831 WRITE32(OP_LOCKU); 831 WRITE32(OP_LOCKU);
@@ -841,7 +841,7 @@ static int encode_locku(struct xdr_stream *xdr, const struct nfs_locku_args *arg
841static int encode_lookup(struct xdr_stream *xdr, const struct qstr *name) 841static int encode_lookup(struct xdr_stream *xdr, const struct qstr *name)
842{ 842{
843 int len = name->len; 843 int len = name->len;
844 uint32_t *p; 844 __be32 *p;
845 845
846 RESERVE_SPACE(8 + len); 846 RESERVE_SPACE(8 + len);
847 WRITE32(OP_LOOKUP); 847 WRITE32(OP_LOOKUP);
@@ -853,7 +853,7 @@ static int encode_lookup(struct xdr_stream *xdr, const struct qstr *name)
853 853
854static void encode_share_access(struct xdr_stream *xdr, int open_flags) 854static void encode_share_access(struct xdr_stream *xdr, int open_flags)
855{ 855{
856 uint32_t *p; 856 __be32 *p;
857 857
858 RESERVE_SPACE(8); 858 RESERVE_SPACE(8);
859 switch (open_flags & (FMODE_READ|FMODE_WRITE)) { 859 switch (open_flags & (FMODE_READ|FMODE_WRITE)) {
@@ -874,7 +874,7 @@ static void encode_share_access(struct xdr_stream *xdr, int open_flags)
874 874
875static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_openargs *arg) 875static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_openargs *arg)
876{ 876{
877 uint32_t *p; 877 __be32 *p;
878 /* 878 /*
879 * opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4, 879 * opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4,
880 * owner 4 = 32 880 * owner 4 = 32
@@ -891,7 +891,7 @@ static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_opena
891 891
892static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg) 892static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg)
893{ 893{
894 uint32_t *p; 894 __be32 *p;
895 895
896 RESERVE_SPACE(4); 896 RESERVE_SPACE(4);
897 switch(arg->open_flags & O_EXCL) { 897 switch(arg->open_flags & O_EXCL) {
@@ -907,7 +907,7 @@ static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_op
907 907
908static void encode_opentype(struct xdr_stream *xdr, const struct nfs_openargs *arg) 908static void encode_opentype(struct xdr_stream *xdr, const struct nfs_openargs *arg)
909{ 909{
910 uint32_t *p; 910 __be32 *p;
911 911
912 RESERVE_SPACE(4); 912 RESERVE_SPACE(4);
913 switch (arg->open_flags & O_CREAT) { 913 switch (arg->open_flags & O_CREAT) {
@@ -923,7 +923,7 @@ static void encode_opentype(struct xdr_stream *xdr, const struct nfs_openargs *a
923 923
924static inline void encode_delegation_type(struct xdr_stream *xdr, int delegation_type) 924static inline void encode_delegation_type(struct xdr_stream *xdr, int delegation_type)
925{ 925{
926 uint32_t *p; 926 __be32 *p;
927 927
928 RESERVE_SPACE(4); 928 RESERVE_SPACE(4);
929 switch (delegation_type) { 929 switch (delegation_type) {
@@ -943,7 +943,7 @@ static inline void encode_delegation_type(struct xdr_stream *xdr, int delegation
943 943
944static inline void encode_claim_null(struct xdr_stream *xdr, const struct qstr *name) 944static inline void encode_claim_null(struct xdr_stream *xdr, const struct qstr *name)
945{ 945{
946 uint32_t *p; 946 __be32 *p;
947 947
948 RESERVE_SPACE(4); 948 RESERVE_SPACE(4);
949 WRITE32(NFS4_OPEN_CLAIM_NULL); 949 WRITE32(NFS4_OPEN_CLAIM_NULL);
@@ -952,7 +952,7 @@ static inline void encode_claim_null(struct xdr_stream *xdr, const struct qstr *
952 952
953static inline void encode_claim_previous(struct xdr_stream *xdr, int type) 953static inline void encode_claim_previous(struct xdr_stream *xdr, int type)
954{ 954{
955 uint32_t *p; 955 __be32 *p;
956 956
957 RESERVE_SPACE(4); 957 RESERVE_SPACE(4);
958 WRITE32(NFS4_OPEN_CLAIM_PREVIOUS); 958 WRITE32(NFS4_OPEN_CLAIM_PREVIOUS);
@@ -961,7 +961,7 @@ static inline void encode_claim_previous(struct xdr_stream *xdr, int type)
961 961
962static inline void encode_claim_delegate_cur(struct xdr_stream *xdr, const struct qstr *name, const nfs4_stateid *stateid) 962static inline void encode_claim_delegate_cur(struct xdr_stream *xdr, const struct qstr *name, const nfs4_stateid *stateid)
963{ 963{
964 uint32_t *p; 964 __be32 *p;
965 965
966 RESERVE_SPACE(4+sizeof(stateid->data)); 966 RESERVE_SPACE(4+sizeof(stateid->data));
967 WRITE32(NFS4_OPEN_CLAIM_DELEGATE_CUR); 967 WRITE32(NFS4_OPEN_CLAIM_DELEGATE_CUR);
@@ -991,7 +991,7 @@ static int encode_open(struct xdr_stream *xdr, const struct nfs_openargs *arg)
991 991
992static int encode_open_confirm(struct xdr_stream *xdr, const struct nfs_open_confirmargs *arg) 992static int encode_open_confirm(struct xdr_stream *xdr, const struct nfs_open_confirmargs *arg)
993{ 993{
994 uint32_t *p; 994 __be32 *p;
995 995
996 RESERVE_SPACE(8+sizeof(arg->stateid->data)); 996 RESERVE_SPACE(8+sizeof(arg->stateid->data));
997 WRITE32(OP_OPEN_CONFIRM); 997 WRITE32(OP_OPEN_CONFIRM);
@@ -1003,7 +1003,7 @@ static int encode_open_confirm(struct xdr_stream *xdr, const struct nfs_open_con
1003 1003
1004static int encode_open_downgrade(struct xdr_stream *xdr, const struct nfs_closeargs *arg) 1004static int encode_open_downgrade(struct xdr_stream *xdr, const struct nfs_closeargs *arg)
1005{ 1005{
1006 uint32_t *p; 1006 __be32 *p;
1007 1007
1008 RESERVE_SPACE(8+sizeof(arg->stateid->data)); 1008 RESERVE_SPACE(8+sizeof(arg->stateid->data));
1009 WRITE32(OP_OPEN_DOWNGRADE); 1009 WRITE32(OP_OPEN_DOWNGRADE);
@@ -1017,7 +1017,7 @@ static int
1017encode_putfh(struct xdr_stream *xdr, const struct nfs_fh *fh) 1017encode_putfh(struct xdr_stream *xdr, const struct nfs_fh *fh)
1018{ 1018{
1019 int len = fh->size; 1019 int len = fh->size;
1020 uint32_t *p; 1020 __be32 *p;
1021 1021
1022 RESERVE_SPACE(8 + len); 1022 RESERVE_SPACE(8 + len);
1023 WRITE32(OP_PUTFH); 1023 WRITE32(OP_PUTFH);
@@ -1029,7 +1029,7 @@ encode_putfh(struct xdr_stream *xdr, const struct nfs_fh *fh)
1029 1029
1030static int encode_putrootfh(struct xdr_stream *xdr) 1030static int encode_putrootfh(struct xdr_stream *xdr)
1031{ 1031{
1032 uint32_t *p; 1032 __be32 *p;
1033 1033
1034 RESERVE_SPACE(4); 1034 RESERVE_SPACE(4);
1035 WRITE32(OP_PUTROOTFH); 1035 WRITE32(OP_PUTROOTFH);
@@ -1040,7 +1040,7 @@ static int encode_putrootfh(struct xdr_stream *xdr)
1040static void encode_stateid(struct xdr_stream *xdr, const struct nfs_open_context *ctx) 1040static void encode_stateid(struct xdr_stream *xdr, const struct nfs_open_context *ctx)
1041{ 1041{
1042 nfs4_stateid stateid; 1042 nfs4_stateid stateid;
1043 uint32_t *p; 1043 __be32 *p;
1044 1044
1045 RESERVE_SPACE(16); 1045 RESERVE_SPACE(16);
1046 if (ctx->state != NULL) { 1046 if (ctx->state != NULL) {
@@ -1052,7 +1052,7 @@ static void encode_stateid(struct xdr_stream *xdr, const struct nfs_open_context
1052 1052
1053static int encode_read(struct xdr_stream *xdr, const struct nfs_readargs *args) 1053static int encode_read(struct xdr_stream *xdr, const struct nfs_readargs *args)
1054{ 1054{
1055 uint32_t *p; 1055 __be32 *p;
1056 1056
1057 RESERVE_SPACE(4); 1057 RESERVE_SPACE(4);
1058 WRITE32(OP_READ); 1058 WRITE32(OP_READ);
@@ -1074,7 +1074,7 @@ static int encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg
1074 FATTR4_WORD1_MOUNTED_ON_FILEID, 1074 FATTR4_WORD1_MOUNTED_ON_FILEID,
1075 }; 1075 };
1076 int replen; 1076 int replen;
1077 uint32_t *p; 1077 __be32 *p;
1078 1078
1079 RESERVE_SPACE(32+sizeof(nfs4_verifier)); 1079 RESERVE_SPACE(32+sizeof(nfs4_verifier));
1080 WRITE32(OP_READDIR); 1080 WRITE32(OP_READDIR);
@@ -1116,7 +1116,7 @@ static int encode_readlink(struct xdr_stream *xdr, const struct nfs4_readlink *r
1116{ 1116{
1117 struct rpc_auth *auth = req->rq_task->tk_auth; 1117 struct rpc_auth *auth = req->rq_task->tk_auth;
1118 unsigned int replen; 1118 unsigned int replen;
1119 uint32_t *p; 1119 __be32 *p;
1120 1120
1121 RESERVE_SPACE(4); 1121 RESERVE_SPACE(4);
1122 WRITE32(OP_READLINK); 1122 WRITE32(OP_READLINK);
@@ -1134,7 +1134,7 @@ static int encode_readlink(struct xdr_stream *xdr, const struct nfs4_readlink *r
1134 1134
1135static int encode_remove(struct xdr_stream *xdr, const struct qstr *name) 1135static int encode_remove(struct xdr_stream *xdr, const struct qstr *name)
1136{ 1136{
1137 uint32_t *p; 1137 __be32 *p;
1138 1138
1139 RESERVE_SPACE(8 + name->len); 1139 RESERVE_SPACE(8 + name->len);
1140 WRITE32(OP_REMOVE); 1140 WRITE32(OP_REMOVE);
@@ -1146,7 +1146,7 @@ static int encode_remove(struct xdr_stream *xdr, const struct qstr *name)
1146 1146
1147static int encode_rename(struct xdr_stream *xdr, const struct qstr *oldname, const struct qstr *newname) 1147static int encode_rename(struct xdr_stream *xdr, const struct qstr *oldname, const struct qstr *newname)
1148{ 1148{
1149 uint32_t *p; 1149 __be32 *p;
1150 1150
1151 RESERVE_SPACE(8 + oldname->len); 1151 RESERVE_SPACE(8 + oldname->len);
1152 WRITE32(OP_RENAME); 1152 WRITE32(OP_RENAME);
@@ -1162,7 +1162,7 @@ static int encode_rename(struct xdr_stream *xdr, const struct qstr *oldname, con
1162 1162
1163static int encode_renew(struct xdr_stream *xdr, const struct nfs_client *client_stateid) 1163static int encode_renew(struct xdr_stream *xdr, const struct nfs_client *client_stateid)
1164{ 1164{
1165 uint32_t *p; 1165 __be32 *p;
1166 1166
1167 RESERVE_SPACE(12); 1167 RESERVE_SPACE(12);
1168 WRITE32(OP_RENEW); 1168 WRITE32(OP_RENEW);
@@ -1174,7 +1174,7 @@ static int encode_renew(struct xdr_stream *xdr, const struct nfs_client *client_
1174static int 1174static int
1175encode_restorefh(struct xdr_stream *xdr) 1175encode_restorefh(struct xdr_stream *xdr)
1176{ 1176{
1177 uint32_t *p; 1177 __be32 *p;
1178 1178
1179 RESERVE_SPACE(4); 1179 RESERVE_SPACE(4);
1180 WRITE32(OP_RESTOREFH); 1180 WRITE32(OP_RESTOREFH);
@@ -1185,7 +1185,7 @@ encode_restorefh(struct xdr_stream *xdr)
1185static int 1185static int
1186encode_setacl(struct xdr_stream *xdr, struct nfs_setaclargs *arg) 1186encode_setacl(struct xdr_stream *xdr, struct nfs_setaclargs *arg)
1187{ 1187{
1188 uint32_t *p; 1188 __be32 *p;
1189 1189
1190 RESERVE_SPACE(4+sizeof(zero_stateid.data)); 1190 RESERVE_SPACE(4+sizeof(zero_stateid.data));
1191 WRITE32(OP_SETATTR); 1191 WRITE32(OP_SETATTR);
@@ -1204,7 +1204,7 @@ encode_setacl(struct xdr_stream *xdr, struct nfs_setaclargs *arg)
1204static int 1204static int
1205encode_savefh(struct xdr_stream *xdr) 1205encode_savefh(struct xdr_stream *xdr)
1206{ 1206{
1207 uint32_t *p; 1207 __be32 *p;
1208 1208
1209 RESERVE_SPACE(4); 1209 RESERVE_SPACE(4);
1210 WRITE32(OP_SAVEFH); 1210 WRITE32(OP_SAVEFH);
@@ -1215,7 +1215,7 @@ encode_savefh(struct xdr_stream *xdr)
1215static int encode_setattr(struct xdr_stream *xdr, const struct nfs_setattrargs *arg, const struct nfs_server *server) 1215static int encode_setattr(struct xdr_stream *xdr, const struct nfs_setattrargs *arg, const struct nfs_server *server)
1216{ 1216{
1217 int status; 1217 int status;
1218 uint32_t *p; 1218 __be32 *p;
1219 1219
1220 RESERVE_SPACE(4+sizeof(arg->stateid.data)); 1220 RESERVE_SPACE(4+sizeof(arg->stateid.data));
1221 WRITE32(OP_SETATTR); 1221 WRITE32(OP_SETATTR);
@@ -1229,7 +1229,7 @@ static int encode_setattr(struct xdr_stream *xdr, const struct nfs_setattrargs *
1229 1229
1230static int encode_setclientid(struct xdr_stream *xdr, const struct nfs4_setclientid *setclientid) 1230static int encode_setclientid(struct xdr_stream *xdr, const struct nfs4_setclientid *setclientid)
1231{ 1231{
1232 uint32_t *p; 1232 __be32 *p;
1233 1233
1234 RESERVE_SPACE(4 + sizeof(setclientid->sc_verifier->data)); 1234 RESERVE_SPACE(4 + sizeof(setclientid->sc_verifier->data));
1235 WRITE32(OP_SETCLIENTID); 1235 WRITE32(OP_SETCLIENTID);
@@ -1248,7 +1248,7 @@ static int encode_setclientid(struct xdr_stream *xdr, const struct nfs4_setclien
1248 1248
1249static int encode_setclientid_confirm(struct xdr_stream *xdr, const struct nfs_client *client_state) 1249static int encode_setclientid_confirm(struct xdr_stream *xdr, const struct nfs_client *client_state)
1250{ 1250{
1251 uint32_t *p; 1251 __be32 *p;
1252 1252
1253 RESERVE_SPACE(12 + sizeof(client_state->cl_confirm.data)); 1253 RESERVE_SPACE(12 + sizeof(client_state->cl_confirm.data));
1254 WRITE32(OP_SETCLIENTID_CONFIRM); 1254 WRITE32(OP_SETCLIENTID_CONFIRM);
@@ -1260,7 +1260,7 @@ static int encode_setclientid_confirm(struct xdr_stream *xdr, const struct nfs_c
1260 1260
1261static int encode_write(struct xdr_stream *xdr, const struct nfs_writeargs *args) 1261static int encode_write(struct xdr_stream *xdr, const struct nfs_writeargs *args)
1262{ 1262{
1263 uint32_t *p; 1263 __be32 *p;
1264 1264
1265 RESERVE_SPACE(4); 1265 RESERVE_SPACE(4);
1266 WRITE32(OP_WRITE); 1266 WRITE32(OP_WRITE);
@@ -1279,7 +1279,7 @@ static int encode_write(struct xdr_stream *xdr, const struct nfs_writeargs *args
1279 1279
1280static int encode_delegreturn(struct xdr_stream *xdr, const nfs4_stateid *stateid) 1280static int encode_delegreturn(struct xdr_stream *xdr, const nfs4_stateid *stateid)
1281{ 1281{
1282 uint32_t *p; 1282 __be32 *p;
1283 1283
1284 RESERVE_SPACE(20); 1284 RESERVE_SPACE(20);
1285 1285
@@ -1295,7 +1295,7 @@ static int encode_delegreturn(struct xdr_stream *xdr, const nfs4_stateid *statei
1295/* 1295/*
1296 * Encode an ACCESS request 1296 * Encode an ACCESS request
1297 */ 1297 */
1298static int nfs4_xdr_enc_access(struct rpc_rqst *req, uint32_t *p, const struct nfs4_accessargs *args) 1298static int nfs4_xdr_enc_access(struct rpc_rqst *req, __be32 *p, const struct nfs4_accessargs *args)
1299{ 1299{
1300 struct xdr_stream xdr; 1300 struct xdr_stream xdr;
1301 struct compound_hdr hdr = { 1301 struct compound_hdr hdr = {
@@ -1313,7 +1313,7 @@ static int nfs4_xdr_enc_access(struct rpc_rqst *req, uint32_t *p, const struct n
1313/* 1313/*
1314 * Encode LOOKUP request 1314 * Encode LOOKUP request
1315 */ 1315 */
1316static int nfs4_xdr_enc_lookup(struct rpc_rqst *req, uint32_t *p, const struct nfs4_lookup_arg *args) 1316static int nfs4_xdr_enc_lookup(struct rpc_rqst *req, __be32 *p, const struct nfs4_lookup_arg *args)
1317{ 1317{
1318 struct xdr_stream xdr; 1318 struct xdr_stream xdr;
1319 struct compound_hdr hdr = { 1319 struct compound_hdr hdr = {
@@ -1337,7 +1337,7 @@ out:
1337/* 1337/*
1338 * Encode LOOKUP_ROOT request 1338 * Encode LOOKUP_ROOT request
1339 */ 1339 */
1340static int nfs4_xdr_enc_lookup_root(struct rpc_rqst *req, uint32_t *p, const struct nfs4_lookup_root_arg *args) 1340static int nfs4_xdr_enc_lookup_root(struct rpc_rqst *req, __be32 *p, const struct nfs4_lookup_root_arg *args)
1341{ 1341{
1342 struct xdr_stream xdr; 1342 struct xdr_stream xdr;
1343 struct compound_hdr hdr = { 1343 struct compound_hdr hdr = {
@@ -1358,7 +1358,7 @@ out:
1358/* 1358/*
1359 * Encode REMOVE request 1359 * Encode REMOVE request
1360 */ 1360 */
1361static int nfs4_xdr_enc_remove(struct rpc_rqst *req, uint32_t *p, const struct nfs4_remove_arg *args) 1361static int nfs4_xdr_enc_remove(struct rpc_rqst *req, __be32 *p, const struct nfs4_remove_arg *args)
1362{ 1362{
1363 struct xdr_stream xdr; 1363 struct xdr_stream xdr;
1364 struct compound_hdr hdr = { 1364 struct compound_hdr hdr = {
@@ -1380,7 +1380,7 @@ out:
1380/* 1380/*
1381 * Encode RENAME request 1381 * Encode RENAME request
1382 */ 1382 */
1383static int nfs4_xdr_enc_rename(struct rpc_rqst *req, uint32_t *p, const struct nfs4_rename_arg *args) 1383static int nfs4_xdr_enc_rename(struct rpc_rqst *req, __be32 *p, const struct nfs4_rename_arg *args)
1384{ 1384{
1385 struct xdr_stream xdr; 1385 struct xdr_stream xdr;
1386 struct compound_hdr hdr = { 1386 struct compound_hdr hdr = {
@@ -1410,7 +1410,7 @@ out:
1410/* 1410/*
1411 * Encode LINK request 1411 * Encode LINK request
1412 */ 1412 */
1413static int nfs4_xdr_enc_link(struct rpc_rqst *req, uint32_t *p, const struct nfs4_link_arg *args) 1413static int nfs4_xdr_enc_link(struct rpc_rqst *req, __be32 *p, const struct nfs4_link_arg *args)
1414{ 1414{
1415 struct xdr_stream xdr; 1415 struct xdr_stream xdr;
1416 struct compound_hdr hdr = { 1416 struct compound_hdr hdr = {
@@ -1440,7 +1440,7 @@ out:
1440/* 1440/*
1441 * Encode CREATE request 1441 * Encode CREATE request
1442 */ 1442 */
1443static int nfs4_xdr_enc_create(struct rpc_rqst *req, uint32_t *p, const struct nfs4_create_arg *args) 1443static int nfs4_xdr_enc_create(struct rpc_rqst *req, __be32 *p, const struct nfs4_create_arg *args)
1444{ 1444{
1445 struct xdr_stream xdr; 1445 struct xdr_stream xdr;
1446 struct compound_hdr hdr = { 1446 struct compound_hdr hdr = {
@@ -1470,7 +1470,7 @@ out:
1470/* 1470/*
1471 * Encode SYMLINK request 1471 * Encode SYMLINK request
1472 */ 1472 */
1473static int nfs4_xdr_enc_symlink(struct rpc_rqst *req, uint32_t *p, const struct nfs4_create_arg *args) 1473static int nfs4_xdr_enc_symlink(struct rpc_rqst *req, __be32 *p, const struct nfs4_create_arg *args)
1474{ 1474{
1475 return nfs4_xdr_enc_create(req, p, args); 1475 return nfs4_xdr_enc_create(req, p, args);
1476} 1476}
@@ -1478,7 +1478,7 @@ static int nfs4_xdr_enc_symlink(struct rpc_rqst *req, uint32_t *p, const struct
1478/* 1478/*
1479 * Encode GETATTR request 1479 * Encode GETATTR request
1480 */ 1480 */
1481static int nfs4_xdr_enc_getattr(struct rpc_rqst *req, uint32_t *p, const struct nfs4_getattr_arg *args) 1481static int nfs4_xdr_enc_getattr(struct rpc_rqst *req, __be32 *p, const struct nfs4_getattr_arg *args)
1482{ 1482{
1483 struct xdr_stream xdr; 1483 struct xdr_stream xdr;
1484 struct compound_hdr hdr = { 1484 struct compound_hdr hdr = {
@@ -1496,7 +1496,7 @@ static int nfs4_xdr_enc_getattr(struct rpc_rqst *req, uint32_t *p, const struct
1496/* 1496/*
1497 * Encode a CLOSE request 1497 * Encode a CLOSE request
1498 */ 1498 */
1499static int nfs4_xdr_enc_close(struct rpc_rqst *req, uint32_t *p, struct nfs_closeargs *args) 1499static int nfs4_xdr_enc_close(struct rpc_rqst *req, __be32 *p, struct nfs_closeargs *args)
1500{ 1500{
1501 struct xdr_stream xdr; 1501 struct xdr_stream xdr;
1502 struct compound_hdr hdr = { 1502 struct compound_hdr hdr = {
@@ -1520,7 +1520,7 @@ out:
1520/* 1520/*
1521 * Encode an OPEN request 1521 * Encode an OPEN request
1522 */ 1522 */
1523static int nfs4_xdr_enc_open(struct rpc_rqst *req, uint32_t *p, struct nfs_openargs *args) 1523static int nfs4_xdr_enc_open(struct rpc_rqst *req, __be32 *p, struct nfs_openargs *args)
1524{ 1524{
1525 struct xdr_stream xdr; 1525 struct xdr_stream xdr;
1526 struct compound_hdr hdr = { 1526 struct compound_hdr hdr = {
@@ -1556,7 +1556,7 @@ out:
1556/* 1556/*
1557 * Encode an OPEN_CONFIRM request 1557 * Encode an OPEN_CONFIRM request
1558 */ 1558 */
1559static int nfs4_xdr_enc_open_confirm(struct rpc_rqst *req, uint32_t *p, struct nfs_open_confirmargs *args) 1559static int nfs4_xdr_enc_open_confirm(struct rpc_rqst *req, __be32 *p, struct nfs_open_confirmargs *args)
1560{ 1560{
1561 struct xdr_stream xdr; 1561 struct xdr_stream xdr;
1562 struct compound_hdr hdr = { 1562 struct compound_hdr hdr = {
@@ -1577,7 +1577,7 @@ out:
1577/* 1577/*
1578 * Encode an OPEN request with no attributes. 1578 * Encode an OPEN request with no attributes.
1579 */ 1579 */
1580static int nfs4_xdr_enc_open_noattr(struct rpc_rqst *req, uint32_t *p, struct nfs_openargs *args) 1580static int nfs4_xdr_enc_open_noattr(struct rpc_rqst *req, __be32 *p, struct nfs_openargs *args)
1581{ 1581{
1582 struct xdr_stream xdr; 1582 struct xdr_stream xdr;
1583 struct compound_hdr hdr = { 1583 struct compound_hdr hdr = {
@@ -1601,7 +1601,7 @@ out:
1601/* 1601/*
1602 * Encode an OPEN_DOWNGRADE request 1602 * Encode an OPEN_DOWNGRADE request
1603 */ 1603 */
1604static int nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req, uint32_t *p, struct nfs_closeargs *args) 1604static int nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req, __be32 *p, struct nfs_closeargs *args)
1605{ 1605{
1606 struct xdr_stream xdr; 1606 struct xdr_stream xdr;
1607 struct compound_hdr hdr = { 1607 struct compound_hdr hdr = {
@@ -1625,7 +1625,7 @@ out:
1625/* 1625/*
1626 * Encode a LOCK request 1626 * Encode a LOCK request
1627 */ 1627 */
1628static int nfs4_xdr_enc_lock(struct rpc_rqst *req, uint32_t *p, struct nfs_lock_args *args) 1628static int nfs4_xdr_enc_lock(struct rpc_rqst *req, __be32 *p, struct nfs_lock_args *args)
1629{ 1629{
1630 struct xdr_stream xdr; 1630 struct xdr_stream xdr;
1631 struct compound_hdr hdr = { 1631 struct compound_hdr hdr = {
@@ -1646,7 +1646,7 @@ out:
1646/* 1646/*
1647 * Encode a LOCKT request 1647 * Encode a LOCKT request
1648 */ 1648 */
1649static int nfs4_xdr_enc_lockt(struct rpc_rqst *req, uint32_t *p, struct nfs_lockt_args *args) 1649static int nfs4_xdr_enc_lockt(struct rpc_rqst *req, __be32 *p, struct nfs_lockt_args *args)
1650{ 1650{
1651 struct xdr_stream xdr; 1651 struct xdr_stream xdr;
1652 struct compound_hdr hdr = { 1652 struct compound_hdr hdr = {
@@ -1667,7 +1667,7 @@ out:
1667/* 1667/*
1668 * Encode a LOCKU request 1668 * Encode a LOCKU request
1669 */ 1669 */
1670static int nfs4_xdr_enc_locku(struct rpc_rqst *req, uint32_t *p, struct nfs_locku_args *args) 1670static int nfs4_xdr_enc_locku(struct rpc_rqst *req, __be32 *p, struct nfs_locku_args *args)
1671{ 1671{
1672 struct xdr_stream xdr; 1672 struct xdr_stream xdr;
1673 struct compound_hdr hdr = { 1673 struct compound_hdr hdr = {
@@ -1688,7 +1688,7 @@ out:
1688/* 1688/*
1689 * Encode a READLINK request 1689 * Encode a READLINK request
1690 */ 1690 */
1691static int nfs4_xdr_enc_readlink(struct rpc_rqst *req, uint32_t *p, const struct nfs4_readlink *args) 1691static int nfs4_xdr_enc_readlink(struct rpc_rqst *req, __be32 *p, const struct nfs4_readlink *args)
1692{ 1692{
1693 struct xdr_stream xdr; 1693 struct xdr_stream xdr;
1694 struct compound_hdr hdr = { 1694 struct compound_hdr hdr = {
@@ -1709,7 +1709,7 @@ out:
1709/* 1709/*
1710 * Encode a READDIR request 1710 * Encode a READDIR request
1711 */ 1711 */
1712static int nfs4_xdr_enc_readdir(struct rpc_rqst *req, uint32_t *p, const struct nfs4_readdir_arg *args) 1712static int nfs4_xdr_enc_readdir(struct rpc_rqst *req, __be32 *p, const struct nfs4_readdir_arg *args)
1713{ 1713{
1714 struct xdr_stream xdr; 1714 struct xdr_stream xdr;
1715 struct compound_hdr hdr = { 1715 struct compound_hdr hdr = {
@@ -1730,7 +1730,7 @@ out:
1730/* 1730/*
1731 * Encode a READ request 1731 * Encode a READ request
1732 */ 1732 */
1733static int nfs4_xdr_enc_read(struct rpc_rqst *req, uint32_t *p, struct nfs_readargs *args) 1733static int nfs4_xdr_enc_read(struct rpc_rqst *req, __be32 *p, struct nfs_readargs *args)
1734{ 1734{
1735 struct rpc_auth *auth = req->rq_task->tk_auth; 1735 struct rpc_auth *auth = req->rq_task->tk_auth;
1736 struct xdr_stream xdr; 1736 struct xdr_stream xdr;
@@ -1762,7 +1762,7 @@ out:
1762/* 1762/*
1763 * Encode an SETATTR request 1763 * Encode an SETATTR request
1764 */ 1764 */
1765static int nfs4_xdr_enc_setattr(struct rpc_rqst *req, uint32_t *p, struct nfs_setattrargs *args) 1765static int nfs4_xdr_enc_setattr(struct rpc_rqst *req, __be32 *p, struct nfs_setattrargs *args)
1766 1766
1767{ 1767{
1768 struct xdr_stream xdr; 1768 struct xdr_stream xdr;
@@ -1788,7 +1788,7 @@ out:
1788 * Encode a GETACL request 1788 * Encode a GETACL request
1789 */ 1789 */
1790static int 1790static int
1791nfs4_xdr_enc_getacl(struct rpc_rqst *req, uint32_t *p, 1791nfs4_xdr_enc_getacl(struct rpc_rqst *req, __be32 *p,
1792 struct nfs_getaclargs *args) 1792 struct nfs_getaclargs *args)
1793{ 1793{
1794 struct xdr_stream xdr; 1794 struct xdr_stream xdr;
@@ -1815,7 +1815,7 @@ out:
1815/* 1815/*
1816 * Encode a WRITE request 1816 * Encode a WRITE request
1817 */ 1817 */
1818static int nfs4_xdr_enc_write(struct rpc_rqst *req, uint32_t *p, struct nfs_writeargs *args) 1818static int nfs4_xdr_enc_write(struct rpc_rqst *req, __be32 *p, struct nfs_writeargs *args)
1819{ 1819{
1820 struct xdr_stream xdr; 1820 struct xdr_stream xdr;
1821 struct compound_hdr hdr = { 1821 struct compound_hdr hdr = {
@@ -1839,7 +1839,7 @@ out:
1839/* 1839/*
1840 * a COMMIT request 1840 * a COMMIT request
1841 */ 1841 */
1842static int nfs4_xdr_enc_commit(struct rpc_rqst *req, uint32_t *p, struct nfs_writeargs *args) 1842static int nfs4_xdr_enc_commit(struct rpc_rqst *req, __be32 *p, struct nfs_writeargs *args)
1843{ 1843{
1844 struct xdr_stream xdr; 1844 struct xdr_stream xdr;
1845 struct compound_hdr hdr = { 1845 struct compound_hdr hdr = {
@@ -1863,7 +1863,7 @@ out:
1863/* 1863/*
1864 * FSINFO request 1864 * FSINFO request
1865 */ 1865 */
1866static int nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, uint32_t *p, struct nfs4_fsinfo_arg *args) 1866static int nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, __be32 *p, struct nfs4_fsinfo_arg *args)
1867{ 1867{
1868 struct xdr_stream xdr; 1868 struct xdr_stream xdr;
1869 struct compound_hdr hdr = { 1869 struct compound_hdr hdr = {
@@ -1882,7 +1882,7 @@ static int nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, uint32_t *p, struct nfs4_fs
1882/* 1882/*
1883 * a PATHCONF request 1883 * a PATHCONF request
1884 */ 1884 */
1885static int nfs4_xdr_enc_pathconf(struct rpc_rqst *req, uint32_t *p, const struct nfs4_pathconf_arg *args) 1885static int nfs4_xdr_enc_pathconf(struct rpc_rqst *req, __be32 *p, const struct nfs4_pathconf_arg *args)
1886{ 1886{
1887 struct xdr_stream xdr; 1887 struct xdr_stream xdr;
1888 struct compound_hdr hdr = { 1888 struct compound_hdr hdr = {
@@ -1902,7 +1902,7 @@ static int nfs4_xdr_enc_pathconf(struct rpc_rqst *req, uint32_t *p, const struct
1902/* 1902/*
1903 * a STATFS request 1903 * a STATFS request
1904 */ 1904 */
1905static int nfs4_xdr_enc_statfs(struct rpc_rqst *req, uint32_t *p, const struct nfs4_statfs_arg *args) 1905static int nfs4_xdr_enc_statfs(struct rpc_rqst *req, __be32 *p, const struct nfs4_statfs_arg *args)
1906{ 1906{
1907 struct xdr_stream xdr; 1907 struct xdr_stream xdr;
1908 struct compound_hdr hdr = { 1908 struct compound_hdr hdr = {
@@ -1923,7 +1923,7 @@ static int nfs4_xdr_enc_statfs(struct rpc_rqst *req, uint32_t *p, const struct n
1923/* 1923/*
1924 * GETATTR_BITMAP request 1924 * GETATTR_BITMAP request
1925 */ 1925 */
1926static int nfs4_xdr_enc_server_caps(struct rpc_rqst *req, uint32_t *p, const struct nfs_fh *fhandle) 1926static int nfs4_xdr_enc_server_caps(struct rpc_rqst *req, __be32 *p, const struct nfs_fh *fhandle)
1927{ 1927{
1928 struct xdr_stream xdr; 1928 struct xdr_stream xdr;
1929 struct compound_hdr hdr = { 1929 struct compound_hdr hdr = {
@@ -1945,7 +1945,7 @@ static int nfs4_xdr_enc_server_caps(struct rpc_rqst *req, uint32_t *p, const str
1945/* 1945/*
1946 * a RENEW request 1946 * a RENEW request
1947 */ 1947 */
1948static int nfs4_xdr_enc_renew(struct rpc_rqst *req, uint32_t *p, struct nfs_client *clp) 1948static int nfs4_xdr_enc_renew(struct rpc_rqst *req, __be32 *p, struct nfs_client *clp)
1949{ 1949{
1950 struct xdr_stream xdr; 1950 struct xdr_stream xdr;
1951 struct compound_hdr hdr = { 1951 struct compound_hdr hdr = {
@@ -1960,7 +1960,7 @@ static int nfs4_xdr_enc_renew(struct rpc_rqst *req, uint32_t *p, struct nfs_clie
1960/* 1960/*
1961 * a SETCLIENTID request 1961 * a SETCLIENTID request
1962 */ 1962 */
1963static int nfs4_xdr_enc_setclientid(struct rpc_rqst *req, uint32_t *p, struct nfs4_setclientid *sc) 1963static int nfs4_xdr_enc_setclientid(struct rpc_rqst *req, __be32 *p, struct nfs4_setclientid *sc)
1964{ 1964{
1965 struct xdr_stream xdr; 1965 struct xdr_stream xdr;
1966 struct compound_hdr hdr = { 1966 struct compound_hdr hdr = {
@@ -1975,7 +1975,7 @@ static int nfs4_xdr_enc_setclientid(struct rpc_rqst *req, uint32_t *p, struct nf
1975/* 1975/*
1976 * a SETCLIENTID_CONFIRM request 1976 * a SETCLIENTID_CONFIRM request
1977 */ 1977 */
1978static int nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, uint32_t *p, struct nfs_client *clp) 1978static int nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, __be32 *p, struct nfs_client *clp)
1979{ 1979{
1980 struct xdr_stream xdr; 1980 struct xdr_stream xdr;
1981 struct compound_hdr hdr = { 1981 struct compound_hdr hdr = {
@@ -1997,7 +1997,7 @@ static int nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, uint32_t *p, s
1997/* 1997/*
1998 * DELEGRETURN request 1998 * DELEGRETURN request
1999 */ 1999 */
2000static int nfs4_xdr_enc_delegreturn(struct rpc_rqst *req, uint32_t *p, const struct nfs4_delegreturnargs *args) 2000static int nfs4_xdr_enc_delegreturn(struct rpc_rqst *req, __be32 *p, const struct nfs4_delegreturnargs *args)
2001{ 2001{
2002 struct xdr_stream xdr; 2002 struct xdr_stream xdr;
2003 struct compound_hdr hdr = { 2003 struct compound_hdr hdr = {
@@ -2021,7 +2021,7 @@ out:
2021/* 2021/*
2022 * Encode FS_LOCATIONS request 2022 * Encode FS_LOCATIONS request
2023 */ 2023 */
2024static int nfs4_xdr_enc_fs_locations(struct rpc_rqst *req, uint32_t *p, struct nfs4_fs_locations_arg *args) 2024static int nfs4_xdr_enc_fs_locations(struct rpc_rqst *req, __be32 *p, struct nfs4_fs_locations_arg *args)
2025{ 2025{
2026 struct xdr_stream xdr; 2026 struct xdr_stream xdr;
2027 struct compound_hdr hdr = { 2027 struct compound_hdr hdr = {
@@ -2086,7 +2086,7 @@ out:
2086 2086
2087static int decode_opaque_inline(struct xdr_stream *xdr, unsigned int *len, char **string) 2087static int decode_opaque_inline(struct xdr_stream *xdr, unsigned int *len, char **string)
2088{ 2088{
2089 uint32_t *p; 2089 __be32 *p;
2090 2090
2091 READ_BUF(4); 2091 READ_BUF(4);
2092 READ32(*len); 2092 READ32(*len);
@@ -2097,7 +2097,7 @@ static int decode_opaque_inline(struct xdr_stream *xdr, unsigned int *len, char
2097 2097
2098static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr) 2098static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr)
2099{ 2099{
2100 uint32_t *p; 2100 __be32 *p;
2101 2101
2102 READ_BUF(8); 2102 READ_BUF(8);
2103 READ32(hdr->status); 2103 READ32(hdr->status);
@@ -2112,7 +2112,7 @@ static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr)
2112 2112
2113static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected) 2113static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected)
2114{ 2114{
2115 uint32_t *p; 2115 __be32 *p;
2116 uint32_t opnum; 2116 uint32_t opnum;
2117 int32_t nfserr; 2117 int32_t nfserr;
2118 2118
@@ -2134,7 +2134,7 @@ static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected)
2134/* Dummy routine */ 2134/* Dummy routine */
2135static int decode_ace(struct xdr_stream *xdr, void *ace, struct nfs_client *clp) 2135static int decode_ace(struct xdr_stream *xdr, void *ace, struct nfs_client *clp)
2136{ 2136{
2137 uint32_t *p; 2137 __be32 *p;
2138 unsigned int strlen; 2138 unsigned int strlen;
2139 char *str; 2139 char *str;
2140 2140
@@ -2144,7 +2144,8 @@ static int decode_ace(struct xdr_stream *xdr, void *ace, struct nfs_client *clp)
2144 2144
2145static int decode_attr_bitmap(struct xdr_stream *xdr, uint32_t *bitmap) 2145static int decode_attr_bitmap(struct xdr_stream *xdr, uint32_t *bitmap)
2146{ 2146{
2147 uint32_t bmlen, *p; 2147 uint32_t bmlen;
2148 __be32 *p;
2148 2149
2149 READ_BUF(4); 2150 READ_BUF(4);
2150 READ32(bmlen); 2151 READ32(bmlen);
@@ -2159,9 +2160,9 @@ static int decode_attr_bitmap(struct xdr_stream *xdr, uint32_t *bitmap)
2159 return 0; 2160 return 0;
2160} 2161}
2161 2162
2162static inline int decode_attr_length(struct xdr_stream *xdr, uint32_t *attrlen, uint32_t **savep) 2163static inline int decode_attr_length(struct xdr_stream *xdr, uint32_t *attrlen, __be32 **savep)
2163{ 2164{
2164 uint32_t *p; 2165 __be32 *p;
2165 2166
2166 READ_BUF(4); 2167 READ_BUF(4);
2167 READ32(*attrlen); 2168 READ32(*attrlen);
@@ -2182,7 +2183,7 @@ static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint3
2182 2183
2183static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *type) 2184static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *type)
2184{ 2185{
2185 uint32_t *p; 2186 __be32 *p;
2186 2187
2187 *type = 0; 2188 *type = 0;
2188 if (unlikely(bitmap[0] & (FATTR4_WORD0_TYPE - 1U))) 2189 if (unlikely(bitmap[0] & (FATTR4_WORD0_TYPE - 1U)))
@@ -2202,7 +2203,7 @@ static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *
2202 2203
2203static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *change) 2204static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *change)
2204{ 2205{
2205 uint32_t *p; 2206 __be32 *p;
2206 2207
2207 *change = 0; 2208 *change = 0;
2208 if (unlikely(bitmap[0] & (FATTR4_WORD0_CHANGE - 1U))) 2209 if (unlikely(bitmap[0] & (FATTR4_WORD0_CHANGE - 1U)))
@@ -2219,7 +2220,7 @@ static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t
2219 2220
2220static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *size) 2221static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *size)
2221{ 2222{
2222 uint32_t *p; 2223 __be32 *p;
2223 2224
2224 *size = 0; 2225 *size = 0;
2225 if (unlikely(bitmap[0] & (FATTR4_WORD0_SIZE - 1U))) 2226 if (unlikely(bitmap[0] & (FATTR4_WORD0_SIZE - 1U)))
@@ -2235,7 +2236,7 @@ static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *
2235 2236
2236static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) 2237static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
2237{ 2238{
2238 uint32_t *p; 2239 __be32 *p;
2239 2240
2240 *res = 0; 2241 *res = 0;
2241 if (unlikely(bitmap[0] & (FATTR4_WORD0_LINK_SUPPORT - 1U))) 2242 if (unlikely(bitmap[0] & (FATTR4_WORD0_LINK_SUPPORT - 1U)))
@@ -2251,7 +2252,7 @@ static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, ui
2251 2252
2252static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) 2253static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
2253{ 2254{
2254 uint32_t *p; 2255 __be32 *p;
2255 2256
2256 *res = 0; 2257 *res = 0;
2257 if (unlikely(bitmap[0] & (FATTR4_WORD0_SYMLINK_SUPPORT - 1U))) 2258 if (unlikely(bitmap[0] & (FATTR4_WORD0_SYMLINK_SUPPORT - 1U)))
@@ -2267,7 +2268,7 @@ static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap,
2267 2268
2268static int decode_attr_fsid(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fsid *fsid) 2269static int decode_attr_fsid(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fsid *fsid)
2269{ 2270{
2270 uint32_t *p; 2271 __be32 *p;
2271 2272
2272 fsid->major = 0; 2273 fsid->major = 0;
2273 fsid->minor = 0; 2274 fsid->minor = 0;
@@ -2287,7 +2288,7 @@ static int decode_attr_fsid(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs
2287 2288
2288static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) 2289static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
2289{ 2290{
2290 uint32_t *p; 2291 __be32 *p;
2291 2292
2292 *res = 60; 2293 *res = 60;
2293 if (unlikely(bitmap[0] & (FATTR4_WORD0_LEASE_TIME - 1U))) 2294 if (unlikely(bitmap[0] & (FATTR4_WORD0_LEASE_TIME - 1U)))
@@ -2303,7 +2304,7 @@ static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint
2303 2304
2304static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) 2305static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
2305{ 2306{
2306 uint32_t *p; 2307 __be32 *p;
2307 2308
2308 *res = ACL4_SUPPORT_ALLOW_ACL|ACL4_SUPPORT_DENY_ACL; 2309 *res = ACL4_SUPPORT_ALLOW_ACL|ACL4_SUPPORT_DENY_ACL;
2309 if (unlikely(bitmap[0] & (FATTR4_WORD0_ACLSUPPORT - 1U))) 2310 if (unlikely(bitmap[0] & (FATTR4_WORD0_ACLSUPPORT - 1U)))
@@ -2319,7 +2320,7 @@ static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint
2319 2320
2320static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) 2321static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid)
2321{ 2322{
2322 uint32_t *p; 2323 __be32 *p;
2323 2324
2324 *fileid = 0; 2325 *fileid = 0;
2325 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEID - 1U))) 2326 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEID - 1U)))
@@ -2335,7 +2336,7 @@ static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t
2335 2336
2336static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) 2337static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid)
2337{ 2338{
2338 uint32_t *p; 2339 __be32 *p;
2339 2340
2340 *fileid = 0; 2341 *fileid = 0;
2341 if (unlikely(bitmap[1] & (FATTR4_WORD1_MOUNTED_ON_FILEID - 1U))) 2342 if (unlikely(bitmap[1] & (FATTR4_WORD1_MOUNTED_ON_FILEID - 1U)))
@@ -2351,7 +2352,7 @@ static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitma
2351 2352
2352static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) 2353static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
2353{ 2354{
2354 uint32_t *p; 2355 __be32 *p;
2355 int status = 0; 2356 int status = 0;
2356 2357
2357 *res = 0; 2358 *res = 0;
@@ -2368,7 +2369,7 @@ static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uin
2368 2369
2369static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) 2370static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
2370{ 2371{
2371 uint32_t *p; 2372 __be32 *p;
2372 int status = 0; 2373 int status = 0;
2373 2374
2374 *res = 0; 2375 *res = 0;
@@ -2385,7 +2386,7 @@ static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint
2385 2386
2386static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) 2387static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
2387{ 2388{
2388 uint32_t *p; 2389 __be32 *p;
2389 int status = 0; 2390 int status = 0;
2390 2391
2391 *res = 0; 2392 *res = 0;
@@ -2403,7 +2404,7 @@ static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uin
2403static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path) 2404static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path)
2404{ 2405{
2405 int n; 2406 int n;
2406 uint32_t *p; 2407 __be32 *p;
2407 int status = 0; 2408 int status = 0;
2408 2409
2409 READ_BUF(4); 2410 READ_BUF(4);
@@ -2448,7 +2449,7 @@ out_eio:
2448static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs4_fs_locations *res) 2449static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs4_fs_locations *res)
2449{ 2450{
2450 int n; 2451 int n;
2451 uint32_t *p; 2452 __be32 *p;
2452 int status = -EIO; 2453 int status = -EIO;
2453 2454
2454 if (unlikely(bitmap[0] & (FATTR4_WORD0_FS_LOCATIONS -1U))) 2455 if (unlikely(bitmap[0] & (FATTR4_WORD0_FS_LOCATIONS -1U)))
@@ -2512,7 +2513,7 @@ out_eio:
2512 2513
2513static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) 2514static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
2514{ 2515{
2515 uint32_t *p; 2516 __be32 *p;
2516 int status = 0; 2517 int status = 0;
2517 2518
2518 *res = 0; 2519 *res = 0;
@@ -2529,7 +2530,7 @@ static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uin
2529 2530
2530static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxlink) 2531static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxlink)
2531{ 2532{
2532 uint32_t *p; 2533 __be32 *p;
2533 int status = 0; 2534 int status = 0;
2534 2535
2535 *maxlink = 1; 2536 *maxlink = 1;
@@ -2546,7 +2547,7 @@ static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_
2546 2547
2547static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxname) 2548static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxname)
2548{ 2549{
2549 uint32_t *p; 2550 __be32 *p;
2550 int status = 0; 2551 int status = 0;
2551 2552
2552 *maxname = 1024; 2553 *maxname = 1024;
@@ -2563,7 +2564,7 @@ static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_
2563 2564
2564static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) 2565static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
2565{ 2566{
2566 uint32_t *p; 2567 __be32 *p;
2567 int status = 0; 2568 int status = 0;
2568 2569
2569 *res = 1024; 2570 *res = 1024;
@@ -2584,7 +2585,7 @@ static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_
2584 2585
2585static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) 2586static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
2586{ 2587{
2587 uint32_t *p; 2588 __be32 *p;
2588 int status = 0; 2589 int status = 0;
2589 2590
2590 *res = 1024; 2591 *res = 1024;
@@ -2605,7 +2606,7 @@ static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32
2605 2606
2606static int decode_attr_mode(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *mode) 2607static int decode_attr_mode(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *mode)
2607{ 2608{
2608 uint32_t *p; 2609 __be32 *p;
2609 2610
2610 *mode = 0; 2611 *mode = 0;
2611 if (unlikely(bitmap[1] & (FATTR4_WORD1_MODE - 1U))) 2612 if (unlikely(bitmap[1] & (FATTR4_WORD1_MODE - 1U)))
@@ -2622,7 +2623,7 @@ static int decode_attr_mode(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *
2622 2623
2623static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *nlink) 2624static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *nlink)
2624{ 2625{
2625 uint32_t *p; 2626 __be32 *p;
2626 2627
2627 *nlink = 1; 2628 *nlink = 1;
2628 if (unlikely(bitmap[1] & (FATTR4_WORD1_NUMLINKS - 1U))) 2629 if (unlikely(bitmap[1] & (FATTR4_WORD1_NUMLINKS - 1U)))
@@ -2638,7 +2639,8 @@ static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t
2638 2639
2639static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_client *clp, int32_t *uid) 2640static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_client *clp, int32_t *uid)
2640{ 2641{
2641 uint32_t len, *p; 2642 uint32_t len;
2643 __be32 *p;
2642 2644
2643 *uid = -2; 2645 *uid = -2;
2644 if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER - 1U))) 2646 if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER - 1U)))
@@ -2662,7 +2664,8 @@ static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, struct nf
2662 2664
2663static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_client *clp, int32_t *gid) 2665static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_client *clp, int32_t *gid)
2664{ 2666{
2665 uint32_t len, *p; 2667 uint32_t len;
2668 __be32 *p;
2666 2669
2667 *gid = -2; 2670 *gid = -2;
2668 if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER_GROUP - 1U))) 2671 if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER_GROUP - 1U)))
@@ -2686,7 +2689,8 @@ static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, struct nf
2686 2689
2687static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rdev) 2690static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rdev)
2688{ 2691{
2689 uint32_t major = 0, minor = 0, *p; 2692 uint32_t major = 0, minor = 0;
2693 __be32 *p;
2690 2694
2691 *rdev = MKDEV(0,0); 2695 *rdev = MKDEV(0,0);
2692 if (unlikely(bitmap[1] & (FATTR4_WORD1_RAWDEV - 1U))) 2696 if (unlikely(bitmap[1] & (FATTR4_WORD1_RAWDEV - 1U)))
@@ -2708,7 +2712,7 @@ static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rde
2708 2712
2709static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) 2713static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
2710{ 2714{
2711 uint32_t *p; 2715 __be32 *p;
2712 int status = 0; 2716 int status = 0;
2713 2717
2714 *res = 0; 2718 *res = 0;
@@ -2725,7 +2729,7 @@ static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uin
2725 2729
2726static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) 2730static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
2727{ 2731{
2728 uint32_t *p; 2732 __be32 *p;
2729 int status = 0; 2733 int status = 0;
2730 2734
2731 *res = 0; 2735 *res = 0;
@@ -2742,7 +2746,7 @@ static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint
2742 2746
2743static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) 2747static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
2744{ 2748{
2745 uint32_t *p; 2749 __be32 *p;
2746 int status = 0; 2750 int status = 0;
2747 2751
2748 *res = 0; 2752 *res = 0;
@@ -2759,7 +2763,7 @@ static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uin
2759 2763
2760static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *used) 2764static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *used)
2761{ 2765{
2762 uint32_t *p; 2766 __be32 *p;
2763 2767
2764 *used = 0; 2768 *used = 0;
2765 if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_USED - 1U))) 2769 if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_USED - 1U)))
@@ -2776,7 +2780,7 @@ static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint
2776 2780
2777static int decode_attr_time(struct xdr_stream *xdr, struct timespec *time) 2781static int decode_attr_time(struct xdr_stream *xdr, struct timespec *time)
2778{ 2782{
2779 uint32_t *p; 2783 __be32 *p;
2780 uint64_t sec; 2784 uint64_t sec;
2781 uint32_t nsec; 2785 uint32_t nsec;
2782 2786
@@ -2836,7 +2840,7 @@ static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, str
2836 return status; 2840 return status;
2837} 2841}
2838 2842
2839static int verify_attr_len(struct xdr_stream *xdr, uint32_t *savep, uint32_t attrlen) 2843static int verify_attr_len(struct xdr_stream *xdr, __be32 *savep, uint32_t attrlen)
2840{ 2844{
2841 unsigned int attrwords = XDR_QUADLEN(attrlen); 2845 unsigned int attrwords = XDR_QUADLEN(attrlen);
2842 unsigned int nwords = xdr->p - savep; 2846 unsigned int nwords = xdr->p - savep;
@@ -2854,7 +2858,7 @@ static int verify_attr_len(struct xdr_stream *xdr, uint32_t *savep, uint32_t att
2854 2858
2855static int decode_change_info(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) 2859static int decode_change_info(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
2856{ 2860{
2857 uint32_t *p; 2861 __be32 *p;
2858 2862
2859 READ_BUF(20); 2863 READ_BUF(20);
2860 READ32(cinfo->atomic); 2864 READ32(cinfo->atomic);
@@ -2865,7 +2869,7 @@ static int decode_change_info(struct xdr_stream *xdr, struct nfs4_change_info *c
2865 2869
2866static int decode_access(struct xdr_stream *xdr, struct nfs4_accessres *access) 2870static int decode_access(struct xdr_stream *xdr, struct nfs4_accessres *access)
2867{ 2871{
2868 uint32_t *p; 2872 __be32 *p;
2869 uint32_t supp, acc; 2873 uint32_t supp, acc;
2870 int status; 2874 int status;
2871 2875
@@ -2882,7 +2886,7 @@ static int decode_access(struct xdr_stream *xdr, struct nfs4_accessres *access)
2882 2886
2883static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res) 2887static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res)
2884{ 2888{
2885 uint32_t *p; 2889 __be32 *p;
2886 int status; 2890 int status;
2887 2891
2888 status = decode_op_hdr(xdr, OP_CLOSE); 2892 status = decode_op_hdr(xdr, OP_CLOSE);
@@ -2895,7 +2899,7 @@ static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res)
2895 2899
2896static int decode_commit(struct xdr_stream *xdr, struct nfs_writeres *res) 2900static int decode_commit(struct xdr_stream *xdr, struct nfs_writeres *res)
2897{ 2901{
2898 uint32_t *p; 2902 __be32 *p;
2899 int status; 2903 int status;
2900 2904
2901 status = decode_op_hdr(xdr, OP_COMMIT); 2905 status = decode_op_hdr(xdr, OP_COMMIT);
@@ -2908,7 +2912,7 @@ static int decode_commit(struct xdr_stream *xdr, struct nfs_writeres *res)
2908 2912
2909static int decode_create(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) 2913static int decode_create(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
2910{ 2914{
2911 uint32_t *p; 2915 __be32 *p;
2912 uint32_t bmlen; 2916 uint32_t bmlen;
2913 int status; 2917 int status;
2914 2918
@@ -2925,7 +2929,7 @@ static int decode_create(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
2925 2929
2926static int decode_server_caps(struct xdr_stream *xdr, struct nfs4_server_caps_res *res) 2930static int decode_server_caps(struct xdr_stream *xdr, struct nfs4_server_caps_res *res)
2927{ 2931{
2928 uint32_t *savep; 2932 __be32 *savep;
2929 uint32_t attrlen, 2933 uint32_t attrlen,
2930 bitmap[2] = {0}; 2934 bitmap[2] = {0};
2931 int status; 2935 int status;
@@ -2952,7 +2956,7 @@ xdr_error:
2952 2956
2953static int decode_statfs(struct xdr_stream *xdr, struct nfs_fsstat *fsstat) 2957static int decode_statfs(struct xdr_stream *xdr, struct nfs_fsstat *fsstat)
2954{ 2958{
2955 uint32_t *savep; 2959 __be32 *savep;
2956 uint32_t attrlen, 2960 uint32_t attrlen,
2957 bitmap[2] = {0}; 2961 bitmap[2] = {0};
2958 int status; 2962 int status;
@@ -2985,7 +2989,7 @@ xdr_error:
2985 2989
2986static int decode_pathconf(struct xdr_stream *xdr, struct nfs_pathconf *pathconf) 2990static int decode_pathconf(struct xdr_stream *xdr, struct nfs_pathconf *pathconf)
2987{ 2991{
2988 uint32_t *savep; 2992 __be32 *savep;
2989 uint32_t attrlen, 2993 uint32_t attrlen,
2990 bitmap[2] = {0}; 2994 bitmap[2] = {0};
2991 int status; 2995 int status;
@@ -3010,7 +3014,7 @@ xdr_error:
3010 3014
3011static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, const struct nfs_server *server) 3015static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, const struct nfs_server *server)
3012{ 3016{
3013 uint32_t *savep; 3017 __be32 *savep;
3014 uint32_t attrlen, 3018 uint32_t attrlen,
3015 bitmap[2] = {0}, 3019 bitmap[2] = {0},
3016 type; 3020 type;
@@ -3079,7 +3083,7 @@ xdr_error:
3079 3083
3080static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo) 3084static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo)
3081{ 3085{
3082 uint32_t *savep; 3086 __be32 *savep;
3083 uint32_t attrlen, bitmap[2]; 3087 uint32_t attrlen, bitmap[2];
3084 int status; 3088 int status;
3085 3089
@@ -3111,7 +3115,7 @@ xdr_error:
3111 3115
3112static int decode_getfh(struct xdr_stream *xdr, struct nfs_fh *fh) 3116static int decode_getfh(struct xdr_stream *xdr, struct nfs_fh *fh)
3113{ 3117{
3114 uint32_t *p; 3118 __be32 *p;
3115 uint32_t len; 3119 uint32_t len;
3116 int status; 3120 int status;
3117 3121
@@ -3147,7 +3151,7 @@ static int decode_link(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
3147static int decode_lock_denied (struct xdr_stream *xdr, struct file_lock *fl) 3151static int decode_lock_denied (struct xdr_stream *xdr, struct file_lock *fl)
3148{ 3152{
3149 uint64_t offset, length, clientid; 3153 uint64_t offset, length, clientid;
3150 uint32_t *p; 3154 __be32 *p;
3151 uint32_t namelen, type; 3155 uint32_t namelen, type;
3152 3156
3153 READ_BUF(32); 3157 READ_BUF(32);
@@ -3172,7 +3176,7 @@ static int decode_lock_denied (struct xdr_stream *xdr, struct file_lock *fl)
3172 3176
3173static int decode_lock(struct xdr_stream *xdr, struct nfs_lock_res *res) 3177static int decode_lock(struct xdr_stream *xdr, struct nfs_lock_res *res)
3174{ 3178{
3175 uint32_t *p; 3179 __be32 *p;
3176 int status; 3180 int status;
3177 3181
3178 status = decode_op_hdr(xdr, OP_LOCK); 3182 status = decode_op_hdr(xdr, OP_LOCK);
@@ -3195,7 +3199,7 @@ static int decode_lockt(struct xdr_stream *xdr, struct nfs_lockt_res *res)
3195 3199
3196static int decode_locku(struct xdr_stream *xdr, struct nfs_locku_res *res) 3200static int decode_locku(struct xdr_stream *xdr, struct nfs_locku_res *res)
3197{ 3201{
3198 uint32_t *p; 3202 __be32 *p;
3199 int status; 3203 int status;
3200 3204
3201 status = decode_op_hdr(xdr, OP_LOCKU); 3205 status = decode_op_hdr(xdr, OP_LOCKU);
@@ -3214,7 +3218,7 @@ static int decode_lookup(struct xdr_stream *xdr)
3214/* This is too sick! */ 3218/* This is too sick! */
3215static int decode_space_limit(struct xdr_stream *xdr, u64 *maxsize) 3219static int decode_space_limit(struct xdr_stream *xdr, u64 *maxsize)
3216{ 3220{
3217 uint32_t *p; 3221 __be32 *p;
3218 uint32_t limit_type, nblocks, blocksize; 3222 uint32_t limit_type, nblocks, blocksize;
3219 3223
3220 READ_BUF(12); 3224 READ_BUF(12);
@@ -3233,7 +3237,7 @@ static int decode_space_limit(struct xdr_stream *xdr, u64 *maxsize)
3233 3237
3234static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res) 3238static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res)
3235{ 3239{
3236 uint32_t *p; 3240 __be32 *p;
3237 uint32_t delegation_type; 3241 uint32_t delegation_type;
3238 3242
3239 READ_BUF(4); 3243 READ_BUF(4);
@@ -3259,7 +3263,7 @@ static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res)
3259 3263
3260static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res) 3264static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res)
3261{ 3265{
3262 uint32_t *p; 3266 __be32 *p;
3263 uint32_t bmlen; 3267 uint32_t bmlen;
3264 int status; 3268 int status;
3265 3269
@@ -3287,7 +3291,7 @@ xdr_error:
3287 3291
3288static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res) 3292static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res)
3289{ 3293{
3290 uint32_t *p; 3294 __be32 *p;
3291 int status; 3295 int status;
3292 3296
3293 status = decode_op_hdr(xdr, OP_OPEN_CONFIRM); 3297 status = decode_op_hdr(xdr, OP_OPEN_CONFIRM);
@@ -3300,7 +3304,7 @@ static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmre
3300 3304
3301static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res) 3305static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res)
3302{ 3306{
3303 uint32_t *p; 3307 __be32 *p;
3304 int status; 3308 int status;
3305 3309
3306 status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE); 3310 status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE);
@@ -3324,7 +3328,7 @@ static int decode_putrootfh(struct xdr_stream *xdr)
3324static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs_readres *res) 3328static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs_readres *res)
3325{ 3329{
3326 struct kvec *iov = req->rq_rcv_buf.head; 3330 struct kvec *iov = req->rq_rcv_buf.head;
3327 uint32_t *p; 3331 __be32 *p;
3328 uint32_t count, eof, recvd, hdrlen; 3332 uint32_t count, eof, recvd, hdrlen;
3329 int status; 3333 int status;
3330 3334
@@ -3354,7 +3358,7 @@ static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct n
3354 struct page *page = *rcvbuf->pages; 3358 struct page *page = *rcvbuf->pages;
3355 struct kvec *iov = rcvbuf->head; 3359 struct kvec *iov = rcvbuf->head;
3356 unsigned int nr, pglen = rcvbuf->page_len; 3360 unsigned int nr, pglen = rcvbuf->page_len;
3357 uint32_t *end, *entry, *p, *kaddr; 3361 __be32 *end, *entry, *p, *kaddr;
3358 uint32_t len, attrlen, xlen; 3362 uint32_t len, attrlen, xlen;
3359 int hdrlen, recvd, status; 3363 int hdrlen, recvd, status;
3360 3364
@@ -3376,7 +3380,7 @@ static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct n
3376 xdr_read_pages(xdr, pglen); 3380 xdr_read_pages(xdr, pglen);
3377 3381
3378 BUG_ON(pglen + readdir->pgbase > PAGE_CACHE_SIZE); 3382 BUG_ON(pglen + readdir->pgbase > PAGE_CACHE_SIZE);
3379 kaddr = p = (uint32_t *) kmap_atomic(page, KM_USER0); 3383 kaddr = p = kmap_atomic(page, KM_USER0);
3380 end = p + ((pglen + readdir->pgbase) >> 2); 3384 end = p + ((pglen + readdir->pgbase) >> 2);
3381 entry = p; 3385 entry = p;
3382 for (nr = 0; *p++; nr++) { 3386 for (nr = 0; *p++; nr++) {
@@ -3428,7 +3432,7 @@ static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req)
3428 struct xdr_buf *rcvbuf = &req->rq_rcv_buf; 3432 struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
3429 struct kvec *iov = rcvbuf->head; 3433 struct kvec *iov = rcvbuf->head;
3430 int hdrlen, len, recvd; 3434 int hdrlen, len, recvd;
3431 uint32_t *p; 3435 __be32 *p;
3432 char *kaddr; 3436 char *kaddr;
3433 int status; 3437 int status;
3434 3438
@@ -3505,7 +3509,7 @@ decode_restorefh(struct xdr_stream *xdr)
3505static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req, 3509static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req,
3506 size_t *acl_len) 3510 size_t *acl_len)
3507{ 3511{
3508 uint32_t *savep; 3512 __be32 *savep;
3509 uint32_t attrlen, 3513 uint32_t attrlen,
3510 bitmap[2] = {0}; 3514 bitmap[2] = {0};
3511 struct kvec *iov = req->rq_rcv_buf.head; 3515 struct kvec *iov = req->rq_rcv_buf.head;
@@ -3551,7 +3555,7 @@ decode_savefh(struct xdr_stream *xdr)
3551 3555
3552static int decode_setattr(struct xdr_stream *xdr, struct nfs_setattrres *res) 3556static int decode_setattr(struct xdr_stream *xdr, struct nfs_setattrres *res)
3553{ 3557{
3554 uint32_t *p; 3558 __be32 *p;
3555 uint32_t bmlen; 3559 uint32_t bmlen;
3556 int status; 3560 int status;
3557 3561
@@ -3567,7 +3571,7 @@ static int decode_setattr(struct xdr_stream *xdr, struct nfs_setattrres *res)
3567 3571
3568static int decode_setclientid(struct xdr_stream *xdr, struct nfs_client *clp) 3572static int decode_setclientid(struct xdr_stream *xdr, struct nfs_client *clp)
3569{ 3573{
3570 uint32_t *p; 3574 __be32 *p;
3571 uint32_t opnum; 3575 uint32_t opnum;
3572 int32_t nfserr; 3576 int32_t nfserr;
3573 3577
@@ -3610,7 +3614,7 @@ static int decode_setclientid_confirm(struct xdr_stream *xdr)
3610 3614
3611static int decode_write(struct xdr_stream *xdr, struct nfs_writeres *res) 3615static int decode_write(struct xdr_stream *xdr, struct nfs_writeres *res)
3612{ 3616{
3613 uint32_t *p; 3617 __be32 *p;
3614 int status; 3618 int status;
3615 3619
3616 status = decode_op_hdr(xdr, OP_WRITE); 3620 status = decode_op_hdr(xdr, OP_WRITE);
@@ -3632,7 +3636,7 @@ static int decode_delegreturn(struct xdr_stream *xdr)
3632/* 3636/*
3633 * Decode OPEN_DOWNGRADE response 3637 * Decode OPEN_DOWNGRADE response
3634 */ 3638 */
3635static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_closeres *res) 3639static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp, __be32 *p, struct nfs_closeres *res)
3636{ 3640{
3637 struct xdr_stream xdr; 3641 struct xdr_stream xdr;
3638 struct compound_hdr hdr; 3642 struct compound_hdr hdr;
@@ -3660,7 +3664,7 @@ out:
3660/* 3664/*
3661 * Decode ACCESS response 3665 * Decode ACCESS response
3662 */ 3666 */
3663static int nfs4_xdr_dec_access(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_accessres *res) 3667static int nfs4_xdr_dec_access(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_accessres *res)
3664{ 3668{
3665 struct xdr_stream xdr; 3669 struct xdr_stream xdr;
3666 struct compound_hdr hdr; 3670 struct compound_hdr hdr;
@@ -3678,7 +3682,7 @@ out:
3678/* 3682/*
3679 * Decode LOOKUP response 3683 * Decode LOOKUP response
3680 */ 3684 */
3681static int nfs4_xdr_dec_lookup(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_lookup_res *res) 3685static int nfs4_xdr_dec_lookup(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_lookup_res *res)
3682{ 3686{
3683 struct xdr_stream xdr; 3687 struct xdr_stream xdr;
3684 struct compound_hdr hdr; 3688 struct compound_hdr hdr;
@@ -3701,7 +3705,7 @@ out:
3701/* 3705/*
3702 * Decode LOOKUP_ROOT response 3706 * Decode LOOKUP_ROOT response
3703 */ 3707 */
3704static int nfs4_xdr_dec_lookup_root(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_lookup_res *res) 3708static int nfs4_xdr_dec_lookup_root(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_lookup_res *res)
3705{ 3709{
3706 struct xdr_stream xdr; 3710 struct xdr_stream xdr;
3707 struct compound_hdr hdr; 3711 struct compound_hdr hdr;
@@ -3721,7 +3725,7 @@ out:
3721/* 3725/*
3722 * Decode REMOVE response 3726 * Decode REMOVE response
3723 */ 3727 */
3724static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_remove_res *res) 3728static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_remove_res *res)
3725{ 3729{
3726 struct xdr_stream xdr; 3730 struct xdr_stream xdr;
3727 struct compound_hdr hdr; 3731 struct compound_hdr hdr;
@@ -3742,7 +3746,7 @@ out:
3742/* 3746/*
3743 * Decode RENAME response 3747 * Decode RENAME response
3744 */ 3748 */
3745static int nfs4_xdr_dec_rename(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_rename_res *res) 3749static int nfs4_xdr_dec_rename(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_rename_res *res)
3746{ 3750{
3747 struct xdr_stream xdr; 3751 struct xdr_stream xdr;
3748 struct compound_hdr hdr; 3752 struct compound_hdr hdr;
@@ -3772,7 +3776,7 @@ out:
3772/* 3776/*
3773 * Decode LINK response 3777 * Decode LINK response
3774 */ 3778 */
3775static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_link_res *res) 3779static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_link_res *res)
3776{ 3780{
3777 struct xdr_stream xdr; 3781 struct xdr_stream xdr;
3778 struct compound_hdr hdr; 3782 struct compound_hdr hdr;
@@ -3805,7 +3809,7 @@ out:
3805/* 3809/*
3806 * Decode CREATE response 3810 * Decode CREATE response
3807 */ 3811 */
3808static int nfs4_xdr_dec_create(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_create_res *res) 3812static int nfs4_xdr_dec_create(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_create_res *res)
3809{ 3813{
3810 struct xdr_stream xdr; 3814 struct xdr_stream xdr;
3811 struct compound_hdr hdr; 3815 struct compound_hdr hdr;
@@ -3834,7 +3838,7 @@ out:
3834/* 3838/*
3835 * Decode SYMLINK response 3839 * Decode SYMLINK response
3836 */ 3840 */
3837static int nfs4_xdr_dec_symlink(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_create_res *res) 3841static int nfs4_xdr_dec_symlink(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_create_res *res)
3838{ 3842{
3839 return nfs4_xdr_dec_create(rqstp, p, res); 3843 return nfs4_xdr_dec_create(rqstp, p, res);
3840} 3844}
@@ -3842,7 +3846,7 @@ static int nfs4_xdr_dec_symlink(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4
3842/* 3846/*
3843 * Decode GETATTR response 3847 * Decode GETATTR response
3844 */ 3848 */
3845static int nfs4_xdr_dec_getattr(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_getattr_res *res) 3849static int nfs4_xdr_dec_getattr(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_getattr_res *res)
3846{ 3850{
3847 struct xdr_stream xdr; 3851 struct xdr_stream xdr;
3848 struct compound_hdr hdr; 3852 struct compound_hdr hdr;
@@ -3865,7 +3869,7 @@ out:
3865 * Encode an SETACL request 3869 * Encode an SETACL request
3866 */ 3870 */
3867static int 3871static int
3868nfs4_xdr_enc_setacl(struct rpc_rqst *req, uint32_t *p, struct nfs_setaclargs *args) 3872nfs4_xdr_enc_setacl(struct rpc_rqst *req, __be32 *p, struct nfs_setaclargs *args)
3869{ 3873{
3870 struct xdr_stream xdr; 3874 struct xdr_stream xdr;
3871 struct compound_hdr hdr = { 3875 struct compound_hdr hdr = {
@@ -3886,7 +3890,7 @@ out:
3886 * Decode SETACL response 3890 * Decode SETACL response
3887 */ 3891 */
3888static int 3892static int
3889nfs4_xdr_dec_setacl(struct rpc_rqst *rqstp, uint32_t *p, void *res) 3893nfs4_xdr_dec_setacl(struct rpc_rqst *rqstp, __be32 *p, void *res)
3890{ 3894{
3891 struct xdr_stream xdr; 3895 struct xdr_stream xdr;
3892 struct compound_hdr hdr; 3896 struct compound_hdr hdr;
@@ -3908,7 +3912,7 @@ out:
3908 * Decode GETACL response 3912 * Decode GETACL response
3909 */ 3913 */
3910static int 3914static int
3911nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, uint32_t *p, size_t *acl_len) 3915nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, __be32 *p, size_t *acl_len)
3912{ 3916{
3913 struct xdr_stream xdr; 3917 struct xdr_stream xdr;
3914 struct compound_hdr hdr; 3918 struct compound_hdr hdr;
@@ -3930,7 +3934,7 @@ out:
3930/* 3934/*
3931 * Decode CLOSE response 3935 * Decode CLOSE response
3932 */ 3936 */
3933static int nfs4_xdr_dec_close(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_closeres *res) 3937static int nfs4_xdr_dec_close(struct rpc_rqst *rqstp, __be32 *p, struct nfs_closeres *res)
3934{ 3938{
3935 struct xdr_stream xdr; 3939 struct xdr_stream xdr;
3936 struct compound_hdr hdr; 3940 struct compound_hdr hdr;
@@ -3960,7 +3964,7 @@ out:
3960/* 3964/*
3961 * Decode OPEN response 3965 * Decode OPEN response
3962 */ 3966 */
3963static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_openres *res) 3967static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, __be32 *p, struct nfs_openres *res)
3964{ 3968{
3965 struct xdr_stream xdr; 3969 struct xdr_stream xdr;
3966 struct compound_hdr hdr; 3970 struct compound_hdr hdr;
@@ -3994,7 +3998,7 @@ out:
3994/* 3998/*
3995 * Decode OPEN_CONFIRM response 3999 * Decode OPEN_CONFIRM response
3996 */ 4000 */
3997static int nfs4_xdr_dec_open_confirm(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_open_confirmres *res) 4001static int nfs4_xdr_dec_open_confirm(struct rpc_rqst *rqstp, __be32 *p, struct nfs_open_confirmres *res)
3998{ 4002{
3999 struct xdr_stream xdr; 4003 struct xdr_stream xdr;
4000 struct compound_hdr hdr; 4004 struct compound_hdr hdr;
@@ -4015,7 +4019,7 @@ out:
4015/* 4019/*
4016 * Decode OPEN response 4020 * Decode OPEN response
4017 */ 4021 */
4018static int nfs4_xdr_dec_open_noattr(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_openres *res) 4022static int nfs4_xdr_dec_open_noattr(struct rpc_rqst *rqstp, __be32 *p, struct nfs_openres *res)
4019{ 4023{
4020 struct xdr_stream xdr; 4024 struct xdr_stream xdr;
4021 struct compound_hdr hdr; 4025 struct compound_hdr hdr;
@@ -4039,7 +4043,7 @@ out:
4039/* 4043/*
4040 * Decode SETATTR response 4044 * Decode SETATTR response
4041 */ 4045 */
4042static int nfs4_xdr_dec_setattr(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_setattrres *res) 4046static int nfs4_xdr_dec_setattr(struct rpc_rqst *rqstp, __be32 *p, struct nfs_setattrres *res)
4043{ 4047{
4044 struct xdr_stream xdr; 4048 struct xdr_stream xdr;
4045 struct compound_hdr hdr; 4049 struct compound_hdr hdr;
@@ -4065,7 +4069,7 @@ out:
4065/* 4069/*
4066 * Decode LOCK response 4070 * Decode LOCK response
4067 */ 4071 */
4068static int nfs4_xdr_dec_lock(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_lock_res *res) 4072static int nfs4_xdr_dec_lock(struct rpc_rqst *rqstp, __be32 *p, struct nfs_lock_res *res)
4069{ 4073{
4070 struct xdr_stream xdr; 4074 struct xdr_stream xdr;
4071 struct compound_hdr hdr; 4075 struct compound_hdr hdr;
@@ -4086,7 +4090,7 @@ out:
4086/* 4090/*
4087 * Decode LOCKT response 4091 * Decode LOCKT response
4088 */ 4092 */
4089static int nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_lockt_res *res) 4093static int nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, __be32 *p, struct nfs_lockt_res *res)
4090{ 4094{
4091 struct xdr_stream xdr; 4095 struct xdr_stream xdr;
4092 struct compound_hdr hdr; 4096 struct compound_hdr hdr;
@@ -4107,7 +4111,7 @@ out:
4107/* 4111/*
4108 * Decode LOCKU response 4112 * Decode LOCKU response
4109 */ 4113 */
4110static int nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_locku_res *res) 4114static int nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, __be32 *p, struct nfs_locku_res *res)
4111{ 4115{
4112 struct xdr_stream xdr; 4116 struct xdr_stream xdr;
4113 struct compound_hdr hdr; 4117 struct compound_hdr hdr;
@@ -4128,7 +4132,7 @@ out:
4128/* 4132/*
4129 * Decode READLINK response 4133 * Decode READLINK response
4130 */ 4134 */
4131static int nfs4_xdr_dec_readlink(struct rpc_rqst *rqstp, uint32_t *p, void *res) 4135static int nfs4_xdr_dec_readlink(struct rpc_rqst *rqstp, __be32 *p, void *res)
4132{ 4136{
4133 struct xdr_stream xdr; 4137 struct xdr_stream xdr;
4134 struct compound_hdr hdr; 4138 struct compound_hdr hdr;
@@ -4149,7 +4153,7 @@ out:
4149/* 4153/*
4150 * Decode READDIR response 4154 * Decode READDIR response
4151 */ 4155 */
4152static int nfs4_xdr_dec_readdir(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_readdir_res *res) 4156static int nfs4_xdr_dec_readdir(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_readdir_res *res)
4153{ 4157{
4154 struct xdr_stream xdr; 4158 struct xdr_stream xdr;
4155 struct compound_hdr hdr; 4159 struct compound_hdr hdr;
@@ -4170,7 +4174,7 @@ out:
4170/* 4174/*
4171 * Decode Read response 4175 * Decode Read response
4172 */ 4176 */
4173static int nfs4_xdr_dec_read(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_readres *res) 4177static int nfs4_xdr_dec_read(struct rpc_rqst *rqstp, __be32 *p, struct nfs_readres *res)
4174{ 4178{
4175 struct xdr_stream xdr; 4179 struct xdr_stream xdr;
4176 struct compound_hdr hdr; 4180 struct compound_hdr hdr;
@@ -4193,7 +4197,7 @@ out:
4193/* 4197/*
4194 * Decode WRITE response 4198 * Decode WRITE response
4195 */ 4199 */
4196static int nfs4_xdr_dec_write(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_writeres *res) 4200static int nfs4_xdr_dec_write(struct rpc_rqst *rqstp, __be32 *p, struct nfs_writeres *res)
4197{ 4201{
4198 struct xdr_stream xdr; 4202 struct xdr_stream xdr;
4199 struct compound_hdr hdr; 4203 struct compound_hdr hdr;
@@ -4219,7 +4223,7 @@ out:
4219/* 4223/*
4220 * Decode COMMIT response 4224 * Decode COMMIT response
4221 */ 4225 */
4222static int nfs4_xdr_dec_commit(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_writeres *res) 4226static int nfs4_xdr_dec_commit(struct rpc_rqst *rqstp, __be32 *p, struct nfs_writeres *res)
4223{ 4227{
4224 struct xdr_stream xdr; 4228 struct xdr_stream xdr;
4225 struct compound_hdr hdr; 4229 struct compound_hdr hdr;
@@ -4243,7 +4247,7 @@ out:
4243/* 4247/*
4244 * FSINFO request 4248 * FSINFO request
4245 */ 4249 */
4246static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, uint32_t *p, struct nfs_fsinfo *fsinfo) 4250static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, __be32 *p, struct nfs_fsinfo *fsinfo)
4247{ 4251{
4248 struct xdr_stream xdr; 4252 struct xdr_stream xdr;
4249 struct compound_hdr hdr; 4253 struct compound_hdr hdr;
@@ -4263,7 +4267,7 @@ static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, uint32_t *p, struct nfs_fsi
4263/* 4267/*
4264 * PATHCONF request 4268 * PATHCONF request
4265 */ 4269 */
4266static int nfs4_xdr_dec_pathconf(struct rpc_rqst *req, uint32_t *p, struct nfs_pathconf *pathconf) 4270static int nfs4_xdr_dec_pathconf(struct rpc_rqst *req, __be32 *p, struct nfs_pathconf *pathconf)
4267{ 4271{
4268 struct xdr_stream xdr; 4272 struct xdr_stream xdr;
4269 struct compound_hdr hdr; 4273 struct compound_hdr hdr;
@@ -4281,7 +4285,7 @@ static int nfs4_xdr_dec_pathconf(struct rpc_rqst *req, uint32_t *p, struct nfs_p
4281/* 4285/*
4282 * STATFS request 4286 * STATFS request
4283 */ 4287 */
4284static int nfs4_xdr_dec_statfs(struct rpc_rqst *req, uint32_t *p, struct nfs_fsstat *fsstat) 4288static int nfs4_xdr_dec_statfs(struct rpc_rqst *req, __be32 *p, struct nfs_fsstat *fsstat)
4285{ 4289{
4286 struct xdr_stream xdr; 4290 struct xdr_stream xdr;
4287 struct compound_hdr hdr; 4291 struct compound_hdr hdr;
@@ -4299,7 +4303,7 @@ static int nfs4_xdr_dec_statfs(struct rpc_rqst *req, uint32_t *p, struct nfs_fss
4299/* 4303/*
4300 * GETATTR_BITMAP request 4304 * GETATTR_BITMAP request
4301 */ 4305 */
4302static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req, uint32_t *p, struct nfs4_server_caps_res *res) 4306static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req, __be32 *p, struct nfs4_server_caps_res *res)
4303{ 4307{
4304 struct xdr_stream xdr; 4308 struct xdr_stream xdr;
4305 struct compound_hdr hdr; 4309 struct compound_hdr hdr;
@@ -4318,7 +4322,7 @@ out:
4318/* 4322/*
4319 * Decode RENEW response 4323 * Decode RENEW response
4320 */ 4324 */
4321static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, uint32_t *p, void *dummy) 4325static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, __be32 *p, void *dummy)
4322{ 4326{
4323 struct xdr_stream xdr; 4327 struct xdr_stream xdr;
4324 struct compound_hdr hdr; 4328 struct compound_hdr hdr;
@@ -4334,7 +4338,7 @@ static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, uint32_t *p, void *dummy)
4334/* 4338/*
4335 * a SETCLIENTID request 4339 * a SETCLIENTID request
4336 */ 4340 */
4337static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, uint32_t *p, 4341static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, __be32 *p,
4338 struct nfs_client *clp) 4342 struct nfs_client *clp)
4339{ 4343{
4340 struct xdr_stream xdr; 4344 struct xdr_stream xdr;
@@ -4353,7 +4357,7 @@ static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, uint32_t *p,
4353/* 4357/*
4354 * a SETCLIENTID_CONFIRM request 4358 * a SETCLIENTID_CONFIRM request
4355 */ 4359 */
4356static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, uint32_t *p, struct nfs_fsinfo *fsinfo) 4360static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, __be32 *p, struct nfs_fsinfo *fsinfo)
4357{ 4361{
4358 struct xdr_stream xdr; 4362 struct xdr_stream xdr;
4359 struct compound_hdr hdr; 4363 struct compound_hdr hdr;
@@ -4375,7 +4379,7 @@ static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, uint32_t *p, s
4375/* 4379/*
4376 * DELEGRETURN request 4380 * DELEGRETURN request
4377 */ 4381 */
4378static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_delegreturnres *res) 4382static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_delegreturnres *res)
4379{ 4383{
4380 struct xdr_stream xdr; 4384 struct xdr_stream xdr;
4381 struct compound_hdr hdr; 4385 struct compound_hdr hdr;
@@ -4397,7 +4401,7 @@ out:
4397/* 4401/*
4398 * FS_LOCATIONS request 4402 * FS_LOCATIONS request
4399 */ 4403 */
4400static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, uint32_t *p, struct nfs4_fs_locations *res) 4404static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, __be32 *p, struct nfs4_fs_locations *res)
4401{ 4405{
4402 struct xdr_stream xdr; 4406 struct xdr_stream xdr;
4403 struct compound_hdr hdr; 4407 struct compound_hdr hdr;
@@ -4417,7 +4421,7 @@ out:
4417 return status; 4421 return status;
4418} 4422}
4419 4423
4420uint32_t *nfs4_decode_dirent(uint32_t *p, struct nfs_entry *entry, int plus) 4424__be32 *nfs4_decode_dirent(__be32 *p, struct nfs_entry *entry, int plus)
4421{ 4425{
4422 uint32_t bitmap[2] = {0}; 4426 uint32_t bitmap[2] = {0};
4423 uint32_t len; 4427 uint32_t len;
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 28659a919d6e..28108c82b887 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -834,7 +834,7 @@ static int nfs4_get_sb(struct file_system_type *fs_type,
834 } 834 }
835 /* RFC3530: The default port for NFS is 2049 */ 835 /* RFC3530: The default port for NFS is 2049 */
836 if (addr.sin_port == 0) 836 if (addr.sin_port == 0)
837 addr.sin_port = NFS_PORT; 837 addr.sin_port = htons(NFS_PORT);
838 838
839 /* Grab the authentication type */ 839 /* Grab the authentication type */
840 authflavour = RPC_AUTH_UNIX; 840 authflavour = RPC_AUTH_UNIX;
diff --git a/fs/nfs/sysctl.c b/fs/nfs/sysctl.c
index 2fe3403c2409..3ea50ac64820 100644
--- a/fs/nfs/sysctl.c
+++ b/fs/nfs/sysctl.c
@@ -18,11 +18,6 @@
18static const int nfs_set_port_min = 0; 18static const int nfs_set_port_min = 0;
19static const int nfs_set_port_max = 65535; 19static const int nfs_set_port_max = 65535;
20static struct ctl_table_header *nfs_callback_sysctl_table; 20static struct ctl_table_header *nfs_callback_sysctl_table;
21/*
22 * Something that isn't CTL_ANY, CTL_NONE or a value that may clash.
23 * Use the same values as fs/lockd/svc.c
24 */
25#define CTL_UNNUMBERED -2
26 21
27static ctl_table nfs_cb_sysctls[] = { 22static ctl_table nfs_cb_sysctls[] = {
28#ifdef CONFIG_NFS_V4 23#ifdef CONFIG_NFS_V4
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index f6675d2c386c..883dd4a1c157 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -57,6 +57,8 @@
57#include <linux/nfs_fs.h> 57#include <linux/nfs_fs.h>
58#include <linux/nfs_mount.h> 58#include <linux/nfs_mount.h>
59#include <linux/nfs_page.h> 59#include <linux/nfs_page.h>
60#include <linux/backing-dev.h>
61
60#include <asm/uaccess.h> 62#include <asm/uaccess.h>
61#include <linux/smp_lock.h> 63#include <linux/smp_lock.h>
62 64
@@ -395,7 +397,7 @@ int nfs_writepages(struct address_space *mapping, struct writeback_control *wbc)
395out: 397out:
396 clear_bit(BDI_write_congested, &bdi->state); 398 clear_bit(BDI_write_congested, &bdi->state);
397 wake_up_all(&nfs_write_congestion); 399 wake_up_all(&nfs_write_congestion);
398 writeback_congestion_end(); 400 congestion_end(WRITE);
399 return err; 401 return err;
400} 402}
401 403
@@ -588,10 +590,10 @@ static void nfs_cancel_commit_list(struct list_head *head)
588 590
589 while(!list_empty(head)) { 591 while(!list_empty(head)) {
590 req = nfs_list_entry(head->next); 592 req = nfs_list_entry(head->next);
593 dec_zone_page_state(req->wb_page, NR_UNSTABLE_NFS);
591 nfs_list_remove_request(req); 594 nfs_list_remove_request(req);
592 nfs_inode_remove_request(req); 595 nfs_inode_remove_request(req);
593 dec_zone_page_state(req->wb_page, NR_UNSTABLE_NFS); 596 nfs_unlock_request(req);
594 nfs_clear_page_writeback(req);
595 } 597 }
596} 598}
597 599
diff --git a/fs/nfs_common/nfsacl.c b/fs/nfs_common/nfsacl.c
index 0c2be8c0307d..c11f5375d7c1 100644
--- a/fs/nfs_common/nfsacl.c
+++ b/fs/nfs_common/nfsacl.c
@@ -46,7 +46,7 @@ xdr_nfsace_encode(struct xdr_array2_desc *desc, void *elem)
46{ 46{
47 struct nfsacl_encode_desc *nfsacl_desc = 47 struct nfsacl_encode_desc *nfsacl_desc =
48 (struct nfsacl_encode_desc *) desc; 48 (struct nfsacl_encode_desc *) desc;
49 u32 *p = (u32 *) elem; 49 __be32 *p = elem;
50 50
51 struct posix_acl_entry *entry = 51 struct posix_acl_entry *entry =
52 &nfsacl_desc->acl->a_entries[nfsacl_desc->count++]; 52 &nfsacl_desc->acl->a_entries[nfsacl_desc->count++];
@@ -127,7 +127,7 @@ xdr_nfsace_decode(struct xdr_array2_desc *desc, void *elem)
127{ 127{
128 struct nfsacl_decode_desc *nfsacl_desc = 128 struct nfsacl_decode_desc *nfsacl_desc =
129 (struct nfsacl_decode_desc *) desc; 129 (struct nfsacl_decode_desc *) desc;
130 u32 *p = (u32 *) elem; 130 __be32 *p = elem;
131 struct posix_acl_entry *entry; 131 struct posix_acl_entry *entry;
132 132
133 if (!nfsacl_desc->acl) { 133 if (!nfsacl_desc->acl) {
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index e13fa23bd108..f37df46d2eaa 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -1148,12 +1148,12 @@ exp_find(struct auth_domain *clp, int fsid_type, u32 *fsidv,
1148 * for a given NFSv4 client. The root is defined to be the 1148 * for a given NFSv4 client. The root is defined to be the
1149 * export point with fsid==0 1149 * export point with fsid==0
1150 */ 1150 */
1151int 1151__be32
1152exp_pseudoroot(struct auth_domain *clp, struct svc_fh *fhp, 1152exp_pseudoroot(struct auth_domain *clp, struct svc_fh *fhp,
1153 struct cache_req *creq) 1153 struct cache_req *creq)
1154{ 1154{
1155 struct svc_export *exp; 1155 struct svc_export *exp;
1156 int rv; 1156 __be32 rv;
1157 u32 fsidv[2]; 1157 u32 fsidv[2];
1158 1158
1159 mk_fsid_v1(fsidv, 0); 1159 mk_fsid_v1(fsidv, 0);
diff --git a/fs/nfsd/lockd.c b/fs/nfsd/lockd.c
index 7b889ff15ae6..11fdaf7721b4 100644
--- a/fs/nfsd/lockd.c
+++ b/fs/nfsd/lockd.c
@@ -25,7 +25,7 @@
25static u32 25static u32
26nlm_fopen(struct svc_rqst *rqstp, struct nfs_fh *f, struct file **filp) 26nlm_fopen(struct svc_rqst *rqstp, struct nfs_fh *f, struct file **filp)
27{ 27{
28 u32 nfserr; 28 __be32 nfserr;
29 struct svc_fh fh; 29 struct svc_fh fh;
30 30
31 /* must initialize before using! but maxsize doesn't matter */ 31 /* must initialize before using! but maxsize doesn't matter */
@@ -39,18 +39,20 @@ nlm_fopen(struct svc_rqst *rqstp, struct nfs_fh *f, struct file **filp)
39 fh_put(&fh); 39 fh_put(&fh);
40 rqstp->rq_client = NULL; 40 rqstp->rq_client = NULL;
41 exp_readunlock(); 41 exp_readunlock();
42 /* nlm and nfsd don't share error codes. 42 /* We return nlm error codes as nlm doesn't know
43 * we invent: 0 = no error 43 * about nfsd, but nfsd does know about nlm..
44 * 1 = stale file handle
45 * 2 = other error
46 */ 44 */
47 switch (nfserr) { 45 switch (nfserr) {
48 case nfs_ok: 46 case nfs_ok:
49 return 0; 47 return 0;
48 case nfserr_dropit:
49 return nlm_drop_reply;
50#ifdef CONFIG_LOCKD_V4
50 case nfserr_stale: 51 case nfserr_stale:
51 return 1; 52 return nlm4_stale_fh;
53#endif
52 default: 54 default:
53 return 2; 55 return nlm_lck_denied;
54 } 56 }
55} 57}
56 58
diff --git a/fs/nfsd/nfs2acl.c b/fs/nfsd/nfs2acl.c
index 9187755661df..e3eca0816986 100644
--- a/fs/nfsd/nfs2acl.c
+++ b/fs/nfsd/nfs2acl.c
@@ -21,7 +21,7 @@
21/* 21/*
22 * NULL call. 22 * NULL call.
23 */ 23 */
24static int 24static __be32
25nfsacld_proc_null(struct svc_rqst *rqstp, void *argp, void *resp) 25nfsacld_proc_null(struct svc_rqst *rqstp, void *argp, void *resp)
26{ 26{
27 return nfs_ok; 27 return nfs_ok;
@@ -30,12 +30,12 @@ nfsacld_proc_null(struct svc_rqst *rqstp, void *argp, void *resp)
30/* 30/*
31 * Get the Access and/or Default ACL of a file. 31 * Get the Access and/or Default ACL of a file.
32 */ 32 */
33static int nfsacld_proc_getacl(struct svc_rqst * rqstp, 33static __be32 nfsacld_proc_getacl(struct svc_rqst * rqstp,
34 struct nfsd3_getaclargs *argp, struct nfsd3_getaclres *resp) 34 struct nfsd3_getaclargs *argp, struct nfsd3_getaclres *resp)
35{ 35{
36 svc_fh *fh; 36 svc_fh *fh;
37 struct posix_acl *acl; 37 struct posix_acl *acl;
38 int nfserr = 0; 38 __be32 nfserr = 0;
39 39
40 dprintk("nfsd: GETACL(2acl) %s\n", SVCFH_fmt(&argp->fh)); 40 dprintk("nfsd: GETACL(2acl) %s\n", SVCFH_fmt(&argp->fh));
41 41
@@ -97,12 +97,12 @@ fail:
97/* 97/*
98 * Set the Access and/or Default ACL of a file. 98 * Set the Access and/or Default ACL of a file.
99 */ 99 */
100static int nfsacld_proc_setacl(struct svc_rqst * rqstp, 100static __be32 nfsacld_proc_setacl(struct svc_rqst * rqstp,
101 struct nfsd3_setaclargs *argp, 101 struct nfsd3_setaclargs *argp,
102 struct nfsd_attrstat *resp) 102 struct nfsd_attrstat *resp)
103{ 103{
104 svc_fh *fh; 104 svc_fh *fh;
105 int nfserr = 0; 105 __be32 nfserr = 0;
106 106
107 dprintk("nfsd: SETACL(2acl) %s\n", SVCFH_fmt(&argp->fh)); 107 dprintk("nfsd: SETACL(2acl) %s\n", SVCFH_fmt(&argp->fh));
108 108
@@ -128,7 +128,7 @@ static int nfsacld_proc_setacl(struct svc_rqst * rqstp,
128/* 128/*
129 * Check file attributes 129 * Check file attributes
130 */ 130 */
131static int nfsacld_proc_getattr(struct svc_rqst * rqstp, 131static __be32 nfsacld_proc_getattr(struct svc_rqst * rqstp,
132 struct nfsd_fhandle *argp, struct nfsd_attrstat *resp) 132 struct nfsd_fhandle *argp, struct nfsd_attrstat *resp)
133{ 133{
134 dprintk("nfsd: GETATTR %s\n", SVCFH_fmt(&argp->fh)); 134 dprintk("nfsd: GETATTR %s\n", SVCFH_fmt(&argp->fh));
@@ -140,10 +140,10 @@ static int nfsacld_proc_getattr(struct svc_rqst * rqstp,
140/* 140/*
141 * Check file access 141 * Check file access
142 */ 142 */
143static int nfsacld_proc_access(struct svc_rqst *rqstp, struct nfsd3_accessargs *argp, 143static __be32 nfsacld_proc_access(struct svc_rqst *rqstp, struct nfsd3_accessargs *argp,
144 struct nfsd3_accessres *resp) 144 struct nfsd3_accessres *resp)
145{ 145{
146 int nfserr; 146 __be32 nfserr;
147 147
148 dprintk("nfsd: ACCESS(2acl) %s 0x%x\n", 148 dprintk("nfsd: ACCESS(2acl) %s 0x%x\n",
149 SVCFH_fmt(&argp->fh), 149 SVCFH_fmt(&argp->fh),
@@ -158,7 +158,7 @@ static int nfsacld_proc_access(struct svc_rqst *rqstp, struct nfsd3_accessargs *
158/* 158/*
159 * XDR decode functions 159 * XDR decode functions
160 */ 160 */
161static int nfsaclsvc_decode_getaclargs(struct svc_rqst *rqstp, u32 *p, 161static int nfsaclsvc_decode_getaclargs(struct svc_rqst *rqstp, __be32 *p,
162 struct nfsd3_getaclargs *argp) 162 struct nfsd3_getaclargs *argp)
163{ 163{
164 if (!(p = nfs2svc_decode_fh(p, &argp->fh))) 164 if (!(p = nfs2svc_decode_fh(p, &argp->fh)))
@@ -169,7 +169,7 @@ static int nfsaclsvc_decode_getaclargs(struct svc_rqst *rqstp, u32 *p,
169} 169}
170 170
171 171
172static int nfsaclsvc_decode_setaclargs(struct svc_rqst *rqstp, u32 *p, 172static int nfsaclsvc_decode_setaclargs(struct svc_rqst *rqstp, __be32 *p,
173 struct nfsd3_setaclargs *argp) 173 struct nfsd3_setaclargs *argp)
174{ 174{
175 struct kvec *head = rqstp->rq_arg.head; 175 struct kvec *head = rqstp->rq_arg.head;
@@ -194,7 +194,7 @@ static int nfsaclsvc_decode_setaclargs(struct svc_rqst *rqstp, u32 *p,
194 return (n > 0); 194 return (n > 0);
195} 195}
196 196
197static int nfsaclsvc_decode_fhandleargs(struct svc_rqst *rqstp, u32 *p, 197static int nfsaclsvc_decode_fhandleargs(struct svc_rqst *rqstp, __be32 *p,
198 struct nfsd_fhandle *argp) 198 struct nfsd_fhandle *argp)
199{ 199{
200 if (!(p = nfs2svc_decode_fh(p, &argp->fh))) 200 if (!(p = nfs2svc_decode_fh(p, &argp->fh)))
@@ -202,7 +202,7 @@ static int nfsaclsvc_decode_fhandleargs(struct svc_rqst *rqstp, u32 *p,
202 return xdr_argsize_check(rqstp, p); 202 return xdr_argsize_check(rqstp, p);
203} 203}
204 204
205static int nfsaclsvc_decode_accessargs(struct svc_rqst *rqstp, u32 *p, 205static int nfsaclsvc_decode_accessargs(struct svc_rqst *rqstp, __be32 *p,
206 struct nfsd3_accessargs *argp) 206 struct nfsd3_accessargs *argp)
207{ 207{
208 if (!(p = nfs2svc_decode_fh(p, &argp->fh))) 208 if (!(p = nfs2svc_decode_fh(p, &argp->fh)))
@@ -217,7 +217,7 @@ static int nfsaclsvc_decode_accessargs(struct svc_rqst *rqstp, u32 *p,
217 */ 217 */
218 218
219/* GETACL */ 219/* GETACL */
220static int nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, u32 *p, 220static int nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p,
221 struct nfsd3_getaclres *resp) 221 struct nfsd3_getaclres *resp)
222{ 222{
223 struct dentry *dentry = resp->fh.fh_dentry; 223 struct dentry *dentry = resp->fh.fh_dentry;
@@ -259,7 +259,7 @@ static int nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, u32 *p,
259 return 1; 259 return 1;
260} 260}
261 261
262static int nfsaclsvc_encode_attrstatres(struct svc_rqst *rqstp, u32 *p, 262static int nfsaclsvc_encode_attrstatres(struct svc_rqst *rqstp, __be32 *p,
263 struct nfsd_attrstat *resp) 263 struct nfsd_attrstat *resp)
264{ 264{
265 p = nfs2svc_encode_fattr(rqstp, p, &resp->fh); 265 p = nfs2svc_encode_fattr(rqstp, p, &resp->fh);
@@ -267,7 +267,7 @@ static int nfsaclsvc_encode_attrstatres(struct svc_rqst *rqstp, u32 *p,
267} 267}
268 268
269/* ACCESS */ 269/* ACCESS */
270static int nfsaclsvc_encode_accessres(struct svc_rqst *rqstp, u32 *p, 270static int nfsaclsvc_encode_accessres(struct svc_rqst *rqstp, __be32 *p,
271 struct nfsd3_accessres *resp) 271 struct nfsd3_accessres *resp)
272{ 272{
273 p = nfs2svc_encode_fattr(rqstp, p, &resp->fh); 273 p = nfs2svc_encode_fattr(rqstp, p, &resp->fh);
@@ -278,7 +278,7 @@ static int nfsaclsvc_encode_accessres(struct svc_rqst *rqstp, u32 *p,
278/* 278/*
279 * XDR release functions 279 * XDR release functions
280 */ 280 */
281static int nfsaclsvc_release_getacl(struct svc_rqst *rqstp, u32 *p, 281static int nfsaclsvc_release_getacl(struct svc_rqst *rqstp, __be32 *p,
282 struct nfsd3_getaclres *resp) 282 struct nfsd3_getaclres *resp)
283{ 283{
284 fh_put(&resp->fh); 284 fh_put(&resp->fh);
@@ -287,7 +287,7 @@ static int nfsaclsvc_release_getacl(struct svc_rqst *rqstp, u32 *p,
287 return 1; 287 return 1;
288} 288}
289 289
290static int nfsaclsvc_release_fhandle(struct svc_rqst *rqstp, u32 *p, 290static int nfsaclsvc_release_fhandle(struct svc_rqst *rqstp, __be32 *p,
291 struct nfsd_fhandle *resp) 291 struct nfsd_fhandle *resp)
292{ 292{
293 fh_put(&resp->fh); 293 fh_put(&resp->fh);
diff --git a/fs/nfsd/nfs3acl.c b/fs/nfsd/nfs3acl.c
index d4bdc00c1169..fcad2895ddb0 100644
--- a/fs/nfsd/nfs3acl.c
+++ b/fs/nfsd/nfs3acl.c
@@ -19,7 +19,7 @@
19/* 19/*
20 * NULL call. 20 * NULL call.
21 */ 21 */
22static int 22static __be32
23nfsd3_proc_null(struct svc_rqst *rqstp, void *argp, void *resp) 23nfsd3_proc_null(struct svc_rqst *rqstp, void *argp, void *resp)
24{ 24{
25 return nfs_ok; 25 return nfs_ok;
@@ -28,12 +28,12 @@ nfsd3_proc_null(struct svc_rqst *rqstp, void *argp, void *resp)
28/* 28/*
29 * Get the Access and/or Default ACL of a file. 29 * Get the Access and/or Default ACL of a file.
30 */ 30 */
31static int nfsd3_proc_getacl(struct svc_rqst * rqstp, 31static __be32 nfsd3_proc_getacl(struct svc_rqst * rqstp,
32 struct nfsd3_getaclargs *argp, struct nfsd3_getaclres *resp) 32 struct nfsd3_getaclargs *argp, struct nfsd3_getaclres *resp)
33{ 33{
34 svc_fh *fh; 34 svc_fh *fh;
35 struct posix_acl *acl; 35 struct posix_acl *acl;
36 int nfserr = 0; 36 __be32 nfserr = 0;
37 37
38 fh = fh_copy(&resp->fh, &argp->fh); 38 fh = fh_copy(&resp->fh, &argp->fh);
39 if ((nfserr = fh_verify(rqstp, &resp->fh, 0, MAY_NOP))) 39 if ((nfserr = fh_verify(rqstp, &resp->fh, 0, MAY_NOP)))
@@ -93,12 +93,12 @@ fail:
93/* 93/*
94 * Set the Access and/or Default ACL of a file. 94 * Set the Access and/or Default ACL of a file.
95 */ 95 */
96static int nfsd3_proc_setacl(struct svc_rqst * rqstp, 96static __be32 nfsd3_proc_setacl(struct svc_rqst * rqstp,
97 struct nfsd3_setaclargs *argp, 97 struct nfsd3_setaclargs *argp,
98 struct nfsd3_attrstat *resp) 98 struct nfsd3_attrstat *resp)
99{ 99{
100 svc_fh *fh; 100 svc_fh *fh;
101 int nfserr = 0; 101 __be32 nfserr = 0;
102 102
103 fh = fh_copy(&resp->fh, &argp->fh); 103 fh = fh_copy(&resp->fh, &argp->fh);
104 nfserr = fh_verify(rqstp, &resp->fh, 0, MAY_SATTR); 104 nfserr = fh_verify(rqstp, &resp->fh, 0, MAY_SATTR);
@@ -122,7 +122,7 @@ static int nfsd3_proc_setacl(struct svc_rqst * rqstp,
122/* 122/*
123 * XDR decode functions 123 * XDR decode functions
124 */ 124 */
125static int nfs3svc_decode_getaclargs(struct svc_rqst *rqstp, u32 *p, 125static int nfs3svc_decode_getaclargs(struct svc_rqst *rqstp, __be32 *p,
126 struct nfsd3_getaclargs *args) 126 struct nfsd3_getaclargs *args)
127{ 127{
128 if (!(p = nfs3svc_decode_fh(p, &args->fh))) 128 if (!(p = nfs3svc_decode_fh(p, &args->fh)))
@@ -133,7 +133,7 @@ static int nfs3svc_decode_getaclargs(struct svc_rqst *rqstp, u32 *p,
133} 133}
134 134
135 135
136static int nfs3svc_decode_setaclargs(struct svc_rqst *rqstp, u32 *p, 136static int nfs3svc_decode_setaclargs(struct svc_rqst *rqstp, __be32 *p,
137 struct nfsd3_setaclargs *args) 137 struct nfsd3_setaclargs *args)
138{ 138{
139 struct kvec *head = rqstp->rq_arg.head; 139 struct kvec *head = rqstp->rq_arg.head;
@@ -163,7 +163,7 @@ static int nfs3svc_decode_setaclargs(struct svc_rqst *rqstp, u32 *p,
163 */ 163 */
164 164
165/* GETACL */ 165/* GETACL */
166static int nfs3svc_encode_getaclres(struct svc_rqst *rqstp, u32 *p, 166static int nfs3svc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p,
167 struct nfsd3_getaclres *resp) 167 struct nfsd3_getaclres *resp)
168{ 168{
169 struct dentry *dentry = resp->fh.fh_dentry; 169 struct dentry *dentry = resp->fh.fh_dentry;
@@ -208,7 +208,7 @@ static int nfs3svc_encode_getaclres(struct svc_rqst *rqstp, u32 *p,
208} 208}
209 209
210/* SETACL */ 210/* SETACL */
211static int nfs3svc_encode_setaclres(struct svc_rqst *rqstp, u32 *p, 211static int nfs3svc_encode_setaclres(struct svc_rqst *rqstp, __be32 *p,
212 struct nfsd3_attrstat *resp) 212 struct nfsd3_attrstat *resp)
213{ 213{
214 p = nfs3svc_encode_post_op_attr(rqstp, p, &resp->fh); 214 p = nfs3svc_encode_post_op_attr(rqstp, p, &resp->fh);
@@ -219,7 +219,7 @@ static int nfs3svc_encode_setaclres(struct svc_rqst *rqstp, u32 *p,
219/* 219/*
220 * XDR release functions 220 * XDR release functions
221 */ 221 */
222static int nfs3svc_release_getacl(struct svc_rqst *rqstp, u32 *p, 222static int nfs3svc_release_getacl(struct svc_rqst *rqstp, __be32 *p,
223 struct nfsd3_getaclres *resp) 223 struct nfsd3_getaclres *resp)
224{ 224{
225 fh_put(&resp->fh); 225 fh_put(&resp->fh);
diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c
index a5ebc7dbb384..7f5bad0393b1 100644
--- a/fs/nfsd/nfs3proc.c
+++ b/fs/nfsd/nfs3proc.c
@@ -43,7 +43,7 @@ static int nfs3_ftypes[] = {
43/* 43/*
44 * NULL call. 44 * NULL call.
45 */ 45 */
46static int 46static __be32
47nfsd3_proc_null(struct svc_rqst *rqstp, void *argp, void *resp) 47nfsd3_proc_null(struct svc_rqst *rqstp, void *argp, void *resp)
48{ 48{
49 return nfs_ok; 49 return nfs_ok;
@@ -52,11 +52,12 @@ nfsd3_proc_null(struct svc_rqst *rqstp, void *argp, void *resp)
52/* 52/*
53 * Get a file's attributes 53 * Get a file's attributes
54 */ 54 */
55static int 55static __be32
56nfsd3_proc_getattr(struct svc_rqst *rqstp, struct nfsd_fhandle *argp, 56nfsd3_proc_getattr(struct svc_rqst *rqstp, struct nfsd_fhandle *argp,
57 struct nfsd3_attrstat *resp) 57 struct nfsd3_attrstat *resp)
58{ 58{
59 int err, nfserr; 59 int err;
60 __be32 nfserr;
60 61
61 dprintk("nfsd: GETATTR(3) %s\n", 62 dprintk("nfsd: GETATTR(3) %s\n",
62 SVCFH_fmt(&argp->fh)); 63 SVCFH_fmt(&argp->fh));
@@ -76,11 +77,11 @@ nfsd3_proc_getattr(struct svc_rqst *rqstp, struct nfsd_fhandle *argp,
76/* 77/*
77 * Set a file's attributes 78 * Set a file's attributes
78 */ 79 */
79static int 80static __be32
80nfsd3_proc_setattr(struct svc_rqst *rqstp, struct nfsd3_sattrargs *argp, 81nfsd3_proc_setattr(struct svc_rqst *rqstp, struct nfsd3_sattrargs *argp,
81 struct nfsd3_attrstat *resp) 82 struct nfsd3_attrstat *resp)
82{ 83{
83 int nfserr; 84 __be32 nfserr;
84 85
85 dprintk("nfsd: SETATTR(3) %s\n", 86 dprintk("nfsd: SETATTR(3) %s\n",
86 SVCFH_fmt(&argp->fh)); 87 SVCFH_fmt(&argp->fh));
@@ -94,11 +95,11 @@ nfsd3_proc_setattr(struct svc_rqst *rqstp, struct nfsd3_sattrargs *argp,
94/* 95/*
95 * Look up a path name component 96 * Look up a path name component
96 */ 97 */
97static int 98static __be32
98nfsd3_proc_lookup(struct svc_rqst *rqstp, struct nfsd3_diropargs *argp, 99nfsd3_proc_lookup(struct svc_rqst *rqstp, struct nfsd3_diropargs *argp,
99 struct nfsd3_diropres *resp) 100 struct nfsd3_diropres *resp)
100{ 101{
101 int nfserr; 102 __be32 nfserr;
102 103
103 dprintk("nfsd: LOOKUP(3) %s %.*s\n", 104 dprintk("nfsd: LOOKUP(3) %s %.*s\n",
104 SVCFH_fmt(&argp->fh), 105 SVCFH_fmt(&argp->fh),
@@ -118,11 +119,11 @@ nfsd3_proc_lookup(struct svc_rqst *rqstp, struct nfsd3_diropargs *argp,
118/* 119/*
119 * Check file access 120 * Check file access
120 */ 121 */
121static int 122static __be32
122nfsd3_proc_access(struct svc_rqst *rqstp, struct nfsd3_accessargs *argp, 123nfsd3_proc_access(struct svc_rqst *rqstp, struct nfsd3_accessargs *argp,
123 struct nfsd3_accessres *resp) 124 struct nfsd3_accessres *resp)
124{ 125{
125 int nfserr; 126 __be32 nfserr;
126 127
127 dprintk("nfsd: ACCESS(3) %s 0x%x\n", 128 dprintk("nfsd: ACCESS(3) %s 0x%x\n",
128 SVCFH_fmt(&argp->fh), 129 SVCFH_fmt(&argp->fh),
@@ -137,11 +138,11 @@ nfsd3_proc_access(struct svc_rqst *rqstp, struct nfsd3_accessargs *argp,
137/* 138/*
138 * Read a symlink. 139 * Read a symlink.
139 */ 140 */
140static int 141static __be32
141nfsd3_proc_readlink(struct svc_rqst *rqstp, struct nfsd3_readlinkargs *argp, 142nfsd3_proc_readlink(struct svc_rqst *rqstp, struct nfsd3_readlinkargs *argp,
142 struct nfsd3_readlinkres *resp) 143 struct nfsd3_readlinkres *resp)
143{ 144{
144 int nfserr; 145 __be32 nfserr;
145 146
146 dprintk("nfsd: READLINK(3) %s\n", SVCFH_fmt(&argp->fh)); 147 dprintk("nfsd: READLINK(3) %s\n", SVCFH_fmt(&argp->fh));
147 148
@@ -155,11 +156,11 @@ nfsd3_proc_readlink(struct svc_rqst *rqstp, struct nfsd3_readlinkargs *argp,
155/* 156/*
156 * Read a portion of a file. 157 * Read a portion of a file.
157 */ 158 */
158static int 159static __be32
159nfsd3_proc_read(struct svc_rqst *rqstp, struct nfsd3_readargs *argp, 160nfsd3_proc_read(struct svc_rqst *rqstp, struct nfsd3_readargs *argp,
160 struct nfsd3_readres *resp) 161 struct nfsd3_readres *resp)
161{ 162{
162 int nfserr; 163 __be32 nfserr;
163 u32 max_blocksize = svc_max_payload(rqstp); 164 u32 max_blocksize = svc_max_payload(rqstp);
164 165
165 dprintk("nfsd: READ(3) %s %lu bytes at %lu\n", 166 dprintk("nfsd: READ(3) %s %lu bytes at %lu\n",
@@ -195,11 +196,11 @@ nfsd3_proc_read(struct svc_rqst *rqstp, struct nfsd3_readargs *argp,
195/* 196/*
196 * Write data to a file 197 * Write data to a file
197 */ 198 */
198static int 199static __be32
199nfsd3_proc_write(struct svc_rqst *rqstp, struct nfsd3_writeargs *argp, 200nfsd3_proc_write(struct svc_rqst *rqstp, struct nfsd3_writeargs *argp,
200 struct nfsd3_writeres *resp) 201 struct nfsd3_writeres *resp)
201{ 202{
202 int nfserr; 203 __be32 nfserr;
203 204
204 dprintk("nfsd: WRITE(3) %s %d bytes at %ld%s\n", 205 dprintk("nfsd: WRITE(3) %s %d bytes at %ld%s\n",
205 SVCFH_fmt(&argp->fh), 206 SVCFH_fmt(&argp->fh),
@@ -223,13 +224,13 @@ nfsd3_proc_write(struct svc_rqst *rqstp, struct nfsd3_writeargs *argp,
223 * At least in theory; we'll see how it fares in practice when the 224 * At least in theory; we'll see how it fares in practice when the
224 * first reports about SunOS compatibility problems start to pour in... 225 * first reports about SunOS compatibility problems start to pour in...
225 */ 226 */
226static int 227static __be32
227nfsd3_proc_create(struct svc_rqst *rqstp, struct nfsd3_createargs *argp, 228nfsd3_proc_create(struct svc_rqst *rqstp, struct nfsd3_createargs *argp,
228 struct nfsd3_diropres *resp) 229 struct nfsd3_diropres *resp)
229{ 230{
230 svc_fh *dirfhp, *newfhp = NULL; 231 svc_fh *dirfhp, *newfhp = NULL;
231 struct iattr *attr; 232 struct iattr *attr;
232 u32 nfserr; 233 __be32 nfserr;
233 234
234 dprintk("nfsd: CREATE(3) %s %.*s\n", 235 dprintk("nfsd: CREATE(3) %s %.*s\n",
235 SVCFH_fmt(&argp->fh), 236 SVCFH_fmt(&argp->fh),
@@ -257,7 +258,7 @@ nfsd3_proc_create(struct svc_rqst *rqstp, struct nfsd3_createargs *argp,
257 /* Now create the file and set attributes */ 258 /* Now create the file and set attributes */
258 nfserr = nfsd_create_v3(rqstp, dirfhp, argp->name, argp->len, 259 nfserr = nfsd_create_v3(rqstp, dirfhp, argp->name, argp->len,
259 attr, newfhp, 260 attr, newfhp,
260 argp->createmode, argp->verf, NULL); 261 argp->createmode, argp->verf, NULL, NULL);
261 262
262 RETURN_STATUS(nfserr); 263 RETURN_STATUS(nfserr);
263} 264}
@@ -265,11 +266,11 @@ nfsd3_proc_create(struct svc_rqst *rqstp, struct nfsd3_createargs *argp,
265/* 266/*
266 * Make directory. This operation is not idempotent. 267 * Make directory. This operation is not idempotent.
267 */ 268 */
268static int 269static __be32
269nfsd3_proc_mkdir(struct svc_rqst *rqstp, struct nfsd3_createargs *argp, 270nfsd3_proc_mkdir(struct svc_rqst *rqstp, struct nfsd3_createargs *argp,
270 struct nfsd3_diropres *resp) 271 struct nfsd3_diropres *resp)
271{ 272{
272 int nfserr; 273 __be32 nfserr;
273 274
274 dprintk("nfsd: MKDIR(3) %s %.*s\n", 275 dprintk("nfsd: MKDIR(3) %s %.*s\n",
275 SVCFH_fmt(&argp->fh), 276 SVCFH_fmt(&argp->fh),
@@ -285,11 +286,11 @@ nfsd3_proc_mkdir(struct svc_rqst *rqstp, struct nfsd3_createargs *argp,
285 RETURN_STATUS(nfserr); 286 RETURN_STATUS(nfserr);
286} 287}
287 288
288static int 289static __be32
289nfsd3_proc_symlink(struct svc_rqst *rqstp, struct nfsd3_symlinkargs *argp, 290nfsd3_proc_symlink(struct svc_rqst *rqstp, struct nfsd3_symlinkargs *argp,
290 struct nfsd3_diropres *resp) 291 struct nfsd3_diropres *resp)
291{ 292{
292 int nfserr; 293 __be32 nfserr;
293 294
294 dprintk("nfsd: SYMLINK(3) %s %.*s -> %.*s\n", 295 dprintk("nfsd: SYMLINK(3) %s %.*s -> %.*s\n",
295 SVCFH_fmt(&argp->ffh), 296 SVCFH_fmt(&argp->ffh),
@@ -307,11 +308,12 @@ nfsd3_proc_symlink(struct svc_rqst *rqstp, struct nfsd3_symlinkargs *argp,
307/* 308/*
308 * Make socket/fifo/device. 309 * Make socket/fifo/device.
309 */ 310 */
310static int 311static __be32
311nfsd3_proc_mknod(struct svc_rqst *rqstp, struct nfsd3_mknodargs *argp, 312nfsd3_proc_mknod(struct svc_rqst *rqstp, struct nfsd3_mknodargs *argp,
312 struct nfsd3_diropres *resp) 313 struct nfsd3_diropres *resp)
313{ 314{
314 int nfserr, type; 315 __be32 nfserr;
316 int type;
315 dev_t rdev = 0; 317 dev_t rdev = 0;
316 318
317 dprintk("nfsd: MKNOD(3) %s %.*s\n", 319 dprintk("nfsd: MKNOD(3) %s %.*s\n",
@@ -343,11 +345,11 @@ nfsd3_proc_mknod(struct svc_rqst *rqstp, struct nfsd3_mknodargs *argp,
343/* 345/*
344 * Remove file/fifo/socket etc. 346 * Remove file/fifo/socket etc.
345 */ 347 */
346static int 348static __be32
347nfsd3_proc_remove(struct svc_rqst *rqstp, struct nfsd3_diropargs *argp, 349nfsd3_proc_remove(struct svc_rqst *rqstp, struct nfsd3_diropargs *argp,
348 struct nfsd3_attrstat *resp) 350 struct nfsd3_attrstat *resp)
349{ 351{
350 int nfserr; 352 __be32 nfserr;
351 353
352 dprintk("nfsd: REMOVE(3) %s %.*s\n", 354 dprintk("nfsd: REMOVE(3) %s %.*s\n",
353 SVCFH_fmt(&argp->fh), 355 SVCFH_fmt(&argp->fh),
@@ -363,11 +365,11 @@ nfsd3_proc_remove(struct svc_rqst *rqstp, struct nfsd3_diropargs *argp,
363/* 365/*
364 * Remove a directory 366 * Remove a directory
365 */ 367 */
366static int 368static __be32
367nfsd3_proc_rmdir(struct svc_rqst *rqstp, struct nfsd3_diropargs *argp, 369nfsd3_proc_rmdir(struct svc_rqst *rqstp, struct nfsd3_diropargs *argp,
368 struct nfsd3_attrstat *resp) 370 struct nfsd3_attrstat *resp)
369{ 371{
370 int nfserr; 372 __be32 nfserr;
371 373
372 dprintk("nfsd: RMDIR(3) %s %.*s\n", 374 dprintk("nfsd: RMDIR(3) %s %.*s\n",
373 SVCFH_fmt(&argp->fh), 375 SVCFH_fmt(&argp->fh),
@@ -379,11 +381,11 @@ nfsd3_proc_rmdir(struct svc_rqst *rqstp, struct nfsd3_diropargs *argp,
379 RETURN_STATUS(nfserr); 381 RETURN_STATUS(nfserr);
380} 382}
381 383
382static int 384static __be32
383nfsd3_proc_rename(struct svc_rqst *rqstp, struct nfsd3_renameargs *argp, 385nfsd3_proc_rename(struct svc_rqst *rqstp, struct nfsd3_renameargs *argp,
384 struct nfsd3_renameres *resp) 386 struct nfsd3_renameres *resp)
385{ 387{
386 int nfserr; 388 __be32 nfserr;
387 389
388 dprintk("nfsd: RENAME(3) %s %.*s ->\n", 390 dprintk("nfsd: RENAME(3) %s %.*s ->\n",
389 SVCFH_fmt(&argp->ffh), 391 SVCFH_fmt(&argp->ffh),
@@ -401,11 +403,11 @@ nfsd3_proc_rename(struct svc_rqst *rqstp, struct nfsd3_renameargs *argp,
401 RETURN_STATUS(nfserr); 403 RETURN_STATUS(nfserr);
402} 404}
403 405
404static int 406static __be32
405nfsd3_proc_link(struct svc_rqst *rqstp, struct nfsd3_linkargs *argp, 407nfsd3_proc_link(struct svc_rqst *rqstp, struct nfsd3_linkargs *argp,
406 struct nfsd3_linkres *resp) 408 struct nfsd3_linkres *resp)
407{ 409{
408 int nfserr; 410 __be32 nfserr;
409 411
410 dprintk("nfsd: LINK(3) %s ->\n", 412 dprintk("nfsd: LINK(3) %s ->\n",
411 SVCFH_fmt(&argp->ffh)); 413 SVCFH_fmt(&argp->ffh));
@@ -424,11 +426,12 @@ nfsd3_proc_link(struct svc_rqst *rqstp, struct nfsd3_linkargs *argp,
424/* 426/*
425 * Read a portion of a directory. 427 * Read a portion of a directory.
426 */ 428 */
427static int 429static __be32
428nfsd3_proc_readdir(struct svc_rqst *rqstp, struct nfsd3_readdirargs *argp, 430nfsd3_proc_readdir(struct svc_rqst *rqstp, struct nfsd3_readdirargs *argp,
429 struct nfsd3_readdirres *resp) 431 struct nfsd3_readdirres *resp)
430{ 432{
431 int nfserr, count; 433 __be32 nfserr;
434 int count;
432 435
433 dprintk("nfsd: READDIR(3) %s %d bytes at %d\n", 436 dprintk("nfsd: READDIR(3) %s %d bytes at %d\n",
434 SVCFH_fmt(&argp->fh), 437 SVCFH_fmt(&argp->fh),
@@ -459,11 +462,12 @@ nfsd3_proc_readdir(struct svc_rqst *rqstp, struct nfsd3_readdirargs *argp,
459 * Read a portion of a directory, including file handles and attrs. 462 * Read a portion of a directory, including file handles and attrs.
460 * For now, we choose to ignore the dircount parameter. 463 * For now, we choose to ignore the dircount parameter.
461 */ 464 */
462static int 465static __be32
463nfsd3_proc_readdirplus(struct svc_rqst *rqstp, struct nfsd3_readdirargs *argp, 466nfsd3_proc_readdirplus(struct svc_rqst *rqstp, struct nfsd3_readdirargs *argp,
464 struct nfsd3_readdirres *resp) 467 struct nfsd3_readdirres *resp)
465{ 468{
466 int nfserr, count = 0; 469 __be32 nfserr;
470 int count = 0;
467 loff_t offset; 471 loff_t offset;
468 int i; 472 int i;
469 caddr_t page_addr = NULL; 473 caddr_t page_addr = NULL;
@@ -517,11 +521,11 @@ nfsd3_proc_readdirplus(struct svc_rqst *rqstp, struct nfsd3_readdirargs *argp,
517/* 521/*
518 * Get file system stats 522 * Get file system stats
519 */ 523 */
520static int 524static __be32
521nfsd3_proc_fsstat(struct svc_rqst * rqstp, struct nfsd_fhandle *argp, 525nfsd3_proc_fsstat(struct svc_rqst * rqstp, struct nfsd_fhandle *argp,
522 struct nfsd3_fsstatres *resp) 526 struct nfsd3_fsstatres *resp)
523{ 527{
524 int nfserr; 528 __be32 nfserr;
525 529
526 dprintk("nfsd: FSSTAT(3) %s\n", 530 dprintk("nfsd: FSSTAT(3) %s\n",
527 SVCFH_fmt(&argp->fh)); 531 SVCFH_fmt(&argp->fh));
@@ -534,11 +538,11 @@ nfsd3_proc_fsstat(struct svc_rqst * rqstp, struct nfsd_fhandle *argp,
534/* 538/*
535 * Get file system info 539 * Get file system info
536 */ 540 */
537static int 541static __be32
538nfsd3_proc_fsinfo(struct svc_rqst * rqstp, struct nfsd_fhandle *argp, 542nfsd3_proc_fsinfo(struct svc_rqst * rqstp, struct nfsd_fhandle *argp,
539 struct nfsd3_fsinfores *resp) 543 struct nfsd3_fsinfores *resp)
540{ 544{
541 int nfserr; 545 __be32 nfserr;
542 u32 max_blocksize = svc_max_payload(rqstp); 546 u32 max_blocksize = svc_max_payload(rqstp);
543 547
544 dprintk("nfsd: FSINFO(3) %s\n", 548 dprintk("nfsd: FSINFO(3) %s\n",
@@ -576,11 +580,11 @@ nfsd3_proc_fsinfo(struct svc_rqst * rqstp, struct nfsd_fhandle *argp,
576/* 580/*
577 * Get pathconf info for the specified file 581 * Get pathconf info for the specified file
578 */ 582 */
579static int 583static __be32
580nfsd3_proc_pathconf(struct svc_rqst * rqstp, struct nfsd_fhandle *argp, 584nfsd3_proc_pathconf(struct svc_rqst * rqstp, struct nfsd_fhandle *argp,
581 struct nfsd3_pathconfres *resp) 585 struct nfsd3_pathconfres *resp)
582{ 586{
583 int nfserr; 587 __be32 nfserr;
584 588
585 dprintk("nfsd: PATHCONF(3) %s\n", 589 dprintk("nfsd: PATHCONF(3) %s\n",
586 SVCFH_fmt(&argp->fh)); 590 SVCFH_fmt(&argp->fh));
@@ -619,11 +623,11 @@ nfsd3_proc_pathconf(struct svc_rqst * rqstp, struct nfsd_fhandle *argp,
619/* 623/*
620 * Commit a file (range) to stable storage. 624 * Commit a file (range) to stable storage.
621 */ 625 */
622static int 626static __be32
623nfsd3_proc_commit(struct svc_rqst * rqstp, struct nfsd3_commitargs *argp, 627nfsd3_proc_commit(struct svc_rqst * rqstp, struct nfsd3_commitargs *argp,
624 struct nfsd3_commitres *resp) 628 struct nfsd3_commitres *resp)
625{ 629{
626 int nfserr; 630 __be32 nfserr;
627 631
628 dprintk("nfsd: COMMIT(3) %s %u@%Lu\n", 632 dprintk("nfsd: COMMIT(3) %s %u@%Lu\n",
629 SVCFH_fmt(&argp->fh), 633 SVCFH_fmt(&argp->fh),
diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c
index 247d518248bf..b4baca3053c3 100644
--- a/fs/nfsd/nfs3xdr.c
+++ b/fs/nfsd/nfs3xdr.c
@@ -42,23 +42,23 @@ static u32 nfs3_ftypes[] = {
42/* 42/*
43 * XDR functions for basic NFS types 43 * XDR functions for basic NFS types
44 */ 44 */
45static inline u32 * 45static inline __be32 *
46encode_time3(u32 *p, struct timespec *time) 46encode_time3(__be32 *p, struct timespec *time)
47{ 47{
48 *p++ = htonl((u32) time->tv_sec); *p++ = htonl(time->tv_nsec); 48 *p++ = htonl((u32) time->tv_sec); *p++ = htonl(time->tv_nsec);
49 return p; 49 return p;
50} 50}
51 51
52static inline u32 * 52static inline __be32 *
53decode_time3(u32 *p, struct timespec *time) 53decode_time3(__be32 *p, struct timespec *time)
54{ 54{
55 time->tv_sec = ntohl(*p++); 55 time->tv_sec = ntohl(*p++);
56 time->tv_nsec = ntohl(*p++); 56 time->tv_nsec = ntohl(*p++);
57 return p; 57 return p;
58} 58}
59 59
60static inline u32 * 60static inline __be32 *
61decode_fh(u32 *p, struct svc_fh *fhp) 61decode_fh(__be32 *p, struct svc_fh *fhp)
62{ 62{
63 unsigned int size; 63 unsigned int size;
64 fh_init(fhp, NFS3_FHSIZE); 64 fh_init(fhp, NFS3_FHSIZE);
@@ -72,13 +72,13 @@ decode_fh(u32 *p, struct svc_fh *fhp)
72} 72}
73 73
74/* Helper function for NFSv3 ACL code */ 74/* Helper function for NFSv3 ACL code */
75u32 *nfs3svc_decode_fh(u32 *p, struct svc_fh *fhp) 75__be32 *nfs3svc_decode_fh(__be32 *p, struct svc_fh *fhp)
76{ 76{
77 return decode_fh(p, fhp); 77 return decode_fh(p, fhp);
78} 78}
79 79
80static inline u32 * 80static inline __be32 *
81encode_fh(u32 *p, struct svc_fh *fhp) 81encode_fh(__be32 *p, struct svc_fh *fhp)
82{ 82{
83 unsigned int size = fhp->fh_handle.fh_size; 83 unsigned int size = fhp->fh_handle.fh_size;
84 *p++ = htonl(size); 84 *p++ = htonl(size);
@@ -91,8 +91,8 @@ encode_fh(u32 *p, struct svc_fh *fhp)
91 * Decode a file name and make sure that the path contains 91 * Decode a file name and make sure that the path contains
92 * no slashes or null bytes. 92 * no slashes or null bytes.
93 */ 93 */
94static inline u32 * 94static inline __be32 *
95decode_filename(u32 *p, char **namp, int *lenp) 95decode_filename(__be32 *p, char **namp, int *lenp)
96{ 96{
97 char *name; 97 char *name;
98 int i; 98 int i;
@@ -107,8 +107,8 @@ decode_filename(u32 *p, char **namp, int *lenp)
107 return p; 107 return p;
108} 108}
109 109
110static inline u32 * 110static inline __be32 *
111decode_sattr3(u32 *p, struct iattr *iap) 111decode_sattr3(__be32 *p, struct iattr *iap)
112{ 112{
113 u32 tmp; 113 u32 tmp;
114 114
@@ -153,8 +153,8 @@ decode_sattr3(u32 *p, struct iattr *iap)
153 return p; 153 return p;
154} 154}
155 155
156static inline u32 * 156static inline __be32 *
157encode_fattr3(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp, 157encode_fattr3(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp,
158 struct kstat *stat) 158 struct kstat *stat)
159{ 159{
160 struct dentry *dentry = fhp->fh_dentry; 160 struct dentry *dentry = fhp->fh_dentry;
@@ -186,8 +186,8 @@ encode_fattr3(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp,
186 return p; 186 return p;
187} 187}
188 188
189static inline u32 * 189static inline __be32 *
190encode_saved_post_attr(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp) 190encode_saved_post_attr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp)
191{ 191{
192 struct inode *inode = fhp->fh_dentry->d_inode; 192 struct inode *inode = fhp->fh_dentry->d_inode;
193 193
@@ -224,8 +224,8 @@ encode_saved_post_attr(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp)
224 * The inode may be NULL if the call failed because of a stale file 224 * The inode may be NULL if the call failed because of a stale file
225 * handle. In this case, no attributes are returned. 225 * handle. In this case, no attributes are returned.
226 */ 226 */
227static u32 * 227static __be32 *
228encode_post_op_attr(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp) 228encode_post_op_attr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp)
229{ 229{
230 struct dentry *dentry = fhp->fh_dentry; 230 struct dentry *dentry = fhp->fh_dentry;
231 if (dentry && dentry->d_inode != NULL) { 231 if (dentry && dentry->d_inode != NULL) {
@@ -243,8 +243,8 @@ encode_post_op_attr(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp)
243} 243}
244 244
245/* Helper for NFSv3 ACLs */ 245/* Helper for NFSv3 ACLs */
246u32 * 246__be32 *
247nfs3svc_encode_post_op_attr(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp) 247nfs3svc_encode_post_op_attr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp)
248{ 248{
249 return encode_post_op_attr(rqstp, p, fhp); 249 return encode_post_op_attr(rqstp, p, fhp);
250} 250}
@@ -252,8 +252,8 @@ nfs3svc_encode_post_op_attr(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp)
252/* 252/*
253 * Enocde weak cache consistency data 253 * Enocde weak cache consistency data
254 */ 254 */
255static u32 * 255static __be32 *
256encode_wcc_data(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp) 256encode_wcc_data(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp)
257{ 257{
258 struct dentry *dentry = fhp->fh_dentry; 258 struct dentry *dentry = fhp->fh_dentry;
259 259
@@ -278,7 +278,7 @@ encode_wcc_data(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp)
278 * XDR decode functions 278 * XDR decode functions
279 */ 279 */
280int 280int
281nfs3svc_decode_fhandle(struct svc_rqst *rqstp, u32 *p, struct nfsd_fhandle *args) 281nfs3svc_decode_fhandle(struct svc_rqst *rqstp, __be32 *p, struct nfsd_fhandle *args)
282{ 282{
283 if (!(p = decode_fh(p, &args->fh))) 283 if (!(p = decode_fh(p, &args->fh)))
284 return 0; 284 return 0;
@@ -286,7 +286,7 @@ nfs3svc_decode_fhandle(struct svc_rqst *rqstp, u32 *p, struct nfsd_fhandle *args
286} 286}
287 287
288int 288int
289nfs3svc_decode_sattrargs(struct svc_rqst *rqstp, u32 *p, 289nfs3svc_decode_sattrargs(struct svc_rqst *rqstp, __be32 *p,
290 struct nfsd3_sattrargs *args) 290 struct nfsd3_sattrargs *args)
291{ 291{
292 if (!(p = decode_fh(p, &args->fh)) 292 if (!(p = decode_fh(p, &args->fh))
@@ -303,7 +303,7 @@ nfs3svc_decode_sattrargs(struct svc_rqst *rqstp, u32 *p,
303} 303}
304 304
305int 305int
306nfs3svc_decode_diropargs(struct svc_rqst *rqstp, u32 *p, 306nfs3svc_decode_diropargs(struct svc_rqst *rqstp, __be32 *p,
307 struct nfsd3_diropargs *args) 307 struct nfsd3_diropargs *args)
308{ 308{
309 if (!(p = decode_fh(p, &args->fh)) 309 if (!(p = decode_fh(p, &args->fh))
@@ -314,7 +314,7 @@ nfs3svc_decode_diropargs(struct svc_rqst *rqstp, u32 *p,
314} 314}
315 315
316int 316int
317nfs3svc_decode_accessargs(struct svc_rqst *rqstp, u32 *p, 317nfs3svc_decode_accessargs(struct svc_rqst *rqstp, __be32 *p,
318 struct nfsd3_accessargs *args) 318 struct nfsd3_accessargs *args)
319{ 319{
320 if (!(p = decode_fh(p, &args->fh))) 320 if (!(p = decode_fh(p, &args->fh)))
@@ -325,7 +325,7 @@ nfs3svc_decode_accessargs(struct svc_rqst *rqstp, u32 *p,
325} 325}
326 326
327int 327int
328nfs3svc_decode_readargs(struct svc_rqst *rqstp, u32 *p, 328nfs3svc_decode_readargs(struct svc_rqst *rqstp, __be32 *p,
329 struct nfsd3_readargs *args) 329 struct nfsd3_readargs *args)
330{ 330{
331 unsigned int len; 331 unsigned int len;
@@ -355,7 +355,7 @@ nfs3svc_decode_readargs(struct svc_rqst *rqstp, u32 *p,
355} 355}
356 356
357int 357int
358nfs3svc_decode_writeargs(struct svc_rqst *rqstp, u32 *p, 358nfs3svc_decode_writeargs(struct svc_rqst *rqstp, __be32 *p,
359 struct nfsd3_writeargs *args) 359 struct nfsd3_writeargs *args)
360{ 360{
361 unsigned int len, v, hdr; 361 unsigned int len, v, hdr;
@@ -393,7 +393,7 @@ nfs3svc_decode_writeargs(struct svc_rqst *rqstp, u32 *p,
393} 393}
394 394
395int 395int
396nfs3svc_decode_createargs(struct svc_rqst *rqstp, u32 *p, 396nfs3svc_decode_createargs(struct svc_rqst *rqstp, __be32 *p,
397 struct nfsd3_createargs *args) 397 struct nfsd3_createargs *args)
398{ 398{
399 if (!(p = decode_fh(p, &args->fh)) 399 if (!(p = decode_fh(p, &args->fh))
@@ -417,7 +417,7 @@ nfs3svc_decode_createargs(struct svc_rqst *rqstp, u32 *p,
417 return xdr_argsize_check(rqstp, p); 417 return xdr_argsize_check(rqstp, p);
418} 418}
419int 419int
420nfs3svc_decode_mkdirargs(struct svc_rqst *rqstp, u32 *p, 420nfs3svc_decode_mkdirargs(struct svc_rqst *rqstp, __be32 *p,
421 struct nfsd3_createargs *args) 421 struct nfsd3_createargs *args)
422{ 422{
423 if (!(p = decode_fh(p, &args->fh)) 423 if (!(p = decode_fh(p, &args->fh))
@@ -429,7 +429,7 @@ nfs3svc_decode_mkdirargs(struct svc_rqst *rqstp, u32 *p,
429} 429}
430 430
431int 431int
432nfs3svc_decode_symlinkargs(struct svc_rqst *rqstp, u32 *p, 432nfs3svc_decode_symlinkargs(struct svc_rqst *rqstp, __be32 *p,
433 struct nfsd3_symlinkargs *args) 433 struct nfsd3_symlinkargs *args)
434{ 434{
435 unsigned int len; 435 unsigned int len;
@@ -481,7 +481,7 @@ nfs3svc_decode_symlinkargs(struct svc_rqst *rqstp, u32 *p,
481} 481}
482 482
483int 483int
484nfs3svc_decode_mknodargs(struct svc_rqst *rqstp, u32 *p, 484nfs3svc_decode_mknodargs(struct svc_rqst *rqstp, __be32 *p,
485 struct nfsd3_mknodargs *args) 485 struct nfsd3_mknodargs *args)
486{ 486{
487 if (!(p = decode_fh(p, &args->fh)) 487 if (!(p = decode_fh(p, &args->fh))
@@ -505,7 +505,7 @@ nfs3svc_decode_mknodargs(struct svc_rqst *rqstp, u32 *p,
505} 505}
506 506
507int 507int
508nfs3svc_decode_renameargs(struct svc_rqst *rqstp, u32 *p, 508nfs3svc_decode_renameargs(struct svc_rqst *rqstp, __be32 *p,
509 struct nfsd3_renameargs *args) 509 struct nfsd3_renameargs *args)
510{ 510{
511 if (!(p = decode_fh(p, &args->ffh)) 511 if (!(p = decode_fh(p, &args->ffh))
@@ -518,7 +518,7 @@ nfs3svc_decode_renameargs(struct svc_rqst *rqstp, u32 *p,
518} 518}
519 519
520int 520int
521nfs3svc_decode_readlinkargs(struct svc_rqst *rqstp, u32 *p, 521nfs3svc_decode_readlinkargs(struct svc_rqst *rqstp, __be32 *p,
522 struct nfsd3_readlinkargs *args) 522 struct nfsd3_readlinkargs *args)
523{ 523{
524 if (!(p = decode_fh(p, &args->fh))) 524 if (!(p = decode_fh(p, &args->fh)))
@@ -530,7 +530,7 @@ nfs3svc_decode_readlinkargs(struct svc_rqst *rqstp, u32 *p,
530} 530}
531 531
532int 532int
533nfs3svc_decode_linkargs(struct svc_rqst *rqstp, u32 *p, 533nfs3svc_decode_linkargs(struct svc_rqst *rqstp, __be32 *p,
534 struct nfsd3_linkargs *args) 534 struct nfsd3_linkargs *args)
535{ 535{
536 if (!(p = decode_fh(p, &args->ffh)) 536 if (!(p = decode_fh(p, &args->ffh))
@@ -542,7 +542,7 @@ nfs3svc_decode_linkargs(struct svc_rqst *rqstp, u32 *p,
542} 542}
543 543
544int 544int
545nfs3svc_decode_readdirargs(struct svc_rqst *rqstp, u32 *p, 545nfs3svc_decode_readdirargs(struct svc_rqst *rqstp, __be32 *p,
546 struct nfsd3_readdirargs *args) 546 struct nfsd3_readdirargs *args)
547{ 547{
548 if (!(p = decode_fh(p, &args->fh))) 548 if (!(p = decode_fh(p, &args->fh)))
@@ -562,7 +562,7 @@ nfs3svc_decode_readdirargs(struct svc_rqst *rqstp, u32 *p,
562} 562}
563 563
564int 564int
565nfs3svc_decode_readdirplusargs(struct svc_rqst *rqstp, u32 *p, 565nfs3svc_decode_readdirplusargs(struct svc_rqst *rqstp, __be32 *p,
566 struct nfsd3_readdirargs *args) 566 struct nfsd3_readdirargs *args)
567{ 567{
568 int len, pn; 568 int len, pn;
@@ -590,7 +590,7 @@ nfs3svc_decode_readdirplusargs(struct svc_rqst *rqstp, u32 *p,
590} 590}
591 591
592int 592int
593nfs3svc_decode_commitargs(struct svc_rqst *rqstp, u32 *p, 593nfs3svc_decode_commitargs(struct svc_rqst *rqstp, __be32 *p,
594 struct nfsd3_commitargs *args) 594 struct nfsd3_commitargs *args)
595{ 595{
596 if (!(p = decode_fh(p, &args->fh))) 596 if (!(p = decode_fh(p, &args->fh)))
@@ -609,14 +609,14 @@ nfs3svc_decode_commitargs(struct svc_rqst *rqstp, u32 *p,
609 * will work properly. 609 * will work properly.
610 */ 610 */
611int 611int
612nfs3svc_encode_voidres(struct svc_rqst *rqstp, u32 *p, void *dummy) 612nfs3svc_encode_voidres(struct svc_rqst *rqstp, __be32 *p, void *dummy)
613{ 613{
614 return xdr_ressize_check(rqstp, p); 614 return xdr_ressize_check(rqstp, p);
615} 615}
616 616
617/* GETATTR */ 617/* GETATTR */
618int 618int
619nfs3svc_encode_attrstat(struct svc_rqst *rqstp, u32 *p, 619nfs3svc_encode_attrstat(struct svc_rqst *rqstp, __be32 *p,
620 struct nfsd3_attrstat *resp) 620 struct nfsd3_attrstat *resp)
621{ 621{
622 if (resp->status == 0) 622 if (resp->status == 0)
@@ -626,7 +626,7 @@ nfs3svc_encode_attrstat(struct svc_rqst *rqstp, u32 *p,
626 626
627/* SETATTR, REMOVE, RMDIR */ 627/* SETATTR, REMOVE, RMDIR */
628int 628int
629nfs3svc_encode_wccstat(struct svc_rqst *rqstp, u32 *p, 629nfs3svc_encode_wccstat(struct svc_rqst *rqstp, __be32 *p,
630 struct nfsd3_attrstat *resp) 630 struct nfsd3_attrstat *resp)
631{ 631{
632 p = encode_wcc_data(rqstp, p, &resp->fh); 632 p = encode_wcc_data(rqstp, p, &resp->fh);
@@ -635,7 +635,7 @@ nfs3svc_encode_wccstat(struct svc_rqst *rqstp, u32 *p,
635 635
636/* LOOKUP */ 636/* LOOKUP */
637int 637int
638nfs3svc_encode_diropres(struct svc_rqst *rqstp, u32 *p, 638nfs3svc_encode_diropres(struct svc_rqst *rqstp, __be32 *p,
639 struct nfsd3_diropres *resp) 639 struct nfsd3_diropres *resp)
640{ 640{
641 if (resp->status == 0) { 641 if (resp->status == 0) {
@@ -648,7 +648,7 @@ nfs3svc_encode_diropres(struct svc_rqst *rqstp, u32 *p,
648 648
649/* ACCESS */ 649/* ACCESS */
650int 650int
651nfs3svc_encode_accessres(struct svc_rqst *rqstp, u32 *p, 651nfs3svc_encode_accessres(struct svc_rqst *rqstp, __be32 *p,
652 struct nfsd3_accessres *resp) 652 struct nfsd3_accessres *resp)
653{ 653{
654 p = encode_post_op_attr(rqstp, p, &resp->fh); 654 p = encode_post_op_attr(rqstp, p, &resp->fh);
@@ -659,7 +659,7 @@ nfs3svc_encode_accessres(struct svc_rqst *rqstp, u32 *p,
659 659
660/* READLINK */ 660/* READLINK */
661int 661int
662nfs3svc_encode_readlinkres(struct svc_rqst *rqstp, u32 *p, 662nfs3svc_encode_readlinkres(struct svc_rqst *rqstp, __be32 *p,
663 struct nfsd3_readlinkres *resp) 663 struct nfsd3_readlinkres *resp)
664{ 664{
665 p = encode_post_op_attr(rqstp, p, &resp->fh); 665 p = encode_post_op_attr(rqstp, p, &resp->fh);
@@ -680,7 +680,7 @@ nfs3svc_encode_readlinkres(struct svc_rqst *rqstp, u32 *p,
680 680
681/* READ */ 681/* READ */
682int 682int
683nfs3svc_encode_readres(struct svc_rqst *rqstp, u32 *p, 683nfs3svc_encode_readres(struct svc_rqst *rqstp, __be32 *p,
684 struct nfsd3_readres *resp) 684 struct nfsd3_readres *resp)
685{ 685{
686 p = encode_post_op_attr(rqstp, p, &resp->fh); 686 p = encode_post_op_attr(rqstp, p, &resp->fh);
@@ -704,7 +704,7 @@ nfs3svc_encode_readres(struct svc_rqst *rqstp, u32 *p,
704 704
705/* WRITE */ 705/* WRITE */
706int 706int
707nfs3svc_encode_writeres(struct svc_rqst *rqstp, u32 *p, 707nfs3svc_encode_writeres(struct svc_rqst *rqstp, __be32 *p,
708 struct nfsd3_writeres *resp) 708 struct nfsd3_writeres *resp)
709{ 709{
710 p = encode_wcc_data(rqstp, p, &resp->fh); 710 p = encode_wcc_data(rqstp, p, &resp->fh);
@@ -719,7 +719,7 @@ nfs3svc_encode_writeres(struct svc_rqst *rqstp, u32 *p,
719 719
720/* CREATE, MKDIR, SYMLINK, MKNOD */ 720/* CREATE, MKDIR, SYMLINK, MKNOD */
721int 721int
722nfs3svc_encode_createres(struct svc_rqst *rqstp, u32 *p, 722nfs3svc_encode_createres(struct svc_rqst *rqstp, __be32 *p,
723 struct nfsd3_diropres *resp) 723 struct nfsd3_diropres *resp)
724{ 724{
725 if (resp->status == 0) { 725 if (resp->status == 0) {
@@ -733,7 +733,7 @@ nfs3svc_encode_createres(struct svc_rqst *rqstp, u32 *p,
733 733
734/* RENAME */ 734/* RENAME */
735int 735int
736nfs3svc_encode_renameres(struct svc_rqst *rqstp, u32 *p, 736nfs3svc_encode_renameres(struct svc_rqst *rqstp, __be32 *p,
737 struct nfsd3_renameres *resp) 737 struct nfsd3_renameres *resp)
738{ 738{
739 p = encode_wcc_data(rqstp, p, &resp->ffh); 739 p = encode_wcc_data(rqstp, p, &resp->ffh);
@@ -743,7 +743,7 @@ nfs3svc_encode_renameres(struct svc_rqst *rqstp, u32 *p,
743 743
744/* LINK */ 744/* LINK */
745int 745int
746nfs3svc_encode_linkres(struct svc_rqst *rqstp, u32 *p, 746nfs3svc_encode_linkres(struct svc_rqst *rqstp, __be32 *p,
747 struct nfsd3_linkres *resp) 747 struct nfsd3_linkres *resp)
748{ 748{
749 p = encode_post_op_attr(rqstp, p, &resp->fh); 749 p = encode_post_op_attr(rqstp, p, &resp->fh);
@@ -753,7 +753,7 @@ nfs3svc_encode_linkres(struct svc_rqst *rqstp, u32 *p,
753 753
754/* READDIR */ 754/* READDIR */
755int 755int
756nfs3svc_encode_readdirres(struct svc_rqst *rqstp, u32 *p, 756nfs3svc_encode_readdirres(struct svc_rqst *rqstp, __be32 *p,
757 struct nfsd3_readdirres *resp) 757 struct nfsd3_readdirres *resp)
758{ 758{
759 p = encode_post_op_attr(rqstp, p, &resp->fh); 759 p = encode_post_op_attr(rqstp, p, &resp->fh);
@@ -776,8 +776,8 @@ nfs3svc_encode_readdirres(struct svc_rqst *rqstp, u32 *p,
776 return xdr_ressize_check(rqstp, p); 776 return xdr_ressize_check(rqstp, p);
777} 777}
778 778
779static inline u32 * 779static inline __be32 *
780encode_entry_baggage(struct nfsd3_readdirres *cd, u32 *p, const char *name, 780encode_entry_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name,
781 int namlen, ino_t ino) 781 int namlen, ino_t ino)
782{ 782{
783 *p++ = xdr_one; /* mark entry present */ 783 *p++ = xdr_one; /* mark entry present */
@@ -790,8 +790,8 @@ encode_entry_baggage(struct nfsd3_readdirres *cd, u32 *p, const char *name,
790 return p; 790 return p;
791} 791}
792 792
793static inline u32 * 793static inline __be32 *
794encode_entryplus_baggage(struct nfsd3_readdirres *cd, u32 *p, 794encode_entryplus_baggage(struct nfsd3_readdirres *cd, __be32 *p,
795 struct svc_fh *fhp) 795 struct svc_fh *fhp)
796{ 796{
797 p = encode_post_op_attr(cd->rqstp, p, fhp); 797 p = encode_post_op_attr(cd->rqstp, p, fhp);
@@ -853,7 +853,7 @@ encode_entry(struct readdir_cd *ccd, const char *name,
853{ 853{
854 struct nfsd3_readdirres *cd = container_of(ccd, struct nfsd3_readdirres, 854 struct nfsd3_readdirres *cd = container_of(ccd, struct nfsd3_readdirres,
855 common); 855 common);
856 u32 *p = cd->buffer; 856 __be32 *p = cd->buffer;
857 caddr_t curr_page_addr = NULL; 857 caddr_t curr_page_addr = NULL;
858 int pn; /* current page number */ 858 int pn; /* current page number */
859 int slen; /* string (name) length */ 859 int slen; /* string (name) length */
@@ -919,7 +919,7 @@ encode_entry(struct readdir_cd *ccd, const char *name,
919 } else if (cd->rqstp->rq_respages[pn+1] != NULL) { 919 } else if (cd->rqstp->rq_respages[pn+1] != NULL) {
920 /* temporarily encode entry into next page, then move back to 920 /* temporarily encode entry into next page, then move back to
921 * current and next page in rq_respages[] */ 921 * current and next page in rq_respages[] */
922 u32 *p1, *tmp; 922 __be32 *p1, *tmp;
923 int len1, len2; 923 int len1, len2;
924 924
925 /* grab next page for temporary storage of entry */ 925 /* grab next page for temporary storage of entry */
@@ -1009,7 +1009,7 @@ nfs3svc_encode_entry_plus(struct readdir_cd *cd, const char *name,
1009 1009
1010/* FSSTAT */ 1010/* FSSTAT */
1011int 1011int
1012nfs3svc_encode_fsstatres(struct svc_rqst *rqstp, u32 *p, 1012nfs3svc_encode_fsstatres(struct svc_rqst *rqstp, __be32 *p,
1013 struct nfsd3_fsstatres *resp) 1013 struct nfsd3_fsstatres *resp)
1014{ 1014{
1015 struct kstatfs *s = &resp->stats; 1015 struct kstatfs *s = &resp->stats;
@@ -1031,7 +1031,7 @@ nfs3svc_encode_fsstatres(struct svc_rqst *rqstp, u32 *p,
1031 1031
1032/* FSINFO */ 1032/* FSINFO */
1033int 1033int
1034nfs3svc_encode_fsinfores(struct svc_rqst *rqstp, u32 *p, 1034nfs3svc_encode_fsinfores(struct svc_rqst *rqstp, __be32 *p,
1035 struct nfsd3_fsinfores *resp) 1035 struct nfsd3_fsinfores *resp)
1036{ 1036{
1037 *p++ = xdr_zero; /* no post_op_attr */ 1037 *p++ = xdr_zero; /* no post_op_attr */
@@ -1055,7 +1055,7 @@ nfs3svc_encode_fsinfores(struct svc_rqst *rqstp, u32 *p,
1055 1055
1056/* PATHCONF */ 1056/* PATHCONF */
1057int 1057int
1058nfs3svc_encode_pathconfres(struct svc_rqst *rqstp, u32 *p, 1058nfs3svc_encode_pathconfres(struct svc_rqst *rqstp, __be32 *p,
1059 struct nfsd3_pathconfres *resp) 1059 struct nfsd3_pathconfres *resp)
1060{ 1060{
1061 *p++ = xdr_zero; /* no post_op_attr */ 1061 *p++ = xdr_zero; /* no post_op_attr */
@@ -1074,7 +1074,7 @@ nfs3svc_encode_pathconfres(struct svc_rqst *rqstp, u32 *p,
1074 1074
1075/* COMMIT */ 1075/* COMMIT */
1076int 1076int
1077nfs3svc_encode_commitres(struct svc_rqst *rqstp, u32 *p, 1077nfs3svc_encode_commitres(struct svc_rqst *rqstp, __be32 *p,
1078 struct nfsd3_commitres *resp) 1078 struct nfsd3_commitres *resp)
1079{ 1079{
1080 p = encode_wcc_data(rqstp, p, &resp->fh); 1080 p = encode_wcc_data(rqstp, p, &resp->fh);
@@ -1090,7 +1090,7 @@ nfs3svc_encode_commitres(struct svc_rqst *rqstp, u32 *p,
1090 * XDR release functions 1090 * XDR release functions
1091 */ 1091 */
1092int 1092int
1093nfs3svc_release_fhandle(struct svc_rqst *rqstp, u32 *p, 1093nfs3svc_release_fhandle(struct svc_rqst *rqstp, __be32 *p,
1094 struct nfsd3_attrstat *resp) 1094 struct nfsd3_attrstat *resp)
1095{ 1095{
1096 fh_put(&resp->fh); 1096 fh_put(&resp->fh);
@@ -1098,7 +1098,7 @@ nfs3svc_release_fhandle(struct svc_rqst *rqstp, u32 *p,
1098} 1098}
1099 1099
1100int 1100int
1101nfs3svc_release_fhandle2(struct svc_rqst *rqstp, u32 *p, 1101nfs3svc_release_fhandle2(struct svc_rqst *rqstp, __be32 *p,
1102 struct nfsd3_fhandle_pair *resp) 1102 struct nfsd3_fhandle_pair *resp)
1103{ 1103{
1104 fh_put(&resp->fh1); 1104 fh_put(&resp->fh1);
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
index f6ca9fb3fc63..f57655a7a2b6 100644
--- a/fs/nfsd/nfs4callback.c
+++ b/fs/nfsd/nfs4callback.c
@@ -85,8 +85,8 @@ enum nfs_cb_opnum4 {
85/* 85/*
86* Generic encode routines from fs/nfs/nfs4xdr.c 86* Generic encode routines from fs/nfs/nfs4xdr.c
87*/ 87*/
88static inline u32 * 88static inline __be32 *
89xdr_writemem(u32 *p, const void *ptr, int nbytes) 89xdr_writemem(__be32 *p, const void *ptr, int nbytes)
90{ 90{
91 int tmp = XDR_QUADLEN(nbytes); 91 int tmp = XDR_QUADLEN(nbytes);
92 if (!tmp) 92 if (!tmp)
@@ -205,7 +205,7 @@ nfs_cb_stat_to_errno(int stat)
205static int 205static int
206encode_cb_compound_hdr(struct xdr_stream *xdr, struct nfs4_cb_compound_hdr *hdr) 206encode_cb_compound_hdr(struct xdr_stream *xdr, struct nfs4_cb_compound_hdr *hdr)
207{ 207{
208 u32 * p; 208 __be32 * p;
209 209
210 RESERVE_SPACE(16); 210 RESERVE_SPACE(16);
211 WRITE32(0); /* tag length is always 0 */ 211 WRITE32(0); /* tag length is always 0 */
@@ -218,7 +218,7 @@ encode_cb_compound_hdr(struct xdr_stream *xdr, struct nfs4_cb_compound_hdr *hdr)
218static int 218static int
219encode_cb_recall(struct xdr_stream *xdr, struct nfs4_cb_recall *cb_rec) 219encode_cb_recall(struct xdr_stream *xdr, struct nfs4_cb_recall *cb_rec)
220{ 220{
221 u32 *p; 221 __be32 *p;
222 int len = cb_rec->cbr_fhlen; 222 int len = cb_rec->cbr_fhlen;
223 223
224 RESERVE_SPACE(12+sizeof(cb_rec->cbr_stateid) + len); 224 RESERVE_SPACE(12+sizeof(cb_rec->cbr_stateid) + len);
@@ -231,7 +231,7 @@ encode_cb_recall(struct xdr_stream *xdr, struct nfs4_cb_recall *cb_rec)
231} 231}
232 232
233static int 233static int
234nfs4_xdr_enc_cb_null(struct rpc_rqst *req, u32 *p) 234nfs4_xdr_enc_cb_null(struct rpc_rqst *req, __be32 *p)
235{ 235{
236 struct xdr_stream xdrs, *xdr = &xdrs; 236 struct xdr_stream xdrs, *xdr = &xdrs;
237 237
@@ -241,7 +241,7 @@ nfs4_xdr_enc_cb_null(struct rpc_rqst *req, u32 *p)
241} 241}
242 242
243static int 243static int
244nfs4_xdr_enc_cb_recall(struct rpc_rqst *req, u32 *p, struct nfs4_cb_recall *args) 244nfs4_xdr_enc_cb_recall(struct rpc_rqst *req, __be32 *p, struct nfs4_cb_recall *args)
245{ 245{
246 struct xdr_stream xdr; 246 struct xdr_stream xdr;
247 struct nfs4_cb_compound_hdr hdr = { 247 struct nfs4_cb_compound_hdr hdr = {
@@ -257,7 +257,7 @@ nfs4_xdr_enc_cb_recall(struct rpc_rqst *req, u32 *p, struct nfs4_cb_recall *args
257 257
258static int 258static int
259decode_cb_compound_hdr(struct xdr_stream *xdr, struct nfs4_cb_compound_hdr *hdr){ 259decode_cb_compound_hdr(struct xdr_stream *xdr, struct nfs4_cb_compound_hdr *hdr){
260 u32 *p; 260 __be32 *p;
261 261
262 READ_BUF(8); 262 READ_BUF(8);
263 READ32(hdr->status); 263 READ32(hdr->status);
@@ -272,7 +272,7 @@ decode_cb_compound_hdr(struct xdr_stream *xdr, struct nfs4_cb_compound_hdr *hdr)
272static int 272static int
273decode_cb_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected) 273decode_cb_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected)
274{ 274{
275 u32 *p; 275 __be32 *p;
276 u32 op; 276 u32 op;
277 int32_t nfserr; 277 int32_t nfserr;
278 278
@@ -291,13 +291,13 @@ decode_cb_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected)
291} 291}
292 292
293static int 293static int
294nfs4_xdr_dec_cb_null(struct rpc_rqst *req, u32 *p) 294nfs4_xdr_dec_cb_null(struct rpc_rqst *req, __be32 *p)
295{ 295{
296 return 0; 296 return 0;
297} 297}
298 298
299static int 299static int
300nfs4_xdr_dec_cb_recall(struct rpc_rqst *rqstp, u32 *p) 300nfs4_xdr_dec_cb_recall(struct rpc_rqst *rqstp, __be32 *p)
301{ 301{
302 struct xdr_stream xdr; 302 struct xdr_stream xdr;
303 struct nfs4_cb_compound_hdr hdr; 303 struct nfs4_cb_compound_hdr hdr;
@@ -421,7 +421,7 @@ nfsd4_probe_callback(struct nfs4_client *clp)
421 421
422 /* Create RPC client */ 422 /* Create RPC client */
423 cb->cb_client = rpc_create(&args); 423 cb->cb_client = rpc_create(&args);
424 if (!cb->cb_client) { 424 if (IS_ERR(cb->cb_client)) {
425 dprintk("NFSD: couldn't create callback client\n"); 425 dprintk("NFSD: couldn't create callback client\n");
426 goto out_err; 426 goto out_err;
427 } 427 }
@@ -448,10 +448,10 @@ nfsd4_probe_callback(struct nfs4_client *clp)
448out_rpciod: 448out_rpciod:
449 atomic_dec(&clp->cl_count); 449 atomic_dec(&clp->cl_count);
450 rpciod_down(); 450 rpciod_down();
451 cb->cb_client = NULL;
452out_clnt: 451out_clnt:
453 rpc_shutdown_client(cb->cb_client); 452 rpc_shutdown_client(cb->cb_client);
454out_err: 453out_err:
454 cb->cb_client = NULL;
455 dprintk("NFSD: warning: no callback path to client %.*s\n", 455 dprintk("NFSD: warning: no callback path to client %.*s\n",
456 (int)clp->cl_name.len, clp->cl_name.data); 456 (int)clp->cl_name.len, clp->cl_name.data);
457} 457}
@@ -461,7 +461,7 @@ nfs4_cb_null(struct rpc_task *task, void *dummy)
461{ 461{
462 struct nfs4_client *clp = (struct nfs4_client *)task->tk_msg.rpc_argp; 462 struct nfs4_client *clp = (struct nfs4_client *)task->tk_msg.rpc_argp;
463 struct nfs4_callback *cb = &clp->cl_callback; 463 struct nfs4_callback *cb = &clp->cl_callback;
464 u32 addr = htonl(cb->cb_addr); 464 __be32 addr = htonl(cb->cb_addr);
465 465
466 dprintk("NFSD: nfs4_cb_null task->tk_status %d\n", task->tk_status); 466 dprintk("NFSD: nfs4_cb_null task->tk_status %d\n", task->tk_status);
467 467
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 8333db12caca..50bc94243ca1 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -67,32 +67,33 @@ fh_dup2(struct svc_fh *dst, struct svc_fh *src)
67 *dst = *src; 67 *dst = *src;
68} 68}
69 69
70static int 70static __be32
71do_open_permission(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open) 71do_open_permission(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open, int accmode)
72{ 72{
73 int accmode, status; 73 __be32 status;
74 74
75 if (open->op_truncate && 75 if (open->op_truncate &&
76 !(open->op_share_access & NFS4_SHARE_ACCESS_WRITE)) 76 !(open->op_share_access & NFS4_SHARE_ACCESS_WRITE))
77 return nfserr_inval; 77 return nfserr_inval;
78 78
79 accmode = MAY_NOP;
80 if (open->op_share_access & NFS4_SHARE_ACCESS_READ) 79 if (open->op_share_access & NFS4_SHARE_ACCESS_READ)
81 accmode = MAY_READ; 80 accmode |= MAY_READ;
82 if (open->op_share_deny & NFS4_SHARE_ACCESS_WRITE) 81 if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE)
83 accmode |= (MAY_WRITE | MAY_TRUNC); 82 accmode |= (MAY_WRITE | MAY_TRUNC);
84 accmode |= MAY_OWNER_OVERRIDE; 83 if (open->op_share_deny & NFS4_SHARE_DENY_WRITE)
84 accmode |= MAY_WRITE;
85 85
86 status = fh_verify(rqstp, current_fh, S_IFREG, accmode); 86 status = fh_verify(rqstp, current_fh, S_IFREG, accmode);
87 87
88 return status; 88 return status;
89} 89}
90 90
91static int 91static __be32
92do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open) 92do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open)
93{ 93{
94 struct svc_fh resfh; 94 struct svc_fh resfh;
95 int status; 95 __be32 status;
96 int created = 0;
96 97
97 fh_init(&resfh, NFS4_FHSIZE); 98 fh_init(&resfh, NFS4_FHSIZE);
98 open->op_truncate = 0; 99 open->op_truncate = 0;
@@ -105,36 +106,35 @@ do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_o
105 status = nfsd_create_v3(rqstp, current_fh, open->op_fname.data, 106 status = nfsd_create_v3(rqstp, current_fh, open->op_fname.data,
106 open->op_fname.len, &open->op_iattr, 107 open->op_fname.len, &open->op_iattr,
107 &resfh, open->op_createmode, 108 &resfh, open->op_createmode,
108 (u32 *)open->op_verf.data, &open->op_truncate); 109 (u32 *)open->op_verf.data, &open->op_truncate, &created);
109 } 110 } else {
110 else {
111 status = nfsd_lookup(rqstp, current_fh, 111 status = nfsd_lookup(rqstp, current_fh,
112 open->op_fname.data, open->op_fname.len, &resfh); 112 open->op_fname.data, open->op_fname.len, &resfh);
113 fh_unlock(current_fh); 113 fh_unlock(current_fh);
114 } 114 }
115 if (status)
116 goto out;
115 117
116 if (!status) { 118 set_change_info(&open->op_cinfo, current_fh);
117 set_change_info(&open->op_cinfo, current_fh);
118 119
119 /* set reply cache */ 120 /* set reply cache */
120 fh_dup2(current_fh, &resfh); 121 fh_dup2(current_fh, &resfh);
121 open->op_stateowner->so_replay.rp_openfh_len = 122 open->op_stateowner->so_replay.rp_openfh_len = resfh.fh_handle.fh_size;
122 resfh.fh_handle.fh_size; 123 memcpy(open->op_stateowner->so_replay.rp_openfh,
123 memcpy(open->op_stateowner->so_replay.rp_openfh, 124 &resfh.fh_handle.fh_base, resfh.fh_handle.fh_size);
124 &resfh.fh_handle.fh_base,
125 resfh.fh_handle.fh_size);
126 125
127 status = do_open_permission(rqstp, current_fh, open); 126 if (!created)
128 } 127 status = do_open_permission(rqstp, current_fh, open, MAY_NOP);
129 128
129out:
130 fh_put(&resfh); 130 fh_put(&resfh);
131 return status; 131 return status;
132} 132}
133 133
134static int 134static __be32
135do_open_fhandle(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open) 135do_open_fhandle(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open)
136{ 136{
137 int status; 137 __be32 status;
138 138
139 /* Only reclaims from previously confirmed clients are valid */ 139 /* Only reclaims from previously confirmed clients are valid */
140 if ((status = nfs4_check_open_reclaim(&open->op_clientid))) 140 if ((status = nfs4_check_open_reclaim(&open->op_clientid)))
@@ -155,16 +155,16 @@ do_open_fhandle(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_
155 open->op_truncate = (open->op_iattr.ia_valid & ATTR_SIZE) && 155 open->op_truncate = (open->op_iattr.ia_valid & ATTR_SIZE) &&
156 (open->op_iattr.ia_size == 0); 156 (open->op_iattr.ia_size == 0);
157 157
158 status = do_open_permission(rqstp, current_fh, open); 158 status = do_open_permission(rqstp, current_fh, open, MAY_OWNER_OVERRIDE);
159 159
160 return status; 160 return status;
161} 161}
162 162
163 163
164static inline int 164static inline __be32
165nfsd4_open(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open, struct nfs4_stateowner **replay_owner) 165nfsd4_open(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open, struct nfs4_stateowner **replay_owner)
166{ 166{
167 int status; 167 __be32 status;
168 dprintk("NFSD: nfsd4_open filename %.*s op_stateowner %p\n", 168 dprintk("NFSD: nfsd4_open filename %.*s op_stateowner %p\n",
169 (int)open->op_fname.len, open->op_fname.data, 169 (int)open->op_fname.len, open->op_fname.data,
170 open->op_stateowner); 170 open->op_stateowner);
@@ -177,7 +177,7 @@ nfsd4_open(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open
177 177
178 /* check seqid for replay. set nfs4_owner */ 178 /* check seqid for replay. set nfs4_owner */
179 status = nfsd4_process_open1(open); 179 status = nfsd4_process_open1(open);
180 if (status == NFSERR_REPLAY_ME) { 180 if (status == nfserr_replay_me) {
181 struct nfs4_replay *rp = &open->op_stateowner->so_replay; 181 struct nfs4_replay *rp = &open->op_stateowner->so_replay;
182 fh_put(current_fh); 182 fh_put(current_fh);
183 current_fh->fh_handle.fh_size = rp->rp_openfh_len; 183 current_fh->fh_handle.fh_size = rp->rp_openfh_len;
@@ -188,7 +188,7 @@ nfsd4_open(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open
188 dprintk("nfsd4_open: replay failed" 188 dprintk("nfsd4_open: replay failed"
189 " restoring previous filehandle\n"); 189 " restoring previous filehandle\n");
190 else 190 else
191 status = NFSERR_REPLAY_ME; 191 status = nfserr_replay_me;
192 } 192 }
193 if (status) 193 if (status)
194 goto out; 194 goto out;
@@ -261,7 +261,7 @@ out:
261/* 261/*
262 * filehandle-manipulating ops. 262 * filehandle-manipulating ops.
263 */ 263 */
264static inline int 264static inline __be32
265nfsd4_getfh(struct svc_fh *current_fh, struct svc_fh **getfh) 265nfsd4_getfh(struct svc_fh *current_fh, struct svc_fh **getfh)
266{ 266{
267 if (!current_fh->fh_dentry) 267 if (!current_fh->fh_dentry)
@@ -271,7 +271,7 @@ nfsd4_getfh(struct svc_fh *current_fh, struct svc_fh **getfh)
271 return nfs_ok; 271 return nfs_ok;
272} 272}
273 273
274static inline int 274static inline __be32
275nfsd4_putfh(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_putfh *putfh) 275nfsd4_putfh(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_putfh *putfh)
276{ 276{
277 fh_put(current_fh); 277 fh_put(current_fh);
@@ -280,10 +280,10 @@ nfsd4_putfh(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_putf
280 return fh_verify(rqstp, current_fh, 0, MAY_NOP); 280 return fh_verify(rqstp, current_fh, 0, MAY_NOP);
281} 281}
282 282
283static inline int 283static inline __be32
284nfsd4_putrootfh(struct svc_rqst *rqstp, struct svc_fh *current_fh) 284nfsd4_putrootfh(struct svc_rqst *rqstp, struct svc_fh *current_fh)
285{ 285{
286 int status; 286 __be32 status;
287 287
288 fh_put(current_fh); 288 fh_put(current_fh);
289 status = exp_pseudoroot(rqstp->rq_client, current_fh, 289 status = exp_pseudoroot(rqstp->rq_client, current_fh,
@@ -291,7 +291,7 @@ nfsd4_putrootfh(struct svc_rqst *rqstp, struct svc_fh *current_fh)
291 return status; 291 return status;
292} 292}
293 293
294static inline int 294static inline __be32
295nfsd4_restorefh(struct svc_fh *current_fh, struct svc_fh *save_fh) 295nfsd4_restorefh(struct svc_fh *current_fh, struct svc_fh *save_fh)
296{ 296{
297 if (!save_fh->fh_dentry) 297 if (!save_fh->fh_dentry)
@@ -301,7 +301,7 @@ nfsd4_restorefh(struct svc_fh *current_fh, struct svc_fh *save_fh)
301 return nfs_ok; 301 return nfs_ok;
302} 302}
303 303
304static inline int 304static inline __be32
305nfsd4_savefh(struct svc_fh *current_fh, struct svc_fh *save_fh) 305nfsd4_savefh(struct svc_fh *current_fh, struct svc_fh *save_fh)
306{ 306{
307 if (!current_fh->fh_dentry) 307 if (!current_fh->fh_dentry)
@@ -314,7 +314,7 @@ nfsd4_savefh(struct svc_fh *current_fh, struct svc_fh *save_fh)
314/* 314/*
315 * misc nfsv4 ops 315 * misc nfsv4 ops
316 */ 316 */
317static inline int 317static inline __be32
318nfsd4_access(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_access *access) 318nfsd4_access(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_access *access)
319{ 319{
320 if (access->ac_req_access & ~NFS3_ACCESS_FULL) 320 if (access->ac_req_access & ~NFS3_ACCESS_FULL)
@@ -324,10 +324,10 @@ nfsd4_access(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_acc
324 return nfsd_access(rqstp, current_fh, &access->ac_resp_access, &access->ac_supported); 324 return nfsd_access(rqstp, current_fh, &access->ac_resp_access, &access->ac_supported);
325} 325}
326 326
327static inline int 327static inline __be32
328nfsd4_commit(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_commit *commit) 328nfsd4_commit(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_commit *commit)
329{ 329{
330 int status; 330 __be32 status;
331 331
332 u32 *p = (u32 *)commit->co_verf.data; 332 u32 *p = (u32 *)commit->co_verf.data;
333 *p++ = nfssvc_boot.tv_sec; 333 *p++ = nfssvc_boot.tv_sec;
@@ -339,11 +339,11 @@ nfsd4_commit(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_com
339 return status; 339 return status;
340} 340}
341 341
342static int 342static __be32
343nfsd4_create(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_create *create) 343nfsd4_create(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_create *create)
344{ 344{
345 struct svc_fh resfh; 345 struct svc_fh resfh;
346 int status; 346 __be32 status;
347 dev_t rdev; 347 dev_t rdev;
348 348
349 fh_init(&resfh, NFS4_FHSIZE); 349 fh_init(&resfh, NFS4_FHSIZE);
@@ -423,10 +423,10 @@ nfsd4_create(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_cre
423 return status; 423 return status;
424} 424}
425 425
426static inline int 426static inline __be32
427nfsd4_getattr(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_getattr *getattr) 427nfsd4_getattr(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_getattr *getattr)
428{ 428{
429 int status; 429 __be32 status;
430 430
431 status = fh_verify(rqstp, current_fh, 0, MAY_NOP); 431 status = fh_verify(rqstp, current_fh, 0, MAY_NOP);
432 if (status) 432 if (status)
@@ -442,11 +442,11 @@ nfsd4_getattr(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_ge
442 return nfs_ok; 442 return nfs_ok;
443} 443}
444 444
445static inline int 445static inline __be32
446nfsd4_link(struct svc_rqst *rqstp, struct svc_fh *current_fh, 446nfsd4_link(struct svc_rqst *rqstp, struct svc_fh *current_fh,
447 struct svc_fh *save_fh, struct nfsd4_link *link) 447 struct svc_fh *save_fh, struct nfsd4_link *link)
448{ 448{
449 int status = nfserr_nofilehandle; 449 __be32 status = nfserr_nofilehandle;
450 450
451 if (!save_fh->fh_dentry) 451 if (!save_fh->fh_dentry)
452 return status; 452 return status;
@@ -456,11 +456,11 @@ nfsd4_link(struct svc_rqst *rqstp, struct svc_fh *current_fh,
456 return status; 456 return status;
457} 457}
458 458
459static int 459static __be32
460nfsd4_lookupp(struct svc_rqst *rqstp, struct svc_fh *current_fh) 460nfsd4_lookupp(struct svc_rqst *rqstp, struct svc_fh *current_fh)
461{ 461{
462 struct svc_fh tmp_fh; 462 struct svc_fh tmp_fh;
463 int ret; 463 __be32 ret;
464 464
465 fh_init(&tmp_fh, NFS4_FHSIZE); 465 fh_init(&tmp_fh, NFS4_FHSIZE);
466 if((ret = exp_pseudoroot(rqstp->rq_client, &tmp_fh, 466 if((ret = exp_pseudoroot(rqstp->rq_client, &tmp_fh,
@@ -474,16 +474,16 @@ nfsd4_lookupp(struct svc_rqst *rqstp, struct svc_fh *current_fh)
474 return nfsd_lookup(rqstp, current_fh, "..", 2, current_fh); 474 return nfsd_lookup(rqstp, current_fh, "..", 2, current_fh);
475} 475}
476 476
477static inline int 477static inline __be32
478nfsd4_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lookup *lookup) 478nfsd4_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lookup *lookup)
479{ 479{
480 return nfsd_lookup(rqstp, current_fh, lookup->lo_name, lookup->lo_len, current_fh); 480 return nfsd_lookup(rqstp, current_fh, lookup->lo_name, lookup->lo_len, current_fh);
481} 481}
482 482
483static inline int 483static inline __be32
484nfsd4_read(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_read *read) 484nfsd4_read(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_read *read)
485{ 485{
486 int status; 486 __be32 status;
487 487
488 /* no need to check permission - this will be done in nfsd_read() */ 488 /* no need to check permission - this will be done in nfsd_read() */
489 489
@@ -508,7 +508,7 @@ out:
508 return status; 508 return status;
509} 509}
510 510
511static inline int 511static inline __be32
512nfsd4_readdir(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_readdir *readdir) 512nfsd4_readdir(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_readdir *readdir)
513{ 513{
514 u64 cookie = readdir->rd_cookie; 514 u64 cookie = readdir->rd_cookie;
@@ -531,7 +531,7 @@ nfsd4_readdir(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_re
531 return nfs_ok; 531 return nfs_ok;
532} 532}
533 533
534static inline int 534static inline __be32
535nfsd4_readlink(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_readlink *readlink) 535nfsd4_readlink(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_readlink *readlink)
536{ 536{
537 readlink->rl_rqstp = rqstp; 537 readlink->rl_rqstp = rqstp;
@@ -539,10 +539,10 @@ nfsd4_readlink(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_r
539 return nfs_ok; 539 return nfs_ok;
540} 540}
541 541
542static inline int 542static inline __be32
543nfsd4_remove(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_remove *remove) 543nfsd4_remove(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_remove *remove)
544{ 544{
545 int status; 545 __be32 status;
546 546
547 if (nfs4_in_grace()) 547 if (nfs4_in_grace())
548 return nfserr_grace; 548 return nfserr_grace;
@@ -556,11 +556,11 @@ nfsd4_remove(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_rem
556 return status; 556 return status;
557} 557}
558 558
559static inline int 559static inline __be32
560nfsd4_rename(struct svc_rqst *rqstp, struct svc_fh *current_fh, 560nfsd4_rename(struct svc_rqst *rqstp, struct svc_fh *current_fh,
561 struct svc_fh *save_fh, struct nfsd4_rename *rename) 561 struct svc_fh *save_fh, struct nfsd4_rename *rename)
562{ 562{
563 int status = nfserr_nofilehandle; 563 __be32 status = nfserr_nofilehandle;
564 564
565 if (!save_fh->fh_dentry) 565 if (!save_fh->fh_dentry)
566 return status; 566 return status;
@@ -589,10 +589,10 @@ nfsd4_rename(struct svc_rqst *rqstp, struct svc_fh *current_fh,
589 return status; 589 return status;
590} 590}
591 591
592static inline int 592static inline __be32
593nfsd4_setattr(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_setattr *setattr) 593nfsd4_setattr(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_setattr *setattr)
594{ 594{
595 int status = nfs_ok; 595 __be32 status = nfs_ok;
596 596
597 if (setattr->sa_iattr.ia_valid & ATTR_SIZE) { 597 if (setattr->sa_iattr.ia_valid & ATTR_SIZE) {
598 nfs4_lock_state(); 598 nfs4_lock_state();
@@ -614,13 +614,13 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_se
614 return status; 614 return status;
615} 615}
616 616
617static inline int 617static inline __be32
618nfsd4_write(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_write *write) 618nfsd4_write(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_write *write)
619{ 619{
620 stateid_t *stateid = &write->wr_stateid; 620 stateid_t *stateid = &write->wr_stateid;
621 struct file *filp = NULL; 621 struct file *filp = NULL;
622 u32 *p; 622 u32 *p;
623 int status = nfs_ok; 623 __be32 status = nfs_ok;
624 624
625 /* no need to check permission - this will be done in nfsd_write() */ 625 /* no need to check permission - this will be done in nfsd_write() */
626 626
@@ -661,12 +661,12 @@ nfsd4_write(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_writ
661 * attributes matched. VERIFY is implemented by mapping NFSERR_SAME 661 * attributes matched. VERIFY is implemented by mapping NFSERR_SAME
662 * to NFS_OK after the call; NVERIFY by mapping NFSERR_NOT_SAME to NFS_OK. 662 * to NFS_OK after the call; NVERIFY by mapping NFSERR_NOT_SAME to NFS_OK.
663 */ 663 */
664static int 664static __be32
665nfsd4_verify(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_verify *verify) 665nfsd4_verify(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_verify *verify)
666{ 666{
667 u32 *buf, *p; 667 __be32 *buf, *p;
668 int count; 668 int count;
669 int status; 669 __be32 status;
670 670
671 status = fh_verify(rqstp, current_fh, 0, MAY_NOP); 671 status = fh_verify(rqstp, current_fh, 0, MAY_NOP);
672 if (status) 672 if (status)
@@ -715,7 +715,7 @@ out_kfree:
715/* 715/*
716 * NULL call. 716 * NULL call.
717 */ 717 */
718static int 718static __be32
719nfsd4_proc_null(struct svc_rqst *rqstp, void *argp, void *resp) 719nfsd4_proc_null(struct svc_rqst *rqstp, void *argp, void *resp)
720{ 720{
721 return nfs_ok; 721 return nfs_ok;
@@ -731,7 +731,7 @@ static inline void nfsd4_increment_op_stats(u32 opnum)
731/* 731/*
732 * COMPOUND call. 732 * COMPOUND call.
733 */ 733 */
734static int 734static __be32
735nfsd4_proc_compound(struct svc_rqst *rqstp, 735nfsd4_proc_compound(struct svc_rqst *rqstp,
736 struct nfsd4_compoundargs *args, 736 struct nfsd4_compoundargs *args,
737 struct nfsd4_compoundres *resp) 737 struct nfsd4_compoundres *resp)
@@ -741,7 +741,7 @@ nfsd4_proc_compound(struct svc_rqst *rqstp,
741 struct svc_fh *save_fh = NULL; 741 struct svc_fh *save_fh = NULL;
742 struct nfs4_stateowner *replay_owner = NULL; 742 struct nfs4_stateowner *replay_owner = NULL;
743 int slack_space; /* in words, not bytes! */ 743 int slack_space; /* in words, not bytes! */
744 int status; 744 __be32 status;
745 745
746 status = nfserr_resource; 746 status = nfserr_resource;
747 current_fh = kmalloc(sizeof(*current_fh), GFP_KERNEL); 747 current_fh = kmalloc(sizeof(*current_fh), GFP_KERNEL);
@@ -937,7 +937,7 @@ nfsd4_proc_compound(struct svc_rqst *rqstp,
937 } 937 }
938 938
939encode_op: 939encode_op:
940 if (op->status == NFSERR_REPLAY_ME) { 940 if (op->status == nfserr_replay_me) {
941 op->replay = &replay_owner->so_replay; 941 op->replay = &replay_owner->so_replay;
942 nfsd4_encode_replay(resp, op); 942 nfsd4_encode_replay(resp, op);
943 status = op->status = op->replay->rp_status; 943 status = op->status = op->replay->rp_status;
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
index 1cbd2e4ee122..81b8565d3837 100644
--- a/fs/nfsd/nfs4recover.c
+++ b/fs/nfsd/nfs4recover.c
@@ -83,13 +83,13 @@ md5_to_hex(char *out, char *md5)
83 *out = '\0'; 83 *out = '\0';
84} 84}
85 85
86int 86__be32
87nfs4_make_rec_clidname(char *dname, struct xdr_netobj *clname) 87nfs4_make_rec_clidname(char *dname, struct xdr_netobj *clname)
88{ 88{
89 struct xdr_netobj cksum; 89 struct xdr_netobj cksum;
90 struct hash_desc desc; 90 struct hash_desc desc;
91 struct scatterlist sg[1]; 91 struct scatterlist sg[1];
92 int status = nfserr_resource; 92 __be32 status = nfserr_resource;
93 93
94 dprintk("NFSD: nfs4_make_rec_clidname for %.*s\n", 94 dprintk("NFSD: nfs4_make_rec_clidname for %.*s\n",
95 clname->len, clname->data); 95 clname->len, clname->data);
@@ -193,7 +193,7 @@ nfsd4_build_dentrylist(void *arg, const char *name, int namlen,
193 struct dentry_list *child; 193 struct dentry_list *child;
194 194
195 if (name && isdotent(name, namlen)) 195 if (name && isdotent(name, namlen))
196 return nfs_ok; 196 return 0;
197 dentry = lookup_one_len(name, parent, namlen); 197 dentry = lookup_one_len(name, parent, namlen);
198 if (IS_ERR(dentry)) 198 if (IS_ERR(dentry))
199 return PTR_ERR(dentry); 199 return PTR_ERR(dentry);
@@ -274,7 +274,7 @@ nfsd4_clear_clid_dir(struct dentry *dir, struct dentry *dentry)
274 * any regular files anyway, just in case the directory was created by 274 * any regular files anyway, just in case the directory was created by
275 * a kernel from the future.... */ 275 * a kernel from the future.... */
276 nfsd4_list_rec_dir(dentry, nfsd4_remove_clid_file); 276 nfsd4_list_rec_dir(dentry, nfsd4_remove_clid_file);
277 mutex_lock(&dir->d_inode->i_mutex); 277 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);
278 status = vfs_rmdir(dir->d_inode, dentry); 278 status = vfs_rmdir(dir->d_inode, dentry);
279 mutex_unlock(&dir->d_inode->i_mutex); 279 mutex_unlock(&dir->d_inode->i_mutex);
280 return status; 280 return status;
@@ -333,14 +333,14 @@ purge_old(struct dentry *parent, struct dentry *child)
333 int status; 333 int status;
334 334
335 if (nfs4_has_reclaimed_state(child->d_name.name)) 335 if (nfs4_has_reclaimed_state(child->d_name.name))
336 return nfs_ok; 336 return 0;
337 337
338 status = nfsd4_clear_clid_dir(parent, child); 338 status = nfsd4_clear_clid_dir(parent, child);
339 if (status) 339 if (status)
340 printk("failed to remove client recovery directory %s\n", 340 printk("failed to remove client recovery directory %s\n",
341 child->d_name.name); 341 child->d_name.name);
342 /* Keep trying, success or failure: */ 342 /* Keep trying, success or failure: */
343 return nfs_ok; 343 return 0;
344} 344}
345 345
346void 346void
@@ -365,10 +365,10 @@ load_recdir(struct dentry *parent, struct dentry *child)
365 printk("nfsd4: illegal name %s in recovery directory\n", 365 printk("nfsd4: illegal name %s in recovery directory\n",
366 child->d_name.name); 366 child->d_name.name);
367 /* Keep trying; maybe the others are OK: */ 367 /* Keep trying; maybe the others are OK: */
368 return nfs_ok; 368 return 0;
369 } 369 }
370 nfs4_client_to_reclaim(child->d_name.name); 370 nfs4_client_to_reclaim(child->d_name.name);
371 return nfs_ok; 371 return 0;
372} 372}
373 373
374int 374int
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index ebcf226a9e4a..293b6495829f 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -710,10 +710,10 @@ out_err:
710 * as described above. 710 * as described above.
711 * 711 *
712 */ 712 */
713int 713__be32
714nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_setclientid *setclid) 714nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_setclientid *setclid)
715{ 715{
716 u32 ip_addr = rqstp->rq_addr.sin_addr.s_addr; 716 __be32 ip_addr = rqstp->rq_addr.sin_addr.s_addr;
717 struct xdr_netobj clname = { 717 struct xdr_netobj clname = {
718 .len = setclid->se_namelen, 718 .len = setclid->se_namelen,
719 .data = setclid->se_name, 719 .data = setclid->se_name,
@@ -721,7 +721,7 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_setclientid *setclid)
721 nfs4_verifier clverifier = setclid->se_verf; 721 nfs4_verifier clverifier = setclid->se_verf;
722 unsigned int strhashval; 722 unsigned int strhashval;
723 struct nfs4_client *conf, *unconf, *new; 723 struct nfs4_client *conf, *unconf, *new;
724 int status; 724 __be32 status;
725 char dname[HEXDIR_LEN]; 725 char dname[HEXDIR_LEN];
726 726
727 if (!check_name(clname)) 727 if (!check_name(clname))
@@ -875,14 +875,14 @@ out:
875 * 875 *
876 * NOTE: callback information will be processed here in a future patch 876 * NOTE: callback information will be processed here in a future patch
877 */ 877 */
878int 878__be32
879nfsd4_setclientid_confirm(struct svc_rqst *rqstp, struct nfsd4_setclientid_confirm *setclientid_confirm) 879nfsd4_setclientid_confirm(struct svc_rqst *rqstp, struct nfsd4_setclientid_confirm *setclientid_confirm)
880{ 880{
881 u32 ip_addr = rqstp->rq_addr.sin_addr.s_addr; 881 __be32 ip_addr = rqstp->rq_addr.sin_addr.s_addr;
882 struct nfs4_client *conf, *unconf; 882 struct nfs4_client *conf, *unconf;
883 nfs4_verifier confirm = setclientid_confirm->sc_confirm; 883 nfs4_verifier confirm = setclientid_confirm->sc_confirm;
884 clientid_t * clid = &setclientid_confirm->sc_clientid; 884 clientid_t * clid = &setclientid_confirm->sc_clientid;
885 int status; 885 __be32 status;
886 886
887 if (STALE_CLIENTID(clid)) 887 if (STALE_CLIENTID(clid))
888 return nfserr_stale_clientid; 888 return nfserr_stale_clientid;
@@ -1280,13 +1280,13 @@ test_share(struct nfs4_stateid *stp, struct nfsd4_open *open) {
1280 * Called to check deny when READ with all zero stateid or 1280 * Called to check deny when READ with all zero stateid or
1281 * WRITE with all zero or all one stateid 1281 * WRITE with all zero or all one stateid
1282 */ 1282 */
1283static int 1283static __be32
1284nfs4_share_conflict(struct svc_fh *current_fh, unsigned int deny_type) 1284nfs4_share_conflict(struct svc_fh *current_fh, unsigned int deny_type)
1285{ 1285{
1286 struct inode *ino = current_fh->fh_dentry->d_inode; 1286 struct inode *ino = current_fh->fh_dentry->d_inode;
1287 struct nfs4_file *fp; 1287 struct nfs4_file *fp;
1288 struct nfs4_stateid *stp; 1288 struct nfs4_stateid *stp;
1289 int ret; 1289 __be32 ret;
1290 1290
1291 dprintk("NFSD: nfs4_share_conflict\n"); 1291 dprintk("NFSD: nfs4_share_conflict\n");
1292 1292
@@ -1444,7 +1444,7 @@ static struct lock_manager_operations nfsd_lease_mng_ops = {
1444}; 1444};
1445 1445
1446 1446
1447int 1447__be32
1448nfsd4_process_open1(struct nfsd4_open *open) 1448nfsd4_process_open1(struct nfsd4_open *open)
1449{ 1449{
1450 clientid_t *clientid = &open->op_clientid; 1450 clientid_t *clientid = &open->op_clientid;
@@ -1477,7 +1477,7 @@ nfsd4_process_open1(struct nfsd4_open *open)
1477 } 1477 }
1478 if (open->op_seqid == sop->so_seqid - 1) { 1478 if (open->op_seqid == sop->so_seqid - 1) {
1479 if (sop->so_replay.rp_buflen) 1479 if (sop->so_replay.rp_buflen)
1480 return NFSERR_REPLAY_ME; 1480 return nfserr_replay_me;
1481 /* The original OPEN failed so spectacularly 1481 /* The original OPEN failed so spectacularly
1482 * that we don't even have replay data saved! 1482 * that we don't even have replay data saved!
1483 * Therefore, we have no choice but to continue 1483 * Therefore, we have no choice but to continue
@@ -1501,7 +1501,7 @@ renew:
1501 return nfs_ok; 1501 return nfs_ok;
1502} 1502}
1503 1503
1504static inline int 1504static inline __be32
1505nfs4_check_delegmode(struct nfs4_delegation *dp, int flags) 1505nfs4_check_delegmode(struct nfs4_delegation *dp, int flags)
1506{ 1506{
1507 if ((flags & WR_STATE) && (dp->dl_type == NFS4_OPEN_DELEGATE_READ)) 1507 if ((flags & WR_STATE) && (dp->dl_type == NFS4_OPEN_DELEGATE_READ))
@@ -1522,12 +1522,12 @@ find_delegation_file(struct nfs4_file *fp, stateid_t *stid)
1522 return NULL; 1522 return NULL;
1523} 1523}
1524 1524
1525static int 1525static __be32
1526nfs4_check_deleg(struct nfs4_file *fp, struct nfsd4_open *open, 1526nfs4_check_deleg(struct nfs4_file *fp, struct nfsd4_open *open,
1527 struct nfs4_delegation **dp) 1527 struct nfs4_delegation **dp)
1528{ 1528{
1529 int flags; 1529 int flags;
1530 int status = nfserr_bad_stateid; 1530 __be32 status = nfserr_bad_stateid;
1531 1531
1532 *dp = find_delegation_file(fp, &open->op_delegate_stateid); 1532 *dp = find_delegation_file(fp, &open->op_delegate_stateid);
1533 if (*dp == NULL) 1533 if (*dp == NULL)
@@ -1546,11 +1546,11 @@ out:
1546 return nfs_ok; 1546 return nfs_ok;
1547} 1547}
1548 1548
1549static int 1549static __be32
1550nfs4_check_open(struct nfs4_file *fp, struct nfsd4_open *open, struct nfs4_stateid **stpp) 1550nfs4_check_open(struct nfs4_file *fp, struct nfsd4_open *open, struct nfs4_stateid **stpp)
1551{ 1551{
1552 struct nfs4_stateid *local; 1552 struct nfs4_stateid *local;
1553 int status = nfserr_share_denied; 1553 __be32 status = nfserr_share_denied;
1554 struct nfs4_stateowner *sop = open->op_stateowner; 1554 struct nfs4_stateowner *sop = open->op_stateowner;
1555 1555
1556 list_for_each_entry(local, &fp->fi_stateids, st_perfile) { 1556 list_for_each_entry(local, &fp->fi_stateids, st_perfile) {
@@ -1575,7 +1575,7 @@ nfs4_alloc_stateid(void)
1575 return kmem_cache_alloc(stateid_slab, GFP_KERNEL); 1575 return kmem_cache_alloc(stateid_slab, GFP_KERNEL);
1576} 1576}
1577 1577
1578static int 1578static __be32
1579nfs4_new_open(struct svc_rqst *rqstp, struct nfs4_stateid **stpp, 1579nfs4_new_open(struct svc_rqst *rqstp, struct nfs4_stateid **stpp,
1580 struct nfs4_delegation *dp, 1580 struct nfs4_delegation *dp,
1581 struct svc_fh *cur_fh, int flags) 1581 struct svc_fh *cur_fh, int flags)
@@ -1590,7 +1590,7 @@ nfs4_new_open(struct svc_rqst *rqstp, struct nfs4_stateid **stpp,
1590 get_file(dp->dl_vfs_file); 1590 get_file(dp->dl_vfs_file);
1591 stp->st_vfs_file = dp->dl_vfs_file; 1591 stp->st_vfs_file = dp->dl_vfs_file;
1592 } else { 1592 } else {
1593 int status; 1593 __be32 status;
1594 status = nfsd_open(rqstp, cur_fh, S_IFREG, flags, 1594 status = nfsd_open(rqstp, cur_fh, S_IFREG, flags,
1595 &stp->st_vfs_file); 1595 &stp->st_vfs_file);
1596 if (status) { 1596 if (status) {
@@ -1604,7 +1604,7 @@ nfs4_new_open(struct svc_rqst *rqstp, struct nfs4_stateid **stpp,
1604 return 0; 1604 return 0;
1605} 1605}
1606 1606
1607static inline int 1607static inline __be32
1608nfsd4_truncate(struct svc_rqst *rqstp, struct svc_fh *fh, 1608nfsd4_truncate(struct svc_rqst *rqstp, struct svc_fh *fh,
1609 struct nfsd4_open *open) 1609 struct nfsd4_open *open)
1610{ 1610{
@@ -1619,22 +1619,22 @@ nfsd4_truncate(struct svc_rqst *rqstp, struct svc_fh *fh,
1619 return nfsd_setattr(rqstp, fh, &iattr, 0, (time_t)0); 1619 return nfsd_setattr(rqstp, fh, &iattr, 0, (time_t)0);
1620} 1620}
1621 1621
1622static int 1622static __be32
1623nfs4_upgrade_open(struct svc_rqst *rqstp, struct svc_fh *cur_fh, struct nfs4_stateid *stp, struct nfsd4_open *open) 1623nfs4_upgrade_open(struct svc_rqst *rqstp, struct svc_fh *cur_fh, struct nfs4_stateid *stp, struct nfsd4_open *open)
1624{ 1624{
1625 struct file *filp = stp->st_vfs_file; 1625 struct file *filp = stp->st_vfs_file;
1626 struct inode *inode = filp->f_dentry->d_inode; 1626 struct inode *inode = filp->f_dentry->d_inode;
1627 unsigned int share_access, new_writer; 1627 unsigned int share_access, new_writer;
1628 int status; 1628 __be32 status;
1629 1629
1630 set_access(&share_access, stp->st_access_bmap); 1630 set_access(&share_access, stp->st_access_bmap);
1631 new_writer = (~share_access) & open->op_share_access 1631 new_writer = (~share_access) & open->op_share_access
1632 & NFS4_SHARE_ACCESS_WRITE; 1632 & NFS4_SHARE_ACCESS_WRITE;
1633 1633
1634 if (new_writer) { 1634 if (new_writer) {
1635 status = get_write_access(inode); 1635 int err = get_write_access(inode);
1636 if (status) 1636 if (err)
1637 return nfserrno(status); 1637 return nfserrno(err);
1638 } 1638 }
1639 status = nfsd4_truncate(rqstp, cur_fh, open); 1639 status = nfsd4_truncate(rqstp, cur_fh, open);
1640 if (status) { 1640 if (status) {
@@ -1738,14 +1738,14 @@ out:
1738/* 1738/*
1739 * called with nfs4_lock_state() held. 1739 * called with nfs4_lock_state() held.
1740 */ 1740 */
1741int 1741__be32
1742nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open) 1742nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open)
1743{ 1743{
1744 struct nfs4_file *fp = NULL; 1744 struct nfs4_file *fp = NULL;
1745 struct inode *ino = current_fh->fh_dentry->d_inode; 1745 struct inode *ino = current_fh->fh_dentry->d_inode;
1746 struct nfs4_stateid *stp = NULL; 1746 struct nfs4_stateid *stp = NULL;
1747 struct nfs4_delegation *dp = NULL; 1747 struct nfs4_delegation *dp = NULL;
1748 int status; 1748 __be32 status;
1749 1749
1750 status = nfserr_inval; 1750 status = nfserr_inval;
1751 if (!access_valid(open->op_share_access) 1751 if (!access_valid(open->op_share_access)
@@ -1833,11 +1833,11 @@ static struct work_struct laundromat_work;
1833static void laundromat_main(void *); 1833static void laundromat_main(void *);
1834static DECLARE_WORK(laundromat_work, laundromat_main, NULL); 1834static DECLARE_WORK(laundromat_work, laundromat_main, NULL);
1835 1835
1836int 1836__be32
1837nfsd4_renew(clientid_t *clid) 1837nfsd4_renew(clientid_t *clid)
1838{ 1838{
1839 struct nfs4_client *clp; 1839 struct nfs4_client *clp;
1840 int status; 1840 __be32 status;
1841 1841
1842 nfs4_lock_state(); 1842 nfs4_lock_state();
1843 dprintk("process_renew(%08x/%08x): starting\n", 1843 dprintk("process_renew(%08x/%08x): starting\n",
@@ -1996,9 +1996,9 @@ access_permit_write(unsigned long access_bmap)
1996} 1996}
1997 1997
1998static 1998static
1999int nfs4_check_openmode(struct nfs4_stateid *stp, int flags) 1999__be32 nfs4_check_openmode(struct nfs4_stateid *stp, int flags)
2000{ 2000{
2001 int status = nfserr_openmode; 2001 __be32 status = nfserr_openmode;
2002 2002
2003 if ((flags & WR_STATE) && (!access_permit_write(stp->st_access_bmap))) 2003 if ((flags & WR_STATE) && (!access_permit_write(stp->st_access_bmap)))
2004 goto out; 2004 goto out;
@@ -2009,7 +2009,7 @@ out:
2009 return status; 2009 return status;
2010} 2010}
2011 2011
2012static inline int 2012static inline __be32
2013check_special_stateids(svc_fh *current_fh, stateid_t *stateid, int flags) 2013check_special_stateids(svc_fh *current_fh, stateid_t *stateid, int flags)
2014{ 2014{
2015 /* Trying to call delegreturn with a special stateid? Yuch: */ 2015 /* Trying to call delegreturn with a special stateid? Yuch: */
@@ -2043,14 +2043,14 @@ io_during_grace_disallowed(struct inode *inode, int flags)
2043/* 2043/*
2044* Checks for stateid operations 2044* Checks for stateid operations
2045*/ 2045*/
2046int 2046__be32
2047nfs4_preprocess_stateid_op(struct svc_fh *current_fh, stateid_t *stateid, int flags, struct file **filpp) 2047nfs4_preprocess_stateid_op(struct svc_fh *current_fh, stateid_t *stateid, int flags, struct file **filpp)
2048{ 2048{
2049 struct nfs4_stateid *stp = NULL; 2049 struct nfs4_stateid *stp = NULL;
2050 struct nfs4_delegation *dp = NULL; 2050 struct nfs4_delegation *dp = NULL;
2051 stateid_t *stidp; 2051 stateid_t *stidp;
2052 struct inode *ino = current_fh->fh_dentry->d_inode; 2052 struct inode *ino = current_fh->fh_dentry->d_inode;
2053 int status; 2053 __be32 status;
2054 2054
2055 dprintk("NFSD: preprocess_stateid_op: stateid = (%08x/%08x/%08x/%08x)\n", 2055 dprintk("NFSD: preprocess_stateid_op: stateid = (%08x/%08x/%08x/%08x)\n",
2056 stateid->si_boot, stateid->si_stateownerid, 2056 stateid->si_boot, stateid->si_stateownerid,
@@ -2125,7 +2125,7 @@ setlkflg (int type)
2125/* 2125/*
2126 * Checks for sequence id mutating operations. 2126 * Checks for sequence id mutating operations.
2127 */ 2127 */
2128static int 2128static __be32
2129nfs4_preprocess_seqid_op(struct svc_fh *current_fh, u32 seqid, stateid_t *stateid, int flags, struct nfs4_stateowner **sopp, struct nfs4_stateid **stpp, struct nfsd4_lock *lock) 2129nfs4_preprocess_seqid_op(struct svc_fh *current_fh, u32 seqid, stateid_t *stateid, int flags, struct nfs4_stateowner **sopp, struct nfs4_stateid **stpp, struct nfsd4_lock *lock)
2130{ 2130{
2131 struct nfs4_stateid *stp; 2131 struct nfs4_stateid *stp;
@@ -2169,7 +2169,7 @@ nfs4_preprocess_seqid_op(struct svc_fh *current_fh, u32 seqid, stateid_t *statei
2169 clientid_t *lockclid = &lock->v.new.clientid; 2169 clientid_t *lockclid = &lock->v.new.clientid;
2170 struct nfs4_client *clp = sop->so_client; 2170 struct nfs4_client *clp = sop->so_client;
2171 int lkflg = 0; 2171 int lkflg = 0;
2172 int status; 2172 __be32 status;
2173 2173
2174 lkflg = setlkflg(lock->lk_type); 2174 lkflg = setlkflg(lock->lk_type);
2175 2175
@@ -2233,7 +2233,7 @@ check_replay:
2233 if (seqid == sop->so_seqid - 1) { 2233 if (seqid == sop->so_seqid - 1) {
2234 dprintk("NFSD: preprocess_seqid_op: retransmission?\n"); 2234 dprintk("NFSD: preprocess_seqid_op: retransmission?\n");
2235 /* indicate replay to calling function */ 2235 /* indicate replay to calling function */
2236 return NFSERR_REPLAY_ME; 2236 return nfserr_replay_me;
2237 } 2237 }
2238 printk("NFSD: preprocess_seqid_op: bad seqid (expected %d, got %d)\n", 2238 printk("NFSD: preprocess_seqid_op: bad seqid (expected %d, got %d)\n",
2239 sop->so_seqid, seqid); 2239 sop->so_seqid, seqid);
@@ -2241,10 +2241,10 @@ check_replay:
2241 return nfserr_bad_seqid; 2241 return nfserr_bad_seqid;
2242} 2242}
2243 2243
2244int 2244__be32
2245nfsd4_open_confirm(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open_confirm *oc, struct nfs4_stateowner **replay_owner) 2245nfsd4_open_confirm(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open_confirm *oc, struct nfs4_stateowner **replay_owner)
2246{ 2246{
2247 int status; 2247 __be32 status;
2248 struct nfs4_stateowner *sop; 2248 struct nfs4_stateowner *sop;
2249 struct nfs4_stateid *stp; 2249 struct nfs4_stateid *stp;
2250 2250
@@ -2310,10 +2310,10 @@ reset_union_bmap_deny(unsigned long deny, unsigned long *bmap)
2310 } 2310 }
2311} 2311}
2312 2312
2313int 2313__be32
2314nfsd4_open_downgrade(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open_downgrade *od, struct nfs4_stateowner **replay_owner) 2314nfsd4_open_downgrade(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open_downgrade *od, struct nfs4_stateowner **replay_owner)
2315{ 2315{
2316 int status; 2316 __be32 status;
2317 struct nfs4_stateid *stp; 2317 struct nfs4_stateid *stp;
2318 unsigned int share_access; 2318 unsigned int share_access;
2319 2319
@@ -2365,10 +2365,10 @@ out:
2365/* 2365/*
2366 * nfs4_unlock_state() called after encode 2366 * nfs4_unlock_state() called after encode
2367 */ 2367 */
2368int 2368__be32
2369nfsd4_close(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_close *close, struct nfs4_stateowner **replay_owner) 2369nfsd4_close(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_close *close, struct nfs4_stateowner **replay_owner)
2370{ 2370{
2371 int status; 2371 __be32 status;
2372 struct nfs4_stateid *stp; 2372 struct nfs4_stateid *stp;
2373 2373
2374 dprintk("NFSD: nfsd4_close on file %.*s\n", 2374 dprintk("NFSD: nfsd4_close on file %.*s\n",
@@ -2404,10 +2404,10 @@ out:
2404 return status; 2404 return status;
2405} 2405}
2406 2406
2407int 2407__be32
2408nfsd4_delegreturn(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_delegreturn *dr) 2408nfsd4_delegreturn(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_delegreturn *dr)
2409{ 2409{
2410 int status; 2410 __be32 status;
2411 2411
2412 if ((status = fh_verify(rqstp, current_fh, S_IFREG, 0))) 2412 if ((status = fh_verify(rqstp, current_fh, S_IFREG, 0)))
2413 goto out; 2413 goto out;
@@ -2635,7 +2635,7 @@ check_lock_length(u64 offset, u64 length)
2635/* 2635/*
2636 * LOCK operation 2636 * LOCK operation
2637 */ 2637 */
2638int 2638__be32
2639nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock *lock, struct nfs4_stateowner **replay_owner) 2639nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock *lock, struct nfs4_stateowner **replay_owner)
2640{ 2640{
2641 struct nfs4_stateowner *open_sop = NULL; 2641 struct nfs4_stateowner *open_sop = NULL;
@@ -2644,8 +2644,9 @@ nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
2644 struct file *filp; 2644 struct file *filp;
2645 struct file_lock file_lock; 2645 struct file_lock file_lock;
2646 struct file_lock conflock; 2646 struct file_lock conflock;
2647 int status = 0; 2647 __be32 status = 0;
2648 unsigned int strhashval; 2648 unsigned int strhashval;
2649 int err;
2649 2650
2650 dprintk("NFSD: nfsd4_lock: start=%Ld length=%Ld\n", 2651 dprintk("NFSD: nfsd4_lock: start=%Ld length=%Ld\n",
2651 (long long) lock->lk_offset, 2652 (long long) lock->lk_offset,
@@ -2758,13 +2759,14 @@ nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
2758 * locks_copy_lock: */ 2759 * locks_copy_lock: */
2759 conflock.fl_ops = NULL; 2760 conflock.fl_ops = NULL;
2760 conflock.fl_lmops = NULL; 2761 conflock.fl_lmops = NULL;
2761 status = posix_lock_file_conf(filp, &file_lock, &conflock); 2762 err = posix_lock_file_conf(filp, &file_lock, &conflock);
2762 dprintk("NFSD: nfsd4_lock: posix_lock_file_conf status %d\n",status); 2763 dprintk("NFSD: nfsd4_lock: posix_lock_file_conf status %d\n",status);
2763 switch (-status) { 2764 switch (-err) {
2764 case 0: /* success! */ 2765 case 0: /* success! */
2765 update_stateid(&lock_stp->st_stateid); 2766 update_stateid(&lock_stp->st_stateid);
2766 memcpy(&lock->lk_resp_stateid, &lock_stp->st_stateid, 2767 memcpy(&lock->lk_resp_stateid, &lock_stp->st_stateid,
2767 sizeof(stateid_t)); 2768 sizeof(stateid_t));
2769 status = 0;
2768 break; 2770 break;
2769 case (EAGAIN): /* conflock holds conflicting lock */ 2771 case (EAGAIN): /* conflock holds conflicting lock */
2770 status = nfserr_denied; 2772 status = nfserr_denied;
@@ -2775,7 +2777,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
2775 status = nfserr_deadlock; 2777 status = nfserr_deadlock;
2776 break; 2778 break;
2777 default: 2779 default:
2778 dprintk("NFSD: nfsd4_lock: posix_lock_file_conf() failed! status %d\n",status); 2780 dprintk("NFSD: nfsd4_lock: posix_lock_file_conf() failed! status %d\n",err);
2779 status = nfserr_resource; 2781 status = nfserr_resource;
2780 break; 2782 break;
2781 } 2783 }
@@ -2793,14 +2795,14 @@ out:
2793/* 2795/*
2794 * LOCKT operation 2796 * LOCKT operation
2795 */ 2797 */
2796int 2798__be32
2797nfsd4_lockt(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lockt *lockt) 2799nfsd4_lockt(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lockt *lockt)
2798{ 2800{
2799 struct inode *inode; 2801 struct inode *inode;
2800 struct file file; 2802 struct file file;
2801 struct file_lock file_lock; 2803 struct file_lock file_lock;
2802 struct file_lock conflock; 2804 struct file_lock conflock;
2803 int status; 2805 __be32 status;
2804 2806
2805 if (nfs4_in_grace()) 2807 if (nfs4_in_grace())
2806 return nfserr_grace; 2808 return nfserr_grace;
@@ -2873,13 +2875,14 @@ out:
2873 return status; 2875 return status;
2874} 2876}
2875 2877
2876int 2878__be32
2877nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_locku *locku, struct nfs4_stateowner **replay_owner) 2879nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_locku *locku, struct nfs4_stateowner **replay_owner)
2878{ 2880{
2879 struct nfs4_stateid *stp; 2881 struct nfs4_stateid *stp;
2880 struct file *filp = NULL; 2882 struct file *filp = NULL;
2881 struct file_lock file_lock; 2883 struct file_lock file_lock;
2882 int status; 2884 __be32 status;
2885 int err;
2883 2886
2884 dprintk("NFSD: nfsd4_locku: start=%Ld length=%Ld\n", 2887 dprintk("NFSD: nfsd4_locku: start=%Ld length=%Ld\n",
2885 (long long) locku->lu_offset, 2888 (long long) locku->lu_offset,
@@ -2917,8 +2920,8 @@ nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
2917 /* 2920 /*
2918 * Try to unlock the file in the VFS. 2921 * Try to unlock the file in the VFS.
2919 */ 2922 */
2920 status = posix_lock_file(filp, &file_lock); 2923 err = posix_lock_file(filp, &file_lock);
2921 if (status) { 2924 if (err) {
2922 dprintk("NFSD: nfs4_locku: posix_lock_file failed!\n"); 2925 dprintk("NFSD: nfs4_locku: posix_lock_file failed!\n");
2923 goto out_nfserr; 2926 goto out_nfserr;
2924 } 2927 }
@@ -2937,7 +2940,7 @@ out:
2937 return status; 2940 return status;
2938 2941
2939out_nfserr: 2942out_nfserr:
2940 status = nfserrno(status); 2943 status = nfserrno(err);
2941 goto out; 2944 goto out;
2942} 2945}
2943 2946
@@ -2965,7 +2968,7 @@ out:
2965 return status; 2968 return status;
2966} 2969}
2967 2970
2968int 2971__be32
2969nfsd4_release_lockowner(struct svc_rqst *rqstp, struct nfsd4_release_lockowner *rlockowner) 2972nfsd4_release_lockowner(struct svc_rqst *rqstp, struct nfsd4_release_lockowner *rlockowner)
2970{ 2973{
2971 clientid_t *clid = &rlockowner->rl_clientid; 2974 clientid_t *clid = &rlockowner->rl_clientid;
@@ -2974,7 +2977,7 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, struct nfsd4_release_lockowner *
2974 struct xdr_netobj *owner = &rlockowner->rl_owner; 2977 struct xdr_netobj *owner = &rlockowner->rl_owner;
2975 struct list_head matches; 2978 struct list_head matches;
2976 int i; 2979 int i;
2977 int status; 2980 __be32 status;
2978 2981
2979 dprintk("nfsd4_release_lockowner clientid: (%08x/%08x):\n", 2982 dprintk("nfsd4_release_lockowner clientid: (%08x/%08x):\n",
2980 clid->cl_boot, clid->cl_id); 2983 clid->cl_boot, clid->cl_id);
@@ -3111,7 +3114,7 @@ nfs4_find_reclaim_client(clientid_t *clid)
3111/* 3114/*
3112* Called from OPEN. Look for clientid in reclaim list. 3115* Called from OPEN. Look for clientid in reclaim list.
3113*/ 3116*/
3114int 3117__be32
3115nfs4_check_open_reclaim(clientid_t *clid) 3118nfs4_check_open_reclaim(clientid_t *clid)
3116{ 3119{
3117 return nfs4_find_reclaim_client(clid) ? nfs_ok : nfserr_reclaim_bad; 3120 return nfs4_find_reclaim_client(clid) ? nfs_ok : nfserr_reclaim_bad;
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 41fc241b729a..f3f239db04bb 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -68,8 +68,8 @@
68#define NFS4_REFERRAL_FSID_MAJOR 0x8000000ULL 68#define NFS4_REFERRAL_FSID_MAJOR 0x8000000ULL
69#define NFS4_REFERRAL_FSID_MINOR 0x8000000ULL 69#define NFS4_REFERRAL_FSID_MINOR 0x8000000ULL
70 70
71static int 71static __be32
72check_filename(char *str, int len, int err) 72check_filename(char *str, int len, __be32 err)
73{ 73{
74 int i; 74 int i;
75 75
@@ -94,8 +94,8 @@ check_filename(char *str, int len, int err)
94 * consistent with the style used in NFSv2/v3... 94 * consistent with the style used in NFSv2/v3...
95 */ 95 */
96#define DECODE_HEAD \ 96#define DECODE_HEAD \
97 u32 *p; \ 97 __be32 *p; \
98 int status 98 __be32 status
99#define DECODE_TAIL \ 99#define DECODE_TAIL \
100 status = 0; \ 100 status = 0; \
101out: \ 101out: \
@@ -144,13 +144,13 @@ xdr_error: \
144 } \ 144 } \
145} while (0) 145} while (0)
146 146
147static u32 *read_buf(struct nfsd4_compoundargs *argp, int nbytes) 147static __be32 *read_buf(struct nfsd4_compoundargs *argp, int nbytes)
148{ 148{
149 /* We want more bytes than seem to be available. 149 /* We want more bytes than seem to be available.
150 * Maybe we need a new page, maybe we have just run out 150 * Maybe we need a new page, maybe we have just run out
151 */ 151 */
152 int avail = (char*)argp->end - (char*)argp->p; 152 int avail = (char*)argp->end - (char*)argp->p;
153 u32 *p; 153 __be32 *p;
154 if (avail + argp->pagelen < nbytes) 154 if (avail + argp->pagelen < nbytes)
155 return NULL; 155 return NULL;
156 if (avail + PAGE_SIZE < nbytes) /* need more than a page !! */ 156 if (avail + PAGE_SIZE < nbytes) /* need more than a page !! */
@@ -197,7 +197,7 @@ defer_free(struct nfsd4_compoundargs *argp,
197 return 0; 197 return 0;
198} 198}
199 199
200static char *savemem(struct nfsd4_compoundargs *argp, u32 *p, int nbytes) 200static char *savemem(struct nfsd4_compoundargs *argp, __be32 *p, int nbytes)
201{ 201{
202 void *new = NULL; 202 void *new = NULL;
203 if (p == argp->tmp) { 203 if (p == argp->tmp) {
@@ -217,7 +217,7 @@ static char *savemem(struct nfsd4_compoundargs *argp, u32 *p, int nbytes)
217} 217}
218 218
219 219
220static int 220static __be32
221nfsd4_decode_bitmap(struct nfsd4_compoundargs *argp, u32 *bmval) 221nfsd4_decode_bitmap(struct nfsd4_compoundargs *argp, u32 *bmval)
222{ 222{
223 u32 bmlen; 223 u32 bmlen;
@@ -240,13 +240,14 @@ nfsd4_decode_bitmap(struct nfsd4_compoundargs *argp, u32 *bmval)
240 DECODE_TAIL; 240 DECODE_TAIL;
241} 241}
242 242
243static int 243static __be32
244nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, struct iattr *iattr, 244nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, struct iattr *iattr,
245 struct nfs4_acl **acl) 245 struct nfs4_acl **acl)
246{ 246{
247 int expected_len, len = 0; 247 int expected_len, len = 0;
248 u32 dummy32; 248 u32 dummy32;
249 char *buf; 249 char *buf;
250 int host_err;
250 251
251 DECODE_HEAD; 252 DECODE_HEAD;
252 iattr->ia_valid = 0; 253 iattr->ia_valid = 0;
@@ -280,7 +281,7 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, struct iattr *ia
280 281
281 *acl = nfs4_acl_new(); 282 *acl = nfs4_acl_new();
282 if (*acl == NULL) { 283 if (*acl == NULL) {
283 status = -ENOMEM; 284 host_err = -ENOMEM;
284 goto out_nfserr; 285 goto out_nfserr;
285 } 286 }
286 defer_free(argp, (void (*)(const void *))nfs4_acl_free, *acl); 287 defer_free(argp, (void (*)(const void *))nfs4_acl_free, *acl);
@@ -295,20 +296,20 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, struct iattr *ia
295 len += XDR_QUADLEN(dummy32) << 2; 296 len += XDR_QUADLEN(dummy32) << 2;
296 READMEM(buf, dummy32); 297 READMEM(buf, dummy32);
297 ace.whotype = nfs4_acl_get_whotype(buf, dummy32); 298 ace.whotype = nfs4_acl_get_whotype(buf, dummy32);
298 status = 0; 299 host_err = 0;
299 if (ace.whotype != NFS4_ACL_WHO_NAMED) 300 if (ace.whotype != NFS4_ACL_WHO_NAMED)
300 ace.who = 0; 301 ace.who = 0;
301 else if (ace.flag & NFS4_ACE_IDENTIFIER_GROUP) 302 else if (ace.flag & NFS4_ACE_IDENTIFIER_GROUP)
302 status = nfsd_map_name_to_gid(argp->rqstp, 303 host_err = nfsd_map_name_to_gid(argp->rqstp,
303 buf, dummy32, &ace.who); 304 buf, dummy32, &ace.who);
304 else 305 else
305 status = nfsd_map_name_to_uid(argp->rqstp, 306 host_err = nfsd_map_name_to_uid(argp->rqstp,
306 buf, dummy32, &ace.who); 307 buf, dummy32, &ace.who);
307 if (status) 308 if (host_err)
308 goto out_nfserr; 309 goto out_nfserr;
309 status = nfs4_acl_add_ace(*acl, ace.type, ace.flag, 310 host_err = nfs4_acl_add_ace(*acl, ace.type, ace.flag,
310 ace.access_mask, ace.whotype, ace.who); 311 ace.access_mask, ace.whotype, ace.who);
311 if (status) 312 if (host_err)
312 goto out_nfserr; 313 goto out_nfserr;
313 } 314 }
314 } else 315 } else
@@ -327,7 +328,7 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, struct iattr *ia
327 READ_BUF(dummy32); 328 READ_BUF(dummy32);
328 len += (XDR_QUADLEN(dummy32) << 2); 329 len += (XDR_QUADLEN(dummy32) << 2);
329 READMEM(buf, dummy32); 330 READMEM(buf, dummy32);
330 if ((status = nfsd_map_name_to_uid(argp->rqstp, buf, dummy32, &iattr->ia_uid))) 331 if ((host_err = nfsd_map_name_to_uid(argp->rqstp, buf, dummy32, &iattr->ia_uid)))
331 goto out_nfserr; 332 goto out_nfserr;
332 iattr->ia_valid |= ATTR_UID; 333 iattr->ia_valid |= ATTR_UID;
333 } 334 }
@@ -338,7 +339,7 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, struct iattr *ia
338 READ_BUF(dummy32); 339 READ_BUF(dummy32);
339 len += (XDR_QUADLEN(dummy32) << 2); 340 len += (XDR_QUADLEN(dummy32) << 2);
340 READMEM(buf, dummy32); 341 READMEM(buf, dummy32);
341 if ((status = nfsd_map_name_to_gid(argp->rqstp, buf, dummy32, &iattr->ia_gid))) 342 if ((host_err = nfsd_map_name_to_gid(argp->rqstp, buf, dummy32, &iattr->ia_gid)))
342 goto out_nfserr; 343 goto out_nfserr;
343 iattr->ia_valid |= ATTR_GID; 344 iattr->ia_valid |= ATTR_GID;
344 } 345 }
@@ -414,11 +415,11 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, struct iattr *ia
414 DECODE_TAIL; 415 DECODE_TAIL;
415 416
416out_nfserr: 417out_nfserr:
417 status = nfserrno(status); 418 status = nfserrno(host_err);
418 goto out; 419 goto out;
419} 420}
420 421
421static int 422static __be32
422nfsd4_decode_access(struct nfsd4_compoundargs *argp, struct nfsd4_access *access) 423nfsd4_decode_access(struct nfsd4_compoundargs *argp, struct nfsd4_access *access)
423{ 424{
424 DECODE_HEAD; 425 DECODE_HEAD;
@@ -429,7 +430,7 @@ nfsd4_decode_access(struct nfsd4_compoundargs *argp, struct nfsd4_access *access
429 DECODE_TAIL; 430 DECODE_TAIL;
430} 431}
431 432
432static int 433static __be32
433nfsd4_decode_close(struct nfsd4_compoundargs *argp, struct nfsd4_close *close) 434nfsd4_decode_close(struct nfsd4_compoundargs *argp, struct nfsd4_close *close)
434{ 435{
435 DECODE_HEAD; 436 DECODE_HEAD;
@@ -444,7 +445,7 @@ nfsd4_decode_close(struct nfsd4_compoundargs *argp, struct nfsd4_close *close)
444} 445}
445 446
446 447
447static int 448static __be32
448nfsd4_decode_commit(struct nfsd4_compoundargs *argp, struct nfsd4_commit *commit) 449nfsd4_decode_commit(struct nfsd4_compoundargs *argp, struct nfsd4_commit *commit)
449{ 450{
450 DECODE_HEAD; 451 DECODE_HEAD;
@@ -456,7 +457,7 @@ nfsd4_decode_commit(struct nfsd4_compoundargs *argp, struct nfsd4_commit *commit
456 DECODE_TAIL; 457 DECODE_TAIL;
457} 458}
458 459
459static int 460static __be32
460nfsd4_decode_create(struct nfsd4_compoundargs *argp, struct nfsd4_create *create) 461nfsd4_decode_create(struct nfsd4_compoundargs *argp, struct nfsd4_create *create)
461{ 462{
462 DECODE_HEAD; 463 DECODE_HEAD;
@@ -496,7 +497,7 @@ nfsd4_decode_create(struct nfsd4_compoundargs *argp, struct nfsd4_create *create
496 DECODE_TAIL; 497 DECODE_TAIL;
497} 498}
498 499
499static inline int 500static inline __be32
500nfsd4_decode_delegreturn(struct nfsd4_compoundargs *argp, struct nfsd4_delegreturn *dr) 501nfsd4_decode_delegreturn(struct nfsd4_compoundargs *argp, struct nfsd4_delegreturn *dr)
501{ 502{
502 DECODE_HEAD; 503 DECODE_HEAD;
@@ -508,13 +509,13 @@ nfsd4_decode_delegreturn(struct nfsd4_compoundargs *argp, struct nfsd4_delegretu
508 DECODE_TAIL; 509 DECODE_TAIL;
509} 510}
510 511
511static inline int 512static inline __be32
512nfsd4_decode_getattr(struct nfsd4_compoundargs *argp, struct nfsd4_getattr *getattr) 513nfsd4_decode_getattr(struct nfsd4_compoundargs *argp, struct nfsd4_getattr *getattr)
513{ 514{
514 return nfsd4_decode_bitmap(argp, getattr->ga_bmval); 515 return nfsd4_decode_bitmap(argp, getattr->ga_bmval);
515} 516}
516 517
517static int 518static __be32
518nfsd4_decode_link(struct nfsd4_compoundargs *argp, struct nfsd4_link *link) 519nfsd4_decode_link(struct nfsd4_compoundargs *argp, struct nfsd4_link *link)
519{ 520{
520 DECODE_HEAD; 521 DECODE_HEAD;
@@ -529,7 +530,7 @@ nfsd4_decode_link(struct nfsd4_compoundargs *argp, struct nfsd4_link *link)
529 DECODE_TAIL; 530 DECODE_TAIL;
530} 531}
531 532
532static int 533static __be32
533nfsd4_decode_lock(struct nfsd4_compoundargs *argp, struct nfsd4_lock *lock) 534nfsd4_decode_lock(struct nfsd4_compoundargs *argp, struct nfsd4_lock *lock)
534{ 535{
535 DECODE_HEAD; 536 DECODE_HEAD;
@@ -568,7 +569,7 @@ nfsd4_decode_lock(struct nfsd4_compoundargs *argp, struct nfsd4_lock *lock)
568 DECODE_TAIL; 569 DECODE_TAIL;
569} 570}
570 571
571static int 572static __be32
572nfsd4_decode_lockt(struct nfsd4_compoundargs *argp, struct nfsd4_lockt *lockt) 573nfsd4_decode_lockt(struct nfsd4_compoundargs *argp, struct nfsd4_lockt *lockt)
573{ 574{
574 DECODE_HEAD; 575 DECODE_HEAD;
@@ -587,7 +588,7 @@ nfsd4_decode_lockt(struct nfsd4_compoundargs *argp, struct nfsd4_lockt *lockt)
587 DECODE_TAIL; 588 DECODE_TAIL;
588} 589}
589 590
590static int 591static __be32
591nfsd4_decode_locku(struct nfsd4_compoundargs *argp, struct nfsd4_locku *locku) 592nfsd4_decode_locku(struct nfsd4_compoundargs *argp, struct nfsd4_locku *locku)
592{ 593{
593 DECODE_HEAD; 594 DECODE_HEAD;
@@ -606,7 +607,7 @@ nfsd4_decode_locku(struct nfsd4_compoundargs *argp, struct nfsd4_locku *locku)
606 DECODE_TAIL; 607 DECODE_TAIL;
607} 608}
608 609
609static int 610static __be32
610nfsd4_decode_lookup(struct nfsd4_compoundargs *argp, struct nfsd4_lookup *lookup) 611nfsd4_decode_lookup(struct nfsd4_compoundargs *argp, struct nfsd4_lookup *lookup)
611{ 612{
612 DECODE_HEAD; 613 DECODE_HEAD;
@@ -621,7 +622,7 @@ nfsd4_decode_lookup(struct nfsd4_compoundargs *argp, struct nfsd4_lookup *lookup
621 DECODE_TAIL; 622 DECODE_TAIL;
622} 623}
623 624
624static int 625static __be32
625nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open) 626nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open)
626{ 627{
627 DECODE_HEAD; 628 DECODE_HEAD;
@@ -699,7 +700,7 @@ nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open)
699 DECODE_TAIL; 700 DECODE_TAIL;
700} 701}
701 702
702static int 703static __be32
703nfsd4_decode_open_confirm(struct nfsd4_compoundargs *argp, struct nfsd4_open_confirm *open_conf) 704nfsd4_decode_open_confirm(struct nfsd4_compoundargs *argp, struct nfsd4_open_confirm *open_conf)
704{ 705{
705 DECODE_HEAD; 706 DECODE_HEAD;
@@ -713,7 +714,7 @@ nfsd4_decode_open_confirm(struct nfsd4_compoundargs *argp, struct nfsd4_open_con
713 DECODE_TAIL; 714 DECODE_TAIL;
714} 715}
715 716
716static int 717static __be32
717nfsd4_decode_open_downgrade(struct nfsd4_compoundargs *argp, struct nfsd4_open_downgrade *open_down) 718nfsd4_decode_open_downgrade(struct nfsd4_compoundargs *argp, struct nfsd4_open_downgrade *open_down)
718{ 719{
719 DECODE_HEAD; 720 DECODE_HEAD;
@@ -729,7 +730,7 @@ nfsd4_decode_open_downgrade(struct nfsd4_compoundargs *argp, struct nfsd4_open_d
729 DECODE_TAIL; 730 DECODE_TAIL;
730} 731}
731 732
732static int 733static __be32
733nfsd4_decode_putfh(struct nfsd4_compoundargs *argp, struct nfsd4_putfh *putfh) 734nfsd4_decode_putfh(struct nfsd4_compoundargs *argp, struct nfsd4_putfh *putfh)
734{ 735{
735 DECODE_HEAD; 736 DECODE_HEAD;
@@ -744,7 +745,7 @@ nfsd4_decode_putfh(struct nfsd4_compoundargs *argp, struct nfsd4_putfh *putfh)
744 DECODE_TAIL; 745 DECODE_TAIL;
745} 746}
746 747
747static int 748static __be32
748nfsd4_decode_read(struct nfsd4_compoundargs *argp, struct nfsd4_read *read) 749nfsd4_decode_read(struct nfsd4_compoundargs *argp, struct nfsd4_read *read)
749{ 750{
750 DECODE_HEAD; 751 DECODE_HEAD;
@@ -758,7 +759,7 @@ nfsd4_decode_read(struct nfsd4_compoundargs *argp, struct nfsd4_read *read)
758 DECODE_TAIL; 759 DECODE_TAIL;
759} 760}
760 761
761static int 762static __be32
762nfsd4_decode_readdir(struct nfsd4_compoundargs *argp, struct nfsd4_readdir *readdir) 763nfsd4_decode_readdir(struct nfsd4_compoundargs *argp, struct nfsd4_readdir *readdir)
763{ 764{
764 DECODE_HEAD; 765 DECODE_HEAD;
@@ -774,7 +775,7 @@ nfsd4_decode_readdir(struct nfsd4_compoundargs *argp, struct nfsd4_readdir *read
774 DECODE_TAIL; 775 DECODE_TAIL;
775} 776}
776 777
777static int 778static __be32
778nfsd4_decode_remove(struct nfsd4_compoundargs *argp, struct nfsd4_remove *remove) 779nfsd4_decode_remove(struct nfsd4_compoundargs *argp, struct nfsd4_remove *remove)
779{ 780{
780 DECODE_HEAD; 781 DECODE_HEAD;
@@ -789,7 +790,7 @@ nfsd4_decode_remove(struct nfsd4_compoundargs *argp, struct nfsd4_remove *remove
789 DECODE_TAIL; 790 DECODE_TAIL;
790} 791}
791 792
792static int 793static __be32
793nfsd4_decode_rename(struct nfsd4_compoundargs *argp, struct nfsd4_rename *rename) 794nfsd4_decode_rename(struct nfsd4_compoundargs *argp, struct nfsd4_rename *rename)
794{ 795{
795 DECODE_HEAD; 796 DECODE_HEAD;
@@ -809,7 +810,7 @@ nfsd4_decode_rename(struct nfsd4_compoundargs *argp, struct nfsd4_rename *rename
809 DECODE_TAIL; 810 DECODE_TAIL;
810} 811}
811 812
812static int 813static __be32
813nfsd4_decode_renew(struct nfsd4_compoundargs *argp, clientid_t *clientid) 814nfsd4_decode_renew(struct nfsd4_compoundargs *argp, clientid_t *clientid)
814{ 815{
815 DECODE_HEAD; 816 DECODE_HEAD;
@@ -820,7 +821,7 @@ nfsd4_decode_renew(struct nfsd4_compoundargs *argp, clientid_t *clientid)
820 DECODE_TAIL; 821 DECODE_TAIL;
821} 822}
822 823
823static int 824static __be32
824nfsd4_decode_setattr(struct nfsd4_compoundargs *argp, struct nfsd4_setattr *setattr) 825nfsd4_decode_setattr(struct nfsd4_compoundargs *argp, struct nfsd4_setattr *setattr)
825{ 826{
826 DECODE_HEAD; 827 DECODE_HEAD;
@@ -834,7 +835,7 @@ nfsd4_decode_setattr(struct nfsd4_compoundargs *argp, struct nfsd4_setattr *seta
834 DECODE_TAIL; 835 DECODE_TAIL;
835} 836}
836 837
837static int 838static __be32
838nfsd4_decode_setclientid(struct nfsd4_compoundargs *argp, struct nfsd4_setclientid *setclientid) 839nfsd4_decode_setclientid(struct nfsd4_compoundargs *argp, struct nfsd4_setclientid *setclientid)
839{ 840{
840 DECODE_HEAD; 841 DECODE_HEAD;
@@ -859,7 +860,7 @@ nfsd4_decode_setclientid(struct nfsd4_compoundargs *argp, struct nfsd4_setclient
859 DECODE_TAIL; 860 DECODE_TAIL;
860} 861}
861 862
862static int 863static __be32
863nfsd4_decode_setclientid_confirm(struct nfsd4_compoundargs *argp, struct nfsd4_setclientid_confirm *scd_c) 864nfsd4_decode_setclientid_confirm(struct nfsd4_compoundargs *argp, struct nfsd4_setclientid_confirm *scd_c)
864{ 865{
865 DECODE_HEAD; 866 DECODE_HEAD;
@@ -872,7 +873,7 @@ nfsd4_decode_setclientid_confirm(struct nfsd4_compoundargs *argp, struct nfsd4_s
872} 873}
873 874
874/* Also used for NVERIFY */ 875/* Also used for NVERIFY */
875static int 876static __be32
876nfsd4_decode_verify(struct nfsd4_compoundargs *argp, struct nfsd4_verify *verify) 877nfsd4_decode_verify(struct nfsd4_compoundargs *argp, struct nfsd4_verify *verify)
877{ 878{
878#if 0 879#if 0
@@ -908,7 +909,7 @@ nfsd4_decode_verify(struct nfsd4_compoundargs *argp, struct nfsd4_verify *verify
908 DECODE_TAIL; 909 DECODE_TAIL;
909} 910}
910 911
911static int 912static __be32
912nfsd4_decode_write(struct nfsd4_compoundargs *argp, struct nfsd4_write *write) 913nfsd4_decode_write(struct nfsd4_compoundargs *argp, struct nfsd4_write *write)
913{ 914{
914 int avail; 915 int avail;
@@ -951,15 +952,15 @@ nfsd4_decode_write(struct nfsd4_compoundargs *argp, struct nfsd4_write *write)
951 argp->pagelen -= len; 952 argp->pagelen -= len;
952 } 953 }
953 } 954 }
954 argp->end = (u32*) (argp->rqstp->rq_vec[v].iov_base + argp->rqstp->rq_vec[v].iov_len); 955 argp->end = (__be32*) (argp->rqstp->rq_vec[v].iov_base + argp->rqstp->rq_vec[v].iov_len);
955 argp->p = (u32*) (argp->rqstp->rq_vec[v].iov_base + (XDR_QUADLEN(len) << 2)); 956 argp->p = (__be32*) (argp->rqstp->rq_vec[v].iov_base + (XDR_QUADLEN(len) << 2));
956 argp->rqstp->rq_vec[v].iov_len = len; 957 argp->rqstp->rq_vec[v].iov_len = len;
957 write->wr_vlen = v+1; 958 write->wr_vlen = v+1;
958 959
959 DECODE_TAIL; 960 DECODE_TAIL;
960} 961}
961 962
962static int 963static __be32
963nfsd4_decode_release_lockowner(struct nfsd4_compoundargs *argp, struct nfsd4_release_lockowner *rlockowner) 964nfsd4_decode_release_lockowner(struct nfsd4_compoundargs *argp, struct nfsd4_release_lockowner *rlockowner)
964{ 965{
965 DECODE_HEAD; 966 DECODE_HEAD;
@@ -973,7 +974,7 @@ nfsd4_decode_release_lockowner(struct nfsd4_compoundargs *argp, struct nfsd4_rel
973 DECODE_TAIL; 974 DECODE_TAIL;
974} 975}
975 976
976static int 977static __be32
977nfsd4_decode_compound(struct nfsd4_compoundargs *argp) 978nfsd4_decode_compound(struct nfsd4_compoundargs *argp)
978{ 979{
979 DECODE_HEAD; 980 DECODE_HEAD;
@@ -1179,7 +1180,7 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp)
1179 * task to translate them into Linux-specific versions which are more 1180 * task to translate them into Linux-specific versions which are more
1180 * consistent with the style used in NFSv2/v3... 1181 * consistent with the style used in NFSv2/v3...
1181 */ 1182 */
1182#define ENCODE_HEAD u32 *p 1183#define ENCODE_HEAD __be32 *p
1183 1184
1184#define WRITE32(n) *p++ = htonl(n) 1185#define WRITE32(n) *p++ = htonl(n)
1185#define WRITE64(n) do { \ 1186#define WRITE64(n) do { \
@@ -1209,8 +1210,8 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp)
1209 * Header routine to setup seqid operation replay cache 1210 * Header routine to setup seqid operation replay cache
1210 */ 1211 */
1211#define ENCODE_SEQID_OP_HEAD \ 1212#define ENCODE_SEQID_OP_HEAD \
1212 u32 *p; \ 1213 __be32 *p; \
1213 u32 *save; \ 1214 __be32 *save; \
1214 \ 1215 \
1215 save = resp->p; 1216 save = resp->p;
1216 1217
@@ -1234,11 +1235,11 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp)
1234/* Encode as an array of strings the string given with components 1235/* Encode as an array of strings the string given with components
1235 * seperated @sep. 1236 * seperated @sep.
1236 */ 1237 */
1237static int nfsd4_encode_components(char sep, char *components, 1238static __be32 nfsd4_encode_components(char sep, char *components,
1238 u32 **pp, int *buflen) 1239 __be32 **pp, int *buflen)
1239{ 1240{
1240 u32 *p = *pp; 1241 __be32 *p = *pp;
1241 u32 *countp = p; 1242 __be32 *countp = p;
1242 int strlen, count=0; 1243 int strlen, count=0;
1243 char *str, *end; 1244 char *str, *end;
1244 1245
@@ -1271,11 +1272,11 @@ static int nfsd4_encode_components(char sep, char *components,
1271/* 1272/*
1272 * encode a location element of a fs_locations structure 1273 * encode a location element of a fs_locations structure
1273 */ 1274 */
1274static int nfsd4_encode_fs_location4(struct nfsd4_fs_location *location, 1275static __be32 nfsd4_encode_fs_location4(struct nfsd4_fs_location *location,
1275 u32 **pp, int *buflen) 1276 __be32 **pp, int *buflen)
1276{ 1277{
1277 int status; 1278 __be32 status;
1278 u32 *p = *pp; 1279 __be32 *p = *pp;
1279 1280
1280 status = nfsd4_encode_components(':', location->hosts, &p, buflen); 1281 status = nfsd4_encode_components(':', location->hosts, &p, buflen);
1281 if (status) 1282 if (status)
@@ -1292,16 +1293,15 @@ static int nfsd4_encode_fs_location4(struct nfsd4_fs_location *location,
1292 * Returned string is safe to use as long as the caller holds a reference 1293 * Returned string is safe to use as long as the caller holds a reference
1293 * to @exp. 1294 * to @exp.
1294 */ 1295 */
1295static char *nfsd4_path(struct svc_rqst *rqstp, struct svc_export *exp) 1296static char *nfsd4_path(struct svc_rqst *rqstp, struct svc_export *exp, __be32 *stat)
1296{ 1297{
1297 struct svc_fh tmp_fh; 1298 struct svc_fh tmp_fh;
1298 char *path, *rootpath; 1299 char *path, *rootpath;
1299 int stat;
1300 1300
1301 fh_init(&tmp_fh, NFS4_FHSIZE); 1301 fh_init(&tmp_fh, NFS4_FHSIZE);
1302 stat = exp_pseudoroot(rqstp->rq_client, &tmp_fh, &rqstp->rq_chandle); 1302 *stat = exp_pseudoroot(rqstp->rq_client, &tmp_fh, &rqstp->rq_chandle);
1303 if (stat) 1303 if (*stat)
1304 return ERR_PTR(stat); 1304 return NULL;
1305 rootpath = tmp_fh.fh_export->ex_path; 1305 rootpath = tmp_fh.fh_export->ex_path;
1306 1306
1307 path = exp->ex_path; 1307 path = exp->ex_path;
@@ -1309,7 +1309,8 @@ static char *nfsd4_path(struct svc_rqst *rqstp, struct svc_export *exp)
1309 if (strncmp(path, rootpath, strlen(rootpath))) { 1309 if (strncmp(path, rootpath, strlen(rootpath))) {
1310 printk("nfsd: fs_locations failed;" 1310 printk("nfsd: fs_locations failed;"
1311 "%s is not contained in %s\n", path, rootpath); 1311 "%s is not contained in %s\n", path, rootpath);
1312 return ERR_PTR(-EOPNOTSUPP); 1312 *stat = nfserr_notsupp;
1313 return NULL;
1313 } 1314 }
1314 1315
1315 return path + strlen(rootpath); 1316 return path + strlen(rootpath);
@@ -1318,17 +1319,18 @@ static char *nfsd4_path(struct svc_rqst *rqstp, struct svc_export *exp)
1318/* 1319/*
1319 * encode a fs_locations structure 1320 * encode a fs_locations structure
1320 */ 1321 */
1321static int nfsd4_encode_fs_locations(struct svc_rqst *rqstp, 1322static __be32 nfsd4_encode_fs_locations(struct svc_rqst *rqstp,
1322 struct svc_export *exp, 1323 struct svc_export *exp,
1323 u32 **pp, int *buflen) 1324 __be32 **pp, int *buflen)
1324{ 1325{
1325 int status, i; 1326 __be32 status;
1326 u32 *p = *pp; 1327 int i;
1328 __be32 *p = *pp;
1327 struct nfsd4_fs_locations *fslocs = &exp->ex_fslocs; 1329 struct nfsd4_fs_locations *fslocs = &exp->ex_fslocs;
1328 char *root = nfsd4_path(rqstp, exp); 1330 char *root = nfsd4_path(rqstp, exp, &status);
1329 1331
1330 if (IS_ERR(root)) 1332 if (status)
1331 return PTR_ERR(root); 1333 return status;
1332 status = nfsd4_encode_components('/', root, &p, buflen); 1334 status = nfsd4_encode_components('/', root, &p, buflen);
1333 if (status) 1335 if (status)
1334 return status; 1336 return status;
@@ -1352,9 +1354,9 @@ static u32 nfs4_ftypes[16] = {
1352 NF4SOCK, NF4BAD, NF4LNK, NF4BAD, 1354 NF4SOCK, NF4BAD, NF4LNK, NF4BAD,
1353}; 1355};
1354 1356
1355static int 1357static __be32
1356nfsd4_encode_name(struct svc_rqst *rqstp, int whotype, uid_t id, int group, 1358nfsd4_encode_name(struct svc_rqst *rqstp, int whotype, uid_t id, int group,
1357 u32 **p, int *buflen) 1359 __be32 **p, int *buflen)
1358{ 1360{
1359 int status; 1361 int status;
1360 1362
@@ -1374,21 +1376,21 @@ nfsd4_encode_name(struct svc_rqst *rqstp, int whotype, uid_t id, int group,
1374 return 0; 1376 return 0;
1375} 1377}
1376 1378
1377static inline int 1379static inline __be32
1378nfsd4_encode_user(struct svc_rqst *rqstp, uid_t uid, u32 **p, int *buflen) 1380nfsd4_encode_user(struct svc_rqst *rqstp, uid_t uid, __be32 **p, int *buflen)
1379{ 1381{
1380 return nfsd4_encode_name(rqstp, NFS4_ACL_WHO_NAMED, uid, 0, p, buflen); 1382 return nfsd4_encode_name(rqstp, NFS4_ACL_WHO_NAMED, uid, 0, p, buflen);
1381} 1383}
1382 1384
1383static inline int 1385static inline __be32
1384nfsd4_encode_group(struct svc_rqst *rqstp, uid_t gid, u32 **p, int *buflen) 1386nfsd4_encode_group(struct svc_rqst *rqstp, uid_t gid, __be32 **p, int *buflen)
1385{ 1387{
1386 return nfsd4_encode_name(rqstp, NFS4_ACL_WHO_NAMED, gid, 1, p, buflen); 1388 return nfsd4_encode_name(rqstp, NFS4_ACL_WHO_NAMED, gid, 1, p, buflen);
1387} 1389}
1388 1390
1389static inline int 1391static inline __be32
1390nfsd4_encode_aclname(struct svc_rqst *rqstp, int whotype, uid_t id, int group, 1392nfsd4_encode_aclname(struct svc_rqst *rqstp, int whotype, uid_t id, int group,
1391 u32 **p, int *buflen) 1393 __be32 **p, int *buflen)
1392{ 1394{
1393 return nfsd4_encode_name(rqstp, whotype, id, group, p, buflen); 1395 return nfsd4_encode_name(rqstp, whotype, id, group, p, buflen);
1394} 1396}
@@ -1397,7 +1399,7 @@ nfsd4_encode_aclname(struct svc_rqst *rqstp, int whotype, uid_t id, int group,
1397 FATTR4_WORD0_RDATTR_ERROR) 1399 FATTR4_WORD0_RDATTR_ERROR)
1398#define WORD1_ABSENT_FS_ATTRS FATTR4_WORD1_MOUNTED_ON_FILEID 1400#define WORD1_ABSENT_FS_ATTRS FATTR4_WORD1_MOUNTED_ON_FILEID
1399 1401
1400static int fattr_handle_absent_fs(u32 *bmval0, u32 *bmval1, u32 *rdattr_err) 1402static __be32 fattr_handle_absent_fs(u32 *bmval0, u32 *bmval1, u32 *rdattr_err)
1401{ 1403{
1402 /* As per referral draft: */ 1404 /* As per referral draft: */
1403 if (*bmval0 & ~WORD0_ABSENT_FS_ATTRS || 1405 if (*bmval0 & ~WORD0_ABSENT_FS_ATTRS ||
@@ -1420,9 +1422,9 @@ static int fattr_handle_absent_fs(u32 *bmval0, u32 *bmval1, u32 *rdattr_err)
1420 * @countp is the buffer size in _words_; upon successful return this becomes 1422 * @countp is the buffer size in _words_; upon successful return this becomes
1421 * replaced with the number of words written. 1423 * replaced with the number of words written.
1422 */ 1424 */
1423int 1425__be32
1424nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp, 1426nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
1425 struct dentry *dentry, u32 *buffer, int *countp, u32 *bmval, 1427 struct dentry *dentry, __be32 *buffer, int *countp, u32 *bmval,
1426 struct svc_rqst *rqstp) 1428 struct svc_rqst *rqstp)
1427{ 1429{
1428 u32 bmval0 = bmval[0]; 1430 u32 bmval0 = bmval[0];
@@ -1431,12 +1433,13 @@ nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
1431 struct svc_fh tempfh; 1433 struct svc_fh tempfh;
1432 struct kstatfs statfs; 1434 struct kstatfs statfs;
1433 int buflen = *countp << 2; 1435 int buflen = *countp << 2;
1434 u32 *attrlenp; 1436 __be32 *attrlenp;
1435 u32 dummy; 1437 u32 dummy;
1436 u64 dummy64; 1438 u64 dummy64;
1437 u32 rdattr_err = 0; 1439 u32 rdattr_err = 0;
1438 u32 *p = buffer; 1440 __be32 *p = buffer;
1439 int status; 1441 __be32 status;
1442 int err;
1440 int aclsupport = 0; 1443 int aclsupport = 0;
1441 struct nfs4_acl *acl = NULL; 1444 struct nfs4_acl *acl = NULL;
1442 1445
@@ -1450,14 +1453,14 @@ nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
1450 goto out; 1453 goto out;
1451 } 1454 }
1452 1455
1453 status = vfs_getattr(exp->ex_mnt, dentry, &stat); 1456 err = vfs_getattr(exp->ex_mnt, dentry, &stat);
1454 if (status) 1457 if (err)
1455 goto out_nfserr; 1458 goto out_nfserr;
1456 if ((bmval0 & (FATTR4_WORD0_FILES_FREE | FATTR4_WORD0_FILES_TOTAL)) || 1459 if ((bmval0 & (FATTR4_WORD0_FILES_FREE | FATTR4_WORD0_FILES_TOTAL)) ||
1457 (bmval1 & (FATTR4_WORD1_SPACE_AVAIL | FATTR4_WORD1_SPACE_FREE | 1460 (bmval1 & (FATTR4_WORD1_SPACE_AVAIL | FATTR4_WORD1_SPACE_FREE |
1458 FATTR4_WORD1_SPACE_TOTAL))) { 1461 FATTR4_WORD1_SPACE_TOTAL))) {
1459 status = vfs_statfs(dentry, &statfs); 1462 err = vfs_statfs(dentry, &statfs);
1460 if (status) 1463 if (err)
1461 goto out_nfserr; 1464 goto out_nfserr;
1462 } 1465 }
1463 if ((bmval0 & (FATTR4_WORD0_FILEHANDLE | FATTR4_WORD0_FSID)) && !fhp) { 1466 if ((bmval0 & (FATTR4_WORD0_FILEHANDLE | FATTR4_WORD0_FSID)) && !fhp) {
@@ -1469,15 +1472,15 @@ nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
1469 } 1472 }
1470 if (bmval0 & (FATTR4_WORD0_ACL | FATTR4_WORD0_ACLSUPPORT 1473 if (bmval0 & (FATTR4_WORD0_ACL | FATTR4_WORD0_ACLSUPPORT
1471 | FATTR4_WORD0_SUPPORTED_ATTRS)) { 1474 | FATTR4_WORD0_SUPPORTED_ATTRS)) {
1472 status = nfsd4_get_nfs4_acl(rqstp, dentry, &acl); 1475 err = nfsd4_get_nfs4_acl(rqstp, dentry, &acl);
1473 aclsupport = (status == 0); 1476 aclsupport = (err == 0);
1474 if (bmval0 & FATTR4_WORD0_ACL) { 1477 if (bmval0 & FATTR4_WORD0_ACL) {
1475 if (status == -EOPNOTSUPP) 1478 if (err == -EOPNOTSUPP)
1476 bmval0 &= ~FATTR4_WORD0_ACL; 1479 bmval0 &= ~FATTR4_WORD0_ACL;
1477 else if (status == -EINVAL) { 1480 else if (err == -EINVAL) {
1478 status = nfserr_attrnotsupp; 1481 status = nfserr_attrnotsupp;
1479 goto out; 1482 goto out;
1480 } else if (status != 0) 1483 } else if (err != 0)
1481 goto out_nfserr; 1484 goto out_nfserr;
1482 } 1485 }
1483 } 1486 }
@@ -1817,7 +1820,7 @@ out:
1817 fh_put(&tempfh); 1820 fh_put(&tempfh);
1818 return status; 1821 return status;
1819out_nfserr: 1822out_nfserr:
1820 status = nfserrno(status); 1823 status = nfserrno(err);
1821 goto out; 1824 goto out;
1822out_resource: 1825out_resource:
1823 *countp = 0; 1826 *countp = 0;
@@ -1828,13 +1831,13 @@ out_serverfault:
1828 goto out; 1831 goto out;
1829} 1832}
1830 1833
1831static int 1834static __be32
1832nfsd4_encode_dirent_fattr(struct nfsd4_readdir *cd, 1835nfsd4_encode_dirent_fattr(struct nfsd4_readdir *cd,
1833 const char *name, int namlen, u32 *p, int *buflen) 1836 const char *name, int namlen, __be32 *p, int *buflen)
1834{ 1837{
1835 struct svc_export *exp = cd->rd_fhp->fh_export; 1838 struct svc_export *exp = cd->rd_fhp->fh_export;
1836 struct dentry *dentry; 1839 struct dentry *dentry;
1837 int nfserr; 1840 __be32 nfserr;
1838 1841
1839 dentry = lookup_one_len(name, cd->rd_fhp->fh_dentry, namlen); 1842 dentry = lookup_one_len(name, cd->rd_fhp->fh_dentry, namlen);
1840 if (IS_ERR(dentry)) 1843 if (IS_ERR(dentry))
@@ -1863,10 +1866,10 @@ out_put:
1863 return nfserr; 1866 return nfserr;
1864} 1867}
1865 1868
1866static u32 * 1869static __be32 *
1867nfsd4_encode_rdattr_error(u32 *p, int buflen, int nfserr) 1870nfsd4_encode_rdattr_error(__be32 *p, int buflen, __be32 nfserr)
1868{ 1871{
1869 u32 *attrlenp; 1872 __be32 *attrlenp;
1870 1873
1871 if (buflen < 6) 1874 if (buflen < 6)
1872 return NULL; 1875 return NULL;
@@ -1886,8 +1889,8 @@ nfsd4_encode_dirent(struct readdir_cd *ccd, const char *name, int namlen,
1886{ 1889{
1887 struct nfsd4_readdir *cd = container_of(ccd, struct nfsd4_readdir, common); 1890 struct nfsd4_readdir *cd = container_of(ccd, struct nfsd4_readdir, common);
1888 int buflen; 1891 int buflen;
1889 u32 *p = cd->buffer; 1892 __be32 *p = cd->buffer;
1890 int nfserr = nfserr_toosmall; 1893 __be32 nfserr = nfserr_toosmall;
1891 1894
1892 /* In nfsv4, "." and ".." never make it onto the wire.. */ 1895 /* In nfsv4, "." and ".." never make it onto the wire.. */
1893 if (name && isdotent(name, namlen)) { 1896 if (name && isdotent(name, namlen)) {
@@ -1943,7 +1946,7 @@ fail:
1943} 1946}
1944 1947
1945static void 1948static void
1946nfsd4_encode_access(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_access *access) 1949nfsd4_encode_access(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_access *access)
1947{ 1950{
1948 ENCODE_HEAD; 1951 ENCODE_HEAD;
1949 1952
@@ -1956,7 +1959,7 @@ nfsd4_encode_access(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_acc
1956} 1959}
1957 1960
1958static void 1961static void
1959nfsd4_encode_close(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_close *close) 1962nfsd4_encode_close(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_close *close)
1960{ 1963{
1961 ENCODE_SEQID_OP_HEAD; 1964 ENCODE_SEQID_OP_HEAD;
1962 1965
@@ -1971,7 +1974,7 @@ nfsd4_encode_close(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_clos
1971 1974
1972 1975
1973static void 1976static void
1974nfsd4_encode_commit(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_commit *commit) 1977nfsd4_encode_commit(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_commit *commit)
1975{ 1978{
1976 ENCODE_HEAD; 1979 ENCODE_HEAD;
1977 1980
@@ -1983,7 +1986,7 @@ nfsd4_encode_commit(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_com
1983} 1986}
1984 1987
1985static void 1988static void
1986nfsd4_encode_create(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_create *create) 1989nfsd4_encode_create(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_create *create)
1987{ 1990{
1988 ENCODE_HEAD; 1991 ENCODE_HEAD;
1989 1992
@@ -1997,8 +2000,8 @@ nfsd4_encode_create(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_cre
1997 } 2000 }
1998} 2001}
1999 2002
2000static int 2003static __be32
2001nfsd4_encode_getattr(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_getattr *getattr) 2004nfsd4_encode_getattr(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_getattr *getattr)
2002{ 2005{
2003 struct svc_fh *fhp = getattr->ga_fhp; 2006 struct svc_fh *fhp = getattr->ga_fhp;
2004 int buflen; 2007 int buflen;
@@ -2016,7 +2019,7 @@ nfsd4_encode_getattr(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_ge
2016} 2019}
2017 2020
2018static void 2021static void
2019nfsd4_encode_getfh(struct nfsd4_compoundres *resp, int nfserr, struct svc_fh *fhp) 2022nfsd4_encode_getfh(struct nfsd4_compoundres *resp, __be32 nfserr, struct svc_fh *fhp)
2020{ 2023{
2021 unsigned int len; 2024 unsigned int len;
2022 ENCODE_HEAD; 2025 ENCODE_HEAD;
@@ -2056,7 +2059,7 @@ nfsd4_encode_lock_denied(struct nfsd4_compoundres *resp, struct nfsd4_lock_denie
2056} 2059}
2057 2060
2058static void 2061static void
2059nfsd4_encode_lock(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_lock *lock) 2062nfsd4_encode_lock(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_lock *lock)
2060{ 2063{
2061 ENCODE_SEQID_OP_HEAD; 2064 ENCODE_SEQID_OP_HEAD;
2062 2065
@@ -2072,14 +2075,14 @@ nfsd4_encode_lock(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_lock
2072} 2075}
2073 2076
2074static void 2077static void
2075nfsd4_encode_lockt(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_lockt *lockt) 2078nfsd4_encode_lockt(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_lockt *lockt)
2076{ 2079{
2077 if (nfserr == nfserr_denied) 2080 if (nfserr == nfserr_denied)
2078 nfsd4_encode_lock_denied(resp, &lockt->lt_denied); 2081 nfsd4_encode_lock_denied(resp, &lockt->lt_denied);
2079} 2082}
2080 2083
2081static void 2084static void
2082nfsd4_encode_locku(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_locku *locku) 2085nfsd4_encode_locku(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_locku *locku)
2083{ 2086{
2084 ENCODE_SEQID_OP_HEAD; 2087 ENCODE_SEQID_OP_HEAD;
2085 2088
@@ -2095,7 +2098,7 @@ nfsd4_encode_locku(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_lock
2095 2098
2096 2099
2097static void 2100static void
2098nfsd4_encode_link(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_link *link) 2101nfsd4_encode_link(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_link *link)
2099{ 2102{
2100 ENCODE_HEAD; 2103 ENCODE_HEAD;
2101 2104
@@ -2108,7 +2111,7 @@ nfsd4_encode_link(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_link
2108 2111
2109 2112
2110static void 2113static void
2111nfsd4_encode_open(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_open *open) 2114nfsd4_encode_open(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_open *open)
2112{ 2115{
2113 ENCODE_SEQID_OP_HEAD; 2116 ENCODE_SEQID_OP_HEAD;
2114 2117
@@ -2173,7 +2176,7 @@ out:
2173} 2176}
2174 2177
2175static void 2178static void
2176nfsd4_encode_open_confirm(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_open_confirm *oc) 2179nfsd4_encode_open_confirm(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_open_confirm *oc)
2177{ 2180{
2178 ENCODE_SEQID_OP_HEAD; 2181 ENCODE_SEQID_OP_HEAD;
2179 2182
@@ -2188,7 +2191,7 @@ nfsd4_encode_open_confirm(struct nfsd4_compoundres *resp, int nfserr, struct nfs
2188} 2191}
2189 2192
2190static void 2193static void
2191nfsd4_encode_open_downgrade(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_open_downgrade *od) 2194nfsd4_encode_open_downgrade(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_open_downgrade *od)
2192{ 2195{
2193 ENCODE_SEQID_OP_HEAD; 2196 ENCODE_SEQID_OP_HEAD;
2194 2197
@@ -2202,8 +2205,8 @@ nfsd4_encode_open_downgrade(struct nfsd4_compoundres *resp, int nfserr, struct n
2202 ENCODE_SEQID_OP_TAIL(od->od_stateowner); 2205 ENCODE_SEQID_OP_TAIL(od->od_stateowner);
2203} 2206}
2204 2207
2205static int 2208static __be32
2206nfsd4_encode_read(struct nfsd4_compoundres *resp, int nfserr, 2209nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr,
2207 struct nfsd4_read *read) 2210 struct nfsd4_read *read)
2208{ 2211{
2209 u32 eof; 2212 u32 eof;
@@ -2267,8 +2270,8 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, int nfserr,
2267 return 0; 2270 return 0;
2268} 2271}
2269 2272
2270static int 2273static __be32
2271nfsd4_encode_readlink(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_readlink *readlink) 2274nfsd4_encode_readlink(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_readlink *readlink)
2272{ 2275{
2273 int maxcount; 2276 int maxcount;
2274 char *page; 2277 char *page;
@@ -2315,12 +2318,12 @@ nfsd4_encode_readlink(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_r
2315 return 0; 2318 return 0;
2316} 2319}
2317 2320
2318static int 2321static __be32
2319nfsd4_encode_readdir(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_readdir *readdir) 2322nfsd4_encode_readdir(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_readdir *readdir)
2320{ 2323{
2321 int maxcount; 2324 int maxcount;
2322 loff_t offset; 2325 loff_t offset;
2323 u32 *page, *savep, *tailbase; 2326 __be32 *page, *savep, *tailbase;
2324 ENCODE_HEAD; 2327 ENCODE_HEAD;
2325 2328
2326 if (nfserr) 2329 if (nfserr)
@@ -2395,7 +2398,7 @@ err_no_verf:
2395} 2398}
2396 2399
2397static void 2400static void
2398nfsd4_encode_remove(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_remove *remove) 2401nfsd4_encode_remove(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_remove *remove)
2399{ 2402{
2400 ENCODE_HEAD; 2403 ENCODE_HEAD;
2401 2404
@@ -2407,7 +2410,7 @@ nfsd4_encode_remove(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_rem
2407} 2410}
2408 2411
2409static void 2412static void
2410nfsd4_encode_rename(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_rename *rename) 2413nfsd4_encode_rename(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_rename *rename)
2411{ 2414{
2412 ENCODE_HEAD; 2415 ENCODE_HEAD;
2413 2416
@@ -2424,7 +2427,7 @@ nfsd4_encode_rename(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_ren
2424 * regardless of the error status. 2427 * regardless of the error status.
2425 */ 2428 */
2426static void 2429static void
2427nfsd4_encode_setattr(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_setattr *setattr) 2430nfsd4_encode_setattr(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_setattr *setattr)
2428{ 2431{
2429 ENCODE_HEAD; 2432 ENCODE_HEAD;
2430 2433
@@ -2443,7 +2446,7 @@ nfsd4_encode_setattr(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_se
2443} 2446}
2444 2447
2445static void 2448static void
2446nfsd4_encode_setclientid(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_setclientid *scd) 2449nfsd4_encode_setclientid(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_setclientid *scd)
2447{ 2450{
2448 ENCODE_HEAD; 2451 ENCODE_HEAD;
2449 2452
@@ -2462,7 +2465,7 @@ nfsd4_encode_setclientid(struct nfsd4_compoundres *resp, int nfserr, struct nfsd
2462} 2465}
2463 2466
2464static void 2467static void
2465nfsd4_encode_write(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_write *write) 2468nfsd4_encode_write(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_write *write)
2466{ 2469{
2467 ENCODE_HEAD; 2470 ENCODE_HEAD;
2468 2471
@@ -2478,7 +2481,7 @@ nfsd4_encode_write(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_writ
2478void 2481void
2479nfsd4_encode_operation(struct nfsd4_compoundres *resp, struct nfsd4_op *op) 2482nfsd4_encode_operation(struct nfsd4_compoundres *resp, struct nfsd4_op *op)
2480{ 2483{
2481 u32 *statp; 2484 __be32 *statp;
2482 ENCODE_HEAD; 2485 ENCODE_HEAD;
2483 2486
2484 RESERVE_SPACE(8); 2487 RESERVE_SPACE(8);
@@ -2616,7 +2619,7 @@ nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op)
2616 */ 2619 */
2617 2620
2618int 2621int
2619nfs4svc_encode_voidres(struct svc_rqst *rqstp, u32 *p, void *dummy) 2622nfs4svc_encode_voidres(struct svc_rqst *rqstp, __be32 *p, void *dummy)
2620{ 2623{
2621 return xdr_ressize_check(rqstp, p); 2624 return xdr_ressize_check(rqstp, p);
2622} 2625}
@@ -2638,9 +2641,9 @@ void nfsd4_release_compoundargs(struct nfsd4_compoundargs *args)
2638} 2641}
2639 2642
2640int 2643int
2641nfs4svc_decode_compoundargs(struct svc_rqst *rqstp, u32 *p, struct nfsd4_compoundargs *args) 2644nfs4svc_decode_compoundargs(struct svc_rqst *rqstp, __be32 *p, struct nfsd4_compoundargs *args)
2642{ 2645{
2643 int status; 2646 __be32 status;
2644 2647
2645 args->p = p; 2648 args->p = p;
2646 args->end = rqstp->rq_arg.head[0].iov_base + rqstp->rq_arg.head[0].iov_len; 2649 args->end = rqstp->rq_arg.head[0].iov_base + rqstp->rq_arg.head[0].iov_len;
@@ -2659,7 +2662,7 @@ nfs4svc_decode_compoundargs(struct svc_rqst *rqstp, u32 *p, struct nfsd4_compoun
2659} 2662}
2660 2663
2661int 2664int
2662nfs4svc_encode_compoundres(struct svc_rqst *rqstp, u32 *p, struct nfsd4_compoundres *resp) 2665nfs4svc_encode_compoundres(struct svc_rqst *rqstp, __be32 *p, struct nfsd4_compoundres *resp)
2663{ 2666{
2664 /* 2667 /*
2665 * All that remains is to write the tag and operation count... 2668 * All that remains is to write the tag and operation count...
diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
index fdf7cf3dfadc..6100bbe27432 100644
--- a/fs/nfsd/nfscache.c
+++ b/fs/nfsd/nfscache.c
@@ -29,7 +29,7 @@
29 */ 29 */
30#define CACHESIZE 1024 30#define CACHESIZE 1024
31#define HASHSIZE 64 31#define HASHSIZE 64
32#define REQHASH(xid) ((((xid) >> 24) ^ (xid)) & (HASHSIZE-1)) 32#define REQHASH(xid) (((((__force __u32)xid) >> 24) ^ ((__force __u32)xid)) & (HASHSIZE-1))
33 33
34static struct hlist_head * hash_list; 34static struct hlist_head * hash_list;
35static struct list_head lru_head; 35static struct list_head lru_head;
@@ -127,8 +127,8 @@ nfsd_cache_lookup(struct svc_rqst *rqstp, int type)
127 struct hlist_node *hn; 127 struct hlist_node *hn;
128 struct hlist_head *rh; 128 struct hlist_head *rh;
129 struct svc_cacherep *rp; 129 struct svc_cacherep *rp;
130 u32 xid = rqstp->rq_xid, 130 __be32 xid = rqstp->rq_xid;
131 proto = rqstp->rq_prot, 131 u32 proto = rqstp->rq_prot,
132 vers = rqstp->rq_vers, 132 vers = rqstp->rq_vers,
133 proc = rqstp->rq_proc; 133 proc = rqstp->rq_proc;
134 unsigned long age; 134 unsigned long age;
@@ -258,7 +258,7 @@ found_entry:
258 * In this case, nfsd_cache_update is called with statp == NULL. 258 * In this case, nfsd_cache_update is called with statp == NULL.
259 */ 259 */
260void 260void
261nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, u32 *statp) 261nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
262{ 262{
263 struct svc_cacherep *rp; 263 struct svc_cacherep *rp;
264 struct kvec *resv = &rqstp->rq_res.head[0], *cachv; 264 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
index 501d83884530..727ab3bd450d 100644
--- a/fs/nfsd/nfsfh.c
+++ b/fs/nfsd/nfsfh.c
@@ -76,7 +76,7 @@ static int nfsd_acceptable(void *expv, struct dentry *dentry)
76 * comment in the NFSv3 spec says this is incorrect (implementation notes for 76 * comment in the NFSv3 spec says this is incorrect (implementation notes for
77 * the write call). 77 * the write call).
78 */ 78 */
79static inline int 79static inline __be32
80nfsd_mode_check(struct svc_rqst *rqstp, umode_t mode, int type) 80nfsd_mode_check(struct svc_rqst *rqstp, umode_t mode, int type)
81{ 81{
82 /* Type can be negative when creating hardlinks - not to a dir */ 82 /* Type can be negative when creating hardlinks - not to a dir */
@@ -110,13 +110,13 @@ nfsd_mode_check(struct svc_rqst *rqstp, umode_t mode, int type)
110 * This is only called at the start of an nfsproc call, so fhp points to 110 * This is only called at the start of an nfsproc call, so fhp points to
111 * a svc_fh which is all 0 except for the over-the-wire file handle. 111 * a svc_fh which is all 0 except for the over-the-wire file handle.
112 */ 112 */
113u32 113__be32
114fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access) 114fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access)
115{ 115{
116 struct knfsd_fh *fh = &fhp->fh_handle; 116 struct knfsd_fh *fh = &fhp->fh_handle;
117 struct svc_export *exp = NULL; 117 struct svc_export *exp = NULL;
118 struct dentry *dentry; 118 struct dentry *dentry;
119 u32 error = 0; 119 __be32 error = 0;
120 120
121 dprintk("nfsd: fh_verify(%s)\n", SVCFH_fmt(fhp)); 121 dprintk("nfsd: fh_verify(%s)\n", SVCFH_fmt(fhp));
122 122
@@ -315,7 +315,7 @@ static inline void _fh_update_old(struct dentry *dentry,
315 fh->ofh_dirino = 0; 315 fh->ofh_dirino = 0;
316} 316}
317 317
318int 318__be32
319fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry, struct svc_fh *ref_fh) 319fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry, struct svc_fh *ref_fh)
320{ 320{
321 /* ref_fh is a reference file handle. 321 /* ref_fh is a reference file handle.
@@ -451,7 +451,7 @@ fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry, st
451 * Update file handle information after changing a dentry. 451 * Update file handle information after changing a dentry.
452 * This is only called by nfsd_create, nfsd_create_v3 and nfsd_proc_create 452 * This is only called by nfsd_create, nfsd_create_v3 and nfsd_proc_create
453 */ 453 */
454int 454__be32
455fh_update(struct svc_fh *fhp) 455fh_update(struct svc_fh *fhp)
456{ 456{
457 struct dentry *dentry; 457 struct dentry *dentry;
diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c
index 9ee1dab5d44a..ec983b777680 100644
--- a/fs/nfsd/nfsproc.c
+++ b/fs/nfsd/nfsproc.c
@@ -30,22 +30,22 @@ typedef struct svc_buf svc_buf;
30#define NFSDDBG_FACILITY NFSDDBG_PROC 30#define NFSDDBG_FACILITY NFSDDBG_PROC
31 31
32 32
33static int 33static __be32
34nfsd_proc_null(struct svc_rqst *rqstp, void *argp, void *resp) 34nfsd_proc_null(struct svc_rqst *rqstp, void *argp, void *resp)
35{ 35{
36 return nfs_ok; 36 return nfs_ok;
37} 37}
38 38
39static int 39static __be32
40nfsd_return_attrs(int err, struct nfsd_attrstat *resp) 40nfsd_return_attrs(__be32 err, struct nfsd_attrstat *resp)
41{ 41{
42 if (err) return err; 42 if (err) return err;
43 return nfserrno(vfs_getattr(resp->fh.fh_export->ex_mnt, 43 return nfserrno(vfs_getattr(resp->fh.fh_export->ex_mnt,
44 resp->fh.fh_dentry, 44 resp->fh.fh_dentry,
45 &resp->stat)); 45 &resp->stat));
46} 46}
47static int 47static __be32
48nfsd_return_dirop(int err, struct nfsd_diropres *resp) 48nfsd_return_dirop(__be32 err, struct nfsd_diropres *resp)
49{ 49{
50 if (err) return err; 50 if (err) return err;
51 return nfserrno(vfs_getattr(resp->fh.fh_export->ex_mnt, 51 return nfserrno(vfs_getattr(resp->fh.fh_export->ex_mnt,
@@ -56,11 +56,11 @@ nfsd_return_dirop(int err, struct nfsd_diropres *resp)
56 * Get a file's attributes 56 * Get a file's attributes
57 * N.B. After this call resp->fh needs an fh_put 57 * N.B. After this call resp->fh needs an fh_put
58 */ 58 */
59static int 59static __be32
60nfsd_proc_getattr(struct svc_rqst *rqstp, struct nfsd_fhandle *argp, 60nfsd_proc_getattr(struct svc_rqst *rqstp, struct nfsd_fhandle *argp,
61 struct nfsd_attrstat *resp) 61 struct nfsd_attrstat *resp)
62{ 62{
63 int nfserr; 63 __be32 nfserr;
64 dprintk("nfsd: GETATTR %s\n", SVCFH_fmt(&argp->fh)); 64 dprintk("nfsd: GETATTR %s\n", SVCFH_fmt(&argp->fh));
65 65
66 fh_copy(&resp->fh, &argp->fh); 66 fh_copy(&resp->fh, &argp->fh);
@@ -72,11 +72,11 @@ nfsd_proc_getattr(struct svc_rqst *rqstp, struct nfsd_fhandle *argp,
72 * Set a file's attributes 72 * Set a file's attributes
73 * N.B. After this call resp->fh needs an fh_put 73 * N.B. After this call resp->fh needs an fh_put
74 */ 74 */
75static int 75static __be32
76nfsd_proc_setattr(struct svc_rqst *rqstp, struct nfsd_sattrargs *argp, 76nfsd_proc_setattr(struct svc_rqst *rqstp, struct nfsd_sattrargs *argp,
77 struct nfsd_attrstat *resp) 77 struct nfsd_attrstat *resp)
78{ 78{
79 int nfserr; 79 __be32 nfserr;
80 dprintk("nfsd: SETATTR %s, valid=%x, size=%ld\n", 80 dprintk("nfsd: SETATTR %s, valid=%x, size=%ld\n",
81 SVCFH_fmt(&argp->fh), 81 SVCFH_fmt(&argp->fh),
82 argp->attrs.ia_valid, (long) argp->attrs.ia_size); 82 argp->attrs.ia_valid, (long) argp->attrs.ia_size);
@@ -92,11 +92,11 @@ nfsd_proc_setattr(struct svc_rqst *rqstp, struct nfsd_sattrargs *argp,
92 * doesn't exist yet. 92 * doesn't exist yet.
93 * N.B. After this call resp->fh needs an fh_put 93 * N.B. After this call resp->fh needs an fh_put
94 */ 94 */
95static int 95static __be32
96nfsd_proc_lookup(struct svc_rqst *rqstp, struct nfsd_diropargs *argp, 96nfsd_proc_lookup(struct svc_rqst *rqstp, struct nfsd_diropargs *argp,
97 struct nfsd_diropres *resp) 97 struct nfsd_diropres *resp)
98{ 98{
99 int nfserr; 99 __be32 nfserr;
100 100
101 dprintk("nfsd: LOOKUP %s %.*s\n", 101 dprintk("nfsd: LOOKUP %s %.*s\n",
102 SVCFH_fmt(&argp->fh), argp->len, argp->name); 102 SVCFH_fmt(&argp->fh), argp->len, argp->name);
@@ -112,11 +112,11 @@ nfsd_proc_lookup(struct svc_rqst *rqstp, struct nfsd_diropargs *argp,
112/* 112/*
113 * Read a symlink. 113 * Read a symlink.
114 */ 114 */
115static int 115static __be32
116nfsd_proc_readlink(struct svc_rqst *rqstp, struct nfsd_readlinkargs *argp, 116nfsd_proc_readlink(struct svc_rqst *rqstp, struct nfsd_readlinkargs *argp,
117 struct nfsd_readlinkres *resp) 117 struct nfsd_readlinkres *resp)
118{ 118{
119 int nfserr; 119 __be32 nfserr;
120 120
121 dprintk("nfsd: READLINK %s\n", SVCFH_fmt(&argp->fh)); 121 dprintk("nfsd: READLINK %s\n", SVCFH_fmt(&argp->fh));
122 122
@@ -132,11 +132,11 @@ nfsd_proc_readlink(struct svc_rqst *rqstp, struct nfsd_readlinkargs *argp,
132 * Read a portion of a file. 132 * Read a portion of a file.
133 * N.B. After this call resp->fh needs an fh_put 133 * N.B. After this call resp->fh needs an fh_put
134 */ 134 */
135static int 135static __be32
136nfsd_proc_read(struct svc_rqst *rqstp, struct nfsd_readargs *argp, 136nfsd_proc_read(struct svc_rqst *rqstp, struct nfsd_readargs *argp,
137 struct nfsd_readres *resp) 137 struct nfsd_readres *resp)
138{ 138{
139 int nfserr; 139 __be32 nfserr;
140 140
141 dprintk("nfsd: READ %s %d bytes at %d\n", 141 dprintk("nfsd: READ %s %d bytes at %d\n",
142 SVCFH_fmt(&argp->fh), 142 SVCFH_fmt(&argp->fh),
@@ -172,11 +172,11 @@ nfsd_proc_read(struct svc_rqst *rqstp, struct nfsd_readargs *argp,
172 * Write data to a file 172 * Write data to a file
173 * N.B. After this call resp->fh needs an fh_put 173 * N.B. After this call resp->fh needs an fh_put
174 */ 174 */
175static int 175static __be32
176nfsd_proc_write(struct svc_rqst *rqstp, struct nfsd_writeargs *argp, 176nfsd_proc_write(struct svc_rqst *rqstp, struct nfsd_writeargs *argp,
177 struct nfsd_attrstat *resp) 177 struct nfsd_attrstat *resp)
178{ 178{
179 int nfserr; 179 __be32 nfserr;
180 int stable = 1; 180 int stable = 1;
181 181
182 dprintk("nfsd: WRITE %s %d bytes at %d\n", 182 dprintk("nfsd: WRITE %s %d bytes at %d\n",
@@ -197,7 +197,7 @@ nfsd_proc_write(struct svc_rqst *rqstp, struct nfsd_writeargs *argp,
197 * and the actual create() call in compliance with VFS protocols. 197 * and the actual create() call in compliance with VFS protocols.
198 * N.B. After this call _both_ argp->fh and resp->fh need an fh_put 198 * N.B. After this call _both_ argp->fh and resp->fh need an fh_put
199 */ 199 */
200static int 200static __be32
201nfsd_proc_create(struct svc_rqst *rqstp, struct nfsd_createargs *argp, 201nfsd_proc_create(struct svc_rqst *rqstp, struct nfsd_createargs *argp,
202 struct nfsd_diropres *resp) 202 struct nfsd_diropres *resp)
203{ 203{
@@ -206,7 +206,8 @@ nfsd_proc_create(struct svc_rqst *rqstp, struct nfsd_createargs *argp,
206 struct iattr *attr = &argp->attrs; 206 struct iattr *attr = &argp->attrs;
207 struct inode *inode; 207 struct inode *inode;
208 struct dentry *dchild; 208 struct dentry *dchild;
209 int nfserr, type, mode; 209 int type, mode;
210 __be32 nfserr;
210 dev_t rdev = 0, wanted = new_decode_dev(attr->ia_size); 211 dev_t rdev = 0, wanted = new_decode_dev(attr->ia_size);
211 212
212 dprintk("nfsd: CREATE %s %.*s\n", 213 dprintk("nfsd: CREATE %s %.*s\n",
@@ -348,11 +349,11 @@ done:
348 return nfsd_return_dirop(nfserr, resp); 349 return nfsd_return_dirop(nfserr, resp);
349} 350}
350 351
351static int 352static __be32
352nfsd_proc_remove(struct svc_rqst *rqstp, struct nfsd_diropargs *argp, 353nfsd_proc_remove(struct svc_rqst *rqstp, struct nfsd_diropargs *argp,
353 void *resp) 354 void *resp)
354{ 355{
355 int nfserr; 356 __be32 nfserr;
356 357
357 dprintk("nfsd: REMOVE %s %.*s\n", SVCFH_fmt(&argp->fh), 358 dprintk("nfsd: REMOVE %s %.*s\n", SVCFH_fmt(&argp->fh),
358 argp->len, argp->name); 359 argp->len, argp->name);
@@ -363,11 +364,11 @@ nfsd_proc_remove(struct svc_rqst *rqstp, struct nfsd_diropargs *argp,
363 return nfserr; 364 return nfserr;
364} 365}
365 366
366static int 367static __be32
367nfsd_proc_rename(struct svc_rqst *rqstp, struct nfsd_renameargs *argp, 368nfsd_proc_rename(struct svc_rqst *rqstp, struct nfsd_renameargs *argp,
368 void *resp) 369 void *resp)
369{ 370{
370 int nfserr; 371 __be32 nfserr;
371 372
372 dprintk("nfsd: RENAME %s %.*s -> \n", 373 dprintk("nfsd: RENAME %s %.*s -> \n",
373 SVCFH_fmt(&argp->ffh), argp->flen, argp->fname); 374 SVCFH_fmt(&argp->ffh), argp->flen, argp->fname);
@@ -381,11 +382,11 @@ nfsd_proc_rename(struct svc_rqst *rqstp, struct nfsd_renameargs *argp,
381 return nfserr; 382 return nfserr;
382} 383}
383 384
384static int 385static __be32
385nfsd_proc_link(struct svc_rqst *rqstp, struct nfsd_linkargs *argp, 386nfsd_proc_link(struct svc_rqst *rqstp, struct nfsd_linkargs *argp,
386 void *resp) 387 void *resp)
387{ 388{
388 int nfserr; 389 __be32 nfserr;
389 390
390 dprintk("nfsd: LINK %s ->\n", 391 dprintk("nfsd: LINK %s ->\n",
391 SVCFH_fmt(&argp->ffh)); 392 SVCFH_fmt(&argp->ffh));
@@ -401,12 +402,12 @@ nfsd_proc_link(struct svc_rqst *rqstp, struct nfsd_linkargs *argp,
401 return nfserr; 402 return nfserr;
402} 403}
403 404
404static int 405static __be32
405nfsd_proc_symlink(struct svc_rqst *rqstp, struct nfsd_symlinkargs *argp, 406nfsd_proc_symlink(struct svc_rqst *rqstp, struct nfsd_symlinkargs *argp,
406 void *resp) 407 void *resp)
407{ 408{
408 struct svc_fh newfh; 409 struct svc_fh newfh;
409 int nfserr; 410 __be32 nfserr;
410 411
411 dprintk("nfsd: SYMLINK %s %.*s -> %.*s\n", 412 dprintk("nfsd: SYMLINK %s %.*s -> %.*s\n",
412 SVCFH_fmt(&argp->ffh), argp->flen, argp->fname, 413 SVCFH_fmt(&argp->ffh), argp->flen, argp->fname,
@@ -430,11 +431,11 @@ nfsd_proc_symlink(struct svc_rqst *rqstp, struct nfsd_symlinkargs *argp,
430 * Make directory. This operation is not idempotent. 431 * Make directory. This operation is not idempotent.
431 * N.B. After this call resp->fh needs an fh_put 432 * N.B. After this call resp->fh needs an fh_put
432 */ 433 */
433static int 434static __be32
434nfsd_proc_mkdir(struct svc_rqst *rqstp, struct nfsd_createargs *argp, 435nfsd_proc_mkdir(struct svc_rqst *rqstp, struct nfsd_createargs *argp,
435 struct nfsd_diropres *resp) 436 struct nfsd_diropres *resp)
436{ 437{
437 int nfserr; 438 __be32 nfserr;
438 439
439 dprintk("nfsd: MKDIR %s %.*s\n", SVCFH_fmt(&argp->fh), argp->len, argp->name); 440 dprintk("nfsd: MKDIR %s %.*s\n", SVCFH_fmt(&argp->fh), argp->len, argp->name);
440 441
@@ -454,11 +455,11 @@ nfsd_proc_mkdir(struct svc_rqst *rqstp, struct nfsd_createargs *argp,
454/* 455/*
455 * Remove a directory 456 * Remove a directory
456 */ 457 */
457static int 458static __be32
458nfsd_proc_rmdir(struct svc_rqst *rqstp, struct nfsd_diropargs *argp, 459nfsd_proc_rmdir(struct svc_rqst *rqstp, struct nfsd_diropargs *argp,
459 void *resp) 460 void *resp)
460{ 461{
461 int nfserr; 462 __be32 nfserr;
462 463
463 dprintk("nfsd: RMDIR %s %.*s\n", SVCFH_fmt(&argp->fh), argp->len, argp->name); 464 dprintk("nfsd: RMDIR %s %.*s\n", SVCFH_fmt(&argp->fh), argp->len, argp->name);
464 465
@@ -470,11 +471,12 @@ nfsd_proc_rmdir(struct svc_rqst *rqstp, struct nfsd_diropargs *argp,
470/* 471/*
471 * Read a portion of a directory. 472 * Read a portion of a directory.
472 */ 473 */
473static int 474static __be32
474nfsd_proc_readdir(struct svc_rqst *rqstp, struct nfsd_readdirargs *argp, 475nfsd_proc_readdir(struct svc_rqst *rqstp, struct nfsd_readdirargs *argp,
475 struct nfsd_readdirres *resp) 476 struct nfsd_readdirres *resp)
476{ 477{
477 int nfserr, count; 478 int count;
479 __be32 nfserr;
478 loff_t offset; 480 loff_t offset;
479 481
480 dprintk("nfsd: READDIR %s %d bytes at %d\n", 482 dprintk("nfsd: READDIR %s %d bytes at %d\n",
@@ -509,11 +511,11 @@ nfsd_proc_readdir(struct svc_rqst *rqstp, struct nfsd_readdirargs *argp,
509/* 511/*
510 * Get file system info 512 * Get file system info
511 */ 513 */
512static int 514static __be32
513nfsd_proc_statfs(struct svc_rqst * rqstp, struct nfsd_fhandle *argp, 515nfsd_proc_statfs(struct svc_rqst * rqstp, struct nfsd_fhandle *argp,
514 struct nfsd_statfsres *resp) 516 struct nfsd_statfsres *resp)
515{ 517{
516 int nfserr; 518 __be32 nfserr;
517 519
518 dprintk("nfsd: STATFS %s\n", SVCFH_fmt(&argp->fh)); 520 dprintk("nfsd: STATFS %s\n", SVCFH_fmt(&argp->fh));
519 521
@@ -579,11 +581,11 @@ struct svc_version nfsd_version2 = {
579/* 581/*
580 * Map errnos to NFS errnos. 582 * Map errnos to NFS errnos.
581 */ 583 */
582int 584__be32
583nfserrno (int errno) 585nfserrno (int errno)
584{ 586{
585 static struct { 587 static struct {
586 int nfserr; 588 __be32 nfserr;
587 int syserr; 589 int syserr;
588 } nfs_errtbl[] = { 590 } nfs_errtbl[] = {
589 { nfs_ok, 0 }, 591 { nfs_ok, 0 },
@@ -615,11 +617,10 @@ nfserrno (int errno)
615 { nfserr_badname, -ESRCH }, 617 { nfserr_badname, -ESRCH },
616 { nfserr_io, -ETXTBSY }, 618 { nfserr_io, -ETXTBSY },
617 { nfserr_notsupp, -EOPNOTSUPP }, 619 { nfserr_notsupp, -EOPNOTSUPP },
618 { -1, -EIO }
619 }; 620 };
620 int i; 621 int i;
621 622
622 for (i = 0; nfs_errtbl[i].nfserr != -1; i++) { 623 for (i = 0; i < ARRAY_SIZE(nfs_errtbl); i++) {
623 if (nfs_errtbl[i].syserr == errno) 624 if (nfs_errtbl[i].syserr == errno)
624 return nfs_errtbl[i].nfserr; 625 return nfs_errtbl[i].nfserr;
625 } 626 }
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index 013b38996e64..0aaccb03bf76 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -491,12 +491,12 @@ out:
491} 491}
492 492
493int 493int
494nfsd_dispatch(struct svc_rqst *rqstp, u32 *statp) 494nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp)
495{ 495{
496 struct svc_procedure *proc; 496 struct svc_procedure *proc;
497 kxdrproc_t xdr; 497 kxdrproc_t xdr;
498 u32 nfserr; 498 __be32 nfserr;
499 u32 *nfserrp; 499 __be32 *nfserrp;
500 500
501 dprintk("nfsd_dispatch: vers %d proc %d\n", 501 dprintk("nfsd_dispatch: vers %d proc %d\n",
502 rqstp->rq_vers, rqstp->rq_proc); 502 rqstp->rq_vers, rqstp->rq_proc);
@@ -515,7 +515,7 @@ nfsd_dispatch(struct svc_rqst *rqstp, u32 *statp)
515 515
516 /* Decode arguments */ 516 /* Decode arguments */
517 xdr = proc->pc_decode; 517 xdr = proc->pc_decode;
518 if (xdr && !xdr(rqstp, (u32*)rqstp->rq_arg.head[0].iov_base, 518 if (xdr && !xdr(rqstp, (__be32*)rqstp->rq_arg.head[0].iov_base,
519 rqstp->rq_argp)) { 519 rqstp->rq_argp)) {
520 dprintk("nfsd: failed to decode arguments!\n"); 520 dprintk("nfsd: failed to decode arguments!\n");
521 nfsd_cache_update(rqstp, RC_NOCACHE, NULL); 521 nfsd_cache_update(rqstp, RC_NOCACHE, NULL);
@@ -528,7 +528,7 @@ nfsd_dispatch(struct svc_rqst *rqstp, u32 *statp)
528 */ 528 */
529 nfserrp = rqstp->rq_res.head[0].iov_base 529 nfserrp = rqstp->rq_res.head[0].iov_base
530 + rqstp->rq_res.head[0].iov_len; 530 + rqstp->rq_res.head[0].iov_len;
531 rqstp->rq_res.head[0].iov_len += sizeof(u32); 531 rqstp->rq_res.head[0].iov_len += sizeof(__be32);
532 532
533 /* Now call the procedure handler, and encode NFS status. */ 533 /* Now call the procedure handler, and encode NFS status. */
534 nfserr = proc->pc_func(rqstp, rqstp->rq_argp, rqstp->rq_resp); 534 nfserr = proc->pc_func(rqstp, rqstp->rq_argp, rqstp->rq_resp);
diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c
index 1135c0d14557..56ebb1443e0e 100644
--- a/fs/nfsd/nfsxdr.c
+++ b/fs/nfsd/nfsxdr.c
@@ -37,8 +37,8 @@ static u32 nfs_ftypes[] = {
37/* 37/*
38 * XDR functions for basic NFS types 38 * XDR functions for basic NFS types
39 */ 39 */
40static u32 * 40static __be32 *
41decode_fh(u32 *p, struct svc_fh *fhp) 41decode_fh(__be32 *p, struct svc_fh *fhp)
42{ 42{
43 fh_init(fhp, NFS_FHSIZE); 43 fh_init(fhp, NFS_FHSIZE);
44 memcpy(&fhp->fh_handle.fh_base, p, NFS_FHSIZE); 44 memcpy(&fhp->fh_handle.fh_base, p, NFS_FHSIZE);
@@ -50,13 +50,13 @@ decode_fh(u32 *p, struct svc_fh *fhp)
50} 50}
51 51
52/* Helper function for NFSv2 ACL code */ 52/* Helper function for NFSv2 ACL code */
53u32 *nfs2svc_decode_fh(u32 *p, struct svc_fh *fhp) 53__be32 *nfs2svc_decode_fh(__be32 *p, struct svc_fh *fhp)
54{ 54{
55 return decode_fh(p, fhp); 55 return decode_fh(p, fhp);
56} 56}
57 57
58static inline u32 * 58static inline __be32 *
59encode_fh(u32 *p, struct svc_fh *fhp) 59encode_fh(__be32 *p, struct svc_fh *fhp)
60{ 60{
61 memcpy(p, &fhp->fh_handle.fh_base, NFS_FHSIZE); 61 memcpy(p, &fhp->fh_handle.fh_base, NFS_FHSIZE);
62 return p + (NFS_FHSIZE>> 2); 62 return p + (NFS_FHSIZE>> 2);
@@ -66,8 +66,8 @@ encode_fh(u32 *p, struct svc_fh *fhp)
66 * Decode a file name and make sure that the path contains 66 * Decode a file name and make sure that the path contains
67 * no slashes or null bytes. 67 * no slashes or null bytes.
68 */ 68 */
69static inline u32 * 69static inline __be32 *
70decode_filename(u32 *p, char **namp, int *lenp) 70decode_filename(__be32 *p, char **namp, int *lenp)
71{ 71{
72 char *name; 72 char *name;
73 int i; 73 int i;
@@ -82,8 +82,8 @@ decode_filename(u32 *p, char **namp, int *lenp)
82 return p; 82 return p;
83} 83}
84 84
85static inline u32 * 85static inline __be32 *
86decode_pathname(u32 *p, char **namp, int *lenp) 86decode_pathname(__be32 *p, char **namp, int *lenp)
87{ 87{
88 char *name; 88 char *name;
89 int i; 89 int i;
@@ -98,8 +98,8 @@ decode_pathname(u32 *p, char **namp, int *lenp)
98 return p; 98 return p;
99} 99}
100 100
101static inline u32 * 101static inline __be32 *
102decode_sattr(u32 *p, struct iattr *iap) 102decode_sattr(__be32 *p, struct iattr *iap)
103{ 103{
104 u32 tmp, tmp1; 104 u32 tmp, tmp1;
105 105
@@ -151,8 +151,8 @@ decode_sattr(u32 *p, struct iattr *iap)
151 return p; 151 return p;
152} 152}
153 153
154static u32 * 154static __be32 *
155encode_fattr(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp, 155encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp,
156 struct kstat *stat) 156 struct kstat *stat)
157{ 157{
158 struct dentry *dentry = fhp->fh_dentry; 158 struct dentry *dentry = fhp->fh_dentry;
@@ -195,7 +195,7 @@ encode_fattr(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp,
195} 195}
196 196
197/* Helper function for NFSv2 ACL code */ 197/* Helper function for NFSv2 ACL code */
198u32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp) 198__be32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp)
199{ 199{
200 struct kstat stat; 200 struct kstat stat;
201 vfs_getattr(fhp->fh_export->ex_mnt, fhp->fh_dentry, &stat); 201 vfs_getattr(fhp->fh_export->ex_mnt, fhp->fh_dentry, &stat);
@@ -206,13 +206,13 @@ u32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp)
206 * XDR decode functions 206 * XDR decode functions
207 */ 207 */
208int 208int
209nfssvc_decode_void(struct svc_rqst *rqstp, u32 *p, void *dummy) 209nfssvc_decode_void(struct svc_rqst *rqstp, __be32 *p, void *dummy)
210{ 210{
211 return xdr_argsize_check(rqstp, p); 211 return xdr_argsize_check(rqstp, p);
212} 212}
213 213
214int 214int
215nfssvc_decode_fhandle(struct svc_rqst *rqstp, u32 *p, struct nfsd_fhandle *args) 215nfssvc_decode_fhandle(struct svc_rqst *rqstp, __be32 *p, struct nfsd_fhandle *args)
216{ 216{
217 if (!(p = decode_fh(p, &args->fh))) 217 if (!(p = decode_fh(p, &args->fh)))
218 return 0; 218 return 0;
@@ -220,7 +220,7 @@ nfssvc_decode_fhandle(struct svc_rqst *rqstp, u32 *p, struct nfsd_fhandle *args)
220} 220}
221 221
222int 222int
223nfssvc_decode_sattrargs(struct svc_rqst *rqstp, u32 *p, 223nfssvc_decode_sattrargs(struct svc_rqst *rqstp, __be32 *p,
224 struct nfsd_sattrargs *args) 224 struct nfsd_sattrargs *args)
225{ 225{
226 if (!(p = decode_fh(p, &args->fh)) 226 if (!(p = decode_fh(p, &args->fh))
@@ -231,7 +231,7 @@ nfssvc_decode_sattrargs(struct svc_rqst *rqstp, u32 *p,
231} 231}
232 232
233int 233int
234nfssvc_decode_diropargs(struct svc_rqst *rqstp, u32 *p, 234nfssvc_decode_diropargs(struct svc_rqst *rqstp, __be32 *p,
235 struct nfsd_diropargs *args) 235 struct nfsd_diropargs *args)
236{ 236{
237 if (!(p = decode_fh(p, &args->fh)) 237 if (!(p = decode_fh(p, &args->fh))
@@ -242,7 +242,7 @@ nfssvc_decode_diropargs(struct svc_rqst *rqstp, u32 *p,
242} 242}
243 243
244int 244int
245nfssvc_decode_readargs(struct svc_rqst *rqstp, u32 *p, 245nfssvc_decode_readargs(struct svc_rqst *rqstp, __be32 *p,
246 struct nfsd_readargs *args) 246 struct nfsd_readargs *args)
247{ 247{
248 unsigned int len; 248 unsigned int len;
@@ -273,7 +273,7 @@ nfssvc_decode_readargs(struct svc_rqst *rqstp, u32 *p,
273} 273}
274 274
275int 275int
276nfssvc_decode_writeargs(struct svc_rqst *rqstp, u32 *p, 276nfssvc_decode_writeargs(struct svc_rqst *rqstp, __be32 *p,
277 struct nfsd_writeargs *args) 277 struct nfsd_writeargs *args)
278{ 278{
279 unsigned int len; 279 unsigned int len;
@@ -303,7 +303,7 @@ nfssvc_decode_writeargs(struct svc_rqst *rqstp, u32 *p,
303} 303}
304 304
305int 305int
306nfssvc_decode_createargs(struct svc_rqst *rqstp, u32 *p, 306nfssvc_decode_createargs(struct svc_rqst *rqstp, __be32 *p,
307 struct nfsd_createargs *args) 307 struct nfsd_createargs *args)
308{ 308{
309 if (!(p = decode_fh(p, &args->fh)) 309 if (!(p = decode_fh(p, &args->fh))
@@ -315,7 +315,7 @@ nfssvc_decode_createargs(struct svc_rqst *rqstp, u32 *p,
315} 315}
316 316
317int 317int
318nfssvc_decode_renameargs(struct svc_rqst *rqstp, u32 *p, 318nfssvc_decode_renameargs(struct svc_rqst *rqstp, __be32 *p,
319 struct nfsd_renameargs *args) 319 struct nfsd_renameargs *args)
320{ 320{
321 if (!(p = decode_fh(p, &args->ffh)) 321 if (!(p = decode_fh(p, &args->ffh))
@@ -328,7 +328,7 @@ nfssvc_decode_renameargs(struct svc_rqst *rqstp, u32 *p,
328} 328}
329 329
330int 330int
331nfssvc_decode_readlinkargs(struct svc_rqst *rqstp, u32 *p, struct nfsd_readlinkargs *args) 331nfssvc_decode_readlinkargs(struct svc_rqst *rqstp, __be32 *p, struct nfsd_readlinkargs *args)
332{ 332{
333 if (!(p = decode_fh(p, &args->fh))) 333 if (!(p = decode_fh(p, &args->fh)))
334 return 0; 334 return 0;
@@ -338,7 +338,7 @@ nfssvc_decode_readlinkargs(struct svc_rqst *rqstp, u32 *p, struct nfsd_readlinka
338} 338}
339 339
340int 340int
341nfssvc_decode_linkargs(struct svc_rqst *rqstp, u32 *p, 341nfssvc_decode_linkargs(struct svc_rqst *rqstp, __be32 *p,
342 struct nfsd_linkargs *args) 342 struct nfsd_linkargs *args)
343{ 343{
344 if (!(p = decode_fh(p, &args->ffh)) 344 if (!(p = decode_fh(p, &args->ffh))
@@ -350,7 +350,7 @@ nfssvc_decode_linkargs(struct svc_rqst *rqstp, u32 *p,
350} 350}
351 351
352int 352int
353nfssvc_decode_symlinkargs(struct svc_rqst *rqstp, u32 *p, 353nfssvc_decode_symlinkargs(struct svc_rqst *rqstp, __be32 *p,
354 struct nfsd_symlinkargs *args) 354 struct nfsd_symlinkargs *args)
355{ 355{
356 if (!(p = decode_fh(p, &args->ffh)) 356 if (!(p = decode_fh(p, &args->ffh))
@@ -363,7 +363,7 @@ nfssvc_decode_symlinkargs(struct svc_rqst *rqstp, u32 *p,
363} 363}
364 364
365int 365int
366nfssvc_decode_readdirargs(struct svc_rqst *rqstp, u32 *p, 366nfssvc_decode_readdirargs(struct svc_rqst *rqstp, __be32 *p,
367 struct nfsd_readdirargs *args) 367 struct nfsd_readdirargs *args)
368{ 368{
369 if (!(p = decode_fh(p, &args->fh))) 369 if (!(p = decode_fh(p, &args->fh)))
@@ -382,13 +382,13 @@ nfssvc_decode_readdirargs(struct svc_rqst *rqstp, u32 *p,
382 * XDR encode functions 382 * XDR encode functions
383 */ 383 */
384int 384int
385nfssvc_encode_void(struct svc_rqst *rqstp, u32 *p, void *dummy) 385nfssvc_encode_void(struct svc_rqst *rqstp, __be32 *p, void *dummy)
386{ 386{
387 return xdr_ressize_check(rqstp, p); 387 return xdr_ressize_check(rqstp, p);
388} 388}
389 389
390int 390int
391nfssvc_encode_attrstat(struct svc_rqst *rqstp, u32 *p, 391nfssvc_encode_attrstat(struct svc_rqst *rqstp, __be32 *p,
392 struct nfsd_attrstat *resp) 392 struct nfsd_attrstat *resp)
393{ 393{
394 p = encode_fattr(rqstp, p, &resp->fh, &resp->stat); 394 p = encode_fattr(rqstp, p, &resp->fh, &resp->stat);
@@ -396,7 +396,7 @@ nfssvc_encode_attrstat(struct svc_rqst *rqstp, u32 *p,
396} 396}
397 397
398int 398int
399nfssvc_encode_diropres(struct svc_rqst *rqstp, u32 *p, 399nfssvc_encode_diropres(struct svc_rqst *rqstp, __be32 *p,
400 struct nfsd_diropres *resp) 400 struct nfsd_diropres *resp)
401{ 401{
402 p = encode_fh(p, &resp->fh); 402 p = encode_fh(p, &resp->fh);
@@ -405,7 +405,7 @@ nfssvc_encode_diropres(struct svc_rqst *rqstp, u32 *p,
405} 405}
406 406
407int 407int
408nfssvc_encode_readlinkres(struct svc_rqst *rqstp, u32 *p, 408nfssvc_encode_readlinkres(struct svc_rqst *rqstp, __be32 *p,
409 struct nfsd_readlinkres *resp) 409 struct nfsd_readlinkres *resp)
410{ 410{
411 *p++ = htonl(resp->len); 411 *p++ = htonl(resp->len);
@@ -421,7 +421,7 @@ nfssvc_encode_readlinkres(struct svc_rqst *rqstp, u32 *p,
421} 421}
422 422
423int 423int
424nfssvc_encode_readres(struct svc_rqst *rqstp, u32 *p, 424nfssvc_encode_readres(struct svc_rqst *rqstp, __be32 *p,
425 struct nfsd_readres *resp) 425 struct nfsd_readres *resp)
426{ 426{
427 p = encode_fattr(rqstp, p, &resp->fh, &resp->stat); 427 p = encode_fattr(rqstp, p, &resp->fh, &resp->stat);
@@ -440,7 +440,7 @@ nfssvc_encode_readres(struct svc_rqst *rqstp, u32 *p,
440} 440}
441 441
442int 442int
443nfssvc_encode_readdirres(struct svc_rqst *rqstp, u32 *p, 443nfssvc_encode_readdirres(struct svc_rqst *rqstp, __be32 *p,
444 struct nfsd_readdirres *resp) 444 struct nfsd_readdirres *resp)
445{ 445{
446 xdr_ressize_check(rqstp, p); 446 xdr_ressize_check(rqstp, p);
@@ -453,7 +453,7 @@ nfssvc_encode_readdirres(struct svc_rqst *rqstp, u32 *p,
453} 453}
454 454
455int 455int
456nfssvc_encode_statfsres(struct svc_rqst *rqstp, u32 *p, 456nfssvc_encode_statfsres(struct svc_rqst *rqstp, __be32 *p,
457 struct nfsd_statfsres *resp) 457 struct nfsd_statfsres *resp)
458{ 458{
459 struct kstatfs *stat = &resp->stats; 459 struct kstatfs *stat = &resp->stats;
@@ -471,7 +471,7 @@ nfssvc_encode_entry(struct readdir_cd *ccd, const char *name,
471 int namlen, loff_t offset, ino_t ino, unsigned int d_type) 471 int namlen, loff_t offset, ino_t ino, unsigned int d_type)
472{ 472{
473 struct nfsd_readdirres *cd = container_of(ccd, struct nfsd_readdirres, common); 473 struct nfsd_readdirres *cd = container_of(ccd, struct nfsd_readdirres, common);
474 u32 *p = cd->buffer; 474 __be32 *p = cd->buffer;
475 int buflen, slen; 475 int buflen, slen;
476 476
477 /* 477 /*
@@ -497,7 +497,7 @@ nfssvc_encode_entry(struct readdir_cd *ccd, const char *name,
497 *p++ = htonl((u32) ino); /* file id */ 497 *p++ = htonl((u32) ino); /* file id */
498 p = xdr_encode_array(p, name, namlen);/* name length & name */ 498 p = xdr_encode_array(p, name, namlen);/* name length & name */
499 cd->offset = p; /* remember pointer */ 499 cd->offset = p; /* remember pointer */
500 *p++ = ~(u32) 0; /* offset of next entry */ 500 *p++ = htonl(~0U); /* offset of next entry */
501 501
502 cd->buflen = buflen; 502 cd->buflen = buflen;
503 cd->buffer = p; 503 cd->buffer = p;
@@ -509,7 +509,7 @@ nfssvc_encode_entry(struct readdir_cd *ccd, const char *name,
509 * XDR release functions 509 * XDR release functions
510 */ 510 */
511int 511int
512nfssvc_release_fhandle(struct svc_rqst *rqstp, u32 *p, 512nfssvc_release_fhandle(struct svc_rqst *rqstp, __be32 *p,
513 struct nfsd_fhandle *resp) 513 struct nfsd_fhandle *resp)
514{ 514{
515 fh_put(&resp->fh); 515 fh_put(&resp->fh);
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 1141bd29e4e3..bb4d926e4487 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -110,7 +110,7 @@ nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp,
110 struct dentry *dentry = *dpp; 110 struct dentry *dentry = *dpp;
111 struct vfsmount *mnt = mntget(exp->ex_mnt); 111 struct vfsmount *mnt = mntget(exp->ex_mnt);
112 struct dentry *mounts = dget(dentry); 112 struct dentry *mounts = dget(dentry);
113 int err = nfs_ok; 113 int err = 0;
114 114
115 while (follow_down(&mnt,&mounts)&&d_mountpoint(mounts)); 115 while (follow_down(&mnt,&mounts)&&d_mountpoint(mounts));
116 116
@@ -148,14 +148,15 @@ out:
148 * clients and is explicitly disallowed for NFSv3 148 * clients and is explicitly disallowed for NFSv3
149 * NeilBrown <neilb@cse.unsw.edu.au> 149 * NeilBrown <neilb@cse.unsw.edu.au>
150 */ 150 */
151int 151__be32
152nfsd_lookup(struct svc_rqst *rqstp, struct svc_fh *fhp, const char *name, 152nfsd_lookup(struct svc_rqst *rqstp, struct svc_fh *fhp, const char *name,
153 int len, struct svc_fh *resfh) 153 int len, struct svc_fh *resfh)
154{ 154{
155 struct svc_export *exp; 155 struct svc_export *exp;
156 struct dentry *dparent; 156 struct dentry *dparent;
157 struct dentry *dentry; 157 struct dentry *dentry;
158 int err; 158 __be32 err;
159 int host_err;
159 160
160 dprintk("nfsd: nfsd_lookup(fh %s, %.*s)\n", SVCFH_fmt(fhp), len,name); 161 dprintk("nfsd: nfsd_lookup(fh %s, %.*s)\n", SVCFH_fmt(fhp), len,name);
161 162
@@ -193,7 +194,7 @@ nfsd_lookup(struct svc_rqst *rqstp, struct svc_fh *fhp, const char *name,
193 exp2 = exp_parent(exp->ex_client, mnt, dentry, 194 exp2 = exp_parent(exp->ex_client, mnt, dentry,
194 &rqstp->rq_chandle); 195 &rqstp->rq_chandle);
195 if (IS_ERR(exp2)) { 196 if (IS_ERR(exp2)) {
196 err = PTR_ERR(exp2); 197 host_err = PTR_ERR(exp2);
197 dput(dentry); 198 dput(dentry);
198 mntput(mnt); 199 mntput(mnt);
199 goto out_nfserr; 200 goto out_nfserr;
@@ -210,14 +211,14 @@ nfsd_lookup(struct svc_rqst *rqstp, struct svc_fh *fhp, const char *name,
210 } else { 211 } else {
211 fh_lock(fhp); 212 fh_lock(fhp);
212 dentry = lookup_one_len(name, dparent, len); 213 dentry = lookup_one_len(name, dparent, len);
213 err = PTR_ERR(dentry); 214 host_err = PTR_ERR(dentry);
214 if (IS_ERR(dentry)) 215 if (IS_ERR(dentry))
215 goto out_nfserr; 216 goto out_nfserr;
216 /* 217 /*
217 * check if we have crossed a mount point ... 218 * check if we have crossed a mount point ...
218 */ 219 */
219 if (d_mountpoint(dentry)) { 220 if (d_mountpoint(dentry)) {
220 if ((err = nfsd_cross_mnt(rqstp, &dentry, &exp))) { 221 if ((host_err = nfsd_cross_mnt(rqstp, &dentry, &exp))) {
221 dput(dentry); 222 dput(dentry);
222 goto out_nfserr; 223 goto out_nfserr;
223 } 224 }
@@ -236,7 +237,7 @@ out:
236 return err; 237 return err;
237 238
238out_nfserr: 239out_nfserr:
239 err = nfserrno(err); 240 err = nfserrno(host_err);
240 goto out; 241 goto out;
241} 242}
242 243
@@ -244,7 +245,7 @@ out_nfserr:
244 * Set various file attributes. 245 * Set various file attributes.
245 * N.B. After this call fhp needs an fh_put 246 * N.B. After this call fhp needs an fh_put
246 */ 247 */
247int 248__be32
248nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap, 249nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
249 int check_guard, time_t guardtime) 250 int check_guard, time_t guardtime)
250{ 251{
@@ -253,7 +254,8 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
253 int accmode = MAY_SATTR; 254 int accmode = MAY_SATTR;
254 int ftype = 0; 255 int ftype = 0;
255 int imode; 256 int imode;
256 int err; 257 __be32 err;
258 int host_err;
257 int size_change = 0; 259 int size_change = 0;
258 260
259 if (iap->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_SIZE)) 261 if (iap->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_SIZE))
@@ -319,19 +321,19 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
319 * If we are changing the size of the file, then 321 * If we are changing the size of the file, then
320 * we need to break all leases. 322 * we need to break all leases.
321 */ 323 */
322 err = break_lease(inode, FMODE_WRITE | O_NONBLOCK); 324 host_err = break_lease(inode, FMODE_WRITE | O_NONBLOCK);
323 if (err == -EWOULDBLOCK) 325 if (host_err == -EWOULDBLOCK)
324 err = -ETIMEDOUT; 326 host_err = -ETIMEDOUT;
325 if (err) /* ENOMEM or EWOULDBLOCK */ 327 if (host_err) /* ENOMEM or EWOULDBLOCK */
326 goto out_nfserr; 328 goto out_nfserr;
327 329
328 err = get_write_access(inode); 330 host_err = get_write_access(inode);
329 if (err) 331 if (host_err)
330 goto out_nfserr; 332 goto out_nfserr;
331 333
332 size_change = 1; 334 size_change = 1;
333 err = locks_verify_truncate(inode, NULL, iap->ia_size); 335 host_err = locks_verify_truncate(inode, NULL, iap->ia_size);
334 if (err) { 336 if (host_err) {
335 put_write_access(inode); 337 put_write_access(inode);
336 goto out_nfserr; 338 goto out_nfserr;
337 } 339 }
@@ -357,8 +359,8 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
357 err = nfserr_notsync; 359 err = nfserr_notsync;
358 if (!check_guard || guardtime == inode->i_ctime.tv_sec) { 360 if (!check_guard || guardtime == inode->i_ctime.tv_sec) {
359 fh_lock(fhp); 361 fh_lock(fhp);
360 err = notify_change(dentry, iap); 362 host_err = notify_change(dentry, iap);
361 err = nfserrno(err); 363 err = nfserrno(host_err);
362 fh_unlock(fhp); 364 fh_unlock(fhp);
363 } 365 }
364 if (size_change) 366 if (size_change)
@@ -370,7 +372,7 @@ out:
370 return err; 372 return err;
371 373
372out_nfserr: 374out_nfserr:
373 err = nfserrno(err); 375 err = nfserrno(host_err);
374 goto out; 376 goto out;
375} 377}
376 378
@@ -420,11 +422,12 @@ out:
420 return error; 422 return error;
421} 423}
422 424
423int 425__be32
424nfsd4_set_nfs4_acl(struct svc_rqst *rqstp, struct svc_fh *fhp, 426nfsd4_set_nfs4_acl(struct svc_rqst *rqstp, struct svc_fh *fhp,
425 struct nfs4_acl *acl) 427 struct nfs4_acl *acl)
426{ 428{
427 int error; 429 __be32 error;
430 int host_error;
428 struct dentry *dentry; 431 struct dentry *dentry;
429 struct inode *inode; 432 struct inode *inode;
430 struct posix_acl *pacl = NULL, *dpacl = NULL; 433 struct posix_acl *pacl = NULL, *dpacl = NULL;
@@ -440,20 +443,20 @@ nfsd4_set_nfs4_acl(struct svc_rqst *rqstp, struct svc_fh *fhp,
440 if (S_ISDIR(inode->i_mode)) 443 if (S_ISDIR(inode->i_mode))
441 flags = NFS4_ACL_DIR; 444 flags = NFS4_ACL_DIR;
442 445
443 error = nfs4_acl_nfsv4_to_posix(acl, &pacl, &dpacl, flags); 446 host_error = nfs4_acl_nfsv4_to_posix(acl, &pacl, &dpacl, flags);
444 if (error == -EINVAL) { 447 if (host_error == -EINVAL) {
445 error = nfserr_attrnotsupp; 448 error = nfserr_attrnotsupp;
446 goto out; 449 goto out;
447 } else if (error < 0) 450 } else if (host_error < 0)
448 goto out_nfserr; 451 goto out_nfserr;
449 452
450 error = set_nfsv4_acl_one(dentry, pacl, POSIX_ACL_XATTR_ACCESS); 453 host_error = set_nfsv4_acl_one(dentry, pacl, POSIX_ACL_XATTR_ACCESS);
451 if (error < 0) 454 if (host_error < 0)
452 goto out_nfserr; 455 goto out_nfserr;
453 456
454 if (S_ISDIR(inode->i_mode)) { 457 if (S_ISDIR(inode->i_mode)) {
455 error = set_nfsv4_acl_one(dentry, dpacl, POSIX_ACL_XATTR_DEFAULT); 458 host_error = set_nfsv4_acl_one(dentry, dpacl, POSIX_ACL_XATTR_DEFAULT);
456 if (error < 0) 459 if (host_error < 0)
457 goto out_nfserr; 460 goto out_nfserr;
458 } 461 }
459 462
@@ -464,7 +467,7 @@ out:
464 posix_acl_release(dpacl); 467 posix_acl_release(dpacl);
465 return (error); 468 return (error);
466out_nfserr: 469out_nfserr:
467 error = nfserrno(error); 470 error = nfserrno(host_error);
468 goto out; 471 goto out;
469} 472}
470 473
@@ -571,14 +574,14 @@ static struct accessmap nfs3_anyaccess[] = {
571 { 0, 0 } 574 { 0, 0 }
572}; 575};
573 576
574int 577__be32
575nfsd_access(struct svc_rqst *rqstp, struct svc_fh *fhp, u32 *access, u32 *supported) 578nfsd_access(struct svc_rqst *rqstp, struct svc_fh *fhp, u32 *access, u32 *supported)
576{ 579{
577 struct accessmap *map; 580 struct accessmap *map;
578 struct svc_export *export; 581 struct svc_export *export;
579 struct dentry *dentry; 582 struct dentry *dentry;
580 u32 query, result = 0, sresult = 0; 583 u32 query, result = 0, sresult = 0;
581 unsigned int error; 584 __be32 error;
582 585
583 error = fh_verify(rqstp, fhp, 0, MAY_NOP); 586 error = fh_verify(rqstp, fhp, 0, MAY_NOP);
584 if (error) 587 if (error)
@@ -598,7 +601,7 @@ nfsd_access(struct svc_rqst *rqstp, struct svc_fh *fhp, u32 *access, u32 *suppor
598 query = *access; 601 query = *access;
599 for (; map->access; map++) { 602 for (; map->access; map++) {
600 if (map->access & query) { 603 if (map->access & query) {
601 unsigned int err2; 604 __be32 err2;
602 605
603 sresult |= map->access; 606 sresult |= map->access;
604 607
@@ -637,13 +640,15 @@ nfsd_access(struct svc_rqst *rqstp, struct svc_fh *fhp, u32 *access, u32 *suppor
637 * The access argument indicates the type of open (read/write/lock) 640 * The access argument indicates the type of open (read/write/lock)
638 * N.B. After this call fhp needs an fh_put 641 * N.B. After this call fhp needs an fh_put
639 */ 642 */
640int 643__be32
641nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, 644nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
642 int access, struct file **filp) 645 int access, struct file **filp)
643{ 646{
644 struct dentry *dentry; 647 struct dentry *dentry;
645 struct inode *inode; 648 struct inode *inode;
646 int flags = O_RDONLY|O_LARGEFILE, err; 649 int flags = O_RDONLY|O_LARGEFILE;
650 __be32 err;
651 int host_err;
647 652
648 /* 653 /*
649 * If we get here, then the client has already done an "open", 654 * If we get here, then the client has already done an "open",
@@ -673,10 +678,10 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
673 * Check to see if there are any leases on this file. 678 * Check to see if there are any leases on this file.
674 * This may block while leases are broken. 679 * This may block while leases are broken.
675 */ 680 */
676 err = break_lease(inode, O_NONBLOCK | ((access & MAY_WRITE) ? FMODE_WRITE : 0)); 681 host_err = break_lease(inode, O_NONBLOCK | ((access & MAY_WRITE) ? FMODE_WRITE : 0));
677 if (err == -EWOULDBLOCK) 682 if (host_err == -EWOULDBLOCK)
678 err = -ETIMEDOUT; 683 host_err = -ETIMEDOUT;
679 if (err) /* NOMEM or WOULDBLOCK */ 684 if (host_err) /* NOMEM or WOULDBLOCK */
680 goto out_nfserr; 685 goto out_nfserr;
681 686
682 if (access & MAY_WRITE) { 687 if (access & MAY_WRITE) {
@@ -689,10 +694,9 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
689 } 694 }
690 *filp = dentry_open(dget(dentry), mntget(fhp->fh_export->ex_mnt), flags); 695 *filp = dentry_open(dget(dentry), mntget(fhp->fh_export->ex_mnt), flags);
691 if (IS_ERR(*filp)) 696 if (IS_ERR(*filp))
692 err = PTR_ERR(*filp); 697 host_err = PTR_ERR(*filp);
693out_nfserr: 698out_nfserr:
694 if (err) 699 err = nfserrno(host_err);
695 err = nfserrno(err);
696out: 700out:
697 return err; 701 return err;
698} 702}
@@ -830,14 +834,15 @@ nfsd_read_actor(read_descriptor_t *desc, struct page *page, unsigned long offset
830 return size; 834 return size;
831} 835}
832 836
833static int 837static __be32
834nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, 838nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
835 loff_t offset, struct kvec *vec, int vlen, unsigned long *count) 839 loff_t offset, struct kvec *vec, int vlen, unsigned long *count)
836{ 840{
837 struct inode *inode; 841 struct inode *inode;
838 struct raparms *ra; 842 struct raparms *ra;
839 mm_segment_t oldfs; 843 mm_segment_t oldfs;
840 int err; 844 __be32 err;
845 int host_err;
841 846
842 err = nfserr_perm; 847 err = nfserr_perm;
843 inode = file->f_dentry->d_inode; 848 inode = file->f_dentry->d_inode;
@@ -855,12 +860,12 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
855 860
856 if (file->f_op->sendfile && rqstp->rq_sendfile_ok) { 861 if (file->f_op->sendfile && rqstp->rq_sendfile_ok) {
857 rqstp->rq_resused = 1; 862 rqstp->rq_resused = 1;
858 err = file->f_op->sendfile(file, &offset, *count, 863 host_err = file->f_op->sendfile(file, &offset, *count,
859 nfsd_read_actor, rqstp); 864 nfsd_read_actor, rqstp);
860 } else { 865 } else {
861 oldfs = get_fs(); 866 oldfs = get_fs();
862 set_fs(KERNEL_DS); 867 set_fs(KERNEL_DS);
863 err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset); 868 host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
864 set_fs(oldfs); 869 set_fs(oldfs);
865 } 870 }
866 871
@@ -874,13 +879,13 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
874 spin_unlock(&rab->pb_lock); 879 spin_unlock(&rab->pb_lock);
875 } 880 }
876 881
877 if (err >= 0) { 882 if (host_err >= 0) {
878 nfsdstats.io_read += err; 883 nfsdstats.io_read += host_err;
879 *count = err; 884 *count = host_err;
880 err = 0; 885 err = 0;
881 fsnotify_access(file->f_dentry); 886 fsnotify_access(file->f_dentry);
882 } else 887 } else
883 err = nfserrno(err); 888 err = nfserrno(host_err);
884out: 889out:
885 return err; 890 return err;
886} 891}
@@ -895,7 +900,7 @@ static void kill_suid(struct dentry *dentry)
895 mutex_unlock(&dentry->d_inode->i_mutex); 900 mutex_unlock(&dentry->d_inode->i_mutex);
896} 901}
897 902
898static int 903static __be32
899nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, 904nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
900 loff_t offset, struct kvec *vec, int vlen, 905 loff_t offset, struct kvec *vec, int vlen,
901 unsigned long cnt, int *stablep) 906 unsigned long cnt, int *stablep)
@@ -904,7 +909,8 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
904 struct dentry *dentry; 909 struct dentry *dentry;
905 struct inode *inode; 910 struct inode *inode;
906 mm_segment_t oldfs; 911 mm_segment_t oldfs;
907 int err = 0; 912 __be32 err = 0;
913 int host_err;
908 int stable = *stablep; 914 int stable = *stablep;
909 915
910#ifdef MSNFS 916#ifdef MSNFS
@@ -940,18 +946,18 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
940 946
941 /* Write the data. */ 947 /* Write the data. */
942 oldfs = get_fs(); set_fs(KERNEL_DS); 948 oldfs = get_fs(); set_fs(KERNEL_DS);
943 err = vfs_writev(file, (struct iovec __user *)vec, vlen, &offset); 949 host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &offset);
944 set_fs(oldfs); 950 set_fs(oldfs);
945 if (err >= 0) { 951 if (host_err >= 0) {
946 nfsdstats.io_write += cnt; 952 nfsdstats.io_write += cnt;
947 fsnotify_modify(file->f_dentry); 953 fsnotify_modify(file->f_dentry);
948 } 954 }
949 955
950 /* clear setuid/setgid flag after write */ 956 /* clear setuid/setgid flag after write */
951 if (err >= 0 && (inode->i_mode & (S_ISUID | S_ISGID))) 957 if (host_err >= 0 && (inode->i_mode & (S_ISUID | S_ISGID)))
952 kill_suid(dentry); 958 kill_suid(dentry);
953 959
954 if (err >= 0 && stable) { 960 if (host_err >= 0 && stable) {
955 static ino_t last_ino; 961 static ino_t last_ino;
956 static dev_t last_dev; 962 static dev_t last_dev;
957 963
@@ -977,7 +983,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
977 983
978 if (inode->i_state & I_DIRTY) { 984 if (inode->i_state & I_DIRTY) {
979 dprintk("nfsd: write sync %d\n", current->pid); 985 dprintk("nfsd: write sync %d\n", current->pid);
980 err=nfsd_sync(file); 986 host_err=nfsd_sync(file);
981 } 987 }
982#if 0 988#if 0
983 wake_up(&inode->i_wait); 989 wake_up(&inode->i_wait);
@@ -987,11 +993,11 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
987 last_dev = inode->i_sb->s_dev; 993 last_dev = inode->i_sb->s_dev;
988 } 994 }
989 995
990 dprintk("nfsd: write complete err=%d\n", err); 996 dprintk("nfsd: write complete host_err=%d\n", host_err);
991 if (err >= 0) 997 if (host_err >= 0)
992 err = 0; 998 err = 0;
993 else 999 else
994 err = nfserrno(err); 1000 err = nfserrno(host_err);
995out: 1001out:
996 return err; 1002 return err;
997} 1003}
@@ -1001,12 +1007,12 @@ out:
1001 * on entry. On return, *count contains the number of bytes actually read. 1007 * on entry. On return, *count contains the number of bytes actually read.
1002 * N.B. After this call fhp needs an fh_put 1008 * N.B. After this call fhp needs an fh_put
1003 */ 1009 */
1004int 1010__be32
1005nfsd_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, 1011nfsd_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
1006 loff_t offset, struct kvec *vec, int vlen, 1012 loff_t offset, struct kvec *vec, int vlen,
1007 unsigned long *count) 1013 unsigned long *count)
1008{ 1014{
1009 int err; 1015 __be32 err;
1010 1016
1011 if (file) { 1017 if (file) {
1012 err = nfsd_permission(fhp->fh_export, fhp->fh_dentry, 1018 err = nfsd_permission(fhp->fh_export, fhp->fh_dentry,
@@ -1030,12 +1036,12 @@ out:
1030 * The stable flag requests synchronous writes. 1036 * The stable flag requests synchronous writes.
1031 * N.B. After this call fhp needs an fh_put 1037 * N.B. After this call fhp needs an fh_put
1032 */ 1038 */
1033int 1039__be32
1034nfsd_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, 1040nfsd_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
1035 loff_t offset, struct kvec *vec, int vlen, unsigned long cnt, 1041 loff_t offset, struct kvec *vec, int vlen, unsigned long cnt,
1036 int *stablep) 1042 int *stablep)
1037{ 1043{
1038 int err = 0; 1044 __be32 err = 0;
1039 1045
1040 if (file) { 1046 if (file) {
1041 err = nfsd_permission(fhp->fh_export, fhp->fh_dentry, 1047 err = nfsd_permission(fhp->fh_export, fhp->fh_dentry,
@@ -1067,12 +1073,12 @@ out:
1067 * Unfortunately we cannot lock the file to make sure we return full WCC 1073 * Unfortunately we cannot lock the file to make sure we return full WCC
1068 * data to the client, as locking happens lower down in the filesystem. 1074 * data to the client, as locking happens lower down in the filesystem.
1069 */ 1075 */
1070int 1076__be32
1071nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp, 1077nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp,
1072 loff_t offset, unsigned long count) 1078 loff_t offset, unsigned long count)
1073{ 1079{
1074 struct file *file; 1080 struct file *file;
1075 int err; 1081 __be32 err;
1076 1082
1077 if ((u64)count > ~(u64)offset) 1083 if ((u64)count > ~(u64)offset)
1078 return nfserr_inval; 1084 return nfserr_inval;
@@ -1100,14 +1106,15 @@ nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp,
1100 * 1106 *
1101 * N.B. Every call to nfsd_create needs an fh_put for _both_ fhp and resfhp 1107 * N.B. Every call to nfsd_create needs an fh_put for _both_ fhp and resfhp
1102 */ 1108 */
1103int 1109__be32
1104nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp, 1110nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
1105 char *fname, int flen, struct iattr *iap, 1111 char *fname, int flen, struct iattr *iap,
1106 int type, dev_t rdev, struct svc_fh *resfhp) 1112 int type, dev_t rdev, struct svc_fh *resfhp)
1107{ 1113{
1108 struct dentry *dentry, *dchild = NULL; 1114 struct dentry *dentry, *dchild = NULL;
1109 struct inode *dirp; 1115 struct inode *dirp;
1110 int err; 1116 __be32 err;
1117 int host_err;
1111 1118
1112 err = nfserr_perm; 1119 err = nfserr_perm;
1113 if (!flen) 1120 if (!flen)
@@ -1134,7 +1141,7 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
1134 /* called from nfsd_proc_mkdir, or possibly nfsd3_proc_create */ 1141 /* called from nfsd_proc_mkdir, or possibly nfsd3_proc_create */
1135 fh_lock_nested(fhp, I_MUTEX_PARENT); 1142 fh_lock_nested(fhp, I_MUTEX_PARENT);
1136 dchild = lookup_one_len(fname, dentry, flen); 1143 dchild = lookup_one_len(fname, dentry, flen);
1137 err = PTR_ERR(dchild); 1144 host_err = PTR_ERR(dchild);
1138 if (IS_ERR(dchild)) 1145 if (IS_ERR(dchild))
1139 goto out_nfserr; 1146 goto out_nfserr;
1140 err = fh_compose(resfhp, fhp->fh_export, dchild, fhp); 1147 err = fh_compose(resfhp, fhp->fh_export, dchild, fhp);
@@ -1170,25 +1177,25 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
1170 /* 1177 /*
1171 * Get the dir op function pointer. 1178 * Get the dir op function pointer.
1172 */ 1179 */
1173 err = nfserr_perm; 1180 err = 0;
1174 switch (type) { 1181 switch (type) {
1175 case S_IFREG: 1182 case S_IFREG:
1176 err = vfs_create(dirp, dchild, iap->ia_mode, NULL); 1183 host_err = vfs_create(dirp, dchild, iap->ia_mode, NULL);
1177 break; 1184 break;
1178 case S_IFDIR: 1185 case S_IFDIR:
1179 err = vfs_mkdir(dirp, dchild, iap->ia_mode); 1186 host_err = vfs_mkdir(dirp, dchild, iap->ia_mode);
1180 break; 1187 break;
1181 case S_IFCHR: 1188 case S_IFCHR:
1182 case S_IFBLK: 1189 case S_IFBLK:
1183 case S_IFIFO: 1190 case S_IFIFO:
1184 case S_IFSOCK: 1191 case S_IFSOCK:
1185 err = vfs_mknod(dirp, dchild, iap->ia_mode, rdev); 1192 host_err = vfs_mknod(dirp, dchild, iap->ia_mode, rdev);
1186 break; 1193 break;
1187 default: 1194 default:
1188 printk("nfsd: bad file type %o in nfsd_create\n", type); 1195 printk("nfsd: bad file type %o in nfsd_create\n", type);
1189 err = -EINVAL; 1196 host_err = -EINVAL;
1190 } 1197 }
1191 if (err < 0) 1198 if (host_err < 0)
1192 goto out_nfserr; 1199 goto out_nfserr;
1193 1200
1194 if (EX_ISSYNC(fhp->fh_export)) { 1201 if (EX_ISSYNC(fhp->fh_export)) {
@@ -1203,7 +1210,7 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
1203 * directories via NFS. 1210 * directories via NFS.
1204 */ 1211 */
1205 if ((iap->ia_valid &= ~(ATTR_UID|ATTR_GID|ATTR_MODE)) != 0) { 1212 if ((iap->ia_valid &= ~(ATTR_UID|ATTR_GID|ATTR_MODE)) != 0) {
1206 int err2 = nfsd_setattr(rqstp, resfhp, iap, 0, (time_t)0); 1213 __be32 err2 = nfsd_setattr(rqstp, resfhp, iap, 0, (time_t)0);
1207 if (err2) 1214 if (err2)
1208 err = err2; 1215 err = err2;
1209 } 1216 }
@@ -1218,7 +1225,7 @@ out:
1218 return err; 1225 return err;
1219 1226
1220out_nfserr: 1227out_nfserr:
1221 err = nfserrno(err); 1228 err = nfserrno(host_err);
1222 goto out; 1229 goto out;
1223} 1230}
1224 1231
@@ -1226,15 +1233,16 @@ out_nfserr:
1226/* 1233/*
1227 * NFSv3 version of nfsd_create 1234 * NFSv3 version of nfsd_create
1228 */ 1235 */
1229int 1236__be32
1230nfsd_create_v3(struct svc_rqst *rqstp, struct svc_fh *fhp, 1237nfsd_create_v3(struct svc_rqst *rqstp, struct svc_fh *fhp,
1231 char *fname, int flen, struct iattr *iap, 1238 char *fname, int flen, struct iattr *iap,
1232 struct svc_fh *resfhp, int createmode, u32 *verifier, 1239 struct svc_fh *resfhp, int createmode, u32 *verifier,
1233 int *truncp) 1240 int *truncp, int *created)
1234{ 1241{
1235 struct dentry *dentry, *dchild = NULL; 1242 struct dentry *dentry, *dchild = NULL;
1236 struct inode *dirp; 1243 struct inode *dirp;
1237 int err; 1244 __be32 err;
1245 int host_err;
1238 __u32 v_mtime=0, v_atime=0; 1246 __u32 v_mtime=0, v_atime=0;
1239 int v_mode=0; 1247 int v_mode=0;
1240 1248
@@ -1264,7 +1272,7 @@ nfsd_create_v3(struct svc_rqst *rqstp, struct svc_fh *fhp,
1264 * Compose the response file handle. 1272 * Compose the response file handle.
1265 */ 1273 */
1266 dchild = lookup_one_len(fname, dentry, flen); 1274 dchild = lookup_one_len(fname, dentry, flen);
1267 err = PTR_ERR(dchild); 1275 host_err = PTR_ERR(dchild);
1268 if (IS_ERR(dchild)) 1276 if (IS_ERR(dchild))
1269 goto out_nfserr; 1277 goto out_nfserr;
1270 1278
@@ -1320,9 +1328,11 @@ nfsd_create_v3(struct svc_rqst *rqstp, struct svc_fh *fhp,
1320 goto out; 1328 goto out;
1321 } 1329 }
1322 1330
1323 err = vfs_create(dirp, dchild, iap->ia_mode, NULL); 1331 host_err = vfs_create(dirp, dchild, iap->ia_mode, NULL);
1324 if (err < 0) 1332 if (host_err < 0)
1325 goto out_nfserr; 1333 goto out_nfserr;
1334 if (created)
1335 *created = 1;
1326 1336
1327 if (EX_ISSYNC(fhp->fh_export)) { 1337 if (EX_ISSYNC(fhp->fh_export)) {
1328 err = nfserrno(nfsd_sync_dir(dentry)); 1338 err = nfserrno(nfsd_sync_dir(dentry));
@@ -1350,7 +1360,7 @@ nfsd_create_v3(struct svc_rqst *rqstp, struct svc_fh *fhp,
1350 */ 1360 */
1351 set_attr: 1361 set_attr:
1352 if ((iap->ia_valid &= ~(ATTR_UID|ATTR_GID)) != 0) { 1362 if ((iap->ia_valid &= ~(ATTR_UID|ATTR_GID)) != 0) {
1353 int err2 = nfsd_setattr(rqstp, resfhp, iap, 0, (time_t)0); 1363 __be32 err2 = nfsd_setattr(rqstp, resfhp, iap, 0, (time_t)0);
1354 if (err2) 1364 if (err2)
1355 err = err2; 1365 err = err2;
1356 } 1366 }
@@ -1368,7 +1378,7 @@ nfsd_create_v3(struct svc_rqst *rqstp, struct svc_fh *fhp,
1368 return err; 1378 return err;
1369 1379
1370 out_nfserr: 1380 out_nfserr:
1371 err = nfserrno(err); 1381 err = nfserrno(host_err);
1372 goto out; 1382 goto out;
1373} 1383}
1374#endif /* CONFIG_NFSD_V3 */ 1384#endif /* CONFIG_NFSD_V3 */
@@ -1378,13 +1388,14 @@ nfsd_create_v3(struct svc_rqst *rqstp, struct svc_fh *fhp,
1378 * fits into the buffer. On return, it contains the true length. 1388 * fits into the buffer. On return, it contains the true length.
1379 * N.B. After this call fhp needs an fh_put 1389 * N.B. After this call fhp needs an fh_put
1380 */ 1390 */
1381int 1391__be32
1382nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp) 1392nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
1383{ 1393{
1384 struct dentry *dentry; 1394 struct dentry *dentry;
1385 struct inode *inode; 1395 struct inode *inode;
1386 mm_segment_t oldfs; 1396 mm_segment_t oldfs;
1387 int err; 1397 __be32 err;
1398 int host_err;
1388 1399
1389 err = fh_verify(rqstp, fhp, S_IFLNK, MAY_NOP); 1400 err = fh_verify(rqstp, fhp, S_IFLNK, MAY_NOP);
1390 if (err) 1401 if (err)
@@ -1403,18 +1414,18 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
1403 */ 1414 */
1404 1415
1405 oldfs = get_fs(); set_fs(KERNEL_DS); 1416 oldfs = get_fs(); set_fs(KERNEL_DS);
1406 err = inode->i_op->readlink(dentry, buf, *lenp); 1417 host_err = inode->i_op->readlink(dentry, buf, *lenp);
1407 set_fs(oldfs); 1418 set_fs(oldfs);
1408 1419
1409 if (err < 0) 1420 if (host_err < 0)
1410 goto out_nfserr; 1421 goto out_nfserr;
1411 *lenp = err; 1422 *lenp = host_err;
1412 err = 0; 1423 err = 0;
1413out: 1424out:
1414 return err; 1425 return err;
1415 1426
1416out_nfserr: 1427out_nfserr:
1417 err = nfserrno(err); 1428 err = nfserrno(host_err);
1418 goto out; 1429 goto out;
1419} 1430}
1420 1431
@@ -1422,7 +1433,7 @@ out_nfserr:
1422 * Create a symlink and look up its inode 1433 * Create a symlink and look up its inode
1423 * N.B. After this call _both_ fhp and resfhp need an fh_put 1434 * N.B. After this call _both_ fhp and resfhp need an fh_put
1424 */ 1435 */
1425int 1436__be32
1426nfsd_symlink(struct svc_rqst *rqstp, struct svc_fh *fhp, 1437nfsd_symlink(struct svc_rqst *rqstp, struct svc_fh *fhp,
1427 char *fname, int flen, 1438 char *fname, int flen,
1428 char *path, int plen, 1439 char *path, int plen,
@@ -1430,7 +1441,8 @@ nfsd_symlink(struct svc_rqst *rqstp, struct svc_fh *fhp,
1430 struct iattr *iap) 1441 struct iattr *iap)
1431{ 1442{
1432 struct dentry *dentry, *dnew; 1443 struct dentry *dentry, *dnew;
1433 int err, cerr; 1444 __be32 err, cerr;
1445 int host_err;
1434 umode_t mode; 1446 umode_t mode;
1435 1447
1436 err = nfserr_noent; 1448 err = nfserr_noent;
@@ -1446,7 +1458,7 @@ nfsd_symlink(struct svc_rqst *rqstp, struct svc_fh *fhp,
1446 fh_lock(fhp); 1458 fh_lock(fhp);
1447 dentry = fhp->fh_dentry; 1459 dentry = fhp->fh_dentry;
1448 dnew = lookup_one_len(fname, dentry, flen); 1460 dnew = lookup_one_len(fname, dentry, flen);
1449 err = PTR_ERR(dnew); 1461 host_err = PTR_ERR(dnew);
1450 if (IS_ERR(dnew)) 1462 if (IS_ERR(dnew))
1451 goto out_nfserr; 1463 goto out_nfserr;
1452 1464
@@ -1458,21 +1470,21 @@ nfsd_symlink(struct svc_rqst *rqstp, struct svc_fh *fhp,
1458 if (unlikely(path[plen] != 0)) { 1470 if (unlikely(path[plen] != 0)) {
1459 char *path_alloced = kmalloc(plen+1, GFP_KERNEL); 1471 char *path_alloced = kmalloc(plen+1, GFP_KERNEL);
1460 if (path_alloced == NULL) 1472 if (path_alloced == NULL)
1461 err = -ENOMEM; 1473 host_err = -ENOMEM;
1462 else { 1474 else {
1463 strncpy(path_alloced, path, plen); 1475 strncpy(path_alloced, path, plen);
1464 path_alloced[plen] = 0; 1476 path_alloced[plen] = 0;
1465 err = vfs_symlink(dentry->d_inode, dnew, path_alloced, mode); 1477 host_err = vfs_symlink(dentry->d_inode, dnew, path_alloced, mode);
1466 kfree(path_alloced); 1478 kfree(path_alloced);
1467 } 1479 }
1468 } else 1480 } else
1469 err = vfs_symlink(dentry->d_inode, dnew, path, mode); 1481 host_err = vfs_symlink(dentry->d_inode, dnew, path, mode);
1470 1482
1471 if (!err) 1483 if (!host_err) {
1472 if (EX_ISSYNC(fhp->fh_export)) 1484 if (EX_ISSYNC(fhp->fh_export))
1473 err = nfsd_sync_dir(dentry); 1485 host_err = nfsd_sync_dir(dentry);
1474 if (err) 1486 }
1475 err = nfserrno(err); 1487 err = nfserrno(host_err);
1476 fh_unlock(fhp); 1488 fh_unlock(fhp);
1477 1489
1478 cerr = fh_compose(resfhp, fhp->fh_export, dnew, fhp); 1490 cerr = fh_compose(resfhp, fhp->fh_export, dnew, fhp);
@@ -1482,7 +1494,7 @@ out:
1482 return err; 1494 return err;
1483 1495
1484out_nfserr: 1496out_nfserr:
1485 err = nfserrno(err); 1497 err = nfserrno(host_err);
1486 goto out; 1498 goto out;
1487} 1499}
1488 1500
@@ -1490,13 +1502,14 @@ out_nfserr:
1490 * Create a hardlink 1502 * Create a hardlink
1491 * N.B. After this call _both_ ffhp and tfhp need an fh_put 1503 * N.B. After this call _both_ ffhp and tfhp need an fh_put
1492 */ 1504 */
1493int 1505__be32
1494nfsd_link(struct svc_rqst *rqstp, struct svc_fh *ffhp, 1506nfsd_link(struct svc_rqst *rqstp, struct svc_fh *ffhp,
1495 char *name, int len, struct svc_fh *tfhp) 1507 char *name, int len, struct svc_fh *tfhp)
1496{ 1508{
1497 struct dentry *ddir, *dnew, *dold; 1509 struct dentry *ddir, *dnew, *dold;
1498 struct inode *dirp, *dest; 1510 struct inode *dirp, *dest;
1499 int err; 1511 __be32 err;
1512 int host_err;
1500 1513
1501 err = fh_verify(rqstp, ffhp, S_IFDIR, MAY_CREATE); 1514 err = fh_verify(rqstp, ffhp, S_IFDIR, MAY_CREATE);
1502 if (err) 1515 if (err)
@@ -1517,24 +1530,25 @@ nfsd_link(struct svc_rqst *rqstp, struct svc_fh *ffhp,
1517 dirp = ddir->d_inode; 1530 dirp = ddir->d_inode;
1518 1531
1519 dnew = lookup_one_len(name, ddir, len); 1532 dnew = lookup_one_len(name, ddir, len);
1520 err = PTR_ERR(dnew); 1533 host_err = PTR_ERR(dnew);
1521 if (IS_ERR(dnew)) 1534 if (IS_ERR(dnew))
1522 goto out_nfserr; 1535 goto out_nfserr;
1523 1536
1524 dold = tfhp->fh_dentry; 1537 dold = tfhp->fh_dentry;
1525 dest = dold->d_inode; 1538 dest = dold->d_inode;
1526 1539
1527 err = vfs_link(dold, dirp, dnew); 1540 host_err = vfs_link(dold, dirp, dnew);
1528 if (!err) { 1541 if (!host_err) {
1529 if (EX_ISSYNC(ffhp->fh_export)) { 1542 if (EX_ISSYNC(ffhp->fh_export)) {
1530 err = nfserrno(nfsd_sync_dir(ddir)); 1543 err = nfserrno(nfsd_sync_dir(ddir));
1531 write_inode_now(dest, 1); 1544 write_inode_now(dest, 1);
1532 } 1545 }
1546 err = 0;
1533 } else { 1547 } else {
1534 if (err == -EXDEV && rqstp->rq_vers == 2) 1548 if (host_err == -EXDEV && rqstp->rq_vers == 2)
1535 err = nfserr_acces; 1549 err = nfserr_acces;
1536 else 1550 else
1537 err = nfserrno(err); 1551 err = nfserrno(host_err);
1538 } 1552 }
1539 1553
1540 dput(dnew); 1554 dput(dnew);
@@ -1544,7 +1558,7 @@ out:
1544 return err; 1558 return err;
1545 1559
1546out_nfserr: 1560out_nfserr:
1547 err = nfserrno(err); 1561 err = nfserrno(host_err);
1548 goto out_unlock; 1562 goto out_unlock;
1549} 1563}
1550 1564
@@ -1552,13 +1566,14 @@ out_nfserr:
1552 * Rename a file 1566 * Rename a file
1553 * N.B. After this call _both_ ffhp and tfhp need an fh_put 1567 * N.B. After this call _both_ ffhp and tfhp need an fh_put
1554 */ 1568 */
1555int 1569__be32
1556nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen, 1570nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
1557 struct svc_fh *tfhp, char *tname, int tlen) 1571 struct svc_fh *tfhp, char *tname, int tlen)
1558{ 1572{
1559 struct dentry *fdentry, *tdentry, *odentry, *ndentry, *trap; 1573 struct dentry *fdentry, *tdentry, *odentry, *ndentry, *trap;
1560 struct inode *fdir, *tdir; 1574 struct inode *fdir, *tdir;
1561 int err; 1575 __be32 err;
1576 int host_err;
1562 1577
1563 err = fh_verify(rqstp, ffhp, S_IFDIR, MAY_REMOVE); 1578 err = fh_verify(rqstp, ffhp, S_IFDIR, MAY_REMOVE);
1564 if (err) 1579 if (err)
@@ -1589,22 +1604,22 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
1589 fill_pre_wcc(tfhp); 1604 fill_pre_wcc(tfhp);
1590 1605
1591 odentry = lookup_one_len(fname, fdentry, flen); 1606 odentry = lookup_one_len(fname, fdentry, flen);
1592 err = PTR_ERR(odentry); 1607 host_err = PTR_ERR(odentry);
1593 if (IS_ERR(odentry)) 1608 if (IS_ERR(odentry))
1594 goto out_nfserr; 1609 goto out_nfserr;
1595 1610
1596 err = -ENOENT; 1611 host_err = -ENOENT;
1597 if (!odentry->d_inode) 1612 if (!odentry->d_inode)
1598 goto out_dput_old; 1613 goto out_dput_old;
1599 err = -EINVAL; 1614 host_err = -EINVAL;
1600 if (odentry == trap) 1615 if (odentry == trap)
1601 goto out_dput_old; 1616 goto out_dput_old;
1602 1617
1603 ndentry = lookup_one_len(tname, tdentry, tlen); 1618 ndentry = lookup_one_len(tname, tdentry, tlen);
1604 err = PTR_ERR(ndentry); 1619 host_err = PTR_ERR(ndentry);
1605 if (IS_ERR(ndentry)) 1620 if (IS_ERR(ndentry))
1606 goto out_dput_old; 1621 goto out_dput_old;
1607 err = -ENOTEMPTY; 1622 host_err = -ENOTEMPTY;
1608 if (ndentry == trap) 1623 if (ndentry == trap)
1609 goto out_dput_new; 1624 goto out_dput_new;
1610 1625
@@ -1612,14 +1627,14 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
1612 if ((ffhp->fh_export->ex_flags & NFSEXP_MSNFS) && 1627 if ((ffhp->fh_export->ex_flags & NFSEXP_MSNFS) &&
1613 ((atomic_read(&odentry->d_count) > 1) 1628 ((atomic_read(&odentry->d_count) > 1)
1614 || (atomic_read(&ndentry->d_count) > 1))) { 1629 || (atomic_read(&ndentry->d_count) > 1))) {
1615 err = -EPERM; 1630 host_err = -EPERM;
1616 } else 1631 } else
1617#endif 1632#endif
1618 err = vfs_rename(fdir, odentry, tdir, ndentry); 1633 host_err = vfs_rename(fdir, odentry, tdir, ndentry);
1619 if (!err && EX_ISSYNC(tfhp->fh_export)) { 1634 if (!host_err && EX_ISSYNC(tfhp->fh_export)) {
1620 err = nfsd_sync_dir(tdentry); 1635 host_err = nfsd_sync_dir(tdentry);
1621 if (!err) 1636 if (!host_err)
1622 err = nfsd_sync_dir(fdentry); 1637 host_err = nfsd_sync_dir(fdentry);
1623 } 1638 }
1624 1639
1625 out_dput_new: 1640 out_dput_new:
@@ -1627,8 +1642,7 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
1627 out_dput_old: 1642 out_dput_old:
1628 dput(odentry); 1643 dput(odentry);
1629 out_nfserr: 1644 out_nfserr:
1630 if (err) 1645 err = nfserrno(host_err);
1631 err = nfserrno(err);
1632 1646
1633 /* we cannot reply on fh_unlock on the two filehandles, 1647 /* we cannot reply on fh_unlock on the two filehandles,
1634 * as that would do the wrong thing if the two directories 1648 * as that would do the wrong thing if the two directories
@@ -1647,13 +1661,14 @@ out:
1647 * Unlink a file or directory 1661 * Unlink a file or directory
1648 * N.B. After this call fhp needs an fh_put 1662 * N.B. After this call fhp needs an fh_put
1649 */ 1663 */
1650int 1664__be32
1651nfsd_unlink(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, 1665nfsd_unlink(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
1652 char *fname, int flen) 1666 char *fname, int flen)
1653{ 1667{
1654 struct dentry *dentry, *rdentry; 1668 struct dentry *dentry, *rdentry;
1655 struct inode *dirp; 1669 struct inode *dirp;
1656 int err; 1670 __be32 err;
1671 int host_err;
1657 1672
1658 err = nfserr_acces; 1673 err = nfserr_acces;
1659 if (!flen || isdotent(fname, flen)) 1674 if (!flen || isdotent(fname, flen))
@@ -1667,7 +1682,7 @@ nfsd_unlink(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
1667 dirp = dentry->d_inode; 1682 dirp = dentry->d_inode;
1668 1683
1669 rdentry = lookup_one_len(fname, dentry, flen); 1684 rdentry = lookup_one_len(fname, dentry, flen);
1670 err = PTR_ERR(rdentry); 1685 host_err = PTR_ERR(rdentry);
1671 if (IS_ERR(rdentry)) 1686 if (IS_ERR(rdentry))
1672 goto out_nfserr; 1687 goto out_nfserr;
1673 1688
@@ -1684,22 +1699,23 @@ nfsd_unlink(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
1684#ifdef MSNFS 1699#ifdef MSNFS
1685 if ((fhp->fh_export->ex_flags & NFSEXP_MSNFS) && 1700 if ((fhp->fh_export->ex_flags & NFSEXP_MSNFS) &&
1686 (atomic_read(&rdentry->d_count) > 1)) { 1701 (atomic_read(&rdentry->d_count) > 1)) {
1687 err = -EPERM; 1702 host_err = -EPERM;
1688 } else 1703 } else
1689#endif 1704#endif
1690 err = vfs_unlink(dirp, rdentry); 1705 host_err = vfs_unlink(dirp, rdentry);
1691 } else { /* It's RMDIR */ 1706 } else { /* It's RMDIR */
1692 err = vfs_rmdir(dirp, rdentry); 1707 host_err = vfs_rmdir(dirp, rdentry);
1693 } 1708 }
1694 1709
1695 dput(rdentry); 1710 dput(rdentry);
1696 1711
1697 if (err == 0 && 1712 if (host_err)
1698 EX_ISSYNC(fhp->fh_export)) 1713 goto out_nfserr;
1699 err = nfsd_sync_dir(dentry); 1714 if (EX_ISSYNC(fhp->fh_export))
1715 host_err = nfsd_sync_dir(dentry);
1700 1716
1701out_nfserr: 1717out_nfserr:
1702 err = nfserrno(err); 1718 err = nfserrno(host_err);
1703out: 1719out:
1704 return err; 1720 return err;
1705} 1721}
@@ -1708,11 +1724,12 @@ out:
1708 * Read entries from a directory. 1724 * Read entries from a directory.
1709 * The NFSv3/4 verifier we ignore for now. 1725 * The NFSv3/4 verifier we ignore for now.
1710 */ 1726 */
1711int 1727__be32
1712nfsd_readdir(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t *offsetp, 1728nfsd_readdir(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t *offsetp,
1713 struct readdir_cd *cdp, encode_dent_fn func) 1729 struct readdir_cd *cdp, encode_dent_fn func)
1714{ 1730{
1715 int err; 1731 __be32 err;
1732 int host_err;
1716 struct file *file; 1733 struct file *file;
1717 loff_t offset = *offsetp; 1734 loff_t offset = *offsetp;
1718 1735
@@ -1734,10 +1751,10 @@ nfsd_readdir(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t *offsetp,
1734 1751
1735 do { 1752 do {
1736 cdp->err = nfserr_eof; /* will be cleared on successful read */ 1753 cdp->err = nfserr_eof; /* will be cleared on successful read */
1737 err = vfs_readdir(file, (filldir_t) func, cdp); 1754 host_err = vfs_readdir(file, (filldir_t) func, cdp);
1738 } while (err >=0 && cdp->err == nfs_ok); 1755 } while (host_err >=0 && cdp->err == nfs_ok);
1739 if (err) 1756 if (host_err)
1740 err = nfserrno(err); 1757 err = nfserrno(host_err);
1741 else 1758 else
1742 err = cdp->err; 1759 err = cdp->err;
1743 *offsetp = vfs_llseek(file, 0, 1); 1760 *offsetp = vfs_llseek(file, 0, 1);
@@ -1754,10 +1771,10 @@ out:
1754 * Get file system stats 1771 * Get file system stats
1755 * N.B. After this call fhp needs an fh_put 1772 * N.B. After this call fhp needs an fh_put
1756 */ 1773 */
1757int 1774__be32
1758nfsd_statfs(struct svc_rqst *rqstp, struct svc_fh *fhp, struct kstatfs *stat) 1775nfsd_statfs(struct svc_rqst *rqstp, struct svc_fh *fhp, struct kstatfs *stat)
1759{ 1776{
1760 int err = fh_verify(rqstp, fhp, 0, MAY_NOP); 1777 __be32 err = fh_verify(rqstp, fhp, 0, MAY_NOP);
1761 if (!err && vfs_statfs(fhp->fh_dentry,stat)) 1778 if (!err && vfs_statfs(fhp->fh_dentry,stat))
1762 err = nfserr_io; 1779 err = nfserr_io;
1763 return err; 1780 return err;
@@ -1766,7 +1783,7 @@ nfsd_statfs(struct svc_rqst *rqstp, struct svc_fh *fhp, struct kstatfs *stat)
1766/* 1783/*
1767 * Check for a user's access permissions to this inode. 1784 * Check for a user's access permissions to this inode.
1768 */ 1785 */
1769int 1786__be32
1770nfsd_permission(struct svc_export *exp, struct dentry *dentry, int acc) 1787nfsd_permission(struct svc_export *exp, struct dentry *dentry, int acc)
1771{ 1788{
1772 struct inode *inode = dentry->d_inode; 1789 struct inode *inode = dentry->d_inode;
diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c
index e1fceb8aa32d..d11753c50bc1 100644
--- a/fs/ocfs2/cluster/nodemanager.c
+++ b/fs/ocfs2/cluster/nodemanager.c
@@ -152,14 +152,16 @@ static struct o2nm_node *o2nm_node_ip_tree_lookup(struct o2nm_cluster *cluster,
152 struct o2nm_node *node, *ret = NULL; 152 struct o2nm_node *node, *ret = NULL;
153 153
154 while (*p) { 154 while (*p) {
155 int cmp;
156
155 parent = *p; 157 parent = *p;
156 node = rb_entry(parent, struct o2nm_node, nd_ip_node); 158 node = rb_entry(parent, struct o2nm_node, nd_ip_node);
157 159
158 if (memcmp(&ip_needle, &node->nd_ipv4_address, 160 cmp = memcmp(&ip_needle, &node->nd_ipv4_address,
159 sizeof(ip_needle)) < 0) 161 sizeof(ip_needle));
162 if (cmp < 0)
160 p = &(*p)->rb_left; 163 p = &(*p)->rb_left;
161 else if (memcmp(&ip_needle, &node->nd_ipv4_address, 164 else if (cmp > 0)
162 sizeof(ip_needle)) > 0)
163 p = &(*p)->rb_right; 165 p = &(*p)->rb_right;
164 else { 166 else {
165 ret = node; 167 ret = node;
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index d9ba0a931a03..1be74c4e7814 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -30,6 +30,7 @@
30#include <linux/highmem.h> 30#include <linux/highmem.h>
31#include <linux/pagemap.h> 31#include <linux/pagemap.h>
32#include <linux/uio.h> 32#include <linux/uio.h>
33#include <linux/sched.h>
33 34
34#define MLOG_MASK_PREFIX ML_INODE 35#define MLOG_MASK_PREFIX ML_INODE
35#include <cluster/masklog.h> 36#include <cluster/masklog.h>
@@ -691,6 +692,12 @@ static int ocfs2_zero_extend(struct inode *inode,
691 } 692 }
692 693
693 start_off += sb->s_blocksize; 694 start_off += sb->s_blocksize;
695
696 /*
697 * Very large extends have the potential to lock up
698 * the cpu for extended periods of time.
699 */
700 cond_resched();
694 } 701 }
695 702
696out: 703out:
@@ -728,31 +735,36 @@ static int ocfs2_extend_file(struct inode *inode,
728 clusters_to_add = ocfs2_clusters_for_bytes(inode->i_sb, new_i_size) - 735 clusters_to_add = ocfs2_clusters_for_bytes(inode->i_sb, new_i_size) -
729 OCFS2_I(inode)->ip_clusters; 736 OCFS2_I(inode)->ip_clusters;
730 737
731 if (clusters_to_add) { 738 /*
732 /* 739 * protect the pages that ocfs2_zero_extend is going to be
733 * protect the pages that ocfs2_zero_extend is going to 740 * pulling into the page cache.. we do this before the
734 * be pulling into the page cache.. we do this before the 741 * metadata extend so that we don't get into the situation
735 * metadata extend so that we don't get into the situation 742 * where we've extended the metadata but can't get the data
736 * where we've extended the metadata but can't get the data 743 * lock to zero.
737 * lock to zero. 744 */
738 */ 745 ret = ocfs2_data_lock(inode, 1);
739 ret = ocfs2_data_lock(inode, 1); 746 if (ret < 0) {
740 if (ret < 0) { 747 mlog_errno(ret);
741 mlog_errno(ret); 748 goto out;
742 goto out; 749 }
743 }
744 750
751 if (clusters_to_add) {
745 ret = ocfs2_extend_allocation(inode, clusters_to_add); 752 ret = ocfs2_extend_allocation(inode, clusters_to_add);
746 if (ret < 0) { 753 if (ret < 0) {
747 mlog_errno(ret); 754 mlog_errno(ret);
748 goto out_unlock; 755 goto out_unlock;
749 } 756 }
757 }
750 758
751 ret = ocfs2_zero_extend(inode, (u64)new_i_size - tail_to_skip); 759 /*
752 if (ret < 0) { 760 * Call this even if we don't add any clusters to the tree. We
753 mlog_errno(ret); 761 * still need to zero the area between the old i_size and the
754 goto out_unlock; 762 * new i_size.
755 } 763 */
764 ret = ocfs2_zero_extend(inode, (u64)new_i_size - tail_to_skip);
765 if (ret < 0) {
766 mlog_errno(ret);
767 goto out_unlock;
756 } 768 }
757 769
758 if (!tail_to_skip) { 770 if (!tail_to_skip) {
@@ -764,8 +776,7 @@ static int ocfs2_extend_file(struct inode *inode,
764 } 776 }
765 777
766out_unlock: 778out_unlock:
767 if (clusters_to_add) /* this is the only case in which we lock */ 779 ocfs2_data_unlock(inode, 1);
768 ocfs2_data_unlock(inode, 1);
769 780
770out: 781out:
771 return ret; 782 return ret;
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 259155f0eb2e..a57b751d4f40 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -1085,14 +1085,6 @@ static int ocfs2_rename(struct inode *old_dir,
1085 BUG(); 1085 BUG();
1086 } 1086 }
1087 1087
1088 if (atomic_read(&old_dentry->d_count) > 2) {
1089 shrink_dcache_parent(old_dentry);
1090 if (atomic_read(&old_dentry->d_count) > 2) {
1091 status = -EBUSY;
1092 goto bail;
1093 }
1094 }
1095
1096 /* Assume a directory heirarchy thusly: 1088 /* Assume a directory heirarchy thusly:
1097 * a/b/c 1089 * a/b/c
1098 * a/d 1090 * a/d
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 4c29cd7cc8e6..76b46ebbb10c 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -339,7 +339,7 @@ static unsigned long long ocfs2_max_file_offset(unsigned int blockshift)
339 339
340#if BITS_PER_LONG == 32 340#if BITS_PER_LONG == 32
341# if defined(CONFIG_LBD) 341# if defined(CONFIG_LBD)
342 BUG_ON(sizeof(sector_t) != 8); 342 BUILD_BUG_ON(sizeof(sector_t) != 8);
343 pagefactor = PAGE_CACHE_SIZE; 343 pagefactor = PAGE_CACHE_SIZE;
344 bitshift = BITS_PER_LONG; 344 bitshift = BITS_PER_LONG;
345# else 345# else
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 51c6a748df49..6fb4b6150d77 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -376,18 +376,48 @@ static char *make_block_name(struct gendisk *disk)
376 return name; 376 return name;
377} 377}
378 378
379static void disk_sysfs_symlinks(struct gendisk *disk) 379static int disk_sysfs_symlinks(struct gendisk *disk)
380{ 380{
381 struct device *target = get_device(disk->driverfs_dev); 381 struct device *target = get_device(disk->driverfs_dev);
382 int err;
383 char *disk_name = NULL;
384
382 if (target) { 385 if (target) {
383 char *disk_name = make_block_name(disk); 386 disk_name = make_block_name(disk);
384 sysfs_create_link(&disk->kobj,&target->kobj,"device"); 387 if (!disk_name) {
385 if (disk_name) { 388 err = -ENOMEM;
386 sysfs_create_link(&target->kobj,&disk->kobj,disk_name); 389 goto err_out;
387 kfree(disk_name);
388 } 390 }
391
392 err = sysfs_create_link(&disk->kobj, &target->kobj, "device");
393 if (err)
394 goto err_out_disk_name;
395
396 err = sysfs_create_link(&target->kobj, &disk->kobj, disk_name);
397 if (err)
398 goto err_out_dev_link;
389 } 399 }
390 sysfs_create_link(&disk->kobj, &block_subsys.kset.kobj, "subsystem"); 400
401 err = sysfs_create_link(&disk->kobj, &block_subsys.kset.kobj,
402 "subsystem");
403 if (err)
404 goto err_out_disk_name_lnk;
405
406 kfree(disk_name);
407
408 return 0;
409
410err_out_disk_name_lnk:
411 if (target) {
412 sysfs_remove_link(&target->kobj, disk_name);
413err_out_dev_link:
414 sysfs_remove_link(&disk->kobj, "device");
415err_out_disk_name:
416 kfree(disk_name);
417err_out:
418 put_device(target);
419 }
420 return err;
391} 421}
392 422
393/* Not exported, helper to add_disk(). */ 423/* Not exported, helper to add_disk(). */
@@ -406,7 +436,11 @@ void register_disk(struct gendisk *disk)
406 *s = '!'; 436 *s = '!';
407 if ((err = kobject_add(&disk->kobj))) 437 if ((err = kobject_add(&disk->kobj)))
408 return; 438 return;
409 disk_sysfs_symlinks(disk); 439 err = disk_sysfs_symlinks(disk);
440 if (err) {
441 kobject_del(&disk->kobj);
442 return;
443 }
410 disk_sysfs_add_subdirs(disk); 444 disk_sysfs_add_subdirs(disk);
411 445
412 /* No minors to use for partitions */ 446 /* No minors to use for partitions */
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 82da55b5cffe..8df27401d292 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -72,6 +72,7 @@
72#include <linux/audit.h> 72#include <linux/audit.h>
73#include <linux/poll.h> 73#include <linux/poll.h>
74#include <linux/nsproxy.h> 74#include <linux/nsproxy.h>
75#include <linux/oom.h>
75#include "internal.h" 76#include "internal.h"
76 77
77/* NOTE: 78/* NOTE:
@@ -86,7 +87,7 @@
86 87
87 88
88/* Worst case buffer size needed for holding an integer. */ 89/* Worst case buffer size needed for holding an integer. */
89#define PROC_NUMBUF 10 90#define PROC_NUMBUF 13
90 91
91struct pid_entry { 92struct pid_entry {
92 int len; 93 int len;
@@ -689,7 +690,8 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf,
689 if (copy_from_user(buffer, buf, count)) 690 if (copy_from_user(buffer, buf, count))
690 return -EFAULT; 691 return -EFAULT;
691 oom_adjust = simple_strtol(buffer, &end, 0); 692 oom_adjust = simple_strtol(buffer, &end, 0);
692 if ((oom_adjust < -16 || oom_adjust > 15) && oom_adjust != OOM_DISABLE) 693 if ((oom_adjust < OOM_ADJUST_MIN || oom_adjust > OOM_ADJUST_MAX) &&
694 oom_adjust != OOM_DISABLE)
693 return -EINVAL; 695 return -EINVAL;
694 if (*end == '\n') 696 if (*end == '\n')
695 end++; 697 end++;
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
index ad8cbc49883a..85ce23268302 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -53,6 +53,7 @@
53#include <linux/workqueue.h> 53#include <linux/workqueue.h>
54#include <linux/writeback.h> 54#include <linux/writeback.h>
55#include <linux/blkdev.h> 55#include <linux/blkdev.h>
56#include <linux/backing-dev.h>
56 57
57/* gets a struct reiserfs_journal_list * from a list head */ 58/* gets a struct reiserfs_journal_list * from a list head */
58#define JOURNAL_LIST_ENTRY(h) (list_entry((h), struct reiserfs_journal_list, \ 59#define JOURNAL_LIST_ENTRY(h) (list_entry((h), struct reiserfs_journal_list, \
@@ -970,7 +971,7 @@ int reiserfs_async_progress_wait(struct super_block *s)
970 DEFINE_WAIT(wait); 971 DEFINE_WAIT(wait);
971 struct reiserfs_journal *j = SB_JOURNAL(s); 972 struct reiserfs_journal *j = SB_JOURNAL(s);
972 if (atomic_read(&j->j_async_throttle)) 973 if (atomic_read(&j->j_async_throttle))
973 blk_congestion_wait(WRITE, HZ / 10); 974 congestion_wait(WRITE, HZ / 10);
974 return 0; 975 return 0;
975} 976}
976 977
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index c89aa2338191..17249994110f 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -430,20 +430,29 @@ int remove_save_link(struct inode *inode, int truncate)
430 return journal_end(&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT); 430 return journal_end(&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT);
431} 431}
432 432
433static void reiserfs_put_super(struct super_block *s) 433static void reiserfs_kill_sb(struct super_block *s)
434{ 434{
435 struct reiserfs_transaction_handle th; 435 if (REISERFS_SB(s)) {
436 th.t_trans_id = 0; 436 if (REISERFS_SB(s)->xattr_root) {
437 d_invalidate(REISERFS_SB(s)->xattr_root);
438 dput(REISERFS_SB(s)->xattr_root);
439 REISERFS_SB(s)->xattr_root = NULL;
440 }
437 441
438 if (REISERFS_SB(s)->xattr_root) { 442 if (REISERFS_SB(s)->priv_root) {
439 d_invalidate(REISERFS_SB(s)->xattr_root); 443 d_invalidate(REISERFS_SB(s)->priv_root);
440 dput(REISERFS_SB(s)->xattr_root); 444 dput(REISERFS_SB(s)->priv_root);
445 REISERFS_SB(s)->priv_root = NULL;
446 }
441 } 447 }
442 448
443 if (REISERFS_SB(s)->priv_root) { 449 kill_block_super(s);
444 d_invalidate(REISERFS_SB(s)->priv_root); 450}
445 dput(REISERFS_SB(s)->priv_root); 451
446 } 452static void reiserfs_put_super(struct super_block *s)
453{
454 struct reiserfs_transaction_handle th;
455 th.t_trans_id = 0;
447 456
448 /* change file system state to current state if it was mounted with read-write permissions */ 457 /* change file system state to current state if it was mounted with read-write permissions */
449 if (!(s->s_flags & MS_RDONLY)) { 458 if (!(s->s_flags & MS_RDONLY)) {
@@ -1610,6 +1619,7 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
1610 "jmacd-8: reiserfs_fill_super: unable to read bitmap"); 1619 "jmacd-8: reiserfs_fill_super: unable to read bitmap");
1611 goto error; 1620 goto error;
1612 } 1621 }
1622 errval = -EINVAL;
1613#ifdef CONFIG_REISERFS_CHECK 1623#ifdef CONFIG_REISERFS_CHECK
1614 SWARN(silent, s, "CONFIG_REISERFS_CHECK is set ON"); 1624 SWARN(silent, s, "CONFIG_REISERFS_CHECK is set ON");
1615 SWARN(silent, s, "- it is slow mode for debugging."); 1625 SWARN(silent, s, "- it is slow mode for debugging.");
@@ -2156,7 +2166,7 @@ struct file_system_type reiserfs_fs_type = {
2156 .owner = THIS_MODULE, 2166 .owner = THIS_MODULE,
2157 .name = "reiserfs", 2167 .name = "reiserfs",
2158 .get_sb = get_super_block, 2168 .get_sb = get_super_block,
2159 .kill_sb = kill_block_super, 2169 .kill_sb = reiserfs_kill_sb,
2160 .fs_flags = FS_REQUIRES_DEV, 2170 .fs_flags = FS_REQUIRES_DEV,
2161}; 2171};
2162 2172
diff --git a/fs/splice.c b/fs/splice.c
index 13e92dd19fbb..da74583a00ee 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -74,7 +74,7 @@ static int page_cache_pipe_buf_steal(struct pipe_inode_info *pipe,
74 wait_on_page_writeback(page); 74 wait_on_page_writeback(page);
75 75
76 if (PagePrivate(page)) 76 if (PagePrivate(page))
77 try_to_release_page(page, mapping_gfp_mask(mapping)); 77 try_to_release_page(page, GFP_KERNEL);
78 78
79 /* 79 /*
80 * If we succeeded in removing the mapping, set LRU flag 80 * If we succeeded in removing the mapping, set LRU flag
@@ -333,7 +333,7 @@ __generic_file_splice_read(struct file *in, loff_t *ppos,
333 break; 333 break;
334 334
335 error = add_to_page_cache_lru(page, mapping, index, 335 error = add_to_page_cache_lru(page, mapping, index,
336 mapping_gfp_mask(mapping)); 336 GFP_KERNEL);
337 if (unlikely(error)) { 337 if (unlikely(error)) {
338 page_cache_release(page); 338 page_cache_release(page);
339 if (error == -EEXIST) 339 if (error == -EEXIST)
@@ -557,7 +557,6 @@ static int pipe_to_file(struct pipe_inode_info *pipe, struct pipe_buffer *buf,
557{ 557{
558 struct file *file = sd->file; 558 struct file *file = sd->file;
559 struct address_space *mapping = file->f_mapping; 559 struct address_space *mapping = file->f_mapping;
560 gfp_t gfp_mask = mapping_gfp_mask(mapping);
561 unsigned int offset, this_len; 560 unsigned int offset, this_len;
562 struct page *page; 561 struct page *page;
563 pgoff_t index; 562 pgoff_t index;
@@ -591,7 +590,7 @@ static int pipe_to_file(struct pipe_inode_info *pipe, struct pipe_buffer *buf,
591 goto find_page; 590 goto find_page;
592 591
593 page = buf->page; 592 page = buf->page;
594 if (add_to_page_cache(page, mapping, index, gfp_mask)) { 593 if (add_to_page_cache(page, mapping, index, GFP_KERNEL)) {
595 unlock_page(page); 594 unlock_page(page);
596 goto find_page; 595 goto find_page;
597 } 596 }
@@ -607,13 +606,13 @@ find_page:
607 ret = -ENOMEM; 606 ret = -ENOMEM;
608 page = page_cache_alloc_cold(mapping); 607 page = page_cache_alloc_cold(mapping);
609 if (unlikely(!page)) 608 if (unlikely(!page))
610 goto out_nomem; 609 goto out_ret;
611 610
612 /* 611 /*
613 * This will also lock the page 612 * This will also lock the page
614 */ 613 */
615 ret = add_to_page_cache_lru(page, mapping, index, 614 ret = add_to_page_cache_lru(page, mapping, index,
616 gfp_mask); 615 GFP_KERNEL);
617 if (unlikely(ret)) 616 if (unlikely(ret))
618 goto out; 617 goto out;
619 } 618 }
@@ -666,7 +665,7 @@ find_page:
666 if (sd->pos + this_len > isize) 665 if (sd->pos + this_len > isize)
667 vmtruncate(mapping->host, isize); 666 vmtruncate(mapping->host, isize);
668 667
669 goto out; 668 goto out_ret;
670 } 669 }
671 670
672 if (buf->page != page) { 671 if (buf->page != page) {
@@ -698,7 +697,7 @@ find_page:
698out: 697out:
699 page_cache_release(page); 698 page_cache_release(page);
700 unlock_page(page); 699 unlock_page(page);
701out_nomem: 700out_ret:
702 return ret; 701 return ret;
703} 702}
704 703
@@ -707,9 +706,9 @@ out_nomem:
707 * key here is the 'actor' worker passed in that actually moves the data 706 * key here is the 'actor' worker passed in that actually moves the data
708 * to the wanted destination. See pipe_to_file/pipe_to_sendpage above. 707 * to the wanted destination. See pipe_to_file/pipe_to_sendpage above.
709 */ 708 */
710ssize_t splice_from_pipe(struct pipe_inode_info *pipe, struct file *out, 709static ssize_t __splice_from_pipe(struct pipe_inode_info *pipe,
711 loff_t *ppos, size_t len, unsigned int flags, 710 struct file *out, loff_t *ppos, size_t len,
712 splice_actor *actor) 711 unsigned int flags, splice_actor *actor)
713{ 712{
714 int ret, do_wakeup, err; 713 int ret, do_wakeup, err;
715 struct splice_desc sd; 714 struct splice_desc sd;
@@ -722,9 +721,6 @@ ssize_t splice_from_pipe(struct pipe_inode_info *pipe, struct file *out,
722 sd.file = out; 721 sd.file = out;
723 sd.pos = *ppos; 722 sd.pos = *ppos;
724 723
725 if (pipe->inode)
726 mutex_lock(&pipe->inode->i_mutex);
727
728 for (;;) { 724 for (;;) {
729 if (pipe->nrbufs) { 725 if (pipe->nrbufs) {
730 struct pipe_buffer *buf = pipe->bufs + pipe->curbuf; 726 struct pipe_buffer *buf = pipe->bufs + pipe->curbuf;
@@ -797,9 +793,6 @@ ssize_t splice_from_pipe(struct pipe_inode_info *pipe, struct file *out,
797 pipe_wait(pipe); 793 pipe_wait(pipe);
798 } 794 }
799 795
800 if (pipe->inode)
801 mutex_unlock(&pipe->inode->i_mutex);
802
803 if (do_wakeup) { 796 if (do_wakeup) {
804 smp_mb(); 797 smp_mb();
805 if (waitqueue_active(&pipe->wait)) 798 if (waitqueue_active(&pipe->wait))
@@ -810,6 +803,73 @@ ssize_t splice_from_pipe(struct pipe_inode_info *pipe, struct file *out,
810 return ret; 803 return ret;
811} 804}
812 805
806ssize_t splice_from_pipe(struct pipe_inode_info *pipe, struct file *out,
807 loff_t *ppos, size_t len, unsigned int flags,
808 splice_actor *actor)
809{
810 ssize_t ret;
811 struct inode *inode = out->f_mapping->host;
812
813 /*
814 * The actor worker might be calling ->prepare_write and
815 * ->commit_write. Most of the time, these expect i_mutex to
816 * be held. Since this may result in an ABBA deadlock with
817 * pipe->inode, we have to order lock acquiry here.
818 */
819 inode_double_lock(inode, pipe->inode);
820 ret = __splice_from_pipe(pipe, out, ppos, len, flags, actor);
821 inode_double_unlock(inode, pipe->inode);
822
823 return ret;
824}
825
826/**
827 * generic_file_splice_write_nolock - generic_file_splice_write without mutexes
828 * @pipe: pipe info
829 * @out: file to write to
830 * @len: number of bytes to splice
831 * @flags: splice modifier flags
832 *
833 * Will either move or copy pages (determined by @flags options) from
834 * the given pipe inode to the given file. The caller is responsible
835 * for acquiring i_mutex on both inodes.
836 *
837 */
838ssize_t
839generic_file_splice_write_nolock(struct pipe_inode_info *pipe, struct file *out,
840 loff_t *ppos, size_t len, unsigned int flags)
841{
842 struct address_space *mapping = out->f_mapping;
843 struct inode *inode = mapping->host;
844 ssize_t ret;
845 int err;
846
847 err = remove_suid(out->f_dentry);
848 if (unlikely(err))
849 return err;
850
851 ret = __splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_file);
852 if (ret > 0) {
853 *ppos += ret;
854
855 /*
856 * If file or inode is SYNC and we actually wrote some data,
857 * sync it.
858 */
859 if (unlikely((out->f_flags & O_SYNC) || IS_SYNC(inode))) {
860 err = generic_osync_inode(inode, mapping,
861 OSYNC_METADATA|OSYNC_DATA);
862
863 if (err)
864 ret = err;
865 }
866 }
867
868 return ret;
869}
870
871EXPORT_SYMBOL(generic_file_splice_write_nolock);
872
813/** 873/**
814 * generic_file_splice_write - splice data from a pipe to a file 874 * generic_file_splice_write - splice data from a pipe to a file
815 * @pipe: pipe info 875 * @pipe: pipe info
@@ -826,12 +886,21 @@ generic_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
826 loff_t *ppos, size_t len, unsigned int flags) 886 loff_t *ppos, size_t len, unsigned int flags)
827{ 887{
828 struct address_space *mapping = out->f_mapping; 888 struct address_space *mapping = out->f_mapping;
889 struct inode *inode = mapping->host;
829 ssize_t ret; 890 ssize_t ret;
891 int err;
892
893 err = should_remove_suid(out->f_dentry);
894 if (unlikely(err)) {
895 mutex_lock(&inode->i_mutex);
896 err = __remove_suid(out->f_dentry, err);
897 mutex_unlock(&inode->i_mutex);
898 if (err)
899 return err;
900 }
830 901
831 ret = splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_file); 902 ret = splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_file);
832 if (ret > 0) { 903 if (ret > 0) {
833 struct inode *inode = mapping->host;
834
835 *ppos += ret; 904 *ppos += ret;
836 905
837 /* 906 /*
@@ -839,8 +908,6 @@ generic_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
839 * sync it. 908 * sync it.
840 */ 909 */
841 if (unlikely((out->f_flags & O_SYNC) || IS_SYNC(inode))) { 910 if (unlikely((out->f_flags & O_SYNC) || IS_SYNC(inode))) {
842 int err;
843
844 mutex_lock(&inode->i_mutex); 911 mutex_lock(&inode->i_mutex);
845 err = generic_osync_inode(inode, mapping, 912 err = generic_osync_inode(inode, mapping,
846 OSYNC_METADATA|OSYNC_DATA); 913 OSYNC_METADATA|OSYNC_DATA);
@@ -1042,6 +1109,19 @@ out_release:
1042EXPORT_SYMBOL(do_splice_direct); 1109EXPORT_SYMBOL(do_splice_direct);
1043 1110
1044/* 1111/*
1112 * After the inode slimming patch, i_pipe/i_bdev/i_cdev share the same
1113 * location, so checking ->i_pipe is not enough to verify that this is a
1114 * pipe.
1115 */
1116static inline struct pipe_inode_info *pipe_info(struct inode *inode)
1117{
1118 if (S_ISFIFO(inode->i_mode))
1119 return inode->i_pipe;
1120
1121 return NULL;
1122}
1123
1124/*
1045 * Determine where to splice to/from. 1125 * Determine where to splice to/from.
1046 */ 1126 */
1047static long do_splice(struct file *in, loff_t __user *off_in, 1127static long do_splice(struct file *in, loff_t __user *off_in,
@@ -1052,7 +1132,7 @@ static long do_splice(struct file *in, loff_t __user *off_in,
1052 loff_t offset, *off; 1132 loff_t offset, *off;
1053 long ret; 1133 long ret;
1054 1134
1055 pipe = in->f_dentry->d_inode->i_pipe; 1135 pipe = pipe_info(in->f_dentry->d_inode);
1056 if (pipe) { 1136 if (pipe) {
1057 if (off_in) 1137 if (off_in)
1058 return -ESPIPE; 1138 return -ESPIPE;
@@ -1073,7 +1153,7 @@ static long do_splice(struct file *in, loff_t __user *off_in,
1073 return ret; 1153 return ret;
1074 } 1154 }
1075 1155
1076 pipe = out->f_dentry->d_inode->i_pipe; 1156 pipe = pipe_info(out->f_dentry->d_inode);
1077 if (pipe) { 1157 if (pipe) {
1078 if (off_out) 1158 if (off_out)
1079 return -ESPIPE; 1159 return -ESPIPE;
@@ -1231,7 +1311,7 @@ static int get_iovec_page_array(const struct iovec __user *iov,
1231static long do_vmsplice(struct file *file, const struct iovec __user *iov, 1311static long do_vmsplice(struct file *file, const struct iovec __user *iov,
1232 unsigned long nr_segs, unsigned int flags) 1312 unsigned long nr_segs, unsigned int flags)
1233{ 1313{
1234 struct pipe_inode_info *pipe = file->f_dentry->d_inode->i_pipe; 1314 struct pipe_inode_info *pipe;
1235 struct page *pages[PIPE_BUFFERS]; 1315 struct page *pages[PIPE_BUFFERS];
1236 struct partial_page partial[PIPE_BUFFERS]; 1316 struct partial_page partial[PIPE_BUFFERS];
1237 struct splice_pipe_desc spd = { 1317 struct splice_pipe_desc spd = {
@@ -1241,7 +1321,8 @@ static long do_vmsplice(struct file *file, const struct iovec __user *iov,
1241 .ops = &user_page_pipe_buf_ops, 1321 .ops = &user_page_pipe_buf_ops,
1242 }; 1322 };
1243 1323
1244 if (unlikely(!pipe)) 1324 pipe = pipe_info(file->f_dentry->d_inode);
1325 if (!pipe)
1245 return -EBADF; 1326 return -EBADF;
1246 if (unlikely(nr_segs > UIO_MAXIOV)) 1327 if (unlikely(nr_segs > UIO_MAXIOV))
1247 return -EINVAL; 1328 return -EINVAL;
@@ -1400,13 +1481,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
1400 * grabbing by inode address. Otherwise two different processes 1481 * grabbing by inode address. Otherwise two different processes
1401 * could deadlock (one doing tee from A -> B, the other from B -> A). 1482 * could deadlock (one doing tee from A -> B, the other from B -> A).
1402 */ 1483 */
1403 if (ipipe->inode < opipe->inode) { 1484 inode_double_lock(ipipe->inode, opipe->inode);
1404 mutex_lock_nested(&ipipe->inode->i_mutex, I_MUTEX_PARENT);
1405 mutex_lock_nested(&opipe->inode->i_mutex, I_MUTEX_CHILD);
1406 } else {
1407 mutex_lock_nested(&opipe->inode->i_mutex, I_MUTEX_PARENT);
1408 mutex_lock_nested(&ipipe->inode->i_mutex, I_MUTEX_CHILD);
1409 }
1410 1485
1411 do { 1486 do {
1412 if (!opipe->readers) { 1487 if (!opipe->readers) {
@@ -1450,8 +1525,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
1450 i++; 1525 i++;
1451 } while (len); 1526 } while (len);
1452 1527
1453 mutex_unlock(&ipipe->inode->i_mutex); 1528 inode_double_unlock(ipipe->inode, opipe->inode);
1454 mutex_unlock(&opipe->inode->i_mutex);
1455 1529
1456 /* 1530 /*
1457 * If we put data in the output pipe, wakeup any potential readers. 1531 * If we put data in the output pipe, wakeup any potential readers.
@@ -1475,8 +1549,8 @@ static int link_pipe(struct pipe_inode_info *ipipe,
1475static long do_tee(struct file *in, struct file *out, size_t len, 1549static long do_tee(struct file *in, struct file *out, size_t len,
1476 unsigned int flags) 1550 unsigned int flags)
1477{ 1551{
1478 struct pipe_inode_info *ipipe = in->f_dentry->d_inode->i_pipe; 1552 struct pipe_inode_info *ipipe = pipe_info(in->f_dentry->d_inode);
1479 struct pipe_inode_info *opipe = out->f_dentry->d_inode->i_pipe; 1553 struct pipe_inode_info *opipe = pipe_info(out->f_dentry->d_inode);
1480 int ret = -EINVAL; 1554 int ret = -EINVAL;
1481 1555
1482 /* 1556 /*
diff --git a/fs/super.c b/fs/super.c
index aec99ddbe53f..47e554c12e76 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -260,17 +260,17 @@ int fsync_super(struct super_block *sb)
260 * that need destruction out of superblock, call generic_shutdown_super() 260 * that need destruction out of superblock, call generic_shutdown_super()
261 * and release aforementioned objects. Note: dentries and inodes _are_ 261 * and release aforementioned objects. Note: dentries and inodes _are_
262 * taken care of and do not need specific handling. 262 * taken care of and do not need specific handling.
263 *
264 * Upon calling this function, the filesystem may no longer alter or
265 * rearrange the set of dentries belonging to this super_block, nor may it
266 * change the attachments of dentries to inodes.
263 */ 267 */
264void generic_shutdown_super(struct super_block *sb) 268void generic_shutdown_super(struct super_block *sb)
265{ 269{
266 struct dentry *root = sb->s_root;
267 struct super_operations *sop = sb->s_op; 270 struct super_operations *sop = sb->s_op;
268 271
269 if (root) { 272 if (sb->s_root) {
270 sb->s_root = NULL; 273 shrink_dcache_for_umount(sb);
271 shrink_dcache_parent(root);
272 shrink_dcache_sb(sb);
273 dput(root);
274 fsync_super(sb); 274 fsync_super(sb);
275 lock_super(sb); 275 lock_super(sb);
276 sb->s_flags &= ~MS_ACTIVE; 276 sb->s_flags &= ~MS_ACTIVE;
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 146f1dedec84..298303b5a716 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -483,17 +483,12 @@ int sysfs_update_file(struct kobject * kobj, const struct attribute * attr)
483 (victim->d_parent->d_inode == dir->d_inode)) { 483 (victim->d_parent->d_inode == dir->d_inode)) {
484 victim->d_inode->i_mtime = CURRENT_TIME; 484 victim->d_inode->i_mtime = CURRENT_TIME;
485 fsnotify_modify(victim); 485 fsnotify_modify(victim);
486
487 /**
488 * Drop reference from initial sysfs_get_dentry().
489 */
490 dput(victim);
491 res = 0; 486 res = 0;
492 } else 487 } else
493 d_drop(victim); 488 d_drop(victim);
494 489
495 /** 490 /**
496 * Drop the reference acquired from sysfs_get_dentry() above. 491 * Drop the reference acquired from lookup_one_len() above.
497 */ 492 */
498 dput(victim); 493 dput(victim);
499 } 494 }
diff --git a/fs/sysv/super.c b/fs/sysv/super.c
index 350cba5d6803..dc9e7dc07fb7 100644
--- a/fs/sysv/super.c
+++ b/fs/sysv/super.c
@@ -358,16 +358,11 @@ static int sysv_fill_super(struct super_block *sb, void *data, int silent)
358 unsigned long blocknr; 358 unsigned long blocknr;
359 int size = 0, i; 359 int size = 0, i;
360 360
361 if (1024 != sizeof (struct xenix_super_block)) 361 BUILD_BUG_ON(1024 != sizeof (struct xenix_super_block));
362 panic("Xenix FS: bad superblock size"); 362 BUILD_BUG_ON(512 != sizeof (struct sysv4_super_block));
363 if (512 != sizeof (struct sysv4_super_block)) 363 BUILD_BUG_ON(512 != sizeof (struct sysv2_super_block));
364 panic("SystemV FS: bad superblock size"); 364 BUILD_BUG_ON(500 != sizeof (struct coh_super_block));
365 if (512 != sizeof (struct sysv2_super_block)) 365 BUILD_BUG_ON(64 != sizeof (struct sysv_inode));
366 panic("SystemV FS: bad superblock size");
367 if (500 != sizeof (struct coh_super_block))
368 panic("Coherent FS: bad superblock size");
369 if (64 != sizeof (struct sysv_inode))
370 panic("sysv fs: bad inode size");
371 366
372 sbi = kzalloc(sizeof(struct sysv_sb_info), GFP_KERNEL); 367 sbi = kzalloc(sizeof(struct sysv_sb_info), GFP_KERNEL);
373 if (!sbi) 368 if (!sbi)
diff --git a/fs/vfat/namei.c b/fs/vfat/namei.c
index edb711ff7b05..0afd745a37cd 100644
--- a/fs/vfat/namei.c
+++ b/fs/vfat/namei.c
@@ -1004,6 +1004,7 @@ static struct inode_operations vfat_dir_inode_operations = {
1004 .rmdir = vfat_rmdir, 1004 .rmdir = vfat_rmdir,
1005 .rename = vfat_rename, 1005 .rename = vfat_rename,
1006 .setattr = fat_notify_change, 1006 .setattr = fat_notify_change,
1007 .getattr = fat_getattr,
1007}; 1008};
1008 1009
1009static int vfat_fill_super(struct super_block *sb, void *data, int silent) 1010static int vfat_fill_super(struct super_block *sb, void *data, int silent)
diff --git a/fs/xattr.c b/fs/xattr.c
index 395635100f77..0901bdc2ce24 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -48,14 +48,21 @@ xattr_permission(struct inode *inode, const char *name, int mask)
48 return 0; 48 return 0;
49 49
50 /* 50 /*
51 * The trusted.* namespace can only accessed by a privilegued user. 51 * The trusted.* namespace can only be accessed by a privileged user.
52 */ 52 */
53 if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN)) 53 if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN))
54 return (capable(CAP_SYS_ADMIN) ? 0 : -EPERM); 54 return (capable(CAP_SYS_ADMIN) ? 0 : -EPERM);
55 55
56 /* In user.* namespace, only regular files and directories can have
57 * extended attributes. For sticky directories, only the owner and
58 * privileged user can write attributes.
59 */
56 if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) { 60 if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
57 if (!S_ISREG(inode->i_mode) && 61 if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode))
58 (!S_ISDIR(inode->i_mode) || inode->i_mode & S_ISVTX)) 62 return -EPERM;
63 if (S_ISDIR(inode->i_mode) && (inode->i_mode & S_ISVTX) &&
64 (mask & MAY_WRITE) && (current->fsuid != inode->i_uid) &&
65 !capable(CAP_FOWNER))
59 return -EPERM; 66 return -EPERM;
60 } 67 }
61 68
diff --git a/fs/xfs/Makefile-linux-2.6 b/fs/xfs/Makefile-linux-2.6
index 291948d5085a..b49989bb89ad 100644
--- a/fs/xfs/Makefile-linux-2.6
+++ b/fs/xfs/Makefile-linux-2.6
@@ -21,22 +21,7 @@ EXTRA_CFLAGS += -Ifs/xfs -Ifs/xfs/linux-2.6 -funsigned-char
21XFS_LINUX := linux-2.6 21XFS_LINUX := linux-2.6
22 22
23ifeq ($(CONFIG_XFS_DEBUG),y) 23ifeq ($(CONFIG_XFS_DEBUG),y)
24 EXTRA_CFLAGS += -g -DSTATIC="" -DDEBUG 24 EXTRA_CFLAGS += -g
25 EXTRA_CFLAGS += -DXFS_BUF_LOCK_TRACKING
26endif
27ifeq ($(CONFIG_XFS_TRACE),y)
28 EXTRA_CFLAGS += -DXFS_ALLOC_TRACE
29 EXTRA_CFLAGS += -DXFS_ATTR_TRACE
30 EXTRA_CFLAGS += -DXFS_BLI_TRACE
31 EXTRA_CFLAGS += -DXFS_BMAP_TRACE
32 EXTRA_CFLAGS += -DXFS_BMBT_TRACE
33 EXTRA_CFLAGS += -DXFS_DIR2_TRACE
34 EXTRA_CFLAGS += -DXFS_DQUOT_TRACE
35 EXTRA_CFLAGS += -DXFS_ILOCK_TRACE
36 EXTRA_CFLAGS += -DXFS_LOG_TRACE
37 EXTRA_CFLAGS += -DXFS_RW_TRACE
38 EXTRA_CFLAGS += -DXFS_BUF_TRACE
39 EXTRA_CFLAGS += -DXFS_VNODE_TRACE
40endif 25endif
41 26
42obj-$(CONFIG_XFS_FS) += xfs.o 27obj-$(CONFIG_XFS_FS) += xfs.o
diff --git a/fs/xfs/linux-2.6/kmem.c b/fs/xfs/linux-2.6/kmem.c
index d59737589815..004baf600611 100644
--- a/fs/xfs/linux-2.6/kmem.c
+++ b/fs/xfs/linux-2.6/kmem.c
@@ -21,6 +21,7 @@
21#include <linux/highmem.h> 21#include <linux/highmem.h>
22#include <linux/swap.h> 22#include <linux/swap.h>
23#include <linux/blkdev.h> 23#include <linux/blkdev.h>
24#include <linux/backing-dev.h>
24#include "time.h" 25#include "time.h"
25#include "kmem.h" 26#include "kmem.h"
26 27
@@ -53,7 +54,7 @@ kmem_alloc(size_t size, unsigned int __nocast flags)
53 printk(KERN_ERR "XFS: possible memory allocation " 54 printk(KERN_ERR "XFS: possible memory allocation "
54 "deadlock in %s (mode:0x%x)\n", 55 "deadlock in %s (mode:0x%x)\n",
55 __FUNCTION__, lflags); 56 __FUNCTION__, lflags);
56 blk_congestion_wait(WRITE, HZ/50); 57 congestion_wait(WRITE, HZ/50);
57 } while (1); 58 } while (1);
58} 59}
59 60
@@ -131,7 +132,7 @@ kmem_zone_alloc(kmem_zone_t *zone, unsigned int __nocast flags)
131 printk(KERN_ERR "XFS: possible memory allocation " 132 printk(KERN_ERR "XFS: possible memory allocation "
132 "deadlock in %s (mode:0x%x)\n", 133 "deadlock in %s (mode:0x%x)\n",
133 __FUNCTION__, lflags); 134 __FUNCTION__, lflags);
134 blk_congestion_wait(WRITE, HZ/50); 135 congestion_wait(WRITE, HZ/50);
135 } while (1); 136 } while (1);
136} 137}
137 138
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index 9bbadafdcb00..d3382843698e 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -15,6 +15,7 @@
15 * along with this program; if not, write the Free Software Foundation, 15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */ 17 */
18#include "xfs.h"
18#include <linux/stddef.h> 19#include <linux/stddef.h>
19#include <linux/errno.h> 20#include <linux/errno.h>
20#include <linux/slab.h> 21#include <linux/slab.h>
@@ -30,7 +31,7 @@
30#include <linux/hash.h> 31#include <linux/hash.h>
31#include <linux/kthread.h> 32#include <linux/kthread.h>
32#include <linux/migrate.h> 33#include <linux/migrate.h>
33#include "xfs_linux.h" 34#include <linux/backing-dev.h>
34 35
35STATIC kmem_zone_t *xfs_buf_zone; 36STATIC kmem_zone_t *xfs_buf_zone;
36STATIC kmem_shaker_t xfs_buf_shake; 37STATIC kmem_shaker_t xfs_buf_shake;
@@ -395,7 +396,7 @@ _xfs_buf_lookup_pages(
395 396
396 XFS_STATS_INC(xb_page_retries); 397 XFS_STATS_INC(xb_page_retries);
397 xfsbufd_wakeup(0, gfp_mask); 398 xfsbufd_wakeup(0, gfp_mask);
398 blk_congestion_wait(WRITE, HZ/50); 399 congestion_wait(WRITE, HZ/50);
399 goto retry; 400 goto retry;
400 } 401 }
401 402
@@ -1405,7 +1406,7 @@ xfs_alloc_bufhash(
1405 btp->bt_hashshift = external ? 3 : 8; /* 8 or 256 buckets */ 1406 btp->bt_hashshift = external ? 3 : 8; /* 8 or 256 buckets */
1406 btp->bt_hashmask = (1 << btp->bt_hashshift) - 1; 1407 btp->bt_hashmask = (1 << btp->bt_hashshift) - 1;
1407 btp->bt_hash = kmem_zalloc((1 << btp->bt_hashshift) * 1408 btp->bt_hash = kmem_zalloc((1 << btp->bt_hashshift) *
1408 sizeof(xfs_bufhash_t), KM_SLEEP); 1409 sizeof(xfs_bufhash_t), KM_SLEEP | KM_LARGE);
1409 for (i = 0; i < (1 << btp->bt_hashshift); i++) { 1410 for (i = 0; i < (1 << btp->bt_hashshift); i++) {
1410 spin_lock_init(&btp->bt_hash[i].bh_lock); 1411 spin_lock_init(&btp->bt_hash[i].bh_lock);
1411 INIT_LIST_HEAD(&btp->bt_hash[i].bh_list); 1412 INIT_LIST_HEAD(&btp->bt_hash[i].bh_list);
diff --git a/fs/xfs/linux-2.6/xfs_dmapi_priv.h b/fs/xfs/linux-2.6/xfs_dmapi_priv.h
new file mode 100644
index 000000000000..a8b0b1685eed
--- /dev/null
+++ b/fs/xfs/linux-2.6/xfs_dmapi_priv.h
@@ -0,0 +1,28 @@
1/*
2 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
3 * All Rights Reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18#ifndef __XFS_DMAPI_PRIV_H__
19#define __XFS_DMAPI_PRIV_H__
20
21/*
22 * Based on IO_ISDIRECT, decide which i_ flag is set.
23 */
24#define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \
25 DM_FLAGS_IMUX : 0)
26#define DM_SEM_FLAG_WR (DM_FLAGS_IALLOCSEM_WR | DM_FLAGS_IMUX)
27
28#endif /*__XFS_DMAPI_PRIV_H__*/
diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c
index a74f854d91e6..74d094829a4d 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl.c
@@ -341,8 +341,11 @@ xfs_open_by_handle(
341 put_unused_fd(new_fd); 341 put_unused_fd(new_fd);
342 return -XFS_ERROR(-PTR_ERR(filp)); 342 return -XFS_ERROR(-PTR_ERR(filp));
343 } 343 }
344 if (inode->i_mode & S_IFREG) 344 if (inode->i_mode & S_IFREG) {
345 /* invisible operation should not change atime */
346 filp->f_flags |= O_NOATIME;
345 filp->f_op = &xfs_invis_file_operations; 347 filp->f_op = &xfs_invis_file_operations;
348 }
346 349
347 fd_install(new_fd, filp); 350 fd_install(new_fd, filp);
348 return new_fd; 351 return new_fd;
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 38c4d128a8c0..de05abbbe7fd 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -227,9 +227,7 @@ xfs_initialize_vnode(
227 xfs_revalidate_inode(XFS_BHVTOM(bdp), vp, ip); 227 xfs_revalidate_inode(XFS_BHVTOM(bdp), vp, ip);
228 xfs_set_inodeops(inode); 228 xfs_set_inodeops(inode);
229 229
230 spin_lock(&ip->i_flags_lock); 230 xfs_iflags_clear(ip, XFS_INEW);
231 ip->i_flags &= ~XFS_INEW;
232 spin_unlock(&ip->i_flags_lock);
233 barrier(); 231 barrier();
234 232
235 unlock_new_inode(inode); 233 unlock_new_inode(inode);
diff --git a/fs/xfs/support/debug.c b/fs/xfs/support/debug.c
index c75f68361e33..4363512d2f90 100644
--- a/fs/xfs/support/debug.c
+++ b/fs/xfs/support/debug.c
@@ -15,11 +15,9 @@
15 * along with this program; if not, write the Free Software Foundation, 15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */ 17 */
18#include <xfs.h>
18#include "debug.h" 19#include "debug.h"
19#include "spin.h" 20#include "spin.h"
20#include <asm/page.h>
21#include <linux/sched.h>
22#include <linux/kernel.h>
23 21
24static char message[256]; /* keep it off the stack */ 22static char message[256]; /* keep it off the stack */
25static DEFINE_SPINLOCK(xfs_err_lock); 23static DEFINE_SPINLOCK(xfs_err_lock);
diff --git a/fs/xfs/support/move.c b/fs/xfs/support/move.c
index caefa17b80fe..ac8617ca3909 100644
--- a/fs/xfs/support/move.c
+++ b/fs/xfs/support/move.c
@@ -22,7 +22,7 @@
22 * as we go. 22 * as we go.
23 */ 23 */
24int 24int
25uio_read(caddr_t src, size_t len, struct uio *uio) 25xfs_uio_read(caddr_t src, size_t len, struct uio *uio)
26{ 26{
27 size_t count; 27 size_t count;
28 28
diff --git a/fs/xfs/support/move.h b/fs/xfs/support/move.h
index 97a2498d2da3..977879c24ff5 100644
--- a/fs/xfs/support/move.h
+++ b/fs/xfs/support/move.h
@@ -65,6 +65,6 @@ struct uio {
65typedef struct uio uio_t; 65typedef struct uio uio_t;
66typedef struct iovec iovec_t; 66typedef struct iovec iovec_t;
67 67
68extern int uio_read (caddr_t, size_t, uio_t *); 68extern int xfs_uio_read (caddr_t, size_t, uio_t *);
69 69
70#endif /* __XFS_SUPPORT_MOVE_H__ */ 70#endif /* __XFS_SUPPORT_MOVE_H__ */
diff --git a/fs/xfs/xfs.h b/fs/xfs/xfs.h
index 1a48dbb902a7..bf0a12040b13 100644
--- a/fs/xfs/xfs.h
+++ b/fs/xfs/xfs.h
@@ -17,5 +17,28 @@
17 */ 17 */
18#ifndef __XFS_H__ 18#ifndef __XFS_H__
19#define __XFS_H__ 19#define __XFS_H__
20
21#ifdef CONFIG_XFS_DEBUG
22#define STATIC
23#define DEBUG 1
24#define XFS_BUF_LOCK_TRACKING 1
25/* #define QUOTADEBUG 1 */
26#endif
27
28#ifdef CONFIG_XFS_TRACE
29#define XFS_ALLOC_TRACE 1
30#define XFS_ATTR_TRACE 1
31#define XFS_BLI_TRACE 1
32#define XFS_BMAP_TRACE 1
33#define XFS_BMBT_TRACE 1
34#define XFS_DIR2_TRACE 1
35#define XFS_DQUOT_TRACE 1
36#define XFS_ILOCK_TRACE 1
37#define XFS_LOG_TRACE 1
38#define XFS_RW_TRACE 1
39#define XFS_BUF_TRACE 1
40#define XFS_VNODE_TRACE 1
41#endif
42
20#include <linux-2.6/xfs_linux.h> 43#include <linux-2.6/xfs_linux.h>
21#endif /* __XFS_H__ */ 44#endif /* __XFS_H__ */
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
index 5b050c06795f..498ad50d1f45 100644
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -1171,6 +1171,8 @@ xfs_bmap_add_extent_delay_real(
1171 xfs_bmap_trace_pre_update(fname, "0", ip, idx, XFS_DATA_FORK); 1171 xfs_bmap_trace_pre_update(fname, "0", ip, idx, XFS_DATA_FORK);
1172 xfs_bmbt_set_blockcount(ep, temp); 1172 xfs_bmbt_set_blockcount(ep, temp);
1173 r[0] = *new; 1173 r[0] = *new;
1174 r[1].br_state = PREV.br_state;
1175 r[1].br_startblock = 0;
1174 r[1].br_startoff = new_endoff; 1176 r[1].br_startoff = new_endoff;
1175 temp2 = PREV.br_startoff + PREV.br_blockcount - new_endoff; 1177 temp2 = PREV.br_startoff + PREV.br_blockcount - new_endoff;
1176 r[1].br_blockcount = temp2; 1178 r[1].br_blockcount = temp2;
diff --git a/fs/xfs/xfs_dir2.c b/fs/xfs/xfs_dir2.c
index 8edbe1adb95b..8e8e5279334a 100644
--- a/fs/xfs/xfs_dir2.c
+++ b/fs/xfs/xfs_dir2.c
@@ -678,7 +678,7 @@ xfs_dir2_put_dirent64_uio(
678 idbp->d_off = pa->cook; 678 idbp->d_off = pa->cook;
679 idbp->d_name[namelen] = '\0'; 679 idbp->d_name[namelen] = '\0';
680 memcpy(idbp->d_name, pa->name, namelen); 680 memcpy(idbp->d_name, pa->name, namelen);
681 rval = uio_read((caddr_t)idbp, reclen, uio); 681 rval = xfs_uio_read((caddr_t)idbp, reclen, uio);
682 pa->done = (rval == 0); 682 pa->done = (rval == 0);
683 return rval; 683 return rval;
684} 684}
diff --git a/fs/xfs/xfs_dmapi.h b/fs/xfs/xfs_dmapi.h
index 4e7865ad6f0e..adc3d251240d 100644
--- a/fs/xfs/xfs_dmapi.h
+++ b/fs/xfs/xfs_dmapi.h
@@ -157,27 +157,9 @@ typedef enum {
157#define DM_FLAGS_IALLOCSEM_WR 0x020 /* thread holds i_alloc_sem wr */ 157#define DM_FLAGS_IALLOCSEM_WR 0x020 /* thread holds i_alloc_sem wr */
158 158
159/* 159/*
160 * Based on IO_ISDIRECT, decide which i_ flag is set. 160 * Pull in platform specific event flags defines
161 */ 161 */
162#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0) 162#include "xfs_dmapi_priv.h"
163#define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \
164 DM_FLAGS_IMUX : 0)
165#define DM_SEM_FLAG_WR (DM_FLAGS_IALLOCSEM_WR | DM_FLAGS_IMUX)
166#endif
167
168#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)) && \
169 (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,22))
170#define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \
171 DM_FLAGS_IALLOCSEM_RD : DM_FLAGS_IMUX)
172#define DM_SEM_FLAG_WR (DM_FLAGS_IALLOCSEM_WR | DM_FLAGS_IMUX)
173#endif
174
175#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,4,21)
176#define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \
177 0 : DM_FLAGS_IMUX)
178#define DM_SEM_FLAG_WR (DM_FLAGS_IMUX)
179#endif
180
181 163
182/* 164/*
183 * Macros to turn caller specified delay/block flags into 165 * Macros to turn caller specified delay/block flags into
diff --git a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c
index b73d216ecaf9..c1c89dac19cc 100644
--- a/fs/xfs/xfs_iget.c
+++ b/fs/xfs/xfs_iget.c
@@ -215,7 +215,7 @@ again:
215 * If INEW is set this inode is being set up 215 * If INEW is set this inode is being set up
216 * we need to pause and try again. 216 * we need to pause and try again.
217 */ 217 */
218 if (ip->i_flags & XFS_INEW) { 218 if (xfs_iflags_test(ip, XFS_INEW)) {
219 read_unlock(&ih->ih_lock); 219 read_unlock(&ih->ih_lock);
220 delay(1); 220 delay(1);
221 XFS_STATS_INC(xs_ig_frecycle); 221 XFS_STATS_INC(xs_ig_frecycle);
@@ -230,22 +230,50 @@ again:
230 * on its way out of the system, 230 * on its way out of the system,
231 * we need to pause and try again. 231 * we need to pause and try again.
232 */ 232 */
233 if (ip->i_flags & XFS_IRECLAIM) { 233 if (xfs_iflags_test(ip, XFS_IRECLAIM)) {
234 read_unlock(&ih->ih_lock); 234 read_unlock(&ih->ih_lock);
235 delay(1); 235 delay(1);
236 XFS_STATS_INC(xs_ig_frecycle); 236 XFS_STATS_INC(xs_ig_frecycle);
237 237
238 goto again; 238 goto again;
239 } 239 }
240 ASSERT(xfs_iflags_test(ip, XFS_IRECLAIMABLE));
241
242 /*
243 * If lookup is racing with unlink, then we
244 * should return an error immediately so we
245 * don't remove it from the reclaim list and
246 * potentially leak the inode.
247 */
248 if ((ip->i_d.di_mode == 0) &&
249 !(flags & XFS_IGET_CREATE)) {
250 read_unlock(&ih->ih_lock);
251 return ENOENT;
252 }
253
254 /*
255 * There may be transactions sitting in the
256 * incore log buffers or being flushed to disk
257 * at this time. We can't clear the
258 * XFS_IRECLAIMABLE flag until these
259 * transactions have hit the disk, otherwise we
260 * will void the guarantee the flag provides
261 * xfs_iunpin()
262 */
263 if (xfs_ipincount(ip)) {
264 read_unlock(&ih->ih_lock);
265 xfs_log_force(mp, 0,
266 XFS_LOG_FORCE|XFS_LOG_SYNC);
267 XFS_STATS_INC(xs_ig_frecycle);
268 goto again;
269 }
240 270
241 vn_trace_exit(vp, "xfs_iget.alloc", 271 vn_trace_exit(vp, "xfs_iget.alloc",
242 (inst_t *)__return_address); 272 (inst_t *)__return_address);
243 273
244 XFS_STATS_INC(xs_ig_found); 274 XFS_STATS_INC(xs_ig_found);
245 275
246 spin_lock(&ip->i_flags_lock); 276 xfs_iflags_clear(ip, XFS_IRECLAIMABLE);
247 ip->i_flags &= ~XFS_IRECLAIMABLE;
248 spin_unlock(&ip->i_flags_lock);
249 version = ih->ih_version; 277 version = ih->ih_version;
250 read_unlock(&ih->ih_lock); 278 read_unlock(&ih->ih_lock);
251 xfs_ihash_promote(ih, ip, version); 279 xfs_ihash_promote(ih, ip, version);
@@ -299,10 +327,7 @@ finish_inode:
299 if (lock_flags != 0) 327 if (lock_flags != 0)
300 xfs_ilock(ip, lock_flags); 328 xfs_ilock(ip, lock_flags);
301 329
302 spin_lock(&ip->i_flags_lock); 330 xfs_iflags_clear(ip, XFS_ISTALE);
303 ip->i_flags &= ~XFS_ISTALE;
304 spin_unlock(&ip->i_flags_lock);
305
306 vn_trace_exit(vp, "xfs_iget.found", 331 vn_trace_exit(vp, "xfs_iget.found",
307 (inst_t *)__return_address); 332 (inst_t *)__return_address);
308 goto return_ip; 333 goto return_ip;
@@ -371,10 +396,7 @@ finish_inode:
371 ih->ih_next = ip; 396 ih->ih_next = ip;
372 ip->i_udquot = ip->i_gdquot = NULL; 397 ip->i_udquot = ip->i_gdquot = NULL;
373 ih->ih_version++; 398 ih->ih_version++;
374 spin_lock(&ip->i_flags_lock); 399 xfs_iflags_set(ip, XFS_INEW);
375 ip->i_flags |= XFS_INEW;
376 spin_unlock(&ip->i_flags_lock);
377
378 write_unlock(&ih->ih_lock); 400 write_unlock(&ih->ih_lock);
379 401
380 /* 402 /*
@@ -625,7 +647,7 @@ xfs_iput_new(xfs_inode_t *ip,
625 vn_trace_entry(vp, "xfs_iput_new", (inst_t *)__return_address); 647 vn_trace_entry(vp, "xfs_iput_new", (inst_t *)__return_address);
626 648
627 if ((ip->i_d.di_mode == 0)) { 649 if ((ip->i_d.di_mode == 0)) {
628 ASSERT(!(ip->i_flags & XFS_IRECLAIMABLE)); 650 ASSERT(!xfs_iflags_test(ip, XFS_IRECLAIMABLE));
629 vn_mark_bad(vp); 651 vn_mark_bad(vp);
630 } 652 }
631 if (inode->i_state & I_NEW) 653 if (inode->i_state & I_NEW)
@@ -683,6 +705,7 @@ xfs_ireclaim(xfs_inode_t *ip)
683 /* 705 /*
684 * Free all memory associated with the inode. 706 * Free all memory associated with the inode.
685 */ 707 */
708 xfs_iunlock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL);
686 xfs_idestroy(ip); 709 xfs_idestroy(ip);
687} 710}
688 711
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index c27d7d495aa0..44dfac521285 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -2193,7 +2193,7 @@ xfs_ifree_cluster(
2193 /* Inode not in memory or we found it already, 2193 /* Inode not in memory or we found it already,
2194 * nothing to do 2194 * nothing to do
2195 */ 2195 */
2196 if (!ip || (ip->i_flags & XFS_ISTALE)) { 2196 if (!ip || xfs_iflags_test(ip, XFS_ISTALE)) {
2197 read_unlock(&ih->ih_lock); 2197 read_unlock(&ih->ih_lock);
2198 continue; 2198 continue;
2199 } 2199 }
@@ -2215,10 +2215,7 @@ xfs_ifree_cluster(
2215 2215
2216 if (ip == free_ip) { 2216 if (ip == free_ip) {
2217 if (xfs_iflock_nowait(ip)) { 2217 if (xfs_iflock_nowait(ip)) {
2218 spin_lock(&ip->i_flags_lock); 2218 xfs_iflags_set(ip, XFS_ISTALE);
2219 ip->i_flags |= XFS_ISTALE;
2220 spin_unlock(&ip->i_flags_lock);
2221
2222 if (xfs_inode_clean(ip)) { 2219 if (xfs_inode_clean(ip)) {
2223 xfs_ifunlock(ip); 2220 xfs_ifunlock(ip);
2224 } else { 2221 } else {
@@ -2231,9 +2228,7 @@ xfs_ifree_cluster(
2231 2228
2232 if (xfs_ilock_nowait(ip, XFS_ILOCK_EXCL)) { 2229 if (xfs_ilock_nowait(ip, XFS_ILOCK_EXCL)) {
2233 if (xfs_iflock_nowait(ip)) { 2230 if (xfs_iflock_nowait(ip)) {
2234 spin_lock(&ip->i_flags_lock); 2231 xfs_iflags_set(ip, XFS_ISTALE);
2235 ip->i_flags |= XFS_ISTALE;
2236 spin_unlock(&ip->i_flags_lock);
2237 2232
2238 if (xfs_inode_clean(ip)) { 2233 if (xfs_inode_clean(ip)) {
2239 xfs_ifunlock(ip); 2234 xfs_ifunlock(ip);
@@ -2263,9 +2258,7 @@ xfs_ifree_cluster(
2263 AIL_LOCK(mp,s); 2258 AIL_LOCK(mp,s);
2264 iip->ili_flush_lsn = iip->ili_item.li_lsn; 2259 iip->ili_flush_lsn = iip->ili_item.li_lsn;
2265 AIL_UNLOCK(mp, s); 2260 AIL_UNLOCK(mp, s);
2266 spin_lock(&iip->ili_inode->i_flags_lock); 2261 xfs_iflags_set(iip->ili_inode, XFS_ISTALE);
2267 iip->ili_inode->i_flags |= XFS_ISTALE;
2268 spin_unlock(&iip->ili_inode->i_flags_lock);
2269 pre_flushed++; 2262 pre_flushed++;
2270 } 2263 }
2271 lip = lip->li_bio_list; 2264 lip = lip->li_bio_list;
@@ -2748,42 +2741,39 @@ xfs_iunpin(
2748{ 2741{
2749 ASSERT(atomic_read(&ip->i_pincount) > 0); 2742 ASSERT(atomic_read(&ip->i_pincount) > 0);
2750 2743
2751 if (atomic_dec_and_test(&ip->i_pincount)) { 2744 if (atomic_dec_and_lock(&ip->i_pincount, &ip->i_flags_lock)) {
2745
2752 /* 2746 /*
2753 * If the inode is currently being reclaimed, the 2747 * If the inode is currently being reclaimed, the link between
2754 * linux inode _and_ the xfs vnode may have been 2748 * the bhv_vnode and the xfs_inode will be broken after the
2755 * freed so we cannot reference either of them safely. 2749 * XFS_IRECLAIM* flag is set. Hence, if these flags are not
2756 * Hence we should not try to do anything to them 2750 * set, then we can move forward and mark the linux inode dirty
2757 * if the xfs inode is currently in the reclaim 2751 * knowing that it is still valid as it won't freed until after
2758 * path. 2752 * the bhv_vnode<->xfs_inode link is broken in xfs_reclaim. The
2753 * i_flags_lock is used to synchronise the setting of the
2754 * XFS_IRECLAIM* flags and the breaking of the link, and so we
2755 * can execute atomically w.r.t to reclaim by holding this lock
2756 * here.
2759 * 2757 *
2760 * However, we still need to issue the unpin wakeup 2758 * However, we still need to issue the unpin wakeup call as the
2761 * call as the inode reclaim may be blocked waiting for 2759 * inode reclaim may be blocked waiting for the inode to become
2762 * the inode to become unpinned. 2760 * unpinned.
2763 */ 2761 */
2764 struct inode *inode = NULL;
2765 2762
2766 spin_lock(&ip->i_flags_lock); 2763 if (!__xfs_iflags_test(ip, XFS_IRECLAIM|XFS_IRECLAIMABLE)) {
2767 if (!(ip->i_flags & (XFS_IRECLAIM|XFS_IRECLAIMABLE))) {
2768 bhv_vnode_t *vp = XFS_ITOV_NULL(ip); 2764 bhv_vnode_t *vp = XFS_ITOV_NULL(ip);
2765 struct inode *inode = NULL;
2766
2767 BUG_ON(vp == NULL);
2768 inode = vn_to_inode(vp);
2769 BUG_ON(inode->i_state & I_CLEAR);
2769 2770
2770 /* make sync come back and flush this inode */ 2771 /* make sync come back and flush this inode */
2771 if (vp) { 2772 if (!(inode->i_state & (I_NEW|I_FREEING)))
2772 inode = vn_to_inode(vp); 2773 mark_inode_dirty_sync(inode);
2773
2774 if (!(inode->i_state &
2775 (I_NEW|I_FREEING|I_CLEAR))) {
2776 inode = igrab(inode);
2777 if (inode)
2778 mark_inode_dirty_sync(inode);
2779 } else
2780 inode = NULL;
2781 }
2782 } 2774 }
2783 spin_unlock(&ip->i_flags_lock); 2775 spin_unlock(&ip->i_flags_lock);
2784 wake_up(&ip->i_ipin_wait); 2776 wake_up(&ip->i_ipin_wait);
2785 if (inode)
2786 iput(inode);
2787 } 2777 }
2788} 2778}
2789 2779
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index e96eb0835fe6..bc823720d88f 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -305,6 +305,47 @@ typedef struct xfs_inode {
305#endif 305#endif
306} xfs_inode_t; 306} xfs_inode_t;
307 307
308
309/*
310 * i_flags helper functions
311 */
312static inline void
313__xfs_iflags_set(xfs_inode_t *ip, unsigned short flags)
314{
315 ip->i_flags |= flags;
316}
317
318static inline void
319xfs_iflags_set(xfs_inode_t *ip, unsigned short flags)
320{
321 spin_lock(&ip->i_flags_lock);
322 __xfs_iflags_set(ip, flags);
323 spin_unlock(&ip->i_flags_lock);
324}
325
326static inline void
327xfs_iflags_clear(xfs_inode_t *ip, unsigned short flags)
328{
329 spin_lock(&ip->i_flags_lock);
330 ip->i_flags &= ~flags;
331 spin_unlock(&ip->i_flags_lock);
332}
333
334static inline int
335__xfs_iflags_test(xfs_inode_t *ip, unsigned short flags)
336{
337 return (ip->i_flags & flags);
338}
339
340static inline int
341xfs_iflags_test(xfs_inode_t *ip, unsigned short flags)
342{
343 int ret;
344 spin_lock(&ip->i_flags_lock);
345 ret = __xfs_iflags_test(ip, flags);
346 spin_unlock(&ip->i_flags_lock);
347 return ret;
348}
308#endif /* __KERNEL__ */ 349#endif /* __KERNEL__ */
309 350
310 351
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index 061e2ffdd1de..bda774a04b8f 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -1013,7 +1013,7 @@ xfs_readlink(
1013 pathlen = (int)ip->i_d.di_size; 1013 pathlen = (int)ip->i_d.di_size;
1014 1014
1015 if (ip->i_df.if_flags & XFS_IFINLINE) { 1015 if (ip->i_df.if_flags & XFS_IFINLINE) {
1016 error = uio_read(ip->i_df.if_u1.if_data, pathlen, uiop); 1016 error = xfs_uio_read(ip->i_df.if_u1.if_data, pathlen, uiop);
1017 } 1017 }
1018 else { 1018 else {
1019 /* 1019 /*
@@ -1044,7 +1044,7 @@ xfs_readlink(
1044 byte_cnt = pathlen; 1044 byte_cnt = pathlen;
1045 pathlen -= byte_cnt; 1045 pathlen -= byte_cnt;
1046 1046
1047 error = uio_read(XFS_BUF_PTR(bp), byte_cnt, uiop); 1047 error = xfs_uio_read(XFS_BUF_PTR(bp), byte_cnt, uiop);
1048 xfs_buf_relse (bp); 1048 xfs_buf_relse (bp);
1049 } 1049 }
1050 1050
@@ -3827,11 +3827,16 @@ xfs_reclaim(
3827 */ 3827 */
3828 xfs_synchronize_atime(ip); 3828 xfs_synchronize_atime(ip);
3829 3829
3830 /* If we have nothing to flush with this inode then complete the 3830 /*
3831 * teardown now, otherwise break the link between the xfs inode 3831 * If we have nothing to flush with this inode then complete the
3832 * and the linux inode and clean up the xfs inode later. This 3832 * teardown now, otherwise break the link between the xfs inode and the
3833 * avoids flushing the inode to disk during the delete operation 3833 * linux inode and clean up the xfs inode later. This avoids flushing
3834 * itself. 3834 * the inode to disk during the delete operation itself.
3835 *
3836 * When breaking the link, we need to set the XFS_IRECLAIMABLE flag
3837 * first to ensure that xfs_iunpin() will never see an xfs inode
3838 * that has a linux inode being reclaimed. Synchronisation is provided
3839 * by the i_flags_lock.
3835 */ 3840 */
3836 if (!ip->i_update_core && (ip->i_itemp == NULL)) { 3841 if (!ip->i_update_core && (ip->i_itemp == NULL)) {
3837 xfs_ilock(ip, XFS_ILOCK_EXCL); 3842 xfs_ilock(ip, XFS_ILOCK_EXCL);
@@ -3840,13 +3845,13 @@ xfs_reclaim(
3840 } else { 3845 } else {
3841 xfs_mount_t *mp = ip->i_mount; 3846 xfs_mount_t *mp = ip->i_mount;
3842 3847
3843 /* Protect sync from us */ 3848 /* Protect sync and unpin from us */
3844 XFS_MOUNT_ILOCK(mp); 3849 XFS_MOUNT_ILOCK(mp);
3845 vn_bhv_remove(VN_BHV_HEAD(vp), XFS_ITOBHV(ip));
3846 list_add_tail(&ip->i_reclaim, &mp->m_del_inodes);
3847 spin_lock(&ip->i_flags_lock); 3850 spin_lock(&ip->i_flags_lock);
3848 ip->i_flags |= XFS_IRECLAIMABLE; 3851 __xfs_iflags_set(ip, XFS_IRECLAIMABLE);
3852 vn_bhv_remove(VN_BHV_HEAD(vp), XFS_ITOBHV(ip));
3849 spin_unlock(&ip->i_flags_lock); 3853 spin_unlock(&ip->i_flags_lock);
3854 list_add_tail(&ip->i_reclaim, &mp->m_del_inodes);
3850 XFS_MOUNT_IUNLOCK(mp); 3855 XFS_MOUNT_IUNLOCK(mp);
3851 } 3856 }
3852 return 0; 3857 return 0;
@@ -3872,8 +3877,8 @@ xfs_finish_reclaim(
3872 */ 3877 */
3873 write_lock(&ih->ih_lock); 3878 write_lock(&ih->ih_lock);
3874 spin_lock(&ip->i_flags_lock); 3879 spin_lock(&ip->i_flags_lock);
3875 if ((ip->i_flags & XFS_IRECLAIM) || 3880 if (__xfs_iflags_test(ip, XFS_IRECLAIM) ||
3876 (!(ip->i_flags & XFS_IRECLAIMABLE) && vp == NULL)) { 3881 (!__xfs_iflags_test(ip, XFS_IRECLAIMABLE) && vp == NULL)) {
3877 spin_unlock(&ip->i_flags_lock); 3882 spin_unlock(&ip->i_flags_lock);
3878 write_unlock(&ih->ih_lock); 3883 write_unlock(&ih->ih_lock);
3879 if (locked) { 3884 if (locked) {
@@ -3882,7 +3887,7 @@ xfs_finish_reclaim(
3882 } 3887 }
3883 return 1; 3888 return 1;
3884 } 3889 }
3885 ip->i_flags |= XFS_IRECLAIM; 3890 __xfs_iflags_set(ip, XFS_IRECLAIM);
3886 spin_unlock(&ip->i_flags_lock); 3891 spin_unlock(&ip->i_flags_lock);
3887 write_unlock(&ih->ih_lock); 3892 write_unlock(&ih->ih_lock);
3888 3893
diff --git a/include/acpi/pdc_intel.h b/include/acpi/pdc_intel.h
index c5472be6f3a2..e72bfdd887f9 100644
--- a/include/acpi/pdc_intel.h
+++ b/include/acpi/pdc_intel.h
@@ -13,6 +13,7 @@
13#define ACPI_PDC_SMP_C_SWCOORD (0x0040) 13#define ACPI_PDC_SMP_C_SWCOORD (0x0040)
14#define ACPI_PDC_SMP_T_SWCOORD (0x0080) 14#define ACPI_PDC_SMP_T_SWCOORD (0x0080)
15#define ACPI_PDC_C_C1_FFH (0x0100) 15#define ACPI_PDC_C_C1_FFH (0x0100)
16#define ACPI_PDC_C_C2C3_FFH (0x0200)
16 17
17#define ACPI_PDC_EST_CAPABILITY_SMP (ACPI_PDC_SMP_C1PT | \ 18#define ACPI_PDC_EST_CAPABILITY_SMP (ACPI_PDC_SMP_C1PT | \
18 ACPI_PDC_C_C1_HALT | \ 19 ACPI_PDC_C_C1_HALT | \
@@ -23,8 +24,10 @@
23 ACPI_PDC_SMP_P_SWCOORD | \ 24 ACPI_PDC_SMP_P_SWCOORD | \
24 ACPI_PDC_P_FFH) 25 ACPI_PDC_P_FFH)
25 26
26#define ACPI_PDC_C_CAPABILITY_SMP (ACPI_PDC_SMP_C2C3 | \ 27#define ACPI_PDC_C_CAPABILITY_SMP (ACPI_PDC_SMP_C2C3 | \
27 ACPI_PDC_SMP_C1PT | \ 28 ACPI_PDC_SMP_C1PT | \
28 ACPI_PDC_C_C1_HALT) 29 ACPI_PDC_C_C1_HALT | \
30 ACPI_PDC_C_C1_FFH | \
31 ACPI_PDC_C_C2C3_FFH)
29 32
30#endif /* __PDC_INTEL_H__ */ 33#endif /* __PDC_INTEL_H__ */
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index 9dd5b75961f8..7798d2a9f793 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -29,6 +29,9 @@
29#define DOMAIN_COORD_TYPE_SW_ANY 0xfd 29#define DOMAIN_COORD_TYPE_SW_ANY 0xfd
30#define DOMAIN_COORD_TYPE_HW_ALL 0xfe 30#define DOMAIN_COORD_TYPE_HW_ALL 0xfe
31 31
32#define ACPI_CSTATE_SYSTEMIO (0)
33#define ACPI_CSTATE_FFH (1)
34
32/* Power Management */ 35/* Power Management */
33 36
34struct acpi_processor_cx; 37struct acpi_processor_cx;
@@ -58,6 +61,8 @@ struct acpi_processor_cx {
58 u8 valid; 61 u8 valid;
59 u8 type; 62 u8 type;
60 u32 address; 63 u32 address;
64 u8 space_id;
65 u8 index;
61 u32 latency; 66 u32 latency;
62 u32 latency_ticks; 67 u32 latency_ticks;
63 u32 power; 68 u32 power;
@@ -206,6 +211,9 @@ void arch_acpi_processor_init_pdc(struct acpi_processor *pr);
206#ifdef ARCH_HAS_POWER_INIT 211#ifdef ARCH_HAS_POWER_INIT
207void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags, 212void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
208 unsigned int cpu); 213 unsigned int cpu);
214int acpi_processor_ffh_cstate_probe(unsigned int cpu,
215 struct acpi_processor_cx *cx, struct acpi_power_register *reg);
216void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx *cstate);
209#else 217#else
210static inline void acpi_processor_power_init_bm_check(struct 218static inline void acpi_processor_power_init_bm_check(struct
211 acpi_processor_flags 219 acpi_processor_flags
@@ -214,6 +222,16 @@ static inline void acpi_processor_power_init_bm_check(struct
214 flags->bm_check = 1; 222 flags->bm_check = 1;
215 return; 223 return;
216} 224}
225static inline int acpi_processor_ffh_cstate_probe(unsigned int cpu,
226 struct acpi_processor_cx *cx, struct acpi_power_register *reg)
227{
228 return -1;
229}
230static inline void acpi_processor_ffh_cstate_enter(
231 struct acpi_processor_cx *cstate)
232{
233 return;
234}
217#endif 235#endif
218 236
219/* in processor_perflib.c */ 237/* in processor_perflib.c */
diff --git a/include/asm-alpha/io.h b/include/asm-alpha/io.h
index f5ae98c25d1f..5d15af24573b 100644
--- a/include/asm-alpha/io.h
+++ b/include/asm-alpha/io.h
@@ -533,19 +533,6 @@ extern void outsl (unsigned long port, const void *src, unsigned long count);
533#define eth_io_copy_and_sum(skb,src,len,unused) \ 533#define eth_io_copy_and_sum(skb,src,len,unused) \
534 memcpy_fromio((skb)->data,src,len) 534 memcpy_fromio((skb)->data,src,len)
535 535
536static inline int
537check_signature(const volatile void __iomem *io_addr,
538 const unsigned char *signature, int length)
539{
540 do {
541 if (readb(io_addr) != *signature)
542 return 0;
543 io_addr++;
544 signature++;
545 } while (--length);
546 return 1;
547}
548
549/* 536/*
550 * The Alpha Jensen hardware for some rather strange reason puts 537 * The Alpha Jensen hardware for some rather strange reason puts
551 * the RTC clock at 0x170 instead of 0x70. Probably due to some 538 * the RTC clock at 0x170 instead of 0x70. Probably due to some
diff --git a/include/asm-arm/arch-pxa/irqs.h b/include/asm-arm/arch-pxa/irqs.h
index f3bc70eee35b..67ed43674c63 100644
--- a/include/asm-arm/arch-pxa/irqs.h
+++ b/include/asm-arm/arch-pxa/irqs.h
@@ -73,7 +73,7 @@
73#define IRQ_TO_GPIO(i) (((i) < IRQ_GPIO(2)) ? ((i) - IRQ_GPIO0) : IRQ_TO_GPIO_2_x(i)) 73#define IRQ_TO_GPIO(i) (((i) < IRQ_GPIO(2)) ? ((i) - IRQ_GPIO0) : IRQ_TO_GPIO_2_x(i))
74 74
75#if defined(CONFIG_PXA25x) 75#if defined(CONFIG_PXA25x)
76#define PXA_LAST_GPIO 80 76#define PXA_LAST_GPIO 84
77#elif defined(CONFIG_PXA27x) 77#elif defined(CONFIG_PXA27x)
78#define PXA_LAST_GPIO 127 78#define PXA_LAST_GPIO 127
79#endif 79#endif
diff --git a/include/asm-arm/arch-pxa/pxa-regs.h b/include/asm-arm/arch-pxa/pxa-regs.h
index f5cc65dd7d0d..cff752f35230 100644
--- a/include/asm-arm/arch-pxa/pxa-regs.h
+++ b/include/asm-arm/arch-pxa/pxa-regs.h
@@ -1681,6 +1681,7 @@
1681#define SSSR_TINT (1 << 19) /* Receiver Time-out Interrupt */ 1681#define SSSR_TINT (1 << 19) /* Receiver Time-out Interrupt */
1682#define SSSR_PINT (1 << 18) /* Peripheral Trailing Byte Interrupt */ 1682#define SSSR_PINT (1 << 18) /* Peripheral Trailing Byte Interrupt */
1683 1683
1684#define SSPSP_FSRT (1 << 25) /* Frame Sync Relative Timing */
1684#define SSPSP_DMYSTOP(x) (x << 23) /* Dummy Stop */ 1685#define SSPSP_DMYSTOP(x) (x << 23) /* Dummy Stop */
1685#define SSPSP_SFRMWDTH(x) (x << 16) /* Serial Frame Width */ 1686#define SSPSP_SFRMWDTH(x) (x << 16) /* Serial Frame Width */
1686#define SSPSP_SFRMDLY(x) (x << 9) /* Serial Frame Delay */ 1687#define SSPSP_SFRMDLY(x) (x << 9) /* Serial Frame Delay */
@@ -2241,7 +2242,7 @@
2241 2242
2242#define CICR1_TBIT (1 << 31) /* Transparency bit */ 2243#define CICR1_TBIT (1 << 31) /* Transparency bit */
2243#define CICR1_RGBT_CONV (0x3 << 30) /* RGBT conversion mask */ 2244#define CICR1_RGBT_CONV (0x3 << 30) /* RGBT conversion mask */
2244#define CICR1_PPL (0x3f << 15) /* Pixels per line mask */ 2245#define CICR1_PPL (0x7ff << 15) /* Pixels per line mask */
2245#define CICR1_RGB_CONV (0x7 << 12) /* RGB conversion mask */ 2246#define CICR1_RGB_CONV (0x7 << 12) /* RGB conversion mask */
2246#define CICR1_RGB_F (1 << 11) /* RGB format */ 2247#define CICR1_RGB_F (1 << 11) /* RGB format */
2247#define CICR1_YCBCR_F (1 << 10) /* YCbCr format */ 2248#define CICR1_YCBCR_F (1 << 10) /* YCbCr format */
@@ -2267,7 +2268,7 @@
2267#define CICR3_VSW (0x3f << 10) /* Vertical sync pulse width mask */ 2268#define CICR3_VSW (0x3f << 10) /* Vertical sync pulse width mask */
2268#define CICR3_BFPW (0x3f << 3) /* Beginning-of-frame pixel clock 2269#define CICR3_BFPW (0x3f << 3) /* Beginning-of-frame pixel clock
2269 wait count mask */ 2270 wait count mask */
2270#define CICR3_LPF (0x3ff << 0) /* Lines per frame mask */ 2271#define CICR3_LPF (0x7ff << 0) /* Lines per frame mask */
2271 2272
2272#define CICR4_MCLK_DLY (0x3 << 24) /* MCLK Data Capture Delay mask */ 2273#define CICR4_MCLK_DLY (0x3 << 24) /* MCLK Data Capture Delay mask */
2273#define CICR4_PCLK_EN (1 << 23) /* Pixel clock enable */ 2274#define CICR4_PCLK_EN (1 << 23) /* Pixel clock enable */
@@ -2288,8 +2289,8 @@
2288#define CISR_EOL (1 << 8) /* End of line */ 2289#define CISR_EOL (1 << 8) /* End of line */
2289#define CISR_PAR_ERR (1 << 7) /* Parity error */ 2290#define CISR_PAR_ERR (1 << 7) /* Parity error */
2290#define CISR_CQD (1 << 6) /* Camera interface quick disable */ 2291#define CISR_CQD (1 << 6) /* Camera interface quick disable */
2291#define CISR_SOF (1 << 5) /* Start of frame */ 2292#define CISR_CDD (1 << 5) /* Camera interface disable done */
2292#define CISR_CDD (1 << 4) /* Camera interface disable done */ 2293#define CISR_SOF (1 << 4) /* Start of frame */
2293#define CISR_EOF (1 << 3) /* End of frame */ 2294#define CISR_EOF (1 << 3) /* End of frame */
2294#define CISR_IFO_2 (1 << 2) /* FIFO overrun for Channel 2 */ 2295#define CISR_IFO_2 (1 << 2) /* FIFO overrun for Channel 2 */
2295#define CISR_IFO_1 (1 << 1) /* FIFO overrun for Channel 1 */ 2296#define CISR_IFO_1 (1 << 1) /* FIFO overrun for Channel 1 */
diff --git a/include/asm-arm/arch-sa1100/jornada720.h b/include/asm-arm/arch-sa1100/jornada720.h
index 1b8e8a304800..3f37ca07806d 100644
--- a/include/asm-arm/arch-sa1100/jornada720.h
+++ b/include/asm-arm/arch-sa1100/jornada720.h
@@ -19,6 +19,20 @@
19#define GPIO_JORNADA720_KEYBOARD_IRQ IRQ_GPIO0 19#define GPIO_JORNADA720_KEYBOARD_IRQ IRQ_GPIO0
20#define GPIO_JORNADA720_MOUSE_IRQ IRQ_GPIO9 20#define GPIO_JORNADA720_MOUSE_IRQ IRQ_GPIO9
21 21
22/* MCU COMMANDS */
23#define MCU_GetBatteryData 0xc0
24#define MCU_GetScanKeyCode 0x90
25#define MCU_GetTouchSamples 0xa0
26#define MCU_GetContrast 0xD0
27#define MCU_SetContrast 0xD1
28#define MCU_GetBrightness 0xD2
29#define MCU_SetBrightness 0xD3
30#define MCU_ContrastOff 0xD8
31#define MCU_BrightnessOff 0xD9
32#define MCU_PWMOFF 0xDF
33#define MCU_TxDummy 0x11
34#define MCU_ErrorCode 0x00
35
22#ifndef __ASSEMBLY__ 36#ifndef __ASSEMBLY__
23 37
24void jornada720_mcu_init(void); 38void jornada720_mcu_init(void);
diff --git a/include/asm-arm/arch-versatile/hardware.h b/include/asm-arm/arch-versatile/hardware.h
index 41c1bee342ad..edc06598d187 100644
--- a/include/asm-arm/arch-versatile/hardware.h
+++ b/include/asm-arm/arch-versatile/hardware.h
@@ -28,8 +28,8 @@
28/* 28/*
29 * PCI space virtual addresses 29 * PCI space virtual addresses
30 */ 30 */
31#define VERSATILE_PCI_VIRT_BASE 0xe8000000 31#define VERSATILE_PCI_VIRT_BASE (void __iomem *)0xe8000000ul
32#define VERSATILE_PCI_CFG_VIRT_BASE 0xe9000000 32#define VERSATILE_PCI_CFG_VIRT_BASE (void __iomem *)0xe9000000ul
33 33
34#if 0 34#if 0
35#define VERSATILE_PCI_VIRT_MEM_BASE0 0xf4000000 35#define VERSATILE_PCI_VIRT_MEM_BASE0 0xf4000000
diff --git a/include/asm-arm/io.h b/include/asm-arm/io.h
index 34aaaac4f617..ae999fd5dc67 100644
--- a/include/asm-arm/io.h
+++ b/include/asm-arm/io.h
@@ -193,23 +193,6 @@ extern void _memset_io(volatile void __iomem *, int, size_t);
193#define eth_io_copy_and_sum(s,c,l,b) \ 193#define eth_io_copy_and_sum(s,c,l,b) \
194 eth_copy_and_sum((s),__mem_pci(c),(l),(b)) 194 eth_copy_and_sum((s),__mem_pci(c),(l),(b))
195 195
196static inline int
197check_signature(void __iomem *io_addr, const unsigned char *signature,
198 int length)
199{
200 int retval = 0;
201 do {
202 if (readb(io_addr) != *signature)
203 goto out;
204 io_addr++;
205 signature++;
206 length--;
207 } while (length);
208 retval = 1;
209out:
210 return retval;
211}
212
213#elif !defined(readb) 196#elif !defined(readb)
214 197
215#define readb(c) (__readwrite_bug("readb"),0) 198#define readb(c) (__readwrite_bug("readb"),0)
diff --git a/include/asm-arm/uaccess.h b/include/asm-arm/uaccess.h
index 87aba57a66c4..5f420a0149f1 100644
--- a/include/asm-arm/uaccess.h
+++ b/include/asm-arm/uaccess.h
@@ -110,7 +110,7 @@ extern int __get_user_4(void *);
110#define get_user(x,p) \ 110#define get_user(x,p) \
111 ({ \ 111 ({ \
112 const register typeof(*(p)) __user *__p asm("r0") = (p);\ 112 const register typeof(*(p)) __user *__p asm("r0") = (p);\
113 register unsigned int __r2 asm("r2"); \ 113 register unsigned long __r2 asm("r2"); \
114 register int __e asm("r0"); \ 114 register int __e asm("r0"); \
115 switch (sizeof(*(__p))) { \ 115 switch (sizeof(*(__p))) { \
116 case 1: \ 116 case 1: \
@@ -383,19 +383,19 @@ do { \
383 383
384 384
385#ifdef CONFIG_MMU 385#ifdef CONFIG_MMU
386extern unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n); 386extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
387extern unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n); 387extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
388extern unsigned long __clear_user(void __user *addr, unsigned long n); 388extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
389#else 389#else
390#define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0) 390#define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
391#define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0) 391#define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
392#define __clear_user(addr,n) (memset((void __force *)addr, 0, n), 0) 392#define __clear_user(addr,n) (memset((void __force *)addr, 0, n), 0)
393#endif 393#endif
394 394
395extern unsigned long __strncpy_from_user(char *to, const char __user *from, unsigned long count); 395extern unsigned long __must_check __strncpy_from_user(char *to, const char __user *from, unsigned long count);
396extern unsigned long __strnlen_user(const char __user *s, long n); 396extern unsigned long __must_check __strnlen_user(const char __user *s, long n);
397 397
398static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n) 398static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
399{ 399{
400 if (access_ok(VERIFY_READ, from, n)) 400 if (access_ok(VERIFY_READ, from, n))
401 n = __copy_from_user(to, from, n); 401 n = __copy_from_user(to, from, n);
@@ -404,7 +404,7 @@ static inline unsigned long copy_from_user(void *to, const void __user *from, un
404 return n; 404 return n;
405} 405}
406 406
407static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n) 407static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
408{ 408{
409 if (access_ok(VERIFY_WRITE, to, n)) 409 if (access_ok(VERIFY_WRITE, to, n))
410 n = __copy_to_user(to, from, n); 410 n = __copy_to_user(to, from, n);
@@ -414,14 +414,14 @@ static inline unsigned long copy_to_user(void __user *to, const void *from, unsi
414#define __copy_to_user_inatomic __copy_to_user 414#define __copy_to_user_inatomic __copy_to_user
415#define __copy_from_user_inatomic __copy_from_user 415#define __copy_from_user_inatomic __copy_from_user
416 416
417static inline unsigned long clear_user(void __user *to, unsigned long n) 417static inline unsigned long __must_check clear_user(void __user *to, unsigned long n)
418{ 418{
419 if (access_ok(VERIFY_WRITE, to, n)) 419 if (access_ok(VERIFY_WRITE, to, n))
420 n = __clear_user(to, n); 420 n = __clear_user(to, n);
421 return n; 421 return n;
422} 422}
423 423
424static inline long strncpy_from_user(char *dst, const char __user *src, long count) 424static inline long __must_check strncpy_from_user(char *dst, const char __user *src, long count)
425{ 425{
426 long res = -EFAULT; 426 long res = -EFAULT;
427 if (access_ok(VERIFY_READ, src, 1)) 427 if (access_ok(VERIFY_READ, src, 1))
@@ -431,7 +431,7 @@ static inline long strncpy_from_user(char *dst, const char __user *src, long cou
431 431
432#define strlen_user(s) strnlen_user(s, ~0UL >> 1) 432#define strlen_user(s) strnlen_user(s, ~0UL >> 1)
433 433
434static inline long strnlen_user(const char __user *s, long n) 434static inline long __must_check strnlen_user(const char __user *s, long n)
435{ 435{
436 unsigned long res = 0; 436 unsigned long res = 0;
437 437
diff --git a/include/asm-avr32/atomic.h b/include/asm-avr32/atomic.h
index e0b9c44c126c..c40b6032c480 100644
--- a/include/asm-avr32/atomic.h
+++ b/include/asm-avr32/atomic.h
@@ -41,7 +41,7 @@ static inline int atomic_sub_return(int i, atomic_t *v)
41 " stcond %1, %0\n" 41 " stcond %1, %0\n"
42 " brne 1b" 42 " brne 1b"
43 : "=&r"(result), "=o"(v->counter) 43 : "=&r"(result), "=o"(v->counter)
44 : "m"(v->counter), "ir"(i) 44 : "m"(v->counter), "rKs21"(i)
45 : "cc"); 45 : "cc");
46 46
47 return result; 47 return result;
@@ -58,7 +58,7 @@ static inline int atomic_add_return(int i, atomic_t *v)
58{ 58{
59 int result; 59 int result;
60 60
61 if (__builtin_constant_p(i)) 61 if (__builtin_constant_p(i) && (i >= -1048575) && (i <= 1048576))
62 result = atomic_sub_return(-i, v); 62 result = atomic_sub_return(-i, v);
63 else 63 else
64 asm volatile( 64 asm volatile(
@@ -101,7 +101,7 @@ static inline int atomic_sub_unless(atomic_t *v, int a, int u)
101 " mov %1, 1\n" 101 " mov %1, 1\n"
102 "1:" 102 "1:"
103 : "=&r"(tmp), "=&r"(result), "=o"(v->counter) 103 : "=&r"(tmp), "=&r"(result), "=o"(v->counter)
104 : "m"(v->counter), "ir"(a), "ir"(u) 104 : "m"(v->counter), "rKs21"(a), "rKs21"(u)
105 : "cc", "memory"); 105 : "cc", "memory");
106 106
107 return result; 107 return result;
@@ -121,7 +121,7 @@ static inline int atomic_add_unless(atomic_t *v, int a, int u)
121{ 121{
122 int tmp, result; 122 int tmp, result;
123 123
124 if (__builtin_constant_p(a)) 124 if (__builtin_constant_p(a) && (a >= -1048575) && (a <= 1048576))
125 result = atomic_sub_unless(v, -a, u); 125 result = atomic_sub_unless(v, -a, u);
126 else { 126 else {
127 result = 0; 127 result = 0;
diff --git a/include/asm-avr32/io.h b/include/asm-avr32/io.h
index 2fc8f111dce9..eec47500fa66 100644
--- a/include/asm-avr32/io.h
+++ b/include/asm-avr32/io.h
@@ -76,6 +76,39 @@ static inline unsigned int readl(const volatile void __iomem *addr)
76#define readsw(p, d, l) __raw_readsw((unsigned int)p, d, l) 76#define readsw(p, d, l) __raw_readsw((unsigned int)p, d, l)
77#define readsl(p, d, l) __raw_readsl((unsigned int)p, d, l) 77#define readsl(p, d, l) __raw_readsl((unsigned int)p, d, l)
78 78
79
80/*
81 * io{read,write}{8,16,32} macros in both le (for PCI style consumers) and native be
82 */
83#ifndef ioread8
84
85#define ioread8(p) ({ unsigned int __v = __raw_readb(p); __v; })
86
87#define ioread16(p) ({ unsigned int __v = le16_to_cpu(__raw_readw(p)); __v; })
88#define ioread16be(p) ({ unsigned int __v = be16_to_cpu(__raw_readw(p)); __v; })
89
90#define ioread32(p) ({ unsigned int __v = le32_to_cpu(__raw_readl(p)); __v; })
91#define ioread32be(p) ({ unsigned int __v = be32_to_cpu(__raw_readl(p)); __v; })
92
93#define iowrite8(v,p) __raw_writeb(v, p)
94
95#define iowrite16(v,p) __raw_writew(cpu_to_le16(v), p)
96#define iowrite16be(v,p) __raw_writew(cpu_to_be16(v), p)
97
98#define iowrite32(v,p) __raw_writel(cpu_to_le32(v), p)
99#define iowrite32be(v,p) __raw_writel(cpu_to_be32(v), p)
100
101#define ioread8_rep(p,d,c) __raw_readsb(p,d,c)
102#define ioread16_rep(p,d,c) __raw_readsw(p,d,c)
103#define ioread32_rep(p,d,c) __raw_readsl(p,d,c)
104
105#define iowrite8_rep(p,s,c) __raw_writesb(p,s,c)
106#define iowrite16_rep(p,s,c) __raw_writesw(p,s,c)
107#define iowrite32_rep(p,s,c) __raw_writesl(p,s,c)
108
109#endif
110
111
79/* 112/*
80 * These two are only here because ALSA _thinks_ it needs them... 113 * These two are only here because ALSA _thinks_ it needs them...
81 */ 114 */
diff --git a/include/asm-avr32/irq_regs.h b/include/asm-avr32/irq_regs.h
new file mode 100644
index 000000000000..3dd9c0b70270
--- /dev/null
+++ b/include/asm-avr32/irq_regs.h
@@ -0,0 +1 @@
#include <asm-generic/irq_regs.h>
diff --git a/include/asm-avr32/unistd.h b/include/asm-avr32/unistd.h
index a50e5004550c..56ed1f9d348a 100644
--- a/include/asm-avr32/unistd.h
+++ b/include/asm-avr32/unistd.h
@@ -280,9 +280,10 @@
280#define __NR_sync_file_range 262 280#define __NR_sync_file_range 262
281#define __NR_tee 263 281#define __NR_tee 263
282#define __NR_vmsplice 264 282#define __NR_vmsplice 264
283#define __NR_epoll_pwait 265
283 284
284#ifdef __KERNEL__ 285#ifdef __KERNEL__
285#define NR_syscalls 265 286#define NR_syscalls 266
286 287
287 288
288#define __ARCH_WANT_IPC_PARSE_VERSION 289#define __ARCH_WANT_IPC_PARSE_VERSION
diff --git a/include/asm-frv/highmem.h b/include/asm-frv/highmem.h
index e2247c22a638..0f390f41f816 100644
--- a/include/asm-frv/highmem.h
+++ b/include/asm-frv/highmem.h
@@ -82,11 +82,11 @@ extern struct page *kmap_atomic_to_page(void *ptr);
82 dampr = paddr | xAMPRx_L | xAMPRx_M | xAMPRx_S | xAMPRx_SS_16Kb | xAMPRx_V; \ 82 dampr = paddr | xAMPRx_L | xAMPRx_M | xAMPRx_S | xAMPRx_SS_16Kb | xAMPRx_V; \
83 \ 83 \
84 if (type != __KM_CACHE) \ 84 if (type != __KM_CACHE) \
85 asm volatile("movgs %0,dampr"#ampr :: "r"(dampr)); \ 85 asm volatile("movgs %0,dampr"#ampr :: "r"(dampr) : "memory"); \
86 else \ 86 else \
87 asm volatile("movgs %0,iampr"#ampr"\n" \ 87 asm volatile("movgs %0,iampr"#ampr"\n" \
88 "movgs %0,dampr"#ampr"\n" \ 88 "movgs %0,dampr"#ampr"\n" \
89 :: "r"(dampr) \ 89 :: "r"(dampr) : "memory" \
90 ); \ 90 ); \
91 \ 91 \
92 asm("movsg damlr"#ampr",%0" : "=r"(damlr)); \ 92 asm("movsg damlr"#ampr",%0" : "=r"(damlr)); \
@@ -104,7 +104,7 @@ extern struct page *kmap_atomic_to_page(void *ptr);
104 asm volatile("movgs %0,tplr \n" \ 104 asm volatile("movgs %0,tplr \n" \
105 "movgs %1,tppr \n" \ 105 "movgs %1,tppr \n" \
106 "tlbpr %0,gr0,#2,#1" \ 106 "tlbpr %0,gr0,#2,#1" \
107 : : "r"(damlr), "r"(dampr)); \ 107 : : "r"(damlr), "r"(dampr) : "memory"); \
108 \ 108 \
109 /*printk("TLB: SECN sl=%d L=%08lx P=%08lx\n", slot, damlr, dampr);*/ \ 109 /*printk("TLB: SECN sl=%d L=%08lx P=%08lx\n", slot, damlr, dampr);*/ \
110 \ 110 \
@@ -115,7 +115,7 @@ static inline void *kmap_atomic(struct page *page, enum km_type type)
115{ 115{
116 unsigned long paddr; 116 unsigned long paddr;
117 117
118 preempt_disable(); 118 inc_preempt_count();
119 paddr = page_to_phys(page); 119 paddr = page_to_phys(page);
120 120
121 switch (type) { 121 switch (type) {
@@ -138,16 +138,16 @@ static inline void *kmap_atomic(struct page *page, enum km_type type)
138 } 138 }
139} 139}
140 140
141#define __kunmap_atomic_primary(type, ampr) \ 141#define __kunmap_atomic_primary(type, ampr) \
142do { \ 142do { \
143 asm volatile("movgs gr0,dampr"#ampr"\n"); \ 143 asm volatile("movgs gr0,dampr"#ampr"\n" ::: "memory"); \
144 if (type == __KM_CACHE) \ 144 if (type == __KM_CACHE) \
145 asm volatile("movgs gr0,iampr"#ampr"\n"); \ 145 asm volatile("movgs gr0,iampr"#ampr"\n" ::: "memory"); \
146} while(0) 146} while(0)
147 147
148#define __kunmap_atomic_secondary(slot, vaddr) \ 148#define __kunmap_atomic_secondary(slot, vaddr) \
149do { \ 149do { \
150 asm volatile("tlbpr %0,gr0,#4,#1" : : "r"(vaddr)); \ 150 asm volatile("tlbpr %0,gr0,#4,#1" : : "r"(vaddr) : "memory"); \
151} while(0) 151} while(0)
152 152
153static inline void kunmap_atomic(void *kvaddr, enum km_type type) 153static inline void kunmap_atomic(void *kvaddr, enum km_type type)
@@ -170,7 +170,8 @@ static inline void kunmap_atomic(void *kvaddr, enum km_type type)
170 default: 170 default:
171 BUG(); 171 BUG();
172 } 172 }
173 preempt_enable(); 173 dec_preempt_count();
174 preempt_check_resched();
174} 175}
175 176
176#endif /* !__ASSEMBLY__ */ 177#endif /* !__ASSEMBLY__ */
diff --git a/include/asm-frv/io.h b/include/asm-frv/io.h
index 7765f5528894..20e44fe00abf 100644
--- a/include/asm-frv/io.h
+++ b/include/asm-frv/io.h
@@ -385,27 +385,6 @@ static inline void pci_iounmap(struct pci_dev *dev, void __iomem *p)
385 */ 385 */
386#define xlate_dev_kmem_ptr(p) p 386#define xlate_dev_kmem_ptr(p) p
387 387
388/*
389 * Check BIOS signature
390 */
391static inline int check_signature(volatile void __iomem *io_addr,
392 const unsigned char *signature, int length)
393{
394 int retval = 0;
395
396 do {
397 if (readb(io_addr) != *signature)
398 goto out;
399 io_addr++;
400 signature++;
401 length--;
402 } while (length);
403
404 retval = 1;
405out:
406 return retval;
407}
408
409#endif /* __KERNEL__ */ 388#endif /* __KERNEL__ */
410 389
411#endif /* _ASM_IO_H */ 390#endif /* _ASM_IO_H */
diff --git a/include/asm-generic/bitops/sched.h b/include/asm-generic/bitops/sched.h
index 5ef93a4d009f..815bb0148060 100644
--- a/include/asm-generic/bitops/sched.h
+++ b/include/asm-generic/bitops/sched.h
@@ -15,7 +15,7 @@ static inline int sched_find_first_bit(const unsigned long *b)
15#if BITS_PER_LONG == 64 15#if BITS_PER_LONG == 64
16 if (unlikely(b[0])) 16 if (unlikely(b[0]))
17 return __ffs(b[0]); 17 return __ffs(b[0]);
18 if (unlikely(b[1])) 18 if (likely(b[1]))
19 return __ffs(b[1]) + 64; 19 return __ffs(b[1]) + 64;
20 return __ffs(b[2]) + 128; 20 return __ffs(b[2]) + 128;
21#elif BITS_PER_LONG == 32 21#elif BITS_PER_LONG == 32
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index 1d9573cf4a0b..c92ae0f166ff 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -37,7 +37,10 @@
37#endif 37#endif
38 38
39#ifndef HAVE_ARCH_WARN_ON 39#ifndef HAVE_ARCH_WARN_ON
40#define WARN_ON(condition) unlikely((condition)) 40#define WARN_ON(condition) ({ \
41 typeof(condition) __ret_warn_on = (condition); \
42 unlikely(__ret_warn_on); \
43})
41#endif 44#endif
42#endif 45#endif
43 46
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 69240b52f8e1..e60d6f21fa62 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -125,6 +125,10 @@
125 *(__param) \ 125 *(__param) \
126 VMLINUX_SYMBOL(__stop___param) = .; \ 126 VMLINUX_SYMBOL(__stop___param) = .; \
127 } \ 127 } \
128 \
129 /* Unwind data binary search table */ \
130 EH_FRAME_HDR \
131 \
128 __end_rodata = .; \ 132 __end_rodata = .; \
129 . = ALIGN(4096); 133 . = ALIGN(4096);
130 134
@@ -157,6 +161,18 @@
157 *(.kprobes.text) \ 161 *(.kprobes.text) \
158 VMLINUX_SYMBOL(__kprobes_text_end) = .; 162 VMLINUX_SYMBOL(__kprobes_text_end) = .;
159 163
164#ifdef CONFIG_STACK_UNWIND
165 /* Unwind data binary search table */
166#define EH_FRAME_HDR \
167 .eh_frame_hdr : AT(ADDR(.eh_frame_hdr) - LOAD_OFFSET) { \
168 VMLINUX_SYMBOL(__start_unwind_hdr) = .; \
169 *(.eh_frame_hdr) \
170 VMLINUX_SYMBOL(__end_unwind_hdr) = .; \
171 }
172#else
173#define EH_FRAME_HDR
174#endif
175
160 /* DWARF debug sections. 176 /* DWARF debug sections.
161 Symbols in the DWARF debugging sections are relative to 177 Symbols in the DWARF debugging sections are relative to
162 the beginning of the section so we begin them at 0. */ 178 the beginning of the section so we begin them at 0. */
@@ -197,3 +213,22 @@
197 213
198#define NOTES \ 214#define NOTES \
199 .notes : { *(.note.*) } :note 215 .notes : { *(.note.*) } :note
216
217#define INITCALLS \
218 *(.initcall0.init) \
219 *(.initcall0s.init) \
220 *(.initcall1.init) \
221 *(.initcall1s.init) \
222 *(.initcall2.init) \
223 *(.initcall2s.init) \
224 *(.initcall3.init) \
225 *(.initcall3s.init) \
226 *(.initcall4.init) \
227 *(.initcall4s.init) \
228 *(.initcall5.init) \
229 *(.initcall5s.init) \
230 *(.initcall6.init) \
231 *(.initcall6s.init) \
232 *(.initcall7.init) \
233 *(.initcall7s.init)
234
diff --git a/include/asm-i386/acpi.h b/include/asm-i386/acpi.h
index 6016632d032f..c80b3a94511a 100644
--- a/include/asm-i386/acpi.h
+++ b/include/asm-i386/acpi.h
@@ -132,6 +132,7 @@ extern int acpi_gsi_to_irq(u32 gsi, unsigned int *irq);
132 132
133#ifdef CONFIG_X86_IO_APIC 133#ifdef CONFIG_X86_IO_APIC
134extern int acpi_skip_timer_override; 134extern int acpi_skip_timer_override;
135extern int acpi_use_timer_override;
135#endif 136#endif
136 137
137static inline void acpi_noirq_set(void) { acpi_noirq = 1; } 138static inline void acpi_noirq_set(void) { acpi_noirq = 1; }
diff --git a/include/asm-i386/io.h b/include/asm-i386/io.h
index b3724fe93ff1..68df0dc3ab8f 100644
--- a/include/asm-i386/io.h
+++ b/include/asm-i386/io.h
@@ -224,33 +224,6 @@ static inline void memcpy_toio(volatile void __iomem *dst, const void *src, int
224 224
225#define eth_io_copy_and_sum(a,b,c,d) eth_copy_and_sum((a),(void __force *)(b),(c),(d)) 225#define eth_io_copy_and_sum(a,b,c,d) eth_copy_and_sum((a),(void __force *)(b),(c),(d))
226 226
227/**
228 * check_signature - find BIOS signatures
229 * @io_addr: mmio address to check
230 * @signature: signature block
231 * @length: length of signature
232 *
233 * Perform a signature comparison with the mmio address io_addr. This
234 * address should have been obtained by ioremap.
235 * Returns 1 on a match.
236 */
237
238static inline int check_signature(volatile void __iomem * io_addr,
239 const unsigned char *signature, int length)
240{
241 int retval = 0;
242 do {
243 if (readb(io_addr) != *signature)
244 goto out;
245 io_addr++;
246 signature++;
247 length--;
248 } while (length);
249 retval = 1;
250out:
251 return retval;
252}
253
254/* 227/*
255 * Cache management 228 * Cache management
256 * 229 *
diff --git a/include/asm-i386/io_apic.h b/include/asm-i386/io_apic.h
index 276ea7e8144a..059a9ff28b4d 100644
--- a/include/asm-i386/io_apic.h
+++ b/include/asm-i386/io_apic.h
@@ -12,10 +12,6 @@
12 12
13#ifdef CONFIG_X86_IO_APIC 13#ifdef CONFIG_X86_IO_APIC
14 14
15#define IO_APIC_BASE(idx) \
16 ((volatile int *)(__fix_to_virt(FIX_IO_APIC_BASE_0 + idx) \
17 + (mp_ioapics[idx].mpc_apicaddr & ~PAGE_MASK)))
18
19/* 15/*
20 * The structure of the IO-APIC: 16 * The structure of the IO-APIC:
21 */ 17 */
@@ -119,31 +115,8 @@ extern struct mpc_config_intsrc mp_irqs[MAX_IRQ_SOURCES];
119/* non-0 if default (table-less) MP configuration */ 115/* non-0 if default (table-less) MP configuration */
120extern int mpc_default_type; 116extern int mpc_default_type;
121 117
122static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg) 118/* Older SiS APIC requires we rewrite the index register */
123{
124 *IO_APIC_BASE(apic) = reg;
125 return *(IO_APIC_BASE(apic)+4);
126}
127
128static inline void io_apic_write(unsigned int apic, unsigned int reg, unsigned int value)
129{
130 *IO_APIC_BASE(apic) = reg;
131 *(IO_APIC_BASE(apic)+4) = value;
132}
133
134/*
135 * Re-write a value: to be used for read-modify-write
136 * cycles where the read already set up the index register.
137 *
138 * Older SiS APIC requires we rewrite the index regiser
139 */
140extern int sis_apic_bug; 119extern int sis_apic_bug;
141static inline void io_apic_modify(unsigned int apic, unsigned int reg, unsigned int value)
142{
143 if (sis_apic_bug)
144 *IO_APIC_BASE(apic) = reg;
145 *(IO_APIC_BASE(apic)+4) = value;
146}
147 120
148/* 1 if "noapic" boot option passed */ 121/* 1 if "noapic" boot option passed */
149extern int skip_ioapic_setup; 122extern int skip_ioapic_setup;
diff --git a/include/asm-i386/mach-visws/do_timer.h b/include/asm-i386/mach-visws/do_timer.h
deleted file mode 100644
index 21cd696d4d0f..000000000000
--- a/include/asm-i386/mach-visws/do_timer.h
+++ /dev/null
@@ -1,53 +0,0 @@
1/* defines for inline arch setup functions */
2
3#include <asm/fixmap.h>
4#include <asm/i8259.h>
5#include "cobalt.h"
6
7static inline void do_timer_interrupt_hook(void)
8{
9 /* Clear the interrupt */
10 co_cpu_write(CO_CPU_STAT,co_cpu_read(CO_CPU_STAT) & ~CO_STAT_TIMEINTR);
11
12 do_timer(1);
13#ifndef CONFIG_SMP
14 update_process_times(user_mode_vm(irq_regs));
15#endif
16/*
17 * In the SMP case we use the local APIC timer interrupt to do the
18 * profiling, except when we simulate SMP mode on a uniprocessor
19 * system, in that case we have to call the local interrupt handler.
20 */
21#ifndef CONFIG_X86_LOCAL_APIC
22 profile_tick(CPU_PROFILING);
23#else
24 if (!using_apic_timer)
25 smp_local_timer_interrupt();
26#endif
27}
28
29static inline int do_timer_overflow(int count)
30{
31 int i;
32
33 spin_lock(&i8259A_lock);
34 /*
35 * This is tricky when I/O APICs are used;
36 * see do_timer_interrupt().
37 */
38 i = inb(0x20);
39 spin_unlock(&i8259A_lock);
40
41 /* assumption about timer being IRQ0 */
42 if (i & 0x01) {
43 /*
44 * We cannot detect lost timer interrupts ...
45 * well, that's why we call them lost, don't we? :)
46 * [hmm, on the Pentium and Alpha we can ... sort of]
47 */
48 count -= LATCH;
49 } else {
50 printk("do_slow_gettimeoffset(): hardware timer problem?\n");
51 }
52 return count;
53}
diff --git a/include/asm-i386/mach-visws/mach_apic.h b/include/asm-i386/mach-visws/mach_apic.h
index de438c7147a8..18afe6b6fc4d 100644
--- a/include/asm-i386/mach-visws/mach_apic.h
+++ b/include/asm-i386/mach-visws/mach_apic.h
@@ -51,6 +51,11 @@ static inline void clustered_apic_check(void)
51{ 51{
52} 52}
53 53
54static inline int apicid_to_node(int logical_apicid)
55{
56 return 0;
57}
58
54/* Mapping from cpu number to logical apicid */ 59/* Mapping from cpu number to logical apicid */
55static inline int cpu_to_logical_apicid(int cpu) 60static inline int cpu_to_logical_apicid(int cpu)
56{ 61{
diff --git a/include/asm-i386/processor.h b/include/asm-i386/processor.h
index 2277127696d2..e0ddca94d50c 100644
--- a/include/asm-i386/processor.h
+++ b/include/asm-i386/processor.h
@@ -306,6 +306,8 @@ static inline void __mwait(unsigned long eax, unsigned long ecx)
306 : :"a" (eax), "c" (ecx)); 306 : :"a" (eax), "c" (ecx));
307} 307}
308 308
309extern void mwait_idle_with_hints(unsigned long eax, unsigned long ecx);
310
309/* from system description table in BIOS. Mostly for MCA use, but 311/* from system description table in BIOS. Mostly for MCA use, but
310others may find it useful. */ 312others may find it useful. */
311extern unsigned int machine_id; 313extern unsigned int machine_id;
diff --git a/include/asm-i386/uaccess.h b/include/asm-i386/uaccess.h
index 54d905ebc63d..eef5133b9ce2 100644
--- a/include/asm-i386/uaccess.h
+++ b/include/asm-i386/uaccess.h
@@ -404,20 +404,6 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero(void *to,
404 * anything, so this is accurate. 404 * anything, so this is accurate.
405 */ 405 */
406 406
407/**
408 * __copy_to_user: - Copy a block of data into user space, with less checking.
409 * @to: Destination address, in user space.
410 * @from: Source address, in kernel space.
411 * @n: Number of bytes to copy.
412 *
413 * Context: User context only. This function may sleep.
414 *
415 * Copy data from kernel space to user space. Caller must check
416 * the specified block with access_ok() before calling this function.
417 *
418 * Returns number of bytes that could not be copied.
419 * On success, this will be zero.
420 */
421static __always_inline unsigned long __must_check 407static __always_inline unsigned long __must_check
422__copy_to_user_inatomic(void __user *to, const void *from, unsigned long n) 408__copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
423{ 409{
@@ -439,35 +425,27 @@ __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
439 return __copy_to_user_ll(to, from, n); 425 return __copy_to_user_ll(to, from, n);
440} 426}
441 427
442static __always_inline unsigned long __must_check
443__copy_to_user(void __user *to, const void *from, unsigned long n)
444{
445 might_sleep();
446 return __copy_to_user_inatomic(to, from, n);
447}
448
449/** 428/**
450 * __copy_from_user: - Copy a block of data from user space, with less checking. 429 * __copy_to_user: - Copy a block of data into user space, with less checking.
451 * @to: Destination address, in kernel space. 430 * @to: Destination address, in user space.
452 * @from: Source address, in user space. 431 * @from: Source address, in kernel space.
453 * @n: Number of bytes to copy. 432 * @n: Number of bytes to copy.
454 * 433 *
455 * Context: User context only. This function may sleep. 434 * Context: User context only. This function may sleep.
456 * 435 *
457 * Copy data from user space to kernel space. Caller must check 436 * Copy data from kernel space to user space. Caller must check
458 * the specified block with access_ok() before calling this function. 437 * the specified block with access_ok() before calling this function.
459 * 438 *
460 * Returns number of bytes that could not be copied. 439 * Returns number of bytes that could not be copied.
461 * On success, this will be zero. 440 * On success, this will be zero.
462 *
463 * If some data could not be copied, this function will pad the copied
464 * data to the requested size using zero bytes.
465 *
466 * An alternate version - __copy_from_user_inatomic() - may be called from
467 * atomic context and will fail rather than sleep. In this case the
468 * uncopied bytes will *NOT* be padded with zeros. See fs/filemap.h
469 * for explanation of why this is needed.
470 */ 441 */
442static __always_inline unsigned long __must_check
443__copy_to_user(void __user *to, const void *from, unsigned long n)
444{
445 might_sleep();
446 return __copy_to_user_inatomic(to, from, n);
447}
448
471static __always_inline unsigned long 449static __always_inline unsigned long
472__copy_from_user_inatomic(void *to, const void __user *from, unsigned long n) 450__copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
473{ 451{
@@ -493,6 +471,29 @@ __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
493 } 471 }
494 return __copy_from_user_ll_nozero(to, from, n); 472 return __copy_from_user_ll_nozero(to, from, n);
495} 473}
474
475/**
476 * __copy_from_user: - Copy a block of data from user space, with less checking.
477 * @to: Destination address, in kernel space.
478 * @from: Source address, in user space.
479 * @n: Number of bytes to copy.
480 *
481 * Context: User context only. This function may sleep.
482 *
483 * Copy data from user space to kernel space. Caller must check
484 * the specified block with access_ok() before calling this function.
485 *
486 * Returns number of bytes that could not be copied.
487 * On success, this will be zero.
488 *
489 * If some data could not be copied, this function will pad the copied
490 * data to the requested size using zero bytes.
491 *
492 * An alternate version - __copy_from_user_inatomic() - may be called from
493 * atomic context and will fail rather than sleep. In this case the
494 * uncopied bytes will *NOT* be padded with zeros. See fs/filemap.h
495 * for explanation of why this is needed.
496 */
496static __always_inline unsigned long 497static __always_inline unsigned long
497__copy_from_user(void *to, const void __user *from, unsigned long n) 498__copy_from_user(void *to, const void __user *from, unsigned long n)
498{ 499{
diff --git a/include/asm-i386/unistd.h b/include/asm-i386/unistd.h
index 3ca7ab963d7d..beeeaf6b054a 100644
--- a/include/asm-i386/unistd.h
+++ b/include/asm-i386/unistd.h
@@ -324,10 +324,11 @@
324#define __NR_vmsplice 316 324#define __NR_vmsplice 316
325#define __NR_move_pages 317 325#define __NR_move_pages 317
326#define __NR_getcpu 318 326#define __NR_getcpu 318
327#define __NR_epoll_pwait 319
327 328
328#ifdef __KERNEL__ 329#ifdef __KERNEL__
329 330
330#define NR_syscalls 319 331#define NR_syscalls 320
331#include <linux/err.h> 332#include <linux/err.h>
332 333
333/* 334/*
diff --git a/include/asm-i386/vic.h b/include/asm-i386/vic.h
index 4abfcfb91eb8..53100f353612 100644
--- a/include/asm-i386/vic.h
+++ b/include/asm-i386/vic.h
@@ -58,4 +58,4 @@ static const int VIC_CPI_Registers[] =
58 58
59#define VIC_BOOT_INTERRUPT_MASK 0xfe 59#define VIC_BOOT_INTERRUPT_MASK 0xfe
60 60
61extern void smp_vic_timer_interrupt(struct pt_regs *regs); 61extern void smp_vic_timer_interrupt(void);
diff --git a/include/asm-i386/voyager.h b/include/asm-i386/voyager.h
index e74c54aa757f..5b27838905b2 100644
--- a/include/asm-i386/voyager.h
+++ b/include/asm-i386/voyager.h
@@ -118,33 +118,33 @@ typedef struct voyager_module {
118} voyager_module_t; 118} voyager_module_t;
119 119
120typedef struct voyager_eeprom_hdr { 120typedef struct voyager_eeprom_hdr {
121 __u8 module_id[4] __attribute__((packed)); 121 __u8 module_id[4];
122 __u8 version_id __attribute__((packed)); 122 __u8 version_id;
123 __u8 config_id __attribute__((packed)); 123 __u8 config_id;
124 __u16 boundry_id __attribute__((packed)); /* boundary scan id */ 124 __u16 boundry_id; /* boundary scan id */
125 __u16 ee_size __attribute__((packed)); /* size of EEPROM */ 125 __u16 ee_size; /* size of EEPROM */
126 __u8 assembly[11] __attribute__((packed)); /* assembly # */ 126 __u8 assembly[11]; /* assembly # */
127 __u8 assembly_rev __attribute__((packed)); /* assembly rev */ 127 __u8 assembly_rev; /* assembly rev */
128 __u8 tracer[4] __attribute__((packed)); /* tracer number */ 128 __u8 tracer[4]; /* tracer number */
129 __u16 assembly_cksum __attribute__((packed)); /* asm checksum */ 129 __u16 assembly_cksum; /* asm checksum */
130 __u16 power_consump __attribute__((packed)); /* pwr requirements */ 130 __u16 power_consump; /* pwr requirements */
131 __u16 num_asics __attribute__((packed)); /* number of asics */ 131 __u16 num_asics; /* number of asics */
132 __u16 bist_time __attribute__((packed)); /* min. bist time */ 132 __u16 bist_time; /* min. bist time */
133 __u16 err_log_offset __attribute__((packed)); /* error log offset */ 133 __u16 err_log_offset; /* error log offset */
134 __u16 scan_path_offset __attribute__((packed));/* scan path offset */ 134 __u16 scan_path_offset;/* scan path offset */
135 __u16 cct_offset __attribute__((packed)); 135 __u16 cct_offset;
136 __u16 log_length __attribute__((packed)); /* length of err log */ 136 __u16 log_length; /* length of err log */
137 __u16 xsum_end __attribute__((packed)); /* offset to end of 137 __u16 xsum_end; /* offset to end of
138 checksum */ 138 checksum */
139 __u8 reserved[4] __attribute__((packed)); 139 __u8 reserved[4];
140 __u8 sflag __attribute__((packed)); /* starting sentinal */ 140 __u8 sflag; /* starting sentinal */
141 __u8 part_number[13] __attribute__((packed)); /* prom part number */ 141 __u8 part_number[13]; /* prom part number */
142 __u8 version[10] __attribute__((packed)); /* version number */ 142 __u8 version[10]; /* version number */
143 __u8 signature[8] __attribute__((packed)); 143 __u8 signature[8];
144 __u16 eeprom_chksum __attribute__((packed)); 144 __u16 eeprom_chksum;
145 __u32 data_stamp_offset __attribute__((packed)); 145 __u32 data_stamp_offset;
146 __u8 eflag __attribute__((packed)); /* ending sentinal */ 146 __u8 eflag ; /* ending sentinal */
147} voyager_eprom_hdr_t; 147} __attribute__((packed)) voyager_eprom_hdr_t;
148 148
149 149
150 150
@@ -155,30 +155,30 @@ typedef struct voyager_eeprom_hdr {
155 * in the module EPROMs. We really only care about the IDs and 155 * in the module EPROMs. We really only care about the IDs and
156 * offsets */ 156 * offsets */
157typedef struct voyager_sp_table { 157typedef struct voyager_sp_table {
158 __u8 asic_id __attribute__((packed)); 158 __u8 asic_id;
159 __u8 bypass_flag __attribute__((packed)); 159 __u8 bypass_flag;
160 __u16 asic_data_offset __attribute__((packed)); 160 __u16 asic_data_offset;
161 __u16 config_data_offset __attribute__((packed)); 161 __u16 config_data_offset;
162} voyager_sp_table_t; 162} __attribute__((packed)) voyager_sp_table_t;
163 163
164typedef struct voyager_jtag_table { 164typedef struct voyager_jtag_table {
165 __u8 icode[4] __attribute__((packed)); 165 __u8 icode[4];
166 __u8 runbist[4] __attribute__((packed)); 166 __u8 runbist[4];
167 __u8 intest[4] __attribute__((packed)); 167 __u8 intest[4];
168 __u8 samp_preld[4] __attribute__((packed)); 168 __u8 samp_preld[4];
169 __u8 ireg_len __attribute__((packed)); 169 __u8 ireg_len;
170} voyager_jtt_t; 170} __attribute__((packed)) voyager_jtt_t;
171 171
172typedef struct voyager_asic_data_table { 172typedef struct voyager_asic_data_table {
173 __u8 jtag_id[4] __attribute__((packed)); 173 __u8 jtag_id[4];
174 __u16 length_bsr __attribute__((packed)); 174 __u16 length_bsr;
175 __u16 length_bist_reg __attribute__((packed)); 175 __u16 length_bist_reg;
176 __u32 bist_clk __attribute__((packed)); 176 __u32 bist_clk;
177 __u16 subaddr_bits __attribute__((packed)); 177 __u16 subaddr_bits;
178 __u16 seed_bits __attribute__((packed)); 178 __u16 seed_bits;
179 __u16 sig_bits __attribute__((packed)); 179 __u16 sig_bits;
180 __u16 jtag_offset __attribute__((packed)); 180 __u16 jtag_offset;
181} voyager_at_t; 181} __attribute__((packed)) voyager_at_t;
182 182
183/* Voyager Interrupt Controller (VIC) registers */ 183/* Voyager Interrupt Controller (VIC) registers */
184 184
@@ -328,52 +328,52 @@ struct voyager_bios_info {
328#define NUMBER_OF_POS_REGS 8 328#define NUMBER_OF_POS_REGS 8
329 329
330typedef struct { 330typedef struct {
331 __u8 MC_Slot __attribute__((packed)); 331 __u8 MC_Slot;
332 __u8 POS_Values[NUMBER_OF_POS_REGS] __attribute__((packed)); 332 __u8 POS_Values[NUMBER_OF_POS_REGS];
333} MC_SlotInformation_t; 333} __attribute__((packed)) MC_SlotInformation_t;
334 334
335struct QuadDescription { 335struct QuadDescription {
336 __u8 Type __attribute__((packed)); /* for type 0 (DYADIC or MONADIC) all fields 336 __u8 Type; /* for type 0 (DYADIC or MONADIC) all fields
337 * will be zero except for slot */ 337 * will be zero except for slot */
338 __u8 StructureVersion __attribute__((packed)); 338 __u8 StructureVersion;
339 __u32 CPI_BaseAddress __attribute__((packed)); 339 __u32 CPI_BaseAddress;
340 __u32 LARC_BankSize __attribute__((packed)); 340 __u32 LARC_BankSize;
341 __u32 LocalMemoryStateBits __attribute__((packed)); 341 __u32 LocalMemoryStateBits;
342 __u8 Slot __attribute__((packed)); /* Processor slots 1 - 4 */ 342 __u8 Slot; /* Processor slots 1 - 4 */
343}; 343} __attribute__((packed));
344 344
345struct ProcBoardInfo { 345struct ProcBoardInfo {
346 __u8 Type __attribute__((packed)); 346 __u8 Type;
347 __u8 StructureVersion __attribute__((packed)); 347 __u8 StructureVersion;
348 __u8 NumberOfBoards __attribute__((packed)); 348 __u8 NumberOfBoards;
349 struct QuadDescription QuadData[MAX_PROCESSOR_BOARDS] __attribute__((packed)); 349 struct QuadDescription QuadData[MAX_PROCESSOR_BOARDS];
350}; 350} __attribute__((packed));
351 351
352struct CacheDescription { 352struct CacheDescription {
353 __u8 Level __attribute__((packed)); 353 __u8 Level;
354 __u32 TotalSize __attribute__((packed)); 354 __u32 TotalSize;
355 __u16 LineSize __attribute__((packed)); 355 __u16 LineSize;
356 __u8 Associativity __attribute__((packed)); 356 __u8 Associativity;
357 __u8 CacheType __attribute__((packed)); 357 __u8 CacheType;
358 __u8 WriteType __attribute__((packed)); 358 __u8 WriteType;
359 __u8 Number_CPUs_SharedBy __attribute__((packed)); 359 __u8 Number_CPUs_SharedBy;
360 __u8 Shared_CPUs_Hardware_IDs[MAX_SHARED_CPUS] __attribute__((packed)); 360 __u8 Shared_CPUs_Hardware_IDs[MAX_SHARED_CPUS];
361 361
362}; 362} __attribute__((packed));
363 363
364struct CPU_Description { 364struct CPU_Description {
365 __u8 CPU_HardwareId __attribute__((packed)); 365 __u8 CPU_HardwareId;
366 char *FRU_String __attribute__((packed)); 366 char *FRU_String;
367 __u8 NumberOfCacheLevels __attribute__((packed)); 367 __u8 NumberOfCacheLevels;
368 struct CacheDescription CacheLevelData[MAX_CACHE_LEVELS] __attribute__((packed)); 368 struct CacheDescription CacheLevelData[MAX_CACHE_LEVELS];
369}; 369} __attribute__((packed));
370 370
371struct CPU_Info { 371struct CPU_Info {
372 __u8 Type __attribute__((packed)); 372 __u8 Type;
373 __u8 StructureVersion __attribute__((packed)); 373 __u8 StructureVersion;
374 __u8 NumberOf_CPUs __attribute__((packed)); 374 __u8 NumberOf_CPUs;
375 struct CPU_Description CPU_Data[MAX_CPUS] __attribute__((packed)); 375 struct CPU_Description CPU_Data[MAX_CPUS];
376}; 376} __attribute__((packed));
377 377
378 378
379/* 379/*
diff --git a/include/asm-ia64/io.h b/include/asm-ia64/io.h
index 43bfff6c6b87..855c30af72a9 100644
--- a/include/asm-ia64/io.h
+++ b/include/asm-ia64/io.h
@@ -417,6 +417,8 @@ __writeq (unsigned long val, volatile void __iomem *addr)
417# define outl_p outl 417# define outl_p outl
418#endif 418#endif
419 419
420# ifdef __KERNEL__
421
420extern void __iomem * ioremap(unsigned long offset, unsigned long size); 422extern void __iomem * ioremap(unsigned long offset, unsigned long size);
421extern void __iomem * ioremap_nocache (unsigned long offset, unsigned long size); 423extern void __iomem * ioremap_nocache (unsigned long offset, unsigned long size);
422 424
@@ -430,8 +432,6 @@ iounmap (volatile void __iomem *addr)
430#define dmi_iounmap(x,l) iounmap(x) 432#define dmi_iounmap(x,l) iounmap(x)
431#define dmi_alloc(l) kmalloc(l, GFP_ATOMIC) 433#define dmi_alloc(l) kmalloc(l, GFP_ATOMIC)
432 434
433# ifdef __KERNEL__
434
435/* 435/*
436 * String version of IO memory access ops: 436 * String version of IO memory access ops:
437 */ 437 */
diff --git a/include/asm-ia64/pal.h b/include/asm-ia64/pal.h
index 2c8fd92d0ece..4283ddcc25fb 100644
--- a/include/asm-ia64/pal.h
+++ b/include/asm-ia64/pal.h
@@ -764,7 +764,7 @@ struct ia64_pal_retval {
764 * (generally 0) MUST be passed. Reserved parameters are not optional 764 * (generally 0) MUST be passed. Reserved parameters are not optional
765 * parameters. 765 * parameters.
766 */ 766 */
767extern struct ia64_pal_retval ia64_pal_call_static (u64, u64, u64, u64, u64); 767extern struct ia64_pal_retval ia64_pal_call_static (u64, u64, u64, u64);
768extern struct ia64_pal_retval ia64_pal_call_stacked (u64, u64, u64, u64); 768extern struct ia64_pal_retval ia64_pal_call_stacked (u64, u64, u64, u64);
769extern struct ia64_pal_retval ia64_pal_call_phys_static (u64, u64, u64, u64); 769extern struct ia64_pal_retval ia64_pal_call_phys_static (u64, u64, u64, u64);
770extern struct ia64_pal_retval ia64_pal_call_phys_stacked (u64, u64, u64, u64); 770extern struct ia64_pal_retval ia64_pal_call_phys_stacked (u64, u64, u64, u64);
@@ -774,14 +774,7 @@ extern void ia64_load_scratch_fpregs (struct ia64_fpreg *);
774#define PAL_CALL(iprv,a0,a1,a2,a3) do { \ 774#define PAL_CALL(iprv,a0,a1,a2,a3) do { \
775 struct ia64_fpreg fr[6]; \ 775 struct ia64_fpreg fr[6]; \
776 ia64_save_scratch_fpregs(fr); \ 776 ia64_save_scratch_fpregs(fr); \
777 iprv = ia64_pal_call_static(a0, a1, a2, a3, 0); \ 777 iprv = ia64_pal_call_static(a0, a1, a2, a3); \
778 ia64_load_scratch_fpregs(fr); \
779} while (0)
780
781#define PAL_CALL_IC_OFF(iprv,a0,a1,a2,a3) do { \
782 struct ia64_fpreg fr[6]; \
783 ia64_save_scratch_fpregs(fr); \
784 iprv = ia64_pal_call_static(a0, a1, a2, a3, 1); \
785 ia64_load_scratch_fpregs(fr); \ 778 ia64_load_scratch_fpregs(fr); \
786} while (0) 779} while (0)
787 780
diff --git a/include/asm-ia64/sal.h b/include/asm-ia64/sal.h
index 0b210abbe003..d000689d9142 100644
--- a/include/asm-ia64/sal.h
+++ b/include/asm-ia64/sal.h
@@ -659,6 +659,7 @@ ia64_sal_freq_base (unsigned long which, unsigned long *ticks_per_second,
659} 659}
660 660
661extern s64 ia64_sal_cache_flush (u64 cache_type); 661extern s64 ia64_sal_cache_flush (u64 cache_type);
662extern void __init check_sal_cache_flush (void);
662 663
663/* Initialize all the processor and platform level instruction and data caches */ 664/* Initialize all the processor and platform level instruction and data caches */
664static inline s64 665static inline s64
diff --git a/include/asm-ia64/sn/addrs.h b/include/asm-ia64/sn/addrs.h
index 1d9efe541662..e715c794b186 100644
--- a/include/asm-ia64/sn/addrs.h
+++ b/include/asm-ia64/sn/addrs.h
@@ -136,9 +136,13 @@
136 */ 136 */
137#define TO_PHYS(x) (TO_PHYS_MASK & (x)) 137#define TO_PHYS(x) (TO_PHYS_MASK & (x))
138#define TO_CAC(x) (CAC_BASE | TO_PHYS(x)) 138#define TO_CAC(x) (CAC_BASE | TO_PHYS(x))
139#ifdef CONFIG_SGI_SN
139#define TO_AMO(x) (AMO_BASE | TO_PHYS(x)) 140#define TO_AMO(x) (AMO_BASE | TO_PHYS(x))
140#define TO_GET(x) (GET_BASE | TO_PHYS(x)) 141#define TO_GET(x) (GET_BASE | TO_PHYS(x))
141 142#else
143#define TO_AMO(x) ({ BUG(); x; })
144#define TO_GET(x) ({ BUG(); x; })
145#endif
142 146
143/* 147/*
144 * Covert from processor physical address to II/TIO physical address: 148 * Covert from processor physical address to II/TIO physical address:
diff --git a/include/asm-ia64/uaccess.h b/include/asm-ia64/uaccess.h
index 9adb51211c22..449c8c0fa2bd 100644
--- a/include/asm-ia64/uaccess.h
+++ b/include/asm-ia64/uaccess.h
@@ -389,7 +389,7 @@ xlate_dev_kmem_ptr (char * p)
389 struct page *page; 389 struct page *page;
390 char * ptr; 390 char * ptr;
391 391
392 page = virt_to_page((unsigned long)p >> PAGE_SHIFT); 392 page = virt_to_page((unsigned long)p);
393 if (PageUncached(page)) 393 if (PageUncached(page))
394 ptr = (char *)__pa(p) + __IA64_UNCACHED_OFFSET; 394 ptr = (char *)__pa(p) + __IA64_UNCACHED_OFFSET;
395 else 395 else
diff --git a/include/asm-m32r/io.h b/include/asm-m32r/io.h
index 70ad1c949c2b..d06933bd6318 100644
--- a/include/asm-m32r/io.h
+++ b/include/asm-m32r/io.h
@@ -166,38 +166,6 @@ static inline void _writel(unsigned long l, unsigned long addr)
166 166
167#define flush_write_buffers() do { } while (0) /* M32R_FIXME */ 167#define flush_write_buffers() do { } while (0) /* M32R_FIXME */
168 168
169/**
170 * check_signature - find BIOS signatures
171 * @io_addr: mmio address to check
172 * @signature: signature block
173 * @length: length of signature
174 *
175 * Perform a signature comparison with the ISA mmio address io_addr.
176 * Returns 1 on a match.
177 *
178 * This function is deprecated. New drivers should use ioremap and
179 * check_signature.
180 */
181
182static inline int check_signature(void __iomem *io_addr,
183 const unsigned char *signature, int length)
184{
185 int retval = 0;
186#if 0
187printk("check_signature\n");
188 do {
189 if (readb(io_addr) != *signature)
190 goto out;
191 io_addr++;
192 signature++;
193 length--;
194 } while (length);
195 retval = 1;
196out:
197#endif
198 return retval;
199}
200
201static inline void 169static inline void
202memset_io(volatile void __iomem *addr, unsigned char val, int count) 170memset_io(volatile void __iomem *addr, unsigned char val, int count)
203{ 171{
diff --git a/include/asm-m68k/sun3mmu.h b/include/asm-m68k/sun3mmu.h
index 6c8c17d047a1..d8f17a0d8c9f 100644
--- a/include/asm-m68k/sun3mmu.h
+++ b/include/asm-m68k/sun3mmu.h
@@ -4,6 +4,7 @@
4#ifndef __SUN3_MMU_H__ 4#ifndef __SUN3_MMU_H__
5#define __SUN3_MMU_H__ 5#define __SUN3_MMU_H__
6 6
7#include <linux/types.h>
7#include <asm/movs.h> 8#include <asm/movs.h>
8#include <asm/sun3-head.h> 9#include <asm/sun3-head.h>
9 10
@@ -160,7 +161,7 @@ static inline void sun3_put_context(unsigned char c)
160 return; 161 return;
161} 162}
162 163
163extern void *sun3_ioremap(unsigned long phys, unsigned long size, 164extern void __iomem *sun3_ioremap(unsigned long phys, unsigned long size,
164 unsigned long type); 165 unsigned long type);
165 166
166extern int sun3_map_test(unsigned long addr, char *val); 167extern int sun3_map_test(unsigned long addr, char *val);
diff --git a/include/asm-m68k/uaccess.h b/include/asm-m68k/uaccess.h
index 88b1f47400e1..e4c9f080ff20 100644
--- a/include/asm-m68k/uaccess.h
+++ b/include/asm-m68k/uaccess.h
@@ -76,7 +76,7 @@ asm volatile ("\n" \
76 break; \ 76 break; \
77 case 8: \ 77 case 8: \
78 { \ 78 { \
79 const void *__pu_ptr = (ptr); \ 79 const void __user *__pu_ptr = (ptr); \
80 asm volatile ("\n" \ 80 asm volatile ("\n" \
81 "1: moves.l %2,(%1)+\n" \ 81 "1: moves.l %2,(%1)+\n" \
82 "2: moves.l %R2,(%1)\n" \ 82 "2: moves.l %R2,(%1)\n" \
@@ -125,7 +125,7 @@ asm volatile ("\n" \
125 " .previous" \ 125 " .previous" \
126 : "+d" (res), "=&" #reg (__gu_val) \ 126 : "+d" (res), "=&" #reg (__gu_val) \
127 : "m" (*(ptr)), "i" (err)); \ 127 : "m" (*(ptr)), "i" (err)); \
128 (x) = (typeof(*(ptr)))(long)__gu_val; \ 128 (x) = (typeof(*(ptr)))(unsigned long)__gu_val; \
129}) 129})
130 130
131#define __get_user(x, ptr) \ 131#define __get_user(x, ptr) \
@@ -221,16 +221,16 @@ __constant_copy_from_user(void *to, const void __user *from, unsigned long n)
221 221
222 switch (n) { 222 switch (n) {
223 case 1: 223 case 1:
224 __get_user_asm(res, *(u8 *)to, (u8 *)from, u8, b, d, 1); 224 __get_user_asm(res, *(u8 *)to, (u8 __user *)from, u8, b, d, 1);
225 break; 225 break;
226 case 2: 226 case 2:
227 __get_user_asm(res, *(u16 *)to, (u16 *)from, u16, w, d, 2); 227 __get_user_asm(res, *(u16 *)to, (u16 __user *)from, u16, w, d, 2);
228 break; 228 break;
229 case 3: 229 case 3:
230 __constant_copy_from_user_asm(res, to, from, tmp, 3, w, b,); 230 __constant_copy_from_user_asm(res, to, from, tmp, 3, w, b,);
231 break; 231 break;
232 case 4: 232 case 4:
233 __get_user_asm(res, *(u32 *)to, (u32 *)from, u32, l, r, 4); 233 __get_user_asm(res, *(u32 *)to, (u32 __user *)from, u32, l, r, 4);
234 break; 234 break;
235 case 5: 235 case 5:
236 __constant_copy_from_user_asm(res, to, from, tmp, 5, l, b,); 236 __constant_copy_from_user_asm(res, to, from, tmp, 5, l, b,);
@@ -302,16 +302,16 @@ __constant_copy_to_user(void __user *to, const void *from, unsigned long n)
302 302
303 switch (n) { 303 switch (n) {
304 case 1: 304 case 1:
305 __put_user_asm(res, *(u8 *)from, (u8 *)to, b, d, 1); 305 __put_user_asm(res, *(u8 *)from, (u8 __user *)to, b, d, 1);
306 break; 306 break;
307 case 2: 307 case 2:
308 __put_user_asm(res, *(u16 *)from, (u16 *)to, w, d, 2); 308 __put_user_asm(res, *(u16 *)from, (u16 __user *)to, w, d, 2);
309 break; 309 break;
310 case 3: 310 case 3:
311 __constant_copy_to_user_asm(res, to, from, tmp, 3, w, b,); 311 __constant_copy_to_user_asm(res, to, from, tmp, 3, w, b,);
312 break; 312 break;
313 case 4: 313 case 4:
314 __put_user_asm(res, *(u32 *)from, (u32 *)to, l, r, 4); 314 __put_user_asm(res, *(u32 *)from, (u32 __user *)to, l, r, 4);
315 break; 315 break;
316 case 5: 316 case 5:
317 __constant_copy_to_user_asm(res, to, from, tmp, 5, l, b,); 317 __constant_copy_to_user_asm(res, to, from, tmp, 5, l, b,);
diff --git a/include/asm-m68knommu/irq_regs.h b/include/asm-m68knommu/irq_regs.h
new file mode 100644
index 000000000000..3dd9c0b70270
--- /dev/null
+++ b/include/asm-m68knommu/irq_regs.h
@@ -0,0 +1 @@
#include <asm-generic/irq_regs.h>
diff --git a/include/asm-m68knommu/irqnode.h b/include/asm-m68knommu/irqnode.h
index a2503dfc554c..6132a9858b52 100644
--- a/include/asm-m68knommu/irqnode.h
+++ b/include/asm-m68knommu/irqnode.h
@@ -8,7 +8,7 @@
8 * interrupt source (if it supports chaining). 8 * interrupt source (if it supports chaining).
9 */ 9 */
10typedef struct irq_node { 10typedef struct irq_node {
11 irqreturn_t (*handler)(int, void *, struct pt_regs *); 11 irq_handler_t handler;
12 unsigned long flags; 12 unsigned long flags;
13 void *dev_id; 13 void *dev_id;
14 const char *devname; 14 const char *devname;
@@ -18,12 +18,12 @@ typedef struct irq_node {
18/* 18/*
19 * This structure has only 4 elements for speed reasons 19 * This structure has only 4 elements for speed reasons
20 */ 20 */
21typedef struct irq_handler { 21struct irq_entry {
22 irqreturn_t (*handler)(int, void *, struct pt_regs *); 22 irq_handler_t handler;
23 unsigned long flags; 23 unsigned long flags;
24 void *dev_id; 24 void *dev_id;
25 const char *devname; 25 const char *devname;
26} irq_handler_t; 26};
27 27
28/* count of spurious interrupts */ 28/* count of spurious interrupts */
29extern volatile unsigned int num_spurious; 29extern volatile unsigned int num_spurious;
diff --git a/include/asm-m68knommu/machdep.h b/include/asm-m68knommu/machdep.h
index 27c90afd3339..6ce28f8e0ead 100644
--- a/include/asm-m68knommu/machdep.h
+++ b/include/asm-m68knommu/machdep.h
@@ -18,7 +18,7 @@ extern int (*mach_kbdrate) (struct kbd_repeat *);
18extern void (*mach_kbd_leds) (unsigned int); 18extern void (*mach_kbd_leds) (unsigned int);
19/* machine dependent irq functions */ 19/* machine dependent irq functions */
20extern void (*mach_init_IRQ) (void); 20extern void (*mach_init_IRQ) (void);
21extern irqreturn_t (*(*mach_default_handler)[]) (int, void *, struct pt_regs *); 21extern irq_handler_t mach_default_handler;
22extern int (*mach_request_irq) (unsigned int irq, void (*handler)(int, void *, struct pt_regs *), 22extern int (*mach_request_irq) (unsigned int irq, void (*handler)(int, void *, struct pt_regs *),
23 unsigned long flags, const char *devname, void *dev_id); 23 unsigned long flags, const char *devname, void *dev_id);
24extern void (*mach_free_irq) (unsigned int irq, void *dev_id); 24extern void (*mach_free_irq) (unsigned int irq, void *dev_id);
diff --git a/include/asm-m68knommu/unistd.h b/include/asm-m68knommu/unistd.h
index daafb5d43ef1..ebaf03197114 100644
--- a/include/asm-m68knommu/unistd.h
+++ b/include/asm-m68knommu/unistd.h
@@ -281,14 +281,43 @@
281#define __NR_mq_notify 275 281#define __NR_mq_notify 275
282#define __NR_mq_getsetattr 276 282#define __NR_mq_getsetattr 276
283#define __NR_waitid 277 283#define __NR_waitid 277
284#define __NR_sys_setaltroot 278 284#define __NR_vserver 278
285#define __NR_add_key 279 285#define __NR_add_key 279
286#define __NR_request_key 280 286#define __NR_request_key 280
287#define __NR_keyctl 281 287#define __NR_keyctl 281
288 288#define __NR_ioprio_set 282
289#define __NR_ioprio_get 283
290#define __NR_inotify_init 284
291#define __NR_inotify_add_watch 285
292#define __NR_inotify_rm_watch 286
293#define __NR_migrate_pages 287
294#define __NR_openat 288
295#define __NR_mkdirat 289
296#define __NR_mknodat 290
297#define __NR_fchownat 291
298#define __NR_futimesat 292
299#define __NR_fstatat64 293
300#define __NR_unlinkat 294
301#define __NR_renameat 295
302#define __NR_linkat 296
303#define __NR_symlinkat 297
304#define __NR_readlinkat 298
305#define __NR_fchmodat 299
306#define __NR_faccessat 300
307#define __NR_pselect6 301
308#define __NR_ppoll 302
309#define __NR_unshare 303
310#define __NR_set_robust_list 304
311#define __NR_get_robust_list 305
312#define __NR_splice 306
313#define __NR_sync_file_range 307
314#define __NR_tee 308
315#define __NR_vmsplice 309
316#define __NR_move_pages 310
317
289#ifdef __KERNEL__ 318#ifdef __KERNEL__
290 319
291#define NR_syscalls 282 320#define NR_syscalls 311
292#include <linux/err.h> 321#include <linux/err.h>
293 322
294/* user-visible error numbers are in the range -1 - -MAX_ERRNO: see 323/* user-visible error numbers are in the range -1 - -MAX_ERRNO: see
diff --git a/include/asm-mips/asm.h b/include/asm-mips/asm.h
index e3038a4599ee..838eb3144d81 100644
--- a/include/asm-mips/asm.h
+++ b/include/asm-mips/asm.h
@@ -344,6 +344,7 @@ symbol = value
344#define PTR_L lw 344#define PTR_L lw
345#define PTR_S sw 345#define PTR_S sw
346#define PTR_LA la 346#define PTR_LA la
347#define PTR_LI li
347#define PTR_SLL sll 348#define PTR_SLL sll
348#define PTR_SLLV sllv 349#define PTR_SLLV sllv
349#define PTR_SRL srl 350#define PTR_SRL srl
@@ -368,6 +369,7 @@ symbol = value
368#define PTR_L ld 369#define PTR_L ld
369#define PTR_S sd 370#define PTR_S sd
370#define PTR_LA dla 371#define PTR_LA dla
372#define PTR_LI dli
371#define PTR_SLL dsll 373#define PTR_SLL dsll
372#define PTR_SLLV dsllv 374#define PTR_SLLV dsllv
373#define PTR_SRL dsrl 375#define PTR_SRL dsrl
diff --git a/include/asm-mips/cacheflush.h b/include/asm-mips/cacheflush.h
index 9ab59e2bb233..e3c9925876a3 100644
--- a/include/asm-mips/cacheflush.h
+++ b/include/asm-mips/cacheflush.h
@@ -55,24 +55,13 @@ extern void (*flush_icache_range)(unsigned long start, unsigned long end);
55#define flush_cache_vmap(start, end) flush_cache_all() 55#define flush_cache_vmap(start, end) flush_cache_all()
56#define flush_cache_vunmap(start, end) flush_cache_all() 56#define flush_cache_vunmap(start, end) flush_cache_all()
57 57
58static inline void copy_to_user_page(struct vm_area_struct *vma, 58extern void copy_to_user_page(struct vm_area_struct *vma,
59 struct page *page, unsigned long vaddr, void *dst, const void *src, 59 struct page *page, unsigned long vaddr, void *dst, const void *src,
60 unsigned long len) 60 unsigned long len);
61{
62 if (cpu_has_dc_aliases)
63 flush_cache_page(vma, vaddr, page_to_pfn(page));
64 memcpy(dst, src, len);
65 __flush_icache_page(vma, page);
66}
67 61
68static inline void copy_from_user_page(struct vm_area_struct *vma, 62extern void copy_from_user_page(struct vm_area_struct *vma,
69 struct page *page, unsigned long vaddr, void *dst, const void *src, 63 struct page *page, unsigned long vaddr, void *dst, const void *src,
70 unsigned long len) 64 unsigned long len);
71{
72 if (cpu_has_dc_aliases)
73 flush_cache_page(vma, vaddr, page_to_pfn(page));
74 memcpy(dst, src, len);
75}
76 65
77extern void (*flush_cache_sigtramp)(unsigned long addr); 66extern void (*flush_cache_sigtramp)(unsigned long addr);
78extern void (*flush_icache_all)(void); 67extern void (*flush_icache_all)(void);
diff --git a/include/asm-mips/div64.h b/include/asm-mips/div64.h
index 5f7dcf5452e7..d107832de1b6 100644
--- a/include/asm-mips/div64.h
+++ b/include/asm-mips/div64.h
@@ -83,27 +83,6 @@
83#if (_MIPS_SZLONG == 64) 83#if (_MIPS_SZLONG == 64)
84 84
85/* 85/*
86 * Don't use this one in new code
87 */
88#define do_div64_32(res, high, low, base) ({ \
89 unsigned int __quot, __mod; \
90 unsigned long __div; \
91 unsigned int __low, __high, __base; \
92 \
93 __high = (high); \
94 __low = (low); \
95 __div = __high; \
96 __div = __div << 32 | __low; \
97 __base = (base); \
98 \
99 __mod = __div % __base; \
100 __div = __div / __base; \
101 \
102 __quot = __div; \
103 (res) = __quot; \
104 __mod; })
105
106/*
107 * Hey, we're already 64-bit, no 86 * Hey, we're already 64-bit, no
108 * need to play games.. 87 * need to play games..
109 */ 88 */
diff --git a/include/asm-mips/fixmap.h b/include/asm-mips/fixmap.h
index 6959bdb59310..02c8a13fc894 100644
--- a/include/asm-mips/fixmap.h
+++ b/include/asm-mips/fixmap.h
@@ -45,8 +45,16 @@
45 * fix-mapped? 45 * fix-mapped?
46 */ 46 */
47enum fixed_addresses { 47enum fixed_addresses {
48#define FIX_N_COLOURS 8
49 FIX_CMAP_BEGIN,
50#ifdef CONFIG_MIPS_MT_SMTC
51 FIX_CMAP_END = FIX_CMAP_BEGIN + (FIX_N_COLOURS * NR_CPUS),
52#else
53 FIX_CMAP_END = FIX_CMAP_BEGIN + FIX_N_COLOURS,
54#endif
48#ifdef CONFIG_HIGHMEM 55#ifdef CONFIG_HIGHMEM
49 FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */ 56 /* reserved pte's for temporary kernel mappings */
57 FIX_KMAP_BEGIN = FIX_CMAP_END + 1,
50 FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1, 58 FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
51#endif 59#endif
52 __end_of_fixed_addresses 60 __end_of_fixed_addresses
@@ -70,9 +78,9 @@ extern void __set_fixmap (enum fixed_addresses idx,
70 * at the top of mem.. 78 * at the top of mem..
71 */ 79 */
72#if defined(CONFIG_CPU_TX39XX) || defined(CONFIG_CPU_TX49XX) 80#if defined(CONFIG_CPU_TX39XX) || defined(CONFIG_CPU_TX49XX)
73#define FIXADDR_TOP (0xff000000UL - 0x2000) 81#define FIXADDR_TOP ((unsigned long)(long)(int)(0xff000000 - 0x20000))
74#else 82#else
75#define FIXADDR_TOP (0xffffe000UL) 83#define FIXADDR_TOP ((unsigned long)(long)(int)0xfffe0000)
76#endif 84#endif
77#define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT) 85#define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
78#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) 86#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)
diff --git a/include/asm-mips/io.h b/include/asm-mips/io.h
index df624e1ee6e2..bc5f3c53155f 100644
--- a/include/asm-mips/io.h
+++ b/include/asm-mips/io.h
@@ -172,7 +172,7 @@ extern unsigned long isa_slot_offset;
172#define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT) 172#define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT)
173 173
174extern void __iomem * __ioremap(phys_t offset, phys_t size, unsigned long flags); 174extern void __iomem * __ioremap(phys_t offset, phys_t size, unsigned long flags);
175extern void __iounmap(volatile void __iomem *addr); 175extern void __iounmap(const volatile void __iomem *addr);
176 176
177static inline void __iomem * __ioremap_mode(phys_t offset, unsigned long size, 177static inline void __iomem * __ioremap_mode(phys_t offset, unsigned long size,
178 unsigned long flags) 178 unsigned long flags)
@@ -279,7 +279,7 @@ static inline void __iomem * __ioremap_mode(phys_t offset, unsigned long size,
279#define ioremap_uncached_accelerated(offset, size) \ 279#define ioremap_uncached_accelerated(offset, size) \
280 __ioremap_mode((offset), (size), _CACHE_UNCACHED_ACCELERATED) 280 __ioremap_mode((offset), (size), _CACHE_UNCACHED_ACCELERATED)
281 281
282static inline void iounmap(volatile void __iomem *addr) 282static inline void iounmap(const volatile void __iomem *addr)
283{ 283{
284#define __IS_KSEG1(addr) (((unsigned long)(addr) & ~0x1fffffffUL) == CKSEG1) 284#define __IS_KSEG1(addr) (((unsigned long)(addr) & ~0x1fffffffUL) == CKSEG1)
285 285
@@ -562,32 +562,6 @@ extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
562#define eth_io_copy_and_sum(skb,src,len,unused) memcpy_fromio((skb)->data,(src),(len)) 562#define eth_io_copy_and_sum(skb,src,len,unused) memcpy_fromio((skb)->data,(src),(len))
563 563
564/* 564/*
565 * check_signature - find BIOS signatures
566 * @io_addr: mmio address to check
567 * @signature: signature block
568 * @length: length of signature
569 *
570 * Perform a signature comparison with the mmio address io_addr. This
571 * address should have been obtained by ioremap.
572 * Returns 1 on a match.
573 */
574static inline int check_signature(char __iomem *io_addr,
575 const unsigned char *signature, int length)
576{
577 int retval = 0;
578 do {
579 if (readb(io_addr) != *signature)
580 goto out;
581 io_addr++;
582 signature++;
583 length--;
584 } while (length);
585 retval = 1;
586out:
587 return retval;
588}
589
590/*
591 * The caches on some architectures aren't dma-coherent and have need to 565 * The caches on some architectures aren't dma-coherent and have need to
592 * handle this in software. There are three types of operations that 566 * handle this in software. There are three types of operations that
593 * can be applied to dma buffers. 567 * can be applied to dma buffers.
diff --git a/include/asm-mips/irq.h b/include/asm-mips/irq.h
index 1a9804c65369..35a05ca5560c 100644
--- a/include/asm-mips/irq.h
+++ b/include/asm-mips/irq.h
@@ -24,8 +24,6 @@ static inline int irq_canonicalize(int irq)
24#define irq_canonicalize(irq) (irq) /* Sane hardware, sane code ... */ 24#define irq_canonicalize(irq) (irq) /* Sane hardware, sane code ... */
25#endif 25#endif
26 26
27struct pt_regs;
28
29extern asmlinkage unsigned int do_IRQ(unsigned int irq); 27extern asmlinkage unsigned int do_IRQ(unsigned int irq);
30 28
31#ifdef CONFIG_MIPS_MT_SMTC 29#ifdef CONFIG_MIPS_MT_SMTC
@@ -76,4 +74,8 @@ extern int setup_irq_smtc(unsigned int irq, struct irqaction * new,
76 unsigned long hwmask); 74 unsigned long hwmask);
77#endif /* CONFIG_MIPS_MT_SMTC */ 75#endif /* CONFIG_MIPS_MT_SMTC */
78 76
77extern int allocate_irqno(void);
78extern void alloc_legacy_irqno(void);
79extern void free_irqno(unsigned int irq);
80
79#endif /* _ASM_IRQ_H */ 81#endif /* _ASM_IRQ_H */
diff --git a/include/asm-mips/mipsmtregs.h b/include/asm-mips/mipsmtregs.h
index f637ce70758f..3e9468f424f4 100644
--- a/include/asm-mips/mipsmtregs.h
+++ b/include/asm-mips/mipsmtregs.h
@@ -352,6 +352,8 @@ do { \
352#define write_vpe_c0_vpecontrol(val) mttc0(1, 1, val) 352#define write_vpe_c0_vpecontrol(val) mttc0(1, 1, val)
353#define read_vpe_c0_vpeconf0() mftc0(1, 2) 353#define read_vpe_c0_vpeconf0() mftc0(1, 2)
354#define write_vpe_c0_vpeconf0(val) mttc0(1, 2, val) 354#define write_vpe_c0_vpeconf0(val) mttc0(1, 2, val)
355#define read_vpe_c0_count() mftc0(9, 0)
356#define write_vpe_c0_count(val) mttc0(9, 0, val)
355#define read_vpe_c0_status() mftc0(12, 0) 357#define read_vpe_c0_status() mftc0(12, 0)
356#define write_vpe_c0_status(val) mttc0(12, 0, val) 358#define write_vpe_c0_status(val) mttc0(12, 0, val)
357#define read_vpe_c0_cause() mftc0(13, 0) 359#define read_vpe_c0_cause() mftc0(13, 0)
diff --git a/include/asm-mips/pgalloc.h b/include/asm-mips/pgalloc.h
index 582c1fe6cc4a..af121c67dc71 100644
--- a/include/asm-mips/pgalloc.h
+++ b/include/asm-mips/pgalloc.h
@@ -48,7 +48,7 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm)
48 48
49 ret = (pgd_t *) __get_free_pages(GFP_KERNEL, PGD_ORDER); 49 ret = (pgd_t *) __get_free_pages(GFP_KERNEL, PGD_ORDER);
50 if (ret) { 50 if (ret) {
51 init = pgd_offset(&init_mm, 0); 51 init = pgd_offset(&init_mm, 0UL);
52 pgd_init((unsigned long)ret); 52 pgd_init((unsigned long)ret);
53 memcpy(ret + USER_PTRS_PER_PGD, init + USER_PTRS_PER_PGD, 53 memcpy(ret + USER_PTRS_PER_PGD, init + USER_PTRS_PER_PGD,
54 (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t)); 54 (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
diff --git a/include/asm-mips/pgtable-64.h b/include/asm-mips/pgtable-64.h
index d05fb6f38aa7..7e7320300aa3 100644
--- a/include/asm-mips/pgtable-64.h
+++ b/include/asm-mips/pgtable-64.h
@@ -174,7 +174,7 @@ static inline void pud_clear(pud_t *pudp)
174#define __pmd_offset(address) pmd_index(address) 174#define __pmd_offset(address) pmd_index(address)
175 175
176/* to find an entry in a kernel page-table-directory */ 176/* to find an entry in a kernel page-table-directory */
177#define pgd_offset_k(address) pgd_offset(&init_mm, 0) 177#define pgd_offset_k(address) pgd_offset(&init_mm, 0UL)
178 178
179#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1)) 179#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
180#define pmd_index(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1)) 180#define pmd_index(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
diff --git a/include/asm-mips/sibyte/sb1250.h b/include/asm-mips/sibyte/sb1250.h
index b09e16c93ca0..2ba6988ddc8e 100644
--- a/include/asm-mips/sibyte/sb1250.h
+++ b/include/asm-mips/sibyte/sb1250.h
@@ -51,8 +51,8 @@ extern void sb1250_mask_irq(int cpu, int irq);
51extern void sb1250_unmask_irq(int cpu, int irq); 51extern void sb1250_unmask_irq(int cpu, int irq);
52extern void sb1250_smp_finish(void); 52extern void sb1250_smp_finish(void);
53 53
54extern void bcm1480_hpt_setup(void);
54extern void bcm1480_time_init(void); 55extern void bcm1480_time_init(void);
55extern unsigned long bcm1480_gettimeoffset(void);
56extern void bcm1480_mask_irq(int cpu, int irq); 56extern void bcm1480_mask_irq(int cpu, int irq);
57extern void bcm1480_unmask_irq(int cpu, int irq); 57extern void bcm1480_unmask_irq(int cpu, int irq);
58extern void bcm1480_smp_finish(void); 58extern void bcm1480_smp_finish(void);
diff --git a/include/asm-mips/stackframe.h b/include/asm-mips/stackframe.h
index 158a4cd12e46..1fae5dc58138 100644
--- a/include/asm-mips/stackframe.h
+++ b/include/asm-mips/stackframe.h
@@ -59,69 +59,43 @@
59 .endm 59 .endm
60 60
61#ifdef CONFIG_SMP 61#ifdef CONFIG_SMP
62 .macro get_saved_sp /* SMP variation */
63#ifdef CONFIG_32BIT
64#ifdef CONFIG_MIPS_MT_SMTC 62#ifdef CONFIG_MIPS_MT_SMTC
65 .set mips32 63#define PTEBASE_SHIFT 19 /* TCBIND */
66 mfc0 k0, CP0_TCBIND;
67 .set mips0
68 lui k1, %hi(kernelsp)
69 srl k0, k0, 19
70 /* No need to shift down and up to clear bits 0-1 */
71#else 64#else
72 mfc0 k0, CP0_CONTEXT 65#define PTEBASE_SHIFT 23 /* CONTEXT */
73 lui k1, %hi(kernelsp)
74 srl k0, k0, 23
75#endif
76 addu k1, k0
77 LONG_L k1, %lo(kernelsp)(k1)
78#endif 66#endif
79#ifdef CONFIG_64BIT 67 .macro get_saved_sp /* SMP variation */
80#ifdef CONFIG_MIPS_MT_SMTC 68#ifdef CONFIG_MIPS_MT_SMTC
81 .set mips64 69 mfc0 k0, CP0_TCBIND
82 mfc0 k0, CP0_TCBIND;
83 .set mips0
84 lui k0, %highest(kernelsp)
85 dsrl k1, 19
86 /* No need to shift down and up to clear bits 0-2 */
87#else 70#else
88 MFC0 k1, CP0_CONTEXT 71 MFC0 k0, CP0_CONTEXT
89 lui k0, %highest(kernelsp) 72#endif
90 dsrl k1, 23 73#if defined(CONFIG_BUILD_ELF64) || (defined(CONFIG_64BIT) && __GNUC__ < 4)
91 daddiu k0, %higher(kernelsp) 74 lui k1, %highest(kernelsp)
92 dsll k0, k0, 16 75 daddiu k1, %higher(kernelsp)
93 daddiu k0, %hi(kernelsp) 76 dsll k1, 16
94 dsll k0, k0, 16 77 daddiu k1, %hi(kernelsp)
95#endif /* CONFIG_MIPS_MT_SMTC */ 78 dsll k1, 16
96 daddu k1, k1, k0 79#else
80 lui k1, %hi(kernelsp)
81#endif
82 LONG_SRL k0, PTEBASE_SHIFT
83 LONG_ADDU k1, k0
97 LONG_L k1, %lo(kernelsp)(k1) 84 LONG_L k1, %lo(kernelsp)(k1)
98#endif /* CONFIG_64BIT */
99 .endm 85 .endm
100 86
101 .macro set_saved_sp stackp temp temp2 87 .macro set_saved_sp stackp temp temp2
102#ifdef CONFIG_32BIT
103#ifdef CONFIG_MIPS_MT_SMTC
104 mfc0 \temp, CP0_TCBIND
105 srl \temp, 19
106#else
107 mfc0 \temp, CP0_CONTEXT
108 srl \temp, 23
109#endif
110#endif
111#ifdef CONFIG_64BIT
112#ifdef CONFIG_MIPS_MT_SMTC 88#ifdef CONFIG_MIPS_MT_SMTC
113 mfc0 \temp, CP0_TCBIND 89 mfc0 \temp, CP0_TCBIND
114 dsrl \temp, 19
115#else 90#else
116 MFC0 \temp, CP0_CONTEXT 91 MFC0 \temp, CP0_CONTEXT
117 dsrl \temp, 23
118#endif
119#endif 92#endif
93 LONG_SRL \temp, PTEBASE_SHIFT
120 LONG_S \stackp, kernelsp(\temp) 94 LONG_S \stackp, kernelsp(\temp)
121 .endm 95 .endm
122#else 96#else
123 .macro get_saved_sp /* Uniprocessor variation */ 97 .macro get_saved_sp /* Uniprocessor variation */
124#ifdef CONFIG_64BIT 98#if defined(CONFIG_BUILD_ELF64) || (defined(CONFIG_64BIT) && __GNUC__ < 4)
125 lui k1, %highest(kernelsp) 99 lui k1, %highest(kernelsp)
126 daddiu k1, %higher(kernelsp) 100 daddiu k1, %higher(kernelsp)
127 dsll k1, k1, 16 101 dsll k1, k1, 16
diff --git a/include/asm-mips/system.h b/include/asm-mips/system.h
index dcb4701d5728..3056feed5a36 100644
--- a/include/asm-mips/system.h
+++ b/include/asm-mips/system.h
@@ -392,7 +392,7 @@ static inline unsigned long __cmpxchg_u64(volatile int * m, unsigned long old,
392{ 392{
393 __u64 retval; 393 __u64 retval;
394 394
395 if (cpu_has_llsc) { 395 if (cpu_has_llsc && R10000_LLSC_WAR) {
396 __asm__ __volatile__( 396 __asm__ __volatile__(
397 " .set push \n" 397 " .set push \n"
398 " .set noat \n" 398 " .set noat \n"
diff --git a/include/asm-mips/termbits.h b/include/asm-mips/termbits.h
index fa6d04dac56b..b62ec7c521cc 100644
--- a/include/asm-mips/termbits.h
+++ b/include/asm-mips/termbits.h
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 1995, 1996, 1999, 2001 Ralf Baechle 6 * Copyright (C) 1995, 96, 99, 2001, 06 Ralf Baechle
7 * Copyright (C) 1999 Silicon Graphics, Inc. 7 * Copyright (C) 1999 Silicon Graphics, Inc.
8 * Copyright (C) 2001 MIPS Technologies, Inc. 8 * Copyright (C) 2001 MIPS Technologies, Inc.
9 */ 9 */
@@ -13,14 +13,8 @@
13#include <linux/posix_types.h> 13#include <linux/posix_types.h>
14 14
15typedef unsigned char cc_t; 15typedef unsigned char cc_t;
16#if (_MIPS_SZLONG == 32) 16typedef unsigned int speed_t;
17typedef unsigned long speed_t; 17typedef unsigned int tcflag_t;
18typedef unsigned long tcflag_t;
19#endif
20#if (_MIPS_SZLONG == 64)
21typedef __u32 speed_t;
22typedef __u32 tcflag_t;
23#endif
24 18
25/* 19/*
26 * The ABI says nothing about NCC but seems to use NCCS as 20 * The ABI says nothing about NCC but seems to use NCCS as
diff --git a/include/asm-mips/time.h b/include/asm-mips/time.h
index 28512ba2266e..625acd337bc3 100644
--- a/include/asm-mips/time.h
+++ b/include/asm-mips/time.h
@@ -48,7 +48,8 @@ extern void (*mips_timer_ack)(void);
48 * If mips_hpt_read is NULL, an R4k-compatible timer setup is attempted. 48 * If mips_hpt_read is NULL, an R4k-compatible timer setup is attempted.
49 */ 49 */
50extern unsigned int (*mips_hpt_read)(void); 50extern unsigned int (*mips_hpt_read)(void);
51extern void (*mips_hpt_init)(unsigned int); 51extern void (*mips_hpt_init)(void);
52extern unsigned int mips_hpt_mask;
52 53
53/* 54/*
54 * to_tm() converts system time back to (year, mon, day, hour, min, sec). 55 * to_tm() converts system time back to (year, mon, day, hour, min, sec).
@@ -58,13 +59,6 @@ extern void (*mips_hpt_init)(unsigned int);
58extern void to_tm(unsigned long tim, struct rtc_time *tm); 59extern void to_tm(unsigned long tim, struct rtc_time *tm);
59 60
60/* 61/*
61 * do_gettimeoffset(). By default, this func pointer points to
62 * do_null_gettimeoffset(), which leads to the same resolution as HZ.
63 * Higher resolution versions are available, which give ~1us resolution.
64 */
65extern unsigned long (*do_gettimeoffset)(void);
66
67/*
68 * high-level timer interrupt routines. 62 * high-level timer interrupt routines.
69 */ 63 */
70extern irqreturn_t timer_interrupt(int irq, void *dev_id); 64extern irqreturn_t timer_interrupt(int irq, void *dev_id);
diff --git a/include/asm-mips/unistd.h b/include/asm-mips/unistd.h
index 685c91467e63..ec56aa52f669 100644
--- a/include/asm-mips/unistd.h
+++ b/include/asm-mips/unistd.h
@@ -331,16 +331,19 @@
331#define __NR_move_pages (__NR_Linux + 308) 331#define __NR_move_pages (__NR_Linux + 308)
332#define __NR_set_robust_list (__NR_Linux + 309) 332#define __NR_set_robust_list (__NR_Linux + 309)
333#define __NR_get_robust_list (__NR_Linux + 310) 333#define __NR_get_robust_list (__NR_Linux + 310)
334#define __NR_kexec_load (__NR_Linux + 311)
335#define __NR_getcpu (__NR_Linux + 312)
336#define __NR_epoll_pwait (__NR_Linux + 313)
334 337
335/* 338/*
336 * Offset of the last Linux o32 flavoured syscall 339 * Offset of the last Linux o32 flavoured syscall
337 */ 340 */
338#define __NR_Linux_syscalls 310 341#define __NR_Linux_syscalls 313
339 342
340#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */ 343#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
341 344
342#define __NR_O32_Linux 4000 345#define __NR_O32_Linux 4000
343#define __NR_O32_Linux_syscalls 310 346#define __NR_O32_Linux_syscalls 313
344 347
345#if _MIPS_SIM == _MIPS_SIM_ABI64 348#if _MIPS_SIM == _MIPS_SIM_ABI64
346 349
@@ -618,16 +621,19 @@
618#define __NR_move_pages (__NR_Linux + 267) 621#define __NR_move_pages (__NR_Linux + 267)
619#define __NR_set_robust_list (__NR_Linux + 268) 622#define __NR_set_robust_list (__NR_Linux + 268)
620#define __NR_get_robust_list (__NR_Linux + 269) 623#define __NR_get_robust_list (__NR_Linux + 269)
624#define __NR_kexec_load (__NR_Linux + 270)
625#define __NR_getcpu (__NR_Linux + 271)
626#define __NR_epoll_pwait (__NR_Linux + 272)
621 627
622/* 628/*
623 * Offset of the last Linux 64-bit flavoured syscall 629 * Offset of the last Linux 64-bit flavoured syscall
624 */ 630 */
625#define __NR_Linux_syscalls 269 631#define __NR_Linux_syscalls 272
626 632
627#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */ 633#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */
628 634
629#define __NR_64_Linux 5000 635#define __NR_64_Linux 5000
630#define __NR_64_Linux_syscalls 269 636#define __NR_64_Linux_syscalls 272
631 637
632#if _MIPS_SIM == _MIPS_SIM_NABI32 638#if _MIPS_SIM == _MIPS_SIM_NABI32
633 639
@@ -909,16 +915,19 @@
909#define __NR_move_pages (__NR_Linux + 271) 915#define __NR_move_pages (__NR_Linux + 271)
910#define __NR_set_robust_list (__NR_Linux + 272) 916#define __NR_set_robust_list (__NR_Linux + 272)
911#define __NR_get_robust_list (__NR_Linux + 273) 917#define __NR_get_robust_list (__NR_Linux + 273)
918#define __NR_kexec_load (__NR_Linux + 274)
919#define __NR_getcpu (__NR_Linux + 275)
920#define __NR_epoll_pwait (__NR_Linux + 276)
912 921
913/* 922/*
914 * Offset of the last N32 flavoured syscall 923 * Offset of the last N32 flavoured syscall
915 */ 924 */
916#define __NR_Linux_syscalls 273 925#define __NR_Linux_syscalls 276
917 926
918#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */ 927#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */
919 928
920#define __NR_N32_Linux 6000 929#define __NR_N32_Linux 6000
921#define __NR_N32_Linux_syscalls 273 930#define __NR_N32_Linux_syscalls 276
922 931
923#ifdef __KERNEL__ 932#ifdef __KERNEL__
924 933
@@ -1186,6 +1195,7 @@ type name (atype a,btype b,ctype c,dtype d,etype e,ftype f) \
1186#endif /* (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64) */ 1195#endif /* (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64) */
1187 1196
1188 1197
1198#define __ARCH_OMIT_COMPAT_SYS_GETDENTS64
1189#define __ARCH_WANT_IPC_PARSE_VERSION 1199#define __ARCH_WANT_IPC_PARSE_VERSION
1190#define __ARCH_WANT_OLD_READDIR 1200#define __ARCH_WANT_OLD_READDIR
1191#define __ARCH_WANT_SYS_ALARM 1201#define __ARCH_WANT_SYS_ALARM
diff --git a/include/asm-mips/vr41xx/vr41xx.h b/include/asm-mips/vr41xx/vr41xx.h
index dd3eb3dc5886..88b492f6ea9c 100644
--- a/include/asm-mips/vr41xx/vr41xx.h
+++ b/include/asm-mips/vr41xx/vr41xx.h
@@ -75,7 +75,7 @@ extern void vr41xx_mask_clock(vr41xx_clock_t clock);
75 * Interrupt Control Unit 75 * Interrupt Control Unit
76 */ 76 */
77extern int vr41xx_set_intassign(unsigned int irq, unsigned char intassign); 77extern int vr41xx_set_intassign(unsigned int irq, unsigned char intassign);
78extern int cascade_irq(unsigned int irq, int (*get_irq)(unsigned int, struct pt_regs *)); 78extern int cascade_irq(unsigned int irq, int (*get_irq)(unsigned int));
79 79
80#define PIUINT_COMMAND 0x0040 80#define PIUINT_COMMAND 0x0040
81#define PIUINT_DATA 0x0020 81#define PIUINT_DATA 0x0020
diff --git a/include/asm-powerpc/asm-compat.h b/include/asm-powerpc/asm-compat.h
index 8e64be0cc47d..c89bd58ee283 100644
--- a/include/asm-powerpc/asm-compat.h
+++ b/include/asm-powerpc/asm-compat.h
@@ -14,6 +14,58 @@
14# define ASM_CONST(x) __ASM_CONST(x) 14# define ASM_CONST(x) __ASM_CONST(x)
15#endif 15#endif
16 16
17
18/*
19 * Feature section common macros
20 *
21 * Note that the entries now contain offsets between the table entry
22 * and the code rather than absolute code pointers in order to be
23 * useable with the vdso shared library. There is also an assumption
24 * that values will be negative, that is, the fixup table has to be
25 * located after the code it fixes up.
26 */
27#ifdef CONFIG_PPC64
28#ifdef __powerpc64__
29/* 64 bits kernel, 64 bits code */
30#define MAKE_FTR_SECTION_ENTRY(msk, val, label, sect) \
3199: \
32 .section sect,"a"; \
33 .align 3; \
3498: \
35 .llong msk; \
36 .llong val; \
37 .llong label##b-98b; \
38 .llong 99b-98b; \
39 .previous
40#else /* __powerpc64__ */
41/* 64 bits kernel, 32 bits code (ie. vdso32) */
42#define MAKE_FTR_SECTION_ENTRY(msk, val, label, sect) \
4399: \
44 .section sect,"a"; \
45 .align 3; \
4698: \
47 .llong msk; \
48 .llong val; \
49 .long 0xffffffff; \
50 .long label##b-98b; \
51 .long 0xffffffff; \
52 .long 99b-98b; \
53 .previous
54#endif /* !__powerpc64__ */
55#else /* CONFIG_PPC64 */
56/* 32 bits kernel, 32 bits code */
57#define MAKE_FTR_SECTION_ENTRY(msk, val, label, sect) \
5899: \
59 .section sect,"a"; \
60 .align 2; \
6198: \
62 .long msk; \
63 .long val; \
64 .long label##b-98b; \
65 .long 99b-98b; \
66 .previous
67#endif /* !CONFIG_PPC64 */
68
17#ifdef __powerpc64__ 69#ifdef __powerpc64__
18 70
19/* operations for longs and pointers */ 71/* operations for longs and pointers */
diff --git a/include/asm-powerpc/cputable.h b/include/asm-powerpc/cputable.h
index 12707ab9dc98..a9a40149a7c0 100644
--- a/include/asm-powerpc/cputable.h
+++ b/include/asm-powerpc/cputable.h
@@ -89,8 +89,11 @@ struct cpu_spec {
89 89
90extern struct cpu_spec *cur_cpu_spec; 90extern struct cpu_spec *cur_cpu_spec;
91 91
92extern void identify_cpu(unsigned long offset, unsigned long cpu); 92extern unsigned int __start___ftr_fixup, __stop___ftr_fixup;
93extern void do_cpu_ftr_fixups(unsigned long offset); 93
94extern struct cpu_spec *identify_cpu(unsigned long offset);
95extern void do_feature_fixups(unsigned long value, void *fixup_start,
96 void *fixup_end);
94 97
95#endif /* __ASSEMBLY__ */ 98#endif /* __ASSEMBLY__ */
96 99
@@ -144,6 +147,7 @@ extern void do_cpu_ftr_fixups(unsigned long offset);
144#define CPU_FTR_CI_LARGE_PAGE LONG_ASM_CONST(0x0000100000000000) 147#define CPU_FTR_CI_LARGE_PAGE LONG_ASM_CONST(0x0000100000000000)
145#define CPU_FTR_PAUSE_ZERO LONG_ASM_CONST(0x0000200000000000) 148#define CPU_FTR_PAUSE_ZERO LONG_ASM_CONST(0x0000200000000000)
146#define CPU_FTR_PURR LONG_ASM_CONST(0x0000400000000000) 149#define CPU_FTR_PURR LONG_ASM_CONST(0x0000400000000000)
150#define CPU_FTR_CELL_TB_BUG LONG_ASM_CONST(0x0000800000000000)
147 151
148#ifndef __ASSEMBLY__ 152#ifndef __ASSEMBLY__
149 153
@@ -332,7 +336,7 @@ extern void do_cpu_ftr_fixups(unsigned long offset);
332#define CPU_FTRS_CELL (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \ 336#define CPU_FTRS_CELL (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \
333 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \ 337 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \
334 CPU_FTR_ALTIVEC_COMP | CPU_FTR_MMCRA | CPU_FTR_SMT | \ 338 CPU_FTR_ALTIVEC_COMP | CPU_FTR_MMCRA | CPU_FTR_SMT | \
335 CPU_FTR_PAUSE_ZERO | CPU_FTR_CI_LARGE_PAGE) 339 CPU_FTR_PAUSE_ZERO | CPU_FTR_CI_LARGE_PAGE | CPU_FTR_CELL_TB_BUG)
336#define CPU_FTRS_PA6T (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \ 340#define CPU_FTRS_PA6T (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \
337 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | \ 341 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | \
338 CPU_FTR_ALTIVEC_COMP | CPU_FTR_CI_LARGE_PAGE | \ 342 CPU_FTR_ALTIVEC_COMP | CPU_FTR_CI_LARGE_PAGE | \
@@ -431,29 +435,12 @@ static inline int cpu_has_feature(unsigned long feature)
431 435
432#ifdef __ASSEMBLY__ 436#ifdef __ASSEMBLY__
433 437
434#define BEGIN_FTR_SECTION 98: 438#define BEGIN_FTR_SECTION_NESTED(label) label:
435 439#define BEGIN_FTR_SECTION BEGIN_FTR_SECTION_NESTED(97)
436#ifndef __powerpc64__ 440#define END_FTR_SECTION_NESTED(msk, val, label) \
441 MAKE_FTR_SECTION_ENTRY(msk, val, label, __ftr_fixup)
437#define END_FTR_SECTION(msk, val) \ 442#define END_FTR_SECTION(msk, val) \
43899: \ 443 END_FTR_SECTION_NESTED(msk, val, 97)
439 .section __ftr_fixup,"a"; \
440 .align 2; \
441 .long msk; \
442 .long val; \
443 .long 98b; \
444 .long 99b; \
445 .previous
446#else /* __powerpc64__ */
447#define END_FTR_SECTION(msk, val) \
44899: \
449 .section __ftr_fixup,"a"; \
450 .align 3; \
451 .llong msk; \
452 .llong val; \
453 .llong 98b; \
454 .llong 99b; \
455 .previous
456#endif /* __powerpc64__ */
457 444
458#define END_FTR_SECTION_IFSET(msk) END_FTR_SECTION((msk), (msk)) 445#define END_FTR_SECTION_IFSET(msk) END_FTR_SECTION((msk), (msk))
459#define END_FTR_SECTION_IFCLR(msk) END_FTR_SECTION((msk), 0) 446#define END_FTR_SECTION_IFCLR(msk) END_FTR_SECTION((msk), 0)
diff --git a/include/asm-powerpc/current.h b/include/asm-powerpc/current.h
index 1938d6abd255..b8708aedf925 100644
--- a/include/asm-powerpc/current.h
+++ b/include/asm-powerpc/current.h
@@ -14,7 +14,17 @@ struct task_struct;
14#ifdef __powerpc64__ 14#ifdef __powerpc64__
15#include <asm/paca.h> 15#include <asm/paca.h>
16 16
17#define current (get_paca()->__current) 17static inline struct task_struct *get_current(void)
18{
19 struct task_struct *task;
20
21 __asm__ __volatile__("ld %0,%1(13)"
22 : "=r" (task)
23 : "i" (offsetof(struct paca_struct, __current)));
24
25 return task;
26}
27#define current get_current()
18 28
19#else 29#else
20 30
diff --git a/include/asm-powerpc/firmware.h b/include/asm-powerpc/firmware.h
index 1022737f4f34..fdf9aff71150 100644
--- a/include/asm-powerpc/firmware.h
+++ b/include/asm-powerpc/firmware.h
@@ -96,19 +96,16 @@ extern void machine_check_fwnmi(void);
96/* This is true if we are using the firmware NMI handler (typically LPAR) */ 96/* This is true if we are using the firmware NMI handler (typically LPAR) */
97extern int fwnmi_active; 97extern int fwnmi_active;
98 98
99#else /* __ASSEMBLY__ */ 99extern unsigned int __start___fw_ftr_fixup, __stop___fw_ftr_fixup;
100 100
101#define BEGIN_FW_FTR_SECTION 96: 101#else /* __ASSEMBLY__ */
102 102
103#define BEGIN_FW_FTR_SECTION_NESTED(label) label:
104#define BEGIN_FW_FTR_SECTION BEGIN_FW_FTR_SECTION_NESTED(97)
105#define END_FW_FTR_SECTION_NESTED(msk, val, label) \
106 MAKE_FTR_SECTION_ENTRY(msk, val, label, __fw_ftr_fixup)
103#define END_FW_FTR_SECTION(msk, val) \ 107#define END_FW_FTR_SECTION(msk, val) \
10497: \ 108 END_FW_FTR_SECTION_NESTED(msk, val, 97)
105 .section __fw_ftr_fixup,"a"; \
106 .align 3; \
107 .llong msk; \
108 .llong val; \
109 .llong 96b; \
110 .llong 97b; \
111 .previous
112 109
113#define END_FW_FTR_SECTION_IFSET(msk) END_FW_FTR_SECTION((msk), (msk)) 110#define END_FW_FTR_SECTION_IFSET(msk) END_FW_FTR_SECTION((msk), (msk))
114#define END_FW_FTR_SECTION_IFCLR(msk) END_FW_FTR_SECTION((msk), 0) 111#define END_FW_FTR_SECTION_IFCLR(msk) END_FW_FTR_SECTION((msk), 0)
diff --git a/include/asm-powerpc/i8259.h b/include/asm-powerpc/i8259.h
index 78489fb8d140..db1362f8c603 100644
--- a/include/asm-powerpc/i8259.h
+++ b/include/asm-powerpc/i8259.h
@@ -7,6 +7,7 @@
7#ifdef CONFIG_PPC_MERGE 7#ifdef CONFIG_PPC_MERGE
8extern void i8259_init(struct device_node *node, unsigned long intack_addr); 8extern void i8259_init(struct device_node *node, unsigned long intack_addr);
9extern unsigned int i8259_irq(void); 9extern unsigned int i8259_irq(void);
10extern struct irq_host *i8259_get_host(void);
10#else 11#else
11extern void i8259_init(unsigned long intack_addr, int offset); 12extern void i8259_init(unsigned long intack_addr, int offset);
12extern int i8259_irq(void); 13extern int i8259_irq(void);
diff --git a/include/asm-powerpc/io.h b/include/asm-powerpc/io.h
index cbbd8c648df1..c2c5f14b5f5f 100644
--- a/include/asm-powerpc/io.h
+++ b/include/asm-powerpc/io.h
@@ -163,8 +163,11 @@ extern void _outsl_ns(volatile u32 __iomem *port, const void *buf, long count);
163 163
164static inline void mmiowb(void) 164static inline void mmiowb(void)
165{ 165{
166 __asm__ __volatile__ ("sync" : : : "memory"); 166 unsigned long tmp;
167 get_paca()->io_sync = 0; 167
168 __asm__ __volatile__("sync; li %0,0; stb %0,%1(13)"
169 : "=&r" (tmp) : "i" (offsetof(struct paca_struct, io_sync))
170 : "memory");
168} 171}
169 172
170/* 173/*
@@ -404,32 +407,6 @@ static inline void __out_be64(volatile unsigned long __iomem *addr, unsigned lon
404 407
405#include <asm/eeh.h> 408#include <asm/eeh.h>
406 409
407/**
408 * check_signature - find BIOS signatures
409 * @io_addr: mmio address to check
410 * @signature: signature block
411 * @length: length of signature
412 *
413 * Perform a signature comparison with the mmio address io_addr. This
414 * address should have been obtained by ioremap.
415 * Returns 1 on a match.
416 */
417static inline int check_signature(const volatile void __iomem * io_addr,
418 const unsigned char *signature, int length)
419{
420 int retval = 0;
421 do {
422 if (readb(io_addr) != *signature)
423 goto out;
424 io_addr++;
425 signature++;
426 length--;
427 } while (length);
428 retval = 1;
429out:
430 return retval;
431}
432
433/* Nothing to do */ 410/* Nothing to do */
434 411
435#define dma_cache_inv(_start,_size) do { } while (0) 412#define dma_cache_inv(_start,_size) do { } while (0)
diff --git a/include/asm-powerpc/iommu.h b/include/asm-powerpc/iommu.h
index a5e98641a2ae..39fad685ffab 100644
--- a/include/asm-powerpc/iommu.h
+++ b/include/asm-powerpc/iommu.h
@@ -22,17 +22,35 @@
22#define _ASM_IOMMU_H 22#define _ASM_IOMMU_H
23#ifdef __KERNEL__ 23#ifdef __KERNEL__
24 24
25#include <asm/types.h> 25#include <linux/compiler.h>
26#include <linux/spinlock.h> 26#include <linux/spinlock.h>
27#include <linux/device.h> 27#include <linux/device.h>
28#include <linux/dma-mapping.h> 28#include <linux/dma-mapping.h>
29#include <asm/types.h>
30#include <asm/bitops.h>
31
32#define IOMMU_PAGE_SHIFT 12
33#define IOMMU_PAGE_SIZE (ASM_CONST(1) << IOMMU_PAGE_SHIFT)
34#define IOMMU_PAGE_MASK (~((1 << IOMMU_PAGE_SHIFT) - 1))
35#define IOMMU_PAGE_ALIGN(addr) _ALIGN_UP(addr, IOMMU_PAGE_SIZE)
36
37#ifndef __ASSEMBLY__
38
39/* Pure 2^n version of get_order */
40static __inline__ __attribute_const__ int get_iommu_order(unsigned long size)
41{
42 return __ilog2((size - 1) >> IOMMU_PAGE_SHIFT) + 1;
43}
44
45#endif /* __ASSEMBLY__ */
46
29 47
30/* 48/*
31 * IOMAP_MAX_ORDER defines the largest contiguous block 49 * IOMAP_MAX_ORDER defines the largest contiguous block
32 * of dma space we can get. IOMAP_MAX_ORDER = 13 50 * of dma space we can get. IOMAP_MAX_ORDER = 13
33 * allows up to 2**12 pages (4096 * 4096) = 16 MB 51 * allows up to 2**12 pages (4096 * 4096) = 16 MB
34 */ 52 */
35#define IOMAP_MAX_ORDER 13 53#define IOMAP_MAX_ORDER 13
36 54
37struct iommu_table { 55struct iommu_table {
38 unsigned long it_busno; /* Bus number this table belongs to */ 56 unsigned long it_busno; /* Bus number this table belongs to */
diff --git a/include/asm-powerpc/oprofile_impl.h b/include/asm-powerpc/oprofile_impl.h
index 5b33994cd488..07a10e590c1d 100644
--- a/include/asm-powerpc/oprofile_impl.h
+++ b/include/asm-powerpc/oprofile_impl.h
@@ -42,7 +42,7 @@ struct op_powerpc_model {
42 void (*reg_setup) (struct op_counter_config *, 42 void (*reg_setup) (struct op_counter_config *,
43 struct op_system_config *, 43 struct op_system_config *,
44 int num_counters); 44 int num_counters);
45 void (*cpu_setup) (void *); 45 void (*cpu_setup) (struct op_counter_config *);
46 void (*start) (struct op_counter_config *); 46 void (*start) (struct op_counter_config *);
47 void (*stop) (void); 47 void (*stop) (void);
48 void (*handle_interrupt) (struct pt_regs *, 48 void (*handle_interrupt) (struct pt_regs *,
@@ -121,7 +121,90 @@ static inline void ctr_write(unsigned int i, unsigned int val)
121 break; 121 break;
122 } 122 }
123} 123}
124#endif /* !CONFIG_FSL_BOOKE */ 124#else /* CONFIG_FSL_BOOKE */
125static inline u32 get_pmlca(int ctr)
126{
127 u32 pmlca;
128
129 switch (ctr) {
130 case 0:
131 pmlca = mfpmr(PMRN_PMLCA0);
132 break;
133 case 1:
134 pmlca = mfpmr(PMRN_PMLCA1);
135 break;
136 case 2:
137 pmlca = mfpmr(PMRN_PMLCA2);
138 break;
139 case 3:
140 pmlca = mfpmr(PMRN_PMLCA3);
141 break;
142 default:
143 panic("Bad ctr number\n");
144 }
145
146 return pmlca;
147}
148
149static inline void set_pmlca(int ctr, u32 pmlca)
150{
151 switch (ctr) {
152 case 0:
153 mtpmr(PMRN_PMLCA0, pmlca);
154 break;
155 case 1:
156 mtpmr(PMRN_PMLCA1, pmlca);
157 break;
158 case 2:
159 mtpmr(PMRN_PMLCA2, pmlca);
160 break;
161 case 3:
162 mtpmr(PMRN_PMLCA3, pmlca);
163 break;
164 default:
165 panic("Bad ctr number\n");
166 }
167}
168
169static inline unsigned int ctr_read(unsigned int i)
170{
171 switch(i) {
172 case 0:
173 return mfpmr(PMRN_PMC0);
174 case 1:
175 return mfpmr(PMRN_PMC1);
176 case 2:
177 return mfpmr(PMRN_PMC2);
178 case 3:
179 return mfpmr(PMRN_PMC3);
180 default:
181 return 0;
182 }
183}
184
185static inline void ctr_write(unsigned int i, unsigned int val)
186{
187 switch(i) {
188 case 0:
189 mtpmr(PMRN_PMC0, val);
190 break;
191 case 1:
192 mtpmr(PMRN_PMC1, val);
193 break;
194 case 2:
195 mtpmr(PMRN_PMC2, val);
196 break;
197 case 3:
198 mtpmr(PMRN_PMC3, val);
199 break;
200 default:
201 break;
202 }
203}
204
205
206#endif /* CONFIG_FSL_BOOKE */
207
125 208
126extern void op_powerpc_backtrace(struct pt_regs * const regs, unsigned int depth); 209extern void op_powerpc_backtrace(struct pt_regs * const regs, unsigned int depth);
127 210
diff --git a/include/asm-powerpc/pmc.h b/include/asm-powerpc/pmc.h
index 07d6a4279319..8588be68e0ad 100644
--- a/include/asm-powerpc/pmc.h
+++ b/include/asm-powerpc/pmc.h
@@ -32,18 +32,5 @@ void release_pmc_hardware(void);
32void power4_enable_pmcs(void); 32void power4_enable_pmcs(void);
33#endif 33#endif
34 34
35#ifdef CONFIG_FSL_BOOKE
36void init_pmc_stop(int ctr);
37void set_pmc_event(int ctr, int event);
38void set_pmc_user_kernel(int ctr, int user, int kernel);
39void set_pmc_marked(int ctr, int mark0, int mark1);
40void pmc_start_ctr(int ctr, int enable);
41void pmc_start_ctrs(int enable);
42void pmc_stop_ctrs(void);
43void dump_pmcs(void);
44
45extern struct op_powerpc_model op_model_fsl_booke;
46#endif
47
48#endif /* __KERNEL__ */ 35#endif /* __KERNEL__ */
49#endif /* _POWERPC_PMC_H */ 36#endif /* _POWERPC_PMC_H */
diff --git a/include/asm-powerpc/ppc_asm.h b/include/asm-powerpc/ppc_asm.h
index a940cfe040da..fa083d8e4663 100644
--- a/include/asm-powerpc/ppc_asm.h
+++ b/include/asm-powerpc/ppc_asm.h
@@ -30,9 +30,9 @@ BEGIN_FTR_SECTION; \
30 mfspr ra,SPRN_PURR; /* get processor util. reg */ \ 30 mfspr ra,SPRN_PURR; /* get processor util. reg */ \
31END_FTR_SECTION_IFSET(CPU_FTR_PURR); \ 31END_FTR_SECTION_IFSET(CPU_FTR_PURR); \
32BEGIN_FTR_SECTION; \ 32BEGIN_FTR_SECTION; \
33 mftb ra; /* or get TB if no PURR */ \ 33 MFTB(ra); /* or get TB if no PURR */ \
34END_FTR_SECTION_IFCLR(CPU_FTR_PURR); \ 34END_FTR_SECTION_IFCLR(CPU_FTR_PURR); \
35 ld rb,PACA_STARTPURR(r13); \ 35 ld rb,PACA_STARTPURR(r13); \
36 std ra,PACA_STARTPURR(r13); \ 36 std ra,PACA_STARTPURR(r13); \
37 subf rb,rb,ra; /* subtract start value */ \ 37 subf rb,rb,ra; /* subtract start value */ \
38 ld ra,PACA_USER_TIME(r13); \ 38 ld ra,PACA_USER_TIME(r13); \
@@ -45,9 +45,9 @@ BEGIN_FTR_SECTION; \
45 mfspr ra,SPRN_PURR; /* get processor util. reg */ \ 45 mfspr ra,SPRN_PURR; /* get processor util. reg */ \
46END_FTR_SECTION_IFSET(CPU_FTR_PURR); \ 46END_FTR_SECTION_IFSET(CPU_FTR_PURR); \
47BEGIN_FTR_SECTION; \ 47BEGIN_FTR_SECTION; \
48 mftb ra; /* or get TB if no PURR */ \ 48 MFTB(ra); /* or get TB if no PURR */ \
49END_FTR_SECTION_IFCLR(CPU_FTR_PURR); \ 49END_FTR_SECTION_IFCLR(CPU_FTR_PURR); \
50 ld rb,PACA_STARTPURR(r13); \ 50 ld rb,PACA_STARTPURR(r13); \
51 std ra,PACA_STARTPURR(r13); \ 51 std ra,PACA_STARTPURR(r13); \
52 subf rb,rb,ra; /* subtract start value */ \ 52 subf rb,rb,ra; /* subtract start value */ \
53 ld ra,PACA_SYSTEM_TIME(r13); \ 53 ld ra,PACA_SYSTEM_TIME(r13); \
@@ -274,6 +274,16 @@ END_FTR_SECTION_IFSET(CPU_FTR_601)
274#define ISYNC_601 274#define ISYNC_601
275#endif 275#endif
276 276
277#ifdef CONFIG_PPC_CELL
278#define MFTB(dest) \
27990: mftb dest; \
280BEGIN_FTR_SECTION_NESTED(96); \
281 cmpwi dest,0; \
282 beq- 90b; \
283END_FTR_SECTION_NESTED(CPU_FTR_CELL_TB_BUG, CPU_FTR_CELL_TB_BUG, 96)
284#else
285#define MFTB(dest) mftb dest
286#endif
277 287
278#ifndef CONFIG_SMP 288#ifndef CONFIG_SMP
279#define TLBSYNC 289#define TLBSYNC
diff --git a/include/asm-powerpc/prom.h b/include/asm-powerpc/prom.h
index 524629769336..ec11d44eaeb5 100644
--- a/include/asm-powerpc/prom.h
+++ b/include/asm-powerpc/prom.h
@@ -134,7 +134,7 @@ extern struct device_node *of_find_all_nodes(struct device_node *prev);
134extern struct device_node *of_get_parent(const struct device_node *node); 134extern struct device_node *of_get_parent(const struct device_node *node);
135extern struct device_node *of_get_next_child(const struct device_node *node, 135extern struct device_node *of_get_next_child(const struct device_node *node,
136 struct device_node *prev); 136 struct device_node *prev);
137extern struct property *of_find_property(struct device_node *np, 137extern struct property *of_find_property(const struct device_node *np,
138 const char *name, 138 const char *name,
139 int *lenp); 139 int *lenp);
140extern struct device_node *of_node_get(struct device_node *node); 140extern struct device_node *of_node_get(struct device_node *node);
@@ -158,10 +158,12 @@ extern void of_detach_node(const struct device_node *);
158extern void finish_device_tree(void); 158extern void finish_device_tree(void);
159extern void unflatten_device_tree(void); 159extern void unflatten_device_tree(void);
160extern void early_init_devtree(void *); 160extern void early_init_devtree(void *);
161extern int device_is_compatible(struct device_node *device, const char *); 161extern int device_is_compatible(const struct device_node *device,
162 const char *);
162extern int machine_is_compatible(const char *compat); 163extern int machine_is_compatible(const char *compat);
163extern const void *get_property(struct device_node *node, const char *name, 164extern const void *get_property(const struct device_node *node,
164 int *lenp); 165 const char *name,
166 int *lenp);
165extern void print_properties(struct device_node *node); 167extern void print_properties(struct device_node *node);
166extern int prom_n_addr_cells(struct device_node* np); 168extern int prom_n_addr_cells(struct device_node* np);
167extern int prom_n_size_cells(struct device_node* np); 169extern int prom_n_size_cells(struct device_node* np);
diff --git a/include/asm-powerpc/reg.h b/include/asm-powerpc/reg.h
index 8fb96811b55d..6faae7b14d55 100644
--- a/include/asm-powerpc/reg.h
+++ b/include/asm-powerpc/reg.h
@@ -591,6 +591,7 @@
591#define PV_630 0x0040 591#define PV_630 0x0040
592#define PV_630p 0x0041 592#define PV_630p 0x0041
593#define PV_970MP 0x0044 593#define PV_970MP 0x0044
594#define PV_970GX 0x0045
594#define PV_BE 0x0070 595#define PV_BE 0x0070
595#define PV_PA6T 0x0090 596#define PV_PA6T 0x0090
596 597
@@ -618,10 +619,35 @@
618 : "=r" (rval)); rval;}) 619 : "=r" (rval)); rval;})
619#define mtspr(rn, v) asm volatile("mtspr " __stringify(rn) ",%0" : : "r" (v)) 620#define mtspr(rn, v) asm volatile("mtspr " __stringify(rn) ",%0" : : "r" (v))
620 621
622#ifdef __powerpc64__
623#ifdef CONFIG_PPC_CELL
624#define mftb() ({unsigned long rval; \
625 asm volatile( \
626 "90: mftb %0;\n" \
627 "97: cmpwi %0,0;\n" \
628 " beq- 90b;\n" \
629 "99:\n" \
630 ".section __ftr_fixup,\"a\"\n" \
631 ".align 3\n" \
632 "98:\n" \
633 " .llong %1\n" \
634 " .llong %1\n" \
635 " .llong 97b-98b\n" \
636 " .llong 99b-98b\n" \
637 ".previous" \
638 : "=r" (rval) : "i" (CPU_FTR_CELL_TB_BUG)); rval;})
639#else
621#define mftb() ({unsigned long rval; \ 640#define mftb() ({unsigned long rval; \
622 asm volatile("mftb %0" : "=r" (rval)); rval;}) 641 asm volatile("mftb %0" : "=r" (rval)); rval;})
642#endif /* !CONFIG_PPC_CELL */
643
644#else /* __powerpc64__ */
645
623#define mftbl() ({unsigned long rval; \ 646#define mftbl() ({unsigned long rval; \
624 asm volatile("mftbl %0" : "=r" (rval)); rval;}) 647 asm volatile("mftbl %0" : "=r" (rval)); rval;})
648#define mftbu() ({unsigned long rval; \
649 asm volatile("mftbu %0" : "=r" (rval)); rval;})
650#endif /* !__powerpc64__ */
625 651
626#define mttbl(v) asm volatile("mttbl %0":: "r"(v)) 652#define mttbl(v) asm volatile("mttbl %0":: "r"(v))
627#define mttbu(v) asm volatile("mttbu %0":: "r"(v)) 653#define mttbu(v) asm volatile("mttbu %0":: "r"(v))
diff --git a/include/asm-powerpc/systbl.h b/include/asm-powerpc/systbl.h
index eac85ce101b6..97b435484177 100644
--- a/include/asm-powerpc/systbl.h
+++ b/include/asm-powerpc/systbl.h
@@ -261,7 +261,7 @@ SYSX(sys_ni_syscall, ppc_fadvise64_64, ppc_fadvise64_64)
261PPC_SYS_SPU(rtas) 261PPC_SYS_SPU(rtas)
262OLDSYS(debug_setcontext) 262OLDSYS(debug_setcontext)
263SYSCALL(ni_syscall) 263SYSCALL(ni_syscall)
264SYSCALL(ni_syscall) 264COMPAT_SYS(migrate_pages)
265COMPAT_SYS(mbind) 265COMPAT_SYS(mbind)
266COMPAT_SYS(get_mempolicy) 266COMPAT_SYS(get_mempolicy)
267COMPAT_SYS(set_mempolicy) 267COMPAT_SYS(set_mempolicy)
@@ -304,3 +304,4 @@ SYSCALL_SPU(fchmodat)
304SYSCALL_SPU(faccessat) 304SYSCALL_SPU(faccessat)
305COMPAT_SYS_SPU(get_robust_list) 305COMPAT_SYS_SPU(get_robust_list)
306COMPAT_SYS_SPU(set_robust_list) 306COMPAT_SYS_SPU(set_robust_list)
307COMPAT_SYS(move_pages)
diff --git a/include/asm-powerpc/system.h b/include/asm-powerpc/system.h
index 43627596003b..f7b1227d6454 100644
--- a/include/asm-powerpc/system.h
+++ b/include/asm-powerpc/system.h
@@ -25,8 +25,8 @@
25 * 25 *
26 * We have to use the sync instructions for mb(), since lwsync doesn't 26 * We have to use the sync instructions for mb(), since lwsync doesn't
27 * order loads with respect to previous stores. Lwsync is fine for 27 * order loads with respect to previous stores. Lwsync is fine for
28 * rmb(), though. Note that lwsync is interpreted as sync by 28 * rmb(), though. Note that rmb() actually uses a sync on 32-bit
29 * 32-bit and older 64-bit CPUs. 29 * architectures.
30 * 30 *
31 * For wmb(), we use sync since wmb is used in drivers to order 31 * For wmb(), we use sync since wmb is used in drivers to order
32 * stores to system memory with respect to writes to the device. 32 * stores to system memory with respect to writes to the device.
@@ -34,7 +34,7 @@
34 * SMP since it is only used to order updates to system memory. 34 * SMP since it is only used to order updates to system memory.
35 */ 35 */
36#define mb() __asm__ __volatile__ ("sync" : : : "memory") 36#define mb() __asm__ __volatile__ ("sync" : : : "memory")
37#define rmb() __asm__ __volatile__ ("lwsync" : : : "memory") 37#define rmb() __asm__ __volatile__ (__stringify(LWSYNC) : : : "memory")
38#define wmb() __asm__ __volatile__ ("sync" : : : "memory") 38#define wmb() __asm__ __volatile__ ("sync" : : : "memory")
39#define read_barrier_depends() do { } while(0) 39#define read_barrier_depends() do { } while(0)
40 40
diff --git a/include/asm-powerpc/tce.h b/include/asm-powerpc/tce.h
index c9483adbf599..f663634cccc9 100644
--- a/include/asm-powerpc/tce.h
+++ b/include/asm-powerpc/tce.h
@@ -22,6 +22,8 @@
22#define _ASM_POWERPC_TCE_H 22#define _ASM_POWERPC_TCE_H
23#ifdef __KERNEL__ 23#ifdef __KERNEL__
24 24
25#include <asm/iommu.h>
26
25/* 27/*
26 * Tces come in two formats, one for the virtual bus and a different 28 * Tces come in two formats, one for the virtual bus and a different
27 * format for PCI 29 * format for PCI
@@ -33,7 +35,6 @@
33 35
34#define TCE_SHIFT 12 36#define TCE_SHIFT 12
35#define TCE_PAGE_SIZE (1 << TCE_SHIFT) 37#define TCE_PAGE_SIZE (1 << TCE_SHIFT)
36#define TCE_PAGE_FACTOR (PAGE_SHIFT - TCE_SHIFT)
37 38
38#define TCE_ENTRY_SIZE 8 /* each TCE is 64 bits */ 39#define TCE_ENTRY_SIZE 8 /* each TCE is 64 bits */
39 40
diff --git a/include/asm-powerpc/time.h b/include/asm-powerpc/time.h
index b051d4c88c3b..4cff977ad526 100644
--- a/include/asm-powerpc/time.h
+++ b/include/asm-powerpc/time.h
@@ -39,10 +39,6 @@ extern void generic_calibrate_decr(void);
39extern void wakeup_decrementer(void); 39extern void wakeup_decrementer(void);
40extern void snapshot_timebase(void); 40extern void snapshot_timebase(void);
41 41
42#ifdef CONFIG_RTC_CLASS
43extern int __init rtc_class_hookup(void);
44#endif
45
46/* Some sane defaults: 125 MHz timebase, 1GHz processor */ 42/* Some sane defaults: 125 MHz timebase, 1GHz processor */
47extern unsigned long ppc_proc_freq; 43extern unsigned long ppc_proc_freq;
48#define DEFAULT_PROC_FREQ (DEFAULT_TB_FREQ * 8) 44#define DEFAULT_PROC_FREQ (DEFAULT_TB_FREQ * 8)
@@ -82,30 +78,35 @@ struct div_result {
82#define __USE_RTC() 0 78#define __USE_RTC() 0
83#endif 79#endif
84 80
85/* On ppc64 this gets us the whole timebase; on ppc32 just the lower half */ 81#ifdef CONFIG_PPC64
82
83/* For compatibility, get_tbl() is defined as get_tb() on ppc64 */
84#define get_tbl get_tb
85
86#else
87
86static inline unsigned long get_tbl(void) 88static inline unsigned long get_tbl(void)
87{ 89{
88 unsigned long tbl;
89
90#if defined(CONFIG_403GCX) 90#if defined(CONFIG_403GCX)
91 unsigned long tbl;
91 asm volatile("mfspr %0, 0x3dd" : "=r" (tbl)); 92 asm volatile("mfspr %0, 0x3dd" : "=r" (tbl));
93 return tbl;
92#else 94#else
93 asm volatile("mftb %0" : "=r" (tbl)); 95 return mftbl();
94#endif 96#endif
95 return tbl;
96} 97}
97 98
98static inline unsigned int get_tbu(void) 99static inline unsigned int get_tbu(void)
99{ 100{
101#ifdef CONFIG_403GCX
100 unsigned int tbu; 102 unsigned int tbu;
101
102#if defined(CONFIG_403GCX)
103 asm volatile("mfspr %0, 0x3dc" : "=r" (tbu)); 103 asm volatile("mfspr %0, 0x3dc" : "=r" (tbu));
104 return tbu;
104#else 105#else
105 asm volatile("mftbu %0" : "=r" (tbu)); 106 return mftbu();
106#endif 107#endif
107 return tbu;
108} 108}
109#endif /* !CONFIG_PPC64 */
109 110
110static inline unsigned int get_rtcl(void) 111static inline unsigned int get_rtcl(void)
111{ 112{
@@ -131,7 +132,7 @@ static inline u64 get_tb(void)
131{ 132{
132 return mftb(); 133 return mftb();
133} 134}
134#else 135#else /* CONFIG_PPC64 */
135static inline u64 get_tb(void) 136static inline u64 get_tb(void)
136{ 137{
137 unsigned int tbhi, tblo, tbhi2; 138 unsigned int tbhi, tblo, tbhi2;
@@ -144,7 +145,7 @@ static inline u64 get_tb(void)
144 145
145 return ((u64)tbhi << 32) | tblo; 146 return ((u64)tbhi << 32) | tblo;
146} 147}
147#endif 148#endif /* !CONFIG_PPC64 */
148 149
149static inline void set_tb(unsigned int upper, unsigned int lower) 150static inline void set_tb(unsigned int upper, unsigned int lower)
150{ 151{
diff --git a/include/asm-powerpc/timex.h b/include/asm-powerpc/timex.h
index 3b9a8e786806..92dedde761d1 100644
--- a/include/asm-powerpc/timex.h
+++ b/include/asm-powerpc/timex.h
@@ -8,6 +8,7 @@
8 */ 8 */
9 9
10#include <asm/cputable.h> 10#include <asm/cputable.h>
11#include <asm/reg.h>
11 12
12#define CLOCK_TICK_RATE 1024000 /* Underlying HZ */ 13#define CLOCK_TICK_RATE 1024000 /* Underlying HZ */
13 14
@@ -15,13 +16,11 @@ typedef unsigned long cycles_t;
15 16
16static inline cycles_t get_cycles(void) 17static inline cycles_t get_cycles(void)
17{ 18{
18 cycles_t ret;
19
20#ifdef __powerpc64__ 19#ifdef __powerpc64__
21 20 return mftb();
22 __asm__ __volatile__("mftb %0" : "=r" (ret) : );
23
24#else 21#else
22 cycles_t ret;
23
25 /* 24 /*
26 * For the "cycle" counter we use the timebase lower half. 25 * For the "cycle" counter we use the timebase lower half.
27 * Currently only used on SMP. 26 * Currently only used on SMP.
@@ -30,18 +29,19 @@ static inline cycles_t get_cycles(void)
30 ret = 0; 29 ret = 0;
31 30
32 __asm__ __volatile__( 31 __asm__ __volatile__(
33 "98: mftb %0\n" 32 "97: mftb %0\n"
34 "99:\n" 33 "99:\n"
35 ".section __ftr_fixup,\"a\"\n" 34 ".section __ftr_fixup,\"a\"\n"
35 ".align 2\n"
36 "98:\n"
36 " .long %1\n" 37 " .long %1\n"
37 " .long 0\n" 38 " .long 0\n"
38 " .long 98b\n" 39 " .long 97b-98b\n"
39 " .long 99b\n" 40 " .long 99b-98b\n"
40 ".previous" 41 ".previous"
41 : "=r" (ret) : "i" (CPU_FTR_601)); 42 : "=r" (ret) : "i" (CPU_FTR_601));
42#endif
43
44 return ret; 43 return ret;
44#endif
45} 45}
46 46
47#endif /* __KERNEL__ */ 47#endif /* __KERNEL__ */
diff --git a/include/asm-powerpc/topology.h b/include/asm-powerpc/topology.h
index 8f7ee16781a4..9fe7894ee035 100644
--- a/include/asm-powerpc/topology.h
+++ b/include/asm-powerpc/topology.h
@@ -96,7 +96,13 @@ static inline void sysfs_remove_device_from_node(struct sys_device *dev,
96 96
97#ifdef CONFIG_SMP 97#ifdef CONFIG_SMP
98#include <asm/cputable.h> 98#include <asm/cputable.h>
99#define smt_capable() (cpu_has_feature(CPU_FTR_SMT)) 99#define smt_capable() (cpu_has_feature(CPU_FTR_SMT))
100
101#ifdef CONFIG_PPC64
102#include <asm/smp.h>
103
104#define topology_thread_siblings(cpu) (cpu_sibling_map[cpu])
105#endif
100#endif 106#endif
101 107
102#endif /* __KERNEL__ */ 108#endif /* __KERNEL__ */
diff --git a/include/asm-powerpc/unistd.h b/include/asm-powerpc/unistd.h
index 464a48cce7f5..0e4ea37f6466 100644
--- a/include/asm-powerpc/unistd.h
+++ b/include/asm-powerpc/unistd.h
@@ -276,7 +276,7 @@
276#define __NR_rtas 255 276#define __NR_rtas 255
277#define __NR_sys_debug_setcontext 256 277#define __NR_sys_debug_setcontext 256
278/* Number 257 is reserved for vserver */ 278/* Number 257 is reserved for vserver */
279/* 258 currently unused */ 279#define __NR_migrate_pages 258
280#define __NR_mbind 259 280#define __NR_mbind 259
281#define __NR_get_mempolicy 260 281#define __NR_get_mempolicy 260
282#define __NR_set_mempolicy 261 282#define __NR_set_mempolicy 261
@@ -323,10 +323,11 @@
323#define __NR_faccessat 298 323#define __NR_faccessat 298
324#define __NR_get_robust_list 299 324#define __NR_get_robust_list 299
325#define __NR_set_robust_list 300 325#define __NR_set_robust_list 300
326#define __NR_move_pages 301
326 327
327#ifdef __KERNEL__ 328#ifdef __KERNEL__
328 329
329#define __NR_syscalls 301 330#define __NR_syscalls 302
330 331
331#define __NR__exit __NR_exit 332#define __NR__exit __NR_exit
332#define NR_syscalls __NR_syscalls 333#define NR_syscalls __NR_syscalls
diff --git a/include/asm-ppc/io.h b/include/asm-ppc/io.h
index 3d9a9e6f3321..a4c411b753ef 100644
--- a/include/asm-ppc/io.h
+++ b/include/asm-ppc/io.h
@@ -439,22 +439,6 @@ extern inline void * phys_to_virt(unsigned long address)
439#define iobarrier_r() eieio() 439#define iobarrier_r() eieio()
440#define iobarrier_w() eieio() 440#define iobarrier_w() eieio()
441 441
442static inline int check_signature(volatile void __iomem * io_addr,
443 const unsigned char *signature, int length)
444{
445 int retval = 0;
446 do {
447 if (readb(io_addr) != *signature)
448 goto out;
449 io_addr++;
450 signature++;
451 length--;
452 } while (length);
453 retval = 1;
454out:
455 return retval;
456}
457
458/* 442/*
459 * Here comes the ppc implementation of the IOMAP 443 * Here comes the ppc implementation of the IOMAP
460 * interfaces. 444 * interfaces.
diff --git a/include/asm-s390/cio.h b/include/asm-s390/cio.h
index da063cd5f0a0..81287d86329d 100644
--- a/include/asm-s390/cio.h
+++ b/include/asm-s390/cio.h
@@ -275,6 +275,12 @@ struct ccw_dev_id {
275 u16 devno; 275 u16 devno;
276}; 276};
277 277
278static inline int ccw_dev_id_is_equal(struct ccw_dev_id *dev_id1,
279 struct ccw_dev_id *dev_id2)
280{
281 return !memcmp(dev_id1, dev_id2, sizeof(struct ccw_dev_id));
282}
283
278extern int diag210(struct diag210 *addr); 284extern int diag210(struct diag210 *addr);
279 285
280extern void wait_cons_dev(void); 286extern void wait_cons_dev(void);
diff --git a/include/asm-s390/pgtable.h b/include/asm-s390/pgtable.h
index 519f0a5ff181..36bb6dacf008 100644
--- a/include/asm-s390/pgtable.h
+++ b/include/asm-s390/pgtable.h
@@ -200,18 +200,45 @@ extern char empty_zero_page[PAGE_SIZE];
200 */ 200 */
201 201
202/* Hardware bits in the page table entry */ 202/* Hardware bits in the page table entry */
203#define _PAGE_RO 0x200 /* HW read-only */ 203#define _PAGE_RO 0x200 /* HW read-only bit */
204#define _PAGE_INVALID 0x400 /* HW invalid */ 204#define _PAGE_INVALID 0x400 /* HW invalid bit */
205#define _PAGE_SWT 0x001 /* SW pte type bit t */
206#define _PAGE_SWX 0x002 /* SW pte type bit x */
205 207
206/* Mask and six different types of pages. */ 208/* Six different types of pages. */
207#define _PAGE_TYPE_MASK 0x601
208#define _PAGE_TYPE_EMPTY 0x400 209#define _PAGE_TYPE_EMPTY 0x400
209#define _PAGE_TYPE_NONE 0x401 210#define _PAGE_TYPE_NONE 0x401
210#define _PAGE_TYPE_SWAP 0x600 211#define _PAGE_TYPE_SWAP 0x403
211#define _PAGE_TYPE_FILE 0x601 212#define _PAGE_TYPE_FILE 0x601 /* bit 0x002 is used for offset !! */
212#define _PAGE_TYPE_RO 0x200 213#define _PAGE_TYPE_RO 0x200
213#define _PAGE_TYPE_RW 0x000 214#define _PAGE_TYPE_RW 0x000
214 215
216/*
217 * PTE type bits are rather complicated. handle_pte_fault uses pte_present,
218 * pte_none and pte_file to find out the pte type WITHOUT holding the page
219 * table lock. ptep_clear_flush on the other hand uses ptep_clear_flush to
220 * invalidate a given pte. ipte sets the hw invalid bit and clears all tlbs
221 * for the page. The page table entry is set to _PAGE_TYPE_EMPTY afterwards.
222 * This change is done while holding the lock, but the intermediate step
223 * of a previously valid pte with the hw invalid bit set can be observed by
224 * handle_pte_fault. That makes it necessary that all valid pte types with
225 * the hw invalid bit set must be distinguishable from the four pte types
226 * empty, none, swap and file.
227 *
228 * irxt ipte irxt
229 * _PAGE_TYPE_EMPTY 1000 -> 1000
230 * _PAGE_TYPE_NONE 1001 -> 1001
231 * _PAGE_TYPE_SWAP 1011 -> 1011
232 * _PAGE_TYPE_FILE 11?1 -> 11?1
233 * _PAGE_TYPE_RO 0100 -> 1100
234 * _PAGE_TYPE_RW 0000 -> 1000
235 *
236 * pte_none is true for bits combinations 1000, 1100
237 * pte_present is true for bits combinations 0000, 0010, 0100, 0110, 1001
238 * pte_file is true for bits combinations 1101, 1111
239 * swap pte is 1011 and 0001, 0011, 0101, 0111, 1010 and 1110 are invalid.
240 */
241
215#ifndef __s390x__ 242#ifndef __s390x__
216 243
217/* Bits in the segment table entry */ 244/* Bits in the segment table entry */
@@ -365,18 +392,21 @@ static inline int pmd_bad(pmd_t pmd)
365 392
366static inline int pte_none(pte_t pte) 393static inline int pte_none(pte_t pte)
367{ 394{
368 return (pte_val(pte) & _PAGE_TYPE_MASK) == _PAGE_TYPE_EMPTY; 395 return (pte_val(pte) & _PAGE_INVALID) && !(pte_val(pte) & _PAGE_SWT);
369} 396}
370 397
371static inline int pte_present(pte_t pte) 398static inline int pte_present(pte_t pte)
372{ 399{
373 return !(pte_val(pte) & _PAGE_INVALID) || 400 unsigned long mask = _PAGE_RO | _PAGE_INVALID | _PAGE_SWT | _PAGE_SWX;
374 (pte_val(pte) & _PAGE_TYPE_MASK) == _PAGE_TYPE_NONE; 401 return (pte_val(pte) & mask) == _PAGE_TYPE_NONE ||
402 (!(pte_val(pte) & _PAGE_INVALID) &&
403 !(pte_val(pte) & _PAGE_SWT));
375} 404}
376 405
377static inline int pte_file(pte_t pte) 406static inline int pte_file(pte_t pte)
378{ 407{
379 return (pte_val(pte) & _PAGE_TYPE_MASK) == _PAGE_TYPE_FILE; 408 unsigned long mask = _PAGE_RO | _PAGE_INVALID | _PAGE_SWT;
409 return (pte_val(pte) & mask) == _PAGE_TYPE_FILE;
380} 410}
381 411
382#define pte_same(a,b) (pte_val(a) == pte_val(b)) 412#define pte_same(a,b) (pte_val(a) == pte_val(b))
diff --git a/include/asm-s390/timer.h b/include/asm-s390/timer.h
index fcd6c256a2d1..30e5cbe570f2 100644
--- a/include/asm-s390/timer.h
+++ b/include/asm-s390/timer.h
@@ -26,7 +26,7 @@ struct vtimer_list {
26 spinlock_t lock; 26 spinlock_t lock;
27 unsigned long magic; 27 unsigned long magic;
28 28
29 void (*function)(unsigned long, struct pt_regs*); 29 void (*function)(unsigned long);
30 unsigned long data; 30 unsigned long data;
31}; 31};
32 32
diff --git a/include/asm-s390/unistd.h b/include/asm-s390/unistd.h
index a19238cbcffa..71d3c21b84f0 100644
--- a/include/asm-s390/unistd.h
+++ b/include/asm-s390/unistd.h
@@ -249,8 +249,9 @@
249#define __NR_vmsplice 309 249#define __NR_vmsplice 309
250/* Number 310 is reserved for new sys_move_pages */ 250/* Number 310 is reserved for new sys_move_pages */
251#define __NR_getcpu 311 251#define __NR_getcpu 311
252#define __NR_epoll_pwait 312
252 253
253#define NR_syscalls 312 254#define NR_syscalls 313
254 255
255/* 256/*
256 * There are some system calls that are not present on 64 bit, some 257 * There are some system calls that are not present on 64 bit, some
diff --git a/include/asm-sh/cpu-sh4/ubc.h b/include/asm-sh/cpu-sh4/ubc.h
index 3d0943167659..c86e17050935 100644
--- a/include/asm-sh/cpu-sh4/ubc.h
+++ b/include/asm-sh/cpu-sh4/ubc.h
@@ -3,6 +3,7 @@
3 * 3 *
4 * Copyright (C) 1999 Niibe Yutaka 4 * Copyright (C) 1999 Niibe Yutaka
5 * Copyright (C) 2003 Paul Mundt 5 * Copyright (C) 2003 Paul Mundt
6 * Copyright (C) 2006 Lineo Solutions Inc. support SH4A UBC
6 * 7 *
7 * This file is subject to the terms and conditions of the GNU General Public 8 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive 9 * License. See the file "COPYING" in the main directory of this archive
@@ -11,6 +12,41 @@
11#ifndef __ASM_CPU_SH4_UBC_H 12#ifndef __ASM_CPU_SH4_UBC_H
12#define __ASM_CPU_SH4_UBC_H 13#define __ASM_CPU_SH4_UBC_H
13 14
15#if defined(CONFIG_CPU_SH4A)
16#define UBC_CBR0 0xff200000
17#define UBC_CRR0 0xff200004
18#define UBC_CAR0 0xff200008
19#define UBC_CAMR0 0xff20000c
20#define UBC_CBR1 0xff200020
21#define UBC_CRR1 0xff200024
22#define UBC_CAR1 0xff200028
23#define UBC_CAMR1 0xff20002c
24#define UBC_CDR1 0xff200030
25#define UBC_CDMR1 0xff200034
26#define UBC_CETR1 0xff200038
27#define UBC_CCMFR 0xff200600
28#define UBC_CBCR 0xff200620
29
30/* CBR */
31#define UBC_CBR_AIE (0x01<<30)
32#define UBC_CBR_ID_INST (0x01<<4)
33#define UBC_CBR_RW_READ (0x01<<1)
34#define UBC_CBR_CE (0x01)
35
36#define UBC_CBR_AIV_MASK (0x00FF0000)
37#define UBC_CBR_AIV_SHIFT (16)
38#define UBC_CBR_AIV_SET(asid) (((asid)<<UBC_CBR_AIV_SHIFT) & UBC_CBR_AIV_MASK)
39
40#define UBC_CBR_INIT 0x20000000
41
42/* CRR */
43#define UBC_CRR_RES (0x01<<13)
44#define UBC_CRR_PCB (0x01<<1)
45#define UBC_CRR_BIE (0x01)
46
47#define UBC_CRR_INIT 0x00002000
48
49#else /* CONFIG_CPU_SH4 */
14#define UBC_BARA 0xff200000 50#define UBC_BARA 0xff200000
15#define UBC_BAMRA 0xff200004 51#define UBC_BAMRA 0xff200004
16#define UBC_BBRA 0xff200008 52#define UBC_BBRA 0xff200008
@@ -22,6 +58,7 @@
22#define UBC_BDRB 0xff200018 58#define UBC_BDRB 0xff200018
23#define UBC_BDMRB 0xff20001c 59#define UBC_BDMRB 0xff20001c
24#define UBC_BRCR 0xff200020 60#define UBC_BRCR 0xff200020
61#endif /* CONFIG_CPU_SH4 */
25 62
26#endif /* __ASM_CPU_SH4_UBC_H */ 63#endif /* __ASM_CPU_SH4_UBC_H */
27 64
diff --git a/include/asm-sh/edosk7705/io.h b/include/asm-sh/edosk7705.h
index a1089a65bc36..a1089a65bc36 100644
--- a/include/asm-sh/edosk7705/io.h
+++ b/include/asm-sh/edosk7705.h
diff --git a/include/asm-sh/hp6xx/hp6xx.h b/include/asm-sh/hp6xx.h
index f35134c159dd..f35134c159dd 100644
--- a/include/asm-sh/hp6xx/hp6xx.h
+++ b/include/asm-sh/hp6xx.h
diff --git a/include/asm-sh/hp6xx/ide.h b/include/asm-sh/hp6xx/ide.h
deleted file mode 100644
index 570395a5ebe5..000000000000
--- a/include/asm-sh/hp6xx/ide.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef __ASM_SH_HP6XX_IDE_H
2#define __ASM_SH_HP6XX_IDE_H
3
4#define IRQ_CFCARD 93
5#define IRQ_PCMCIA 94
6
7#endif /* __ASM_SH_HP6XX_IDE_H */
8
diff --git a/include/asm-sh/hp6xx/io.h b/include/asm-sh/hp6xx/io.h
deleted file mode 100644
index 2044476ab199..000000000000
--- a/include/asm-sh/hp6xx/io.h
+++ /dev/null
@@ -1,10 +0,0 @@
1#ifndef __ASM_SH_HP6XX_IO_H
2#define __ASM_SH_HP6XX_IO_H
3
4/*
5 * Nothing special here.. just use the generic cchip io routines.
6 */
7#include <asm/hd64461.h>
8
9#endif /* __ASM_SH_HP6XX_IO_H */
10
diff --git a/include/asm-sh/hs7751rvoip/hs7751rvoip.h b/include/asm-sh/hs7751rvoip.h
index c4cff9d33927..c4cff9d33927 100644
--- a/include/asm-sh/hs7751rvoip/hs7751rvoip.h
+++ b/include/asm-sh/hs7751rvoip.h
diff --git a/include/asm-sh/hs7751rvoip/ide.h b/include/asm-sh/hs7751rvoip/ide.h
deleted file mode 100644
index 65ad1d0f763b..000000000000
--- a/include/asm-sh/hs7751rvoip/ide.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef __ASM_SH_HS7751RVOIP_IDE_H
2#define __ASM_SH_HS7751RVOIP_IDE_H
3
4/* Nothing to see here.. */
5#include <asm/hs7751rvoip/hs7751rvoip.h>
6
7#endif /* __ASM_SH_HS7751RVOIP_IDE_H */
8
diff --git a/include/asm-sh/hw_irq.h b/include/asm-sh/hw_irq.h
index fed26616967a..80ee1cda7498 100644
--- a/include/asm-sh/hw_irq.h
+++ b/include/asm-sh/hw_irq.h
@@ -1,4 +1,8 @@
1#ifndef __ASM_SH_HW_IRQ_H 1#ifndef __ASM_SH_HW_IRQ_H
2#define __ASM_SH_HW_IRQ_H 2#define __ASM_SH_HW_IRQ_H
3 3
4#include <asm/atomic.h>
5
6extern atomic_t irq_err_count;
7
4#endif /* __ASM_SH_HW_IRQ_H */ 8#endif /* __ASM_SH_HW_IRQ_H */
diff --git a/include/asm-sh/io.h b/include/asm-sh/io.h
index ed12d38e8c00..a0e55b09e4fd 100644
--- a/include/asm-sh/io.h
+++ b/include/asm-sh/io.h
@@ -304,22 +304,6 @@ __ioremap_mode(unsigned long offset, unsigned long size, unsigned long flags)
304#define iounmap(addr) \ 304#define iounmap(addr) \
305 __iounmap((addr)) 305 __iounmap((addr))
306 306
307static inline int check_signature(char __iomem *io_addr,
308 const unsigned char *signature, int length)
309{
310 int retval = 0;
311 do {
312 if (readb(io_addr) != *signature)
313 goto out;
314 io_addr++;
315 signature++;
316 length--;
317 } while (length);
318 retval = 1;
319out:
320 return retval;
321}
322
323/* 307/*
324 * The caches on some architectures aren't dma-coherent and have need to 308 * The caches on some architectures aren't dma-coherent and have need to
325 * handle this in software. There are three types of operations that 309 * handle this in software. There are three types of operations that
diff --git a/include/asm-sh/irq-sh7780.h b/include/asm-sh/irq-sh7780.h
index 895c5780e454..19912ae6a7f7 100644
--- a/include/asm-sh/irq-sh7780.h
+++ b/include/asm-sh/irq-sh7780.h
@@ -6,16 +6,6 @@
6 * 6 *
7 * Copyright (C) 2004 Takashi SHUDO <shudo@hitachi-ul.co.jp> 7 * Copyright (C) 2004 Takashi SHUDO <shudo@hitachi-ul.co.jp>
8 */ 8 */
9
10#ifdef CONFIG_IDE
11# ifndef IRQ_CFCARD
12# define IRQ_CFCARD 14
13# endif
14# ifndef IRQ_PCMCIA
15# define IRQ_PCMCIA 15
16# endif
17#endif
18
19#define INTC_BASE 0xffd00000 9#define INTC_BASE 0xffd00000
20#define INTC_ICR0 (INTC_BASE+0x0) 10#define INTC_ICR0 (INTC_BASE+0x0)
21#define INTC_ICR1 (INTC_BASE+0x1c) 11#define INTC_ICR1 (INTC_BASE+0x1c)
diff --git a/include/asm-sh/irq.h b/include/asm-sh/irq.h
index 0e5f365aff70..6cd3e9e2a76a 100644
--- a/include/asm-sh/irq.h
+++ b/include/asm-sh/irq.h
@@ -14,16 +14,6 @@
14#include <asm/machvec.h> 14#include <asm/machvec.h>
15#include <asm/ptrace.h> /* for pt_regs */ 15#include <asm/ptrace.h> /* for pt_regs */
16 16
17#if defined(CONFIG_SH_HP6XX) || \
18 defined(CONFIG_SH_RTS7751R2D) || \
19 defined(CONFIG_SH_HS7751RVOIP) || \
20 defined(CONFIG_SH_HS7751RVOIP) || \
21 defined(CONFIG_SH_SH03) || \
22 defined(CONFIG_SH_R7780RP) || \
23 defined(CONFIG_SH_LANDISK)
24#include <asm/mach/ide.h>
25#endif
26
27#ifndef CONFIG_CPU_SUBTYPE_SH7780 17#ifndef CONFIG_CPU_SUBTYPE_SH7780
28 18
29#define INTC_DMAC0_MSK 0 19#define INTC_DMAC0_MSK 0
@@ -38,15 +28,6 @@
38#define INTC_IPRD 0xffd00010UL 28#define INTC_IPRD 0xffd00010UL
39#endif 29#endif
40 30
41#ifdef CONFIG_IDE
42# ifndef IRQ_CFCARD
43# define IRQ_CFCARD 14
44# endif
45# ifndef IRQ_PCMCIA
46# define IRQ_PCMCIA 15
47# endif
48#endif
49
50#define TIMER_IRQ 16 31#define TIMER_IRQ 16
51#define TIMER_IPR_ADDR INTC_IPRA 32#define TIMER_IPR_ADDR INTC_IPRA
52#define TIMER_IPR_POS 3 33#define TIMER_IPR_POS 3
@@ -346,11 +327,17 @@ extern unsigned short *irq_mask_register;
346 */ 327 */
347void init_IRQ_pint(void); 328void init_IRQ_pint(void);
348 329
330struct ipr_data {
331 unsigned int irq;
332 unsigned int addr; /* Address of Interrupt Priority Register */
333 int shift; /* Shifts of the 16-bit data */
334 int priority; /* The priority */
335};
336
349/* 337/*
350 * Function for "on chip support modules". 338 * Function for "on chip support modules".
351 */ 339 */
352extern void make_ipr_irq(unsigned int irq, unsigned int addr, 340extern void make_ipr_irq(struct ipr_data *table, unsigned int nr_irqs);
353 int pos, int priority);
354extern void make_imask_irq(unsigned int irq); 341extern void make_imask_irq(unsigned int irq);
355 342
356#if defined(CONFIG_CPU_SUBTYPE_SH7300) 343#if defined(CONFIG_CPU_SUBTYPE_SH7300)
@@ -697,13 +684,15 @@ extern int ipr_irq_demux(int irq);
697 684
698#define INTC2_INTPRI_OFFSET 0x00 685#define INTC2_INTPRI_OFFSET 0x00
699 686
700void make_intc2_irq(unsigned int irq, 687struct intc2_data {
701 unsigned int ipr_offset, unsigned int ipr_shift, 688 unsigned short irq;
702 unsigned int msk_offset, unsigned int msk_shift, 689 unsigned char ipr_offset, ipr_shift;
703 unsigned int priority); 690 unsigned char msk_offset, msk_shift;
704void init_IRQ_intc2(void); 691 unsigned char priority;
705void intc2_add_clear_irq(int irq, int (*fn)(int)); 692};
706 693
694void make_intc2_irq(struct intc2_data *, unsigned int nr_irqs);
695void init_IRQ_intc2(void);
707#endif 696#endif
708 697
709extern int shmse_irq_demux(int irq); 698extern int shmse_irq_demux(int irq);
diff --git a/include/asm-sh/irq_regs.h b/include/asm-sh/irq_regs.h
new file mode 100644
index 000000000000..3dd9c0b70270
--- /dev/null
+++ b/include/asm-sh/irq_regs.h
@@ -0,0 +1 @@
#include <asm-generic/irq_regs.h>
diff --git a/include/asm-sh/landisk/ide.h b/include/asm-sh/landisk/ide.h
deleted file mode 100644
index 6490e28415ed..000000000000
--- a/include/asm-sh/landisk/ide.h
+++ /dev/null
@@ -1,14 +0,0 @@
1/*
2 * modifed by kogiidena
3 * 2005.03.03
4 */
5
6#ifndef __ASM_SH_LANDISK_IDE_H
7#define __ASM_SH_LANDISK_IDE_H
8
9/* Nothing to see here.. */
10#include <asm/landisk/iodata_landisk.h>
11#define IRQ_CFCARD IRQ_FATA /* CF Card IRQ */
12#define IRQ_PCMCIA IRQ_ATA /* PCMCIA IRQ */
13
14#endif /* __ASM_SH_LANDISK_IDE_H */
diff --git a/include/asm-sh/processor.h b/include/asm-sh/processor.h
index 474773853cd1..45bb74e35d32 100644
--- a/include/asm-sh/processor.h
+++ b/include/asm-sh/processor.h
@@ -255,6 +255,8 @@ extern void save_fpu(struct task_struct *__tsk, struct pt_regs *regs);
255 */ 255 */
256#define thread_saved_pc(tsk) (tsk->thread.pc) 256#define thread_saved_pc(tsk) (tsk->thread.pc)
257 257
258void show_trace(struct task_struct *tsk, unsigned long *sp,
259 struct pt_regs *regs);
258extern unsigned long get_wchan(struct task_struct *p); 260extern unsigned long get_wchan(struct task_struct *p);
259 261
260#define KSTK_EIP(tsk) ((tsk)->thread.pc) 262#define KSTK_EIP(tsk) ((tsk)->thread.pc)
diff --git a/include/asm-sh/r7780rp/r7780rp.h b/include/asm-sh/r7780rp.h
index f95d9dba31a2..c18f648a7995 100644
--- a/include/asm-sh/r7780rp/r7780rp.h
+++ b/include/asm-sh/r7780rp.h
@@ -72,8 +72,6 @@
72 72
73#define PA_AX88796L 0xa4100400 /* AX88796L Area */ 73#define PA_AX88796L 0xa4100400 /* AX88796L Area */
74#define PA_SC1602BSLB 0xa6000000 /* SC1602BSLB Area */ 74#define PA_SC1602BSLB 0xa6000000 /* SC1602BSLB Area */
75#define PA_AREA5_IO 0xb4000000 /* Area 5 IO Memory */
76#define PA_AREA6_IO 0xb8000000 /* Area 6 IO Memory */
77#define PA_IDE_OFFSET 0x1f0 /* CF IDE Offset */ 75#define PA_IDE_OFFSET 0x1f0 /* CF IDE Offset */
78#define AX88796L_IO_BASE 0x1000 /* AX88796L IO Base Address */ 76#define AX88796L_IO_BASE 0x1000 /* AX88796L IO Base Address */
79 77
@@ -83,7 +81,6 @@
83#define IRQ_PCISLOT2 66 /* PCI Slot #2 IRQ */ 81#define IRQ_PCISLOT2 66 /* PCI Slot #2 IRQ */
84#define IRQ_PCISLOT3 67 /* PCI Slot #3 IRQ */ 82#define IRQ_PCISLOT3 67 /* PCI Slot #3 IRQ */
85#define IRQ_PCISLOT4 68 /* PCI Slot #4 IRQ */ 83#define IRQ_PCISLOT4 68 /* PCI Slot #4 IRQ */
86#define IRQ_CFCARD 1 /* CF Card IRQ */
87// #define IRQ_CFINST 0 /* CF Card Insert IRQ */ 84// #define IRQ_CFINST 0 /* CF Card Insert IRQ */
88#define IRQ_TP 2 /* Touch Panel IRQ */ 85#define IRQ_TP 2 /* Touch Panel IRQ */
89#define IRQ_SCI1 3 /* SCI1 IRQ */ 86#define IRQ_SCI1 3 /* SCI1 IRQ */
@@ -146,8 +143,6 @@
146 143
147#define PA_AX88796L 0xa5800400 /* AX88796L Area */ 144#define PA_AX88796L 0xa5800400 /* AX88796L Area */
148#define PA_SC1602BSLB 0xa6000000 /* SC1602BSLB Area */ 145#define PA_SC1602BSLB 0xa6000000 /* SC1602BSLB Area */
149#define PA_AREA5_IO 0xb4000000 /* Area 5 IO Memory */
150#define PA_AREA6_IO 0xb8000000 /* Area 6 IO Memory */
151#define PA_IDE_OFFSET 0x1f0 /* CF IDE Offset */ 146#define PA_IDE_OFFSET 0x1f0 /* CF IDE Offset */
152#define AX88796L_IO_BASE 0x1000 /* AX88796L IO Base Address */ 147#define AX88796L_IO_BASE 0x1000 /* AX88796L IO Base Address */
153 148
@@ -157,7 +152,6 @@
157#define IRQ_PCISLOT2 1 /* PCI Slot #2 IRQ */ 152#define IRQ_PCISLOT2 1 /* PCI Slot #2 IRQ */
158#define IRQ_PCISLOT3 2 /* PCI Slot #3 IRQ */ 153#define IRQ_PCISLOT3 2 /* PCI Slot #3 IRQ */
159#define IRQ_PCISLOT4 3 /* PCI Slot #4 IRQ */ 154#define IRQ_PCISLOT4 3 /* PCI Slot #4 IRQ */
160#define IRQ_CFCARD 4 /* CF Card IRQ */
161#define IRQ_CFINST 5 /* CF Card Insert IRQ */ 155#define IRQ_CFINST 5 /* CF Card Insert IRQ */
162#define IRQ_M66596 6 /* M66596 IRQ */ 156#define IRQ_M66596 6 /* M66596 IRQ */
163#define IRQ_SDCARD 7 /* SD Card IRQ */ 157#define IRQ_SDCARD 7 /* SD Card IRQ */
diff --git a/include/asm-sh/r7780rp/ide.h b/include/asm-sh/r7780rp/ide.h
deleted file mode 100644
index a1ed78e0f617..000000000000
--- a/include/asm-sh/r7780rp/ide.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef __ASM_SH_R7780RP_IDE_H
2#define __ASM_SH_R7780RP_IDE_H
3
4/* Nothing to see here.. */
5#include <asm/mach/r7780rp.h>
6
7#endif /* __ASM_SH_R7780RP_IDE_H */
8
diff --git a/include/asm-sh/rts7751r2d/rts7751r2d.h b/include/asm-sh/rts7751r2d.h
index 796b8fcb81a8..796b8fcb81a8 100644
--- a/include/asm-sh/rts7751r2d/rts7751r2d.h
+++ b/include/asm-sh/rts7751r2d.h
diff --git a/include/asm-sh/rts7751r2d/ide.h b/include/asm-sh/rts7751r2d/ide.h
deleted file mode 100644
index 416f96b407cb..000000000000
--- a/include/asm-sh/rts7751r2d/ide.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef __ASM_SH_RTS7751R2D_IDE_H
2#define __ASM_SH_RTS7751R2D_IDE_H
3
4/* Nothing to see here.. */
5#include <asm/rts7751r2d/rts7751r2d.h>
6
7#endif /* __ASM_SH_RTS7751R2D_IDE_H */
8
diff --git a/include/asm-sh/sh03/ide.h b/include/asm-sh/sh03/ide.h
deleted file mode 100644
index 73ee92e5c79e..000000000000
--- a/include/asm-sh/sh03/ide.h
+++ /dev/null
@@ -1,7 +0,0 @@
1#ifndef __ASM_SH_SH03_IDE_H
2#define __ASM_SH_SH03_IDE_H
3
4#define IRQ_CFCARD 8
5#define IRQ_PCMCIA 8
6
7#endif /* __ASM_SH_SH03_IDE_H */
diff --git a/include/asm-sh/shmin/shmin.h b/include/asm-sh/shmin.h
index 36ba138a81fb..36ba138a81fb 100644
--- a/include/asm-sh/shmin/shmin.h
+++ b/include/asm-sh/shmin.h
diff --git a/include/asm-sh/system.h b/include/asm-sh/system.h
index 6c1f8fde5ac4..3340126f4e0f 100644
--- a/include/asm-sh/system.h
+++ b/include/asm-sh/system.h
@@ -353,6 +353,13 @@ static inline unsigned long __cmpxchg(volatile void * ptr, unsigned long old,
353 (unsigned long)_n_, sizeof(*(ptr))); \ 353 (unsigned long)_n_, sizeof(*(ptr))); \
354 }) 354 })
355 355
356extern void *set_exception_table_vec(unsigned int vec, void *handler);
357
358static inline void *set_exception_table_evt(unsigned int evt, void *handler)
359{
360 return set_exception_table_vec(evt >> 5, handler);
361}
362
356/* XXX 363/* XXX
357 * disable hlt during certain critical i/o operations 364 * disable hlt during certain critical i/o operations
358 */ 365 */
diff --git a/include/asm-sh/timer.h b/include/asm-sh/timer.h
index c7ab28095ba0..5df842bcf7b6 100644
--- a/include/asm-sh/timer.h
+++ b/include/asm-sh/timer.h
@@ -8,8 +8,9 @@ struct sys_timer_ops {
8 int (*init)(void); 8 int (*init)(void);
9 int (*start)(void); 9 int (*start)(void);
10 int (*stop)(void); 10 int (*stop)(void);
11#ifndef CONFIG_GENERIC_TIME
11 unsigned long (*get_offset)(void); 12 unsigned long (*get_offset)(void);
12 unsigned long (*get_frequency)(void); 13#endif
13}; 14};
14 15
15struct sys_timer { 16struct sys_timer {
@@ -24,21 +25,17 @@ struct sys_timer {
24extern struct sys_timer tmu_timer; 25extern struct sys_timer tmu_timer;
25extern struct sys_timer *sys_timer; 26extern struct sys_timer *sys_timer;
26 27
28#ifndef CONFIG_GENERIC_TIME
27static inline unsigned long get_timer_offset(void) 29static inline unsigned long get_timer_offset(void)
28{ 30{
29 return sys_timer->ops->get_offset(); 31 return sys_timer->ops->get_offset();
30} 32}
31 33#endif
32static inline unsigned long get_timer_frequency(void)
33{
34 return sys_timer->ops->get_frequency();
35}
36 34
37/* arch/sh/kernel/timers/timer.c */ 35/* arch/sh/kernel/timers/timer.c */
38struct sys_timer *get_sys_timer(void); 36struct sys_timer *get_sys_timer(void);
39 37
40/* arch/sh/kernel/time.c */ 38/* arch/sh/kernel/time.c */
41void handle_timer_tick(struct pt_regs *); 39void handle_timer_tick(void);
42 40
43#endif /* __ASM_SH_TIMER_H */ 41#endif /* __ASM_SH_TIMER_H */
44
diff --git a/include/asm-sh/unistd.h b/include/asm-sh/unistd.h
index f1a0cbc966be..1c2abde122cd 100644
--- a/include/asm-sh/unistd.h
+++ b/include/asm-sh/unistd.h
@@ -324,8 +324,11 @@
324#define __NR_sync_file_range 314 324#define __NR_sync_file_range 314
325#define __NR_tee 315 325#define __NR_tee 315
326#define __NR_vmsplice 316 326#define __NR_vmsplice 316
327#define __NR_move_pages 317
328#define __NR_getcpu 318
329#define __NR_epoll_pwait 319
327 330
328#define NR_syscalls 317 331#define NR_syscalls 320
329 332
330#ifdef __KERNEL__ 333#ifdef __KERNEL__
331 334
diff --git a/include/asm-sh64/io.h b/include/asm-sh64/io.h
index 252fedbb6621..14d8e7b4bf4b 100644
--- a/include/asm-sh64/io.h
+++ b/include/asm-sh64/io.h
@@ -178,22 +178,6 @@ extern void iounmap(void *addr);
178unsigned long onchip_remap(unsigned long addr, unsigned long size, const char* name); 178unsigned long onchip_remap(unsigned long addr, unsigned long size, const char* name);
179extern void onchip_unmap(unsigned long vaddr); 179extern void onchip_unmap(unsigned long vaddr);
180 180
181static __inline__ int check_signature(volatile void __iomem *io_addr,
182 const unsigned char *signature, int length)
183{
184 int retval = 0;
185 do {
186 if (readb(io_addr) != *signature)
187 goto out;
188 io_addr++;
189 signature++;
190 length--;
191 } while (length);
192 retval = 1;
193out:
194 return retval;
195}
196
197/* 181/*
198 * The caches on some architectures aren't dma-coherent and have need to 182 * The caches on some architectures aren't dma-coherent and have need to
199 * handle this in software. There are three types of operations that 183 * handle this in software. There are three types of operations that
diff --git a/include/asm-sparc/elf.h b/include/asm-sparc/elf.h
index 83a3dd15a6ed..aaf6ef40ee2f 100644
--- a/include/asm-sparc/elf.h
+++ b/include/asm-sparc/elf.h
@@ -8,11 +8,6 @@
8 8
9#include <asm/ptrace.h> 9#include <asm/ptrace.h>
10 10
11#ifdef __KERNEL__
12#include <asm/mbus.h>
13#include <asm/uaccess.h>
14#endif
15
16/* 11/*
17 * Sparc section types 12 * Sparc section types
18 */ 13 */
@@ -77,6 +72,23 @@ typedef unsigned long elf_greg_t;
77#define ELF_NGREG 38 72#define ELF_NGREG 38
78typedef elf_greg_t elf_gregset_t[ELF_NGREG]; 73typedef elf_greg_t elf_gregset_t[ELF_NGREG];
79 74
75typedef struct {
76 union {
77 unsigned long pr_regs[32];
78 double pr_dregs[16];
79 } pr_fr;
80 unsigned long __unused;
81 unsigned long pr_fsr;
82 unsigned char pr_qcnt;
83 unsigned char pr_q_entrysize;
84 unsigned char pr_en;
85 unsigned int pr_q[64];
86} elf_fpregset_t;
87
88#ifdef __KERNEL__
89#include <asm/mbus.h>
90#include <asm/uaccess.h>
91
80/* Format is: 92/* Format is:
81 * G0 --> G7 93 * G0 --> G7
82 * O0 --> O7 94 * O0 --> O7
@@ -99,20 +111,7 @@ do { unsigned long *dest = &(__elf_regs[0]); \
99 dest[34] = src->npc; \ 111 dest[34] = src->npc; \
100 dest[35] = src->y; \ 112 dest[35] = src->y; \
101 dest[36] = dest[37] = 0; /* XXX */ \ 113 dest[36] = dest[37] = 0; /* XXX */ \
102} while(0); /* Janitors: Don't touch this colon. */ 114} while(0); /* Janitors: Don't touch this semicolon. */
103
104typedef struct {
105 union {
106 unsigned long pr_regs[32];
107 double pr_dregs[16];
108 } pr_fr;
109 unsigned long __unused;
110 unsigned long pr_fsr;
111 unsigned char pr_qcnt;
112 unsigned char pr_q_entrysize;
113 unsigned char pr_en;
114 unsigned int pr_q[64];
115} elf_fpregset_t;
116 115
117#define ELF_CORE_COPY_TASK_REGS(__tsk, __elf_regs) \ 116#define ELF_CORE_COPY_TASK_REGS(__tsk, __elf_regs) \
118 ({ ELF_CORE_COPY_REGS((*(__elf_regs)), (__tsk)->thread.kregs); 1; }) 117 ({ ELF_CORE_COPY_REGS((*(__elf_regs)), (__tsk)->thread.kregs); 1; })
@@ -165,8 +164,8 @@ typedef struct {
165 164
166#define ELF_PLATFORM (NULL) 165#define ELF_PLATFORM (NULL)
167 166
168#ifdef __KERNEL__
169#define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX) 167#define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX)
170#endif 168
169#endif /* __KERNEL__ */
171 170
172#endif /* !(__ASMSPARC_ELF_H) */ 171#endif /* !(__ASMSPARC_ELF_H) */
diff --git a/include/asm-sparc/unistd.h b/include/asm-sparc/unistd.h
index c7a495afc82e..f7827fa4cd5e 100644
--- a/include/asm-sparc/unistd.h
+++ b/include/asm-sparc/unistd.h
@@ -318,12 +318,15 @@
318#define __NR_unshare 299 318#define __NR_unshare 299
319#define __NR_set_robust_list 300 319#define __NR_set_robust_list 300
320#define __NR_get_robust_list 301 320#define __NR_get_robust_list 301
321#define __NR_migrate_pages 302
322
323#define NR_SYSCALLS 303
321 324
322#ifdef __KERNEL__ 325#ifdef __KERNEL__
323/* WARNING: You MAY NOT add syscall numbers larger than 301, since 326/* WARNING: You MAY NOT add syscall numbers larger than 302, since
324 * all of the syscall tables in the Sparc kernel are 327 * all of the syscall tables in the Sparc kernel are
325 * sized to have 301 entries (starting at zero). Therefore 328 * sized to have 302 entries (starting at zero). Therefore
326 * find a free slot in the 0-301 range. 329 * find a free slot in the 0-302 range.
327 */ 330 */
328 331
329#define _syscall0(type,name) \ 332#define _syscall0(type,name) \
diff --git a/include/asm-sparc64/compat.h b/include/asm-sparc64/compat.h
index c73935dc7ba1..36511ca51416 100644
--- a/include/asm-sparc64/compat.h
+++ b/include/asm-sparc64/compat.h
@@ -164,7 +164,7 @@ static inline compat_uptr_t ptr_to_compat(void __user *uptr)
164 return (u32)(unsigned long)uptr; 164 return (u32)(unsigned long)uptr;
165} 165}
166 166
167static __inline__ void __user *compat_alloc_user_space(long len) 167static inline void __user *compat_alloc_user_space(long len)
168{ 168{
169 struct pt_regs *regs = current_thread_info()->kregs; 169 struct pt_regs *regs = current_thread_info()->kregs;
170 unsigned long usp = regs->u_regs[UREG_I6]; 170 unsigned long usp = regs->u_regs[UREG_I6];
@@ -174,7 +174,10 @@ static __inline__ void __user *compat_alloc_user_space(long len)
174 else 174 else
175 usp &= 0xffffffffUL; 175 usp &= 0xffffffffUL;
176 176
177 return (void __user *) (usp - len); 177 usp -= len;
178 usp &= ~0x7UL;
179
180 return (void __user *) usp;
178} 181}
179 182
180struct compat_ipc64_perm { 183struct compat_ipc64_perm {
diff --git a/include/asm-sparc64/futex.h b/include/asm-sparc64/futex.h
index dee40206b221..7392fc4a954e 100644
--- a/include/asm-sparc64/futex.h
+++ b/include/asm-sparc64/futex.h
@@ -87,24 +87,22 @@ static inline int
87futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) 87futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
88{ 88{
89 __asm__ __volatile__( 89 __asm__ __volatile__(
90 "\n1: lduwa [%2] %%asi, %0\n" 90 "\n1: casa [%3] %%asi, %2, %0\n"
91 "2: casa [%2] %%asi, %0, %1\n" 91 "2:\n"
92 "3:\n"
93 " .section .fixup,#alloc,#execinstr\n" 92 " .section .fixup,#alloc,#execinstr\n"
94 " .align 4\n" 93 " .align 4\n"
95 "4: ba 3b\n" 94 "3: ba 2b\n"
96 " mov %3, %0\n" 95 " mov %4, %0\n"
97 " .previous\n" 96 " .previous\n"
98 " .section __ex_table,\"a\"\n" 97 " .section __ex_table,\"a\"\n"
99 " .align 4\n" 98 " .align 4\n"
100 " .word 1b, 4b\n" 99 " .word 1b, 3b\n"
101 " .word 2b, 4b\n"
102 " .previous\n" 100 " .previous\n"
103 : "=&r" (oldval) 101 : "=r" (newval)
104 : "r" (newval), "r" (uaddr), "i" (-EFAULT) 102 : "0" (newval), "r" (oldval), "r" (uaddr), "i" (-EFAULT)
105 : "memory"); 103 : "memory");
106 104
107 return oldval; 105 return newval;
108} 106}
109 107
110#endif /* !(_SPARC64_FUTEX_H) */ 108#endif /* !(_SPARC64_FUTEX_H) */
diff --git a/include/asm-sparc64/io.h b/include/asm-sparc64/io.h
index 0056770e83ad..30b912d8e8bc 100644
--- a/include/asm-sparc64/io.h
+++ b/include/asm-sparc64/io.h
@@ -440,21 +440,6 @@ _memcpy_toio(volatile void __iomem *dst, const void *src, __kernel_size_t n)
440 440
441#define memcpy_toio(d,s,sz) _memcpy_toio(d,s,sz) 441#define memcpy_toio(d,s,sz) _memcpy_toio(d,s,sz)
442 442
443static inline int check_signature(void __iomem *io_addr,
444 const unsigned char *signature,
445 int length)
446{
447 int retval = 0;
448 do {
449 if (readb(io_addr) != *signature++)
450 goto out;
451 io_addr++;
452 } while (--length);
453 retval = 1;
454out:
455 return retval;
456}
457
458#define mmiowb() 443#define mmiowb()
459 444
460#ifdef __KERNEL__ 445#ifdef __KERNEL__
diff --git a/include/asm-sparc64/unistd.h b/include/asm-sparc64/unistd.h
index 124cf076717f..63669dad0d72 100644
--- a/include/asm-sparc64/unistd.h
+++ b/include/asm-sparc64/unistd.h
@@ -320,12 +320,16 @@
320#define __NR_unshare 299 320#define __NR_unshare 299
321#define __NR_set_robust_list 300 321#define __NR_set_robust_list 300
322#define __NR_get_robust_list 301 322#define __NR_get_robust_list 301
323#define __NR_migrate_pages 302
324
325#define NR_SYSCALLS 303
323 326
324#ifdef __KERNEL__ 327#ifdef __KERNEL__
325/* WARNING: You MAY NOT add syscall numbers larger than 301, since 328
329/* WARNING: You MAY NOT add syscall numbers larger than 302, since
326 * all of the syscall tables in the Sparc kernel are 330 * all of the syscall tables in the Sparc kernel are
327 * sized to have 301 entries (starting at zero). Therefore 331 * sized to have 302 entries (starting at zero). Therefore
328 * find a free slot in the 0-301 range. 332 * find a free slot in the 0-302 range.
329 */ 333 */
330 334
331#define _syscall0(type,name) \ 335#define _syscall0(type,name) \
diff --git a/include/asm-um/archparam-ppc.h b/include/asm-um/archparam-ppc.h
index 172cd6ffacc4..4269d8a37b4f 100644
--- a/include/asm-um/archparam-ppc.h
+++ b/include/asm-um/archparam-ppc.h
@@ -1,15 +1,6 @@
1#ifndef __UM_ARCHPARAM_PPC_H 1#ifndef __UM_ARCHPARAM_PPC_H
2#define __UM_ARCHPARAM_PPC_H 2#define __UM_ARCHPARAM_PPC_H
3 3
4/********* Bits for asm-um/hw_irq.h **********/
5
6struct hw_interrupt_type;
7
8/********* Bits for asm-um/hardirq.h **********/
9
10#define irq_enter(cpu, irq) hardirq_enter(cpu)
11#define irq_exit(cpu, irq) hardirq_exit(cpu)
12
13/********* Bits for asm-um/string.h **********/ 4/********* Bits for asm-um/string.h **********/
14 5
15#define __HAVE_ARCH_STRRCHR 6#define __HAVE_ARCH_STRRCHR
diff --git a/include/asm-um/common.lds.S b/include/asm-um/common.lds.S
index 1010153faaf9..f0454516dd31 100644
--- a/include/asm-um/common.lds.S
+++ b/include/asm-um/common.lds.S
@@ -42,13 +42,7 @@
42 42
43 __initcall_start = .; 43 __initcall_start = .;
44 .initcall.init : { 44 .initcall.init : {
45 *(.initcall1.init) 45 INITCALLS
46 *(.initcall2.init)
47 *(.initcall3.init)
48 *(.initcall4.init)
49 *(.initcall5.init)
50 *(.initcall6.init)
51 *(.initcall7.init)
52 } 46 }
53 __initcall_end = .; 47 __initcall_end = .;
54 48
diff --git a/include/asm-x86_64/acpi.h b/include/asm-x86_64/acpi.h
index ed59aa4c6ff9..9d1916e59c04 100644
--- a/include/asm-x86_64/acpi.h
+++ b/include/asm-x86_64/acpi.h
@@ -163,6 +163,7 @@ extern u8 x86_acpiid_to_apicid[];
163#define ARCH_HAS_POWER_INIT 1 163#define ARCH_HAS_POWER_INIT 1
164 164
165extern int acpi_skip_timer_override; 165extern int acpi_skip_timer_override;
166extern int acpi_use_timer_override;
166 167
167#endif /*__KERNEL__*/ 168#endif /*__KERNEL__*/
168 169
diff --git a/include/asm-x86_64/hw_irq.h b/include/asm-x86_64/hw_irq.h
index 792dd52fcd70..179cce755aa7 100644
--- a/include/asm-x86_64/hw_irq.h
+++ b/include/asm-x86_64/hw_irq.h
@@ -76,6 +76,8 @@
76#ifndef __ASSEMBLY__ 76#ifndef __ASSEMBLY__
77typedef int vector_irq_t[NR_VECTORS]; 77typedef int vector_irq_t[NR_VECTORS];
78DECLARE_PER_CPU(vector_irq_t, vector_irq); 78DECLARE_PER_CPU(vector_irq_t, vector_irq);
79extern void __setup_vector_irq(int cpu);
80extern spinlock_t vector_lock;
79 81
80/* 82/*
81 * Various low-level irq details needed by irq.c, process.c, 83 * Various low-level irq details needed by irq.c, process.c,
diff --git a/include/asm-x86_64/io.h b/include/asm-x86_64/io.h
index 70e91fe76344..6ee9fadaaacb 100644
--- a/include/asm-x86_64/io.h
+++ b/include/asm-x86_64/io.h
@@ -254,33 +254,6 @@ void memset_io(volatile void __iomem *a, int b, size_t c);
254 254
255#define eth_io_copy_and_sum(a,b,c,d) eth_copy_and_sum((a),(void *)(b),(c),(d)) 255#define eth_io_copy_and_sum(a,b,c,d) eth_copy_and_sum((a),(void *)(b),(c),(d))
256 256
257/**
258 * check_signature - find BIOS signatures
259 * @io_addr: mmio address to check
260 * @signature: signature block
261 * @length: length of signature
262 *
263 * Perform a signature comparison with the mmio address io_addr. This
264 * address should have been obtained by ioremap.
265 * Returns 1 on a match.
266 */
267
268static inline int check_signature(void __iomem *io_addr,
269 const unsigned char *signature, int length)
270{
271 int retval = 0;
272 do {
273 if (readb(io_addr) != *signature)
274 goto out;
275 io_addr++;
276 signature++;
277 length--;
278 } while (length);
279 retval = 1;
280out:
281 return retval;
282}
283
284/* Nothing to do */ 257/* Nothing to do */
285 258
286#define dma_cache_inv(_start,_size) do { } while (0) 259#define dma_cache_inv(_start,_size) do { } while (0)
diff --git a/include/asm-x86_64/io_apic.h b/include/asm-x86_64/io_apic.h
index 171ec2dc8c04..561ecbfd4cb5 100644
--- a/include/asm-x86_64/io_apic.h
+++ b/include/asm-x86_64/io_apic.h
@@ -12,10 +12,6 @@
12 12
13#define APIC_MISMATCH_DEBUG 13#define APIC_MISMATCH_DEBUG
14 14
15#define IO_APIC_BASE(idx) \
16 ((volatile int *)(__fix_to_virt(FIX_IO_APIC_BASE_0 + idx) \
17 + (mp_ioapics[idx].mpc_apicaddr & ~PAGE_MASK)))
18
19/* 15/*
20 * The structure of the IO-APIC: 16 * The structure of the IO-APIC:
21 */ 17 */
@@ -119,36 +115,6 @@ extern struct mpc_config_intsrc mp_irqs[MAX_IRQ_SOURCES];
119/* non-0 if default (table-less) MP configuration */ 115/* non-0 if default (table-less) MP configuration */
120extern int mpc_default_type; 116extern int mpc_default_type;
121 117
122static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg)
123{
124 *IO_APIC_BASE(apic) = reg;
125 return *(IO_APIC_BASE(apic)+4);
126}
127
128static inline void io_apic_write(unsigned int apic, unsigned int reg, unsigned int value)
129{
130 *IO_APIC_BASE(apic) = reg;
131 *(IO_APIC_BASE(apic)+4) = value;
132}
133
134/*
135 * Re-write a value: to be used for read-modify-write
136 * cycles where the read already set up the index register.
137 */
138static inline void io_apic_modify(unsigned int apic, unsigned int value)
139{
140 *(IO_APIC_BASE(apic)+4) = value;
141}
142
143/*
144 * Synchronize the IO-APIC and the CPU by doing
145 * a dummy read from the IO-APIC
146 */
147static inline void io_apic_sync(unsigned int apic)
148{
149 (void) *(IO_APIC_BASE(apic)+4);
150}
151
152/* 1 if "noapic" boot option passed */ 118/* 1 if "noapic" boot option passed */
153extern int skip_ioapic_setup; 119extern int skip_ioapic_setup;
154 120
diff --git a/include/asm-x86_64/pda.h b/include/asm-x86_64/pda.h
index 14996d962bac..5642634843c4 100644
--- a/include/asm-x86_64/pda.h
+++ b/include/asm-x86_64/pda.h
@@ -109,6 +109,15 @@ extern struct x8664_pda _proxy_pda;
109#define sub_pda(field,val) pda_to_op("sub",field,val) 109#define sub_pda(field,val) pda_to_op("sub",field,val)
110#define or_pda(field,val) pda_to_op("or",field,val) 110#define or_pda(field,val) pda_to_op("or",field,val)
111 111
112/* This is not atomic against other CPUs -- CPU preemption needs to be off */
113#define test_and_clear_bit_pda(bit,field) ({ \
114 int old__; \
115 asm volatile("btr %2,%%gs:%c3\n\tsbbl %0,%0" \
116 : "=r" (old__), "+m" (_proxy_pda.field) \
117 : "dIr" (bit), "i" (pda_offset(field)) : "memory"); \
118 old__; \
119})
120
112#endif 121#endif
113 122
114#define PDA_STACKOFFSET (5*8) 123#define PDA_STACKOFFSET (5*8)
diff --git a/include/asm-x86_64/pgtable.h b/include/asm-x86_64/pgtable.h
index 6899e770b173..0555c1c4d8fa 100644
--- a/include/asm-x86_64/pgtable.h
+++ b/include/asm-x86_64/pgtable.h
@@ -366,6 +366,7 @@ static inline pte_t mk_pte_phys(unsigned long physpage, pgprot_t pgprot)
366{ 366{
367 pte_t pte; 367 pte_t pte;
368 pte_val(pte) = physpage | pgprot_val(pgprot); 368 pte_val(pte) = physpage | pgprot_val(pgprot);
369 pte_val(pte) &= __supported_pte_mask;
369 return pte; 370 return pte;
370} 371}
371 372
diff --git a/include/asm-x86_64/processor.h b/include/asm-x86_64/processor.h
index de9c3147ee4c..cef17e0f828c 100644
--- a/include/asm-x86_64/processor.h
+++ b/include/asm-x86_64/processor.h
@@ -475,6 +475,8 @@ static inline void __mwait(unsigned long eax, unsigned long ecx)
475 : :"a" (eax), "c" (ecx)); 475 : :"a" (eax), "c" (ecx));
476} 476}
477 477
478extern void mwait_idle_with_hints(unsigned long eax, unsigned long ecx);
479
478#define stack_current() \ 480#define stack_current() \
479({ \ 481({ \
480 struct thread_info *ti; \ 482 struct thread_info *ti; \
diff --git a/include/asm-x86_64/proto.h b/include/asm-x86_64/proto.h
index c181fef786e4..e72cfcdf5344 100644
--- a/include/asm-x86_64/proto.h
+++ b/include/asm-x86_64/proto.h
@@ -122,6 +122,8 @@ extern int fix_aperture;
122extern int reboot_force; 122extern int reboot_force;
123extern int notsc_setup(char *); 123extern int notsc_setup(char *);
124 124
125extern int timer_over_8254;
126
125extern int gsi_irq_sharing(int gsi); 127extern int gsi_irq_sharing(int gsi);
126 128
127extern void smp_local_timer_interrupt(void); 129extern void smp_local_timer_interrupt(void);
diff --git a/include/asm-x86_64/vsyscall.h b/include/asm-x86_64/vsyscall.h
index fd452fc2c037..01d1c17e2849 100644
--- a/include/asm-x86_64/vsyscall.h
+++ b/include/asm-x86_64/vsyscall.h
@@ -59,8 +59,6 @@ extern seqlock_t xtime_lock;
59 59
60extern int sysctl_vsyscall; 60extern int sysctl_vsyscall;
61 61
62extern void vsyscall_set_cpu(int cpu);
63
64#define ARCH_HAVE_XTIME_LOCK 1 62#define ARCH_HAVE_XTIME_LOCK 1
65 63
66#endif /* __KERNEL__ */ 64#endif /* __KERNEL__ */
diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index 5114ff18101d..a1155a2beb32 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -120,6 +120,7 @@ header-y += netrom.h
120header-y += nfs2.h 120header-y += nfs2.h
121header-y += nfs4_mount.h 121header-y += nfs4_mount.h
122header-y += nfs_mount.h 122header-y += nfs_mount.h
123header-y += oom.h
123header-y += param.h 124header-y += param.h
124header-y += pci_ids.h 125header-y += pci_ids.h
125header-y += pci_regs.h 126header-y += pci_regs.h
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 88b5dfd8ee12..2b0c955590fe 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -494,6 +494,9 @@ void acpi_pci_unregister_driver(struct acpi_pci_driver *driver);
494 494
495extern int ec_read(u8 addr, u8 *val); 495extern int ec_read(u8 addr, u8 *val);
496extern int ec_write(u8 addr, u8 val); 496extern int ec_write(u8 addr, u8 val);
497extern int ec_transaction(u8 command,
498 const u8 *wdata, unsigned wdata_len,
499 u8 *rdata, unsigned rdata_len);
497 500
498#endif /*CONFIG_ACPI_EC*/ 501#endif /*CONFIG_ACPI_EC*/
499 502
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index f7a1390d67f5..7011d6255593 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -10,6 +10,8 @@
10 10
11#include <asm/atomic.h> 11#include <asm/atomic.h>
12 12
13struct page;
14
13/* 15/*
14 * Bits in backing_dev_info.state 16 * Bits in backing_dev_info.state
15 */ 17 */
@@ -88,6 +90,11 @@ static inline int bdi_rw_congested(struct backing_dev_info *bdi)
88 (1 << BDI_write_congested)); 90 (1 << BDI_write_congested));
89} 91}
90 92
93void clear_bdi_congested(struct backing_dev_info *bdi, int rw);
94void set_bdi_congested(struct backing_dev_info *bdi, int rw);
95long congestion_wait(int rw, long timeout);
96void congestion_end(int rw);
97
91#define bdi_cap_writeback_dirty(bdi) \ 98#define bdi_cap_writeback_dirty(bdi) \
92 (!((bdi)->capabilities & BDI_CAP_NO_WRITEBACK)) 99 (!((bdi)->capabilities & BDI_CAP_NO_WRITEBACK))
93 100
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index dcc5de7cc487..64b4641904fe 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -46,7 +46,8 @@
46 * bitmap_remap(dst, src, old, new, nbits) *dst = map(old, new)(src) 46 * bitmap_remap(dst, src, old, new, nbits) *dst = map(old, new)(src)
47 * bitmap_bitremap(oldbit, old, new, nbits) newbit = map(old, new)(oldbit) 47 * bitmap_bitremap(oldbit, old, new, nbits) newbit = map(old, new)(oldbit)
48 * bitmap_scnprintf(buf, len, src, nbits) Print bitmap src to buf 48 * bitmap_scnprintf(buf, len, src, nbits) Print bitmap src to buf
49 * bitmap_parse(ubuf, ulen, dst, nbits) Parse bitmap dst from user buf 49 * bitmap_parse(buf, buflen, dst, nbits) Parse bitmap dst from kernel buf
50 * bitmap_parse_user(ubuf, ulen, dst, nbits) Parse bitmap dst from user buf
50 * bitmap_scnlistprintf(buf, len, src, nbits) Print bitmap src as list to buf 51 * bitmap_scnlistprintf(buf, len, src, nbits) Print bitmap src as list to buf
51 * bitmap_parselist(buf, dst, nbits) Parse bitmap dst from list 52 * bitmap_parselist(buf, dst, nbits) Parse bitmap dst from list
52 * bitmap_find_free_region(bitmap, bits, order) Find and allocate bit region 53 * bitmap_find_free_region(bitmap, bits, order) Find and allocate bit region
@@ -106,7 +107,9 @@ extern int __bitmap_weight(const unsigned long *bitmap, int bits);
106 107
107extern int bitmap_scnprintf(char *buf, unsigned int len, 108extern int bitmap_scnprintf(char *buf, unsigned int len,
108 const unsigned long *src, int nbits); 109 const unsigned long *src, int nbits);
109extern int bitmap_parse(const char __user *ubuf, unsigned int ulen, 110extern int __bitmap_parse(const char *buf, unsigned int buflen, int is_user,
111 unsigned long *dst, int nbits);
112extern int bitmap_parse_user(const char __user *ubuf, unsigned int ulen,
110 unsigned long *dst, int nbits); 113 unsigned long *dst, int nbits);
111extern int bitmap_scnlistprintf(char *buf, unsigned int len, 114extern int bitmap_scnlistprintf(char *buf, unsigned int len,
112 const unsigned long *src, int nbits); 115 const unsigned long *src, int nbits);
@@ -270,6 +273,12 @@ static inline void bitmap_shift_left(unsigned long *dst,
270 __bitmap_shift_left(dst, src, n, nbits); 273 __bitmap_shift_left(dst, src, n, nbits);
271} 274}
272 275
276static inline int bitmap_parse(const char *buf, unsigned int buflen,
277 unsigned long *maskp, int nmaskbits)
278{
279 return __bitmap_parse(buf, buflen, 0, maskp, nmaskbits);
280}
281
273#endif /* __ASSEMBLY__ */ 282#endif /* __ASSEMBLY__ */
274 283
275#endif /* __LINUX_BITMAP_H */ 284#endif /* __LINUX_BITMAP_H */
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 26f7856ff812..7bfcde2d5578 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -157,6 +157,7 @@ enum rq_cmd_type_bits {
157 REQ_TYPE_ATA_CMD, 157 REQ_TYPE_ATA_CMD,
158 REQ_TYPE_ATA_TASK, 158 REQ_TYPE_ATA_TASK,
159 REQ_TYPE_ATA_TASKFILE, 159 REQ_TYPE_ATA_TASKFILE,
160 REQ_TYPE_ATA_PC,
160}; 161};
161 162
162/* 163/*
@@ -650,6 +651,26 @@ extern void blk_recount_segments(request_queue_t *, struct bio *);
650extern int scsi_cmd_ioctl(struct file *, struct gendisk *, unsigned int, void __user *); 651extern int scsi_cmd_ioctl(struct file *, struct gendisk *, unsigned int, void __user *);
651extern int sg_scsi_ioctl(struct file *, struct request_queue *, 652extern int sg_scsi_ioctl(struct file *, struct request_queue *,
652 struct gendisk *, struct scsi_ioctl_command __user *); 653 struct gendisk *, struct scsi_ioctl_command __user *);
654
655/*
656 * A queue has just exitted congestion. Note this in the global counter of
657 * congested queues, and wake up anyone who was waiting for requests to be
658 * put back.
659 */
660static inline void blk_clear_queue_congested(request_queue_t *q, int rw)
661{
662 clear_bdi_congested(&q->backing_dev_info, rw);
663}
664
665/*
666 * A queue has just entered congestion. Flag that in the queue's VM-visible
667 * state flags and increment the global gounter of congested queues.
668 */
669static inline void blk_set_queue_congested(request_queue_t *q, int rw)
670{
671 set_bdi_congested(&q->backing_dev_info, rw);
672}
673
653extern void blk_start_queue(request_queue_t *q); 674extern void blk_start_queue(request_queue_t *q);
654extern void blk_stop_queue(request_queue_t *q); 675extern void blk_stop_queue(request_queue_t *q);
655extern void blk_sync_queue(struct request_queue *q); 676extern void blk_sync_queue(struct request_queue *q);
@@ -764,10 +785,8 @@ extern int blk_queue_init_tags(request_queue_t *, int, struct blk_queue_tag *);
764extern void blk_queue_free_tags(request_queue_t *); 785extern void blk_queue_free_tags(request_queue_t *);
765extern int blk_queue_resize_tags(request_queue_t *, int); 786extern int blk_queue_resize_tags(request_queue_t *, int);
766extern void blk_queue_invalidate_tags(request_queue_t *); 787extern void blk_queue_invalidate_tags(request_queue_t *);
767extern long blk_congestion_wait(int rw, long timeout);
768extern struct blk_queue_tag *blk_init_tags(int); 788extern struct blk_queue_tag *blk_init_tags(int);
769extern void blk_free_tags(struct blk_queue_tag *); 789extern void blk_free_tags(struct blk_queue_tag *);
770extern void blk_congestion_end(int rw);
771 790
772static inline struct request *blk_map_queue_find_tag(struct blk_queue_tag *bqt, 791static inline struct request *blk_map_queue_find_tag(struct blk_queue_tag *bqt,
773 int tag) 792 int tag)
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index 131ffd37e716..5d9fb0e94156 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -69,6 +69,8 @@ struct buffer_head {
69 bh_end_io_t *b_end_io; /* I/O completion */ 69 bh_end_io_t *b_end_io; /* I/O completion */
70 void *b_private; /* reserved for b_end_io */ 70 void *b_private; /* reserved for b_end_io */
71 struct list_head b_assoc_buffers; /* associated with another mapping */ 71 struct list_head b_assoc_buffers; /* associated with another mapping */
72 struct address_space *b_assoc_map; /* mapping this buffer is
73 associated with */
72 atomic_t b_count; /* users using this buffer_head */ 74 atomic_t b_count; /* users using this buffer_head */
73}; 75};
74 76
diff --git a/include/linux/carta_random32.h b/include/linux/carta_random32.h
new file mode 100644
index 000000000000..f6f3bd9f20b5
--- /dev/null
+++ b/include/linux/carta_random32.h
@@ -0,0 +1,29 @@
1/*
2 * Fast, simple, yet decent quality random number generator based on
3 * a paper by David G. Carta ("Two Fast Implementations of the
4 * `Minimal Standard' Random Number Generator," Communications of the
5 * ACM, January, 1990).
6 *
7 * Copyright (c) 2002-2006 Hewlett-Packard Development Company, L.P.
8 * Contributed by Stephane Eranian <eranian@hpl.hp.com>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 * 02111-1307 USA
23 */
24#ifndef _LINUX_CARTA_RANDOM32_H_
25#define _LINUX_CARTA_RANDOM32_H_
26
27u64 carta_random32(u64 seed);
28
29#endif /* _LINUX_CARTA_RANDOM32_H_ */
diff --git a/include/linux/compat.h b/include/linux/compat.h
index f4ebf96f5308..80b17f440ec1 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -196,7 +196,7 @@ asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp,
196#define BITS_TO_COMPAT_LONGS(bits) \ 196#define BITS_TO_COMPAT_LONGS(bits) \
197 (((bits)+BITS_PER_COMPAT_LONG-1)/BITS_PER_COMPAT_LONG) 197 (((bits)+BITS_PER_COMPAT_LONG-1)/BITS_PER_COMPAT_LONG)
198 198
199long compat_get_bitmap(unsigned long *mask, compat_ulong_t __user *umask, 199long compat_get_bitmap(unsigned long *mask, const compat_ulong_t __user *umask,
200 unsigned long bitmap_size); 200 unsigned long bitmap_size);
201long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask, 201long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask,
202 unsigned long bitmap_size); 202 unsigned long bitmap_size);
@@ -230,5 +230,9 @@ asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp);
230extern int compat_printk(const char *fmt, ...); 230extern int compat_printk(const char *fmt, ...);
231extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat); 231extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat);
232 232
233asmlinkage long compat_sys_migrate_pages(compat_pid_t pid,
234 compat_ulong_t maxnode, const compat_ulong_t __user *old_nodes,
235 const compat_ulong_t __user *new_nodes);
236
233#endif /* CONFIG_COMPAT */ 237#endif /* CONFIG_COMPAT */
234#endif /* _LINUX_COMPAT_H */ 238#endif /* _LINUX_COMPAT_H */
diff --git a/include/linux/compat_ioctl.h b/include/linux/compat_ioctl.h
index 4e1663d7691e..c26c3adcfacf 100644
--- a/include/linux/compat_ioctl.h
+++ b/include/linux/compat_ioctl.h
@@ -61,17 +61,23 @@ COMPATIBLE_IOCTL(FIGETBSZ)
61 * Some need translations, these do not. 61 * Some need translations, these do not.
62 */ 62 */
63COMPATIBLE_IOCTL(HDIO_GET_IDENTITY) 63COMPATIBLE_IOCTL(HDIO_GET_IDENTITY)
64COMPATIBLE_IOCTL(HDIO_SET_DMA)
65COMPATIBLE_IOCTL(HDIO_SET_UNMASKINTR)
66COMPATIBLE_IOCTL(HDIO_SET_NOWERR)
67COMPATIBLE_IOCTL(HDIO_SET_32BIT)
68COMPATIBLE_IOCTL(HDIO_SET_MULTCOUNT)
69COMPATIBLE_IOCTL(HDIO_DRIVE_CMD)
70COMPATIBLE_IOCTL(HDIO_DRIVE_TASK) 64COMPATIBLE_IOCTL(HDIO_DRIVE_TASK)
71COMPATIBLE_IOCTL(HDIO_SET_PIO_MODE) 65COMPATIBLE_IOCTL(HDIO_DRIVE_CMD)
72COMPATIBLE_IOCTL(HDIO_SET_NICE) 66ULONG_IOCTL(HDIO_SET_MULTCOUNT)
73COMPATIBLE_IOCTL(HDIO_SET_KEEPSETTINGS) 67ULONG_IOCTL(HDIO_SET_UNMASKINTR)
68ULONG_IOCTL(HDIO_SET_KEEPSETTINGS)
69ULONG_IOCTL(HDIO_SET_32BIT)
70ULONG_IOCTL(HDIO_SET_NOWERR)
71ULONG_IOCTL(HDIO_SET_DMA)
72ULONG_IOCTL(HDIO_SET_PIO_MODE)
73ULONG_IOCTL(HDIO_SET_NICE)
74ULONG_IOCTL(HDIO_SET_WCACHE)
75ULONG_IOCTL(HDIO_SET_ACOUSTIC)
76ULONG_IOCTL(HDIO_SET_BUSSTATE)
77ULONG_IOCTL(HDIO_SET_ADDRESS)
74COMPATIBLE_IOCTL(HDIO_SCAN_HWIF) 78COMPATIBLE_IOCTL(HDIO_SCAN_HWIF)
79/* 0x330 is reserved -- it used to be HDIO_GETGEO_BIG */
80COMPATIBLE_IOCTL(0x330)
75/* 0x02 -- Floppy ioctls */ 81/* 0x02 -- Floppy ioctls */
76COMPATIBLE_IOCTL(FDMSGON) 82COMPATIBLE_IOCTL(FDMSGON)
77COMPATIBLE_IOCTL(FDMSGOFF) 83COMPATIBLE_IOCTL(FDMSGOFF)
@@ -125,6 +131,7 @@ COMPATIBLE_IOCTL(RUN_ARRAY)
125COMPATIBLE_IOCTL(STOP_ARRAY) 131COMPATIBLE_IOCTL(STOP_ARRAY)
126COMPATIBLE_IOCTL(STOP_ARRAY_RO) 132COMPATIBLE_IOCTL(STOP_ARRAY_RO)
127COMPATIBLE_IOCTL(RESTART_ARRAY_RW) 133COMPATIBLE_IOCTL(RESTART_ARRAY_RW)
134COMPATIBLE_IOCTL(GET_BITMAP_FILE)
128ULONG_IOCTL(SET_BITMAP_FILE) 135ULONG_IOCTL(SET_BITMAP_FILE)
129/* DM */ 136/* DM */
130COMPATIBLE_IOCTL(DM_VERSION_32) 137COMPATIBLE_IOCTL(DM_VERSION_32)
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index b268a3c0c376..d0e8c8b0e34d 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -8,8 +8,8 @@
8 * See detailed comments in the file linux/bitmap.h describing the 8 * See detailed comments in the file linux/bitmap.h describing the
9 * data type on which these cpumasks are based. 9 * data type on which these cpumasks are based.
10 * 10 *
11 * For details of cpumask_scnprintf() and cpumask_parse(), 11 * For details of cpumask_scnprintf() and cpumask_parse_user(),
12 * see bitmap_scnprintf() and bitmap_parse() in lib/bitmap.c. 12 * see bitmap_scnprintf() and bitmap_parse_user() in lib/bitmap.c.
13 * For details of cpulist_scnprintf() and cpulist_parse(), see 13 * For details of cpulist_scnprintf() and cpulist_parse(), see
14 * bitmap_scnlistprintf() and bitmap_parselist(), also in bitmap.c. 14 * bitmap_scnlistprintf() and bitmap_parselist(), also in bitmap.c.
15 * For details of cpu_remap(), see bitmap_bitremap in lib/bitmap.c 15 * For details of cpu_remap(), see bitmap_bitremap in lib/bitmap.c
@@ -49,7 +49,7 @@
49 * unsigned long *cpus_addr(mask) Array of unsigned long's in mask 49 * unsigned long *cpus_addr(mask) Array of unsigned long's in mask
50 * 50 *
51 * int cpumask_scnprintf(buf, len, mask) Format cpumask for printing 51 * int cpumask_scnprintf(buf, len, mask) Format cpumask for printing
52 * int cpumask_parse(ubuf, ulen, mask) Parse ascii string as cpumask 52 * int cpumask_parse_user(ubuf, ulen, mask) Parse ascii string as cpumask
53 * int cpulist_scnprintf(buf, len, mask) Format cpumask as list for printing 53 * int cpulist_scnprintf(buf, len, mask) Format cpumask as list for printing
54 * int cpulist_parse(buf, map) Parse ascii string as cpulist 54 * int cpulist_parse(buf, map) Parse ascii string as cpulist
55 * int cpu_remap(oldbit, old, new) newbit = map(old, new)(oldbit) 55 * int cpu_remap(oldbit, old, new) newbit = map(old, new)(oldbit)
@@ -273,12 +273,12 @@ static inline int __cpumask_scnprintf(char *buf, int len,
273 return bitmap_scnprintf(buf, len, srcp->bits, nbits); 273 return bitmap_scnprintf(buf, len, srcp->bits, nbits);
274} 274}
275 275
276#define cpumask_parse(ubuf, ulen, dst) \ 276#define cpumask_parse_user(ubuf, ulen, dst) \
277 __cpumask_parse((ubuf), (ulen), &(dst), NR_CPUS) 277 __cpumask_parse_user((ubuf), (ulen), &(dst), NR_CPUS)
278static inline int __cpumask_parse(const char __user *buf, int len, 278static inline int __cpumask_parse_user(const char __user *buf, int len,
279 cpumask_t *dstp, int nbits) 279 cpumask_t *dstp, int nbits)
280{ 280{
281 return bitmap_parse(buf, len, dstp->bits, nbits); 281 return bitmap_parse_user(buf, len, dstp->bits, nbits);
282} 282}
283 283
284#define cpulist_scnprintf(buf, len, src) \ 284#define cpulist_scnprintf(buf, len, src) \
diff --git a/include/linux/crypto.h b/include/linux/crypto.h
index 8f2ffa4caabf..6485e9716b36 100644
--- a/include/linux/crypto.h
+++ b/include/linux/crypto.h
@@ -245,7 +245,7 @@ int crypto_alg_available(const char *name, u32 flags)
245 __deprecated_for_modules; 245 __deprecated_for_modules;
246int crypto_has_alg(const char *name, u32 type, u32 mask); 246int crypto_has_alg(const char *name, u32 type, u32 mask);
247#else 247#else
248static int crypto_alg_available(const char *name, u32 flags); 248static int crypto_alg_available(const char *name, u32 flags)
249 __deprecated_for_modules; 249 __deprecated_for_modules;
250static inline int crypto_alg_available(const char *name, u32 flags) 250static inline int crypto_alg_available(const char *name, u32 flags)
251{ 251{
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index 44605be59409..63f64a9a5bf7 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -230,6 +230,7 @@ extern struct dentry * d_alloc_anon(struct inode *);
230extern struct dentry * d_splice_alias(struct inode *, struct dentry *); 230extern struct dentry * d_splice_alias(struct inode *, struct dentry *);
231extern void shrink_dcache_sb(struct super_block *); 231extern void shrink_dcache_sb(struct super_block *);
232extern void shrink_dcache_parent(struct dentry *); 232extern void shrink_dcache_parent(struct dentry *);
233extern void shrink_dcache_for_umount(struct super_block *);
233extern int d_invalidate(struct dentry *); 234extern int d_invalidate(struct dentry *);
234 235
235/* only used at mount-time */ 236/* only used at mount-time */
diff --git a/include/linux/device.h b/include/linux/device.h
index 662e6a10144e..9d4f6a963936 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -393,7 +393,7 @@ extern void device_unregister(struct device * dev);
393extern void device_initialize(struct device * dev); 393extern void device_initialize(struct device * dev);
394extern int __must_check device_add(struct device * dev); 394extern int __must_check device_add(struct device * dev);
395extern void device_del(struct device * dev); 395extern void device_del(struct device * dev);
396extern int __must_check device_for_each_child(struct device *, void *, 396extern int device_for_each_child(struct device *, void *,
397 int (*fn)(struct device *, void *)); 397 int (*fn)(struct device *, void *));
398extern int device_rename(struct device *dev, char *new_name); 398extern int device_rename(struct device *dev, char *new_name);
399 399
diff --git a/include/linux/dmi.h b/include/linux/dmi.h
index 38dc403be70b..904bf3d2d90b 100644
--- a/include/linux/dmi.h
+++ b/include/linux/dmi.h
@@ -69,6 +69,7 @@ extern struct dmi_device * dmi_find_device(int type, const char *name,
69 struct dmi_device *from); 69 struct dmi_device *from);
70extern void dmi_scan_machine(void); 70extern void dmi_scan_machine(void);
71extern int dmi_get_year(int field); 71extern int dmi_get_year(int field);
72extern int dmi_name_in_vendors(char *str);
72 73
73#else 74#else
74 75
@@ -77,6 +78,7 @@ static inline char * dmi_get_system_info(int field) { return NULL; }
77static inline struct dmi_device * dmi_find_device(int type, const char *name, 78static inline struct dmi_device * dmi_find_device(int type, const char *name,
78 struct dmi_device *from) { return NULL; } 79 struct dmi_device *from) { return NULL; }
79static inline int dmi_get_year(int year) { return 0; } 80static inline int dmi_get_year(int year) { return 0; }
81static inline int dmi_name_in_vendors(char *s) { return 0; }
80 82
81#endif 83#endif
82 84
diff --git a/include/linux/elevator.h b/include/linux/elevator.h
index b3370ef5164d..2fa9f1144228 100644
--- a/include/linux/elevator.h
+++ b/include/linux/elevator.h
@@ -70,7 +70,6 @@ struct elevator_type
70{ 70{
71 struct list_head list; 71 struct list_head list;
72 struct elevator_ops ops; 72 struct elevator_ops ops;
73 struct elevator_type *elevator_type;
74 struct elv_fs_entry *elevator_attrs; 73 struct elv_fs_entry *elevator_attrs;
75 char elevator_name[ELV_NAME_MAX]; 74 char elevator_name[ELV_NAME_MAX];
76 struct module *elevator_owner; 75 struct module *elevator_owner;
diff --git a/include/linux/ext4_fs.h b/include/linux/ext4_fs.h
new file mode 100644
index 000000000000..498503ee613d
--- /dev/null
+++ b/include/linux/ext4_fs.h
@@ -0,0 +1,994 @@
1/*
2 * linux/include/linux/ext4_fs.h
3 *
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 *
9 * from
10 *
11 * linux/include/linux/minix_fs.h
12 *
13 * Copyright (C) 1991, 1992 Linus Torvalds
14 */
15
16#ifndef _LINUX_EXT4_FS_H
17#define _LINUX_EXT4_FS_H
18
19#include <linux/types.h>
20#include <linux/blkdev.h>
21#include <linux/magic.h>
22
23/*
24 * The second extended filesystem constants/structures
25 */
26
27/*
28 * Define EXT4FS_DEBUG to produce debug messages
29 */
30#undef EXT4FS_DEBUG
31
32/*
33 * Define EXT4_RESERVATION to reserve data blocks for expanding files
34 */
35#define EXT4_DEFAULT_RESERVE_BLOCKS 8
36/*max window size: 1024(direct blocks) + 3([t,d]indirect blocks) */
37#define EXT4_MAX_RESERVE_BLOCKS 1027
38#define EXT4_RESERVE_WINDOW_NOT_ALLOCATED 0
39/*
40 * Always enable hashed directories
41 */
42#define CONFIG_EXT4_INDEX
43
44/*
45 * Debug code
46 */
47#ifdef EXT4FS_DEBUG
48#define ext4_debug(f, a...) \
49 do { \
50 printk (KERN_DEBUG "EXT4-fs DEBUG (%s, %d): %s:", \
51 __FILE__, __LINE__, __FUNCTION__); \
52 printk (KERN_DEBUG f, ## a); \
53 } while (0)
54#else
55#define ext4_debug(f, a...) do {} while (0)
56#endif
57
58/*
59 * Special inodes numbers
60 */
61#define EXT4_BAD_INO 1 /* Bad blocks inode */
62#define EXT4_ROOT_INO 2 /* Root inode */
63#define EXT4_BOOT_LOADER_INO 5 /* Boot loader inode */
64#define EXT4_UNDEL_DIR_INO 6 /* Undelete directory inode */
65#define EXT4_RESIZE_INO 7 /* Reserved group descriptors inode */
66#define EXT4_JOURNAL_INO 8 /* Journal inode */
67
68/* First non-reserved inode for old ext4 filesystems */
69#define EXT4_GOOD_OLD_FIRST_INO 11
70
71/*
72 * Maximal count of links to a file
73 */
74#define EXT4_LINK_MAX 32000
75
76/*
77 * Macro-instructions used to manage several block sizes
78 */
79#define EXT4_MIN_BLOCK_SIZE 1024
80#define EXT4_MAX_BLOCK_SIZE 4096
81#define EXT4_MIN_BLOCK_LOG_SIZE 10
82#ifdef __KERNEL__
83# define EXT4_BLOCK_SIZE(s) ((s)->s_blocksize)
84#else
85# define EXT4_BLOCK_SIZE(s) (EXT4_MIN_BLOCK_SIZE << (s)->s_log_block_size)
86#endif
87#define EXT4_ADDR_PER_BLOCK(s) (EXT4_BLOCK_SIZE(s) / sizeof (__u32))
88#ifdef __KERNEL__
89# define EXT4_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
90#else
91# define EXT4_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
92#endif
93#ifdef __KERNEL__
94#define EXT4_ADDR_PER_BLOCK_BITS(s) (EXT4_SB(s)->s_addr_per_block_bits)
95#define EXT4_INODE_SIZE(s) (EXT4_SB(s)->s_inode_size)
96#define EXT4_FIRST_INO(s) (EXT4_SB(s)->s_first_ino)
97#else
98#define EXT4_INODE_SIZE(s) (((s)->s_rev_level == EXT4_GOOD_OLD_REV) ? \
99 EXT4_GOOD_OLD_INODE_SIZE : \
100 (s)->s_inode_size)
101#define EXT4_FIRST_INO(s) (((s)->s_rev_level == EXT4_GOOD_OLD_REV) ? \
102 EXT4_GOOD_OLD_FIRST_INO : \
103 (s)->s_first_ino)
104#endif
105
106/*
107 * Macro-instructions used to manage fragments
108 */
109#define EXT4_MIN_FRAG_SIZE 1024
110#define EXT4_MAX_FRAG_SIZE 4096
111#define EXT4_MIN_FRAG_LOG_SIZE 10
112#ifdef __KERNEL__
113# define EXT4_FRAG_SIZE(s) (EXT4_SB(s)->s_frag_size)
114# define EXT4_FRAGS_PER_BLOCK(s) (EXT4_SB(s)->s_frags_per_block)
115#else
116# define EXT4_FRAG_SIZE(s) (EXT4_MIN_FRAG_SIZE << (s)->s_log_frag_size)
117# define EXT4_FRAGS_PER_BLOCK(s) (EXT4_BLOCK_SIZE(s) / EXT4_FRAG_SIZE(s))
118#endif
119
120/*
121 * Structure of a blocks group descriptor
122 */
123struct ext4_group_desc
124{
125 __le32 bg_block_bitmap; /* Blocks bitmap block */
126 __le32 bg_inode_bitmap; /* Inodes bitmap block */
127 __le32 bg_inode_table; /* Inodes table block */
128 __le16 bg_free_blocks_count; /* Free blocks count */
129 __le16 bg_free_inodes_count; /* Free inodes count */
130 __le16 bg_used_dirs_count; /* Directories count */
131 __u16 bg_flags;
132 __u32 bg_reserved[3];
133 __le32 bg_block_bitmap_hi; /* Blocks bitmap block MSB */
134 __le32 bg_inode_bitmap_hi; /* Inodes bitmap block MSB */
135 __le32 bg_inode_table_hi; /* Inodes table block MSB */
136};
137
138#ifdef __KERNEL__
139#include <linux/ext4_fs_i.h>
140#include <linux/ext4_fs_sb.h>
141#endif
142/*
143 * Macro-instructions used to manage group descriptors
144 */
145#define EXT4_MIN_DESC_SIZE 32
146#define EXT4_MIN_DESC_SIZE_64BIT 64
147#define EXT4_MAX_DESC_SIZE EXT4_MIN_BLOCK_SIZE
148#define EXT4_DESC_SIZE(s) (EXT4_SB(s)->s_desc_size)
149#ifdef __KERNEL__
150# define EXT4_BLOCKS_PER_GROUP(s) (EXT4_SB(s)->s_blocks_per_group)
151# define EXT4_DESC_PER_BLOCK(s) (EXT4_SB(s)->s_desc_per_block)
152# define EXT4_INODES_PER_GROUP(s) (EXT4_SB(s)->s_inodes_per_group)
153# define EXT4_DESC_PER_BLOCK_BITS(s) (EXT4_SB(s)->s_desc_per_block_bits)
154#else
155# define EXT4_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group)
156# define EXT4_DESC_PER_BLOCK(s) (EXT4_BLOCK_SIZE(s) / EXT4_DESC_SIZE(s))
157# define EXT4_INODES_PER_GROUP(s) ((s)->s_inodes_per_group)
158#endif
159
160/*
161 * Constants relative to the data blocks
162 */
163#define EXT4_NDIR_BLOCKS 12
164#define EXT4_IND_BLOCK EXT4_NDIR_BLOCKS
165#define EXT4_DIND_BLOCK (EXT4_IND_BLOCK + 1)
166#define EXT4_TIND_BLOCK (EXT4_DIND_BLOCK + 1)
167#define EXT4_N_BLOCKS (EXT4_TIND_BLOCK + 1)
168
169/*
170 * Inode flags
171 */
172#define EXT4_SECRM_FL 0x00000001 /* Secure deletion */
173#define EXT4_UNRM_FL 0x00000002 /* Undelete */
174#define EXT4_COMPR_FL 0x00000004 /* Compress file */
175#define EXT4_SYNC_FL 0x00000008 /* Synchronous updates */
176#define EXT4_IMMUTABLE_FL 0x00000010 /* Immutable file */
177#define EXT4_APPEND_FL 0x00000020 /* writes to file may only append */
178#define EXT4_NODUMP_FL 0x00000040 /* do not dump file */
179#define EXT4_NOATIME_FL 0x00000080 /* do not update atime */
180/* Reserved for compression usage... */
181#define EXT4_DIRTY_FL 0x00000100
182#define EXT4_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
183#define EXT4_NOCOMPR_FL 0x00000400 /* Don't compress */
184#define EXT4_ECOMPR_FL 0x00000800 /* Compression error */
185/* End compression flags --- maybe not all used */
186#define EXT4_INDEX_FL 0x00001000 /* hash-indexed directory */
187#define EXT4_IMAGIC_FL 0x00002000 /* AFS directory */
188#define EXT4_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */
189#define EXT4_NOTAIL_FL 0x00008000 /* file tail should not be merged */
190#define EXT4_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
191#define EXT4_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
192#define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
193#define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
194
195#define EXT4_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */
196#define EXT4_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
197
198/*
199 * Inode dynamic state flags
200 */
201#define EXT4_STATE_JDATA 0x00000001 /* journaled data exists */
202#define EXT4_STATE_NEW 0x00000002 /* inode is newly created */
203#define EXT4_STATE_XATTR 0x00000004 /* has in-inode xattrs */
204
205/* Used to pass group descriptor data when online resize is done */
206struct ext4_new_group_input {
207 __u32 group; /* Group number for this data */
208 __u64 block_bitmap; /* Absolute block number of block bitmap */
209 __u64 inode_bitmap; /* Absolute block number of inode bitmap */
210 __u64 inode_table; /* Absolute block number of inode table start */
211 __u32 blocks_count; /* Total number of blocks in this group */
212 __u16 reserved_blocks; /* Number of reserved blocks in this group */
213 __u16 unused;
214};
215
216/* The struct ext4_new_group_input in kernel space, with free_blocks_count */
217struct ext4_new_group_data {
218 __u32 group;
219 __u64 block_bitmap;
220 __u64 inode_bitmap;
221 __u64 inode_table;
222 __u32 blocks_count;
223 __u16 reserved_blocks;
224 __u16 unused;
225 __u32 free_blocks_count;
226};
227
228
229/*
230 * ioctl commands
231 */
232#define EXT4_IOC_GETFLAGS FS_IOC_GETFLAGS
233#define EXT4_IOC_SETFLAGS FS_IOC_SETFLAGS
234#define EXT4_IOC_GETVERSION _IOR('f', 3, long)
235#define EXT4_IOC_SETVERSION _IOW('f', 4, long)
236#define EXT4_IOC_GROUP_EXTEND _IOW('f', 7, unsigned long)
237#define EXT4_IOC_GROUP_ADD _IOW('f', 8,struct ext4_new_group_input)
238#define EXT4_IOC_GETVERSION_OLD FS_IOC_GETVERSION
239#define EXT4_IOC_SETVERSION_OLD FS_IOC_SETVERSION
240#ifdef CONFIG_JBD_DEBUG
241#define EXT4_IOC_WAIT_FOR_READONLY _IOR('f', 99, long)
242#endif
243#define EXT4_IOC_GETRSVSZ _IOR('f', 5, long)
244#define EXT4_IOC_SETRSVSZ _IOW('f', 6, long)
245
246/*
247 * ioctl commands in 32 bit emulation
248 */
249#define EXT4_IOC32_GETFLAGS FS_IOC32_GETFLAGS
250#define EXT4_IOC32_SETFLAGS FS_IOC32_SETFLAGS
251#define EXT4_IOC32_GETVERSION _IOR('f', 3, int)
252#define EXT4_IOC32_SETVERSION _IOW('f', 4, int)
253#define EXT4_IOC32_GETRSVSZ _IOR('f', 5, int)
254#define EXT4_IOC32_SETRSVSZ _IOW('f', 6, int)
255#define EXT4_IOC32_GROUP_EXTEND _IOW('f', 7, unsigned int)
256#ifdef CONFIG_JBD_DEBUG
257#define EXT4_IOC32_WAIT_FOR_READONLY _IOR('f', 99, int)
258#endif
259#define EXT4_IOC32_GETVERSION_OLD FS_IOC32_GETVERSION
260#define EXT4_IOC32_SETVERSION_OLD FS_IOC32_SETVERSION
261
262
263/*
264 * Mount options
265 */
266struct ext4_mount_options {
267 unsigned long s_mount_opt;
268 uid_t s_resuid;
269 gid_t s_resgid;
270 unsigned long s_commit_interval;
271#ifdef CONFIG_QUOTA
272 int s_jquota_fmt;
273 char *s_qf_names[MAXQUOTAS];
274#endif
275};
276
277/*
278 * Structure of an inode on the disk
279 */
280struct ext4_inode {
281 __le16 i_mode; /* File mode */
282 __le16 i_uid; /* Low 16 bits of Owner Uid */
283 __le32 i_size; /* Size in bytes */
284 __le32 i_atime; /* Access time */
285 __le32 i_ctime; /* Creation time */
286 __le32 i_mtime; /* Modification time */
287 __le32 i_dtime; /* Deletion Time */
288 __le16 i_gid; /* Low 16 bits of Group Id */
289 __le16 i_links_count; /* Links count */
290 __le32 i_blocks; /* Blocks count */
291 __le32 i_flags; /* File flags */
292 union {
293 struct {
294 __u32 l_i_reserved1;
295 } linux1;
296 struct {
297 __u32 h_i_translator;
298 } hurd1;
299 struct {
300 __u32 m_i_reserved1;
301 } masix1;
302 } osd1; /* OS dependent 1 */
303 __le32 i_block[EXT4_N_BLOCKS];/* Pointers to blocks */
304 __le32 i_generation; /* File version (for NFS) */
305 __le32 i_file_acl; /* File ACL */
306 __le32 i_dir_acl; /* Directory ACL */
307 __le32 i_faddr; /* Fragment address */
308 union {
309 struct {
310 __u8 l_i_frag; /* Fragment number */
311 __u8 l_i_fsize; /* Fragment size */
312 __le16 l_i_file_acl_high;
313 __le16 l_i_uid_high; /* these 2 fields */
314 __le16 l_i_gid_high; /* were reserved2[0] */
315 __u32 l_i_reserved2;
316 } linux2;
317 struct {
318 __u8 h_i_frag; /* Fragment number */
319 __u8 h_i_fsize; /* Fragment size */
320 __u16 h_i_mode_high;
321 __u16 h_i_uid_high;
322 __u16 h_i_gid_high;
323 __u32 h_i_author;
324 } hurd2;
325 struct {
326 __u8 m_i_frag; /* Fragment number */
327 __u8 m_i_fsize; /* Fragment size */
328 __le16 m_i_file_acl_high;
329 __u32 m_i_reserved2[2];
330 } masix2;
331 } osd2; /* OS dependent 2 */
332 __le16 i_extra_isize;
333 __le16 i_pad1;
334};
335
336#define i_size_high i_dir_acl
337
338#if defined(__KERNEL__) || defined(__linux__)
339#define i_reserved1 osd1.linux1.l_i_reserved1
340#define i_frag osd2.linux2.l_i_frag
341#define i_fsize osd2.linux2.l_i_fsize
342#define i_file_acl_high osd2.linux2.l_i_file_acl_high
343#define i_uid_low i_uid
344#define i_gid_low i_gid
345#define i_uid_high osd2.linux2.l_i_uid_high
346#define i_gid_high osd2.linux2.l_i_gid_high
347#define i_reserved2 osd2.linux2.l_i_reserved2
348
349#elif defined(__GNU__)
350
351#define i_translator osd1.hurd1.h_i_translator
352#define i_frag osd2.hurd2.h_i_frag;
353#define i_fsize osd2.hurd2.h_i_fsize;
354#define i_uid_high osd2.hurd2.h_i_uid_high
355#define i_gid_high osd2.hurd2.h_i_gid_high
356#define i_author osd2.hurd2.h_i_author
357
358#elif defined(__masix__)
359
360#define i_reserved1 osd1.masix1.m_i_reserved1
361#define i_frag osd2.masix2.m_i_frag
362#define i_fsize osd2.masix2.m_i_fsize
363#define i_file_acl_high osd2.masix2.m_i_file_acl_high
364#define i_reserved2 osd2.masix2.m_i_reserved2
365
366#endif /* defined(__KERNEL__) || defined(__linux__) */
367
368/*
369 * File system states
370 */
371#define EXT4_VALID_FS 0x0001 /* Unmounted cleanly */
372#define EXT4_ERROR_FS 0x0002 /* Errors detected */
373#define EXT4_ORPHAN_FS 0x0004 /* Orphans being recovered */
374
375/*
376 * Mount flags
377 */
378#define EXT4_MOUNT_CHECK 0x00001 /* Do mount-time checks */
379#define EXT4_MOUNT_OLDALLOC 0x00002 /* Don't use the new Orlov allocator */
380#define EXT4_MOUNT_GRPID 0x00004 /* Create files with directory's group */
381#define EXT4_MOUNT_DEBUG 0x00008 /* Some debugging messages */
382#define EXT4_MOUNT_ERRORS_CONT 0x00010 /* Continue on errors */
383#define EXT4_MOUNT_ERRORS_RO 0x00020 /* Remount fs ro on errors */
384#define EXT4_MOUNT_ERRORS_PANIC 0x00040 /* Panic on errors */
385#define EXT4_MOUNT_MINIX_DF 0x00080 /* Mimics the Minix statfs */
386#define EXT4_MOUNT_NOLOAD 0x00100 /* Don't use existing journal*/
387#define EXT4_MOUNT_ABORT 0x00200 /* Fatal error detected */
388#define EXT4_MOUNT_DATA_FLAGS 0x00C00 /* Mode for data writes: */
389#define EXT4_MOUNT_JOURNAL_DATA 0x00400 /* Write data to journal */
390#define EXT4_MOUNT_ORDERED_DATA 0x00800 /* Flush data before commit */
391#define EXT4_MOUNT_WRITEBACK_DATA 0x00C00 /* No data ordering */
392#define EXT4_MOUNT_UPDATE_JOURNAL 0x01000 /* Update the journal format */
393#define EXT4_MOUNT_NO_UID32 0x02000 /* Disable 32-bit UIDs */
394#define EXT4_MOUNT_XATTR_USER 0x04000 /* Extended user attributes */
395#define EXT4_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
396#define EXT4_MOUNT_RESERVATION 0x10000 /* Preallocation */
397#define EXT4_MOUNT_BARRIER 0x20000 /* Use block barriers */
398#define EXT4_MOUNT_NOBH 0x40000 /* No bufferheads */
399#define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
400#define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
401#define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
402#define EXT4_MOUNT_EXTENTS 0x400000 /* Extents support */
403
404/* Compatibility, for having both ext2_fs.h and ext4_fs.h included at once */
405#ifndef _LINUX_EXT2_FS_H
406#define clear_opt(o, opt) o &= ~EXT4_MOUNT_##opt
407#define set_opt(o, opt) o |= EXT4_MOUNT_##opt
408#define test_opt(sb, opt) (EXT4_SB(sb)->s_mount_opt & \
409 EXT4_MOUNT_##opt)
410#else
411#define EXT2_MOUNT_NOLOAD EXT4_MOUNT_NOLOAD
412#define EXT2_MOUNT_ABORT EXT4_MOUNT_ABORT
413#define EXT2_MOUNT_DATA_FLAGS EXT4_MOUNT_DATA_FLAGS
414#endif
415
416#define ext4_set_bit ext2_set_bit
417#define ext4_set_bit_atomic ext2_set_bit_atomic
418#define ext4_clear_bit ext2_clear_bit
419#define ext4_clear_bit_atomic ext2_clear_bit_atomic
420#define ext4_test_bit ext2_test_bit
421#define ext4_find_first_zero_bit ext2_find_first_zero_bit
422#define ext4_find_next_zero_bit ext2_find_next_zero_bit
423
424/*
425 * Maximal mount counts between two filesystem checks
426 */
427#define EXT4_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
428#define EXT4_DFL_CHECKINTERVAL 0 /* Don't use interval check */
429
430/*
431 * Behaviour when detecting errors
432 */
433#define EXT4_ERRORS_CONTINUE 1 /* Continue execution */
434#define EXT4_ERRORS_RO 2 /* Remount fs read-only */
435#define EXT4_ERRORS_PANIC 3 /* Panic */
436#define EXT4_ERRORS_DEFAULT EXT4_ERRORS_CONTINUE
437
438/*
439 * Structure of the super block
440 */
441struct ext4_super_block {
442/*00*/ __le32 s_inodes_count; /* Inodes count */
443 __le32 s_blocks_count; /* Blocks count */
444 __le32 s_r_blocks_count; /* Reserved blocks count */
445 __le32 s_free_blocks_count; /* Free blocks count */
446/*10*/ __le32 s_free_inodes_count; /* Free inodes count */
447 __le32 s_first_data_block; /* First Data Block */
448 __le32 s_log_block_size; /* Block size */
449 __le32 s_log_frag_size; /* Fragment size */
450/*20*/ __le32 s_blocks_per_group; /* # Blocks per group */
451 __le32 s_frags_per_group; /* # Fragments per group */
452 __le32 s_inodes_per_group; /* # Inodes per group */
453 __le32 s_mtime; /* Mount time */
454/*30*/ __le32 s_wtime; /* Write time */
455 __le16 s_mnt_count; /* Mount count */
456 __le16 s_max_mnt_count; /* Maximal mount count */
457 __le16 s_magic; /* Magic signature */
458 __le16 s_state; /* File system state */
459 __le16 s_errors; /* Behaviour when detecting errors */
460 __le16 s_minor_rev_level; /* minor revision level */
461/*40*/ __le32 s_lastcheck; /* time of last check */
462 __le32 s_checkinterval; /* max. time between checks */
463 __le32 s_creator_os; /* OS */
464 __le32 s_rev_level; /* Revision level */
465/*50*/ __le16 s_def_resuid; /* Default uid for reserved blocks */
466 __le16 s_def_resgid; /* Default gid for reserved blocks */
467 /*
468 * These fields are for EXT4_DYNAMIC_REV superblocks only.
469 *
470 * Note: the difference between the compatible feature set and
471 * the incompatible feature set is that if there is a bit set
472 * in the incompatible feature set that the kernel doesn't
473 * know about, it should refuse to mount the filesystem.
474 *
475 * e2fsck's requirements are more strict; if it doesn't know
476 * about a feature in either the compatible or incompatible
477 * feature set, it must abort and not try to meddle with
478 * things it doesn't understand...
479 */
480 __le32 s_first_ino; /* First non-reserved inode */
481 __le16 s_inode_size; /* size of inode structure */
482 __le16 s_block_group_nr; /* block group # of this superblock */
483 __le32 s_feature_compat; /* compatible feature set */
484/*60*/ __le32 s_feature_incompat; /* incompatible feature set */
485 __le32 s_feature_ro_compat; /* readonly-compatible feature set */
486/*68*/ __u8 s_uuid[16]; /* 128-bit uuid for volume */
487/*78*/ char s_volume_name[16]; /* volume name */
488/*88*/ char s_last_mounted[64]; /* directory where last mounted */
489/*C8*/ __le32 s_algorithm_usage_bitmap; /* For compression */
490 /*
491 * Performance hints. Directory preallocation should only
492 * happen if the EXT4_FEATURE_COMPAT_DIR_PREALLOC flag is on.
493 */
494 __u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
495 __u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
496 __le16 s_reserved_gdt_blocks; /* Per group desc for online growth */
497 /*
498 * Journaling support valid if EXT4_FEATURE_COMPAT_HAS_JOURNAL set.
499 */
500/*D0*/ __u8 s_journal_uuid[16]; /* uuid of journal superblock */
501/*E0*/ __le32 s_journal_inum; /* inode number of journal file */
502 __le32 s_journal_dev; /* device number of journal file */
503 __le32 s_last_orphan; /* start of list of inodes to delete */
504 __le32 s_hash_seed[4]; /* HTREE hash seed */
505 __u8 s_def_hash_version; /* Default hash version to use */
506 __u8 s_reserved_char_pad;
507 __le16 s_desc_size; /* size of group descriptor */
508/*100*/ __le32 s_default_mount_opts;
509 __le32 s_first_meta_bg; /* First metablock block group */
510 __le32 s_mkfs_time; /* When the filesystem was created */
511 __le32 s_jnl_blocks[17]; /* Backup of the journal inode */
512 /* 64bit support valid if EXT4_FEATURE_COMPAT_64BIT */
513/*150*/ __le32 s_blocks_count_hi; /* Blocks count */
514 __le32 s_r_blocks_count_hi; /* Reserved blocks count */
515 __le32 s_free_blocks_count_hi; /* Free blocks count */
516 __u32 s_reserved[169]; /* Padding to the end of the block */
517};
518
519#ifdef __KERNEL__
520static inline struct ext4_sb_info * EXT4_SB(struct super_block *sb)
521{
522 return sb->s_fs_info;
523}
524static inline struct ext4_inode_info *EXT4_I(struct inode *inode)
525{
526 return container_of(inode, struct ext4_inode_info, vfs_inode);
527}
528
529static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino)
530{
531 return ino == EXT4_ROOT_INO ||
532 ino == EXT4_JOURNAL_INO ||
533 ino == EXT4_RESIZE_INO ||
534 (ino >= EXT4_FIRST_INO(sb) &&
535 ino <= le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count));
536}
537#else
538/* Assume that user mode programs are passing in an ext4fs superblock, not
539 * a kernel struct super_block. This will allow us to call the feature-test
540 * macros from user land. */
541#define EXT4_SB(sb) (sb)
542#endif
543
544#define NEXT_ORPHAN(inode) EXT4_I(inode)->i_dtime
545
546/*
547 * Codes for operating systems
548 */
549#define EXT4_OS_LINUX 0
550#define EXT4_OS_HURD 1
551#define EXT4_OS_MASIX 2
552#define EXT4_OS_FREEBSD 3
553#define EXT4_OS_LITES 4
554
555/*
556 * Revision levels
557 */
558#define EXT4_GOOD_OLD_REV 0 /* The good old (original) format */
559#define EXT4_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
560
561#define EXT4_CURRENT_REV EXT4_GOOD_OLD_REV
562#define EXT4_MAX_SUPP_REV EXT4_DYNAMIC_REV
563
564#define EXT4_GOOD_OLD_INODE_SIZE 128
565
566/*
567 * Feature set definitions
568 */
569
570#define EXT4_HAS_COMPAT_FEATURE(sb,mask) \
571 ( EXT4_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask) )
572#define EXT4_HAS_RO_COMPAT_FEATURE(sb,mask) \
573 ( EXT4_SB(sb)->s_es->s_feature_ro_compat & cpu_to_le32(mask) )
574#define EXT4_HAS_INCOMPAT_FEATURE(sb,mask) \
575 ( EXT4_SB(sb)->s_es->s_feature_incompat & cpu_to_le32(mask) )
576#define EXT4_SET_COMPAT_FEATURE(sb,mask) \
577 EXT4_SB(sb)->s_es->s_feature_compat |= cpu_to_le32(mask)
578#define EXT4_SET_RO_COMPAT_FEATURE(sb,mask) \
579 EXT4_SB(sb)->s_es->s_feature_ro_compat |= cpu_to_le32(mask)
580#define EXT4_SET_INCOMPAT_FEATURE(sb,mask) \
581 EXT4_SB(sb)->s_es->s_feature_incompat |= cpu_to_le32(mask)
582#define EXT4_CLEAR_COMPAT_FEATURE(sb,mask) \
583 EXT4_SB(sb)->s_es->s_feature_compat &= ~cpu_to_le32(mask)
584#define EXT4_CLEAR_RO_COMPAT_FEATURE(sb,mask) \
585 EXT4_SB(sb)->s_es->s_feature_ro_compat &= ~cpu_to_le32(mask)
586#define EXT4_CLEAR_INCOMPAT_FEATURE(sb,mask) \
587 EXT4_SB(sb)->s_es->s_feature_incompat &= ~cpu_to_le32(mask)
588
589#define EXT4_FEATURE_COMPAT_DIR_PREALLOC 0x0001
590#define EXT4_FEATURE_COMPAT_IMAGIC_INODES 0x0002
591#define EXT4_FEATURE_COMPAT_HAS_JOURNAL 0x0004
592#define EXT4_FEATURE_COMPAT_EXT_ATTR 0x0008
593#define EXT4_FEATURE_COMPAT_RESIZE_INODE 0x0010
594#define EXT4_FEATURE_COMPAT_DIR_INDEX 0x0020
595
596#define EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
597#define EXT4_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
598#define EXT4_FEATURE_RO_COMPAT_BTREE_DIR 0x0004
599
600#define EXT4_FEATURE_INCOMPAT_COMPRESSION 0x0001
601#define EXT4_FEATURE_INCOMPAT_FILETYPE 0x0002
602#define EXT4_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */
603#define EXT4_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */
604#define EXT4_FEATURE_INCOMPAT_META_BG 0x0010
605#define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040 /* extents support */
606#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
607
608#define EXT4_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR
609#define EXT4_FEATURE_INCOMPAT_SUPP (EXT4_FEATURE_INCOMPAT_FILETYPE| \
610 EXT4_FEATURE_INCOMPAT_RECOVER| \
611 EXT4_FEATURE_INCOMPAT_META_BG| \
612 EXT4_FEATURE_INCOMPAT_EXTENTS| \
613 EXT4_FEATURE_INCOMPAT_64BIT)
614#define EXT4_FEATURE_RO_COMPAT_SUPP (EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER| \
615 EXT4_FEATURE_RO_COMPAT_LARGE_FILE| \
616 EXT4_FEATURE_RO_COMPAT_BTREE_DIR)
617
618/*
619 * Default values for user and/or group using reserved blocks
620 */
621#define EXT4_DEF_RESUID 0
622#define EXT4_DEF_RESGID 0
623
624/*
625 * Default mount options
626 */
627#define EXT4_DEFM_DEBUG 0x0001
628#define EXT4_DEFM_BSDGROUPS 0x0002
629#define EXT4_DEFM_XATTR_USER 0x0004
630#define EXT4_DEFM_ACL 0x0008
631#define EXT4_DEFM_UID16 0x0010
632#define EXT4_DEFM_JMODE 0x0060
633#define EXT4_DEFM_JMODE_DATA 0x0020
634#define EXT4_DEFM_JMODE_ORDERED 0x0040
635#define EXT4_DEFM_JMODE_WBACK 0x0060
636
637/*
638 * Structure of a directory entry
639 */
640#define EXT4_NAME_LEN 255
641
642struct ext4_dir_entry {
643 __le32 inode; /* Inode number */
644 __le16 rec_len; /* Directory entry length */
645 __le16 name_len; /* Name length */
646 char name[EXT4_NAME_LEN]; /* File name */
647};
648
649/*
650 * The new version of the directory entry. Since EXT4 structures are
651 * stored in intel byte order, and the name_len field could never be
652 * bigger than 255 chars, it's safe to reclaim the extra byte for the
653 * file_type field.
654 */
655struct ext4_dir_entry_2 {
656 __le32 inode; /* Inode number */
657 __le16 rec_len; /* Directory entry length */
658 __u8 name_len; /* Name length */
659 __u8 file_type;
660 char name[EXT4_NAME_LEN]; /* File name */
661};
662
663/*
664 * Ext4 directory file types. Only the low 3 bits are used. The
665 * other bits are reserved for now.
666 */
667#define EXT4_FT_UNKNOWN 0
668#define EXT4_FT_REG_FILE 1
669#define EXT4_FT_DIR 2
670#define EXT4_FT_CHRDEV 3
671#define EXT4_FT_BLKDEV 4
672#define EXT4_FT_FIFO 5
673#define EXT4_FT_SOCK 6
674#define EXT4_FT_SYMLINK 7
675
676#define EXT4_FT_MAX 8
677
678/*
679 * EXT4_DIR_PAD defines the directory entries boundaries
680 *
681 * NOTE: It must be a multiple of 4
682 */
683#define EXT4_DIR_PAD 4
684#define EXT4_DIR_ROUND (EXT4_DIR_PAD - 1)
685#define EXT4_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT4_DIR_ROUND) & \
686 ~EXT4_DIR_ROUND)
687/*
688 * Hash Tree Directory indexing
689 * (c) Daniel Phillips, 2001
690 */
691
692#ifdef CONFIG_EXT4_INDEX
693 #define is_dx(dir) (EXT4_HAS_COMPAT_FEATURE(dir->i_sb, \
694 EXT4_FEATURE_COMPAT_DIR_INDEX) && \
695 (EXT4_I(dir)->i_flags & EXT4_INDEX_FL))
696#define EXT4_DIR_LINK_MAX(dir) (!is_dx(dir) && (dir)->i_nlink >= EXT4_LINK_MAX)
697#define EXT4_DIR_LINK_EMPTY(dir) ((dir)->i_nlink == 2 || (dir)->i_nlink == 1)
698#else
699 #define is_dx(dir) 0
700#define EXT4_DIR_LINK_MAX(dir) ((dir)->i_nlink >= EXT4_LINK_MAX)
701#define EXT4_DIR_LINK_EMPTY(dir) ((dir)->i_nlink == 2)
702#endif
703
704/* Legal values for the dx_root hash_version field: */
705
706#define DX_HASH_LEGACY 0
707#define DX_HASH_HALF_MD4 1
708#define DX_HASH_TEA 2
709
710#ifdef __KERNEL__
711
712/* hash info structure used by the directory hash */
713struct dx_hash_info
714{
715 u32 hash;
716 u32 minor_hash;
717 int hash_version;
718 u32 *seed;
719};
720
721#define EXT4_HTREE_EOF 0x7fffffff
722
723/*
724 * Control parameters used by ext4_htree_next_block
725 */
726#define HASH_NB_ALWAYS 1
727
728
729/*
730 * Describe an inode's exact location on disk and in memory
731 */
732struct ext4_iloc
733{
734 struct buffer_head *bh;
735 unsigned long offset;
736 unsigned long block_group;
737};
738
739static inline struct ext4_inode *ext4_raw_inode(struct ext4_iloc *iloc)
740{
741 return (struct ext4_inode *) (iloc->bh->b_data + iloc->offset);
742}
743
744/*
745 * This structure is stuffed into the struct file's private_data field
746 * for directories. It is where we put information so that we can do
747 * readdir operations in hash tree order.
748 */
749struct dir_private_info {
750 struct rb_root root;
751 struct rb_node *curr_node;
752 struct fname *extra_fname;
753 loff_t last_pos;
754 __u32 curr_hash;
755 __u32 curr_minor_hash;
756 __u32 next_hash;
757};
758
759/* calculate the first block number of the group */
760static inline ext4_fsblk_t
761ext4_group_first_block_no(struct super_block *sb, unsigned long group_no)
762{
763 return group_no * (ext4_fsblk_t)EXT4_BLOCKS_PER_GROUP(sb) +
764 le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block);
765}
766
767/*
768 * Special error return code only used by dx_probe() and its callers.
769 */
770#define ERR_BAD_DX_DIR -75000
771
772void ext4_get_group_no_and_offset(struct super_block *sb, ext4_fsblk_t blocknr,
773 unsigned long *blockgrpp, ext4_grpblk_t *offsetp);
774
775/*
776 * Function prototypes
777 */
778
779/*
780 * Ok, these declarations are also in <linux/kernel.h> but none of the
781 * ext4 source programs needs to include it so they are duplicated here.
782 */
783# define NORET_TYPE /**/
784# define ATTRIB_NORET __attribute__((noreturn))
785# define NORET_AND noreturn,
786
787/* balloc.c */
788extern unsigned int ext4_block_group(struct super_block *sb,
789 ext4_fsblk_t blocknr);
790extern ext4_grpblk_t ext4_block_group_offset(struct super_block *sb,
791 ext4_fsblk_t blocknr);
792extern int ext4_bg_has_super(struct super_block *sb, int group);
793extern unsigned long ext4_bg_num_gdb(struct super_block *sb, int group);
794extern ext4_fsblk_t ext4_new_block (handle_t *handle, struct inode *inode,
795 ext4_fsblk_t goal, int *errp);
796extern ext4_fsblk_t ext4_new_blocks (handle_t *handle, struct inode *inode,
797 ext4_fsblk_t goal, unsigned long *count, int *errp);
798extern void ext4_free_blocks (handle_t *handle, struct inode *inode,
799 ext4_fsblk_t block, unsigned long count);
800extern void ext4_free_blocks_sb (handle_t *handle, struct super_block *sb,
801 ext4_fsblk_t block, unsigned long count,
802 unsigned long *pdquot_freed_blocks);
803extern ext4_fsblk_t ext4_count_free_blocks (struct super_block *);
804extern void ext4_check_blocks_bitmap (struct super_block *);
805extern struct ext4_group_desc * ext4_get_group_desc(struct super_block * sb,
806 unsigned int block_group,
807 struct buffer_head ** bh);
808extern int ext4_should_retry_alloc(struct super_block *sb, int *retries);
809extern void ext4_init_block_alloc_info(struct inode *);
810extern void ext4_rsv_window_add(struct super_block *sb, struct ext4_reserve_window_node *rsv);
811
812/* dir.c */
813extern int ext4_check_dir_entry(const char *, struct inode *,
814 struct ext4_dir_entry_2 *,
815 struct buffer_head *, unsigned long);
816extern int ext4_htree_store_dirent(struct file *dir_file, __u32 hash,
817 __u32 minor_hash,
818 struct ext4_dir_entry_2 *dirent);
819extern void ext4_htree_free_dir_info(struct dir_private_info *p);
820
821/* fsync.c */
822extern int ext4_sync_file (struct file *, struct dentry *, int);
823
824/* hash.c */
825extern int ext4fs_dirhash(const char *name, int len, struct
826 dx_hash_info *hinfo);
827
828/* ialloc.c */
829extern struct inode * ext4_new_inode (handle_t *, struct inode *, int);
830extern void ext4_free_inode (handle_t *, struct inode *);
831extern struct inode * ext4_orphan_get (struct super_block *, unsigned long);
832extern unsigned long ext4_count_free_inodes (struct super_block *);
833extern unsigned long ext4_count_dirs (struct super_block *);
834extern void ext4_check_inodes_bitmap (struct super_block *);
835extern unsigned long ext4_count_free (struct buffer_head *, unsigned);
836
837
838/* inode.c */
839int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode,
840 struct buffer_head *bh, ext4_fsblk_t blocknr);
841struct buffer_head * ext4_getblk (handle_t *, struct inode *, long, int, int *);
842struct buffer_head * ext4_bread (handle_t *, struct inode *, int, int, int *);
843int ext4_get_blocks_handle(handle_t *handle, struct inode *inode,
844 sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
845 int create, int extend_disksize);
846
847extern void ext4_read_inode (struct inode *);
848extern int ext4_write_inode (struct inode *, int);
849extern int ext4_setattr (struct dentry *, struct iattr *);
850extern void ext4_delete_inode (struct inode *);
851extern int ext4_sync_inode (handle_t *, struct inode *);
852extern void ext4_discard_reservation (struct inode *);
853extern void ext4_dirty_inode(struct inode *);
854extern int ext4_change_inode_journal_flag(struct inode *, int);
855extern int ext4_get_inode_loc(struct inode *, struct ext4_iloc *);
856extern void ext4_truncate (struct inode *);
857extern void ext4_set_inode_flags(struct inode *);
858extern void ext4_set_aops(struct inode *inode);
859extern int ext4_writepage_trans_blocks(struct inode *);
860extern int ext4_block_truncate_page(handle_t *handle, struct page *page,
861 struct address_space *mapping, loff_t from);
862
863/* ioctl.c */
864extern int ext4_ioctl (struct inode *, struct file *, unsigned int,
865 unsigned long);
866extern long ext4_compat_ioctl (struct file *, unsigned int, unsigned long);
867
868/* namei.c */
869extern int ext4_orphan_add(handle_t *, struct inode *);
870extern int ext4_orphan_del(handle_t *, struct inode *);
871extern int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash,
872 __u32 start_minor_hash, __u32 *next_hash);
873
874/* resize.c */
875extern int ext4_group_add(struct super_block *sb,
876 struct ext4_new_group_data *input);
877extern int ext4_group_extend(struct super_block *sb,
878 struct ext4_super_block *es,
879 ext4_fsblk_t n_blocks_count);
880
881/* super.c */
882extern void ext4_error (struct super_block *, const char *, const char *, ...)
883 __attribute__ ((format (printf, 3, 4)));
884extern void __ext4_std_error (struct super_block *, const char *, int);
885extern void ext4_abort (struct super_block *, const char *, const char *, ...)
886 __attribute__ ((format (printf, 3, 4)));
887extern void ext4_warning (struct super_block *, const char *, const char *, ...)
888 __attribute__ ((format (printf, 3, 4)));
889extern void ext4_update_dynamic_rev (struct super_block *sb);
890extern ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,
891 struct ext4_group_desc *bg);
892extern ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb,
893 struct ext4_group_desc *bg);
894extern ext4_fsblk_t ext4_inode_table(struct super_block *sb,
895 struct ext4_group_desc *bg);
896extern void ext4_block_bitmap_set(struct super_block *sb,
897 struct ext4_group_desc *bg, ext4_fsblk_t blk);
898extern void ext4_inode_bitmap_set(struct super_block *sb,
899 struct ext4_group_desc *bg, ext4_fsblk_t blk);
900extern void ext4_inode_table_set(struct super_block *sb,
901 struct ext4_group_desc *bg, ext4_fsblk_t blk);
902
903static inline ext4_fsblk_t ext4_blocks_count(struct ext4_super_block *es)
904{
905 return ((ext4_fsblk_t)le32_to_cpu(es->s_blocks_count_hi) << 32) |
906 le32_to_cpu(es->s_blocks_count);
907}
908
909static inline ext4_fsblk_t ext4_r_blocks_count(struct ext4_super_block *es)
910{
911 return ((ext4_fsblk_t)le32_to_cpu(es->s_r_blocks_count_hi) << 32) |
912 le32_to_cpu(es->s_r_blocks_count);
913}
914
915static inline ext4_fsblk_t ext4_free_blocks_count(struct ext4_super_block *es)
916{
917 return ((ext4_fsblk_t)le32_to_cpu(es->s_free_blocks_count_hi) << 32) |
918 le32_to_cpu(es->s_free_blocks_count);
919}
920
921static inline void ext4_blocks_count_set(struct ext4_super_block *es,
922 ext4_fsblk_t blk)
923{
924 es->s_blocks_count = cpu_to_le32((u32)blk);
925 es->s_blocks_count_hi = cpu_to_le32(blk >> 32);
926}
927
928static inline void ext4_free_blocks_count_set(struct ext4_super_block *es,
929 ext4_fsblk_t blk)
930{
931 es->s_free_blocks_count = cpu_to_le32((u32)blk);
932 es->s_free_blocks_count_hi = cpu_to_le32(blk >> 32);
933}
934
935static inline void ext4_r_blocks_count_set(struct ext4_super_block *es,
936 ext4_fsblk_t blk)
937{
938 es->s_r_blocks_count = cpu_to_le32((u32)blk);
939 es->s_r_blocks_count_hi = cpu_to_le32(blk >> 32);
940}
941
942
943
944#define ext4_std_error(sb, errno) \
945do { \
946 if ((errno)) \
947 __ext4_std_error((sb), __FUNCTION__, (errno)); \
948} while (0)
949
950/*
951 * Inodes and files operations
952 */
953
954/* dir.c */
955extern const struct file_operations ext4_dir_operations;
956
957/* file.c */
958extern struct inode_operations ext4_file_inode_operations;
959extern const struct file_operations ext4_file_operations;
960
961/* namei.c */
962extern struct inode_operations ext4_dir_inode_operations;
963extern struct inode_operations ext4_special_inode_operations;
964
965/* symlink.c */
966extern struct inode_operations ext4_symlink_inode_operations;
967extern struct inode_operations ext4_fast_symlink_inode_operations;
968
969/* extents.c */
970extern int ext4_ext_tree_init(handle_t *handle, struct inode *);
971extern int ext4_ext_writepage_trans_blocks(struct inode *, int);
972extern int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
973 ext4_fsblk_t iblock,
974 unsigned long max_blocks, struct buffer_head *bh_result,
975 int create, int extend_disksize);
976extern void ext4_ext_truncate(struct inode *, struct page *);
977extern void ext4_ext_init(struct super_block *);
978extern void ext4_ext_release(struct super_block *);
979static inline int
980ext4_get_blocks_wrap(handle_t *handle, struct inode *inode, sector_t block,
981 unsigned long max_blocks, struct buffer_head *bh,
982 int create, int extend_disksize)
983{
984 if (EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)
985 return ext4_ext_get_blocks(handle, inode, block, max_blocks,
986 bh, create, extend_disksize);
987 return ext4_get_blocks_handle(handle, inode, block, max_blocks, bh,
988 create, extend_disksize);
989}
990
991
992#endif /* __KERNEL__ */
993
994#endif /* _LINUX_EXT4_FS_H */
diff --git a/include/linux/ext4_fs_extents.h b/include/linux/ext4_fs_extents.h
new file mode 100644
index 000000000000..a41cc24568ca
--- /dev/null
+++ b/include/linux/ext4_fs_extents.h
@@ -0,0 +1,198 @@
1/*
2 * Copyright (c) 2003-2006, Cluster File Systems, Inc, info@clusterfs.com
3 * Written by Alex Tomas <alex@clusterfs.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public Licens
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-
17 */
18
19#ifndef _LINUX_EXT4_EXTENTS
20#define _LINUX_EXT4_EXTENTS
21
22#include <linux/ext4_fs.h>
23
24/*
25 * With AGRESSIVE_TEST defined, the capacity of index/leaf blocks
26 * becomes very small, so index split, in-depth growing and
27 * other hard changes happen much more often.
28 * This is for debug purposes only.
29 */
30#define AGRESSIVE_TEST_
31
32/*
33 * With EXTENTS_STATS defined, the number of blocks and extents
34 * are collected in the truncate path. They'll be shown at
35 * umount time.
36 */
37#define EXTENTS_STATS__
38
39/*
40 * If CHECK_BINSEARCH is defined, then the results of the binary search
41 * will also be checked by linear search.
42 */
43#define CHECK_BINSEARCH__
44
45/*
46 * If EXT_DEBUG is defined you can use the 'extdebug' mount option
47 * to get lots of info about what's going on.
48 */
49#define EXT_DEBUG__
50#ifdef EXT_DEBUG
51#define ext_debug(a...) printk(a)
52#else
53#define ext_debug(a...)
54#endif
55
56/*
57 * If EXT_STATS is defined then stats numbers are collected.
58 * These number will be displayed at umount time.
59 */
60#define EXT_STATS_
61
62
63/*
64 * ext4_inode has i_block array (60 bytes total).
65 * The first 12 bytes store ext4_extent_header;
66 * the remainder stores an array of ext4_extent.
67 */
68
69/*
70 * This is the extent on-disk structure.
71 * It's used at the bottom of the tree.
72 */
73struct ext4_extent {
74 __le32 ee_block; /* first logical block extent covers */
75 __le16 ee_len; /* number of blocks covered by extent */
76 __le16 ee_start_hi; /* high 16 bits of physical block */
77 __le32 ee_start; /* low 32 bits of physical block */
78};
79
80/*
81 * This is index on-disk structure.
82 * It's used at all the levels except the bottom.
83 */
84struct ext4_extent_idx {
85 __le32 ei_block; /* index covers logical blocks from 'block' */
86 __le32 ei_leaf; /* pointer to the physical block of the next *
87 * level. leaf or next index could be there */
88 __le16 ei_leaf_hi; /* high 16 bits of physical block */
89 __u16 ei_unused;
90};
91
92/*
93 * Each block (leaves and indexes), even inode-stored has header.
94 */
95struct ext4_extent_header {
96 __le16 eh_magic; /* probably will support different formats */
97 __le16 eh_entries; /* number of valid entries */
98 __le16 eh_max; /* capacity of store in entries */
99 __le16 eh_depth; /* has tree real underlying blocks? */
100 __le32 eh_generation; /* generation of the tree */
101};
102
103#define EXT4_EXT_MAGIC cpu_to_le16(0xf30a)
104
105/*
106 * Array of ext4_ext_path contains path to some extent.
107 * Creation/lookup routines use it for traversal/splitting/etc.
108 * Truncate uses it to simulate recursive walking.
109 */
110struct ext4_ext_path {
111 ext4_fsblk_t p_block;
112 __u16 p_depth;
113 struct ext4_extent *p_ext;
114 struct ext4_extent_idx *p_idx;
115 struct ext4_extent_header *p_hdr;
116 struct buffer_head *p_bh;
117};
118
119/*
120 * structure for external API
121 */
122
123#define EXT4_EXT_CACHE_NO 0
124#define EXT4_EXT_CACHE_GAP 1
125#define EXT4_EXT_CACHE_EXTENT 2
126
127/*
128 * to be called by ext4_ext_walk_space()
129 * negative retcode - error
130 * positive retcode - signal for ext4_ext_walk_space(), see below
131 * callback must return valid extent (passed or newly created)
132 */
133typedef int (*ext_prepare_callback)(struct inode *, struct ext4_ext_path *,
134 struct ext4_ext_cache *,
135 void *);
136
137#define EXT_CONTINUE 0
138#define EXT_BREAK 1
139#define EXT_REPEAT 2
140
141
142#define EXT_MAX_BLOCK 0xffffffff
143
144#define EXT_MAX_LEN ((1UL << 15) - 1)
145
146
147#define EXT_FIRST_EXTENT(__hdr__) \
148 ((struct ext4_extent *) (((char *) (__hdr__)) + \
149 sizeof(struct ext4_extent_header)))
150#define EXT_FIRST_INDEX(__hdr__) \
151 ((struct ext4_extent_idx *) (((char *) (__hdr__)) + \
152 sizeof(struct ext4_extent_header)))
153#define EXT_HAS_FREE_INDEX(__path__) \
154 (le16_to_cpu((__path__)->p_hdr->eh_entries) \
155 < le16_to_cpu((__path__)->p_hdr->eh_max))
156#define EXT_LAST_EXTENT(__hdr__) \
157 (EXT_FIRST_EXTENT((__hdr__)) + le16_to_cpu((__hdr__)->eh_entries) - 1)
158#define EXT_LAST_INDEX(__hdr__) \
159 (EXT_FIRST_INDEX((__hdr__)) + le16_to_cpu((__hdr__)->eh_entries) - 1)
160#define EXT_MAX_EXTENT(__hdr__) \
161 (EXT_FIRST_EXTENT((__hdr__)) + le16_to_cpu((__hdr__)->eh_max) - 1)
162#define EXT_MAX_INDEX(__hdr__) \
163 (EXT_FIRST_INDEX((__hdr__)) + le16_to_cpu((__hdr__)->eh_max) - 1)
164
165static inline struct ext4_extent_header *ext_inode_hdr(struct inode *inode)
166{
167 return (struct ext4_extent_header *) EXT4_I(inode)->i_data;
168}
169
170static inline struct ext4_extent_header *ext_block_hdr(struct buffer_head *bh)
171{
172 return (struct ext4_extent_header *) bh->b_data;
173}
174
175static inline unsigned short ext_depth(struct inode *inode)
176{
177 return le16_to_cpu(ext_inode_hdr(inode)->eh_depth);
178}
179
180static inline void ext4_ext_tree_changed(struct inode *inode)
181{
182 EXT4_I(inode)->i_ext_generation++;
183}
184
185static inline void
186ext4_ext_invalidate_cache(struct inode *inode)
187{
188 EXT4_I(inode)->i_cached_extent.ec_type = EXT4_EXT_CACHE_NO;
189}
190
191extern int ext4_extent_tree_init(handle_t *, struct inode *);
192extern int ext4_ext_calc_credits_for_insert(struct inode *, struct ext4_ext_path *);
193extern int ext4_ext_insert_extent(handle_t *, struct inode *, struct ext4_ext_path *, struct ext4_extent *);
194extern int ext4_ext_walk_space(struct inode *, unsigned long, unsigned long, ext_prepare_callback, void *);
195extern struct ext4_ext_path * ext4_ext_find_extent(struct inode *, int, struct ext4_ext_path *);
196
197#endif /* _LINUX_EXT4_EXTENTS */
198
diff --git a/include/linux/ext4_fs_i.h b/include/linux/ext4_fs_i.h
new file mode 100644
index 000000000000..bb42379cb7fd
--- /dev/null
+++ b/include/linux/ext4_fs_i.h
@@ -0,0 +1,158 @@
1/*
2 * linux/include/linux/ext4_fs_i.h
3 *
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 *
9 * from
10 *
11 * linux/include/linux/minix_fs_i.h
12 *
13 * Copyright (C) 1991, 1992 Linus Torvalds
14 */
15
16#ifndef _LINUX_EXT4_FS_I
17#define _LINUX_EXT4_FS_I
18
19#include <linux/rwsem.h>
20#include <linux/rbtree.h>
21#include <linux/seqlock.h>
22#include <linux/mutex.h>
23
24/* data type for block offset of block group */
25typedef int ext4_grpblk_t;
26
27/* data type for filesystem-wide blocks number */
28typedef unsigned long long ext4_fsblk_t;
29
30struct ext4_reserve_window {
31 ext4_fsblk_t _rsv_start; /* First byte reserved */
32 ext4_fsblk_t _rsv_end; /* Last byte reserved or 0 */
33};
34
35struct ext4_reserve_window_node {
36 struct rb_node rsv_node;
37 __u32 rsv_goal_size;
38 __u32 rsv_alloc_hit;
39 struct ext4_reserve_window rsv_window;
40};
41
42struct ext4_block_alloc_info {
43 /* information about reservation window */
44 struct ext4_reserve_window_node rsv_window_node;
45 /*
46 * was i_next_alloc_block in ext4_inode_info
47 * is the logical (file-relative) number of the
48 * most-recently-allocated block in this file.
49 * We use this for detecting linearly ascending allocation requests.
50 */
51 __u32 last_alloc_logical_block;
52 /*
53 * Was i_next_alloc_goal in ext4_inode_info
54 * is the *physical* companion to i_next_alloc_block.
55 * it the the physical block number of the block which was most-recentl
56 * allocated to this file. This give us the goal (target) for the next
57 * allocation when we detect linearly ascending requests.
58 */
59 ext4_fsblk_t last_alloc_physical_block;
60};
61
62#define rsv_start rsv_window._rsv_start
63#define rsv_end rsv_window._rsv_end
64
65/*
66 * storage for cached extent
67 */
68struct ext4_ext_cache {
69 ext4_fsblk_t ec_start;
70 __u32 ec_block;
71 __u32 ec_len; /* must be 32bit to return holes */
72 __u32 ec_type;
73};
74
75/*
76 * third extended file system inode data in memory
77 */
78struct ext4_inode_info {
79 __le32 i_data[15]; /* unconverted */
80 __u32 i_flags;
81#ifdef EXT4_FRAGMENTS
82 __u32 i_faddr;
83 __u8 i_frag_no;
84 __u8 i_frag_size;
85#endif
86 ext4_fsblk_t i_file_acl;
87 __u32 i_dir_acl;
88 __u32 i_dtime;
89
90 /*
91 * i_block_group is the number of the block group which contains
92 * this file's inode. Constant across the lifetime of the inode,
93 * it is ued for making block allocation decisions - we try to
94 * place a file's data blocks near its inode block, and new inodes
95 * near to their parent directory's inode.
96 */
97 __u32 i_block_group;
98 __u32 i_state; /* Dynamic state flags for ext4 */
99
100 /* block reservation info */
101 struct ext4_block_alloc_info *i_block_alloc_info;
102
103 __u32 i_dir_start_lookup;
104#ifdef CONFIG_EXT4DEV_FS_XATTR
105 /*
106 * Extended attributes can be read independently of the main file
107 * data. Taking i_mutex even when reading would cause contention
108 * between readers of EAs and writers of regular file data, so
109 * instead we synchronize on xattr_sem when reading or changing
110 * EAs.
111 */
112 struct rw_semaphore xattr_sem;
113#endif
114#ifdef CONFIG_EXT4DEV_FS_POSIX_ACL
115 struct posix_acl *i_acl;
116 struct posix_acl *i_default_acl;
117#endif
118
119 struct list_head i_orphan; /* unlinked but open inodes */
120
121 /*
122 * i_disksize keeps track of what the inode size is ON DISK, not
123 * in memory. During truncate, i_size is set to the new size by
124 * the VFS prior to calling ext4_truncate(), but the filesystem won't
125 * set i_disksize to 0 until the truncate is actually under way.
126 *
127 * The intent is that i_disksize always represents the blocks which
128 * are used by this file. This allows recovery to restart truncate
129 * on orphans if we crash during truncate. We actually write i_disksize
130 * into the on-disk inode when writing inodes out, instead of i_size.
131 *
132 * The only time when i_disksize and i_size may be different is when
133 * a truncate is in progress. The only things which change i_disksize
134 * are ext4_get_block (growth) and ext4_truncate (shrinkth).
135 */
136 loff_t i_disksize;
137
138 /* on-disk additional length */
139 __u16 i_extra_isize;
140
141 /*
142 * truncate_mutex is for serialising ext4_truncate() against
143 * ext4_getblock(). In the 2.4 ext2 design, great chunks of inode's
144 * data tree are chopped off during truncate. We can't do that in
145 * ext4 because whenever we perform intermediate commits during
146 * truncate, the inode and all the metadata blocks *must* be in a
147 * consistent state which allows truncation of the orphans to restart
148 * during recovery. Hence we must fix the get_block-vs-truncate race
149 * by other means, so we have truncate_mutex.
150 */
151 struct mutex truncate_mutex;
152 struct inode vfs_inode;
153
154 unsigned long i_ext_generation;
155 struct ext4_ext_cache i_cached_extent;
156};
157
158#endif /* _LINUX_EXT4_FS_I */
diff --git a/include/linux/ext4_fs_sb.h b/include/linux/ext4_fs_sb.h
new file mode 100644
index 000000000000..691a713139ce
--- /dev/null
+++ b/include/linux/ext4_fs_sb.h
@@ -0,0 +1,94 @@
1/*
2 * linux/include/linux/ext4_fs_sb.h
3 *
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 *
9 * from
10 *
11 * linux/include/linux/minix_fs_sb.h
12 *
13 * Copyright (C) 1991, 1992 Linus Torvalds
14 */
15
16#ifndef _LINUX_EXT4_FS_SB
17#define _LINUX_EXT4_FS_SB
18
19#ifdef __KERNEL__
20#include <linux/timer.h>
21#include <linux/wait.h>
22#include <linux/blockgroup_lock.h>
23#include <linux/percpu_counter.h>
24#endif
25#include <linux/rbtree.h>
26
27/*
28 * third extended-fs super-block data in memory
29 */
30struct ext4_sb_info {
31 unsigned long s_frag_size; /* Size of a fragment in bytes */
32 unsigned long s_desc_size; /* Size of a group descriptor in bytes */
33 unsigned long s_frags_per_block;/* Number of fragments per block */
34 unsigned long s_inodes_per_block;/* Number of inodes per block */
35 unsigned long s_frags_per_group;/* Number of fragments in a group */
36 unsigned long s_blocks_per_group;/* Number of blocks in a group */
37 unsigned long s_inodes_per_group;/* Number of inodes in a group */
38 unsigned long s_itb_per_group; /* Number of inode table blocks per group */
39 unsigned long s_gdb_count; /* Number of group descriptor blocks */
40 unsigned long s_desc_per_block; /* Number of group descriptors per block */
41 unsigned long s_groups_count; /* Number of groups in the fs */
42 struct buffer_head * s_sbh; /* Buffer containing the super block */
43 struct ext4_super_block * s_es; /* Pointer to the super block in the buffer */
44 struct buffer_head ** s_group_desc;
45 unsigned long s_mount_opt;
46 uid_t s_resuid;
47 gid_t s_resgid;
48 unsigned short s_mount_state;
49 unsigned short s_pad;
50 int s_addr_per_block_bits;
51 int s_desc_per_block_bits;
52 int s_inode_size;
53 int s_first_ino;
54 spinlock_t s_next_gen_lock;
55 u32 s_next_generation;
56 u32 s_hash_seed[4];
57 int s_def_hash_version;
58 struct percpu_counter s_freeblocks_counter;
59 struct percpu_counter s_freeinodes_counter;
60 struct percpu_counter s_dirs_counter;
61 struct blockgroup_lock s_blockgroup_lock;
62
63 /* root of the per fs reservation window tree */
64 spinlock_t s_rsv_window_lock;
65 struct rb_root s_rsv_window_root;
66 struct ext4_reserve_window_node s_rsv_window_head;
67
68 /* Journaling */
69 struct inode * s_journal_inode;
70 struct journal_s * s_journal;
71 struct list_head s_orphan;
72 unsigned long s_commit_interval;
73 struct block_device *journal_bdev;
74#ifdef CONFIG_JBD_DEBUG
75 struct timer_list turn_ro_timer; /* For turning read-only (crash simulation) */
76 wait_queue_head_t ro_wait_queue; /* For people waiting for the fs to go read-only */
77#endif
78#ifdef CONFIG_QUOTA
79 char *s_qf_names[MAXQUOTAS]; /* Names of quota files with journalled quota */
80 int s_jquota_fmt; /* Format of quota to use */
81#endif
82
83#ifdef EXTENTS_STATS
84 /* ext4 extents stats */
85 unsigned long s_ext_min;
86 unsigned long s_ext_max;
87 unsigned long s_depth_max;
88 spinlock_t s_ext_stats_lock;
89 unsigned long s_ext_blocks;
90 unsigned long s_ext_extents;
91#endif
92};
93
94#endif /* _LINUX_EXT4_FS_SB */
diff --git a/include/linux/ext4_jbd2.h b/include/linux/ext4_jbd2.h
new file mode 100644
index 000000000000..72dd631912e4
--- /dev/null
+++ b/include/linux/ext4_jbd2.h
@@ -0,0 +1,273 @@
1/*
2 * linux/include/linux/ext4_jbd2.h
3 *
4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1999
5 *
6 * Copyright 1998--1999 Red Hat corp --- All Rights Reserved
7 *
8 * This file is part of the Linux kernel and is made available under
9 * the terms of the GNU General Public License, version 2, or at your
10 * option, any later version, incorporated herein by reference.
11 *
12 * Ext4-specific journaling extensions.
13 */
14
15#ifndef _LINUX_EXT4_JBD_H
16#define _LINUX_EXT4_JBD_H
17
18#include <linux/fs.h>
19#include <linux/jbd2.h>
20#include <linux/ext4_fs.h>
21
22#define EXT4_JOURNAL(inode) (EXT4_SB((inode)->i_sb)->s_journal)
23
24/* Define the number of blocks we need to account to a transaction to
25 * modify one block of data.
26 *
27 * We may have to touch one inode, one bitmap buffer, up to three
28 * indirection blocks, the group and superblock summaries, and the data
29 * block to complete the transaction.
30 *
31 * For extents-enabled fs we may have to allocate and modify up to
32 * 5 levels of tree + root which are stored in the inode. */
33
34#define EXT4_SINGLEDATA_TRANS_BLOCKS(sb) \
35 (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS) \
36 || test_opt(sb, EXTENTS) ? 27U : 8U)
37
38/* Extended attribute operations touch at most two data buffers,
39 * two bitmap buffers, and two group summaries, in addition to the inode
40 * and the superblock, which are already accounted for. */
41
42#define EXT4_XATTR_TRANS_BLOCKS 6U
43
44/* Define the minimum size for a transaction which modifies data. This
45 * needs to take into account the fact that we may end up modifying two
46 * quota files too (one for the group, one for the user quota). The
47 * superblock only gets updated once, of course, so don't bother
48 * counting that again for the quota updates. */
49
50#define EXT4_DATA_TRANS_BLOCKS(sb) (EXT4_SINGLEDATA_TRANS_BLOCKS(sb) + \
51 EXT4_XATTR_TRANS_BLOCKS - 2 + \
52 2*EXT4_QUOTA_TRANS_BLOCKS(sb))
53
54/* Delete operations potentially hit one directory's namespace plus an
55 * entire inode, plus arbitrary amounts of bitmap/indirection data. Be
56 * generous. We can grow the delete transaction later if necessary. */
57
58#define EXT4_DELETE_TRANS_BLOCKS(sb) (2 * EXT4_DATA_TRANS_BLOCKS(sb) + 64)
59
60/* Define an arbitrary limit for the amount of data we will anticipate
61 * writing to any given transaction. For unbounded transactions such as
62 * write(2) and truncate(2) we can write more than this, but we always
63 * start off at the maximum transaction size and grow the transaction
64 * optimistically as we go. */
65
66#define EXT4_MAX_TRANS_DATA 64U
67
68/* We break up a large truncate or write transaction once the handle's
69 * buffer credits gets this low, we need either to extend the
70 * transaction or to start a new one. Reserve enough space here for
71 * inode, bitmap, superblock, group and indirection updates for at least
72 * one block, plus two quota updates. Quota allocations are not
73 * needed. */
74
75#define EXT4_RESERVE_TRANS_BLOCKS 12U
76
77#define EXT4_INDEX_EXTRA_TRANS_BLOCKS 8
78
79#ifdef CONFIG_QUOTA
80/* Amount of blocks needed for quota update - we know that the structure was
81 * allocated so we need to update only inode+data */
82#define EXT4_QUOTA_TRANS_BLOCKS(sb) (test_opt(sb, QUOTA) ? 2 : 0)
83/* Amount of blocks needed for quota insert/delete - we do some block writes
84 * but inode, sb and group updates are done only once */
85#define EXT4_QUOTA_INIT_BLOCKS(sb) (test_opt(sb, QUOTA) ? (DQUOT_INIT_ALLOC*\
86 (EXT4_SINGLEDATA_TRANS_BLOCKS(sb)-3)+3+DQUOT_INIT_REWRITE) : 0)
87#define EXT4_QUOTA_DEL_BLOCKS(sb) (test_opt(sb, QUOTA) ? (DQUOT_DEL_ALLOC*\
88 (EXT4_SINGLEDATA_TRANS_BLOCKS(sb)-3)+3+DQUOT_DEL_REWRITE) : 0)
89#else
90#define EXT4_QUOTA_TRANS_BLOCKS(sb) 0
91#define EXT4_QUOTA_INIT_BLOCKS(sb) 0
92#define EXT4_QUOTA_DEL_BLOCKS(sb) 0
93#endif
94
95int
96ext4_mark_iloc_dirty(handle_t *handle,
97 struct inode *inode,
98 struct ext4_iloc *iloc);
99
100/*
101 * On success, We end up with an outstanding reference count against
102 * iloc->bh. This _must_ be cleaned up later.
103 */
104
105int ext4_reserve_inode_write(handle_t *handle, struct inode *inode,
106 struct ext4_iloc *iloc);
107
108int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode);
109
110/*
111 * Wrapper functions with which ext4 calls into JBD. The intent here is
112 * to allow these to be turned into appropriate stubs so ext4 can control
113 * ext2 filesystems, so ext2+ext4 systems only nee one fs. This work hasn't
114 * been done yet.
115 */
116
117void ext4_journal_abort_handle(const char *caller, const char *err_fn,
118 struct buffer_head *bh, handle_t *handle, int err);
119
120static inline int
121__ext4_journal_get_undo_access(const char *where, handle_t *handle,
122 struct buffer_head *bh)
123{
124 int err = jbd2_journal_get_undo_access(handle, bh);
125 if (err)
126 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
127 return err;
128}
129
130static inline int
131__ext4_journal_get_write_access(const char *where, handle_t *handle,
132 struct buffer_head *bh)
133{
134 int err = jbd2_journal_get_write_access(handle, bh);
135 if (err)
136 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
137 return err;
138}
139
140static inline void
141ext4_journal_release_buffer(handle_t *handle, struct buffer_head *bh)
142{
143 jbd2_journal_release_buffer(handle, bh);
144}
145
146static inline int
147__ext4_journal_forget(const char *where, handle_t *handle, struct buffer_head *bh)
148{
149 int err = jbd2_journal_forget(handle, bh);
150 if (err)
151 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
152 return err;
153}
154
155static inline int
156__ext4_journal_revoke(const char *where, handle_t *handle,
157 ext4_fsblk_t blocknr, struct buffer_head *bh)
158{
159 int err = jbd2_journal_revoke(handle, blocknr, bh);
160 if (err)
161 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
162 return err;
163}
164
165static inline int
166__ext4_journal_get_create_access(const char *where,
167 handle_t *handle, struct buffer_head *bh)
168{
169 int err = jbd2_journal_get_create_access(handle, bh);
170 if (err)
171 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
172 return err;
173}
174
175static inline int
176__ext4_journal_dirty_metadata(const char *where,
177 handle_t *handle, struct buffer_head *bh)
178{
179 int err = jbd2_journal_dirty_metadata(handle, bh);
180 if (err)
181 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
182 return err;
183}
184
185
186#define ext4_journal_get_undo_access(handle, bh) \
187 __ext4_journal_get_undo_access(__FUNCTION__, (handle), (bh))
188#define ext4_journal_get_write_access(handle, bh) \
189 __ext4_journal_get_write_access(__FUNCTION__, (handle), (bh))
190#define ext4_journal_revoke(handle, blocknr, bh) \
191 __ext4_journal_revoke(__FUNCTION__, (handle), (blocknr), (bh))
192#define ext4_journal_get_create_access(handle, bh) \
193 __ext4_journal_get_create_access(__FUNCTION__, (handle), (bh))
194#define ext4_journal_dirty_metadata(handle, bh) \
195 __ext4_journal_dirty_metadata(__FUNCTION__, (handle), (bh))
196#define ext4_journal_forget(handle, bh) \
197 __ext4_journal_forget(__FUNCTION__, (handle), (bh))
198
199int ext4_journal_dirty_data(handle_t *handle, struct buffer_head *bh);
200
201handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks);
202int __ext4_journal_stop(const char *where, handle_t *handle);
203
204static inline handle_t *ext4_journal_start(struct inode *inode, int nblocks)
205{
206 return ext4_journal_start_sb(inode->i_sb, nblocks);
207}
208
209#define ext4_journal_stop(handle) \
210 __ext4_journal_stop(__FUNCTION__, (handle))
211
212static inline handle_t *ext4_journal_current_handle(void)
213{
214 return journal_current_handle();
215}
216
217static inline int ext4_journal_extend(handle_t *handle, int nblocks)
218{
219 return jbd2_journal_extend(handle, nblocks);
220}
221
222static inline int ext4_journal_restart(handle_t *handle, int nblocks)
223{
224 return jbd2_journal_restart(handle, nblocks);
225}
226
227static inline int ext4_journal_blocks_per_page(struct inode *inode)
228{
229 return jbd2_journal_blocks_per_page(inode);
230}
231
232static inline int ext4_journal_force_commit(journal_t *journal)
233{
234 return jbd2_journal_force_commit(journal);
235}
236
237/* super.c */
238int ext4_force_commit(struct super_block *sb);
239
240static inline int ext4_should_journal_data(struct inode *inode)
241{
242 if (!S_ISREG(inode->i_mode))
243 return 1;
244 if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA)
245 return 1;
246 if (EXT4_I(inode)->i_flags & EXT4_JOURNAL_DATA_FL)
247 return 1;
248 return 0;
249}
250
251static inline int ext4_should_order_data(struct inode *inode)
252{
253 if (!S_ISREG(inode->i_mode))
254 return 0;
255 if (EXT4_I(inode)->i_flags & EXT4_JOURNAL_DATA_FL)
256 return 0;
257 if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA)
258 return 1;
259 return 0;
260}
261
262static inline int ext4_should_writeback_data(struct inode *inode)
263{
264 if (!S_ISREG(inode->i_mode))
265 return 0;
266 if (EXT4_I(inode)->i_flags & EXT4_JOURNAL_DATA_FL)
267 return 0;
268 if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)
269 return 1;
270 return 0;
271}
272
273#endif /* _LINUX_EXT4_JBD_H */
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 34406ed467c3..2fe6e3f900ba 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -623,6 +623,9 @@ enum inode_i_mutex_lock_class
623 I_MUTEX_QUOTA 623 I_MUTEX_QUOTA
624}; 624};
625 625
626extern void inode_double_lock(struct inode *inode1, struct inode *inode2);
627extern void inode_double_unlock(struct inode *inode1, struct inode *inode2);
628
626/* 629/*
627 * NOTE: in a 32bit arch with a preemptable kernel and 630 * NOTE: in a 32bit arch with a preemptable kernel and
628 * an UP compile the i_size_read/write must be atomic 631 * an UP compile the i_size_read/write must be atomic
@@ -656,7 +659,11 @@ static inline loff_t i_size_read(struct inode *inode)
656#endif 659#endif
657} 660}
658 661
659 662/*
663 * NOTE: unlike i_size_read(), i_size_write() does need locking around it
664 * (normally i_mutex), otherwise on 32bit/SMP an update of i_size_seqcount
665 * can be lost, resulting in subsequent i_size_read() calls spinning forever.
666 */
660static inline void i_size_write(struct inode *inode, loff_t i_size) 667static inline void i_size_write(struct inode *inode, loff_t i_size)
661{ 668{
662#if BITS_PER_LONG==32 && defined(CONFIG_SMP) 669#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
@@ -1705,6 +1712,8 @@ extern void __iget(struct inode * inode);
1705extern void clear_inode(struct inode *); 1712extern void clear_inode(struct inode *);
1706extern void destroy_inode(struct inode *); 1713extern void destroy_inode(struct inode *);
1707extern struct inode *new_inode(struct super_block *); 1714extern struct inode *new_inode(struct super_block *);
1715extern int __remove_suid(struct dentry *, int);
1716extern int should_remove_suid(struct dentry *);
1708extern int remove_suid(struct dentry *); 1717extern int remove_suid(struct dentry *);
1709extern void remove_dquot_ref(struct super_block *, int, struct list_head *); 1718extern void remove_dquot_ref(struct super_block *, int, struct list_head *);
1710 1719
@@ -1751,6 +1760,8 @@ extern ssize_t generic_file_splice_read(struct file *, loff_t *,
1751 struct pipe_inode_info *, size_t, unsigned int); 1760 struct pipe_inode_info *, size_t, unsigned int);
1752extern ssize_t generic_file_splice_write(struct pipe_inode_info *, 1761extern ssize_t generic_file_splice_write(struct pipe_inode_info *,
1753 struct file *, loff_t *, size_t, unsigned int); 1762 struct file *, loff_t *, size_t, unsigned int);
1763extern ssize_t generic_file_splice_write_nolock(struct pipe_inode_info *,
1764 struct file *, loff_t *, size_t, unsigned int);
1754extern ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe, 1765extern ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe,
1755 struct file *out, loff_t *, size_t len, unsigned int flags); 1766 struct file *out, loff_t *, size_t len, unsigned int flags);
1756extern long do_splice_direct(struct file *in, loff_t *ppos, struct file *out, 1767extern long do_splice_direct(struct file *in, loff_t *ppos, struct file *out,
diff --git a/include/linux/htirq.h b/include/linux/htirq.h
index 1f15ce279a23..c96ea46737d0 100644
--- a/include/linux/htirq.h
+++ b/include/linux/htirq.h
@@ -1,15 +1,23 @@
1#ifndef LINUX_HTIRQ_H 1#ifndef LINUX_HTIRQ_H
2#define LINUX_HTIRQ_H 2#define LINUX_HTIRQ_H
3 3
4struct ht_irq_msg {
5 u32 address_lo; /* low 32 bits of the ht irq message */
6 u32 address_hi; /* high 32 bits of the it irq message */
7};
8
4/* Helper functions.. */ 9/* Helper functions.. */
5void write_ht_irq_low(unsigned int irq, u32 data); 10void fetch_ht_irq_msg(unsigned int irq, struct ht_irq_msg *msg);
6void write_ht_irq_high(unsigned int irq, u32 data); 11void write_ht_irq_msg(unsigned int irq, struct ht_irq_msg *msg);
7u32 read_ht_irq_low(unsigned int irq);
8u32 read_ht_irq_high(unsigned int irq);
9void mask_ht_irq(unsigned int irq); 12void mask_ht_irq(unsigned int irq);
10void unmask_ht_irq(unsigned int irq); 13void unmask_ht_irq(unsigned int irq);
11 14
12/* The arch hook for getting things started */ 15/* The arch hook for getting things started */
13int arch_setup_ht_irq(unsigned int irq, struct pci_dev *dev); 16int arch_setup_ht_irq(unsigned int irq, struct pci_dev *dev);
14 17
18/* For drivers of buggy hardware */
19typedef void (ht_irq_update_t)(struct pci_dev *dev, int irq,
20 struct ht_irq_msg *msg);
21int __ht_create_irq(struct pci_dev *dev, int idx, ht_irq_update_t *update);
22
15#endif /* LINUX_HTIRQ_H */ 23#endif /* LINUX_HTIRQ_H */
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index c25a38d8f600..ace64e57e17f 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -17,6 +17,7 @@ int hugetlb_sysctl_handler(struct ctl_table *, int, struct file *, void __user *
17int copy_hugetlb_page_range(struct mm_struct *, struct mm_struct *, struct vm_area_struct *); 17int copy_hugetlb_page_range(struct mm_struct *, struct mm_struct *, struct vm_area_struct *);
18int follow_hugetlb_page(struct mm_struct *, struct vm_area_struct *, struct page **, struct vm_area_struct **, unsigned long *, int *, int); 18int follow_hugetlb_page(struct mm_struct *, struct vm_area_struct *, struct page **, struct vm_area_struct **, unsigned long *, int *, int);
19void unmap_hugepage_range(struct vm_area_struct *, unsigned long, unsigned long); 19void unmap_hugepage_range(struct vm_area_struct *, unsigned long, unsigned long);
20void __unmap_hugepage_range(struct vm_area_struct *, unsigned long, unsigned long);
20int hugetlb_prefault(struct address_space *, struct vm_area_struct *); 21int hugetlb_prefault(struct address_space *, struct vm_area_struct *);
21int hugetlb_report_meminfo(char *); 22int hugetlb_report_meminfo(char *);
22int hugetlb_report_node_meminfo(int, char *); 23int hugetlb_report_node_meminfo(int, char *);
@@ -59,8 +60,11 @@ void hugetlb_free_pgd_range(struct mmu_gather **tlb, unsigned long addr,
59 * If the arch doesn't supply something else, assume that hugepage 60 * If the arch doesn't supply something else, assume that hugepage
60 * size aligned regions are ok without further preparation. 61 * size aligned regions are ok without further preparation.
61 */ 62 */
62static inline int prepare_hugepage_range(unsigned long addr, unsigned long len) 63static inline int prepare_hugepage_range(unsigned long addr, unsigned long len,
64 pgoff_t pgoff)
63{ 65{
66 if (pgoff & (~HPAGE_MASK >> PAGE_SHIFT))
67 return -EINVAL;
64 if (len & ~HPAGE_MASK) 68 if (len & ~HPAGE_MASK)
65 return -EINVAL; 69 return -EINVAL;
66 if (addr & ~HPAGE_MASK) 70 if (addr & ~HPAGE_MASK)
@@ -68,7 +72,8 @@ static inline int prepare_hugepage_range(unsigned long addr, unsigned long len)
68 return 0; 72 return 0;
69} 73}
70#else 74#else
71int prepare_hugepage_range(unsigned long addr, unsigned long len); 75int prepare_hugepage_range(unsigned long addr, unsigned long len,
76 pgoff_t pgoff);
72#endif 77#endif
73 78
74#ifndef ARCH_HAS_SETCLEAR_HUGE_PTE 79#ifndef ARCH_HAS_SETCLEAR_HUGE_PTE
@@ -106,7 +111,7 @@ static inline unsigned long hugetlb_total_pages(void)
106#define hugetlb_report_meminfo(buf) 0 111#define hugetlb_report_meminfo(buf) 0
107#define hugetlb_report_node_meminfo(n, buf) 0 112#define hugetlb_report_node_meminfo(n, buf) 0
108#define follow_huge_pmd(mm, addr, pmd, write) NULL 113#define follow_huge_pmd(mm, addr, pmd, write) NULL
109#define prepare_hugepage_range(addr, len) (-EINVAL) 114#define prepare_hugepage_range(addr,len,pgoff) (-EINVAL)
110#define pmd_huge(x) 0 115#define pmd_huge(x) 0
111#define is_hugepage_only_range(mm, addr, len) 0 116#define is_hugepage_only_range(mm, addr, len) 0
112#define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) ({BUG(); 0; }) 117#define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) ({BUG(); 0; })
diff --git a/include/linux/igmp.h b/include/linux/igmp.h
index 03f43e2893a4..21dd56905271 100644
--- a/include/linux/igmp.h
+++ b/include/linux/igmp.h
@@ -191,7 +191,7 @@ struct ip_mc_list
191#define IGMPV3_MASK(value, nb) ((nb)>=32 ? (value) : ((1<<(nb))-1) & (value)) 191#define IGMPV3_MASK(value, nb) ((nb)>=32 ? (value) : ((1<<(nb))-1) & (value))
192#define IGMPV3_EXP(thresh, nbmant, nbexp, value) \ 192#define IGMPV3_EXP(thresh, nbmant, nbexp, value) \
193 ((value) < (thresh) ? (value) : \ 193 ((value) < (thresh) ? (value) : \
194 ((IGMPV3_MASK(value, nbmant) | (1<<(nbmant+nbexp))) << \ 194 ((IGMPV3_MASK(value, nbmant) | (1<<(nbmant))) << \
195 (IGMPV3_MASK((value) >> (nbmant), nbexp) + (nbexp)))) 195 (IGMPV3_MASK((value) >> (nbmant), nbexp) + (nbexp))))
196 196
197#define IGMPV3_QQIC(value) IGMPV3_EXP(0x80, 4, 3, value) 197#define IGMPV3_QQIC(value) IGMPV3_EXP(0x80, 4, 3, value)
diff --git a/include/linux/in6.h b/include/linux/in6.h
index 9be6a4756f0b..f28621f638e0 100644
--- a/include/linux/in6.h
+++ b/include/linux/in6.h
@@ -225,7 +225,7 @@ struct in6_flowlabel_req
225#endif 225#endif
226 226
227/* 227/*
228 * Netfilter 228 * Netfilter (1)
229 * 229 *
230 * Following socket options are used in ip6_tables; 230 * Following socket options are used in ip6_tables;
231 * see include/linux/netfilter_ipv6/ip6_tables.h. 231 * see include/linux/netfilter_ipv6/ip6_tables.h.
@@ -240,4 +240,14 @@ struct in6_flowlabel_req
240#define IPV6_RECVTCLASS 66 240#define IPV6_RECVTCLASS 66
241#define IPV6_TCLASS 67 241#define IPV6_TCLASS 67
242 242
243/*
244 * Netfilter (2)
245 *
246 * Following socket options are used in ip6_tables;
247 * see include/linux/netfilter_ipv6/ip6_tables.h.
248 *
249 * IP6T_SO_GET_REVISION_MATCH 68
250 * IP6T_SO_GET_REVISION_TARGET 69
251 */
252
243#endif 253#endif
diff --git a/include/linux/init.h b/include/linux/init.h
index e92b1455d7af..5eb5d24b7680 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -84,19 +84,37 @@ extern void setup_arch(char **);
84 * by link order. 84 * by link order.
85 * For backwards compatibility, initcall() puts the call in 85 * For backwards compatibility, initcall() puts the call in
86 * the device init subsection. 86 * the device init subsection.
87 *
88 * The `id' arg to __define_initcall() is needed so that multiple initcalls
89 * can point at the same handler without causing duplicate-symbol build errors.
87 */ 90 */
88 91
89#define __define_initcall(level,fn) \ 92#define __define_initcall(level,fn,id) \
90 static initcall_t __initcall_##fn __attribute_used__ \ 93 static initcall_t __initcall_##fn##id __attribute_used__ \
91 __attribute__((__section__(".initcall" level ".init"))) = fn 94 __attribute__((__section__(".initcall" level ".init"))) = fn
92 95
93#define core_initcall(fn) __define_initcall("1",fn) 96/*
94#define postcore_initcall(fn) __define_initcall("2",fn) 97 * A "pure" initcall has no dependencies on anything else, and purely
95#define arch_initcall(fn) __define_initcall("3",fn) 98 * initializes variables that couldn't be statically initialized.
96#define subsys_initcall(fn) __define_initcall("4",fn) 99 *
97#define fs_initcall(fn) __define_initcall("5",fn) 100 * This only exists for built-in code, not for modules.
98#define device_initcall(fn) __define_initcall("6",fn) 101 */
99#define late_initcall(fn) __define_initcall("7",fn) 102#define pure_initcall(fn) __define_initcall("0",fn,1)
103
104#define core_initcall(fn) __define_initcall("1",fn,1)
105#define core_initcall_sync(fn) __define_initcall("1s",fn,1s)
106#define postcore_initcall(fn) __define_initcall("2",fn,2)
107#define postcore_initcall_sync(fn) __define_initcall("2s",fn,2s)
108#define arch_initcall(fn) __define_initcall("3",fn,3)
109#define arch_initcall_sync(fn) __define_initcall("3s",fn,3s)
110#define subsys_initcall(fn) __define_initcall("4",fn,4)
111#define subsys_initcall_sync(fn) __define_initcall("4s",fn,4s)
112#define fs_initcall(fn) __define_initcall("5",fn,5)
113#define fs_initcall_sync(fn) __define_initcall("5s",fn,5s)
114#define device_initcall(fn) __define_initcall("6",fn,6)
115#define device_initcall_sync(fn) __define_initcall("6s",fn,6s)
116#define late_initcall(fn) __define_initcall("7",fn,7)
117#define late_initcall_sync(fn) __define_initcall("7s",fn,7s)
100 118
101#define __initcall(fn) device_initcall(fn) 119#define __initcall(fn) device_initcall(fn)
102 120
diff --git a/include/linux/io.h b/include/linux/io.h
index 2ad96c3f0e4e..81877ea39309 100644
--- a/include/linux/io.h
+++ b/include/linux/io.h
@@ -28,4 +28,31 @@ void __iowrite64_copy(void __iomem *to, const void *from, size_t count);
28int ioremap_page_range(unsigned long addr, unsigned long end, 28int ioremap_page_range(unsigned long addr, unsigned long end,
29 unsigned long phys_addr, pgprot_t prot); 29 unsigned long phys_addr, pgprot_t prot);
30 30
31/**
32 * check_signature - find BIOS signatures
33 * @io_addr: mmio address to check
34 * @signature: signature block
35 * @length: length of signature
36 *
37 * Perform a signature comparison with the mmio address io_addr. This
38 * address should have been obtained by ioremap.
39 * Returns 1 on a match.
40 */
41
42static inline int check_signature(const volatile void __iomem *io_addr,
43 const unsigned char *signature, int length)
44{
45 int retval = 0;
46 do {
47 if (readb(io_addr) != *signature)
48 goto out;
49 io_addr++;
50 signature++;
51 length--;
52 } while (length);
53 retval = 1;
54out:
55 return retval;
56}
57
31#endif /* _LINUX_IO_H */ 58#endif /* _LINUX_IO_H */
diff --git a/include/linux/ipmi_msgdefs.h b/include/linux/ipmi_msgdefs.h
index 22f5e2afda4f..4d04d8b58a0a 100644
--- a/include/linux/ipmi_msgdefs.h
+++ b/include/linux/ipmi_msgdefs.h
@@ -75,6 +75,8 @@
75#define IPMI_INVALID_COMMAND_ERR 0xc1 75#define IPMI_INVALID_COMMAND_ERR 0xc1
76#define IPMI_ERR_MSG_TRUNCATED 0xc6 76#define IPMI_ERR_MSG_TRUNCATED 0xc6
77#define IPMI_LOST_ARBITRATION_ERR 0x81 77#define IPMI_LOST_ARBITRATION_ERR 0x81
78#define IPMI_BUS_ERR 0x82
79#define IPMI_NAK_ON_WRITE_ERR 0x83
78#define IPMI_ERR_UNSPECIFIED 0xff 80#define IPMI_ERR_UNSPECIFIED 0xff
79 81
80#define IPMI_CHANNEL_PROTOCOL_IPMB 1 82#define IPMI_CHANNEL_PROTOCOL_IPMB 1
diff --git a/include/linux/ipx.h b/include/linux/ipx.h
index 4f29c60964c4..eb19b4ea84f4 100644
--- a/include/linux/ipx.h
+++ b/include/linux/ipx.h
@@ -7,8 +7,8 @@
7 7
8struct sockaddr_ipx { 8struct sockaddr_ipx {
9 sa_family_t sipx_family; 9 sa_family_t sipx_family;
10 __u16 sipx_port; 10 __be16 sipx_port;
11 __u32 sipx_network; 11 __be32 sipx_network;
12 unsigned char sipx_node[IPX_NODE_LEN]; 12 unsigned char sipx_node[IPX_NODE_LEN];
13 __u8 sipx_type; 13 __u8 sipx_type;
14 unsigned char sipx_zero; /* 16 byte fill */ 14 unsigned char sipx_zero; /* 16 byte fill */
@@ -23,13 +23,13 @@ struct sockaddr_ipx {
23#define IPX_CRTITF 1 23#define IPX_CRTITF 1
24 24
25struct ipx_route_definition { 25struct ipx_route_definition {
26 __u32 ipx_network; 26 __be32 ipx_network;
27 __u32 ipx_router_network; 27 __be32 ipx_router_network;
28 unsigned char ipx_router_node[IPX_NODE_LEN]; 28 unsigned char ipx_router_node[IPX_NODE_LEN];
29}; 29};
30 30
31struct ipx_interface_definition { 31struct ipx_interface_definition {
32 __u32 ipx_network; 32 __be32 ipx_network;
33 unsigned char ipx_device[16]; 33 unsigned char ipx_device[16];
34 unsigned char ipx_dlink_type; 34 unsigned char ipx_dlink_type;
35#define IPX_FRAME_NONE 0 35#define IPX_FRAME_NONE 0
@@ -55,8 +55,8 @@ struct ipx_config_data {
55 */ 55 */
56 56
57struct ipx_route_def { 57struct ipx_route_def {
58 __u32 ipx_network; 58 __be32 ipx_network;
59 __u32 ipx_router_network; 59 __be32 ipx_router_network;
60#define IPX_ROUTE_NO_ROUTER 0 60#define IPX_ROUTE_NO_ROUTER 0
61 unsigned char ipx_router_node[IPX_NODE_LEN]; 61 unsigned char ipx_router_node[IPX_NODE_LEN];
62 unsigned char ipx_device[16]; 62 unsigned char ipx_device[16];
diff --git a/include/linux/irq.h b/include/linux/irq.h
index c64f3cc7e870..52fc4052a0ae 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -141,6 +141,7 @@ struct irq_chip {
141 * @pending_mask: pending rebalanced interrupts 141 * @pending_mask: pending rebalanced interrupts
142 * @dir: /proc/irq/ procfs entry 142 * @dir: /proc/irq/ procfs entry
143 * @affinity_entry: /proc/irq/smp_affinity procfs entry on SMP 143 * @affinity_entry: /proc/irq/smp_affinity procfs entry on SMP
144 * @name: flow handler name for /proc/interrupts output
144 * 145 *
145 * Pad this out to 32 bytes for cache and indexing reasons. 146 * Pad this out to 32 bytes for cache and indexing reasons.
146 */ 147 */
@@ -165,8 +166,9 @@ struct irq_desc {
165 cpumask_t pending_mask; 166 cpumask_t pending_mask;
166#endif 167#endif
167#ifdef CONFIG_PROC_FS 168#ifdef CONFIG_PROC_FS
168 struct proc_dir_entry *dir; 169 struct proc_dir_entry *dir;
169#endif 170#endif
171 const char *name;
170} ____cacheline_aligned; 172} ____cacheline_aligned;
171 173
172extern struct irq_desc irq_desc[NR_IRQS]; 174extern struct irq_desc irq_desc[NR_IRQS];
@@ -272,12 +274,6 @@ extern void fastcall handle_percpu_irq(unsigned int irq, struct irq_desc *desc);
272extern void fastcall handle_bad_irq(unsigned int irq, struct irq_desc *desc); 274extern void fastcall handle_bad_irq(unsigned int irq, struct irq_desc *desc);
273 275
274/* 276/*
275 * Get a descriptive string for the highlevel handler, for
276 * /proc/interrupts output:
277 */
278extern const char *handle_irq_name(irq_flow_handler_t handle);
279
280/*
281 * Monolithic do_IRQ implementation. 277 * Monolithic do_IRQ implementation.
282 * (is an explicit fastcall, because i386 4KSTACKS calls it from assembly) 278 * (is an explicit fastcall, because i386 4KSTACKS calls it from assembly)
283 */ 279 */
@@ -329,7 +325,12 @@ extern void
329set_irq_chip_and_handler(unsigned int irq, struct irq_chip *chip, 325set_irq_chip_and_handler(unsigned int irq, struct irq_chip *chip,
330 irq_flow_handler_t handle); 326 irq_flow_handler_t handle);
331extern void 327extern void
332__set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained); 328set_irq_chip_and_handler_name(unsigned int irq, struct irq_chip *chip,
329 irq_flow_handler_t handle, const char *name);
330
331extern void
332__set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
333 const char *name);
333 334
334/* 335/*
335 * Set a highlevel flow handler for a given IRQ: 336 * Set a highlevel flow handler for a given IRQ:
@@ -337,7 +338,7 @@ __set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained);
337static inline void 338static inline void
338set_irq_handler(unsigned int irq, irq_flow_handler_t handle) 339set_irq_handler(unsigned int irq, irq_flow_handler_t handle)
339{ 340{
340 __set_irq_handler(irq, handle, 0); 341 __set_irq_handler(irq, handle, 0, NULL);
341} 342}
342 343
343/* 344/*
@@ -349,7 +350,7 @@ static inline void
349set_irq_chained_handler(unsigned int irq, 350set_irq_chained_handler(unsigned int irq,
350 irq_flow_handler_t handle) 351 irq_flow_handler_t handle)
351{ 352{
352 __set_irq_handler(irq, handle, 1); 353 __set_irq_handler(irq, handle, 1, NULL);
353} 354}
354 355
355/* Handle dynamic irq creation and destruction */ 356/* Handle dynamic irq creation and destruction */
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
new file mode 100644
index 000000000000..ddb128795781
--- /dev/null
+++ b/include/linux/jbd2.h
@@ -0,0 +1,1107 @@
1/*
2 * linux/include/linux/jbd2.h
3 *
4 * Written by Stephen C. Tweedie <sct@redhat.com>
5 *
6 * Copyright 1998-2000 Red Hat, Inc --- All Rights Reserved
7 *
8 * This file is part of the Linux kernel and is made available under
9 * the terms of the GNU General Public License, version 2, or at your
10 * option, any later version, incorporated herein by reference.
11 *
12 * Definitions for transaction data structures for the buffer cache
13 * filesystem journaling support.
14 */
15
16#ifndef _LINUX_JBD_H
17#define _LINUX_JBD_H
18
19/* Allow this file to be included directly into e2fsprogs */
20#ifndef __KERNEL__
21#include "jfs_compat.h"
22#define JBD2_DEBUG
23#define jfs_debug jbd_debug
24#else
25
26#include <linux/types.h>
27#include <linux/buffer_head.h>
28#include <linux/journal-head.h>
29#include <linux/stddef.h>
30#include <linux/bit_spinlock.h>
31#include <linux/mutex.h>
32#include <linux/timer.h>
33
34#include <asm/semaphore.h>
35#endif
36
37#define journal_oom_retry 1
38
39/*
40 * Define JBD_PARANIOD_IOFAIL to cause a kernel BUG() if ext3 finds
41 * certain classes of error which can occur due to failed IOs. Under
42 * normal use we want ext3 to continue after such errors, because
43 * hardware _can_ fail, but for debugging purposes when running tests on
44 * known-good hardware we may want to trap these errors.
45 */
46#undef JBD_PARANOID_IOFAIL
47
48/*
49 * The default maximum commit age, in seconds.
50 */
51#define JBD_DEFAULT_MAX_COMMIT_AGE 5
52
53#ifdef CONFIG_JBD_DEBUG
54/*
55 * Define JBD_EXPENSIVE_CHECKING to enable more expensive internal
56 * consistency checks. By default we don't do this unless
57 * CONFIG_JBD_DEBUG is on.
58 */
59#define JBD_EXPENSIVE_CHECKING
60extern int jbd2_journal_enable_debug;
61
62#define jbd_debug(n, f, a...) \
63 do { \
64 if ((n) <= jbd2_journal_enable_debug) { \
65 printk (KERN_DEBUG "(%s, %d): %s: ", \
66 __FILE__, __LINE__, __FUNCTION__); \
67 printk (f, ## a); \
68 } \
69 } while (0)
70#else
71#define jbd_debug(f, a...) /**/
72#endif
73
74extern void * __jbd2_kmalloc (const char *where, size_t size, gfp_t flags, int retry);
75extern void * jbd2_slab_alloc(size_t size, gfp_t flags);
76extern void jbd2_slab_free(void *ptr, size_t size);
77
78#define jbd_kmalloc(size, flags) \
79 __jbd2_kmalloc(__FUNCTION__, (size), (flags), journal_oom_retry)
80#define jbd_rep_kmalloc(size, flags) \
81 __jbd2_kmalloc(__FUNCTION__, (size), (flags), 1)
82
83#define JBD2_MIN_JOURNAL_BLOCKS 1024
84
85#ifdef __KERNEL__
86
87/**
88 * typedef handle_t - The handle_t type represents a single atomic update being performed by some process.
89 *
90 * All filesystem modifications made by the process go
91 * through this handle. Recursive operations (such as quota operations)
92 * are gathered into a single update.
93 *
94 * The buffer credits field is used to account for journaled buffers
95 * being modified by the running process. To ensure that there is
96 * enough log space for all outstanding operations, we need to limit the
97 * number of outstanding buffers possible at any time. When the
98 * operation completes, any buffer credits not used are credited back to
99 * the transaction, so that at all times we know how many buffers the
100 * outstanding updates on a transaction might possibly touch.
101 *
102 * This is an opaque datatype.
103 **/
104typedef struct handle_s handle_t; /* Atomic operation type */
105
106
107/**
108 * typedef journal_t - The journal_t maintains all of the journaling state information for a single filesystem.
109 *
110 * journal_t is linked to from the fs superblock structure.
111 *
112 * We use the journal_t to keep track of all outstanding transaction
113 * activity on the filesystem, and to manage the state of the log
114 * writing process.
115 *
116 * This is an opaque datatype.
117 **/
118typedef struct journal_s journal_t; /* Journal control structure */
119#endif
120
121/*
122 * Internal structures used by the logging mechanism:
123 */
124
125#define JBD2_MAGIC_NUMBER 0xc03b3998U /* The first 4 bytes of /dev/random! */
126
127/*
128 * On-disk structures
129 */
130
131/*
132 * Descriptor block types:
133 */
134
135#define JBD2_DESCRIPTOR_BLOCK 1
136#define JBD2_COMMIT_BLOCK 2
137#define JBD2_SUPERBLOCK_V1 3
138#define JBD2_SUPERBLOCK_V2 4
139#define JBD2_REVOKE_BLOCK 5
140
141/*
142 * Standard header for all descriptor blocks:
143 */
144typedef struct journal_header_s
145{
146 __be32 h_magic;
147 __be32 h_blocktype;
148 __be32 h_sequence;
149} journal_header_t;
150
151
152/*
153 * The block tag: used to describe a single buffer in the journal.
154 * t_blocknr_high is only used if INCOMPAT_64BIT is set, so this
155 * raw struct shouldn't be used for pointer math or sizeof() - use
156 * journal_tag_bytes(journal) instead to compute this.
157 */
158typedef struct journal_block_tag_s
159{
160 __be32 t_blocknr; /* The on-disk block number */
161 __be32 t_flags; /* See below */
162 __be32 t_blocknr_high; /* most-significant high 32bits. */
163} journal_block_tag_t;
164
165#define JBD_TAG_SIZE32 (offsetof(journal_block_tag_t, t_blocknr_high))
166#define JBD_TAG_SIZE64 (sizeof(journal_block_tag_t))
167
168/*
169 * The revoke descriptor: used on disk to describe a series of blocks to
170 * be revoked from the log
171 */
172typedef struct jbd2_journal_revoke_header_s
173{
174 journal_header_t r_header;
175 __be32 r_count; /* Count of bytes used in the block */
176} jbd2_journal_revoke_header_t;
177
178
179/* Definitions for the journal tag flags word: */
180#define JBD2_FLAG_ESCAPE 1 /* on-disk block is escaped */
181#define JBD2_FLAG_SAME_UUID 2 /* block has same uuid as previous */
182#define JBD2_FLAG_DELETED 4 /* block deleted by this transaction */
183#define JBD2_FLAG_LAST_TAG 8 /* last tag in this descriptor block */
184
185
186/*
187 * The journal superblock. All fields are in big-endian byte order.
188 */
189typedef struct journal_superblock_s
190{
191/* 0x0000 */
192 journal_header_t s_header;
193
194/* 0x000C */
195 /* Static information describing the journal */
196 __be32 s_blocksize; /* journal device blocksize */
197 __be32 s_maxlen; /* total blocks in journal file */
198 __be32 s_first; /* first block of log information */
199
200/* 0x0018 */
201 /* Dynamic information describing the current state of the log */
202 __be32 s_sequence; /* first commit ID expected in log */
203 __be32 s_start; /* blocknr of start of log */
204
205/* 0x0020 */
206 /* Error value, as set by jbd2_journal_abort(). */
207 __be32 s_errno;
208
209/* 0x0024 */
210 /* Remaining fields are only valid in a version-2 superblock */
211 __be32 s_feature_compat; /* compatible feature set */
212 __be32 s_feature_incompat; /* incompatible feature set */
213 __be32 s_feature_ro_compat; /* readonly-compatible feature set */
214/* 0x0030 */
215 __u8 s_uuid[16]; /* 128-bit uuid for journal */
216
217/* 0x0040 */
218 __be32 s_nr_users; /* Nr of filesystems sharing log */
219
220 __be32 s_dynsuper; /* Blocknr of dynamic superblock copy*/
221
222/* 0x0048 */
223 __be32 s_max_transaction; /* Limit of journal blocks per trans.*/
224 __be32 s_max_trans_data; /* Limit of data blocks per trans. */
225
226/* 0x0050 */
227 __u32 s_padding[44];
228
229/* 0x0100 */
230 __u8 s_users[16*48]; /* ids of all fs'es sharing the log */
231/* 0x0400 */
232} journal_superblock_t;
233
234#define JBD2_HAS_COMPAT_FEATURE(j,mask) \
235 ((j)->j_format_version >= 2 && \
236 ((j)->j_superblock->s_feature_compat & cpu_to_be32((mask))))
237#define JBD2_HAS_RO_COMPAT_FEATURE(j,mask) \
238 ((j)->j_format_version >= 2 && \
239 ((j)->j_superblock->s_feature_ro_compat & cpu_to_be32((mask))))
240#define JBD2_HAS_INCOMPAT_FEATURE(j,mask) \
241 ((j)->j_format_version >= 2 && \
242 ((j)->j_superblock->s_feature_incompat & cpu_to_be32((mask))))
243
244#define JBD2_FEATURE_INCOMPAT_REVOKE 0x00000001
245#define JBD2_FEATURE_INCOMPAT_64BIT 0x00000002
246
247/* Features known to this kernel version: */
248#define JBD2_KNOWN_COMPAT_FEATURES 0
249#define JBD2_KNOWN_ROCOMPAT_FEATURES 0
250#define JBD2_KNOWN_INCOMPAT_FEATURES (JBD2_FEATURE_INCOMPAT_REVOKE | \
251 JBD2_FEATURE_INCOMPAT_64BIT)
252
253#ifdef __KERNEL__
254
255#include <linux/fs.h>
256#include <linux/sched.h>
257
258#define JBD_ASSERTIONS
259#ifdef JBD_ASSERTIONS
260#define J_ASSERT(assert) \
261do { \
262 if (!(assert)) { \
263 printk (KERN_EMERG \
264 "Assertion failure in %s() at %s:%d: \"%s\"\n", \
265 __FUNCTION__, __FILE__, __LINE__, # assert); \
266 BUG(); \
267 } \
268} while (0)
269
270#if defined(CONFIG_BUFFER_DEBUG)
271void buffer_assertion_failure(struct buffer_head *bh);
272#define J_ASSERT_BH(bh, expr) \
273 do { \
274 if (!(expr)) \
275 buffer_assertion_failure(bh); \
276 J_ASSERT(expr); \
277 } while (0)
278#define J_ASSERT_JH(jh, expr) J_ASSERT_BH(jh2bh(jh), expr)
279#else
280#define J_ASSERT_BH(bh, expr) J_ASSERT(expr)
281#define J_ASSERT_JH(jh, expr) J_ASSERT(expr)
282#endif
283
284#else
285#define J_ASSERT(assert) do { } while (0)
286#endif /* JBD_ASSERTIONS */
287
288#if defined(JBD_PARANOID_IOFAIL)
289#define J_EXPECT(expr, why...) J_ASSERT(expr)
290#define J_EXPECT_BH(bh, expr, why...) J_ASSERT_BH(bh, expr)
291#define J_EXPECT_JH(jh, expr, why...) J_ASSERT_JH(jh, expr)
292#else
293#define __journal_expect(expr, why...) \
294 ({ \
295 int val = (expr); \
296 if (!val) { \
297 printk(KERN_ERR \
298 "EXT3-fs unexpected failure: %s;\n",# expr); \
299 printk(KERN_ERR why "\n"); \
300 } \
301 val; \
302 })
303#define J_EXPECT(expr, why...) __journal_expect(expr, ## why)
304#define J_EXPECT_BH(bh, expr, why...) __journal_expect(expr, ## why)
305#define J_EXPECT_JH(jh, expr, why...) __journal_expect(expr, ## why)
306#endif
307
308enum jbd_state_bits {
309 BH_JBD /* Has an attached ext3 journal_head */
310 = BH_PrivateStart,
311 BH_JWrite, /* Being written to log (@@@ DEBUGGING) */
312 BH_Freed, /* Has been freed (truncated) */
313 BH_Revoked, /* Has been revoked from the log */
314 BH_RevokeValid, /* Revoked flag is valid */
315 BH_JBDDirty, /* Is dirty but journaled */
316 BH_State, /* Pins most journal_head state */
317 BH_JournalHead, /* Pins bh->b_private and jh->b_bh */
318 BH_Unshadow, /* Dummy bit, for BJ_Shadow wakeup filtering */
319};
320
321BUFFER_FNS(JBD, jbd)
322BUFFER_FNS(JWrite, jwrite)
323BUFFER_FNS(JBDDirty, jbddirty)
324TAS_BUFFER_FNS(JBDDirty, jbddirty)
325BUFFER_FNS(Revoked, revoked)
326TAS_BUFFER_FNS(Revoked, revoked)
327BUFFER_FNS(RevokeValid, revokevalid)
328TAS_BUFFER_FNS(RevokeValid, revokevalid)
329BUFFER_FNS(Freed, freed)
330
331static inline struct buffer_head *jh2bh(struct journal_head *jh)
332{
333 return jh->b_bh;
334}
335
336static inline struct journal_head *bh2jh(struct buffer_head *bh)
337{
338 return bh->b_private;
339}
340
341static inline void jbd_lock_bh_state(struct buffer_head *bh)
342{
343 bit_spin_lock(BH_State, &bh->b_state);
344}
345
346static inline int jbd_trylock_bh_state(struct buffer_head *bh)
347{
348 return bit_spin_trylock(BH_State, &bh->b_state);
349}
350
351static inline int jbd_is_locked_bh_state(struct buffer_head *bh)
352{
353 return bit_spin_is_locked(BH_State, &bh->b_state);
354}
355
356static inline void jbd_unlock_bh_state(struct buffer_head *bh)
357{
358 bit_spin_unlock(BH_State, &bh->b_state);
359}
360
361static inline void jbd_lock_bh_journal_head(struct buffer_head *bh)
362{
363 bit_spin_lock(BH_JournalHead, &bh->b_state);
364}
365
366static inline void jbd_unlock_bh_journal_head(struct buffer_head *bh)
367{
368 bit_spin_unlock(BH_JournalHead, &bh->b_state);
369}
370
371struct jbd2_revoke_table_s;
372
373/**
374 * struct handle_s - The handle_s type is the concrete type associated with
375 * handle_t.
376 * @h_transaction: Which compound transaction is this update a part of?
377 * @h_buffer_credits: Number of remaining buffers we are allowed to dirty.
378 * @h_ref: Reference count on this handle
379 * @h_err: Field for caller's use to track errors through large fs operations
380 * @h_sync: flag for sync-on-close
381 * @h_jdata: flag to force data journaling
382 * @h_aborted: flag indicating fatal error on handle
383 **/
384
385/* Docbook can't yet cope with the bit fields, but will leave the documentation
386 * in so it can be fixed later.
387 */
388
389struct handle_s
390{
391 /* Which compound transaction is this update a part of? */
392 transaction_t *h_transaction;
393
394 /* Number of remaining buffers we are allowed to dirty: */
395 int h_buffer_credits;
396
397 /* Reference count on this handle */
398 int h_ref;
399
400 /* Field for caller's use to track errors through large fs */
401 /* operations */
402 int h_err;
403
404 /* Flags [no locking] */
405 unsigned int h_sync: 1; /* sync-on-close */
406 unsigned int h_jdata: 1; /* force data journaling */
407 unsigned int h_aborted: 1; /* fatal error on handle */
408};
409
410
411/* The transaction_t type is the guts of the journaling mechanism. It
412 * tracks a compound transaction through its various states:
413 *
414 * RUNNING: accepting new updates
415 * LOCKED: Updates still running but we don't accept new ones
416 * RUNDOWN: Updates are tidying up but have finished requesting
417 * new buffers to modify (state not used for now)
418 * FLUSH: All updates complete, but we are still writing to disk
419 * COMMIT: All data on disk, writing commit record
420 * FINISHED: We still have to keep the transaction for checkpointing.
421 *
422 * The transaction keeps track of all of the buffers modified by a
423 * running transaction, and all of the buffers committed but not yet
424 * flushed to home for finished transactions.
425 */
426
427/*
428 * Lock ranking:
429 *
430 * j_list_lock
431 * ->jbd_lock_bh_journal_head() (This is "innermost")
432 *
433 * j_state_lock
434 * ->jbd_lock_bh_state()
435 *
436 * jbd_lock_bh_state()
437 * ->j_list_lock
438 *
439 * j_state_lock
440 * ->t_handle_lock
441 *
442 * j_state_lock
443 * ->j_list_lock (journal_unmap_buffer)
444 *
445 */
446
447struct transaction_s
448{
449 /* Pointer to the journal for this transaction. [no locking] */
450 journal_t *t_journal;
451
452 /* Sequence number for this transaction [no locking] */
453 tid_t t_tid;
454
455 /*
456 * Transaction's current state
457 * [no locking - only kjournald2 alters this]
458 * FIXME: needs barriers
459 * KLUDGE: [use j_state_lock]
460 */
461 enum {
462 T_RUNNING,
463 T_LOCKED,
464 T_RUNDOWN,
465 T_FLUSH,
466 T_COMMIT,
467 T_FINISHED
468 } t_state;
469
470 /*
471 * Where in the log does this transaction's commit start? [no locking]
472 */
473 unsigned long t_log_start;
474
475 /* Number of buffers on the t_buffers list [j_list_lock] */
476 int t_nr_buffers;
477
478 /*
479 * Doubly-linked circular list of all buffers reserved but not yet
480 * modified by this transaction [j_list_lock]
481 */
482 struct journal_head *t_reserved_list;
483
484 /*
485 * Doubly-linked circular list of all buffers under writeout during
486 * commit [j_list_lock]
487 */
488 struct journal_head *t_locked_list;
489
490 /*
491 * Doubly-linked circular list of all metadata buffers owned by this
492 * transaction [j_list_lock]
493 */
494 struct journal_head *t_buffers;
495
496 /*
497 * Doubly-linked circular list of all data buffers still to be
498 * flushed before this transaction can be committed [j_list_lock]
499 */
500 struct journal_head *t_sync_datalist;
501
502 /*
503 * Doubly-linked circular list of all forget buffers (superseded
504 * buffers which we can un-checkpoint once this transaction commits)
505 * [j_list_lock]
506 */
507 struct journal_head *t_forget;
508
509 /*
510 * Doubly-linked circular list of all buffers still to be flushed before
511 * this transaction can be checkpointed. [j_list_lock]
512 */
513 struct journal_head *t_checkpoint_list;
514
515 /*
516 * Doubly-linked circular list of all buffers submitted for IO while
517 * checkpointing. [j_list_lock]
518 */
519 struct journal_head *t_checkpoint_io_list;
520
521 /*
522 * Doubly-linked circular list of temporary buffers currently undergoing
523 * IO in the log [j_list_lock]
524 */
525 struct journal_head *t_iobuf_list;
526
527 /*
528 * Doubly-linked circular list of metadata buffers being shadowed by log
529 * IO. The IO buffers on the iobuf list and the shadow buffers on this
530 * list match each other one for one at all times. [j_list_lock]
531 */
532 struct journal_head *t_shadow_list;
533
534 /*
535 * Doubly-linked circular list of control buffers being written to the
536 * log. [j_list_lock]
537 */
538 struct journal_head *t_log_list;
539
540 /*
541 * Protects info related to handles
542 */
543 spinlock_t t_handle_lock;
544
545 /*
546 * Number of outstanding updates running on this transaction
547 * [t_handle_lock]
548 */
549 int t_updates;
550
551 /*
552 * Number of buffers reserved for use by all handles in this transaction
553 * handle but not yet modified. [t_handle_lock]
554 */
555 int t_outstanding_credits;
556
557 /*
558 * Forward and backward links for the circular list of all transactions
559 * awaiting checkpoint. [j_list_lock]
560 */
561 transaction_t *t_cpnext, *t_cpprev;
562
563 /*
564 * When will the transaction expire (become due for commit), in jiffies?
565 * [no locking]
566 */
567 unsigned long t_expires;
568
569 /*
570 * How many handles used this transaction? [t_handle_lock]
571 */
572 int t_handle_count;
573
574};
575
576/**
577 * struct journal_s - The journal_s type is the concrete type associated with
578 * journal_t.
579 * @j_flags: General journaling state flags
580 * @j_errno: Is there an outstanding uncleared error on the journal (from a
581 * prior abort)?
582 * @j_sb_buffer: First part of superblock buffer
583 * @j_superblock: Second part of superblock buffer
584 * @j_format_version: Version of the superblock format
585 * @j_state_lock: Protect the various scalars in the journal
586 * @j_barrier_count: Number of processes waiting to create a barrier lock
587 * @j_barrier: The barrier lock itself
588 * @j_running_transaction: The current running transaction..
589 * @j_committing_transaction: the transaction we are pushing to disk
590 * @j_checkpoint_transactions: a linked circular list of all transactions
591 * waiting for checkpointing
592 * @j_wait_transaction_locked: Wait queue for waiting for a locked transaction
593 * to start committing, or for a barrier lock to be released
594 * @j_wait_logspace: Wait queue for waiting for checkpointing to complete
595 * @j_wait_done_commit: Wait queue for waiting for commit to complete
596 * @j_wait_checkpoint: Wait queue to trigger checkpointing
597 * @j_wait_commit: Wait queue to trigger commit
598 * @j_wait_updates: Wait queue to wait for updates to complete
599 * @j_checkpoint_mutex: Mutex for locking against concurrent checkpoints
600 * @j_head: Journal head - identifies the first unused block in the journal
601 * @j_tail: Journal tail - identifies the oldest still-used block in the
602 * journal.
603 * @j_free: Journal free - how many free blocks are there in the journal?
604 * @j_first: The block number of the first usable block
605 * @j_last: The block number one beyond the last usable block
606 * @j_dev: Device where we store the journal
607 * @j_blocksize: blocksize for the location where we store the journal.
608 * @j_blk_offset: starting block offset for into the device where we store the
609 * journal
610 * @j_fs_dev: Device which holds the client fs. For internal journal this will
611 * be equal to j_dev
612 * @j_maxlen: Total maximum capacity of the journal region on disk.
613 * @j_list_lock: Protects the buffer lists and internal buffer state.
614 * @j_inode: Optional inode where we store the journal. If present, all journal
615 * block numbers are mapped into this inode via bmap().
616 * @j_tail_sequence: Sequence number of the oldest transaction in the log
617 * @j_transaction_sequence: Sequence number of the next transaction to grant
618 * @j_commit_sequence: Sequence number of the most recently committed
619 * transaction
620 * @j_commit_request: Sequence number of the most recent transaction wanting
621 * commit
622 * @j_uuid: Uuid of client object.
623 * @j_task: Pointer to the current commit thread for this journal
624 * @j_max_transaction_buffers: Maximum number of metadata buffers to allow in a
625 * single compound commit transaction
626 * @j_commit_interval: What is the maximum transaction lifetime before we begin
627 * a commit?
628 * @j_commit_timer: The timer used to wakeup the commit thread
629 * @j_revoke_lock: Protect the revoke table
630 * @j_revoke: The revoke table - maintains the list of revoked blocks in the
631 * current transaction.
632 * @j_revoke_table: alternate revoke tables for j_revoke
633 * @j_wbuf: array of buffer_heads for jbd2_journal_commit_transaction
634 * @j_wbufsize: maximum number of buffer_heads allowed in j_wbuf, the
635 * number that will fit in j_blocksize
636 * @j_last_sync_writer: most recent pid which did a synchronous write
637 * @j_private: An opaque pointer to fs-private information.
638 */
639
640struct journal_s
641{
642 /* General journaling state flags [j_state_lock] */
643 unsigned long j_flags;
644
645 /*
646 * Is there an outstanding uncleared error on the journal (from a prior
647 * abort)? [j_state_lock]
648 */
649 int j_errno;
650
651 /* The superblock buffer */
652 struct buffer_head *j_sb_buffer;
653 journal_superblock_t *j_superblock;
654
655 /* Version of the superblock format */
656 int j_format_version;
657
658 /*
659 * Protect the various scalars in the journal
660 */
661 spinlock_t j_state_lock;
662
663 /*
664 * Number of processes waiting to create a barrier lock [j_state_lock]
665 */
666 int j_barrier_count;
667
668 /* The barrier lock itself */
669 struct mutex j_barrier;
670
671 /*
672 * Transactions: The current running transaction...
673 * [j_state_lock] [caller holding open handle]
674 */
675 transaction_t *j_running_transaction;
676
677 /*
678 * the transaction we are pushing to disk
679 * [j_state_lock] [caller holding open handle]
680 */
681 transaction_t *j_committing_transaction;
682
683 /*
684 * ... and a linked circular list of all transactions waiting for
685 * checkpointing. [j_list_lock]
686 */
687 transaction_t *j_checkpoint_transactions;
688
689 /*
690 * Wait queue for waiting for a locked transaction to start committing,
691 * or for a barrier lock to be released
692 */
693 wait_queue_head_t j_wait_transaction_locked;
694
695 /* Wait queue for waiting for checkpointing to complete */
696 wait_queue_head_t j_wait_logspace;
697
698 /* Wait queue for waiting for commit to complete */
699 wait_queue_head_t j_wait_done_commit;
700
701 /* Wait queue to trigger checkpointing */
702 wait_queue_head_t j_wait_checkpoint;
703
704 /* Wait queue to trigger commit */
705 wait_queue_head_t j_wait_commit;
706
707 /* Wait queue to wait for updates to complete */
708 wait_queue_head_t j_wait_updates;
709
710 /* Semaphore for locking against concurrent checkpoints */
711 struct mutex j_checkpoint_mutex;
712
713 /*
714 * Journal head: identifies the first unused block in the journal.
715 * [j_state_lock]
716 */
717 unsigned long j_head;
718
719 /*
720 * Journal tail: identifies the oldest still-used block in the journal.
721 * [j_state_lock]
722 */
723 unsigned long j_tail;
724
725 /*
726 * Journal free: how many free blocks are there in the journal?
727 * [j_state_lock]
728 */
729 unsigned long j_free;
730
731 /*
732 * Journal start and end: the block numbers of the first usable block
733 * and one beyond the last usable block in the journal. [j_state_lock]
734 */
735 unsigned long j_first;
736 unsigned long j_last;
737
738 /*
739 * Device, blocksize and starting block offset for the location where we
740 * store the journal.
741 */
742 struct block_device *j_dev;
743 int j_blocksize;
744 unsigned long long j_blk_offset;
745
746 /*
747 * Device which holds the client fs. For internal journal this will be
748 * equal to j_dev.
749 */
750 struct block_device *j_fs_dev;
751
752 /* Total maximum capacity of the journal region on disk. */
753 unsigned int j_maxlen;
754
755 /*
756 * Protects the buffer lists and internal buffer state.
757 */
758 spinlock_t j_list_lock;
759
760 /* Optional inode where we store the journal. If present, all */
761 /* journal block numbers are mapped into this inode via */
762 /* bmap(). */
763 struct inode *j_inode;
764
765 /*
766 * Sequence number of the oldest transaction in the log [j_state_lock]
767 */
768 tid_t j_tail_sequence;
769
770 /*
771 * Sequence number of the next transaction to grant [j_state_lock]
772 */
773 tid_t j_transaction_sequence;
774
775 /*
776 * Sequence number of the most recently committed transaction
777 * [j_state_lock].
778 */
779 tid_t j_commit_sequence;
780
781 /*
782 * Sequence number of the most recent transaction wanting commit
783 * [j_state_lock]
784 */
785 tid_t j_commit_request;
786
787 /*
788 * Journal uuid: identifies the object (filesystem, LVM volume etc)
789 * backed by this journal. This will eventually be replaced by an array
790 * of uuids, allowing us to index multiple devices within a single
791 * journal and to perform atomic updates across them.
792 */
793 __u8 j_uuid[16];
794
795 /* Pointer to the current commit thread for this journal */
796 struct task_struct *j_task;
797
798 /*
799 * Maximum number of metadata buffers to allow in a single compound
800 * commit transaction
801 */
802 int j_max_transaction_buffers;
803
804 /*
805 * What is the maximum transaction lifetime before we begin a commit?
806 */
807 unsigned long j_commit_interval;
808
809 /* The timer used to wakeup the commit thread: */
810 struct timer_list j_commit_timer;
811
812 /*
813 * The revoke table: maintains the list of revoked blocks in the
814 * current transaction. [j_revoke_lock]
815 */
816 spinlock_t j_revoke_lock;
817 struct jbd2_revoke_table_s *j_revoke;
818 struct jbd2_revoke_table_s *j_revoke_table[2];
819
820 /*
821 * array of bhs for jbd2_journal_commit_transaction
822 */
823 struct buffer_head **j_wbuf;
824 int j_wbufsize;
825
826 pid_t j_last_sync_writer;
827
828 /*
829 * An opaque pointer to fs-private information. ext3 puts its
830 * superblock pointer here
831 */
832 void *j_private;
833};
834
835/*
836 * Journal flag definitions
837 */
838#define JBD2_UNMOUNT 0x001 /* Journal thread is being destroyed */
839#define JBD2_ABORT 0x002 /* Journaling has been aborted for errors. */
840#define JBD2_ACK_ERR 0x004 /* The errno in the sb has been acked */
841#define JBD2_FLUSHED 0x008 /* The journal superblock has been flushed */
842#define JBD2_LOADED 0x010 /* The journal superblock has been loaded */
843#define JBD2_BARRIER 0x020 /* Use IDE barriers */
844
845/*
846 * Function declarations for the journaling transaction and buffer
847 * management
848 */
849
850/* Filing buffers */
851extern void __jbd2_journal_temp_unlink_buffer(struct journal_head *jh);
852extern void jbd2_journal_unfile_buffer(journal_t *, struct journal_head *);
853extern void __jbd2_journal_unfile_buffer(struct journal_head *);
854extern void __jbd2_journal_refile_buffer(struct journal_head *);
855extern void jbd2_journal_refile_buffer(journal_t *, struct journal_head *);
856extern void __jbd2_journal_file_buffer(struct journal_head *, transaction_t *, int);
857extern void __journal_free_buffer(struct journal_head *bh);
858extern void jbd2_journal_file_buffer(struct journal_head *, transaction_t *, int);
859extern void __journal_clean_data_list(transaction_t *transaction);
860
861/* Log buffer allocation */
862extern struct journal_head * jbd2_journal_get_descriptor_buffer(journal_t *);
863int jbd2_journal_next_log_block(journal_t *, unsigned long long *);
864
865/* Commit management */
866extern void jbd2_journal_commit_transaction(journal_t *);
867
868/* Checkpoint list management */
869int __jbd2_journal_clean_checkpoint_list(journal_t *journal);
870int __jbd2_journal_remove_checkpoint(struct journal_head *);
871void __jbd2_journal_insert_checkpoint(struct journal_head *, transaction_t *);
872
873/* Buffer IO */
874extern int
875jbd2_journal_write_metadata_buffer(transaction_t *transaction,
876 struct journal_head *jh_in,
877 struct journal_head **jh_out,
878 unsigned long long blocknr);
879
880/* Transaction locking */
881extern void __wait_on_journal (journal_t *);
882
883/*
884 * Journal locking.
885 *
886 * We need to lock the journal during transaction state changes so that nobody
887 * ever tries to take a handle on the running transaction while we are in the
888 * middle of moving it to the commit phase. j_state_lock does this.
889 *
890 * Note that the locking is completely interrupt unsafe. We never touch
891 * journal structures from interrupts.
892 */
893
894static inline handle_t *journal_current_handle(void)
895{
896 return current->journal_info;
897}
898
899/* The journaling code user interface:
900 *
901 * Create and destroy handles
902 * Register buffer modifications against the current transaction.
903 */
904
905extern handle_t *jbd2_journal_start(journal_t *, int nblocks);
906extern int jbd2_journal_restart (handle_t *, int nblocks);
907extern int jbd2_journal_extend (handle_t *, int nblocks);
908extern int jbd2_journal_get_write_access(handle_t *, struct buffer_head *);
909extern int jbd2_journal_get_create_access (handle_t *, struct buffer_head *);
910extern int jbd2_journal_get_undo_access(handle_t *, struct buffer_head *);
911extern int jbd2_journal_dirty_data (handle_t *, struct buffer_head *);
912extern int jbd2_journal_dirty_metadata (handle_t *, struct buffer_head *);
913extern void jbd2_journal_release_buffer (handle_t *, struct buffer_head *);
914extern int jbd2_journal_forget (handle_t *, struct buffer_head *);
915extern void journal_sync_buffer (struct buffer_head *);
916extern void jbd2_journal_invalidatepage(journal_t *,
917 struct page *, unsigned long);
918extern int jbd2_journal_try_to_free_buffers(journal_t *, struct page *, gfp_t);
919extern int jbd2_journal_stop(handle_t *);
920extern int jbd2_journal_flush (journal_t *);
921extern void jbd2_journal_lock_updates (journal_t *);
922extern void jbd2_journal_unlock_updates (journal_t *);
923
924extern journal_t * jbd2_journal_init_dev(struct block_device *bdev,
925 struct block_device *fs_dev,
926 unsigned long long start, int len, int bsize);
927extern journal_t * jbd2_journal_init_inode (struct inode *);
928extern int jbd2_journal_update_format (journal_t *);
929extern int jbd2_journal_check_used_features
930 (journal_t *, unsigned long, unsigned long, unsigned long);
931extern int jbd2_journal_check_available_features
932 (journal_t *, unsigned long, unsigned long, unsigned long);
933extern int jbd2_journal_set_features
934 (journal_t *, unsigned long, unsigned long, unsigned long);
935extern int jbd2_journal_create (journal_t *);
936extern int jbd2_journal_load (journal_t *journal);
937extern void jbd2_journal_destroy (journal_t *);
938extern int jbd2_journal_recover (journal_t *journal);
939extern int jbd2_journal_wipe (journal_t *, int);
940extern int jbd2_journal_skip_recovery (journal_t *);
941extern void jbd2_journal_update_superblock (journal_t *, int);
942extern void __jbd2_journal_abort_hard (journal_t *);
943extern void jbd2_journal_abort (journal_t *, int);
944extern int jbd2_journal_errno (journal_t *);
945extern void jbd2_journal_ack_err (journal_t *);
946extern int jbd2_journal_clear_err (journal_t *);
947extern int jbd2_journal_bmap(journal_t *, unsigned long, unsigned long long *);
948extern int jbd2_journal_force_commit(journal_t *);
949
950/*
951 * journal_head management
952 */
953struct journal_head *jbd2_journal_add_journal_head(struct buffer_head *bh);
954struct journal_head *jbd2_journal_grab_journal_head(struct buffer_head *bh);
955void jbd2_journal_remove_journal_head(struct buffer_head *bh);
956void jbd2_journal_put_journal_head(struct journal_head *jh);
957
958/*
959 * handle management
960 */
961extern kmem_cache_t *jbd2_handle_cache;
962
963static inline handle_t *jbd_alloc_handle(gfp_t gfp_flags)
964{
965 return kmem_cache_alloc(jbd2_handle_cache, gfp_flags);
966}
967
968static inline void jbd_free_handle(handle_t *handle)
969{
970 kmem_cache_free(jbd2_handle_cache, handle);
971}
972
973/* Primary revoke support */
974#define JOURNAL_REVOKE_DEFAULT_HASH 256
975extern int jbd2_journal_init_revoke(journal_t *, int);
976extern void jbd2_journal_destroy_revoke_caches(void);
977extern int jbd2_journal_init_revoke_caches(void);
978
979extern void jbd2_journal_destroy_revoke(journal_t *);
980extern int jbd2_journal_revoke (handle_t *, unsigned long long, struct buffer_head *);
981extern int jbd2_journal_cancel_revoke(handle_t *, struct journal_head *);
982extern void jbd2_journal_write_revoke_records(journal_t *, transaction_t *);
983
984/* Recovery revoke support */
985extern int jbd2_journal_set_revoke(journal_t *, unsigned long long, tid_t);
986extern int jbd2_journal_test_revoke(journal_t *, unsigned long long, tid_t);
987extern void jbd2_journal_clear_revoke(journal_t *);
988extern void jbd2_journal_switch_revoke_table(journal_t *journal);
989
990/*
991 * The log thread user interface:
992 *
993 * Request space in the current transaction, and force transaction commit
994 * transitions on demand.
995 */
996
997int __jbd2_log_space_left(journal_t *); /* Called with journal locked */
998int jbd2_log_start_commit(journal_t *journal, tid_t tid);
999int __jbd2_log_start_commit(journal_t *journal, tid_t tid);
1000int jbd2_journal_start_commit(journal_t *journal, tid_t *tid);
1001int jbd2_journal_force_commit_nested(journal_t *journal);
1002int jbd2_log_wait_commit(journal_t *journal, tid_t tid);
1003int jbd2_log_do_checkpoint(journal_t *journal);
1004
1005void __jbd2_log_wait_for_space(journal_t *journal);
1006extern void __jbd2_journal_drop_transaction(journal_t *, transaction_t *);
1007extern int jbd2_cleanup_journal_tail(journal_t *);
1008
1009/* Debugging code only: */
1010
1011#define jbd_ENOSYS() \
1012do { \
1013 printk (KERN_ERR "JBD unimplemented function %s\n", __FUNCTION__); \
1014 current->state = TASK_UNINTERRUPTIBLE; \
1015 schedule(); \
1016} while (1)
1017
1018/*
1019 * is_journal_abort
1020 *
1021 * Simple test wrapper function to test the JBD2_ABORT state flag. This
1022 * bit, when set, indicates that we have had a fatal error somewhere,
1023 * either inside the journaling layer or indicated to us by the client
1024 * (eg. ext3), and that we and should not commit any further
1025 * transactions.
1026 */
1027
1028static inline int is_journal_aborted(journal_t *journal)
1029{
1030 return journal->j_flags & JBD2_ABORT;
1031}
1032
1033static inline int is_handle_aborted(handle_t *handle)
1034{
1035 if (handle->h_aborted)
1036 return 1;
1037 return is_journal_aborted(handle->h_transaction->t_journal);
1038}
1039
1040static inline void jbd2_journal_abort_handle(handle_t *handle)
1041{
1042 handle->h_aborted = 1;
1043}
1044
1045#endif /* __KERNEL__ */
1046
1047/* Comparison functions for transaction IDs: perform comparisons using
1048 * modulo arithmetic so that they work over sequence number wraps. */
1049
1050static inline int tid_gt(tid_t x, tid_t y)
1051{
1052 int difference = (x - y);
1053 return (difference > 0);
1054}
1055
1056static inline int tid_geq(tid_t x, tid_t y)
1057{
1058 int difference = (x - y);
1059 return (difference >= 0);
1060}
1061
1062extern int jbd2_journal_blocks_per_page(struct inode *inode);
1063extern size_t journal_tag_bytes(journal_t *journal);
1064
1065/*
1066 * Return the minimum number of blocks which must be free in the journal
1067 * before a new transaction may be started. Must be called under j_state_lock.
1068 */
1069static inline int jbd_space_needed(journal_t *journal)
1070{
1071 int nblocks = journal->j_max_transaction_buffers;
1072 if (journal->j_committing_transaction)
1073 nblocks += journal->j_committing_transaction->
1074 t_outstanding_credits;
1075 return nblocks;
1076}
1077
1078/*
1079 * Definitions which augment the buffer_head layer
1080 */
1081
1082/* journaling buffer types */
1083#define BJ_None 0 /* Not journaled */
1084#define BJ_SyncData 1 /* Normal data: flush before commit */
1085#define BJ_Metadata 2 /* Normal journaled metadata */
1086#define BJ_Forget 3 /* Buffer superseded by this transaction */
1087#define BJ_IO 4 /* Buffer is for temporary IO use */
1088#define BJ_Shadow 5 /* Buffer contents being shadowed to the log */
1089#define BJ_LogCtl 6 /* Buffer contains log descriptors */
1090#define BJ_Reserved 7 /* Buffer is reserved for access by journal */
1091#define BJ_Locked 8 /* Locked for I/O during commit */
1092#define BJ_Types 9
1093
1094extern int jbd_blocks_per_page(struct inode *inode);
1095
1096#ifdef __KERNEL__
1097
1098#define buffer_trace_init(bh) do {} while (0)
1099#define print_buffer_fields(bh) do {} while (0)
1100#define print_buffer_trace(bh) do {} while (0)
1101#define BUFFER_TRACE(bh, info) do {} while (0)
1102#define BUFFER_TRACE2(bh, bh2, info) do {} while (0)
1103#define JBUFFER_TRACE(jh, info) do {} while (0)
1104
1105#endif /* __KERNEL__ */
1106
1107#endif /* _LINUX_JBD_H */
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 80f39cab470a..24b611147adb 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -171,6 +171,8 @@ __attribute_const__ roundup_pow_of_two(unsigned long x)
171 171
172extern int printk_ratelimit(void); 172extern int printk_ratelimit(void);
173extern int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst); 173extern int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst);
174extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
175 unsigned int interval_msec);
174 176
175static inline void console_silent(void) 177static inline void console_silent(void)
176{ 178{
diff --git a/include/linux/libata.h b/include/linux/libata.h
index d0a7ad5ed518..abd2debebca2 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -143,7 +143,7 @@ enum {
143 ATA_DFLAG_CFG_MASK = (1 << 8) - 1, 143 ATA_DFLAG_CFG_MASK = (1 << 8) - 1,
144 144
145 ATA_DFLAG_PIO = (1 << 8), /* device limited to PIO mode */ 145 ATA_DFLAG_PIO = (1 << 8), /* device limited to PIO mode */
146 ATA_DFLAG_NCQ_OFF = (1 << 9), /* devied limited to non-NCQ mode */ 146 ATA_DFLAG_NCQ_OFF = (1 << 9), /* device limited to non-NCQ mode */
147 ATA_DFLAG_SUSPENDED = (1 << 10), /* device suspended */ 147 ATA_DFLAG_SUSPENDED = (1 << 10), /* device suspended */
148 ATA_DFLAG_INIT_MASK = (1 << 16) - 1, 148 ATA_DFLAG_INIT_MASK = (1 << 16) - 1,
149 149
@@ -702,7 +702,6 @@ extern int ata_std_prereset(struct ata_port *ap);
702extern int ata_std_softreset(struct ata_port *ap, unsigned int *classes); 702extern int ata_std_softreset(struct ata_port *ap, unsigned int *classes);
703extern int sata_std_hardreset(struct ata_port *ap, unsigned int *class); 703extern int sata_std_hardreset(struct ata_port *ap, unsigned int *class);
704extern void ata_std_postreset(struct ata_port *ap, unsigned int *classes); 704extern void ata_std_postreset(struct ata_port *ap, unsigned int *classes);
705extern int ata_dev_revalidate(struct ata_device *dev, int post_reset);
706extern void ata_port_disable(struct ata_port *); 705extern void ata_port_disable(struct ata_port *);
707extern void ata_std_ports(struct ata_ioports *ioaddr); 706extern void ata_std_ports(struct ata_ioports *ioaddr);
708#ifdef CONFIG_PCI 707#ifdef CONFIG_PCI
diff --git a/include/linux/lockd/bind.h b/include/linux/lockd/bind.h
index 81e3a185f951..aa50d89eacd7 100644
--- a/include/linux/lockd/bind.h
+++ b/include/linux/lockd/bind.h
@@ -10,6 +10,11 @@
10#define LINUX_LOCKD_BIND_H 10#define LINUX_LOCKD_BIND_H
11 11
12#include <linux/lockd/nlm.h> 12#include <linux/lockd/nlm.h>
13/* need xdr-encoded error codes too, so... */
14#include <linux/lockd/xdr.h>
15#ifdef CONFIG_LOCKD_V4
16#include <linux/lockd/xdr4.h>
17#endif
13 18
14/* Dummy declarations */ 19/* Dummy declarations */
15struct svc_rqst; 20struct svc_rqst;
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index 2909619c0295..862d9730a60d 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -154,7 +154,7 @@ int nlm_async_reply(struct nlm_rqst *, u32, const struct rpc_call_ops *);
154struct nlm_wait * nlmclnt_prepare_block(struct nlm_host *host, struct file_lock *fl); 154struct nlm_wait * nlmclnt_prepare_block(struct nlm_host *host, struct file_lock *fl);
155void nlmclnt_finish_block(struct nlm_wait *block); 155void nlmclnt_finish_block(struct nlm_wait *block);
156int nlmclnt_block(struct nlm_wait *block, struct nlm_rqst *req, long timeout); 156int nlmclnt_block(struct nlm_wait *block, struct nlm_rqst *req, long timeout);
157u32 nlmclnt_grant(const struct sockaddr_in *addr, const struct nlm_lock *); 157__be32 nlmclnt_grant(const struct sockaddr_in *addr, const struct nlm_lock *);
158void nlmclnt_recovery(struct nlm_host *); 158void nlmclnt_recovery(struct nlm_host *);
159int nlmclnt_reclaim(struct nlm_host *, struct file_lock *); 159int nlmclnt_reclaim(struct nlm_host *, struct file_lock *);
160void nlmclnt_next_cookie(struct nlm_cookie *); 160void nlmclnt_next_cookie(struct nlm_cookie *);
@@ -184,12 +184,12 @@ typedef int (*nlm_host_match_fn_t)(struct nlm_host *cur, struct nlm_host *ref)
184/* 184/*
185 * Server-side lock handling 185 * Server-side lock handling
186 */ 186 */
187u32 nlmsvc_lock(struct svc_rqst *, struct nlm_file *, 187__be32 nlmsvc_lock(struct svc_rqst *, struct nlm_file *,
188 struct nlm_lock *, int, struct nlm_cookie *); 188 struct nlm_lock *, int, struct nlm_cookie *);
189u32 nlmsvc_unlock(struct nlm_file *, struct nlm_lock *); 189__be32 nlmsvc_unlock(struct nlm_file *, struct nlm_lock *);
190u32 nlmsvc_testlock(struct nlm_file *, struct nlm_lock *, 190__be32 nlmsvc_testlock(struct nlm_file *, struct nlm_lock *,
191 struct nlm_lock *); 191 struct nlm_lock *);
192u32 nlmsvc_cancel_blocked(struct nlm_file *, struct nlm_lock *); 192__be32 nlmsvc_cancel_blocked(struct nlm_file *, struct nlm_lock *);
193unsigned long nlmsvc_retry_blocked(void); 193unsigned long nlmsvc_retry_blocked(void);
194void nlmsvc_traverse_blocks(struct nlm_host *, struct nlm_file *, 194void nlmsvc_traverse_blocks(struct nlm_host *, struct nlm_file *,
195 nlm_host_match_fn_t match); 195 nlm_host_match_fn_t match);
@@ -198,7 +198,7 @@ void nlmsvc_grant_reply(struct nlm_cookie *, u32);
198/* 198/*
199 * File handling for the server personality 199 * File handling for the server personality
200 */ 200 */
201u32 nlm_lookup_file(struct svc_rqst *, struct nlm_file **, 201__be32 nlm_lookup_file(struct svc_rqst *, struct nlm_file **,
202 struct nfs_fh *); 202 struct nfs_fh *);
203void nlm_release_file(struct nlm_file *); 203void nlm_release_file(struct nlm_file *);
204void nlmsvc_mark_resources(void); 204void nlmsvc_mark_resources(void);
diff --git a/include/linux/lockd/share.h b/include/linux/lockd/share.h
index cd7816e74c05..630c5bf69b07 100644
--- a/include/linux/lockd/share.h
+++ b/include/linux/lockd/share.h
@@ -21,9 +21,9 @@ struct nlm_share {
21 u32 s_mode; /* deny mode */ 21 u32 s_mode; /* deny mode */
22}; 22};
23 23
24u32 nlmsvc_share_file(struct nlm_host *, struct nlm_file *, 24__be32 nlmsvc_share_file(struct nlm_host *, struct nlm_file *,
25 struct nlm_args *); 25 struct nlm_args *);
26u32 nlmsvc_unshare_file(struct nlm_host *, struct nlm_file *, 26__be32 nlmsvc_unshare_file(struct nlm_host *, struct nlm_file *,
27 struct nlm_args *); 27 struct nlm_args *);
28void nlmsvc_traverse_shares(struct nlm_host *, struct nlm_file *, 28void nlmsvc_traverse_shares(struct nlm_host *, struct nlm_file *,
29 nlm_host_match_fn_t); 29 nlm_host_match_fn_t);
diff --git a/include/linux/lockd/xdr.h b/include/linux/lockd/xdr.h
index bb0a0f1caa91..29e7d9fc9dad 100644
--- a/include/linux/lockd/xdr.h
+++ b/include/linux/lockd/xdr.h
@@ -13,6 +13,8 @@
13#include <linux/nfs.h> 13#include <linux/nfs.h>
14#include <linux/sunrpc/xdr.h> 14#include <linux/sunrpc/xdr.h>
15 15
16struct svc_rqst;
17
16#define NLM_MAXCOOKIELEN 32 18#define NLM_MAXCOOKIELEN 32
17#define NLM_MAXSTRLEN 1024 19#define NLM_MAXSTRLEN 1024
18 20
@@ -22,6 +24,8 @@
22#define nlm_lck_blocked __constant_htonl(NLM_LCK_BLOCKED) 24#define nlm_lck_blocked __constant_htonl(NLM_LCK_BLOCKED)
23#define nlm_lck_denied_grace_period __constant_htonl(NLM_LCK_DENIED_GRACE_PERIOD) 25#define nlm_lck_denied_grace_period __constant_htonl(NLM_LCK_DENIED_GRACE_PERIOD)
24 26
27#define nlm_drop_reply __constant_htonl(30000)
28
25/* Lock info passed via NLM */ 29/* Lock info passed via NLM */
26struct nlm_lock { 30struct nlm_lock {
27 char * caller; 31 char * caller;
@@ -86,19 +90,19 @@ struct nlm_reboot {
86 */ 90 */
87#define NLMSVC_XDRSIZE sizeof(struct nlm_args) 91#define NLMSVC_XDRSIZE sizeof(struct nlm_args)
88 92
89int nlmsvc_decode_testargs(struct svc_rqst *, u32 *, struct nlm_args *); 93int nlmsvc_decode_testargs(struct svc_rqst *, __be32 *, struct nlm_args *);
90int nlmsvc_encode_testres(struct svc_rqst *, u32 *, struct nlm_res *); 94int nlmsvc_encode_testres(struct svc_rqst *, __be32 *, struct nlm_res *);
91int nlmsvc_decode_lockargs(struct svc_rqst *, u32 *, struct nlm_args *); 95int nlmsvc_decode_lockargs(struct svc_rqst *, __be32 *, struct nlm_args *);
92int nlmsvc_decode_cancargs(struct svc_rqst *, u32 *, struct nlm_args *); 96int nlmsvc_decode_cancargs(struct svc_rqst *, __be32 *, struct nlm_args *);
93int nlmsvc_decode_unlockargs(struct svc_rqst *, u32 *, struct nlm_args *); 97int nlmsvc_decode_unlockargs(struct svc_rqst *, __be32 *, struct nlm_args *);
94int nlmsvc_encode_res(struct svc_rqst *, u32 *, struct nlm_res *); 98int nlmsvc_encode_res(struct svc_rqst *, __be32 *, struct nlm_res *);
95int nlmsvc_decode_res(struct svc_rqst *, u32 *, struct nlm_res *); 99int nlmsvc_decode_res(struct svc_rqst *, __be32 *, struct nlm_res *);
96int nlmsvc_encode_void(struct svc_rqst *, u32 *, void *); 100int nlmsvc_encode_void(struct svc_rqst *, __be32 *, void *);
97int nlmsvc_decode_void(struct svc_rqst *, u32 *, void *); 101int nlmsvc_decode_void(struct svc_rqst *, __be32 *, void *);
98int nlmsvc_decode_shareargs(struct svc_rqst *, u32 *, struct nlm_args *); 102int nlmsvc_decode_shareargs(struct svc_rqst *, __be32 *, struct nlm_args *);
99int nlmsvc_encode_shareres(struct svc_rqst *, u32 *, struct nlm_res *); 103int nlmsvc_encode_shareres(struct svc_rqst *, __be32 *, struct nlm_res *);
100int nlmsvc_decode_notify(struct svc_rqst *, u32 *, struct nlm_args *); 104int nlmsvc_decode_notify(struct svc_rqst *, __be32 *, struct nlm_args *);
101int nlmsvc_decode_reboot(struct svc_rqst *, u32 *, struct nlm_reboot *); 105int nlmsvc_decode_reboot(struct svc_rqst *, __be32 *, struct nlm_reboot *);
102/* 106/*
103int nlmclt_encode_testargs(struct rpc_rqst *, u32 *, struct nlm_args *); 107int nlmclt_encode_testargs(struct rpc_rqst *, u32 *, struct nlm_args *);
104int nlmclt_encode_lockargs(struct rpc_rqst *, u32 *, struct nlm_args *); 108int nlmclt_encode_lockargs(struct rpc_rqst *, u32 *, struct nlm_args *);
diff --git a/include/linux/lockd/xdr4.h b/include/linux/lockd/xdr4.h
index 3cc1ae25009b..dd12b4c9e613 100644
--- a/include/linux/lockd/xdr4.h
+++ b/include/linux/lockd/xdr4.h
@@ -23,19 +23,19 @@
23 23
24 24
25 25
26int nlm4svc_decode_testargs(struct svc_rqst *, u32 *, struct nlm_args *); 26int nlm4svc_decode_testargs(struct svc_rqst *, __be32 *, struct nlm_args *);
27int nlm4svc_encode_testres(struct svc_rqst *, u32 *, struct nlm_res *); 27int nlm4svc_encode_testres(struct svc_rqst *, __be32 *, struct nlm_res *);
28int nlm4svc_decode_lockargs(struct svc_rqst *, u32 *, struct nlm_args *); 28int nlm4svc_decode_lockargs(struct svc_rqst *, __be32 *, struct nlm_args *);
29int nlm4svc_decode_cancargs(struct svc_rqst *, u32 *, struct nlm_args *); 29int nlm4svc_decode_cancargs(struct svc_rqst *, __be32 *, struct nlm_args *);
30int nlm4svc_decode_unlockargs(struct svc_rqst *, u32 *, struct nlm_args *); 30int nlm4svc_decode_unlockargs(struct svc_rqst *, __be32 *, struct nlm_args *);
31int nlm4svc_encode_res(struct svc_rqst *, u32 *, struct nlm_res *); 31int nlm4svc_encode_res(struct svc_rqst *, __be32 *, struct nlm_res *);
32int nlm4svc_decode_res(struct svc_rqst *, u32 *, struct nlm_res *); 32int nlm4svc_decode_res(struct svc_rqst *, __be32 *, struct nlm_res *);
33int nlm4svc_encode_void(struct svc_rqst *, u32 *, void *); 33int nlm4svc_encode_void(struct svc_rqst *, __be32 *, void *);
34int nlm4svc_decode_void(struct svc_rqst *, u32 *, void *); 34int nlm4svc_decode_void(struct svc_rqst *, __be32 *, void *);
35int nlm4svc_decode_shareargs(struct svc_rqst *, u32 *, struct nlm_args *); 35int nlm4svc_decode_shareargs(struct svc_rqst *, __be32 *, struct nlm_args *);
36int nlm4svc_encode_shareres(struct svc_rqst *, u32 *, struct nlm_res *); 36int nlm4svc_encode_shareres(struct svc_rqst *, __be32 *, struct nlm_res *);
37int nlm4svc_decode_notify(struct svc_rqst *, u32 *, struct nlm_args *); 37int nlm4svc_decode_notify(struct svc_rqst *, __be32 *, struct nlm_args *);
38int nlm4svc_decode_reboot(struct svc_rqst *, u32 *, struct nlm_reboot *); 38int nlm4svc_decode_reboot(struct svc_rqst *, __be32 *, struct nlm_reboot *);
39/* 39/*
40int nlmclt_encode_testargs(struct rpc_rqst *, u32 *, struct nlm_args *); 40int nlmclt_encode_testargs(struct rpc_rqst *, u32 *, struct nlm_args *);
41int nlmclt_encode_lockargs(struct rpc_rqst *, u32 *, struct nlm_args *); 41int nlmclt_encode_lockargs(struct rpc_rqst *, u32 *, struct nlm_args *);
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index 1314ca0f29be..819f08f1310d 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -202,7 +202,7 @@ extern int lockdep_internal(void);
202 */ 202 */
203 203
204extern void lockdep_init_map(struct lockdep_map *lock, const char *name, 204extern void lockdep_init_map(struct lockdep_map *lock, const char *name,
205 struct lock_class_key *key); 205 struct lock_class_key *key, int subclass);
206 206
207/* 207/*
208 * Reinitialize a lock key - for cases where there is special locking or 208 * Reinitialize a lock key - for cases where there is special locking or
@@ -211,9 +211,14 @@ extern void lockdep_init_map(struct lockdep_map *lock, const char *name,
211 * or they are too narrow (they suffer from a false class-split): 211 * or they are too narrow (they suffer from a false class-split):
212 */ 212 */
213#define lockdep_set_class(lock, key) \ 213#define lockdep_set_class(lock, key) \
214 lockdep_init_map(&(lock)->dep_map, #key, key) 214 lockdep_init_map(&(lock)->dep_map, #key, key, 0)
215#define lockdep_set_class_and_name(lock, key, name) \ 215#define lockdep_set_class_and_name(lock, key, name) \
216 lockdep_init_map(&(lock)->dep_map, name, key) 216 lockdep_init_map(&(lock)->dep_map, name, key, 0)
217#define lockdep_set_class_and_subclass(lock, key, sub) \
218 lockdep_init_map(&(lock)->dep_map, #key, key, sub)
219#define lockdep_set_subclass(lock, sub) \
220 lockdep_init_map(&(lock)->dep_map, #lock, \
221 (lock)->dep_map.key, sub)
217 222
218/* 223/*
219 * Acquire a lock. 224 * Acquire a lock.
@@ -257,10 +262,14 @@ static inline int lockdep_internal(void)
257# define lock_release(l, n, i) do { } while (0) 262# define lock_release(l, n, i) do { } while (0)
258# define lockdep_init() do { } while (0) 263# define lockdep_init() do { } while (0)
259# define lockdep_info() do { } while (0) 264# define lockdep_info() do { } while (0)
260# define lockdep_init_map(lock, name, key) do { (void)(key); } while (0) 265# define lockdep_init_map(lock, name, key, sub) do { (void)(key); } while (0)
261# define lockdep_set_class(lock, key) do { (void)(key); } while (0) 266# define lockdep_set_class(lock, key) do { (void)(key); } while (0)
262# define lockdep_set_class_and_name(lock, key, name) \ 267# define lockdep_set_class_and_name(lock, key, name) \
263 do { (void)(key); } while (0) 268 do { (void)(key); } while (0)
269#define lockdep_set_class_and_subclass(lock, key, sub) \
270 do { (void)(key); } while (0)
271#define lockdep_set_subclass(lock, sub) do { } while (0)
272
264# define INIT_LOCKDEP 273# define INIT_LOCKDEP
265# define lockdep_reset() do { debug_locks = 1; } while (0) 274# define lockdep_reset() do { debug_locks = 1; } while (0)
266# define lockdep_free_key_range(start, size) do { } while (0) 275# define lockdep_free_key_range(start, size) do { } while (0)
diff --git a/include/linux/magic.h b/include/linux/magic.h
index 22036dd2ba36..156c40fc664e 100644
--- a/include/linux/magic.h
+++ b/include/linux/magic.h
@@ -8,6 +8,7 @@
8#define EFS_SUPER_MAGIC 0x414A53 8#define EFS_SUPER_MAGIC 0x414A53
9#define EXT2_SUPER_MAGIC 0xEF53 9#define EXT2_SUPER_MAGIC 0xEF53
10#define EXT3_SUPER_MAGIC 0xEF53 10#define EXT3_SUPER_MAGIC 0xEF53
11#define EXT4_SUPER_MAGIC 0xEF53
11#define HPFS_SUPER_MAGIC 0xf995e849 12#define HPFS_SUPER_MAGIC 0xf995e849
12#define ISOFS_SUPER_MAGIC 0x9660 13#define ISOFS_SUPER_MAGIC 0x9660
13#define JFFS2_SUPER_MAGIC 0x72b6 14#define JFFS2_SUPER_MAGIC 0x72b6
diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
index 09f0f575ddff..daabb3aa1ec6 100644
--- a/include/linux/mempolicy.h
+++ b/include/linux/mempolicy.h
@@ -150,7 +150,7 @@ extern void mpol_rebind_mm(struct mm_struct *mm, nodemask_t *new);
150extern void mpol_fix_fork_child_flag(struct task_struct *p); 150extern void mpol_fix_fork_child_flag(struct task_struct *p);
151#define set_cpuset_being_rebound(x) (cpuset_being_rebound = (x)) 151#define set_cpuset_being_rebound(x) (cpuset_being_rebound = (x))
152 152
153#ifdef CONFIG_CPUSET 153#ifdef CONFIG_CPUSETS
154#define current_cpuset_is_being_rebound() \ 154#define current_cpuset_is_being_rebound() \
155 (cpuset_being_rebound == current->cpuset) 155 (cpuset_being_rebound == current->cpuset)
156#else 156#else
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 26146623be2f..d538de901965 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1103,12 +1103,7 @@ static inline void vm_stat_account(struct mm_struct *mm,
1103 1103
1104#ifndef CONFIG_DEBUG_PAGEALLOC 1104#ifndef CONFIG_DEBUG_PAGEALLOC
1105static inline void 1105static inline void
1106kernel_map_pages(struct page *page, int numpages, int enable) 1106kernel_map_pages(struct page *page, int numpages, int enable) {}
1107{
1108 if (!PageHighMem(page) && !enable)
1109 debug_check_no_locks_freed(page_address(page),
1110 numpages * PAGE_SIZE);
1111}
1112#endif 1107#endif
1113 1108
1114extern struct vm_area_struct *get_gate_vma(struct task_struct *tsk); 1109extern struct vm_area_struct *get_gate_vma(struct task_struct *tsk);
@@ -1120,9 +1115,6 @@ int in_gate_area_no_task(unsigned long addr);
1120#define in_gate_area(task, addr) ({(void)task; in_gate_area_no_task(addr);}) 1115#define in_gate_area(task, addr) ({(void)task; in_gate_area_no_task(addr);})
1121#endif /* __HAVE_ARCH_GATE_AREA */ 1116#endif /* __HAVE_ARCH_GATE_AREA */
1122 1117
1123/* /proc/<pid>/oom_adj set to -17 protects from the oom-killer */
1124#define OOM_DISABLE -17
1125
1126int drop_caches_sysctl_handler(struct ctl_table *, int, struct file *, 1118int drop_caches_sysctl_handler(struct ctl_table *, int, struct file *,
1127 void __user *, size_t *, loff_t *); 1119 void __user *, size_t *, loff_t *);
1128unsigned long shrink_slab(unsigned long scanned, gfp_t gfp_mask, 1120unsigned long shrink_slab(unsigned long scanned, gfp_t gfp_mask,
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 59855b8718a0..e06683e2bea3 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -218,13 +218,9 @@ struct zone {
218 * under - it drives the swappiness decision: whether to unmap mapped 218 * under - it drives the swappiness decision: whether to unmap mapped
219 * pages. 219 * pages.
220 * 220 *
221 * temp_priority is used to remember the scanning priority at which 221 * Access to both this field is quite racy even on uniprocessor. But
222 * this zone was successfully refilled to free_pages == pages_high.
223 *
224 * Access to both these fields is quite racy even on uniprocessor. But
225 * it is expected to average out OK. 222 * it is expected to average out OK.
226 */ 223 */
227 int temp_priority;
228 int prev_priority; 224 int prev_priority;
229 225
230 226
@@ -674,6 +670,12 @@ void sparse_init(void);
674#define sparse_index_init(_sec, _nid) do {} while (0) 670#define sparse_index_init(_sec, _nid) do {} while (0)
675#endif /* CONFIG_SPARSEMEM */ 671#endif /* CONFIG_SPARSEMEM */
676 672
673#ifdef CONFIG_NODES_SPAN_OTHER_NODES
674#define early_pfn_in_nid(pfn, nid) (early_pfn_to_nid(pfn) == (nid))
675#else
676#define early_pfn_in_nid(pfn, nid) (1)
677#endif
678
677#ifndef early_pfn_valid 679#ifndef early_pfn_valid
678#define early_pfn_valid(pfn) (1) 680#define early_pfn_valid(pfn) (1)
679#endif 681#endif
diff --git a/include/linux/module.h b/include/linux/module.h
index 4b2d8091a410..d1d00ce8f4ed 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -317,9 +317,6 @@ struct module
317 /* Am I unsafe to unload? */ 317 /* Am I unsafe to unload? */
318 int unsafe; 318 int unsafe;
319 319
320 /* Am I GPL-compatible */
321 int license_gplok;
322
323 unsigned int taints; /* same bits as kernel:tainted */ 320 unsigned int taints; /* same bits as kernel:tainted */
324 321
325#ifdef CONFIG_MODULE_UNLOAD 322#ifdef CONFIG_MODULE_UNLOAD
diff --git a/include/linux/msdos_fs.h b/include/linux/msdos_fs.h
index ce6c85815cbd..24a9ef1506b6 100644
--- a/include/linux/msdos_fs.h
+++ b/include/linux/msdos_fs.h
@@ -402,6 +402,8 @@ extern const struct file_operations fat_file_operations;
402extern struct inode_operations fat_file_inode_operations; 402extern struct inode_operations fat_file_inode_operations;
403extern int fat_notify_change(struct dentry * dentry, struct iattr * attr); 403extern int fat_notify_change(struct dentry * dentry, struct iattr * attr);
404extern void fat_truncate(struct inode *inode); 404extern void fat_truncate(struct inode *inode);
405extern int fat_getattr(struct vfsmount *mnt, struct dentry *dentry,
406 struct kstat *stat);
405 407
406/* fat/inode.c */ 408/* fat/inode.c */
407extern void fat_attach(struct inode *inode, loff_t i_pos); 409extern void fat_attach(struct inode *inode, loff_t i_pos);
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 70420bbae82b..8b3ef4187219 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -355,7 +355,7 @@ struct nand_buffers {
355 * @priv: [OPTIONAL] pointer to private chip date 355 * @priv: [OPTIONAL] pointer to private chip date
356 * @errstat: [OPTIONAL] hardware specific function to perform additional error status checks 356 * @errstat: [OPTIONAL] hardware specific function to perform additional error status checks
357 * (determine if errors are correctable) 357 * (determine if errors are correctable)
358 * @write_page [REPLACEABLE] High-level page write function 358 * @write_page: [REPLACEABLE] High-level page write function
359 */ 359 */
360 360
361struct nand_chip { 361struct nand_chip {
diff --git a/include/linux/nbd.h b/include/linux/nbd.h
index e712e7d47cc2..d6b6dc09ad97 100644
--- a/include/linux/nbd.h
+++ b/include/linux/nbd.h
@@ -15,6 +15,8 @@
15#ifndef LINUX_NBD_H 15#ifndef LINUX_NBD_H
16#define LINUX_NBD_H 16#define LINUX_NBD_H
17 17
18#include <linux/types.h>
19
18#define NBD_SET_SOCK _IO( 0xab, 0 ) 20#define NBD_SET_SOCK _IO( 0xab, 0 )
19#define NBD_SET_BLKSIZE _IO( 0xab, 1 ) 21#define NBD_SET_BLKSIZE _IO( 0xab, 1 )
20#define NBD_SET_SIZE _IO( 0xab, 2 ) 22#define NBD_SET_SIZE _IO( 0xab, 2 )
diff --git a/include/linux/net.h b/include/linux/net.h
index c257f716e00f..15c733b816f0 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -19,6 +19,7 @@
19#define _LINUX_NET_H 19#define _LINUX_NET_H
20 20
21#include <linux/wait.h> 21#include <linux/wait.h>
22#include <linux/random.h>
22#include <asm/socket.h> 23#include <asm/socket.h>
23 24
24struct poll_table_struct; 25struct poll_table_struct;
@@ -193,9 +194,9 @@ extern int sock_map_fd(struct socket *sock);
193extern struct socket *sockfd_lookup(int fd, int *err); 194extern struct socket *sockfd_lookup(int fd, int *err);
194#define sockfd_put(sock) fput(sock->file) 195#define sockfd_put(sock) fput(sock->file)
195extern int net_ratelimit(void); 196extern int net_ratelimit(void);
196extern unsigned long net_random(void); 197
197extern void net_srandom(unsigned long); 198#define net_random() random32()
198extern void net_random_init(void); 199#define net_srandom(seed) srandom32(seed)
199 200
200extern int kernel_sendmsg(struct socket *sock, struct msghdr *msg, 201extern int kernel_sendmsg(struct socket *sock, struct msghdr *msg,
201 struct kvec *vec, size_t num, size_t len); 202 struct kvec *vec, size_t num, size_t len);
diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h
index 04319a76103a..022edfa97ed9 100644
--- a/include/linux/netfilter/x_tables.h
+++ b/include/linux/netfilter/x_tables.h
@@ -96,22 +96,6 @@ struct _xt_align
96/* Error verdict. */ 96/* Error verdict. */
97#define XT_ERROR_TARGET "ERROR" 97#define XT_ERROR_TARGET "ERROR"
98 98
99/*
100 * New IP firewall options for [gs]etsockopt at the RAW IP level.
101 * Unlike BSD Linux inherits IP options so you don't have to use a raw
102 * socket for this. Instead we check rights in the calls. */
103#define XT_BASE_CTL 64 /* base for firewall socket options */
104
105#define XT_SO_SET_REPLACE (XT_BASE_CTL)
106#define XT_SO_SET_ADD_COUNTERS (XT_BASE_CTL + 1)
107#define XT_SO_SET_MAX XT_SO_SET_ADD_COUNTERS
108
109#define XT_SO_GET_INFO (XT_BASE_CTL)
110#define XT_SO_GET_ENTRIES (XT_BASE_CTL + 1)
111#define XT_SO_GET_REVISION_MATCH (XT_BASE_CTL + 2)
112#define XT_SO_GET_REVISION_TARGET (XT_BASE_CTL + 3)
113#define XT_SO_GET_MAX XT_SO_GET_REVISION_TARGET
114
115#define SET_COUNTER(c,b,p) do { (c).bcnt = (b); (c).pcnt = (p); } while(0) 99#define SET_COUNTER(c,b,p) do { (c).bcnt = (b); (c).pcnt = (p); } while(0)
116#define ADD_COUNTER(c,b,p) do { (c).bcnt += (b); (c).pcnt += (p); } while(0) 100#define ADD_COUNTER(c,b,p) do { (c).bcnt += (b); (c).pcnt += (p); } while(0)
117 101
diff --git a/include/linux/netfilter_arp/arp_tables.h b/include/linux/netfilter_arp/arp_tables.h
index 44e39b61d9e7..0be235418a2f 100644
--- a/include/linux/netfilter_arp/arp_tables.h
+++ b/include/linux/netfilter_arp/arp_tables.h
@@ -112,19 +112,20 @@ struct arpt_entry
112 * New IP firewall options for [gs]etsockopt at the RAW IP level. 112 * New IP firewall options for [gs]etsockopt at the RAW IP level.
113 * Unlike BSD Linux inherits IP options so you don't have to use a raw 113 * Unlike BSD Linux inherits IP options so you don't have to use a raw
114 * socket for this. Instead we check rights in the calls. 114 * socket for this. Instead we check rights in the calls.
115 *
116 * ATTENTION: check linux/in.h before adding new number here.
115 */ 117 */
116#define ARPT_CTL_OFFSET 32 118#define ARPT_BASE_CTL 96
117#define ARPT_BASE_CTL (XT_BASE_CTL+ARPT_CTL_OFFSET) 119
118 120#define ARPT_SO_SET_REPLACE (ARPT_BASE_CTL)
119#define ARPT_SO_SET_REPLACE (XT_SO_SET_REPLACE+ARPT_CTL_OFFSET) 121#define ARPT_SO_SET_ADD_COUNTERS (ARPT_BASE_CTL + 1)
120#define ARPT_SO_SET_ADD_COUNTERS (XT_SO_SET_ADD_COUNTERS+ARPT_CTL_OFFSET) 122#define ARPT_SO_SET_MAX ARPT_SO_SET_ADD_COUNTERS
121#define ARPT_SO_SET_MAX (XT_SO_SET_MAX+ARPT_CTL_OFFSET) 123
122 124#define ARPT_SO_GET_INFO (ARPT_BASE_CTL)
123#define ARPT_SO_GET_INFO (XT_SO_GET_INFO+ARPT_CTL_OFFSET) 125#define ARPT_SO_GET_ENTRIES (ARPT_BASE_CTL + 1)
124#define ARPT_SO_GET_ENTRIES (XT_SO_GET_ENTRIES+ARPT_CTL_OFFSET) 126/* #define ARPT_SO_GET_REVISION_MATCH (APRT_BASE_CTL + 2) */
125/* #define ARPT_SO_GET_REVISION_MATCH XT_SO_GET_REVISION_MATCH */ 127#define ARPT_SO_GET_REVISION_TARGET (ARPT_BASE_CTL + 3)
126#define ARPT_SO_GET_REVISION_TARGET (XT_SO_GET_REVISION_TARGET+ARPT_CTL_OFFSET) 128#define ARPT_SO_GET_MAX (ARPT_SO_GET_REVISION_TARGET)
127#define ARPT_SO_GET_MAX (XT_SO_GET_REVISION_TARGET+ARPT_CTL_OFFSET)
128 129
129/* CONTINUE verdict for targets */ 130/* CONTINUE verdict for targets */
130#define ARPT_CONTINUE XT_CONTINUE 131#define ARPT_CONTINUE XT_CONTINUE
diff --git a/include/linux/netfilter_ipv4/ip_tables.h b/include/linux/netfilter_ipv4/ip_tables.h
index a536bbdef145..4f06dad0bde9 100644
--- a/include/linux/netfilter_ipv4/ip_tables.h
+++ b/include/linux/netfilter_ipv4/ip_tables.h
@@ -101,18 +101,21 @@ struct ipt_entry
101/* 101/*
102 * New IP firewall options for [gs]etsockopt at the RAW IP level. 102 * New IP firewall options for [gs]etsockopt at the RAW IP level.
103 * Unlike BSD Linux inherits IP options so you don't have to use a raw 103 * Unlike BSD Linux inherits IP options so you don't have to use a raw
104 * socket for this. Instead we check rights in the calls. */ 104 * socket for this. Instead we check rights in the calls.
105#define IPT_BASE_CTL XT_BASE_CTL 105 *
106 106 * ATTENTION: check linux/in.h before adding new number here.
107#define IPT_SO_SET_REPLACE XT_SO_SET_REPLACE 107 */
108#define IPT_SO_SET_ADD_COUNTERS XT_SO_SET_ADD_COUNTERS 108#define IPT_BASE_CTL 64
109#define IPT_SO_SET_MAX XT_SO_SET_MAX 109
110 110#define IPT_SO_SET_REPLACE (IPT_BASE_CTL)
111#define IPT_SO_GET_INFO XT_SO_GET_INFO 111#define IPT_SO_SET_ADD_COUNTERS (IPT_BASE_CTL + 1)
112#define IPT_SO_GET_ENTRIES XT_SO_GET_ENTRIES 112#define IPT_SO_SET_MAX IPT_SO_SET_ADD_COUNTERS
113#define IPT_SO_GET_REVISION_MATCH XT_SO_GET_REVISION_MATCH 113
114#define IPT_SO_GET_REVISION_TARGET XT_SO_GET_REVISION_TARGET 114#define IPT_SO_GET_INFO (IPT_BASE_CTL)
115#define IPT_SO_GET_MAX XT_SO_GET_REVISION_TARGET 115#define IPT_SO_GET_ENTRIES (IPT_BASE_CTL + 1)
116#define IPT_SO_GET_REVISION_MATCH (IPT_BASE_CTL + 2)
117#define IPT_SO_GET_REVISION_TARGET (IPT_BASE_CTL + 3)
118#define IPT_SO_GET_MAX IPT_SO_GET_REVISION_TARGET
116 119
117#define IPT_CONTINUE XT_CONTINUE 120#define IPT_CONTINUE XT_CONTINUE
118#define IPT_RETURN XT_RETURN 121#define IPT_RETURN XT_RETURN
diff --git a/include/linux/netfilter_ipv6/ip6_tables.h b/include/linux/netfilter_ipv6/ip6_tables.h
index d7a8e9c0dad0..4aed340401db 100644
--- a/include/linux/netfilter_ipv6/ip6_tables.h
+++ b/include/linux/netfilter_ipv6/ip6_tables.h
@@ -107,18 +107,21 @@ struct ip6t_entry
107/* 107/*
108 * New IP firewall options for [gs]etsockopt at the RAW IP level. 108 * New IP firewall options for [gs]etsockopt at the RAW IP level.
109 * Unlike BSD Linux inherits IP options so you don't have to use 109 * Unlike BSD Linux inherits IP options so you don't have to use
110 * a raw socket for this. Instead we check rights in the calls. */ 110 * a raw socket for this. Instead we check rights in the calls.
111#define IP6T_BASE_CTL XT_BASE_CTL 111 *
112 112 * ATTENTION: check linux/in6.h before adding new number here.
113#define IP6T_SO_SET_REPLACE XT_SO_SET_REPLACE 113 */
114#define IP6T_SO_SET_ADD_COUNTERS XT_SO_SET_ADD_COUNTERS 114#define IP6T_BASE_CTL 64
115#define IP6T_SO_SET_MAX XT_SO_SET_MAX 115
116 116#define IP6T_SO_SET_REPLACE (IP6T_BASE_CTL)
117#define IP6T_SO_GET_INFO XT_SO_GET_INFO 117#define IP6T_SO_SET_ADD_COUNTERS (IP6T_BASE_CTL + 1)
118#define IP6T_SO_GET_ENTRIES XT_SO_GET_ENTRIES 118#define IP6T_SO_SET_MAX IP6T_SO_SET_ADD_COUNTERS
119#define IP6T_SO_GET_REVISION_MATCH XT_SO_GET_REVISION_MATCH 119
120#define IP6T_SO_GET_REVISION_TARGET XT_SO_GET_REVISION_TARGET 120#define IP6T_SO_GET_INFO (IP6T_BASE_CTL)
121#define IP6T_SO_GET_MAX XT_SO_GET_REVISION_TARGET 121#define IP6T_SO_GET_ENTRIES (IP6T_BASE_CTL + 1)
122#define IP6T_SO_GET_REVISION_MATCH (IP6T_BASE_CTL + 4)
123#define IP6T_SO_GET_REVISION_TARGET (IP6T_BASE_CTL + 5)
124#define IP6T_SO_GET_MAX IP6T_SO_GET_REVISION_TARGET
122 125
123/* CONTINUE verdict for targets */ 126/* CONTINUE verdict for targets */
124#define IP6T_CONTINUE XT_CONTINUE 127#define IP6T_CONTINUE XT_CONTINUE
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index 76ff54846ada..45228c1a1195 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -157,7 +157,7 @@ struct nfs_inode {
157 * This is the cookie verifier used for NFSv3 readdir 157 * This is the cookie verifier used for NFSv3 readdir
158 * operations 158 * operations
159 */ 159 */
160 __u32 cookieverf[2]; 160 __be32 cookieverf[2];
161 161
162 /* 162 /*
163 * This is the list of dirty unwritten pages. 163 * This is the list of dirty unwritten pages.
@@ -290,6 +290,7 @@ static inline int nfs_verify_change_attribute(struct inode *inode, unsigned long
290 * linux/fs/nfs/inode.c 290 * linux/fs/nfs/inode.c
291 */ 291 */
292extern int nfs_sync_mapping(struct address_space *mapping); 292extern int nfs_sync_mapping(struct address_space *mapping);
293extern void nfs_zap_mapping(struct inode *inode, struct address_space *mapping);
293extern void nfs_zap_caches(struct inode *); 294extern void nfs_zap_caches(struct inode *);
294extern struct inode *nfs_fhget(struct super_block *, struct nfs_fh *, 295extern struct inode *nfs_fhget(struct super_block *, struct nfs_fh *,
295 struct nfs_fattr *); 296 struct nfs_fattr *);
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index dc5397d9d23c..768c1ad5ff6f 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -266,7 +266,7 @@ struct nfs_writeargs {
266 266
267struct nfs_writeverf { 267struct nfs_writeverf {
268 enum nfs3_stable_how committed; 268 enum nfs3_stable_how committed;
269 __u32 verifier[2]; 269 __be32 verifier[2];
270}; 270};
271 271
272struct nfs_writeres { 272struct nfs_writeres {
@@ -420,7 +420,7 @@ struct nfs3_createargs {
420 unsigned int len; 420 unsigned int len;
421 struct iattr * sattr; 421 struct iattr * sattr;
422 enum nfs3_createmode createmode; 422 enum nfs3_createmode createmode;
423 __u32 verifier[2]; 423 __be32 verifier[2];
424}; 424};
425 425
426struct nfs3_mkdirargs { 426struct nfs3_mkdirargs {
@@ -467,7 +467,7 @@ struct nfs3_linkargs {
467struct nfs3_readdirargs { 467struct nfs3_readdirargs {
468 struct nfs_fh * fh; 468 struct nfs_fh * fh;
469 __u64 cookie; 469 __u64 cookie;
470 __u32 verf[2]; 470 __be32 verf[2];
471 int plus; 471 int plus;
472 unsigned int count; 472 unsigned int count;
473 struct page ** pages; 473 struct page ** pages;
@@ -503,7 +503,7 @@ struct nfs3_linkres {
503 503
504struct nfs3_readdirres { 504struct nfs3_readdirres {
505 struct nfs_fattr * dir_attr; 505 struct nfs_fattr * dir_attr;
506 __u32 * verf; 506 __be32 * verf;
507 int plus; 507 int plus;
508}; 508};
509 509
@@ -811,7 +811,7 @@ struct nfs_rpc_ops {
811 int (*pathconf) (struct nfs_server *, struct nfs_fh *, 811 int (*pathconf) (struct nfs_server *, struct nfs_fh *,
812 struct nfs_pathconf *); 812 struct nfs_pathconf *);
813 int (*set_capabilities)(struct nfs_server *, struct nfs_fh *); 813 int (*set_capabilities)(struct nfs_server *, struct nfs_fh *);
814 u32 * (*decode_dirent)(u32 *, struct nfs_entry *, int plus); 814 __be32 *(*decode_dirent)(__be32 *, struct nfs_entry *, int plus);
815 void (*read_setup) (struct nfs_read_data *); 815 void (*read_setup) (struct nfs_read_data *);
816 int (*read_done) (struct rpc_task *, struct nfs_read_data *); 816 int (*read_done) (struct rpc_task *, struct nfs_read_data *);
817 void (*write_setup) (struct nfs_write_data *, int how); 817 void (*write_setup) (struct nfs_write_data *, int how);
diff --git a/include/linux/nfsd/cache.h b/include/linux/nfsd/cache.h
index c3a3557c2a5b..007480cd6a60 100644
--- a/include/linux/nfsd/cache.h
+++ b/include/linux/nfsd/cache.h
@@ -26,14 +26,14 @@ struct svc_cacherep {
26 c_type, /* status, buffer */ 26 c_type, /* status, buffer */
27 c_secure : 1; /* req came from port < 1024 */ 27 c_secure : 1; /* req came from port < 1024 */
28 struct sockaddr_in c_addr; 28 struct sockaddr_in c_addr;
29 u32 c_xid; 29 __be32 c_xid;
30 u32 c_prot; 30 u32 c_prot;
31 u32 c_proc; 31 u32 c_proc;
32 u32 c_vers; 32 u32 c_vers;
33 unsigned long c_timestamp; 33 unsigned long c_timestamp;
34 union { 34 union {
35 struct kvec u_vec; 35 struct kvec u_vec;
36 u32 u_status; 36 __be32 u_status;
37 } c_u; 37 } c_u;
38}; 38};
39 39
@@ -75,7 +75,7 @@ enum {
75void nfsd_cache_init(void); 75void nfsd_cache_init(void);
76void nfsd_cache_shutdown(void); 76void nfsd_cache_shutdown(void);
77int nfsd_cache_lookup(struct svc_rqst *, int); 77int nfsd_cache_lookup(struct svc_rqst *, int);
78void nfsd_cache_update(struct svc_rqst *, int, u32 *); 78void nfsd_cache_update(struct svc_rqst *, int, __be32 *);
79 79
80#endif /* __KERNEL__ */ 80#endif /* __KERNEL__ */
81#endif /* NFSCACHE_H */ 81#endif /* NFSCACHE_H */
diff --git a/include/linux/nfsd/export.h b/include/linux/nfsd/export.h
index 6e78ea969f49..045e38cdbe64 100644
--- a/include/linux/nfsd/export.h
+++ b/include/linux/nfsd/export.h
@@ -117,8 +117,8 @@ struct svc_export * exp_parent(struct auth_domain *clp,
117 struct cache_req *reqp); 117 struct cache_req *reqp);
118int exp_rootfh(struct auth_domain *, 118int exp_rootfh(struct auth_domain *,
119 char *path, struct knfsd_fh *, int maxsize); 119 char *path, struct knfsd_fh *, int maxsize);
120int exp_pseudoroot(struct auth_domain *, struct svc_fh *fhp, struct cache_req *creq); 120__be32 exp_pseudoroot(struct auth_domain *, struct svc_fh *fhp, struct cache_req *creq);
121int nfserrno(int errno); 121__be32 nfserrno(int errno);
122 122
123extern struct cache_detail svc_export_cache; 123extern struct cache_detail svc_export_cache;
124 124
diff --git a/include/linux/nfsd/nfsd.h b/include/linux/nfsd/nfsd.h
index d0d4aae7085f..edb54c3171b3 100644
--- a/include/linux/nfsd/nfsd.h
+++ b/include/linux/nfsd/nfsd.h
@@ -50,7 +50,7 @@
50 * Callback function for readdir 50 * Callback function for readdir
51 */ 51 */
52struct readdir_cd { 52struct readdir_cd {
53 int err; /* 0, nfserr, or nfserr_eof */ 53 __be32 err; /* 0, nfserr, or nfserr_eof */
54}; 54};
55typedef int (*encode_dent_fn)(struct readdir_cd *, const char *, 55typedef int (*encode_dent_fn)(struct readdir_cd *, const char *,
56 int, loff_t, ino_t, unsigned int); 56 int, loff_t, ino_t, unsigned int);
@@ -64,7 +64,7 @@ extern struct svc_serv *nfsd_serv;
64 * Function prototypes. 64 * Function prototypes.
65 */ 65 */
66int nfsd_svc(unsigned short port, int nrservs); 66int nfsd_svc(unsigned short port, int nrservs);
67int nfsd_dispatch(struct svc_rqst *rqstp, u32 *statp); 67int nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp);
68 68
69/* nfsd/vfs.c */ 69/* nfsd/vfs.c */
70int fh_lock_parent(struct svc_fh *, struct dentry *); 70int fh_lock_parent(struct svc_fh *, struct dentry *);
@@ -72,57 +72,57 @@ int nfsd_racache_init(int);
72void nfsd_racache_shutdown(void); 72void nfsd_racache_shutdown(void);
73int nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp, 73int nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp,
74 struct svc_export **expp); 74 struct svc_export **expp);
75int nfsd_lookup(struct svc_rqst *, struct svc_fh *, 75__be32 nfsd_lookup(struct svc_rqst *, struct svc_fh *,
76 const char *, int, struct svc_fh *); 76 const char *, int, struct svc_fh *);
77int nfsd_setattr(struct svc_rqst *, struct svc_fh *, 77__be32 nfsd_setattr(struct svc_rqst *, struct svc_fh *,
78 struct iattr *, int, time_t); 78 struct iattr *, int, time_t);
79#ifdef CONFIG_NFSD_V4 79#ifdef CONFIG_NFSD_V4
80int nfsd4_set_nfs4_acl(struct svc_rqst *, struct svc_fh *, 80__be32 nfsd4_set_nfs4_acl(struct svc_rqst *, struct svc_fh *,
81 struct nfs4_acl *); 81 struct nfs4_acl *);
82int nfsd4_get_nfs4_acl(struct svc_rqst *, struct dentry *, struct nfs4_acl **); 82int nfsd4_get_nfs4_acl(struct svc_rqst *, struct dentry *, struct nfs4_acl **);
83#endif /* CONFIG_NFSD_V4 */ 83#endif /* CONFIG_NFSD_V4 */
84int nfsd_create(struct svc_rqst *, struct svc_fh *, 84__be32 nfsd_create(struct svc_rqst *, struct svc_fh *,
85 char *name, int len, struct iattr *attrs, 85 char *name, int len, struct iattr *attrs,
86 int type, dev_t rdev, struct svc_fh *res); 86 int type, dev_t rdev, struct svc_fh *res);
87#ifdef CONFIG_NFSD_V3 87#ifdef CONFIG_NFSD_V3
88int nfsd_access(struct svc_rqst *, struct svc_fh *, u32 *, u32 *); 88__be32 nfsd_access(struct svc_rqst *, struct svc_fh *, u32 *, u32 *);
89int nfsd_create_v3(struct svc_rqst *, struct svc_fh *, 89__be32 nfsd_create_v3(struct svc_rqst *, struct svc_fh *,
90 char *name, int len, struct iattr *attrs, 90 char *name, int len, struct iattr *attrs,
91 struct svc_fh *res, int createmode, 91 struct svc_fh *res, int createmode,
92 u32 *verifier, int *truncp); 92 u32 *verifier, int *truncp, int *created);
93int nfsd_commit(struct svc_rqst *, struct svc_fh *, 93__be32 nfsd_commit(struct svc_rqst *, struct svc_fh *,
94 loff_t, unsigned long); 94 loff_t, unsigned long);
95#endif /* CONFIG_NFSD_V3 */ 95#endif /* CONFIG_NFSD_V3 */
96int nfsd_open(struct svc_rqst *, struct svc_fh *, int, 96__be32 nfsd_open(struct svc_rqst *, struct svc_fh *, int,
97 int, struct file **); 97 int, struct file **);
98void nfsd_close(struct file *); 98void nfsd_close(struct file *);
99int nfsd_read(struct svc_rqst *, struct svc_fh *, struct file *, 99__be32 nfsd_read(struct svc_rqst *, struct svc_fh *, struct file *,
100 loff_t, struct kvec *, int, unsigned long *); 100 loff_t, struct kvec *, int, unsigned long *);
101int nfsd_write(struct svc_rqst *, struct svc_fh *,struct file *, 101__be32 nfsd_write(struct svc_rqst *, struct svc_fh *,struct file *,
102 loff_t, struct kvec *,int, unsigned long, int *); 102 loff_t, struct kvec *,int, unsigned long, int *);
103int nfsd_readlink(struct svc_rqst *, struct svc_fh *, 103__be32 nfsd_readlink(struct svc_rqst *, struct svc_fh *,
104 char *, int *); 104 char *, int *);
105int nfsd_symlink(struct svc_rqst *, struct svc_fh *, 105__be32 nfsd_symlink(struct svc_rqst *, struct svc_fh *,
106 char *name, int len, char *path, int plen, 106 char *name, int len, char *path, int plen,
107 struct svc_fh *res, struct iattr *); 107 struct svc_fh *res, struct iattr *);
108int nfsd_link(struct svc_rqst *, struct svc_fh *, 108__be32 nfsd_link(struct svc_rqst *, struct svc_fh *,
109 char *, int, struct svc_fh *); 109 char *, int, struct svc_fh *);
110int nfsd_rename(struct svc_rqst *, 110__be32 nfsd_rename(struct svc_rqst *,
111 struct svc_fh *, char *, int, 111 struct svc_fh *, char *, int,
112 struct svc_fh *, char *, int); 112 struct svc_fh *, char *, int);
113int nfsd_remove(struct svc_rqst *, 113__be32 nfsd_remove(struct svc_rqst *,
114 struct svc_fh *, char *, int); 114 struct svc_fh *, char *, int);
115int nfsd_unlink(struct svc_rqst *, struct svc_fh *, int type, 115__be32 nfsd_unlink(struct svc_rqst *, struct svc_fh *, int type,
116 char *name, int len); 116 char *name, int len);
117int nfsd_truncate(struct svc_rqst *, struct svc_fh *, 117int nfsd_truncate(struct svc_rqst *, struct svc_fh *,
118 unsigned long size); 118 unsigned long size);
119int nfsd_readdir(struct svc_rqst *, struct svc_fh *, 119__be32 nfsd_readdir(struct svc_rqst *, struct svc_fh *,
120 loff_t *, struct readdir_cd *, encode_dent_fn); 120 loff_t *, struct readdir_cd *, encode_dent_fn);
121int nfsd_statfs(struct svc_rqst *, struct svc_fh *, 121__be32 nfsd_statfs(struct svc_rqst *, struct svc_fh *,
122 struct kstatfs *); 122 struct kstatfs *);
123 123
124int nfsd_notify_change(struct inode *, struct iattr *); 124int nfsd_notify_change(struct inode *, struct iattr *);
125int nfsd_permission(struct svc_export *, struct dentry *, int); 125__be32 nfsd_permission(struct svc_export *, struct dentry *, int);
126int nfsd_sync_dir(struct dentry *dp); 126int nfsd_sync_dir(struct dentry *dp);
127 127
128#if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL) 128#if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
@@ -238,6 +238,7 @@ void nfsd_lockd_shutdown(void);
238#define nfserr_badname __constant_htonl(NFSERR_BADNAME) 238#define nfserr_badname __constant_htonl(NFSERR_BADNAME)
239#define nfserr_cb_path_down __constant_htonl(NFSERR_CB_PATH_DOWN) 239#define nfserr_cb_path_down __constant_htonl(NFSERR_CB_PATH_DOWN)
240#define nfserr_locked __constant_htonl(NFSERR_LOCKED) 240#define nfserr_locked __constant_htonl(NFSERR_LOCKED)
241#define nfserr_replay_me __constant_htonl(NFSERR_REPLAY_ME)
241 242
242/* error codes for internal use */ 243/* error codes for internal use */
243/* if a request fails due to kmalloc failure, it gets dropped. 244/* if a request fails due to kmalloc failure, it gets dropped.
diff --git a/include/linux/nfsd/nfsfh.h b/include/linux/nfsd/nfsfh.h
index 069257ea99a0..f3b51d62ec7d 100644
--- a/include/linux/nfsd/nfsfh.h
+++ b/include/linux/nfsd/nfsfh.h
@@ -157,7 +157,7 @@ typedef struct svc_fh {
157 __u64 fh_post_size; /* i_size */ 157 __u64 fh_post_size; /* i_size */
158 unsigned long fh_post_blocks; /* i_blocks */ 158 unsigned long fh_post_blocks; /* i_blocks */
159 unsigned long fh_post_blksize;/* i_blksize */ 159 unsigned long fh_post_blksize;/* i_blksize */
160 __u32 fh_post_rdev[2];/* i_rdev */ 160 __be32 fh_post_rdev[2];/* i_rdev */
161 struct timespec fh_post_atime; /* i_atime */ 161 struct timespec fh_post_atime; /* i_atime */
162 struct timespec fh_post_mtime; /* i_mtime */ 162 struct timespec fh_post_mtime; /* i_mtime */
163 struct timespec fh_post_ctime; /* i_ctime */ 163 struct timespec fh_post_ctime; /* i_ctime */
@@ -209,9 +209,9 @@ extern char * SVCFH_fmt(struct svc_fh *fhp);
209/* 209/*
210 * Function prototypes 210 * Function prototypes
211 */ 211 */
212u32 fh_verify(struct svc_rqst *, struct svc_fh *, int, int); 212__be32 fh_verify(struct svc_rqst *, struct svc_fh *, int, int);
213int fh_compose(struct svc_fh *, struct svc_export *, struct dentry *, struct svc_fh *); 213__be32 fh_compose(struct svc_fh *, struct svc_export *, struct dentry *, struct svc_fh *);
214int fh_update(struct svc_fh *); 214__be32 fh_update(struct svc_fh *);
215void fh_put(struct svc_fh *); 215void fh_put(struct svc_fh *);
216 216
217static __inline__ struct svc_fh * 217static __inline__ struct svc_fh *
diff --git a/include/linux/nfsd/state.h b/include/linux/nfsd/state.h
index 8bf23cf8b603..c3673f487e84 100644
--- a/include/linux/nfsd/state.h
+++ b/include/linux/nfsd/state.h
@@ -125,7 +125,7 @@ struct nfs4_client {
125 char cl_recdir[HEXDIR_LEN]; /* recovery dir */ 125 char cl_recdir[HEXDIR_LEN]; /* recovery dir */
126 nfs4_verifier cl_verifier; /* generated by client */ 126 nfs4_verifier cl_verifier; /* generated by client */
127 time_t cl_time; /* time of last lease renewal */ 127 time_t cl_time; /* time of last lease renewal */
128 u32 cl_addr; /* client ipaddress */ 128 __be32 cl_addr; /* client ipaddress */
129 struct svc_cred cl_cred; /* setclientid principal */ 129 struct svc_cred cl_cred; /* setclientid principal */
130 clientid_t cl_clientid; /* generated by server */ 130 clientid_t cl_clientid; /* generated by server */
131 nfs4_verifier cl_confirm; /* generated by server */ 131 nfs4_verifier cl_confirm; /* generated by server */
@@ -164,7 +164,7 @@ update_stateid(stateid_t *stateid)
164 * is cached. 164 * is cached.
165 */ 165 */
166struct nfs4_replay { 166struct nfs4_replay {
167 u32 rp_status; 167 __be32 rp_status;
168 unsigned int rp_buflen; 168 unsigned int rp_buflen;
169 char *rp_buf; 169 char *rp_buf;
170 unsigned intrp_allocated; 170 unsigned intrp_allocated;
@@ -273,19 +273,19 @@ struct nfs4_stateid {
273 ((err) != nfserr_stale_stateid) && \ 273 ((err) != nfserr_stale_stateid) && \
274 ((err) != nfserr_bad_stateid)) 274 ((err) != nfserr_bad_stateid))
275 275
276extern int nfsd4_renew(clientid_t *clid); 276extern __be32 nfsd4_renew(clientid_t *clid);
277extern int nfs4_preprocess_stateid_op(struct svc_fh *current_fh, 277extern __be32 nfs4_preprocess_stateid_op(struct svc_fh *current_fh,
278 stateid_t *stateid, int flags, struct file **filp); 278 stateid_t *stateid, int flags, struct file **filp);
279extern void nfs4_lock_state(void); 279extern void nfs4_lock_state(void);
280extern void nfs4_unlock_state(void); 280extern void nfs4_unlock_state(void);
281extern int nfs4_in_grace(void); 281extern int nfs4_in_grace(void);
282extern int nfs4_check_open_reclaim(clientid_t *clid); 282extern __be32 nfs4_check_open_reclaim(clientid_t *clid);
283extern void put_nfs4_client(struct nfs4_client *clp); 283extern void put_nfs4_client(struct nfs4_client *clp);
284extern void nfs4_free_stateowner(struct kref *kref); 284extern void nfs4_free_stateowner(struct kref *kref);
285extern void nfsd4_probe_callback(struct nfs4_client *clp); 285extern void nfsd4_probe_callback(struct nfs4_client *clp);
286extern void nfsd4_cb_recall(struct nfs4_delegation *dp); 286extern void nfsd4_cb_recall(struct nfs4_delegation *dp);
287extern void nfs4_put_delegation(struct nfs4_delegation *dp); 287extern void nfs4_put_delegation(struct nfs4_delegation *dp);
288extern int nfs4_make_rec_clidname(char *clidname, struct xdr_netobj *clname); 288extern __be32 nfs4_make_rec_clidname(char *clidname, struct xdr_netobj *clname);
289extern void nfsd4_init_recdir(char *recdir_name); 289extern void nfsd4_init_recdir(char *recdir_name);
290extern int nfsd4_recdir_load(void); 290extern int nfsd4_recdir_load(void);
291extern void nfsd4_shutdown_recdir(void); 291extern void nfsd4_shutdown_recdir(void);
diff --git a/include/linux/nfsd/xdr.h b/include/linux/nfsd/xdr.h
index 0e53de87d886..877192d3ae79 100644
--- a/include/linux/nfsd/xdr.h
+++ b/include/linux/nfsd/xdr.h
@@ -81,7 +81,7 @@ struct nfsd_readdirargs {
81 struct svc_fh fh; 81 struct svc_fh fh;
82 __u32 cookie; 82 __u32 cookie;
83 __u32 count; 83 __u32 count;
84 u32 * buffer; 84 __be32 * buffer;
85}; 85};
86 86
87struct nfsd_attrstat { 87struct nfsd_attrstat {
@@ -108,9 +108,9 @@ struct nfsd_readdirres {
108 int count; 108 int count;
109 109
110 struct readdir_cd common; 110 struct readdir_cd common;
111 u32 * buffer; 111 __be32 * buffer;
112 int buflen; 112 int buflen;
113 u32 * offset; 113 __be32 * offset;
114}; 114};
115 115
116struct nfsd_statfsres { 116struct nfsd_statfsres {
@@ -135,43 +135,43 @@ union nfsd_xdrstore {
135#define NFS2_SVC_XDRSIZE sizeof(union nfsd_xdrstore) 135#define NFS2_SVC_XDRSIZE sizeof(union nfsd_xdrstore)
136 136
137 137
138int nfssvc_decode_void(struct svc_rqst *, u32 *, void *); 138int nfssvc_decode_void(struct svc_rqst *, __be32 *, void *);
139int nfssvc_decode_fhandle(struct svc_rqst *, u32 *, struct nfsd_fhandle *); 139int nfssvc_decode_fhandle(struct svc_rqst *, __be32 *, struct nfsd_fhandle *);
140int nfssvc_decode_sattrargs(struct svc_rqst *, u32 *, 140int nfssvc_decode_sattrargs(struct svc_rqst *, __be32 *,
141 struct nfsd_sattrargs *); 141 struct nfsd_sattrargs *);
142int nfssvc_decode_diropargs(struct svc_rqst *, u32 *, 142int nfssvc_decode_diropargs(struct svc_rqst *, __be32 *,
143 struct nfsd_diropargs *); 143 struct nfsd_diropargs *);
144int nfssvc_decode_readargs(struct svc_rqst *, u32 *, 144int nfssvc_decode_readargs(struct svc_rqst *, __be32 *,
145 struct nfsd_readargs *); 145 struct nfsd_readargs *);
146int nfssvc_decode_writeargs(struct svc_rqst *, u32 *, 146int nfssvc_decode_writeargs(struct svc_rqst *, __be32 *,
147 struct nfsd_writeargs *); 147 struct nfsd_writeargs *);
148int nfssvc_decode_createargs(struct svc_rqst *, u32 *, 148int nfssvc_decode_createargs(struct svc_rqst *, __be32 *,
149 struct nfsd_createargs *); 149 struct nfsd_createargs *);
150int nfssvc_decode_renameargs(struct svc_rqst *, u32 *, 150int nfssvc_decode_renameargs(struct svc_rqst *, __be32 *,
151 struct nfsd_renameargs *); 151 struct nfsd_renameargs *);
152int nfssvc_decode_readlinkargs(struct svc_rqst *, u32 *, 152int nfssvc_decode_readlinkargs(struct svc_rqst *, __be32 *,
153 struct nfsd_readlinkargs *); 153 struct nfsd_readlinkargs *);
154int nfssvc_decode_linkargs(struct svc_rqst *, u32 *, 154int nfssvc_decode_linkargs(struct svc_rqst *, __be32 *,
155 struct nfsd_linkargs *); 155 struct nfsd_linkargs *);
156int nfssvc_decode_symlinkargs(struct svc_rqst *, u32 *, 156int nfssvc_decode_symlinkargs(struct svc_rqst *, __be32 *,
157 struct nfsd_symlinkargs *); 157 struct nfsd_symlinkargs *);
158int nfssvc_decode_readdirargs(struct svc_rqst *, u32 *, 158int nfssvc_decode_readdirargs(struct svc_rqst *, __be32 *,
159 struct nfsd_readdirargs *); 159 struct nfsd_readdirargs *);
160int nfssvc_encode_void(struct svc_rqst *, u32 *, void *); 160int nfssvc_encode_void(struct svc_rqst *, __be32 *, void *);
161int nfssvc_encode_attrstat(struct svc_rqst *, u32 *, struct nfsd_attrstat *); 161int nfssvc_encode_attrstat(struct svc_rqst *, __be32 *, struct nfsd_attrstat *);
162int nfssvc_encode_diropres(struct svc_rqst *, u32 *, struct nfsd_diropres *); 162int nfssvc_encode_diropres(struct svc_rqst *, __be32 *, struct nfsd_diropres *);
163int nfssvc_encode_readlinkres(struct svc_rqst *, u32 *, struct nfsd_readlinkres *); 163int nfssvc_encode_readlinkres(struct svc_rqst *, __be32 *, struct nfsd_readlinkres *);
164int nfssvc_encode_readres(struct svc_rqst *, u32 *, struct nfsd_readres *); 164int nfssvc_encode_readres(struct svc_rqst *, __be32 *, struct nfsd_readres *);
165int nfssvc_encode_statfsres(struct svc_rqst *, u32 *, struct nfsd_statfsres *); 165int nfssvc_encode_statfsres(struct svc_rqst *, __be32 *, struct nfsd_statfsres *);
166int nfssvc_encode_readdirres(struct svc_rqst *, u32 *, struct nfsd_readdirres *); 166int nfssvc_encode_readdirres(struct svc_rqst *, __be32 *, struct nfsd_readdirres *);
167 167
168int nfssvc_encode_entry(struct readdir_cd *, const char *name, 168int nfssvc_encode_entry(struct readdir_cd *, const char *name,
169 int namlen, loff_t offset, ino_t ino, unsigned int); 169 int namlen, loff_t offset, ino_t ino, unsigned int);
170 170
171int nfssvc_release_fhandle(struct svc_rqst *, u32 *, struct nfsd_fhandle *); 171int nfssvc_release_fhandle(struct svc_rqst *, __be32 *, struct nfsd_fhandle *);
172 172
173/* Helper functions for NFSv2 ACL code */ 173/* Helper functions for NFSv2 ACL code */
174u32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp); 174__be32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp);
175u32 *nfs2svc_decode_fh(u32 *p, struct svc_fh *fhp); 175__be32 *nfs2svc_decode_fh(__be32 *p, struct svc_fh *fhp);
176 176
177#endif /* LINUX_NFSD_H */ 177#endif /* LINUX_NFSD_H */
diff --git a/include/linux/nfsd/xdr3.h b/include/linux/nfsd/xdr3.h
index 474d882dc2f3..79963867b0d7 100644
--- a/include/linux/nfsd/xdr3.h
+++ b/include/linux/nfsd/xdr3.h
@@ -51,7 +51,7 @@ struct nfsd3_createargs {
51 int len; 51 int len;
52 int createmode; 52 int createmode;
53 struct iattr attrs; 53 struct iattr attrs;
54 __u32 * verf; 54 __be32 * verf;
55}; 55};
56 56
57struct nfsd3_mknodargs { 57struct nfsd3_mknodargs {
@@ -98,8 +98,8 @@ struct nfsd3_readdirargs {
98 __u64 cookie; 98 __u64 cookie;
99 __u32 dircount; 99 __u32 dircount;
100 __u32 count; 100 __u32 count;
101 __u32 * verf; 101 __be32 * verf;
102 u32 * buffer; 102 __be32 * buffer;
103}; 103};
104 104
105struct nfsd3_commitargs { 105struct nfsd3_commitargs {
@@ -122,79 +122,79 @@ struct nfsd3_setaclargs {
122}; 122};
123 123
124struct nfsd3_attrstat { 124struct nfsd3_attrstat {
125 __u32 status; 125 __be32 status;
126 struct svc_fh fh; 126 struct svc_fh fh;
127 struct kstat stat; 127 struct kstat stat;
128}; 128};
129 129
130/* LOOKUP, CREATE, MKDIR, SYMLINK, MKNOD */ 130/* LOOKUP, CREATE, MKDIR, SYMLINK, MKNOD */
131struct nfsd3_diropres { 131struct nfsd3_diropres {
132 __u32 status; 132 __be32 status;
133 struct svc_fh dirfh; 133 struct svc_fh dirfh;
134 struct svc_fh fh; 134 struct svc_fh fh;
135}; 135};
136 136
137struct nfsd3_accessres { 137struct nfsd3_accessres {
138 __u32 status; 138 __be32 status;
139 struct svc_fh fh; 139 struct svc_fh fh;
140 __u32 access; 140 __u32 access;
141}; 141};
142 142
143struct nfsd3_readlinkres { 143struct nfsd3_readlinkres {
144 __u32 status; 144 __be32 status;
145 struct svc_fh fh; 145 struct svc_fh fh;
146 __u32 len; 146 __u32 len;
147}; 147};
148 148
149struct nfsd3_readres { 149struct nfsd3_readres {
150 __u32 status; 150 __be32 status;
151 struct svc_fh fh; 151 struct svc_fh fh;
152 unsigned long count; 152 unsigned long count;
153 int eof; 153 int eof;
154}; 154};
155 155
156struct nfsd3_writeres { 156struct nfsd3_writeres {
157 __u32 status; 157 __be32 status;
158 struct svc_fh fh; 158 struct svc_fh fh;
159 unsigned long count; 159 unsigned long count;
160 int committed; 160 int committed;
161}; 161};
162 162
163struct nfsd3_renameres { 163struct nfsd3_renameres {
164 __u32 status; 164 __be32 status;
165 struct svc_fh ffh; 165 struct svc_fh ffh;
166 struct svc_fh tfh; 166 struct svc_fh tfh;
167}; 167};
168 168
169struct nfsd3_linkres { 169struct nfsd3_linkres {
170 __u32 status; 170 __be32 status;
171 struct svc_fh tfh; 171 struct svc_fh tfh;
172 struct svc_fh fh; 172 struct svc_fh fh;
173}; 173};
174 174
175struct nfsd3_readdirres { 175struct nfsd3_readdirres {
176 __u32 status; 176 __be32 status;
177 struct svc_fh fh; 177 struct svc_fh fh;
178 int count; 178 int count;
179 __u32 verf[2]; 179 __be32 verf[2];
180 180
181 struct readdir_cd common; 181 struct readdir_cd common;
182 u32 * buffer; 182 __be32 * buffer;
183 int buflen; 183 int buflen;
184 u32 * offset; 184 __be32 * offset;
185 u32 * offset1; 185 __be32 * offset1;
186 struct svc_rqst * rqstp; 186 struct svc_rqst * rqstp;
187 187
188}; 188};
189 189
190struct nfsd3_fsstatres { 190struct nfsd3_fsstatres {
191 __u32 status; 191 __be32 status;
192 struct kstatfs stats; 192 struct kstatfs stats;
193 __u32 invarsec; 193 __u32 invarsec;
194}; 194};
195 195
196struct nfsd3_fsinfores { 196struct nfsd3_fsinfores {
197 __u32 status; 197 __be32 status;
198 __u32 f_rtmax; 198 __u32 f_rtmax;
199 __u32 f_rtpref; 199 __u32 f_rtpref;
200 __u32 f_rtmult; 200 __u32 f_rtmult;
@@ -207,7 +207,7 @@ struct nfsd3_fsinfores {
207}; 207};
208 208
209struct nfsd3_pathconfres { 209struct nfsd3_pathconfres {
210 __u32 status; 210 __be32 status;
211 __u32 p_link_max; 211 __u32 p_link_max;
212 __u32 p_name_max; 212 __u32 p_name_max;
213 __u32 p_no_trunc; 213 __u32 p_no_trunc;
@@ -217,12 +217,12 @@ struct nfsd3_pathconfres {
217}; 217};
218 218
219struct nfsd3_commitres { 219struct nfsd3_commitres {
220 __u32 status; 220 __be32 status;
221 struct svc_fh fh; 221 struct svc_fh fh;
222}; 222};
223 223
224struct nfsd3_getaclres { 224struct nfsd3_getaclres {
225 __u32 status; 225 __be32 status;
226 struct svc_fh fh; 226 struct svc_fh fh;
227 int mask; 227 int mask;
228 struct posix_acl *acl_access; 228 struct posix_acl *acl_access;
@@ -266,70 +266,70 @@ union nfsd3_xdrstore {
266 266
267#define NFS3_SVC_XDRSIZE sizeof(union nfsd3_xdrstore) 267#define NFS3_SVC_XDRSIZE sizeof(union nfsd3_xdrstore)
268 268
269int nfs3svc_decode_fhandle(struct svc_rqst *, u32 *, struct nfsd_fhandle *); 269int nfs3svc_decode_fhandle(struct svc_rqst *, __be32 *, struct nfsd_fhandle *);
270int nfs3svc_decode_sattrargs(struct svc_rqst *, u32 *, 270int nfs3svc_decode_sattrargs(struct svc_rqst *, __be32 *,
271 struct nfsd3_sattrargs *); 271 struct nfsd3_sattrargs *);
272int nfs3svc_decode_diropargs(struct svc_rqst *, u32 *, 272int nfs3svc_decode_diropargs(struct svc_rqst *, __be32 *,
273 struct nfsd3_diropargs *); 273 struct nfsd3_diropargs *);
274int nfs3svc_decode_accessargs(struct svc_rqst *, u32 *, 274int nfs3svc_decode_accessargs(struct svc_rqst *, __be32 *,
275 struct nfsd3_accessargs *); 275 struct nfsd3_accessargs *);
276int nfs3svc_decode_readargs(struct svc_rqst *, u32 *, 276int nfs3svc_decode_readargs(struct svc_rqst *, __be32 *,
277 struct nfsd3_readargs *); 277 struct nfsd3_readargs *);
278int nfs3svc_decode_writeargs(struct svc_rqst *, u32 *, 278int nfs3svc_decode_writeargs(struct svc_rqst *, __be32 *,
279 struct nfsd3_writeargs *); 279 struct nfsd3_writeargs *);
280int nfs3svc_decode_createargs(struct svc_rqst *, u32 *, 280int nfs3svc_decode_createargs(struct svc_rqst *, __be32 *,
281 struct nfsd3_createargs *); 281 struct nfsd3_createargs *);
282int nfs3svc_decode_mkdirargs(struct svc_rqst *, u32 *, 282int nfs3svc_decode_mkdirargs(struct svc_rqst *, __be32 *,
283 struct nfsd3_createargs *); 283 struct nfsd3_createargs *);
284int nfs3svc_decode_mknodargs(struct svc_rqst *, u32 *, 284int nfs3svc_decode_mknodargs(struct svc_rqst *, __be32 *,
285 struct nfsd3_mknodargs *); 285 struct nfsd3_mknodargs *);
286int nfs3svc_decode_renameargs(struct svc_rqst *, u32 *, 286int nfs3svc_decode_renameargs(struct svc_rqst *, __be32 *,
287 struct nfsd3_renameargs *); 287 struct nfsd3_renameargs *);
288int nfs3svc_decode_readlinkargs(struct svc_rqst *, u32 *, 288int nfs3svc_decode_readlinkargs(struct svc_rqst *, __be32 *,
289 struct nfsd3_readlinkargs *); 289 struct nfsd3_readlinkargs *);
290int nfs3svc_decode_linkargs(struct svc_rqst *, u32 *, 290int nfs3svc_decode_linkargs(struct svc_rqst *, __be32 *,
291 struct nfsd3_linkargs *); 291 struct nfsd3_linkargs *);
292int nfs3svc_decode_symlinkargs(struct svc_rqst *, u32 *, 292int nfs3svc_decode_symlinkargs(struct svc_rqst *, __be32 *,
293 struct nfsd3_symlinkargs *); 293 struct nfsd3_symlinkargs *);
294int nfs3svc_decode_readdirargs(struct svc_rqst *, u32 *, 294int nfs3svc_decode_readdirargs(struct svc_rqst *, __be32 *,
295 struct nfsd3_readdirargs *); 295 struct nfsd3_readdirargs *);
296int nfs3svc_decode_readdirplusargs(struct svc_rqst *, u32 *, 296int nfs3svc_decode_readdirplusargs(struct svc_rqst *, __be32 *,
297 struct nfsd3_readdirargs *); 297 struct nfsd3_readdirargs *);
298int nfs3svc_decode_commitargs(struct svc_rqst *, u32 *, 298int nfs3svc_decode_commitargs(struct svc_rqst *, __be32 *,
299 struct nfsd3_commitargs *); 299 struct nfsd3_commitargs *);
300int nfs3svc_encode_voidres(struct svc_rqst *, u32 *, void *); 300int nfs3svc_encode_voidres(struct svc_rqst *, __be32 *, void *);
301int nfs3svc_encode_attrstat(struct svc_rqst *, u32 *, 301int nfs3svc_encode_attrstat(struct svc_rqst *, __be32 *,
302 struct nfsd3_attrstat *); 302 struct nfsd3_attrstat *);
303int nfs3svc_encode_wccstat(struct svc_rqst *, u32 *, 303int nfs3svc_encode_wccstat(struct svc_rqst *, __be32 *,
304 struct nfsd3_attrstat *); 304 struct nfsd3_attrstat *);
305int nfs3svc_encode_diropres(struct svc_rqst *, u32 *, 305int nfs3svc_encode_diropres(struct svc_rqst *, __be32 *,
306 struct nfsd3_diropres *); 306 struct nfsd3_diropres *);
307int nfs3svc_encode_accessres(struct svc_rqst *, u32 *, 307int nfs3svc_encode_accessres(struct svc_rqst *, __be32 *,
308 struct nfsd3_accessres *); 308 struct nfsd3_accessres *);
309int nfs3svc_encode_readlinkres(struct svc_rqst *, u32 *, 309int nfs3svc_encode_readlinkres(struct svc_rqst *, __be32 *,
310 struct nfsd3_readlinkres *); 310 struct nfsd3_readlinkres *);
311int nfs3svc_encode_readres(struct svc_rqst *, u32 *, struct nfsd3_readres *); 311int nfs3svc_encode_readres(struct svc_rqst *, __be32 *, struct nfsd3_readres *);
312int nfs3svc_encode_writeres(struct svc_rqst *, u32 *, struct nfsd3_writeres *); 312int nfs3svc_encode_writeres(struct svc_rqst *, __be32 *, struct nfsd3_writeres *);
313int nfs3svc_encode_createres(struct svc_rqst *, u32 *, 313int nfs3svc_encode_createres(struct svc_rqst *, __be32 *,
314 struct nfsd3_diropres *); 314 struct nfsd3_diropres *);
315int nfs3svc_encode_renameres(struct svc_rqst *, u32 *, 315int nfs3svc_encode_renameres(struct svc_rqst *, __be32 *,
316 struct nfsd3_renameres *); 316 struct nfsd3_renameres *);
317int nfs3svc_encode_linkres(struct svc_rqst *, u32 *, 317int nfs3svc_encode_linkres(struct svc_rqst *, __be32 *,
318 struct nfsd3_linkres *); 318 struct nfsd3_linkres *);
319int nfs3svc_encode_readdirres(struct svc_rqst *, u32 *, 319int nfs3svc_encode_readdirres(struct svc_rqst *, __be32 *,
320 struct nfsd3_readdirres *); 320 struct nfsd3_readdirres *);
321int nfs3svc_encode_fsstatres(struct svc_rqst *, u32 *, 321int nfs3svc_encode_fsstatres(struct svc_rqst *, __be32 *,
322 struct nfsd3_fsstatres *); 322 struct nfsd3_fsstatres *);
323int nfs3svc_encode_fsinfores(struct svc_rqst *, u32 *, 323int nfs3svc_encode_fsinfores(struct svc_rqst *, __be32 *,
324 struct nfsd3_fsinfores *); 324 struct nfsd3_fsinfores *);
325int nfs3svc_encode_pathconfres(struct svc_rqst *, u32 *, 325int nfs3svc_encode_pathconfres(struct svc_rqst *, __be32 *,
326 struct nfsd3_pathconfres *); 326 struct nfsd3_pathconfres *);
327int nfs3svc_encode_commitres(struct svc_rqst *, u32 *, 327int nfs3svc_encode_commitres(struct svc_rqst *, __be32 *,
328 struct nfsd3_commitres *); 328 struct nfsd3_commitres *);
329 329
330int nfs3svc_release_fhandle(struct svc_rqst *, u32 *, 330int nfs3svc_release_fhandle(struct svc_rqst *, __be32 *,
331 struct nfsd3_attrstat *); 331 struct nfsd3_attrstat *);
332int nfs3svc_release_fhandle2(struct svc_rqst *, u32 *, 332int nfs3svc_release_fhandle2(struct svc_rqst *, __be32 *,
333 struct nfsd3_fhandle_pair *); 333 struct nfsd3_fhandle_pair *);
334int nfs3svc_encode_entry(struct readdir_cd *, const char *name, 334int nfs3svc_encode_entry(struct readdir_cd *, const char *name,
335 int namlen, loff_t offset, ino_t ino, 335 int namlen, loff_t offset, ino_t ino,
@@ -338,9 +338,9 @@ int nfs3svc_encode_entry_plus(struct readdir_cd *, const char *name,
338 int namlen, loff_t offset, ino_t ino, 338 int namlen, loff_t offset, ino_t ino,
339 unsigned int); 339 unsigned int);
340/* Helper functions for NFSv3 ACL code */ 340/* Helper functions for NFSv3 ACL code */
341u32 *nfs3svc_encode_post_op_attr(struct svc_rqst *rqstp, u32 *p, 341__be32 *nfs3svc_encode_post_op_attr(struct svc_rqst *rqstp, __be32 *p,
342 struct svc_fh *fhp); 342 struct svc_fh *fhp);
343u32 *nfs3svc_decode_fh(u32 *p, struct svc_fh *fhp); 343__be32 *nfs3svc_decode_fh(__be32 *p, struct svc_fh *fhp);
344 344
345 345
346#endif /* _LINUX_NFSD_XDR3_H */ 346#endif /* _LINUX_NFSD_XDR3_H */
diff --git a/include/linux/nfsd/xdr4.h b/include/linux/nfsd/xdr4.h
index 66e642762a07..45ca01b5f844 100644
--- a/include/linux/nfsd/xdr4.h
+++ b/include/linux/nfsd/xdr4.h
@@ -258,9 +258,9 @@ struct nfsd4_readdir {
258 struct svc_fh * rd_fhp; /* response */ 258 struct svc_fh * rd_fhp; /* response */
259 259
260 struct readdir_cd common; 260 struct readdir_cd common;
261 u32 * buffer; 261 __be32 * buffer;
262 int buflen; 262 int buflen;
263 u32 * offset; 263 __be32 * offset;
264}; 264};
265 265
266struct nfsd4_release_lockowner { 266struct nfsd4_release_lockowner {
@@ -334,7 +334,7 @@ struct nfsd4_write {
334 334
335struct nfsd4_op { 335struct nfsd4_op {
336 int opnum; 336 int opnum;
337 int status; 337 __be32 status;
338 union { 338 union {
339 struct nfsd4_access access; 339 struct nfsd4_access access;
340 struct nfsd4_close close; 340 struct nfsd4_close close;
@@ -371,12 +371,12 @@ struct nfsd4_op {
371 371
372struct nfsd4_compoundargs { 372struct nfsd4_compoundargs {
373 /* scratch variables for XDR decode */ 373 /* scratch variables for XDR decode */
374 u32 * p; 374 __be32 * p;
375 u32 * end; 375 __be32 * end;
376 struct page ** pagelist; 376 struct page ** pagelist;
377 int pagelen; 377 int pagelen;
378 u32 tmp[8]; 378 __be32 tmp[8];
379 u32 * tmpp; 379 __be32 * tmpp;
380 struct tmpbuf { 380 struct tmpbuf {
381 struct tmpbuf *next; 381 struct tmpbuf *next;
382 void (*release)(const void *); 382 void (*release)(const void *);
@@ -395,15 +395,15 @@ struct nfsd4_compoundargs {
395 395
396struct nfsd4_compoundres { 396struct nfsd4_compoundres {
397 /* scratch variables for XDR encode */ 397 /* scratch variables for XDR encode */
398 u32 * p; 398 __be32 * p;
399 u32 * end; 399 __be32 * end;
400 struct xdr_buf * xbuf; 400 struct xdr_buf * xbuf;
401 struct svc_rqst * rqstp; 401 struct svc_rqst * rqstp;
402 402
403 u32 taglen; 403 u32 taglen;
404 char * tag; 404 char * tag;
405 u32 opcnt; 405 u32 opcnt;
406 u32 * tagp; /* where to encode tag and opcount */ 406 __be32 * tagp; /* where to encode tag and opcount */
407}; 407};
408 408
409#define NFS4_SVC_XDRSIZE sizeof(struct nfsd4_compoundargs) 409#define NFS4_SVC_XDRSIZE sizeof(struct nfsd4_compoundargs)
@@ -419,45 +419,45 @@ set_change_info(struct nfsd4_change_info *cinfo, struct svc_fh *fhp)
419 cinfo->after_ctime_nsec = fhp->fh_post_ctime.tv_nsec; 419 cinfo->after_ctime_nsec = fhp->fh_post_ctime.tv_nsec;
420} 420}
421 421
422int nfs4svc_encode_voidres(struct svc_rqst *, u32 *, void *); 422int nfs4svc_encode_voidres(struct svc_rqst *, __be32 *, void *);
423int nfs4svc_decode_compoundargs(struct svc_rqst *, u32 *, 423int nfs4svc_decode_compoundargs(struct svc_rqst *, __be32 *,
424 struct nfsd4_compoundargs *); 424 struct nfsd4_compoundargs *);
425int nfs4svc_encode_compoundres(struct svc_rqst *, u32 *, 425int nfs4svc_encode_compoundres(struct svc_rqst *, __be32 *,
426 struct nfsd4_compoundres *); 426 struct nfsd4_compoundres *);
427void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *); 427void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *);
428void nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op); 428void nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op);
429int nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp, 429__be32 nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
430 struct dentry *dentry, u32 *buffer, int *countp, 430 struct dentry *dentry, __be32 *buffer, int *countp,
431 u32 *bmval, struct svc_rqst *); 431 u32 *bmval, struct svc_rqst *);
432extern int nfsd4_setclientid(struct svc_rqst *rqstp, 432extern __be32 nfsd4_setclientid(struct svc_rqst *rqstp,
433 struct nfsd4_setclientid *setclid); 433 struct nfsd4_setclientid *setclid);
434extern int nfsd4_setclientid_confirm(struct svc_rqst *rqstp, 434extern __be32 nfsd4_setclientid_confirm(struct svc_rqst *rqstp,
435 struct nfsd4_setclientid_confirm *setclientid_confirm); 435 struct nfsd4_setclientid_confirm *setclientid_confirm);
436extern int nfsd4_process_open1(struct nfsd4_open *open); 436extern __be32 nfsd4_process_open1(struct nfsd4_open *open);
437extern int nfsd4_process_open2(struct svc_rqst *rqstp, 437extern __be32 nfsd4_process_open2(struct svc_rqst *rqstp,
438 struct svc_fh *current_fh, struct nfsd4_open *open); 438 struct svc_fh *current_fh, struct nfsd4_open *open);
439extern int nfsd4_open_confirm(struct svc_rqst *rqstp, 439extern __be32 nfsd4_open_confirm(struct svc_rqst *rqstp,
440 struct svc_fh *current_fh, struct nfsd4_open_confirm *oc, 440 struct svc_fh *current_fh, struct nfsd4_open_confirm *oc,
441 struct nfs4_stateowner **); 441 struct nfs4_stateowner **);
442extern int nfsd4_close(struct svc_rqst *rqstp, struct svc_fh *current_fh, 442extern __be32 nfsd4_close(struct svc_rqst *rqstp, struct svc_fh *current_fh,
443 struct nfsd4_close *close, 443 struct nfsd4_close *close,
444 struct nfs4_stateowner **replay_owner); 444 struct nfs4_stateowner **replay_owner);
445extern int nfsd4_open_downgrade(struct svc_rqst *rqstp, 445extern __be32 nfsd4_open_downgrade(struct svc_rqst *rqstp,
446 struct svc_fh *current_fh, struct nfsd4_open_downgrade *od, 446 struct svc_fh *current_fh, struct nfsd4_open_downgrade *od,
447 struct nfs4_stateowner **replay_owner); 447 struct nfs4_stateowner **replay_owner);
448extern int nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, 448extern __be32 nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh,
449 struct nfsd4_lock *lock, 449 struct nfsd4_lock *lock,
450 struct nfs4_stateowner **replay_owner); 450 struct nfs4_stateowner **replay_owner);
451extern int nfsd4_lockt(struct svc_rqst *rqstp, struct svc_fh *current_fh, 451extern __be32 nfsd4_lockt(struct svc_rqst *rqstp, struct svc_fh *current_fh,
452 struct nfsd4_lockt *lockt); 452 struct nfsd4_lockt *lockt);
453extern int nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh, 453extern __be32 nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh,
454 struct nfsd4_locku *locku, 454 struct nfsd4_locku *locku,
455 struct nfs4_stateowner **replay_owner); 455 struct nfs4_stateowner **replay_owner);
456extern int 456extern __be32
457nfsd4_release_lockowner(struct svc_rqst *rqstp, 457nfsd4_release_lockowner(struct svc_rqst *rqstp,
458 struct nfsd4_release_lockowner *rlockowner); 458 struct nfsd4_release_lockowner *rlockowner);
459extern void nfsd4_release_compoundargs(struct nfsd4_compoundargs *); 459extern void nfsd4_release_compoundargs(struct nfsd4_compoundargs *);
460extern int nfsd4_delegreturn(struct svc_rqst *rqstp, 460extern __be32 nfsd4_delegreturn(struct svc_rqst *rqstp,
461 struct svc_fh *current_fh, struct nfsd4_delegreturn *dr); 461 struct svc_fh *current_fh, struct nfsd4_delegreturn *dr);
462#endif 462#endif
463 463
diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h
index 5dce5c21822c..b1063e9cdb1b 100644
--- a/include/linux/nodemask.h
+++ b/include/linux/nodemask.h
@@ -8,8 +8,8 @@
8 * See detailed comments in the file linux/bitmap.h describing the 8 * See detailed comments in the file linux/bitmap.h describing the
9 * data type on which these nodemasks are based. 9 * data type on which these nodemasks are based.
10 * 10 *
11 * For details of nodemask_scnprintf() and nodemask_parse(), 11 * For details of nodemask_scnprintf() and nodemask_parse_user(),
12 * see bitmap_scnprintf() and bitmap_parse() in lib/bitmap.c. 12 * see bitmap_scnprintf() and bitmap_parse_user() in lib/bitmap.c.
13 * For details of nodelist_scnprintf() and nodelist_parse(), see 13 * For details of nodelist_scnprintf() and nodelist_parse(), see
14 * bitmap_scnlistprintf() and bitmap_parselist(), also in bitmap.c. 14 * bitmap_scnlistprintf() and bitmap_parselist(), also in bitmap.c.
15 * For details of node_remap(), see bitmap_bitremap in lib/bitmap.c. 15 * For details of node_remap(), see bitmap_bitremap in lib/bitmap.c.
@@ -51,7 +51,7 @@
51 * unsigned long *nodes_addr(mask) Array of unsigned long's in mask 51 * unsigned long *nodes_addr(mask) Array of unsigned long's in mask
52 * 52 *
53 * int nodemask_scnprintf(buf, len, mask) Format nodemask for printing 53 * int nodemask_scnprintf(buf, len, mask) Format nodemask for printing
54 * int nodemask_parse(ubuf, ulen, mask) Parse ascii string as nodemask 54 * int nodemask_parse_user(ubuf, ulen, mask) Parse ascii string as nodemask
55 * int nodelist_scnprintf(buf, len, mask) Format nodemask as list for printing 55 * int nodelist_scnprintf(buf, len, mask) Format nodemask as list for printing
56 * int nodelist_parse(buf, map) Parse ascii string as nodelist 56 * int nodelist_parse(buf, map) Parse ascii string as nodelist
57 * int node_remap(oldbit, old, new) newbit = map(old, new)(oldbit) 57 * int node_remap(oldbit, old, new) newbit = map(old, new)(oldbit)
@@ -288,12 +288,12 @@ static inline int __nodemask_scnprintf(char *buf, int len,
288 return bitmap_scnprintf(buf, len, srcp->bits, nbits); 288 return bitmap_scnprintf(buf, len, srcp->bits, nbits);
289} 289}
290 290
291#define nodemask_parse(ubuf, ulen, dst) \ 291#define nodemask_parse_user(ubuf, ulen, dst) \
292 __nodemask_parse((ubuf), (ulen), &(dst), MAX_NUMNODES) 292 __nodemask_parse_user((ubuf), (ulen), &(dst), MAX_NUMNODES)
293static inline int __nodemask_parse(const char __user *buf, int len, 293static inline int __nodemask_parse_user(const char __user *buf, int len,
294 nodemask_t *dstp, int nbits) 294 nodemask_t *dstp, int nbits)
295{ 295{
296 return bitmap_parse(buf, len, dstp->bits, nbits); 296 return bitmap_parse_user(buf, len, dstp->bits, nbits);
297} 297}
298 298
299#define nodelist_scnprintf(buf, len, src) \ 299#define nodelist_scnprintf(buf, len, src) \
diff --git a/include/linux/oom.h b/include/linux/oom.h
new file mode 100644
index 000000000000..ad76463629a0
--- /dev/null
+++ b/include/linux/oom.h
@@ -0,0 +1,10 @@
1#ifndef __INCLUDE_LINUX_OOM_H
2#define __INCLUDE_LINUX_OOM_H
3
4/* /proc/<pid>/oom_adj set to -17 protects from the oom-killer */
5#define OOM_DISABLE (-17)
6/* inclusive */
7#define OOM_ADJUST_MIN (-16)
8#define OOM_ADJUST_MAX 15
9
10#endif
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 64f950925151..c3e255bf8594 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -52,19 +52,23 @@ static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask)
52void release_pages(struct page **pages, int nr, int cold); 52void release_pages(struct page **pages, int nr, int cold);
53 53
54#ifdef CONFIG_NUMA 54#ifdef CONFIG_NUMA
55extern struct page *page_cache_alloc(struct address_space *x); 55extern struct page *__page_cache_alloc(gfp_t gfp);
56extern struct page *page_cache_alloc_cold(struct address_space *x);
57#else 56#else
57static inline struct page *__page_cache_alloc(gfp_t gfp)
58{
59 return alloc_pages(gfp, 0);
60}
61#endif
62
58static inline struct page *page_cache_alloc(struct address_space *x) 63static inline struct page *page_cache_alloc(struct address_space *x)
59{ 64{
60 return alloc_pages(mapping_gfp_mask(x), 0); 65 return __page_cache_alloc(mapping_gfp_mask(x));
61} 66}
62 67
63static inline struct page *page_cache_alloc_cold(struct address_space *x) 68static inline struct page *page_cache_alloc_cold(struct address_space *x)
64{ 69{
65 return alloc_pages(mapping_gfp_mask(x)|__GFP_COLD, 0); 70 return __page_cache_alloc(mapping_gfp_mask(x)|__GFP_COLD);
66} 71}
67#endif
68 72
69typedef int filler_t(void *, struct page *); 73typedef int filler_t(void *, struct page *);
70 74
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 5c604f5fad67..09be0f81b27b 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -443,6 +443,7 @@ extern void pci_remove_bus(struct pci_bus *b);
443extern void pci_remove_bus_device(struct pci_dev *dev); 443extern void pci_remove_bus_device(struct pci_dev *dev);
444extern void pci_stop_bus_device(struct pci_dev *dev); 444extern void pci_stop_bus_device(struct pci_dev *dev);
445void pci_setup_cardbus(struct pci_bus *bus); 445void pci_setup_cardbus(struct pci_bus *bus);
446extern void pci_sort_breadthfirst(void);
446 447
447/* Generic PCI functions exported to card drivers */ 448/* Generic PCI functions exported to card drivers */
448 449
@@ -452,13 +453,18 @@ struct pci_dev *pci_find_slot (unsigned int bus, unsigned int devfn);
452int pci_find_capability (struct pci_dev *dev, int cap); 453int pci_find_capability (struct pci_dev *dev, int cap);
453int pci_find_next_capability (struct pci_dev *dev, u8 pos, int cap); 454int pci_find_next_capability (struct pci_dev *dev, u8 pos, int cap);
454int pci_find_ext_capability (struct pci_dev *dev, int cap); 455int pci_find_ext_capability (struct pci_dev *dev, int cap);
455struct pci_bus * pci_find_next_bus(const struct pci_bus *from); 456struct pci_bus *pci_find_next_bus(const struct pci_bus *from);
457
458struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device,
459 struct pci_dev *from);
460struct pci_dev *pci_get_device_reverse(unsigned int vendor, unsigned int device,
461 struct pci_dev *from);
456 462
457struct pci_dev *pci_get_device (unsigned int vendor, unsigned int device, struct pci_dev *from);
458struct pci_dev *pci_get_subsys (unsigned int vendor, unsigned int device, 463struct pci_dev *pci_get_subsys (unsigned int vendor, unsigned int device,
459 unsigned int ss_vendor, unsigned int ss_device, 464 unsigned int ss_vendor, unsigned int ss_device,
460 struct pci_dev *from); 465 struct pci_dev *from);
461struct pci_dev *pci_get_slot (struct pci_bus *bus, unsigned int devfn); 466struct pci_dev *pci_get_slot (struct pci_bus *bus, unsigned int devfn);
467struct pci_dev *pci_get_bus_and_slot (unsigned int bus, unsigned int devfn);
462struct pci_dev *pci_get_class (unsigned int class, struct pci_dev *from); 468struct pci_dev *pci_get_class (unsigned int class, struct pci_dev *from);
463int pci_dev_present(const struct pci_device_id *ids); 469int pci_dev_present(const struct pci_device_id *ids);
464 470
@@ -658,7 +664,12 @@ static inline struct pci_dev *pci_find_device(unsigned int vendor, unsigned int
658static inline struct pci_dev *pci_find_slot(unsigned int bus, unsigned int devfn) 664static inline struct pci_dev *pci_find_slot(unsigned int bus, unsigned int devfn)
659{ return NULL; } 665{ return NULL; }
660 666
661static inline struct pci_dev *pci_get_device (unsigned int vendor, unsigned int device, struct pci_dev *from) 667static inline struct pci_dev *pci_get_device(unsigned int vendor,
668 unsigned int device, struct pci_dev *from)
669{ return NULL; }
670
671static inline struct pci_dev *pci_get_device_reverse(unsigned int vendor,
672 unsigned int device, struct pci_dev *from)
662{ return NULL; } 673{ return NULL; }
663 674
664static inline struct pci_dev *pci_get_subsys (unsigned int vendor, unsigned int device, 675static inline struct pci_dev *pci_get_subsys (unsigned int vendor, unsigned int device,
diff --git a/drivers/pci/hotplug/pci_hotplug.h b/include/linux/pci_hotplug.h
index 772523dc3860..a675a05c4091 100644
--- a/drivers/pci/hotplug/pci_hotplug.h
+++ b/include/linux/pci_hotplug.h
@@ -22,7 +22,7 @@
22 * along with this program; if not, write to the Free Software 22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 * 24 *
25 * Send feedback to <greg@kroah.com> 25 * Send feedback to <kristen.c.accardi@intel.com>
26 * 26 *
27 */ 27 */
28#ifndef _PCI_HOTPLUG_H 28#ifndef _PCI_HOTPLUG_H
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index f069df245469..fa4e1d799782 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -1213,6 +1213,7 @@
1213#define PCI_DEVICE_ID_NVIDIA_NVENET_21 0x0451 1213#define PCI_DEVICE_ID_NVIDIA_NVENET_21 0x0451
1214#define PCI_DEVICE_ID_NVIDIA_NVENET_22 0x0452 1214#define PCI_DEVICE_ID_NVIDIA_NVENET_22 0x0452
1215#define PCI_DEVICE_ID_NVIDIA_NVENET_23 0x0453 1215#define PCI_DEVICE_ID_NVIDIA_NVENET_23 0x0453
1216#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE 0x0560
1216 1217
1217#define PCI_VENDOR_ID_IMS 0x10e0 1218#define PCI_VENDOR_ID_IMS 0x10e0
1218#define PCI_DEVICE_ID_IMS_TT128 0x9128 1219#define PCI_DEVICE_ID_IMS_TT128 0x9128
@@ -2351,3 +2352,5 @@
2351#define PCI_DEVICE_ID_RME_DIGI32_PRO 0x9897 2352#define PCI_DEVICE_ID_RME_DIGI32_PRO 0x9897
2352#define PCI_DEVICE_ID_RME_DIGI32_8 0x9898 2353#define PCI_DEVICE_ID_RME_DIGI32_8 0x9898
2353 2354
2355#define PCI_VENDOR_ID_QUICKNET 0x15E2
2356#define PCI_DEVICE_ID_QUICKNET_XJ 0x0500
diff --git a/include/linux/pci_regs.h b/include/linux/pci_regs.h
index c312a12ad2d6..c321316f1bc7 100644
--- a/include/linux/pci_regs.h
+++ b/include/linux/pci_regs.h
@@ -371,6 +371,7 @@
371#define PCI_EXP_DEVSTA_TRPND 0x20 /* Transactions Pending */ 371#define PCI_EXP_DEVSTA_TRPND 0x20 /* Transactions Pending */
372#define PCI_EXP_LNKCAP 12 /* Link Capabilities */ 372#define PCI_EXP_LNKCAP 12 /* Link Capabilities */
373#define PCI_EXP_LNKCTL 16 /* Link Control */ 373#define PCI_EXP_LNKCTL 16 /* Link Control */
374#define PCI_EXP_LNKCTL_CLKREQ_EN 0x100 /* Enable clkreq */
374#define PCI_EXP_LNKSTA 18 /* Link Status */ 375#define PCI_EXP_LNKSTA 18 /* Link Status */
375#define PCI_EXP_SLTCAP 20 /* Slot Capabilities */ 376#define PCI_EXP_SLTCAP 20 /* Slot Capabilities */
376#define PCI_EXP_SLTCTL 24 /* Slot Control */ 377#define PCI_EXP_SLTCTL 24 /* Slot Control */
diff --git a/include/linux/personality.h b/include/linux/personality.h
index 80d780e5a8f5..012cd558189b 100644
--- a/include/linux/personality.h
+++ b/include/linux/personality.h
@@ -1,6 +1,8 @@
1#ifndef _LINUX_PERSONALITY_H 1#ifndef _LINUX_PERSONALITY_H
2#define _LINUX_PERSONALITY_H 2#define _LINUX_PERSONALITY_H
3 3
4#ifdef __KERNEL__
5
4/* 6/*
5 * Handling of different ABIs (personalities). 7 * Handling of different ABIs (personalities).
6 */ 8 */
@@ -12,6 +14,8 @@ extern int register_exec_domain(struct exec_domain *);
12extern int unregister_exec_domain(struct exec_domain *); 14extern int unregister_exec_domain(struct exec_domain *);
13extern int __set_personality(unsigned long); 15extern int __set_personality(unsigned long);
14 16
17#endif /* __KERNEL__ */
18
15/* 19/*
16 * Flags for bug emulation. 20 * Flags for bug emulation.
17 * 21 *
@@ -71,6 +75,7 @@ enum {
71 PER_MASK = 0x00ff, 75 PER_MASK = 0x00ff,
72}; 76};
73 77
78#ifdef __KERNEL__
74 79
75/* 80/*
76 * Description of an execution domain. 81 * Description of an execution domain.
@@ -109,6 +114,8 @@ struct exec_domain {
109 * Change personality of the currently running process. 114 * Change personality of the currently running process.
110 */ 115 */
111#define set_personality(pers) \ 116#define set_personality(pers) \
112 ((current->personality == pers) ? 0 : __set_personality(pers)) 117 ((current->personality == (pers)) ? 0 : __set_personality(pers))
118
119#endif /* __KERNEL__ */
113 120
114#endif /* _LINUX_PERSONALITY_H */ 121#endif /* _LINUX_PERSONALITY_H */
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 6b27e07aef19..070394e846d0 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -116,7 +116,9 @@ typedef int __bitwise suspend_disk_method_t;
116#define PM_DISK_PLATFORM ((__force suspend_disk_method_t) 2) 116#define PM_DISK_PLATFORM ((__force suspend_disk_method_t) 2)
117#define PM_DISK_SHUTDOWN ((__force suspend_disk_method_t) 3) 117#define PM_DISK_SHUTDOWN ((__force suspend_disk_method_t) 3)
118#define PM_DISK_REBOOT ((__force suspend_disk_method_t) 4) 118#define PM_DISK_REBOOT ((__force suspend_disk_method_t) 4)
119#define PM_DISK_MAX ((__force suspend_disk_method_t) 5) 119#define PM_DISK_TEST ((__force suspend_disk_method_t) 5)
120#define PM_DISK_TESTPROC ((__force suspend_disk_method_t) 6)
121#define PM_DISK_MAX ((__force suspend_disk_method_t) 7)
120 122
121struct pm_ops { 123struct pm_ops {
122 suspend_disk_method_t pm_disk_mode; 124 suspend_disk_method_t pm_disk_mode;
diff --git a/include/linux/raid/bitmap.h b/include/linux/raid/bitmap.h
index 84d887751855..ebd42a3710b4 100644
--- a/include/linux/raid/bitmap.h
+++ b/include/linux/raid/bitmap.h
@@ -146,16 +146,16 @@ enum bitmap_state {
146 146
147/* the superblock at the front of the bitmap file -- little endian */ 147/* the superblock at the front of the bitmap file -- little endian */
148typedef struct bitmap_super_s { 148typedef struct bitmap_super_s {
149 __u32 magic; /* 0 BITMAP_MAGIC */ 149 __le32 magic; /* 0 BITMAP_MAGIC */
150 __u32 version; /* 4 the bitmap major for now, could change... */ 150 __le32 version; /* 4 the bitmap major for now, could change... */
151 __u8 uuid[16]; /* 8 128 bit uuid - must match md device uuid */ 151 __u8 uuid[16]; /* 8 128 bit uuid - must match md device uuid */
152 __u64 events; /* 24 event counter for the bitmap (1)*/ 152 __le64 events; /* 24 event counter for the bitmap (1)*/
153 __u64 events_cleared;/*32 event counter when last bit cleared (2) */ 153 __le64 events_cleared;/*32 event counter when last bit cleared (2) */
154 __u64 sync_size; /* 40 the size of the md device's sync range(3) */ 154 __le64 sync_size; /* 40 the size of the md device's sync range(3) */
155 __u32 state; /* 48 bitmap state information */ 155 __le32 state; /* 48 bitmap state information */
156 __u32 chunksize; /* 52 the bitmap chunk size in bytes */ 156 __le32 chunksize; /* 52 the bitmap chunk size in bytes */
157 __u32 daemon_sleep; /* 56 seconds between disk flushes */ 157 __le32 daemon_sleep; /* 56 seconds between disk flushes */
158 __u32 write_behind; /* 60 number of outstanding write-behind writes */ 158 __le32 write_behind; /* 60 number of outstanding write-behind writes */
159 159
160 __u8 pad[256 - 64]; /* set to zero */ 160 __u8 pad[256 - 64]; /* set to zero */
161} bitmap_super_t; 161} bitmap_super_t;
diff --git a/include/linux/raid/md_p.h b/include/linux/raid/md_p.h
index b6ebc69bae54..3f2cd98c508b 100644
--- a/include/linux/raid/md_p.h
+++ b/include/linux/raid/md_p.h
@@ -206,52 +206,52 @@ static inline __u64 md_event(mdp_super_t *sb) {
206 */ 206 */
207struct mdp_superblock_1 { 207struct mdp_superblock_1 {
208 /* constant array information - 128 bytes */ 208 /* constant array information - 128 bytes */
209 __u32 magic; /* MD_SB_MAGIC: 0xa92b4efc - little endian */ 209 __le32 magic; /* MD_SB_MAGIC: 0xa92b4efc - little endian */
210 __u32 major_version; /* 1 */ 210 __le32 major_version; /* 1 */
211 __u32 feature_map; /* bit 0 set if 'bitmap_offset' is meaningful */ 211 __le32 feature_map; /* bit 0 set if 'bitmap_offset' is meaningful */
212 __u32 pad0; /* always set to 0 when writing */ 212 __le32 pad0; /* always set to 0 when writing */
213 213
214 __u8 set_uuid[16]; /* user-space generated. */ 214 __u8 set_uuid[16]; /* user-space generated. */
215 char set_name[32]; /* set and interpreted by user-space */ 215 char set_name[32]; /* set and interpreted by user-space */
216 216
217 __u64 ctime; /* lo 40 bits are seconds, top 24 are microseconds or 0*/ 217 __le64 ctime; /* lo 40 bits are seconds, top 24 are microseconds or 0*/
218 __u32 level; /* -4 (multipath), -1 (linear), 0,1,4,5 */ 218 __le32 level; /* -4 (multipath), -1 (linear), 0,1,4,5 */
219 __u32 layout; /* only for raid5 and raid10 currently */ 219 __le32 layout; /* only for raid5 and raid10 currently */
220 __u64 size; /* used size of component devices, in 512byte sectors */ 220 __le64 size; /* used size of component devices, in 512byte sectors */
221 221
222 __u32 chunksize; /* in 512byte sectors */ 222 __le32 chunksize; /* in 512byte sectors */
223 __u32 raid_disks; 223 __le32 raid_disks;
224 __u32 bitmap_offset; /* sectors after start of superblock that bitmap starts 224 __le32 bitmap_offset; /* sectors after start of superblock that bitmap starts
225 * NOTE: signed, so bitmap can be before superblock 225 * NOTE: signed, so bitmap can be before superblock
226 * only meaningful of feature_map[0] is set. 226 * only meaningful of feature_map[0] is set.
227 */ 227 */
228 228
229 /* These are only valid with feature bit '4' */ 229 /* These are only valid with feature bit '4' */
230 __u32 new_level; /* new level we are reshaping to */ 230 __le32 new_level; /* new level we are reshaping to */
231 __u64 reshape_position; /* next address in array-space for reshape */ 231 __le64 reshape_position; /* next address in array-space for reshape */
232 __u32 delta_disks; /* change in number of raid_disks */ 232 __le32 delta_disks; /* change in number of raid_disks */
233 __u32 new_layout; /* new layout */ 233 __le32 new_layout; /* new layout */
234 __u32 new_chunk; /* new chunk size (bytes) */ 234 __le32 new_chunk; /* new chunk size (bytes) */
235 __u8 pad1[128-124]; /* set to 0 when written */ 235 __u8 pad1[128-124]; /* set to 0 when written */
236 236
237 /* constant this-device information - 64 bytes */ 237 /* constant this-device information - 64 bytes */
238 __u64 data_offset; /* sector start of data, often 0 */ 238 __le64 data_offset; /* sector start of data, often 0 */
239 __u64 data_size; /* sectors in this device that can be used for data */ 239 __le64 data_size; /* sectors in this device that can be used for data */
240 __u64 super_offset; /* sector start of this superblock */ 240 __le64 super_offset; /* sector start of this superblock */
241 __u64 recovery_offset;/* sectors before this offset (from data_offset) have been recovered */ 241 __le64 recovery_offset;/* sectors before this offset (from data_offset) have been recovered */
242 __u32 dev_number; /* permanent identifier of this device - not role in raid */ 242 __le32 dev_number; /* permanent identifier of this device - not role in raid */
243 __u32 cnt_corrected_read; /* number of read errors that were corrected by re-writing */ 243 __le32 cnt_corrected_read; /* number of read errors that were corrected by re-writing */
244 __u8 device_uuid[16]; /* user-space setable, ignored by kernel */ 244 __u8 device_uuid[16]; /* user-space setable, ignored by kernel */
245 __u8 devflags; /* per-device flags. Only one defined...*/ 245 __u8 devflags; /* per-device flags. Only one defined...*/
246#define WriteMostly1 1 /* mask for writemostly flag in above */ 246#define WriteMostly1 1 /* mask for writemostly flag in above */
247 __u8 pad2[64-57]; /* set to 0 when writing */ 247 __u8 pad2[64-57]; /* set to 0 when writing */
248 248
249 /* array state information - 64 bytes */ 249 /* array state information - 64 bytes */
250 __u64 utime; /* 40 bits second, 24 btes microseconds */ 250 __le64 utime; /* 40 bits second, 24 btes microseconds */
251 __u64 events; /* incremented when superblock updated */ 251 __le64 events; /* incremented when superblock updated */
252 __u64 resync_offset; /* data before this offset (from data_offset) known to be in sync */ 252 __le64 resync_offset; /* data before this offset (from data_offset) known to be in sync */
253 __u32 sb_csum; /* checksum upto devs[max_dev] */ 253 __le32 sb_csum; /* checksum upto devs[max_dev] */
254 __u32 max_dev; /* size of devs[] array to consider */ 254 __le32 max_dev; /* size of devs[] array to consider */
255 __u8 pad3[64-32]; /* set to 0 when writing */ 255 __u8 pad3[64-32]; /* set to 0 when writing */
256 256
257 /* device state information. Indexed by dev_number. 257 /* device state information. Indexed by dev_number.
@@ -260,7 +260,7 @@ struct mdp_superblock_1 {
260 * into the 'roles' value. If a device is spare or faulty, then it doesn't 260 * into the 'roles' value. If a device is spare or faulty, then it doesn't
261 * have a meaningful role. 261 * have a meaningful role.
262 */ 262 */
263 __u16 dev_roles[0]; /* role in array, or 0xffff for a spare, or 0xfffe for faulty */ 263 __le16 dev_roles[0]; /* role in array, or 0xffff for a spare, or 0xfffe for faulty */
264}; 264};
265 265
266/* feature_map bits */ 266/* feature_map bits */
diff --git a/include/linux/random.h b/include/linux/random.h
index 5d6456bcdeba..0248b30e306d 100644
--- a/include/linux/random.h
+++ b/include/linux/random.h
@@ -69,6 +69,9 @@ extern struct file_operations random_fops, urandom_fops;
69unsigned int get_random_int(void); 69unsigned int get_random_int(void);
70unsigned long randomize_range(unsigned long start, unsigned long end, unsigned long len); 70unsigned long randomize_range(unsigned long start, unsigned long end, unsigned long len);
71 71
72u32 random32(void);
73void srandom32(u32 seed);
74
72#endif /* __KERNEL___ */ 75#endif /* __KERNEL___ */
73 76
74#endif /* _LINUX_RANDOM_H */ 77#endif /* _LINUX_RANDOM_H */
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 6735c1cf334c..eafe4a7b8237 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -466,7 +466,6 @@ struct signal_struct {
466 struct pacct_struct pacct; /* per-process accounting information */ 466 struct pacct_struct pacct; /* per-process accounting information */
467#endif 467#endif
468#ifdef CONFIG_TASKSTATS 468#ifdef CONFIG_TASKSTATS
469 spinlock_t stats_lock;
470 struct taskstats *stats; 469 struct taskstats *stats;
471#endif 470#endif
472}; 471};
diff --git a/include/linux/security.h b/include/linux/security.h
index 9b5fea81f55e..b200b9856f32 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -882,7 +882,8 @@ struct request_sock;
882 * Check permission when a flow selects a xfrm_policy for processing 882 * Check permission when a flow selects a xfrm_policy for processing
883 * XFRMs on a packet. The hook is called when selecting either a 883 * XFRMs on a packet. The hook is called when selecting either a
884 * per-socket policy or a generic xfrm policy. 884 * per-socket policy or a generic xfrm policy.
885 * Return 0 if permission is granted. 885 * Return 0 if permission is granted, -ESRCH otherwise, or -errno
886 * on other errors.
886 * @xfrm_state_pol_flow_match: 887 * @xfrm_state_pol_flow_match:
887 * @x contains the state to match. 888 * @x contains the state to match.
888 * @xp contains the policy to check for a match. 889 * @xp contains the policy to check for a match.
@@ -891,6 +892,7 @@ struct request_sock;
891 * @xfrm_flow_state_match: 892 * @xfrm_flow_state_match:
892 * @fl contains the flow key to match. 893 * @fl contains the flow key to match.
893 * @xfrm points to the xfrm_state to match. 894 * @xfrm points to the xfrm_state to match.
895 * @xp points to the xfrm_policy to match.
894 * Return 1 if there is a match. 896 * Return 1 if there is a match.
895 * @xfrm_decode_session: 897 * @xfrm_decode_session:
896 * @skb points to skb to decode. 898 * @skb points to skb to decode.
@@ -1388,7 +1390,8 @@ struct security_operations {
1388 int (*xfrm_policy_lookup)(struct xfrm_policy *xp, u32 fl_secid, u8 dir); 1390 int (*xfrm_policy_lookup)(struct xfrm_policy *xp, u32 fl_secid, u8 dir);
1389 int (*xfrm_state_pol_flow_match)(struct xfrm_state *x, 1391 int (*xfrm_state_pol_flow_match)(struct xfrm_state *x,
1390 struct xfrm_policy *xp, struct flowi *fl); 1392 struct xfrm_policy *xp, struct flowi *fl);
1391 int (*xfrm_flow_state_match)(struct flowi *fl, struct xfrm_state *xfrm); 1393 int (*xfrm_flow_state_match)(struct flowi *fl, struct xfrm_state *xfrm,
1394 struct xfrm_policy *xp);
1392 int (*xfrm_decode_session)(struct sk_buff *skb, u32 *secid, int ckall); 1395 int (*xfrm_decode_session)(struct sk_buff *skb, u32 *secid, int ckall);
1393#endif /* CONFIG_SECURITY_NETWORK_XFRM */ 1396#endif /* CONFIG_SECURITY_NETWORK_XFRM */
1394 1397
@@ -3120,11 +3123,6 @@ static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm
3120 return security_ops->xfrm_policy_alloc_security(xp, sec_ctx, NULL); 3123 return security_ops->xfrm_policy_alloc_security(xp, sec_ctx, NULL);
3121} 3124}
3122 3125
3123static inline int security_xfrm_sock_policy_alloc(struct xfrm_policy *xp, struct sock *sk)
3124{
3125 return security_ops->xfrm_policy_alloc_security(xp, NULL, sk);
3126}
3127
3128static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new) 3126static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
3129{ 3127{
3130 return security_ops->xfrm_policy_clone_security(old, new); 3128 return security_ops->xfrm_policy_clone_security(old, new);
@@ -3175,9 +3173,10 @@ static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
3175 return security_ops->xfrm_state_pol_flow_match(x, xp, fl); 3173 return security_ops->xfrm_state_pol_flow_match(x, xp, fl);
3176} 3174}
3177 3175
3178static inline int security_xfrm_flow_state_match(struct flowi *fl, struct xfrm_state *xfrm) 3176static inline int security_xfrm_flow_state_match(struct flowi *fl,
3177 struct xfrm_state *xfrm, struct xfrm_policy *xp)
3179{ 3178{
3180 return security_ops->xfrm_flow_state_match(fl, xfrm); 3179 return security_ops->xfrm_flow_state_match(fl, xfrm, xp);
3181} 3180}
3182 3181
3183static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid) 3182static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
@@ -3197,11 +3196,6 @@ static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm
3197 return 0; 3196 return 0;
3198} 3197}
3199 3198
3200static inline int security_xfrm_sock_policy_alloc(struct xfrm_policy *xp, struct sock *sk)
3201{
3202 return 0;
3203}
3204
3205static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new) 3199static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
3206{ 3200{
3207 return 0; 3201 return 0;
@@ -3249,7 +3243,7 @@ static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
3249} 3243}
3250 3244
3251static inline int security_xfrm_flow_state_match(struct flowi *fl, 3245static inline int security_xfrm_flow_state_match(struct flowi *fl,
3252 struct xfrm_state *xfrm) 3246 struct xfrm_state *xfrm, struct xfrm_policy *xp)
3253{ 3247{
3254 return 1; 3248 return 1;
3255} 3249}
diff --git a/include/linux/serio.h b/include/linux/serio.h
index 3a697cc6ecae..b99c5ca9708d 100644
--- a/include/linux/serio.h
+++ b/include/linux/serio.h
@@ -41,6 +41,7 @@ struct serio {
41 void (*stop)(struct serio *); 41 void (*stop)(struct serio *);
42 42
43 struct serio *parent, *child; 43 struct serio *parent, *child;
44 unsigned int depth; /* level of nesting in serio hierarchy */
44 45
45 struct serio_driver *drv; /* accessed from interrupt, must be protected by serio->lock and serio->sem */ 46 struct serio_driver *drv; /* accessed from interrupt, must be protected by serio->lock and serio->sem */
46 struct mutex drv_mutex; /* protects serio->drv so attributes can pin driver */ 47 struct mutex drv_mutex; /* protects serio->drv so attributes can pin driver */
diff --git a/include/linux/sunrpc/msg_prot.h b/include/linux/sunrpc/msg_prot.h
index 1e65f2dd80e5..606cb2165232 100644
--- a/include/linux/sunrpc/msg_prot.h
+++ b/include/linux/sunrpc/msg_prot.h
@@ -56,7 +56,9 @@ enum rpc_accept_stat {
56 RPC_PROG_MISMATCH = 2, 56 RPC_PROG_MISMATCH = 2,
57 RPC_PROC_UNAVAIL = 3, 57 RPC_PROC_UNAVAIL = 3,
58 RPC_GARBAGE_ARGS = 4, 58 RPC_GARBAGE_ARGS = 4,
59 RPC_SYSTEM_ERR = 5 59 RPC_SYSTEM_ERR = 5,
60 /* internal use only */
61 RPC_DROP_REPLY = 60000,
60}; 62};
61 63
62enum rpc_reject_stat { 64enum rpc_reject_stat {
diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
index 9c9a8ad92477..965d6c20086e 100644
--- a/include/linux/sunrpc/svc.h
+++ b/include/linux/sunrpc/svc.h
@@ -335,7 +335,7 @@ struct svc_version {
335/* 335/*
336 * RPC procedure info 336 * RPC procedure info
337 */ 337 */
338typedef int (*svc_procfunc)(struct svc_rqst *, void *argp, void *resp); 338typedef __be32 (*svc_procfunc)(struct svc_rqst *, void *argp, void *resp);
339struct svc_procedure { 339struct svc_procedure {
340 svc_procfunc pc_func; /* process the request */ 340 svc_procfunc pc_func; /* process the request */
341 kxdrproc_t pc_decode; /* XDR decode args */ 341 kxdrproc_t pc_decode; /* XDR decode args */
diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h
index 953723b09bc6..ac69e5511606 100644
--- a/include/linux/sunrpc/xdr.h
+++ b/include/linux/sunrpc/xdr.h
@@ -74,6 +74,7 @@ struct xdr_buf {
74#define rpc_proc_unavail __constant_htonl(RPC_PROC_UNAVAIL) 74#define rpc_proc_unavail __constant_htonl(RPC_PROC_UNAVAIL)
75#define rpc_garbage_args __constant_htonl(RPC_GARBAGE_ARGS) 75#define rpc_garbage_args __constant_htonl(RPC_GARBAGE_ARGS)
76#define rpc_system_err __constant_htonl(RPC_SYSTEM_ERR) 76#define rpc_system_err __constant_htonl(RPC_SYSTEM_ERR)
77#define rpc_drop_reply __constant_htonl(RPC_DROP_REPLY)
77 78
78#define rpc_auth_ok __constant_htonl(RPC_AUTH_OK) 79#define rpc_auth_ok __constant_htonl(RPC_AUTH_OK)
79#define rpc_autherr_badcred __constant_htonl(RPC_AUTH_BADCRED) 80#define rpc_autherr_badcred __constant_htonl(RPC_AUTH_BADCRED)
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index b0ace3fd7eb9..1912c6cbef55 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -431,6 +431,10 @@ asmlinkage long sys_epoll_ctl(int epfd, int op, int fd,
431 struct epoll_event __user *event); 431 struct epoll_event __user *event);
432asmlinkage long sys_epoll_wait(int epfd, struct epoll_event __user *events, 432asmlinkage long sys_epoll_wait(int epfd, struct epoll_event __user *events,
433 int maxevents, int timeout); 433 int maxevents, int timeout);
434asmlinkage long sys_epoll_pwait(int epfd, struct epoll_event __user *events,
435 int maxevents, int timeout,
436 const sigset_t __user *sigmask,
437 size_t sigsetsize);
434asmlinkage long sys_gethostname(char __user *name, int len); 438asmlinkage long sys_gethostname(char __user *name, int len);
435asmlinkage long sys_sethostname(char __user *name, int len); 439asmlinkage long sys_sethostname(char __user *name, int len);
436asmlinkage long sys_setdomainname(char __user *name, int len); 440asmlinkage long sys_setdomainname(char __user *name, int len);
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 1b24bd45e080..d98562f1df76 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -6,10 +6,17 @@
6 **************************************************************** 6 ****************************************************************
7 **************************************************************** 7 ****************************************************************
8 ** 8 **
9 ** WARNING:
9 ** The values in this file are exported to user space via 10 ** The values in this file are exported to user space via
10 ** the sysctl() binary interface. However this interface 11 ** the sysctl() binary interface. Do *NOT* change the
11 ** is unstable and deprecated and will be removed in the future. 12 ** numbering of any existing values here, and do not change
12 ** For a stable interface use /proc/sys. 13 ** any numbers within any one set of values. If you have to
14 ** have to redefine an existing interface, use a new number for it.
15 ** The kernel will then return -ENOTDIR to any application using
16 ** the old binary interface.
17 **
18 ** For new interfaces unless you really need a binary number
19 ** please use CTL_UNNUMBERED.
13 ** 20 **
14 **************************************************************** 21 ****************************************************************
15 **************************************************************** 22 ****************************************************************
@@ -48,6 +55,7 @@ struct __sysctl_args {
48#ifdef __KERNEL__ 55#ifdef __KERNEL__
49#define CTL_ANY -1 /* Matches any name */ 56#define CTL_ANY -1 /* Matches any name */
50#define CTL_NONE 0 57#define CTL_NONE 0
58#define CTL_UNNUMBERED CTL_NONE /* sysctl without a binary number */
51#endif 59#endif
52 60
53enum 61enum
@@ -961,8 +969,8 @@ extern ctl_handler sysctl_ms_jiffies;
961/* 969/*
962 * Register a set of sysctl names by calling register_sysctl_table 970 * Register a set of sysctl names by calling register_sysctl_table
963 * with an initialised array of ctl_table's. An entry with zero 971 * with an initialised array of ctl_table's. An entry with zero
964 * ctl_name terminates the table. table->de will be set up by the 972 * ctl_name and NULL procname terminates the table. table->de will be
965 * registration and need not be initialised in advance. 973 * set up by the registration and need not be initialised in advance.
966 * 974 *
967 * sysctl names can be mirrored automatically under /proc/sys. The 975 * sysctl names can be mirrored automatically under /proc/sys. The
968 * procname supplied controls /proc naming. 976 * procname supplied controls /proc naming.
@@ -973,7 +981,10 @@ extern ctl_handler sysctl_ms_jiffies;
973 * Leaf nodes in the sysctl tree will be represented by a single file 981 * Leaf nodes in the sysctl tree will be represented by a single file
974 * under /proc; non-leaf nodes will be represented by directories. A 982 * under /proc; non-leaf nodes will be represented by directories. A
975 * null procname disables /proc mirroring at this node. 983 * null procname disables /proc mirroring at this node.
976 * 984 *
985 * sysctl entries with a zero ctl_name will not be available through
986 * the binary sysctl interface.
987 *
977 * sysctl(2) can automatically manage read and write requests through 988 * sysctl(2) can automatically manage read and write requests through
978 * the sysctl table. The data and maxlen fields of the ctl_table 989 * the sysctl table. The data and maxlen fields of the ctl_table
979 * struct enable minimal validation of the values being written to be 990 * struct enable minimal validation of the values being written to be
diff --git a/include/linux/taskstats_kern.h b/include/linux/taskstats_kern.h
index 16894b7edcc8..6562a2050a25 100644
--- a/include/linux/taskstats_kern.h
+++ b/include/linux/taskstats_kern.h
@@ -23,25 +23,26 @@ static inline void taskstats_exit_free(struct taskstats *tidstats)
23 23
24static inline void taskstats_tgid_init(struct signal_struct *sig) 24static inline void taskstats_tgid_init(struct signal_struct *sig)
25{ 25{
26 spin_lock_init(&sig->stats_lock);
27 sig->stats = NULL; 26 sig->stats = NULL;
28} 27}
29 28
30static inline void taskstats_tgid_alloc(struct signal_struct *sig) 29static inline void taskstats_tgid_alloc(struct task_struct *tsk)
31{ 30{
31 struct signal_struct *sig = tsk->signal;
32 struct taskstats *stats; 32 struct taskstats *stats;
33 unsigned long flags;
34 33
35 stats = kmem_cache_zalloc(taskstats_cache, SLAB_KERNEL); 34 if (sig->stats != NULL)
36 if (!stats)
37 return; 35 return;
38 36
39 spin_lock_irqsave(&sig->stats_lock, flags); 37 /* No problem if kmem_cache_zalloc() fails */
38 stats = kmem_cache_zalloc(taskstats_cache, SLAB_KERNEL);
39
40 spin_lock_irq(&tsk->sighand->siglock);
40 if (!sig->stats) { 41 if (!sig->stats) {
41 sig->stats = stats; 42 sig->stats = stats;
42 stats = NULL; 43 stats = NULL;
43 } 44 }
44 spin_unlock_irqrestore(&sig->stats_lock, flags); 45 spin_unlock_irq(&tsk->sighand->siglock);
45 46
46 if (stats) 47 if (stats)
47 kmem_cache_free(taskstats_cache, stats); 48 kmem_cache_free(taskstats_cache, stats);
@@ -49,23 +50,13 @@ static inline void taskstats_tgid_alloc(struct signal_struct *sig)
49 50
50static inline void taskstats_tgid_free(struct signal_struct *sig) 51static inline void taskstats_tgid_free(struct signal_struct *sig)
51{ 52{
52 struct taskstats *stats = NULL; 53 if (sig->stats)
53 unsigned long flags; 54 kmem_cache_free(taskstats_cache, sig->stats);
54
55 spin_lock_irqsave(&sig->stats_lock, flags);
56 if (sig->stats) {
57 stats = sig->stats;
58 sig->stats = NULL;
59 }
60 spin_unlock_irqrestore(&sig->stats_lock, flags);
61 if (stats)
62 kmem_cache_free(taskstats_cache, stats);
63} 55}
64 56
65extern void taskstats_exit_alloc(struct taskstats **, unsigned int *); 57extern void taskstats_exit_alloc(struct taskstats **, unsigned int *);
66extern void taskstats_exit_send(struct task_struct *, struct taskstats *, int, unsigned int); 58extern void taskstats_exit_send(struct task_struct *, struct taskstats *, int, unsigned int);
67extern void taskstats_init_early(void); 59extern void taskstats_init_early(void);
68extern void taskstats_tgid_alloc(struct signal_struct *);
69#else 60#else
70static inline void taskstats_exit_alloc(struct taskstats **ptidstats, unsigned int *mycpu) 61static inline void taskstats_exit_alloc(struct taskstats **ptidstats, unsigned int *mycpu)
71{} 62{}
@@ -77,7 +68,7 @@ static inline void taskstats_exit_send(struct task_struct *tsk,
77{} 68{}
78static inline void taskstats_tgid_init(struct signal_struct *sig) 69static inline void taskstats_tgid_init(struct signal_struct *sig)
79{} 70{}
80static inline void taskstats_tgid_alloc(struct signal_struct *sig) 71static inline void taskstats_tgid_alloc(struct task_struct *tsk)
81{} 72{}
82static inline void taskstats_tgid_free(struct signal_struct *sig) 73static inline void taskstats_tgid_free(struct signal_struct *sig)
83{} 74{}
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index 0e058a2d1c6d..2d36f6db3706 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -342,6 +342,8 @@ struct tcp_sock {
342 342
343 unsigned long last_synq_overflow; 343 unsigned long last_synq_overflow;
344 344
345 __u32 tso_deferred;
346
345/* Receiver side RTT estimation */ 347/* Receiver side RTT estimation */
346 struct { 348 struct {
347 __u32 rtt; 349 __u32 rtt;
diff --git a/include/linux/tipc.h b/include/linux/tipc.h
index 243a15f54002..bea469455a0c 100644
--- a/include/linux/tipc.h
+++ b/include/linux/tipc.h
@@ -129,6 +129,7 @@ static inline unsigned int tipc_node(__u32 addr)
129 129
130#define TIPC_SUB_PORTS 0x01 /* filter for port availability */ 130#define TIPC_SUB_PORTS 0x01 /* filter for port availability */
131#define TIPC_SUB_SERVICE 0x02 /* filter for service availability */ 131#define TIPC_SUB_SERVICE 0x02 /* filter for service availability */
132#define TIPC_SUB_CANCEL 0x04 /* cancel a subscription */
132#if 0 133#if 0
133/* The following filter options are not currently implemented */ 134/* The following filter options are not currently implemented */
134#define TIPC_SUB_NO_BIND_EVTS 0x04 /* filter out "publish" events */ 135#define TIPC_SUB_NO_BIND_EVTS 0x04 /* filter out "publish" events */
diff --git a/include/linux/ufs_fs.h b/include/linux/ufs_fs.h
index 61eef508b041..28967eda9d7b 100644
--- a/include/linux/ufs_fs.h
+++ b/include/linux/ufs_fs.h
@@ -908,7 +908,7 @@ struct ufs_super_block_third {
908 __fs64 fs_csaddr; /* blk addr of cyl grp summary area */ 908 __fs64 fs_csaddr; /* blk addr of cyl grp summary area */
909 __fs64 fs_pendingblocks;/* blocks in process of being freed */ 909 __fs64 fs_pendingblocks;/* blocks in process of being freed */
910 __fs32 fs_pendinginodes;/*inodes in process of being freed */ 910 __fs32 fs_pendinginodes;/*inodes in process of being freed */
911 } fs_u2; 911 } __attribute__ ((packed)) fs_u2;
912 } fs_un1; 912 } fs_un1;
913 union { 913 union {
914 struct { 914 struct {
diff --git a/include/linux/unwind.h b/include/linux/unwind.h
index 73e1751d03dd..749928c161fb 100644
--- a/include/linux/unwind.h
+++ b/include/linux/unwind.h
@@ -26,6 +26,7 @@ struct module;
26 * Initialize unwind support. 26 * Initialize unwind support.
27 */ 27 */
28extern void unwind_init(void); 28extern void unwind_init(void);
29extern void unwind_setup(void);
29 30
30#ifdef CONFIG_MODULES 31#ifdef CONFIG_MODULES
31 32
@@ -73,6 +74,7 @@ extern int unwind_to_user(struct unwind_frame_info *);
73struct unwind_frame_info {}; 74struct unwind_frame_info {};
74 75
75static inline void unwind_init(void) {} 76static inline void unwind_init(void) {}
77static inline void unwind_setup(void) {}
76 78
77#ifdef CONFIG_MODULES 79#ifdef CONFIG_MODULES
78 80
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index c5fdf6259548..df5c4654360d 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -243,7 +243,7 @@ struct v4l2_pix_format
243#define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y','U','1','2') /* 12 YUV 4:2:0 */ 243#define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y','U','1','2') /* 12 YUV 4:2:0 */
244#define V4L2_PIX_FMT_YYUV v4l2_fourcc('Y','Y','U','V') /* 16 YUV 4:2:2 */ 244#define V4L2_PIX_FMT_YYUV v4l2_fourcc('Y','Y','U','V') /* 16 YUV 4:2:2 */
245#define V4L2_PIX_FMT_HI240 v4l2_fourcc('H','I','2','4') /* 8 8-bit color */ 245#define V4L2_PIX_FMT_HI240 v4l2_fourcc('H','I','2','4') /* 8 8-bit color */
246#define V4L2_PIX_FMT_HM12 v4l2_fourcc('H','M','1','2') /* 8 YUV 4:1:1 16x16 macroblocks */ 246#define V4L2_PIX_FMT_HM12 v4l2_fourcc('H','M','1','2') /* 8 YUV 4:2:0 16x16 macroblocks */
247 247
248/* see http://www.siliconimaging.com/RGB%20Bayer.htm */ 248/* see http://www.siliconimaging.com/RGB%20Bayer.htm */
249#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B','A','8','1') /* 8 BGBG.. GRGR.. */ 249#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B','A','8','1') /* 8 BGBG.. GRGR.. */
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
index ce5f1482e6be..924e502905d4 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -23,13 +23,14 @@ struct vm_area_struct;
23#endif 23#endif
24 24
25struct vm_struct { 25struct vm_struct {
26 /* keep next,addr,size together to speedup lookups */
27 struct vm_struct *next;
26 void *addr; 28 void *addr;
27 unsigned long size; 29 unsigned long size;
28 unsigned long flags; 30 unsigned long flags;
29 struct page **pages; 31 struct page **pages;
30 unsigned int nr_pages; 32 unsigned int nr_pages;
31 unsigned long phys_addr; 33 unsigned long phys_addr;
32 struct vm_struct *next;
33}; 34};
34 35
35/* 36/*
@@ -60,7 +61,8 @@ extern struct vm_struct *get_vm_area(unsigned long size, unsigned long flags);
60extern struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags, 61extern struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags,
61 unsigned long start, unsigned long end); 62 unsigned long start, unsigned long end);
62extern struct vm_struct *get_vm_area_node(unsigned long size, 63extern struct vm_struct *get_vm_area_node(unsigned long size,
63 unsigned long flags, int node); 64 unsigned long flags, int node,
65 gfp_t gfp_mask);
64extern struct vm_struct *remove_vm_area(void *addr); 66extern struct vm_struct *remove_vm_area(void *addr);
65extern int map_vm_area(struct vm_struct *area, pgprot_t prot, 67extern int map_vm_area(struct vm_struct *area, pgprot_t prot,
66 struct page ***pages); 68 struct page ***pages);
diff --git a/include/linux/wait.h b/include/linux/wait.h
index b3b9048421d8..e820d00e1383 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -79,6 +79,15 @@ struct task_struct;
79 79
80extern void init_waitqueue_head(wait_queue_head_t *q); 80extern void init_waitqueue_head(wait_queue_head_t *q);
81 81
82#ifdef CONFIG_LOCKDEP
83# define __WAIT_QUEUE_HEAD_INIT_ONSTACK(name) \
84 ({ init_waitqueue_head(&name); name; })
85# define DECLARE_WAIT_QUEUE_HEAD_ONSTACK(name) \
86 wait_queue_head_t name = __WAIT_QUEUE_HEAD_INIT_ONSTACK(name)
87#else
88# define DECLARE_WAIT_QUEUE_HEAD_ONSTACK(name) DECLARE_WAIT_QUEUE_HEAD(name)
89#endif
90
82static inline void init_waitqueue_entry(wait_queue_t *q, struct task_struct *p) 91static inline void init_waitqueue_entry(wait_queue_t *q, struct task_struct *p)
83{ 92{
84 q->flags = 0; 93 q->flags = 0;
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index a341c8032866..fc35e6bdfb93 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -85,7 +85,6 @@ int wakeup_pdflush(long nr_pages);
85void laptop_io_completion(void); 85void laptop_io_completion(void);
86void laptop_sync_completion(void); 86void laptop_sync_completion(void);
87void throttle_vm_writeout(void); 87void throttle_vm_writeout(void);
88void writeback_congestion_end(void);
89 88
90/* These are exported to sysctl. */ 89/* These are exported to sysctl. */
91extern int dirty_background_ratio; 90extern int dirty_background_ratio;
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index df22efcfcc0b..c0fc39620f36 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -153,6 +153,7 @@ struct hci_conn {
153 __u8 mode; 153 __u8 mode;
154 __u8 type; 154 __u8 type;
155 __u8 out; 155 __u8 out;
156 __u8 attempt;
156 __u8 dev_class[3]; 157 __u8 dev_class[3];
157 __u8 features[8]; 158 __u8 features[8];
158 __u16 interval; 159 __u16 interval;
@@ -289,6 +290,22 @@ static inline struct hci_conn *hci_conn_hash_lookup_ba(struct hci_dev *hdev,
289 return NULL; 290 return NULL;
290} 291}
291 292
293static inline struct hci_conn *hci_conn_hash_lookup_state(struct hci_dev *hdev,
294 __u8 type, __u16 state)
295{
296 struct hci_conn_hash *h = &hdev->conn_hash;
297 struct list_head *p;
298 struct hci_conn *c;
299
300 list_for_each(p, &h->list) {
301 c = list_entry(p, struct hci_conn, list);
302 if (c->type == type && c->state == state)
303 return c;
304 }
305 return NULL;
306}
307
308void hci_acl_connect(struct hci_conn *conn);
292void hci_acl_disconn(struct hci_conn *conn, __u8 reason); 309void hci_acl_disconn(struct hci_conn *conn, __u8 reason);
293void hci_add_sco(struct hci_conn *conn, __u16 handle); 310void hci_add_sco(struct hci_conn *conn, __u16 handle);
294 311
diff --git a/include/net/dn.h b/include/net/dn.h
index 465b78302782..ac4ce9091747 100644
--- a/include/net/dn.h
+++ b/include/net/dn.h
@@ -199,11 +199,6 @@ static inline void dn_sk_ports_copy(struct flowi *fl, struct dn_scp *scp)
199{ 199{
200 fl->uli_u.dnports.sport = scp->addrloc; 200 fl->uli_u.dnports.sport = scp->addrloc;
201 fl->uli_u.dnports.dport = scp->addrrem; 201 fl->uli_u.dnports.dport = scp->addrrem;
202 fl->uli_u.dnports.objnum = scp->addr.sdn_objnum;
203 if (fl->uli_u.dnports.objnum == 0) {
204 fl->uli_u.dnports.objnamel = (__u8)dn_ntohs(scp->addr.sdn_objnamel);
205 memcpy(fl->uli_u.dnports.objname, scp->addr.sdn_objname, 16);
206 }
207} 202}
208 203
209extern unsigned dn_mss_from_pmtu(struct net_device *dev, int mtu); 204extern unsigned dn_mss_from_pmtu(struct net_device *dev, int mtu);
diff --git a/include/net/flow.h b/include/net/flow.h
index ddf5f3ca1720..5cda27cd9deb 100644
--- a/include/net/flow.h
+++ b/include/net/flow.h
@@ -68,9 +68,6 @@ struct flowi {
68 struct { 68 struct {
69 __le16 sport; 69 __le16 sport;
70 __le16 dport; 70 __le16 dport;
71 __u8 objnum;
72 __u8 objnamel; /* Not 16 bits since max val is 16 */
73 __u8 objname[16]; /* Not zero terminated */
74 } dnports; 71 } dnports;
75 72
76 __be32 spi; 73 __be32 spi;
@@ -97,7 +94,7 @@ struct flowi {
97#define FLOW_DIR_FWD 2 94#define FLOW_DIR_FWD 2
98 95
99struct sock; 96struct sock;
100typedef void (*flow_resolve_t)(struct flowi *key, u16 family, u8 dir, 97typedef int (*flow_resolve_t)(struct flowi *key, u16 family, u8 dir,
101 void **objp, atomic_t **obj_refp); 98 void **objp, atomic_t **obj_refp);
102 99
103extern void *flow_cache_lookup(struct flowi *key, u16 family, u8 dir, 100extern void *flow_cache_lookup(struct flowi *key, u16 family, u8 dir,
diff --git a/include/net/ieee80211softmac.h b/include/net/ieee80211softmac.h
index 425b3a57ac74..617b672b1132 100644
--- a/include/net/ieee80211softmac.h
+++ b/include/net/ieee80211softmac.h
@@ -63,13 +63,11 @@ struct ieee80211softmac_wpa {
63 63
64/* 64/*
65 * Information about association 65 * Information about association
66 *
67 * Do we need a lock for this?
68 * We only ever use this structure inlined
69 * into our global struct. I've used its lock,
70 * but maybe we need a local one here?
71 */ 66 */
72struct ieee80211softmac_assoc_info { 67struct ieee80211softmac_assoc_info {
68
69 struct mutex mutex;
70
73 /* 71 /*
74 * This is the requested ESSID. It is written 72 * This is the requested ESSID. It is written
75 * only by the WX handlers. 73 * only by the WX handlers.
@@ -99,12 +97,13 @@ struct ieee80211softmac_assoc_info {
99 * 97 *
100 * bssfixed is used for SIOCSIWAP. 98 * bssfixed is used for SIOCSIWAP.
101 */ 99 */
102 u8 static_essid:1, 100 u8 static_essid;
103 short_preamble_available:1, 101 u8 short_preamble_available;
104 associating:1, 102 u8 associating;
105 assoc_wait:1, 103 u8 associated;
106 bssvalid:1, 104 u8 assoc_wait;
107 bssfixed:1; 105 u8 bssvalid;
106 u8 bssfixed;
108 107
109 /* Scan retries remaining */ 108 /* Scan retries remaining */
110 int scan_retry; 109 int scan_retry;
@@ -229,12 +228,10 @@ struct ieee80211softmac_device {
229 /* private stuff follows */ 228 /* private stuff follows */
230 /* this lock protects this structure */ 229 /* this lock protects this structure */
231 spinlock_t lock; 230 spinlock_t lock;
232 231
233 /* couple of flags */ 232 u8 running; /* SoftMAC started? */
234 u8 scanning:1, /* protects scanning from being done multiple times at once */ 233 u8 scanning;
235 associated:1, 234
236 running:1;
237
238 struct ieee80211softmac_scaninfo *scaninfo; 235 struct ieee80211softmac_scaninfo *scaninfo;
239 struct ieee80211softmac_assoc_info associnfo; 236 struct ieee80211softmac_assoc_info associnfo;
240 struct ieee80211softmac_bss_info bssinfo; 237 struct ieee80211softmac_bss_info bssinfo;
@@ -250,7 +247,7 @@ struct ieee80211softmac_device {
250 247
251 /* we need to keep a list of network structs we copied */ 248 /* we need to keep a list of network structs we copied */
252 struct list_head network_list; 249 struct list_head network_list;
253 250
254 /* This must be the last item so that it points to the data 251 /* This must be the last item so that it points to the data
255 * allocated beyond this structure by alloc_ieee80211 */ 252 * allocated beyond this structure by alloc_ieee80211 */
256 u8 priv[0]; 253 u8 priv[0];
@@ -295,7 +292,7 @@ static inline u8 ieee80211softmac_suggest_txrate(struct ieee80211softmac_device
295{ 292{
296 struct ieee80211softmac_txrates *txrates = &mac->txrates; 293 struct ieee80211softmac_txrates *txrates = &mac->txrates;
297 294
298 if (!mac->associated) 295 if (!mac->associnfo.associated)
299 return txrates->mgt_mcast_rate; 296 return txrates->mgt_mcast_rate;
300 297
301 /* We are associated, sending unicast frame */ 298 /* We are associated, sending unicast frame */
diff --git a/include/net/inet_ecn.h b/include/net/inet_ecn.h
index d599c6bfbb86..7849844a4911 100644
--- a/include/net/inet_ecn.h
+++ b/include/net/inet_ecn.h
@@ -48,7 +48,7 @@ static inline __u8 INET_ECN_encapsulate(__u8 outer, __u8 inner)
48 48
49#define IP6_ECN_flow_xmit(sk, label) do { \ 49#define IP6_ECN_flow_xmit(sk, label) do { \
50 if (INET_ECN_is_capable(inet_sk(sk)->tos)) \ 50 if (INET_ECN_is_capable(inet_sk(sk)->tos)) \
51 (label) |= __constant_htons(INET_ECN_ECT_0 << 4); \ 51 (label) |= htonl(INET_ECN_ECT_0 << 20); \
52 } while (0) 52 } while (0)
53 53
54static inline int IP_ECN_set_ce(struct iphdr *iph) 54static inline int IP_ECN_set_ce(struct iphdr *iph)
diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h
index 6d14c22a00c5..5f48748fe017 100644
--- a/include/net/inet_timewait_sock.h
+++ b/include/net/inet_timewait_sock.h
@@ -196,6 +196,7 @@ static inline void inet_twsk_put(struct inet_timewait_sock *tw)
196{ 196{
197 if (atomic_dec_and_test(&tw->tw_refcnt)) { 197 if (atomic_dec_and_test(&tw->tw_refcnt)) {
198 struct module *owner = tw->tw_prot->owner; 198 struct module *owner = tw->tw_prot->owner;
199 twsk_destructor((struct sock *)tw);
199#ifdef SOCK_REFCNT_DEBUG 200#ifdef SOCK_REFCNT_DEBUG
200 printk(KERN_DEBUG "%s timewait_sock %p released\n", 201 printk(KERN_DEBUG "%s timewait_sock %p released\n",
201 tw->tw_prot->name, tw); 202 tw->tw_prot->name, tw);
diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
index 925573fd2aed..aa10a8178e70 100644
--- a/include/net/inetpeer.h
+++ b/include/net/inetpeer.h
@@ -17,14 +17,15 @@
17 17
18struct inet_peer 18struct inet_peer
19{ 19{
20 /* group together avl_left,avl_right,v4daddr to speedup lookups */
20 struct inet_peer *avl_left, *avl_right; 21 struct inet_peer *avl_left, *avl_right;
21 struct inet_peer *unused_next, **unused_prevp;
22 unsigned long dtime; /* the time of last use of not
23 * referenced entries */
24 atomic_t refcnt;
25 __be32 v4daddr; /* peer's address */ 22 __be32 v4daddr; /* peer's address */
26 __u16 avl_height; 23 __u16 avl_height;
27 __u16 ip_id_count; /* IP ID for the next packet */ 24 __u16 ip_id_count; /* IP ID for the next packet */
25 struct inet_peer *unused_next, **unused_prevp;
26 __u32 dtime; /* the time of last use of not
27 * referenced entries */
28 atomic_t refcnt;
28 atomic_t rid; /* Frag reception counter */ 29 atomic_t rid; /* Frag reception counter */
29 __u32 tcp_ts; 30 __u32 tcp_ts;
30 unsigned long tcp_ts_stamp; 31 unsigned long tcp_ts_stamp;
@@ -35,21 +36,8 @@ void inet_initpeers(void) __init;
35/* can be called with or without local BH being disabled */ 36/* can be called with or without local BH being disabled */
36struct inet_peer *inet_getpeer(__be32 daddr, int create); 37struct inet_peer *inet_getpeer(__be32 daddr, int create);
37 38
38extern spinlock_t inet_peer_unused_lock;
39extern struct inet_peer **inet_peer_unused_tailp;
40/* can be called from BH context or outside */ 39/* can be called from BH context or outside */
41static inline void inet_putpeer(struct inet_peer *p) 40extern void inet_putpeer(struct inet_peer *p);
42{
43 spin_lock_bh(&inet_peer_unused_lock);
44 if (atomic_dec_and_test(&p->refcnt)) {
45 p->unused_prevp = inet_peer_unused_tailp;
46 p->unused_next = NULL;
47 *inet_peer_unused_tailp = p;
48 inet_peer_unused_tailp = &p->unused_next;
49 p->dtime = jiffies;
50 }
51 spin_unlock_bh(&inet_peer_unused_lock);
52}
53 41
54extern spinlock_t inet_peer_idlock; 42extern spinlock_t inet_peer_idlock;
55/* can be called with or without local BH being disabled */ 43/* can be called with or without local BH being disabled */
diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index 6ca6b71dfe0f..c14b70ed4c57 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -36,13 +36,6 @@ struct route_info {
36#define RT6_LOOKUP_F_REACHABLE 0x2 36#define RT6_LOOKUP_F_REACHABLE 0x2
37#define RT6_LOOKUP_F_HAS_SADDR 0x4 37#define RT6_LOOKUP_F_HAS_SADDR 0x4
38 38
39struct pol_chain {
40 int type;
41 int priority;
42 struct fib6_node *rules;
43 struct pol_chain *next;
44};
45
46extern struct rt6_info ip6_null_entry; 39extern struct rt6_info ip6_null_entry;
47 40
48#ifdef CONFIG_IPV6_MULTIPLE_TABLES 41#ifdef CONFIG_IPV6_MULTIPLE_TABLES
diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
index 82229146bac7..949b932d2f08 100644
--- a/include/net/ip_fib.h
+++ b/include/net/ip_fib.h
@@ -21,17 +21,14 @@
21#include <net/fib_rules.h> 21#include <net/fib_rules.h>
22 22
23struct fib_config { 23struct fib_config {
24 u8 fc_family;
25 u8 fc_dst_len; 24 u8 fc_dst_len;
26 u8 fc_src_len;
27 u8 fc_tos; 25 u8 fc_tos;
28 u8 fc_protocol; 26 u8 fc_protocol;
29 u8 fc_scope; 27 u8 fc_scope;
30 u8 fc_type; 28 u8 fc_type;
31 /* 1 byte unused */ 29 /* 3 bytes unused */
32 u32 fc_table; 30 u32 fc_table;
33 __be32 fc_dst; 31 __be32 fc_dst;
34 __be32 fc_src;
35 __be32 fc_gw; 32 __be32 fc_gw;
36 int fc_oif; 33 int fc_oif;
37 u32 fc_flags; 34 u32 fc_flags;
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index 49c717e3b040..903108e583f8 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -7,6 +7,7 @@
7#define _IP_VS_H 7#define _IP_VS_H
8 8
9#include <asm/types.h> /* For __uXX types */ 9#include <asm/types.h> /* For __uXX types */
10#include <linux/types.h> /* For __beXX types in userland */
10 11
11#define IP_VS_VERSION_CODE 0x010201 12#define IP_VS_VERSION_CODE 0x010201
12#define NVERSION(version) \ 13#define NVERSION(version) \
diff --git a/include/net/ipx.h b/include/net/ipx.h
index 5c0cf33826c5..c6b2ee610866 100644
--- a/include/net/ipx.h
+++ b/include/net/ipx.h
@@ -15,9 +15,9 @@
15#include <linux/list.h> 15#include <linux/list.h>
16 16
17struct ipx_address { 17struct ipx_address {
18 __u32 net; 18 __be32 net;
19 __u8 node[IPX_NODE_LEN]; 19 __u8 node[IPX_NODE_LEN];
20 __u16 sock; 20 __be16 sock;
21}; 21};
22 22
23#define ipx_broadcast_node "\377\377\377\377\377\377" 23#define ipx_broadcast_node "\377\377\377\377\377\377"
@@ -26,9 +26,9 @@ struct ipx_address {
26#define IPX_MAX_PPROP_HOPS 8 26#define IPX_MAX_PPROP_HOPS 8
27 27
28struct ipxhdr { 28struct ipxhdr {
29 __u16 ipx_checksum __attribute__ ((packed)); 29 __be16 ipx_checksum __attribute__ ((packed));
30#define IPX_NO_CHECKSUM 0xFFFF 30#define IPX_NO_CHECKSUM __constant_htons(0xFFFF)
31 __u16 ipx_pktsize __attribute__ ((packed)); 31 __be16 ipx_pktsize __attribute__ ((packed));
32 __u8 ipx_tctrl; 32 __u8 ipx_tctrl;
33 __u8 ipx_type; 33 __u8 ipx_type;
34#define IPX_TYPE_UNKNOWN 0x00 34#define IPX_TYPE_UNKNOWN 0x00
@@ -48,14 +48,14 @@ static __inline__ struct ipxhdr *ipx_hdr(struct sk_buff *skb)
48 48
49struct ipx_interface { 49struct ipx_interface {
50 /* IPX address */ 50 /* IPX address */
51 __u32 if_netnum; 51 __be32 if_netnum;
52 unsigned char if_node[IPX_NODE_LEN]; 52 unsigned char if_node[IPX_NODE_LEN];
53 atomic_t refcnt; 53 atomic_t refcnt;
54 54
55 /* physical device info */ 55 /* physical device info */
56 struct net_device *if_dev; 56 struct net_device *if_dev;
57 struct datalink_proto *if_dlink; 57 struct datalink_proto *if_dlink;
58 unsigned short if_dlink_type; 58 __be16 if_dlink_type;
59 59
60 /* socket support */ 60 /* socket support */
61 unsigned short if_sknum; 61 unsigned short if_sknum;
@@ -71,7 +71,7 @@ struct ipx_interface {
71}; 71};
72 72
73struct ipx_route { 73struct ipx_route {
74 __u32 ir_net; 74 __be32 ir_net;
75 struct ipx_interface *ir_intrfc; 75 struct ipx_interface *ir_intrfc;
76 unsigned char ir_routed; 76 unsigned char ir_routed;
77 unsigned char ir_router_node[IPX_NODE_LEN]; 77 unsigned char ir_router_node[IPX_NODE_LEN];
@@ -82,10 +82,10 @@ struct ipx_route {
82#ifdef __KERNEL__ 82#ifdef __KERNEL__
83struct ipx_cb { 83struct ipx_cb {
84 u8 ipx_tctrl; 84 u8 ipx_tctrl;
85 u32 ipx_dest_net; 85 __be32 ipx_dest_net;
86 u32 ipx_source_net; 86 __be32 ipx_source_net;
87 struct { 87 struct {
88 u32 netnum; 88 __be32 netnum;
89 int index; 89 int index;
90 } last_hop; 90 } last_hop;
91}; 91};
@@ -97,7 +97,7 @@ struct ipx_sock {
97 struct sock sk; 97 struct sock sk;
98 struct ipx_address dest_addr; 98 struct ipx_address dest_addr;
99 struct ipx_interface *intrfc; 99 struct ipx_interface *intrfc;
100 unsigned short port; 100 __be16 port;
101#ifdef CONFIG_IPX_INTERN 101#ifdef CONFIG_IPX_INTERN
102 unsigned char node[IPX_NODE_LEN]; 102 unsigned char node[IPX_NODE_LEN];
103#endif 103#endif
@@ -132,7 +132,7 @@ extern struct ipx_interface *ipx_primary_net;
132extern int ipx_proc_init(void); 132extern int ipx_proc_init(void);
133extern void ipx_proc_exit(void); 133extern void ipx_proc_exit(void);
134 134
135extern const char *ipx_frame_name(unsigned short); 135extern const char *ipx_frame_name(__be16);
136extern const char *ipx_device_name(struct ipx_interface *intrfc); 136extern const char *ipx_device_name(struct ipx_interface *intrfc);
137 137
138static __inline__ void ipxitf_hold(struct ipx_interface *intrfc) 138static __inline__ void ipxitf_hold(struct ipx_interface *intrfc)
diff --git a/include/net/netlabel.h b/include/net/netlabel.h
index c63a58058e21..12c214b9eadf 100644
--- a/include/net/netlabel.h
+++ b/include/net/netlabel.h
@@ -34,6 +34,7 @@
34#include <linux/net.h> 34#include <linux/net.h>
35#include <linux/skbuff.h> 35#include <linux/skbuff.h>
36#include <net/netlink.h> 36#include <net/netlink.h>
37#include <asm/atomic.h>
37 38
38/* 39/*
39 * NetLabel - A management interface for maintaining network packet label 40 * NetLabel - A management interface for maintaining network packet label
@@ -106,6 +107,7 @@ int netlbl_domhsh_remove(const char *domain, struct netlbl_audit *audit_info);
106 107
107/* LSM security attributes */ 108/* LSM security attributes */
108struct netlbl_lsm_cache { 109struct netlbl_lsm_cache {
110 atomic_t refcount;
109 void (*free) (const void *data); 111 void (*free) (const void *data);
110 void *data; 112 void *data;
111}; 113};
@@ -117,7 +119,7 @@ struct netlbl_lsm_secattr {
117 unsigned char *mls_cat; 119 unsigned char *mls_cat;
118 size_t mls_cat_len; 120 size_t mls_cat_len;
119 121
120 struct netlbl_lsm_cache cache; 122 struct netlbl_lsm_cache *cache;
121}; 123};
122 124
123/* 125/*
@@ -126,6 +128,43 @@ struct netlbl_lsm_secattr {
126 128
127 129
128/** 130/**
131 * netlbl_secattr_cache_alloc - Allocate and initialize a secattr cache
132 * @flags: the memory allocation flags
133 *
134 * Description:
135 * Allocate and initialize a netlbl_lsm_cache structure. Returns a pointer
136 * on success, NULL on failure.
137 *
138 */
139static inline struct netlbl_lsm_cache *netlbl_secattr_cache_alloc(gfp_t flags)
140{
141 struct netlbl_lsm_cache *cache;
142
143 cache = kzalloc(sizeof(*cache), flags);
144 if (cache)
145 atomic_set(&cache->refcount, 1);
146 return cache;
147}
148
149/**
150 * netlbl_secattr_cache_free - Frees a netlbl_lsm_cache struct
151 * @cache: the struct to free
152 *
153 * Description:
154 * Frees @secattr including all of the internal buffers.
155 *
156 */
157static inline void netlbl_secattr_cache_free(struct netlbl_lsm_cache *cache)
158{
159 if (!atomic_dec_and_test(&cache->refcount))
160 return;
161
162 if (cache->free)
163 cache->free(cache->data);
164 kfree(cache);
165}
166
167/**
129 * netlbl_secattr_init - Initialize a netlbl_lsm_secattr struct 168 * netlbl_secattr_init - Initialize a netlbl_lsm_secattr struct
130 * @secattr: the struct to initialize 169 * @secattr: the struct to initialize
131 * 170 *
@@ -143,20 +182,16 @@ static inline int netlbl_secattr_init(struct netlbl_lsm_secattr *secattr)
143/** 182/**
144 * netlbl_secattr_destroy - Clears a netlbl_lsm_secattr struct 183 * netlbl_secattr_destroy - Clears a netlbl_lsm_secattr struct
145 * @secattr: the struct to clear 184 * @secattr: the struct to clear
146 * @clear_cache: cache clear flag
147 * 185 *
148 * Description: 186 * Description:
149 * Destroys the @secattr struct, including freeing all of the internal buffers. 187 * Destroys the @secattr struct, including freeing all of the internal buffers.
150 * If @clear_cache is true then free the cache fields, otherwise leave them 188 * The struct must be reset with a call to netlbl_secattr_init() before reuse.
151 * intact. The struct must be reset with a call to netlbl_secattr_init()
152 * before reuse.
153 * 189 *
154 */ 190 */
155static inline void netlbl_secattr_destroy(struct netlbl_lsm_secattr *secattr, 191static inline void netlbl_secattr_destroy(struct netlbl_lsm_secattr *secattr)
156 u32 clear_cache)
157{ 192{
158 if (clear_cache && secattr->cache.data != NULL && secattr->cache.free) 193 if (secattr->cache)
159 secattr->cache.free(secattr->cache.data); 194 netlbl_secattr_cache_free(secattr->cache);
160 kfree(secattr->domain); 195 kfree(secattr->domain);
161 kfree(secattr->mls_cat); 196 kfree(secattr->mls_cat);
162} 197}
@@ -178,17 +213,14 @@ static inline struct netlbl_lsm_secattr *netlbl_secattr_alloc(int flags)
178/** 213/**
179 * netlbl_secattr_free - Frees a netlbl_lsm_secattr struct 214 * netlbl_secattr_free - Frees a netlbl_lsm_secattr struct
180 * @secattr: the struct to free 215 * @secattr: the struct to free
181 * @clear_cache: cache clear flag
182 * 216 *
183 * Description: 217 * Description:
184 * Frees @secattr including all of the internal buffers. If @clear_cache is 218 * Frees @secattr including all of the internal buffers.
185 * true then free the cache fields, otherwise leave them intact.
186 * 219 *
187 */ 220 */
188static inline void netlbl_secattr_free(struct netlbl_lsm_secattr *secattr, 221static inline void netlbl_secattr_free(struct netlbl_lsm_secattr *secattr)
189 u32 clear_cache)
190{ 222{
191 netlbl_secattr_destroy(secattr, clear_cache); 223 netlbl_secattr_destroy(secattr);
192 kfree(secattr); 224 kfree(secattr);
193} 225}
194 226
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index ee68a3124076..764e3af5be93 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -139,6 +139,7 @@ int sctp_inet_listen(struct socket *sock, int backlog);
139void sctp_write_space(struct sock *sk); 139void sctp_write_space(struct sock *sk);
140unsigned int sctp_poll(struct file *file, struct socket *sock, 140unsigned int sctp_poll(struct file *file, struct socket *sock,
141 poll_table *wait); 141 poll_table *wait);
142void sctp_sock_rfree(struct sk_buff *skb);
142 143
143/* 144/*
144 * sctp/primitive.c 145 * sctp/primitive.c
@@ -444,6 +445,19 @@ static inline struct list_head *sctp_list_dequeue(struct list_head *list)
444 return result; 445 return result;
445} 446}
446 447
448/* SCTP version of skb_set_owner_r. We need this one because
449 * of the way we have to do receive buffer accounting on bundled
450 * chunks.
451 */
452static inline void sctp_skb_set_owner_r(struct sk_buff *skb, struct sock *sk)
453{
454 struct sctp_ulpevent *event = sctp_skb2event(skb);
455
456 skb->sk = sk;
457 skb->destructor = sctp_sock_rfree;
458 atomic_add(event->rmem_len, &sk->sk_rmem_alloc);
459}
460
447/* Tests if the list has one and only one entry. */ 461/* Tests if the list has one and only one entry. */
448static inline int sctp_list_single_entry(struct list_head *head) 462static inline int sctp_list_single_entry(struct list_head *head)
449{ 463{
diff --git a/include/net/sctp/ulpevent.h b/include/net/sctp/ulpevent.h
index 6c40cfc4832d..1a4ddc1ec7d2 100644
--- a/include/net/sctp/ulpevent.h
+++ b/include/net/sctp/ulpevent.h
@@ -63,6 +63,7 @@ struct sctp_ulpevent {
63 __u32 cumtsn; 63 __u32 cumtsn;
64 int msg_flags; 64 int msg_flags;
65 int iif; 65 int iif;
66 unsigned int rmem_len;
66}; 67};
67 68
68/* Retrieve the skb this event sits inside of. */ 69/* Retrieve the skb this event sits inside of. */
diff --git a/include/net/sock.h b/include/net/sock.h
index 40bb90ebb2d1..ac286a353032 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -884,8 +884,7 @@ static inline int sk_filter(struct sock *sk, struct sk_buff *skb)
884 884
885/** 885/**
886 * sk_filter_release: Release a socket filter 886 * sk_filter_release: Release a socket filter
887 * @sk: socket 887 * @rcu: rcu_head that contains the sk_filter info to remove
888 * @fp: filter to remove
889 * 888 *
890 * Remove a filter from a socket and release its resources. 889 * Remove a filter from a socket and release its resources.
891 */ 890 */
diff --git a/include/net/timewait_sock.h b/include/net/timewait_sock.h
index 2544281e1d5e..be293d795e38 100644
--- a/include/net/timewait_sock.h
+++ b/include/net/timewait_sock.h
@@ -19,6 +19,7 @@ struct timewait_sock_ops {
19 unsigned int twsk_obj_size; 19 unsigned int twsk_obj_size;
20 int (*twsk_unique)(struct sock *sk, 20 int (*twsk_unique)(struct sock *sk,
21 struct sock *sktw, void *twp); 21 struct sock *sktw, void *twp);
22 void (*twsk_destructor)(struct sock *sk);
22}; 23};
23 24
24static inline int twsk_unique(struct sock *sk, struct sock *sktw, void *twp) 25static inline int twsk_unique(struct sock *sk, struct sock *sktw, void *twp)
@@ -28,4 +29,10 @@ static inline int twsk_unique(struct sock *sk, struct sock *sktw, void *twp)
28 return 0; 29 return 0;
29} 30}
30 31
32static inline void twsk_destructor(struct sock *sk)
33{
34 if (sk->sk_prot->twsk_prot->twsk_destructor != NULL)
35 sk->sk_prot->twsk_prot->twsk_destructor(sk);
36}
37
31#endif /* _TIMEWAIT_SOCK_H */ 38#endif /* _TIMEWAIT_SOCK_H */
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 1e2a4ddec96e..737fdb2ee8a4 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -995,7 +995,8 @@ struct xfrm_state * xfrm_find_acq(u8 mode, u32 reqid, u8 proto,
995 int create, unsigned short family); 995 int create, unsigned short family);
996extern void xfrm_policy_flush(u8 type); 996extern void xfrm_policy_flush(u8 type);
997extern int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol); 997extern int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol);
998extern int xfrm_bundle_ok(struct xfrm_dst *xdst, struct flowi *fl, int family, int strict); 998extern int xfrm_bundle_ok(struct xfrm_policy *pol, struct xfrm_dst *xdst,
999 struct flowi *fl, int family, int strict);
999extern void xfrm_init_pmtu(struct dst_entry *dst); 1000extern void xfrm_init_pmtu(struct dst_entry *dst);
1000 1001
1001extern wait_queue_head_t km_waitq; 1002extern wait_queue_head_t km_waitq;
diff --git a/include/rdma/ib_addr.h b/include/rdma/ib_addr.h
index 81b62307621d..c094e5012862 100644
--- a/include/rdma/ib_addr.h
+++ b/include/rdma/ib_addr.h
@@ -36,6 +36,22 @@
36#include <linux/socket.h> 36#include <linux/socket.h>
37#include <rdma/ib_verbs.h> 37#include <rdma/ib_verbs.h>
38 38
39struct rdma_addr_client {
40 atomic_t refcount;
41 struct completion comp;
42};
43
44/**
45 * rdma_addr_register_client - Register an address client.
46 */
47void rdma_addr_register_client(struct rdma_addr_client *client);
48
49/**
50 * rdma_addr_unregister_client - Deregister an address client.
51 * @client: Client object to deregister.
52 */
53void rdma_addr_unregister_client(struct rdma_addr_client *client);
54
39struct rdma_dev_addr { 55struct rdma_dev_addr {
40 unsigned char src_dev_addr[MAX_ADDR_LEN]; 56 unsigned char src_dev_addr[MAX_ADDR_LEN];
41 unsigned char dst_dev_addr[MAX_ADDR_LEN]; 57 unsigned char dst_dev_addr[MAX_ADDR_LEN];
@@ -52,6 +68,7 @@ int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr);
52/** 68/**
53 * rdma_resolve_ip - Resolve source and destination IP addresses to 69 * rdma_resolve_ip - Resolve source and destination IP addresses to
54 * RDMA hardware addresses. 70 * RDMA hardware addresses.
71 * @client: Address client associated with request.
55 * @src_addr: An optional source address to use in the resolution. If a 72 * @src_addr: An optional source address to use in the resolution. If a
56 * source address is not provided, a usable address will be returned via 73 * source address is not provided, a usable address will be returned via
57 * the callback. 74 * the callback.
@@ -64,7 +81,8 @@ int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr);
64 * or been canceled. A status of 0 indicates success. 81 * or been canceled. A status of 0 indicates success.
65 * @context: User-specified context associated with the call. 82 * @context: User-specified context associated with the call.
66 */ 83 */
67int rdma_resolve_ip(struct sockaddr *src_addr, struct sockaddr *dst_addr, 84int rdma_resolve_ip(struct rdma_addr_client *client,
85 struct sockaddr *src_addr, struct sockaddr *dst_addr,
68 struct rdma_dev_addr *addr, int timeout_ms, 86 struct rdma_dev_addr *addr, int timeout_ms,
69 void (*callback)(int status, struct sockaddr *src_addr, 87 void (*callback)(int status, struct sockaddr *src_addr,
70 struct rdma_dev_addr *addr, void *context), 88 struct rdma_dev_addr *addr, void *context),
diff --git a/include/rdma/ib_user_verbs.h b/include/rdma/ib_user_verbs.h
index db1b814b62cc..64a721fcbc1c 100644
--- a/include/rdma/ib_user_verbs.h
+++ b/include/rdma/ib_user_verbs.h
@@ -458,7 +458,7 @@ struct ib_uverbs_query_qp_resp {
458 __u8 cur_qp_state; 458 __u8 cur_qp_state;
459 __u8 path_mtu; 459 __u8 path_mtu;
460 __u8 path_mig_state; 460 __u8 path_mig_state;
461 __u8 en_sqd_async_notify; 461 __u8 sq_draining;
462 __u8 max_rd_atomic; 462 __u8 max_rd_atomic;
463 __u8 max_dest_rd_atomic; 463 __u8 max_dest_rd_atomic;
464 __u8 min_rnr_timer; 464 __u8 min_rnr_timer;
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index 401192e56e50..61eebec00a7b 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -136,7 +136,6 @@ struct iscsi_conn {
136 136
137 /* control data */ 137 /* control data */
138 int id; /* CID */ 138 int id; /* CID */
139 struct list_head item; /* maintains list of conns */
140 int c_stage; /* connection state */ 139 int c_stage; /* connection state */
141 /* 140 /*
142 * Preallocated buffer for pdus that have data but do not 141 * Preallocated buffer for pdus that have data but do not
@@ -235,10 +234,8 @@ struct iscsi_session {
235 * - mgmtpool, * 234 * - mgmtpool, *
236 * - r2tpool */ 235 * - r2tpool */
237 int state; /* session state */ 236 int state; /* session state */
238 struct list_head item;
239 int age; /* counts session re-opens */ 237 int age; /* counts session re-opens */
240 238
241 struct list_head connections; /* list of connections */
242 int cmds_max; /* size of cmds array */ 239 int cmds_max; /* size of cmds array */
243 struct iscsi_cmd_task **cmds; /* Original Cmds arr */ 240 struct iscsi_cmd_task **cmds; /* Original Cmds arr */
244 struct iscsi_queue cmdpool; /* PDU's pool */ 241 struct iscsi_queue cmdpool; /* PDU's pool */
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index 84a6d5fe0920..5c0e9791441c 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -97,6 +97,7 @@ extern const unsigned char scsi_command_size[8];
97#define PERSISTENT_RESERVE_IN 0x5e 97#define PERSISTENT_RESERVE_IN 0x5e
98#define PERSISTENT_RESERVE_OUT 0x5f 98#define PERSISTENT_RESERVE_OUT 0x5f
99#define REPORT_LUNS 0xa0 99#define REPORT_LUNS 0xa0
100#define MAINTENANCE_IN 0xa3
100#define MOVE_MEDIUM 0xa5 101#define MOVE_MEDIUM 0xa5
101#define EXCHANGE_MEDIUM 0xa6 102#define EXCHANGE_MEDIUM 0xa6
102#define READ_12 0xa8 103#define READ_12 0xa8
@@ -114,6 +115,8 @@ extern const unsigned char scsi_command_size[8];
114#define SERVICE_ACTION_IN 0x9e 115#define SERVICE_ACTION_IN 0x9e
115/* values for service action in */ 116/* values for service action in */
116#define SAI_READ_CAPACITY_16 0x10 117#define SAI_READ_CAPACITY_16 0x10
118/* values for maintenance in */
119#define MI_REPORT_TARGET_PGS 0x0a
117 120
118/* Values for T10/04-262r7 */ 121/* Values for T10/04-262r7 */
119#define ATA_16 0x85 /* 16-byte pass-thru */ 122#define ATA_16 0x85 /* 16-byte pass-thru */
@@ -430,7 +433,7 @@ struct scsi_lun {
430#define SCSI_IOCTL_GET_PCI 0x5387 433#define SCSI_IOCTL_GET_PCI 0x5387
431 434
432/* Pull a u32 out of a SCSI message (using BE SCSI conventions) */ 435/* Pull a u32 out of a SCSI message (using BE SCSI conventions) */
433static inline u32 scsi_to_u32(u8 *ptr) 436static inline __u32 scsi_to_u32(__u8 *ptr)
434{ 437{
435 return (ptr[0]<<24) + (ptr[1]<<16) + (ptr[2]<<8) + ptr[3]; 438 return (ptr[0]<<24) + (ptr[1]<<16) + (ptr[2]<<8) + ptr[3];
436} 439}
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index 39e833260bd0..4b95c89c95c9 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -29,7 +29,6 @@
29struct scsi_transport_template; 29struct scsi_transport_template;
30struct iscsi_transport; 30struct iscsi_transport;
31struct Scsi_Host; 31struct Scsi_Host;
32struct mempool_zone;
33struct iscsi_cls_conn; 32struct iscsi_cls_conn;
34struct iscsi_conn; 33struct iscsi_conn;
35struct iscsi_cmd_task; 34struct iscsi_cmd_task;
@@ -157,9 +156,6 @@ struct iscsi_cls_conn {
157 156
158 int active; /* must be accessed with the connlock */ 157 int active; /* must be accessed with the connlock */
159 struct device dev; /* sysfs transport/container device */ 158 struct device dev; /* sysfs transport/container device */
160 struct mempool_zone *z_error;
161 struct mempool_zone *z_pdu;
162 struct list_head freequeue;
163}; 159};
164 160
165#define iscsi_dev_to_conn(_dev) \ 161#define iscsi_dev_to_conn(_dev) \
diff --git a/include/sound/version.h b/include/sound/version.h
index 4ad86eb6440b..52fd6879b86e 100644
--- a/include/sound/version.h
+++ b/include/sound/version.h
@@ -1,3 +1,3 @@
1/* include/version.h. Generated by alsa/ksync script. */ 1/* include/version.h. Generated by alsa/ksync script. */
2#define CONFIG_SND_VERSION "1.0.13" 2#define CONFIG_SND_VERSION "1.0.13"
3#define CONFIG_SND_DATE " (Fri Oct 06 18:28:19 2006 UTC)" 3#define CONFIG_SND_DATE " (Sun Oct 22 08:56:16 2006 UTC)"
diff --git a/init/Kconfig b/init/Kconfig
index 10382931eead..176f7e5136c7 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1,5 +1,6 @@
1config DEFCONFIG_LIST 1config DEFCONFIG_LIST
2 string 2 string
3 depends on !UML
3 option defconfig_list 4 option defconfig_list
4 default "/lib/modules/$UNAME_RELEASE/.config" 5 default "/lib/modules/$UNAME_RELEASE/.config"
5 default "/etc/kernel-config" 6 default "/etc/kernel-config"
@@ -303,20 +304,19 @@ config UID16
303 304
304config SYSCTL_SYSCALL 305config SYSCTL_SYSCALL
305 bool "Sysctl syscall support" if EMBEDDED 306 bool "Sysctl syscall support" if EMBEDDED
306 default n 307 default y
307 select SYSCTL 308 select SYSCTL
308 ---help--- 309 ---help---
309 Enable the deprecated sysctl system call. sys_sysctl uses 310 sys_sysctl uses binary paths that have been found challenging
310 binary paths that have been found to be a major pain to maintain 311 to properly maintain and use. The interface in /proc/sys
311 and use. The interface in /proc/sys is now the primary and what 312 using paths with ascii names is now the primary path to this
312 everyone uses. 313 information.
313 314
314 Nothing has been using the binary sysctl interface for some 315 Almost nothing using the binary sysctl interface so if you are
315 time now so nothing should break if you disable sysctl syscall 316 trying to save some space it is probably safe to disable this,
316 support, and your kernel will get marginally smaller. 317 making your kernel marginally smaller.
317 318
318 Unless you have an application that uses the sys_sysctl interface 319 If unsure say Y here.
319 you should probably say N here.
320 320
321config KALLSYMS 321config KALLSYMS
322 bool "Load all symbols for debugging/kksymoops" if EMBEDDED 322 bool "Load all symbols for debugging/kksymoops" if EMBEDDED
diff --git a/init/main.c b/init/main.c
index ee123243fb53..36f608a7cfba 100644
--- a/init/main.c
+++ b/init/main.c
@@ -503,6 +503,7 @@ asmlinkage void __init start_kernel(void)
503 printk(KERN_NOTICE); 503 printk(KERN_NOTICE);
504 printk(linux_banner); 504 printk(linux_banner);
505 setup_arch(&command_line); 505 setup_arch(&command_line);
506 unwind_setup();
506 setup_per_cpu_areas(); 507 setup_per_cpu_areas();
507 smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */ 508 smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */
508 509
diff --git a/ipc/msg.c b/ipc/msg.c
index 5b213d952545..1266b1d0c8e3 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -52,7 +52,7 @@ struct msg_receiver {
52 long r_msgtype; 52 long r_msgtype;
53 long r_maxsize; 53 long r_maxsize;
54 54
55 volatile struct msg_msg *r_msg; 55 struct msg_msg *volatile r_msg;
56}; 56};
57 57
58/* one msg_sender for each sleeping sender */ 58/* one msg_sender for each sleeping sender */
@@ -124,6 +124,7 @@ void msg_exit_ns(struct ipc_namespace *ns)
124 } 124 }
125 mutex_unlock(&msg_ids(ns).mutex); 125 mutex_unlock(&msg_ids(ns).mutex);
126 126
127 ipc_fini_ids(ns->ids[IPC_MSG_IDS]);
127 kfree(ns->ids[IPC_MSG_IDS]); 128 kfree(ns->ids[IPC_MSG_IDS]);
128 ns->ids[IPC_MSG_IDS] = NULL; 129 ns->ids[IPC_MSG_IDS] = NULL;
129} 130}
diff --git a/ipc/sem.c b/ipc/sem.c
index 0dafcc455f92..21b3289d640c 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -161,6 +161,7 @@ void sem_exit_ns(struct ipc_namespace *ns)
161 } 161 }
162 mutex_unlock(&sem_ids(ns).mutex); 162 mutex_unlock(&sem_ids(ns).mutex);
163 163
164 ipc_fini_ids(ns->ids[IPC_SEM_IDS]);
164 kfree(ns->ids[IPC_SEM_IDS]); 165 kfree(ns->ids[IPC_SEM_IDS]);
165 ns->ids[IPC_SEM_IDS] = NULL; 166 ns->ids[IPC_SEM_IDS] = NULL;
166} 167}
diff --git a/ipc/shm.c b/ipc/shm.c
index bfbd317ec11c..d1198dd07a1a 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -116,6 +116,7 @@ void shm_exit_ns(struct ipc_namespace *ns)
116 } 116 }
117 mutex_unlock(&shm_ids(ns).mutex); 117 mutex_unlock(&shm_ids(ns).mutex);
118 118
119 ipc_fini_ids(ns->ids[IPC_SHM_IDS]);
119 kfree(ns->ids[IPC_SHM_IDS]); 120 kfree(ns->ids[IPC_SHM_IDS]);
120 ns->ids[IPC_SHM_IDS] = NULL; 121 ns->ids[IPC_SHM_IDS] = NULL;
121} 122}
diff --git a/ipc/util.c b/ipc/util.c
index 42479e4eec59..cd8bb14a431f 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -301,7 +301,7 @@ static int grow_ary(struct ipc_ids* ids, int newsize)
301 */ 301 */
302 rcu_assign_pointer(ids->entries, new); 302 rcu_assign_pointer(ids->entries, new);
303 303
304 ipc_rcu_putref(old); 304 __ipc_fini_ids(ids, old);
305 return newsize; 305 return newsize;
306} 306}
307 307
diff --git a/ipc/util.h b/ipc/util.h
index c8fd6b9d77b5..e3aa2c5c97dc 100644
--- a/ipc/util.h
+++ b/ipc/util.h
@@ -83,6 +83,18 @@ void* ipc_rcu_alloc(int size);
83void ipc_rcu_getref(void *ptr); 83void ipc_rcu_getref(void *ptr);
84void ipc_rcu_putref(void *ptr); 84void ipc_rcu_putref(void *ptr);
85 85
86static inline void __ipc_fini_ids(struct ipc_ids *ids,
87 struct ipc_id_ary *entries)
88{
89 if (entries != &ids->nullentry)
90 ipc_rcu_putref(entries);
91}
92
93static inline void ipc_fini_ids(struct ipc_ids *ids)
94{
95 __ipc_fini_ids(ids, ids->entries);
96}
97
86struct kern_ipc_perm* ipc_get(struct ipc_ids* ids, int id); 98struct kern_ipc_perm* ipc_get(struct ipc_ids* ids, int id);
87struct kern_ipc_perm* ipc_lock(struct ipc_ids* ids, int id); 99struct kern_ipc_perm* ipc_lock(struct ipc_ids* ids, int id);
88void ipc_lock_by_ptr(struct kern_ipc_perm *ipcp); 100void ipc_lock_by_ptr(struct kern_ipc_perm *ipcp);
diff --git a/kernel/compat.c b/kernel/compat.c
index 75573e5d27b0..6952dd057300 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -678,7 +678,7 @@ int get_compat_sigevent(struct sigevent *event,
678 ? -EFAULT : 0; 678 ? -EFAULT : 0;
679} 679}
680 680
681long compat_get_bitmap(unsigned long *mask, compat_ulong_t __user *umask, 681long compat_get_bitmap(unsigned long *mask, const compat_ulong_t __user *umask,
682 unsigned long bitmap_size) 682 unsigned long bitmap_size)
683{ 683{
684 int i, j; 684 int i, j;
@@ -982,4 +982,37 @@ asmlinkage long compat_sys_move_pages(pid_t pid, unsigned long nr_pages,
982 } 982 }
983 return sys_move_pages(pid, nr_pages, pages, nodes, status, flags); 983 return sys_move_pages(pid, nr_pages, pages, nodes, status, flags);
984} 984}
985
986asmlinkage long compat_sys_migrate_pages(compat_pid_t pid,
987 compat_ulong_t maxnode,
988 const compat_ulong_t __user *old_nodes,
989 const compat_ulong_t __user *new_nodes)
990{
991 unsigned long __user *old = NULL;
992 unsigned long __user *new = NULL;
993 nodemask_t tmp_mask;
994 unsigned long nr_bits;
995 unsigned long size;
996
997 nr_bits = min_t(unsigned long, maxnode - 1, MAX_NUMNODES);
998 size = ALIGN(nr_bits, BITS_PER_LONG) / 8;
999 if (old_nodes) {
1000 if (compat_get_bitmap(nodes_addr(tmp_mask), old_nodes, nr_bits))
1001 return -EFAULT;
1002 old = compat_alloc_user_space(new_nodes ? size * 2 : size);
1003 if (new_nodes)
1004 new = old + size / sizeof(unsigned long);
1005 if (copy_to_user(old, nodes_addr(tmp_mask), size))
1006 return -EFAULT;
1007 }
1008 if (new_nodes) {
1009 if (compat_get_bitmap(nodes_addr(tmp_mask), new_nodes, nr_bits))
1010 return -EFAULT;
1011 if (new == NULL)
1012 new = compat_alloc_user_space(size);
1013 if (copy_to_user(new, nodes_addr(tmp_mask), size))
1014 return -EFAULT;
1015 }
1016 return sys_migrate_pages(pid, nr_bits + 1, old, new);
1017}
985#endif 1018#endif
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 32c96628463e..272254f20d97 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -19,7 +19,7 @@
19static DEFINE_MUTEX(cpu_add_remove_lock); 19static DEFINE_MUTEX(cpu_add_remove_lock);
20static DEFINE_MUTEX(cpu_bitmask_lock); 20static DEFINE_MUTEX(cpu_bitmask_lock);
21 21
22static __cpuinitdata BLOCKING_NOTIFIER_HEAD(cpu_chain); 22static __cpuinitdata RAW_NOTIFIER_HEAD(cpu_chain);
23 23
24/* If set, cpu_up and cpu_down will return -EBUSY and do nothing. 24/* If set, cpu_up and cpu_down will return -EBUSY and do nothing.
25 * Should always be manipulated under cpu_add_remove_lock 25 * Should always be manipulated under cpu_add_remove_lock
@@ -58,8 +58,8 @@ void unlock_cpu_hotplug(void)
58 recursive_depth--; 58 recursive_depth--;
59 return; 59 return;
60 } 60 }
61 mutex_unlock(&cpu_bitmask_lock);
62 recursive = NULL; 61 recursive = NULL;
62 mutex_unlock(&cpu_bitmask_lock);
63} 63}
64EXPORT_SYMBOL_GPL(unlock_cpu_hotplug); 64EXPORT_SYMBOL_GPL(unlock_cpu_hotplug);
65 65
@@ -68,7 +68,11 @@ EXPORT_SYMBOL_GPL(unlock_cpu_hotplug);
68/* Need to know about CPUs going up/down? */ 68/* Need to know about CPUs going up/down? */
69int __cpuinit register_cpu_notifier(struct notifier_block *nb) 69int __cpuinit register_cpu_notifier(struct notifier_block *nb)
70{ 70{
71 return blocking_notifier_chain_register(&cpu_chain, nb); 71 int ret;
72 mutex_lock(&cpu_add_remove_lock);
73 ret = raw_notifier_chain_register(&cpu_chain, nb);
74 mutex_unlock(&cpu_add_remove_lock);
75 return ret;
72} 76}
73 77
74#ifdef CONFIG_HOTPLUG_CPU 78#ifdef CONFIG_HOTPLUG_CPU
@@ -77,7 +81,9 @@ EXPORT_SYMBOL(register_cpu_notifier);
77 81
78void unregister_cpu_notifier(struct notifier_block *nb) 82void unregister_cpu_notifier(struct notifier_block *nb)
79{ 83{
80 blocking_notifier_chain_unregister(&cpu_chain, nb); 84 mutex_lock(&cpu_add_remove_lock);
85 raw_notifier_chain_unregister(&cpu_chain, nb);
86 mutex_unlock(&cpu_add_remove_lock);
81} 87}
82EXPORT_SYMBOL(unregister_cpu_notifier); 88EXPORT_SYMBOL(unregister_cpu_notifier);
83 89
@@ -126,7 +132,7 @@ static int _cpu_down(unsigned int cpu)
126 if (!cpu_online(cpu)) 132 if (!cpu_online(cpu))
127 return -EINVAL; 133 return -EINVAL;
128 134
129 err = blocking_notifier_call_chain(&cpu_chain, CPU_DOWN_PREPARE, 135 err = raw_notifier_call_chain(&cpu_chain, CPU_DOWN_PREPARE,
130 (void *)(long)cpu); 136 (void *)(long)cpu);
131 if (err == NOTIFY_BAD) { 137 if (err == NOTIFY_BAD) {
132 printk("%s: attempt to take down CPU %u failed\n", 138 printk("%s: attempt to take down CPU %u failed\n",
@@ -144,18 +150,18 @@ static int _cpu_down(unsigned int cpu)
144 p = __stop_machine_run(take_cpu_down, NULL, cpu); 150 p = __stop_machine_run(take_cpu_down, NULL, cpu);
145 mutex_unlock(&cpu_bitmask_lock); 151 mutex_unlock(&cpu_bitmask_lock);
146 152
147 if (IS_ERR(p)) { 153 if (IS_ERR(p) || cpu_online(cpu)) {
148 /* CPU didn't die: tell everyone. Can't complain. */ 154 /* CPU didn't die: tell everyone. Can't complain. */
149 if (blocking_notifier_call_chain(&cpu_chain, CPU_DOWN_FAILED, 155 if (raw_notifier_call_chain(&cpu_chain, CPU_DOWN_FAILED,
150 (void *)(long)cpu) == NOTIFY_BAD) 156 (void *)(long)cpu) == NOTIFY_BAD)
151 BUG(); 157 BUG();
152 158
153 err = PTR_ERR(p); 159 if (IS_ERR(p)) {
154 goto out_allowed; 160 err = PTR_ERR(p);
155 } 161 goto out_allowed;
156 162 }
157 if (cpu_online(cpu))
158 goto out_thread; 163 goto out_thread;
164 }
159 165
160 /* Wait for it to sleep (leaving idle task). */ 166 /* Wait for it to sleep (leaving idle task). */
161 while (!idle_cpu(cpu)) 167 while (!idle_cpu(cpu))
@@ -169,7 +175,7 @@ static int _cpu_down(unsigned int cpu)
169 put_cpu(); 175 put_cpu();
170 176
171 /* CPU is completely dead: tell everyone. Too late to complain. */ 177 /* CPU is completely dead: tell everyone. Too late to complain. */
172 if (blocking_notifier_call_chain(&cpu_chain, CPU_DEAD, 178 if (raw_notifier_call_chain(&cpu_chain, CPU_DEAD,
173 (void *)(long)cpu) == NOTIFY_BAD) 179 (void *)(long)cpu) == NOTIFY_BAD)
174 BUG(); 180 BUG();
175 181
@@ -206,7 +212,7 @@ static int __devinit _cpu_up(unsigned int cpu)
206 if (cpu_online(cpu) || !cpu_present(cpu)) 212 if (cpu_online(cpu) || !cpu_present(cpu))
207 return -EINVAL; 213 return -EINVAL;
208 214
209 ret = blocking_notifier_call_chain(&cpu_chain, CPU_UP_PREPARE, hcpu); 215 ret = raw_notifier_call_chain(&cpu_chain, CPU_UP_PREPARE, hcpu);
210 if (ret == NOTIFY_BAD) { 216 if (ret == NOTIFY_BAD) {
211 printk("%s: attempt to bring up CPU %u failed\n", 217 printk("%s: attempt to bring up CPU %u failed\n",
212 __FUNCTION__, cpu); 218 __FUNCTION__, cpu);
@@ -223,11 +229,11 @@ static int __devinit _cpu_up(unsigned int cpu)
223 BUG_ON(!cpu_online(cpu)); 229 BUG_ON(!cpu_online(cpu));
224 230
225 /* Now call notifier in preparation. */ 231 /* Now call notifier in preparation. */
226 blocking_notifier_call_chain(&cpu_chain, CPU_ONLINE, hcpu); 232 raw_notifier_call_chain(&cpu_chain, CPU_ONLINE, hcpu);
227 233
228out_notify: 234out_notify:
229 if (ret != 0) 235 if (ret != 0)
230 blocking_notifier_call_chain(&cpu_chain, 236 raw_notifier_call_chain(&cpu_chain,
231 CPU_UP_CANCELED, hcpu); 237 CPU_UP_CANCELED, hcpu);
232 238
233 return ret; 239 return ret;
diff --git a/kernel/delayacct.c b/kernel/delayacct.c
index 36752f124c6a..66a0ea48751d 100644
--- a/kernel/delayacct.c
+++ b/kernel/delayacct.c
@@ -66,6 +66,7 @@ static void delayacct_end(struct timespec *start, struct timespec *end,
66{ 66{
67 struct timespec ts; 67 struct timespec ts;
68 s64 ns; 68 s64 ns;
69 unsigned long flags;
69 70
70 do_posix_clock_monotonic_gettime(end); 71 do_posix_clock_monotonic_gettime(end);
71 ts = timespec_sub(*end, *start); 72 ts = timespec_sub(*end, *start);
@@ -73,10 +74,10 @@ static void delayacct_end(struct timespec *start, struct timespec *end,
73 if (ns < 0) 74 if (ns < 0)
74 return; 75 return;
75 76
76 spin_lock(&current->delays->lock); 77 spin_lock_irqsave(&current->delays->lock, flags);
77 *total += ns; 78 *total += ns;
78 (*count)++; 79 (*count)++;
79 spin_unlock(&current->delays->lock); 80 spin_unlock_irqrestore(&current->delays->lock, flags);
80} 81}
81 82
82void __delayacct_blkio_start(void) 83void __delayacct_blkio_start(void)
@@ -104,6 +105,7 @@ int __delayacct_add_tsk(struct taskstats *d, struct task_struct *tsk)
104 s64 tmp; 105 s64 tmp;
105 struct timespec ts; 106 struct timespec ts;
106 unsigned long t1,t2,t3; 107 unsigned long t1,t2,t3;
108 unsigned long flags;
107 109
108 /* Though tsk->delays accessed later, early exit avoids 110 /* Though tsk->delays accessed later, early exit avoids
109 * unnecessary returning of other data 111 * unnecessary returning of other data
@@ -136,14 +138,14 @@ int __delayacct_add_tsk(struct taskstats *d, struct task_struct *tsk)
136 138
137 /* zero XXX_total, non-zero XXX_count implies XXX stat overflowed */ 139 /* zero XXX_total, non-zero XXX_count implies XXX stat overflowed */
138 140
139 spin_lock(&tsk->delays->lock); 141 spin_lock_irqsave(&tsk->delays->lock, flags);
140 tmp = d->blkio_delay_total + tsk->delays->blkio_delay; 142 tmp = d->blkio_delay_total + tsk->delays->blkio_delay;
141 d->blkio_delay_total = (tmp < d->blkio_delay_total) ? 0 : tmp; 143 d->blkio_delay_total = (tmp < d->blkio_delay_total) ? 0 : tmp;
142 tmp = d->swapin_delay_total + tsk->delays->swapin_delay; 144 tmp = d->swapin_delay_total + tsk->delays->swapin_delay;
143 d->swapin_delay_total = (tmp < d->swapin_delay_total) ? 0 : tmp; 145 d->swapin_delay_total = (tmp < d->swapin_delay_total) ? 0 : tmp;
144 d->blkio_count += tsk->delays->blkio_count; 146 d->blkio_count += tsk->delays->blkio_count;
145 d->swapin_count += tsk->delays->swapin_count; 147 d->swapin_count += tsk->delays->swapin_count;
146 spin_unlock(&tsk->delays->lock); 148 spin_unlock_irqrestore(&tsk->delays->lock, flags);
147 149
148done: 150done:
149 return 0; 151 return 0;
@@ -152,11 +154,12 @@ done:
152__u64 __delayacct_blkio_ticks(struct task_struct *tsk) 154__u64 __delayacct_blkio_ticks(struct task_struct *tsk)
153{ 155{
154 __u64 ret; 156 __u64 ret;
157 unsigned long flags;
155 158
156 spin_lock(&tsk->delays->lock); 159 spin_lock_irqsave(&tsk->delays->lock, flags);
157 ret = nsec_to_clock_t(tsk->delays->blkio_delay + 160 ret = nsec_to_clock_t(tsk->delays->blkio_delay +
158 tsk->delays->swapin_delay); 161 tsk->delays->swapin_delay);
159 spin_unlock(&tsk->delays->lock); 162 spin_unlock_irqrestore(&tsk->delays->lock, flags);
160 return ret; 163 return ret;
161} 164}
162 165
diff --git a/kernel/exit.c b/kernel/exit.c
index f250a5e3e281..06de6c4e8ca3 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -128,6 +128,7 @@ static void __exit_signal(struct task_struct *tsk)
128 flush_sigqueue(&tsk->pending); 128 flush_sigqueue(&tsk->pending);
129 if (sig) { 129 if (sig) {
130 flush_sigqueue(&sig->shared_pending); 130 flush_sigqueue(&sig->shared_pending);
131 taskstats_tgid_free(sig);
131 __cleanup_signal(sig); 132 __cleanup_signal(sig);
132 } 133 }
133} 134}
diff --git a/kernel/fork.c b/kernel/fork.c
index 7dc6140baac6..3da978eec791 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -830,7 +830,7 @@ static inline int copy_signal(unsigned long clone_flags, struct task_struct * ts
830 if (clone_flags & CLONE_THREAD) { 830 if (clone_flags & CLONE_THREAD) {
831 atomic_inc(&current->signal->count); 831 atomic_inc(&current->signal->count);
832 atomic_inc(&current->signal->live); 832 atomic_inc(&current->signal->live);
833 taskstats_tgid_alloc(current->signal); 833 taskstats_tgid_alloc(current);
834 return 0; 834 return 0;
835 } 835 }
836 sig = kmem_cache_alloc(signal_cachep, GFP_KERNEL); 836 sig = kmem_cache_alloc(signal_cachep, GFP_KERNEL);
@@ -897,7 +897,6 @@ static inline int copy_signal(unsigned long clone_flags, struct task_struct * ts
897void __cleanup_signal(struct signal_struct *sig) 897void __cleanup_signal(struct signal_struct *sig)
898{ 898{
899 exit_thread_group_keys(sig); 899 exit_thread_group_keys(sig);
900 taskstats_tgid_free(sig);
901 kmem_cache_free(signal_cachep, sig); 900 kmem_cache_free(signal_cachep, sig);
902} 901}
903 902
@@ -984,6 +983,8 @@ static struct task_struct *copy_process(unsigned long clone_flags,
984 if (!p) 983 if (!p)
985 goto fork_out; 984 goto fork_out;
986 985
986 rt_mutex_init_task(p);
987
987#ifdef CONFIG_TRACE_IRQFLAGS 988#ifdef CONFIG_TRACE_IRQFLAGS
988 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled); 989 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
989 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled); 990 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
@@ -1088,8 +1089,6 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1088 p->lockdep_recursion = 0; 1089 p->lockdep_recursion = 0;
1089#endif 1090#endif
1090 1091
1091 rt_mutex_init_task(p);
1092
1093#ifdef CONFIG_DEBUG_MUTEXES 1092#ifdef CONFIG_DEBUG_MUTEXES
1094 p->blocked_on = NULL; /* not blocked yet */ 1093 p->blocked_on = NULL; /* not blocked yet */
1095#endif 1094#endif
diff --git a/kernel/futex.c b/kernel/futex.c
index b364e0026191..93ef30ba209f 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -1507,6 +1507,13 @@ static int futex_fd(u32 __user *uaddr, int signal)
1507 struct futex_q *q; 1507 struct futex_q *q;
1508 struct file *filp; 1508 struct file *filp;
1509 int ret, err; 1509 int ret, err;
1510 static unsigned long printk_interval;
1511
1512 if (printk_timed_ratelimit(&printk_interval, 60 * 60 * 1000)) {
1513 printk(KERN_WARNING "Process `%s' used FUTEX_FD, which "
1514 "will be removed from the kernel in June 2007\n",
1515 current->comm);
1516 }
1510 1517
1511 ret = -EINVAL; 1518 ret = -EINVAL;
1512 if (!valid_signal(signal)) 1519 if (!valid_signal(signal))
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index 11c99697acfe..ebfd24a41858 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -233,6 +233,8 @@ void irq_chip_set_defaults(struct irq_chip *chip)
233 chip->shutdown = chip->disable; 233 chip->shutdown = chip->disable;
234 if (!chip->name) 234 if (!chip->name)
235 chip->name = chip->typename; 235 chip->name = chip->typename;
236 if (!chip->end)
237 chip->end = dummy_irq_chip.end;
236} 238}
237 239
238static inline void mask_ack_irq(struct irq_desc *desc, int irq) 240static inline void mask_ack_irq(struct irq_desc *desc, int irq)
@@ -499,7 +501,8 @@ handle_percpu_irq(unsigned int irq, struct irq_desc *desc)
499#endif /* CONFIG_SMP */ 501#endif /* CONFIG_SMP */
500 502
501void 503void
502__set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained) 504__set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
505 const char *name)
503{ 506{
504 struct irq_desc *desc; 507 struct irq_desc *desc;
505 unsigned long flags; 508 unsigned long flags;
@@ -540,6 +543,7 @@ __set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained)
540 desc->depth = 1; 543 desc->depth = 1;
541 } 544 }
542 desc->handle_irq = handle; 545 desc->handle_irq = handle;
546 desc->name = name;
543 547
544 if (handle != handle_bad_irq && is_chained) { 548 if (handle != handle_bad_irq && is_chained) {
545 desc->status &= ~IRQ_DISABLED; 549 desc->status &= ~IRQ_DISABLED;
@@ -555,30 +559,13 @@ set_irq_chip_and_handler(unsigned int irq, struct irq_chip *chip,
555 irq_flow_handler_t handle) 559 irq_flow_handler_t handle)
556{ 560{
557 set_irq_chip(irq, chip); 561 set_irq_chip(irq, chip);
558 __set_irq_handler(irq, handle, 0); 562 __set_irq_handler(irq, handle, 0, NULL);
559} 563}
560 564
561/* 565void
562 * Get a descriptive string for the highlevel handler, for 566set_irq_chip_and_handler_name(unsigned int irq, struct irq_chip *chip,
563 * /proc/interrupts output: 567 irq_flow_handler_t handle, const char *name)
564 */
565const char *
566handle_irq_name(irq_flow_handler_t handle)
567{ 568{
568 if (handle == handle_level_irq) 569 set_irq_chip(irq, chip);
569 return "level "; 570 __set_irq_handler(irq, handle, 0, name);
570 if (handle == handle_fasteoi_irq)
571 return "fasteoi";
572 if (handle == handle_edge_irq)
573 return "edge ";
574 if (handle == handle_simple_irq)
575 return "simple ";
576#ifdef CONFIG_SMP
577 if (handle == handle_percpu_irq)
578 return "percpu ";
579#endif
580 if (handle == handle_bad_irq)
581 return "bad ";
582
583 return NULL;
584} 571}
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 6879202afe9a..b385878c6e80 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -216,6 +216,7 @@ int setup_irq(unsigned int irq, struct irqaction *new)
216{ 216{
217 struct irq_desc *desc = irq_desc + irq; 217 struct irq_desc *desc = irq_desc + irq;
218 struct irqaction *old, **p; 218 struct irqaction *old, **p;
219 const char *old_name = NULL;
219 unsigned long flags; 220 unsigned long flags;
220 int shared = 0; 221 int shared = 0;
221 222
@@ -255,8 +256,10 @@ int setup_irq(unsigned int irq, struct irqaction *new)
255 * set the trigger type must match. 256 * set the trigger type must match.
256 */ 257 */
257 if (!((old->flags & new->flags) & IRQF_SHARED) || 258 if (!((old->flags & new->flags) & IRQF_SHARED) ||
258 ((old->flags ^ new->flags) & IRQF_TRIGGER_MASK)) 259 ((old->flags ^ new->flags) & IRQF_TRIGGER_MASK)) {
260 old_name = old->name;
259 goto mismatch; 261 goto mismatch;
262 }
260 263
261#if defined(CONFIG_IRQ_PER_CPU) 264#if defined(CONFIG_IRQ_PER_CPU)
262 /* All handlers must agree on per-cpuness */ 265 /* All handlers must agree on per-cpuness */
@@ -322,11 +325,13 @@ int setup_irq(unsigned int irq, struct irqaction *new)
322 return 0; 325 return 0;
323 326
324mismatch: 327mismatch:
325 spin_unlock_irqrestore(&desc->lock, flags);
326 if (!(new->flags & IRQF_PROBE_SHARED)) { 328 if (!(new->flags & IRQF_PROBE_SHARED)) {
327 printk(KERN_ERR "IRQ handler type mismatch for IRQ %d\n", irq); 329 printk(KERN_ERR "IRQ handler type mismatch for IRQ %d\n", irq);
330 if (old_name)
331 printk(KERN_ERR "current handler: %s\n", old_name);
328 dump_stack(); 332 dump_stack();
329 } 333 }
334 spin_unlock_irqrestore(&desc->lock, flags);
330 return -EBUSY; 335 return -EBUSY;
331} 336}
332 337
diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
index 607c7809ad01..9a352667007c 100644
--- a/kernel/irq/proc.c
+++ b/kernel/irq/proc.c
@@ -57,7 +57,7 @@ static int irq_affinity_write_proc(struct file *file, const char __user *buffer,
57 if (!irq_desc[irq].chip->set_affinity || no_irq_affinity) 57 if (!irq_desc[irq].chip->set_affinity || no_irq_affinity)
58 return -EIO; 58 return -EIO;
59 59
60 err = cpumask_parse(buffer, count, new_value); 60 err = cpumask_parse_user(buffer, count, new_value);
61 if (err) 61 if (err)
62 return err; 62 return err;
63 63
diff --git a/kernel/irq/spurious.c b/kernel/irq/spurious.c
index 543ea2e5ad93..9c7e2e4c1fe7 100644
--- a/kernel/irq/spurious.c
+++ b/kernel/irq/spurious.c
@@ -147,7 +147,11 @@ void note_interrupt(unsigned int irq, struct irq_desc *desc,
147 if (unlikely(irqfixup)) { 147 if (unlikely(irqfixup)) {
148 /* Don't punish working computers */ 148 /* Don't punish working computers */
149 if ((irqfixup == 2 && irq == 0) || action_ret == IRQ_NONE) { 149 if ((irqfixup == 2 && irq == 0) || action_ret == IRQ_NONE) {
150 int ok = misrouted_irq(irq); 150 int ok;
151
152 spin_unlock(&desc->lock);
153 ok = misrouted_irq(irq);
154 spin_lock(&desc->lock);
151 if (action_ret == IRQ_NONE) 155 if (action_ret == IRQ_NONE)
152 desc->irqs_unhandled -= ok; 156 desc->irqs_unhandled -= ok;
153 } 157 }
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 4c0553461000..c9fefdb1a7db 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -575,6 +575,8 @@ static noinline int print_circular_bug_tail(void)
575 return 0; 575 return 0;
576} 576}
577 577
578#define RECURSION_LIMIT 40
579
578static int noinline print_infinite_recursion_bug(void) 580static int noinline print_infinite_recursion_bug(void)
579{ 581{
580 __raw_spin_unlock(&hash_lock); 582 __raw_spin_unlock(&hash_lock);
@@ -595,7 +597,7 @@ check_noncircular(struct lock_class *source, unsigned int depth)
595 debug_atomic_inc(&nr_cyclic_check_recursions); 597 debug_atomic_inc(&nr_cyclic_check_recursions);
596 if (depth > max_recursion_depth) 598 if (depth > max_recursion_depth)
597 max_recursion_depth = depth; 599 max_recursion_depth = depth;
598 if (depth >= 20) 600 if (depth >= RECURSION_LIMIT)
599 return print_infinite_recursion_bug(); 601 return print_infinite_recursion_bug();
600 /* 602 /*
601 * Check this lock's dependency list: 603 * Check this lock's dependency list:
@@ -645,7 +647,7 @@ find_usage_forwards(struct lock_class *source, unsigned int depth)
645 647
646 if (depth > max_recursion_depth) 648 if (depth > max_recursion_depth)
647 max_recursion_depth = depth; 649 max_recursion_depth = depth;
648 if (depth >= 20) 650 if (depth >= RECURSION_LIMIT)
649 return print_infinite_recursion_bug(); 651 return print_infinite_recursion_bug();
650 652
651 debug_atomic_inc(&nr_find_usage_forwards_checks); 653 debug_atomic_inc(&nr_find_usage_forwards_checks);
@@ -684,7 +686,7 @@ find_usage_backwards(struct lock_class *source, unsigned int depth)
684 686
685 if (depth > max_recursion_depth) 687 if (depth > max_recursion_depth)
686 max_recursion_depth = depth; 688 max_recursion_depth = depth;
687 if (depth >= 20) 689 if (depth >= RECURSION_LIMIT)
688 return print_infinite_recursion_bug(); 690 return print_infinite_recursion_bug();
689 691
690 debug_atomic_inc(&nr_find_usage_backwards_checks); 692 debug_atomic_inc(&nr_find_usage_backwards_checks);
@@ -1079,7 +1081,8 @@ static int static_obj(void *obj)
1079 */ 1081 */
1080 for_each_possible_cpu(i) { 1082 for_each_possible_cpu(i) {
1081 start = (unsigned long) &__per_cpu_start + per_cpu_offset(i); 1083 start = (unsigned long) &__per_cpu_start + per_cpu_offset(i);
1082 end = (unsigned long) &__per_cpu_end + per_cpu_offset(i); 1084 end = (unsigned long) &__per_cpu_start + PERCPU_ENOUGH_ROOM
1085 + per_cpu_offset(i);
1083 1086
1084 if ((addr >= start) && (addr < end)) 1087 if ((addr >= start) && (addr < end))
1085 return 1; 1088 return 1;
@@ -1114,8 +1117,6 @@ static int count_matching_names(struct lock_class *new_class)
1114 return count + 1; 1117 return count + 1;
1115} 1118}
1116 1119
1117extern void __error_too_big_MAX_LOCKDEP_SUBCLASSES(void);
1118
1119/* 1120/*
1120 * Register a lock's class in the hash-table, if the class is not present 1121 * Register a lock's class in the hash-table, if the class is not present
1121 * yet. Otherwise we look it up. We cache the result in the lock object 1122 * yet. Otherwise we look it up. We cache the result in the lock object
@@ -1153,8 +1154,7 @@ look_up_lock_class(struct lockdep_map *lock, unsigned int subclass)
1153 * (or spin_lock_init()) call - which acts as the key. For static 1154 * (or spin_lock_init()) call - which acts as the key. For static
1154 * locks we use the lock object itself as the key. 1155 * locks we use the lock object itself as the key.
1155 */ 1156 */
1156 if (sizeof(struct lock_class_key) > sizeof(struct lock_class)) 1157 BUILD_BUG_ON(sizeof(struct lock_class_key) > sizeof(struct lock_class));
1157 __error_too_big_MAX_LOCKDEP_SUBCLASSES();
1158 1158
1159 key = lock->key->subkeys + subclass; 1159 key = lock->key->subkeys + subclass;
1160 1160
@@ -1177,7 +1177,7 @@ look_up_lock_class(struct lockdep_map *lock, unsigned int subclass)
1177 * itself, so actual lookup of the hash should be once per lock object. 1177 * itself, so actual lookup of the hash should be once per lock object.
1178 */ 1178 */
1179static inline struct lock_class * 1179static inline struct lock_class *
1180register_lock_class(struct lockdep_map *lock, unsigned int subclass) 1180register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
1181{ 1181{
1182 struct lockdep_subclass_key *key; 1182 struct lockdep_subclass_key *key;
1183 struct list_head *hash_head; 1183 struct list_head *hash_head;
@@ -1249,7 +1249,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass)
1249out_unlock_set: 1249out_unlock_set:
1250 __raw_spin_unlock(&hash_lock); 1250 __raw_spin_unlock(&hash_lock);
1251 1251
1252 if (!subclass) 1252 if (!subclass || force)
1253 lock->class_cache = class; 1253 lock->class_cache = class;
1254 1254
1255 DEBUG_LOCKS_WARN_ON(class->subclass != subclass); 1255 DEBUG_LOCKS_WARN_ON(class->subclass != subclass);
@@ -1937,7 +1937,7 @@ void trace_softirqs_off(unsigned long ip)
1937 * Initialize a lock instance's lock-class mapping info: 1937 * Initialize a lock instance's lock-class mapping info:
1938 */ 1938 */
1939void lockdep_init_map(struct lockdep_map *lock, const char *name, 1939void lockdep_init_map(struct lockdep_map *lock, const char *name,
1940 struct lock_class_key *key) 1940 struct lock_class_key *key, int subclass)
1941{ 1941{
1942 if (unlikely(!debug_locks)) 1942 if (unlikely(!debug_locks))
1943 return; 1943 return;
@@ -1957,6 +1957,8 @@ void lockdep_init_map(struct lockdep_map *lock, const char *name,
1957 lock->name = name; 1957 lock->name = name;
1958 lock->key = key; 1958 lock->key = key;
1959 lock->class_cache = NULL; 1959 lock->class_cache = NULL;
1960 if (subclass)
1961 register_lock_class(lock, subclass, 1);
1960} 1962}
1961 1963
1962EXPORT_SYMBOL_GPL(lockdep_init_map); 1964EXPORT_SYMBOL_GPL(lockdep_init_map);
@@ -1995,7 +1997,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
1995 * Not cached yet or subclass? 1997 * Not cached yet or subclass?
1996 */ 1998 */
1997 if (unlikely(!class)) { 1999 if (unlikely(!class)) {
1998 class = register_lock_class(lock, subclass); 2000 class = register_lock_class(lock, subclass, 0);
1999 if (!class) 2001 if (!class)
2000 return 0; 2002 return 0;
2001 } 2003 }
diff --git a/kernel/module.c b/kernel/module.c
index 7f60e782de1e..f0166563c602 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -87,6 +87,12 @@ static inline int strong_try_module_get(struct module *mod)
87 return try_module_get(mod); 87 return try_module_get(mod);
88} 88}
89 89
90static inline void add_taint_module(struct module *mod, unsigned flag)
91{
92 add_taint(flag);
93 mod->taints |= flag;
94}
95
90/* A thread that wants to hold a reference to a module only while it 96/* A thread that wants to hold a reference to a module only while it
91 * is running can call ths to safely exit. 97 * is running can call ths to safely exit.
92 * nfsd and lockd use this. 98 * nfsd and lockd use this.
@@ -847,12 +853,10 @@ static int check_version(Elf_Shdr *sechdrs,
847 return 0; 853 return 0;
848 } 854 }
849 /* Not in module's version table. OK, but that taints the kernel. */ 855 /* Not in module's version table. OK, but that taints the kernel. */
850 if (!(tainted & TAINT_FORCED_MODULE)) { 856 if (!(tainted & TAINT_FORCED_MODULE))
851 printk("%s: no version for \"%s\" found: kernel tainted.\n", 857 printk("%s: no version for \"%s\" found: kernel tainted.\n",
852 mod->name, symname); 858 mod->name, symname);
853 add_taint(TAINT_FORCED_MODULE); 859 add_taint_module(mod, TAINT_FORCED_MODULE);
854 mod->taints |= TAINT_FORCED_MODULE;
855 }
856 return 1; 860 return 1;
857} 861}
858 862
@@ -910,7 +914,8 @@ static unsigned long resolve_symbol(Elf_Shdr *sechdrs,
910 unsigned long ret; 914 unsigned long ret;
911 const unsigned long *crc; 915 const unsigned long *crc;
912 916
913 ret = __find_symbol(name, &owner, &crc, mod->license_gplok); 917 ret = __find_symbol(name, &owner, &crc,
918 !(mod->taints & TAINT_PROPRIETARY_MODULE));
914 if (ret) { 919 if (ret) {
915 /* use_module can fail due to OOM, or module unloading */ 920 /* use_module can fail due to OOM, or module unloading */
916 if (!check_version(sechdrs, versindex, name, mod, crc) || 921 if (!check_version(sechdrs, versindex, name, mod, crc) ||
@@ -1335,12 +1340,11 @@ static void set_license(struct module *mod, const char *license)
1335 if (!license) 1340 if (!license)
1336 license = "unspecified"; 1341 license = "unspecified";
1337 1342
1338 mod->license_gplok = license_is_gpl_compatible(license); 1343 if (!license_is_gpl_compatible(license)) {
1339 if (!mod->license_gplok && !(tainted & TAINT_PROPRIETARY_MODULE)) { 1344 if (!(tainted & TAINT_PROPRIETARY_MODULE))
1340 printk(KERN_WARNING "%s: module license '%s' taints kernel.\n", 1345 printk(KERN_WARNING "%s: module license '%s' taints "
1341 mod->name, license); 1346 "kernel.\n", mod->name, license);
1342 add_taint(TAINT_PROPRIETARY_MODULE); 1347 add_taint_module(mod, TAINT_PROPRIETARY_MODULE);
1343 mod->taints |= TAINT_PROPRIETARY_MODULE;
1344 } 1348 }
1345} 1349}
1346 1350
@@ -1619,8 +1623,7 @@ static struct module *load_module(void __user *umod,
1619 modmagic = get_modinfo(sechdrs, infoindex, "vermagic"); 1623 modmagic = get_modinfo(sechdrs, infoindex, "vermagic");
1620 /* This is allowed: modprobe --force will invalidate it. */ 1624 /* This is allowed: modprobe --force will invalidate it. */
1621 if (!modmagic) { 1625 if (!modmagic) {
1622 add_taint(TAINT_FORCED_MODULE); 1626 add_taint_module(mod, TAINT_FORCED_MODULE);
1623 mod->taints |= TAINT_FORCED_MODULE;
1624 printk(KERN_WARNING "%s: no version magic, tainting kernel.\n", 1627 printk(KERN_WARNING "%s: no version magic, tainting kernel.\n",
1625 mod->name); 1628 mod->name);
1626 } else if (!same_magic(modmagic, vermagic)) { 1629 } else if (!same_magic(modmagic, vermagic)) {
@@ -1714,14 +1717,10 @@ static struct module *load_module(void __user *umod,
1714 /* Set up license info based on the info section */ 1717 /* Set up license info based on the info section */
1715 set_license(mod, get_modinfo(sechdrs, infoindex, "license")); 1718 set_license(mod, get_modinfo(sechdrs, infoindex, "license"));
1716 1719
1717 if (strcmp(mod->name, "ndiswrapper") == 0) { 1720 if (strcmp(mod->name, "ndiswrapper") == 0)
1718 add_taint(TAINT_PROPRIETARY_MODULE);
1719 mod->taints |= TAINT_PROPRIETARY_MODULE;
1720 }
1721 if (strcmp(mod->name, "driverloader") == 0) {
1722 add_taint(TAINT_PROPRIETARY_MODULE); 1721 add_taint(TAINT_PROPRIETARY_MODULE);
1723 mod->taints |= TAINT_PROPRIETARY_MODULE; 1722 if (strcmp(mod->name, "driverloader") == 0)
1724 } 1723 add_taint_module(mod, TAINT_PROPRIETARY_MODULE);
1725 1724
1726 /* Set up MODINFO_ATTR fields */ 1725 /* Set up MODINFO_ATTR fields */
1727 setup_modinfo(mod, sechdrs, infoindex); 1726 setup_modinfo(mod, sechdrs, infoindex);
@@ -1766,8 +1765,7 @@ static struct module *load_module(void __user *umod,
1766 (mod->num_unused_gpl_syms && !unusedgplcrcindex)) { 1765 (mod->num_unused_gpl_syms && !unusedgplcrcindex)) {
1767 printk(KERN_WARNING "%s: No versions for exported symbols." 1766 printk(KERN_WARNING "%s: No versions for exported symbols."
1768 " Tainting kernel.\n", mod->name); 1767 " Tainting kernel.\n", mod->name);
1769 add_taint(TAINT_FORCED_MODULE); 1768 add_taint_module(mod, TAINT_FORCED_MODULE);
1770 mod->taints |= TAINT_FORCED_MODULE;
1771 } 1769 }
1772#endif 1770#endif
1773 1771
@@ -2132,9 +2130,33 @@ static void m_stop(struct seq_file *m, void *p)
2132 mutex_unlock(&module_mutex); 2130 mutex_unlock(&module_mutex);
2133} 2131}
2134 2132
2133static char *taint_flags(unsigned int taints, char *buf)
2134{
2135 int bx = 0;
2136
2137 if (taints) {
2138 buf[bx++] = '(';
2139 if (taints & TAINT_PROPRIETARY_MODULE)
2140 buf[bx++] = 'P';
2141 if (taints & TAINT_FORCED_MODULE)
2142 buf[bx++] = 'F';
2143 /*
2144 * TAINT_FORCED_RMMOD: could be added.
2145 * TAINT_UNSAFE_SMP, TAINT_MACHINE_CHECK, TAINT_BAD_PAGE don't
2146 * apply to modules.
2147 */
2148 buf[bx++] = ')';
2149 }
2150 buf[bx] = '\0';
2151
2152 return buf;
2153}
2154
2135static int m_show(struct seq_file *m, void *p) 2155static int m_show(struct seq_file *m, void *p)
2136{ 2156{
2137 struct module *mod = list_entry(p, struct module, list); 2157 struct module *mod = list_entry(p, struct module, list);
2158 char buf[8];
2159
2138 seq_printf(m, "%s %lu", 2160 seq_printf(m, "%s %lu",
2139 mod->name, mod->init_size + mod->core_size); 2161 mod->name, mod->init_size + mod->core_size);
2140 print_unload_info(m, mod); 2162 print_unload_info(m, mod);
@@ -2147,6 +2169,10 @@ static int m_show(struct seq_file *m, void *p)
2147 /* Used by oprofile and other similar tools. */ 2169 /* Used by oprofile and other similar tools. */
2148 seq_printf(m, " 0x%p", mod->module_core); 2170 seq_printf(m, " 0x%p", mod->module_core);
2149 2171
2172 /* Taints info */
2173 if (mod->taints)
2174 seq_printf(m, " %s", taint_flags(mod->taints, buf));
2175
2150 seq_printf(m, "\n"); 2176 seq_printf(m, "\n");
2151 return 0; 2177 return 0;
2152} 2178}
@@ -2235,28 +2261,6 @@ struct module *module_text_address(unsigned long addr)
2235 return mod; 2261 return mod;
2236} 2262}
2237 2263
2238static char *taint_flags(unsigned int taints, char *buf)
2239{
2240 *buf = '\0';
2241 if (taints) {
2242 int bx;
2243
2244 buf[0] = '(';
2245 bx = 1;
2246 if (taints & TAINT_PROPRIETARY_MODULE)
2247 buf[bx++] = 'P';
2248 if (taints & TAINT_FORCED_MODULE)
2249 buf[bx++] = 'F';
2250 /*
2251 * TAINT_FORCED_RMMOD: could be added.
2252 * TAINT_UNSAFE_SMP, TAINT_MACHINE_CHECK, TAINT_BAD_PAGE don't
2253 * apply to modules.
2254 */
2255 buf[bx] = ')';
2256 }
2257 return buf;
2258}
2259
2260/* Don't grab lock, we're oopsing. */ 2264/* Don't grab lock, we're oopsing. */
2261void print_modules(void) 2265void print_modules(void)
2262{ 2266{
diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
index e3203c654dda..18651641a7b5 100644
--- a/kernel/mutex-debug.c
+++ b/kernel/mutex-debug.c
@@ -91,7 +91,7 @@ void debug_mutex_init(struct mutex *lock, const char *name,
91 * Make sure we are not reinitializing a held lock: 91 * Make sure we are not reinitializing a held lock:
92 */ 92 */
93 debug_check_no_locks_freed((void *)lock, sizeof(*lock)); 93 debug_check_no_locks_freed((void *)lock, sizeof(*lock));
94 lockdep_init_map(&lock->dep_map, name, key); 94 lockdep_init_map(&lock->dep_map, name, key, 0);
95#endif 95#endif
96 lock->owner = NULL; 96 lock->owner = NULL;
97 lock->magic = lock; 97 lock->magic = lock;
diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c
index 6ebdb82a0ce4..674aceb7335a 100644
--- a/kernel/nsproxy.c
+++ b/kernel/nsproxy.c
@@ -44,11 +44,9 @@ static inline struct nsproxy *clone_namespaces(struct nsproxy *orig)
44{ 44{
45 struct nsproxy *ns; 45 struct nsproxy *ns;
46 46
47 ns = kmalloc(sizeof(struct nsproxy), GFP_KERNEL); 47 ns = kmemdup(orig, sizeof(struct nsproxy), GFP_KERNEL);
48 if (ns) { 48 if (ns)
49 memcpy(ns, orig, sizeof(struct nsproxy));
50 atomic_set(&ns->count, 1); 49 atomic_set(&ns->count, 1);
51 }
52 return ns; 50 return ns;
53} 51}
54 52
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
index 479b16b44f79..7c3e1e6dfb5b 100644
--- a/kernel/posix-cpu-timers.c
+++ b/kernel/posix-cpu-timers.c
@@ -88,6 +88,19 @@ static inline union cpu_time_count cpu_time_sub(const clockid_t which_clock,
88} 88}
89 89
90/* 90/*
91 * Divide and limit the result to res >= 1
92 *
93 * This is necessary to prevent signal delivery starvation, when the result of
94 * the division would be rounded down to 0.
95 */
96static inline cputime_t cputime_div_non_zero(cputime_t time, unsigned long div)
97{
98 cputime_t res = cputime_div(time, div);
99
100 return max_t(cputime_t, res, 1);
101}
102
103/*
91 * Update expiry time from increment, and increase overrun count, 104 * Update expiry time from increment, and increase overrun count,
92 * given the current clock sample. 105 * given the current clock sample.
93 */ 106 */
@@ -483,8 +496,8 @@ static void process_timer_rebalance(struct task_struct *p,
483 BUG(); 496 BUG();
484 break; 497 break;
485 case CPUCLOCK_PROF: 498 case CPUCLOCK_PROF:
486 left = cputime_div(cputime_sub(expires.cpu, val.cpu), 499 left = cputime_div_non_zero(cputime_sub(expires.cpu, val.cpu),
487 nthreads); 500 nthreads);
488 do { 501 do {
489 if (likely(!(t->flags & PF_EXITING))) { 502 if (likely(!(t->flags & PF_EXITING))) {
490 ticks = cputime_add(prof_ticks(t), left); 503 ticks = cputime_add(prof_ticks(t), left);
@@ -498,8 +511,8 @@ static void process_timer_rebalance(struct task_struct *p,
498 } while (t != p); 511 } while (t != p);
499 break; 512 break;
500 case CPUCLOCK_VIRT: 513 case CPUCLOCK_VIRT:
501 left = cputime_div(cputime_sub(expires.cpu, val.cpu), 514 left = cputime_div_non_zero(cputime_sub(expires.cpu, val.cpu),
502 nthreads); 515 nthreads);
503 do { 516 do {
504 if (likely(!(t->flags & PF_EXITING))) { 517 if (likely(!(t->flags & PF_EXITING))) {
505 ticks = cputime_add(virt_ticks(t), left); 518 ticks = cputime_add(virt_ticks(t), left);
@@ -515,6 +528,7 @@ static void process_timer_rebalance(struct task_struct *p,
515 case CPUCLOCK_SCHED: 528 case CPUCLOCK_SCHED:
516 nsleft = expires.sched - val.sched; 529 nsleft = expires.sched - val.sched;
517 do_div(nsleft, nthreads); 530 do_div(nsleft, nthreads);
531 nsleft = max_t(unsigned long long, nsleft, 1);
518 do { 532 do {
519 if (likely(!(t->flags & PF_EXITING))) { 533 if (likely(!(t->flags & PF_EXITING))) {
520 ns = t->sched_time + nsleft; 534 ns = t->sched_time + nsleft;
@@ -1159,12 +1173,13 @@ static void check_process_timers(struct task_struct *tsk,
1159 1173
1160 prof_left = cputime_sub(prof_expires, utime); 1174 prof_left = cputime_sub(prof_expires, utime);
1161 prof_left = cputime_sub(prof_left, stime); 1175 prof_left = cputime_sub(prof_left, stime);
1162 prof_left = cputime_div(prof_left, nthreads); 1176 prof_left = cputime_div_non_zero(prof_left, nthreads);
1163 virt_left = cputime_sub(virt_expires, utime); 1177 virt_left = cputime_sub(virt_expires, utime);
1164 virt_left = cputime_div(virt_left, nthreads); 1178 virt_left = cputime_div_non_zero(virt_left, nthreads);
1165 if (sched_expires) { 1179 if (sched_expires) {
1166 sched_left = sched_expires - sched_time; 1180 sched_left = sched_expires - sched_time;
1167 do_div(sched_left, nthreads); 1181 do_div(sched_left, nthreads);
1182 sched_left = max_t(unsigned long long, sched_left, 1);
1168 } else { 1183 } else {
1169 sched_left = 0; 1184 sched_left = 0;
1170 } 1185 }
diff --git a/kernel/power/disk.c b/kernel/power/disk.c
index d72234942798..b1fb7866b0b3 100644
--- a/kernel/power/disk.c
+++ b/kernel/power/disk.c
@@ -18,6 +18,7 @@
18#include <linux/fs.h> 18#include <linux/fs.h>
19#include <linux/mount.h> 19#include <linux/mount.h>
20#include <linux/pm.h> 20#include <linux/pm.h>
21#include <linux/console.h>
21#include <linux/cpu.h> 22#include <linux/cpu.h>
22 23
23#include "power.h" 24#include "power.h"
@@ -70,7 +71,7 @@ static inline void platform_finish(void)
70 71
71static int prepare_processes(void) 72static int prepare_processes(void)
72{ 73{
73 int error; 74 int error = 0;
74 75
75 pm_prepare_console(); 76 pm_prepare_console();
76 77
@@ -83,6 +84,12 @@ static int prepare_processes(void)
83 goto thaw; 84 goto thaw;
84 } 85 }
85 86
87 if (pm_disk_mode == PM_DISK_TESTPROC) {
88 printk("swsusp debug: Waiting for 5 seconds.\n");
89 mdelay(5000);
90 goto thaw;
91 }
92
86 /* Free memory before shutting down devices. */ 93 /* Free memory before shutting down devices. */
87 if (!(error = swsusp_shrink_memory())) 94 if (!(error = swsusp_shrink_memory()))
88 return 0; 95 return 0;
@@ -119,11 +126,21 @@ int pm_suspend_disk(void)
119 if (error) 126 if (error)
120 return error; 127 return error;
121 128
129 if (pm_disk_mode == PM_DISK_TESTPROC)
130 goto Thaw;
131
132 suspend_console();
122 error = device_suspend(PMSG_FREEZE); 133 error = device_suspend(PMSG_FREEZE);
123 if (error) { 134 if (error) {
135 resume_console();
124 printk("Some devices failed to suspend\n"); 136 printk("Some devices failed to suspend\n");
125 unprepare_processes(); 137 goto Thaw;
126 return error; 138 }
139
140 if (pm_disk_mode == PM_DISK_TEST) {
141 printk("swsusp debug: Waiting for 5 seconds.\n");
142 mdelay(5000);
143 goto Done;
127 } 144 }
128 145
129 pr_debug("PM: snapshotting memory.\n"); 146 pr_debug("PM: snapshotting memory.\n");
@@ -133,21 +150,24 @@ int pm_suspend_disk(void)
133 150
134 if (in_suspend) { 151 if (in_suspend) {
135 device_resume(); 152 device_resume();
153 resume_console();
136 pr_debug("PM: writing image.\n"); 154 pr_debug("PM: writing image.\n");
137 error = swsusp_write(); 155 error = swsusp_write();
138 if (!error) 156 if (!error)
139 power_down(pm_disk_mode); 157 power_down(pm_disk_mode);
140 else { 158 else {
141 swsusp_free(); 159 swsusp_free();
142 unprepare_processes(); 160 goto Thaw;
143 return error;
144 } 161 }
145 } else 162 } else {
146 pr_debug("PM: Image restored successfully.\n"); 163 pr_debug("PM: Image restored successfully.\n");
164 }
147 165
148 swsusp_free(); 166 swsusp_free();
149 Done: 167 Done:
150 device_resume(); 168 device_resume();
169 resume_console();
170 Thaw:
151 unprepare_processes(); 171 unprepare_processes();
152 return error; 172 return error;
153} 173}
@@ -212,7 +232,9 @@ static int software_resume(void)
212 232
213 pr_debug("PM: Preparing devices for restore.\n"); 233 pr_debug("PM: Preparing devices for restore.\n");
214 234
235 suspend_console();
215 if ((error = device_suspend(PMSG_PRETHAW))) { 236 if ((error = device_suspend(PMSG_PRETHAW))) {
237 resume_console();
216 printk("Some devices failed to suspend\n"); 238 printk("Some devices failed to suspend\n");
217 swsusp_free(); 239 swsusp_free();
218 goto Thaw; 240 goto Thaw;
@@ -224,6 +246,7 @@ static int software_resume(void)
224 swsusp_resume(); 246 swsusp_resume();
225 pr_debug("PM: Restore failed, recovering.n"); 247 pr_debug("PM: Restore failed, recovering.n");
226 device_resume(); 248 device_resume();
249 resume_console();
227 Thaw: 250 Thaw:
228 unprepare_processes(); 251 unprepare_processes();
229 Done: 252 Done:
@@ -241,6 +264,8 @@ static const char * const pm_disk_modes[] = {
241 [PM_DISK_PLATFORM] = "platform", 264 [PM_DISK_PLATFORM] = "platform",
242 [PM_DISK_SHUTDOWN] = "shutdown", 265 [PM_DISK_SHUTDOWN] = "shutdown",
243 [PM_DISK_REBOOT] = "reboot", 266 [PM_DISK_REBOOT] = "reboot",
267 [PM_DISK_TEST] = "test",
268 [PM_DISK_TESTPROC] = "testproc",
244}; 269};
245 270
246/** 271/**
@@ -295,17 +320,19 @@ static ssize_t disk_store(struct subsystem * s, const char * buf, size_t n)
295 } 320 }
296 } 321 }
297 if (mode) { 322 if (mode) {
298 if (mode == PM_DISK_SHUTDOWN || mode == PM_DISK_REBOOT) 323 if (mode == PM_DISK_SHUTDOWN || mode == PM_DISK_REBOOT ||
324 mode == PM_DISK_TEST || mode == PM_DISK_TESTPROC) {
299 pm_disk_mode = mode; 325 pm_disk_mode = mode;
300 else { 326 } else {
301 if (pm_ops && pm_ops->enter && 327 if (pm_ops && pm_ops->enter &&
302 (mode == pm_ops->pm_disk_mode)) 328 (mode == pm_ops->pm_disk_mode))
303 pm_disk_mode = mode; 329 pm_disk_mode = mode;
304 else 330 else
305 error = -EINVAL; 331 error = -EINVAL;
306 } 332 }
307 } else 333 } else {
308 error = -EINVAL; 334 error = -EINVAL;
335 }
309 336
310 pr_debug("PM: suspend-to-disk mode set to '%s'\n", 337 pr_debug("PM: suspend-to-disk mode set to '%s'\n",
311 pm_disk_modes[mode]); 338 pm_disk_modes[mode]);
diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index 9b2ee5344dee..1a3b0dd2c3fc 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -425,7 +425,8 @@ static int submit(int rw, pgoff_t page_off, struct page *page,
425 bio_set_pages_dirty(bio); 425 bio_set_pages_dirty(bio);
426 bio_put(bio); 426 bio_put(bio);
427 } else { 427 } else {
428 get_page(page); 428 if (rw == READ)
429 get_page(page); /* These pages are freed later */
429 bio->bi_private = *bio_chain; 430 bio->bi_private = *bio_chain;
430 *bio_chain = bio; 431 *bio_chain = bio;
431 submit_bio(rw | (1 << BIO_RW_SYNC), bio); 432 submit_bio(rw | (1 << BIO_RW_SYNC), bio);
diff --git a/kernel/power/user.c b/kernel/power/user.c
index 93b5dd283dea..d991d3b0e5a4 100644
--- a/kernel/power/user.c
+++ b/kernel/power/user.c
@@ -19,6 +19,7 @@
19#include <linux/swapops.h> 19#include <linux/swapops.h>
20#include <linux/pm.h> 20#include <linux/pm.h>
21#include <linux/fs.h> 21#include <linux/fs.h>
22#include <linux/console.h>
22#include <linux/cpu.h> 23#include <linux/cpu.h>
23 24
24#include <asm/uaccess.h> 25#include <asm/uaccess.h>
@@ -173,12 +174,14 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
173 /* Free memory before shutting down devices. */ 174 /* Free memory before shutting down devices. */
174 error = swsusp_shrink_memory(); 175 error = swsusp_shrink_memory();
175 if (!error) { 176 if (!error) {
177 suspend_console();
176 error = device_suspend(PMSG_FREEZE); 178 error = device_suspend(PMSG_FREEZE);
177 if (!error) { 179 if (!error) {
178 in_suspend = 1; 180 in_suspend = 1;
179 error = swsusp_suspend(); 181 error = swsusp_suspend();
180 device_resume(); 182 device_resume();
181 } 183 }
184 resume_console();
182 } 185 }
183 up(&pm_sem); 186 up(&pm_sem);
184 if (!error) 187 if (!error)
@@ -196,11 +199,13 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
196 snapshot_free_unused_memory(&data->handle); 199 snapshot_free_unused_memory(&data->handle);
197 down(&pm_sem); 200 down(&pm_sem);
198 pm_prepare_console(); 201 pm_prepare_console();
202 suspend_console();
199 error = device_suspend(PMSG_PRETHAW); 203 error = device_suspend(PMSG_PRETHAW);
200 if (!error) { 204 if (!error) {
201 error = swsusp_resume(); 205 error = swsusp_resume();
202 device_resume(); 206 device_resume();
203 } 207 }
208 resume_console();
204 pm_restore_console(); 209 pm_restore_console();
205 up(&pm_sem); 210 up(&pm_sem);
206 break; 211 break;
@@ -289,6 +294,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
289 } 294 }
290 295
291 /* Put devices to sleep */ 296 /* Put devices to sleep */
297 suspend_console();
292 error = device_suspend(PMSG_SUSPEND); 298 error = device_suspend(PMSG_SUSPEND);
293 if (error) { 299 if (error) {
294 printk(KERN_ERR "Failed to suspend some devices.\n"); 300 printk(KERN_ERR "Failed to suspend some devices.\n");
@@ -299,7 +305,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
299 /* Wake up devices */ 305 /* Wake up devices */
300 device_resume(); 306 device_resume();
301 } 307 }
302 308 resume_console();
303 if (pm_ops->finish) 309 if (pm_ops->finish)
304 pm_ops->finish(PM_SUSPEND_MEM); 310 pm_ops->finish(PM_SUSPEND_MEM);
305 311
diff --git a/kernel/printk.c b/kernel/printk.c
index 771f5e861bcd..66426552fbfe 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -31,6 +31,7 @@
31#include <linux/security.h> 31#include <linux/security.h>
32#include <linux/bootmem.h> 32#include <linux/bootmem.h>
33#include <linux/syscalls.h> 33#include <linux/syscalls.h>
34#include <linux/jiffies.h>
34 35
35#include <asm/uaccess.h> 36#include <asm/uaccess.h>
36 37
@@ -820,15 +821,8 @@ void release_console_sem(void)
820 console_locked = 0; 821 console_locked = 0;
821 up(&console_sem); 822 up(&console_sem);
822 spin_unlock_irqrestore(&logbuf_lock, flags); 823 spin_unlock_irqrestore(&logbuf_lock, flags);
823 if (wake_klogd && !oops_in_progress && waitqueue_active(&log_wait)) { 824 if (wake_klogd && !oops_in_progress && waitqueue_active(&log_wait))
824 /* 825 wake_up_interruptible(&log_wait);
825 * If we printk from within the lock dependency code,
826 * from within the scheduler code, then do not lock
827 * up due to self-recursion:
828 */
829 if (!lockdep_internal())
830 wake_up_interruptible(&log_wait);
831 }
832} 826}
833EXPORT_SYMBOL(release_console_sem); 827EXPORT_SYMBOL(release_console_sem);
834 828
@@ -1108,3 +1102,23 @@ int printk_ratelimit(void)
1108 printk_ratelimit_burst); 1102 printk_ratelimit_burst);
1109} 1103}
1110EXPORT_SYMBOL(printk_ratelimit); 1104EXPORT_SYMBOL(printk_ratelimit);
1105
1106/**
1107 * printk_timed_ratelimit - caller-controlled printk ratelimiting
1108 * @caller_jiffies: pointer to caller's state
1109 * @interval_msecs: minimum interval between prints
1110 *
1111 * printk_timed_ratelimit() returns true if more than @interval_msecs
1112 * milliseconds have elapsed since the last time printk_timed_ratelimit()
1113 * returned true.
1114 */
1115bool printk_timed_ratelimit(unsigned long *caller_jiffies,
1116 unsigned int interval_msecs)
1117{
1118 if (*caller_jiffies == 0 || time_after(jiffies, *caller_jiffies)) {
1119 *caller_jiffies = jiffies + msecs_to_jiffies(interval_msecs);
1120 return true;
1121 }
1122 return false;
1123}
1124EXPORT_SYMBOL(printk_timed_ratelimit);
diff --git a/kernel/profile.c b/kernel/profile.c
index 857300a2afec..f940b462eec9 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -399,7 +399,7 @@ static int prof_cpu_mask_write_proc (struct file *file, const char __user *buffe
399 unsigned long full_count = count, err; 399 unsigned long full_count = count, err;
400 cpumask_t new_value; 400 cpumask_t new_value;
401 401
402 err = cpumask_parse(buffer, count, new_value); 402 err = cpumask_parse_user(buffer, count, new_value);
403 if (err) 403 if (err)
404 return err; 404 return err;
405 405
diff --git a/kernel/sched.c b/kernel/sched.c
index 53608a59d6e3..3399701c680e 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -160,15 +160,6 @@
160#define TASK_PREEMPTS_CURR(p, rq) \ 160#define TASK_PREEMPTS_CURR(p, rq) \
161 ((p)->prio < (rq)->curr->prio) 161 ((p)->prio < (rq)->curr->prio)
162 162
163/*
164 * task_timeslice() scales user-nice values [ -20 ... 0 ... 19 ]
165 * to time slice values: [800ms ... 100ms ... 5ms]
166 *
167 * The higher a thread's priority, the bigger timeslices
168 * it gets during one round of execution. But even the lowest
169 * priority thread gets MIN_TIMESLICE worth of execution time.
170 */
171
172#define SCALE_PRIO(x, prio) \ 163#define SCALE_PRIO(x, prio) \
173 max(x * (MAX_PRIO - prio) / (MAX_USER_PRIO / 2), MIN_TIMESLICE) 164 max(x * (MAX_PRIO - prio) / (MAX_USER_PRIO / 2), MIN_TIMESLICE)
174 165
@@ -180,6 +171,15 @@ static unsigned int static_prio_timeslice(int static_prio)
180 return SCALE_PRIO(DEF_TIMESLICE, static_prio); 171 return SCALE_PRIO(DEF_TIMESLICE, static_prio);
181} 172}
182 173
174/*
175 * task_timeslice() scales user-nice values [ -20 ... 0 ... 19 ]
176 * to time slice values: [800ms ... 100ms ... 5ms]
177 *
178 * The higher a thread's priority, the bigger timeslices
179 * it gets during one round of execution. But even the lowest
180 * priority thread gets MIN_TIMESLICE worth of execution time.
181 */
182
183static inline unsigned int task_timeslice(struct task_struct *p) 183static inline unsigned int task_timeslice(struct task_struct *p)
184{ 184{
185 return static_prio_timeslice(p->static_prio); 185 return static_prio_timeslice(p->static_prio);
@@ -1822,14 +1822,14 @@ context_switch(struct rq *rq, struct task_struct *prev,
1822 struct mm_struct *mm = next->mm; 1822 struct mm_struct *mm = next->mm;
1823 struct mm_struct *oldmm = prev->active_mm; 1823 struct mm_struct *oldmm = prev->active_mm;
1824 1824
1825 if (unlikely(!mm)) { 1825 if (!mm) {
1826 next->active_mm = oldmm; 1826 next->active_mm = oldmm;
1827 atomic_inc(&oldmm->mm_count); 1827 atomic_inc(&oldmm->mm_count);
1828 enter_lazy_tlb(oldmm, next); 1828 enter_lazy_tlb(oldmm, next);
1829 } else 1829 } else
1830 switch_mm(oldmm, mm, next); 1830 switch_mm(oldmm, mm, next);
1831 1831
1832 if (unlikely(!prev->mm)) { 1832 if (!prev->mm) {
1833 prev->active_mm = NULL; 1833 prev->active_mm = NULL;
1834 WARN_ON(rq->prev_mm); 1834 WARN_ON(rq->prev_mm);
1835 rq->prev_mm = oldmm; 1835 rq->prev_mm = oldmm;
@@ -3491,7 +3491,7 @@ asmlinkage void __sched preempt_schedule(void)
3491 * If there is a non-zero preempt_count or interrupts are disabled, 3491 * If there is a non-zero preempt_count or interrupts are disabled,
3492 * we do not want to preempt the current task. Just return.. 3492 * we do not want to preempt the current task. Just return..
3493 */ 3493 */
3494 if (unlikely(ti->preempt_count || irqs_disabled())) 3494 if (likely(ti->preempt_count || irqs_disabled()))
3495 return; 3495 return;
3496 3496
3497need_resched: 3497need_resched:
diff --git a/kernel/signal.c b/kernel/signal.c
index 7ed8d5304bec..df18c167a2a7 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -267,18 +267,25 @@ static struct sigqueue *__sigqueue_alloc(struct task_struct *t, gfp_t flags,
267 int override_rlimit) 267 int override_rlimit)
268{ 268{
269 struct sigqueue *q = NULL; 269 struct sigqueue *q = NULL;
270 struct user_struct *user;
270 271
271 atomic_inc(&t->user->sigpending); 272 /*
273 * In order to avoid problems with "switch_user()", we want to make
274 * sure that the compiler doesn't re-load "t->user"
275 */
276 user = t->user;
277 barrier();
278 atomic_inc(&user->sigpending);
272 if (override_rlimit || 279 if (override_rlimit ||
273 atomic_read(&t->user->sigpending) <= 280 atomic_read(&user->sigpending) <=
274 t->signal->rlim[RLIMIT_SIGPENDING].rlim_cur) 281 t->signal->rlim[RLIMIT_SIGPENDING].rlim_cur)
275 q = kmem_cache_alloc(sigqueue_cachep, flags); 282 q = kmem_cache_alloc(sigqueue_cachep, flags);
276 if (unlikely(q == NULL)) { 283 if (unlikely(q == NULL)) {
277 atomic_dec(&t->user->sigpending); 284 atomic_dec(&user->sigpending);
278 } else { 285 } else {
279 INIT_LIST_HEAD(&q->list); 286 INIT_LIST_HEAD(&q->list);
280 q->flags = 0; 287 q->flags = 0;
281 q->user = get_uid(t->user); 288 q->user = get_uid(user);
282 } 289 }
283 return(q); 290 return(q);
284} 291}
diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c
index 7a3b2e75f040..d7306d0f3dfc 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -49,6 +49,7 @@ cond_syscall(compat_sys_get_robust_list);
49cond_syscall(sys_epoll_create); 49cond_syscall(sys_epoll_create);
50cond_syscall(sys_epoll_ctl); 50cond_syscall(sys_epoll_ctl);
51cond_syscall(sys_epoll_wait); 51cond_syscall(sys_epoll_wait);
52cond_syscall(sys_epoll_pwait);
52cond_syscall(sys_semget); 53cond_syscall(sys_semget);
53cond_syscall(sys_semop); 54cond_syscall(sys_semop);
54cond_syscall(sys_semtimedop); 55cond_syscall(sys_semtimedop);
@@ -134,6 +135,7 @@ cond_syscall(sys_madvise);
134cond_syscall(sys_mremap); 135cond_syscall(sys_mremap);
135cond_syscall(sys_remap_file_pages); 136cond_syscall(sys_remap_file_pages);
136cond_syscall(compat_sys_move_pages); 137cond_syscall(compat_sys_move_pages);
138cond_syscall(compat_sys_migrate_pages);
137 139
138/* block-layer dependent */ 140/* block-layer dependent */
139cond_syscall(sys_bdflush); 141cond_syscall(sys_bdflush);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 8020fb273c4f..09e569f4792b 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -136,8 +136,10 @@ static int parse_table(int __user *, int, void __user *, size_t __user *,
136static int proc_do_uts_string(ctl_table *table, int write, struct file *filp, 136static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
137 void __user *buffer, size_t *lenp, loff_t *ppos); 137 void __user *buffer, size_t *lenp, loff_t *ppos);
138 138
139#ifdef CONFIG_PROC_SYSCTL
139static int proc_do_cad_pid(ctl_table *table, int write, struct file *filp, 140static int proc_do_cad_pid(ctl_table *table, int write, struct file *filp,
140 void __user *buffer, size_t *lenp, loff_t *ppos); 141 void __user *buffer, size_t *lenp, loff_t *ppos);
142#endif
141 143
142static ctl_table root_table[]; 144static ctl_table root_table[];
143static struct ctl_table_header root_table_header = 145static struct ctl_table_header root_table_header =
@@ -542,6 +544,7 @@ static ctl_table kern_table[] = {
542 .proc_handler = &proc_dointvec, 544 .proc_handler = &proc_dointvec,
543 }, 545 },
544#endif 546#endif
547#ifdef CONFIG_PROC_SYSCTL
545 { 548 {
546 .ctl_name = KERN_CADPID, 549 .ctl_name = KERN_CADPID,
547 .procname = "cad_pid", 550 .procname = "cad_pid",
@@ -550,6 +553,7 @@ static ctl_table kern_table[] = {
550 .mode = 0600, 553 .mode = 0600,
551 .proc_handler = &proc_do_cad_pid, 554 .proc_handler = &proc_do_cad_pid,
552 }, 555 },
556#endif
553 { 557 {
554 .ctl_name = KERN_MAX_THREADS, 558 .ctl_name = KERN_MAX_THREADS,
555 .procname = "threads-max", 559 .procname = "threads-max",
@@ -1311,7 +1315,9 @@ repeat:
1311 return -ENOTDIR; 1315 return -ENOTDIR;
1312 if (get_user(n, name)) 1316 if (get_user(n, name))
1313 return -EFAULT; 1317 return -EFAULT;
1314 for ( ; table->ctl_name; table++) { 1318 for ( ; table->ctl_name || table->procname; table++) {
1319 if (!table->ctl_name)
1320 continue;
1315 if (n == table->ctl_name || table->ctl_name == CTL_ANY) { 1321 if (n == table->ctl_name || table->ctl_name == CTL_ANY) {
1316 int error; 1322 int error;
1317 if (table->child) { 1323 if (table->child) {
@@ -1528,7 +1534,7 @@ static void register_proc_table(ctl_table * table, struct proc_dir_entry *root,
1528 int len; 1534 int len;
1529 mode_t mode; 1535 mode_t mode;
1530 1536
1531 for (; table->ctl_name; table++) { 1537 for (; table->ctl_name || table->procname; table++) {
1532 /* Can't do anything without a proc name. */ 1538 /* Can't do anything without a proc name. */
1533 if (!table->procname) 1539 if (!table->procname)
1534 continue; 1540 continue;
@@ -1575,7 +1581,7 @@ static void register_proc_table(ctl_table * table, struct proc_dir_entry *root,
1575static void unregister_proc_table(ctl_table * table, struct proc_dir_entry *root) 1581static void unregister_proc_table(ctl_table * table, struct proc_dir_entry *root)
1576{ 1582{
1577 struct proc_dir_entry *de; 1583 struct proc_dir_entry *de;
1578 for (; table->ctl_name; table++) { 1584 for (; table->ctl_name || table->procname; table++) {
1579 if (!(de = table->de)) 1585 if (!(de = table->de))
1580 continue; 1586 continue;
1581 if (de->mode & S_IFDIR) { 1587 if (de->mode & S_IFDIR) {
@@ -2676,13 +2682,33 @@ int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
2676asmlinkage long sys_sysctl(struct __sysctl_args __user *args) 2682asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
2677{ 2683{
2678 static int msg_count; 2684 static int msg_count;
2685 struct __sysctl_args tmp;
2686 int name[CTL_MAXNAME];
2687 int i;
2688
2689 /* Read in the sysctl name for better debug message logging */
2690 if (copy_from_user(&tmp, args, sizeof(tmp)))
2691 return -EFAULT;
2692 if (tmp.nlen <= 0 || tmp.nlen >= CTL_MAXNAME)
2693 return -ENOTDIR;
2694 for (i = 0; i < tmp.nlen; i++)
2695 if (get_user(name[i], tmp.name + i))
2696 return -EFAULT;
2697
2698 /* Ignore accesses to kernel.version */
2699 if ((tmp.nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION))
2700 goto out;
2679 2701
2680 if (msg_count < 5) { 2702 if (msg_count < 5) {
2681 msg_count++; 2703 msg_count++;
2682 printk(KERN_INFO 2704 printk(KERN_INFO
2683 "warning: process `%s' used the removed sysctl " 2705 "warning: process `%s' used the removed sysctl "
2684 "system call\n", current->comm); 2706 "system call with ", current->comm);
2707 for (i = 0; i < tmp.nlen; i++)
2708 printk("%d.", name[i]);
2709 printk("\n");
2685 } 2710 }
2711out:
2686 return -ENOSYS; 2712 return -ENOSYS;
2687} 2713}
2688 2714
diff --git a/kernel/taskstats.c b/kernel/taskstats.c
index 5d6a8c54ee85..f45c5e70773c 100644
--- a/kernel/taskstats.c
+++ b/kernel/taskstats.c
@@ -77,7 +77,8 @@ static int prepare_reply(struct genl_info *info, u8 cmd, struct sk_buff **skbp,
77 /* 77 /*
78 * If new attributes are added, please revisit this allocation 78 * If new attributes are added, please revisit this allocation
79 */ 79 */
80 skb = nlmsg_new(genlmsg_total_size(size), GFP_KERNEL); 80 size = nlmsg_total_size(genlmsg_total_size(size));
81 skb = nlmsg_new(size, GFP_KERNEL);
81 if (!skb) 82 if (!skb)
82 return -ENOMEM; 83 return -ENOMEM;
83 84
@@ -174,21 +175,19 @@ static void send_cpu_listeners(struct sk_buff *skb, unsigned int cpu)
174 up_write(&listeners->sem); 175 up_write(&listeners->sem);
175} 176}
176 177
177static int fill_pid(pid_t pid, struct task_struct *pidtsk, 178static int fill_pid(pid_t pid, struct task_struct *tsk,
178 struct taskstats *stats) 179 struct taskstats *stats)
179{ 180{
180 int rc = 0; 181 int rc = 0;
181 struct task_struct *tsk = pidtsk;
182 182
183 if (!pidtsk) { 183 if (!tsk) {
184 read_lock(&tasklist_lock); 184 rcu_read_lock();
185 tsk = find_task_by_pid(pid); 185 tsk = find_task_by_pid(pid);
186 if (!tsk) { 186 if (tsk)
187 read_unlock(&tasklist_lock); 187 get_task_struct(tsk);
188 rcu_read_unlock();
189 if (!tsk)
188 return -ESRCH; 190 return -ESRCH;
189 }
190 get_task_struct(tsk);
191 read_unlock(&tasklist_lock);
192 } else 191 } else
193 get_task_struct(tsk); 192 get_task_struct(tsk);
194 193
@@ -214,39 +213,30 @@ static int fill_pid(pid_t pid, struct task_struct *pidtsk,
214 213
215} 214}
216 215
217static int fill_tgid(pid_t tgid, struct task_struct *tgidtsk, 216static int fill_tgid(pid_t tgid, struct task_struct *first,
218 struct taskstats *stats) 217 struct taskstats *stats)
219{ 218{
220 struct task_struct *tsk, *first; 219 struct task_struct *tsk;
221 unsigned long flags; 220 unsigned long flags;
221 int rc = -ESRCH;
222 222
223 /* 223 /*
224 * Add additional stats from live tasks except zombie thread group 224 * Add additional stats from live tasks except zombie thread group
225 * leaders who are already counted with the dead tasks 225 * leaders who are already counted with the dead tasks
226 */ 226 */
227 first = tgidtsk; 227 rcu_read_lock();
228 if (!first) { 228 if (!first)
229 read_lock(&tasklist_lock);
230 first = find_task_by_pid(tgid); 229 first = find_task_by_pid(tgid);
231 if (!first) {
232 read_unlock(&tasklist_lock);
233 return -ESRCH;
234 }
235 get_task_struct(first);
236 read_unlock(&tasklist_lock);
237 } else
238 get_task_struct(first);
239 230
240 /* Start with stats from dead tasks */ 231 if (!first || !lock_task_sighand(first, &flags))
241 spin_lock_irqsave(&first->signal->stats_lock, flags); 232 goto out;
233
242 if (first->signal->stats) 234 if (first->signal->stats)
243 memcpy(stats, first->signal->stats, sizeof(*stats)); 235 memcpy(stats, first->signal->stats, sizeof(*stats));
244 spin_unlock_irqrestore(&first->signal->stats_lock, flags);
245 236
246 tsk = first; 237 tsk = first;
247 read_lock(&tasklist_lock);
248 do { 238 do {
249 if (tsk->exit_state == EXIT_ZOMBIE && thread_group_leader(tsk)) 239 if (tsk->exit_state)
250 continue; 240 continue;
251 /* 241 /*
252 * Accounting subsystem can call its functions here to 242 * Accounting subsystem can call its functions here to
@@ -257,15 +247,18 @@ static int fill_tgid(pid_t tgid, struct task_struct *tgidtsk,
257 delayacct_add_tsk(stats, tsk); 247 delayacct_add_tsk(stats, tsk);
258 248
259 } while_each_thread(first, tsk); 249 } while_each_thread(first, tsk);
260 read_unlock(&tasklist_lock);
261 stats->version = TASKSTATS_VERSION;
262 250
251 unlock_task_sighand(first, &flags);
252 rc = 0;
253out:
254 rcu_read_unlock();
255
256 stats->version = TASKSTATS_VERSION;
263 /* 257 /*
264 * Accounting subsytems can also add calls here to modify 258 * Accounting subsytems can also add calls here to modify
265 * fields of taskstats. 259 * fields of taskstats.
266 */ 260 */
267 261 return rc;
268 return 0;
269} 262}
270 263
271 264
@@ -273,7 +266,7 @@ static void fill_tgid_exit(struct task_struct *tsk)
273{ 266{
274 unsigned long flags; 267 unsigned long flags;
275 268
276 spin_lock_irqsave(&tsk->signal->stats_lock, flags); 269 spin_lock_irqsave(&tsk->sighand->siglock, flags);
277 if (!tsk->signal->stats) 270 if (!tsk->signal->stats)
278 goto ret; 271 goto ret;
279 272
@@ -285,7 +278,7 @@ static void fill_tgid_exit(struct task_struct *tsk)
285 */ 278 */
286 delayacct_add_tsk(tsk->signal->stats, tsk); 279 delayacct_add_tsk(tsk->signal->stats, tsk);
287ret: 280ret:
288 spin_unlock_irqrestore(&tsk->signal->stats_lock, flags); 281 spin_unlock_irqrestore(&tsk->sighand->siglock, flags);
289 return; 282 return;
290} 283}
291 284
@@ -419,7 +412,7 @@ static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
419 return send_reply(rep_skb, info->snd_pid); 412 return send_reply(rep_skb, info->snd_pid);
420 413
421nla_put_failure: 414nla_put_failure:
422 return genlmsg_cancel(rep_skb, reply); 415 rc = genlmsg_cancel(rep_skb, reply);
423err: 416err:
424 nlmsg_free(rep_skb); 417 nlmsg_free(rep_skb);
425 return rc; 418 return rc;
@@ -461,24 +454,26 @@ void taskstats_exit_send(struct task_struct *tsk, struct taskstats *tidstats,
461 size_t size; 454 size_t size;
462 int is_thread_group; 455 int is_thread_group;
463 struct nlattr *na; 456 struct nlattr *na;
464 unsigned long flags;
465 457
466 if (!family_registered || !tidstats) 458 if (!family_registered)
467 return; 459 return;
468 460
469 spin_lock_irqsave(&tsk->signal->stats_lock, flags);
470 is_thread_group = tsk->signal->stats ? 1 : 0;
471 spin_unlock_irqrestore(&tsk->signal->stats_lock, flags);
472
473 rc = 0;
474 /* 461 /*
475 * Size includes space for nested attributes 462 * Size includes space for nested attributes
476 */ 463 */
477 size = nla_total_size(sizeof(u32)) + 464 size = nla_total_size(sizeof(u32)) +
478 nla_total_size(sizeof(struct taskstats)) + nla_total_size(0); 465 nla_total_size(sizeof(struct taskstats)) + nla_total_size(0);
479 466
480 if (is_thread_group) 467 is_thread_group = (tsk->signal->stats != NULL);
481 size = 2 * size; /* PID + STATS + TGID + STATS */ 468 if (is_thread_group) {
469 /* PID + STATS + TGID + STATS */
470 size = 2 * size;
471 /* fill the tsk->signal->stats structure */
472 fill_tgid_exit(tsk);
473 }
474
475 if (!tidstats)
476 return;
482 477
483 rc = prepare_reply(NULL, TASKSTATS_CMD_NEW, &rep_skb, &reply, size); 478 rc = prepare_reply(NULL, TASKSTATS_CMD_NEW, &rep_skb, &reply, size);
484 if (rc < 0) 479 if (rc < 0)
@@ -498,11 +493,8 @@ void taskstats_exit_send(struct task_struct *tsk, struct taskstats *tidstats,
498 goto send; 493 goto send;
499 494
500 /* 495 /*
501 * tsk has/had a thread group so fill the tsk->signal->stats structure
502 * Doesn't matter if tsk is the leader or the last group member leaving 496 * Doesn't matter if tsk is the leader or the last group member leaving
503 */ 497 */
504
505 fill_tgid_exit(tsk);
506 if (!group_dead) 498 if (!group_dead)
507 goto send; 499 goto send;
508 500
@@ -519,7 +511,6 @@ send:
519 511
520nla_put_failure: 512nla_put_failure:
521 genlmsg_cancel(rep_skb, reply); 513 genlmsg_cancel(rep_skb, reply);
522 goto ret;
523err_skb: 514err_skb:
524 nlmsg_free(rep_skb); 515 nlmsg_free(rep_skb);
525ret: 516ret:
diff --git a/kernel/time/jiffies.c b/kernel/time/jiffies.c
index 126bb30c4afe..a99b2a6e6a07 100644
--- a/kernel/time/jiffies.c
+++ b/kernel/time/jiffies.c
@@ -57,7 +57,7 @@ static cycle_t jiffies_read(void)
57 57
58struct clocksource clocksource_jiffies = { 58struct clocksource clocksource_jiffies = {
59 .name = "jiffies", 59 .name = "jiffies",
60 .rating = 0, /* lowest rating*/ 60 .rating = 1, /* lowest valid rating*/
61 .read = jiffies_read, 61 .read = jiffies_read,
62 .mask = 0xffffffff, /*32bits*/ 62 .mask = 0xffffffff, /*32bits*/
63 .mult = NSEC_PER_JIFFY << JIFFIES_SHIFT, /* details above */ 63 .mult = NSEC_PER_JIFFY << JIFFIES_SHIFT, /* details above */
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index 47195fa0ec4f..3afeaa3a73f9 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -161,9 +161,9 @@ void second_overflow(void)
161 time_adjust += MAX_TICKADJ; 161 time_adjust += MAX_TICKADJ;
162 tick_length -= MAX_TICKADJ_SCALED; 162 tick_length -= MAX_TICKADJ_SCALED;
163 } else { 163 } else {
164 time_adjust = 0;
165 tick_length += (s64)(time_adjust * NSEC_PER_USEC / 164 tick_length += (s64)(time_adjust * NSEC_PER_USEC /
166 HZ) << TICK_LENGTH_SHIFT; 165 HZ) << TICK_LENGTH_SHIFT;
166 time_adjust = 0;
167 } 167 }
168 } 168 }
169} 169}
diff --git a/kernel/tsacct.c b/kernel/tsacct.c
index db443221ba5b..96f77013d3f0 100644
--- a/kernel/tsacct.c
+++ b/kernel/tsacct.c
@@ -36,7 +36,7 @@ void bacct_add_tsk(struct taskstats *stats, struct task_struct *tsk)
36 36
37 /* calculate task elapsed time in timespec */ 37 /* calculate task elapsed time in timespec */
38 do_posix_clock_monotonic_gettime(&uptime); 38 do_posix_clock_monotonic_gettime(&uptime);
39 ts = timespec_sub(uptime, current->group_leader->start_time); 39 ts = timespec_sub(uptime, tsk->start_time);
40 /* rebase elapsed time to usec */ 40 /* rebase elapsed time to usec */
41 ac_etime = timespec_to_ns(&ts); 41 ac_etime = timespec_to_ns(&ts);
42 do_div(ac_etime, NSEC_PER_USEC); 42 do_div(ac_etime, NSEC_PER_USEC);
@@ -58,7 +58,10 @@ void bacct_add_tsk(struct taskstats *stats, struct task_struct *tsk)
58 stats->ac_uid = tsk->uid; 58 stats->ac_uid = tsk->uid;
59 stats->ac_gid = tsk->gid; 59 stats->ac_gid = tsk->gid;
60 stats->ac_pid = tsk->pid; 60 stats->ac_pid = tsk->pid;
61 stats->ac_ppid = (tsk->parent) ? tsk->parent->pid : 0; 61 rcu_read_lock();
62 stats->ac_ppid = pid_alive(tsk) ?
63 rcu_dereference(tsk->real_parent)->tgid : 0;
64 rcu_read_unlock();
62 stats->ac_utime = cputime_to_msecs(tsk->utime) * USEC_PER_MSEC; 65 stats->ac_utime = cputime_to_msecs(tsk->utime) * USEC_PER_MSEC;
63 stats->ac_stime = cputime_to_msecs(tsk->stime) * USEC_PER_MSEC; 66 stats->ac_stime = cputime_to_msecs(tsk->stime) * USEC_PER_MSEC;
64 stats->ac_minflt = tsk->min_flt; 67 stats->ac_minflt = tsk->min_flt;
@@ -77,13 +80,17 @@ void bacct_add_tsk(struct taskstats *stats, struct task_struct *tsk)
77 */ 80 */
78void xacct_add_tsk(struct taskstats *stats, struct task_struct *p) 81void xacct_add_tsk(struct taskstats *stats, struct task_struct *p)
79{ 82{
83 struct mm_struct *mm;
84
80 /* convert pages-jiffies to Mbyte-usec */ 85 /* convert pages-jiffies to Mbyte-usec */
81 stats->coremem = jiffies_to_usecs(p->acct_rss_mem1) * PAGE_SIZE / MB; 86 stats->coremem = jiffies_to_usecs(p->acct_rss_mem1) * PAGE_SIZE / MB;
82 stats->virtmem = jiffies_to_usecs(p->acct_vm_mem1) * PAGE_SIZE / MB; 87 stats->virtmem = jiffies_to_usecs(p->acct_vm_mem1) * PAGE_SIZE / MB;
83 if (p->mm) { 88 mm = get_task_mm(p);
89 if (mm) {
84 /* adjust to KB unit */ 90 /* adjust to KB unit */
85 stats->hiwater_rss = p->mm->hiwater_rss * PAGE_SIZE / KB; 91 stats->hiwater_rss = mm->hiwater_rss * PAGE_SIZE / KB;
86 stats->hiwater_vm = p->mm->hiwater_vm * PAGE_SIZE / KB; 92 stats->hiwater_vm = mm->hiwater_vm * PAGE_SIZE / KB;
93 mmput(mm);
87 } 94 }
88 stats->read_char = p->rchar; 95 stats->read_char = p->rchar;
89 stats->write_char = p->wchar; 96 stats->write_char = p->wchar;
diff --git a/kernel/unwind.c b/kernel/unwind.c
index 2e2368607aab..f7e50d16dbf6 100644
--- a/kernel/unwind.c
+++ b/kernel/unwind.c
@@ -11,13 +11,15 @@
11 11
12#include <linux/unwind.h> 12#include <linux/unwind.h>
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/delay.h> 14#include <linux/bootmem.h>
15#include <linux/sort.h>
15#include <linux/stop_machine.h> 16#include <linux/stop_machine.h>
16#include <asm/sections.h> 17#include <asm/sections.h>
17#include <asm/uaccess.h> 18#include <asm/uaccess.h>
18#include <asm/unaligned.h> 19#include <asm/unaligned.h>
19 20
20extern char __start_unwind[], __end_unwind[]; 21extern char __start_unwind[], __end_unwind[];
22extern const u8 __start_unwind_hdr[], __end_unwind_hdr[];
21 23
22#define MAX_STACK_DEPTH 8 24#define MAX_STACK_DEPTH 8
23 25
@@ -100,6 +102,8 @@ static struct unwind_table {
100 } core, init; 102 } core, init;
101 const void *address; 103 const void *address;
102 unsigned long size; 104 unsigned long size;
105 const unsigned char *header;
106 unsigned long hdrsz;
103 struct unwind_table *link; 107 struct unwind_table *link;
104 const char *name; 108 const char *name;
105} root_table; 109} root_table;
@@ -145,6 +149,10 @@ static struct unwind_table *find_table(unsigned long pc)
145 return table; 149 return table;
146} 150}
147 151
152static unsigned long read_pointer(const u8 **pLoc,
153 const void *end,
154 signed ptrType);
155
148static void init_unwind_table(struct unwind_table *table, 156static void init_unwind_table(struct unwind_table *table,
149 const char *name, 157 const char *name,
150 const void *core_start, 158 const void *core_start,
@@ -152,14 +160,30 @@ static void init_unwind_table(struct unwind_table *table,
152 const void *init_start, 160 const void *init_start,
153 unsigned long init_size, 161 unsigned long init_size,
154 const void *table_start, 162 const void *table_start,
155 unsigned long table_size) 163 unsigned long table_size,
164 const u8 *header_start,
165 unsigned long header_size)
156{ 166{
167 const u8 *ptr = header_start + 4;
168 const u8 *end = header_start + header_size;
169
157 table->core.pc = (unsigned long)core_start; 170 table->core.pc = (unsigned long)core_start;
158 table->core.range = core_size; 171 table->core.range = core_size;
159 table->init.pc = (unsigned long)init_start; 172 table->init.pc = (unsigned long)init_start;
160 table->init.range = init_size; 173 table->init.range = init_size;
161 table->address = table_start; 174 table->address = table_start;
162 table->size = table_size; 175 table->size = table_size;
176 /* See if the linker provided table looks valid. */
177 if (header_size <= 4
178 || header_start[0] != 1
179 || (void *)read_pointer(&ptr, end, header_start[1]) != table_start
180 || header_start[2] == DW_EH_PE_omit
181 || read_pointer(&ptr, end, header_start[2]) <= 0
182 || header_start[3] == DW_EH_PE_omit)
183 header_start = NULL;
184 table->hdrsz = header_size;
185 smp_wmb();
186 table->header = header_start;
163 table->link = NULL; 187 table->link = NULL;
164 table->name = name; 188 table->name = name;
165} 189}
@@ -169,7 +193,143 @@ void __init unwind_init(void)
169 init_unwind_table(&root_table, "kernel", 193 init_unwind_table(&root_table, "kernel",
170 _text, _end - _text, 194 _text, _end - _text,
171 NULL, 0, 195 NULL, 0,
172 __start_unwind, __end_unwind - __start_unwind); 196 __start_unwind, __end_unwind - __start_unwind,
197 __start_unwind_hdr, __end_unwind_hdr - __start_unwind_hdr);
198}
199
200static const u32 bad_cie, not_fde;
201static const u32 *cie_for_fde(const u32 *fde, const struct unwind_table *);
202static signed fde_pointer_type(const u32 *cie);
203
204struct eh_frame_hdr_table_entry {
205 unsigned long start, fde;
206};
207
208static int cmp_eh_frame_hdr_table_entries(const void *p1, const void *p2)
209{
210 const struct eh_frame_hdr_table_entry *e1 = p1;
211 const struct eh_frame_hdr_table_entry *e2 = p2;
212
213 return (e1->start > e2->start) - (e1->start < e2->start);
214}
215
216static void swap_eh_frame_hdr_table_entries(void *p1, void *p2, int size)
217{
218 struct eh_frame_hdr_table_entry *e1 = p1;
219 struct eh_frame_hdr_table_entry *e2 = p2;
220 unsigned long v;
221
222 v = e1->start;
223 e1->start = e2->start;
224 e2->start = v;
225 v = e1->fde;
226 e1->fde = e2->fde;
227 e2->fde = v;
228}
229
230static void __init setup_unwind_table(struct unwind_table *table,
231 void *(*alloc)(unsigned long))
232{
233 const u8 *ptr;
234 unsigned long tableSize = table->size, hdrSize;
235 unsigned n;
236 const u32 *fde;
237 struct {
238 u8 version;
239 u8 eh_frame_ptr_enc;
240 u8 fde_count_enc;
241 u8 table_enc;
242 unsigned long eh_frame_ptr;
243 unsigned int fde_count;
244 struct eh_frame_hdr_table_entry table[];
245 } __attribute__((__packed__)) *header;
246
247 if (table->header)
248 return;
249
250 if (table->hdrsz)
251 printk(KERN_WARNING ".eh_frame_hdr for '%s' present but unusable\n",
252 table->name);
253
254 if (tableSize & (sizeof(*fde) - 1))
255 return;
256
257 for (fde = table->address, n = 0;
258 tableSize > sizeof(*fde) && tableSize - sizeof(*fde) >= *fde;
259 tableSize -= sizeof(*fde) + *fde, fde += 1 + *fde / sizeof(*fde)) {
260 const u32 *cie = cie_for_fde(fde, table);
261 signed ptrType;
262
263 if (cie == &not_fde)
264 continue;
265 if (cie == NULL
266 || cie == &bad_cie
267 || (ptrType = fde_pointer_type(cie)) < 0)
268 return;
269 ptr = (const u8 *)(fde + 2);
270 if (!read_pointer(&ptr,
271 (const u8 *)(fde + 1) + *fde,
272 ptrType))
273 return;
274 ++n;
275 }
276
277 if (tableSize || !n)
278 return;
279
280 hdrSize = 4 + sizeof(unsigned long) + sizeof(unsigned int)
281 + 2 * n * sizeof(unsigned long);
282 header = alloc(hdrSize);
283 if (!header)
284 return;
285 header->version = 1;
286 header->eh_frame_ptr_enc = DW_EH_PE_abs|DW_EH_PE_native;
287 header->fde_count_enc = DW_EH_PE_abs|DW_EH_PE_data4;
288 header->table_enc = DW_EH_PE_abs|DW_EH_PE_native;
289 put_unaligned((unsigned long)table->address, &header->eh_frame_ptr);
290 BUILD_BUG_ON(offsetof(typeof(*header), fde_count)
291 % __alignof(typeof(header->fde_count)));
292 header->fde_count = n;
293
294 BUILD_BUG_ON(offsetof(typeof(*header), table)
295 % __alignof(typeof(*header->table)));
296 for (fde = table->address, tableSize = table->size, n = 0;
297 tableSize;
298 tableSize -= sizeof(*fde) + *fde, fde += 1 + *fde / sizeof(*fde)) {
299 const u32 *cie = fde + 1 - fde[1] / sizeof(*fde);
300
301 if (!fde[1])
302 continue; /* this is a CIE */
303 ptr = (const u8 *)(fde + 2);
304 header->table[n].start = read_pointer(&ptr,
305 (const u8 *)(fde + 1) + *fde,
306 fde_pointer_type(cie));
307 header->table[n].fde = (unsigned long)fde;
308 ++n;
309 }
310 WARN_ON(n != header->fde_count);
311
312 sort(header->table,
313 n,
314 sizeof(*header->table),
315 cmp_eh_frame_hdr_table_entries,
316 swap_eh_frame_hdr_table_entries);
317
318 table->hdrsz = hdrSize;
319 smp_wmb();
320 table->header = (const void *)header;
321}
322
323static void *__init balloc(unsigned long sz)
324{
325 return __alloc_bootmem_nopanic(sz,
326 sizeof(unsigned int),
327 __pa(MAX_DMA_ADDRESS));
328}
329
330void __init unwind_setup(void)
331{
332 setup_unwind_table(&root_table, balloc);
173} 333}
174 334
175#ifdef CONFIG_MODULES 335#ifdef CONFIG_MODULES
@@ -193,7 +353,8 @@ void *unwind_add_table(struct module *module,
193 init_unwind_table(table, module->name, 353 init_unwind_table(table, module->name,
194 module->module_core, module->core_size, 354 module->module_core, module->core_size,
195 module->module_init, module->init_size, 355 module->module_init, module->init_size,
196 table_start, table_size); 356 table_start, table_size,
357 NULL, 0);
197 358
198 if (last_table) 359 if (last_table)
199 last_table->link = table; 360 last_table->link = table;
@@ -303,6 +464,26 @@ static sleb128_t get_sleb128(const u8 **pcur, const u8 *end)
303 return value; 464 return value;
304} 465}
305 466
467static const u32 *cie_for_fde(const u32 *fde, const struct unwind_table *table)
468{
469 const u32 *cie;
470
471 if (!*fde || (*fde & (sizeof(*fde) - 1)))
472 return &bad_cie;
473 if (!fde[1])
474 return &not_fde; /* this is a CIE */
475 if ((fde[1] & (sizeof(*fde) - 1))
476 || fde[1] > (unsigned long)(fde + 1) - (unsigned long)table->address)
477 return NULL; /* this is not a valid FDE */
478 cie = fde + 1 - fde[1] / sizeof(*fde);
479 if (*cie <= sizeof(*cie) + 4
480 || *cie >= fde[1] - sizeof(*fde)
481 || (*cie & (sizeof(*cie) - 1))
482 || cie[1])
483 return NULL; /* this is not a (valid) CIE */
484 return cie;
485}
486
306static unsigned long read_pointer(const u8 **pLoc, 487static unsigned long read_pointer(const u8 **pLoc,
307 const void *end, 488 const void *end,
308 signed ptrType) 489 signed ptrType)
@@ -610,49 +791,108 @@ int unwind(struct unwind_frame_info *frame)
610 unsigned i; 791 unsigned i;
611 signed ptrType = -1; 792 signed ptrType = -1;
612 uleb128_t retAddrReg = 0; 793 uleb128_t retAddrReg = 0;
613 struct unwind_table *table; 794 const struct unwind_table *table;
614 struct unwind_state state; 795 struct unwind_state state;
615 796
616 if (UNW_PC(frame) == 0) 797 if (UNW_PC(frame) == 0)
617 return -EINVAL; 798 return -EINVAL;
618 if ((table = find_table(pc)) != NULL 799 if ((table = find_table(pc)) != NULL
619 && !(table->size & (sizeof(*fde) - 1))) { 800 && !(table->size & (sizeof(*fde) - 1))) {
620 unsigned long tableSize = table->size; 801 const u8 *hdr = table->header;
621 802 unsigned long tableSize;
622 for (fde = table->address; 803
623 tableSize > sizeof(*fde) && tableSize - sizeof(*fde) >= *fde; 804 smp_rmb();
624 tableSize -= sizeof(*fde) + *fde, 805 if (hdr && hdr[0] == 1) {
625 fde += 1 + *fde / sizeof(*fde)) { 806 switch(hdr[3] & DW_EH_PE_FORM) {
626 if (!*fde || (*fde & (sizeof(*fde) - 1))) 807 case DW_EH_PE_native: tableSize = sizeof(unsigned long); break;
627 break; 808 case DW_EH_PE_data2: tableSize = 2; break;
628 if (!fde[1]) 809 case DW_EH_PE_data4: tableSize = 4; break;
629 continue; /* this is a CIE */ 810 case DW_EH_PE_data8: tableSize = 8; break;
630 if ((fde[1] & (sizeof(*fde) - 1)) 811 default: tableSize = 0; break;
631 || fde[1] > (unsigned long)(fde + 1) 812 }
632 - (unsigned long)table->address) 813 ptr = hdr + 4;
633 continue; /* this is not a valid FDE */ 814 end = hdr + table->hdrsz;
634 cie = fde + 1 - fde[1] / sizeof(*fde); 815 if (tableSize
635 if (*cie <= sizeof(*cie) + 4 816 && read_pointer(&ptr, end, hdr[1])
636 || *cie >= fde[1] - sizeof(*fde) 817 == (unsigned long)table->address
637 || (*cie & (sizeof(*cie) - 1)) 818 && (i = read_pointer(&ptr, end, hdr[2])) > 0
638 || cie[1] 819 && i == (end - ptr) / (2 * tableSize)
639 || (ptrType = fde_pointer_type(cie)) < 0) { 820 && !((end - ptr) % (2 * tableSize))) {
640 cie = NULL; /* this is not a (valid) CIE */ 821 do {
641 continue; 822 const u8 *cur = ptr + (i / 2) * (2 * tableSize);
823
824 startLoc = read_pointer(&cur,
825 cur + tableSize,
826 hdr[3]);
827 if (pc < startLoc)
828 i /= 2;
829 else {
830 ptr = cur - tableSize;
831 i = (i + 1) / 2;
832 }
833 } while (startLoc && i > 1);
834 if (i == 1
835 && (startLoc = read_pointer(&ptr,
836 ptr + tableSize,
837 hdr[3])) != 0
838 && pc >= startLoc)
839 fde = (void *)read_pointer(&ptr,
840 ptr + tableSize,
841 hdr[3]);
642 } 842 }
843 }
844
845 if (fde != NULL) {
846 cie = cie_for_fde(fde, table);
643 ptr = (const u8 *)(fde + 2); 847 ptr = (const u8 *)(fde + 2);
644 startLoc = read_pointer(&ptr, 848 if(cie != NULL
645 (const u8 *)(fde + 1) + *fde, 849 && cie != &bad_cie
646 ptrType); 850 && cie != &not_fde
647 endLoc = startLoc 851 && (ptrType = fde_pointer_type(cie)) >= 0
648 + read_pointer(&ptr, 852 && read_pointer(&ptr,
649 (const u8 *)(fde + 1) + *fde, 853 (const u8 *)(fde + 1) + *fde,
650 ptrType & DW_EH_PE_indirect 854 ptrType) == startLoc) {
651 ? ptrType 855 if (!(ptrType & DW_EH_PE_indirect))
652 : ptrType & (DW_EH_PE_FORM|DW_EH_PE_signed)); 856 ptrType &= DW_EH_PE_FORM|DW_EH_PE_signed;
653 if (pc >= startLoc && pc < endLoc) 857 endLoc = startLoc
654 break; 858 + read_pointer(&ptr,
655 cie = NULL; 859 (const u8 *)(fde + 1) + *fde,
860 ptrType);
861 if(pc >= endLoc)
862 fde = NULL;
863 } else
864 fde = NULL;
865 }
866 if (fde == NULL) {
867 for (fde = table->address, tableSize = table->size;
868 cie = NULL, tableSize > sizeof(*fde)
869 && tableSize - sizeof(*fde) >= *fde;
870 tableSize -= sizeof(*fde) + *fde,
871 fde += 1 + *fde / sizeof(*fde)) {
872 cie = cie_for_fde(fde, table);
873 if (cie == &bad_cie) {
874 cie = NULL;
875 break;
876 }
877 if (cie == NULL
878 || cie == &not_fde
879 || (ptrType = fde_pointer_type(cie)) < 0)
880 continue;
881 ptr = (const u8 *)(fde + 2);
882 startLoc = read_pointer(&ptr,
883 (const u8 *)(fde + 1) + *fde,
884 ptrType);
885 if (!startLoc)
886 continue;
887 if (!(ptrType & DW_EH_PE_indirect))
888 ptrType &= DW_EH_PE_FORM|DW_EH_PE_signed;
889 endLoc = startLoc
890 + read_pointer(&ptr,
891 (const u8 *)(fde + 1) + *fde,
892 ptrType);
893 if (pc >= startLoc && pc < endLoc)
894 break;
895 }
656 } 896 }
657 } 897 }
658 if (cie != NULL) { 898 if (cie != NULL) {
diff --git a/kernel/user.c b/kernel/user.c
index 6408c0424291..220e586127a0 100644
--- a/kernel/user.c
+++ b/kernel/user.c
@@ -187,6 +187,17 @@ void switch_uid(struct user_struct *new_user)
187 atomic_dec(&old_user->processes); 187 atomic_dec(&old_user->processes);
188 switch_uid_keyring(new_user); 188 switch_uid_keyring(new_user);
189 current->user = new_user; 189 current->user = new_user;
190
191 /*
192 * We need to synchronize with __sigqueue_alloc()
193 * doing a get_uid(p->user).. If that saw the old
194 * user value, we need to wait until it has exited
195 * its critical region before we can free the old
196 * structure.
197 */
198 smp_mb();
199 spin_unlock_wait(&current->sighand->siglock);
200
190 free_uid(old_user); 201 free_uid(old_user);
191 suid_keys(current); 202 suid_keys(current);
192} 203}
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index cfc737bffe6d..17c2f03d2c27 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -28,6 +28,7 @@
28#include <linux/notifier.h> 28#include <linux/notifier.h>
29#include <linux/kthread.h> 29#include <linux/kthread.h>
30#include <linux/hardirq.h> 30#include <linux/hardirq.h>
31#include <linux/mempolicy.h>
31 32
32/* 33/*
33 * The per-CPU workqueue (if single thread, we always use the first 34 * The per-CPU workqueue (if single thread, we always use the first
@@ -98,7 +99,7 @@ static void __queue_work(struct cpu_workqueue_struct *cwq,
98 * @wq: workqueue to use 99 * @wq: workqueue to use
99 * @work: work to queue 100 * @work: work to queue
100 * 101 *
101 * Returns non-zero if it was successfully added. 102 * Returns 0 if @work was already on a queue, non-zero otherwise.
102 * 103 *
103 * We queue the work to the CPU it was submitted, but there is no 104 * We queue the work to the CPU it was submitted, but there is no
104 * guarantee that it will be processed by that CPU. 105 * guarantee that it will be processed by that CPU.
@@ -137,7 +138,7 @@ static void delayed_work_timer_fn(unsigned long __data)
137 * @work: work to queue 138 * @work: work to queue
138 * @delay: number of jiffies to wait before queueing 139 * @delay: number of jiffies to wait before queueing
139 * 140 *
140 * Returns non-zero if it was successfully added. 141 * Returns 0 if @work was already on a queue, non-zero otherwise.
141 */ 142 */
142int fastcall queue_delayed_work(struct workqueue_struct *wq, 143int fastcall queue_delayed_work(struct workqueue_struct *wq,
143 struct work_struct *work, unsigned long delay) 144 struct work_struct *work, unsigned long delay)
@@ -168,7 +169,7 @@ EXPORT_SYMBOL_GPL(queue_delayed_work);
168 * @work: work to queue 169 * @work: work to queue
169 * @delay: number of jiffies to wait before queueing 170 * @delay: number of jiffies to wait before queueing
170 * 171 *
171 * Returns non-zero if it was successfully added. 172 * Returns 0 if @work was already on a queue, non-zero otherwise.
172 */ 173 */
173int queue_delayed_work_on(int cpu, struct workqueue_struct *wq, 174int queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
174 struct work_struct *work, unsigned long delay) 175 struct work_struct *work, unsigned long delay)
@@ -245,6 +246,12 @@ static int worker_thread(void *__cwq)
245 sigprocmask(SIG_BLOCK, &blocked, NULL); 246 sigprocmask(SIG_BLOCK, &blocked, NULL);
246 flush_signals(current); 247 flush_signals(current);
247 248
249 /*
250 * We inherited MPOL_INTERLEAVE from the booting kernel.
251 * Set MPOL_DEFAULT to insure node local allocations.
252 */
253 numa_default_policy();
254
248 /* SIG_IGN makes children autoreap: see do_notify_parent(). */ 255 /* SIG_IGN makes children autoreap: see do_notify_parent(). */
249 sa.sa.sa_handler = SIG_IGN; 256 sa.sa.sa_handler = SIG_IGN;
250 sa.sa.sa_flags = 0; 257 sa.sa.sa_flags = 0;
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 756a908c441d..d3679103a8e4 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -71,7 +71,7 @@ config LOG_BUF_SHIFT
71 71
72config DETECT_SOFTLOCKUP 72config DETECT_SOFTLOCKUP
73 bool "Detect Soft Lockups" 73 bool "Detect Soft Lockups"
74 depends on DEBUG_KERNEL 74 depends on DEBUG_KERNEL && !S390
75 default y 75 default y
76 help 76 help
77 Say Y here to enable the kernel to detect "soft lockups", 77 Say Y here to enable the kernel to detect "soft lockups",
@@ -341,7 +341,7 @@ config FRAME_POINTER
341 341
342config UNWIND_INFO 342config UNWIND_INFO
343 bool "Compile the kernel with frame unwind information" 343 bool "Compile the kernel with frame unwind information"
344 depends on !IA64 && !PARISC 344 depends on !IA64 && !PARISC && !ARM
345 depends on !MODULES || !(MIPS || PPC || SUPERH || V850) 345 depends on !MODULES || !(MIPS || PPC || SUPERH || V850)
346 help 346 help
347 If you say Y here the resulting kernel image will be slightly larger 347 If you say Y here the resulting kernel image will be slightly larger
@@ -371,6 +371,20 @@ config FORCED_INLINING
371 become the default in the future, until then this option is there to 371 become the default in the future, until then this option is there to
372 test gcc for this. 372 test gcc for this.
373 373
374config HEADERS_CHECK
375 bool "Run 'make headers_check' when building vmlinux"
376 depends on !UML
377 help
378 This option will extract the user-visible kernel headers whenever
379 building the kernel, and will run basic sanity checks on them to
380 ensure that exported files do not attempt to include files which
381 were not exported, etc.
382
383 If you're making modifications to header files which are
384 relevant for userspace, say 'Y', and check the headers
385 exported to $(INSTALL_HDR_PATH) (usually 'usr/include' in
386 your build tree), to make sure they're suitable.
387
374config RCU_TORTURE_TEST 388config RCU_TORTURE_TEST
375 tristate "torture tests for RCU" 389 tristate "torture tests for RCU"
376 depends on DEBUG_KERNEL 390 depends on DEBUG_KERNEL
diff --git a/lib/Makefile b/lib/Makefile
index 8e6662bb9c37..cf98fabaa549 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -12,7 +12,7 @@ lib-$(CONFIG_SMP) += cpumask.o
12 12
13lib-y += kobject.o kref.o kobject_uevent.o klist.o 13lib-y += kobject.o kref.o kobject_uevent.o klist.o
14 14
15obj-y += sort.o parser.o halfmd4.o iomap_copy.o debug_locks.o 15obj-y += sort.o parser.o halfmd4.o iomap_copy.o debug_locks.o random32.o
16 16
17ifeq ($(CONFIG_DEBUG_KOBJECT),y) 17ifeq ($(CONFIG_DEBUG_KOBJECT),y)
18CFLAGS_kobject.o += -DDEBUG 18CFLAGS_kobject.o += -DDEBUG
diff --git a/lib/bitmap.c b/lib/bitmap.c
index d71e38c54ea5..037fa9aa2ed7 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -316,10 +316,11 @@ int bitmap_scnprintf(char *buf, unsigned int buflen,
316EXPORT_SYMBOL(bitmap_scnprintf); 316EXPORT_SYMBOL(bitmap_scnprintf);
317 317
318/** 318/**
319 * bitmap_parse - convert an ASCII hex string into a bitmap. 319 * __bitmap_parse - convert an ASCII hex string into a bitmap.
320 * @ubuf: pointer to buffer in user space containing string. 320 * @buf: pointer to buffer containing string.
321 * @ubuflen: buffer size in bytes. If string is smaller than this 321 * @buflen: buffer size in bytes. If string is smaller than this
322 * then it must be terminated with a \0. 322 * then it must be terminated with a \0.
323 * @is_user: location of buffer, 0 indicates kernel space
323 * @maskp: pointer to bitmap array that will contain result. 324 * @maskp: pointer to bitmap array that will contain result.
324 * @nmaskbits: size of bitmap, in bits. 325 * @nmaskbits: size of bitmap, in bits.
325 * 326 *
@@ -330,11 +331,13 @@ EXPORT_SYMBOL(bitmap_scnprintf);
330 * characters and for grouping errors such as "1,,5", ",44", "," and "". 331 * characters and for grouping errors such as "1,,5", ",44", "," and "".
331 * Leading and trailing whitespace accepted, but not embedded whitespace. 332 * Leading and trailing whitespace accepted, but not embedded whitespace.
332 */ 333 */
333int bitmap_parse(const char __user *ubuf, unsigned int ubuflen, 334int __bitmap_parse(const char *buf, unsigned int buflen,
334 unsigned long *maskp, int nmaskbits) 335 int is_user, unsigned long *maskp,
336 int nmaskbits)
335{ 337{
336 int c, old_c, totaldigits, ndigits, nchunks, nbits; 338 int c, old_c, totaldigits, ndigits, nchunks, nbits;
337 u32 chunk; 339 u32 chunk;
340 const char __user *ubuf = buf;
338 341
339 bitmap_zero(maskp, nmaskbits); 342 bitmap_zero(maskp, nmaskbits);
340 343
@@ -343,11 +346,15 @@ int bitmap_parse(const char __user *ubuf, unsigned int ubuflen,
343 chunk = ndigits = 0; 346 chunk = ndigits = 0;
344 347
345 /* Get the next chunk of the bitmap */ 348 /* Get the next chunk of the bitmap */
346 while (ubuflen) { 349 while (buflen) {
347 old_c = c; 350 old_c = c;
348 if (get_user(c, ubuf++)) 351 if (is_user) {
349 return -EFAULT; 352 if (__get_user(c, ubuf++))
350 ubuflen--; 353 return -EFAULT;
354 }
355 else
356 c = *buf++;
357 buflen--;
351 if (isspace(c)) 358 if (isspace(c))
352 continue; 359 continue;
353 360
@@ -388,11 +395,36 @@ int bitmap_parse(const char __user *ubuf, unsigned int ubuflen,
388 nbits += (nchunks == 1) ? nbits_to_hold_value(chunk) : CHUNKSZ; 395 nbits += (nchunks == 1) ? nbits_to_hold_value(chunk) : CHUNKSZ;
389 if (nbits > nmaskbits) 396 if (nbits > nmaskbits)
390 return -EOVERFLOW; 397 return -EOVERFLOW;
391 } while (ubuflen && c == ','); 398 } while (buflen && c == ',');
392 399
393 return 0; 400 return 0;
394} 401}
395EXPORT_SYMBOL(bitmap_parse); 402EXPORT_SYMBOL(__bitmap_parse);
403
404/**
405 * bitmap_parse_user()
406 *
407 * @ubuf: pointer to user buffer containing string.
408 * @ulen: buffer size in bytes. If string is smaller than this
409 * then it must be terminated with a \0.
410 * @maskp: pointer to bitmap array that will contain result.
411 * @nmaskbits: size of bitmap, in bits.
412 *
413 * Wrapper for __bitmap_parse(), providing it with user buffer.
414 *
415 * We cannot have this as an inline function in bitmap.h because it needs
416 * linux/uaccess.h to get the access_ok() declaration and this causes
417 * cyclic dependencies.
418 */
419int bitmap_parse_user(const char __user *ubuf,
420 unsigned int ulen, unsigned long *maskp,
421 int nmaskbits)
422{
423 if (!access_ok(VERIFY_READ, ubuf, ulen))
424 return -EFAULT;
425 return __bitmap_parse((const char *)ubuf, ulen, 1, maskp, nmaskbits);
426}
427EXPORT_SYMBOL(bitmap_parse_user);
396 428
397/* 429/*
398 * bscnl_emit(buf, buflen, rbot, rtop, bp) 430 * bscnl_emit(buf, buflen, rbot, rtop, bp)
diff --git a/lib/cpumask.c b/lib/cpumask.c
index 7a2a73f88d59..3a67dc5ada7d 100644
--- a/lib/cpumask.c
+++ b/lib/cpumask.c
@@ -43,19 +43,3 @@ int __any_online_cpu(const cpumask_t *mask)
43 return cpu; 43 return cpu;
44} 44}
45EXPORT_SYMBOL(__any_online_cpu); 45EXPORT_SYMBOL(__any_online_cpu);
46
47#if MAX_NUMNODES > 1
48/*
49 * Find the highest possible node id.
50 */
51int highest_possible_node_id(void)
52{
53 unsigned int node;
54 unsigned int highest = 0;
55
56 for_each_node_mask(node, node_possible_map)
57 highest = node;
58 return highest;
59}
60EXPORT_SYMBOL(highest_possible_node_id);
61#endif
diff --git a/lib/kobject.c b/lib/kobject.c
index 1699eb9161f3..7dd5c0e9d996 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -119,6 +119,7 @@ char *kobject_get_path(struct kobject *kobj, gfp_t gfp_mask)
119 119
120 return path; 120 return path;
121} 121}
122EXPORT_SYMBOL_GPL(kobject_get_path);
122 123
123/** 124/**
124 * kobject_init - initialize object. 125 * kobject_init - initialize object.
diff --git a/lib/random32.c b/lib/random32.c
new file mode 100644
index 000000000000..4a15ce51cea7
--- /dev/null
+++ b/lib/random32.c
@@ -0,0 +1,142 @@
1/*
2 This is a maximally equidistributed combined Tausworthe generator
3 based on code from GNU Scientific Library 1.5 (30 Jun 2004)
4
5 x_n = (s1_n ^ s2_n ^ s3_n)
6
7 s1_{n+1} = (((s1_n & 4294967294) <<12) ^ (((s1_n <<13) ^ s1_n) >>19))
8 s2_{n+1} = (((s2_n & 4294967288) << 4) ^ (((s2_n << 2) ^ s2_n) >>25))
9 s3_{n+1} = (((s3_n & 4294967280) <<17) ^ (((s3_n << 3) ^ s3_n) >>11))
10
11 The period of this generator is about 2^88.
12
13 From: P. L'Ecuyer, "Maximally Equidistributed Combined Tausworthe
14 Generators", Mathematics of Computation, 65, 213 (1996), 203--213.
15
16 This is available on the net from L'Ecuyer's home page,
17
18 http://www.iro.umontreal.ca/~lecuyer/myftp/papers/tausme.ps
19 ftp://ftp.iro.umontreal.ca/pub/simulation/lecuyer/papers/tausme.ps
20
21 There is an erratum in the paper "Tables of Maximally
22 Equidistributed Combined LFSR Generators", Mathematics of
23 Computation, 68, 225 (1999), 261--269:
24 http://www.iro.umontreal.ca/~lecuyer/myftp/papers/tausme2.ps
25
26 ... the k_j most significant bits of z_j must be non-
27 zero, for each j. (Note: this restriction also applies to the
28 computer code given in [4], but was mistakenly not mentioned in
29 that paper.)
30
31 This affects the seeding procedure by imposing the requirement
32 s1 > 1, s2 > 7, s3 > 15.
33
34*/
35
36#include <linux/types.h>
37#include <linux/percpu.h>
38#include <linux/module.h>
39#include <linux/random.h>
40
41struct rnd_state {
42 u32 s1, s2, s3;
43};
44
45static DEFINE_PER_CPU(struct rnd_state, net_rand_state);
46
47static u32 __random32(struct rnd_state *state)
48{
49#define TAUSWORTHE(s,a,b,c,d) ((s&c)<<d) ^ (((s <<a) ^ s)>>b)
50
51 state->s1 = TAUSWORTHE(state->s1, 13, 19, 4294967294UL, 12);
52 state->s2 = TAUSWORTHE(state->s2, 2, 25, 4294967288UL, 4);
53 state->s3 = TAUSWORTHE(state->s3, 3, 11, 4294967280UL, 17);
54
55 return (state->s1 ^ state->s2 ^ state->s3);
56}
57
58static void __set_random32(struct rnd_state *state, unsigned long s)
59{
60 if (s == 0)
61 s = 1; /* default seed is 1 */
62
63#define LCG(n) (69069 * n)
64 state->s1 = LCG(s);
65 state->s2 = LCG(state->s1);
66 state->s3 = LCG(state->s2);
67
68 /* "warm it up" */
69 __random32(state);
70 __random32(state);
71 __random32(state);
72 __random32(state);
73 __random32(state);
74 __random32(state);
75}
76
77/**
78 * random32 - pseudo random number generator
79 *
80 * A 32 bit pseudo-random number is generated using a fast
81 * algorithm suitable for simulation. This algorithm is NOT
82 * considered safe for cryptographic use.
83 */
84u32 random32(void)
85{
86 unsigned long r;
87 struct rnd_state *state = &get_cpu_var(net_rand_state);
88 r = __random32(state);
89 put_cpu_var(state);
90 return r;
91}
92EXPORT_SYMBOL(random32);
93
94/**
95 * srandom32 - add entropy to pseudo random number generator
96 * @seed: seed value
97 *
98 * Add some additional seeding to the random32() pool.
99 * Note: this pool is per cpu so it only affects current CPU.
100 */
101void srandom32(u32 entropy)
102{
103 struct rnd_state *state = &get_cpu_var(net_rand_state);
104 __set_random32(state, state->s1 ^ entropy);
105 put_cpu_var(state);
106}
107EXPORT_SYMBOL(srandom32);
108
109/*
110 * Generate some initially weak seeding values to allow
111 * to start the random32() engine.
112 */
113static int __init random32_init(void)
114{
115 int i;
116
117 for_each_possible_cpu(i) {
118 struct rnd_state *state = &per_cpu(net_rand_state,i);
119 __set_random32(state, i + jiffies);
120 }
121 return 0;
122}
123core_initcall(random32_init);
124
125/*
126 * Generate better values after random number generator
127 * is fully initalized.
128 */
129static int __init random32_reseed(void)
130{
131 int i;
132 unsigned long seed;
133
134 for_each_possible_cpu(i) {
135 struct rnd_state *state = &per_cpu(net_rand_state,i);
136
137 get_random_bytes(&seed, sizeof(seed));
138 __set_random32(state, seed);
139 }
140 return 0;
141}
142late_initcall(random32_reseed);
diff --git a/lib/rwsem-spinlock.c b/lib/rwsem-spinlock.c
index db4fed74b940..c4cfd6c0342f 100644
--- a/lib/rwsem-spinlock.c
+++ b/lib/rwsem-spinlock.c
@@ -28,7 +28,7 @@ void __init_rwsem(struct rw_semaphore *sem, const char *name,
28 * Make sure we are not reinitializing a held semaphore: 28 * Make sure we are not reinitializing a held semaphore:
29 */ 29 */
30 debug_check_no_locks_freed((void *)sem, sizeof(*sem)); 30 debug_check_no_locks_freed((void *)sem, sizeof(*sem));
31 lockdep_init_map(&sem->dep_map, name, key); 31 lockdep_init_map(&sem->dep_map, name, key, 0);
32#endif 32#endif
33 sem->activity = 0; 33 sem->activity = 0;
34 spin_lock_init(&sem->wait_lock); 34 spin_lock_init(&sem->wait_lock);
diff --git a/lib/rwsem.c b/lib/rwsem.c
index 901d0e7da892..cdb4e3d05607 100644
--- a/lib/rwsem.c
+++ b/lib/rwsem.c
@@ -19,7 +19,7 @@ void __init_rwsem(struct rw_semaphore *sem, const char *name,
19 * Make sure we are not reinitializing a held semaphore: 19 * Make sure we are not reinitializing a held semaphore:
20 */ 20 */
21 debug_check_no_locks_freed((void *)sem, sizeof(*sem)); 21 debug_check_no_locks_freed((void *)sem, sizeof(*sem));
22 lockdep_init_map(&sem->dep_map, name, key); 22 lockdep_init_map(&sem->dep_map, name, key, 0);
23#endif 23#endif
24 sem->count = RWSEM_UNLOCKED_VALUE; 24 sem->count = RWSEM_UNLOCKED_VALUE;
25 spin_lock_init(&sem->wait_lock); 25 spin_lock_init(&sem->wait_lock);
diff --git a/lib/spinlock_debug.c b/lib/spinlock_debug.c
index dafaf1de2491..b6c4f898197c 100644
--- a/lib/spinlock_debug.c
+++ b/lib/spinlock_debug.c
@@ -20,7 +20,7 @@ void __spin_lock_init(spinlock_t *lock, const char *name,
20 * Make sure we are not reinitializing a held lock: 20 * Make sure we are not reinitializing a held lock:
21 */ 21 */
22 debug_check_no_locks_freed((void *)lock, sizeof(*lock)); 22 debug_check_no_locks_freed((void *)lock, sizeof(*lock));
23 lockdep_init_map(&lock->dep_map, name, key); 23 lockdep_init_map(&lock->dep_map, name, key, 0);
24#endif 24#endif
25 lock->raw_lock = (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED; 25 lock->raw_lock = (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED;
26 lock->magic = SPINLOCK_MAGIC; 26 lock->magic = SPINLOCK_MAGIC;
@@ -38,7 +38,7 @@ void __rwlock_init(rwlock_t *lock, const char *name,
38 * Make sure we are not reinitializing a held lock: 38 * Make sure we are not reinitializing a held lock:
39 */ 39 */
40 debug_check_no_locks_freed((void *)lock, sizeof(*lock)); 40 debug_check_no_locks_freed((void *)lock, sizeof(*lock));
41 lockdep_init_map(&lock->dep_map, name, key); 41 lockdep_init_map(&lock->dep_map, name, key, 0);
42#endif 42#endif
43 lock->raw_lock = (raw_rwlock_t) __RAW_RW_LOCK_UNLOCKED; 43 lock->raw_lock = (raw_rwlock_t) __RAW_RW_LOCK_UNLOCKED;
44 lock->magic = RWLOCK_MAGIC; 44 lock->magic = RWLOCK_MAGIC;
diff --git a/lib/string.c b/lib/string.c
index 63077267367e..a485d75962af 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -320,7 +320,7 @@ char *strstrip(char *s)
320 return s; 320 return s;
321 321
322 end = s + size - 1; 322 end = s + size - 1;
323 while (end != s && isspace(*end)) 323 while (end >= s && isspace(*end))
324 end--; 324 end--;
325 *(end + 1) = '\0'; 325 *(end + 1) = '\0';
326 326
diff --git a/mm/Makefile b/mm/Makefile
index 12b3a4eee88d..f3c077eb0b8e 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -10,7 +10,8 @@ mmu-$(CONFIG_MMU) := fremap.o highmem.o madvise.o memory.o mincore.o \
10obj-y := bootmem.o filemap.o mempool.o oom_kill.o fadvise.o \ 10obj-y := bootmem.o filemap.o mempool.o oom_kill.o fadvise.o \
11 page_alloc.o page-writeback.o pdflush.o \ 11 page_alloc.o page-writeback.o pdflush.o \
12 readahead.o swap.o truncate.o vmscan.o \ 12 readahead.o swap.o truncate.o vmscan.o \
13 prio_tree.o util.o mmzone.o vmstat.o $(mmu-y) 13 prio_tree.o util.o mmzone.o vmstat.o backing-dev.o \
14 $(mmu-y)
14 15
15ifeq ($(CONFIG_MMU)$(CONFIG_BLOCK),yy) 16ifeq ($(CONFIG_MMU)$(CONFIG_BLOCK),yy)
16obj-y += bounce.o 17obj-y += bounce.o
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
new file mode 100644
index 000000000000..f50a2811f9dc
--- /dev/null
+++ b/mm/backing-dev.c
@@ -0,0 +1,69 @@
1
2#include <linux/wait.h>
3#include <linux/backing-dev.h>
4#include <linux/fs.h>
5#include <linux/sched.h>
6#include <linux/module.h>
7
8static wait_queue_head_t congestion_wqh[2] = {
9 __WAIT_QUEUE_HEAD_INITIALIZER(congestion_wqh[0]),
10 __WAIT_QUEUE_HEAD_INITIALIZER(congestion_wqh[1])
11 };
12
13
14void clear_bdi_congested(struct backing_dev_info *bdi, int rw)
15{
16 enum bdi_state bit;
17 wait_queue_head_t *wqh = &congestion_wqh[rw];
18
19 bit = (rw == WRITE) ? BDI_write_congested : BDI_read_congested;
20 clear_bit(bit, &bdi->state);
21 smp_mb__after_clear_bit();
22 if (waitqueue_active(wqh))
23 wake_up(wqh);
24}
25EXPORT_SYMBOL(clear_bdi_congested);
26
27void set_bdi_congested(struct backing_dev_info *bdi, int rw)
28{
29 enum bdi_state bit;
30
31 bit = (rw == WRITE) ? BDI_write_congested : BDI_read_congested;
32 set_bit(bit, &bdi->state);
33}
34EXPORT_SYMBOL(set_bdi_congested);
35
36/**
37 * congestion_wait - wait for a backing_dev to become uncongested
38 * @rw: READ or WRITE
39 * @timeout: timeout in jiffies
40 *
41 * Waits for up to @timeout jiffies for a backing_dev (any backing_dev) to exit
42 * write congestion. If no backing_devs are congested then just wait for the
43 * next write to be completed.
44 */
45long congestion_wait(int rw, long timeout)
46{
47 long ret;
48 DEFINE_WAIT(wait);
49 wait_queue_head_t *wqh = &congestion_wqh[rw];
50
51 prepare_to_wait(wqh, &wait, TASK_UNINTERRUPTIBLE);
52 ret = io_schedule_timeout(timeout);
53 finish_wait(wqh, &wait);
54 return ret;
55}
56EXPORT_SYMBOL(congestion_wait);
57
58/**
59 * congestion_end - wake up sleepers on a congested backing_dev_info
60 * @rw: READ or WRITE
61 */
62void congestion_end(int rw)
63{
64 wait_queue_head_t *wqh = &congestion_wqh[rw];
65
66 if (waitqueue_active(wqh))
67 wake_up(wqh);
68}
69EXPORT_SYMBOL(congestion_end);
diff --git a/mm/filemap.c b/mm/filemap.c
index 3464b681f844..7b84dc814347 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -75,8 +75,8 @@ generic_file_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
75 * ->mmap_sem 75 * ->mmap_sem
76 * ->lock_page (access_process_vm) 76 * ->lock_page (access_process_vm)
77 * 77 *
78 * ->mmap_sem 78 * ->i_mutex (generic_file_buffered_write)
79 * ->i_mutex (msync) 79 * ->mmap_sem (fault_in_pages_readable->do_page_fault)
80 * 80 *
81 * ->i_mutex 81 * ->i_mutex
82 * ->i_alloc_sem (various) 82 * ->i_alloc_sem (various)
@@ -467,25 +467,15 @@ int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
467} 467}
468 468
469#ifdef CONFIG_NUMA 469#ifdef CONFIG_NUMA
470struct page *page_cache_alloc(struct address_space *x) 470struct page *__page_cache_alloc(gfp_t gfp)
471{ 471{
472 if (cpuset_do_page_mem_spread()) { 472 if (cpuset_do_page_mem_spread()) {
473 int n = cpuset_mem_spread_node(); 473 int n = cpuset_mem_spread_node();
474 return alloc_pages_node(n, mapping_gfp_mask(x), 0); 474 return alloc_pages_node(n, gfp, 0);
475 } 475 }
476 return alloc_pages(mapping_gfp_mask(x), 0); 476 return alloc_pages(gfp, 0);
477} 477}
478EXPORT_SYMBOL(page_cache_alloc); 478EXPORT_SYMBOL(__page_cache_alloc);
479
480struct page *page_cache_alloc_cold(struct address_space *x)
481{
482 if (cpuset_do_page_mem_spread()) {
483 int n = cpuset_mem_spread_node();
484 return alloc_pages_node(n, mapping_gfp_mask(x)|__GFP_COLD, 0);
485 }
486 return alloc_pages(mapping_gfp_mask(x)|__GFP_COLD, 0);
487}
488EXPORT_SYMBOL(page_cache_alloc_cold);
489#endif 479#endif
490 480
491static int __sleep_on_page_lock(void *word) 481static int __sleep_on_page_lock(void *word)
@@ -826,7 +816,6 @@ struct page *
826grab_cache_page_nowait(struct address_space *mapping, unsigned long index) 816grab_cache_page_nowait(struct address_space *mapping, unsigned long index)
827{ 817{
828 struct page *page = find_get_page(mapping, index); 818 struct page *page = find_get_page(mapping, index);
829 gfp_t gfp_mask;
830 819
831 if (page) { 820 if (page) {
832 if (!TestSetPageLocked(page)) 821 if (!TestSetPageLocked(page))
@@ -834,9 +823,8 @@ grab_cache_page_nowait(struct address_space *mapping, unsigned long index)
834 page_cache_release(page); 823 page_cache_release(page);
835 return NULL; 824 return NULL;
836 } 825 }
837 gfp_mask = mapping_gfp_mask(mapping) & ~__GFP_FS; 826 page = __page_cache_alloc(mapping_gfp_mask(mapping) & ~__GFP_FS);
838 page = alloc_pages(gfp_mask, 0); 827 if (page && add_to_page_cache_lru(page, mapping, index, GFP_KERNEL)) {
839 if (page && add_to_page_cache_lru(page, mapping, index, gfp_mask)) {
840 page_cache_release(page); 828 page_cache_release(page);
841 page = NULL; 829 page = NULL;
842 } 830 }
@@ -1884,11 +1872,10 @@ repeat:
1884 * if suid or (sgid and xgrp) 1872 * if suid or (sgid and xgrp)
1885 * remove privs 1873 * remove privs
1886 */ 1874 */
1887int remove_suid(struct dentry *dentry) 1875int should_remove_suid(struct dentry *dentry)
1888{ 1876{
1889 mode_t mode = dentry->d_inode->i_mode; 1877 mode_t mode = dentry->d_inode->i_mode;
1890 int kill = 0; 1878 int kill = 0;
1891 int result = 0;
1892 1879
1893 /* suid always must be killed */ 1880 /* suid always must be killed */
1894 if (unlikely(mode & S_ISUID)) 1881 if (unlikely(mode & S_ISUID))
@@ -1901,13 +1888,28 @@ int remove_suid(struct dentry *dentry)
1901 if (unlikely((mode & S_ISGID) && (mode & S_IXGRP))) 1888 if (unlikely((mode & S_ISGID) && (mode & S_IXGRP)))
1902 kill |= ATTR_KILL_SGID; 1889 kill |= ATTR_KILL_SGID;
1903 1890
1904 if (unlikely(kill && !capable(CAP_FSETID))) { 1891 if (unlikely(kill && !capable(CAP_FSETID)))
1905 struct iattr newattrs; 1892 return kill;
1906 1893
1907 newattrs.ia_valid = ATTR_FORCE | kill; 1894 return 0;
1908 result = notify_change(dentry, &newattrs); 1895}
1909 } 1896
1910 return result; 1897int __remove_suid(struct dentry *dentry, int kill)
1898{
1899 struct iattr newattrs;
1900
1901 newattrs.ia_valid = ATTR_FORCE | kill;
1902 return notify_change(dentry, &newattrs);
1903}
1904
1905int remove_suid(struct dentry *dentry)
1906{
1907 int kill = should_remove_suid(dentry);
1908
1909 if (unlikely(kill))
1910 return __remove_suid(dentry, kill);
1911
1912 return 0;
1911} 1913}
1912EXPORT_SYMBOL(remove_suid); 1914EXPORT_SYMBOL(remove_suid);
1913 1915
@@ -2222,7 +2224,7 @@ __generic_file_aio_write_nolock(struct kiocb *iocb, const struct iovec *iov,
2222 unsigned long nr_segs, loff_t *ppos) 2224 unsigned long nr_segs, loff_t *ppos)
2223{ 2225{
2224 struct file *file = iocb->ki_filp; 2226 struct file *file = iocb->ki_filp;
2225 const struct address_space * mapping = file->f_mapping; 2227 struct address_space * mapping = file->f_mapping;
2226 size_t ocount; /* original count */ 2228 size_t ocount; /* original count */
2227 size_t count; /* after file limit checks */ 2229 size_t count; /* after file limit checks */
2228 struct inode *inode = mapping->host; 2230 struct inode *inode = mapping->host;
@@ -2275,8 +2277,11 @@ __generic_file_aio_write_nolock(struct kiocb *iocb, const struct iovec *iov,
2275 2277
2276 /* coalesce the iovecs and go direct-to-BIO for O_DIRECT */ 2278 /* coalesce the iovecs and go direct-to-BIO for O_DIRECT */
2277 if (unlikely(file->f_flags & O_DIRECT)) { 2279 if (unlikely(file->f_flags & O_DIRECT)) {
2278 written = generic_file_direct_write(iocb, iov, 2280 loff_t endbyte;
2279 &nr_segs, pos, ppos, count, ocount); 2281 ssize_t written_buffered;
2282
2283 written = generic_file_direct_write(iocb, iov, &nr_segs, pos,
2284 ppos, count, ocount);
2280 if (written < 0 || written == count) 2285 if (written < 0 || written == count)
2281 goto out; 2286 goto out;
2282 /* 2287 /*
@@ -2285,10 +2290,46 @@ __generic_file_aio_write_nolock(struct kiocb *iocb, const struct iovec *iov,
2285 */ 2290 */
2286 pos += written; 2291 pos += written;
2287 count -= written; 2292 count -= written;
2288 } 2293 written_buffered = generic_file_buffered_write(iocb, iov,
2294 nr_segs, pos, ppos, count,
2295 written);
2296 /*
2297 * If generic_file_buffered_write() retuned a synchronous error
2298 * then we want to return the number of bytes which were
2299 * direct-written, or the error code if that was zero. Note
2300 * that this differs from normal direct-io semantics, which
2301 * will return -EFOO even if some bytes were written.
2302 */
2303 if (written_buffered < 0) {
2304 err = written_buffered;
2305 goto out;
2306 }
2289 2307
2290 written = generic_file_buffered_write(iocb, iov, nr_segs, 2308 /*
2291 pos, ppos, count, written); 2309 * We need to ensure that the page cache pages are written to
2310 * disk and invalidated to preserve the expected O_DIRECT
2311 * semantics.
2312 */
2313 endbyte = pos + written_buffered - written - 1;
2314 err = do_sync_file_range(file, pos, endbyte,
2315 SYNC_FILE_RANGE_WAIT_BEFORE|
2316 SYNC_FILE_RANGE_WRITE|
2317 SYNC_FILE_RANGE_WAIT_AFTER);
2318 if (err == 0) {
2319 written = written_buffered;
2320 invalidate_mapping_pages(mapping,
2321 pos >> PAGE_CACHE_SHIFT,
2322 endbyte >> PAGE_CACHE_SHIFT);
2323 } else {
2324 /*
2325 * We don't know how much we wrote, so just return
2326 * the number of bytes which were direct-written
2327 */
2328 }
2329 } else {
2330 written = generic_file_buffered_write(iocb, iov, nr_segs,
2331 pos, ppos, count, written);
2332 }
2292out: 2333out:
2293 current->backing_dev_info = NULL; 2334 current->backing_dev_info = NULL;
2294 return written ? written : err; 2335 return written ? written : err;
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 1d709ff528e1..a088f593a807 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -356,8 +356,8 @@ nomem:
356 return -ENOMEM; 356 return -ENOMEM;
357} 357}
358 358
359void unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start, 359void __unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start,
360 unsigned long end) 360 unsigned long end)
361{ 361{
362 struct mm_struct *mm = vma->vm_mm; 362 struct mm_struct *mm = vma->vm_mm;
363 unsigned long address; 363 unsigned long address;
@@ -398,6 +398,24 @@ void unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start,
398 } 398 }
399} 399}
400 400
401void unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start,
402 unsigned long end)
403{
404 /*
405 * It is undesirable to test vma->vm_file as it should be non-null
406 * for valid hugetlb area. However, vm_file will be NULL in the error
407 * cleanup path of do_mmap_pgoff. When hugetlbfs ->mmap method fails,
408 * do_mmap_pgoff() nullifies vma->vm_file before calling this function
409 * to clean up. Since no pte has actually been setup, it is safe to
410 * do nothing in this case.
411 */
412 if (vma->vm_file) {
413 spin_lock(&vma->vm_file->f_mapping->i_mmap_lock);
414 __unmap_hugepage_range(vma, start, end);
415 spin_unlock(&vma->vm_file->f_mapping->i_mmap_lock);
416 }
417}
418
401static int hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma, 419static int hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma,
402 unsigned long address, pte_t *ptep, pte_t pte) 420 unsigned long address, pte_t *ptep, pte_t pte)
403{ 421{
@@ -460,6 +478,9 @@ int hugetlb_no_page(struct mm_struct *mm, struct vm_area_struct *vma,
460retry: 478retry:
461 page = find_lock_page(mapping, idx); 479 page = find_lock_page(mapping, idx);
462 if (!page) { 480 if (!page) {
481 size = i_size_read(mapping->host) >> HPAGE_SHIFT;
482 if (idx >= size)
483 goto out;
463 if (hugetlb_get_quota(mapping)) 484 if (hugetlb_get_quota(mapping))
464 goto out; 485 goto out;
465 page = alloc_huge_page(vma, address); 486 page = alloc_huge_page(vma, address);
diff --git a/mm/memory.c b/mm/memory.c
index b5a4aadd961a..156861fcac43 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1452,6 +1452,7 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
1452 if (__copy_from_user_inatomic(kaddr, uaddr, PAGE_SIZE)) 1452 if (__copy_from_user_inatomic(kaddr, uaddr, PAGE_SIZE))
1453 memset(kaddr, 0, PAGE_SIZE); 1453 memset(kaddr, 0, PAGE_SIZE);
1454 kunmap_atomic(kaddr, KM_USER0); 1454 kunmap_atomic(kaddr, KM_USER0);
1455 flush_dcache_page(dst);
1455 return; 1456 return;
1456 1457
1457 } 1458 }
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 25788b1b7fcf..617fb31086ee 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -727,7 +727,7 @@ int do_migrate_pages(struct mm_struct *mm,
727 return -ENOSYS; 727 return -ENOSYS;
728} 728}
729 729
730static struct page *new_vma_page(struct page *page, unsigned long private) 730static struct page *new_vma_page(struct page *page, unsigned long private, int **x)
731{ 731{
732 return NULL; 732 return NULL;
733} 733}
diff --git a/mm/migrate.c b/mm/migrate.c
index ba2453f9483d..b4979d423d2b 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -952,7 +952,8 @@ asmlinkage long sys_move_pages(pid_t pid, unsigned long nr_pages,
952 goto out; 952 goto out;
953 953
954 pm[i].node = node; 954 pm[i].node = node;
955 } 955 } else
956 pm[i].node = 0; /* anything to not match MAX_NUMNODES */
956 } 957 }
957 /* End marker */ 958 /* End marker */
958 pm[nr_pages].node = MAX_NUMNODES; 959 pm[nr_pages].node = MAX_NUMNODES;
diff --git a/mm/mmap.c b/mm/mmap.c
index eea8eefd51a8..7b40abd7cba2 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -900,17 +900,6 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,
900 int accountable = 1; 900 int accountable = 1;
901 unsigned long charged = 0, reqprot = prot; 901 unsigned long charged = 0, reqprot = prot;
902 902
903 if (file) {
904 if (is_file_hugepages(file))
905 accountable = 0;
906
907 if (!file->f_op || !file->f_op->mmap)
908 return -ENODEV;
909
910 if ((prot & PROT_EXEC) &&
911 (file->f_vfsmnt->mnt_flags & MNT_NOEXEC))
912 return -EPERM;
913 }
914 /* 903 /*
915 * Does the application expect PROT_READ to imply PROT_EXEC? 904 * Does the application expect PROT_READ to imply PROT_EXEC?
916 * 905 *
@@ -1000,6 +989,16 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,
1000 case MAP_PRIVATE: 989 case MAP_PRIVATE:
1001 if (!(file->f_mode & FMODE_READ)) 990 if (!(file->f_mode & FMODE_READ))
1002 return -EACCES; 991 return -EACCES;
992 if (file->f_vfsmnt->mnt_flags & MNT_NOEXEC) {
993 if (vm_flags & VM_EXEC)
994 return -EPERM;
995 vm_flags &= ~VM_MAYEXEC;
996 }
997 if (is_file_hugepages(file))
998 accountable = 0;
999
1000 if (!file->f_op || !file->f_op->mmap)
1001 return -ENODEV;
1003 break; 1002 break;
1004 1003
1005 default: 1004 default:
@@ -1380,7 +1379,7 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
1380 * Check if the given range is hugepage aligned, and 1379 * Check if the given range is hugepage aligned, and
1381 * can be made suitable for hugepages. 1380 * can be made suitable for hugepages.
1382 */ 1381 */
1383 ret = prepare_hugepage_range(addr, len); 1382 ret = prepare_hugepage_range(addr, len, pgoff);
1384 } else { 1383 } else {
1385 /* 1384 /*
1386 * Ensure that a normal request is not falling in a 1385 * Ensure that a normal request is not falling in a
@@ -1881,6 +1880,9 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
1881 if ((addr + len) > TASK_SIZE || (addr + len) < addr) 1880 if ((addr + len) > TASK_SIZE || (addr + len) < addr)
1882 return -EINVAL; 1881 return -EINVAL;
1883 1882
1883 if (is_hugepage_only_range(mm, addr, len))
1884 return -EINVAL;
1885
1884 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags; 1886 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
1885 1887
1886 error = arch_mmap_check(addr, len, flags); 1888 error = arch_mmap_check(addr, len, flags);
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 20f41b082e16..2e3ce3a928b9 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -15,6 +15,7 @@
15 * kernel subsystems and hints as to where to find out what things do. 15 * kernel subsystems and hints as to where to find out what things do.
16 */ 16 */
17 17
18#include <linux/oom.h>
18#include <linux/mm.h> 19#include <linux/mm.h>
19#include <linux/sched.h> 20#include <linux/sched.h>
20#include <linux/swap.h> 21#include <linux/swap.h>
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index a0f339057449..8d9b19f239c3 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -222,7 +222,7 @@ static void balance_dirty_pages(struct address_space *mapping)
222 if (pages_written >= write_chunk) 222 if (pages_written >= write_chunk)
223 break; /* We've done our duty */ 223 break; /* We've done our duty */
224 } 224 }
225 blk_congestion_wait(WRITE, HZ/10); 225 congestion_wait(WRITE, HZ/10);
226 } 226 }
227 227
228 if (nr_reclaimable + global_page_state(NR_WRITEBACK) 228 if (nr_reclaimable + global_page_state(NR_WRITEBACK)
@@ -314,7 +314,7 @@ void throttle_vm_writeout(void)
314 if (global_page_state(NR_UNSTABLE_NFS) + 314 if (global_page_state(NR_UNSTABLE_NFS) +
315 global_page_state(NR_WRITEBACK) <= dirty_thresh) 315 global_page_state(NR_WRITEBACK) <= dirty_thresh)
316 break; 316 break;
317 blk_congestion_wait(WRITE, HZ/10); 317 congestion_wait(WRITE, HZ/10);
318 } 318 }
319} 319}
320 320
@@ -351,7 +351,7 @@ static void background_writeout(unsigned long _min_pages)
351 min_pages -= MAX_WRITEBACK_PAGES - wbc.nr_to_write; 351 min_pages -= MAX_WRITEBACK_PAGES - wbc.nr_to_write;
352 if (wbc.nr_to_write > 0 || wbc.pages_skipped > 0) { 352 if (wbc.nr_to_write > 0 || wbc.pages_skipped > 0) {
353 /* Wrote less than expected */ 353 /* Wrote less than expected */
354 blk_congestion_wait(WRITE, HZ/10); 354 congestion_wait(WRITE, HZ/10);
355 if (!wbc.encountered_congestion) 355 if (!wbc.encountered_congestion)
356 break; 356 break;
357 } 357 }
@@ -422,7 +422,7 @@ static void wb_kupdate(unsigned long arg)
422 writeback_inodes(&wbc); 422 writeback_inodes(&wbc);
423 if (wbc.nr_to_write > 0) { 423 if (wbc.nr_to_write > 0) {
424 if (wbc.encountered_congestion) 424 if (wbc.encountered_congestion)
425 blk_congestion_wait(WRITE, HZ/10); 425 congestion_wait(WRITE, HZ/10);
426 else 426 else
427 break; /* All the old data is written */ 427 break; /* All the old data is written */
428 } 428 }
@@ -956,15 +956,6 @@ int test_set_page_writeback(struct page *page)
956EXPORT_SYMBOL(test_set_page_writeback); 956EXPORT_SYMBOL(test_set_page_writeback);
957 957
958/* 958/*
959 * Wakes up tasks that are being throttled due to writeback congestion
960 */
961void writeback_congestion_end(void)
962{
963 blk_congestion_end(WRITE);
964}
965EXPORT_SYMBOL(writeback_congestion_end);
966
967/*
968 * Return true if any of the pages in the mapping are marged with the 959 * Return true if any of the pages in the mapping are marged with the
969 * passed tag. 960 * passed tag.
970 */ 961 */
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index a8c003e7b3d5..bf2f6cff1d6a 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -39,6 +39,7 @@
39#include <linux/stop_machine.h> 39#include <linux/stop_machine.h>
40#include <linux/sort.h> 40#include <linux/sort.h>
41#include <linux/pfn.h> 41#include <linux/pfn.h>
42#include <linux/backing-dev.h>
42 43
43#include <asm/tlbflush.h> 44#include <asm/tlbflush.h>
44#include <asm/div64.h> 45#include <asm/div64.h>
@@ -495,17 +496,16 @@ static void __free_pages_ok(struct page *page, unsigned int order)
495 int i; 496 int i;
496 int reserved = 0; 497 int reserved = 0;
497 498
498 arch_free_page(page, order);
499 if (!PageHighMem(page))
500 debug_check_no_locks_freed(page_address(page),
501 PAGE_SIZE<<order);
502
503 for (i = 0 ; i < (1 << order) ; ++i) 499 for (i = 0 ; i < (1 << order) ; ++i)
504 reserved += free_pages_check(page + i); 500 reserved += free_pages_check(page + i);
505 if (reserved) 501 if (reserved)
506 return; 502 return;
507 503
504 if (!PageHighMem(page))
505 debug_check_no_locks_freed(page_address(page),PAGE_SIZE<<order);
506 arch_free_page(page, order);
508 kernel_map_pages(page, 1 << order, 0); 507 kernel_map_pages(page, 1 << order, 0);
508
509 local_irq_save(flags); 509 local_irq_save(flags);
510 __count_vm_events(PGFREE, 1 << order); 510 __count_vm_events(PGFREE, 1 << order);
511 free_one_page(page_zone(page), page, order); 511 free_one_page(page_zone(page), page, order);
@@ -781,13 +781,14 @@ static void fastcall free_hot_cold_page(struct page *page, int cold)
781 struct per_cpu_pages *pcp; 781 struct per_cpu_pages *pcp;
782 unsigned long flags; 782 unsigned long flags;
783 783
784 arch_free_page(page, 0);
785
786 if (PageAnon(page)) 784 if (PageAnon(page))
787 page->mapping = NULL; 785 page->mapping = NULL;
788 if (free_pages_check(page)) 786 if (free_pages_check(page))
789 return; 787 return;
790 788
789 if (!PageHighMem(page))
790 debug_check_no_locks_freed(page_address(page), PAGE_SIZE);
791 arch_free_page(page, 0);
791 kernel_map_pages(page, 1, 0); 792 kernel_map_pages(page, 1, 0);
792 793
793 pcp = &zone_pcp(zone, get_cpu())->pcp[cold]; 794 pcp = &zone_pcp(zone, get_cpu())->pcp[cold];
@@ -852,7 +853,7 @@ again:
852 pcp = &zone_pcp(zone, cpu)->pcp[cold]; 853 pcp = &zone_pcp(zone, cpu)->pcp[cold];
853 local_irq_save(flags); 854 local_irq_save(flags);
854 if (!pcp->count) { 855 if (!pcp->count) {
855 pcp->count += rmqueue_bulk(zone, 0, 856 pcp->count = rmqueue_bulk(zone, 0,
856 pcp->batch, &pcp->list); 857 pcp->batch, &pcp->list);
857 if (unlikely(!pcp->count)) 858 if (unlikely(!pcp->count))
858 goto failed; 859 goto failed;
@@ -1050,7 +1051,7 @@ nofail_alloc:
1050 if (page) 1051 if (page)
1051 goto got_pg; 1052 goto got_pg;
1052 if (gfp_mask & __GFP_NOFAIL) { 1053 if (gfp_mask & __GFP_NOFAIL) {
1053 blk_congestion_wait(WRITE, HZ/50); 1054 congestion_wait(WRITE, HZ/50);
1054 goto nofail_alloc; 1055 goto nofail_alloc;
1055 } 1056 }
1056 } 1057 }
@@ -1113,7 +1114,7 @@ rebalance:
1113 do_retry = 1; 1114 do_retry = 1;
1114 } 1115 }
1115 if (do_retry) { 1116 if (do_retry) {
1116 blk_congestion_wait(WRITE, HZ/50); 1117 congestion_wait(WRITE, HZ/50);
1117 goto rebalance; 1118 goto rebalance;
1118 } 1119 }
1119 1120
@@ -1688,6 +1689,8 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone,
1688 for (pfn = start_pfn; pfn < end_pfn; pfn++) { 1689 for (pfn = start_pfn; pfn < end_pfn; pfn++) {
1689 if (!early_pfn_valid(pfn)) 1690 if (!early_pfn_valid(pfn))
1690 continue; 1691 continue;
1692 if (!early_pfn_in_nid(pfn, nid))
1693 continue;
1691 page = pfn_to_page(pfn); 1694 page = pfn_to_page(pfn);
1692 set_page_links(page, zone, nid, pfn); 1695 set_page_links(page, zone, nid, pfn);
1693 init_page_count(page); 1696 init_page_count(page);
@@ -2258,7 +2261,7 @@ unsigned long __init __absent_pages_in_range(int nid,
2258 2261
2259 /* Account for ranges past physical memory on this node */ 2262 /* Account for ranges past physical memory on this node */
2260 if (range_end_pfn > prev_end_pfn) 2263 if (range_end_pfn > prev_end_pfn)
2261 hole_pages = range_end_pfn - 2264 hole_pages += range_end_pfn -
2262 max(range_start_pfn, prev_end_pfn); 2265 max(range_start_pfn, prev_end_pfn);
2263 2266
2264 return hole_pages; 2267 return hole_pages;
@@ -2294,19 +2297,6 @@ unsigned long __init zone_absent_pages_in_node(int nid,
2294 return __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn); 2297 return __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn);
2295} 2298}
2296 2299
2297/* Return the zone index a PFN is in */
2298int memmap_zone_idx(struct page *lmem_map)
2299{
2300 int i;
2301 unsigned long phys_addr = virt_to_phys(lmem_map);
2302 unsigned long pfn = phys_addr >> PAGE_SHIFT;
2303
2304 for (i = 0; i < MAX_NR_ZONES; i++)
2305 if (pfn < arch_zone_highest_possible_pfn[i])
2306 break;
2307
2308 return i;
2309}
2310#else 2300#else
2311static inline unsigned long zone_spanned_pages_in_node(int nid, 2301static inline unsigned long zone_spanned_pages_in_node(int nid,
2312 unsigned long zone_type, 2302 unsigned long zone_type,
@@ -2325,10 +2315,6 @@ static inline unsigned long zone_absent_pages_in_node(int nid,
2325 return zholes_size[zone_type]; 2315 return zholes_size[zone_type];
2326} 2316}
2327 2317
2328static inline int memmap_zone_idx(struct page *lmem_map)
2329{
2330 return MAX_NR_ZONES;
2331}
2332#endif 2318#endif
2333 2319
2334static void __init calculate_node_totalpages(struct pglist_data *pgdat, 2320static void __init calculate_node_totalpages(struct pglist_data *pgdat,
@@ -2421,7 +2407,7 @@ static void __meminit free_area_init_core(struct pglist_data *pgdat,
2421 zone->zone_pgdat = pgdat; 2407 zone->zone_pgdat = pgdat;
2422 zone->free_pages = 0; 2408 zone->free_pages = 0;
2423 2409
2424 zone->temp_priority = zone->prev_priority = DEF_PRIORITY; 2410 zone->prev_priority = DEF_PRIORITY;
2425 2411
2426 zone_pcp_init(zone); 2412 zone_pcp_init(zone);
2427 INIT_LIST_HEAD(&zone->active_list); 2413 INIT_LIST_HEAD(&zone->active_list);
@@ -3136,3 +3122,19 @@ unsigned long page_to_pfn(struct page *page)
3136EXPORT_SYMBOL(pfn_to_page); 3122EXPORT_SYMBOL(pfn_to_page);
3137EXPORT_SYMBOL(page_to_pfn); 3123EXPORT_SYMBOL(page_to_pfn);
3138#endif /* CONFIG_OUT_OF_LINE_PFN_TO_PAGE */ 3124#endif /* CONFIG_OUT_OF_LINE_PFN_TO_PAGE */
3125
3126#if MAX_NUMNODES > 1
3127/*
3128 * Find the highest possible node id.
3129 */
3130int highest_possible_node_id(void)
3131{
3132 unsigned int node;
3133 unsigned int highest = 0;
3134
3135 for_each_node_mask(node, node_possible_map)
3136 highest = node;
3137 return highest;
3138}
3139EXPORT_SYMBOL(highest_possible_node_id);
3140#endif
diff --git a/mm/readahead.c b/mm/readahead.c
index 1ba736ac0367..23cb61a01c6e 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -173,6 +173,8 @@ static int read_pages(struct address_space *mapping, struct file *filp,
173 173
174 if (mapping->a_ops->readpages) { 174 if (mapping->a_ops->readpages) {
175 ret = mapping->a_ops->readpages(filp, mapping, pages, nr_pages); 175 ret = mapping->a_ops->readpages(filp, mapping, pages, nr_pages);
176 /* Clean up the remaining pages */
177 put_pages_list(pages);
176 goto out; 178 goto out;
177 } 179 }
178 180
diff --git a/mm/rmap.c b/mm/rmap.c
index e2155d791d99..d8a842a586db 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -21,27 +21,21 @@
21 * Lock ordering in mm: 21 * Lock ordering in mm:
22 * 22 *
23 * inode->i_mutex (while writing or truncating, not reading or faulting) 23 * inode->i_mutex (while writing or truncating, not reading or faulting)
24 * inode->i_alloc_sem 24 * inode->i_alloc_sem (vmtruncate_range)
25 * 25 * mm->mmap_sem
26 * When a page fault occurs in writing from user to file, down_read 26 * page->flags PG_locked (lock_page)
27 * of mmap_sem nests within i_mutex; in sys_msync, i_mutex nests within 27 * mapping->i_mmap_lock
28 * down_read of mmap_sem; i_mutex and down_write of mmap_sem are never 28 * anon_vma->lock
29 * taken together; in truncation, i_mutex is taken outermost. 29 * mm->page_table_lock or pte_lock
30 * 30 * zone->lru_lock (in mark_page_accessed, isolate_lru_page)
31 * mm->mmap_sem 31 * swap_lock (in swap_duplicate, swap_info_get)
32 * page->flags PG_locked (lock_page) 32 * mmlist_lock (in mmput, drain_mmlist and others)
33 * mapping->i_mmap_lock 33 * mapping->private_lock (in __set_page_dirty_buffers)
34 * anon_vma->lock 34 * inode_lock (in set_page_dirty's __mark_inode_dirty)
35 * mm->page_table_lock or pte_lock 35 * sb_lock (within inode_lock in fs/fs-writeback.c)
36 * zone->lru_lock (in mark_page_accessed, isolate_lru_page) 36 * mapping->tree_lock (widely used, in set_page_dirty,
37 * swap_lock (in swap_duplicate, swap_info_get) 37 * in arch-dependent flush_dcache_mmap_lock,
38 * mmlist_lock (in mmput, drain_mmlist and others) 38 * within inode_lock in __sync_single_inode)
39 * mapping->private_lock (in __set_page_dirty_buffers)
40 * inode_lock (in set_page_dirty's __mark_inode_dirty)
41 * sb_lock (within inode_lock in fs/fs-writeback.c)
42 * mapping->tree_lock (widely used, in set_page_dirty,
43 * in arch-dependent flush_dcache_mmap_lock,
44 * within inode_lock in __sync_single_inode)
45 */ 39 */
46 40
47#include <linux/mm.h> 41#include <linux/mm.h>
@@ -576,15 +570,14 @@ void page_add_file_rmap(struct page *page)
576void page_remove_rmap(struct page *page) 570void page_remove_rmap(struct page *page)
577{ 571{
578 if (atomic_add_negative(-1, &page->_mapcount)) { 572 if (atomic_add_negative(-1, &page->_mapcount)) {
579#ifdef CONFIG_DEBUG_VM
580 if (unlikely(page_mapcount(page) < 0)) { 573 if (unlikely(page_mapcount(page) < 0)) {
581 printk (KERN_EMERG "Eeek! page_mapcount(page) went negative! (%d)\n", page_mapcount(page)); 574 printk (KERN_EMERG "Eeek! page_mapcount(page) went negative! (%d)\n", page_mapcount(page));
582 printk (KERN_EMERG " page->flags = %lx\n", page->flags); 575 printk (KERN_EMERG " page->flags = %lx\n", page->flags);
583 printk (KERN_EMERG " page->count = %x\n", page_count(page)); 576 printk (KERN_EMERG " page->count = %x\n", page_count(page));
584 printk (KERN_EMERG " page->mapping = %p\n", page->mapping); 577 printk (KERN_EMERG " page->mapping = %p\n", page->mapping);
578 BUG();
585 } 579 }
586#endif 580
587 BUG_ON(page_mapcount(page) < 0);
588 /* 581 /*
589 * It would be tidy to reset the PageAnon mapping here, 582 * It would be tidy to reset the PageAnon mapping here,
590 * but that might overwrite a racing page_add_anon_rmap 583 * but that might overwrite a racing page_add_anon_rmap
diff --git a/mm/shmem.c b/mm/shmem.c
index bb8ca7ef7094..4959535fc14c 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -48,6 +48,7 @@
48#include <linux/ctype.h> 48#include <linux/ctype.h>
49#include <linux/migrate.h> 49#include <linux/migrate.h>
50#include <linux/highmem.h> 50#include <linux/highmem.h>
51#include <linux/backing-dev.h>
51 52
52#include <asm/uaccess.h> 53#include <asm/uaccess.h>
53#include <asm/div64.h> 54#include <asm/div64.h>
@@ -1131,7 +1132,7 @@ repeat:
1131 page_cache_release(swappage); 1132 page_cache_release(swappage);
1132 if (error == -ENOMEM) { 1133 if (error == -ENOMEM) {
1133 /* let kswapd refresh zone for GFP_ATOMICs */ 1134 /* let kswapd refresh zone for GFP_ATOMICs */
1134 blk_congestion_wait(WRITE, HZ/50); 1135 congestion_wait(WRITE, HZ/50);
1135 } 1136 }
1136 goto repeat; 1137 goto repeat;
1137 } 1138 }
@@ -1362,6 +1363,7 @@ shmem_get_inode(struct super_block *sb, int mode, dev_t dev)
1362 inode->i_mapping->a_ops = &shmem_aops; 1363 inode->i_mapping->a_ops = &shmem_aops;
1363 inode->i_mapping->backing_dev_info = &shmem_backing_dev_info; 1364 inode->i_mapping->backing_dev_info = &shmem_backing_dev_info;
1364 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 1365 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
1366 inode->i_generation = get_seconds();
1365 info = SHMEM_I(inode); 1367 info = SHMEM_I(inode);
1366 memset(info, 0, (char *)inode - (char *)info); 1368 memset(info, 0, (char *)inode - (char *)info);
1367 spin_lock_init(&info->lock); 1369 spin_lock_init(&info->lock);
@@ -1956,6 +1958,85 @@ static struct xattr_handler *shmem_xattr_handlers[] = {
1956}; 1958};
1957#endif 1959#endif
1958 1960
1961static struct dentry *shmem_get_parent(struct dentry *child)
1962{
1963 return ERR_PTR(-ESTALE);
1964}
1965
1966static int shmem_match(struct inode *ino, void *vfh)
1967{
1968 __u32 *fh = vfh;
1969 __u64 inum = fh[2];
1970 inum = (inum << 32) | fh[1];
1971 return ino->i_ino == inum && fh[0] == ino->i_generation;
1972}
1973
1974static struct dentry *shmem_get_dentry(struct super_block *sb, void *vfh)
1975{
1976 struct dentry *de = NULL;
1977 struct inode *inode;
1978 __u32 *fh = vfh;
1979 __u64 inum = fh[2];
1980 inum = (inum << 32) | fh[1];
1981
1982 inode = ilookup5(sb, (unsigned long)(inum+fh[0]), shmem_match, vfh);
1983 if (inode) {
1984 de = d_find_alias(inode);
1985 iput(inode);
1986 }
1987
1988 return de? de: ERR_PTR(-ESTALE);
1989}
1990
1991static struct dentry *shmem_decode_fh(struct super_block *sb, __u32 *fh,
1992 int len, int type,
1993 int (*acceptable)(void *context, struct dentry *de),
1994 void *context)
1995{
1996 if (len < 3)
1997 return ERR_PTR(-ESTALE);
1998
1999 return sb->s_export_op->find_exported_dentry(sb, fh, NULL, acceptable,
2000 context);
2001}
2002
2003static int shmem_encode_fh(struct dentry *dentry, __u32 *fh, int *len,
2004 int connectable)
2005{
2006 struct inode *inode = dentry->d_inode;
2007
2008 if (*len < 3)
2009 return 255;
2010
2011 if (hlist_unhashed(&inode->i_hash)) {
2012 /* Unfortunately insert_inode_hash is not idempotent,
2013 * so as we hash inodes here rather than at creation
2014 * time, we need a lock to ensure we only try
2015 * to do it once
2016 */
2017 static DEFINE_SPINLOCK(lock);
2018 spin_lock(&lock);
2019 if (hlist_unhashed(&inode->i_hash))
2020 __insert_inode_hash(inode,
2021 inode->i_ino + inode->i_generation);
2022 spin_unlock(&lock);
2023 }
2024
2025 fh[0] = inode->i_generation;
2026 fh[1] = inode->i_ino;
2027 fh[2] = ((__u64)inode->i_ino) >> 32;
2028
2029 *len = 3;
2030 return 1;
2031}
2032
2033static struct export_operations shmem_export_ops = {
2034 .get_parent = shmem_get_parent,
2035 .get_dentry = shmem_get_dentry,
2036 .encode_fh = shmem_encode_fh,
2037 .decode_fh = shmem_decode_fh,
2038};
2039
1959static int shmem_parse_options(char *options, int *mode, uid_t *uid, 2040static int shmem_parse_options(char *options, int *mode, uid_t *uid,
1960 gid_t *gid, unsigned long *blocks, unsigned long *inodes, 2041 gid_t *gid, unsigned long *blocks, unsigned long *inodes,
1961 int *policy, nodemask_t *policy_nodes) 2042 int *policy, nodemask_t *policy_nodes)
@@ -2128,6 +2209,7 @@ static int shmem_fill_super(struct super_block *sb,
2128 &inodes, &policy, &policy_nodes)) 2209 &inodes, &policy, &policy_nodes))
2129 return -EINVAL; 2210 return -EINVAL;
2130 } 2211 }
2212 sb->s_export_op = &shmem_export_ops;
2131#else 2213#else
2132 sb->s_flags |= MS_NOUSER; 2214 sb->s_flags |= MS_NOUSER;
2133#endif 2215#endif
diff --git a/mm/shmem_acl.c b/mm/shmem_acl.c
index c946bf468718..f5664c5b9eb1 100644
--- a/mm/shmem_acl.c
+++ b/mm/shmem_acl.c
@@ -35,7 +35,7 @@ shmem_get_acl(struct inode *inode, int type)
35} 35}
36 36
37/** 37/**
38 * shmem_get_acl - generic_acl_operations->setacl() operation 38 * shmem_set_acl - generic_acl_operations->setacl() operation
39 */ 39 */
40static void 40static void
41shmem_set_acl(struct inode *inode, int type, struct posix_acl *acl) 41shmem_set_acl(struct inode *inode, int type, struct posix_acl *acl)
diff --git a/mm/slab.c b/mm/slab.c
index 266449d604bd..3c4a7e34eddc 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -883,7 +883,7 @@ static void init_reap_node(int cpu)
883 if (node == MAX_NUMNODES) 883 if (node == MAX_NUMNODES)
884 node = first_node(node_online_map); 884 node = first_node(node_online_map);
885 885
886 __get_cpu_var(reap_node) = node; 886 per_cpu(reap_node, cpu) = node;
887} 887}
888 888
889static void next_reap_node(void) 889static void next_reap_node(void)
@@ -3152,12 +3152,15 @@ void *fallback_alloc(struct kmem_cache *cache, gfp_t flags)
3152 struct zone **z; 3152 struct zone **z;
3153 void *obj = NULL; 3153 void *obj = NULL;
3154 3154
3155 for (z = zonelist->zones; *z && !obj; z++) 3155 for (z = zonelist->zones; *z && !obj; z++) {
3156 int nid = zone_to_nid(*z);
3157
3156 if (zone_idx(*z) <= ZONE_NORMAL && 3158 if (zone_idx(*z) <= ZONE_NORMAL &&
3157 cpuset_zone_allowed(*z, flags)) 3159 cpuset_zone_allowed(*z, flags) &&
3160 cache->nodelists[nid])
3158 obj = __cache_alloc_node(cache, 3161 obj = __cache_alloc_node(cache,
3159 flags | __GFP_THISNODE, 3162 flags | __GFP_THISNODE, nid);
3160 zone_to_nid(*z)); 3163 }
3161 return obj; 3164 return obj;
3162} 3165}
3163 3166
diff --git a/mm/sparse.c b/mm/sparse.c
index 86c52ab80878..b3c82ba30012 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -211,7 +211,7 @@ static struct page *__kmalloc_section_memmap(unsigned long nr_pages)
211 struct page *page, *ret; 211 struct page *page, *ret;
212 unsigned long memmap_size = sizeof(struct page) * nr_pages; 212 unsigned long memmap_size = sizeof(struct page) * nr_pages;
213 213
214 page = alloc_pages(GFP_KERNEL, get_order(memmap_size)); 214 page = alloc_pages(GFP_KERNEL|__GFP_NOWARN, get_order(memmap_size));
215 if (page) 215 if (page)
216 goto got_map_page; 216 goto got_map_page;
217 217
diff --git a/mm/truncate.c b/mm/truncate.c
index f4edbc179d14..e07b1e682c38 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -96,7 +96,6 @@ invalidate_complete_page(struct address_space *mapping, struct page *page)
96 return 0; 96 return 0;
97 97
98 ret = remove_mapping(mapping, page); 98 ret = remove_mapping(mapping, page);
99 ClearPageUptodate(page);
100 99
101 return ret; 100 return ret;
102} 101}
@@ -302,7 +301,7 @@ invalidate_complete_page2(struct address_space *mapping, struct page *page)
302 if (page->mapping != mapping) 301 if (page->mapping != mapping)
303 return 0; 302 return 0;
304 303
305 if (PagePrivate(page) && !try_to_release_page(page, 0)) 304 if (PagePrivate(page) && !try_to_release_page(page, GFP_KERNEL))
306 return 0; 305 return 0;
307 306
308 write_lock_irq(&mapping->tree_lock); 307 write_lock_irq(&mapping->tree_lock);
@@ -396,6 +395,7 @@ int invalidate_inode_pages2_range(struct address_space *mapping,
396 pagevec_release(&pvec); 395 pagevec_release(&pvec);
397 cond_resched(); 396 cond_resched();
398 } 397 }
398 WARN_ON_ONCE(ret);
399 return ret; 399 return ret;
400} 400}
401EXPORT_SYMBOL_GPL(invalidate_inode_pages2_range); 401EXPORT_SYMBOL_GPL(invalidate_inode_pages2_range);
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 750ab6ed13fc..86897ee792d6 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -160,13 +160,15 @@ int map_vm_area(struct vm_struct *area, pgprot_t prot, struct page ***pages)
160 return err; 160 return err;
161} 161}
162 162
163struct vm_struct *__get_vm_area_node(unsigned long size, unsigned long flags, 163static struct vm_struct *__get_vm_area_node(unsigned long size, unsigned long flags,
164 unsigned long start, unsigned long end, int node) 164 unsigned long start, unsigned long end,
165 int node, gfp_t gfp_mask)
165{ 166{
166 struct vm_struct **p, *tmp, *area; 167 struct vm_struct **p, *tmp, *area;
167 unsigned long align = 1; 168 unsigned long align = 1;
168 unsigned long addr; 169 unsigned long addr;
169 170
171 BUG_ON(in_interrupt());
170 if (flags & VM_IOREMAP) { 172 if (flags & VM_IOREMAP) {
171 int bit = fls(size); 173 int bit = fls(size);
172 174
@@ -179,16 +181,13 @@ struct vm_struct *__get_vm_area_node(unsigned long size, unsigned long flags,
179 } 181 }
180 addr = ALIGN(start, align); 182 addr = ALIGN(start, align);
181 size = PAGE_ALIGN(size); 183 size = PAGE_ALIGN(size);
184 if (unlikely(!size))
185 return NULL;
182 186
183 area = kmalloc_node(sizeof(*area), GFP_KERNEL, node); 187 area = kmalloc_node(sizeof(*area), gfp_mask & GFP_LEVEL_MASK, node);
184 if (unlikely(!area)) 188 if (unlikely(!area))
185 return NULL; 189 return NULL;
186 190
187 if (unlikely(!size)) {
188 kfree (area);
189 return NULL;
190 }
191
192 /* 191 /*
193 * We always allocate a guard page. 192 * We always allocate a guard page.
194 */ 193 */
@@ -236,7 +235,7 @@ out:
236struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags, 235struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags,
237 unsigned long start, unsigned long end) 236 unsigned long start, unsigned long end)
238{ 237{
239 return __get_vm_area_node(size, flags, start, end, -1); 238 return __get_vm_area_node(size, flags, start, end, -1, GFP_KERNEL);
240} 239}
241 240
242/** 241/**
@@ -253,9 +252,11 @@ struct vm_struct *get_vm_area(unsigned long size, unsigned long flags)
253 return __get_vm_area(size, flags, VMALLOC_START, VMALLOC_END); 252 return __get_vm_area(size, flags, VMALLOC_START, VMALLOC_END);
254} 253}
255 254
256struct vm_struct *get_vm_area_node(unsigned long size, unsigned long flags, int node) 255struct vm_struct *get_vm_area_node(unsigned long size, unsigned long flags,
256 int node, gfp_t gfp_mask)
257{ 257{
258 return __get_vm_area_node(size, flags, VMALLOC_START, VMALLOC_END, node); 258 return __get_vm_area_node(size, flags, VMALLOC_START, VMALLOC_END, node,
259 gfp_mask);
259} 260}
260 261
261/* Caller must hold vmlist_lock */ 262/* Caller must hold vmlist_lock */
@@ -428,8 +429,11 @@ void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
428 if (array_size > PAGE_SIZE) { 429 if (array_size > PAGE_SIZE) {
429 pages = __vmalloc_node(array_size, gfp_mask, PAGE_KERNEL, node); 430 pages = __vmalloc_node(array_size, gfp_mask, PAGE_KERNEL, node);
430 area->flags |= VM_VPAGES; 431 area->flags |= VM_VPAGES;
431 } else 432 } else {
432 pages = kmalloc_node(array_size, (gfp_mask & ~__GFP_HIGHMEM), node); 433 pages = kmalloc_node(array_size,
434 (gfp_mask & ~(__GFP_HIGHMEM | __GFP_ZERO)),
435 node);
436 }
433 area->pages = pages; 437 area->pages = pages;
434 if (!area->pages) { 438 if (!area->pages) {
435 remove_vm_area(area->addr); 439 remove_vm_area(area->addr);
@@ -484,7 +488,7 @@ static void *__vmalloc_node(unsigned long size, gfp_t gfp_mask, pgprot_t prot,
484 if (!size || (size >> PAGE_SHIFT) > num_physpages) 488 if (!size || (size >> PAGE_SHIFT) > num_physpages)
485 return NULL; 489 return NULL;
486 490
487 area = get_vm_area_node(size, VM_ALLOC, node); 491 area = get_vm_area_node(size, VM_ALLOC, node, gfp_mask);
488 if (!area) 492 if (!area)
489 return NULL; 493 return NULL;
490 494
@@ -525,11 +529,12 @@ void *vmalloc_user(unsigned long size)
525 void *ret; 529 void *ret;
526 530
527 ret = __vmalloc(size, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL); 531 ret = __vmalloc(size, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL);
528 write_lock(&vmlist_lock); 532 if (ret) {
529 area = __find_vm_area(ret); 533 write_lock(&vmlist_lock);
530 area->flags |= VM_USERMAP; 534 area = __find_vm_area(ret);
531 write_unlock(&vmlist_lock); 535 area->flags |= VM_USERMAP;
532 536 write_unlock(&vmlist_lock);
537 }
533 return ret; 538 return ret;
534} 539}
535EXPORT_SYMBOL(vmalloc_user); 540EXPORT_SYMBOL(vmalloc_user);
@@ -598,11 +603,12 @@ void *vmalloc_32_user(unsigned long size)
598 void *ret; 603 void *ret;
599 604
600 ret = __vmalloc(size, GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL); 605 ret = __vmalloc(size, GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL);
601 write_lock(&vmlist_lock); 606 if (ret) {
602 area = __find_vm_area(ret); 607 write_lock(&vmlist_lock);
603 area->flags |= VM_USERMAP; 608 area = __find_vm_area(ret);
604 write_unlock(&vmlist_lock); 609 area->flags |= VM_USERMAP;
605 610 write_unlock(&vmlist_lock);
611 }
606 return ret; 612 return ret;
607} 613}
608EXPORT_SYMBOL(vmalloc_32_user); 614EXPORT_SYMBOL(vmalloc_32_user);
diff --git a/mm/vmscan.c b/mm/vmscan.c
index eca70310adb2..518540a4a2a6 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -378,6 +378,12 @@ static pageout_t pageout(struct page *page, struct address_space *mapping)
378 return PAGE_CLEAN; 378 return PAGE_CLEAN;
379} 379}
380 380
381/*
382 * Attempt to detach a locked page from its ->mapping. If it is dirty or if
383 * someone else has a ref on the page, abort and return 0. If it was
384 * successfully detached, return 1. Assumes the caller has a single ref on
385 * this page.
386 */
381int remove_mapping(struct address_space *mapping, struct page *page) 387int remove_mapping(struct address_space *mapping, struct page *page)
382{ 388{
383 BUG_ON(!PageLocked(page)); 389 BUG_ON(!PageLocked(page));
@@ -717,6 +723,20 @@ done:
717 return nr_reclaimed; 723 return nr_reclaimed;
718} 724}
719 725
726/*
727 * We are about to scan this zone at a certain priority level. If that priority
728 * level is smaller (ie: more urgent) than the previous priority, then note
729 * that priority level within the zone. This is done so that when the next
730 * process comes in to scan this zone, it will immediately start out at this
731 * priority level rather than having to build up its own scanning priority.
732 * Here, this priority affects only the reclaim-mapped threshold.
733 */
734static inline void note_zone_scanning_priority(struct zone *zone, int priority)
735{
736 if (priority < zone->prev_priority)
737 zone->prev_priority = priority;
738}
739
720static inline int zone_is_near_oom(struct zone *zone) 740static inline int zone_is_near_oom(struct zone *zone)
721{ 741{
722 return zone->pages_scanned >= (zone->nr_active + zone->nr_inactive)*3; 742 return zone->pages_scanned >= (zone->nr_active + zone->nr_inactive)*3;
@@ -740,7 +760,7 @@ static inline int zone_is_near_oom(struct zone *zone)
740 * But we had to alter page->flags anyway. 760 * But we had to alter page->flags anyway.
741 */ 761 */
742static void shrink_active_list(unsigned long nr_pages, struct zone *zone, 762static void shrink_active_list(unsigned long nr_pages, struct zone *zone,
743 struct scan_control *sc) 763 struct scan_control *sc, int priority)
744{ 764{
745 unsigned long pgmoved; 765 unsigned long pgmoved;
746 int pgdeactivate = 0; 766 int pgdeactivate = 0;
@@ -764,7 +784,7 @@ static void shrink_active_list(unsigned long nr_pages, struct zone *zone,
764 * `distress' is a measure of how much trouble we're having 784 * `distress' is a measure of how much trouble we're having
765 * reclaiming pages. 0 -> no problems. 100 -> great trouble. 785 * reclaiming pages. 0 -> no problems. 100 -> great trouble.
766 */ 786 */
767 distress = 100 >> zone->prev_priority; 787 distress = 100 >> min(zone->prev_priority, priority);
768 788
769 /* 789 /*
770 * The point of this algorithm is to decide when to start 790 * The point of this algorithm is to decide when to start
@@ -916,7 +936,7 @@ static unsigned long shrink_zone(int priority, struct zone *zone,
916 nr_to_scan = min(nr_active, 936 nr_to_scan = min(nr_active,
917 (unsigned long)sc->swap_cluster_max); 937 (unsigned long)sc->swap_cluster_max);
918 nr_active -= nr_to_scan; 938 nr_active -= nr_to_scan;
919 shrink_active_list(nr_to_scan, zone, sc); 939 shrink_active_list(nr_to_scan, zone, sc, priority);
920 } 940 }
921 941
922 if (nr_inactive) { 942 if (nr_inactive) {
@@ -966,9 +986,7 @@ static unsigned long shrink_zones(int priority, struct zone **zones,
966 if (!cpuset_zone_allowed(zone, __GFP_HARDWALL)) 986 if (!cpuset_zone_allowed(zone, __GFP_HARDWALL))
967 continue; 987 continue;
968 988
969 zone->temp_priority = priority; 989 note_zone_scanning_priority(zone, priority);
970 if (zone->prev_priority > priority)
971 zone->prev_priority = priority;
972 990
973 if (zone->all_unreclaimable && priority != DEF_PRIORITY) 991 if (zone->all_unreclaimable && priority != DEF_PRIORITY)
974 continue; /* Let kswapd poll it */ 992 continue; /* Let kswapd poll it */
@@ -1018,7 +1036,6 @@ unsigned long try_to_free_pages(struct zone **zones, gfp_t gfp_mask)
1018 if (!cpuset_zone_allowed(zone, __GFP_HARDWALL)) 1036 if (!cpuset_zone_allowed(zone, __GFP_HARDWALL))
1019 continue; 1037 continue;
1020 1038
1021 zone->temp_priority = DEF_PRIORITY;
1022 lru_pages += zone->nr_active + zone->nr_inactive; 1039 lru_pages += zone->nr_active + zone->nr_inactive;
1023 } 1040 }
1024 1041
@@ -1053,19 +1070,28 @@ unsigned long try_to_free_pages(struct zone **zones, gfp_t gfp_mask)
1053 1070
1054 /* Take a nap, wait for some writeback to complete */ 1071 /* Take a nap, wait for some writeback to complete */
1055 if (sc.nr_scanned && priority < DEF_PRIORITY - 2) 1072 if (sc.nr_scanned && priority < DEF_PRIORITY - 2)
1056 blk_congestion_wait(WRITE, HZ/10); 1073 congestion_wait(WRITE, HZ/10);
1057 } 1074 }
1058 /* top priority shrink_caches still had more to do? don't OOM, then */ 1075 /* top priority shrink_caches still had more to do? don't OOM, then */
1059 if (!sc.all_unreclaimable) 1076 if (!sc.all_unreclaimable)
1060 ret = 1; 1077 ret = 1;
1061out: 1078out:
1079 /*
1080 * Now that we've scanned all the zones at this priority level, note
1081 * that level within the zone so that the next thread which performs
1082 * scanning of this zone will immediately start out at this priority
1083 * level. This affects only the decision whether or not to bring
1084 * mapped pages onto the inactive list.
1085 */
1086 if (priority < 0)
1087 priority = 0;
1062 for (i = 0; zones[i] != 0; i++) { 1088 for (i = 0; zones[i] != 0; i++) {
1063 struct zone *zone = zones[i]; 1089 struct zone *zone = zones[i];
1064 1090
1065 if (!cpuset_zone_allowed(zone, __GFP_HARDWALL)) 1091 if (!cpuset_zone_allowed(zone, __GFP_HARDWALL))
1066 continue; 1092 continue;
1067 1093
1068 zone->prev_priority = zone->temp_priority; 1094 zone->prev_priority = priority;
1069 } 1095 }
1070 return ret; 1096 return ret;
1071} 1097}
@@ -1105,6 +1131,11 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order)
1105 .swap_cluster_max = SWAP_CLUSTER_MAX, 1131 .swap_cluster_max = SWAP_CLUSTER_MAX,
1106 .swappiness = vm_swappiness, 1132 .swappiness = vm_swappiness,
1107 }; 1133 };
1134 /*
1135 * temp_priority is used to remember the scanning priority at which
1136 * this zone was successfully refilled to free_pages == pages_high.
1137 */
1138 int temp_priority[MAX_NR_ZONES];
1108 1139
1109loop_again: 1140loop_again:
1110 total_scanned = 0; 1141 total_scanned = 0;
@@ -1112,11 +1143,8 @@ loop_again:
1112 sc.may_writepage = !laptop_mode; 1143 sc.may_writepage = !laptop_mode;
1113 count_vm_event(PAGEOUTRUN); 1144 count_vm_event(PAGEOUTRUN);
1114 1145
1115 for (i = 0; i < pgdat->nr_zones; i++) { 1146 for (i = 0; i < pgdat->nr_zones; i++)
1116 struct zone *zone = pgdat->node_zones + i; 1147 temp_priority[i] = DEF_PRIORITY;
1117
1118 zone->temp_priority = DEF_PRIORITY;
1119 }
1120 1148
1121 for (priority = DEF_PRIORITY; priority >= 0; priority--) { 1149 for (priority = DEF_PRIORITY; priority >= 0; priority--) {
1122 int end_zone = 0; /* Inclusive. 0 = ZONE_DMA */ 1150 int end_zone = 0; /* Inclusive. 0 = ZONE_DMA */
@@ -1177,10 +1205,9 @@ scan:
1177 if (!zone_watermark_ok(zone, order, zone->pages_high, 1205 if (!zone_watermark_ok(zone, order, zone->pages_high,
1178 end_zone, 0)) 1206 end_zone, 0))
1179 all_zones_ok = 0; 1207 all_zones_ok = 0;
1180 zone->temp_priority = priority; 1208 temp_priority[i] = priority;
1181 if (zone->prev_priority > priority)
1182 zone->prev_priority = priority;
1183 sc.nr_scanned = 0; 1209 sc.nr_scanned = 0;
1210 note_zone_scanning_priority(zone, priority);
1184 nr_reclaimed += shrink_zone(priority, zone, &sc); 1211 nr_reclaimed += shrink_zone(priority, zone, &sc);
1185 reclaim_state->reclaimed_slab = 0; 1212 reclaim_state->reclaimed_slab = 0;
1186 nr_slab = shrink_slab(sc.nr_scanned, GFP_KERNEL, 1213 nr_slab = shrink_slab(sc.nr_scanned, GFP_KERNEL,
@@ -1208,7 +1235,7 @@ scan:
1208 * another pass across the zones. 1235 * another pass across the zones.
1209 */ 1236 */
1210 if (total_scanned && priority < DEF_PRIORITY - 2) 1237 if (total_scanned && priority < DEF_PRIORITY - 2)
1211 blk_congestion_wait(WRITE, HZ/10); 1238 congestion_wait(WRITE, HZ/10);
1212 1239
1213 /* 1240 /*
1214 * We do this so kswapd doesn't build up large priorities for 1241 * We do this so kswapd doesn't build up large priorities for
@@ -1220,10 +1247,15 @@ scan:
1220 break; 1247 break;
1221 } 1248 }
1222out: 1249out:
1250 /*
1251 * Note within each zone the priority level at which this zone was
1252 * brought into a happy state. So that the next thread which scans this
1253 * zone will start out at that priority level.
1254 */
1223 for (i = 0; i < pgdat->nr_zones; i++) { 1255 for (i = 0; i < pgdat->nr_zones; i++) {
1224 struct zone *zone = pgdat->node_zones + i; 1256 struct zone *zone = pgdat->node_zones + i;
1225 1257
1226 zone->prev_priority = zone->temp_priority; 1258 zone->prev_priority = temp_priority[i];
1227 } 1259 }
1228 if (!all_zones_ok) { 1260 if (!all_zones_ok) {
1229 cond_resched(); 1261 cond_resched();
@@ -1352,7 +1384,7 @@ static unsigned long shrink_all_zones(unsigned long nr_pages, int pass,
1352 if (zone->nr_scan_active >= nr_pages || pass > 3) { 1384 if (zone->nr_scan_active >= nr_pages || pass > 3) {
1353 zone->nr_scan_active = 0; 1385 zone->nr_scan_active = 0;
1354 nr_to_scan = min(nr_pages, zone->nr_active); 1386 nr_to_scan = min(nr_pages, zone->nr_active);
1355 shrink_active_list(nr_to_scan, zone, sc); 1387 shrink_active_list(nr_to_scan, zone, sc, prio);
1356 } 1388 }
1357 } 1389 }
1358 1390
@@ -1452,7 +1484,7 @@ unsigned long shrink_all_memory(unsigned long nr_pages)
1452 goto out; 1484 goto out;
1453 1485
1454 if (sc.nr_scanned && prio < DEF_PRIORITY - 2) 1486 if (sc.nr_scanned && prio < DEF_PRIORITY - 2)
1455 blk_congestion_wait(WRITE, HZ / 10); 1487 congestion_wait(WRITE, HZ / 10);
1456 } 1488 }
1457 1489
1458 lru_pages = 0; 1490 lru_pages = 0;
@@ -1608,6 +1640,7 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
1608 */ 1640 */
1609 priority = ZONE_RECLAIM_PRIORITY; 1641 priority = ZONE_RECLAIM_PRIORITY;
1610 do { 1642 do {
1643 note_zone_scanning_priority(zone, priority);
1611 nr_reclaimed += shrink_zone(priority, zone, &sc); 1644 nr_reclaimed += shrink_zone(priority, zone, &sc);
1612 priority--; 1645 priority--;
1613 } while (priority >= 0 && nr_reclaimed < nr_pages); 1646 } while (priority >= 0 && nr_reclaimed < nr_pages);
diff --git a/mm/vmstat.c b/mm/vmstat.c
index 45b124e012f5..8614e8f6743b 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -587,11 +587,9 @@ static int zoneinfo_show(struct seq_file *m, void *arg)
587 seq_printf(m, 587 seq_printf(m,
588 "\n all_unreclaimable: %u" 588 "\n all_unreclaimable: %u"
589 "\n prev_priority: %i" 589 "\n prev_priority: %i"
590 "\n temp_priority: %i"
591 "\n start_pfn: %lu", 590 "\n start_pfn: %lu",
592 zone->all_unreclaimable, 591 zone->all_unreclaimable,
593 zone->prev_priority, 592 zone->prev_priority,
594 zone->temp_priority,
595 zone->zone_start_pfn); 593 zone->zone_start_pfn);
596 spin_unlock_irqrestore(&zone->lock, flags); 594 spin_unlock_irqrestore(&zone->lock, flags);
597 seq_putc(m, '\n'); 595 seq_putc(m, '\n');
diff --git a/net/Kconfig b/net/Kconfig
index a81aca43932f..67e39ad8b8b6 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -63,6 +63,7 @@ config INET
63if INET 63if INET
64source "net/ipv4/Kconfig" 64source "net/ipv4/Kconfig"
65source "net/ipv6/Kconfig" 65source "net/ipv6/Kconfig"
66source "net/netlabel/Kconfig"
66 67
67endif # if INET 68endif # if INET
68 69
@@ -249,8 +250,6 @@ source "net/ieee80211/Kconfig"
249config WIRELESS_EXT 250config WIRELESS_EXT
250 bool 251 bool
251 252
252source "net/netlabel/Kconfig"
253
254config FIB_RULES 253config FIB_RULES
255 bool 254 bool
256 255
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index 708e2e0371af..485e35c3b28b 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -1584,7 +1584,6 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
1584 1584
1585 if (usat->sat_addr.s_net || usat->sat_addr.s_node == ATADDR_ANYNODE) { 1585 if (usat->sat_addr.s_net || usat->sat_addr.s_node == ATADDR_ANYNODE) {
1586 rt = atrtr_find(&usat->sat_addr); 1586 rt = atrtr_find(&usat->sat_addr);
1587 dev = rt->dev;
1588 } else { 1587 } else {
1589 struct atalk_addr at_hint; 1588 struct atalk_addr at_hint;
1590 1589
@@ -1592,7 +1591,6 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
1592 at_hint.s_net = at->src_net; 1591 at_hint.s_net = at->src_net;
1593 1592
1594 rt = atrtr_find(&at_hint); 1593 rt = atrtr_find(&at_hint);
1595 dev = rt->dev;
1596 } 1594 }
1597 if (!rt) 1595 if (!rt)
1598 return -ENETUNREACH; 1596 return -ENETUNREACH;
diff --git a/net/atm/atm_sysfs.c b/net/atm/atm_sysfs.c
index c0a4ae28fcfa..62f6ed1f2f98 100644
--- a/net/atm/atm_sysfs.c
+++ b/net/atm/atm_sysfs.c
@@ -141,7 +141,7 @@ static struct class atm_class = {
141int atm_register_sysfs(struct atm_dev *adev) 141int atm_register_sysfs(struct atm_dev *adev)
142{ 142{
143 struct class_device *cdev = &adev->class_dev; 143 struct class_device *cdev = &adev->class_dev;
144 int i, err; 144 int i, j, err;
145 145
146 cdev->class = &atm_class; 146 cdev->class = &atm_class;
147 class_set_devdata(cdev, adev); 147 class_set_devdata(cdev, adev);
@@ -151,10 +151,19 @@ int atm_register_sysfs(struct atm_dev *adev)
151 if (err < 0) 151 if (err < 0)
152 return err; 152 return err;
153 153
154 for (i = 0; atm_attrs[i]; i++) 154 for (i = 0; atm_attrs[i]; i++) {
155 class_device_create_file(cdev, atm_attrs[i]); 155 err = class_device_create_file(cdev, atm_attrs[i]);
156 if (err)
157 goto err_out;
158 }
156 159
157 return 0; 160 return 0;
161
162err_out:
163 for (j = 0; j < i; j++)
164 class_device_remove_file(cdev, atm_attrs[j]);
165 class_device_del(cdev);
166 return err;
158} 167}
159 168
160void atm_unregister_sysfs(struct atm_dev *adev) 169void atm_unregister_sysfs(struct atm_dev *adev)
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index 305a099b7477..67df99e2e5c8 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -48,41 +48,56 @@
48#define BT_DBG(D...) 48#define BT_DBG(D...)
49#endif 49#endif
50 50
51#define VERSION "2.10" 51#define VERSION "2.11"
52 52
53/* Bluetooth sockets */ 53/* Bluetooth sockets */
54#define BT_MAX_PROTO 8 54#define BT_MAX_PROTO 8
55static struct net_proto_family *bt_proto[BT_MAX_PROTO]; 55static struct net_proto_family *bt_proto[BT_MAX_PROTO];
56static DEFINE_RWLOCK(bt_proto_lock);
56 57
57int bt_sock_register(int proto, struct net_proto_family *ops) 58int bt_sock_register(int proto, struct net_proto_family *ops)
58{ 59{
60 int err = 0;
61
59 if (proto < 0 || proto >= BT_MAX_PROTO) 62 if (proto < 0 || proto >= BT_MAX_PROTO)
60 return -EINVAL; 63 return -EINVAL;
61 64
65 write_lock(&bt_proto_lock);
66
62 if (bt_proto[proto]) 67 if (bt_proto[proto])
63 return -EEXIST; 68 err = -EEXIST;
69 else
70 bt_proto[proto] = ops;
64 71
65 bt_proto[proto] = ops; 72 write_unlock(&bt_proto_lock);
66 return 0; 73
74 return err;
67} 75}
68EXPORT_SYMBOL(bt_sock_register); 76EXPORT_SYMBOL(bt_sock_register);
69 77
70int bt_sock_unregister(int proto) 78int bt_sock_unregister(int proto)
71{ 79{
80 int err = 0;
81
72 if (proto < 0 || proto >= BT_MAX_PROTO) 82 if (proto < 0 || proto >= BT_MAX_PROTO)
73 return -EINVAL; 83 return -EINVAL;
74 84
85 write_lock(&bt_proto_lock);
86
75 if (!bt_proto[proto]) 87 if (!bt_proto[proto])
76 return -ENOENT; 88 err = -ENOENT;
89 else
90 bt_proto[proto] = NULL;
77 91
78 bt_proto[proto] = NULL; 92 write_unlock(&bt_proto_lock);
79 return 0; 93
94 return err;
80} 95}
81EXPORT_SYMBOL(bt_sock_unregister); 96EXPORT_SYMBOL(bt_sock_unregister);
82 97
83static int bt_sock_create(struct socket *sock, int proto) 98static int bt_sock_create(struct socket *sock, int proto)
84{ 99{
85 int err = 0; 100 int err;
86 101
87 if (proto < 0 || proto >= BT_MAX_PROTO) 102 if (proto < 0 || proto >= BT_MAX_PROTO)
88 return -EINVAL; 103 return -EINVAL;
@@ -92,11 +107,18 @@ static int bt_sock_create(struct socket *sock, int proto)
92 request_module("bt-proto-%d", proto); 107 request_module("bt-proto-%d", proto);
93 } 108 }
94#endif 109#endif
110
95 err = -EPROTONOSUPPORT; 111 err = -EPROTONOSUPPORT;
112
113 read_lock(&bt_proto_lock);
114
96 if (bt_proto[proto] && try_module_get(bt_proto[proto]->owner)) { 115 if (bt_proto[proto] && try_module_get(bt_proto[proto]->owner)) {
97 err = bt_proto[proto]->create(sock, proto); 116 err = bt_proto[proto]->create(sock, proto);
98 module_put(bt_proto[proto]->owner); 117 module_put(bt_proto[proto]->owner);
99 } 118 }
119
120 read_unlock(&bt_proto_lock);
121
100 return err; 122 return err;
101} 123}
102 124
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
index 2312d050eeed..4d3424c2421c 100644
--- a/net/bluetooth/bnep/core.c
+++ b/net/bluetooth/bnep/core.c
@@ -528,12 +528,10 @@ static struct device *bnep_get_device(struct bnep_session *session)
528 return NULL; 528 return NULL;
529 529
530 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst); 530 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst);
531 if (!conn)
532 return NULL;
533 531
534 hci_dev_put(hdev); 532 hci_dev_put(hdev);
535 533
536 return &conn->dev; 534 return conn ? &conn->dev : NULL;
537} 535}
538 536
539int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock) 537int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)
diff --git a/net/bluetooth/bnep/sock.c b/net/bluetooth/bnep/sock.c
index 28c55835422a..5563db1bf526 100644
--- a/net/bluetooth/bnep/sock.c
+++ b/net/bluetooth/bnep/sock.c
@@ -43,6 +43,7 @@
43#include <linux/ioctl.h> 43#include <linux/ioctl.h>
44#include <linux/file.h> 44#include <linux/file.h>
45#include <linux/init.h> 45#include <linux/init.h>
46#include <linux/compat.h>
46#include <net/sock.h> 47#include <net/sock.h>
47 48
48#include <asm/system.h> 49#include <asm/system.h>
@@ -146,24 +147,56 @@ static int bnep_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
146 return 0; 147 return 0;
147} 148}
148 149
150#ifdef CONFIG_COMPAT
151static int bnep_sock_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
152{
153 if (cmd == BNEPGETCONNLIST) {
154 struct bnep_connlist_req cl;
155 uint32_t uci;
156 int err;
157
158 if (get_user(cl.cnum, (uint32_t __user *) arg) ||
159 get_user(uci, (u32 __user *) (arg + 4)))
160 return -EFAULT;
161
162 cl.ci = compat_ptr(uci);
163
164 if (cl.cnum <= 0)
165 return -EINVAL;
166
167 err = bnep_get_connlist(&cl);
168
169 if (!err && put_user(cl.cnum, (uint32_t __user *) arg))
170 err = -EFAULT;
171
172 return err;
173 }
174
175 return bnep_sock_ioctl(sock, cmd, arg);
176}
177#endif
178
149static const struct proto_ops bnep_sock_ops = { 179static const struct proto_ops bnep_sock_ops = {
150 .family = PF_BLUETOOTH, 180 .family = PF_BLUETOOTH,
151 .owner = THIS_MODULE, 181 .owner = THIS_MODULE,
152 .release = bnep_sock_release, 182 .release = bnep_sock_release,
153 .ioctl = bnep_sock_ioctl, 183 .ioctl = bnep_sock_ioctl,
154 .bind = sock_no_bind, 184#ifdef CONFIG_COMPAT
155 .getname = sock_no_getname, 185 .compat_ioctl = bnep_sock_compat_ioctl,
156 .sendmsg = sock_no_sendmsg, 186#endif
157 .recvmsg = sock_no_recvmsg, 187 .bind = sock_no_bind,
158 .poll = sock_no_poll, 188 .getname = sock_no_getname,
159 .listen = sock_no_listen, 189 .sendmsg = sock_no_sendmsg,
160 .shutdown = sock_no_shutdown, 190 .recvmsg = sock_no_recvmsg,
161 .setsockopt = sock_no_setsockopt, 191 .poll = sock_no_poll,
162 .getsockopt = sock_no_getsockopt, 192 .listen = sock_no_listen,
163 .connect = sock_no_connect, 193 .shutdown = sock_no_shutdown,
164 .socketpair = sock_no_socketpair, 194 .setsockopt = sock_no_setsockopt,
165 .accept = sock_no_accept, 195 .getsockopt = sock_no_getsockopt,
166 .mmap = sock_no_mmap 196 .connect = sock_no_connect,
197 .socketpair = sock_no_socketpair,
198 .accept = sock_no_accept,
199 .mmap = sock_no_mmap
167}; 200};
168 201
169static struct proto bnep_proto = { 202static struct proto bnep_proto = {
@@ -181,7 +214,7 @@ static int bnep_sock_create(struct socket *sock, int protocol)
181 if (sock->type != SOCK_RAW) 214 if (sock->type != SOCK_RAW)
182 return -ESOCKTNOSUPPORT; 215 return -ESOCKTNOSUPPORT;
183 216
184 sk = sk_alloc(PF_BLUETOOTH, GFP_KERNEL, &bnep_proto, 1); 217 sk = sk_alloc(PF_BLUETOOTH, GFP_ATOMIC, &bnep_proto, 1);
185 if (!sk) 218 if (!sk)
186 return -ENOMEM; 219 return -ENOMEM;
187 220
diff --git a/net/bluetooth/cmtp/sock.c b/net/bluetooth/cmtp/sock.c
index 10ad7fd91d83..53295d33dc5c 100644
--- a/net/bluetooth/cmtp/sock.c
+++ b/net/bluetooth/cmtp/sock.c
@@ -34,6 +34,7 @@
34#include <linux/socket.h> 34#include <linux/socket.h>
35#include <linux/ioctl.h> 35#include <linux/ioctl.h>
36#include <linux/file.h> 36#include <linux/file.h>
37#include <linux/compat.h>
37#include <net/sock.h> 38#include <net/sock.h>
38 39
39#include <linux/isdn/capilli.h> 40#include <linux/isdn/capilli.h>
@@ -137,11 +138,43 @@ static int cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
137 return -EINVAL; 138 return -EINVAL;
138} 139}
139 140
141#ifdef CONFIG_COMPAT
142static int cmtp_sock_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
143{
144 if (cmd == CMTPGETCONNLIST) {
145 struct cmtp_connlist_req cl;
146 uint32_t uci;
147 int err;
148
149 if (get_user(cl.cnum, (uint32_t __user *) arg) ||
150 get_user(uci, (u32 __user *) (arg + 4)))
151 return -EFAULT;
152
153 cl.ci = compat_ptr(uci);
154
155 if (cl.cnum <= 0)
156 return -EINVAL;
157
158 err = cmtp_get_connlist(&cl);
159
160 if (!err && put_user(cl.cnum, (uint32_t __user *) arg))
161 err = -EFAULT;
162
163 return err;
164 }
165
166 return cmtp_sock_ioctl(sock, cmd, arg);
167}
168#endif
169
140static const struct proto_ops cmtp_sock_ops = { 170static const struct proto_ops cmtp_sock_ops = {
141 .family = PF_BLUETOOTH, 171 .family = PF_BLUETOOTH,
142 .owner = THIS_MODULE, 172 .owner = THIS_MODULE,
143 .release = cmtp_sock_release, 173 .release = cmtp_sock_release,
144 .ioctl = cmtp_sock_ioctl, 174 .ioctl = cmtp_sock_ioctl,
175#ifdef CONFIG_COMPAT
176 .compat_ioctl = cmtp_sock_compat_ioctl,
177#endif
145 .bind = sock_no_bind, 178 .bind = sock_no_bind,
146 .getname = sock_no_getname, 179 .getname = sock_no_getname,
147 .sendmsg = sock_no_sendmsg, 180 .sendmsg = sock_no_sendmsg,
@@ -172,7 +205,7 @@ static int cmtp_sock_create(struct socket *sock, int protocol)
172 if (sock->type != SOCK_RAW) 205 if (sock->type != SOCK_RAW)
173 return -ESOCKTNOSUPPORT; 206 return -ESOCKTNOSUPPORT;
174 207
175 sk = sk_alloc(PF_BLUETOOTH, GFP_KERNEL, &cmtp_proto, 1); 208 sk = sk_alloc(PF_BLUETOOTH, GFP_ATOMIC, &cmtp_proto, 1);
176 if (!sk) 209 if (!sk)
177 return -ENOMEM; 210 return -ENOMEM;
178 211
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 90e3a285a17e..6cd5711fa28a 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -51,7 +51,7 @@
51#define BT_DBG(D...) 51#define BT_DBG(D...)
52#endif 52#endif
53 53
54static void hci_acl_connect(struct hci_conn *conn) 54void hci_acl_connect(struct hci_conn *conn)
55{ 55{
56 struct hci_dev *hdev = conn->hdev; 56 struct hci_dev *hdev = conn->hdev;
57 struct inquiry_entry *ie; 57 struct inquiry_entry *ie;
@@ -63,6 +63,8 @@ static void hci_acl_connect(struct hci_conn *conn)
63 conn->out = 1; 63 conn->out = 1;
64 conn->link_mode = HCI_LM_MASTER; 64 conn->link_mode = HCI_LM_MASTER;
65 65
66 conn->attempt++;
67
66 memset(&cp, 0, sizeof(cp)); 68 memset(&cp, 0, sizeof(cp));
67 bacpy(&cp.bdaddr, &conn->dst); 69 bacpy(&cp.bdaddr, &conn->dst);
68 cp.pscan_rep_mode = 0x02; 70 cp.pscan_rep_mode = 0x02;
@@ -80,7 +82,7 @@ static void hci_acl_connect(struct hci_conn *conn)
80 cp.role_switch = 0x01; 82 cp.role_switch = 0x01;
81 else 83 else
82 cp.role_switch = 0x00; 84 cp.role_switch = 0x00;
83 85
84 hci_send_cmd(hdev, OGF_LINK_CTL, OCF_CREATE_CONN, sizeof(cp), &cp); 86 hci_send_cmd(hdev, OGF_LINK_CTL, OCF_CREATE_CONN, sizeof(cp), &cp);
85} 87}
86 88
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index d43d0c890975..bb94e6da223c 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -57,6 +57,7 @@
57static void hci_cc_link_ctl(struct hci_dev *hdev, __u16 ocf, struct sk_buff *skb) 57static void hci_cc_link_ctl(struct hci_dev *hdev, __u16 ocf, struct sk_buff *skb)
58{ 58{
59 __u8 status; 59 __u8 status;
60 struct hci_conn *pend;
60 61
61 BT_DBG("%s ocf 0x%x", hdev->name, ocf); 62 BT_DBG("%s ocf 0x%x", hdev->name, ocf);
62 63
@@ -71,6 +72,15 @@ static void hci_cc_link_ctl(struct hci_dev *hdev, __u16 ocf, struct sk_buff *skb
71 clear_bit(HCI_INQUIRY, &hdev->flags); 72 clear_bit(HCI_INQUIRY, &hdev->flags);
72 hci_req_complete(hdev, status); 73 hci_req_complete(hdev, status);
73 } 74 }
75
76 hci_dev_lock(hdev);
77
78 pend = hci_conn_hash_lookup_state(hdev, ACL_LINK, BT_CONNECT2);
79 if (pend)
80 hci_acl_connect(pend);
81
82 hci_dev_unlock(hdev);
83
74 break; 84 break;
75 85
76 default: 86 default:
@@ -414,9 +424,12 @@ static inline void hci_cs_create_conn(struct hci_dev *hdev, __u8 status)
414 424
415 if (status) { 425 if (status) {
416 if (conn && conn->state == BT_CONNECT) { 426 if (conn && conn->state == BT_CONNECT) {
417 conn->state = BT_CLOSED; 427 if (status != 0x0c || conn->attempt > 2) {
418 hci_proto_connect_cfm(conn, status); 428 conn->state = BT_CLOSED;
419 hci_conn_del(conn); 429 hci_proto_connect_cfm(conn, status);
430 hci_conn_del(conn);
431 } else
432 conn->state = BT_CONNECT2;
420 } 433 }
421 } else { 434 } else {
422 if (!conn) { 435 if (!conn) {
@@ -562,11 +575,20 @@ static void hci_cs_info_param(struct hci_dev *hdev, __u16 ocf, __u8 status)
562static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) 575static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
563{ 576{
564 __u8 status = *((__u8 *) skb->data); 577 __u8 status = *((__u8 *) skb->data);
578 struct hci_conn *pend;
565 579
566 BT_DBG("%s status %d", hdev->name, status); 580 BT_DBG("%s status %d", hdev->name, status);
567 581
568 clear_bit(HCI_INQUIRY, &hdev->flags); 582 clear_bit(HCI_INQUIRY, &hdev->flags);
569 hci_req_complete(hdev, status); 583 hci_req_complete(hdev, status);
584
585 hci_dev_lock(hdev);
586
587 pend = hci_conn_hash_lookup_state(hdev, ACL_LINK, BT_CONNECT2);
588 if (pend)
589 hci_acl_connect(pend);
590
591 hci_dev_unlock(hdev);
570} 592}
571 593
572/* Inquiry Result */ 594/* Inquiry Result */
@@ -728,7 +750,7 @@ static inline void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *sk
728static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) 750static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
729{ 751{
730 struct hci_ev_conn_complete *ev = (struct hci_ev_conn_complete *) skb->data; 752 struct hci_ev_conn_complete *ev = (struct hci_ev_conn_complete *) skb->data;
731 struct hci_conn *conn; 753 struct hci_conn *conn, *pend;
732 754
733 BT_DBG("%s", hdev->name); 755 BT_DBG("%s", hdev->name);
734 756
@@ -801,6 +823,10 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s
801 if (ev->status) 823 if (ev->status)
802 hci_conn_del(conn); 824 hci_conn_del(conn);
803 825
826 pend = hci_conn_hash_lookup_state(hdev, ACL_LINK, BT_CONNECT2);
827 if (pend)
828 hci_acl_connect(pend);
829
804 hci_dev_unlock(hdev); 830 hci_dev_unlock(hdev);
805} 831}
806 832
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 1a35d343e08a..711a085eca5b 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -120,10 +120,13 @@ void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb)
120 if (!hci_test_bit(evt, &flt->event_mask)) 120 if (!hci_test_bit(evt, &flt->event_mask))
121 continue; 121 continue;
122 122
123 if (flt->opcode && ((evt == HCI_EV_CMD_COMPLETE && 123 if (flt->opcode &&
124 flt->opcode != *(__u16 *)(skb->data + 3)) || 124 ((evt == HCI_EV_CMD_COMPLETE &&
125 (evt == HCI_EV_CMD_STATUS && 125 flt->opcode !=
126 flt->opcode != *(__u16 *)(skb->data + 4)))) 126 get_unaligned((__u16 *)(skb->data + 3))) ||
127 (evt == HCI_EV_CMD_STATUS &&
128 flt->opcode !=
129 get_unaligned((__u16 *)(skb->data + 4)))))
127 continue; 130 continue;
128 } 131 }
129 132
@@ -618,7 +621,7 @@ static int hci_sock_create(struct socket *sock, int protocol)
618 621
619 sock->ops = &hci_sock_ops; 622 sock->ops = &hci_sock_ops;
620 623
621 sk = sk_alloc(PF_BLUETOOTH, GFP_KERNEL, &hci_sk_proto, 1); 624 sk = sk_alloc(PF_BLUETOOTH, GFP_ATOMIC, &hci_sk_proto, 1);
622 if (!sk) 625 if (!sk)
623 return -ENOMEM; 626 return -ENOMEM;
624 627
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 989b22d9042e..3eeeb7a86e75 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -242,10 +242,14 @@ static void add_conn(void *data)
242 struct hci_conn *conn = data; 242 struct hci_conn *conn = data;
243 int i; 243 int i;
244 244
245 device_register(&conn->dev); 245 if (device_register(&conn->dev) < 0) {
246 BT_ERR("Failed to register connection device");
247 return;
248 }
246 249
247 for (i = 0; conn_attrs[i]; i++) 250 for (i = 0; conn_attrs[i]; i++)
248 device_create_file(&conn->dev, conn_attrs[i]); 251 if (device_create_file(&conn->dev, conn_attrs[i]) < 0)
252 BT_ERR("Failed to create connection attribute");
249} 253}
250 254
251void hci_conn_add_sysfs(struct hci_conn *conn) 255void hci_conn_add_sysfs(struct hci_conn *conn)
@@ -255,7 +259,9 @@ void hci_conn_add_sysfs(struct hci_conn *conn)
255 259
256 BT_DBG("conn %p", conn); 260 BT_DBG("conn %p", conn);
257 261
258 conn->dev.parent = &hdev->dev; 262 conn->dev.bus = &bt_bus;
263 conn->dev.parent = &hdev->dev;
264
259 conn->dev.release = bt_release; 265 conn->dev.release = bt_release;
260 266
261 snprintf(conn->dev.bus_id, BUS_ID_SIZE, 267 snprintf(conn->dev.bus_id, BUS_ID_SIZE,
@@ -295,11 +301,7 @@ int hci_register_sysfs(struct hci_dev *hdev)
295 BT_DBG("%p name %s type %d", hdev, hdev->name, hdev->type); 301 BT_DBG("%p name %s type %d", hdev, hdev->name, hdev->type);
296 302
297 dev->class = bt_class; 303 dev->class = bt_class;
298 304 dev->parent = hdev->parent;
299 if (hdev->parent)
300 dev->parent = hdev->parent;
301 else
302 dev->parent = &bt_platform->dev;
303 305
304 strlcpy(dev->bus_id, hdev->name, BUS_ID_SIZE); 306 strlcpy(dev->bus_id, hdev->name, BUS_ID_SIZE);
305 307
@@ -312,7 +314,8 @@ int hci_register_sysfs(struct hci_dev *hdev)
312 return err; 314 return err;
313 315
314 for (i = 0; bt_attrs[i]; i++) 316 for (i = 0; bt_attrs[i]; i++)
315 device_create_file(dev, bt_attrs[i]); 317 if (device_create_file(dev, bt_attrs[i]) < 0)
318 BT_ERR("Failed to create device attribute");
316 319
317 return 0; 320 return 0;
318} 321}
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index 03b5dadb4951..66782010f82c 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -507,14 +507,12 @@ static int hidp_session(void *arg)
507 507
508 hidp_del_timer(session); 508 hidp_del_timer(session);
509 509
510 if (intr_sk->sk_state != BT_CONNECTED) 510 fput(session->intr_sock->file);
511 wait_event_timeout(*(ctrl_sk->sk_sleep), (ctrl_sk->sk_state == BT_CLOSED), HZ);
512
513 fput(session->ctrl_sock->file);
514 511
515 wait_event_timeout(*(intr_sk->sk_sleep), (intr_sk->sk_state == BT_CLOSED), HZ); 512 wait_event_timeout(*(ctrl_sk->sk_sleep),
513 (ctrl_sk->sk_state == BT_CLOSED), msecs_to_jiffies(500));
516 514
517 fput(session->intr_sock->file); 515 fput(session->ctrl_sock->file);
518 516
519 __hidp_unlink_session(session); 517 __hidp_unlink_session(session);
520 518
@@ -541,12 +539,10 @@ static struct device *hidp_get_device(struct hidp_session *session)
541 return NULL; 539 return NULL;
542 540
543 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst); 541 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst);
544 if (!conn)
545 return NULL;
546 542
547 hci_dev_put(hdev); 543 hci_dev_put(hdev);
548 544
549 return &conn->dev; 545 return conn ? &conn->dev : NULL;
550} 546}
551 547
552static inline void hidp_setup_input(struct hidp_session *session, struct hidp_connadd_req *req) 548static inline void hidp_setup_input(struct hidp_session *session, struct hidp_connadd_req *req)
diff --git a/net/bluetooth/hidp/sock.c b/net/bluetooth/hidp/sock.c
index 099646e4e2ef..407fba43c1b9 100644
--- a/net/bluetooth/hidp/sock.c
+++ b/net/bluetooth/hidp/sock.c
@@ -35,6 +35,7 @@
35#include <linux/ioctl.h> 35#include <linux/ioctl.h>
36#include <linux/file.h> 36#include <linux/file.h>
37#include <linux/init.h> 37#include <linux/init.h>
38#include <linux/compat.h>
38#include <net/sock.h> 39#include <net/sock.h>
39 40
40#include "hidp.h" 41#include "hidp.h"
@@ -143,11 +144,88 @@ static int hidp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
143 return -EINVAL; 144 return -EINVAL;
144} 145}
145 146
147#ifdef CONFIG_COMPAT
148struct compat_hidp_connadd_req {
149 int ctrl_sock; // Connected control socket
150 int intr_sock; // Connteted interrupt socket
151 __u16 parser;
152 __u16 rd_size;
153 compat_uptr_t rd_data;
154 __u8 country;
155 __u8 subclass;
156 __u16 vendor;
157 __u16 product;
158 __u16 version;
159 __u32 flags;
160 __u32 idle_to;
161 char name[128];
162};
163
164static int hidp_sock_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
165{
166 if (cmd == HIDPGETCONNLIST) {
167 struct hidp_connlist_req cl;
168 uint32_t uci;
169 int err;
170
171 if (get_user(cl.cnum, (uint32_t __user *) arg) ||
172 get_user(uci, (u32 __user *) (arg + 4)))
173 return -EFAULT;
174
175 cl.ci = compat_ptr(uci);
176
177 if (cl.cnum <= 0)
178 return -EINVAL;
179
180 err = hidp_get_connlist(&cl);
181
182 if (!err && put_user(cl.cnum, (uint32_t __user *) arg))
183 err = -EFAULT;
184
185 return err;
186 } else if (cmd == HIDPCONNADD) {
187 struct compat_hidp_connadd_req ca;
188 struct hidp_connadd_req __user *uca;
189
190 uca = compat_alloc_user_space(sizeof(*uca));
191
192 if (copy_from_user(&ca, (void *) arg, sizeof(ca)))
193 return -EFAULT;
194
195 if (put_user(ca.ctrl_sock, &uca->ctrl_sock) ||
196 put_user(ca.intr_sock, &uca->intr_sock) ||
197 put_user(ca.parser, &uca->parser) ||
198 put_user(ca.rd_size, &uca->parser) ||
199 put_user(compat_ptr(ca.rd_data), &uca->rd_data) ||
200 put_user(ca.country, &uca->country) ||
201 put_user(ca.subclass, &uca->subclass) ||
202 put_user(ca.vendor, &uca->vendor) ||
203 put_user(ca.product, &uca->product) ||
204 put_user(ca.version, &uca->version) ||
205 put_user(ca.flags, &uca->flags) ||
206 put_user(ca.idle_to, &uca->idle_to) ||
207 copy_to_user(&uca->name[0], &ca.name[0], 128))
208 return -EFAULT;
209
210 arg = (unsigned long) uca;
211
212 /* Fall through. We don't actually write back any _changes_
213 to the structure anyway, so there's no need to copy back
214 into the original compat version */
215 }
216
217 return hidp_sock_ioctl(sock, cmd, arg);
218}
219#endif
220
146static const struct proto_ops hidp_sock_ops = { 221static const struct proto_ops hidp_sock_ops = {
147 .family = PF_BLUETOOTH, 222 .family = PF_BLUETOOTH,
148 .owner = THIS_MODULE, 223 .owner = THIS_MODULE,
149 .release = hidp_sock_release, 224 .release = hidp_sock_release,
150 .ioctl = hidp_sock_ioctl, 225 .ioctl = hidp_sock_ioctl,
226#ifdef CONFIG_COMPAT
227 .compat_ioctl = hidp_sock_compat_ioctl,
228#endif
151 .bind = sock_no_bind, 229 .bind = sock_no_bind,
152 .getname = sock_no_getname, 230 .getname = sock_no_getname,
153 .sendmsg = sock_no_sendmsg, 231 .sendmsg = sock_no_sendmsg,
@@ -178,7 +256,7 @@ static int hidp_sock_create(struct socket *sock, int protocol)
178 if (sock->type != SOCK_RAW) 256 if (sock->type != SOCK_RAW)
179 return -ESOCKTNOSUPPORT; 257 return -ESOCKTNOSUPPORT;
180 258
181 sk = sk_alloc(PF_BLUETOOTH, GFP_KERNEL, &hidp_proto, 1); 259 sk = sk_alloc(PF_BLUETOOTH, GFP_ATOMIC, &hidp_proto, 1);
182 if (!sk) 260 if (!sk)
183 return -ENOMEM; 261 return -ENOMEM;
184 262
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index d56f60b392ac..bbf78e6a7bc3 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -559,7 +559,7 @@ static int l2cap_sock_create(struct socket *sock, int protocol)
559 559
560 sock->ops = &l2cap_sock_ops; 560 sock->ops = &l2cap_sock_ops;
561 561
562 sk = l2cap_sock_alloc(sock, protocol, GFP_KERNEL); 562 sk = l2cap_sock_alloc(sock, protocol, GFP_ATOMIC);
563 if (!sk) 563 if (!sk)
564 return -ENOMEM; 564 return -ENOMEM;
565 565
@@ -1353,12 +1353,12 @@ static inline int l2cap_conf_output(struct sock *sk, void **ptr)
1353 1353
1354 /* Configure output options and let the other side know 1354 /* Configure output options and let the other side know
1355 * which ones we don't like. */ 1355 * which ones we don't like. */
1356 if (pi->conf_mtu < pi->omtu) { 1356 if (pi->conf_mtu < pi->omtu)
1357 l2cap_add_conf_opt(ptr, L2CAP_CONF_MTU, 2, pi->omtu);
1358 result = L2CAP_CONF_UNACCEPT; 1357 result = L2CAP_CONF_UNACCEPT;
1359 } else { 1358 else
1360 pi->omtu = pi->conf_mtu; 1359 pi->omtu = pi->conf_mtu;
1361 } 1360
1361 l2cap_add_conf_opt(ptr, L2CAP_CONF_MTU, 2, pi->omtu);
1362 1362
1363 BT_DBG("sk %p result %d", sk, result); 1363 BT_DBG("sk %p result %d", sk, result);
1364 return result; 1364 return result;
@@ -1533,6 +1533,9 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr
1533 if (!(sk = l2cap_get_chan_by_scid(&conn->chan_list, dcid))) 1533 if (!(sk = l2cap_get_chan_by_scid(&conn->chan_list, dcid)))
1534 return -ENOENT; 1534 return -ENOENT;
1535 1535
1536 if (sk->sk_state == BT_DISCONN)
1537 goto unlock;
1538
1536 l2cap_parse_conf_req(sk, req->data, cmd->len - sizeof(*req)); 1539 l2cap_parse_conf_req(sk, req->data, cmd->len - sizeof(*req));
1537 1540
1538 if (flags & 0x0001) { 1541 if (flags & 0x0001) {
@@ -2216,7 +2219,8 @@ static int __init l2cap_init(void)
2216 goto error; 2219 goto error;
2217 } 2220 }
2218 2221
2219 class_create_file(bt_class, &class_attr_l2cap); 2222 if (class_create_file(bt_class, &class_attr_l2cap) < 0)
2223 BT_ERR("Failed to create L2CAP info file");
2220 2224
2221 BT_INFO("L2CAP ver %s", VERSION); 2225 BT_INFO("L2CAP ver %s", VERSION);
2222 BT_INFO("L2CAP socket layer initialized"); 2226 BT_INFO("L2CAP socket layer initialized");
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index 468df3b953f6..ddc4e9d5963e 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -2058,7 +2058,8 @@ static int __init rfcomm_init(void)
2058 2058
2059 kernel_thread(rfcomm_run, NULL, CLONE_KERNEL); 2059 kernel_thread(rfcomm_run, NULL, CLONE_KERNEL);
2060 2060
2061 class_create_file(bt_class, &class_attr_rfcomm_dlc); 2061 if (class_create_file(bt_class, &class_attr_rfcomm_dlc) < 0)
2062 BT_ERR("Failed to create RFCOMM info file");
2062 2063
2063 rfcomm_init_sockets(); 2064 rfcomm_init_sockets();
2064 2065
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index 220fee04e7f2..544d65b7baa7 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -336,7 +336,8 @@ static int rfcomm_sock_create(struct socket *sock, int protocol)
336 336
337 sock->ops = &rfcomm_sock_ops; 337 sock->ops = &rfcomm_sock_ops;
338 338
339 if (!(sk = rfcomm_sock_alloc(sock, protocol, GFP_KERNEL))) 339 sk = rfcomm_sock_alloc(sock, protocol, GFP_ATOMIC);
340 if (!sk)
340 return -ENOMEM; 341 return -ENOMEM;
341 342
342 rfcomm_sock_init(sk, NULL); 343 rfcomm_sock_init(sk, NULL);
@@ -944,7 +945,8 @@ int __init rfcomm_init_sockets(void)
944 if (err < 0) 945 if (err < 0)
945 goto error; 946 goto error;
946 947
947 class_create_file(bt_class, &class_attr_rfcomm); 948 if (class_create_file(bt_class, &class_attr_rfcomm) < 0)
949 BT_ERR("Failed to create RFCOMM info file");
948 950
949 BT_INFO("RFCOMM socket layer initialized"); 951 BT_INFO("RFCOMM socket layer initialized");
950 952
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index 1958ad1b8541..1fb5d42f37ae 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -172,12 +172,10 @@ static struct device *rfcomm_get_device(struct rfcomm_dev *dev)
172 return NULL; 172 return NULL;
173 173
174 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &dev->dst); 174 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &dev->dst);
175 if (!conn)
176 return NULL;
177 175
178 hci_dev_put(hdev); 176 hci_dev_put(hdev);
179 177
180 return &conn->dev; 178 return conn ? &conn->dev : NULL;
181} 179}
182 180
183static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc) 181static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
@@ -767,6 +765,9 @@ static void rfcomm_tty_set_termios(struct tty_struct *tty, struct termios *old)
767 765
768 BT_DBG("tty %p termios %p", tty, old); 766 BT_DBG("tty %p termios %p", tty, old);
769 767
768 if (!dev || !dev->dlc || !dev->dlc->session)
769 return;
770
770 /* Handle turning off CRTSCTS */ 771 /* Handle turning off CRTSCTS */
771 if ((old->c_cflag & CRTSCTS) && !(new->c_cflag & CRTSCTS)) 772 if ((old->c_cflag & CRTSCTS) && !(new->c_cflag & CRTSCTS))
772 BT_DBG("Turning off CRTSCTS unsupported"); 773 BT_DBG("Turning off CRTSCTS unsupported");
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index 7714a2ec3854..5d13d4f31753 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -452,7 +452,8 @@ static int sco_sock_create(struct socket *sock, int protocol)
452 452
453 sock->ops = &sco_sock_ops; 453 sock->ops = &sco_sock_ops;
454 454
455 if (!(sk = sco_sock_alloc(sock, protocol, GFP_KERNEL))) 455 sk = sco_sock_alloc(sock, protocol, GFP_ATOMIC);
456 if (!sk)
456 return -ENOMEM; 457 return -ENOMEM;
457 458
458 sco_sock_init(sk, NULL); 459 sco_sock_init(sk, NULL);
@@ -967,7 +968,8 @@ static int __init sco_init(void)
967 goto error; 968 goto error;
968 } 969 }
969 970
970 class_create_file(bt_class, &class_attr_sco); 971 if (class_create_file(bt_class, &class_attr_sco) < 0)
972 BT_ERR("Failed to create SCO info file");
971 973
972 BT_INFO("SCO (Voice Link) ver %s", VERSION); 974 BT_INFO("SCO (Voice Link) ver %s", VERSION);
973 BT_INFO("SCO socket layer initialized"); 975 BT_INFO("SCO socket layer initialized");
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index 3a73b8c94271..d9f04864d15d 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -128,7 +128,10 @@ void br_fdb_cleanup(unsigned long _data)
128 mod_timer(&br->gc_timer, jiffies + HZ/10); 128 mod_timer(&br->gc_timer, jiffies + HZ/10);
129} 129}
130 130
131void br_fdb_delete_by_port(struct net_bridge *br, struct net_bridge_port *p) 131
132void br_fdb_delete_by_port(struct net_bridge *br,
133 const struct net_bridge_port *p,
134 int do_all)
132{ 135{
133 int i; 136 int i;
134 137
@@ -142,6 +145,8 @@ void br_fdb_delete_by_port(struct net_bridge *br, struct net_bridge_port *p)
142 if (f->dst != p) 145 if (f->dst != p)
143 continue; 146 continue;
144 147
148 if (f->is_static && !do_all)
149 continue;
145 /* 150 /*
146 * if multiple ports all have the same device address 151 * if multiple ports all have the same device address
147 * then when one port is deleted, assign 152 * then when one port is deleted, assign
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index b1211d5342f6..f753c40c11d2 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -163,7 +163,7 @@ static void del_nbp(struct net_bridge_port *p)
163 br_stp_disable_port(p); 163 br_stp_disable_port(p);
164 spin_unlock_bh(&br->lock); 164 spin_unlock_bh(&br->lock);
165 165
166 br_fdb_delete_by_port(br, p); 166 br_fdb_delete_by_port(br, p, 1);
167 167
168 list_del_rcu(&p->list); 168 list_del_rcu(&p->list);
169 169
@@ -448,7 +448,7 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
448 448
449 return 0; 449 return 0;
450err2: 450err2:
451 br_fdb_delete_by_port(br, p); 451 br_fdb_delete_by_port(br, p, 1);
452err1: 452err1:
453 kobject_del(&p->kobj); 453 kobject_del(&p->kobj);
454err0: 454err0:
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index c491fb2f280e..74258d86f256 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -143,7 +143,7 @@ extern void br_fdb_changeaddr(struct net_bridge_port *p,
143 const unsigned char *newaddr); 143 const unsigned char *newaddr);
144extern void br_fdb_cleanup(unsigned long arg); 144extern void br_fdb_cleanup(unsigned long arg);
145extern void br_fdb_delete_by_port(struct net_bridge *br, 145extern void br_fdb_delete_by_port(struct net_bridge *br,
146 struct net_bridge_port *p); 146 const struct net_bridge_port *p, int do_all);
147extern struct net_bridge_fdb_entry *__br_fdb_get(struct net_bridge *br, 147extern struct net_bridge_fdb_entry *__br_fdb_get(struct net_bridge *br,
148 const unsigned char *addr); 148 const unsigned char *addr);
149extern struct net_bridge_fdb_entry *br_fdb_get(struct net_bridge *br, 149extern struct net_bridge_fdb_entry *br_fdb_get(struct net_bridge *br,
diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
index 14cd025079af..d294224592db 100644
--- a/net/bridge/br_stp_if.c
+++ b/net/bridge/br_stp_if.c
@@ -113,6 +113,8 @@ void br_stp_disable_port(struct net_bridge_port *p)
113 del_timer(&p->forward_delay_timer); 113 del_timer(&p->forward_delay_timer);
114 del_timer(&p->hold_timer); 114 del_timer(&p->hold_timer);
115 115
116 br_fdb_delete_by_port(br, p, 0);
117
116 br_configuration_update(br); 118 br_configuration_update(br);
117 119
118 br_port_state_selection(br); 120 br_port_state_selection(br);
diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c
index 96bcb2ff59ab..de9d1a9473f2 100644
--- a/net/bridge/br_sysfs_br.c
+++ b/net/bridge/br_sysfs_br.c
@@ -376,7 +376,7 @@ int br_sysfs_addbr(struct net_device *dev)
376 376
377 err = sysfs_create_bin_file(brobj, &bridge_forward); 377 err = sysfs_create_bin_file(brobj, &bridge_forward);
378 if (err) { 378 if (err) {
379 pr_info("%s: can't create attribue file %s/%s\n", 379 pr_info("%s: can't create attribute file %s/%s\n",
380 __FUNCTION__, dev->name, bridge_forward.attr.name); 380 __FUNCTION__, dev->name, bridge_forward.attr.name);
381 goto out2; 381 goto out2;
382 } 382 }
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index 3df55b2bd91d..9f85666f29f7 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -86,7 +86,7 @@ static inline int ebt_do_match (struct ebt_entry_match *m,
86static inline int ebt_dev_check(char *entry, const struct net_device *device) 86static inline int ebt_dev_check(char *entry, const struct net_device *device)
87{ 87{
88 int i = 0; 88 int i = 0;
89 char *devname = device->name; 89 const char *devname = device->name;
90 90
91 if (*entry == '\0') 91 if (*entry == '\0')
92 return 0; 92 return 0;
diff --git a/net/compat.c b/net/compat.c
index d5d69fa15d07..52d32f1bc728 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -285,8 +285,7 @@ void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
285 285
286 if (i > 0) { 286 if (i > 0) {
287 int cmlen = CMSG_COMPAT_LEN(i * sizeof(int)); 287 int cmlen = CMSG_COMPAT_LEN(i * sizeof(int));
288 if (!err) 288 err = put_user(SOL_SOCKET, &cm->cmsg_level);
289 err = put_user(SOL_SOCKET, &cm->cmsg_level);
290 if (!err) 289 if (!err)
291 err = put_user(SCM_RIGHTS, &cm->cmsg_type); 290 err = put_user(SCM_RIGHTS, &cm->cmsg_type);
292 if (!err) 291 if (!err)
diff --git a/net/core/dev.c b/net/core/dev.c
index 4d891beab138..81c426adcd1e 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3502,8 +3502,6 @@ static int __init net_dev_init(void)
3502 3502
3503 BUG_ON(!dev_boot_phase); 3503 BUG_ON(!dev_boot_phase);
3504 3504
3505 net_random_init();
3506
3507 if (dev_proc_init()) 3505 if (dev_proc_init())
3508 goto out; 3506 goto out;
3509 3507
diff --git a/net/core/flow.c b/net/core/flow.c
index f23e7e386543..b16d31ae5e54 100644
--- a/net/core/flow.c
+++ b/net/core/flow.c
@@ -85,6 +85,14 @@ static void flow_cache_new_hashrnd(unsigned long arg)
85 add_timer(&flow_hash_rnd_timer); 85 add_timer(&flow_hash_rnd_timer);
86} 86}
87 87
88static void flow_entry_kill(int cpu, struct flow_cache_entry *fle)
89{
90 if (fle->object)
91 atomic_dec(fle->object_ref);
92 kmem_cache_free(flow_cachep, fle);
93 flow_count(cpu)--;
94}
95
88static void __flow_cache_shrink(int cpu, int shrink_to) 96static void __flow_cache_shrink(int cpu, int shrink_to)
89{ 97{
90 struct flow_cache_entry *fle, **flp; 98 struct flow_cache_entry *fle, **flp;
@@ -100,10 +108,7 @@ static void __flow_cache_shrink(int cpu, int shrink_to)
100 } 108 }
101 while ((fle = *flp) != NULL) { 109 while ((fle = *flp) != NULL) {
102 *flp = fle->next; 110 *flp = fle->next;
103 if (fle->object) 111 flow_entry_kill(cpu, fle);
104 atomic_dec(fle->object_ref);
105 kmem_cache_free(flow_cachep, fle);
106 flow_count(cpu)--;
107 } 112 }
108 } 113 }
109} 114}
@@ -220,24 +225,33 @@ void *flow_cache_lookup(struct flowi *key, u16 family, u8 dir,
220 225
221nocache: 226nocache:
222 { 227 {
228 int err;
223 void *obj; 229 void *obj;
224 atomic_t *obj_ref; 230 atomic_t *obj_ref;
225 231
226 resolver(key, family, dir, &obj, &obj_ref); 232 err = resolver(key, family, dir, &obj, &obj_ref);
227 233
228 if (fle) { 234 if (fle) {
229 fle->genid = atomic_read(&flow_cache_genid); 235 if (err) {
230 236 /* Force security policy check on next lookup */
231 if (fle->object) 237 *head = fle->next;
232 atomic_dec(fle->object_ref); 238 flow_entry_kill(cpu, fle);
233 239 } else {
234 fle->object = obj; 240 fle->genid = atomic_read(&flow_cache_genid);
235 fle->object_ref = obj_ref; 241
236 if (obj) 242 if (fle->object)
237 atomic_inc(fle->object_ref); 243 atomic_dec(fle->object_ref);
244
245 fle->object = obj;
246 fle->object_ref = obj_ref;
247 if (obj)
248 atomic_inc(fle->object_ref);
249 }
238 } 250 }
239 local_bh_enable(); 251 local_bh_enable();
240 252
253 if (err)
254 obj = ERR_PTR(err);
241 return obj; 255 return obj;
242 } 256 }
243} 257}
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index ead5920c26d6..6589adb14cbf 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -335,13 +335,19 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
335 memcpy(skb->data, msg, len); 335 memcpy(skb->data, msg, len);
336 skb->len += len; 336 skb->len += len;
337 337
338 udph = (struct udphdr *) skb_push(skb, sizeof(*udph)); 338 skb->h.uh = udph = (struct udphdr *) skb_push(skb, sizeof(*udph));
339 udph->source = htons(np->local_port); 339 udph->source = htons(np->local_port);
340 udph->dest = htons(np->remote_port); 340 udph->dest = htons(np->remote_port);
341 udph->len = htons(udp_len); 341 udph->len = htons(udp_len);
342 udph->check = 0; 342 udph->check = 0;
343 udph->check = csum_tcpudp_magic(htonl(np->local_ip),
344 htonl(np->remote_ip),
345 udp_len, IPPROTO_UDP,
346 csum_partial((unsigned char *)udph, udp_len, 0));
347 if (udph->check == 0)
348 udph->check = -1;
343 349
344 iph = (struct iphdr *)skb_push(skb, sizeof(*iph)); 350 skb->nh.iph = iph = (struct iphdr *)skb_push(skb, sizeof(*iph));
345 351
346 /* iph->version = 4; iph->ihl = 5; */ 352 /* iph->version = 4; iph->ihl = 5; */
347 put_unaligned(0x45, (unsigned char *)iph); 353 put_unaligned(0x45, (unsigned char *)iph);
@@ -357,8 +363,8 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
357 iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl); 363 iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl);
358 364
359 eth = (struct ethhdr *) skb_push(skb, ETH_HLEN); 365 eth = (struct ethhdr *) skb_push(skb, ETH_HLEN);
360 366 skb->mac.raw = skb->data;
361 eth->h_proto = htons(ETH_P_IP); 367 skb->protocol = eth->h_proto = htons(ETH_P_IP);
362 memcpy(eth->h_source, np->local_mac, 6); 368 memcpy(eth->h_source, np->local_mac, 6);
363 memcpy(eth->h_dest, np->remote_mac, 6); 369 memcpy(eth->h_dest, np->remote_mac, 6);
364 370
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index dd023fd28304..733d86d0a4fb 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -2304,6 +2304,12 @@ static void mpls_push(__be32 *mpls, struct pktgen_dev *pkt_dev)
2304 *mpls |= MPLS_STACK_BOTTOM; 2304 *mpls |= MPLS_STACK_BOTTOM;
2305} 2305}
2306 2306
2307static inline __be16 build_tci(unsigned int id, unsigned int cfi,
2308 unsigned int prio)
2309{
2310 return htons(id | (cfi << 12) | (prio << 13));
2311}
2312
2307static struct sk_buff *fill_packet_ipv4(struct net_device *odev, 2313static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
2308 struct pktgen_dev *pkt_dev) 2314 struct pktgen_dev *pkt_dev)
2309{ 2315{
@@ -2353,16 +2359,16 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
2353 if (pkt_dev->vlan_id != 0xffff) { 2359 if (pkt_dev->vlan_id != 0xffff) {
2354 if(pkt_dev->svlan_id != 0xffff) { 2360 if(pkt_dev->svlan_id != 0xffff) {
2355 svlan_tci = (__be16 *)skb_put(skb, sizeof(__be16)); 2361 svlan_tci = (__be16 *)skb_put(skb, sizeof(__be16));
2356 *svlan_tci = htons(pkt_dev->svlan_id); 2362 *svlan_tci = build_tci(pkt_dev->svlan_id,
2357 *svlan_tci |= pkt_dev->svlan_p << 5; 2363 pkt_dev->svlan_cfi,
2358 *svlan_tci |= pkt_dev->svlan_cfi << 4; 2364 pkt_dev->svlan_p);
2359 svlan_encapsulated_proto = (__be16 *)skb_put(skb, sizeof(__be16)); 2365 svlan_encapsulated_proto = (__be16 *)skb_put(skb, sizeof(__be16));
2360 *svlan_encapsulated_proto = __constant_htons(ETH_P_8021Q); 2366 *svlan_encapsulated_proto = __constant_htons(ETH_P_8021Q);
2361 } 2367 }
2362 vlan_tci = (__be16 *)skb_put(skb, sizeof(__be16)); 2368 vlan_tci = (__be16 *)skb_put(skb, sizeof(__be16));
2363 *vlan_tci = htons(pkt_dev->vlan_id); 2369 *vlan_tci = build_tci(pkt_dev->vlan_id,
2364 *vlan_tci |= pkt_dev->vlan_p << 5; 2370 pkt_dev->vlan_cfi,
2365 *vlan_tci |= pkt_dev->vlan_cfi << 4; 2371 pkt_dev->vlan_p);
2366 vlan_encapsulated_proto = (__be16 *)skb_put(skb, sizeof(__be16)); 2372 vlan_encapsulated_proto = (__be16 *)skb_put(skb, sizeof(__be16));
2367 *vlan_encapsulated_proto = __constant_htons(ETH_P_IP); 2373 *vlan_encapsulated_proto = __constant_htons(ETH_P_IP);
2368 } 2374 }
@@ -2689,16 +2695,16 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
2689 if (pkt_dev->vlan_id != 0xffff) { 2695 if (pkt_dev->vlan_id != 0xffff) {
2690 if(pkt_dev->svlan_id != 0xffff) { 2696 if(pkt_dev->svlan_id != 0xffff) {
2691 svlan_tci = (__be16 *)skb_put(skb, sizeof(__be16)); 2697 svlan_tci = (__be16 *)skb_put(skb, sizeof(__be16));
2692 *svlan_tci = htons(pkt_dev->svlan_id); 2698 *svlan_tci = build_tci(pkt_dev->svlan_id,
2693 *svlan_tci |= pkt_dev->svlan_p << 5; 2699 pkt_dev->svlan_cfi,
2694 *svlan_tci |= pkt_dev->svlan_cfi << 4; 2700 pkt_dev->svlan_p);
2695 svlan_encapsulated_proto = (__be16 *)skb_put(skb, sizeof(__be16)); 2701 svlan_encapsulated_proto = (__be16 *)skb_put(skb, sizeof(__be16));
2696 *svlan_encapsulated_proto = __constant_htons(ETH_P_8021Q); 2702 *svlan_encapsulated_proto = __constant_htons(ETH_P_8021Q);
2697 } 2703 }
2698 vlan_tci = (__be16 *)skb_put(skb, sizeof(__be16)); 2704 vlan_tci = (__be16 *)skb_put(skb, sizeof(__be16));
2699 *vlan_tci = htons(pkt_dev->vlan_id); 2705 *vlan_tci = build_tci(pkt_dev->vlan_id,
2700 *vlan_tci |= pkt_dev->vlan_p << 5; 2706 pkt_dev->vlan_cfi,
2701 *vlan_tci |= pkt_dev->vlan_cfi << 4; 2707 pkt_dev->vlan_p);
2702 vlan_encapsulated_proto = (__be16 *)skb_put(skb, sizeof(__be16)); 2708 vlan_encapsulated_proto = (__be16 *)skb_put(skb, sizeof(__be16));
2703 *vlan_encapsulated_proto = __constant_htons(ETH_P_IPV6); 2709 *vlan_encapsulated_proto = __constant_htons(ETH_P_IPV6);
2704 } 2710 }
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 221e4038216b..02f3c7947898 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -602,7 +602,7 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
602 goto errout; 602 goto errout;
603 } 603 }
604 604
605 err = rtnl_unicast(skb, NETLINK_CB(skb).pid); 605 err = rtnl_unicast(nskb, NETLINK_CB(skb).pid);
606errout: 606errout:
607 kfree(iw_buf); 607 kfree(iw_buf);
608 dev_put(dev); 608 dev_put(dev);
diff --git a/net/core/scm.c b/net/core/scm.c
index 649d01ef35b6..271cf060ef8c 100644
--- a/net/core/scm.c
+++ b/net/core/scm.c
@@ -245,8 +245,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
245 if (i > 0) 245 if (i > 0)
246 { 246 {
247 int cmlen = CMSG_LEN(i*sizeof(int)); 247 int cmlen = CMSG_LEN(i*sizeof(int));
248 if (!err) 248 err = put_user(SOL_SOCKET, &cm->cmsg_level);
249 err = put_user(SOL_SOCKET, &cm->cmsg_level);
250 if (!err) 249 if (!err)
251 err = put_user(SCM_RIGHTS, &cm->cmsg_type); 250 err = put_user(SCM_RIGHTS, &cm->cmsg_type);
252 if (!err) 251 if (!err)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 3c23760c5827..b8b106358040 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -639,6 +639,7 @@ struct sk_buff *pskb_copy(struct sk_buff *skb, gfp_t gfp_mask)
639 n->csum = skb->csum; 639 n->csum = skb->csum;
640 n->ip_summed = skb->ip_summed; 640 n->ip_summed = skb->ip_summed;
641 641
642 n->truesize += skb->data_len;
642 n->data_len = skb->data_len; 643 n->data_len = skb->data_len;
643 n->len = skb->len; 644 n->len = skb->len;
644 645
@@ -1946,7 +1947,7 @@ struct sk_buff *skb_segment(struct sk_buff *skb, int features)
1946 do { 1947 do {
1947 struct sk_buff *nskb; 1948 struct sk_buff *nskb;
1948 skb_frag_t *frag; 1949 skb_frag_t *frag;
1949 int hsize, nsize; 1950 int hsize;
1950 int k; 1951 int k;
1951 int size; 1952 int size;
1952 1953
@@ -1957,11 +1958,10 @@ struct sk_buff *skb_segment(struct sk_buff *skb, int features)
1957 hsize = skb_headlen(skb) - offset; 1958 hsize = skb_headlen(skb) - offset;
1958 if (hsize < 0) 1959 if (hsize < 0)
1959 hsize = 0; 1960 hsize = 0;
1960 nsize = hsize + doffset; 1961 if (hsize > len || !sg)
1961 if (nsize > len + doffset || !sg) 1962 hsize = len;
1962 nsize = len + doffset;
1963 1963
1964 nskb = alloc_skb(nsize + headroom, GFP_ATOMIC); 1964 nskb = alloc_skb(hsize + doffset + headroom, GFP_ATOMIC);
1965 if (unlikely(!nskb)) 1965 if (unlikely(!nskb))
1966 goto err; 1966 goto err;
1967 1967
diff --git a/net/core/sock.c b/net/core/sock.c
index b77e155cbe6c..ee6cd2541d35 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -823,7 +823,7 @@ static void inline sock_lock_init(struct sock *sk)
823 af_family_slock_key_strings[sk->sk_family]); 823 af_family_slock_key_strings[sk->sk_family]);
824 lockdep_init_map(&sk->sk_lock.dep_map, 824 lockdep_init_map(&sk->sk_lock.dep_map,
825 af_family_key_strings[sk->sk_family], 825 af_family_key_strings[sk->sk_family],
826 af_family_keys + sk->sk_family); 826 af_family_keys + sk->sk_family, 0);
827} 827}
828 828
829/** 829/**
@@ -1160,7 +1160,7 @@ static struct sk_buff *sock_alloc_send_pskb(struct sock *sk,
1160 goto failure; 1160 goto failure;
1161 1161
1162 if (atomic_read(&sk->sk_wmem_alloc) < sk->sk_sndbuf) { 1162 if (atomic_read(&sk->sk_wmem_alloc) < sk->sk_sndbuf) {
1163 skb = alloc_skb(header_len, sk->sk_allocation); 1163 skb = alloc_skb(header_len, gfp_mask);
1164 if (skb) { 1164 if (skb) {
1165 int npages; 1165 int npages;
1166 int i; 1166 int i;
diff --git a/net/core/utils.c b/net/core/utils.c
index 94c5d761c830..d93fe64f6693 100644
--- a/net/core/utils.c
+++ b/net/core/utils.c
@@ -30,119 +30,6 @@
30#include <asm/system.h> 30#include <asm/system.h>
31#include <asm/uaccess.h> 31#include <asm/uaccess.h>
32 32
33/*
34 This is a maximally equidistributed combined Tausworthe generator
35 based on code from GNU Scientific Library 1.5 (30 Jun 2004)
36
37 x_n = (s1_n ^ s2_n ^ s3_n)
38
39 s1_{n+1} = (((s1_n & 4294967294) <<12) ^ (((s1_n <<13) ^ s1_n) >>19))
40 s2_{n+1} = (((s2_n & 4294967288) << 4) ^ (((s2_n << 2) ^ s2_n) >>25))
41 s3_{n+1} = (((s3_n & 4294967280) <<17) ^ (((s3_n << 3) ^ s3_n) >>11))
42
43 The period of this generator is about 2^88.
44
45 From: P. L'Ecuyer, "Maximally Equidistributed Combined Tausworthe
46 Generators", Mathematics of Computation, 65, 213 (1996), 203--213.
47
48 This is available on the net from L'Ecuyer's home page,
49
50 http://www.iro.umontreal.ca/~lecuyer/myftp/papers/tausme.ps
51 ftp://ftp.iro.umontreal.ca/pub/simulation/lecuyer/papers/tausme.ps
52
53 There is an erratum in the paper "Tables of Maximally
54 Equidistributed Combined LFSR Generators", Mathematics of
55 Computation, 68, 225 (1999), 261--269:
56 http://www.iro.umontreal.ca/~lecuyer/myftp/papers/tausme2.ps
57
58 ... the k_j most significant bits of z_j must be non-
59 zero, for each j. (Note: this restriction also applies to the
60 computer code given in [4], but was mistakenly not mentioned in
61 that paper.)
62
63 This affects the seeding procedure by imposing the requirement
64 s1 > 1, s2 > 7, s3 > 15.
65
66*/
67struct nrnd_state {
68 u32 s1, s2, s3;
69};
70
71static DEFINE_PER_CPU(struct nrnd_state, net_rand_state);
72
73static u32 __net_random(struct nrnd_state *state)
74{
75#define TAUSWORTHE(s,a,b,c,d) ((s&c)<<d) ^ (((s <<a) ^ s)>>b)
76
77 state->s1 = TAUSWORTHE(state->s1, 13, 19, 4294967294UL, 12);
78 state->s2 = TAUSWORTHE(state->s2, 2, 25, 4294967288UL, 4);
79 state->s3 = TAUSWORTHE(state->s3, 3, 11, 4294967280UL, 17);
80
81 return (state->s1 ^ state->s2 ^ state->s3);
82}
83
84static void __net_srandom(struct nrnd_state *state, unsigned long s)
85{
86 if (s == 0)
87 s = 1; /* default seed is 1 */
88
89#define LCG(n) (69069 * n)
90 state->s1 = LCG(s);
91 state->s2 = LCG(state->s1);
92 state->s3 = LCG(state->s2);
93
94 /* "warm it up" */
95 __net_random(state);
96 __net_random(state);
97 __net_random(state);
98 __net_random(state);
99 __net_random(state);
100 __net_random(state);
101}
102
103
104unsigned long net_random(void)
105{
106 unsigned long r;
107 struct nrnd_state *state = &get_cpu_var(net_rand_state);
108 r = __net_random(state);
109 put_cpu_var(state);
110 return r;
111}
112
113
114void net_srandom(unsigned long entropy)
115{
116 struct nrnd_state *state = &get_cpu_var(net_rand_state);
117 __net_srandom(state, state->s1^entropy);
118 put_cpu_var(state);
119}
120
121void __init net_random_init(void)
122{
123 int i;
124
125 for_each_possible_cpu(i) {
126 struct nrnd_state *state = &per_cpu(net_rand_state,i);
127 __net_srandom(state, i+jiffies);
128 }
129}
130
131static int net_random_reseed(void)
132{
133 int i;
134 unsigned long seed;
135
136 for_each_possible_cpu(i) {
137 struct nrnd_state *state = &per_cpu(net_rand_state,i);
138
139 get_random_bytes(&seed, sizeof(seed));
140 __net_srandom(state, seed);
141 }
142 return 0;
143}
144late_initcall(net_random_reseed);
145
146int net_msg_cost = 5*HZ; 33int net_msg_cost = 5*HZ;
147int net_msg_burst = 10; 34int net_msg_burst = 10;
148 35
@@ -153,10 +40,7 @@ int net_ratelimit(void)
153{ 40{
154 return __printk_ratelimit(net_msg_cost, net_msg_burst); 41 return __printk_ratelimit(net_msg_cost, net_msg_burst);
155} 42}
156
157EXPORT_SYMBOL(net_random);
158EXPORT_SYMBOL(net_ratelimit); 43EXPORT_SYMBOL(net_ratelimit);
159EXPORT_SYMBOL(net_srandom);
160 44
161/* 45/*
162 * Convert an ASCII string to binary IP. 46 * Convert an ASCII string to binary IP.
diff --git a/net/core/wireless.c b/net/core/wireless.c
index ffff0da46c6e..cb1b8728d7ee 100644
--- a/net/core/wireless.c
+++ b/net/core/wireless.c
@@ -748,11 +748,39 @@ static int ioctl_standard_call(struct net_device * dev,
748 int extra_size; 748 int extra_size;
749 int user_length = 0; 749 int user_length = 0;
750 int err; 750 int err;
751 int essid_compat = 0;
751 752
752 /* Calculate space needed by arguments. Always allocate 753 /* Calculate space needed by arguments. Always allocate
753 * for max space. Easier, and won't last long... */ 754 * for max space. Easier, and won't last long... */
754 extra_size = descr->max_tokens * descr->token_size; 755 extra_size = descr->max_tokens * descr->token_size;
755 756
757 /* Check need for ESSID compatibility for WE < 21 */
758 switch (cmd) {
759 case SIOCSIWESSID:
760 case SIOCGIWESSID:
761 case SIOCSIWNICKN:
762 case SIOCGIWNICKN:
763 if (iwr->u.data.length == descr->max_tokens + 1)
764 essid_compat = 1;
765 else if (IW_IS_SET(cmd) && (iwr->u.data.length != 0)) {
766 char essid[IW_ESSID_MAX_SIZE + 1];
767
768 err = copy_from_user(essid, iwr->u.data.pointer,
769 iwr->u.data.length *
770 descr->token_size);
771 if (err)
772 return -EFAULT;
773
774 if (essid[iwr->u.data.length - 1] == '\0')
775 essid_compat = 1;
776 }
777 break;
778 default:
779 break;
780 }
781
782 iwr->u.data.length -= essid_compat;
783
756 /* Check what user space is giving us */ 784 /* Check what user space is giving us */
757 if(IW_IS_SET(cmd)) { 785 if(IW_IS_SET(cmd)) {
758 /* Check NULL pointer */ 786 /* Check NULL pointer */
@@ -795,7 +823,8 @@ static int ioctl_standard_call(struct net_device * dev,
795#endif /* WE_IOCTL_DEBUG */ 823#endif /* WE_IOCTL_DEBUG */
796 824
797 /* Create the kernel buffer */ 825 /* Create the kernel buffer */
798 extra = kmalloc(extra_size, GFP_KERNEL); 826 /* kzalloc ensures NULL-termination for essid_compat */
827 extra = kzalloc(extra_size, GFP_KERNEL);
799 if (extra == NULL) { 828 if (extra == NULL) {
800 return -ENOMEM; 829 return -ENOMEM;
801 } 830 }
@@ -819,6 +848,8 @@ static int ioctl_standard_call(struct net_device * dev,
819 /* Call the handler */ 848 /* Call the handler */
820 ret = handler(dev, &info, &(iwr->u), extra); 849 ret = handler(dev, &info, &(iwr->u), extra);
821 850
851 iwr->u.data.length += essid_compat;
852
822 /* If we have something to return to the user */ 853 /* If we have something to return to the user */
823 if (!ret && IW_IS_GET(cmd)) { 854 if (!ret && IW_IS_GET(cmd)) {
824 /* Check if there is enough buffer up there */ 855 /* Check if there is enough buffer up there */
diff --git a/net/dccp/Kconfig b/net/dccp/Kconfig
index e2a095d0fd80..ef8919cca74b 100644
--- a/net/dccp/Kconfig
+++ b/net/dccp/Kconfig
@@ -4,15 +4,15 @@ menu "DCCP Configuration (EXPERIMENTAL)"
4config IP_DCCP 4config IP_DCCP
5 tristate "The DCCP Protocol (EXPERIMENTAL)" 5 tristate "The DCCP Protocol (EXPERIMENTAL)"
6 ---help--- 6 ---help---
7 Datagram Congestion Control Protocol 7 Datagram Congestion Control Protocol (RFC 4340)
8 8
9 From draft-ietf-dccp-spec-11 <http://www.icir.org/kohler/dcp/draft-ietf-dccp-spec-11.txt>. 9 From http://www.ietf.org/rfc/rfc4340.txt:
10 10
11 The Datagram Congestion Control Protocol (DCCP) is a transport 11 The Datagram Congestion Control Protocol (DCCP) is a transport
12 protocol that implements bidirectional, unicast connections of 12 protocol that implements bidirectional, unicast connections of
13 congestion-controlled, unreliable datagrams. It should be suitable 13 congestion-controlled, unreliable datagrams. It should be suitable
14 for use by applications such as streaming media, Internet telephony, 14 for use by applications such as streaming media, Internet telephony,
15 and on-line games 15 and on-line games.
16 16
17 To compile this protocol support as a module, choose M here: the 17 To compile this protocol support as a module, choose M here: the
18 module will be called dccp. 18 module will be called dccp.
diff --git a/net/dccp/ackvec.c b/net/dccp/ackvec.c
index 4d176d33983f..f8208874ac7d 100644
--- a/net/dccp/ackvec.c
+++ b/net/dccp/ackvec.c
@@ -113,7 +113,7 @@ int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb)
113 113
114 memcpy(to, from, len); 114 memcpy(to, from, len);
115 /* 115 /*
116 * From draft-ietf-dccp-spec-11.txt: 116 * From RFC 4340, A.2:
117 * 117 *
118 * For each acknowledgement it sends, the HC-Receiver will add an 118 * For each acknowledgement it sends, the HC-Receiver will add an
119 * acknowledgement record. ack_seqno will equal the HC-Receiver 119 * acknowledgement record. ack_seqno will equal the HC-Receiver
@@ -224,7 +224,7 @@ static inline int dccp_ackvec_set_buf_head_state(struct dccp_ackvec *av,
224} 224}
225 225
226/* 226/*
227 * Implements the draft-ietf-dccp-spec-11.txt Appendix A 227 * Implements the RFC 4340, Appendix A
228 */ 228 */
229int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk, 229int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk,
230 const u64 ackno, const u8 state) 230 const u64 ackno, const u8 state)
@@ -237,7 +237,7 @@ int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk,
237 * We may well decide to do buffer compression, etc, but for now lets 237 * We may well decide to do buffer compression, etc, but for now lets
238 * just drop. 238 * just drop.
239 * 239 *
240 * From Appendix A: 240 * From Appendix A.1.1 (`New Packets'):
241 * 241 *
242 * Of course, the circular buffer may overflow, either when the 242 * Of course, the circular buffer may overflow, either when the
243 * HC-Sender is sending data at a very high rate, when the 243 * HC-Sender is sending data at a very high rate, when the
@@ -274,9 +274,9 @@ int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk,
274 /* 274 /*
275 * A.1.2. Old Packets 275 * A.1.2. Old Packets
276 * 276 *
277 * When a packet with Sequence Number S arrives, and 277 * When a packet with Sequence Number S <= buf_ackno
278 * S <= buf_ackno, the HC-Receiver will scan the table 278 * arrives, the HC-Receiver will scan the table for
279 * for the byte corresponding to S. (Indexing structures 279 * the byte corresponding to S. (Indexing structures
280 * could reduce the complexity of this scan.) 280 * could reduce the complexity of this scan.)
281 */ 281 */
282 u64 delta = dccp_delta_seqno(ackno, av->dccpav_buf_ackno); 282 u64 delta = dccp_delta_seqno(ackno, av->dccpav_buf_ackno);
diff --git a/net/dccp/ackvec.h b/net/dccp/ackvec.h
index 2424effac7f6..cf8f20ce23a9 100644
--- a/net/dccp/ackvec.h
+++ b/net/dccp/ackvec.h
@@ -28,8 +28,7 @@
28 28
29/** struct dccp_ackvec - ack vector 29/** struct dccp_ackvec - ack vector
30 * 30 *
31 * This data structure is the one defined in the DCCP draft 31 * This data structure is the one defined in RFC 4340, Appendix A.
32 * Appendix A.
33 * 32 *
34 * @dccpav_buf_head - circular buffer head 33 * @dccpav_buf_head - circular buffer head
35 * @dccpav_buf_tail - circular buffer tail 34 * @dccpav_buf_tail - circular buffer tail
diff --git a/net/dccp/ccids/Kconfig b/net/dccp/ccids/Kconfig
index 32752f750447..8533dabfb9f8 100644
--- a/net/dccp/ccids/Kconfig
+++ b/net/dccp/ccids/Kconfig
@@ -22,11 +22,11 @@ config IP_DCCP_CCID2
22 for lost packets, would prefer CCID 2 to CCID 3. On-line games may 22 for lost packets, would prefer CCID 2 to CCID 3. On-line games may
23 also prefer CCID 2. 23 also prefer CCID 2.
24 24
25 CCID 2 is further described in: 25 CCID 2 is further described in RFC 4341,
26 http://www.icir.org/kohler/dccp/draft-ietf-dccp-ccid2-10.txt 26 http://www.ietf.org/rfc/rfc4341.txt
27 27
28 This text was extracted from: 28 This text was extracted from RFC 4340 (sec. 10.1),
29 http://www.icir.org/kohler/dccp/draft-ietf-dccp-spec-13.txt 29 http://www.ietf.org/rfc/rfc4340.txt
30 30
31 If in doubt, say M. 31 If in doubt, say M.
32 32
@@ -53,15 +53,14 @@ config IP_DCCP_CCID3
53 suitable than CCID 2 for applications such streaming media where a 53 suitable than CCID 2 for applications such streaming media where a
54 relatively smooth sending rate is of importance. 54 relatively smooth sending rate is of importance.
55 55
56 CCID 3 is further described in: 56 CCID 3 is further described in RFC 4342,
57 57 http://www.ietf.org/rfc/rfc4342.txt
58 http://www.icir.org/kohler/dccp/draft-ietf-dccp-ccid3-11.txt.
59 58
60 The TFRC congestion control algorithms were initially described in 59 The TFRC congestion control algorithms were initially described in
61 RFC 3448. 60 RFC 3448.
62 61
63 This text was extracted from: 62 This text was extracted from RFC 4340 (sec. 10.2),
64 http://www.icir.org/kohler/dccp/draft-ietf-dccp-spec-13.txt 63 http://www.ietf.org/rfc/rfc4340.txt
65 64
66 If in doubt, say M. 65 If in doubt, say M.
67 66
diff --git a/net/dccp/ccids/ccid2.c b/net/dccp/ccids/ccid2.c
index 2efb505aeb35..162032baeac0 100644
--- a/net/dccp/ccids/ccid2.c
+++ b/net/dccp/ccids/ccid2.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25/* 25/*
26 * This implementation should follow: draft-ietf-dccp-ccid2-10.txt 26 * This implementation should follow RFC 4341
27 * 27 *
28 * BUGS: 28 * BUGS:
29 * - sequence number wrapping 29 * - sequence number wrapping
@@ -352,14 +352,14 @@ static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, int len)
352 352
353#ifdef CONFIG_IP_DCCP_CCID2_DEBUG 353#ifdef CONFIG_IP_DCCP_CCID2_DEBUG
354 ccid2_pr_debug("pipe=%d\n", hctx->ccid2hctx_pipe); 354 ccid2_pr_debug("pipe=%d\n", hctx->ccid2hctx_pipe);
355 ccid2_pr_debug("Sent: seq=%llu\n", seq); 355 ccid2_pr_debug("Sent: seq=%llu\n", (unsigned long long)seq);
356 do { 356 do {
357 struct ccid2_seq *seqp = hctx->ccid2hctx_seqt; 357 struct ccid2_seq *seqp = hctx->ccid2hctx_seqt;
358 358
359 while (seqp != hctx->ccid2hctx_seqh) { 359 while (seqp != hctx->ccid2hctx_seqh) {
360 ccid2_pr_debug("out seq=%llu acked=%d time=%lu\n", 360 ccid2_pr_debug("out seq=%llu acked=%d time=%lu\n",
361 seqp->ccid2s_seq, seqp->ccid2s_acked, 361 (unsigned long long)seqp->ccid2s_seq,
362 seqp->ccid2s_sent); 362 seqp->ccid2s_acked, seqp->ccid2s_sent);
363 seqp = seqp->ccid2s_next; 363 seqp = seqp->ccid2s_next;
364 } 364 }
365 } while (0); 365 } while (0);
@@ -480,7 +480,8 @@ static inline void ccid2_new_ack(struct sock *sk,
480 /* first measurement */ 480 /* first measurement */
481 if (hctx->ccid2hctx_srtt == -1) { 481 if (hctx->ccid2hctx_srtt == -1) {
482 ccid2_pr_debug("R: %lu Time=%lu seq=%llu\n", 482 ccid2_pr_debug("R: %lu Time=%lu seq=%llu\n",
483 r, jiffies, seqp->ccid2s_seq); 483 r, jiffies,
484 (unsigned long long)seqp->ccid2s_seq);
484 ccid2_change_srtt(hctx, r); 485 ccid2_change_srtt(hctx, r);
485 hctx->ccid2hctx_rttvar = r >> 1; 486 hctx->ccid2hctx_rttvar = r >> 1;
486 } else { 487 } else {
@@ -636,8 +637,9 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
636 u64 ackno_end_rl; 637 u64 ackno_end_rl;
637 638
638 dccp_set_seqno(&ackno_end_rl, ackno - rl); 639 dccp_set_seqno(&ackno_end_rl, ackno - rl);
639 ccid2_pr_debug("ackvec start:%llu end:%llu\n", ackno, 640 ccid2_pr_debug("ackvec start:%llu end:%llu\n",
640 ackno_end_rl); 641 (unsigned long long)ackno,
642 (unsigned long long)ackno_end_rl);
641 /* if the seqno we are analyzing is larger than the 643 /* if the seqno we are analyzing is larger than the
642 * current ackno, then move towards the tail of our 644 * current ackno, then move towards the tail of our
643 * seqnos. 645 * seqnos.
@@ -672,7 +674,7 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
672 674
673 seqp->ccid2s_acked = 1; 675 seqp->ccid2s_acked = 1;
674 ccid2_pr_debug("Got ack for %llu\n", 676 ccid2_pr_debug("Got ack for %llu\n",
675 seqp->ccid2s_seq); 677 (unsigned long long)seqp->ccid2s_seq);
676 ccid2_hc_tx_dec_pipe(sk); 678 ccid2_hc_tx_dec_pipe(sk);
677 } 679 }
678 if (seqp == hctx->ccid2hctx_seqt) { 680 if (seqp == hctx->ccid2hctx_seqt) {
@@ -718,7 +720,7 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
718 while (1) { 720 while (1) {
719 if (!seqp->ccid2s_acked) { 721 if (!seqp->ccid2s_acked) {
720 ccid2_pr_debug("Packet lost: %llu\n", 722 ccid2_pr_debug("Packet lost: %llu\n",
721 seqp->ccid2s_seq); 723 (unsigned long long)seqp->ccid2s_seq);
722 /* XXX need to traverse from tail -> head in 724 /* XXX need to traverse from tail -> head in
723 * order to detect multiple congestion events in 725 * order to detect multiple congestion events in
724 * one ack vector. 726 * one ack vector.
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index 67d2dc0e7c67..cec23ad286de 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -379,8 +379,7 @@ static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len)
379 packet->dccphtx_seqno = dp->dccps_gss; 379 packet->dccphtx_seqno = dp->dccps_gss;
380 /* 380 /*
381 * Check if win_count have changed 381 * Check if win_count have changed
382 * Algorithm in "8.1. Window Counter Valuer" in 382 * Algorithm in "8.1. Window Counter Value" in RFC 4342.
383 * draft-ietf-dccp-ccid3-11.txt
384 */ 383 */
385 quarter_rtt = timeval_delta(&now, &hctx->ccid3hctx_t_last_win_count); 384 quarter_rtt = timeval_delta(&now, &hctx->ccid3hctx_t_last_win_count);
386 if (likely(hctx->ccid3hctx_rtt > 8)) 385 if (likely(hctx->ccid3hctx_rtt > 8))
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h
index 0a21be437ed3..272e8584564e 100644
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -50,7 +50,7 @@ extern void dccp_time_wait(struct sock *sk, int state, int timeo);
50#define DCCP_TIMEWAIT_LEN (60 * HZ) /* how long to wait to destroy TIME-WAIT 50#define DCCP_TIMEWAIT_LEN (60 * HZ) /* how long to wait to destroy TIME-WAIT
51 * state, about 60 seconds */ 51 * state, about 60 seconds */
52 52
53/* draft-ietf-dccp-spec-11.txt initial RTO value */ 53/* RFC 1122, 4.2.3.1 initial RTO value */
54#define DCCP_TIMEOUT_INIT ((unsigned)(3 * HZ)) 54#define DCCP_TIMEOUT_INIT ((unsigned)(3 * HZ))
55 55
56/* Maximal interval between probes for local resources. */ 56/* Maximal interval between probes for local resources. */
diff --git a/net/dccp/input.c b/net/dccp/input.c
index 7f9dc6ac58c9..1d24881ac0ab 100644
--- a/net/dccp/input.c
+++ b/net/dccp/input.c
@@ -216,11 +216,11 @@ send_sync:
216 dccp_send_sync(sk, DCCP_SKB_CB(skb)->dccpd_seq, 216 dccp_send_sync(sk, DCCP_SKB_CB(skb)->dccpd_seq,
217 DCCP_PKT_SYNCACK); 217 DCCP_PKT_SYNCACK);
218 /* 218 /*
219 * From the draft: 219 * From RFC 4340, sec. 5.7
220 * 220 *
221 * As with DCCP-Ack packets, DCCP-Sync and DCCP-SyncAck packets 221 * As with DCCP-Ack packets, DCCP-Sync and DCCP-SyncAck packets
222 * MAY have non-zero-length application data areas, whose 222 * MAY have non-zero-length application data areas, whose
223 * contents * receivers MUST ignore. 223 * contents receivers MUST ignore.
224 */ 224 */
225 goto discard; 225 goto discard;
226 } 226 }
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index bf692c1c116f..e08e7688a263 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -183,7 +183,7 @@ static inline void dccp_do_pmtu_discovery(struct sock *sk,
183 dccp_sync_mss(sk, mtu); 183 dccp_sync_mss(sk, mtu);
184 184
185 /* 185 /*
186 * From: draft-ietf-dccp-spec-11.txt 186 * From RFC 4340, sec. 14.1:
187 * 187 *
188 * DCCP-Sync packets are the best choice for upward 188 * DCCP-Sync packets are the best choice for upward
189 * probing, since DCCP-Sync probes do not risk application 189 * probing, since DCCP-Sync probes do not risk application
@@ -311,7 +311,7 @@ static void dccp_v4_err(struct sk_buff *skb, u32 info)
311 } 311 }
312 312
313 if (sk->sk_state == DCCP_TIME_WAIT) { 313 if (sk->sk_state == DCCP_TIME_WAIT) {
314 inet_twsk_put((struct inet_timewait_sock *)sk); 314 inet_twsk_put(inet_twsk(sk));
315 return; 315 return;
316 } 316 }
317 317
@@ -449,6 +449,8 @@ static inline u64 dccp_v4_init_sequence(const struct sock *sk,
449 dccp_hdr(skb)->dccph_sport); 449 dccp_hdr(skb)->dccph_sport);
450} 450}
451 451
452static struct request_sock_ops dccp_request_sock_ops;
453
452int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb) 454int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
453{ 455{
454 struct inet_request_sock *ireq; 456 struct inet_request_sock *ireq;
@@ -489,7 +491,7 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
489 if (sk_acceptq_is_full(sk) && inet_csk_reqsk_queue_young(sk) > 1) 491 if (sk_acceptq_is_full(sk) && inet_csk_reqsk_queue_young(sk) > 1)
490 goto drop; 492 goto drop;
491 493
492 req = reqsk_alloc(sk->sk_prot->rsk_prot); 494 req = reqsk_alloc(&dccp_request_sock_ops);
493 if (req == NULL) 495 if (req == NULL)
494 goto drop; 496 goto drop;
495 497
@@ -614,7 +616,7 @@ static struct sock *dccp_v4_hnd_req(struct sock *sk, struct sk_buff *skb)
614 bh_lock_sock(nsk); 616 bh_lock_sock(nsk);
615 return nsk; 617 return nsk;
616 } 618 }
617 inet_twsk_put((struct inet_timewait_sock *)nsk); 619 inet_twsk_put(inet_twsk(nsk));
618 return NULL; 620 return NULL;
619 } 621 }
620 622
@@ -731,7 +733,7 @@ static void dccp_v4_ctl_send_reset(struct sk_buff *rxskb)
731 dccp_hdr_reset(skb)->dccph_reset_code = 733 dccp_hdr_reset(skb)->dccph_reset_code =
732 DCCP_SKB_CB(rxskb)->dccpd_reset_code; 734 DCCP_SKB_CB(rxskb)->dccpd_reset_code;
733 735
734 /* See "8.3.1. Abnormal Termination" in draft-ietf-dccp-spec-11 */ 736 /* See "8.3.1. Abnormal Termination" in RFC 4340 */
735 seqno = 0; 737 seqno = 0;
736 if (DCCP_SKB_CB(rxskb)->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ) 738 if (DCCP_SKB_CB(rxskb)->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ)
737 dccp_set_seqno(&seqno, DCCP_SKB_CB(rxskb)->dccpd_ack_seq + 1); 739 dccp_set_seqno(&seqno, DCCP_SKB_CB(rxskb)->dccpd_ack_seq + 1);
@@ -980,7 +982,7 @@ discard_and_relse:
980 goto discard_it; 982 goto discard_it;
981 983
982do_time_wait: 984do_time_wait:
983 inet_twsk_put((struct inet_timewait_sock *)sk); 985 inet_twsk_put(inet_twsk(sk));
984 goto no_dccp_socket; 986 goto no_dccp_socket;
985} 987}
986 988
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index 7a47399cf31f..fc4242c0767c 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -277,7 +277,7 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
277 __u64 seq; 277 __u64 seq;
278 278
279 sk = inet6_lookup(&dccp_hashinfo, &hdr->daddr, dh->dccph_dport, 279 sk = inet6_lookup(&dccp_hashinfo, &hdr->daddr, dh->dccph_dport,
280 &hdr->saddr, dh->dccph_sport, skb->dev->ifindex); 280 &hdr->saddr, dh->dccph_sport, inet6_iif(skb));
281 281
282 if (sk == NULL) { 282 if (sk == NULL) {
283 ICMP6_INC_STATS_BH(__in6_dev_get(skb->dev), ICMP6_MIB_INERRORS); 283 ICMP6_INC_STATS_BH(__in6_dev_get(skb->dev), ICMP6_MIB_INERRORS);
@@ -285,7 +285,7 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
285 } 285 }
286 286
287 if (sk->sk_state == DCCP_TIME_WAIT) { 287 if (sk->sk_state == DCCP_TIME_WAIT) {
288 inet_twsk_put((struct inet_timewait_sock *)sk); 288 inet_twsk_put(inet_twsk(sk));
289 return; 289 return;
290 } 290 }
291 291
@@ -550,7 +550,7 @@ static void dccp_v6_ctl_send_reset(struct sk_buff *rxskb)
550 dccp_hdr_reset(skb)->dccph_reset_code = 550 dccp_hdr_reset(skb)->dccph_reset_code =
551 DCCP_SKB_CB(rxskb)->dccpd_reset_code; 551 DCCP_SKB_CB(rxskb)->dccpd_reset_code;
552 552
553 /* See "8.3.1. Abnormal Termination" in draft-ietf-dccp-spec-11 */ 553 /* See "8.3.1. Abnormal Termination" in RFC 4340 */
554 seqno = 0; 554 seqno = 0;
555 if (DCCP_SKB_CB(rxskb)->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ) 555 if (DCCP_SKB_CB(rxskb)->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ)
556 dccp_set_seqno(&seqno, DCCP_SKB_CB(rxskb)->dccpd_ack_seq + 1); 556 dccp_set_seqno(&seqno, DCCP_SKB_CB(rxskb)->dccpd_ack_seq + 1);
@@ -663,7 +663,7 @@ static struct sock *dccp_v6_hnd_req(struct sock *sk,struct sk_buff *skb)
663 bh_lock_sock(nsk); 663 bh_lock_sock(nsk);
664 return nsk; 664 return nsk;
665 } 665 }
666 inet_twsk_put((struct inet_timewait_sock *)nsk); 666 inet_twsk_put(inet_twsk(nsk));
667 return NULL; 667 return NULL;
668 } 668 }
669 669
@@ -672,7 +672,6 @@ static struct sock *dccp_v6_hnd_req(struct sock *sk,struct sk_buff *skb)
672 672
673static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb) 673static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
674{ 674{
675 struct inet_request_sock *ireq;
676 struct dccp_sock dp; 675 struct dccp_sock dp;
677 struct request_sock *req; 676 struct request_sock *req;
678 struct dccp_request_sock *dreq; 677 struct dccp_request_sock *dreq;
@@ -701,7 +700,7 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
701 if (sk_acceptq_is_full(sk) && inet_csk_reqsk_queue_young(sk) > 1) 700 if (sk_acceptq_is_full(sk) && inet_csk_reqsk_queue_young(sk) > 1)
702 goto drop; 701 goto drop;
703 702
704 req = inet6_reqsk_alloc(sk->sk_prot->rsk_prot); 703 req = inet6_reqsk_alloc(&dccp6_request_sock_ops);
705 if (req == NULL) 704 if (req == NULL)
706 goto drop; 705 goto drop;
707 706
@@ -713,7 +712,6 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
713 goto drop_and_free; 712 goto drop_and_free;
714 713
715 ireq6 = inet6_rsk(req); 714 ireq6 = inet6_rsk(req);
716 ireq = inet_rsk(req);
717 ipv6_addr_copy(&ireq6->rmt_addr, &skb->nh.ipv6h->saddr); 715 ipv6_addr_copy(&ireq6->rmt_addr, &skb->nh.ipv6h->saddr);
718 ipv6_addr_copy(&ireq6->loc_addr, &skb->nh.ipv6h->daddr); 716 ipv6_addr_copy(&ireq6->loc_addr, &skb->nh.ipv6h->daddr);
719 req->rcv_wnd = dccp_feat_default_sequence_window; 717 req->rcv_wnd = dccp_feat_default_sequence_window;
@@ -997,6 +995,10 @@ static int dccp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
997 if (sk->sk_state == DCCP_OPEN) { /* Fast path */ 995 if (sk->sk_state == DCCP_OPEN) { /* Fast path */
998 if (dccp_rcv_established(sk, skb, dccp_hdr(skb), skb->len)) 996 if (dccp_rcv_established(sk, skb, dccp_hdr(skb), skb->len))
999 goto reset; 997 goto reset;
998 if (opt_skb) {
999 /* This is where we would goto ipv6_pktoptions. */
1000 __kfree_skb(opt_skb);
1001 }
1000 return 0; 1002 return 0;
1001 } 1003 }
1002 1004
@@ -1021,6 +1023,10 @@ static int dccp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
1021 1023
1022 if (dccp_rcv_state_process(sk, skb, dccp_hdr(skb), skb->len)) 1024 if (dccp_rcv_state_process(sk, skb, dccp_hdr(skb), skb->len))
1023 goto reset; 1025 goto reset;
1026 if (opt_skb) {
1027 /* This is where we would goto ipv6_pktoptions. */
1028 __kfree_skb(opt_skb);
1029 }
1024 return 0; 1030 return 0;
1025 1031
1026reset: 1032reset:
@@ -1109,7 +1115,7 @@ discard_and_relse:
1109 goto discard_it; 1115 goto discard_it;
1110 1116
1111do_time_wait: 1117do_time_wait:
1112 inet_twsk_put((struct inet_timewait_sock *)sk); 1118 inet_twsk_put(inet_twsk(sk));
1113 goto no_dccp_socket; 1119 goto no_dccp_socket;
1114} 1120}
1115 1121
diff --git a/net/dccp/options.c b/net/dccp/options.c
index 07a34696ac97..fb0db1f7cd7b 100644
--- a/net/dccp/options.c
+++ b/net/dccp/options.c
@@ -215,7 +215,7 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
215 elapsed_time); 215 elapsed_time);
216 break; 216 break;
217 /* 217 /*
218 * From draft-ietf-dccp-spec-11.txt: 218 * From RFC 4340, sec. 10.3:
219 * 219 *
220 * Option numbers 128 through 191 are for 220 * Option numbers 128 through 191 are for
221 * options sent from the HC-Sender to the 221 * options sent from the HC-Sender to the
diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
index 70e027375682..21f20f21dd32 100644
--- a/net/decnet/af_decnet.c
+++ b/net/decnet/af_decnet.c
@@ -166,7 +166,7 @@ static struct hlist_head *dn_find_list(struct sock *sk)
166 if (scp->addr.sdn_flags & SDF_WILD) 166 if (scp->addr.sdn_flags & SDF_WILD)
167 return hlist_empty(&dn_wild_sk) ? &dn_wild_sk : NULL; 167 return hlist_empty(&dn_wild_sk) ? &dn_wild_sk : NULL;
168 168
169 return &dn_sk_hash[scp->addrloc & DN_SK_HASH_MASK]; 169 return &dn_sk_hash[dn_ntohs(scp->addrloc) & DN_SK_HASH_MASK];
170} 170}
171 171
172/* 172/*
@@ -180,7 +180,7 @@ static int check_port(__le16 port)
180 if (port == 0) 180 if (port == 0)
181 return -1; 181 return -1;
182 182
183 sk_for_each(sk, node, &dn_sk_hash[port & DN_SK_HASH_MASK]) { 183 sk_for_each(sk, node, &dn_sk_hash[dn_ntohs(port) & DN_SK_HASH_MASK]) {
184 struct dn_scp *scp = DN_SK(sk); 184 struct dn_scp *scp = DN_SK(sk);
185 if (scp->addrloc == port) 185 if (scp->addrloc == port)
186 return -1; 186 return -1;
@@ -194,12 +194,12 @@ static unsigned short port_alloc(struct sock *sk)
194static unsigned short port = 0x2000; 194static unsigned short port = 0x2000;
195 unsigned short i_port = port; 195 unsigned short i_port = port;
196 196
197 while(check_port(++port) != 0) { 197 while(check_port(dn_htons(++port)) != 0) {
198 if (port == i_port) 198 if (port == i_port)
199 return 0; 199 return 0;
200 } 200 }
201 201
202 scp->addrloc = port; 202 scp->addrloc = dn_htons(port);
203 203
204 return 1; 204 return 1;
205} 205}
@@ -418,7 +418,7 @@ struct sock *dn_find_by_skb(struct sk_buff *skb)
418 struct dn_scp *scp; 418 struct dn_scp *scp;
419 419
420 read_lock(&dn_hash_lock); 420 read_lock(&dn_hash_lock);
421 sk_for_each(sk, node, &dn_sk_hash[cb->dst_port & DN_SK_HASH_MASK]) { 421 sk_for_each(sk, node, &dn_sk_hash[dn_ntohs(cb->dst_port) & DN_SK_HASH_MASK]) {
422 scp = DN_SK(sk); 422 scp = DN_SK(sk);
423 if (cb->src != dn_saddr2dn(&scp->peer)) 423 if (cb->src != dn_saddr2dn(&scp->peer))
424 continue; 424 continue;
@@ -1016,13 +1016,14 @@ static void dn_access_copy(struct sk_buff *skb, struct accessdata_dn *acc)
1016 1016
1017static void dn_user_copy(struct sk_buff *skb, struct optdata_dn *opt) 1017static void dn_user_copy(struct sk_buff *skb, struct optdata_dn *opt)
1018{ 1018{
1019 unsigned char *ptr = skb->data; 1019 unsigned char *ptr = skb->data;
1020 1020 u16 len = *ptr++; /* yes, it's 8bit on the wire */
1021 opt->opt_optl = *ptr++; 1021
1022 opt->opt_status = 0; 1022 BUG_ON(len > 16); /* we've checked the contents earlier */
1023 memcpy(opt->opt_data, ptr, opt->opt_optl); 1023 opt->opt_optl = dn_htons(len);
1024 skb_pull(skb, dn_ntohs(opt->opt_optl) + 1); 1024 opt->opt_status = 0;
1025 1025 memcpy(opt->opt_data, ptr, len);
1026 skb_pull(skb, len + 1);
1026} 1027}
1027 1028
1028static struct sk_buff *dn_wait_for_connect(struct sock *sk, long *timeo) 1029static struct sk_buff *dn_wait_for_connect(struct sock *sk, long *timeo)
@@ -1178,8 +1179,10 @@ static int dn_getname(struct socket *sock, struct sockaddr *uaddr,int *uaddr_len
1178 if (peer) { 1179 if (peer) {
1179 if ((sock->state != SS_CONNECTED && 1180 if ((sock->state != SS_CONNECTED &&
1180 sock->state != SS_CONNECTING) && 1181 sock->state != SS_CONNECTING) &&
1181 scp->accept_mode == ACC_IMMED) 1182 scp->accept_mode == ACC_IMMED) {
1183 release_sock(sk);
1182 return -ENOTCONN; 1184 return -ENOTCONN;
1185 }
1183 1186
1184 memcpy(sa, &scp->peer, sizeof(struct sockaddr_dn)); 1187 memcpy(sa, &scp->peer, sizeof(struct sockaddr_dn));
1185 } else { 1188 } else {
diff --git a/net/decnet/dn_nsp_in.c b/net/decnet/dn_nsp_in.c
index 72ecc6e62ec4..7683d4f754d2 100644
--- a/net/decnet/dn_nsp_in.c
+++ b/net/decnet/dn_nsp_in.c
@@ -360,9 +360,9 @@ static void dn_nsp_conn_conf(struct sock *sk, struct sk_buff *skb)
360 scp->max_window = decnet_no_fc_max_cwnd; 360 scp->max_window = decnet_no_fc_max_cwnd;
361 361
362 if (skb->len > 0) { 362 if (skb->len > 0) {
363 unsigned char dlen = *skb->data; 363 u16 dlen = *skb->data;
364 if ((dlen <= 16) && (dlen <= skb->len)) { 364 if ((dlen <= 16) && (dlen <= skb->len)) {
365 scp->conndata_in.opt_optl = dn_htons((__u16)dlen); 365 scp->conndata_in.opt_optl = dn_htons(dlen);
366 memcpy(scp->conndata_in.opt_data, skb->data + 1, dlen); 366 memcpy(scp->conndata_in.opt_data, skb->data + 1, dlen);
367 } 367 }
368 } 368 }
@@ -404,9 +404,9 @@ static void dn_nsp_disc_init(struct sock *sk, struct sk_buff *skb)
404 memset(scp->discdata_in.opt_data, 0, 16); 404 memset(scp->discdata_in.opt_data, 0, 16);
405 405
406 if (skb->len > 0) { 406 if (skb->len > 0) {
407 unsigned char dlen = *skb->data; 407 u16 dlen = *skb->data;
408 if ((dlen <= 16) && (dlen <= skb->len)) { 408 if ((dlen <= 16) && (dlen <= skb->len)) {
409 scp->discdata_in.opt_optl = dn_htons((__u16)dlen); 409 scp->discdata_in.opt_optl = dn_htons(dlen);
410 memcpy(scp->discdata_in.opt_data, skb->data + 1, dlen); 410 memcpy(scp->discdata_in.opt_data, skb->data + 1, dlen);
411 } 411 }
412 } 412 }
diff --git a/net/decnet/dn_nsp_out.c b/net/decnet/dn_nsp_out.c
index c2e21cd89b3c..b342e4e8f5f8 100644
--- a/net/decnet/dn_nsp_out.c
+++ b/net/decnet/dn_nsp_out.c
@@ -526,7 +526,7 @@ void dn_send_conn_conf(struct sock *sk, gfp_t gfp)
526 struct nsp_conn_init_msg *msg; 526 struct nsp_conn_init_msg *msg;
527 __u8 len = (__u8)dn_ntohs(scp->conndata_out.opt_optl); 527 __u8 len = (__u8)dn_ntohs(scp->conndata_out.opt_optl);
528 528
529 if ((skb = dn_alloc_skb(sk, 50 + dn_ntohs(scp->conndata_out.opt_optl), gfp)) == NULL) 529 if ((skb = dn_alloc_skb(sk, 50 + len, gfp)) == NULL)
530 return; 530 return;
531 531
532 msg = (struct nsp_conn_init_msg *)skb_put(skb, sizeof(*msg)); 532 msg = (struct nsp_conn_init_msg *)skb_put(skb, sizeof(*msg));
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
index dd0761e3d280..23489f7232d2 100644
--- a/net/decnet/dn_route.c
+++ b/net/decnet/dn_route.c
@@ -267,9 +267,14 @@ static void dn_dst_link_failure(struct sk_buff *skb)
267 267
268static inline int compare_keys(struct flowi *fl1, struct flowi *fl2) 268static inline int compare_keys(struct flowi *fl1, struct flowi *fl2)
269{ 269{
270 return memcmp(&fl1->nl_u.dn_u, &fl2->nl_u.dn_u, sizeof(fl1->nl_u.dn_u)) == 0 && 270 return ((fl1->nl_u.dn_u.daddr ^ fl2->nl_u.dn_u.daddr) |
271 fl1->oif == fl2->oif && 271 (fl1->nl_u.dn_u.saddr ^ fl2->nl_u.dn_u.saddr) |
272 fl1->iif == fl2->iif; 272#ifdef CONFIG_DECNET_ROUTE_FWMARK
273 (fl1->nl_u.dn_u.fwmark ^ fl2->nl_u.dn_u.fwmark) |
274#endif
275 (fl1->nl_u.dn_u.scope ^ fl2->nl_u.dn_u.scope) |
276 (fl1->oif ^ fl2->oif) |
277 (fl1->iif ^ fl2->iif)) == 0;
273} 278}
274 279
275static int dn_insert_route(struct dn_route *rt, unsigned hash, struct dn_route **rp) 280static int dn_insert_route(struct dn_route *rt, unsigned hash, struct dn_route **rp)
@@ -1270,7 +1275,6 @@ static int dn_route_input_slow(struct sk_buff *skb)
1270 goto e_inval; 1275 goto e_inval;
1271 1276
1272 res.type = RTN_LOCAL; 1277 res.type = RTN_LOCAL;
1273 flags |= RTCF_DIRECTSRC;
1274 } else { 1278 } else {
1275 __le16 src_map = fl.fld_src; 1279 __le16 src_map = fl.fld_src;
1276 free_res = 1; 1280 free_res = 1;
@@ -1341,7 +1345,7 @@ static int dn_route_input_slow(struct sk_buff *skb)
1341 goto make_route; 1345 goto make_route;
1342 1346
1343 /* Packet was intra-ethernet, so we know its on-link */ 1347 /* Packet was intra-ethernet, so we know its on-link */
1344 if (cb->rt_flags | DN_RT_F_IE) { 1348 if (cb->rt_flags & DN_RT_F_IE) {
1345 gateway = cb->src; 1349 gateway = cb->src;
1346 flags |= RTCF_DIRECTSRC; 1350 flags |= RTCF_DIRECTSRC;
1347 goto make_route; 1351 goto make_route;
diff --git a/net/decnet/dn_rules.c b/net/decnet/dn_rules.c
index 3e0c882c90bf..590e0a72495c 100644
--- a/net/decnet/dn_rules.c
+++ b/net/decnet/dn_rules.c
@@ -124,8 +124,8 @@ static struct nla_policy dn_fib_rule_policy[FRA_MAX+1] __read_mostly = {
124static int dn_fib_rule_match(struct fib_rule *rule, struct flowi *fl, int flags) 124static int dn_fib_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
125{ 125{
126 struct dn_fib_rule *r = (struct dn_fib_rule *)rule; 126 struct dn_fib_rule *r = (struct dn_fib_rule *)rule;
127 u16 daddr = fl->fld_dst; 127 __le16 daddr = fl->fld_dst;
128 u16 saddr = fl->fld_src; 128 __le16 saddr = fl->fld_src;
129 129
130 if (((saddr ^ r->src) & r->srcmask) || 130 if (((saddr ^ r->src) & r->srcmask) ||
131 ((daddr ^ r->dst) & r->dstmask)) 131 ((daddr ^ r->dst) & r->dstmask))
diff --git a/net/ieee80211/Kconfig b/net/ieee80211/Kconfig
index f7e84e9d13ad..a64be6cdf078 100644
--- a/net/ieee80211/Kconfig
+++ b/net/ieee80211/Kconfig
@@ -32,6 +32,7 @@ config IEEE80211_CRYPT_WEP
32 depends on IEEE80211 32 depends on IEEE80211
33 select CRYPTO 33 select CRYPTO
34 select CRYPTO_ARC4 34 select CRYPTO_ARC4
35 select CRYPTO_ECB
35 select CRC32 36 select CRC32
36 ---help--- 37 ---help---
37 Include software based cipher suites in support of IEEE 38 Include software based cipher suites in support of IEEE
@@ -58,6 +59,7 @@ config IEEE80211_CRYPT_TKIP
58 depends on IEEE80211 && NET_RADIO 59 depends on IEEE80211 && NET_RADIO
59 select CRYPTO 60 select CRYPTO
60 select CRYPTO_MICHAEL_MIC 61 select CRYPTO_MICHAEL_MIC
62 select CRYPTO_ECB
61 select CRC32 63 select CRC32
62 ---help--- 64 ---help---
63 Include software based cipher suites in support of IEEE 802.11i 65 Include software based cipher suites in support of IEEE 802.11i
diff --git a/net/ieee80211/ieee80211_rx.c b/net/ieee80211/ieee80211_rx.c
index 770704183a1b..2759312a4204 100644
--- a/net/ieee80211/ieee80211_rx.c
+++ b/net/ieee80211/ieee80211_rx.c
@@ -1078,12 +1078,12 @@ static int ieee80211_parse_info_param(struct ieee80211_info_element
1078 1078
1079 while (length >= sizeof(*info_element)) { 1079 while (length >= sizeof(*info_element)) {
1080 if (sizeof(*info_element) + info_element->len > length) { 1080 if (sizeof(*info_element) + info_element->len > length) {
1081 IEEE80211_ERROR("Info elem: parse failed: " 1081 IEEE80211_DEBUG_MGMT("Info elem: parse failed: "
1082 "info_element->len + 2 > left : " 1082 "info_element->len + 2 > left : "
1083 "info_element->len+2=%zd left=%d, id=%d.\n", 1083 "info_element->len+2=%zd left=%d, id=%d.\n",
1084 info_element->len + 1084 info_element->len +
1085 sizeof(*info_element), 1085 sizeof(*info_element),
1086 length, info_element->id); 1086 length, info_element->id);
1087 /* We stop processing but don't return an error here 1087 /* We stop processing but don't return an error here
1088 * because some misbehaviour APs break this rule. ie. 1088 * because some misbehaviour APs break this rule. ie.
1089 * Orinoco AP1000. */ 1089 * Orinoco AP1000. */
diff --git a/net/ieee80211/softmac/ieee80211softmac_assoc.c b/net/ieee80211/softmac/ieee80211softmac_assoc.c
index 589f6d2c548a..cf51c87a971d 100644
--- a/net/ieee80211/softmac/ieee80211softmac_assoc.c
+++ b/net/ieee80211/softmac/ieee80211softmac_assoc.c
@@ -48,7 +48,7 @@ ieee80211softmac_assoc(struct ieee80211softmac_device *mac, struct ieee80211soft
48 dprintk(KERN_INFO PFX "sent association request!\n"); 48 dprintk(KERN_INFO PFX "sent association request!\n");
49 49
50 spin_lock_irqsave(&mac->lock, flags); 50 spin_lock_irqsave(&mac->lock, flags);
51 mac->associated = 0; /* just to make sure */ 51 mac->associnfo.associated = 0; /* just to make sure */
52 52
53 /* Set a timer for timeout */ 53 /* Set a timer for timeout */
54 /* FIXME: make timeout configurable */ 54 /* FIXME: make timeout configurable */
@@ -62,24 +62,22 @@ ieee80211softmac_assoc_timeout(void *d)
62{ 62{
63 struct ieee80211softmac_device *mac = (struct ieee80211softmac_device *)d; 63 struct ieee80211softmac_device *mac = (struct ieee80211softmac_device *)d;
64 struct ieee80211softmac_network *n; 64 struct ieee80211softmac_network *n;
65 unsigned long flags;
66 65
67 spin_lock_irqsave(&mac->lock, flags); 66 mutex_lock(&mac->associnfo.mutex);
68 /* we might race against ieee80211softmac_handle_assoc_response, 67 /* we might race against ieee80211softmac_handle_assoc_response,
69 * so make sure only one of us does something */ 68 * so make sure only one of us does something */
70 if (!mac->associnfo.associating) { 69 if (!mac->associnfo.associating)
71 spin_unlock_irqrestore(&mac->lock, flags); 70 goto out;
72 return;
73 }
74 mac->associnfo.associating = 0; 71 mac->associnfo.associating = 0;
75 mac->associnfo.bssvalid = 0; 72 mac->associnfo.bssvalid = 0;
76 mac->associated = 0; 73 mac->associnfo.associated = 0;
77 74
78 n = ieee80211softmac_get_network_by_bssid_locked(mac, mac->associnfo.bssid); 75 n = ieee80211softmac_get_network_by_bssid_locked(mac, mac->associnfo.bssid);
79 spin_unlock_irqrestore(&mac->lock, flags);
80 76
81 dprintk(KERN_INFO PFX "assoc request timed out!\n"); 77 dprintk(KERN_INFO PFX "assoc request timed out!\n");
82 ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_TIMEOUT, n); 78 ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_TIMEOUT, n);
79out:
80 mutex_unlock(&mac->associnfo.mutex);
83} 81}
84 82
85void 83void
@@ -93,7 +91,7 @@ ieee80211softmac_disassoc(struct ieee80211softmac_device *mac)
93 91
94 netif_carrier_off(mac->dev); 92 netif_carrier_off(mac->dev);
95 93
96 mac->associated = 0; 94 mac->associnfo.associated = 0;
97 mac->associnfo.bssvalid = 0; 95 mac->associnfo.bssvalid = 0;
98 mac->associnfo.associating = 0; 96 mac->associnfo.associating = 0;
99 ieee80211softmac_init_bss(mac); 97 ieee80211softmac_init_bss(mac);
@@ -107,7 +105,7 @@ ieee80211softmac_send_disassoc_req(struct ieee80211softmac_device *mac, u16 reas
107{ 105{
108 struct ieee80211softmac_network *found; 106 struct ieee80211softmac_network *found;
109 107
110 if (mac->associnfo.bssvalid && mac->associated) { 108 if (mac->associnfo.bssvalid && mac->associnfo.associated) {
111 found = ieee80211softmac_get_network_by_bssid(mac, mac->associnfo.bssid); 109 found = ieee80211softmac_get_network_by_bssid(mac, mac->associnfo.bssid);
112 if (found) 110 if (found)
113 ieee80211softmac_send_mgt_frame(mac, found, IEEE80211_STYPE_DISASSOC, reason); 111 ieee80211softmac_send_mgt_frame(mac, found, IEEE80211_STYPE_DISASSOC, reason);
@@ -196,17 +194,18 @@ ieee80211softmac_assoc_work(void *d)
196 int bssvalid; 194 int bssvalid;
197 unsigned long flags; 195 unsigned long flags;
198 196
197 mutex_lock(&mac->associnfo.mutex);
198
199 if (!mac->associnfo.associating)
200 goto out;
201
199 /* ieee80211_disassoc might clear this */ 202 /* ieee80211_disassoc might clear this */
200 bssvalid = mac->associnfo.bssvalid; 203 bssvalid = mac->associnfo.bssvalid;
201 204
202 /* meh */ 205 /* meh */
203 if (mac->associated) 206 if (mac->associnfo.associated)
204 ieee80211softmac_send_disassoc_req(mac, WLAN_REASON_DISASSOC_STA_HAS_LEFT); 207 ieee80211softmac_send_disassoc_req(mac, WLAN_REASON_DISASSOC_STA_HAS_LEFT);
205 208
206 spin_lock_irqsave(&mac->lock, flags);
207 mac->associnfo.associating = 1;
208 spin_unlock_irqrestore(&mac->lock, flags);
209
210 /* try to find the requested network in our list, if we found one already */ 209 /* try to find the requested network in our list, if we found one already */
211 if (bssvalid || mac->associnfo.bssfixed) 210 if (bssvalid || mac->associnfo.bssfixed)
212 found = ieee80211softmac_get_network_by_bssid(mac, mac->associnfo.bssid); 211 found = ieee80211softmac_get_network_by_bssid(mac, mac->associnfo.bssid);
@@ -260,10 +259,8 @@ ieee80211softmac_assoc_work(void *d)
260 259
261 if (!found) { 260 if (!found) {
262 if (mac->associnfo.scan_retry > 0) { 261 if (mac->associnfo.scan_retry > 0) {
263 spin_lock_irqsave(&mac->lock, flags);
264 mac->associnfo.scan_retry--; 262 mac->associnfo.scan_retry--;
265 spin_unlock_irqrestore(&mac->lock, flags); 263
266
267 /* We know of no such network. Let's scan. 264 /* We know of no such network. Let's scan.
268 * NB: this also happens if we had no memory to copy the network info... 265 * NB: this also happens if we had no memory to copy the network info...
269 * Maybe we can hope to have more memory after scanning finishes ;) 266 * Maybe we can hope to have more memory after scanning finishes ;)
@@ -272,19 +269,17 @@ ieee80211softmac_assoc_work(void *d)
272 ieee80211softmac_notify(mac->dev, IEEE80211SOFTMAC_EVENT_SCAN_FINISHED, ieee80211softmac_assoc_notify_scan, NULL); 269 ieee80211softmac_notify(mac->dev, IEEE80211SOFTMAC_EVENT_SCAN_FINISHED, ieee80211softmac_assoc_notify_scan, NULL);
273 if (ieee80211softmac_start_scan(mac)) 270 if (ieee80211softmac_start_scan(mac))
274 dprintk(KERN_INFO PFX "Associate: failed to initiate scan. Is device up?\n"); 271 dprintk(KERN_INFO PFX "Associate: failed to initiate scan. Is device up?\n");
275 return; 272 goto out;
276 } else { 273 } else {
277 spin_lock_irqsave(&mac->lock, flags);
278 mac->associnfo.associating = 0; 274 mac->associnfo.associating = 0;
279 mac->associated = 0; 275 mac->associnfo.associated = 0;
280 spin_unlock_irqrestore(&mac->lock, flags);
281 276
282 dprintk(KERN_INFO PFX "Unable to find matching network after scan!\n"); 277 dprintk(KERN_INFO PFX "Unable to find matching network after scan!\n");
283 /* reset the retry counter for the next user request since we 278 /* reset the retry counter for the next user request since we
284 * break out and don't reschedule ourselves after this point. */ 279 * break out and don't reschedule ourselves after this point. */
285 mac->associnfo.scan_retry = IEEE80211SOFTMAC_ASSOC_SCAN_RETRY_LIMIT; 280 mac->associnfo.scan_retry = IEEE80211SOFTMAC_ASSOC_SCAN_RETRY_LIMIT;
286 ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_NET_NOT_FOUND, NULL); 281 ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_NET_NOT_FOUND, NULL);
287 return; 282 goto out;
288 } 283 }
289 } 284 }
290 285
@@ -297,7 +292,7 @@ ieee80211softmac_assoc_work(void *d)
297 /* copy the ESSID for displaying it */ 292 /* copy the ESSID for displaying it */
298 mac->associnfo.associate_essid.len = found->essid.len; 293 mac->associnfo.associate_essid.len = found->essid.len;
299 memcpy(mac->associnfo.associate_essid.data, found->essid.data, IW_ESSID_MAX_SIZE + 1); 294 memcpy(mac->associnfo.associate_essid.data, found->essid.data, IW_ESSID_MAX_SIZE + 1);
300 295
301 /* we found a network! authenticate (if necessary) and associate to it. */ 296 /* we found a network! authenticate (if necessary) and associate to it. */
302 if (found->authenticating) { 297 if (found->authenticating) {
303 dprintk(KERN_INFO PFX "Already requested authentication, waiting...\n"); 298 dprintk(KERN_INFO PFX "Already requested authentication, waiting...\n");
@@ -305,7 +300,7 @@ ieee80211softmac_assoc_work(void *d)
305 mac->associnfo.assoc_wait = 1; 300 mac->associnfo.assoc_wait = 1;
306 ieee80211softmac_notify_internal(mac, IEEE80211SOFTMAC_EVENT_ANY, found, ieee80211softmac_assoc_notify_auth, NULL, GFP_KERNEL); 301 ieee80211softmac_notify_internal(mac, IEEE80211SOFTMAC_EVENT_ANY, found, ieee80211softmac_assoc_notify_auth, NULL, GFP_KERNEL);
307 } 302 }
308 return; 303 goto out;
309 } 304 }
310 if (!found->authenticated && !found->authenticating) { 305 if (!found->authenticated && !found->authenticating) {
311 /* This relies on the fact that _auth_req only queues the work, 306 /* This relies on the fact that _auth_req only queues the work,
@@ -321,11 +316,14 @@ ieee80211softmac_assoc_work(void *d)
321 mac->associnfo.assoc_wait = 0; 316 mac->associnfo.assoc_wait = 0;
322 ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_FAILED, found); 317 ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_FAILED, found);
323 } 318 }
324 return; 319 goto out;
325 } 320 }
326 /* finally! now we can start associating */ 321 /* finally! now we can start associating */
327 mac->associnfo.assoc_wait = 0; 322 mac->associnfo.assoc_wait = 0;
328 ieee80211softmac_assoc(mac, found); 323 ieee80211softmac_assoc(mac, found);
324
325out:
326 mutex_unlock(&mac->associnfo.mutex);
329} 327}
330 328
331/* call this to do whatever is necessary when we're associated */ 329/* call this to do whatever is necessary when we're associated */
@@ -341,7 +339,7 @@ ieee80211softmac_associated(struct ieee80211softmac_device *mac,
341 mac->bssinfo.supported_rates = net->supported_rates; 339 mac->bssinfo.supported_rates = net->supported_rates;
342 ieee80211softmac_recalc_txrates(mac); 340 ieee80211softmac_recalc_txrates(mac);
343 341
344 mac->associated = 1; 342 mac->associnfo.associated = 1;
345 343
346 mac->associnfo.short_preamble_available = 344 mac->associnfo.short_preamble_available =
347 (cap & WLAN_CAPABILITY_SHORT_PREAMBLE) != 0; 345 (cap & WLAN_CAPABILITY_SHORT_PREAMBLE) != 0;
@@ -421,7 +419,7 @@ ieee80211softmac_handle_assoc_response(struct net_device * dev,
421 dprintk(KERN_INFO PFX "associating failed (reason: 0x%x)!\n", status); 419 dprintk(KERN_INFO PFX "associating failed (reason: 0x%x)!\n", status);
422 mac->associnfo.associating = 0; 420 mac->associnfo.associating = 0;
423 mac->associnfo.bssvalid = 0; 421 mac->associnfo.bssvalid = 0;
424 mac->associated = 0; 422 mac->associnfo.associated = 0;
425 ieee80211softmac_call_events_locked(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_FAILED, network); 423 ieee80211softmac_call_events_locked(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_FAILED, network);
426 } 424 }
427 425
diff --git a/net/ieee80211/softmac/ieee80211softmac_io.c b/net/ieee80211/softmac/ieee80211softmac_io.c
index 82bfddbf33a2..b96931001b43 100644
--- a/net/ieee80211/softmac/ieee80211softmac_io.c
+++ b/net/ieee80211/softmac/ieee80211softmac_io.c
@@ -304,7 +304,7 @@ ieee80211softmac_auth(struct ieee80211_auth **pkt,
304 2 + /* Auth Transaction Seq */ 304 2 + /* Auth Transaction Seq */
305 2 + /* Status Code */ 305 2 + /* Status Code */
306 /* Challenge Text IE */ 306 /* Challenge Text IE */
307 is_shared_response ? 0 : 1 + 1 + net->challenge_len 307 (is_shared_response ? 1 + 1 + net->challenge_len : 0)
308 ); 308 );
309 if (unlikely((*pkt) == NULL)) 309 if (unlikely((*pkt) == NULL))
310 return 0; 310 return 0;
@@ -475,8 +475,13 @@ int ieee80211softmac_handle_beacon(struct net_device *dev,
475{ 475{
476 struct ieee80211softmac_device *mac = ieee80211_priv(dev); 476 struct ieee80211softmac_device *mac = ieee80211_priv(dev);
477 477
478 if (mac->associated && memcmp(network->bssid, mac->associnfo.bssid, ETH_ALEN) == 0) 478 /* This might race, but we don't really care and it's not worth
479 ieee80211softmac_process_erp(mac, network->erp_value); 479 * adding heavyweight locking in this fastpath.
480 */
481 if (mac->associnfo.associated) {
482 if (memcmp(network->bssid, mac->associnfo.bssid, ETH_ALEN) == 0)
483 ieee80211softmac_process_erp(mac, network->erp_value);
484 }
480 485
481 return 0; 486 return 0;
482} 487}
diff --git a/net/ieee80211/softmac/ieee80211softmac_module.c b/net/ieee80211/softmac/ieee80211softmac_module.c
index addea1cf73ae..33aff4f4a471 100644
--- a/net/ieee80211/softmac/ieee80211softmac_module.c
+++ b/net/ieee80211/softmac/ieee80211softmac_module.c
@@ -57,6 +57,7 @@ struct net_device *alloc_ieee80211softmac(int sizeof_priv)
57 INIT_LIST_HEAD(&softmac->network_list); 57 INIT_LIST_HEAD(&softmac->network_list);
58 INIT_LIST_HEAD(&softmac->events); 58 INIT_LIST_HEAD(&softmac->events);
59 59
60 mutex_init(&softmac->associnfo.mutex);
60 INIT_WORK(&softmac->associnfo.work, ieee80211softmac_assoc_work, softmac); 61 INIT_WORK(&softmac->associnfo.work, ieee80211softmac_assoc_work, softmac);
61 INIT_WORK(&softmac->associnfo.timeout, ieee80211softmac_assoc_timeout, softmac); 62 INIT_WORK(&softmac->associnfo.timeout, ieee80211softmac_assoc_timeout, softmac);
62 softmac->start_scan = ieee80211softmac_start_scan_implementation; 63 softmac->start_scan = ieee80211softmac_start_scan_implementation;
diff --git a/net/ieee80211/softmac/ieee80211softmac_wx.c b/net/ieee80211/softmac/ieee80211softmac_wx.c
index 2aa779d18f38..23068a830f7d 100644
--- a/net/ieee80211/softmac/ieee80211softmac_wx.c
+++ b/net/ieee80211/softmac/ieee80211softmac_wx.c
@@ -73,13 +73,14 @@ ieee80211softmac_wx_set_essid(struct net_device *net_dev,
73 struct ieee80211softmac_network *n; 73 struct ieee80211softmac_network *n;
74 struct ieee80211softmac_auth_queue_item *authptr; 74 struct ieee80211softmac_auth_queue_item *authptr;
75 int length = 0; 75 int length = 0;
76 unsigned long flags; 76
77 mutex_lock(&sm->associnfo.mutex);
77 78
78 /* Check if we're already associating to this or another network 79 /* Check if we're already associating to this or another network
79 * If it's another network, cancel and start over with our new network 80 * If it's another network, cancel and start over with our new network
80 * If it's our network, ignore the change, we're already doing it! 81 * If it's our network, ignore the change, we're already doing it!
81 */ 82 */
82 if((sm->associnfo.associating || sm->associated) && 83 if((sm->associnfo.associating || sm->associnfo.associated) &&
83 (data->essid.flags && data->essid.length)) { 84 (data->essid.flags && data->essid.length)) {
84 /* Get the associating network */ 85 /* Get the associating network */
85 n = ieee80211softmac_get_network_by_bssid(sm, sm->associnfo.bssid); 86 n = ieee80211softmac_get_network_by_bssid(sm, sm->associnfo.bssid);
@@ -87,10 +88,9 @@ ieee80211softmac_wx_set_essid(struct net_device *net_dev,
87 !memcmp(n->essid.data, extra, n->essid.len)) { 88 !memcmp(n->essid.data, extra, n->essid.len)) {
88 dprintk(KERN_INFO PFX "Already associating or associated to "MAC_FMT"\n", 89 dprintk(KERN_INFO PFX "Already associating or associated to "MAC_FMT"\n",
89 MAC_ARG(sm->associnfo.bssid)); 90 MAC_ARG(sm->associnfo.bssid));
90 return 0; 91 goto out;
91 } else { 92 } else {
92 dprintk(KERN_INFO PFX "Canceling existing associate request!\n"); 93 dprintk(KERN_INFO PFX "Canceling existing associate request!\n");
93 spin_lock_irqsave(&sm->lock,flags);
94 /* Cancel assoc work */ 94 /* Cancel assoc work */
95 cancel_delayed_work(&sm->associnfo.work); 95 cancel_delayed_work(&sm->associnfo.work);
96 /* We don't have to do this, but it's a little cleaner */ 96 /* We don't have to do this, but it's a little cleaner */
@@ -98,14 +98,13 @@ ieee80211softmac_wx_set_essid(struct net_device *net_dev,
98 cancel_delayed_work(&authptr->work); 98 cancel_delayed_work(&authptr->work);
99 sm->associnfo.bssvalid = 0; 99 sm->associnfo.bssvalid = 0;
100 sm->associnfo.bssfixed = 0; 100 sm->associnfo.bssfixed = 0;
101 spin_unlock_irqrestore(&sm->lock,flags);
102 flush_scheduled_work(); 101 flush_scheduled_work();
102 sm->associnfo.associating = 0;
103 sm->associnfo.associated = 0;
103 } 104 }
104 } 105 }
105 106
106 107
107 spin_lock_irqsave(&sm->lock, flags);
108
109 sm->associnfo.static_essid = 0; 108 sm->associnfo.static_essid = 0;
110 sm->associnfo.assoc_wait = 0; 109 sm->associnfo.assoc_wait = 0;
111 110
@@ -121,10 +120,12 @@ ieee80211softmac_wx_set_essid(struct net_device *net_dev,
121 * If applicable, we have already copied the data in */ 120 * If applicable, we have already copied the data in */
122 sm->associnfo.req_essid.len = length; 121 sm->associnfo.req_essid.len = length;
123 122
123 sm->associnfo.associating = 1;
124 /* queue lower level code to do work (if necessary) */ 124 /* queue lower level code to do work (if necessary) */
125 schedule_work(&sm->associnfo.work); 125 schedule_work(&sm->associnfo.work);
126out:
127 mutex_unlock(&sm->associnfo.mutex);
126 128
127 spin_unlock_irqrestore(&sm->lock, flags);
128 return 0; 129 return 0;
129} 130}
130EXPORT_SYMBOL_GPL(ieee80211softmac_wx_set_essid); 131EXPORT_SYMBOL_GPL(ieee80211softmac_wx_set_essid);
@@ -136,10 +137,8 @@ ieee80211softmac_wx_get_essid(struct net_device *net_dev,
136 char *extra) 137 char *extra)
137{ 138{
138 struct ieee80211softmac_device *sm = ieee80211_priv(net_dev); 139 struct ieee80211softmac_device *sm = ieee80211_priv(net_dev);
139 unsigned long flags;
140 140
141 /* avoid getting inconsistent information */ 141 mutex_lock(&sm->associnfo.mutex);
142 spin_lock_irqsave(&sm->lock, flags);
143 /* If all fails, return ANY (empty) */ 142 /* If all fails, return ANY (empty) */
144 data->essid.length = 0; 143 data->essid.length = 0;
145 data->essid.flags = 0; /* active */ 144 data->essid.flags = 0; /* active */
@@ -152,12 +151,13 @@ ieee80211softmac_wx_get_essid(struct net_device *net_dev,
152 } 151 }
153 152
154 /* If we're associating/associated, return that */ 153 /* If we're associating/associated, return that */
155 if (sm->associated || sm->associnfo.associating) { 154 if (sm->associnfo.associated || sm->associnfo.associating) {
156 data->essid.length = sm->associnfo.associate_essid.len; 155 data->essid.length = sm->associnfo.associate_essid.len;
157 data->essid.flags = 1; /* active */ 156 data->essid.flags = 1; /* active */
158 memcpy(extra, sm->associnfo.associate_essid.data, sm->associnfo.associate_essid.len); 157 memcpy(extra, sm->associnfo.associate_essid.data, sm->associnfo.associate_essid.len);
159 } 158 }
160 spin_unlock_irqrestore(&sm->lock, flags); 159 mutex_unlock(&sm->associnfo.mutex);
160
161 return 0; 161 return 0;
162} 162}
163EXPORT_SYMBOL_GPL(ieee80211softmac_wx_get_essid); 163EXPORT_SYMBOL_GPL(ieee80211softmac_wx_get_essid);
@@ -322,15 +322,15 @@ ieee80211softmac_wx_get_wap(struct net_device *net_dev,
322{ 322{
323 struct ieee80211softmac_device *mac = ieee80211_priv(net_dev); 323 struct ieee80211softmac_device *mac = ieee80211_priv(net_dev);
324 int err = 0; 324 int err = 0;
325 unsigned long flags;
326 325
327 spin_lock_irqsave(&mac->lock, flags); 326 mutex_lock(&mac->associnfo.mutex);
328 if (mac->associnfo.bssvalid) 327 if (mac->associnfo.bssvalid)
329 memcpy(data->ap_addr.sa_data, mac->associnfo.bssid, ETH_ALEN); 328 memcpy(data->ap_addr.sa_data, mac->associnfo.bssid, ETH_ALEN);
330 else 329 else
331 memset(data->ap_addr.sa_data, 0xff, ETH_ALEN); 330 memset(data->ap_addr.sa_data, 0xff, ETH_ALEN);
332 data->ap_addr.sa_family = ARPHRD_ETHER; 331 data->ap_addr.sa_family = ARPHRD_ETHER;
333 spin_unlock_irqrestore(&mac->lock, flags); 332 mutex_unlock(&mac->associnfo.mutex);
333
334 return err; 334 return err;
335} 335}
336EXPORT_SYMBOL_GPL(ieee80211softmac_wx_get_wap); 336EXPORT_SYMBOL_GPL(ieee80211softmac_wx_get_wap);
@@ -342,28 +342,27 @@ ieee80211softmac_wx_set_wap(struct net_device *net_dev,
342 char *extra) 342 char *extra)
343{ 343{
344 struct ieee80211softmac_device *mac = ieee80211_priv(net_dev); 344 struct ieee80211softmac_device *mac = ieee80211_priv(net_dev);
345 unsigned long flags;
346 345
347 /* sanity check */ 346 /* sanity check */
348 if (data->ap_addr.sa_family != ARPHRD_ETHER) { 347 if (data->ap_addr.sa_family != ARPHRD_ETHER) {
349 return -EINVAL; 348 return -EINVAL;
350 } 349 }
351 350
352 spin_lock_irqsave(&mac->lock, flags); 351 mutex_lock(&mac->associnfo.mutex);
353 if (is_broadcast_ether_addr(data->ap_addr.sa_data)) { 352 if (is_broadcast_ether_addr(data->ap_addr.sa_data)) {
354 /* the bssid we have is not to be fixed any longer, 353 /* the bssid we have is not to be fixed any longer,
355 * and we should reassociate to the best AP. */ 354 * and we should reassociate to the best AP. */
356 mac->associnfo.bssfixed = 0; 355 mac->associnfo.bssfixed = 0;
357 /* force reassociation */ 356 /* force reassociation */
358 mac->associnfo.bssvalid = 0; 357 mac->associnfo.bssvalid = 0;
359 if (mac->associated) 358 if (mac->associnfo.associated)
360 schedule_work(&mac->associnfo.work); 359 schedule_work(&mac->associnfo.work);
361 } else if (is_zero_ether_addr(data->ap_addr.sa_data)) { 360 } else if (is_zero_ether_addr(data->ap_addr.sa_data)) {
362 /* the bssid we have is no longer fixed */ 361 /* the bssid we have is no longer fixed */
363 mac->associnfo.bssfixed = 0; 362 mac->associnfo.bssfixed = 0;
364 } else { 363 } else {
365 if (!memcmp(mac->associnfo.bssid, data->ap_addr.sa_data, ETH_ALEN)) { 364 if (!memcmp(mac->associnfo.bssid, data->ap_addr.sa_data, ETH_ALEN)) {
366 if (mac->associnfo.associating || mac->associated) { 365 if (mac->associnfo.associating || mac->associnfo.associated) {
367 /* bssid unchanged and associated or associating - just return */ 366 /* bssid unchanged and associated or associating - just return */
368 goto out; 367 goto out;
369 } 368 }
@@ -378,7 +377,8 @@ ieee80211softmac_wx_set_wap(struct net_device *net_dev,
378 } 377 }
379 378
380 out: 379 out:
381 spin_unlock_irqrestore(&mac->lock, flags); 380 mutex_unlock(&mac->associnfo.mutex);
381
382 return 0; 382 return 0;
383} 383}
384EXPORT_SYMBOL_GPL(ieee80211softmac_wx_set_wap); 384EXPORT_SYMBOL_GPL(ieee80211softmac_wx_set_wap);
@@ -394,7 +394,8 @@ ieee80211softmac_wx_set_genie(struct net_device *dev,
394 int err = 0; 394 int err = 0;
395 char *buf; 395 char *buf;
396 int i; 396 int i;
397 397
398 mutex_lock(&mac->associnfo.mutex);
398 spin_lock_irqsave(&mac->lock, flags); 399 spin_lock_irqsave(&mac->lock, flags);
399 /* bleh. shouldn't be locked for that kmalloc... */ 400 /* bleh. shouldn't be locked for that kmalloc... */
400 401
@@ -432,6 +433,8 @@ ieee80211softmac_wx_set_genie(struct net_device *dev,
432 433
433 out: 434 out:
434 spin_unlock_irqrestore(&mac->lock, flags); 435 spin_unlock_irqrestore(&mac->lock, flags);
436 mutex_unlock(&mac->associnfo.mutex);
437
435 return err; 438 return err;
436} 439}
437EXPORT_SYMBOL_GPL(ieee80211softmac_wx_set_genie); 440EXPORT_SYMBOL_GPL(ieee80211softmac_wx_set_genie);
@@ -446,7 +449,8 @@ ieee80211softmac_wx_get_genie(struct net_device *dev,
446 unsigned long flags; 449 unsigned long flags;
447 int err = 0; 450 int err = 0;
448 int space = wrqu->data.length; 451 int space = wrqu->data.length;
449 452
453 mutex_lock(&mac->associnfo.mutex);
450 spin_lock_irqsave(&mac->lock, flags); 454 spin_lock_irqsave(&mac->lock, flags);
451 455
452 wrqu->data.length = 0; 456 wrqu->data.length = 0;
@@ -459,6 +463,8 @@ ieee80211softmac_wx_get_genie(struct net_device *dev,
459 err = -E2BIG; 463 err = -E2BIG;
460 } 464 }
461 spin_unlock_irqrestore(&mac->lock, flags); 465 spin_unlock_irqrestore(&mac->lock, flags);
466 mutex_lock(&mac->associnfo.mutex);
467
462 return err; 468 return err;
463} 469}
464EXPORT_SYMBOL_GPL(ieee80211softmac_wx_get_genie); 470EXPORT_SYMBOL_GPL(ieee80211softmac_wx_get_genie);
@@ -473,10 +479,13 @@ ieee80211softmac_wx_set_mlme(struct net_device *dev,
473 struct iw_mlme *mlme = (struct iw_mlme *)extra; 479 struct iw_mlme *mlme = (struct iw_mlme *)extra;
474 u16 reason = cpu_to_le16(mlme->reason_code); 480 u16 reason = cpu_to_le16(mlme->reason_code);
475 struct ieee80211softmac_network *net; 481 struct ieee80211softmac_network *net;
482 int err = -EINVAL;
483
484 mutex_lock(&mac->associnfo.mutex);
476 485
477 if (memcmp(mac->associnfo.bssid, mlme->addr.sa_data, ETH_ALEN)) { 486 if (memcmp(mac->associnfo.bssid, mlme->addr.sa_data, ETH_ALEN)) {
478 printk(KERN_DEBUG PFX "wx_set_mlme: requested operation on net we don't use\n"); 487 printk(KERN_DEBUG PFX "wx_set_mlme: requested operation on net we don't use\n");
479 return -EINVAL; 488 goto out;
480 } 489 }
481 490
482 switch (mlme->cmd) { 491 switch (mlme->cmd) {
@@ -484,14 +493,22 @@ ieee80211softmac_wx_set_mlme(struct net_device *dev,
484 net = ieee80211softmac_get_network_by_bssid_locked(mac, mlme->addr.sa_data); 493 net = ieee80211softmac_get_network_by_bssid_locked(mac, mlme->addr.sa_data);
485 if (!net) { 494 if (!net) {
486 printk(KERN_DEBUG PFX "wx_set_mlme: we should know the net here...\n"); 495 printk(KERN_DEBUG PFX "wx_set_mlme: we should know the net here...\n");
487 return -EINVAL; 496 goto out;
488 } 497 }
489 return ieee80211softmac_deauth_req(mac, net, reason); 498 return ieee80211softmac_deauth_req(mac, net, reason);
490 case IW_MLME_DISASSOC: 499 case IW_MLME_DISASSOC:
491 ieee80211softmac_send_disassoc_req(mac, reason); 500 ieee80211softmac_send_disassoc_req(mac, reason);
492 return 0; 501 mac->associnfo.associated = 0;
502 mac->associnfo.associating = 0;
503 err = 0;
504 goto out;
493 default: 505 default:
494 return -EOPNOTSUPP; 506 err = -EOPNOTSUPP;
495 } 507 }
508
509out:
510 mutex_unlock(&mac->associnfo.mutex);
511
512 return err;
496} 513}
497EXPORT_SYMBOL_GPL(ieee80211softmac_wx_set_mlme); 514EXPORT_SYMBOL_GPL(ieee80211softmac_wx_set_mlme);
diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c
index a8e2e879a647..6460233407c7 100644
--- a/net/ipv4/cipso_ipv4.c
+++ b/net/ipv4/cipso_ipv4.c
@@ -43,6 +43,7 @@
43#include <net/tcp.h> 43#include <net/tcp.h>
44#include <net/netlabel.h> 44#include <net/netlabel.h>
45#include <net/cipso_ipv4.h> 45#include <net/cipso_ipv4.h>
46#include <asm/atomic.h>
46#include <asm/bug.h> 47#include <asm/bug.h>
47 48
48struct cipso_v4_domhsh_entry { 49struct cipso_v4_domhsh_entry {
@@ -79,7 +80,7 @@ struct cipso_v4_map_cache_entry {
79 unsigned char *key; 80 unsigned char *key;
80 size_t key_len; 81 size_t key_len;
81 82
82 struct netlbl_lsm_cache lsm_data; 83 struct netlbl_lsm_cache *lsm_data;
83 84
84 u32 activity; 85 u32 activity;
85 struct list_head list; 86 struct list_head list;
@@ -188,13 +189,14 @@ static void cipso_v4_doi_domhsh_free(struct rcu_head *entry)
188 * @entry: the entry to free 189 * @entry: the entry to free
189 * 190 *
190 * Description: 191 * Description:
191 * This function frees the memory associated with a cache entry. 192 * This function frees the memory associated with a cache entry including the
193 * LSM cache data if there are no longer any users, i.e. reference count == 0.
192 * 194 *
193 */ 195 */
194static void cipso_v4_cache_entry_free(struct cipso_v4_map_cache_entry *entry) 196static void cipso_v4_cache_entry_free(struct cipso_v4_map_cache_entry *entry)
195{ 197{
196 if (entry->lsm_data.free) 198 if (entry->lsm_data)
197 entry->lsm_data.free(entry->lsm_data.data); 199 netlbl_secattr_cache_free(entry->lsm_data);
198 kfree(entry->key); 200 kfree(entry->key);
199 kfree(entry); 201 kfree(entry);
200} 202}
@@ -315,8 +317,8 @@ static int cipso_v4_cache_check(const unsigned char *key,
315 entry->key_len == key_len && 317 entry->key_len == key_len &&
316 memcmp(entry->key, key, key_len) == 0) { 318 memcmp(entry->key, key, key_len) == 0) {
317 entry->activity += 1; 319 entry->activity += 1;
318 secattr->cache.free = entry->lsm_data.free; 320 atomic_inc(&entry->lsm_data->refcount);
319 secattr->cache.data = entry->lsm_data.data; 321 secattr->cache = entry->lsm_data;
320 if (prev_entry == NULL) { 322 if (prev_entry == NULL) {
321 spin_unlock_bh(&cipso_v4_cache[bkt].lock); 323 spin_unlock_bh(&cipso_v4_cache[bkt].lock);
322 return 0; 324 return 0;
@@ -383,8 +385,8 @@ int cipso_v4_cache_add(const struct sk_buff *skb,
383 memcpy(entry->key, cipso_ptr, cipso_ptr_len); 385 memcpy(entry->key, cipso_ptr, cipso_ptr_len);
384 entry->key_len = cipso_ptr_len; 386 entry->key_len = cipso_ptr_len;
385 entry->hash = cipso_v4_map_cache_hash(cipso_ptr, cipso_ptr_len); 387 entry->hash = cipso_v4_map_cache_hash(cipso_ptr, cipso_ptr_len);
386 entry->lsm_data.free = secattr->cache.free; 388 atomic_inc(&secattr->cache->refcount);
387 entry->lsm_data.data = secattr->cache.data; 389 entry->lsm_data = secattr->cache;
388 390
389 bkt = entry->hash & (CIPSO_V4_CACHE_BUCKETBITS - 1); 391 bkt = entry->hash & (CIPSO_V4_CACHE_BUCKETBITS - 1);
390 spin_lock_bh(&cipso_v4_cache[bkt].lock); 392 spin_lock_bh(&cipso_v4_cache[bkt].lock);
@@ -771,13 +773,15 @@ static int cipso_v4_map_cat_rbm_valid(const struct cipso_v4_doi *doi_def,
771{ 773{
772 int cat = -1; 774 int cat = -1;
773 u32 bitmap_len_bits = bitmap_len * 8; 775 u32 bitmap_len_bits = bitmap_len * 8;
774 u32 cipso_cat_size = doi_def->map.std->cat.cipso_size; 776 u32 cipso_cat_size;
775 u32 *cipso_array = doi_def->map.std->cat.cipso; 777 u32 *cipso_array;
776 778
777 switch (doi_def->type) { 779 switch (doi_def->type) {
778 case CIPSO_V4_MAP_PASS: 780 case CIPSO_V4_MAP_PASS:
779 return 0; 781 return 0;
780 case CIPSO_V4_MAP_STD: 782 case CIPSO_V4_MAP_STD:
783 cipso_cat_size = doi_def->map.std->cat.cipso_size;
784 cipso_array = doi_def->map.std->cat.cipso;
781 for (;;) { 785 for (;;) {
782 cat = cipso_v4_bitmap_walk(bitmap, 786 cat = cipso_v4_bitmap_walk(bitmap,
783 bitmap_len_bits, 787 bitmap_len_bits,
@@ -823,19 +827,21 @@ static int cipso_v4_map_cat_rbm_hton(const struct cipso_v4_doi *doi_def,
823 u32 net_spot_max = 0; 827 u32 net_spot_max = 0;
824 u32 host_clen_bits = host_cat_len * 8; 828 u32 host_clen_bits = host_cat_len * 8;
825 u32 net_clen_bits = net_cat_len * 8; 829 u32 net_clen_bits = net_cat_len * 8;
826 u32 host_cat_size = doi_def->map.std->cat.local_size; 830 u32 host_cat_size;
827 u32 *host_cat_array = doi_def->map.std->cat.local; 831 u32 *host_cat_array;
828 832
829 switch (doi_def->type) { 833 switch (doi_def->type) {
830 case CIPSO_V4_MAP_PASS: 834 case CIPSO_V4_MAP_PASS:
831 net_spot_max = host_cat_len - 1; 835 net_spot_max = host_cat_len;
832 while (net_spot_max > 0 && host_cat[net_spot_max] == 0) 836 while (net_spot_max > 0 && host_cat[net_spot_max - 1] == 0)
833 net_spot_max--; 837 net_spot_max--;
834 if (net_spot_max > net_cat_len) 838 if (net_spot_max > net_cat_len)
835 return -EINVAL; 839 return -EINVAL;
836 memcpy(net_cat, host_cat, net_spot_max); 840 memcpy(net_cat, host_cat, net_spot_max);
837 return net_spot_max; 841 return net_spot_max;
838 case CIPSO_V4_MAP_STD: 842 case CIPSO_V4_MAP_STD:
843 host_cat_size = doi_def->map.std->cat.local_size;
844 host_cat_array = doi_def->map.std->cat.local;
839 for (;;) { 845 for (;;) {
840 host_spot = cipso_v4_bitmap_walk(host_cat, 846 host_spot = cipso_v4_bitmap_walk(host_cat,
841 host_clen_bits, 847 host_clen_bits,
@@ -891,8 +897,8 @@ static int cipso_v4_map_cat_rbm_ntoh(const struct cipso_v4_doi *doi_def,
891 int net_spot = -1; 897 int net_spot = -1;
892 u32 net_clen_bits = net_cat_len * 8; 898 u32 net_clen_bits = net_cat_len * 8;
893 u32 host_clen_bits = host_cat_len * 8; 899 u32 host_clen_bits = host_cat_len * 8;
894 u32 net_cat_size = doi_def->map.std->cat.cipso_size; 900 u32 net_cat_size;
895 u32 *net_cat_array = doi_def->map.std->cat.cipso; 901 u32 *net_cat_array;
896 902
897 switch (doi_def->type) { 903 switch (doi_def->type) {
898 case CIPSO_V4_MAP_PASS: 904 case CIPSO_V4_MAP_PASS:
@@ -901,6 +907,8 @@ static int cipso_v4_map_cat_rbm_ntoh(const struct cipso_v4_doi *doi_def,
901 memcpy(host_cat, net_cat, net_cat_len); 907 memcpy(host_cat, net_cat, net_cat_len);
902 return net_cat_len; 908 return net_cat_len;
903 case CIPSO_V4_MAP_STD: 909 case CIPSO_V4_MAP_STD:
910 net_cat_size = doi_def->map.std->cat.cipso_size;
911 net_cat_array = doi_def->map.std->cat.cipso;
904 for (;;) { 912 for (;;) {
905 net_spot = cipso_v4_bitmap_walk(net_cat, 913 net_spot = cipso_v4_bitmap_walk(net_cat,
906 net_clen_bits, 914 net_clen_bits,
@@ -1299,7 +1307,8 @@ int cipso_v4_socket_setattr(const struct socket *sock,
1299 1307
1300 /* We can't use ip_options_get() directly because it makes a call to 1308 /* We can't use ip_options_get() directly because it makes a call to
1301 * ip_options_get_alloc() which allocates memory with GFP_KERNEL and 1309 * ip_options_get_alloc() which allocates memory with GFP_KERNEL and
1302 * we can't block here. */ 1310 * we won't always have CAP_NET_RAW even though we _always_ want to
1311 * set the IPOPT_CIPSO option. */
1303 opt_len = (buf_len + 3) & ~3; 1312 opt_len = (buf_len + 3) & ~3;
1304 opt = kzalloc(sizeof(*opt) + opt_len, GFP_ATOMIC); 1313 opt = kzalloc(sizeof(*opt) + opt_len, GFP_ATOMIC);
1305 if (opt == NULL) { 1314 if (opt == NULL) {
@@ -1309,11 +1318,9 @@ int cipso_v4_socket_setattr(const struct socket *sock,
1309 memcpy(opt->__data, buf, buf_len); 1318 memcpy(opt->__data, buf, buf_len);
1310 opt->optlen = opt_len; 1319 opt->optlen = opt_len;
1311 opt->is_data = 1; 1320 opt->is_data = 1;
1321 opt->cipso = sizeof(struct iphdr);
1312 kfree(buf); 1322 kfree(buf);
1313 buf = NULL; 1323 buf = NULL;
1314 ret_val = ip_options_compile(opt, NULL);
1315 if (ret_val != 0)
1316 goto socket_setattr_failure;
1317 1324
1318 sk_inet = inet_sk(sk); 1325 sk_inet = inet_sk(sk);
1319 if (sk_inet->is_icsk) { 1326 if (sk_inet->is_icsk) {
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 9c399a70dd5d..af0190d8b6c0 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -482,9 +482,7 @@ static int rtm_to_fib_config(struct sk_buff *skb, struct nlmsghdr *nlh,
482 memset(cfg, 0, sizeof(*cfg)); 482 memset(cfg, 0, sizeof(*cfg));
483 483
484 rtm = nlmsg_data(nlh); 484 rtm = nlmsg_data(nlh);
485 cfg->fc_family = rtm->rtm_family;
486 cfg->fc_dst_len = rtm->rtm_dst_len; 485 cfg->fc_dst_len = rtm->rtm_dst_len;
487 cfg->fc_src_len = rtm->rtm_src_len;
488 cfg->fc_tos = rtm->rtm_tos; 486 cfg->fc_tos = rtm->rtm_tos;
489 cfg->fc_table = rtm->rtm_table; 487 cfg->fc_table = rtm->rtm_table;
490 cfg->fc_protocol = rtm->rtm_protocol; 488 cfg->fc_protocol = rtm->rtm_protocol;
@@ -501,9 +499,6 @@ static int rtm_to_fib_config(struct sk_buff *skb, struct nlmsghdr *nlh,
501 case RTA_DST: 499 case RTA_DST:
502 cfg->fc_dst = nla_get_be32(attr); 500 cfg->fc_dst = nla_get_be32(attr);
503 break; 501 break;
504 case RTA_SRC:
505 cfg->fc_src = nla_get_be32(attr);
506 break;
507 case RTA_OIF: 502 case RTA_OIF:
508 cfg->fc_oif = nla_get_u32(attr); 503 cfg->fc_oif = nla_get_u32(attr);
509 break; 504 break;
diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
index 2b1a54b59c48..f072f3875af8 100644
--- a/net/ipv4/inetpeer.c
+++ b/net/ipv4/inetpeer.c
@@ -94,10 +94,8 @@ int inet_peer_minttl = 120 * HZ; /* TTL under high load: 120 sec */
94int inet_peer_maxttl = 10 * 60 * HZ; /* usual time to live: 10 min */ 94int inet_peer_maxttl = 10 * 60 * HZ; /* usual time to live: 10 min */
95 95
96static struct inet_peer *inet_peer_unused_head; 96static struct inet_peer *inet_peer_unused_head;
97/* Exported for inet_putpeer inline function. */ 97static struct inet_peer **inet_peer_unused_tailp = &inet_peer_unused_head;
98struct inet_peer **inet_peer_unused_tailp = &inet_peer_unused_head; 98static DEFINE_SPINLOCK(inet_peer_unused_lock);
99DEFINE_SPINLOCK(inet_peer_unused_lock);
100#define PEER_MAX_CLEANUP_WORK 30
101 99
102static void peer_check_expire(unsigned long dummy); 100static void peer_check_expire(unsigned long dummy);
103static DEFINE_TIMER(peer_periodic_timer, peer_check_expire, 0, 0); 101static DEFINE_TIMER(peer_periodic_timer, peer_check_expire, 0, 0);
@@ -340,7 +338,8 @@ static int cleanup_once(unsigned long ttl)
340 spin_lock_bh(&inet_peer_unused_lock); 338 spin_lock_bh(&inet_peer_unused_lock);
341 p = inet_peer_unused_head; 339 p = inet_peer_unused_head;
342 if (p != NULL) { 340 if (p != NULL) {
343 if (time_after(p->dtime + ttl, jiffies)) { 341 __u32 delta = (__u32)jiffies - p->dtime;
342 if (delta < ttl) {
344 /* Do not prune fresh entries. */ 343 /* Do not prune fresh entries. */
345 spin_unlock_bh(&inet_peer_unused_lock); 344 spin_unlock_bh(&inet_peer_unused_lock);
346 return -1; 345 return -1;
@@ -432,7 +431,7 @@ out_free:
432/* Called with local BH disabled. */ 431/* Called with local BH disabled. */
433static void peer_check_expire(unsigned long dummy) 432static void peer_check_expire(unsigned long dummy)
434{ 433{
435 int i; 434 unsigned long now = jiffies;
436 int ttl; 435 int ttl;
437 436
438 if (peer_total >= inet_peer_threshold) 437 if (peer_total >= inet_peer_threshold)
@@ -441,7 +440,10 @@ static void peer_check_expire(unsigned long dummy)
441 ttl = inet_peer_maxttl 440 ttl = inet_peer_maxttl
442 - (inet_peer_maxttl - inet_peer_minttl) / HZ * 441 - (inet_peer_maxttl - inet_peer_minttl) / HZ *
443 peer_total / inet_peer_threshold * HZ; 442 peer_total / inet_peer_threshold * HZ;
444 for (i = 0; i < PEER_MAX_CLEANUP_WORK && !cleanup_once(ttl); i++); 443 while (!cleanup_once(ttl)) {
444 if (jiffies != now)
445 break;
446 }
445 447
446 /* Trigger the timer after inet_peer_gc_mintime .. inet_peer_gc_maxtime 448 /* Trigger the timer after inet_peer_gc_mintime .. inet_peer_gc_maxtime
447 * interval depending on the total number of entries (more entries, 449 * interval depending on the total number of entries (more entries,
@@ -455,3 +457,16 @@ static void peer_check_expire(unsigned long dummy)
455 peer_total / inet_peer_threshold * HZ; 457 peer_total / inet_peer_threshold * HZ;
456 add_timer(&peer_periodic_timer); 458 add_timer(&peer_periodic_timer);
457} 459}
460
461void inet_putpeer(struct inet_peer *p)
462{
463 spin_lock_bh(&inet_peer_unused_lock);
464 if (atomic_dec_and_test(&p->refcnt)) {
465 p->unused_prevp = inet_peer_unused_tailp;
466 p->unused_next = NULL;
467 *inet_peer_unused_tailp = p;
468 inet_peer_unused_tailp = &p->unused_next;
469 p->dtime = (__u32)jiffies;
470 }
471 spin_unlock_bh(&inet_peer_unused_lock);
472}
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index f5fba051df3d..d5b5dec075b8 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -611,8 +611,8 @@ static int ipgre_rcv(struct sk_buff *skb)
611 * - When dealing with WCCPv2, Skip extra 4 bytes in GRE header 611 * - When dealing with WCCPv2, Skip extra 4 bytes in GRE header
612 */ 612 */
613 if (flags == 0 && 613 if (flags == 0 &&
614 skb->protocol == __constant_htons(ETH_P_WCCP)) { 614 skb->protocol == htons(ETH_P_WCCP)) {
615 skb->protocol = __constant_htons(ETH_P_IP); 615 skb->protocol = htons(ETH_P_IP);
616 if ((*(h + offset) & 0xF0) != 0x40) 616 if ((*(h + offset) & 0xF0) != 0x40)
617 offset += 4; 617 offset += 4;
618 } 618 }
diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c
index 8dabbfc31267..9f02917d6f45 100644
--- a/net/ipv4/ip_options.c
+++ b/net/ipv4/ip_options.c
@@ -443,7 +443,7 @@ int ip_options_compile(struct ip_options * opt, struct sk_buff * skb)
443 opt->router_alert = optptr - iph; 443 opt->router_alert = optptr - iph;
444 break; 444 break;
445 case IPOPT_CIPSO: 445 case IPOPT_CIPSO:
446 if (opt->cipso) { 446 if ((!skb && !capable(CAP_NET_RAW)) || opt->cipso) {
447 pp_ptr = optptr; 447 pp_ptr = optptr;
448 goto error; 448 goto error;
449 } 449 }
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index f8ce84759159..955a07abb91d 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -420,7 +420,7 @@ ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
420{ 420{
421 struct arphdr *rarp; 421 struct arphdr *rarp;
422 unsigned char *rarp_ptr; 422 unsigned char *rarp_ptr;
423 unsigned long sip, tip; 423 u32 sip, tip;
424 unsigned char *sha, *tha; /* s for "source", t for "target" */ 424 unsigned char *sha, *tha; /* s for "source", t for "target" */
425 struct ic_device *d; 425 struct ic_device *d;
426 426
diff --git a/net/ipv4/ipvs/ip_vs_ftp.c b/net/ipv4/ipvs/ip_vs_ftp.c
index 6d398f10aa91..687c1de1146f 100644
--- a/net/ipv4/ipvs/ip_vs_ftp.c
+++ b/net/ipv4/ipvs/ip_vs_ftp.c
@@ -200,7 +200,7 @@ static int ip_vs_ftp_out(struct ip_vs_app *app, struct ip_vs_conn *cp,
200 from = n_cp->vaddr; 200 from = n_cp->vaddr;
201 port = n_cp->vport; 201 port = n_cp->vport;
202 sprintf(buf,"%d,%d,%d,%d,%d,%d", NIPQUAD(from), 202 sprintf(buf,"%d,%d,%d,%d,%d,%d", NIPQUAD(from),
203 ntohs(port)&255, (ntohs(port)>>8)&255); 203 (ntohs(port)>>8)&255, ntohs(port)&255);
204 buf_len = strlen(buf); 204 buf_len = strlen(buf);
205 205
206 /* 206 /*
diff --git a/net/ipv4/ipvs/ip_vs_proto_tcp.c b/net/ipv4/ipvs/ip_vs_proto_tcp.c
index bfe779e74590..6ff05c3a32e6 100644
--- a/net/ipv4/ipvs/ip_vs_proto_tcp.c
+++ b/net/ipv4/ipvs/ip_vs_proto_tcp.c
@@ -117,7 +117,7 @@ tcp_fast_csum_update(struct tcphdr *tcph, __be32 oldip, __be32 newip,
117{ 117{
118 tcph->check = 118 tcph->check =
119 ip_vs_check_diff(~oldip, newip, 119 ip_vs_check_diff(~oldip, newip,
120 ip_vs_check_diff(oldport ^ htonl(0xFFFF), 120 ip_vs_check_diff(oldport ^ htons(0xFFFF),
121 newport, tcph->check)); 121 newport, tcph->check));
122} 122}
123 123
diff --git a/net/ipv4/ipvs/ip_vs_proto_udp.c b/net/ipv4/ipvs/ip_vs_proto_udp.c
index 54aa7603591f..691c8b637b29 100644
--- a/net/ipv4/ipvs/ip_vs_proto_udp.c
+++ b/net/ipv4/ipvs/ip_vs_proto_udp.c
@@ -122,10 +122,10 @@ udp_fast_csum_update(struct udphdr *uhdr, __be32 oldip, __be32 newip,
122{ 122{
123 uhdr->check = 123 uhdr->check =
124 ip_vs_check_diff(~oldip, newip, 124 ip_vs_check_diff(~oldip, newip,
125 ip_vs_check_diff(oldport ^ htonl(0xFFFF), 125 ip_vs_check_diff(oldport ^ htons(0xFFFF),
126 newport, uhdr->check)); 126 newport, uhdr->check));
127 if (!uhdr->check) 127 if (!uhdr->check)
128 uhdr->check = htonl(0xFFFF); 128 uhdr->check = -1;
129} 129}
130 130
131static int 131static int
@@ -173,7 +173,7 @@ udp_snat_handler(struct sk_buff **pskb,
173 cp->protocol, 173 cp->protocol,
174 (*pskb)->csum); 174 (*pskb)->csum);
175 if (udph->check == 0) 175 if (udph->check == 0)
176 udph->check = htonl(0xFFFF); 176 udph->check = -1;
177 IP_VS_DBG(11, "O-pkt: %s O-csum=%d (+%zd)\n", 177 IP_VS_DBG(11, "O-pkt: %s O-csum=%d (+%zd)\n",
178 pp->name, udph->check, 178 pp->name, udph->check,
179 (char*)&(udph->check) - (char*)udph); 179 (char*)&(udph->check) - (char*)udph);
@@ -228,7 +228,7 @@ udp_dnat_handler(struct sk_buff **pskb,
228 cp->protocol, 228 cp->protocol,
229 (*pskb)->csum); 229 (*pskb)->csum);
230 if (udph->check == 0) 230 if (udph->check == 0)
231 udph->check = 0xFFFF; 231 udph->check = -1;
232 (*pskb)->ip_summed = CHECKSUM_UNNECESSARY; 232 (*pskb)->ip_summed = CHECKSUM_UNNECESSARY;
233 } 233 }
234 return 1; 234 return 1;
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
index 17e1a687ab45..413c2d0a1f3d 100644
--- a/net/ipv4/netfilter/arp_tables.c
+++ b/net/ipv4/netfilter/arp_tables.c
@@ -466,7 +466,13 @@ static inline int check_entry(struct arpt_entry *e, const char *name, unsigned i
466 return -EINVAL; 466 return -EINVAL;
467 } 467 }
468 468
469 if (e->target_offset + sizeof(struct arpt_entry_target) > e->next_offset)
470 return -EINVAL;
471
469 t = arpt_get_target(e); 472 t = arpt_get_target(e);
473 if (e->target_offset + t->u.target_size > e->next_offset)
474 return -EINVAL;
475
470 target = try_then_request_module(xt_find_target(NF_ARP, t->u.user.name, 476 target = try_then_request_module(xt_find_target(NF_ARP, t->u.user.name,
471 t->u.user.revision), 477 t->u.user.revision),
472 "arpt_%s", t->u.user.name); 478 "arpt_%s", t->u.user.name);
@@ -621,20 +627,18 @@ static int translate_table(const char *name,
621 } 627 }
622 } 628 }
623 629
624 if (!mark_source_chains(newinfo, valid_hooks, entry0)) {
625 duprintf("Looping hook\n");
626 return -ELOOP;
627 }
628
629 /* Finally, each sanity check must pass */ 630 /* Finally, each sanity check must pass */
630 i = 0; 631 i = 0;
631 ret = ARPT_ENTRY_ITERATE(entry0, newinfo->size, 632 ret = ARPT_ENTRY_ITERATE(entry0, newinfo->size,
632 check_entry, name, size, &i); 633 check_entry, name, size, &i);
633 634
634 if (ret != 0) { 635 if (ret != 0)
635 ARPT_ENTRY_ITERATE(entry0, newinfo->size, 636 goto cleanup;
636 cleanup_entry, &i); 637
637 return ret; 638 ret = -ELOOP;
639 if (!mark_source_chains(newinfo, valid_hooks, entry0)) {
640 duprintf("Looping hook\n");
641 goto cleanup;
638 } 642 }
639 643
640 /* And one copy for every other CPU */ 644 /* And one copy for every other CPU */
@@ -643,6 +647,9 @@ static int translate_table(const char *name,
643 memcpy(newinfo->entries[i], entry0, newinfo->size); 647 memcpy(newinfo->entries[i], entry0, newinfo->size);
644 } 648 }
645 649
650 return 0;
651cleanup:
652 ARPT_ENTRY_ITERATE(entry0, newinfo->size, cleanup_entry, &i);
646 return ret; 653 return ret;
647} 654}
648 655
@@ -1196,6 +1203,8 @@ err1:
1196static void __exit arp_tables_fini(void) 1203static void __exit arp_tables_fini(void)
1197{ 1204{
1198 nf_unregister_sockopt(&arpt_sockopts); 1205 nf_unregister_sockopt(&arpt_sockopts);
1206 xt_unregister_target(&arpt_error_target);
1207 xt_unregister_target(&arpt_standard_target);
1199 xt_proto_fini(NF_ARP); 1208 xt_proto_fini(NF_ARP);
1200} 1209}
1201 1210
diff --git a/net/ipv4/netfilter/ip_conntrack_netlink.c b/net/ipv4/netfilter/ip_conntrack_netlink.c
index 53b6dffea6c2..262d0d44ec1b 100644
--- a/net/ipv4/netfilter/ip_conntrack_netlink.c
+++ b/net/ipv4/netfilter/ip_conntrack_netlink.c
@@ -44,13 +44,6 @@ MODULE_LICENSE("GPL");
44 44
45static char __initdata version[] = "0.90"; 45static char __initdata version[] = "0.90";
46 46
47#if 0
48#define DEBUGP printk
49#else
50#define DEBUGP(format, args...)
51#endif
52
53
54static inline int 47static inline int
55ctnetlink_dump_tuples_proto(struct sk_buff *skb, 48ctnetlink_dump_tuples_proto(struct sk_buff *skb,
56 const struct ip_conntrack_tuple *tuple, 49 const struct ip_conntrack_tuple *tuple,
@@ -398,7 +391,6 @@ nfattr_failure:
398 391
399static int ctnetlink_done(struct netlink_callback *cb) 392static int ctnetlink_done(struct netlink_callback *cb)
400{ 393{
401 DEBUGP("entered %s\n", __FUNCTION__);
402 if (cb->args[1]) 394 if (cb->args[1])
403 ip_conntrack_put((struct ip_conntrack *)cb->args[1]); 395 ip_conntrack_put((struct ip_conntrack *)cb->args[1]);
404 return 0; 396 return 0;
@@ -411,9 +403,6 @@ ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
411 struct ip_conntrack_tuple_hash *h; 403 struct ip_conntrack_tuple_hash *h;
412 struct list_head *i; 404 struct list_head *i;
413 405
414 DEBUGP("entered %s, last bucket=%lu id=%u\n", __FUNCTION__,
415 cb->args[0], *id);
416
417 read_lock_bh(&ip_conntrack_lock); 406 read_lock_bh(&ip_conntrack_lock);
418 last = (struct ip_conntrack *)cb->args[1]; 407 last = (struct ip_conntrack *)cb->args[1];
419 for (; cb->args[0] < ip_conntrack_htable_size; cb->args[0]++) { 408 for (; cb->args[0] < ip_conntrack_htable_size; cb->args[0]++) {
@@ -452,7 +441,6 @@ out:
452 if (last) 441 if (last)
453 ip_conntrack_put(last); 442 ip_conntrack_put(last);
454 443
455 DEBUGP("leaving, last bucket=%lu id=%u\n", cb->args[0], *id);
456 return skb->len; 444 return skb->len;
457} 445}
458 446
@@ -466,8 +454,6 @@ ctnetlink_parse_tuple_ip(struct nfattr *attr, struct ip_conntrack_tuple *tuple)
466{ 454{
467 struct nfattr *tb[CTA_IP_MAX]; 455 struct nfattr *tb[CTA_IP_MAX];
468 456
469 DEBUGP("entered %s\n", __FUNCTION__);
470
471 nfattr_parse_nested(tb, CTA_IP_MAX, attr); 457 nfattr_parse_nested(tb, CTA_IP_MAX, attr);
472 458
473 if (nfattr_bad_size(tb, CTA_IP_MAX, cta_min_ip)) 459 if (nfattr_bad_size(tb, CTA_IP_MAX, cta_min_ip))
@@ -481,8 +467,6 @@ ctnetlink_parse_tuple_ip(struct nfattr *attr, struct ip_conntrack_tuple *tuple)
481 return -EINVAL; 467 return -EINVAL;
482 tuple->dst.ip = *(__be32 *)NFA_DATA(tb[CTA_IP_V4_DST-1]); 468 tuple->dst.ip = *(__be32 *)NFA_DATA(tb[CTA_IP_V4_DST-1]);
483 469
484 DEBUGP("leaving\n");
485
486 return 0; 470 return 0;
487} 471}
488 472
@@ -503,8 +487,6 @@ ctnetlink_parse_tuple_proto(struct nfattr *attr,
503 struct ip_conntrack_protocol *proto; 487 struct ip_conntrack_protocol *proto;
504 int ret = 0; 488 int ret = 0;
505 489
506 DEBUGP("entered %s\n", __FUNCTION__);
507
508 nfattr_parse_nested(tb, CTA_PROTO_MAX, attr); 490 nfattr_parse_nested(tb, CTA_PROTO_MAX, attr);
509 491
510 if (nfattr_bad_size(tb, CTA_PROTO_MAX, cta_min_proto)) 492 if (nfattr_bad_size(tb, CTA_PROTO_MAX, cta_min_proto))
@@ -531,8 +513,6 @@ ctnetlink_parse_tuple(struct nfattr *cda[], struct ip_conntrack_tuple *tuple,
531 struct nfattr *tb[CTA_TUPLE_MAX]; 513 struct nfattr *tb[CTA_TUPLE_MAX];
532 int err; 514 int err;
533 515
534 DEBUGP("entered %s\n", __FUNCTION__);
535
536 memset(tuple, 0, sizeof(*tuple)); 516 memset(tuple, 0, sizeof(*tuple));
537 517
538 nfattr_parse_nested(tb, CTA_TUPLE_MAX, cda[type-1]); 518 nfattr_parse_nested(tb, CTA_TUPLE_MAX, cda[type-1]);
@@ -557,10 +537,6 @@ ctnetlink_parse_tuple(struct nfattr *cda[], struct ip_conntrack_tuple *tuple,
557 else 537 else
558 tuple->dst.dir = IP_CT_DIR_ORIGINAL; 538 tuple->dst.dir = IP_CT_DIR_ORIGINAL;
559 539
560 DUMP_TUPLE(tuple);
561
562 DEBUGP("leaving\n");
563
564 return 0; 540 return 0;
565} 541}
566 542
@@ -577,8 +553,6 @@ static int ctnetlink_parse_nat_proto(struct nfattr *attr,
577 struct nfattr *tb[CTA_PROTONAT_MAX]; 553 struct nfattr *tb[CTA_PROTONAT_MAX];
578 struct ip_nat_protocol *npt; 554 struct ip_nat_protocol *npt;
579 555
580 DEBUGP("entered %s\n", __FUNCTION__);
581
582 nfattr_parse_nested(tb, CTA_PROTONAT_MAX, attr); 556 nfattr_parse_nested(tb, CTA_PROTONAT_MAX, attr);
583 557
584 if (nfattr_bad_size(tb, CTA_PROTONAT_MAX, cta_min_protonat)) 558 if (nfattr_bad_size(tb, CTA_PROTONAT_MAX, cta_min_protonat))
@@ -597,7 +571,6 @@ static int ctnetlink_parse_nat_proto(struct nfattr *attr,
597 571
598 ip_nat_proto_put(npt); 572 ip_nat_proto_put(npt);
599 573
600 DEBUGP("leaving\n");
601 return 0; 574 return 0;
602} 575}
603 576
@@ -613,8 +586,6 @@ ctnetlink_parse_nat(struct nfattr *nat,
613 struct nfattr *tb[CTA_NAT_MAX]; 586 struct nfattr *tb[CTA_NAT_MAX];
614 int err; 587 int err;
615 588
616 DEBUGP("entered %s\n", __FUNCTION__);
617
618 memset(range, 0, sizeof(*range)); 589 memset(range, 0, sizeof(*range));
619 590
620 nfattr_parse_nested(tb, CTA_NAT_MAX, nat); 591 nfattr_parse_nested(tb, CTA_NAT_MAX, nat);
@@ -640,7 +611,6 @@ ctnetlink_parse_nat(struct nfattr *nat,
640 if (err < 0) 611 if (err < 0)
641 return err; 612 return err;
642 613
643 DEBUGP("leaving\n");
644 return 0; 614 return 0;
645} 615}
646#endif 616#endif
@@ -650,8 +620,6 @@ ctnetlink_parse_help(struct nfattr *attr, char **helper_name)
650{ 620{
651 struct nfattr *tb[CTA_HELP_MAX]; 621 struct nfattr *tb[CTA_HELP_MAX];
652 622
653 DEBUGP("entered %s\n", __FUNCTION__);
654
655 nfattr_parse_nested(tb, CTA_HELP_MAX, attr); 623 nfattr_parse_nested(tb, CTA_HELP_MAX, attr);
656 624
657 if (!tb[CTA_HELP_NAME-1]) 625 if (!tb[CTA_HELP_NAME-1])
@@ -679,8 +647,6 @@ ctnetlink_del_conntrack(struct sock *ctnl, struct sk_buff *skb,
679 struct ip_conntrack *ct; 647 struct ip_conntrack *ct;
680 int err = 0; 648 int err = 0;
681 649
682 DEBUGP("entered %s\n", __FUNCTION__);
683
684 if (nfattr_bad_size(cda, CTA_MAX, cta_min)) 650 if (nfattr_bad_size(cda, CTA_MAX, cta_min))
685 return -EINVAL; 651 return -EINVAL;
686 652
@@ -698,10 +664,8 @@ ctnetlink_del_conntrack(struct sock *ctnl, struct sk_buff *skb,
698 return err; 664 return err;
699 665
700 h = ip_conntrack_find_get(&tuple, NULL); 666 h = ip_conntrack_find_get(&tuple, NULL);
701 if (!h) { 667 if (!h)
702 DEBUGP("tuple not found in conntrack hash\n");
703 return -ENOENT; 668 return -ENOENT;
704 }
705 669
706 ct = tuplehash_to_ctrack(h); 670 ct = tuplehash_to_ctrack(h);
707 671
@@ -716,7 +680,6 @@ ctnetlink_del_conntrack(struct sock *ctnl, struct sk_buff *skb,
716 ct->timeout.function((unsigned long)ct); 680 ct->timeout.function((unsigned long)ct);
717 681
718 ip_conntrack_put(ct); 682 ip_conntrack_put(ct);
719 DEBUGP("leaving\n");
720 683
721 return 0; 684 return 0;
722} 685}
@@ -731,8 +694,6 @@ ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb,
731 struct sk_buff *skb2 = NULL; 694 struct sk_buff *skb2 = NULL;
732 int err = 0; 695 int err = 0;
733 696
734 DEBUGP("entered %s\n", __FUNCTION__);
735
736 if (nlh->nlmsg_flags & NLM_F_DUMP) { 697 if (nlh->nlmsg_flags & NLM_F_DUMP) {
737 struct nfgenmsg *msg = NLMSG_DATA(nlh); 698 struct nfgenmsg *msg = NLMSG_DATA(nlh);
738 u32 rlen; 699 u32 rlen;
@@ -770,11 +731,9 @@ ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb,
770 return err; 731 return err;
771 732
772 h = ip_conntrack_find_get(&tuple, NULL); 733 h = ip_conntrack_find_get(&tuple, NULL);
773 if (!h) { 734 if (!h)
774 DEBUGP("tuple not found in conntrack hash");
775 return -ENOENT; 735 return -ENOENT;
776 } 736
777 DEBUGP("tuple found\n");
778 ct = tuplehash_to_ctrack(h); 737 ct = tuplehash_to_ctrack(h);
779 738
780 err = -ENOMEM; 739 err = -ENOMEM;
@@ -795,7 +754,6 @@ ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb,
795 if (err < 0) 754 if (err < 0)
796 goto out; 755 goto out;
797 756
798 DEBUGP("leaving\n");
799 return 0; 757 return 0;
800 758
801free: 759free:
@@ -866,8 +824,6 @@ ctnetlink_change_helper(struct ip_conntrack *ct, struct nfattr *cda[])
866 char *helpname; 824 char *helpname;
867 int err; 825 int err;
868 826
869 DEBUGP("entered %s\n", __FUNCTION__);
870
871 /* don't change helper of sibling connections */ 827 /* don't change helper of sibling connections */
872 if (ct->master) 828 if (ct->master)
873 return -EINVAL; 829 return -EINVAL;
@@ -938,8 +894,6 @@ ctnetlink_change_conntrack(struct ip_conntrack *ct, struct nfattr *cda[])
938{ 894{
939 int err; 895 int err;
940 896
941 DEBUGP("entered %s\n", __FUNCTION__);
942
943 if (cda[CTA_HELP-1]) { 897 if (cda[CTA_HELP-1]) {
944 err = ctnetlink_change_helper(ct, cda); 898 err = ctnetlink_change_helper(ct, cda);
945 if (err < 0) 899 if (err < 0)
@@ -969,7 +923,6 @@ ctnetlink_change_conntrack(struct ip_conntrack *ct, struct nfattr *cda[])
969 ct->mark = ntohl(*(__be32 *)NFA_DATA(cda[CTA_MARK-1])); 923 ct->mark = ntohl(*(__be32 *)NFA_DATA(cda[CTA_MARK-1]));
970#endif 924#endif
971 925
972 DEBUGP("all done\n");
973 return 0; 926 return 0;
974} 927}
975 928
@@ -981,8 +934,6 @@ ctnetlink_create_conntrack(struct nfattr *cda[],
981 struct ip_conntrack *ct; 934 struct ip_conntrack *ct;
982 int err = -EINVAL; 935 int err = -EINVAL;
983 936
984 DEBUGP("entered %s\n", __FUNCTION__);
985
986 ct = ip_conntrack_alloc(otuple, rtuple); 937 ct = ip_conntrack_alloc(otuple, rtuple);
987 if (ct == NULL || IS_ERR(ct)) 938 if (ct == NULL || IS_ERR(ct))
988 return -ENOMEM; 939 return -ENOMEM;
@@ -1017,7 +968,6 @@ ctnetlink_create_conntrack(struct nfattr *cda[],
1017 if (ct->helper) 968 if (ct->helper)
1018 ip_conntrack_helper_put(ct->helper); 969 ip_conntrack_helper_put(ct->helper);
1019 970
1020 DEBUGP("conntrack with id %u inserted\n", ct->id);
1021 return 0; 971 return 0;
1022 972
1023err: 973err:
@@ -1033,8 +983,6 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
1033 struct ip_conntrack_tuple_hash *h = NULL; 983 struct ip_conntrack_tuple_hash *h = NULL;
1034 int err = 0; 984 int err = 0;
1035 985
1036 DEBUGP("entered %s\n", __FUNCTION__);
1037
1038 if (nfattr_bad_size(cda, CTA_MAX, cta_min)) 986 if (nfattr_bad_size(cda, CTA_MAX, cta_min))
1039 return -EINVAL; 987 return -EINVAL;
1040 988
@@ -1058,7 +1006,6 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
1058 1006
1059 if (h == NULL) { 1007 if (h == NULL) {
1060 write_unlock_bh(&ip_conntrack_lock); 1008 write_unlock_bh(&ip_conntrack_lock);
1061 DEBUGP("no such conntrack, create new\n");
1062 err = -ENOENT; 1009 err = -ENOENT;
1063 if (nlh->nlmsg_flags & NLM_F_CREATE) 1010 if (nlh->nlmsg_flags & NLM_F_CREATE)
1064 err = ctnetlink_create_conntrack(cda, &otuple, &rtuple); 1011 err = ctnetlink_create_conntrack(cda, &otuple, &rtuple);
@@ -1074,7 +1021,6 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
1074 1021
1075 /* We manipulate the conntrack inside the global conntrack table lock, 1022 /* We manipulate the conntrack inside the global conntrack table lock,
1076 * so there's no need to increase the refcount */ 1023 * so there's no need to increase the refcount */
1077 DEBUGP("conntrack found\n");
1078 err = -EEXIST; 1024 err = -EEXIST;
1079 if (!(nlh->nlmsg_flags & NLM_F_EXCL)) 1025 if (!(nlh->nlmsg_flags & NLM_F_EXCL))
1080 err = ctnetlink_change_conntrack(tuplehash_to_ctrack(h), cda); 1026 err = ctnetlink_change_conntrack(tuplehash_to_ctrack(h), cda);
@@ -1249,8 +1195,6 @@ ctnetlink_exp_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
1249 struct list_head *i; 1195 struct list_head *i;
1250 u_int32_t *id = (u_int32_t *) &cb->args[0]; 1196 u_int32_t *id = (u_int32_t *) &cb->args[0];
1251 1197
1252 DEBUGP("entered %s, last id=%llu\n", __FUNCTION__, *id);
1253
1254 read_lock_bh(&ip_conntrack_lock); 1198 read_lock_bh(&ip_conntrack_lock);
1255 list_for_each_prev(i, &ip_conntrack_expect_list) { 1199 list_for_each_prev(i, &ip_conntrack_expect_list) {
1256 exp = (struct ip_conntrack_expect *) i; 1200 exp = (struct ip_conntrack_expect *) i;
@@ -1266,8 +1210,6 @@ ctnetlink_exp_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
1266out: 1210out:
1267 read_unlock_bh(&ip_conntrack_lock); 1211 read_unlock_bh(&ip_conntrack_lock);
1268 1212
1269 DEBUGP("leaving, last id=%llu\n", *id);
1270
1271 return skb->len; 1213 return skb->len;
1272} 1214}
1273 1215
@@ -1285,8 +1227,6 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,
1285 struct sk_buff *skb2; 1227 struct sk_buff *skb2;
1286 int err = 0; 1228 int err = 0;
1287 1229
1288 DEBUGP("entered %s\n", __FUNCTION__);
1289
1290 if (nfattr_bad_size(cda, CTA_EXPECT_MAX, cta_min_exp)) 1230 if (nfattr_bad_size(cda, CTA_EXPECT_MAX, cta_min_exp))
1291 return -EINVAL; 1231 return -EINVAL;
1292 1232
@@ -1437,8 +1377,6 @@ ctnetlink_create_expect(struct nfattr *cda[])
1437 struct ip_conntrack *ct; 1377 struct ip_conntrack *ct;
1438 int err = 0; 1378 int err = 0;
1439 1379
1440 DEBUGP("entered %s\n", __FUNCTION__);
1441
1442 /* caller guarantees that those three CTA_EXPECT_* exist */ 1380 /* caller guarantees that those three CTA_EXPECT_* exist */
1443 err = ctnetlink_parse_tuple(cda, &tuple, CTA_EXPECT_TUPLE); 1381 err = ctnetlink_parse_tuple(cda, &tuple, CTA_EXPECT_TUPLE);
1444 if (err < 0) 1382 if (err < 0)
@@ -1490,8 +1428,6 @@ ctnetlink_new_expect(struct sock *ctnl, struct sk_buff *skb,
1490 struct ip_conntrack_expect *exp; 1428 struct ip_conntrack_expect *exp;
1491 int err = 0; 1429 int err = 0;
1492 1430
1493 DEBUGP("entered %s\n", __FUNCTION__);
1494
1495 if (nfattr_bad_size(cda, CTA_EXPECT_MAX, cta_min_exp)) 1431 if (nfattr_bad_size(cda, CTA_EXPECT_MAX, cta_min_exp))
1496 return -EINVAL; 1432 return -EINVAL;
1497 1433
@@ -1520,8 +1456,6 @@ ctnetlink_new_expect(struct sock *ctnl, struct sk_buff *skb,
1520 err = ctnetlink_change_expect(exp, cda); 1456 err = ctnetlink_change_expect(exp, cda);
1521 write_unlock_bh(&ip_conntrack_lock); 1457 write_unlock_bh(&ip_conntrack_lock);
1522 1458
1523 DEBUGP("leaving\n");
1524
1525 return err; 1459 return err;
1526} 1460}
1527 1461
diff --git a/net/ipv4/netfilter/ip_queue.c b/net/ipv4/netfilter/ip_queue.c
index 7edad790478a..97556cc2e4e0 100644
--- a/net/ipv4/netfilter/ip_queue.c
+++ b/net/ipv4/netfilter/ip_queue.c
@@ -351,9 +351,10 @@ ipq_mangle_ipv4(ipq_verdict_msg_t *v, struct ipq_queue_entry *e)
351 if (v->data_len < sizeof(*user_iph)) 351 if (v->data_len < sizeof(*user_iph))
352 return 0; 352 return 0;
353 diff = v->data_len - e->skb->len; 353 diff = v->data_len - e->skb->len;
354 if (diff < 0) 354 if (diff < 0) {
355 skb_trim(e->skb, v->data_len); 355 if (pskb_trim(e->skb, v->data_len))
356 else if (diff > 0) { 356 return -ENOMEM;
357 } else if (diff > 0) {
357 if (v->data_len > 0xFFFF) 358 if (v->data_len > 0xFFFF)
358 return -EINVAL; 359 return -EINVAL;
359 if (diff > skb_tailroom(e->skb)) { 360 if (diff > skb_tailroom(e->skb)) {
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index 78a44b01c035..8a455439b128 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -547,12 +547,18 @@ check_entry(struct ipt_entry *e, const char *name, unsigned int size,
547 return -EINVAL; 547 return -EINVAL;
548 } 548 }
549 549
550 if (e->target_offset + sizeof(struct ipt_entry_target) > e->next_offset)
551 return -EINVAL;
552
550 j = 0; 553 j = 0;
551 ret = IPT_MATCH_ITERATE(e, check_match, name, &e->ip, e->comefrom, &j); 554 ret = IPT_MATCH_ITERATE(e, check_match, name, &e->ip, e->comefrom, &j);
552 if (ret != 0) 555 if (ret != 0)
553 goto cleanup_matches; 556 goto cleanup_matches;
554 557
555 t = ipt_get_target(e); 558 t = ipt_get_target(e);
559 ret = -EINVAL;
560 if (e->target_offset + t->u.target_size > e->next_offset)
561 goto cleanup_matches;
556 target = try_then_request_module(xt_find_target(AF_INET, 562 target = try_then_request_module(xt_find_target(AF_INET,
557 t->u.user.name, 563 t->u.user.name,
558 t->u.user.revision), 564 t->u.user.revision),
@@ -712,19 +718,17 @@ translate_table(const char *name,
712 } 718 }
713 } 719 }
714 720
715 if (!mark_source_chains(newinfo, valid_hooks, entry0))
716 return -ELOOP;
717
718 /* Finally, each sanity check must pass */ 721 /* Finally, each sanity check must pass */
719 i = 0; 722 i = 0;
720 ret = IPT_ENTRY_ITERATE(entry0, newinfo->size, 723 ret = IPT_ENTRY_ITERATE(entry0, newinfo->size,
721 check_entry, name, size, &i); 724 check_entry, name, size, &i);
722 725
723 if (ret != 0) { 726 if (ret != 0)
724 IPT_ENTRY_ITERATE(entry0, newinfo->size, 727 goto cleanup;
725 cleanup_entry, &i); 728
726 return ret; 729 ret = -ELOOP;
727 } 730 if (!mark_source_chains(newinfo, valid_hooks, entry0))
731 goto cleanup;
728 732
729 /* And one copy for every other CPU */ 733 /* And one copy for every other CPU */
730 for_each_possible_cpu(i) { 734 for_each_possible_cpu(i) {
@@ -732,6 +736,9 @@ translate_table(const char *name,
732 memcpy(newinfo->entries[i], entry0, newinfo->size); 736 memcpy(newinfo->entries[i], entry0, newinfo->size);
733 } 737 }
734 738
739 return 0;
740cleanup:
741 IPT_ENTRY_ITERATE(entry0, newinfo->size, cleanup_entry, &i);
735 return ret; 742 return ret;
736} 743}
737 744
@@ -1463,6 +1470,10 @@ check_compat_entry_size_and_hooks(struct ipt_entry *e,
1463 return -EINVAL; 1470 return -EINVAL;
1464 } 1471 }
1465 1472
1473 if (e->target_offset + sizeof(struct compat_xt_entry_target) >
1474 e->next_offset)
1475 return -EINVAL;
1476
1466 off = 0; 1477 off = 0;
1467 entry_offset = (void *)e - (void *)base; 1478 entry_offset = (void *)e - (void *)base;
1468 j = 0; 1479 j = 0;
@@ -1472,6 +1483,9 @@ check_compat_entry_size_and_hooks(struct ipt_entry *e,
1472 goto cleanup_matches; 1483 goto cleanup_matches;
1473 1484
1474 t = ipt_get_target(e); 1485 t = ipt_get_target(e);
1486 ret = -EINVAL;
1487 if (e->target_offset + t->u.target_size > e->next_offset)
1488 goto cleanup_matches;
1475 target = try_then_request_module(xt_find_target(AF_INET, 1489 target = try_then_request_module(xt_find_target(AF_INET,
1476 t->u.user.name, 1490 t->u.user.name,
1477 t->u.user.revision), 1491 t->u.user.revision),
@@ -1513,7 +1527,7 @@ cleanup_matches:
1513 1527
1514static inline int compat_copy_match_from_user(struct ipt_entry_match *m, 1528static inline int compat_copy_match_from_user(struct ipt_entry_match *m,
1515 void **dstptr, compat_uint_t *size, const char *name, 1529 void **dstptr, compat_uint_t *size, const char *name,
1516 const struct ipt_ip *ip, unsigned int hookmask, int *i) 1530 const struct ipt_ip *ip, unsigned int hookmask)
1517{ 1531{
1518 struct ipt_entry_match *dm; 1532 struct ipt_entry_match *dm;
1519 struct ipt_match *match; 1533 struct ipt_match *match;
@@ -1526,22 +1540,13 @@ static inline int compat_copy_match_from_user(struct ipt_entry_match *m,
1526 ret = xt_check_match(match, AF_INET, dm->u.match_size - sizeof(*dm), 1540 ret = xt_check_match(match, AF_INET, dm->u.match_size - sizeof(*dm),
1527 name, hookmask, ip->proto, 1541 name, hookmask, ip->proto,
1528 ip->invflags & IPT_INV_PROTO); 1542 ip->invflags & IPT_INV_PROTO);
1529 if (ret) 1543 if (!ret && m->u.kernel.match->checkentry
1530 goto err;
1531
1532 if (m->u.kernel.match->checkentry
1533 && !m->u.kernel.match->checkentry(name, ip, match, dm->data, 1544 && !m->u.kernel.match->checkentry(name, ip, match, dm->data,
1534 hookmask)) { 1545 hookmask)) {
1535 duprintf("ip_tables: check failed for `%s'.\n", 1546 duprintf("ip_tables: check failed for `%s'.\n",
1536 m->u.kernel.match->name); 1547 m->u.kernel.match->name);
1537 ret = -EINVAL; 1548 ret = -EINVAL;
1538 goto err;
1539 } 1549 }
1540 (*i)++;
1541 return 0;
1542
1543err:
1544 module_put(m->u.kernel.match->me);
1545 return ret; 1550 return ret;
1546} 1551}
1547 1552
@@ -1553,19 +1558,18 @@ static int compat_copy_entry_from_user(struct ipt_entry *e, void **dstptr,
1553 struct ipt_target *target; 1558 struct ipt_target *target;
1554 struct ipt_entry *de; 1559 struct ipt_entry *de;
1555 unsigned int origsize; 1560 unsigned int origsize;
1556 int ret, h, j; 1561 int ret, h;
1557 1562
1558 ret = 0; 1563 ret = 0;
1559 origsize = *size; 1564 origsize = *size;
1560 de = (struct ipt_entry *)*dstptr; 1565 de = (struct ipt_entry *)*dstptr;
1561 memcpy(de, e, sizeof(struct ipt_entry)); 1566 memcpy(de, e, sizeof(struct ipt_entry));
1562 1567
1563 j = 0;
1564 *dstptr += sizeof(struct compat_ipt_entry); 1568 *dstptr += sizeof(struct compat_ipt_entry);
1565 ret = IPT_MATCH_ITERATE(e, compat_copy_match_from_user, dstptr, size, 1569 ret = IPT_MATCH_ITERATE(e, compat_copy_match_from_user, dstptr, size,
1566 name, &de->ip, de->comefrom, &j); 1570 name, &de->ip, de->comefrom);
1567 if (ret) 1571 if (ret)
1568 goto cleanup_matches; 1572 goto err;
1569 de->target_offset = e->target_offset - (origsize - *size); 1573 de->target_offset = e->target_offset - (origsize - *size);
1570 t = ipt_get_target(e); 1574 t = ipt_get_target(e);
1571 target = t->u.kernel.target; 1575 target = t->u.kernel.target;
@@ -1599,12 +1603,7 @@ static int compat_copy_entry_from_user(struct ipt_entry *e, void **dstptr,
1599 goto err; 1603 goto err;
1600 } 1604 }
1601 ret = 0; 1605 ret = 0;
1602 return ret;
1603
1604err: 1606err:
1605 module_put(t->u.kernel.target->me);
1606cleanup_matches:
1607 IPT_MATCH_ITERATE(e, cleanup_match, &j);
1608 return ret; 1607 return ret;
1609} 1608}
1610 1609
@@ -1618,7 +1617,7 @@ translate_compat_table(const char *name,
1618 unsigned int *hook_entries, 1617 unsigned int *hook_entries,
1619 unsigned int *underflows) 1618 unsigned int *underflows)
1620{ 1619{
1621 unsigned int i; 1620 unsigned int i, j;
1622 struct xt_table_info *newinfo, *info; 1621 struct xt_table_info *newinfo, *info;
1623 void *pos, *entry0, *entry1; 1622 void *pos, *entry0, *entry1;
1624 unsigned int size; 1623 unsigned int size;
@@ -1636,21 +1635,21 @@ translate_compat_table(const char *name,
1636 } 1635 }
1637 1636
1638 duprintf("translate_compat_table: size %u\n", info->size); 1637 duprintf("translate_compat_table: size %u\n", info->size);
1639 i = 0; 1638 j = 0;
1640 xt_compat_lock(AF_INET); 1639 xt_compat_lock(AF_INET);
1641 /* Walk through entries, checking offsets. */ 1640 /* Walk through entries, checking offsets. */
1642 ret = IPT_ENTRY_ITERATE(entry0, total_size, 1641 ret = IPT_ENTRY_ITERATE(entry0, total_size,
1643 check_compat_entry_size_and_hooks, 1642 check_compat_entry_size_and_hooks,
1644 info, &size, entry0, 1643 info, &size, entry0,
1645 entry0 + total_size, 1644 entry0 + total_size,
1646 hook_entries, underflows, &i, name); 1645 hook_entries, underflows, &j, name);
1647 if (ret != 0) 1646 if (ret != 0)
1648 goto out_unlock; 1647 goto out_unlock;
1649 1648
1650 ret = -EINVAL; 1649 ret = -EINVAL;
1651 if (i != number) { 1650 if (j != number) {
1652 duprintf("translate_compat_table: %u not %u entries\n", 1651 duprintf("translate_compat_table: %u not %u entries\n",
1653 i, number); 1652 j, number);
1654 goto out_unlock; 1653 goto out_unlock;
1655 } 1654 }
1656 1655
@@ -1709,8 +1708,10 @@ translate_compat_table(const char *name,
1709free_newinfo: 1708free_newinfo:
1710 xt_free_table_info(newinfo); 1709 xt_free_table_info(newinfo);
1711out: 1710out:
1711 IPT_ENTRY_ITERATE(entry0, total_size, cleanup_entry, &j);
1712 return ret; 1712 return ret;
1713out_unlock: 1713out_unlock:
1714 compat_flush_offsets();
1714 xt_compat_unlock(AF_INET); 1715 xt_compat_unlock(AF_INET);
1715 goto out; 1716 goto out;
1716} 1717}
@@ -1932,6 +1933,9 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
1932{ 1933{
1933 int ret; 1934 int ret;
1934 1935
1936 if (!capable(CAP_NET_ADMIN))
1937 return -EPERM;
1938
1935 switch (cmd) { 1939 switch (cmd) {
1936 case IPT_SO_GET_INFO: 1940 case IPT_SO_GET_INFO:
1937 ret = get_info(user, len, 1); 1941 ret = get_info(user, len, 1);
diff --git a/net/ipv4/netfilter/ipt_ECN.c b/net/ipv4/netfilter/ipt_ECN.c
index 12a818a2462f..1aa4517fbcdb 100644
--- a/net/ipv4/netfilter/ipt_ECN.c
+++ b/net/ipv4/netfilter/ipt_ECN.c
@@ -28,7 +28,7 @@ static inline int
28set_ect_ip(struct sk_buff **pskb, const struct ipt_ECN_info *einfo) 28set_ect_ip(struct sk_buff **pskb, const struct ipt_ECN_info *einfo)
29{ 29{
30 struct iphdr *iph = (*pskb)->nh.iph; 30 struct iphdr *iph = (*pskb)->nh.iph;
31 __be16 oldtos; 31 u_int16_t oldtos;
32 32
33 if ((iph->tos & IPT_ECN_IP_MASK) != (einfo->ip_ect & IPT_ECN_IP_MASK)) { 33 if ((iph->tos & IPT_ECN_IP_MASK) != (einfo->ip_ect & IPT_ECN_IP_MASK)) {
34 if (!skb_make_writable(pskb, sizeof(struct iphdr))) 34 if (!skb_make_writable(pskb, sizeof(struct iphdr)))
@@ -37,8 +37,8 @@ set_ect_ip(struct sk_buff **pskb, const struct ipt_ECN_info *einfo)
37 oldtos = iph->tos; 37 oldtos = iph->tos;
38 iph->tos &= ~IPT_ECN_IP_MASK; 38 iph->tos &= ~IPT_ECN_IP_MASK;
39 iph->tos |= (einfo->ip_ect & IPT_ECN_IP_MASK); 39 iph->tos |= (einfo->ip_ect & IPT_ECN_IP_MASK);
40 iph->check = nf_csum_update(oldtos ^ htons(0xFFFF), iph->tos, 40 iph->check = nf_csum_update(htons(oldtos) ^ htons(0xFFFF),
41 iph->check); 41 htons(iph->tos), iph->check);
42 } 42 }
43 return 1; 43 return 1;
44} 44}
diff --git a/net/ipv4/netfilter/ipt_TOS.c b/net/ipv4/netfilter/ipt_TOS.c
index 6b8b14ccc3d3..83b80b3a5d2f 100644
--- a/net/ipv4/netfilter/ipt_TOS.c
+++ b/net/ipv4/netfilter/ipt_TOS.c
@@ -30,7 +30,7 @@ target(struct sk_buff **pskb,
30{ 30{
31 const struct ipt_tos_target_info *tosinfo = targinfo; 31 const struct ipt_tos_target_info *tosinfo = targinfo;
32 struct iphdr *iph = (*pskb)->nh.iph; 32 struct iphdr *iph = (*pskb)->nh.iph;
33 __be16 oldtos; 33 u_int16_t oldtos;
34 34
35 if ((iph->tos & IPTOS_TOS_MASK) != tosinfo->tos) { 35 if ((iph->tos & IPTOS_TOS_MASK) != tosinfo->tos) {
36 if (!skb_make_writable(pskb, sizeof(struct iphdr))) 36 if (!skb_make_writable(pskb, sizeof(struct iphdr)))
@@ -38,8 +38,8 @@ target(struct sk_buff **pskb,
38 iph = (*pskb)->nh.iph; 38 iph = (*pskb)->nh.iph;
39 oldtos = iph->tos; 39 oldtos = iph->tos;
40 iph->tos = (iph->tos & IPTOS_PREC_MASK) | tosinfo->tos; 40 iph->tos = (iph->tos & IPTOS_PREC_MASK) | tosinfo->tos;
41 iph->check = nf_csum_update(oldtos ^ htons(0xFFFF), iph->tos, 41 iph->check = nf_csum_update(htons(oldtos) ^ htons(0xFFFF),
42 iph->check); 42 htons(iph->tos), iph->check);
43 } 43 }
44 return IPT_CONTINUE; 44 return IPT_CONTINUE;
45} 45}
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index b430cf2a4f66..5c31dead2bdc 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -329,7 +329,7 @@ error:
329 return err; 329 return err;
330} 330}
331 331
332static void raw_probe_proto_opt(struct flowi *fl, struct msghdr *msg) 332static int raw_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
333{ 333{
334 struct iovec *iov; 334 struct iovec *iov;
335 u8 __user *type = NULL; 335 u8 __user *type = NULL;
@@ -338,7 +338,7 @@ static void raw_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
338 unsigned int i; 338 unsigned int i;
339 339
340 if (!msg->msg_iov) 340 if (!msg->msg_iov)
341 return; 341 return 0;
342 342
343 for (i = 0; i < msg->msg_iovlen; i++) { 343 for (i = 0; i < msg->msg_iovlen; i++) {
344 iov = &msg->msg_iov[i]; 344 iov = &msg->msg_iov[i];
@@ -360,8 +360,9 @@ static void raw_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
360 code = iov->iov_base; 360 code = iov->iov_base;
361 361
362 if (type && code) { 362 if (type && code) {
363 get_user(fl->fl_icmp_type, type); 363 if (get_user(fl->fl_icmp_type, type) ||
364 get_user(fl->fl_icmp_code, code); 364 get_user(fl->fl_icmp_code, code))
365 return -EFAULT;
365 probed = 1; 366 probed = 1;
366 } 367 }
367 break; 368 break;
@@ -372,6 +373,7 @@ static void raw_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
372 if (probed) 373 if (probed)
373 break; 374 break;
374 } 375 }
376 return 0;
375} 377}
376 378
377static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, 379static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
@@ -480,8 +482,11 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
480 .proto = inet->hdrincl ? IPPROTO_RAW : 482 .proto = inet->hdrincl ? IPPROTO_RAW :
481 sk->sk_protocol, 483 sk->sk_protocol,
482 }; 484 };
483 if (!inet->hdrincl) 485 if (!inet->hdrincl) {
484 raw_probe_proto_opt(&fl, msg); 486 err = raw_probe_proto_opt(&fl, msg);
487 if (err)
488 goto done;
489 }
485 490
486 security_sk_classify_flow(sk, &fl); 491 security_sk_classify_flow(sk, &fl);
487 err = ip_route_output_flow(&rt, &fl, sk, !(msg->msg_flags&MSG_DONTWAIT)); 492 err = ip_route_output_flow(&rt, &fl, sk, !(msg->msg_flags&MSG_DONTWAIT));
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index c41ddba02e9d..925ee4dfc32c 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -566,9 +566,15 @@ static inline u32 rt_score(struct rtable *rt)
566 566
567static inline int compare_keys(struct flowi *fl1, struct flowi *fl2) 567static inline int compare_keys(struct flowi *fl1, struct flowi *fl2)
568{ 568{
569 return memcmp(&fl1->nl_u.ip4_u, &fl2->nl_u.ip4_u, sizeof(fl1->nl_u.ip4_u)) == 0 && 569 return ((fl1->nl_u.ip4_u.daddr ^ fl2->nl_u.ip4_u.daddr) |
570 fl1->oif == fl2->oif && 570 (fl1->nl_u.ip4_u.saddr ^ fl2->nl_u.ip4_u.saddr) |
571 fl1->iif == fl2->iif; 571#ifdef CONFIG_IP_ROUTE_FWMARK
572 (fl1->nl_u.ip4_u.fwmark ^ fl2->nl_u.ip4_u.fwmark) |
573#endif
574 (*(u16 *)&fl1->nl_u.ip4_u.tos ^
575 *(u16 *)&fl2->nl_u.ip4_u.tos) |
576 (fl1->oif ^ fl2->oif) |
577 (fl1->iif ^ fl2->iif)) == 0;
572} 578}
573 579
574#ifdef CONFIG_IP_ROUTE_MULTIPATH_CACHED 580#ifdef CONFIG_IP_ROUTE_MULTIPATH_CACHED
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index e82a5be894b5..15061b314411 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -129,13 +129,6 @@ static int sysctl_tcp_congestion_control(ctl_table *table, int __user *name,
129 return ret; 129 return ret;
130} 130}
131 131
132static int __init tcp_congestion_default(void)
133{
134 return tcp_set_default_congestion_control(CONFIG_DEFAULT_TCP_CONG);
135}
136
137late_initcall(tcp_congestion_default);
138
139ctl_table ipv4_table[] = { 132ctl_table ipv4_table[] = {
140 { 133 {
141 .ctl_name = NET_IPV4_TCP_TIMESTAMPS, 134 .ctl_name = NET_IPV4_TCP_TIMESTAMPS,
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 66e9a729f6df..c05e8edaf544 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2270,7 +2270,7 @@ void __init tcp_init(void)
2270 thash_entries, 2270 thash_entries,
2271 (num_physpages >= 128 * 1024) ? 2271 (num_physpages >= 128 * 1024) ?
2272 13 : 15, 2272 13 : 15,
2273 HASH_HIGHMEM, 2273 0,
2274 &tcp_hashinfo.ehash_size, 2274 &tcp_hashinfo.ehash_size,
2275 NULL, 2275 NULL,
2276 0); 2276 0);
@@ -2286,7 +2286,7 @@ void __init tcp_init(void)
2286 tcp_hashinfo.ehash_size, 2286 tcp_hashinfo.ehash_size,
2287 (num_physpages >= 128 * 1024) ? 2287 (num_physpages >= 128 * 1024) ?
2288 13 : 15, 2288 13 : 15,
2289 HASH_HIGHMEM, 2289 0,
2290 &tcp_hashinfo.bhash_size, 2290 &tcp_hashinfo.bhash_size,
2291 NULL, 2291 NULL,
2292 64 * 1024); 2292 64 * 1024);
@@ -2316,9 +2316,10 @@ void __init tcp_init(void)
2316 sysctl_max_syn_backlog = 128; 2316 sysctl_max_syn_backlog = 128;
2317 } 2317 }
2318 2318
2319 sysctl_tcp_mem[0] = 768 << order; 2319 /* Allow no more than 3/4 kernel memory (usually less) allocated to TCP */
2320 sysctl_tcp_mem[1] = 1024 << order; 2320 sysctl_tcp_mem[0] = (1536 / sizeof (struct inet_bind_hashbucket)) << order;
2321 sysctl_tcp_mem[2] = 1536 << order; 2321 sysctl_tcp_mem[1] = sysctl_tcp_mem[0] * 4 / 3;
2322 sysctl_tcp_mem[2] = sysctl_tcp_mem[0] * 2;
2322 2323
2323 limit = ((unsigned long)sysctl_tcp_mem[1]) << (PAGE_SHIFT - 7); 2324 limit = ((unsigned long)sysctl_tcp_mem[1]) << (PAGE_SHIFT - 7);
2324 max_share = min(4UL*1024*1024, limit); 2325 max_share = min(4UL*1024*1024, limit);
diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c
index af0aca1e6be6..1e2982f4acd4 100644
--- a/net/ipv4/tcp_cong.c
+++ b/net/ipv4/tcp_cong.c
@@ -131,6 +131,14 @@ int tcp_set_default_congestion_control(const char *name)
131 return ret; 131 return ret;
132} 132}
133 133
134/* Set default value from kernel configuration at bootup */
135static int __init tcp_congestion_default(void)
136{
137 return tcp_set_default_congestion_control(CONFIG_DEFAULT_TCP_CONG);
138}
139late_initcall(tcp_congestion_default);
140
141
134/* Get current default congestion control */ 142/* Get current default congestion control */
135void tcp_get_default_congestion_control(char *name) 143void tcp_get_default_congestion_control(char *name)
136{ 144{
diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c
index a60ef38d75c6..6ad184802266 100644
--- a/net/ipv4/tcp_cubic.c
+++ b/net/ipv4/tcp_cubic.c
@@ -190,7 +190,7 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd)
190 */ 190 */
191 191
192 /* change the unit from HZ to bictcp_HZ */ 192 /* change the unit from HZ to bictcp_HZ */
193 t = ((tcp_time_stamp + ca->delay_min - ca->epoch_start) 193 t = ((tcp_time_stamp + (ca->delay_min>>3) - ca->epoch_start)
194 << BICTCP_HZ) / HZ; 194 << BICTCP_HZ) / HZ;
195 195
196 if (t < ca->bic_K) /* t - K */ 196 if (t < ca->bic_K) /* t - K */
@@ -259,7 +259,7 @@ static inline void measure_delay(struct sock *sk)
259 (s32)(tcp_time_stamp - ca->epoch_start) < HZ) 259 (s32)(tcp_time_stamp - ca->epoch_start) < HZ)
260 return; 260 return;
261 261
262 delay = tcp_time_stamp - tp->rx_opt.rcv_tsecr; 262 delay = (tcp_time_stamp - tp->rx_opt.rcv_tsecr)<<3;
263 if (delay == 0) 263 if (delay == 0)
264 delay = 1; 264 delay = 1;
265 265
@@ -366,7 +366,7 @@ static int __init cubictcp_register(void)
366 366
367 beta_scale = 8*(BICTCP_BETA_SCALE+beta)/ 3 / (BICTCP_BETA_SCALE - beta); 367 beta_scale = 8*(BICTCP_BETA_SCALE+beta)/ 3 / (BICTCP_BETA_SCALE - beta);
368 368
369 cube_rtt_scale = (bic_scale << 3) / 10; /* 1024*c/rtt */ 369 cube_rtt_scale = (bic_scale * 10); /* 1024*c/rtt */
370 370
371 /* calculate the "K" for (wmax-cwnd) = c/rtt * K^3 371 /* calculate the "K" for (wmax-cwnd) = c/rtt * K^3
372 * so K = cubic_root( (wmax-cwnd)*rtt/c ) 372 * so K = cubic_root( (wmax-cwnd)*rtt/c )
diff --git a/net/ipv4/tcp_htcp.c b/net/ipv4/tcp_htcp.c
index 682e7d5b6f2f..283be3cb4667 100644
--- a/net/ipv4/tcp_htcp.c
+++ b/net/ipv4/tcp_htcp.c
@@ -23,7 +23,7 @@ module_param(use_bandwidth_switch, int, 0644);
23MODULE_PARM_DESC(use_bandwidth_switch, "turn on/off bandwidth switcher"); 23MODULE_PARM_DESC(use_bandwidth_switch, "turn on/off bandwidth switcher");
24 24
25struct htcp { 25struct htcp {
26 u16 alpha; /* Fixed point arith, << 7 */ 26 u32 alpha; /* Fixed point arith, << 7 */
27 u8 beta; /* Fixed point arith, << 7 */ 27 u8 beta; /* Fixed point arith, << 7 */
28 u8 modeswitch; /* Delay modeswitch until we had at least one congestion event */ 28 u8 modeswitch; /* Delay modeswitch until we had at least one congestion event */
29 u32 last_cong; /* Time since last congestion event end */ 29 u32 last_cong; /* Time since last congestion event end */
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index c83938b8fcb1..22ef8bd26620 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -355,7 +355,7 @@ void tcp_v4_err(struct sk_buff *skb, u32 info)
355 return; 355 return;
356 } 356 }
357 if (sk->sk_state == TCP_TIME_WAIT) { 357 if (sk->sk_state == TCP_TIME_WAIT) {
358 inet_twsk_put((struct inet_timewait_sock *)sk); 358 inet_twsk_put(inet_twsk(sk));
359 return; 359 return;
360 } 360 }
361 361
@@ -373,7 +373,7 @@ void tcp_v4_err(struct sk_buff *skb, u32 info)
373 seq = ntohl(th->seq); 373 seq = ntohl(th->seq);
374 if (sk->sk_state != TCP_LISTEN && 374 if (sk->sk_state != TCP_LISTEN &&
375 !between(seq, tp->snd_una, tp->snd_nxt)) { 375 !between(seq, tp->snd_una, tp->snd_nxt)) {
376 NET_INC_STATS(LINUX_MIB_OUTOFWINDOWICMPS); 376 NET_INC_STATS_BH(LINUX_MIB_OUTOFWINDOWICMPS);
377 goto out; 377 goto out;
378 } 378 }
379 379
@@ -578,7 +578,7 @@ static void tcp_v4_send_ack(struct sk_buff *skb, u32 seq, u32 ack,
578 struct tcphdr *th = skb->h.th; 578 struct tcphdr *th = skb->h.th;
579 struct { 579 struct {
580 struct tcphdr th; 580 struct tcphdr th;
581 u32 tsopt[3]; 581 u32 tsopt[TCPOLEN_TSTAMP_ALIGNED >> 2];
582 } rep; 582 } rep;
583 struct ip_reply_arg arg; 583 struct ip_reply_arg arg;
584 584
@@ -960,7 +960,7 @@ static struct sock *tcp_v4_hnd_req(struct sock *sk, struct sk_buff *skb)
960 bh_lock_sock(nsk); 960 bh_lock_sock(nsk);
961 return nsk; 961 return nsk;
962 } 962 }
963 inet_twsk_put((struct inet_timewait_sock *)nsk); 963 inet_twsk_put(inet_twsk(nsk));
964 return NULL; 964 return NULL;
965 } 965 }
966 966
@@ -1154,26 +1154,24 @@ discard_and_relse:
1154 1154
1155do_time_wait: 1155do_time_wait:
1156 if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) { 1156 if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) {
1157 inet_twsk_put((struct inet_timewait_sock *) sk); 1157 inet_twsk_put(inet_twsk(sk));
1158 goto discard_it; 1158 goto discard_it;
1159 } 1159 }
1160 1160
1161 if (skb->len < (th->doff << 2) || tcp_checksum_complete(skb)) { 1161 if (skb->len < (th->doff << 2) || tcp_checksum_complete(skb)) {
1162 TCP_INC_STATS_BH(TCP_MIB_INERRS); 1162 TCP_INC_STATS_BH(TCP_MIB_INERRS);
1163 inet_twsk_put((struct inet_timewait_sock *) sk); 1163 inet_twsk_put(inet_twsk(sk));
1164 goto discard_it; 1164 goto discard_it;
1165 } 1165 }
1166 switch (tcp_timewait_state_process((struct inet_timewait_sock *)sk, 1166 switch (tcp_timewait_state_process(inet_twsk(sk), skb, th)) {
1167 skb, th)) {
1168 case TCP_TW_SYN: { 1167 case TCP_TW_SYN: {
1169 struct sock *sk2 = inet_lookup_listener(&tcp_hashinfo, 1168 struct sock *sk2 = inet_lookup_listener(&tcp_hashinfo,
1170 skb->nh.iph->daddr, 1169 skb->nh.iph->daddr,
1171 th->dest, 1170 th->dest,
1172 inet_iif(skb)); 1171 inet_iif(skb));
1173 if (sk2) { 1172 if (sk2) {
1174 inet_twsk_deschedule((struct inet_timewait_sock *)sk, 1173 inet_twsk_deschedule(inet_twsk(sk), &tcp_death_row);
1175 &tcp_death_row); 1174 inet_twsk_put(inet_twsk(sk));
1176 inet_twsk_put((struct inet_timewait_sock *)sk);
1177 sk = sk2; 1175 sk = sk2;
1178 goto process; 1176 goto process;
1179 } 1177 }
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 9a253faefc81..ca406157724c 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -273,10 +273,10 @@ static void tcp_build_and_update_options(__be32 *ptr, struct tcp_sock *tp,
273 __u32 tstamp) 273 __u32 tstamp)
274{ 274{
275 if (tp->rx_opt.tstamp_ok) { 275 if (tp->rx_opt.tstamp_ok) {
276 *ptr++ = __constant_htonl((TCPOPT_NOP << 24) | 276 *ptr++ = htonl((TCPOPT_NOP << 24) |
277 (TCPOPT_NOP << 16) | 277 (TCPOPT_NOP << 16) |
278 (TCPOPT_TIMESTAMP << 8) | 278 (TCPOPT_TIMESTAMP << 8) |
279 TCPOLEN_TIMESTAMP); 279 TCPOLEN_TIMESTAMP);
280 *ptr++ = htonl(tstamp); 280 *ptr++ = htonl(tstamp);
281 *ptr++ = htonl(tp->rx_opt.ts_recent); 281 *ptr++ = htonl(tp->rx_opt.ts_recent);
282 } 282 }
@@ -325,18 +325,27 @@ static void tcp_syn_build_options(__be32 *ptr, int mss, int ts, int sack,
325 *ptr++ = htonl((TCPOPT_MSS << 24) | (TCPOLEN_MSS << 16) | mss); 325 *ptr++ = htonl((TCPOPT_MSS << 24) | (TCPOLEN_MSS << 16) | mss);
326 if (ts) { 326 if (ts) {
327 if(sack) 327 if(sack)
328 *ptr++ = __constant_htonl((TCPOPT_SACK_PERM << 24) | (TCPOLEN_SACK_PERM << 16) | 328 *ptr++ = htonl((TCPOPT_SACK_PERM << 24) |
329 (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP); 329 (TCPOLEN_SACK_PERM << 16) |
330 (TCPOPT_TIMESTAMP << 8) |
331 TCPOLEN_TIMESTAMP);
330 else 332 else
331 *ptr++ = __constant_htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | 333 *ptr++ = htonl((TCPOPT_NOP << 24) |
332 (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP); 334 (TCPOPT_NOP << 16) |
335 (TCPOPT_TIMESTAMP << 8) |
336 TCPOLEN_TIMESTAMP);
333 *ptr++ = htonl(tstamp); /* TSVAL */ 337 *ptr++ = htonl(tstamp); /* TSVAL */
334 *ptr++ = htonl(ts_recent); /* TSECR */ 338 *ptr++ = htonl(ts_recent); /* TSECR */
335 } else if(sack) 339 } else if(sack)
336 *ptr++ = __constant_htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | 340 *ptr++ = htonl((TCPOPT_NOP << 24) |
337 (TCPOPT_SACK_PERM << 8) | TCPOLEN_SACK_PERM); 341 (TCPOPT_NOP << 16) |
342 (TCPOPT_SACK_PERM << 8) |
343 TCPOLEN_SACK_PERM);
338 if (offer_wscale) 344 if (offer_wscale)
339 *ptr++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_WINDOW << 16) | (TCPOLEN_WINDOW << 8) | (wscale)); 345 *ptr++ = htonl((TCPOPT_NOP << 24) |
346 (TCPOPT_WINDOW << 16) |
347 (TCPOLEN_WINDOW << 8) |
348 (wscale));
340} 349}
341 350
342/* This routine actually transmits TCP packets queued in by 351/* This routine actually transmits TCP packets queued in by
@@ -1087,10 +1096,14 @@ static int tcp_tso_should_defer(struct sock *sk, struct tcp_sock *tp, struct sk_
1087 u32 send_win, cong_win, limit, in_flight; 1096 u32 send_win, cong_win, limit, in_flight;
1088 1097
1089 if (TCP_SKB_CB(skb)->flags & TCPCB_FLAG_FIN) 1098 if (TCP_SKB_CB(skb)->flags & TCPCB_FLAG_FIN)
1090 return 0; 1099 goto send_now;
1091 1100
1092 if (icsk->icsk_ca_state != TCP_CA_Open) 1101 if (icsk->icsk_ca_state != TCP_CA_Open)
1093 return 0; 1102 goto send_now;
1103
1104 /* Defer for less than two clock ticks. */
1105 if (!tp->tso_deferred && ((jiffies<<1)>>1) - (tp->tso_deferred>>1) > 1)
1106 goto send_now;
1094 1107
1095 in_flight = tcp_packets_in_flight(tp); 1108 in_flight = tcp_packets_in_flight(tp);
1096 1109
@@ -1106,7 +1119,7 @@ static int tcp_tso_should_defer(struct sock *sk, struct tcp_sock *tp, struct sk_
1106 1119
1107 /* If a full-sized TSO skb can be sent, do it. */ 1120 /* If a full-sized TSO skb can be sent, do it. */
1108 if (limit >= 65536) 1121 if (limit >= 65536)
1109 return 0; 1122 goto send_now;
1110 1123
1111 if (sysctl_tcp_tso_win_divisor) { 1124 if (sysctl_tcp_tso_win_divisor) {
1112 u32 chunk = min(tp->snd_wnd, tp->snd_cwnd * tp->mss_cache); 1125 u32 chunk = min(tp->snd_wnd, tp->snd_cwnd * tp->mss_cache);
@@ -1116,7 +1129,7 @@ static int tcp_tso_should_defer(struct sock *sk, struct tcp_sock *tp, struct sk_
1116 */ 1129 */
1117 chunk /= sysctl_tcp_tso_win_divisor; 1130 chunk /= sysctl_tcp_tso_win_divisor;
1118 if (limit >= chunk) 1131 if (limit >= chunk)
1119 return 0; 1132 goto send_now;
1120 } else { 1133 } else {
1121 /* Different approach, try not to defer past a single 1134 /* Different approach, try not to defer past a single
1122 * ACK. Receiver should ACK every other full sized 1135 * ACK. Receiver should ACK every other full sized
@@ -1124,11 +1137,17 @@ static int tcp_tso_should_defer(struct sock *sk, struct tcp_sock *tp, struct sk_
1124 * then send now. 1137 * then send now.
1125 */ 1138 */
1126 if (limit > tcp_max_burst(tp) * tp->mss_cache) 1139 if (limit > tcp_max_burst(tp) * tp->mss_cache)
1127 return 0; 1140 goto send_now;
1128 } 1141 }
1129 1142
1130 /* Ok, it looks like it is advisable to defer. */ 1143 /* Ok, it looks like it is advisable to defer. */
1144 tp->tso_deferred = 1 | (jiffies<<1);
1145
1131 return 1; 1146 return 1;
1147
1148send_now:
1149 tp->tso_deferred = 0;
1150 return 0;
1132} 1151}
1133 1152
1134/* Create a new MTU probe if we are ready. 1153/* Create a new MTU probe if we are ready.
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
index 7a7a00147e55..1bed0cdf53e3 100644
--- a/net/ipv4/xfrm4_policy.c
+++ b/net/ipv4/xfrm4_policy.c
@@ -52,7 +52,7 @@ __xfrm4_find_bundle(struct flowi *fl, struct xfrm_policy *policy)
52 xdst->u.rt.fl.fl4_dst == fl->fl4_dst && 52 xdst->u.rt.fl.fl4_dst == fl->fl4_dst &&
53 xdst->u.rt.fl.fl4_src == fl->fl4_src && 53 xdst->u.rt.fl.fl4_src == fl->fl4_src &&
54 xdst->u.rt.fl.fl4_tos == fl->fl4_tos && 54 xdst->u.rt.fl.fl4_tos == fl->fl4_tos &&
55 xfrm_bundle_ok(xdst, fl, AF_INET, 0)) { 55 xfrm_bundle_ok(policy, xdst, fl, AF_INET, 0)) {
56 dst_clone(dst); 56 dst_clone(dst);
57 break; 57 break;
58 } 58 }
diff --git a/net/ipv6/Kconfig b/net/ipv6/Kconfig
index a460e8132b4d..6e48f52e197c 100644
--- a/net/ipv6/Kconfig
+++ b/net/ipv6/Kconfig
@@ -153,6 +153,19 @@ config INET6_XFRM_MODE_ROUTEOPTIMIZATION
153 ---help--- 153 ---help---
154 Support for MIPv6 route optimization mode. 154 Support for MIPv6 route optimization mode.
155 155
156config IPV6_SIT
157 tristate "IPv6: IPv6-in-IPv4 tunnel (SIT driver)"
158 depends on IPV6
159 default y
160 ---help---
161 Tunneling means encapsulating data of one protocol type within
162 another protocol and sending it over a channel that understands the
163 encapsulating protocol. This driver implements encapsulation of IPv6
164 into IPv4 packets. This is useful if you want to connect two IPv6
165 networks over an IPv4-only path.
166
167 Saying M here will produce a module called sit.ko. If unsure, say Y.
168
156config IPV6_TUNNEL 169config IPV6_TUNNEL
157 tristate "IPv6: IPv6-in-IPv6 tunnel" 170 tristate "IPv6: IPv6-in-IPv6 tunnel"
158 select INET6_TUNNEL 171 select INET6_TUNNEL
@@ -162,9 +175,16 @@ config IPV6_TUNNEL
162 175
163 If unsure, say N. 176 If unsure, say N.
164 177
178config IPV6_MULTIPLE_TABLES
179 bool "IPv6: Multiple Routing Tables"
180 depends on IPV6 && EXPERIMENTAL
181 select FIB_RULES
182 ---help---
183 Support multiple routing tables.
184
165config IPV6_SUBTREES 185config IPV6_SUBTREES
166 bool "IPv6: source address based routing" 186 bool "IPv6: source address based routing"
167 depends on IPV6 && EXPERIMENTAL 187 depends on IPV6_MULTIPLE_TABLES
168 ---help--- 188 ---help---
169 Enable routing by source address or prefix. 189 Enable routing by source address or prefix.
170 190
@@ -176,13 +196,6 @@ config IPV6_SUBTREES
176 196
177 If unsure, say N. 197 If unsure, say N.
178 198
179config IPV6_MULTIPLE_TABLES
180 bool "IPv6: Multiple Routing Tables"
181 depends on IPV6 && EXPERIMENTAL
182 select FIB_RULES
183 ---help---
184 Support multiple routing tables.
185
186config IPV6_ROUTE_FWMARK 199config IPV6_ROUTE_FWMARK
187 bool "IPv6: use netfilter MARK value as routing key" 200 bool "IPv6: use netfilter MARK value as routing key"
188 depends on IPV6_MULTIPLE_TABLES && NETFILTER 201 depends on IPV6_MULTIPLE_TABLES && NETFILTER
diff --git a/net/ipv6/Makefile b/net/ipv6/Makefile
index 87274e47fe32..addcc011bc01 100644
--- a/net/ipv6/Makefile
+++ b/net/ipv6/Makefile
@@ -4,7 +4,7 @@
4 4
5obj-$(CONFIG_IPV6) += ipv6.o 5obj-$(CONFIG_IPV6) += ipv6.o
6 6
7ipv6-objs := af_inet6.o anycast.o ip6_output.o ip6_input.o addrconf.o sit.o \ 7ipv6-objs := af_inet6.o anycast.o ip6_output.o ip6_input.o addrconf.o \
8 route.o ip6_fib.o ipv6_sockglue.o ndisc.o udp.o raw.o \ 8 route.o ip6_fib.o ipv6_sockglue.o ndisc.o udp.o raw.o \
9 protocol.o icmp.o mcast.o reassembly.o tcp_ipv6.o \ 9 protocol.o icmp.o mcast.o reassembly.o tcp_ipv6.o \
10 exthdrs.o sysctl_net_ipv6.o datagram.o proc.o \ 10 exthdrs.o sysctl_net_ipv6.o datagram.o proc.o \
@@ -29,6 +29,7 @@ obj-$(CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION) += xfrm6_mode_ro.o
29obj-$(CONFIG_INET6_XFRM_MODE_BEET) += xfrm6_mode_beet.o 29obj-$(CONFIG_INET6_XFRM_MODE_BEET) += xfrm6_mode_beet.o
30obj-$(CONFIG_NETFILTER) += netfilter/ 30obj-$(CONFIG_NETFILTER) += netfilter/
31 31
32obj-$(CONFIG_IPV6_SIT) += sit.o
32obj-$(CONFIG_IPV6_TUNNEL) += ip6_tunnel.o 33obj-$(CONFIG_IPV6_TUNNEL) += ip6_tunnel.o
33 34
34obj-y += exthdrs_core.o 35obj-y += exthdrs_core.o
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index e03c33b2465b..b312a5f7a759 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -396,8 +396,10 @@ static struct inet6_dev * ipv6_add_dev(struct net_device *dev)
396 ndev->regen_timer.data = (unsigned long) ndev; 396 ndev->regen_timer.data = (unsigned long) ndev;
397 if ((dev->flags&IFF_LOOPBACK) || 397 if ((dev->flags&IFF_LOOPBACK) ||
398 dev->type == ARPHRD_TUNNEL || 398 dev->type == ARPHRD_TUNNEL ||
399 dev->type == ARPHRD_NONE || 399#if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE)
400 dev->type == ARPHRD_SIT) { 400 dev->type == ARPHRD_SIT ||
401#endif
402 dev->type == ARPHRD_NONE) {
401 printk(KERN_INFO 403 printk(KERN_INFO
402 "%s: Disabled Privacy Extensions\n", 404 "%s: Disabled Privacy Extensions\n",
403 dev->name); 405 dev->name);
@@ -1546,8 +1548,10 @@ addrconf_prefix_route(struct in6_addr *pfx, int plen, struct net_device *dev,
1546 This thing is done here expecting that the whole 1548 This thing is done here expecting that the whole
1547 class of non-broadcast devices need not cloning. 1549 class of non-broadcast devices need not cloning.
1548 */ 1550 */
1551#if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE)
1549 if (dev->type == ARPHRD_SIT && (dev->flags & IFF_POINTOPOINT)) 1552 if (dev->type == ARPHRD_SIT && (dev->flags & IFF_POINTOPOINT))
1550 cfg.fc_flags |= RTF_NONEXTHOP; 1553 cfg.fc_flags |= RTF_NONEXTHOP;
1554#endif
1551 1555
1552 ip6_route_add(&cfg); 1556 ip6_route_add(&cfg);
1553} 1557}
@@ -1569,6 +1573,7 @@ static void addrconf_add_mroute(struct net_device *dev)
1569 ip6_route_add(&cfg); 1573 ip6_route_add(&cfg);
1570} 1574}
1571 1575
1576#if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE)
1572static void sit_route_add(struct net_device *dev) 1577static void sit_route_add(struct net_device *dev)
1573{ 1578{
1574 struct fib6_config cfg = { 1579 struct fib6_config cfg = {
@@ -1582,6 +1587,7 @@ static void sit_route_add(struct net_device *dev)
1582 /* prefix length - 96 bits "::d.d.d.d" */ 1587 /* prefix length - 96 bits "::d.d.d.d" */
1583 ip6_route_add(&cfg); 1588 ip6_route_add(&cfg);
1584} 1589}
1590#endif
1585 1591
1586static void addrconf_add_lroute(struct net_device *dev) 1592static void addrconf_add_lroute(struct net_device *dev)
1587{ 1593{
@@ -1852,6 +1858,7 @@ int addrconf_set_dstaddr(void __user *arg)
1852 if (dev == NULL) 1858 if (dev == NULL)
1853 goto err_exit; 1859 goto err_exit;
1854 1860
1861#if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE)
1855 if (dev->type == ARPHRD_SIT) { 1862 if (dev->type == ARPHRD_SIT) {
1856 struct ifreq ifr; 1863 struct ifreq ifr;
1857 mm_segment_t oldfs; 1864 mm_segment_t oldfs;
@@ -1881,6 +1888,7 @@ int addrconf_set_dstaddr(void __user *arg)
1881 err = dev_open(dev); 1888 err = dev_open(dev);
1882 } 1889 }
1883 } 1890 }
1891#endif
1884 1892
1885err_exit: 1893err_exit:
1886 rtnl_unlock(); 1894 rtnl_unlock();
@@ -2010,6 +2018,7 @@ int addrconf_del_ifaddr(void __user *arg)
2010 return err; 2018 return err;
2011} 2019}
2012 2020
2021#if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE)
2013static void sit_add_v4_addrs(struct inet6_dev *idev) 2022static void sit_add_v4_addrs(struct inet6_dev *idev)
2014{ 2023{
2015 struct inet6_ifaddr * ifp; 2024 struct inet6_ifaddr * ifp;
@@ -2078,6 +2087,7 @@ static void sit_add_v4_addrs(struct inet6_dev *idev)
2078 } 2087 }
2079 } 2088 }
2080} 2089}
2090#endif
2081 2091
2082static void init_loopback(struct net_device *dev) 2092static void init_loopback(struct net_device *dev)
2083{ 2093{
@@ -2141,6 +2151,7 @@ static void addrconf_dev_config(struct net_device *dev)
2141 addrconf_add_linklocal(idev, &addr); 2151 addrconf_add_linklocal(idev, &addr);
2142} 2152}
2143 2153
2154#if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE)
2144static void addrconf_sit_config(struct net_device *dev) 2155static void addrconf_sit_config(struct net_device *dev)
2145{ 2156{
2146 struct inet6_dev *idev; 2157 struct inet6_dev *idev;
@@ -2166,6 +2177,7 @@ static void addrconf_sit_config(struct net_device *dev)
2166 } else 2177 } else
2167 sit_route_add(dev); 2178 sit_route_add(dev);
2168} 2179}
2180#endif
2169 2181
2170static inline int 2182static inline int
2171ipv6_inherit_linklocal(struct inet6_dev *idev, struct net_device *link_dev) 2183ipv6_inherit_linklocal(struct inet6_dev *idev, struct net_device *link_dev)
@@ -2260,9 +2272,11 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
2260 } 2272 }
2261 2273
2262 switch(dev->type) { 2274 switch(dev->type) {
2275#if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE)
2263 case ARPHRD_SIT: 2276 case ARPHRD_SIT:
2264 addrconf_sit_config(dev); 2277 addrconf_sit_config(dev);
2265 break; 2278 break;
2279#endif
2266 case ARPHRD_TUNNEL6: 2280 case ARPHRD_TUNNEL6:
2267 addrconf_ip6_tnl_config(dev); 2281 addrconf_ip6_tnl_config(dev);
2268 break; 2282 break;
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index e94eccb99707..858cae29581c 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -850,7 +850,6 @@ static int __init inet6_init(void)
850 err = addrconf_init(); 850 err = addrconf_init();
851 if (err) 851 if (err)
852 goto addrconf_fail; 852 goto addrconf_fail;
853 sit_init();
854 853
855 /* Init v6 extension headers. */ 854 /* Init v6 extension headers. */
856 ipv6_rthdr_init(); 855 ipv6_rthdr_init();
@@ -927,7 +926,6 @@ static void __exit inet6_exit(void)
927 mip6_fini(); 926 mip6_fini();
928#endif 927#endif
929 /* Cleanup code parts. */ 928 /* Cleanup code parts. */
930 sit_cleanup();
931 ip6_flowlabel_cleanup(); 929 ip6_flowlabel_cleanup();
932 addrconf_cleanup(); 930 addrconf_cleanup();
933 ip6_route_cleanup(); 931 ip6_route_cleanup();
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
index d8c1057e8b00..1896ecb52899 100644
--- a/net/ipv6/fib6_rules.c
+++ b/net/ipv6/fib6_rules.c
@@ -117,12 +117,15 @@ static int fib6_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
117{ 117{
118 struct fib6_rule *r = (struct fib6_rule *) rule; 118 struct fib6_rule *r = (struct fib6_rule *) rule;
119 119
120 if (!ipv6_prefix_equal(&fl->fl6_dst, &r->dst.addr, r->dst.plen)) 120 if (r->dst.plen &&
121 !ipv6_prefix_equal(&fl->fl6_dst, &r->dst.addr, r->dst.plen))
121 return 0; 122 return 0;
122 123
123 if ((flags & RT6_LOOKUP_F_HAS_SADDR) && 124 if (r->src.plen) {
124 !ipv6_prefix_equal(&fl->fl6_src, &r->src.addr, r->src.plen)) 125 if (!(flags & RT6_LOOKUP_F_HAS_SADDR) ||
125 return 0; 126 !ipv6_prefix_equal(&fl->fl6_src, &r->src.addr, r->src.plen))
127 return 0;
128 }
126 129
127 if (r->tclass && r->tclass != ((ntohl(fl->fl6_flowlabel) >> 20) & 0xff)) 130 if (r->tclass && r->tclass != ((ntohl(fl->fl6_flowlabel) >> 20) & 0xff))
128 return 0; 131 return 0;
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 8fcae7a6510b..f98ca30d7c1f 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -169,7 +169,6 @@ static __inline__ void rt6_release(struct rt6_info *rt)
169 169
170static struct fib6_table fib6_main_tbl = { 170static struct fib6_table fib6_main_tbl = {
171 .tb6_id = RT6_TABLE_MAIN, 171 .tb6_id = RT6_TABLE_MAIN,
172 .tb6_lock = RW_LOCK_UNLOCKED,
173 .tb6_root = { 172 .tb6_root = {
174 .leaf = &ip6_null_entry, 173 .leaf = &ip6_null_entry,
175 .fn_flags = RTN_ROOT | RTN_TL_ROOT | RTN_RTINFO, 174 .fn_flags = RTN_ROOT | RTN_TL_ROOT | RTN_RTINFO,
@@ -187,6 +186,12 @@ static void fib6_link_table(struct fib6_table *tb)
187{ 186{
188 unsigned int h; 187 unsigned int h;
189 188
189 /*
190 * Initialize table lock at a single place to give lockdep a key,
191 * tables aren't visible prior to being linked to the list.
192 */
193 rwlock_init(&tb->tb6_lock);
194
190 h = tb->tb6_id & (FIB_TABLE_HASHSZ - 1); 195 h = tb->tb6_id & (FIB_TABLE_HASHSZ - 1);
191 196
192 /* 197 /*
@@ -199,7 +204,6 @@ static void fib6_link_table(struct fib6_table *tb)
199#ifdef CONFIG_IPV6_MULTIPLE_TABLES 204#ifdef CONFIG_IPV6_MULTIPLE_TABLES
200static struct fib6_table fib6_local_tbl = { 205static struct fib6_table fib6_local_tbl = {
201 .tb6_id = RT6_TABLE_LOCAL, 206 .tb6_id = RT6_TABLE_LOCAL,
202 .tb6_lock = RW_LOCK_UNLOCKED,
203 .tb6_root = { 207 .tb6_root = {
204 .leaf = &ip6_null_entry, 208 .leaf = &ip6_null_entry,
205 .fn_flags = RTN_ROOT | RTN_TL_ROOT | RTN_RTINFO, 209 .fn_flags = RTN_ROOT | RTN_TL_ROOT | RTN_RTINFO,
@@ -213,7 +217,6 @@ static struct fib6_table *fib6_alloc_table(u32 id)
213 table = kzalloc(sizeof(*table), GFP_ATOMIC); 217 table = kzalloc(sizeof(*table), GFP_ATOMIC);
214 if (table != NULL) { 218 if (table != NULL) {
215 table->tb6_id = id; 219 table->tb6_id = id;
216 table->tb6_lock = RW_LOCK_UNLOCKED;
217 table->tb6_root.leaf = &ip6_null_entry; 220 table->tb6_root.leaf = &ip6_null_entry;
218 table->tb6_root.fn_flags = RTN_ROOT | RTN_TL_ROOT | RTN_RTINFO; 221 table->tb6_root.fn_flags = RTN_ROOT | RTN_TL_ROOT | RTN_RTINFO;
219 } 222 }
diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
index 1d672b0547f2..6d4533b58dca 100644
--- a/net/ipv6/ip6_flowlabel.c
+++ b/net/ipv6/ip6_flowlabel.c
@@ -330,8 +330,10 @@ fl_create(struct in6_flowlabel_req *freq, char __user *optval, int optlen, int *
330 fl->share = freq->flr_share; 330 fl->share = freq->flr_share;
331 addr_type = ipv6_addr_type(&freq->flr_dst); 331 addr_type = ipv6_addr_type(&freq->flr_dst);
332 if ((addr_type&IPV6_ADDR_MAPPED) 332 if ((addr_type&IPV6_ADDR_MAPPED)
333 || addr_type == IPV6_ADDR_ANY) 333 || addr_type == IPV6_ADDR_ANY) {
334 err = -EINVAL;
334 goto done; 335 goto done;
336 }
335 ipv6_addr_copy(&fl->dst, &freq->flr_dst); 337 ipv6_addr_copy(&fl->dst, &freq->flr_dst);
336 atomic_set(&fl->users, 1); 338 atomic_set(&fl->users, 1);
337 switch (fl->share) { 339 switch (fl->share) {
@@ -587,6 +589,8 @@ static struct ip6_flowlabel *ip6fl_get_next(struct seq_file *seq, struct ip6_flo
587 while (!fl) { 589 while (!fl) {
588 if (++state->bucket <= FL_HASH_MASK) 590 if (++state->bucket <= FL_HASH_MASK)
589 fl = fl_ht[state->bucket]; 591 fl = fl_ht[state->bucket];
592 else
593 break;
590 } 594 }
591 return fl; 595 return fl;
592} 596}
@@ -623,9 +627,13 @@ static void ip6fl_seq_stop(struct seq_file *seq, void *v)
623 read_unlock_bh(&ip6_fl_lock); 627 read_unlock_bh(&ip6_fl_lock);
624} 628}
625 629
626static void ip6fl_fl_seq_show(struct seq_file *seq, struct ip6_flowlabel *fl) 630static int ip6fl_seq_show(struct seq_file *seq, void *v)
627{ 631{
628 while(fl) { 632 if (v == SEQ_START_TOKEN)
633 seq_printf(seq, "%-5s %-1s %-6s %-6s %-6s %-8s %-32s %s\n",
634 "Label", "S", "Owner", "Users", "Linger", "Expires", "Dst", "Opt");
635 else {
636 struct ip6_flowlabel *fl = v;
629 seq_printf(seq, 637 seq_printf(seq,
630 "%05X %-1d %-6d %-6d %-6ld %-8ld " NIP6_SEQFMT " %-4d\n", 638 "%05X %-1d %-6d %-6d %-6ld %-8ld " NIP6_SEQFMT " %-4d\n",
631 (unsigned)ntohl(fl->label), 639 (unsigned)ntohl(fl->label),
@@ -636,17 +644,7 @@ static void ip6fl_fl_seq_show(struct seq_file *seq, struct ip6_flowlabel *fl)
636 (long)(fl->expires - jiffies)/HZ, 644 (long)(fl->expires - jiffies)/HZ,
637 NIP6(fl->dst), 645 NIP6(fl->dst),
638 fl->opt ? fl->opt->opt_nflen : 0); 646 fl->opt ? fl->opt->opt_nflen : 0);
639 fl = fl->next;
640 } 647 }
641}
642
643static int ip6fl_seq_show(struct seq_file *seq, void *v)
644{
645 if (v == SEQ_START_TOKEN)
646 seq_printf(seq, "%-5s %-1s %-6s %-6s %-6s %-8s %-32s %s\n",
647 "Label", "S", "Owner", "Users", "Linger", "Expires", "Dst", "Opt");
648 else
649 ip6fl_fl_seq_show(seq, v);
650 return 0; 648 return 0;
651} 649}
652 650
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 84d7ebdb9d21..b9f40290d12a 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -542,6 +542,7 @@ ip6ip6_rcv(struct sk_buff *skb)
542 skb->dev = t->dev; 542 skb->dev = t->dev;
543 dst_release(skb->dst); 543 dst_release(skb->dst);
544 skb->dst = NULL; 544 skb->dst = NULL;
545 nf_reset(skb);
545 if (t->parms.flags & IP6_TNL_F_RCV_DSCP_COPY) 546 if (t->parms.flags & IP6_TNL_F_RCV_DSCP_COPY)
546 ipv6_copy_dscp(ipv6h, skb->nh.ipv6h); 547 ipv6_copy_dscp(ipv6h, skb->nh.ipv6h);
547 ip6ip6_ecn_decapsulate(ipv6h, skb); 548 ip6ip6_ecn_decapsulate(ipv6h, skb);
@@ -1149,6 +1150,20 @@ fail:
1149 return err; 1150 return err;
1150} 1151}
1151 1152
1153static void __exit ip6ip6_destroy_tunnels(void)
1154{
1155 int h;
1156 struct ip6_tnl *t;
1157
1158 for (h = 0; h < HASH_SIZE; h++) {
1159 while ((t = tnls_r_l[h]) != NULL)
1160 unregister_netdevice(t->dev);
1161 }
1162
1163 t = tnls_wc[0];
1164 unregister_netdevice(t->dev);
1165}
1166
1152/** 1167/**
1153 * ip6_tunnel_cleanup - free resources and unregister protocol 1168 * ip6_tunnel_cleanup - free resources and unregister protocol
1154 **/ 1169 **/
@@ -1158,7 +1173,9 @@ static void __exit ip6_tunnel_cleanup(void)
1158 if (xfrm6_tunnel_deregister(&ip6ip6_handler)) 1173 if (xfrm6_tunnel_deregister(&ip6ip6_handler))
1159 printk(KERN_INFO "ip6ip6 close: can't deregister tunnel\n"); 1174 printk(KERN_INFO "ip6ip6 close: can't deregister tunnel\n");
1160 1175
1161 unregister_netdev(ip6ip6_fb_tnl_dev); 1176 rtnl_lock();
1177 ip6ip6_destroy_tunnels();
1178 rtnl_unlock();
1162} 1179}
1163 1180
1164module_init(ip6_tunnel_init); 1181module_init(ip6_tunnel_init);
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 0304b5fe8d6a..73eb8c33e9f0 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -967,8 +967,6 @@ static void ndisc_recv_na(struct sk_buff *skb)
967 ipv6_devconf.forwarding && ipv6_devconf.proxy_ndp && 967 ipv6_devconf.forwarding && ipv6_devconf.proxy_ndp &&
968 pneigh_lookup(&nd_tbl, &msg->target, dev, 0)) { 968 pneigh_lookup(&nd_tbl, &msg->target, dev, 0)) {
969 /* XXX: idev->cnf.prixy_ndp */ 969 /* XXX: idev->cnf.prixy_ndp */
970 WARN_ON(skb->dst != NULL &&
971 ((struct rt6_info *)skb->dst)->rt6i_idev);
972 goto out; 970 goto out;
973 } 971 }
974 972
@@ -1744,6 +1742,7 @@ int __init ndisc_init(struct net_proto_family *ops)
1744 1742
1745void ndisc_cleanup(void) 1743void ndisc_cleanup(void)
1746{ 1744{
1745 unregister_netdevice_notifier(&ndisc_netdev_notifier);
1747#ifdef CONFIG_SYSCTL 1746#ifdef CONFIG_SYSCTL
1748 neigh_sysctl_unregister(&nd_tbl.parms); 1747 neigh_sysctl_unregister(&nd_tbl.parms);
1749#endif 1748#endif
diff --git a/net/ipv6/netfilter/Kconfig b/net/ipv6/netfilter/Kconfig
index 4bc4e5b33794..d7c45a9c15fe 100644
--- a/net/ipv6/netfilter/Kconfig
+++ b/net/ipv6/netfilter/Kconfig
@@ -40,7 +40,7 @@ config IP6_NF_QUEUE
40 To compile it as a module, choose M here. If unsure, say N. 40 To compile it as a module, choose M here. If unsure, say N.
41 41
42config IP6_NF_IPTABLES 42config IP6_NF_IPTABLES
43 tristate "IP6 tables support (required for filtering/masq/NAT)" 43 tristate "IP6 tables support (required for filtering)"
44 depends on NETFILTER_XTABLES 44 depends on NETFILTER_XTABLES
45 help 45 help
46 ip6tables is a general, extensible packet identification framework. 46 ip6tables is a general, extensible packet identification framework.
diff --git a/net/ipv6/netfilter/ip6_queue.c b/net/ipv6/netfilter/ip6_queue.c
index 9510c24ca8d2..9fec832ee08b 100644
--- a/net/ipv6/netfilter/ip6_queue.c
+++ b/net/ipv6/netfilter/ip6_queue.c
@@ -349,9 +349,10 @@ ipq_mangle_ipv6(ipq_verdict_msg_t *v, struct ipq_queue_entry *e)
349 if (v->data_len < sizeof(*user_iph)) 349 if (v->data_len < sizeof(*user_iph))
350 return 0; 350 return 0;
351 diff = v->data_len - e->skb->len; 351 diff = v->data_len - e->skb->len;
352 if (diff < 0) 352 if (diff < 0) {
353 skb_trim(e->skb, v->data_len); 353 if (pskb_trim(e->skb, v->data_len))
354 else if (diff > 0) { 354 return -ENOMEM;
355 } else if (diff > 0) {
355 if (v->data_len > 0xFFFF) 356 if (v->data_len > 0xFFFF)
356 return -EINVAL; 357 return -EINVAL;
357 if (diff > skb_tailroom(e->skb)) { 358 if (diff > skb_tailroom(e->skb)) {
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index 4ab368fa0b8f..204e02162d49 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -111,7 +111,7 @@ ip6_packet_match(const struct sk_buff *skb,
111 const char *outdev, 111 const char *outdev,
112 const struct ip6t_ip6 *ip6info, 112 const struct ip6t_ip6 *ip6info,
113 unsigned int *protoff, 113 unsigned int *protoff,
114 int *fragoff) 114 int *fragoff, int *hotdrop)
115{ 115{
116 size_t i; 116 size_t i;
117 unsigned long ret; 117 unsigned long ret;
@@ -169,9 +169,11 @@ ip6_packet_match(const struct sk_buff *skb,
169 unsigned short _frag_off; 169 unsigned short _frag_off;
170 170
171 protohdr = ipv6_find_hdr(skb, protoff, -1, &_frag_off); 171 protohdr = ipv6_find_hdr(skb, protoff, -1, &_frag_off);
172 if (protohdr < 0) 172 if (protohdr < 0) {
173 if (_frag_off == 0)
174 *hotdrop = 1;
173 return 0; 175 return 0;
174 176 }
175 *fragoff = _frag_off; 177 *fragoff = _frag_off;
176 178
177 dprintf("Packet protocol %hi ?= %s%hi.\n", 179 dprintf("Packet protocol %hi ?= %s%hi.\n",
@@ -290,7 +292,7 @@ ip6t_do_table(struct sk_buff **pskb,
290 IP_NF_ASSERT(e); 292 IP_NF_ASSERT(e);
291 IP_NF_ASSERT(back); 293 IP_NF_ASSERT(back);
292 if (ip6_packet_match(*pskb, indev, outdev, &e->ipv6, 294 if (ip6_packet_match(*pskb, indev, outdev, &e->ipv6,
293 &protoff, &offset)) { 295 &protoff, &offset, &hotdrop)) {
294 struct ip6t_entry_target *t; 296 struct ip6t_entry_target *t;
295 297
296 if (IP6T_MATCH_ITERATE(e, do_match, 298 if (IP6T_MATCH_ITERATE(e, do_match,
@@ -584,12 +586,19 @@ check_entry(struct ip6t_entry *e, const char *name, unsigned int size,
584 return -EINVAL; 586 return -EINVAL;
585 } 587 }
586 588
589 if (e->target_offset + sizeof(struct ip6t_entry_target) >
590 e->next_offset)
591 return -EINVAL;
592
587 j = 0; 593 j = 0;
588 ret = IP6T_MATCH_ITERATE(e, check_match, name, &e->ipv6, e->comefrom, &j); 594 ret = IP6T_MATCH_ITERATE(e, check_match, name, &e->ipv6, e->comefrom, &j);
589 if (ret != 0) 595 if (ret != 0)
590 goto cleanup_matches; 596 goto cleanup_matches;
591 597
592 t = ip6t_get_target(e); 598 t = ip6t_get_target(e);
599 ret = -EINVAL;
600 if (e->target_offset + t->u.target_size > e->next_offset)
601 goto cleanup_matches;
593 target = try_then_request_module(xt_find_target(AF_INET6, 602 target = try_then_request_module(xt_find_target(AF_INET6,
594 t->u.user.name, 603 t->u.user.name,
595 t->u.user.revision), 604 t->u.user.revision),
@@ -749,19 +758,17 @@ translate_table(const char *name,
749 } 758 }
750 } 759 }
751 760
752 if (!mark_source_chains(newinfo, valid_hooks, entry0))
753 return -ELOOP;
754
755 /* Finally, each sanity check must pass */ 761 /* Finally, each sanity check must pass */
756 i = 0; 762 i = 0;
757 ret = IP6T_ENTRY_ITERATE(entry0, newinfo->size, 763 ret = IP6T_ENTRY_ITERATE(entry0, newinfo->size,
758 check_entry, name, size, &i); 764 check_entry, name, size, &i);
759 765
760 if (ret != 0) { 766 if (ret != 0)
761 IP6T_ENTRY_ITERATE(entry0, newinfo->size, 767 goto cleanup;
762 cleanup_entry, &i); 768
763 return ret; 769 ret = -ELOOP;
764 } 770 if (!mark_source_chains(newinfo, valid_hooks, entry0))
771 goto cleanup;
765 772
766 /* And one copy for every other CPU */ 773 /* And one copy for every other CPU */
767 for_each_possible_cpu(i) { 774 for_each_possible_cpu(i) {
@@ -769,6 +776,9 @@ translate_table(const char *name,
769 memcpy(newinfo->entries[i], entry0, newinfo->size); 776 memcpy(newinfo->entries[i], entry0, newinfo->size);
770 } 777 }
771 778
779 return 0;
780cleanup:
781 IP6T_ENTRY_ITERATE(entry0, newinfo->size, cleanup_entry, &i);
772 return ret; 782 return ret;
773} 783}
774 784
@@ -1438,6 +1448,9 @@ static void __exit ip6_tables_fini(void)
1438 * If target header is found, its offset is set in *offset and return protocol 1448 * If target header is found, its offset is set in *offset and return protocol
1439 * number. Otherwise, return -1. 1449 * number. Otherwise, return -1.
1440 * 1450 *
1451 * If the first fragment doesn't contain the final protocol header or
1452 * NEXTHDR_NONE it is considered invalid.
1453 *
1441 * Note that non-1st fragment is special case that "the protocol number 1454 * Note that non-1st fragment is special case that "the protocol number
1442 * of last header" is "next header" field in Fragment header. In this case, 1455 * of last header" is "next header" field in Fragment header. In this case,
1443 * *offset is meaningless and fragment offset is stored in *fragoff if fragoff 1456 * *offset is meaningless and fragment offset is stored in *fragoff if fragoff
@@ -1461,12 +1474,12 @@ int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset,
1461 if ((!ipv6_ext_hdr(nexthdr)) || nexthdr == NEXTHDR_NONE) { 1474 if ((!ipv6_ext_hdr(nexthdr)) || nexthdr == NEXTHDR_NONE) {
1462 if (target < 0) 1475 if (target < 0)
1463 break; 1476 break;
1464 return -1; 1477 return -ENOENT;
1465 } 1478 }
1466 1479
1467 hp = skb_header_pointer(skb, start, sizeof(_hdr), &_hdr); 1480 hp = skb_header_pointer(skb, start, sizeof(_hdr), &_hdr);
1468 if (hp == NULL) 1481 if (hp == NULL)
1469 return -1; 1482 return -EBADMSG;
1470 if (nexthdr == NEXTHDR_FRAGMENT) { 1483 if (nexthdr == NEXTHDR_FRAGMENT) {
1471 unsigned short _frag_off, *fp; 1484 unsigned short _frag_off, *fp;
1472 fp = skb_header_pointer(skb, 1485 fp = skb_header_pointer(skb,
@@ -1475,18 +1488,18 @@ int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset,
1475 sizeof(_frag_off), 1488 sizeof(_frag_off),
1476 &_frag_off); 1489 &_frag_off);
1477 if (fp == NULL) 1490 if (fp == NULL)
1478 return -1; 1491 return -EBADMSG;
1479 1492
1480 _frag_off = ntohs(*fp) & ~0x7; 1493 _frag_off = ntohs(*fp) & ~0x7;
1481 if (_frag_off) { 1494 if (_frag_off) {
1482 if (target < 0 && 1495 if (target < 0 &&
1483 ((!ipv6_ext_hdr(hp->nexthdr)) || 1496 ((!ipv6_ext_hdr(hp->nexthdr)) ||
1484 nexthdr == NEXTHDR_NONE)) { 1497 hp->nexthdr == NEXTHDR_NONE)) {
1485 if (fragoff) 1498 if (fragoff)
1486 *fragoff = _frag_off; 1499 *fragoff = _frag_off;
1487 return hp->nexthdr; 1500 return hp->nexthdr;
1488 } 1501 }
1489 return -1; 1502 return -ENOENT;
1490 } 1503 }
1491 hdrlen = 8; 1504 hdrlen = 8;
1492 } else if (nexthdr == NEXTHDR_AUTH) 1505 } else if (nexthdr == NEXTHDR_AUTH)
diff --git a/net/ipv6/netfilter/ip6t_ah.c b/net/ipv6/netfilter/ip6t_ah.c
index ec1b1608156c..46486645eb75 100644
--- a/net/ipv6/netfilter/ip6t_ah.c
+++ b/net/ipv6/netfilter/ip6t_ah.c
@@ -54,9 +54,14 @@ match(const struct sk_buff *skb,
54 const struct ip6t_ah *ahinfo = matchinfo; 54 const struct ip6t_ah *ahinfo = matchinfo;
55 unsigned int ptr; 55 unsigned int ptr;
56 unsigned int hdrlen = 0; 56 unsigned int hdrlen = 0;
57 int err;
57 58
58 if (ipv6_find_hdr(skb, &ptr, NEXTHDR_AUTH, NULL) < 0) 59 err = ipv6_find_hdr(skb, &ptr, NEXTHDR_AUTH, NULL);
60 if (err < 0) {
61 if (err != -ENOENT)
62 *hotdrop = 1;
59 return 0; 63 return 0;
64 }
60 65
61 ah = skb_header_pointer(skb, ptr, sizeof(_ah), &_ah); 66 ah = skb_header_pointer(skb, ptr, sizeof(_ah), &_ah);
62 if (ah == NULL) { 67 if (ah == NULL) {
diff --git a/net/ipv6/netfilter/ip6t_frag.c b/net/ipv6/netfilter/ip6t_frag.c
index 78d9c8b9e28a..cd22eaaccdca 100644
--- a/net/ipv6/netfilter/ip6t_frag.c
+++ b/net/ipv6/netfilter/ip6t_frag.c
@@ -52,9 +52,14 @@ match(const struct sk_buff *skb,
52 struct frag_hdr _frag, *fh; 52 struct frag_hdr _frag, *fh;
53 const struct ip6t_frag *fraginfo = matchinfo; 53 const struct ip6t_frag *fraginfo = matchinfo;
54 unsigned int ptr; 54 unsigned int ptr;
55 int err;
55 56
56 if (ipv6_find_hdr(skb, &ptr, NEXTHDR_FRAGMENT, NULL) < 0) 57 err = ipv6_find_hdr(skb, &ptr, NEXTHDR_FRAGMENT, NULL);
58 if (err < 0) {
59 if (err != -ENOENT)
60 *hotdrop = 1;
57 return 0; 61 return 0;
62 }
58 63
59 fh = skb_header_pointer(skb, ptr, sizeof(_frag), &_frag); 64 fh = skb_header_pointer(skb, ptr, sizeof(_frag), &_frag);
60 if (fh == NULL) { 65 if (fh == NULL) {
diff --git a/net/ipv6/netfilter/ip6t_hbh.c b/net/ipv6/netfilter/ip6t_hbh.c
index d32a205e3af2..3f25babe0440 100644
--- a/net/ipv6/netfilter/ip6t_hbh.c
+++ b/net/ipv6/netfilter/ip6t_hbh.c
@@ -65,9 +65,14 @@ match(const struct sk_buff *skb,
65 u8 _opttype, *tp = NULL; 65 u8 _opttype, *tp = NULL;
66 u8 _optlen, *lp = NULL; 66 u8 _optlen, *lp = NULL;
67 unsigned int optlen; 67 unsigned int optlen;
68 int err;
68 69
69 if (ipv6_find_hdr(skb, &ptr, match->data, NULL) < 0) 70 err = ipv6_find_hdr(skb, &ptr, match->data, NULL);
71 if (err < 0) {
72 if (err != -ENOENT)
73 *hotdrop = 1;
70 return 0; 74 return 0;
75 }
71 76
72 oh = skb_header_pointer(skb, ptr, sizeof(_optsh), &_optsh); 77 oh = skb_header_pointer(skb, ptr, sizeof(_optsh), &_optsh);
73 if (oh == NULL) { 78 if (oh == NULL) {
diff --git a/net/ipv6/netfilter/ip6t_rt.c b/net/ipv6/netfilter/ip6t_rt.c
index bcb2e168a5bc..54d7d14134fd 100644
--- a/net/ipv6/netfilter/ip6t_rt.c
+++ b/net/ipv6/netfilter/ip6t_rt.c
@@ -58,9 +58,14 @@ match(const struct sk_buff *skb,
58 unsigned int hdrlen = 0; 58 unsigned int hdrlen = 0;
59 unsigned int ret = 0; 59 unsigned int ret = 0;
60 struct in6_addr *ap, _addr; 60 struct in6_addr *ap, _addr;
61 int err;
61 62
62 if (ipv6_find_hdr(skb, &ptr, NEXTHDR_ROUTING, NULL) < 0) 63 err = ipv6_find_hdr(skb, &ptr, NEXTHDR_ROUTING, NULL);
64 if (err < 0) {
65 if (err != -ENOENT)
66 *hotdrop = 1;
63 return 0; 67 return 0;
68 }
64 69
65 rh = skb_header_pointer(skb, ptr, sizeof(_route), &_route); 70 rh = skb_header_pointer(skb, ptr, sizeof(_route), &_route);
66 if (rh == NULL) { 71 if (rh == NULL) {
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index d09329ca3267..d6dedc4aec77 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -604,7 +604,7 @@ error:
604 return err; 604 return err;
605} 605}
606 606
607static void rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg) 607static int rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
608{ 608{
609 struct iovec *iov; 609 struct iovec *iov;
610 u8 __user *type = NULL; 610 u8 __user *type = NULL;
@@ -616,7 +616,7 @@ static void rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
616 int i; 616 int i;
617 617
618 if (!msg->msg_iov) 618 if (!msg->msg_iov)
619 return; 619 return 0;
620 620
621 for (i = 0; i < msg->msg_iovlen; i++) { 621 for (i = 0; i < msg->msg_iovlen; i++) {
622 iov = &msg->msg_iov[i]; 622 iov = &msg->msg_iov[i];
@@ -638,8 +638,9 @@ static void rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
638 code = iov->iov_base; 638 code = iov->iov_base;
639 639
640 if (type && code) { 640 if (type && code) {
641 get_user(fl->fl_icmp_type, type); 641 if (get_user(fl->fl_icmp_type, type) ||
642 get_user(fl->fl_icmp_code, code); 642 get_user(fl->fl_icmp_code, code))
643 return -EFAULT;
643 probed = 1; 644 probed = 1;
644 } 645 }
645 break; 646 break;
@@ -650,7 +651,8 @@ static void rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
650 /* check if type field is readable or not. */ 651 /* check if type field is readable or not. */
651 if (iov->iov_len > 2 - len) { 652 if (iov->iov_len > 2 - len) {
652 u8 __user *p = iov->iov_base; 653 u8 __user *p = iov->iov_base;
653 get_user(fl->fl_mh_type, &p[2 - len]); 654 if (get_user(fl->fl_mh_type, &p[2 - len]))
655 return -EFAULT;
654 probed = 1; 656 probed = 1;
655 } else 657 } else
656 len += iov->iov_len; 658 len += iov->iov_len;
@@ -664,6 +666,7 @@ static void rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
664 if (probed) 666 if (probed)
665 break; 667 break;
666 } 668 }
669 return 0;
667} 670}
668 671
669static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, 672static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
@@ -787,7 +790,9 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
787 opt = ipv6_fixup_options(&opt_space, opt); 790 opt = ipv6_fixup_options(&opt_space, opt);
788 791
789 fl.proto = proto; 792 fl.proto = proto;
790 rawv6_probe_proto_opt(&fl, msg); 793 err = rawv6_probe_proto_opt(&fl, msg);
794 if (err)
795 goto out;
791 796
792 ipv6_addr_copy(&fl.fl6_dst, daddr); 797 ipv6_addr_copy(&fl.fl6_dst, daddr);
793 if (ipv6_addr_any(&fl.fl6_src) && !ipv6_addr_any(&np->saddr)) 798 if (ipv6_addr_any(&fl.fl6_src) && !ipv6_addr_any(&np->saddr))
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index d6b4b4f48d18..b39ae99122d5 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -141,6 +141,10 @@ struct rt6_info ip6_null_entry = {
141 141
142#ifdef CONFIG_IPV6_MULTIPLE_TABLES 142#ifdef CONFIG_IPV6_MULTIPLE_TABLES
143 143
144static int ip6_pkt_prohibit(struct sk_buff *skb);
145static int ip6_pkt_prohibit_out(struct sk_buff *skb);
146static int ip6_pkt_blk_hole(struct sk_buff *skb);
147
144struct rt6_info ip6_prohibit_entry = { 148struct rt6_info ip6_prohibit_entry = {
145 .u = { 149 .u = {
146 .dst = { 150 .dst = {
@@ -150,8 +154,8 @@ struct rt6_info ip6_prohibit_entry = {
150 .obsolete = -1, 154 .obsolete = -1,
151 .error = -EACCES, 155 .error = -EACCES,
152 .metrics = { [RTAX_HOPLIMIT - 1] = 255, }, 156 .metrics = { [RTAX_HOPLIMIT - 1] = 255, },
153 .input = ip6_pkt_discard, 157 .input = ip6_pkt_prohibit,
154 .output = ip6_pkt_discard_out, 158 .output = ip6_pkt_prohibit_out,
155 .ops = &ip6_dst_ops, 159 .ops = &ip6_dst_ops,
156 .path = (struct dst_entry*)&ip6_prohibit_entry, 160 .path = (struct dst_entry*)&ip6_prohibit_entry,
157 } 161 }
@@ -170,8 +174,8 @@ struct rt6_info ip6_blk_hole_entry = {
170 .obsolete = -1, 174 .obsolete = -1,
171 .error = -EINVAL, 175 .error = -EINVAL,
172 .metrics = { [RTAX_HOPLIMIT - 1] = 255, }, 176 .metrics = { [RTAX_HOPLIMIT - 1] = 255, },
173 .input = ip6_pkt_discard, 177 .input = ip6_pkt_blk_hole,
174 .output = ip6_pkt_discard_out, 178 .output = ip6_pkt_blk_hole,
175 .ops = &ip6_dst_ops, 179 .ops = &ip6_dst_ops,
176 .path = (struct dst_entry*)&ip6_blk_hole_entry, 180 .path = (struct dst_entry*)&ip6_blk_hole_entry,
177 } 181 }
@@ -326,6 +330,8 @@ static int inline rt6_check_neigh(struct rt6_info *rt)
326 read_lock_bh(&neigh->lock); 330 read_lock_bh(&neigh->lock);
327 if (neigh->nud_state & NUD_VALID) 331 if (neigh->nud_state & NUD_VALID)
328 m = 2; 332 m = 2;
333 else if (!(neigh->nud_state & NUD_FAILED))
334 m = 1;
329 read_unlock_bh(&neigh->lock); 335 read_unlock_bh(&neigh->lock);
330 } 336 }
331 return m; 337 return m;
@@ -343,9 +349,7 @@ static int rt6_score_route(struct rt6_info *rt, int oif,
343 m |= IPV6_DECODE_PREF(IPV6_EXTRACT_PREF(rt->rt6i_flags)) << 2; 349 m |= IPV6_DECODE_PREF(IPV6_EXTRACT_PREF(rt->rt6i_flags)) << 2;
344#endif 350#endif
345 n = rt6_check_neigh(rt); 351 n = rt6_check_neigh(rt);
346 if (n > 1) 352 if (!n && (strict & RT6_LOOKUP_F_REACHABLE))
347 m |= 16;
348 else if (!n && strict & RT6_LOOKUP_F_REACHABLE)
349 return -1; 353 return -1;
350 return m; 354 return m;
351} 355}
@@ -376,10 +380,11 @@ static struct rt6_info *rt6_select(struct rt6_info **head, int oif,
376 continue; 380 continue;
377 381
378 if (m > mpri) { 382 if (m > mpri) {
379 rt6_probe(match); 383 if (strict & RT6_LOOKUP_F_REACHABLE)
384 rt6_probe(match);
380 match = rt; 385 match = rt;
381 mpri = m; 386 mpri = m;
382 } else { 387 } else if (strict & RT6_LOOKUP_F_REACHABLE) {
383 rt6_probe(rt); 388 rt6_probe(rt);
384 } 389 }
385 } 390 }
@@ -484,7 +489,7 @@ int rt6_route_rcv(struct net_device *dev, u8 *opt, int len,
484do { \ 489do { \
485 if (rt == &ip6_null_entry) { \ 490 if (rt == &ip6_null_entry) { \
486 struct fib6_node *pn; \ 491 struct fib6_node *pn; \
487 while (fn) { \ 492 while (1) { \
488 if (fn->fn_flags & RTN_TL_ROOT) \ 493 if (fn->fn_flags & RTN_TL_ROOT) \
489 goto out; \ 494 goto out; \
490 pn = fn->parent; \ 495 pn = fn->parent; \
@@ -529,13 +534,17 @@ struct rt6_info *rt6_lookup(struct in6_addr *daddr, struct in6_addr *saddr,
529 .nl_u = { 534 .nl_u = {
530 .ip6_u = { 535 .ip6_u = {
531 .daddr = *daddr, 536 .daddr = *daddr,
532 /* TODO: saddr */
533 }, 537 },
534 }, 538 },
535 }; 539 };
536 struct dst_entry *dst; 540 struct dst_entry *dst;
537 int flags = strict ? RT6_LOOKUP_F_IFACE : 0; 541 int flags = strict ? RT6_LOOKUP_F_IFACE : 0;
538 542
543 if (saddr) {
544 memcpy(&fl.fl6_src, saddr, sizeof(*saddr));
545 flags |= RT6_LOOKUP_F_HAS_SADDR;
546 }
547
539 dst = fib6_rule_lookup(&fl, flags, ip6_pol_route_lookup); 548 dst = fib6_rule_lookup(&fl, flags, ip6_pol_route_lookup);
540 if (dst->error == 0) 549 if (dst->error == 0)
541 return (struct rt6_info *) dst; 550 return (struct rt6_info *) dst;
@@ -614,8 +623,6 @@ static struct rt6_info *rt6_alloc_clone(struct rt6_info *ort, struct in6_addr *d
614 ipv6_addr_copy(&rt->rt6i_dst.addr, daddr); 623 ipv6_addr_copy(&rt->rt6i_dst.addr, daddr);
615 rt->rt6i_dst.plen = 128; 624 rt->rt6i_dst.plen = 128;
616 rt->rt6i_flags |= RTF_CACHE; 625 rt->rt6i_flags |= RTF_CACHE;
617 if (rt->rt6i_flags & RTF_REJECT)
618 rt->u.dst.error = ort->u.dst.error;
619 rt->u.dst.flags |= DST_HOST; 626 rt->u.dst.flags |= DST_HOST;
620 rt->rt6i_nexthop = neigh_clone(ort->rt6i_nexthop); 627 rt->rt6i_nexthop = neigh_clone(ort->rt6i_nexthop);
621 } 628 }
@@ -630,7 +637,7 @@ static struct rt6_info *ip6_pol_route_input(struct fib6_table *table,
630 int strict = 0; 637 int strict = 0;
631 int attempts = 3; 638 int attempts = 3;
632 int err; 639 int err;
633 int reachable = RT6_LOOKUP_F_REACHABLE; 640 int reachable = ipv6_devconf.forwarding ? 0 : RT6_LOOKUP_F_REACHABLE;
634 641
635 strict |= flags & RT6_LOOKUP_F_IFACE; 642 strict |= flags & RT6_LOOKUP_F_IFACE;
636 643
@@ -697,6 +704,7 @@ out2:
697void ip6_route_input(struct sk_buff *skb) 704void ip6_route_input(struct sk_buff *skb)
698{ 705{
699 struct ipv6hdr *iph = skb->nh.ipv6h; 706 struct ipv6hdr *iph = skb->nh.ipv6h;
707 int flags = RT6_LOOKUP_F_HAS_SADDR;
700 struct flowi fl = { 708 struct flowi fl = {
701 .iif = skb->dev->ifindex, 709 .iif = skb->dev->ifindex,
702 .nl_u = { 710 .nl_u = {
@@ -711,7 +719,9 @@ void ip6_route_input(struct sk_buff *skb)
711 }, 719 },
712 .proto = iph->nexthdr, 720 .proto = iph->nexthdr,
713 }; 721 };
714 int flags = rt6_need_strict(&iph->daddr) ? RT6_LOOKUP_F_IFACE : 0; 722
723 if (rt6_need_strict(&iph->daddr))
724 flags |= RT6_LOOKUP_F_IFACE;
715 725
716 skb->dst = fib6_rule_lookup(&fl, flags, ip6_pol_route_input); 726 skb->dst = fib6_rule_lookup(&fl, flags, ip6_pol_route_input);
717} 727}
@@ -724,7 +734,7 @@ static struct rt6_info *ip6_pol_route_output(struct fib6_table *table,
724 int strict = 0; 734 int strict = 0;
725 int attempts = 3; 735 int attempts = 3;
726 int err; 736 int err;
727 int reachable = RT6_LOOKUP_F_REACHABLE; 737 int reachable = ipv6_devconf.forwarding ? 0 : RT6_LOOKUP_F_REACHABLE;
728 738
729 strict |= flags & RT6_LOOKUP_F_IFACE; 739 strict |= flags & RT6_LOOKUP_F_IFACE;
730 740
@@ -794,6 +804,9 @@ struct dst_entry * ip6_route_output(struct sock *sk, struct flowi *fl)
794 if (rt6_need_strict(&fl->fl6_dst)) 804 if (rt6_need_strict(&fl->fl6_dst))
795 flags |= RT6_LOOKUP_F_IFACE; 805 flags |= RT6_LOOKUP_F_IFACE;
796 806
807 if (!ipv6_addr_any(&fl->fl6_src))
808 flags |= RT6_LOOKUP_F_HAS_SADDR;
809
797 return fib6_rule_lookup(fl, flags, ip6_pol_route_output); 810 return fib6_rule_lookup(fl, flags, ip6_pol_route_output);
798} 811}
799 812
@@ -1345,6 +1358,7 @@ static struct rt6_info *ip6_route_redirect(struct in6_addr *dest,
1345 struct in6_addr *gateway, 1358 struct in6_addr *gateway,
1346 struct net_device *dev) 1359 struct net_device *dev)
1347{ 1360{
1361 int flags = RT6_LOOKUP_F_HAS_SADDR;
1348 struct ip6rd_flowi rdfl = { 1362 struct ip6rd_flowi rdfl = {
1349 .fl = { 1363 .fl = {
1350 .oif = dev->ifindex, 1364 .oif = dev->ifindex,
@@ -1357,7 +1371,9 @@ static struct rt6_info *ip6_route_redirect(struct in6_addr *dest,
1357 }, 1371 },
1358 .gateway = *gateway, 1372 .gateway = *gateway,
1359 }; 1373 };
1360 int flags = rt6_need_strict(dest) ? RT6_LOOKUP_F_IFACE : 0; 1374
1375 if (rt6_need_strict(dest))
1376 flags |= RT6_LOOKUP_F_IFACE;
1361 1377
1362 return (struct rt6_info *)fib6_rule_lookup((struct flowi *)&rdfl, flags, __ip6_route_redirect); 1378 return (struct rt6_info *)fib6_rule_lookup((struct flowi *)&rdfl, flags, __ip6_route_redirect);
1363} 1379}
@@ -1527,6 +1543,7 @@ static struct rt6_info * ip6_rt_copy(struct rt6_info *ort)
1527 rt->u.dst.output = ort->u.dst.output; 1543 rt->u.dst.output = ort->u.dst.output;
1528 1544
1529 memcpy(rt->u.dst.metrics, ort->u.dst.metrics, RTAX_MAX*sizeof(u32)); 1545 memcpy(rt->u.dst.metrics, ort->u.dst.metrics, RTAX_MAX*sizeof(u32));
1546 rt->u.dst.error = ort->u.dst.error;
1530 rt->u.dst.dev = ort->u.dst.dev; 1547 rt->u.dst.dev = ort->u.dst.dev;
1531 if (rt->u.dst.dev) 1548 if (rt->u.dst.dev)
1532 dev_hold(rt->u.dst.dev); 1549 dev_hold(rt->u.dst.dev);
@@ -1730,24 +1747,50 @@ int ipv6_route_ioctl(unsigned int cmd, void __user *arg)
1730 * Drop the packet on the floor 1747 * Drop the packet on the floor
1731 */ 1748 */
1732 1749
1733static int ip6_pkt_discard(struct sk_buff *skb) 1750static inline int ip6_pkt_drop(struct sk_buff *skb, int code)
1734{ 1751{
1735 int type = ipv6_addr_type(&skb->nh.ipv6h->daddr); 1752 int type = ipv6_addr_type(&skb->nh.ipv6h->daddr);
1736 if (type == IPV6_ADDR_ANY || type == IPV6_ADDR_RESERVED) 1753 if (type == IPV6_ADDR_ANY || type == IPV6_ADDR_RESERVED)
1737 IP6_INC_STATS(IPSTATS_MIB_INADDRERRORS); 1754 IP6_INC_STATS(IPSTATS_MIB_INADDRERRORS);
1738 1755
1739 IP6_INC_STATS(IPSTATS_MIB_OUTNOROUTES); 1756 IP6_INC_STATS(IPSTATS_MIB_OUTNOROUTES);
1740 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_NOROUTE, 0, skb->dev); 1757 icmpv6_send(skb, ICMPV6_DEST_UNREACH, code, 0, skb->dev);
1741 kfree_skb(skb); 1758 kfree_skb(skb);
1742 return 0; 1759 return 0;
1743} 1760}
1744 1761
1762static int ip6_pkt_discard(struct sk_buff *skb)
1763{
1764 return ip6_pkt_drop(skb, ICMPV6_NOROUTE);
1765}
1766
1745static int ip6_pkt_discard_out(struct sk_buff *skb) 1767static int ip6_pkt_discard_out(struct sk_buff *skb)
1746{ 1768{
1747 skb->dev = skb->dst->dev; 1769 skb->dev = skb->dst->dev;
1748 return ip6_pkt_discard(skb); 1770 return ip6_pkt_discard(skb);
1749} 1771}
1750 1772
1773#ifdef CONFIG_IPV6_MULTIPLE_TABLES
1774
1775static int ip6_pkt_prohibit(struct sk_buff *skb)
1776{
1777 return ip6_pkt_drop(skb, ICMPV6_ADM_PROHIBITED);
1778}
1779
1780static int ip6_pkt_prohibit_out(struct sk_buff *skb)
1781{
1782 skb->dev = skb->dst->dev;
1783 return ip6_pkt_prohibit(skb);
1784}
1785
1786static int ip6_pkt_blk_hole(struct sk_buff *skb)
1787{
1788 kfree_skb(skb);
1789 return 0;
1790}
1791
1792#endif
1793
1751/* 1794/*
1752 * Allocate a dst for local (unicast / anycast) address. 1795 * Allocate a dst for local (unicast / anycast) address.
1753 */ 1796 */
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 836eecd7e62b..be699f85b2c7 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -850,3 +850,8 @@ int __init sit_init(void)
850 inet_del_protocol(&sit_protocol, IPPROTO_IPV6); 850 inet_del_protocol(&sit_protocol, IPPROTO_IPV6);
851 goto out; 851 goto out;
852} 852}
853
854module_init(sit_init);
855module_exit(sit_cleanup);
856MODULE_LICENSE("GPL");
857MODULE_ALIAS("sit0");
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 3b6575478fcc..4c2a7c0cafef 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -329,7 +329,7 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
329 } 329 }
330 330
331 if (sk->sk_state == TCP_TIME_WAIT) { 331 if (sk->sk_state == TCP_TIME_WAIT) {
332 inet_twsk_put((struct inet_timewait_sock *)sk); 332 inet_twsk_put(inet_twsk(sk));
333 return; 333 return;
334 } 334 }
335 335
@@ -653,7 +653,7 @@ static void tcp_v6_send_ack(struct sk_buff *skb, u32 seq, u32 ack, u32 win, u32
653 int tot_len = sizeof(struct tcphdr); 653 int tot_len = sizeof(struct tcphdr);
654 654
655 if (ts) 655 if (ts)
656 tot_len += 3*4; 656 tot_len += TCPOLEN_TSTAMP_ALIGNED;
657 657
658 buff = alloc_skb(MAX_HEADER + sizeof(struct ipv6hdr) + tot_len, 658 buff = alloc_skb(MAX_HEADER + sizeof(struct ipv6hdr) + tot_len,
659 GFP_ATOMIC); 659 GFP_ATOMIC);
@@ -749,7 +749,7 @@ static struct sock *tcp_v6_hnd_req(struct sock *sk,struct sk_buff *skb)
749 bh_lock_sock(nsk); 749 bh_lock_sock(nsk);
750 return nsk; 750 return nsk;
751 } 751 }
752 inet_twsk_put((struct inet_timewait_sock *)nsk); 752 inet_twsk_put(inet_twsk(nsk));
753 return NULL; 753 return NULL;
754 } 754 }
755 755
@@ -1283,18 +1283,17 @@ discard_and_relse:
1283 1283
1284do_time_wait: 1284do_time_wait:
1285 if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) { 1285 if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) {
1286 inet_twsk_put((struct inet_timewait_sock *)sk); 1286 inet_twsk_put(inet_twsk(sk));
1287 goto discard_it; 1287 goto discard_it;
1288 } 1288 }
1289 1289
1290 if (skb->len < (th->doff<<2) || tcp_checksum_complete(skb)) { 1290 if (skb->len < (th->doff<<2) || tcp_checksum_complete(skb)) {
1291 TCP_INC_STATS_BH(TCP_MIB_INERRS); 1291 TCP_INC_STATS_BH(TCP_MIB_INERRS);
1292 inet_twsk_put((struct inet_timewait_sock *)sk); 1292 inet_twsk_put(inet_twsk(sk));
1293 goto discard_it; 1293 goto discard_it;
1294 } 1294 }
1295 1295
1296 switch (tcp_timewait_state_process((struct inet_timewait_sock *)sk, 1296 switch (tcp_timewait_state_process(inet_twsk(sk), skb, th)) {
1297 skb, th)) {
1298 case TCP_TW_SYN: 1297 case TCP_TW_SYN:
1299 { 1298 {
1300 struct sock *sk2; 1299 struct sock *sk2;
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index e0c3934a7e4b..c83f23e51c46 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -242,14 +242,13 @@ static void udpv6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
242{ 242{
243 struct ipv6_pinfo *np; 243 struct ipv6_pinfo *np;
244 struct ipv6hdr *hdr = (struct ipv6hdr*)skb->data; 244 struct ipv6hdr *hdr = (struct ipv6hdr*)skb->data;
245 struct net_device *dev = skb->dev;
246 struct in6_addr *saddr = &hdr->saddr; 245 struct in6_addr *saddr = &hdr->saddr;
247 struct in6_addr *daddr = &hdr->daddr; 246 struct in6_addr *daddr = &hdr->daddr;
248 struct udphdr *uh = (struct udphdr*)(skb->data+offset); 247 struct udphdr *uh = (struct udphdr*)(skb->data+offset);
249 struct sock *sk; 248 struct sock *sk;
250 int err; 249 int err;
251 250
252 sk = udp_v6_lookup(daddr, uh->dest, saddr, uh->source, dev->ifindex); 251 sk = udp_v6_lookup(daddr, uh->dest, saddr, uh->source, inet6_iif(skb));
253 252
254 if (sk == NULL) 253 if (sk == NULL)
255 return; 254 return;
@@ -348,7 +347,7 @@ static void udpv6_mcast_deliver(struct udphdr *uh,
348 347
349 read_lock(&udp_hash_lock); 348 read_lock(&udp_hash_lock);
350 sk = sk_head(&udp_hash[ntohs(uh->dest) & (UDP_HTABLE_SIZE - 1)]); 349 sk = sk_head(&udp_hash[ntohs(uh->dest) & (UDP_HTABLE_SIZE - 1)]);
351 dif = skb->dev->ifindex; 350 dif = inet6_iif(skb);
352 sk = udp_v6_mcast_next(sk, uh->dest, daddr, uh->source, saddr, dif); 351 sk = udp_v6_mcast_next(sk, uh->dest, daddr, uh->source, saddr, dif);
353 if (!sk) { 352 if (!sk) {
354 kfree_skb(skb); 353 kfree_skb(skb);
@@ -429,7 +428,7 @@ static int udpv6_rcv(struct sk_buff **pskb)
429 * check socket cache ... must talk to Alan about his plans 428 * check socket cache ... must talk to Alan about his plans
430 * for sock caches... i'll skip this for now. 429 * for sock caches... i'll skip this for now.
431 */ 430 */
432 sk = udp_v6_lookup(saddr, uh->source, daddr, uh->dest, dev->ifindex); 431 sk = udp_v6_lookup(saddr, uh->source, daddr, uh->dest, inet6_iif(skb));
433 432
434 if (sk == NULL) { 433 if (sk == NULL) {
435 if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) 434 if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
index 6a252e2134d1..d400f8fae129 100644
--- a/net/ipv6/xfrm6_policy.c
+++ b/net/ipv6/xfrm6_policy.c
@@ -25,12 +25,14 @@
25static struct dst_ops xfrm6_dst_ops; 25static struct dst_ops xfrm6_dst_ops;
26static struct xfrm_policy_afinfo xfrm6_policy_afinfo; 26static struct xfrm_policy_afinfo xfrm6_policy_afinfo;
27 27
28static int xfrm6_dst_lookup(struct xfrm_dst **dst, struct flowi *fl) 28static int xfrm6_dst_lookup(struct xfrm_dst **xdst, struct flowi *fl)
29{ 29{
30 int err = 0; 30 struct dst_entry *dst = ip6_route_output(NULL, fl);
31 *dst = (struct xfrm_dst*)ip6_route_output(NULL, fl); 31 int err = dst->error;
32 if (!*dst) 32 if (!err)
33 err = -ENETUNREACH; 33 *xdst = (struct xfrm_dst *) dst;
34 else
35 dst_release(dst);
34 return err; 36 return err;
35} 37}
36 38
@@ -73,7 +75,7 @@ __xfrm6_find_bundle(struct flowi *fl, struct xfrm_policy *policy)
73 xdst->u.rt6.rt6i_src.plen); 75 xdst->u.rt6.rt6i_src.plen);
74 if (ipv6_addr_equal(&xdst->u.rt6.rt6i_dst.addr, &fl_dst_prefix) && 76 if (ipv6_addr_equal(&xdst->u.rt6.rt6i_dst.addr, &fl_dst_prefix) &&
75 ipv6_addr_equal(&xdst->u.rt6.rt6i_src.addr, &fl_src_prefix) && 77 ipv6_addr_equal(&xdst->u.rt6.rt6i_src.addr, &fl_src_prefix) &&
76 xfrm_bundle_ok(xdst, fl, AF_INET6, 78 xfrm_bundle_ok(policy, xdst, fl, AF_INET6,
77 (xdst->u.rt6.rt6i_dst.plen != 128 || 79 (xdst->u.rt6.rt6i_dst.plen != 128 ||
78 xdst->u.rt6.rt6i_src.plen != 128))) { 80 xdst->u.rt6.rt6i_src.plen != 128))) {
79 dst_clone(dst); 81 dst_clone(dst);
diff --git a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c
index 7af227bb1551..7931e4f898d4 100644
--- a/net/ipv6/xfrm6_tunnel.c
+++ b/net/ipv6/xfrm6_tunnel.c
@@ -135,7 +135,7 @@ u32 xfrm6_tunnel_spi_lookup(xfrm_address_t *saddr)
135 x6spi = __xfrm6_tunnel_spi_lookup(saddr); 135 x6spi = __xfrm6_tunnel_spi_lookup(saddr);
136 spi = x6spi ? x6spi->spi : 0; 136 spi = x6spi ? x6spi->spi : 0;
137 read_unlock_bh(&xfrm6_tunnel_spi_lock); 137 read_unlock_bh(&xfrm6_tunnel_spi_lock);
138 return spi; 138 return htonl(spi);
139} 139}
140 140
141EXPORT_SYMBOL(xfrm6_tunnel_spi_lookup); 141EXPORT_SYMBOL(xfrm6_tunnel_spi_lookup);
@@ -210,7 +210,7 @@ u32 xfrm6_tunnel_alloc_spi(xfrm_address_t *saddr)
210 spi = __xfrm6_tunnel_alloc_spi(saddr); 210 spi = __xfrm6_tunnel_alloc_spi(saddr);
211 write_unlock_bh(&xfrm6_tunnel_spi_lock); 211 write_unlock_bh(&xfrm6_tunnel_spi_lock);
212 212
213 return spi; 213 return htonl(spi);
214} 214}
215 215
216EXPORT_SYMBOL(xfrm6_tunnel_alloc_spi); 216EXPORT_SYMBOL(xfrm6_tunnel_alloc_spi);
diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c
index bef3f61569f7..76c661566dfd 100644
--- a/net/ipx/af_ipx.c
+++ b/net/ipx/af_ipx.c
@@ -83,13 +83,13 @@ DEFINE_SPINLOCK(ipx_interfaces_lock);
83struct ipx_interface *ipx_primary_net; 83struct ipx_interface *ipx_primary_net;
84struct ipx_interface *ipx_internal_net; 84struct ipx_interface *ipx_internal_net;
85 85
86extern int ipxrtr_add_route(__u32 network, struct ipx_interface *intrfc, 86extern int ipxrtr_add_route(__be32 network, struct ipx_interface *intrfc,
87 unsigned char *node); 87 unsigned char *node);
88extern void ipxrtr_del_routes(struct ipx_interface *intrfc); 88extern void ipxrtr_del_routes(struct ipx_interface *intrfc);
89extern int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx, 89extern int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx,
90 struct iovec *iov, int len, int noblock); 90 struct iovec *iov, int len, int noblock);
91extern int ipxrtr_route_skb(struct sk_buff *skb); 91extern int ipxrtr_route_skb(struct sk_buff *skb);
92extern struct ipx_route *ipxrtr_lookup(__u32 net); 92extern struct ipx_route *ipxrtr_lookup(__be32 net);
93extern int ipxrtr_ioctl(unsigned int cmd, void __user *arg); 93extern int ipxrtr_ioctl(unsigned int cmd, void __user *arg);
94 94
95#undef IPX_REFCNT_DEBUG 95#undef IPX_REFCNT_DEBUG
@@ -177,7 +177,7 @@ static void ipxitf_clear_primary_net(void)
177} 177}
178 178
179static struct ipx_interface *__ipxitf_find_using_phys(struct net_device *dev, 179static struct ipx_interface *__ipxitf_find_using_phys(struct net_device *dev,
180 unsigned short datalink) 180 __be16 datalink)
181{ 181{
182 struct ipx_interface *i; 182 struct ipx_interface *i;
183 183
@@ -190,7 +190,7 @@ out:
190} 190}
191 191
192static struct ipx_interface *ipxitf_find_using_phys(struct net_device *dev, 192static struct ipx_interface *ipxitf_find_using_phys(struct net_device *dev,
193 unsigned short datalink) 193 __be16 datalink)
194{ 194{
195 struct ipx_interface *i; 195 struct ipx_interface *i;
196 196
@@ -202,7 +202,7 @@ static struct ipx_interface *ipxitf_find_using_phys(struct net_device *dev,
202 return i; 202 return i;
203} 203}
204 204
205struct ipx_interface *ipxitf_find_using_net(__u32 net) 205struct ipx_interface *ipxitf_find_using_net(__be32 net)
206{ 206{
207 struct ipx_interface *i; 207 struct ipx_interface *i;
208 208
@@ -237,7 +237,7 @@ static void ipxitf_insert_socket(struct ipx_interface *intrfc, struct sock *sk)
237 237
238/* caller must hold intrfc->if_sklist_lock */ 238/* caller must hold intrfc->if_sklist_lock */
239static struct sock *__ipxitf_find_socket(struct ipx_interface *intrfc, 239static struct sock *__ipxitf_find_socket(struct ipx_interface *intrfc,
240 unsigned short port) 240 __be16 port)
241{ 241{
242 struct sock *s; 242 struct sock *s;
243 struct hlist_node *node; 243 struct hlist_node *node;
@@ -252,7 +252,7 @@ found:
252 252
253/* caller must hold a reference to intrfc */ 253/* caller must hold a reference to intrfc */
254static struct sock *ipxitf_find_socket(struct ipx_interface *intrfc, 254static struct sock *ipxitf_find_socket(struct ipx_interface *intrfc,
255 unsigned short port) 255 __be16 port)
256{ 256{
257 struct sock *s; 257 struct sock *s;
258 258
@@ -268,7 +268,7 @@ static struct sock *ipxitf_find_socket(struct ipx_interface *intrfc,
268#ifdef CONFIG_IPX_INTERN 268#ifdef CONFIG_IPX_INTERN
269static struct sock *ipxitf_find_internal_socket(struct ipx_interface *intrfc, 269static struct sock *ipxitf_find_internal_socket(struct ipx_interface *intrfc,
270 unsigned char *ipx_node, 270 unsigned char *ipx_node,
271 unsigned short port) 271 __be16 port)
272{ 272{
273 struct sock *s; 273 struct sock *s;
274 struct hlist_node *node; 274 struct hlist_node *node;
@@ -600,10 +600,10 @@ int ipxitf_send(struct ipx_interface *intrfc, struct sk_buff *skb, char *node)
600 600
601 /* see if we need to include the netnum in the route list */ 601 /* see if we need to include the netnum in the route list */
602 if (IPX_SKB_CB(skb)->last_hop.index >= 0) { 602 if (IPX_SKB_CB(skb)->last_hop.index >= 0) {
603 u32 *last_hop = (u32 *)(((u8 *) skb->data) + 603 __be32 *last_hop = (__be32 *)(((u8 *) skb->data) +
604 sizeof(struct ipxhdr) + 604 sizeof(struct ipxhdr) +
605 IPX_SKB_CB(skb)->last_hop.index * 605 IPX_SKB_CB(skb)->last_hop.index *
606 sizeof(u32)); 606 sizeof(__be32));
607 *last_hop = IPX_SKB_CB(skb)->last_hop.netnum; 607 *last_hop = IPX_SKB_CB(skb)->last_hop.netnum;
608 IPX_SKB_CB(skb)->last_hop.index = -1; 608 IPX_SKB_CB(skb)->last_hop.index = -1;
609 } 609 }
@@ -772,7 +772,7 @@ static void ipxitf_discover_netnum(struct ipx_interface *intrfc,
772 } else { 772 } else {
773 printk(KERN_WARNING "IPX: Network number collision " 773 printk(KERN_WARNING "IPX: Network number collision "
774 "%lx\n %s %s and %s %s\n", 774 "%lx\n %s %s and %s %s\n",
775 (unsigned long) htonl(cb->ipx_source_net), 775 (unsigned long) ntohl(cb->ipx_source_net),
776 ipx_device_name(i), 776 ipx_device_name(i),
777 ipx_frame_name(i->if_dlink_type), 777 ipx_frame_name(i->if_dlink_type),
778 ipx_device_name(intrfc), 778 ipx_device_name(intrfc),
@@ -812,7 +812,7 @@ static int ipxitf_pprop(struct ipx_interface *intrfc, struct sk_buff *skb)
812 int i, rc = -EINVAL; 812 int i, rc = -EINVAL;
813 struct ipx_interface *ifcs; 813 struct ipx_interface *ifcs;
814 char *c; 814 char *c;
815 u32 *l; 815 __be32 *l;
816 816
817 /* Illegal packet - too many hops or too short */ 817 /* Illegal packet - too many hops or too short */
818 /* We decide to throw it away: no broadcasting, no local processing. 818 /* We decide to throw it away: no broadcasting, no local processing.
@@ -833,7 +833,7 @@ static int ipxitf_pprop(struct ipx_interface *intrfc, struct sk_buff *skb)
833 goto out; 833 goto out;
834 834
835 c = ((u8 *) ipx) + sizeof(struct ipxhdr); 835 c = ((u8 *) ipx) + sizeof(struct ipxhdr);
836 l = (u32 *) c; 836 l = (__be32 *) c;
837 837
838 /* Don't broadcast packet if already seen this net */ 838 /* Don't broadcast packet if already seen this net */
839 for (i = 0; i < IPX_SKB_CB(skb)->ipx_tctrl; i++) 839 for (i = 0; i < IPX_SKB_CB(skb)->ipx_tctrl; i++)
@@ -855,7 +855,7 @@ static int ipxitf_pprop(struct ipx_interface *intrfc, struct sk_buff *skb)
855 /* That aren't in the list */ 855 /* That aren't in the list */
856 if (ifcs == intrfc) 856 if (ifcs == intrfc)
857 continue; 857 continue;
858 l = (__u32 *) c; 858 l = (__be32 *) c;
859 /* don't consider the last entry in the packet list, 859 /* don't consider the last entry in the packet list,
860 * it is our netnum, and it is not there yet */ 860 * it is our netnum, and it is not there yet */
861 for (i = 0; i < IPX_SKB_CB(skb)->ipx_tctrl; i++) 861 for (i = 0; i < IPX_SKB_CB(skb)->ipx_tctrl; i++)
@@ -885,8 +885,8 @@ static void ipxitf_insert(struct ipx_interface *intrfc)
885 ipx_primary_net = intrfc; 885 ipx_primary_net = intrfc;
886} 886}
887 887
888static struct ipx_interface *ipxitf_alloc(struct net_device *dev, __u32 netnum, 888static struct ipx_interface *ipxitf_alloc(struct net_device *dev, __be32 netnum,
889 unsigned short dlink_type, 889 __be16 dlink_type,
890 struct datalink_proto *dlink, 890 struct datalink_proto *dlink,
891 unsigned char internal, 891 unsigned char internal,
892 int ipx_offset) 892 int ipx_offset)
@@ -960,7 +960,7 @@ static __be16 ipx_map_frame_type(unsigned char type)
960static int ipxitf_create(struct ipx_interface_definition *idef) 960static int ipxitf_create(struct ipx_interface_definition *idef)
961{ 961{
962 struct net_device *dev; 962 struct net_device *dev;
963 unsigned short dlink_type = 0; 963 __be16 dlink_type = 0;
964 struct datalink_proto *datalink = NULL; 964 struct datalink_proto *datalink = NULL;
965 struct ipx_interface *intrfc; 965 struct ipx_interface *intrfc;
966 int rc; 966 int rc;
@@ -1073,7 +1073,7 @@ out:
1073static int ipxitf_delete(struct ipx_interface_definition *idef) 1073static int ipxitf_delete(struct ipx_interface_definition *idef)
1074{ 1074{
1075 struct net_device *dev = NULL; 1075 struct net_device *dev = NULL;
1076 unsigned short dlink_type = 0; 1076 __be16 dlink_type = 0;
1077 struct ipx_interface *intrfc; 1077 struct ipx_interface *intrfc;
1078 int rc = 0; 1078 int rc = 0;
1079 1079
@@ -1110,7 +1110,7 @@ out:
1110} 1110}
1111 1111
1112static struct ipx_interface *ipxitf_auto_create(struct net_device *dev, 1112static struct ipx_interface *ipxitf_auto_create(struct net_device *dev,
1113 unsigned short dlink_type) 1113 __be16 dlink_type)
1114{ 1114{
1115 struct ipx_interface *intrfc = NULL; 1115 struct ipx_interface *intrfc = NULL;
1116 struct datalink_proto *datalink; 1116 struct datalink_proto *datalink;
@@ -1122,7 +1122,7 @@ static struct ipx_interface *ipxitf_auto_create(struct net_device *dev,
1122 if (dev->addr_len > IPX_NODE_LEN) 1122 if (dev->addr_len > IPX_NODE_LEN)
1123 goto out; 1123 goto out;
1124 1124
1125 switch (htons(dlink_type)) { 1125 switch (ntohs(dlink_type)) {
1126 case ETH_P_IPX: datalink = pEII_datalink; break; 1126 case ETH_P_IPX: datalink = pEII_datalink; break;
1127 case ETH_P_802_2: datalink = p8022_datalink; break; 1127 case ETH_P_802_2: datalink = p8022_datalink; break;
1128 case ETH_P_SNAP: datalink = pSNAP_datalink; break; 1128 case ETH_P_SNAP: datalink = pSNAP_datalink; break;
@@ -1234,27 +1234,27 @@ static int ipxitf_ioctl(unsigned int cmd, void __user *arg)
1234/* Note: We assume ipx_tctrl==0 and htons(length)==ipx_pktsize */ 1234/* Note: We assume ipx_tctrl==0 and htons(length)==ipx_pktsize */
1235/* This functions should *not* mess with packet contents */ 1235/* This functions should *not* mess with packet contents */
1236 1236
1237__u16 ipx_cksum(struct ipxhdr *packet, int length) 1237__be16 ipx_cksum(struct ipxhdr *packet, int length)
1238{ 1238{
1239 /* 1239 /*
1240 * NOTE: sum is a net byte order quantity, which optimizes the 1240 * NOTE: sum is a net byte order quantity, which optimizes the
1241 * loop. This only works on big and little endian machines. (I 1241 * loop. This only works on big and little endian machines. (I
1242 * don't know of a machine that isn't.) 1242 * don't know of a machine that isn't.)
1243 */ 1243 */
1244 /* start at ipx_dest - We skip the checksum field and start with 1244 /* handle the first 3 words separately; checksum should be skipped
1245 * ipx_type before the loop, not considering ipx_tctrl in the calc */ 1245 * and ipx_tctrl masked out */
1246 __u16 *p = (__u16 *)&packet->ipx_dest; 1246 __u16 *p = (__u16 *)packet;
1247 __u32 i = (length >> 1) - 1; /* Number of complete words */ 1247 __u32 sum = p[1] + (p[2] & (__force u16)htons(0x00ff));
1248 __u32 sum = packet->ipx_type << sizeof(packet->ipx_tctrl); 1248 __u32 i = (length >> 1) - 3; /* Number of remaining complete words */
1249 1249
1250 /* Loop through all complete words except the checksum field, 1250 /* Loop through them */
1251 * ipx_type (accounted above) and ipx_tctrl (not used in the cksum) */ 1251 p += 3;
1252 while (--i) 1252 while (i--)
1253 sum += *p++; 1253 sum += *p++;
1254 1254
1255 /* Add on the last part word if it exists */ 1255 /* Add on the last part word if it exists */
1256 if (packet->ipx_pktsize & htons(1)) 1256 if (packet->ipx_pktsize & htons(1))
1257 sum += ntohs(0xff00) & *p; 1257 sum += (__force u16)htons(0xff00) & *p;
1258 1258
1259 /* Do final fixup */ 1259 /* Do final fixup */
1260 sum = (sum & 0xffff) + (sum >> 16); 1260 sum = (sum & 0xffff) + (sum >> 16);
@@ -1263,10 +1263,17 @@ __u16 ipx_cksum(struct ipxhdr *packet, int length)
1263 if (sum >= 0x10000) 1263 if (sum >= 0x10000)
1264 sum++; 1264 sum++;
1265 1265
1266 return ~sum; 1266 /*
1267 * Leave 0 alone; we don't want 0xffff here. Note that we can't get
1268 * here with 0x10000, so this check is the same as ((__u16)sum)
1269 */
1270 if (sum)
1271 sum = ~sum;
1272
1273 return (__force __be16)sum;
1267} 1274}
1268 1275
1269const char *ipx_frame_name(unsigned short frame) 1276const char *ipx_frame_name(__be16 frame)
1270{ 1277{
1271 char* rc = "None"; 1278 char* rc = "None";
1272 1279
@@ -1401,7 +1408,7 @@ out:
1401 1408
1402/* caller must hold a reference to intrfc */ 1409/* caller must hold a reference to intrfc */
1403 1410
1404static unsigned short ipx_first_free_socketnum(struct ipx_interface *intrfc) 1411static __be16 ipx_first_free_socketnum(struct ipx_interface *intrfc)
1405{ 1412{
1406 unsigned short socketNum = intrfc->if_sknum; 1413 unsigned short socketNum = intrfc->if_sknum;
1407 1414
@@ -1410,7 +1417,7 @@ static unsigned short ipx_first_free_socketnum(struct ipx_interface *intrfc)
1410 if (socketNum < IPX_MIN_EPHEMERAL_SOCKET) 1417 if (socketNum < IPX_MIN_EPHEMERAL_SOCKET)
1411 socketNum = IPX_MIN_EPHEMERAL_SOCKET; 1418 socketNum = IPX_MIN_EPHEMERAL_SOCKET;
1412 1419
1413 while (__ipxitf_find_socket(intrfc, ntohs(socketNum))) 1420 while (__ipxitf_find_socket(intrfc, htons(socketNum)))
1414 if (socketNum > IPX_MAX_EPHEMERAL_SOCKET) 1421 if (socketNum > IPX_MAX_EPHEMERAL_SOCKET)
1415 socketNum = IPX_MIN_EPHEMERAL_SOCKET; 1422 socketNum = IPX_MIN_EPHEMERAL_SOCKET;
1416 else 1423 else
@@ -1419,7 +1426,7 @@ static unsigned short ipx_first_free_socketnum(struct ipx_interface *intrfc)
1419 spin_unlock_bh(&intrfc->if_sklist_lock); 1426 spin_unlock_bh(&intrfc->if_sklist_lock);
1420 intrfc->if_sknum = socketNum; 1427 intrfc->if_sknum = socketNum;
1421 1428
1422 return ntohs(socketNum); 1429 return htons(socketNum);
1423} 1430}
1424 1431
1425static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) 1432static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
@@ -1473,7 +1480,7 @@ static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
1473 ipxs->port)) { 1480 ipxs->port)) {
1474 SOCK_DEBUG(sk, 1481 SOCK_DEBUG(sk,
1475 "IPX: bind failed because port %X in use.\n", 1482 "IPX: bind failed because port %X in use.\n",
1476 ntohs((int)addr->sipx_port)); 1483 ntohs(addr->sipx_port));
1477 goto out_put; 1484 goto out_put;
1478 } 1485 }
1479 } else { 1486 } else {
@@ -1488,7 +1495,7 @@ static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
1488 if (ipxitf_find_socket(intrfc, addr->sipx_port)) { 1495 if (ipxitf_find_socket(intrfc, addr->sipx_port)) {
1489 SOCK_DEBUG(sk, 1496 SOCK_DEBUG(sk,
1490 "IPX: bind failed because port %X in use.\n", 1497 "IPX: bind failed because port %X in use.\n",
1491 ntohs((int)addr->sipx_port)); 1498 ntohs(addr->sipx_port));
1492 goto out_put; 1499 goto out_put;
1493 } 1500 }
1494 } 1501 }
@@ -1665,7 +1672,7 @@ static int ipx_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_ty
1665 intrfc = ipxitf_find_using_phys(dev, pt->type); 1672 intrfc = ipxitf_find_using_phys(dev, pt->type);
1666 if (!intrfc) { 1673 if (!intrfc) {
1667 if (ipxcfg_auto_create_interfaces && 1674 if (ipxcfg_auto_create_interfaces &&
1668 ntohl(IPX_SKB_CB(skb)->ipx_dest_net)) { 1675 IPX_SKB_CB(skb)->ipx_dest_net) {
1669 intrfc = ipxitf_auto_create(dev, pt->type); 1676 intrfc = ipxitf_auto_create(dev, pt->type);
1670 if (intrfc) 1677 if (intrfc)
1671 ipxitf_hold(intrfc); 1678 ipxitf_hold(intrfc);
diff --git a/net/ipx/ipx_proc.c b/net/ipx/ipx_proc.c
index 4c0c71206e54..b7463dfca63e 100644
--- a/net/ipx/ipx_proc.c
+++ b/net/ipx/ipx_proc.c
@@ -260,22 +260,22 @@ static int ipx_seq_socket_show(struct seq_file *seq, void *v)
260 ipxs = ipx_sk(s); 260 ipxs = ipx_sk(s);
261#ifdef CONFIG_IPX_INTERN 261#ifdef CONFIG_IPX_INTERN
262 seq_printf(seq, "%08lX:%02X%02X%02X%02X%02X%02X:%04X ", 262 seq_printf(seq, "%08lX:%02X%02X%02X%02X%02X%02X:%04X ",
263 (unsigned long)htonl(ipxs->intrfc->if_netnum), 263 (unsigned long)ntohl(ipxs->intrfc->if_netnum),
264 ipxs->node[0], ipxs->node[1], ipxs->node[2], ipxs->node[3], 264 ipxs->node[0], ipxs->node[1], ipxs->node[2], ipxs->node[3],
265 ipxs->node[4], ipxs->node[5], htons(ipxs->port)); 265 ipxs->node[4], ipxs->node[5], ntohs(ipxs->port));
266#else 266#else
267 seq_printf(seq, "%08lX:%04X ", (unsigned long) htonl(ipxs->intrfc->if_netnum), 267 seq_printf(seq, "%08lX:%04X ", (unsigned long) ntohl(ipxs->intrfc->if_netnum),
268 htons(ipxs->port)); 268 ntohs(ipxs->port));
269#endif /* CONFIG_IPX_INTERN */ 269#endif /* CONFIG_IPX_INTERN */
270 if (s->sk_state != TCP_ESTABLISHED) 270 if (s->sk_state != TCP_ESTABLISHED)
271 seq_printf(seq, "%-28s", "Not_Connected"); 271 seq_printf(seq, "%-28s", "Not_Connected");
272 else { 272 else {
273 seq_printf(seq, "%08lX:%02X%02X%02X%02X%02X%02X:%04X ", 273 seq_printf(seq, "%08lX:%02X%02X%02X%02X%02X%02X:%04X ",
274 (unsigned long)htonl(ipxs->dest_addr.net), 274 (unsigned long)ntohl(ipxs->dest_addr.net),
275 ipxs->dest_addr.node[0], ipxs->dest_addr.node[1], 275 ipxs->dest_addr.node[0], ipxs->dest_addr.node[1],
276 ipxs->dest_addr.node[2], ipxs->dest_addr.node[3], 276 ipxs->dest_addr.node[2], ipxs->dest_addr.node[3],
277 ipxs->dest_addr.node[4], ipxs->dest_addr.node[5], 277 ipxs->dest_addr.node[4], ipxs->dest_addr.node[5],
278 htons(ipxs->dest_addr.sock)); 278 ntohs(ipxs->dest_addr.sock));
279 } 279 }
280 280
281 seq_printf(seq, "%08X %08X %02X %03d\n", 281 seq_printf(seq, "%08X %08X %02X %03d\n",
diff --git a/net/ipx/ipx_route.c b/net/ipx/ipx_route.c
index a30dbb1e08fb..68560ee0d797 100644
--- a/net/ipx/ipx_route.c
+++ b/net/ipx/ipx_route.c
@@ -19,17 +19,17 @@ DEFINE_RWLOCK(ipx_routes_lock);
19 19
20extern struct ipx_interface *ipx_internal_net; 20extern struct ipx_interface *ipx_internal_net;
21 21
22extern __u16 ipx_cksum(struct ipxhdr *packet, int length); 22extern __be16 ipx_cksum(struct ipxhdr *packet, int length);
23extern struct ipx_interface *ipxitf_find_using_net(__u32 net); 23extern struct ipx_interface *ipxitf_find_using_net(__be32 net);
24extern int ipxitf_demux_socket(struct ipx_interface *intrfc, 24extern int ipxitf_demux_socket(struct ipx_interface *intrfc,
25 struct sk_buff *skb, int copy); 25 struct sk_buff *skb, int copy);
26extern int ipxitf_demux_socket(struct ipx_interface *intrfc, 26extern int ipxitf_demux_socket(struct ipx_interface *intrfc,
27 struct sk_buff *skb, int copy); 27 struct sk_buff *skb, int copy);
28extern int ipxitf_send(struct ipx_interface *intrfc, struct sk_buff *skb, 28extern int ipxitf_send(struct ipx_interface *intrfc, struct sk_buff *skb,
29 char *node); 29 char *node);
30extern struct ipx_interface *ipxitf_find_using_net(__u32 net); 30extern struct ipx_interface *ipxitf_find_using_net(__be32 net);
31 31
32struct ipx_route *ipxrtr_lookup(__u32 net) 32struct ipx_route *ipxrtr_lookup(__be32 net)
33{ 33{
34 struct ipx_route *r; 34 struct ipx_route *r;
35 35
@@ -48,7 +48,7 @@ unlock:
48/* 48/*
49 * Caller must hold a reference to intrfc 49 * Caller must hold a reference to intrfc
50 */ 50 */
51int ipxrtr_add_route(__u32 network, struct ipx_interface *intrfc, 51int ipxrtr_add_route(__be32 network, struct ipx_interface *intrfc,
52 unsigned char *node) 52 unsigned char *node)
53{ 53{
54 struct ipx_route *rt; 54 struct ipx_route *rt;
@@ -118,7 +118,7 @@ out:
118 return rc; 118 return rc;
119} 119}
120 120
121static int ipxrtr_delete(__u32 net) 121static int ipxrtr_delete(__be32 net)
122{ 122{
123 struct ipx_route *r, *tmp; 123 struct ipx_route *r, *tmp;
124 int rc; 124 int rc;
@@ -238,7 +238,7 @@ int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx,
238 238
239 /* Apply checksum. Not allowed on 802.3 links. */ 239 /* Apply checksum. Not allowed on 802.3 links. */
240 if (sk->sk_no_check || intrfc->if_dlink_type == htons(IPX_FRAME_8023)) 240 if (sk->sk_no_check || intrfc->if_dlink_type == htons(IPX_FRAME_8023))
241 ipx->ipx_checksum = 0xFFFF; 241 ipx->ipx_checksum = htons(0xFFFF);
242 else 242 else
243 ipx->ipx_checksum = ipx_cksum(ipx, len + sizeof(struct ipxhdr)); 243 ipx->ipx_checksum = ipx_cksum(ipx, len + sizeof(struct ipxhdr));
244 244
diff --git a/net/irda/irlmp.c b/net/irda/irlmp.c
index 5073261b9d0c..fede83763095 100644
--- a/net/irda/irlmp.c
+++ b/net/irda/irlmp.c
@@ -1678,7 +1678,8 @@ static int irlmp_slsap_inuse(__u8 slsap_sel)
1678 * every IrLAP connection and check every LSAP associated with each 1678 * every IrLAP connection and check every LSAP associated with each
1679 * the connection. 1679 * the connection.
1680 */ 1680 */
1681 spin_lock_irqsave(&irlmp->links->hb_spinlock, flags); 1681 spin_lock_irqsave_nested(&irlmp->links->hb_spinlock, flags,
1682 SINGLE_DEPTH_NESTING);
1682 lap = (struct lap_cb *) hashbin_get_first(irlmp->links); 1683 lap = (struct lap_cb *) hashbin_get_first(irlmp->links);
1683 while (lap != NULL) { 1684 while (lap != NULL) {
1684 IRDA_ASSERT(lap->magic == LMP_LAP_MAGIC, goto errlap;); 1685 IRDA_ASSERT(lap->magic == LMP_LAP_MAGIC, goto errlap;);
diff --git a/net/key/af_key.c b/net/key/af_key.c
index ff98e70b0931..20ff7cca1d07 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -2928,11 +2928,6 @@ static struct xfrm_policy *pfkey_compile_policy(struct sock *sk, int opt,
2928 if (*dir) 2928 if (*dir)
2929 goto out; 2929 goto out;
2930 } 2930 }
2931 else {
2932 *dir = security_xfrm_sock_policy_alloc(xp, sk);
2933 if (*dir)
2934 goto out;
2935 }
2936 2931
2937 *dir = pol->sadb_x_policy_dir-1; 2932 *dir = pol->sadb_x_policy_dir-1;
2938 return xp; 2933 return xp;
diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
index ce94732b8e23..f619c6527266 100644
--- a/net/netfilter/Kconfig
+++ b/net/netfilter/Kconfig
@@ -209,7 +209,9 @@ config NETFILTER_XT_TARGET_SECMARK
209 209
210config NETFILTER_XT_TARGET_CONNSECMARK 210config NETFILTER_XT_TARGET_CONNSECMARK
211 tristate '"CONNSECMARK" target support' 211 tristate '"CONNSECMARK" target support'
212 depends on NETFILTER_XTABLES && (NF_CONNTRACK_SECMARK || IP_NF_CONNTRACK_SECMARK) 212 depends on NETFILTER_XTABLES && \
213 ((NF_CONNTRACK && NF_CONNTRACK_SECMARK) || \
214 (IP_NF_CONNTRACK && IP_NF_CONNTRACK_SECMARK))
213 help 215 help
214 The CONNSECMARK target copies security markings from packets 216 The CONNSECMARK target copies security markings from packets
215 to connections, and restores security markings from connections 217 to connections, and restores security markings from connections
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 093b3ddc513c..836541e509fe 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -1520,9 +1520,10 @@ get_next_corpse(int (*iter)(struct nf_conn *i, void *data),
1520 if (iter(ct, data)) 1520 if (iter(ct, data))
1521 goto found; 1521 goto found;
1522 } 1522 }
1523 write_unlock_bh(&nf_conntrack_lock);
1523 return NULL; 1524 return NULL;
1524found: 1525found:
1525 atomic_inc(&nf_ct_tuplehash_to_ctrack(h)->ct_general.use); 1526 atomic_inc(&ct->ct_general.use);
1526 write_unlock_bh(&nf_conntrack_lock); 1527 write_unlock_bh(&nf_conntrack_lock);
1527 return ct; 1528 return ct;
1528} 1529}
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 1721f7c78c77..bd0156a28ecd 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -47,13 +47,6 @@ MODULE_LICENSE("GPL");
47 47
48static char __initdata version[] = "0.93"; 48static char __initdata version[] = "0.93";
49 49
50#if 0
51#define DEBUGP printk
52#else
53#define DEBUGP(format, args...)
54#endif
55
56
57static inline int 50static inline int
58ctnetlink_dump_tuples_proto(struct sk_buff *skb, 51ctnetlink_dump_tuples_proto(struct sk_buff *skb,
59 const struct nf_conntrack_tuple *tuple, 52 const struct nf_conntrack_tuple *tuple,
@@ -410,7 +403,6 @@ static int ctnetlink_done(struct netlink_callback *cb)
410{ 403{
411 if (cb->args[1]) 404 if (cb->args[1])
412 nf_ct_put((struct nf_conn *)cb->args[1]); 405 nf_ct_put((struct nf_conn *)cb->args[1]);
413 DEBUGP("entered %s\n", __FUNCTION__);
414 return 0; 406 return 0;
415} 407}
416 408
@@ -425,9 +417,6 @@ ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
425 struct nfgenmsg *nfmsg = NLMSG_DATA(cb->nlh); 417 struct nfgenmsg *nfmsg = NLMSG_DATA(cb->nlh);
426 u_int8_t l3proto = nfmsg->nfgen_family; 418 u_int8_t l3proto = nfmsg->nfgen_family;
427 419
428 DEBUGP("entered %s, last bucket=%lu id=%u\n", __FUNCTION__,
429 cb->args[0], *id);
430
431 read_lock_bh(&nf_conntrack_lock); 420 read_lock_bh(&nf_conntrack_lock);
432 last = (struct nf_conn *)cb->args[1]; 421 last = (struct nf_conn *)cb->args[1];
433 for (; cb->args[0] < nf_conntrack_htable_size; cb->args[0]++) { 422 for (; cb->args[0] < nf_conntrack_htable_size; cb->args[0]++) {
@@ -471,7 +460,6 @@ out:
471 if (last) 460 if (last)
472 nf_ct_put(last); 461 nf_ct_put(last);
473 462
474 DEBUGP("leaving, last bucket=%lu id=%u\n", cb->args[0], *id);
475 return skb->len; 463 return skb->len;
476} 464}
477 465
@@ -482,8 +470,6 @@ ctnetlink_parse_tuple_ip(struct nfattr *attr, struct nf_conntrack_tuple *tuple)
482 struct nf_conntrack_l3proto *l3proto; 470 struct nf_conntrack_l3proto *l3proto;
483 int ret = 0; 471 int ret = 0;
484 472
485 DEBUGP("entered %s\n", __FUNCTION__);
486
487 nfattr_parse_nested(tb, CTA_IP_MAX, attr); 473 nfattr_parse_nested(tb, CTA_IP_MAX, attr);
488 474
489 l3proto = nf_ct_l3proto_find_get(tuple->src.l3num); 475 l3proto = nf_ct_l3proto_find_get(tuple->src.l3num);
@@ -493,8 +479,6 @@ ctnetlink_parse_tuple_ip(struct nfattr *attr, struct nf_conntrack_tuple *tuple)
493 479
494 nf_ct_l3proto_put(l3proto); 480 nf_ct_l3proto_put(l3proto);
495 481
496 DEBUGP("leaving\n");
497
498 return ret; 482 return ret;
499} 483}
500 484
@@ -510,8 +494,6 @@ ctnetlink_parse_tuple_proto(struct nfattr *attr,
510 struct nf_conntrack_protocol *proto; 494 struct nf_conntrack_protocol *proto;
511 int ret = 0; 495 int ret = 0;
512 496
513 DEBUGP("entered %s\n", __FUNCTION__);
514
515 nfattr_parse_nested(tb, CTA_PROTO_MAX, attr); 497 nfattr_parse_nested(tb, CTA_PROTO_MAX, attr);
516 498
517 if (nfattr_bad_size(tb, CTA_PROTO_MAX, cta_min_proto)) 499 if (nfattr_bad_size(tb, CTA_PROTO_MAX, cta_min_proto))
@@ -538,8 +520,6 @@ ctnetlink_parse_tuple(struct nfattr *cda[], struct nf_conntrack_tuple *tuple,
538 struct nfattr *tb[CTA_TUPLE_MAX]; 520 struct nfattr *tb[CTA_TUPLE_MAX];
539 int err; 521 int err;
540 522
541 DEBUGP("entered %s\n", __FUNCTION__);
542
543 memset(tuple, 0, sizeof(*tuple)); 523 memset(tuple, 0, sizeof(*tuple));
544 524
545 nfattr_parse_nested(tb, CTA_TUPLE_MAX, cda[type-1]); 525 nfattr_parse_nested(tb, CTA_TUPLE_MAX, cda[type-1]);
@@ -566,10 +546,6 @@ ctnetlink_parse_tuple(struct nfattr *cda[], struct nf_conntrack_tuple *tuple,
566 else 546 else
567 tuple->dst.dir = IP_CT_DIR_ORIGINAL; 547 tuple->dst.dir = IP_CT_DIR_ORIGINAL;
568 548
569 NF_CT_DUMP_TUPLE(tuple);
570
571 DEBUGP("leaving\n");
572
573 return 0; 549 return 0;
574} 550}
575 551
@@ -586,8 +562,6 @@ static int ctnetlink_parse_nat_proto(struct nfattr *attr,
586 struct nfattr *tb[CTA_PROTONAT_MAX]; 562 struct nfattr *tb[CTA_PROTONAT_MAX];
587 struct ip_nat_protocol *npt; 563 struct ip_nat_protocol *npt;
588 564
589 DEBUGP("entered %s\n", __FUNCTION__);
590
591 nfattr_parse_nested(tb, CTA_PROTONAT_MAX, attr); 565 nfattr_parse_nested(tb, CTA_PROTONAT_MAX, attr);
592 566
593 if (nfattr_bad_size(tb, CTA_PROTONAT_MAX, cta_min_protonat)) 567 if (nfattr_bad_size(tb, CTA_PROTONAT_MAX, cta_min_protonat))
@@ -606,7 +580,6 @@ static int ctnetlink_parse_nat_proto(struct nfattr *attr,
606 580
607 ip_nat_proto_put(npt); 581 ip_nat_proto_put(npt);
608 582
609 DEBUGP("leaving\n");
610 return 0; 583 return 0;
611} 584}
612 585
@@ -622,8 +595,6 @@ ctnetlink_parse_nat(struct nfattr *nat,
622 struct nfattr *tb[CTA_NAT_MAX]; 595 struct nfattr *tb[CTA_NAT_MAX];
623 int err; 596 int err;
624 597
625 DEBUGP("entered %s\n", __FUNCTION__);
626
627 memset(range, 0, sizeof(*range)); 598 memset(range, 0, sizeof(*range));
628 599
629 nfattr_parse_nested(tb, CTA_NAT_MAX, nat); 600 nfattr_parse_nested(tb, CTA_NAT_MAX, nat);
@@ -649,7 +620,6 @@ ctnetlink_parse_nat(struct nfattr *nat,
649 if (err < 0) 620 if (err < 0)
650 return err; 621 return err;
651 622
652 DEBUGP("leaving\n");
653 return 0; 623 return 0;
654} 624}
655#endif 625#endif
@@ -659,8 +629,6 @@ ctnetlink_parse_help(struct nfattr *attr, char **helper_name)
659{ 629{
660 struct nfattr *tb[CTA_HELP_MAX]; 630 struct nfattr *tb[CTA_HELP_MAX];
661 631
662 DEBUGP("entered %s\n", __FUNCTION__);
663
664 nfattr_parse_nested(tb, CTA_HELP_MAX, attr); 632 nfattr_parse_nested(tb, CTA_HELP_MAX, attr);
665 633
666 if (!tb[CTA_HELP_NAME-1]) 634 if (!tb[CTA_HELP_NAME-1])
@@ -690,8 +658,6 @@ ctnetlink_del_conntrack(struct sock *ctnl, struct sk_buff *skb,
690 u_int8_t u3 = nfmsg->nfgen_family; 658 u_int8_t u3 = nfmsg->nfgen_family;
691 int err = 0; 659 int err = 0;
692 660
693 DEBUGP("entered %s\n", __FUNCTION__);
694
695 if (nfattr_bad_size(cda, CTA_MAX, cta_min)) 661 if (nfattr_bad_size(cda, CTA_MAX, cta_min))
696 return -EINVAL; 662 return -EINVAL;
697 663
@@ -709,10 +675,8 @@ ctnetlink_del_conntrack(struct sock *ctnl, struct sk_buff *skb,
709 return err; 675 return err;
710 676
711 h = nf_conntrack_find_get(&tuple, NULL); 677 h = nf_conntrack_find_get(&tuple, NULL);
712 if (!h) { 678 if (!h)
713 DEBUGP("tuple not found in conntrack hash\n");
714 return -ENOENT; 679 return -ENOENT;
715 }
716 680
717 ct = nf_ct_tuplehash_to_ctrack(h); 681 ct = nf_ct_tuplehash_to_ctrack(h);
718 682
@@ -727,7 +691,6 @@ ctnetlink_del_conntrack(struct sock *ctnl, struct sk_buff *skb,
727 ct->timeout.function((unsigned long)ct); 691 ct->timeout.function((unsigned long)ct);
728 692
729 nf_ct_put(ct); 693 nf_ct_put(ct);
730 DEBUGP("leaving\n");
731 694
732 return 0; 695 return 0;
733} 696}
@@ -744,8 +707,6 @@ ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb,
744 u_int8_t u3 = nfmsg->nfgen_family; 707 u_int8_t u3 = nfmsg->nfgen_family;
745 int err = 0; 708 int err = 0;
746 709
747 DEBUGP("entered %s\n", __FUNCTION__);
748
749 if (nlh->nlmsg_flags & NLM_F_DUMP) { 710 if (nlh->nlmsg_flags & NLM_F_DUMP) {
750 u32 rlen; 711 u32 rlen;
751 712
@@ -779,11 +740,9 @@ ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb,
779 return err; 740 return err;
780 741
781 h = nf_conntrack_find_get(&tuple, NULL); 742 h = nf_conntrack_find_get(&tuple, NULL);
782 if (!h) { 743 if (!h)
783 DEBUGP("tuple not found in conntrack hash");
784 return -ENOENT; 744 return -ENOENT;
785 } 745
786 DEBUGP("tuple found\n");
787 ct = nf_ct_tuplehash_to_ctrack(h); 746 ct = nf_ct_tuplehash_to_ctrack(h);
788 747
789 err = -ENOMEM; 748 err = -ENOMEM;
@@ -804,7 +763,6 @@ ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb,
804 if (err < 0) 763 if (err < 0)
805 goto out; 764 goto out;
806 765
807 DEBUGP("leaving\n");
808 return 0; 766 return 0;
809 767
810free: 768free:
@@ -876,8 +834,6 @@ ctnetlink_change_helper(struct nf_conn *ct, struct nfattr *cda[])
876 char *helpname; 834 char *helpname;
877 int err; 835 int err;
878 836
879 DEBUGP("entered %s\n", __FUNCTION__);
880
881 if (!help) { 837 if (!help) {
882 /* FIXME: we need to reallocate and rehash */ 838 /* FIXME: we need to reallocate and rehash */
883 return -EBUSY; 839 return -EBUSY;
@@ -954,8 +910,6 @@ ctnetlink_change_conntrack(struct nf_conn *ct, struct nfattr *cda[])
954{ 910{
955 int err; 911 int err;
956 912
957 DEBUGP("entered %s\n", __FUNCTION__);
958
959 if (cda[CTA_HELP-1]) { 913 if (cda[CTA_HELP-1]) {
960 err = ctnetlink_change_helper(ct, cda); 914 err = ctnetlink_change_helper(ct, cda);
961 if (err < 0) 915 if (err < 0)
@@ -985,7 +939,6 @@ ctnetlink_change_conntrack(struct nf_conn *ct, struct nfattr *cda[])
985 ct->mark = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_MARK-1])); 939 ct->mark = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_MARK-1]));
986#endif 940#endif
987 941
988 DEBUGP("all done\n");
989 return 0; 942 return 0;
990} 943}
991 944
@@ -997,8 +950,6 @@ ctnetlink_create_conntrack(struct nfattr *cda[],
997 struct nf_conn *ct; 950 struct nf_conn *ct;
998 int err = -EINVAL; 951 int err = -EINVAL;
999 952
1000 DEBUGP("entered %s\n", __FUNCTION__);
1001
1002 ct = nf_conntrack_alloc(otuple, rtuple); 953 ct = nf_conntrack_alloc(otuple, rtuple);
1003 if (ct == NULL || IS_ERR(ct)) 954 if (ct == NULL || IS_ERR(ct))
1004 return -ENOMEM; 955 return -ENOMEM;
@@ -1028,7 +979,6 @@ ctnetlink_create_conntrack(struct nfattr *cda[],
1028 add_timer(&ct->timeout); 979 add_timer(&ct->timeout);
1029 nf_conntrack_hash_insert(ct); 980 nf_conntrack_hash_insert(ct);
1030 981
1031 DEBUGP("conntrack with id %u inserted\n", ct->id);
1032 return 0; 982 return 0;
1033 983
1034err: 984err:
@@ -1046,8 +996,6 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
1046 u_int8_t u3 = nfmsg->nfgen_family; 996 u_int8_t u3 = nfmsg->nfgen_family;
1047 int err = 0; 997 int err = 0;
1048 998
1049 DEBUGP("entered %s\n", __FUNCTION__);
1050
1051 if (nfattr_bad_size(cda, CTA_MAX, cta_min)) 999 if (nfattr_bad_size(cda, CTA_MAX, cta_min))
1052 return -EINVAL; 1000 return -EINVAL;
1053 1001
@@ -1071,7 +1019,6 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
1071 1019
1072 if (h == NULL) { 1020 if (h == NULL) {
1073 write_unlock_bh(&nf_conntrack_lock); 1021 write_unlock_bh(&nf_conntrack_lock);
1074 DEBUGP("no such conntrack, create new\n");
1075 err = -ENOENT; 1022 err = -ENOENT;
1076 if (nlh->nlmsg_flags & NLM_F_CREATE) 1023 if (nlh->nlmsg_flags & NLM_F_CREATE)
1077 err = ctnetlink_create_conntrack(cda, &otuple, &rtuple); 1024 err = ctnetlink_create_conntrack(cda, &otuple, &rtuple);
@@ -1087,7 +1034,6 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
1087 1034
1088 /* We manipulate the conntrack inside the global conntrack table lock, 1035 /* We manipulate the conntrack inside the global conntrack table lock,
1089 * so there's no need to increase the refcount */ 1036 * so there's no need to increase the refcount */
1090 DEBUGP("conntrack found\n");
1091 err = -EEXIST; 1037 err = -EEXIST;
1092 if (!(nlh->nlmsg_flags & NLM_F_EXCL)) 1038 if (!(nlh->nlmsg_flags & NLM_F_EXCL))
1093 err = ctnetlink_change_conntrack(nf_ct_tuplehash_to_ctrack(h), cda); 1039 err = ctnetlink_change_conntrack(nf_ct_tuplehash_to_ctrack(h), cda);
@@ -1268,8 +1214,6 @@ ctnetlink_exp_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
1268 struct nfgenmsg *nfmsg = NLMSG_DATA(cb->nlh); 1214 struct nfgenmsg *nfmsg = NLMSG_DATA(cb->nlh);
1269 u_int8_t l3proto = nfmsg->nfgen_family; 1215 u_int8_t l3proto = nfmsg->nfgen_family;
1270 1216
1271 DEBUGP("entered %s, last id=%llu\n", __FUNCTION__, *id);
1272
1273 read_lock_bh(&nf_conntrack_lock); 1217 read_lock_bh(&nf_conntrack_lock);
1274 list_for_each_prev(i, &nf_conntrack_expect_list) { 1218 list_for_each_prev(i, &nf_conntrack_expect_list) {
1275 exp = (struct nf_conntrack_expect *) i; 1219 exp = (struct nf_conntrack_expect *) i;
@@ -1287,8 +1231,6 @@ ctnetlink_exp_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
1287out: 1231out:
1288 read_unlock_bh(&nf_conntrack_lock); 1232 read_unlock_bh(&nf_conntrack_lock);
1289 1233
1290 DEBUGP("leaving, last id=%llu\n", *id);
1291
1292 return skb->len; 1234 return skb->len;
1293} 1235}
1294 1236
@@ -1308,8 +1250,6 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,
1308 u_int8_t u3 = nfmsg->nfgen_family; 1250 u_int8_t u3 = nfmsg->nfgen_family;
1309 int err = 0; 1251 int err = 0;
1310 1252
1311 DEBUGP("entered %s\n", __FUNCTION__);
1312
1313 if (nfattr_bad_size(cda, CTA_EXPECT_MAX, cta_min_exp)) 1253 if (nfattr_bad_size(cda, CTA_EXPECT_MAX, cta_min_exp))
1314 return -EINVAL; 1254 return -EINVAL;
1315 1255
@@ -1460,8 +1400,6 @@ ctnetlink_create_expect(struct nfattr *cda[], u_int8_t u3)
1460 struct nf_conn_help *help; 1400 struct nf_conn_help *help;
1461 int err = 0; 1401 int err = 0;
1462 1402
1463 DEBUGP("entered %s\n", __FUNCTION__);
1464
1465 /* caller guarantees that those three CTA_EXPECT_* exist */ 1403 /* caller guarantees that those three CTA_EXPECT_* exist */
1466 err = ctnetlink_parse_tuple(cda, &tuple, CTA_EXPECT_TUPLE, u3); 1404 err = ctnetlink_parse_tuple(cda, &tuple, CTA_EXPECT_TUPLE, u3);
1467 if (err < 0) 1405 if (err < 0)
@@ -1516,8 +1454,6 @@ ctnetlink_new_expect(struct sock *ctnl, struct sk_buff *skb,
1516 u_int8_t u3 = nfmsg->nfgen_family; 1454 u_int8_t u3 = nfmsg->nfgen_family;
1517 int err = 0; 1455 int err = 0;
1518 1456
1519 DEBUGP("entered %s\n", __FUNCTION__);
1520
1521 if (nfattr_bad_size(cda, CTA_EXPECT_MAX, cta_min_exp)) 1457 if (nfattr_bad_size(cda, CTA_EXPECT_MAX, cta_min_exp))
1522 return -EINVAL; 1458 return -EINVAL;
1523 1459
@@ -1546,8 +1482,6 @@ ctnetlink_new_expect(struct sock *ctnl, struct sk_buff *skb,
1546 err = ctnetlink_change_expect(exp, cda); 1482 err = ctnetlink_change_expect(exp, cda);
1547 write_unlock_bh(&nf_conntrack_lock); 1483 write_unlock_bh(&nf_conntrack_lock);
1548 1484
1549 DEBUGP("leaving\n");
1550
1551 return err; 1485 return err;
1552} 1486}
1553 1487
diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index b59d3b2bde21..1e5207b80fe5 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -427,7 +427,7 @@ __build_packet_message(struct nfulnl_instance *inst,
427 nfmsg->version = NFNETLINK_V0; 427 nfmsg->version = NFNETLINK_V0;
428 nfmsg->res_id = htons(inst->group_num); 428 nfmsg->res_id = htons(inst->group_num);
429 429
430 pmsg.hw_protocol = htons(skb->protocol); 430 pmsg.hw_protocol = skb->protocol;
431 pmsg.hook = hooknum; 431 pmsg.hook = hooknum;
432 432
433 NFA_PUT(inst->skb, NFULA_PACKET_HDR, sizeof(pmsg), &pmsg); 433 NFA_PUT(inst->skb, NFULA_PACKET_HDR, sizeof(pmsg), &pmsg);
@@ -544,7 +544,7 @@ __build_packet_message(struct nfulnl_instance *inst,
544 } 544 }
545 /* global sequence number */ 545 /* global sequence number */
546 if (inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) { 546 if (inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) {
547 tmp_uint = atomic_inc_return(&global_seq); 547 tmp_uint = htonl(atomic_inc_return(&global_seq));
548 NFA_PUT(inst->skb, NFULA_SEQ_GLOBAL, sizeof(tmp_uint), &tmp_uint); 548 NFA_PUT(inst->skb, NFULA_SEQ_GLOBAL, sizeof(tmp_uint), &tmp_uint);
549 } 549 }
550 550
@@ -878,7 +878,7 @@ nfulnl_recv_config(struct sock *ctnl, struct sk_buff *skb,
878 params = NFA_DATA(nfula[NFULA_CFG_MODE-1]); 878 params = NFA_DATA(nfula[NFULA_CFG_MODE-1]);
879 879
880 nfulnl_set_mode(inst, params->copy_mode, 880 nfulnl_set_mode(inst, params->copy_mode,
881 ntohs(params->copy_range)); 881 ntohl(params->copy_range));
882 } 882 }
883 883
884 if (nfula[NFULA_CFG_TIMEOUT-1]) { 884 if (nfula[NFULA_CFG_TIMEOUT-1]) {
@@ -896,8 +896,8 @@ nfulnl_recv_config(struct sock *ctnl, struct sk_buff *skb,
896 } 896 }
897 897
898 if (nfula[NFULA_CFG_QTHRESH-1]) { 898 if (nfula[NFULA_CFG_QTHRESH-1]) {
899 u_int32_t qthresh = 899 __be32 qthresh =
900 *(u_int16_t *)NFA_DATA(nfula[NFULA_CFG_QTHRESH-1]); 900 *(__be32 *)NFA_DATA(nfula[NFULA_CFG_QTHRESH-1]);
901 901
902 nfulnl_set_qthresh(inst, ntohl(qthresh)); 902 nfulnl_set_qthresh(inst, ntohl(qthresh));
903 } 903 }
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
index 8eb2473d83e1..e815a9aa6e95 100644
--- a/net/netfilter/nfnetlink_queue.c
+++ b/net/netfilter/nfnetlink_queue.c
@@ -414,7 +414,7 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue,
414 nfmsg->res_id = htons(queue->queue_num); 414 nfmsg->res_id = htons(queue->queue_num);
415 415
416 pmsg.packet_id = htonl(entry->id); 416 pmsg.packet_id = htonl(entry->id);
417 pmsg.hw_protocol = htons(entskb->protocol); 417 pmsg.hw_protocol = entskb->protocol;
418 pmsg.hook = entinf->hook; 418 pmsg.hook = entinf->hook;
419 419
420 NFA_PUT(skb, NFQA_PACKET_HDR, sizeof(pmsg), &pmsg); 420 NFA_PUT(skb, NFQA_PACKET_HDR, sizeof(pmsg), &pmsg);
@@ -622,9 +622,10 @@ nfqnl_mangle(void *data, int data_len, struct nfqnl_queue_entry *e)
622 int diff; 622 int diff;
623 623
624 diff = data_len - e->skb->len; 624 diff = data_len - e->skb->len;
625 if (diff < 0) 625 if (diff < 0) {
626 skb_trim(e->skb, data_len); 626 if (pskb_trim(e->skb, data_len))
627 else if (diff > 0) { 627 return -ENOMEM;
628 } else if (diff > 0) {
628 if (data_len > 0xFFFF) 629 if (data_len > 0xFFFF)
629 return -EINVAL; 630 return -EINVAL;
630 if (diff > skb_tailroom(e->skb)) { 631 if (diff > skb_tailroom(e->skb)) {
diff --git a/net/netfilter/xt_NFQUEUE.c b/net/netfilter/xt_NFQUEUE.c
index db9b896e57c8..39e117502bd7 100644
--- a/net/netfilter/xt_NFQUEUE.c
+++ b/net/netfilter/xt_NFQUEUE.c
@@ -68,7 +68,7 @@ static int __init xt_nfqueue_init(void)
68 68
69static void __exit xt_nfqueue_fini(void) 69static void __exit xt_nfqueue_fini(void)
70{ 70{
71 xt_register_targets(xt_nfqueue_target, ARRAY_SIZE(xt_nfqueue_target)); 71 xt_unregister_targets(xt_nfqueue_target, ARRAY_SIZE(xt_nfqueue_target));
72} 72}
73 73
74module_init(xt_nfqueue_init); 74module_init(xt_nfqueue_init);
diff --git a/net/netfilter/xt_connmark.c b/net/netfilter/xt_connmark.c
index 92a5726ef237..a8f03057dbde 100644
--- a/net/netfilter/xt_connmark.c
+++ b/net/netfilter/xt_connmark.c
@@ -147,7 +147,7 @@ static int __init xt_connmark_init(void)
147 147
148static void __exit xt_connmark_fini(void) 148static void __exit xt_connmark_fini(void)
149{ 149{
150 xt_register_matches(xt_connmark_match, ARRAY_SIZE(xt_connmark_match)); 150 xt_unregister_matches(xt_connmark_match, ARRAY_SIZE(xt_connmark_match));
151} 151}
152 152
153module_init(xt_connmark_init); 153module_init(xt_connmark_init);
diff --git a/net/netlabel/Kconfig b/net/netlabel/Kconfig
index 9f7121ae13e9..56958c85f2b4 100644
--- a/net/netlabel/Kconfig
+++ b/net/netlabel/Kconfig
@@ -4,7 +4,7 @@
4 4
5config NETLABEL 5config NETLABEL
6 bool "NetLabel subsystem support" 6 bool "NetLabel subsystem support"
7 depends on NET && SECURITY 7 depends on SECURITY
8 default n 8 default n
9 ---help--- 9 ---help---
10 NetLabel provides support for explicit network packet labeling 10 NetLabel provides support for explicit network packet labeling
diff --git a/net/netlabel/netlabel_kapi.c b/net/netlabel/netlabel_kapi.c
index 54fb7de3c2b1..ff971103fd0c 100644
--- a/net/netlabel/netlabel_kapi.c
+++ b/net/netlabel/netlabel_kapi.c
@@ -200,7 +200,7 @@ void netlbl_cache_invalidate(void)
200int netlbl_cache_add(const struct sk_buff *skb, 200int netlbl_cache_add(const struct sk_buff *skb,
201 const struct netlbl_lsm_secattr *secattr) 201 const struct netlbl_lsm_secattr *secattr)
202{ 202{
203 if (secattr->cache.data == NULL) 203 if (secattr->cache == NULL)
204 return -ENOMSG; 204 return -ENOMSG;
205 205
206 if (CIPSO_V4_OPTEXIST(skb)) 206 if (CIPSO_V4_OPTEXIST(skb))
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index d56e0d21f919..d527c8977b1f 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1075,8 +1075,9 @@ static int netlink_getsockopt(struct socket *sock, int level, int optname,
1075 return -EINVAL; 1075 return -EINVAL;
1076 len = sizeof(int); 1076 len = sizeof(int);
1077 val = nlk->flags & NETLINK_RECV_PKTINFO ? 1 : 0; 1077 val = nlk->flags & NETLINK_RECV_PKTINFO ? 1 : 0;
1078 put_user(len, optlen); 1078 if (put_user(len, optlen) ||
1079 put_user(val, optval); 1079 put_user(val, optval))
1080 return -EFAULT;
1080 err = 0; 1081 err = 0;
1081 break; 1082 break;
1082 default: 1083 default:
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index bb3ddd4784b1..4b52fa78935a 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -786,11 +786,10 @@ static long htb_do_events(struct htb_sched *q, int level)
786 for (i = 0; i < 500; i++) { 786 for (i = 0; i < 500; i++) {
787 struct htb_class *cl; 787 struct htb_class *cl;
788 long diff; 788 long diff;
789 struct rb_node *p = q->wait_pq[level].rb_node; 789 struct rb_node *p = rb_first(&q->wait_pq[level]);
790
790 if (!p) 791 if (!p)
791 return 0; 792 return 0;
792 while (p->rb_left)
793 p = p->rb_left;
794 793
795 cl = rb_entry(p, struct htb_class, pq_node); 794 cl = rb_entry(p, struct htb_class, pq_node);
796 if (time_after(cl->pq_key, q->jiffies)) { 795 if (time_after(cl->pq_key, q->jiffies)) {
@@ -1285,8 +1284,7 @@ static void htb_destroy_class(struct Qdisc *sch, struct htb_class *cl)
1285 struct htb_class, sibling)); 1284 struct htb_class, sibling));
1286 1285
1287 /* note: this delete may happen twice (see htb_delete) */ 1286 /* note: this delete may happen twice (see htb_delete) */
1288 if (!hlist_unhashed(&cl->hlist)) 1287 hlist_del_init(&cl->hlist);
1289 hlist_del(&cl->hlist);
1290 list_del(&cl->sibling); 1288 list_del(&cl->sibling);
1291 1289
1292 if (cl->prio_activity) 1290 if (cl->prio_activity)
@@ -1334,8 +1332,7 @@ static int htb_delete(struct Qdisc *sch, unsigned long arg)
1334 sch_tree_lock(sch); 1332 sch_tree_lock(sch);
1335 1333
1336 /* delete from hash and active; remainder in destroy_class */ 1334 /* delete from hash and active; remainder in destroy_class */
1337 if (!hlist_unhashed(&cl->hlist)) 1335 hlist_del_init(&cl->hlist);
1338 hlist_del(&cl->hlist);
1339 1336
1340 if (cl->prio_activity) 1337 if (cl->prio_activity)
1341 htb_deactivate(q, cl); 1338 htb_deactivate(q, cl);
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index 45939bafbdf8..0441876aa1e7 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -4,7 +4,7 @@
4 * This program is free software; you can redistribute it and/or 4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License 5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version. 7 * 2 of the License.
8 * 8 *
9 * Many of the algorithms and ideas for this came from 9 * Many of the algorithms and ideas for this came from
10 * NIST Net which is not copyrighted. 10 * NIST Net which is not copyrighted.
@@ -170,6 +170,8 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
170 return NET_XMIT_BYPASS; 170 return NET_XMIT_BYPASS;
171 } 171 }
172 172
173 skb_orphan(skb);
174
173 /* 175 /*
174 * If we need to duplicate packet, then re-insert at top of the 176 * If we need to duplicate packet, then re-insert at top of the
175 * qdisc tree, since parent queuer expects that only one 177 * qdisc tree, since parent queuer expects that only one
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index 27329ce9c311..ed0445fe85e7 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -346,11 +346,18 @@ void sctp_association_free(struct sctp_association *asoc)
346 struct list_head *pos, *temp; 346 struct list_head *pos, *temp;
347 int i; 347 int i;
348 348
349 list_del(&asoc->asocs); 349 /* Only real associations count against the endpoint, so
350 * don't bother for if this is a temporary association.
351 */
352 if (!asoc->temp) {
353 list_del(&asoc->asocs);
350 354
351 /* Decrement the backlog value for a TCP-style listening socket. */ 355 /* Decrement the backlog value for a TCP-style listening
352 if (sctp_style(sk, TCP) && sctp_sstate(sk, LISTENING)) 356 * socket.
353 sk->sk_ack_backlog--; 357 */
358 if (sctp_style(sk, TCP) && sctp_sstate(sk, LISTENING))
359 sk->sk_ack_backlog--;
360 }
354 361
355 /* Mark as dead, so other users can know this structure is 362 /* Mark as dead, so other users can know this structure is
356 * going away. 363 * going away.
diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c
index 35c49ff2d062..9b6b394b66f6 100644
--- a/net/sctp/endpointola.c
+++ b/net/sctp/endpointola.c
@@ -144,6 +144,13 @@ void sctp_endpoint_add_asoc(struct sctp_endpoint *ep,
144{ 144{
145 struct sock *sk = ep->base.sk; 145 struct sock *sk = ep->base.sk;
146 146
147 /* If this is a temporary association, don't bother
148 * since we'll be removing it shortly and don't
149 * want anyone to find it anyway.
150 */
151 if (asoc->temp)
152 return;
153
147 /* Now just add it to our list of asocs */ 154 /* Now just add it to our list of asocs */
148 list_add_tail(&asoc->asocs, &ep->asocs); 155 list_add_tail(&asoc->asocs, &ep->asocs);
149 156
diff --git a/net/sctp/input.c b/net/sctp/input.c
index 64f630102532..6d82f400d13c 100644
--- a/net/sctp/input.c
+++ b/net/sctp/input.c
@@ -135,6 +135,9 @@ int sctp_rcv(struct sk_buff *skb)
135 135
136 SCTP_INC_STATS_BH(SCTP_MIB_INSCTPPACKS); 136 SCTP_INC_STATS_BH(SCTP_MIB_INSCTPPACKS);
137 137
138 if (skb_linearize(skb))
139 goto discard_it;
140
138 sh = (struct sctphdr *) skb->h.raw; 141 sh = (struct sctphdr *) skb->h.raw;
139 142
140 /* Pull up the IP and SCTP headers. */ 143 /* Pull up the IP and SCTP headers. */
@@ -768,6 +771,9 @@ static void __sctp_hash_established(struct sctp_association *asoc)
768/* Add an association to the hash. Local BH-safe. */ 771/* Add an association to the hash. Local BH-safe. */
769void sctp_hash_established(struct sctp_association *asoc) 772void sctp_hash_established(struct sctp_association *asoc)
770{ 773{
774 if (asoc->temp)
775 return;
776
771 sctp_local_bh_disable(); 777 sctp_local_bh_disable();
772 __sctp_hash_established(asoc); 778 __sctp_hash_established(asoc);
773 sctp_local_bh_enable(); 779 sctp_local_bh_enable();
@@ -801,6 +807,9 @@ static void __sctp_unhash_established(struct sctp_association *asoc)
801/* Remove association from the hash table. Local BH-safe. */ 807/* Remove association from the hash table. Local BH-safe. */
802void sctp_unhash_established(struct sctp_association *asoc) 808void sctp_unhash_established(struct sctp_association *asoc)
803{ 809{
810 if (asoc->temp)
811 return;
812
804 sctp_local_bh_disable(); 813 sctp_local_bh_disable();
805 __sctp_unhash_established(asoc); 814 __sctp_unhash_established(asoc);
806 sctp_local_bh_enable(); 815 sctp_local_bh_enable();
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index 249e5033c1a8..78071c6e6cf1 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -215,17 +215,17 @@ static struct dst_entry *sctp_v6_get_dst(struct sctp_association *asoc,
215 } 215 }
216 216
217 dst = ip6_route_output(NULL, &fl); 217 dst = ip6_route_output(NULL, &fl);
218 if (dst) { 218 if (!dst->error) {
219 struct rt6_info *rt; 219 struct rt6_info *rt;
220 rt = (struct rt6_info *)dst; 220 rt = (struct rt6_info *)dst;
221 SCTP_DEBUG_PRINTK( 221 SCTP_DEBUG_PRINTK(
222 "rt6_dst:" NIP6_FMT " rt6_src:" NIP6_FMT "\n", 222 "rt6_dst:" NIP6_FMT " rt6_src:" NIP6_FMT "\n",
223 NIP6(rt->rt6i_dst.addr), NIP6(rt->rt6i_src.addr)); 223 NIP6(rt->rt6i_dst.addr), NIP6(rt->rt6i_src.addr));
224 } else { 224 return dst;
225 SCTP_DEBUG_PRINTK("NO ROUTE\n");
226 } 225 }
227 226 SCTP_DEBUG_PRINTK("NO ROUTE\n");
228 return dst; 227 dst_release(dst);
228 return NULL;
229} 229}
230 230
231/* Returns the number of consecutive initial bits that match in the 2 ipv6 231/* Returns the number of consecutive initial bits that match in the 2 ipv6
diff --git a/net/sctp/proc.c b/net/sctp/proc.c
index a356d8d310a9..7f49e769080e 100644
--- a/net/sctp/proc.c
+++ b/net/sctp/proc.c
@@ -344,7 +344,7 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
344 assoc, sk, sctp_sk(sk)->type, sk->sk_state, 344 assoc, sk, sctp_sk(sk)->type, sk->sk_state,
345 assoc->state, hash, assoc->assoc_id, 345 assoc->state, hash, assoc->assoc_id,
346 assoc->sndbuf_used, 346 assoc->sndbuf_used,
347 (sk->sk_rcvbuf - assoc->rwnd), 347 atomic_read(&assoc->rmem_alloc),
348 sock_i_uid(sk), sock_i_ino(sk), 348 sock_i_uid(sk), sock_i_ino(sk),
349 epb->bind_addr.port, 349 epb->bind_addr.port,
350 assoc->peer.port); 350 assoc->peer.port);
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index fac7674438a4..5b4f82fd98f8 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -591,7 +591,7 @@ static struct sock *sctp_v4_create_accept_sk(struct sock *sk,
591 newinet->dport = htons(asoc->peer.port); 591 newinet->dport = htons(asoc->peer.port);
592 newinet->daddr = asoc->peer.primary_addr.v4.sin_addr.s_addr; 592 newinet->daddr = asoc->peer.primary_addr.v4.sin_addr.s_addr;
593 newinet->pmtudisc = inet->pmtudisc; 593 newinet->pmtudisc = inet->pmtudisc;
594 newinet->id = 0; 594 newinet->id = asoc->next_tsn ^ jiffies;
595 595
596 newinet->uc_ttl = -1; 596 newinet->uc_ttl = -1;
597 newinet->mc_loop = 1; 597 newinet->mc_loop = 1;
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 3fe906d65069..935bc9187fd8 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -821,7 +821,7 @@ out:
821 * addrs is a pointer to an array of one or more socket addresses. Each 821 * addrs is a pointer to an array of one or more socket addresses. Each
822 * address is contained in its appropriate structure (i.e. struct 822 * address is contained in its appropriate structure (i.e. struct
823 * sockaddr_in or struct sockaddr_in6) the family of the address type 823 * sockaddr_in or struct sockaddr_in6) the family of the address type
824 * must be used to distengish the address length (note that this 824 * must be used to distinguish the address length (note that this
825 * representation is termed a "packed array" of addresses). The caller 825 * representation is termed a "packed array" of addresses). The caller
826 * specifies the number of addresses in the array with addrcnt. 826 * specifies the number of addresses in the array with addrcnt.
827 * 827 *
@@ -3372,6 +3372,7 @@ SCTP_STATIC int sctp_do_peeloff(struct sctp_association *asoc,
3372{ 3372{
3373 struct sock *sk = asoc->base.sk; 3373 struct sock *sk = asoc->base.sk;
3374 struct socket *sock; 3374 struct socket *sock;
3375 struct inet_sock *inetsk;
3375 int err = 0; 3376 int err = 0;
3376 3377
3377 /* An association cannot be branched off from an already peeled-off 3378 /* An association cannot be branched off from an already peeled-off
@@ -3389,6 +3390,14 @@ SCTP_STATIC int sctp_do_peeloff(struct sctp_association *asoc,
3389 * asoc to the newsk. 3390 * asoc to the newsk.
3390 */ 3391 */
3391 sctp_sock_migrate(sk, sock->sk, asoc, SCTP_SOCKET_UDP_HIGH_BANDWIDTH); 3392 sctp_sock_migrate(sk, sock->sk, asoc, SCTP_SOCKET_UDP_HIGH_BANDWIDTH);
3393
3394 /* Make peeled-off sockets more like 1-1 accepted sockets.
3395 * Set the daddr and initialize id to something more random
3396 */
3397 inetsk = inet_sk(sock->sk);
3398 inetsk->daddr = asoc->peer.primary_addr.v4.sin_addr.s_addr;
3399 inetsk->id = asoc->next_tsn ^ jiffies;
3400
3392 *sockp = sock; 3401 *sockp = sock;
3393 3402
3394 return err; 3403 return err;
@@ -5362,6 +5371,20 @@ static void sctp_wfree(struct sk_buff *skb)
5362 sctp_association_put(asoc); 5371 sctp_association_put(asoc);
5363} 5372}
5364 5373
5374/* Do accounting for the receive space on the socket.
5375 * Accounting for the association is done in ulpevent.c
5376 * We set this as a destructor for the cloned data skbs so that
5377 * accounting is done at the correct time.
5378 */
5379void sctp_sock_rfree(struct sk_buff *skb)
5380{
5381 struct sock *sk = skb->sk;
5382 struct sctp_ulpevent *event = sctp_skb2event(skb);
5383
5384 atomic_sub(event->rmem_len, &sk->sk_rmem_alloc);
5385}
5386
5387
5365/* Helper function to wait for space in the sndbuf. */ 5388/* Helper function to wait for space in the sndbuf. */
5366static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p, 5389static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p,
5367 size_t msg_len) 5390 size_t msg_len)
@@ -5634,10 +5657,10 @@ static void sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
5634 sctp_skb_for_each(skb, &oldsk->sk_receive_queue, tmp) { 5657 sctp_skb_for_each(skb, &oldsk->sk_receive_queue, tmp) {
5635 event = sctp_skb2event(skb); 5658 event = sctp_skb2event(skb);
5636 if (event->asoc == assoc) { 5659 if (event->asoc == assoc) {
5637 sock_rfree(skb); 5660 sctp_sock_rfree(skb);
5638 __skb_unlink(skb, &oldsk->sk_receive_queue); 5661 __skb_unlink(skb, &oldsk->sk_receive_queue);
5639 __skb_queue_tail(&newsk->sk_receive_queue, skb); 5662 __skb_queue_tail(&newsk->sk_receive_queue, skb);
5640 skb_set_owner_r(skb, newsk); 5663 sctp_skb_set_owner_r(skb, newsk);
5641 } 5664 }
5642 } 5665 }
5643 5666
@@ -5665,10 +5688,10 @@ static void sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
5665 sctp_skb_for_each(skb, &oldsp->pd_lobby, tmp) { 5688 sctp_skb_for_each(skb, &oldsp->pd_lobby, tmp) {
5666 event = sctp_skb2event(skb); 5689 event = sctp_skb2event(skb);
5667 if (event->asoc == assoc) { 5690 if (event->asoc == assoc) {
5668 sock_rfree(skb); 5691 sctp_sock_rfree(skb);
5669 __skb_unlink(skb, &oldsp->pd_lobby); 5692 __skb_unlink(skb, &oldsp->pd_lobby);
5670 __skb_queue_tail(queue, skb); 5693 __skb_queue_tail(queue, skb);
5671 skb_set_owner_r(skb, newsk); 5694 sctp_skb_set_owner_r(skb, newsk);
5672 } 5695 }
5673 } 5696 }
5674 5697
diff --git a/net/sctp/ulpevent.c b/net/sctp/ulpevent.c
index ee236784a6bb..a015283a9087 100644
--- a/net/sctp/ulpevent.c
+++ b/net/sctp/ulpevent.c
@@ -55,10 +55,13 @@ static void sctp_ulpevent_release_frag_data(struct sctp_ulpevent *event);
55 55
56 56
57/* Initialize an ULP event from an given skb. */ 57/* Initialize an ULP event from an given skb. */
58SCTP_STATIC void sctp_ulpevent_init(struct sctp_ulpevent *event, int msg_flags) 58SCTP_STATIC void sctp_ulpevent_init(struct sctp_ulpevent *event,
59 int msg_flags,
60 unsigned int len)
59{ 61{
60 memset(event, 0, sizeof(struct sctp_ulpevent)); 62 memset(event, 0, sizeof(struct sctp_ulpevent));
61 event->msg_flags = msg_flags; 63 event->msg_flags = msg_flags;
64 event->rmem_len = len;
62} 65}
63 66
64/* Create a new sctp_ulpevent. */ 67/* Create a new sctp_ulpevent. */
@@ -73,7 +76,7 @@ SCTP_STATIC struct sctp_ulpevent *sctp_ulpevent_new(int size, int msg_flags,
73 goto fail; 76 goto fail;
74 77
75 event = sctp_skb2event(skb); 78 event = sctp_skb2event(skb);
76 sctp_ulpevent_init(event, msg_flags); 79 sctp_ulpevent_init(event, msg_flags, skb->truesize);
77 80
78 return event; 81 return event;
79 82
@@ -101,17 +104,16 @@ static inline void sctp_ulpevent_set_owner(struct sctp_ulpevent *event,
101 sctp_association_hold((struct sctp_association *)asoc); 104 sctp_association_hold((struct sctp_association *)asoc);
102 skb = sctp_event2skb(event); 105 skb = sctp_event2skb(event);
103 event->asoc = (struct sctp_association *)asoc; 106 event->asoc = (struct sctp_association *)asoc;
104 atomic_add(skb->truesize, &event->asoc->rmem_alloc); 107 atomic_add(event->rmem_len, &event->asoc->rmem_alloc);
105 skb_set_owner_r(skb, asoc->base.sk); 108 sctp_skb_set_owner_r(skb, asoc->base.sk);
106} 109}
107 110
108/* A simple destructor to give up the reference to the association. */ 111/* A simple destructor to give up the reference to the association. */
109static inline void sctp_ulpevent_release_owner(struct sctp_ulpevent *event) 112static inline void sctp_ulpevent_release_owner(struct sctp_ulpevent *event)
110{ 113{
111 struct sctp_association *asoc = event->asoc; 114 struct sctp_association *asoc = event->asoc;
112 struct sk_buff *skb = sctp_event2skb(event);
113 115
114 atomic_sub(skb->truesize, &asoc->rmem_alloc); 116 atomic_sub(event->rmem_len, &asoc->rmem_alloc);
115 sctp_association_put(asoc); 117 sctp_association_put(asoc);
116} 118}
117 119
@@ -372,7 +374,7 @@ struct sctp_ulpevent *sctp_ulpevent_make_remote_error(
372 374
373 /* Embed the event fields inside the cloned skb. */ 375 /* Embed the event fields inside the cloned skb. */
374 event = sctp_skb2event(skb); 376 event = sctp_skb2event(skb);
375 sctp_ulpevent_init(event, MSG_NOTIFICATION); 377 sctp_ulpevent_init(event, MSG_NOTIFICATION, skb->truesize);
376 378
377 sre = (struct sctp_remote_error *) 379 sre = (struct sctp_remote_error *)
378 skb_push(skb, sizeof(struct sctp_remote_error)); 380 skb_push(skb, sizeof(struct sctp_remote_error));
@@ -464,7 +466,7 @@ struct sctp_ulpevent *sctp_ulpevent_make_send_failed(
464 466
465 /* Embed the event fields inside the cloned skb. */ 467 /* Embed the event fields inside the cloned skb. */
466 event = sctp_skb2event(skb); 468 event = sctp_skb2event(skb);
467 sctp_ulpevent_init(event, MSG_NOTIFICATION); 469 sctp_ulpevent_init(event, MSG_NOTIFICATION, skb->truesize);
468 470
469 ssf = (struct sctp_send_failed *) 471 ssf = (struct sctp_send_failed *)
470 skb_push(skb, sizeof(struct sctp_send_failed)); 472 skb_push(skb, sizeof(struct sctp_send_failed));
@@ -682,8 +684,11 @@ struct sctp_ulpevent *sctp_ulpevent_make_rcvmsg(struct sctp_association *asoc,
682 /* Embed the event fields inside the cloned skb. */ 684 /* Embed the event fields inside the cloned skb. */
683 event = sctp_skb2event(skb); 685 event = sctp_skb2event(skb);
684 686
685 /* Initialize event with flags 0. */ 687 /* Initialize event with flags 0 and correct length
686 sctp_ulpevent_init(event, 0); 688 * Since this is a clone of the original skb, only account for
689 * the data of this chunk as other chunks will be accounted separately.
690 */
691 sctp_ulpevent_init(event, 0, skb->len + sizeof(struct sk_buff));
687 692
688 sctp_ulpevent_receive_data(event, asoc); 693 sctp_ulpevent_receive_data(event, asoc);
689 694
diff --git a/net/sctp/ulpqueue.c b/net/sctp/ulpqueue.c
index 575e556aeb3e..e1d144275f97 100644
--- a/net/sctp/ulpqueue.c
+++ b/net/sctp/ulpqueue.c
@@ -309,7 +309,7 @@ static struct sctp_ulpevent *sctp_make_reassembled_event(struct sk_buff_head *qu
309 if (!new) 309 if (!new)
310 return NULL; /* try again later */ 310 return NULL; /* try again later */
311 311
312 new->sk = f_frag->sk; 312 sctp_skb_set_owner_r(new, f_frag->sk);
313 313
314 skb_shinfo(new)->frag_list = pos; 314 skb_shinfo(new)->frag_list = pos;
315 } else 315 } else
diff --git a/net/sunrpc/pmap_clnt.c b/net/sunrpc/pmap_clnt.c
index 919d5ba7ca0a..e52afab413de 100644
--- a/net/sunrpc/pmap_clnt.c
+++ b/net/sunrpc/pmap_clnt.c
@@ -101,11 +101,13 @@ void rpc_getport(struct rpc_task *task)
101 /* Autobind on cloned rpc clients is discouraged */ 101 /* Autobind on cloned rpc clients is discouraged */
102 BUG_ON(clnt->cl_parent != clnt); 102 BUG_ON(clnt->cl_parent != clnt);
103 103
104 if (xprt_test_and_set_binding(xprt)) { 104 /* Put self on queue before sending rpcbind request, in case
105 task->tk_status = -EACCES; /* tell caller to check again */ 105 * pmap_getport_done completes before we return from rpc_run_task */
106 rpc_sleep_on(&xprt->binding, task, NULL, NULL); 106 rpc_sleep_on(&xprt->binding, task, NULL, NULL);
107 return; 107
108 } 108 status = -EACCES; /* tell caller to check again */
109 if (xprt_test_and_set_binding(xprt))
110 goto bailout_nofree;
109 111
110 /* Someone else may have bound if we slept */ 112 /* Someone else may have bound if we slept */
111 status = 0; 113 status = 0;
@@ -134,8 +136,6 @@ void rpc_getport(struct rpc_task *task)
134 goto bailout; 136 goto bailout;
135 rpc_release_task(child); 137 rpc_release_task(child);
136 138
137 rpc_sleep_on(&xprt->binding, task, NULL, NULL);
138
139 task->tk_xprt->stat.bind_count++; 139 task->tk_xprt->stat.bind_count++;
140 return; 140 return;
141 141
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index 2807fa0eab40..eb44ec929ca1 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -828,6 +828,11 @@ svc_process(struct svc_rqst *rqstp)
828 *statp = procp->pc_func(rqstp, rqstp->rq_argp, rqstp->rq_resp); 828 *statp = procp->pc_func(rqstp, rqstp->rq_argp, rqstp->rq_resp);
829 829
830 /* Encode reply */ 830 /* Encode reply */
831 if (*statp == rpc_drop_reply) {
832 if (procp->pc_release)
833 procp->pc_release(rqstp, NULL, rqstp->rq_resp);
834 goto dropit;
835 }
831 if (*statp == rpc_success && (xdr = procp->pc_encode) 836 if (*statp == rpc_success && (xdr = procp->pc_encode)
832 && !xdr(rqstp, resv->iov_base+resv->iov_len, rqstp->rq_resp)) { 837 && !xdr(rqstp, resv->iov_base+resv->iov_len, rqstp->rq_resp)) {
833 dprintk("svc: failed to encode reply\n"); 838 dprintk("svc: failed to encode reply\n");
diff --git a/net/sunrpc/svcauth.c b/net/sunrpc/svcauth.c
index 8f2320aded5c..ee9bb1522d5e 100644
--- a/net/sunrpc/svcauth.c
+++ b/net/sunrpc/svcauth.c
@@ -126,6 +126,7 @@ void auth_domain_put(struct auth_domain *dom)
126 if (atomic_dec_and_lock(&dom->ref.refcount, &auth_domain_lock)) { 126 if (atomic_dec_and_lock(&dom->ref.refcount, &auth_domain_lock)) {
127 hlist_del(&dom->hash); 127 hlist_del(&dom->hash);
128 dom->flavour->domain_release(dom); 128 dom->flavour->domain_release(dom);
129 spin_unlock(&auth_domain_lock);
129 } 130 }
130} 131}
131 132
@@ -147,10 +148,8 @@ auth_domain_lookup(char *name, struct auth_domain *new)
147 return hp; 148 return hp;
148 } 149 }
149 } 150 }
150 if (new) { 151 if (new)
151 hlist_add_head(&new->hash, head); 152 hlist_add_head(&new->hash, head);
152 kref_get(&new->ref);
153 }
154 spin_unlock(&auth_domain_lock); 153 spin_unlock(&auth_domain_lock);
155 return new; 154 return new;
156} 155}
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 61e307cca13d..64ca1f61dd94 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -299,9 +299,15 @@ void svc_reserve(struct svc_rqst *rqstp, int space)
299static inline void 299static inline void
300svc_sock_put(struct svc_sock *svsk) 300svc_sock_put(struct svc_sock *svsk)
301{ 301{
302 if (atomic_dec_and_test(&svsk->sk_inuse) && test_bit(SK_DEAD, &svsk->sk_flags)) { 302 if (atomic_dec_and_test(&svsk->sk_inuse) &&
303 test_bit(SK_DEAD, &svsk->sk_flags)) {
303 dprintk("svc: releasing dead socket\n"); 304 dprintk("svc: releasing dead socket\n");
304 sock_release(svsk->sk_sock); 305 if (svsk->sk_sock->file)
306 sockfd_put(svsk->sk_sock);
307 else
308 sock_release(svsk->sk_sock);
309 if (svsk->sk_info_authunix != NULL)
310 svcauth_unix_info_release(svsk->sk_info_authunix);
305 kfree(svsk); 311 kfree(svsk);
306 } 312 }
307} 313}
@@ -973,7 +979,7 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp)
973 return 0; 979 return 0;
974 } 980 }
975 981
976 if (test_bit(SK_CONN, &svsk->sk_flags)) { 982 if (svsk->sk_sk->sk_state == TCP_LISTEN) {
977 svc_tcp_accept(svsk); 983 svc_tcp_accept(svsk);
978 svc_sock_received(svsk); 984 svc_sock_received(svsk);
979 return 0; 985 return 0;
@@ -1604,20 +1610,13 @@ svc_delete_socket(struct svc_sock *svsk)
1604 if (test_bit(SK_TEMP, &svsk->sk_flags)) 1610 if (test_bit(SK_TEMP, &svsk->sk_flags))
1605 serv->sv_tmpcnt--; 1611 serv->sv_tmpcnt--;
1606 1612
1607 if (!atomic_read(&svsk->sk_inuse)) { 1613 /* This atomic_inc should be needed - svc_delete_socket
1608 spin_unlock_bh(&serv->sv_lock); 1614 * should have the semantic of dropping a reference.
1609 if (svsk->sk_sock->file) 1615 * But it doesn't yet....
1610 sockfd_put(svsk->sk_sock); 1616 */
1611 else 1617 atomic_inc(&svsk->sk_inuse);
1612 sock_release(svsk->sk_sock); 1618 spin_unlock_bh(&serv->sv_lock);
1613 if (svsk->sk_info_authunix != NULL) 1619 svc_sock_put(svsk);
1614 svcauth_unix_info_release(svsk->sk_info_authunix);
1615 kfree(svsk);
1616 } else {
1617 spin_unlock_bh(&serv->sv_lock);
1618 dprintk(KERN_NOTICE "svc: server socket destroy delayed\n");
1619 /* svsk->sk_server = NULL; */
1620 }
1621} 1620}
1622 1621
1623/* 1622/*
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 28100e019225..757fc91ef25d 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -1366,7 +1366,7 @@ int xs_setup_udp(struct rpc_xprt *xprt, struct rpc_timeout *to)
1366 if (xprt->slot == NULL) 1366 if (xprt->slot == NULL)
1367 return -ENOMEM; 1367 return -ENOMEM;
1368 1368
1369 if (ntohs(addr->sin_port != 0)) 1369 if (ntohs(addr->sin_port) != 0)
1370 xprt_set_bound(xprt); 1370 xprt_set_bound(xprt);
1371 xprt->port = xs_get_random_port(); 1371 xprt->port = xs_get_random_port();
1372 1372
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 75a5968c2139..39744a33bd36 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -2,7 +2,7 @@
2 * net/tipc/bearer.c: TIPC bearer code 2 * net/tipc/bearer.c: TIPC bearer code
3 * 3 *
4 * Copyright (c) 1996-2006, Ericsson AB 4 * Copyright (c) 1996-2006, Ericsson AB
5 * Copyright (c) 2004-2005, Wind River Systems 5 * Copyright (c) 2004-2006, Wind River Systems
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
@@ -191,14 +191,14 @@ void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a)
191 if ((i < media_count) && (m_ptr->addr2str != NULL)) { 191 if ((i < media_count) && (m_ptr->addr2str != NULL)) {
192 char addr_str[MAX_ADDR_STR]; 192 char addr_str[MAX_ADDR_STR];
193 193
194 tipc_printf(pb, "%s(%s) ", m_ptr->name, 194 tipc_printf(pb, "%s(%s)", m_ptr->name,
195 m_ptr->addr2str(a, addr_str, sizeof(addr_str))); 195 m_ptr->addr2str(a, addr_str, sizeof(addr_str)));
196 } else { 196 } else {
197 unchar *addr = (unchar *)&a->dev_addr; 197 unchar *addr = (unchar *)&a->dev_addr;
198 198
199 tipc_printf(pb, "UNKNOWN(%u):", media_type); 199 tipc_printf(pb, "UNKNOWN(%u)", media_type);
200 for (i = 0; i < (sizeof(*a) - sizeof(a->type)); i++) { 200 for (i = 0; i < (sizeof(*a) - sizeof(a->type)); i++) {
201 tipc_printf(pb, "%02x ", addr[i]); 201 tipc_printf(pb, "-%02x", addr[i]);
202 } 202 }
203 } 203 }
204} 204}
diff --git a/net/tipc/config.c b/net/tipc/config.c
index 285e1bc2d880..ed1351ed05e1 100644
--- a/net/tipc/config.c
+++ b/net/tipc/config.c
@@ -2,7 +2,7 @@
2 * net/tipc/config.c: TIPC configuration management code 2 * net/tipc/config.c: TIPC configuration management code
3 * 3 *
4 * Copyright (c) 2002-2006, Ericsson AB 4 * Copyright (c) 2002-2006, Ericsson AB
5 * Copyright (c) 2004-2005, Wind River Systems 5 * Copyright (c) 2004-2006, Wind River Systems
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
@@ -613,7 +613,8 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area
613 rep_tlv_buf = tipc_cfg_reply_unsigned(tipc_net_id); 613 rep_tlv_buf = tipc_cfg_reply_unsigned(tipc_net_id);
614 break; 614 break;
615 default: 615 default:
616 rep_tlv_buf = NULL; 616 rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
617 " (unknown command)");
617 break; 618 break;
618 } 619 }
619 620
diff --git a/net/tipc/core.c b/net/tipc/core.c
index 0539a8362858..6f5b7ee31180 100644
--- a/net/tipc/core.c
+++ b/net/tipc/core.c
@@ -57,7 +57,7 @@ void tipc_socket_stop(void);
57int tipc_netlink_start(void); 57int tipc_netlink_start(void);
58void tipc_netlink_stop(void); 58void tipc_netlink_stop(void);
59 59
60#define TIPC_MOD_VER "1.6.1" 60#define TIPC_MOD_VER "1.6.2"
61 61
62#ifndef CONFIG_TIPC_ZONES 62#ifndef CONFIG_TIPC_ZONES
63#define CONFIG_TIPC_ZONES 3 63#define CONFIG_TIPC_ZONES 3
@@ -90,7 +90,7 @@ int tipc_random;
90atomic_t tipc_user_count = ATOMIC_INIT(0); 90atomic_t tipc_user_count = ATOMIC_INIT(0);
91 91
92const char tipc_alphabet[] = 92const char tipc_alphabet[] =
93 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"; 93 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.";
94 94
95/* configurable TIPC parameters */ 95/* configurable TIPC parameters */
96 96
diff --git a/net/tipc/core.h b/net/tipc/core.h
index 762aac2572be..4638947c2326 100644
--- a/net/tipc/core.h
+++ b/net/tipc/core.h
@@ -65,7 +65,7 @@
65#define assert(i) BUG_ON(!(i)) 65#define assert(i) BUG_ON(!(i))
66 66
67struct tipc_msg; 67struct tipc_msg;
68extern struct print_buf *TIPC_CONS, *TIPC_LOG; 68extern struct print_buf *TIPC_NULL, *TIPC_CONS, *TIPC_LOG;
69extern struct print_buf *TIPC_TEE(struct print_buf *, struct print_buf *); 69extern struct print_buf *TIPC_TEE(struct print_buf *, struct print_buf *);
70void tipc_msg_print(struct print_buf*,struct tipc_msg *,const char*); 70void tipc_msg_print(struct print_buf*,struct tipc_msg *,const char*);
71void tipc_printf(struct print_buf *, const char *fmt, ...); 71void tipc_printf(struct print_buf *, const char *fmt, ...);
@@ -83,9 +83,9 @@ void tipc_dump(struct print_buf*,const char *fmt, ...);
83#define warn(fmt, arg...) tipc_printf(TIPC_OUTPUT, KERN_WARNING "TIPC: " fmt, ## arg) 83#define warn(fmt, arg...) tipc_printf(TIPC_OUTPUT, KERN_WARNING "TIPC: " fmt, ## arg)
84#define info(fmt, arg...) tipc_printf(TIPC_OUTPUT, KERN_NOTICE "TIPC: " fmt, ## arg) 84#define info(fmt, arg...) tipc_printf(TIPC_OUTPUT, KERN_NOTICE "TIPC: " fmt, ## arg)
85 85
86#define dbg(fmt, arg...) do {if (DBG_OUTPUT) tipc_printf(DBG_OUTPUT, fmt, ## arg);} while(0) 86#define dbg(fmt, arg...) do {if (DBG_OUTPUT != TIPC_NULL) tipc_printf(DBG_OUTPUT, fmt, ## arg);} while(0)
87#define msg_dbg(msg, txt) do {if (DBG_OUTPUT) tipc_msg_print(DBG_OUTPUT, msg, txt);} while(0) 87#define msg_dbg(msg, txt) do {if (DBG_OUTPUT != TIPC_NULL) tipc_msg_print(DBG_OUTPUT, msg, txt);} while(0)
88#define dump(fmt, arg...) do {if (DBG_OUTPUT) tipc_dump(DBG_OUTPUT, fmt, ##arg);} while(0) 88#define dump(fmt, arg...) do {if (DBG_OUTPUT != TIPC_NULL) tipc_dump(DBG_OUTPUT, fmt, ##arg);} while(0)
89 89
90 90
91/* 91/*
@@ -94,11 +94,11 @@ void tipc_dump(struct print_buf*,const char *fmt, ...);
94 * here, or on a per .c file basis, by redefining these symbols. The following 94 * here, or on a per .c file basis, by redefining these symbols. The following
95 * print buffer options are available: 95 * print buffer options are available:
96 * 96 *
97 * NULL : Output to null print buffer (i.e. print nowhere) 97 * TIPC_NULL : null buffer (i.e. print nowhere)
98 * TIPC_CONS : Output to system console 98 * TIPC_CONS : system console
99 * TIPC_LOG : Output to TIPC log buffer 99 * TIPC_LOG : TIPC log buffer
100 * &buf : Output to user-defined buffer (struct print_buf *) 100 * &buf : user-defined buffer (struct print_buf *)
101 * TIPC_TEE(&buf_a,&buf_b) : Output to two print buffers (eg. TIPC_TEE(TIPC_CONS,TIPC_LOG) ) 101 * TIPC_TEE(&buf_a,&buf_b) : list of buffers (eg. TIPC_TEE(TIPC_CONS,TIPC_LOG))
102 */ 102 */
103 103
104#ifndef TIPC_OUTPUT 104#ifndef TIPC_OUTPUT
@@ -106,7 +106,7 @@ void tipc_dump(struct print_buf*,const char *fmt, ...);
106#endif 106#endif
107 107
108#ifndef DBG_OUTPUT 108#ifndef DBG_OUTPUT
109#define DBG_OUTPUT NULL 109#define DBG_OUTPUT TIPC_NULL
110#endif 110#endif
111 111
112#else 112#else
@@ -136,7 +136,7 @@ void tipc_dump(struct print_buf*,const char *fmt, ...);
136#define TIPC_OUTPUT TIPC_CONS 136#define TIPC_OUTPUT TIPC_CONS
137 137
138#undef DBG_OUTPUT 138#undef DBG_OUTPUT
139#define DBG_OUTPUT NULL 139#define DBG_OUTPUT TIPC_NULL
140 140
141#endif 141#endif
142 142
@@ -275,11 +275,15 @@ static inline void k_term_timer(struct timer_list *timer)
275/* 275/*
276 * TIPC message buffer code 276 * TIPC message buffer code
277 * 277 *
278 * TIPC message buffer headroom leaves room for 14 byte Ethernet header, 278 * TIPC message buffer headroom reserves space for a link-level header
279 * (in case the message is sent off-node),
279 * while ensuring TIPC header is word aligned for quicker access 280 * while ensuring TIPC header is word aligned for quicker access
281 *
282 * The largest header currently supported is 18 bytes, which is used when
283 * the standard 14 byte Ethernet header has 4 added bytes for VLAN info
280 */ 284 */
281 285
282#define BUF_HEADROOM 16u 286#define BUF_HEADROOM 20u
283 287
284struct tipc_skb_cb { 288struct tipc_skb_cb {
285 void *handle; 289 void *handle;
diff --git a/net/tipc/dbg.c b/net/tipc/dbg.c
index 55130655e1ed..d8af4c28695d 100644
--- a/net/tipc/dbg.c
+++ b/net/tipc/dbg.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * net/tipc/dbg.c: TIPC print buffer routines for debuggign 2 * net/tipc/dbg.c: TIPC print buffer routines for debugging
3 * 3 *
4 * Copyright (c) 1996-2006, Ericsson AB 4 * Copyright (c) 1996-2006, Ericsson AB
5 * Copyright (c) 2005, Wind River Systems 5 * Copyright (c) 2005-2006, Wind River Systems
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
@@ -38,11 +38,12 @@
38#include "config.h" 38#include "config.h"
39#include "dbg.h" 39#include "dbg.h"
40 40
41#define MAX_STRING 512 41static char print_string[TIPC_PB_MAX_STR];
42
43static char print_string[MAX_STRING];
44static DEFINE_SPINLOCK(print_lock); 42static DEFINE_SPINLOCK(print_lock);
45 43
44static struct print_buf null_buf = { NULL, 0, NULL, NULL };
45struct print_buf *TIPC_NULL = &null_buf;
46
46static struct print_buf cons_buf = { NULL, 0, NULL, NULL }; 47static struct print_buf cons_buf = { NULL, 0, NULL, NULL };
47struct print_buf *TIPC_CONS = &cons_buf; 48struct print_buf *TIPC_CONS = &cons_buf;
48 49
@@ -62,68 +63,83 @@ struct print_buf *TIPC_LOG = &log_buf;
62/* 63/*
63 * Locking policy when using print buffers. 64 * Locking policy when using print buffers.
64 * 65 *
65 * 1) Routines of the form printbuf_XXX() rely on the caller to prevent 66 * The following routines use 'print_lock' for protection:
66 * simultaneous use of the print buffer(s) being manipulated. 67 * 1) tipc_printf() - to protect its print buffer(s) and 'print_string'
67 * 2) tipc_printf() uses 'print_lock' to prevent simultaneous use of 68 * 2) TIPC_TEE() - to protect its print buffer(s)
68 * 'print_string' and to protect its print buffer(s). 69 * 3) tipc_dump() - to protect its print buffer(s) and 'print_string'
69 * 3) TIPC_TEE() uses 'print_lock' to protect its print buffer(s). 70 * 4) tipc_log_XXX() - to protect TIPC_LOG
70 * 4) Routines of the form log_XXX() uses 'print_lock' to protect TIPC_LOG. 71 *
72 * All routines of the form tipc_printbuf_XXX() rely on the caller to prevent
73 * simultaneous use of the print buffer(s) being manipulated.
71 */ 74 */
72 75
73/** 76/**
74 * tipc_printbuf_init - initialize print buffer to empty 77 * tipc_printbuf_init - initialize print buffer to empty
78 * @pb: pointer to print buffer structure
79 * @raw: pointer to character array used by print buffer
80 * @size: size of character array
81 *
82 * Makes the print buffer a null device that discards anything written to it
83 * if the character array is too small (or absent).
75 */ 84 */
76 85
77void tipc_printbuf_init(struct print_buf *pb, char *raw, u32 sz) 86void tipc_printbuf_init(struct print_buf *pb, char *raw, u32 size)
78{ 87{
79 if (!pb || !raw || (sz < (MAX_STRING + 1))) 88 pb->buf = raw;
80 return; 89 pb->crs = raw;
81 90 pb->size = size;
82 pb->crs = pb->buf = raw;
83 pb->size = sz;
84 pb->next = NULL; 91 pb->next = NULL;
85 pb->buf[0] = 0; 92
86 pb->buf[sz-1] = ~0; 93 if (size < TIPC_PB_MIN_SIZE) {
94 pb->buf = NULL;
95 } else if (raw) {
96 pb->buf[0] = 0;
97 pb->buf[size-1] = ~0;
98 }
87} 99}
88 100
89/** 101/**
90 * tipc_printbuf_reset - reinitialize print buffer to empty state 102 * tipc_printbuf_reset - reinitialize print buffer to empty state
103 * @pb: pointer to print buffer structure
91 */ 104 */
92 105
93void tipc_printbuf_reset(struct print_buf *pb) 106void tipc_printbuf_reset(struct print_buf *pb)
94{ 107{
95 if (pb && pb->buf) 108 tipc_printbuf_init(pb, pb->buf, pb->size);
96 tipc_printbuf_init(pb, pb->buf, pb->size);
97} 109}
98 110
99/** 111/**
100 * tipc_printbuf_empty - test if print buffer is in empty state 112 * tipc_printbuf_empty - test if print buffer is in empty state
113 * @pb: pointer to print buffer structure
114 *
115 * Returns non-zero if print buffer is empty.
101 */ 116 */
102 117
103int tipc_printbuf_empty(struct print_buf *pb) 118int tipc_printbuf_empty(struct print_buf *pb)
104{ 119{
105 return (!pb || !pb->buf || (pb->crs == pb->buf)); 120 return (!pb->buf || (pb->crs == pb->buf));
106} 121}
107 122
108/** 123/**
109 * tipc_printbuf_validate - check for print buffer overflow 124 * tipc_printbuf_validate - check for print buffer overflow
125 * @pb: pointer to print buffer structure
110 * 126 *
111 * Verifies that a print buffer has captured all data written to it. 127 * Verifies that a print buffer has captured all data written to it.
112 * If data has been lost, linearize buffer and prepend an error message 128 * If data has been lost, linearize buffer and prepend an error message
113 * 129 *
114 * Returns length of print buffer data string (including trailing NULL) 130 * Returns length of print buffer data string (including trailing NUL)
115 */ 131 */
116 132
117int tipc_printbuf_validate(struct print_buf *pb) 133int tipc_printbuf_validate(struct print_buf *pb)
118{ 134{
119 char *err = " *** PRINT BUFFER WRAPPED AROUND ***\n"; 135 char *err = "\n\n*** PRINT BUFFER OVERFLOW ***\n\n";
120 char *cp_buf; 136 char *cp_buf;
121 struct print_buf cb; 137 struct print_buf cb;
122 138
123 if (!pb || !pb->buf) 139 if (!pb->buf)
124 return 0; 140 return 0;
125 141
126 if (pb->buf[pb->size - 1] == '\0') { 142 if (pb->buf[pb->size - 1] == 0) {
127 cp_buf = kmalloc(pb->size, GFP_ATOMIC); 143 cp_buf = kmalloc(pb->size, GFP_ATOMIC);
128 if (cp_buf != NULL){ 144 if (cp_buf != NULL){
129 tipc_printbuf_init(&cb, cp_buf, pb->size); 145 tipc_printbuf_init(&cb, cp_buf, pb->size);
@@ -141,6 +157,8 @@ int tipc_printbuf_validate(struct print_buf *pb)
141 157
142/** 158/**
143 * tipc_printbuf_move - move print buffer contents to another print buffer 159 * tipc_printbuf_move - move print buffer contents to another print buffer
160 * @pb_to: pointer to destination print buffer structure
161 * @pb_from: pointer to source print buffer structure
144 * 162 *
145 * Current contents of destination print buffer (if any) are discarded. 163 * Current contents of destination print buffer (if any) are discarded.
146 * Source print buffer becomes empty if a successful move occurs. 164 * Source print buffer becomes empty if a successful move occurs.
@@ -152,21 +170,22 @@ void tipc_printbuf_move(struct print_buf *pb_to, struct print_buf *pb_from)
152 170
153 /* Handle the cases where contents can't be moved */ 171 /* Handle the cases where contents can't be moved */
154 172
155 if (!pb_to || !pb_to->buf) 173 if (!pb_to->buf)
156 return; 174 return;
157 175
158 if (!pb_from || !pb_from->buf) { 176 if (!pb_from->buf) {
159 tipc_printbuf_reset(pb_to); 177 tipc_printbuf_reset(pb_to);
160 return; 178 return;
161 } 179 }
162 180
163 if (pb_to->size < pb_from->size) { 181 if (pb_to->size < pb_from->size) {
164 tipc_printbuf_reset(pb_to); 182 tipc_printbuf_reset(pb_to);
165 tipc_printf(pb_to, "*** PRINT BUFFER OVERFLOW ***"); 183 tipc_printf(pb_to, "*** PRINT BUFFER MOVE ERROR ***");
166 return; 184 return;
167 } 185 }
168 186
169 /* Copy data from char after cursor to end (if used) */ 187 /* Copy data from char after cursor to end (if used) */
188
170 len = pb_from->buf + pb_from->size - pb_from->crs - 2; 189 len = pb_from->buf + pb_from->size - pb_from->crs - 2;
171 if ((pb_from->buf[pb_from->size-1] == 0) && (len > 0)) { 190 if ((pb_from->buf[pb_from->size-1] == 0) && (len > 0)) {
172 strcpy(pb_to->buf, pb_from->crs + 1); 191 strcpy(pb_to->buf, pb_from->crs + 1);
@@ -175,6 +194,7 @@ void tipc_printbuf_move(struct print_buf *pb_to, struct print_buf *pb_from)
175 pb_to->crs = pb_to->buf; 194 pb_to->crs = pb_to->buf;
176 195
177 /* Copy data from start to cursor (always) */ 196 /* Copy data from start to cursor (always) */
197
178 len = pb_from->crs - pb_from->buf; 198 len = pb_from->crs - pb_from->buf;
179 strcpy(pb_to->crs, pb_from->buf); 199 strcpy(pb_to->crs, pb_from->buf);
180 pb_to->crs += len; 200 pb_to->crs += len;
@@ -184,6 +204,8 @@ void tipc_printbuf_move(struct print_buf *pb_to, struct print_buf *pb_from)
184 204
185/** 205/**
186 * tipc_printf - append formatted output to print buffer chain 206 * tipc_printf - append formatted output to print buffer chain
207 * @pb: pointer to chain of print buffers (may be NULL)
208 * @fmt: formatted info to be printed
187 */ 209 */
188 210
189void tipc_printf(struct print_buf *pb, const char *fmt, ...) 211void tipc_printf(struct print_buf *pb, const char *fmt, ...)
@@ -195,8 +217,8 @@ void tipc_printf(struct print_buf *pb, const char *fmt, ...)
195 217
196 spin_lock_bh(&print_lock); 218 spin_lock_bh(&print_lock);
197 FORMAT(print_string, chars_to_add, fmt); 219 FORMAT(print_string, chars_to_add, fmt);
198 if (chars_to_add >= MAX_STRING) 220 if (chars_to_add >= TIPC_PB_MAX_STR)
199 strcpy(print_string, "*** STRING TOO LONG ***"); 221 strcpy(print_string, "*** PRINT BUFFER STRING TOO LONG ***");
200 222
201 while (pb) { 223 while (pb) {
202 if (pb == TIPC_CONS) 224 if (pb == TIPC_CONS)
@@ -206,6 +228,10 @@ void tipc_printf(struct print_buf *pb, const char *fmt, ...)
206 if (chars_to_add <= chars_left) { 228 if (chars_to_add <= chars_left) {
207 strcpy(pb->crs, print_string); 229 strcpy(pb->crs, print_string);
208 pb->crs += chars_to_add; 230 pb->crs += chars_to_add;
231 } else if (chars_to_add >= (pb->size - 1)) {
232 strcpy(pb->buf, print_string + chars_to_add + 1
233 - pb->size);
234 pb->crs = pb->buf + pb->size - 1;
209 } else { 235 } else {
210 strcpy(pb->buf, print_string + chars_left); 236 strcpy(pb->buf, print_string + chars_left);
211 save_char = print_string[chars_left]; 237 save_char = print_string[chars_left];
@@ -224,6 +250,10 @@ void tipc_printf(struct print_buf *pb, const char *fmt, ...)
224 250
225/** 251/**
226 * TIPC_TEE - perform next output operation on both print buffers 252 * TIPC_TEE - perform next output operation on both print buffers
253 * @b0: pointer to chain of print buffers (may be NULL)
254 * @b1: pointer to print buffer to add to chain
255 *
256 * Returns pointer to print buffer chain.
227 */ 257 */
228 258
229struct print_buf *TIPC_TEE(struct print_buf *b0, struct print_buf *b1) 259struct print_buf *TIPC_TEE(struct print_buf *b0, struct print_buf *b1)
@@ -232,8 +262,6 @@ struct print_buf *TIPC_TEE(struct print_buf *b0, struct print_buf *b1)
232 262
233 if (!b0 || (b0 == b1)) 263 if (!b0 || (b0 == b1))
234 return b1; 264 return b1;
235 if (!b1)
236 return b0;
237 265
238 spin_lock_bh(&print_lock); 266 spin_lock_bh(&print_lock);
239 while (pb->next) { 267 while (pb->next) {
@@ -256,7 +284,7 @@ static void print_to_console(char *crs, int len)
256 int rest = len; 284 int rest = len;
257 285
258 while (rest > 0) { 286 while (rest > 0) {
259 int sz = rest < MAX_STRING ? rest : MAX_STRING; 287 int sz = rest < TIPC_PB_MAX_STR ? rest : TIPC_PB_MAX_STR;
260 char c = crs[sz]; 288 char c = crs[sz];
261 289
262 crs[sz] = 0; 290 crs[sz] = 0;
@@ -275,36 +303,48 @@ static void printbuf_dump(struct print_buf *pb)
275{ 303{
276 int len; 304 int len;
277 305
306 if (!pb->buf) {
307 printk("*** PRINT BUFFER NOT ALLOCATED ***");
308 return;
309 }
310
278 /* Dump print buffer from char after cursor to end (if used) */ 311 /* Dump print buffer from char after cursor to end (if used) */
312
279 len = pb->buf + pb->size - pb->crs - 2; 313 len = pb->buf + pb->size - pb->crs - 2;
280 if ((pb->buf[pb->size - 1] == 0) && (len > 0)) 314 if ((pb->buf[pb->size - 1] == 0) && (len > 0))
281 print_to_console(pb->crs + 1, len); 315 print_to_console(pb->crs + 1, len);
282 316
283 /* Dump print buffer from start to cursor (always) */ 317 /* Dump print buffer from start to cursor (always) */
318
284 len = pb->crs - pb->buf; 319 len = pb->crs - pb->buf;
285 print_to_console(pb->buf, len); 320 print_to_console(pb->buf, len);
286} 321}
287 322
288/** 323/**
289 * tipc_dump - dump non-console print buffer(s) to console 324 * tipc_dump - dump non-console print buffer(s) to console
325 * @pb: pointer to chain of print buffers
290 */ 326 */
291 327
292void tipc_dump(struct print_buf *pb, const char *fmt, ...) 328void tipc_dump(struct print_buf *pb, const char *fmt, ...)
293{ 329{
330 struct print_buf *pb_next;
294 int len; 331 int len;
295 332
296 spin_lock_bh(&print_lock); 333 spin_lock_bh(&print_lock);
297 FORMAT(TIPC_CONS->buf, len, fmt); 334 FORMAT(print_string, len, fmt);
298 printk(TIPC_CONS->buf); 335 printk(print_string);
299 336
300 for (; pb; pb = pb->next) { 337 for (; pb; pb = pb->next) {
301 if (pb == TIPC_CONS) 338 if (pb != TIPC_CONS) {
302 continue; 339 printk("\n---- Start of %s log dump ----\n\n",
303 printk("\n---- Start of dump,%s log ----\n\n", 340 (pb == TIPC_LOG) ? "global" : "local");
304 (pb == TIPC_LOG) ? "global" : "local"); 341 printbuf_dump(pb);
305 printbuf_dump(pb); 342 tipc_printbuf_reset(pb);
306 tipc_printbuf_reset(pb); 343 printk("\n---- End of dump ----\n");
307 printk("\n-------- End of dump --------\n"); 344 }
345 pb_next = pb->next;
346 pb->next = NULL;
347 pb = pb_next;
308 } 348 }
309 spin_unlock_bh(&print_lock); 349 spin_unlock_bh(&print_lock);
310} 350}
@@ -324,7 +364,8 @@ void tipc_log_stop(void)
324} 364}
325 365
326/** 366/**
327 * tipc_log_reinit - set TIPC log print buffer to specified size 367 * tipc_log_reinit - (re)initialize TIPC log print buffer
368 * @log_size: print buffer size to use
328 */ 369 */
329 370
330void tipc_log_reinit(int log_size) 371void tipc_log_reinit(int log_size)
@@ -332,10 +373,11 @@ void tipc_log_reinit(int log_size)
332 tipc_log_stop(); 373 tipc_log_stop();
333 374
334 if (log_size) { 375 if (log_size) {
335 if (log_size <= MAX_STRING) 376 if (log_size < TIPC_PB_MIN_SIZE)
336 log_size = MAX_STRING + 1; 377 log_size = TIPC_PB_MIN_SIZE;
337 spin_lock_bh(&print_lock); 378 spin_lock_bh(&print_lock);
338 tipc_printbuf_init(TIPC_LOG, kmalloc(log_size, GFP_ATOMIC), log_size); 379 tipc_printbuf_init(TIPC_LOG, kmalloc(log_size, GFP_ATOMIC),
380 log_size);
339 spin_unlock_bh(&print_lock); 381 spin_unlock_bh(&print_lock);
340 } 382 }
341} 383}
diff --git a/net/tipc/dbg.h b/net/tipc/dbg.h
index 227f050d2a52..467c0bc78a79 100644
--- a/net/tipc/dbg.h
+++ b/net/tipc/dbg.h
@@ -2,7 +2,7 @@
2 * net/tipc/dbg.h: Include file for TIPC print buffer routines 2 * net/tipc/dbg.h: Include file for TIPC print buffer routines
3 * 3 *
4 * Copyright (c) 1997-2006, Ericsson AB 4 * Copyright (c) 1997-2006, Ericsson AB
5 * Copyright (c) 2005, Wind River Systems 5 * Copyright (c) 2005-2006, Wind River Systems
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
@@ -37,6 +37,14 @@
37#ifndef _TIPC_DBG_H 37#ifndef _TIPC_DBG_H
38#define _TIPC_DBG_H 38#define _TIPC_DBG_H
39 39
40/**
41 * struct print_buf - TIPC print buffer structure
42 * @buf: pointer to character array containing print buffer contents
43 * @size: size of character array
44 * @crs: pointer to first unused space in character array (i.e. final NUL)
45 * @next: used to link print buffers when printing to more than one at a time
46 */
47
40struct print_buf { 48struct print_buf {
41 char *buf; 49 char *buf;
42 u32 size; 50 u32 size;
@@ -44,7 +52,10 @@ struct print_buf {
44 struct print_buf *next; 52 struct print_buf *next;
45}; 53};
46 54
47void tipc_printbuf_init(struct print_buf *pb, char *buf, u32 sz); 55#define TIPC_PB_MIN_SIZE 64 /* minimum size for a print buffer's array */
56#define TIPC_PB_MAX_STR 512 /* max printable string (with trailing NUL) */
57
58void tipc_printbuf_init(struct print_buf *pb, char *buf, u32 size);
48void tipc_printbuf_reset(struct print_buf *pb); 59void tipc_printbuf_reset(struct print_buf *pb);
49int tipc_printbuf_empty(struct print_buf *pb); 60int tipc_printbuf_empty(struct print_buf *pb);
50int tipc_printbuf_validate(struct print_buf *pb); 61int tipc_printbuf_validate(struct print_buf *pb);
diff --git a/net/tipc/discover.c b/net/tipc/discover.c
index ee94de92ae99..3b0cd12f37da 100644
--- a/net/tipc/discover.c
+++ b/net/tipc/discover.c
@@ -132,6 +132,28 @@ static struct sk_buff *tipc_disc_init_msg(u32 type,
132} 132}
133 133
134/** 134/**
135 * disc_dupl_alert - issue node address duplication alert
136 * @b_ptr: pointer to bearer detecting duplication
137 * @node_addr: duplicated node address
138 * @media_addr: media address advertised by duplicated node
139 */
140
141static void disc_dupl_alert(struct bearer *b_ptr, u32 node_addr,
142 struct tipc_media_addr *media_addr)
143{
144 char node_addr_str[16];
145 char media_addr_str[64];
146 struct print_buf pb;
147
148 addr_string_fill(node_addr_str, node_addr);
149 tipc_printbuf_init(&pb, media_addr_str, sizeof(media_addr_str));
150 tipc_media_addr_printf(&pb, media_addr);
151 tipc_printbuf_validate(&pb);
152 warn("Duplicate %s using %s seen on <%s>\n",
153 node_addr_str, media_addr_str, b_ptr->publ.name);
154}
155
156/**
135 * tipc_disc_recv_msg - handle incoming link setup message (request or response) 157 * tipc_disc_recv_msg - handle incoming link setup message (request or response)
136 * @buf: buffer containing message 158 * @buf: buffer containing message
137 */ 159 */
@@ -157,8 +179,11 @@ void tipc_disc_recv_msg(struct sk_buff *buf)
157 return; 179 return;
158 if (!tipc_addr_node_valid(orig)) 180 if (!tipc_addr_node_valid(orig))
159 return; 181 return;
160 if (orig == tipc_own_addr) 182 if (orig == tipc_own_addr) {
183 if (memcmp(&media_addr, &b_ptr->publ.addr, sizeof(media_addr)))
184 disc_dupl_alert(b_ptr, tipc_own_addr, &media_addr);
161 return; 185 return;
186 }
162 if (!in_scope(dest, tipc_own_addr)) 187 if (!in_scope(dest, tipc_own_addr))
163 return; 188 return;
164 if (is_slave(tipc_own_addr) && is_slave(orig)) 189 if (is_slave(tipc_own_addr) && is_slave(orig))
@@ -170,7 +195,8 @@ void tipc_disc_recv_msg(struct sk_buff *buf)
170 struct sk_buff *rbuf; 195 struct sk_buff *rbuf;
171 struct tipc_media_addr *addr; 196 struct tipc_media_addr *addr;
172 struct node *n_ptr = tipc_node_find(orig); 197 struct node *n_ptr = tipc_node_find(orig);
173 int link_up; 198 int link_fully_up;
199
174 dbg(" in own cluster\n"); 200 dbg(" in own cluster\n");
175 if (n_ptr == NULL) { 201 if (n_ptr == NULL) {
176 n_ptr = tipc_node_create(orig); 202 n_ptr = tipc_node_create(orig);
@@ -190,14 +216,19 @@ void tipc_disc_recv_msg(struct sk_buff *buf)
190 } 216 }
191 addr = &link->media_addr; 217 addr = &link->media_addr;
192 if (memcmp(addr, &media_addr, sizeof(*addr))) { 218 if (memcmp(addr, &media_addr, sizeof(*addr))) {
219 if (tipc_link_is_up(link) || (!link->started)) {
220 disc_dupl_alert(b_ptr, orig, &media_addr);
221 spin_unlock_bh(&n_ptr->lock);
222 return;
223 }
193 warn("Resetting link <%s>, peer interface address changed\n", 224 warn("Resetting link <%s>, peer interface address changed\n",
194 link->name); 225 link->name);
195 memcpy(addr, &media_addr, sizeof(*addr)); 226 memcpy(addr, &media_addr, sizeof(*addr));
196 tipc_link_reset(link); 227 tipc_link_reset(link);
197 } 228 }
198 link_up = tipc_link_is_up(link); 229 link_fully_up = (link->state == WORKING_WORKING);
199 spin_unlock_bh(&n_ptr->lock); 230 spin_unlock_bh(&n_ptr->lock);
200 if ((type == DSC_RESP_MSG) || link_up) 231 if ((type == DSC_RESP_MSG) || link_fully_up)
201 return; 232 return;
202 rbuf = tipc_disc_init_msg(DSC_RESP_MSG, 1, orig, b_ptr); 233 rbuf = tipc_disc_init_msg(DSC_RESP_MSG, 1, orig, b_ptr);
203 if (rbuf != NULL) { 234 if (rbuf != NULL) {
diff --git a/net/tipc/link.c b/net/tipc/link.c
index 53bc8cb5adbc..1bb983c8130b 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -132,7 +132,7 @@ static void link_print(struct link *l_ptr, struct print_buf *buf,
132 * allow the output from multiple links to be intermixed. For this reason 132 * allow the output from multiple links to be intermixed. For this reason
133 * routines of the form "dbg_link_XXX()" have been created that will capture 133 * routines of the form "dbg_link_XXX()" have been created that will capture
134 * debug info into a link's personal print buffer, which can then be dumped 134 * debug info into a link's personal print buffer, which can then be dumped
135 * into the TIPC system log (LOG) upon request. 135 * into the TIPC system log (TIPC_LOG) upon request.
136 * 136 *
137 * To enable per-link debugging, use LINK_LOG_BUF_SIZE to specify the size 137 * To enable per-link debugging, use LINK_LOG_BUF_SIZE to specify the size
138 * of the print buffer used by each link. If LINK_LOG_BUF_SIZE is set to 0, 138 * of the print buffer used by each link. If LINK_LOG_BUF_SIZE is set to 0,
@@ -141,7 +141,7 @@ static void link_print(struct link *l_ptr, struct print_buf *buf,
141 * when there is only a single link in the system being debugged. 141 * when there is only a single link in the system being debugged.
142 * 142 *
143 * Notes: 143 * Notes:
144 * - When enabled, LINK_LOG_BUF_SIZE should be set to at least 1000 (bytes) 144 * - When enabled, LINK_LOG_BUF_SIZE should be set to at least TIPC_PB_MIN_SIZE
145 * - "l_ptr" must be valid when using dbg_link_XXX() macros 145 * - "l_ptr" must be valid when using dbg_link_XXX() macros
146 */ 146 */
147 147
@@ -159,13 +159,13 @@ static void link_print(struct link *l_ptr, struct print_buf *buf,
159 159
160static void dbg_print_link(struct link *l_ptr, const char *str) 160static void dbg_print_link(struct link *l_ptr, const char *str)
161{ 161{
162 if (DBG_OUTPUT) 162 if (DBG_OUTPUT != TIPC_NULL)
163 link_print(l_ptr, DBG_OUTPUT, str); 163 link_print(l_ptr, DBG_OUTPUT, str);
164} 164}
165 165
166static void dbg_print_buf_chain(struct sk_buff *root_buf) 166static void dbg_print_buf_chain(struct sk_buff *root_buf)
167{ 167{
168 if (DBG_OUTPUT) { 168 if (DBG_OUTPUT != TIPC_NULL) {
169 struct sk_buff *buf = root_buf; 169 struct sk_buff *buf = root_buf;
170 170
171 while (buf) { 171 while (buf) {
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c
index f0b063bcc2a9..03bd659c43ca 100644
--- a/net/tipc/name_distr.c
+++ b/net/tipc/name_distr.c
@@ -122,7 +122,7 @@ void tipc_named_publish(struct publication *publ)
122 struct sk_buff *buf; 122 struct sk_buff *buf;
123 struct distr_item *item; 123 struct distr_item *item;
124 124
125 list_add(&publ->local_list, &publ_root); 125 list_add_tail(&publ->local_list, &publ_root);
126 publ_cnt++; 126 publ_cnt++;
127 127
128 buf = named_prepare_buf(PUBLICATION, ITEM_SIZE, 0); 128 buf = named_prepare_buf(PUBLICATION, ITEM_SIZE, 0);
diff --git a/net/tipc/node.c b/net/tipc/node.c
index fc6d09630ccd..886bda5e88db 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -648,7 +648,7 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)
648 return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE 648 return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
649 " (network address)"); 649 " (network address)");
650 650
651 if (!tipc_nodes) 651 if (tipc_mode != TIPC_NET_MODE)
652 return tipc_cfg_reply_none(); 652 return tipc_cfg_reply_none();
653 653
654 /* Get space for all unicast links + multicast link */ 654 /* Get space for all unicast links + multicast link */
diff --git a/net/tipc/port.c b/net/tipc/port.c
index b9c8c6b9e94f..b7f3199523ca 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -505,8 +505,13 @@ static void port_timeout(unsigned long ref)
505 struct port *p_ptr = tipc_port_lock(ref); 505 struct port *p_ptr = tipc_port_lock(ref);
506 struct sk_buff *buf = NULL; 506 struct sk_buff *buf = NULL;
507 507
508 if (!p_ptr || !p_ptr->publ.connected) 508 if (!p_ptr)
509 return;
510
511 if (!p_ptr->publ.connected) {
512 tipc_port_unlock(p_ptr);
509 return; 513 return;
514 }
510 515
511 /* Last probe answered ? */ 516 /* Last probe answered ? */
512 if (p_ptr->probing_state == PROBING) { 517 if (p_ptr->probing_state == PROBING) {
@@ -1131,11 +1136,12 @@ int tipc_publish(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
1131 int res = -EINVAL; 1136 int res = -EINVAL;
1132 1137
1133 p_ptr = tipc_port_lock(ref); 1138 p_ptr = tipc_port_lock(ref);
1139 if (!p_ptr)
1140 return -EINVAL;
1141
1134 dbg("tipc_publ %u, p_ptr = %x, conn = %x, scope = %x, " 1142 dbg("tipc_publ %u, p_ptr = %x, conn = %x, scope = %x, "
1135 "lower = %u, upper = %u\n", 1143 "lower = %u, upper = %u\n",
1136 ref, p_ptr, p_ptr->publ.connected, scope, seq->lower, seq->upper); 1144 ref, p_ptr, p_ptr->publ.connected, scope, seq->lower, seq->upper);
1137 if (!p_ptr)
1138 return -EINVAL;
1139 if (p_ptr->publ.connected) 1145 if (p_ptr->publ.connected)
1140 goto exit; 1146 goto exit;
1141 if (seq->lower > seq->upper) 1147 if (seq->lower > seq->upper)
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index acfb852e7c98..2a6a5a6b4c12 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -2,7 +2,7 @@
2 * net/tipc/socket.c: TIPC socket API 2 * net/tipc/socket.c: TIPC socket API
3 * 3 *
4 * Copyright (c) 2001-2006, Ericsson AB 4 * Copyright (c) 2001-2006, Ericsson AB
5 * Copyright (c) 2004-2005, Wind River Systems 5 * Copyright (c) 2004-2006, Wind River Systems
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
@@ -629,6 +629,9 @@ static int send_stream(struct kiocb *iocb, struct socket *sock,
629 return -ENOTCONN; 629 return -ENOTCONN;
630 } 630 }
631 631
632 if (unlikely(m->msg_name))
633 return -EISCONN;
634
632 /* 635 /*
633 * Send each iovec entry using one or more messages 636 * Send each iovec entry using one or more messages
634 * 637 *
@@ -641,6 +644,8 @@ static int send_stream(struct kiocb *iocb, struct socket *sock,
641 curr_iovlen = m->msg_iovlen; 644 curr_iovlen = m->msg_iovlen;
642 my_msg.msg_iov = &my_iov; 645 my_msg.msg_iov = &my_iov;
643 my_msg.msg_iovlen = 1; 646 my_msg.msg_iovlen = 1;
647 my_msg.msg_flags = m->msg_flags;
648 my_msg.msg_name = NULL;
644 bytes_sent = 0; 649 bytes_sent = 0;
645 650
646 while (curr_iovlen--) { 651 while (curr_iovlen--) {
@@ -1203,7 +1208,8 @@ static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf)
1203 atomic_inc(&tipc_queue_size); 1208 atomic_inc(&tipc_queue_size);
1204 skb_queue_tail(&sock->sk->sk_receive_queue, buf); 1209 skb_queue_tail(&sock->sk->sk_receive_queue, buf);
1205 1210
1206 wake_up_interruptible(sock->sk->sk_sleep); 1211 if (waitqueue_active(sock->sk->sk_sleep))
1212 wake_up_interruptible(sock->sk->sk_sleep);
1207 return TIPC_OK; 1213 return TIPC_OK;
1208} 1214}
1209 1215
@@ -1218,7 +1224,8 @@ static void wakeupdispatch(struct tipc_port *tport)
1218{ 1224{
1219 struct tipc_sock *tsock = (struct tipc_sock *)tport->usr_handle; 1225 struct tipc_sock *tsock = (struct tipc_sock *)tport->usr_handle;
1220 1226
1221 wake_up_interruptible(tsock->sk.sk_sleep); 1227 if (waitqueue_active(tsock->sk.sk_sleep))
1228 wake_up_interruptible(tsock->sk.sk_sleep);
1222} 1229}
1223 1230
1224/** 1231/**
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
index c51600ba5f4a..7a918f12a5df 100644
--- a/net/tipc/subscr.c
+++ b/net/tipc/subscr.c
@@ -155,7 +155,7 @@ void tipc_subscr_report_overlap(struct subscription *sub,
155 sub->seq.upper, found_lower, found_upper); 155 sub->seq.upper, found_lower, found_upper);
156 if (!tipc_subscr_overlap(sub, found_lower, found_upper)) 156 if (!tipc_subscr_overlap(sub, found_lower, found_upper))
157 return; 157 return;
158 if (!must && (sub->filter != TIPC_SUB_PORTS)) 158 if (!must && !(sub->filter & TIPC_SUB_PORTS))
159 return; 159 return;
160 subscr_send_event(sub, found_lower, found_upper, event, port_ref, node); 160 subscr_send_event(sub, found_lower, found_upper, event, port_ref, node);
161} 161}
@@ -176,6 +176,13 @@ static void subscr_timeout(struct subscription *sub)
176 if (subscriber == NULL) 176 if (subscriber == NULL)
177 return; 177 return;
178 178
179 /* Validate timeout (in case subscription is being cancelled) */
180
181 if (sub->timeout == TIPC_WAIT_FOREVER) {
182 tipc_ref_unlock(subscriber_ref);
183 return;
184 }
185
179 /* Unlink subscription from name table */ 186 /* Unlink subscription from name table */
180 187
181 tipc_nametbl_unsubscribe(sub); 188 tipc_nametbl_unsubscribe(sub);
@@ -199,6 +206,20 @@ static void subscr_timeout(struct subscription *sub)
199} 206}
200 207
201/** 208/**
209 * subscr_del - delete a subscription within a subscription list
210 *
211 * Called with subscriber locked.
212 */
213
214static void subscr_del(struct subscription *sub)
215{
216 tipc_nametbl_unsubscribe(sub);
217 list_del(&sub->subscription_list);
218 kfree(sub);
219 atomic_dec(&topsrv.subscription_count);
220}
221
222/**
202 * subscr_terminate - terminate communication with a subscriber 223 * subscr_terminate - terminate communication with a subscriber
203 * 224 *
204 * Called with subscriber locked. Routine must temporarily release this lock 225 * Called with subscriber locked. Routine must temporarily release this lock
@@ -227,12 +248,9 @@ static void subscr_terminate(struct subscriber *subscriber)
227 k_cancel_timer(&sub->timer); 248 k_cancel_timer(&sub->timer);
228 k_term_timer(&sub->timer); 249 k_term_timer(&sub->timer);
229 } 250 }
230 tipc_nametbl_unsubscribe(sub); 251 dbg("Term: Removing sub %u,%u,%u from subscriber %x list\n",
231 list_del(&sub->subscription_list);
232 dbg("Term: Removed sub %u,%u,%u from subscriber %x list\n",
233 sub->seq.type, sub->seq.lower, sub->seq.upper, subscriber); 252 sub->seq.type, sub->seq.lower, sub->seq.upper, subscriber);
234 kfree(sub); 253 subscr_del(sub);
235 atomic_dec(&topsrv.subscription_count);
236 } 254 }
237 255
238 /* Sever connection to subscriber */ 256 /* Sever connection to subscriber */
@@ -253,6 +271,49 @@ static void subscr_terminate(struct subscriber *subscriber)
253} 271}
254 272
255/** 273/**
274 * subscr_cancel - handle subscription cancellation request
275 *
276 * Called with subscriber locked. Routine must temporarily release this lock
277 * to enable the subscription timeout routine to finish without deadlocking;
278 * the lock is then reclaimed to allow caller to release it upon return.
279 *
280 * Note that fields of 's' use subscriber's endianness!
281 */
282
283static void subscr_cancel(struct tipc_subscr *s,
284 struct subscriber *subscriber)
285{
286 struct subscription *sub;
287 struct subscription *sub_temp;
288 int found = 0;
289
290 /* Find first matching subscription, exit if not found */
291
292 list_for_each_entry_safe(sub, sub_temp, &subscriber->subscription_list,
293 subscription_list) {
294 if (!memcmp(s, &sub->evt.s, sizeof(struct tipc_subscr))) {
295 found = 1;
296 break;
297 }
298 }
299 if (!found)
300 return;
301
302 /* Cancel subscription timer (if used), then delete subscription */
303
304 if (sub->timeout != TIPC_WAIT_FOREVER) {
305 sub->timeout = TIPC_WAIT_FOREVER;
306 spin_unlock_bh(subscriber->lock);
307 k_cancel_timer(&sub->timer);
308 k_term_timer(&sub->timer);
309 spin_lock_bh(subscriber->lock);
310 }
311 dbg("Cancel: removing sub %u,%u,%u from subscriber %x list\n",
312 sub->seq.type, sub->seq.lower, sub->seq.upper, subscriber);
313 subscr_del(sub);
314}
315
316/**
256 * subscr_subscribe - create subscription for subscriber 317 * subscr_subscribe - create subscription for subscriber
257 * 318 *
258 * Called with subscriber locked 319 * Called with subscriber locked
@@ -263,6 +324,21 @@ static void subscr_subscribe(struct tipc_subscr *s,
263{ 324{
264 struct subscription *sub; 325 struct subscription *sub;
265 326
327 /* Determine/update subscriber's endianness */
328
329 if (s->filter & (TIPC_SUB_PORTS | TIPC_SUB_SERVICE))
330 subscriber->swap = 0;
331 else
332 subscriber->swap = 1;
333
334 /* Detect & process a subscription cancellation request */
335
336 if (s->filter & htohl(TIPC_SUB_CANCEL, subscriber->swap)) {
337 s->filter &= ~htohl(TIPC_SUB_CANCEL, subscriber->swap);
338 subscr_cancel(s, subscriber);
339 return;
340 }
341
266 /* Refuse subscription if global limit exceeded */ 342 /* Refuse subscription if global limit exceeded */
267 343
268 if (atomic_read(&topsrv.subscription_count) >= tipc_max_subscriptions) { 344 if (atomic_read(&topsrv.subscription_count) >= tipc_max_subscriptions) {
@@ -281,13 +357,6 @@ static void subscr_subscribe(struct tipc_subscr *s,
281 return; 357 return;
282 } 358 }
283 359
284 /* Determine/update subscriber's endianness */
285
286 if ((s->filter == TIPC_SUB_PORTS) || (s->filter == TIPC_SUB_SERVICE))
287 subscriber->swap = 0;
288 else
289 subscriber->swap = 1;
290
291 /* Initialize subscription object */ 360 /* Initialize subscription object */
292 361
293 memset(sub, 0, sizeof(*sub)); 362 memset(sub, 0, sizeof(*sub));
@@ -296,8 +365,8 @@ static void subscr_subscribe(struct tipc_subscr *s,
296 sub->seq.upper = htohl(s->seq.upper, subscriber->swap); 365 sub->seq.upper = htohl(s->seq.upper, subscriber->swap);
297 sub->timeout = htohl(s->timeout, subscriber->swap); 366 sub->timeout = htohl(s->timeout, subscriber->swap);
298 sub->filter = htohl(s->filter, subscriber->swap); 367 sub->filter = htohl(s->filter, subscriber->swap);
299 if ((((sub->filter != TIPC_SUB_PORTS) 368 if ((!(sub->filter & TIPC_SUB_PORTS)
300 && (sub->filter != TIPC_SUB_SERVICE))) 369 == !(sub->filter & TIPC_SUB_SERVICE))
301 || (sub->seq.lower > sub->seq.upper)) { 370 || (sub->seq.lower > sub->seq.upper)) {
302 warn("Subscription rejected, illegal request\n"); 371 warn("Subscription rejected, illegal request\n");
303 kfree(sub); 372 kfree(sub);
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 2a7861661f14..7736b23c3f03 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -883,30 +883,32 @@ out:
883} 883}
884EXPORT_SYMBOL(xfrm_policy_walk); 884EXPORT_SYMBOL(xfrm_policy_walk);
885 885
886/* Find policy to apply to this flow. */ 886/*
887 887 * Find policy to apply to this flow.
888 *
889 * Returns 0 if policy found, else an -errno.
890 */
888static int xfrm_policy_match(struct xfrm_policy *pol, struct flowi *fl, 891static int xfrm_policy_match(struct xfrm_policy *pol, struct flowi *fl,
889 u8 type, u16 family, int dir) 892 u8 type, u16 family, int dir)
890{ 893{
891 struct xfrm_selector *sel = &pol->selector; 894 struct xfrm_selector *sel = &pol->selector;
892 int match; 895 int match, ret = -ESRCH;
893 896
894 if (pol->family != family || 897 if (pol->family != family ||
895 pol->type != type) 898 pol->type != type)
896 return 0; 899 return ret;
897 900
898 match = xfrm_selector_match(sel, fl, family); 901 match = xfrm_selector_match(sel, fl, family);
899 if (match) { 902 if (match)
900 if (!security_xfrm_policy_lookup(pol, fl->secid, dir)) 903 ret = security_xfrm_policy_lookup(pol, fl->secid, dir);
901 return 1;
902 }
903 904
904 return 0; 905 return ret;
905} 906}
906 907
907static struct xfrm_policy *xfrm_policy_lookup_bytype(u8 type, struct flowi *fl, 908static struct xfrm_policy *xfrm_policy_lookup_bytype(u8 type, struct flowi *fl,
908 u16 family, u8 dir) 909 u16 family, u8 dir)
909{ 910{
911 int err;
910 struct xfrm_policy *pol, *ret; 912 struct xfrm_policy *pol, *ret;
911 xfrm_address_t *daddr, *saddr; 913 xfrm_address_t *daddr, *saddr;
912 struct hlist_node *entry; 914 struct hlist_node *entry;
@@ -922,7 +924,15 @@ static struct xfrm_policy *xfrm_policy_lookup_bytype(u8 type, struct flowi *fl,
922 chain = policy_hash_direct(daddr, saddr, family, dir); 924 chain = policy_hash_direct(daddr, saddr, family, dir);
923 ret = NULL; 925 ret = NULL;
924 hlist_for_each_entry(pol, entry, chain, bydst) { 926 hlist_for_each_entry(pol, entry, chain, bydst) {
925 if (xfrm_policy_match(pol, fl, type, family, dir)) { 927 err = xfrm_policy_match(pol, fl, type, family, dir);
928 if (err) {
929 if (err == -ESRCH)
930 continue;
931 else {
932 ret = ERR_PTR(err);
933 goto fail;
934 }
935 } else {
926 ret = pol; 936 ret = pol;
927 priority = ret->priority; 937 priority = ret->priority;
928 break; 938 break;
@@ -930,36 +940,53 @@ static struct xfrm_policy *xfrm_policy_lookup_bytype(u8 type, struct flowi *fl,
930 } 940 }
931 chain = &xfrm_policy_inexact[dir]; 941 chain = &xfrm_policy_inexact[dir];
932 hlist_for_each_entry(pol, entry, chain, bydst) { 942 hlist_for_each_entry(pol, entry, chain, bydst) {
933 if (xfrm_policy_match(pol, fl, type, family, dir) && 943 err = xfrm_policy_match(pol, fl, type, family, dir);
934 pol->priority < priority) { 944 if (err) {
945 if (err == -ESRCH)
946 continue;
947 else {
948 ret = ERR_PTR(err);
949 goto fail;
950 }
951 } else if (pol->priority < priority) {
935 ret = pol; 952 ret = pol;
936 break; 953 break;
937 } 954 }
938 } 955 }
939 if (ret) 956 if (ret)
940 xfrm_pol_hold(ret); 957 xfrm_pol_hold(ret);
958fail:
941 read_unlock_bh(&xfrm_policy_lock); 959 read_unlock_bh(&xfrm_policy_lock);
942 960
943 return ret; 961 return ret;
944} 962}
945 963
946static void xfrm_policy_lookup(struct flowi *fl, u16 family, u8 dir, 964static int xfrm_policy_lookup(struct flowi *fl, u16 family, u8 dir,
947 void **objp, atomic_t **obj_refp) 965 void **objp, atomic_t **obj_refp)
948{ 966{
949 struct xfrm_policy *pol; 967 struct xfrm_policy *pol;
968 int err = 0;
950 969
951#ifdef CONFIG_XFRM_SUB_POLICY 970#ifdef CONFIG_XFRM_SUB_POLICY
952 pol = xfrm_policy_lookup_bytype(XFRM_POLICY_TYPE_SUB, fl, family, dir); 971 pol = xfrm_policy_lookup_bytype(XFRM_POLICY_TYPE_SUB, fl, family, dir);
953 if (pol) 972 if (IS_ERR(pol)) {
973 err = PTR_ERR(pol);
974 pol = NULL;
975 }
976 if (pol || err)
954 goto end; 977 goto end;
955#endif 978#endif
956 pol = xfrm_policy_lookup_bytype(XFRM_POLICY_TYPE_MAIN, fl, family, dir); 979 pol = xfrm_policy_lookup_bytype(XFRM_POLICY_TYPE_MAIN, fl, family, dir);
957 980 if (IS_ERR(pol)) {
981 err = PTR_ERR(pol);
982 pol = NULL;
983 }
958#ifdef CONFIG_XFRM_SUB_POLICY 984#ifdef CONFIG_XFRM_SUB_POLICY
959end: 985end:
960#endif 986#endif
961 if ((*objp = (void *) pol) != NULL) 987 if ((*objp = (void *) pol) != NULL)
962 *obj_refp = &pol->refcnt; 988 *obj_refp = &pol->refcnt;
989 return err;
963} 990}
964 991
965static inline int policy_to_flow_dir(int dir) 992static inline int policy_to_flow_dir(int dir)
@@ -989,12 +1016,16 @@ static struct xfrm_policy *xfrm_sk_policy_lookup(struct sock *sk, int dir, struc
989 sk->sk_family); 1016 sk->sk_family);
990 int err = 0; 1017 int err = 0;
991 1018
992 if (match) 1019 if (match) {
993 err = security_xfrm_policy_lookup(pol, fl->secid, policy_to_flow_dir(dir)); 1020 err = security_xfrm_policy_lookup(pol, fl->secid,
994 1021 policy_to_flow_dir(dir));
995 if (match && !err) 1022 if (!err)
996 xfrm_pol_hold(pol); 1023 xfrm_pol_hold(pol);
997 else 1024 else if (err == -ESRCH)
1025 pol = NULL;
1026 else
1027 pol = ERR_PTR(err);
1028 } else
998 pol = NULL; 1029 pol = NULL;
999 } 1030 }
1000 read_unlock_bh(&xfrm_policy_lock); 1031 read_unlock_bh(&xfrm_policy_lock);
@@ -1286,8 +1317,11 @@ restart:
1286 pol_dead = 0; 1317 pol_dead = 0;
1287 xfrm_nr = 0; 1318 xfrm_nr = 0;
1288 1319
1289 if (sk && sk->sk_policy[1]) 1320 if (sk && sk->sk_policy[1]) {
1290 policy = xfrm_sk_policy_lookup(sk, XFRM_POLICY_OUT, fl); 1321 policy = xfrm_sk_policy_lookup(sk, XFRM_POLICY_OUT, fl);
1322 if (IS_ERR(policy))
1323 return PTR_ERR(policy);
1324 }
1291 1325
1292 if (!policy) { 1326 if (!policy) {
1293 /* To accelerate a bit... */ 1327 /* To accelerate a bit... */
@@ -1297,6 +1331,8 @@ restart:
1297 1331
1298 policy = flow_cache_lookup(fl, dst_orig->ops->family, 1332 policy = flow_cache_lookup(fl, dst_orig->ops->family,
1299 dir, xfrm_policy_lookup); 1333 dir, xfrm_policy_lookup);
1334 if (IS_ERR(policy))
1335 return PTR_ERR(policy);
1300 } 1336 }
1301 1337
1302 if (!policy) 1338 if (!policy)
@@ -1343,6 +1379,10 @@ restart:
1343 fl, family, 1379 fl, family,
1344 XFRM_POLICY_OUT); 1380 XFRM_POLICY_OUT);
1345 if (pols[1]) { 1381 if (pols[1]) {
1382 if (IS_ERR(pols[1])) {
1383 err = PTR_ERR(pols[1]);
1384 goto error;
1385 }
1346 if (pols[1]->action == XFRM_POLICY_BLOCK) { 1386 if (pols[1]->action == XFRM_POLICY_BLOCK) {
1347 err = -EPERM; 1387 err = -EPERM;
1348 goto error; 1388 goto error;
@@ -1574,13 +1614,19 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb,
1574 } 1614 }
1575 1615
1576 pol = NULL; 1616 pol = NULL;
1577 if (sk && sk->sk_policy[dir]) 1617 if (sk && sk->sk_policy[dir]) {
1578 pol = xfrm_sk_policy_lookup(sk, dir, &fl); 1618 pol = xfrm_sk_policy_lookup(sk, dir, &fl);
1619 if (IS_ERR(pol))
1620 return 0;
1621 }
1579 1622
1580 if (!pol) 1623 if (!pol)
1581 pol = flow_cache_lookup(&fl, family, fl_dir, 1624 pol = flow_cache_lookup(&fl, family, fl_dir,
1582 xfrm_policy_lookup); 1625 xfrm_policy_lookup);
1583 1626
1627 if (IS_ERR(pol))
1628 return 0;
1629
1584 if (!pol) { 1630 if (!pol) {
1585 if (skb->sp && secpath_has_nontransport(skb->sp, 0, &xerr_idx)) { 1631 if (skb->sp && secpath_has_nontransport(skb->sp, 0, &xerr_idx)) {
1586 xfrm_secpath_reject(xerr_idx, skb, &fl); 1632 xfrm_secpath_reject(xerr_idx, skb, &fl);
@@ -1599,6 +1645,8 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb,
1599 &fl, family, 1645 &fl, family,
1600 XFRM_POLICY_IN); 1646 XFRM_POLICY_IN);
1601 if (pols[1]) { 1647 if (pols[1]) {
1648 if (IS_ERR(pols[1]))
1649 return 0;
1602 pols[1]->curlft.use_time = (unsigned long)xtime.tv_sec; 1650 pols[1]->curlft.use_time = (unsigned long)xtime.tv_sec;
1603 npols ++; 1651 npols ++;
1604 } 1652 }
@@ -1706,7 +1754,7 @@ static struct dst_entry *xfrm_dst_check(struct dst_entry *dst, u32 cookie)
1706 1754
1707static int stale_bundle(struct dst_entry *dst) 1755static int stale_bundle(struct dst_entry *dst)
1708{ 1756{
1709 return !xfrm_bundle_ok((struct xfrm_dst *)dst, NULL, AF_UNSPEC, 0); 1757 return !xfrm_bundle_ok(NULL, (struct xfrm_dst *)dst, NULL, AF_UNSPEC, 0);
1710} 1758}
1711 1759
1712void xfrm_dst_ifdown(struct dst_entry *dst, struct net_device *dev) 1760void xfrm_dst_ifdown(struct dst_entry *dst, struct net_device *dev)
@@ -1828,7 +1876,8 @@ EXPORT_SYMBOL(xfrm_init_pmtu);
1828 * still valid. 1876 * still valid.
1829 */ 1877 */
1830 1878
1831int xfrm_bundle_ok(struct xfrm_dst *first, struct flowi *fl, int family, int strict) 1879int xfrm_bundle_ok(struct xfrm_policy *pol, struct xfrm_dst *first,
1880 struct flowi *fl, int family, int strict)
1832{ 1881{
1833 struct dst_entry *dst = &first->u.dst; 1882 struct dst_entry *dst = &first->u.dst;
1834 struct xfrm_dst *last; 1883 struct xfrm_dst *last;
@@ -1845,7 +1894,7 @@ int xfrm_bundle_ok(struct xfrm_dst *first, struct flowi *fl, int family, int str
1845 1894
1846 if (fl && !xfrm_selector_match(&dst->xfrm->sel, fl, family)) 1895 if (fl && !xfrm_selector_match(&dst->xfrm->sel, fl, family))
1847 return 0; 1896 return 0;
1848 if (fl && !security_xfrm_flow_state_match(fl, dst->xfrm)) 1897 if (fl && !security_xfrm_flow_state_match(fl, dst->xfrm, pol))
1849 return 0; 1898 return 0;
1850 if (dst->xfrm->km.state != XFRM_STATE_VALID) 1899 if (dst->xfrm->km.state != XFRM_STATE_VALID)
1851 return 0; 1900 return 0;
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 39b8bf3a9ded..899de9ed22a6 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -505,6 +505,14 @@ __xfrm_state_locate(struct xfrm_state *x, int use_spi, int family)
505 x->id.proto, family); 505 x->id.proto, family);
506} 506}
507 507
508static void xfrm_hash_grow_check(int have_hash_collision)
509{
510 if (have_hash_collision &&
511 (xfrm_state_hmask + 1) < xfrm_state_hashmax &&
512 xfrm_state_num > xfrm_state_hmask)
513 schedule_work(&xfrm_hash_work);
514}
515
508struct xfrm_state * 516struct xfrm_state *
509xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr, 517xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr,
510 struct flowi *fl, struct xfrm_tmpl *tmpl, 518 struct flowi *fl, struct xfrm_tmpl *tmpl,
@@ -598,6 +606,8 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr,
598 x->lft.hard_add_expires_seconds = XFRM_ACQ_EXPIRES; 606 x->lft.hard_add_expires_seconds = XFRM_ACQ_EXPIRES;
599 x->timer.expires = jiffies + XFRM_ACQ_EXPIRES*HZ; 607 x->timer.expires = jiffies + XFRM_ACQ_EXPIRES*HZ;
600 add_timer(&x->timer); 608 add_timer(&x->timer);
609 xfrm_state_num++;
610 xfrm_hash_grow_check(x->bydst.next != NULL);
601 } else { 611 } else {
602 x->km.state = XFRM_STATE_DEAD; 612 x->km.state = XFRM_STATE_DEAD;
603 xfrm_state_put(x); 613 xfrm_state_put(x);
@@ -642,10 +652,7 @@ static void __xfrm_state_insert(struct xfrm_state *x)
642 652
643 xfrm_state_num++; 653 xfrm_state_num++;
644 654
645 if (x->bydst.next != NULL && 655 xfrm_hash_grow_check(x->bydst.next != NULL);
646 (xfrm_state_hmask + 1) < xfrm_state_hashmax &&
647 xfrm_state_num > xfrm_state_hmask)
648 schedule_work(&xfrm_hash_work);
649} 656}
650 657
651/* xfrm_state_lock is held */ 658/* xfrm_state_lock is held */
@@ -753,6 +760,10 @@ static struct xfrm_state *__find_acq_core(unsigned short family, u8 mode, u32 re
753 h = xfrm_src_hash(daddr, saddr, family); 760 h = xfrm_src_hash(daddr, saddr, family);
754 hlist_add_head(&x->bysrc, xfrm_state_bysrc+h); 761 hlist_add_head(&x->bysrc, xfrm_state_bysrc+h);
755 wake_up(&km_waitq); 762 wake_up(&km_waitq);
763
764 xfrm_state_num++;
765
766 xfrm_hash_grow_check(x->bydst.next != NULL);
756 } 767 }
757 768
758 return x; 769 return x;
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index d54b3a70d5df..c4cde57d9216 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -323,7 +323,7 @@ static void copy_from_user_state(struct xfrm_state *x, struct xfrm_usersa_info *
323 x->props.replay_window = p->replay_window; 323 x->props.replay_window = p->replay_window;
324 x->props.reqid = p->reqid; 324 x->props.reqid = p->reqid;
325 x->props.family = p->family; 325 x->props.family = p->family;
326 x->props.saddr = p->saddr; 326 memcpy(&x->props.saddr, &p->saddr, sizeof(x->props.saddr));
327 x->props.flags = p->flags; 327 x->props.flags = p->flags;
328} 328}
329 329
@@ -545,7 +545,7 @@ static void copy_to_user_state(struct xfrm_state *x, struct xfrm_usersa_info *p)
545 memcpy(&p->lft, &x->lft, sizeof(p->lft)); 545 memcpy(&p->lft, &x->lft, sizeof(p->lft));
546 memcpy(&p->curlft, &x->curlft, sizeof(p->curlft)); 546 memcpy(&p->curlft, &x->curlft, sizeof(p->curlft));
547 memcpy(&p->stats, &x->stats, sizeof(p->stats)); 547 memcpy(&p->stats, &x->stats, sizeof(p->stats));
548 p->saddr = x->props.saddr; 548 memcpy(&p->saddr, &x->props.saddr, sizeof(p->saddr));
549 p->mode = x->props.mode; 549 p->mode = x->props.mode;
550 p->replay_window = x->props.replay_window; 550 p->replay_window = x->props.replay_window;
551 p->reqid = x->props.reqid; 551 p->reqid = x->props.reqid;
@@ -1927,6 +1927,9 @@ static int xfrm_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *xt,
1927 len = RTA_SPACE(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr); 1927 len = RTA_SPACE(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr);
1928 len += NLMSG_SPACE(sizeof(struct xfrm_user_acquire)); 1928 len += NLMSG_SPACE(sizeof(struct xfrm_user_acquire));
1929 len += RTA_SPACE(xfrm_user_sec_ctx_size(xp)); 1929 len += RTA_SPACE(xfrm_user_sec_ctx_size(xp));
1930#ifdef CONFIG_XFRM_SUB_POLICY
1931 len += RTA_SPACE(sizeof(struct xfrm_userpolicy_type));
1932#endif
1930 skb = alloc_skb(len, GFP_ATOMIC); 1933 skb = alloc_skb(len, GFP_ATOMIC);
1931 if (skb == NULL) 1934 if (skb == NULL)
1932 return -ENOMEM; 1935 return -ENOMEM;
@@ -1992,15 +1995,6 @@ static struct xfrm_policy *xfrm_compile_policy(struct sock *sk, int opt,
1992 xp->type = XFRM_POLICY_TYPE_MAIN; 1995 xp->type = XFRM_POLICY_TYPE_MAIN;
1993 copy_templates(xp, ut, nr); 1996 copy_templates(xp, ut, nr);
1994 1997
1995 if (!xp->security) {
1996 int err = security_xfrm_sock_policy_alloc(xp, sk);
1997 if (err) {
1998 kfree(xp);
1999 *dir = err;
2000 return NULL;
2001 }
2002 }
2003
2004 *dir = p->dir; 1998 *dir = p->dir;
2005 1999
2006 return xp; 2000 return xp;
@@ -2043,6 +2037,9 @@ static int xfrm_exp_policy_notify(struct xfrm_policy *xp, int dir, struct km_eve
2043 len = RTA_SPACE(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr); 2037 len = RTA_SPACE(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr);
2044 len += NLMSG_SPACE(sizeof(struct xfrm_user_polexpire)); 2038 len += NLMSG_SPACE(sizeof(struct xfrm_user_polexpire));
2045 len += RTA_SPACE(xfrm_user_sec_ctx_size(xp)); 2039 len += RTA_SPACE(xfrm_user_sec_ctx_size(xp));
2040#ifdef CONFIG_XFRM_SUB_POLICY
2041 len += RTA_SPACE(sizeof(struct xfrm_userpolicy_type));
2042#endif
2046 skb = alloc_skb(len, GFP_ATOMIC); 2043 skb = alloc_skb(len, GFP_ATOMIC);
2047 if (skb == NULL) 2044 if (skb == NULL)
2048 return -ENOMEM; 2045 return -ENOMEM;
@@ -2069,6 +2066,9 @@ static int xfrm_notify_policy(struct xfrm_policy *xp, int dir, struct km_event *
2069 len += RTA_SPACE(headlen); 2066 len += RTA_SPACE(headlen);
2070 headlen = sizeof(*id); 2067 headlen = sizeof(*id);
2071 } 2068 }
2069#ifdef CONFIG_XFRM_SUB_POLICY
2070 len += RTA_SPACE(sizeof(struct xfrm_userpolicy_type));
2071#endif
2072 len += NLMSG_SPACE(headlen); 2072 len += NLMSG_SPACE(headlen);
2073 2073
2074 skb = alloc_skb(len, GFP_ATOMIC); 2074 skb = alloc_skb(len, GFP_ATOMIC);
@@ -2115,10 +2115,12 @@ static int xfrm_notify_policy_flush(struct km_event *c)
2115 struct nlmsghdr *nlh; 2115 struct nlmsghdr *nlh;
2116 struct sk_buff *skb; 2116 struct sk_buff *skb;
2117 unsigned char *b; 2117 unsigned char *b;
2118 int len = 0;
2118#ifdef CONFIG_XFRM_SUB_POLICY 2119#ifdef CONFIG_XFRM_SUB_POLICY
2119 struct xfrm_userpolicy_type upt; 2120 struct xfrm_userpolicy_type upt;
2121 len += RTA_SPACE(sizeof(struct xfrm_userpolicy_type));
2120#endif 2122#endif
2121 int len = NLMSG_LENGTH(0); 2123 len += NLMSG_LENGTH(0);
2122 2124
2123 skb = alloc_skb(len, GFP_ATOMIC); 2125 skb = alloc_skb(len, GFP_ATOMIC);
2124 if (skb == NULL) 2126 if (skb == NULL)
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
index 6a026f69b563..4241e0dfeeaf 100644
--- a/scripts/Makefile.headersinst
+++ b/scripts/Makefile.headersinst
@@ -168,7 +168,7 @@ $(objhdr-y) $(header-y) $(unifdef-y): $(KBUILDFILES)
168 $(call cmd,gen) 168 $(call cmd,gen)
169 169
170else 170else
171$(objhdr-y) : $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(KBUILDFILES) 171$(objhdr-y) : $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(objtree)/$(obj)/%.h $(KBUILDFILES)
172 $(call cmd,o_hdr_install) 172 $(call cmd,o_hdr_install)
173 173
174$(header-y) : $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(KBUILDFILES) 174$(header-y) : $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(KBUILDFILES)
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index 6c5469b1473b..65e0a79c36cf 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -44,7 +44,7 @@ include scripts/Kbuild.include
44include scripts/Makefile.lib 44include scripts/Makefile.lib
45 45
46kernelsymfile := $(objtree)/Module.symvers 46kernelsymfile := $(objtree)/Module.symvers
47modulesymfile := $(KBUILD_EXTMOD)/Module.symvers 47modulesymfile := $(firstword $(KBUILD_EXTMOD))/Module.symvers
48 48
49# Step 1), find all modules listed in $(MODVERDIR)/ 49# Step 1), find all modules listed in $(MODVERDIR)/
50__modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod))) 50__modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod)))
diff --git a/scripts/basic/docproc.c b/scripts/basic/docproc.c
index 4ab6cbf09225..d6071cbf13d7 100644
--- a/scripts/basic/docproc.c
+++ b/scripts/basic/docproc.c
@@ -250,7 +250,7 @@ void intfunc(char * filename) { docfunctions(filename, NOFUNCTION); }
250void extfunc(char * filename) { docfunctions(filename, FUNCTION); } 250void extfunc(char * filename) { docfunctions(filename, FUNCTION); }
251 251
252/* 252/*
253 * Document spåecific function(s) in a file. 253 * Document specific function(s) in a file.
254 * Call kernel-doc with the following parameters: 254 * Call kernel-doc with the following parameters:
255 * kernel-doc -docbook -function function1 [-function function2] 255 * kernel-doc -docbook -function function1 [-function function2]
256 */ 256 */
diff --git a/scripts/kconfig/.gitignore b/scripts/kconfig/.gitignore
index e8ad1f6b3da4..b49584c932cc 100644
--- a/scripts/kconfig/.gitignore
+++ b/scripts/kconfig/.gitignore
@@ -6,6 +6,8 @@ lex.*.c
6*.tab.c 6*.tab.c
7*.tab.h 7*.tab.h
8zconf.hash.c 8zconf.hash.c
9*.moc
10lkc_defs.h
9 11
10# 12#
11# configuration programs 13# configuration programs
diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h
index 8dea47f9d3e4..fd695e1070f7 100644
--- a/scripts/kconfig/lxdialog/dialog.h
+++ b/scripts/kconfig/lxdialog/dialog.h
@@ -24,6 +24,7 @@
24#include <ctype.h> 24#include <ctype.h>
25#include <stdlib.h> 25#include <stdlib.h>
26#include <string.h> 26#include <string.h>
27#include <stdbool.h>
27 28
28#ifdef __sun__ 29#ifdef __sun__
29#define CURS_MACROS 30#define CURS_MACROS
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 00d1ad19b2cc..187f5de4612c 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1262,7 +1262,9 @@ sub output_intro_text(%) {
1262} 1262}
1263 1263
1264## 1264##
1265# generic output function for typedefs 1265# generic output function for all types (function, struct/union, typedef, enum);
1266# calls the generated, variable output_ function name based on
1267# functype and output_mode
1266sub output_declaration { 1268sub output_declaration {
1267 no strict 'refs'; 1269 no strict 'refs';
1268 my $name = shift; 1270 my $name = shift;
@@ -1278,8 +1280,7 @@ sub output_declaration {
1278} 1280}
1279 1281
1280## 1282##
1281# generic output function - calls the right one based 1283# generic output function - calls the right one based on current output mode.
1282# on current output mode.
1283sub output_intro { 1284sub output_intro {
1284 no strict 'refs'; 1285 no strict 'refs';
1285 my $func = "output_intro_".$output_mode; 1286 my $func = "output_intro_".$output_mode;
@@ -1518,6 +1519,9 @@ sub dump_function($$) {
1518 $prototype =~ s/^asmlinkage +//; 1519 $prototype =~ s/^asmlinkage +//;
1519 $prototype =~ s/^inline +//; 1520 $prototype =~ s/^inline +//;
1520 $prototype =~ s/^__inline__ +//; 1521 $prototype =~ s/^__inline__ +//;
1522 $prototype =~ s/^__inline +//;
1523 $prototype =~ s/^__always_inline +//;
1524 $prototype =~ s/^noinline +//;
1521 $prototype =~ s/__devinit +//; 1525 $prototype =~ s/__devinit +//;
1522 $prototype =~ s/^#define +//; #ak added 1526 $prototype =~ s/^#define +//; #ak added
1523 $prototype =~ s/__attribute__ \(\([a-z,]*\)\)//; 1527 $prototype =~ s/__attribute__ \(\([a-z,]*\)\)//;
@@ -1778,8 +1782,9 @@ sub process_file($) {
1778 $in_doc_sect = 1; 1782 $in_doc_sect = 1;
1779 $contents = $newcontents; 1783 $contents = $newcontents;
1780 if ($contents ne "") { 1784 if ($contents ne "") {
1781 if (substr($contents, 0, 1) eq " ") { 1785 while ((substr($contents, 0, 1) eq " ") ||
1782 $contents = substr($contents, 1); 1786 substr($contents, 0, 1) eq "\t") {
1787 $contents = substr($contents, 1);
1783 } 1788 }
1784 $contents .= "\n"; 1789 $contents .= "\n";
1785 } 1790 }
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 41277963f47a..2e1141623147 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -921,6 +921,8 @@ static int init_section_ref_ok(const char *name)
921 ".fixup", 921 ".fixup",
922 ".smp_locks", 922 ".smp_locks",
923 ".plt", /* seen on ARCH=um build on x86_64. Harmless */ 923 ".plt", /* seen on ARCH=um build on x86_64. Harmless */
924 "__ftr_fixup", /* powerpc cpu feature fixup */
925 "__fw_ftr_fixup", /* powerpc firmware feature fixup */
924 NULL 926 NULL
925 }; 927 };
926 /* Start of section names */ 928 /* Start of section names */
diff --git a/security/dummy.c b/security/dummy.c
index aeee70565509..43874c1e6e23 100644
--- a/security/dummy.c
+++ b/security/dummy.c
@@ -881,7 +881,8 @@ static int dummy_xfrm_state_pol_flow_match(struct xfrm_state *x,
881 return 1; 881 return 1;
882} 882}
883 883
884static int dummy_xfrm_flow_state_match(struct flowi *fl, struct xfrm_state *xfrm) 884static int dummy_xfrm_flow_state_match(struct flowi *fl, struct xfrm_state *xfrm,
885 struct xfrm_policy *xp)
885{ 886{
886 return 1; 887 return 1;
887} 888}
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index e9969a2fc846..8ab5679a37a3 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3313,7 +3313,13 @@ static int selinux_socket_getpeername(struct socket *sock)
3313 3313
3314static int selinux_socket_setsockopt(struct socket *sock,int level,int optname) 3314static int selinux_socket_setsockopt(struct socket *sock,int level,int optname)
3315{ 3315{
3316 return socket_has_perm(current, sock, SOCKET__SETOPT); 3316 int err;
3317
3318 err = socket_has_perm(current, sock, SOCKET__SETOPT);
3319 if (err)
3320 return err;
3321
3322 return selinux_netlbl_socket_setsockopt(sock, level, optname);
3317} 3323}
3318 3324
3319static int selinux_socket_getsockopt(struct socket *sock, int level, 3325static int selinux_socket_getsockopt(struct socket *sock, int level,
diff --git a/security/selinux/include/selinux_netlabel.h b/security/selinux/include/selinux_netlabel.h
index ecab4bddaaf4..9de10cc2cef2 100644
--- a/security/selinux/include/selinux_netlabel.h
+++ b/security/selinux/include/selinux_netlabel.h
@@ -53,6 +53,9 @@ void selinux_netlbl_sk_security_init(struct sk_security_struct *ssec,
53void selinux_netlbl_sk_clone_security(struct sk_security_struct *ssec, 53void selinux_netlbl_sk_clone_security(struct sk_security_struct *ssec,
54 struct sk_security_struct *newssec); 54 struct sk_security_struct *newssec);
55int selinux_netlbl_inode_permission(struct inode *inode, int mask); 55int selinux_netlbl_inode_permission(struct inode *inode, int mask);
56int selinux_netlbl_socket_setsockopt(struct socket *sock,
57 int level,
58 int optname);
56#else 59#else
57static inline void selinux_netlbl_cache_invalidate(void) 60static inline void selinux_netlbl_cache_invalidate(void)
58{ 61{
@@ -114,6 +117,13 @@ static inline int selinux_netlbl_inode_permission(struct inode *inode,
114{ 117{
115 return 0; 118 return 0;
116} 119}
120
121static inline int selinux_netlbl_socket_setsockopt(struct socket *sock,
122 int level,
123 int optname)
124{
125 return 0;
126}
117#endif /* CONFIG_NETLABEL */ 127#endif /* CONFIG_NETLABEL */
118 128
119#endif 129#endif
diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
index 81eb59890162..526b28019aca 100644
--- a/security/selinux/include/xfrm.h
+++ b/security/selinux/include/xfrm.h
@@ -19,7 +19,8 @@ int selinux_xfrm_state_delete(struct xfrm_state *x);
19int selinux_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir); 19int selinux_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir);
20int selinux_xfrm_state_pol_flow_match(struct xfrm_state *x, 20int selinux_xfrm_state_pol_flow_match(struct xfrm_state *x,
21 struct xfrm_policy *xp, struct flowi *fl); 21 struct xfrm_policy *xp, struct flowi *fl);
22int selinux_xfrm_flow_state_match(struct flowi *fl, struct xfrm_state *xfrm); 22int selinux_xfrm_flow_state_match(struct flowi *fl, struct xfrm_state *xfrm,
23 struct xfrm_policy *xp);
23 24
24 25
25/* 26/*
diff --git a/security/selinux/ss/ebitmap.c b/security/selinux/ss/ebitmap.c
index cfed1d30fa6a..d539346ab3a2 100644
--- a/security/selinux/ss/ebitmap.c
+++ b/security/selinux/ss/ebitmap.c
@@ -93,11 +93,15 @@ int ebitmap_export(const struct ebitmap *src,
93 size_t bitmap_byte; 93 size_t bitmap_byte;
94 unsigned char bitmask; 94 unsigned char bitmask;
95 95
96 if (src->highbit == 0) {
97 *dst = NULL;
98 *dst_len = 0;
99 return 0;
100 }
101
96 bitmap_len = src->highbit / 8; 102 bitmap_len = src->highbit / 8;
97 if (src->highbit % 7) 103 if (src->highbit % 7)
98 bitmap_len += 1; 104 bitmap_len += 1;
99 if (bitmap_len == 0)
100 return -EINVAL;
101 105
102 bitmap = kzalloc((bitmap_len & ~(sizeof(MAPTYPE) - 1)) + 106 bitmap = kzalloc((bitmap_len & ~(sizeof(MAPTYPE) - 1)) +
103 sizeof(MAPTYPE), 107 sizeof(MAPTYPE),
diff --git a/security/selinux/ss/mls.c b/security/selinux/ss/mls.c
index c713af23250a..2cca8e251624 100644
--- a/security/selinux/ss/mls.c
+++ b/security/selinux/ss/mls.c
@@ -640,8 +640,13 @@ int mls_export_cat(const struct context *context,
640{ 640{
641 int rc = -EPERM; 641 int rc = -EPERM;
642 642
643 if (!selinux_mls_enabled) 643 if (!selinux_mls_enabled) {
644 *low = NULL;
645 *low_len = 0;
646 *high = NULL;
647 *high_len = 0;
644 return 0; 648 return 0;
649 }
645 650
646 if (low != NULL) { 651 if (low != NULL) {
647 rc = ebitmap_export(&context->range.level[0].cat, 652 rc = ebitmap_export(&context->range.level[0].cat,
@@ -661,10 +666,16 @@ int mls_export_cat(const struct context *context,
661 return 0; 666 return 0;
662 667
663export_cat_failure: 668export_cat_failure:
664 if (low != NULL) 669 if (low != NULL) {
665 kfree(*low); 670 kfree(*low);
666 if (high != NULL) 671 *low = NULL;
672 *low_len = 0;
673 }
674 if (high != NULL) {
667 kfree(*high); 675 kfree(*high);
676 *high = NULL;
677 *high_len = 0;
678 }
668 return rc; 679 return rc;
669} 680}
670 681
diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
index b18895302555..ba48961f9d05 100644
--- a/security/selinux/ss/policydb.c
+++ b/security/selinux/ss/policydb.c
@@ -618,6 +618,7 @@ void policydb_destroy(struct policydb *p)
618 c = c->next; 618 c = c->next;
619 ocontext_destroy(ctmp,i); 619 ocontext_destroy(ctmp,i);
620 } 620 }
621 p->ocontexts[i] = NULL;
621 } 622 }
622 623
623 g = p->genfs; 624 g = p->genfs;
@@ -633,6 +634,7 @@ void policydb_destroy(struct policydb *p)
633 g = g->next; 634 g = g->next;
634 kfree(gtmp); 635 kfree(gtmp);
635 } 636 }
637 p->genfs = NULL;
636 638
637 cond_policydb_destroy(p); 639 cond_policydb_destroy(p);
638 640
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
index 0c219a1b3243..bfe122764c98 100644
--- a/security/selinux/ss/services.c
+++ b/security/selinux/ss/services.c
@@ -2172,7 +2172,12 @@ struct netlbl_cache {
2172 */ 2172 */
2173static void selinux_netlbl_cache_free(const void *data) 2173static void selinux_netlbl_cache_free(const void *data)
2174{ 2174{
2175 struct netlbl_cache *cache = NETLBL_CACHE(data); 2175 struct netlbl_cache *cache;
2176
2177 if (data == NULL)
2178 return;
2179
2180 cache = NETLBL_CACHE(data);
2176 switch (cache->type) { 2181 switch (cache->type) {
2177 case NETLBL_CACHE_T_MLS: 2182 case NETLBL_CACHE_T_MLS:
2178 ebitmap_destroy(&cache->data.mls_label.level[0].cat); 2183 ebitmap_destroy(&cache->data.mls_label.level[0].cat);
@@ -2197,17 +2202,20 @@ static void selinux_netlbl_cache_add(struct sk_buff *skb, struct context *ctx)
2197 struct netlbl_lsm_secattr secattr; 2202 struct netlbl_lsm_secattr secattr;
2198 2203
2199 netlbl_secattr_init(&secattr); 2204 netlbl_secattr_init(&secattr);
2205 secattr.cache = netlbl_secattr_cache_alloc(GFP_ATOMIC);
2206 if (secattr.cache == NULL)
2207 goto netlbl_cache_add_return;
2200 2208
2201 cache = kzalloc(sizeof(*cache), GFP_ATOMIC); 2209 cache = kzalloc(sizeof(*cache), GFP_ATOMIC);
2202 if (cache == NULL) 2210 if (cache == NULL)
2203 goto netlbl_cache_add_failure; 2211 goto netlbl_cache_add_return;
2204 secattr.cache.free = selinux_netlbl_cache_free; 2212 secattr.cache->free = selinux_netlbl_cache_free;
2205 secattr.cache.data = (void *)cache; 2213 secattr.cache->data = (void *)cache;
2206 2214
2207 cache->type = NETLBL_CACHE_T_MLS; 2215 cache->type = NETLBL_CACHE_T_MLS;
2208 if (ebitmap_cpy(&cache->data.mls_label.level[0].cat, 2216 if (ebitmap_cpy(&cache->data.mls_label.level[0].cat,
2209 &ctx->range.level[0].cat) != 0) 2217 &ctx->range.level[0].cat) != 0)
2210 goto netlbl_cache_add_failure; 2218 goto netlbl_cache_add_return;
2211 cache->data.mls_label.level[1].cat.highbit = 2219 cache->data.mls_label.level[1].cat.highbit =
2212 cache->data.mls_label.level[0].cat.highbit; 2220 cache->data.mls_label.level[0].cat.highbit;
2213 cache->data.mls_label.level[1].cat.node = 2221 cache->data.mls_label.level[1].cat.node =
@@ -2215,13 +2223,10 @@ static void selinux_netlbl_cache_add(struct sk_buff *skb, struct context *ctx)
2215 cache->data.mls_label.level[0].sens = ctx->range.level[0].sens; 2223 cache->data.mls_label.level[0].sens = ctx->range.level[0].sens;
2216 cache->data.mls_label.level[1].sens = ctx->range.level[0].sens; 2224 cache->data.mls_label.level[1].sens = ctx->range.level[0].sens;
2217 2225
2218 if (netlbl_cache_add(skb, &secattr) != 0) 2226 netlbl_cache_add(skb, &secattr);
2219 goto netlbl_cache_add_failure;
2220
2221 return;
2222 2227
2223netlbl_cache_add_failure: 2228netlbl_cache_add_return:
2224 netlbl_secattr_destroy(&secattr, 1); 2229 netlbl_secattr_destroy(&secattr);
2225} 2230}
2226 2231
2227/** 2232/**
@@ -2263,8 +2268,8 @@ static int selinux_netlbl_secattr_to_sid(struct sk_buff *skb,
2263 2268
2264 POLICY_RDLOCK; 2269 POLICY_RDLOCK;
2265 2270
2266 if (secattr->cache.data) { 2271 if (secattr->cache) {
2267 cache = NETLBL_CACHE(secattr->cache.data); 2272 cache = NETLBL_CACHE(secattr->cache->data);
2268 switch (cache->type) { 2273 switch (cache->type) {
2269 case NETLBL_CACHE_T_SID: 2274 case NETLBL_CACHE_T_SID:
2270 *sid = cache->data.sid; 2275 *sid = cache->data.sid;
@@ -2331,7 +2336,7 @@ static int selinux_netlbl_secattr_to_sid(struct sk_buff *skb,
2331 selinux_netlbl_cache_add(skb, &ctx_new); 2336 selinux_netlbl_cache_add(skb, &ctx_new);
2332 ebitmap_destroy(&ctx_new.range.level[0].cat); 2337 ebitmap_destroy(&ctx_new.range.level[0].cat);
2333 } else { 2338 } else {
2334 *sid = SECINITSID_UNLABELED; 2339 *sid = SECSID_NULL;
2335 rc = 0; 2340 rc = 0;
2336 } 2341 }
2337 2342
@@ -2369,7 +2374,7 @@ static int selinux_netlbl_skbuff_getsid(struct sk_buff *skb,
2369 &secattr, 2374 &secattr,
2370 base_sid, 2375 base_sid,
2371 sid); 2376 sid);
2372 netlbl_secattr_destroy(&secattr, 0); 2377 netlbl_secattr_destroy(&secattr);
2373 2378
2374 return rc; 2379 return rc;
2375} 2380}
@@ -2394,31 +2399,33 @@ static int selinux_netlbl_socket_setsid(struct socket *sock, u32 sid)
2394 if (!ss_initialized) 2399 if (!ss_initialized)
2395 return 0; 2400 return 0;
2396 2401
2402 netlbl_secattr_init(&secattr);
2403
2397 POLICY_RDLOCK; 2404 POLICY_RDLOCK;
2398 2405
2399 ctx = sidtab_search(&sidtab, sid); 2406 ctx = sidtab_search(&sidtab, sid);
2400 if (ctx == NULL) 2407 if (ctx == NULL)
2401 goto netlbl_socket_setsid_return; 2408 goto netlbl_socket_setsid_return;
2402 2409
2403 netlbl_secattr_init(&secattr);
2404 secattr.domain = kstrdup(policydb.p_type_val_to_name[ctx->type - 1], 2410 secattr.domain = kstrdup(policydb.p_type_val_to_name[ctx->type - 1],
2405 GFP_ATOMIC); 2411 GFP_ATOMIC);
2406 mls_export_lvl(ctx, &secattr.mls_lvl, NULL); 2412 mls_export_lvl(ctx, &secattr.mls_lvl, NULL);
2407 secattr.mls_lvl_vld = 1; 2413 secattr.mls_lvl_vld = 1;
2408 mls_export_cat(ctx, 2414 rc = mls_export_cat(ctx,
2409 &secattr.mls_cat, 2415 &secattr.mls_cat,
2410 &secattr.mls_cat_len, 2416 &secattr.mls_cat_len,
2411 NULL, 2417 NULL,
2412 NULL); 2418 NULL);
2419 if (rc != 0)
2420 goto netlbl_socket_setsid_return;
2413 2421
2414 rc = netlbl_socket_setattr(sock, &secattr); 2422 rc = netlbl_socket_setattr(sock, &secattr);
2415 if (rc == 0) 2423 if (rc == 0)
2416 sksec->nlbl_state = NLBL_LABELED; 2424 sksec->nlbl_state = NLBL_LABELED;
2417 2425
2418 netlbl_secattr_destroy(&secattr, 0);
2419
2420netlbl_socket_setsid_return: 2426netlbl_socket_setsid_return:
2421 POLICY_RDUNLOCK; 2427 POLICY_RDUNLOCK;
2428 netlbl_secattr_destroy(&secattr);
2422 return rc; 2429 return rc;
2423} 2430}
2424 2431
@@ -2514,10 +2521,10 @@ void selinux_netlbl_sock_graft(struct sock *sk, struct socket *sock)
2514 if (netlbl_sock_getattr(sk, &secattr) == 0 && 2521 if (netlbl_sock_getattr(sk, &secattr) == 0 &&
2515 selinux_netlbl_secattr_to_sid(NULL, 2522 selinux_netlbl_secattr_to_sid(NULL,
2516 &secattr, 2523 &secattr,
2517 sksec->sid, 2524 SECINITSID_UNLABELED,
2518 &nlbl_peer_sid) == 0) 2525 &nlbl_peer_sid) == 0)
2519 sksec->peer_sid = nlbl_peer_sid; 2526 sksec->peer_sid = nlbl_peer_sid;
2520 netlbl_secattr_destroy(&secattr, 0); 2527 netlbl_secattr_destroy(&secattr);
2521 2528
2522 sksec->nlbl_state = NLBL_REQUIRE; 2529 sksec->nlbl_state = NLBL_REQUIRE;
2523 2530
@@ -2547,9 +2554,6 @@ u32 selinux_netlbl_inet_conn_request(struct sk_buff *skb, u32 sock_sid)
2547 if (rc != 0) 2554 if (rc != 0)
2548 return SECSID_NULL; 2555 return SECSID_NULL;
2549 2556
2550 if (peer_sid == SECINITSID_UNLABELED)
2551 return SECSID_NULL;
2552
2553 return peer_sid; 2557 return peer_sid;
2554} 2558}
2555 2559
@@ -2611,11 +2615,13 @@ int selinux_netlbl_sock_rcv_skb(struct sk_security_struct *sksec,
2611 u32 netlbl_sid; 2615 u32 netlbl_sid;
2612 u32 recv_perm; 2616 u32 recv_perm;
2613 2617
2614 rc = selinux_netlbl_skbuff_getsid(skb, SECINITSID_NETMSG, &netlbl_sid); 2618 rc = selinux_netlbl_skbuff_getsid(skb,
2619 SECINITSID_UNLABELED,
2620 &netlbl_sid);
2615 if (rc != 0) 2621 if (rc != 0)
2616 return rc; 2622 return rc;
2617 2623
2618 if (netlbl_sid == SECINITSID_UNLABELED) 2624 if (netlbl_sid == SECSID_NULL)
2619 return 0; 2625 return 0;
2620 2626
2621 switch (sksec->sclass) { 2627 switch (sksec->sclass) {
@@ -2653,10 +2659,6 @@ int selinux_netlbl_sock_rcv_skb(struct sk_security_struct *sksec,
2653u32 selinux_netlbl_socket_getpeersec_stream(struct socket *sock) 2659u32 selinux_netlbl_socket_getpeersec_stream(struct socket *sock)
2654{ 2660{
2655 struct sk_security_struct *sksec = sock->sk->sk_security; 2661 struct sk_security_struct *sksec = sock->sk->sk_security;
2656
2657 if (sksec->peer_sid == SECINITSID_UNLABELED)
2658 return SECSID_NULL;
2659
2660 return sksec->peer_sid; 2662 return sksec->peer_sid;
2661} 2663}
2662 2664
@@ -2672,18 +2674,49 @@ u32 selinux_netlbl_socket_getpeersec_stream(struct socket *sock)
2672u32 selinux_netlbl_socket_getpeersec_dgram(struct sk_buff *skb) 2674u32 selinux_netlbl_socket_getpeersec_dgram(struct sk_buff *skb)
2673{ 2675{
2674 int peer_sid; 2676 int peer_sid;
2675 struct sock *sk = skb->sk;
2676 struct inode_security_struct *isec;
2677 2677
2678 if (sk == NULL || sk->sk_socket == NULL) 2678 if (selinux_netlbl_skbuff_getsid(skb,
2679 return SECSID_NULL; 2679 SECINITSID_UNLABELED,
2680 2680 &peer_sid) != 0)
2681 isec = SOCK_INODE(sk->sk_socket)->i_security;
2682 if (selinux_netlbl_skbuff_getsid(skb, isec->sid, &peer_sid) != 0)
2683 return SECSID_NULL;
2684 if (peer_sid == SECINITSID_UNLABELED)
2685 return SECSID_NULL; 2681 return SECSID_NULL;
2686 2682
2687 return peer_sid; 2683 return peer_sid;
2688} 2684}
2685
2686/**
2687 * selinux_netlbl_socket_setsockopt - Do not allow users to remove a NetLabel
2688 * @sock: the socket
2689 * @level: the socket level or protocol
2690 * @optname: the socket option name
2691 *
2692 * Description:
2693 * Check the setsockopt() call and if the user is trying to replace the IP
2694 * options on a socket and a NetLabel is in place for the socket deny the
2695 * access; otherwise allow the access. Returns zero when the access is
2696 * allowed, -EACCES when denied, and other negative values on error.
2697 *
2698 */
2699int selinux_netlbl_socket_setsockopt(struct socket *sock,
2700 int level,
2701 int optname)
2702{
2703 int rc = 0;
2704 struct inode *inode = SOCK_INODE(sock);
2705 struct sk_security_struct *sksec = sock->sk->sk_security;
2706 struct inode_security_struct *isec = inode->i_security;
2707 struct netlbl_lsm_secattr secattr;
2708
2709 mutex_lock(&isec->lock);
2710 if (level == IPPROTO_IP && optname == IP_OPTIONS &&
2711 sksec->nlbl_state == NLBL_LABELED) {
2712 netlbl_secattr_init(&secattr);
2713 rc = netlbl_socket_getattr(sock, &secattr);
2714 if (rc == 0 && (secattr.cache || secattr.mls_lvl_vld))
2715 rc = -EACCES;
2716 netlbl_secattr_destroy(&secattr);
2717 }
2718 mutex_unlock(&isec->lock);
2719
2720 return rc;
2721}
2689#endif /* CONFIG_NETLABEL */ 2722#endif /* CONFIG_NETLABEL */
diff --git a/security/selinux/xfrm.c b/security/selinux/xfrm.c
index 3e742b850af6..675b995a67c3 100644
--- a/security/selinux/xfrm.c
+++ b/security/selinux/xfrm.c
@@ -77,8 +77,8 @@ static inline int selinux_authorizable_xfrm(struct xfrm_state *x)
77 */ 77 */
78int selinux_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir) 78int selinux_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir)
79{ 79{
80 int rc = 0; 80 int rc;
81 u32 sel_sid = SECINITSID_UNLABELED; 81 u32 sel_sid;
82 struct xfrm_sec_ctx *ctx; 82 struct xfrm_sec_ctx *ctx;
83 83
84 /* Context sid is either set to label or ANY_ASSOC */ 84 /* Context sid is either set to label or ANY_ASSOC */
@@ -88,11 +88,21 @@ int selinux_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir)
88 88
89 sel_sid = ctx->ctx_sid; 89 sel_sid = ctx->ctx_sid;
90 } 90 }
91 else
92 /*
93 * All flows should be treated as polmatch'ing an
94 * otherwise applicable "non-labeled" policy. This
95 * would prevent inadvertent "leaks".
96 */
97 return 0;
91 98
92 rc = avc_has_perm(fl_secid, sel_sid, SECCLASS_ASSOCIATION, 99 rc = avc_has_perm(fl_secid, sel_sid, SECCLASS_ASSOCIATION,
93 ASSOCIATION__POLMATCH, 100 ASSOCIATION__POLMATCH,
94 NULL); 101 NULL);
95 102
103 if (rc == -EACCES)
104 rc = -ESRCH;
105
96 return rc; 106 return rc;
97} 107}
98 108
@@ -108,15 +118,20 @@ int selinux_xfrm_state_pol_flow_match(struct xfrm_state *x, struct xfrm_policy *
108 u32 pol_sid; 118 u32 pol_sid;
109 int err; 119 int err;
110 120
111 if (x->security) 121 if (xp->security) {
112 state_sid = x->security->ctx_sid; 122 if (!x->security)
113 else 123 /* unlabeled SA and labeled policy can't match */
114 state_sid = SECINITSID_UNLABELED; 124 return 0;
115 125 else
116 if (xp->security) 126 state_sid = x->security->ctx_sid;
117 pol_sid = xp->security->ctx_sid; 127 pol_sid = xp->security->ctx_sid;
118 else 128 } else
119 pol_sid = SECINITSID_UNLABELED; 129 if (x->security)
130 /* unlabeled policy and labeled SA can't match */
131 return 0;
132 else
133 /* unlabeled policy and unlabeled SA match all flows */
134 return 1;
120 135
121 err = avc_has_perm(state_sid, pol_sid, SECCLASS_ASSOCIATION, 136 err = avc_has_perm(state_sid, pol_sid, SECCLASS_ASSOCIATION,
122 ASSOCIATION__POLMATCH, 137 ASSOCIATION__POLMATCH,
@@ -125,7 +140,11 @@ int selinux_xfrm_state_pol_flow_match(struct xfrm_state *x, struct xfrm_policy *
125 if (err) 140 if (err)
126 return 0; 141 return 0;
127 142
128 return selinux_xfrm_flow_state_match(fl, x); 143 err = avc_has_perm(fl->secid, state_sid, SECCLASS_ASSOCIATION,
144 ASSOCIATION__SENDTO,
145 NULL)? 0:1;
146
147 return err;
129} 148}
130 149
131/* 150/*
@@ -133,12 +152,22 @@ int selinux_xfrm_state_pol_flow_match(struct xfrm_state *x, struct xfrm_policy *
133 * can use a given security association. 152 * can use a given security association.
134 */ 153 */
135 154
136int selinux_xfrm_flow_state_match(struct flowi *fl, struct xfrm_state *xfrm) 155int selinux_xfrm_flow_state_match(struct flowi *fl, struct xfrm_state *xfrm,
156 struct xfrm_policy *xp)
137{ 157{
138 int rc = 0; 158 int rc = 0;
139 u32 sel_sid = SECINITSID_UNLABELED; 159 u32 sel_sid = SECINITSID_UNLABELED;
140 struct xfrm_sec_ctx *ctx; 160 struct xfrm_sec_ctx *ctx;
141 161
162 if (!xp->security)
163 if (!xfrm->security)
164 return 1;
165 else
166 return 0;
167 else
168 if (!xfrm->security)
169 return 0;
170
142 /* Context sid is either set to label or ANY_ASSOC */ 171 /* Context sid is either set to label or ANY_ASSOC */
143 if ((ctx = xfrm->security)) { 172 if ((ctx = xfrm->security)) {
144 if (!selinux_authorizable_ctx(ctx)) 173 if (!selinux_authorizable_ctx(ctx))
diff --git a/sound/core/control.c b/sound/core/control.c
index 6973a9686b67..48ef0a09a7a7 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -1018,10 +1018,6 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file,
1018 } 1018 }
1019 switch (info->type) { 1019 switch (info->type) {
1020 case SNDRV_CTL_ELEM_TYPE_BOOLEAN: 1020 case SNDRV_CTL_ELEM_TYPE_BOOLEAN:
1021 private_size = sizeof(char);
1022 if (info->count > 128)
1023 return -EINVAL;
1024 break;
1025 case SNDRV_CTL_ELEM_TYPE_INTEGER: 1021 case SNDRV_CTL_ELEM_TYPE_INTEGER:
1026 private_size = sizeof(long); 1022 private_size = sizeof(long);
1027 if (info->count > 128) 1023 if (info->count > 128)
diff --git a/sound/core/info.c b/sound/core/info.c
index e43662b33f16..0b4aab3225e5 100644
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -120,7 +120,10 @@ int snd_iprintf(struct snd_info_buffer *buffer, char *fmt,...)
120 len = buffer->len - buffer->size; 120 len = buffer->len - buffer->size;
121 va_start(args, fmt); 121 va_start(args, fmt);
122 for (;;) { 122 for (;;) {
123 res = vsnprintf(buffer->buffer + buffer->curr, len, fmt, args); 123 va_list ap;
124 va_copy(ap, args);
125 res = vsnprintf(buffer->buffer + buffer->curr, len, fmt, ap);
126 va_end(ap);
124 if (res < len) 127 if (res < len)
125 break; 128 break;
126 err = resize_info_buffer(buffer, buffer->len + PAGE_SIZE); 129 err = resize_info_buffer(buffer, buffer->len + PAGE_SIZE);
diff --git a/sound/isa/Kconfig b/sound/isa/Kconfig
index 557c4de22960..57371f1a441f 100644
--- a/sound/isa/Kconfig
+++ b/sound/isa/Kconfig
@@ -13,6 +13,7 @@ config SND_CS4231_LIB
13 13
14config SND_ADLIB 14config SND_ADLIB
15 tristate "AdLib FM card" 15 tristate "AdLib FM card"
16 depends on SND
16 select SND_OPL3_LIB 17 select SND_OPL3_LIB
17 help 18 help
18 Say Y here to include support for AdLib FM cards. 19 Say Y here to include support for AdLib FM cards.
diff --git a/sound/isa/ad1816a/ad1816a.c b/sound/isa/ad1816a/ad1816a.c
index b33a5fb59ec2..59034507175b 100644
--- a/sound/isa/ad1816a/ad1816a.c
+++ b/sound/isa/ad1816a/ad1816a.c
@@ -120,6 +120,8 @@ static int __devinit snd_card_ad1816a_pnp(int dev, struct snd_card_ad1816a *acar
120 struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); 120 struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL);
121 int err; 121 int err;
122 122
123 if (!cfg)
124 return -ENOMEM;
123 acard->dev = pnp_request_card_device(card, id->devs[0].id, NULL); 125 acard->dev = pnp_request_card_device(card, id->devs[0].id, NULL);
124 if (acard->dev == NULL) { 126 if (acard->dev == NULL) {
125 kfree(cfg); 127 kfree(cfg);
diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c
index 3c1e9fd56fe0..d1f6dfcec46e 100644
--- a/sound/isa/cmi8330.c
+++ b/sound/isa/cmi8330.c
@@ -289,6 +289,8 @@ static int __devinit snd_cmi8330_pnp(int dev, struct snd_cmi8330 *acard,
289 struct pnp_resource_table * cfg = kmalloc(sizeof(struct pnp_resource_table), GFP_KERNEL); 289 struct pnp_resource_table * cfg = kmalloc(sizeof(struct pnp_resource_table), GFP_KERNEL);
290 int err; 290 int err;
291 291
292 if (!cfg)
293 return -ENOMEM;
292 acard->cap = pnp_request_card_device(card, id->devs[0].id, NULL); 294 acard->cap = pnp_request_card_device(card, id->devs[0].id, NULL);
293 if (acard->cap == NULL) { 295 if (acard->cap == NULL) {
294 kfree(cfg); 296 kfree(cfg);
diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c
index f12cd09d1fcc..4ec2d79431fc 100644
--- a/sound/isa/gus/interwave.c
+++ b/sound/isa/gus/interwave.c
@@ -564,6 +564,8 @@ static int __devinit snd_interwave_pnp(int dev, struct snd_interwave *iwcard,
564 struct pnp_resource_table * cfg = kmalloc(sizeof(struct pnp_resource_table), GFP_KERNEL); 564 struct pnp_resource_table * cfg = kmalloc(sizeof(struct pnp_resource_table), GFP_KERNEL);
565 int err; 565 int err;
566 566
567 if (!cfg)
568 return -ENOMEM;
567 iwcard->dev = pnp_request_card_device(card, id->devs[0].id, NULL); 569 iwcard->dev = pnp_request_card_device(card, id->devs[0].id, NULL);
568 if (iwcard->dev == NULL) { 570 if (iwcard->dev == NULL) {
569 kfree(cfg); 571 kfree(cfg);
diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c
index a1ad39a8cdce..df227377c333 100644
--- a/sound/isa/opti9xx/opti92x-ad1848.c
+++ b/sound/isa/opti9xx/opti92x-ad1848.c
@@ -1683,6 +1683,8 @@ static int __init snd_card_opti9xx_pnp(struct snd_opti9xx *chip, struct pnp_card
1683 struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); 1683 struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL);
1684 int err; 1684 int err;
1685 1685
1686 if (!cfg)
1687 return -ENOMEM;
1686 chip->dev = pnp_request_card_device(card, pid->devs[0].id, NULL); 1688 chip->dev = pnp_request_card_device(card, pid->devs[0].id, NULL);
1687 if (chip->dev == NULL) { 1689 if (chip->dev == NULL) {
1688 kfree(cfg); 1690 kfree(cfg);
diff --git a/sound/oss/sh_dac_audio.c b/sound/oss/sh_dac_audio.c
index 3b3b4da8cfd3..51f554154c48 100644
--- a/sound/oss/sh_dac_audio.c
+++ b/sound/oss/sh_dac_audio.c
@@ -26,7 +26,7 @@
26#include <asm/cpu/dac.h> 26#include <asm/cpu/dac.h>
27#include <asm/cpu/timer.h> 27#include <asm/cpu/timer.h>
28#include <asm/machvec.h> 28#include <asm/machvec.h>
29#include <asm/hp6xx/hp6xx.h> 29#include <asm/hp6xx.h>
30#include <asm/hd64461.h> 30#include <asm/hd64461.h>
31 31
32#define MODNAME "sh_dac_audio" 32#define MODNAME "sh_dac_audio"
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
index a79e91850ba3..6577b2325357 100644
--- a/sound/pci/ac97/ac97_codec.c
+++ b/sound/pci/ac97/ac97_codec.c
@@ -570,8 +570,7 @@ int snd_ac97_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value
570 ac97->power_up &= ~(1 << (reg>>1)); 570 ac97->power_up &= ~(1 << (reg>>1));
571 else 571 else
572 ac97->power_up |= 1 << (reg>>1); 572 ac97->power_up |= 1 << (reg>>1);
573 if (power_save) 573 update_power_regs(ac97);
574 update_power_regs(ac97);
575 } 574 }
576#endif 575#endif
577 return err; 576 return err;
@@ -2337,10 +2336,7 @@ int snd_ac97_update_power(struct snd_ac97 *ac97, int reg, int powerup)
2337 } 2336 }
2338 } 2337 }
2339 2338
2340 if (! power_save) 2339 if (power_save && !powerup && ac97->power_workq)
2341 return 0;
2342
2343 if (! powerup && ac97->power_workq)
2344 /* adjust power-down bits after two seconds delay 2340 /* adjust power-down bits after two seconds delay
2345 * (for avoiding loud click noises for many (OSS) apps 2341 * (for avoiding loud click noises for many (OSS) apps
2346 * that open/close frequently) 2342 * that open/close frequently)
diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c
index 13a8cefa7749..a7edd56542d4 100644
--- a/sound/pci/ali5451/ali5451.c
+++ b/sound/pci/ali5451/ali5451.c
@@ -2032,8 +2032,10 @@ static int ali_suspend(struct pci_dev *pci, pm_message_t state)
2032 outl(0xffffffff, ALI_REG(chip, ALI_STOP)); 2032 outl(0xffffffff, ALI_REG(chip, ALI_STOP));
2033 2033
2034 spin_unlock_irq(&chip->reg_lock); 2034 spin_unlock_irq(&chip->reg_lock);
2035
2035 pci_disable_device(pci); 2036 pci_disable_device(pci);
2036 pci_save_state(pci); 2037 pci_save_state(pci);
2038 pci_set_power_state(pci, pci_choose_state(pci, state));
2037 return 0; 2039 return 0;
2038} 2040}
2039 2041
@@ -2048,8 +2050,15 @@ static int ali_resume(struct pci_dev *pci)
2048 if (! im) 2050 if (! im)
2049 return 0; 2051 return 0;
2050 2052
2053 pci_set_power_state(pci, PCI_D0);
2051 pci_restore_state(pci); 2054 pci_restore_state(pci);
2052 pci_enable_device(pci); 2055 if (pci_enable_device(pci) < 0) {
2056 printk(KERN_ERR "ali5451: pci_enable_device failed, "
2057 "disabling device\n");
2058 snd_card_disconnect(card);
2059 return -EIO;
2060 }
2061 pci_set_master(pci);
2053 2062
2054 spin_lock_irq(&chip->reg_lock); 2063 spin_lock_irq(&chip->reg_lock);
2055 2064
diff --git a/sound/pci/als300.c b/sound/pci/als300.c
index 9b16c299f0a9..95f70f3cc37e 100644
--- a/sound/pci/als300.c
+++ b/sound/pci/als300.c
@@ -768,9 +768,9 @@ static int snd_als300_suspend(struct pci_dev *pci, pm_message_t state)
768 snd_pcm_suspend_all(chip->pcm); 768 snd_pcm_suspend_all(chip->pcm);
769 snd_ac97_suspend(chip->ac97); 769 snd_ac97_suspend(chip->ac97);
770 770
771 pci_set_power_state(pci, PCI_D3hot);
772 pci_disable_device(pci); 771 pci_disable_device(pci);
773 pci_save_state(pci); 772 pci_save_state(pci);
773 pci_set_power_state(pci, pci_choose_state(pci, state));
774 return 0; 774 return 0;
775} 775}
776 776
@@ -779,9 +779,14 @@ static int snd_als300_resume(struct pci_dev *pci)
779 struct snd_card *card = pci_get_drvdata(pci); 779 struct snd_card *card = pci_get_drvdata(pci);
780 struct snd_als300 *chip = card->private_data; 780 struct snd_als300 *chip = card->private_data;
781 781
782 pci_restore_state(pci);
783 pci_enable_device(pci);
784 pci_set_power_state(pci, PCI_D0); 782 pci_set_power_state(pci, PCI_D0);
783 pci_restore_state(pci);
784 if (pci_enable_device(pci) < 0) {
785 printk(KERN_ERR "als300: pci_enable_device failed, "
786 "disabling device\n");
787 snd_card_disconnect(card);
788 return -EIO;
789 }
785 pci_set_master(pci); 790 pci_set_master(pci);
786 791
787 snd_als300_init(chip); 792 snd_als300_init(chip);
diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c
index 15fc3929b5f7..8fb55d3b454b 100644
--- a/sound/pci/als4000.c
+++ b/sound/pci/als4000.c
@@ -804,9 +804,9 @@ static int snd_als4000_suspend(struct pci_dev *pci, pm_message_t state)
804 snd_pcm_suspend_all(chip->pcm); 804 snd_pcm_suspend_all(chip->pcm);
805 snd_sbmixer_suspend(chip); 805 snd_sbmixer_suspend(chip);
806 806
807 pci_set_power_state(pci, PCI_D3hot);
808 pci_disable_device(pci); 807 pci_disable_device(pci);
809 pci_save_state(pci); 808 pci_save_state(pci);
809 pci_set_power_state(pci, pci_choose_state(pci, state));
810 return 0; 810 return 0;
811} 811}
812 812
@@ -816,9 +816,14 @@ static int snd_als4000_resume(struct pci_dev *pci)
816 struct snd_card_als4000 *acard = card->private_data; 816 struct snd_card_als4000 *acard = card->private_data;
817 struct snd_sb *chip = acard->chip; 817 struct snd_sb *chip = acard->chip;
818 818
819 pci_restore_state(pci);
820 pci_enable_device(pci);
821 pci_set_power_state(pci, PCI_D0); 819 pci_set_power_state(pci, PCI_D0);
820 pci_restore_state(pci);
821 if (pci_enable_device(pci) < 0) {
822 printk(KERN_ERR "als4000: pci_enable_device failed, "
823 "disabling device\n");
824 snd_card_disconnect(card);
825 return -EIO;
826 }
822 pci_set_master(pci); 827 pci_set_master(pci);
823 828
824 snd_als4000_configure(chip); 829 snd_als4000_configure(chip);
diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c
index 3e8fc5a0006a..e3e99f396711 100644
--- a/sound/pci/atiixp.c
+++ b/sound/pci/atiixp.c
@@ -1442,9 +1442,9 @@ static int snd_atiixp_suspend(struct pci_dev *pci, pm_message_t state)
1442 snd_atiixp_aclink_down(chip); 1442 snd_atiixp_aclink_down(chip);
1443 snd_atiixp_chip_stop(chip); 1443 snd_atiixp_chip_stop(chip);
1444 1444
1445 pci_set_power_state(pci, PCI_D3hot);
1446 pci_disable_device(pci); 1445 pci_disable_device(pci);
1447 pci_save_state(pci); 1446 pci_save_state(pci);
1447 pci_set_power_state(pci, pci_choose_state(pci, state));
1448 return 0; 1448 return 0;
1449} 1449}
1450 1450
@@ -1454,9 +1454,14 @@ static int snd_atiixp_resume(struct pci_dev *pci)
1454 struct atiixp *chip = card->private_data; 1454 struct atiixp *chip = card->private_data;
1455 int i; 1455 int i;
1456 1456
1457 pci_restore_state(pci);
1458 pci_enable_device(pci);
1459 pci_set_power_state(pci, PCI_D0); 1457 pci_set_power_state(pci, PCI_D0);
1458 pci_restore_state(pci);
1459 if (pci_enable_device(pci) < 0) {
1460 printk(KERN_ERR "atiixp: pci_enable_device failed, "
1461 "disabling device\n");
1462 snd_card_disconnect(card);
1463 return -EIO;
1464 }
1460 pci_set_master(pci); 1465 pci_set_master(pci);
1461 1466
1462 snd_atiixp_aclink_reset(chip); 1467 snd_atiixp_aclink_reset(chip);
diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c
index c5dda1bf3d46..dc54f2c68ed7 100644
--- a/sound/pci/atiixp_modem.c
+++ b/sound/pci/atiixp_modem.c
@@ -1128,9 +1128,9 @@ static int snd_atiixp_suspend(struct pci_dev *pci, pm_message_t state)
1128 snd_atiixp_aclink_down(chip); 1128 snd_atiixp_aclink_down(chip);
1129 snd_atiixp_chip_stop(chip); 1129 snd_atiixp_chip_stop(chip);
1130 1130
1131 pci_set_power_state(pci, PCI_D3hot);
1132 pci_disable_device(pci); 1131 pci_disable_device(pci);
1133 pci_save_state(pci); 1132 pci_save_state(pci);
1133 pci_set_power_state(pci, pci_choose_state(pci, state));
1134 return 0; 1134 return 0;
1135} 1135}
1136 1136
@@ -1140,9 +1140,14 @@ static int snd_atiixp_resume(struct pci_dev *pci)
1140 struct atiixp_modem *chip = card->private_data; 1140 struct atiixp_modem *chip = card->private_data;
1141 int i; 1141 int i;
1142 1142
1143 pci_restore_state(pci);
1144 pci_enable_device(pci);
1145 pci_set_power_state(pci, PCI_D0); 1143 pci_set_power_state(pci, PCI_D0);
1144 pci_restore_state(pci);
1145 if (pci_enable_device(pci) < 0) {
1146 printk(KERN_ERR "atiixp-modem: pci_enable_device failed, "
1147 "disabling device\n");
1148 snd_card_disconnect(card);
1149 return -EIO;
1150 }
1146 pci_set_master(pci); 1151 pci_set_master(pci);
1147 1152
1148 snd_atiixp_aclink_reset(chip); 1153 snd_atiixp_aclink_reset(chip);
diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c
index 692f203d65d8..2414ee630756 100644
--- a/sound/pci/azt3328.c
+++ b/sound/pci/azt3328.c
@@ -1903,9 +1903,9 @@ snd_azf3328_suspend(struct pci_dev *pci, pm_message_t state)
1903 for (reg = 0; reg < AZF_IO_SIZE_SYNTH_PM / 2; reg++) 1903 for (reg = 0; reg < AZF_IO_SIZE_SYNTH_PM / 2; reg++)
1904 chip->saved_regs_synth[reg] = inw(chip->synth_port + reg * 2); 1904 chip->saved_regs_synth[reg] = inw(chip->synth_port + reg * 2);
1905 1905
1906 pci_set_power_state(pci, PCI_D3hot);
1907 pci_disable_device(pci); 1906 pci_disable_device(pci);
1908 pci_save_state(pci); 1907 pci_save_state(pci);
1908 pci_set_power_state(pci, pci_choose_state(pci, state));
1909 return 0; 1909 return 0;
1910} 1910}
1911 1911
@@ -1916,9 +1916,14 @@ snd_azf3328_resume(struct pci_dev *pci)
1916 struct snd_azf3328 *chip = card->private_data; 1916 struct snd_azf3328 *chip = card->private_data;
1917 int reg; 1917 int reg;
1918 1918
1919 pci_restore_state(pci);
1920 pci_enable_device(pci);
1921 pci_set_power_state(pci, PCI_D0); 1919 pci_set_power_state(pci, PCI_D0);
1920 pci_restore_state(pci);
1921 if (pci_enable_device(pci) < 0) {
1922 printk(KERN_ERR "azt3328: pci_enable_device failed, "
1923 "disabling device\n");
1924 snd_card_disconnect(card);
1925 return -EIO;
1926 }
1922 pci_set_master(pci); 1927 pci_set_master(pci);
1923 1928
1924 for (reg = 0; reg < AZF_IO_SIZE_IO2_PM / 2; reg++) 1929 for (reg = 0; reg < AZF_IO_SIZE_IO2_PM / 2; reg++)
diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c
index 1f7e71083069..0093cd1f92db 100644
--- a/sound/pci/cmipci.c
+++ b/sound/pci/cmipci.c
@@ -3122,9 +3122,9 @@ static int snd_cmipci_suspend(struct pci_dev *pci, pm_message_t state)
3122 /* disable ints */ 3122 /* disable ints */
3123 snd_cmipci_write(cm, CM_REG_INT_HLDCLR, 0); 3123 snd_cmipci_write(cm, CM_REG_INT_HLDCLR, 0);
3124 3124
3125 pci_set_power_state(pci, PCI_D3hot);
3126 pci_disable_device(pci); 3125 pci_disable_device(pci);
3127 pci_save_state(pci); 3126 pci_save_state(pci);
3127 pci_set_power_state(pci, pci_choose_state(pci, state));
3128 return 0; 3128 return 0;
3129} 3129}
3130 3130
@@ -3134,9 +3134,14 @@ static int snd_cmipci_resume(struct pci_dev *pci)
3134 struct cmipci *cm = card->private_data; 3134 struct cmipci *cm = card->private_data;
3135 int i; 3135 int i;
3136 3136
3137 pci_restore_state(pci);
3138 pci_enable_device(pci);
3139 pci_set_power_state(pci, PCI_D0); 3137 pci_set_power_state(pci, PCI_D0);
3138 pci_restore_state(pci);
3139 if (pci_enable_device(pci) < 0) {
3140 printk(KERN_ERR "cmipci: pci_enable_device failed, "
3141 "disabling device\n");
3142 snd_card_disconnect(card);
3143 return -EIO;
3144 }
3140 pci_set_master(pci); 3145 pci_set_master(pci);
3141 3146
3142 /* reset / initialize to a sane state */ 3147 /* reset / initialize to a sane state */
diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c
index d54924e60bb1..0905fa88129d 100644
--- a/sound/pci/cs4281.c
+++ b/sound/pci/cs4281.c
@@ -2050,6 +2050,7 @@ static int cs4281_suspend(struct pci_dev *pci, pm_message_t state)
2050 2050
2051 pci_disable_device(pci); 2051 pci_disable_device(pci);
2052 pci_save_state(pci); 2052 pci_save_state(pci);
2053 pci_set_power_state(pci, pci_choose_state(pci, state));
2053 return 0; 2054 return 0;
2054} 2055}
2055 2056
@@ -2060,8 +2061,14 @@ static int cs4281_resume(struct pci_dev *pci)
2060 unsigned int i; 2061 unsigned int i;
2061 u32 ulCLK; 2062 u32 ulCLK;
2062 2063
2064 pci_set_power_state(pci, PCI_D0);
2063 pci_restore_state(pci); 2065 pci_restore_state(pci);
2064 pci_enable_device(pci); 2066 if (pci_enable_device(pci) < 0) {
2067 printk(KERN_ERR "cs4281: pci_enable_device failed, "
2068 "disabling device\n");
2069 snd_card_disconnect(card);
2070 return -EIO;
2071 }
2065 pci_set_master(pci); 2072 pci_set_master(pci);
2066 2073
2067 ulCLK = snd_cs4281_peekBA0(chip, BA0_CLKCR1); 2074 ulCLK = snd_cs4281_peekBA0(chip, BA0_CLKCR1);
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
index 16d4ebf2a33f..2807b9756ef0 100644
--- a/sound/pci/cs46xx/cs46xx_lib.c
+++ b/sound/pci/cs46xx/cs46xx_lib.c
@@ -3687,8 +3687,10 @@ int snd_cs46xx_suspend(struct pci_dev *pci, pm_message_t state)
3687 /* disable CLKRUN */ 3687 /* disable CLKRUN */
3688 chip->active_ctrl(chip, -chip->amplifier); 3688 chip->active_ctrl(chip, -chip->amplifier);
3689 chip->amplifier = amp_saved; /* restore the status */ 3689 chip->amplifier = amp_saved; /* restore the status */
3690
3690 pci_disable_device(pci); 3691 pci_disable_device(pci);
3691 pci_save_state(pci); 3692 pci_save_state(pci);
3693 pci_set_power_state(pci, pci_choose_state(pci, state));
3692 return 0; 3694 return 0;
3693} 3695}
3694 3696
@@ -3698,9 +3700,16 @@ int snd_cs46xx_resume(struct pci_dev *pci)
3698 struct snd_cs46xx *chip = card->private_data; 3700 struct snd_cs46xx *chip = card->private_data;
3699 int amp_saved; 3701 int amp_saved;
3700 3702
3703 pci_set_power_state(pci, PCI_D0);
3701 pci_restore_state(pci); 3704 pci_restore_state(pci);
3702 pci_enable_device(pci); 3705 if (pci_enable_device(pci) < 0) {
3706 printk(KERN_ERR "cs46xx: pci_enable_device failed, "
3707 "disabling device\n");
3708 snd_card_disconnect(card);
3709 return -EIO;
3710 }
3703 pci_set_master(pci); 3711 pci_set_master(pci);
3712
3704 amp_saved = chip->amplifier; 3713 amp_saved = chip->amplifier;
3705 chip->amplifier = 0; 3714 chip->amplifier = 0;
3706 chip->active_ctrl(chip, 1); /* force to on */ 3715 chip->active_ctrl(chip, 1); /* force to on */
diff --git a/sound/pci/cs5535audio/cs5535audio_pm.c b/sound/pci/cs5535audio/cs5535audio_pm.c
index aad0e69db9c1..3e4d198a4502 100644
--- a/sound/pci/cs5535audio/cs5535audio_pm.c
+++ b/sound/pci/cs5535audio/cs5535audio_pm.c
@@ -73,9 +73,10 @@ int snd_cs5535audio_suspend(struct pci_dev *pci, pm_message_t state)
73 snd_ac97_suspend(cs5535au->ac97); 73 snd_ac97_suspend(cs5535au->ac97);
74 /* save important regs, then disable aclink in hw */ 74 /* save important regs, then disable aclink in hw */
75 snd_cs5535audio_stop_hardware(cs5535au); 75 snd_cs5535audio_stop_hardware(cs5535au);
76
76 pci_disable_device(pci); 77 pci_disable_device(pci);
77 pci_save_state(pci); 78 pci_save_state(pci);
78 79 pci_set_power_state(pci, pci_choose_state(pci, state));
79 return 0; 80 return 0;
80} 81}
81 82
@@ -87,8 +88,14 @@ int snd_cs5535audio_resume(struct pci_dev *pci)
87 int timeout; 88 int timeout;
88 int i; 89 int i;
89 90
91 pci_set_power_state(pci, PCI_D0);
90 pci_restore_state(pci); 92 pci_restore_state(pci);
91 pci_enable_device(pci); 93 if (pci_enable_device(pci) < 0) {
94 printk(KERN_ERR "cs5535audio: pci_enable_device failed, "
95 "disabling device\n");
96 snd_card_disconnect(card);
97 return -EIO;
98 }
92 pci_set_master(pci); 99 pci_set_master(pci);
93 100
94 /* set LNK_WRM_RST to reset AC link */ 101 /* set LNK_WRM_RST to reset AC link */
diff --git a/sound/pci/emu10k1/emu10k1.c b/sound/pci/emu10k1/emu10k1.c
index 493ec0816bb3..55caf341933a 100644
--- a/sound/pci/emu10k1/emu10k1.c
+++ b/sound/pci/emu10k1/emu10k1.c
@@ -226,9 +226,9 @@ static int snd_emu10k1_suspend(struct pci_dev *pci, pm_message_t state)
226 226
227 snd_emu10k1_done(emu); 227 snd_emu10k1_done(emu);
228 228
229 pci_set_power_state(pci, PCI_D3hot);
230 pci_disable_device(pci); 229 pci_disable_device(pci);
231 pci_save_state(pci); 230 pci_save_state(pci);
231 pci_set_power_state(pci, pci_choose_state(pci, state));
232 return 0; 232 return 0;
233} 233}
234 234
@@ -237,11 +237,16 @@ static int snd_emu10k1_resume(struct pci_dev *pci)
237 struct snd_card *card = pci_get_drvdata(pci); 237 struct snd_card *card = pci_get_drvdata(pci);
238 struct snd_emu10k1 *emu = card->private_data; 238 struct snd_emu10k1 *emu = card->private_data;
239 239
240 pci_restore_state(pci);
241 pci_enable_device(pci);
242 pci_set_power_state(pci, PCI_D0); 240 pci_set_power_state(pci, PCI_D0);
241 pci_restore_state(pci);
242 if (pci_enable_device(pci) < 0) {
243 printk(KERN_ERR "emu10k1: pci_enable_device failed, "
244 "disabling device\n");
245 snd_card_disconnect(card);
246 return -EIO;
247 }
243 pci_set_master(pci); 248 pci_set_master(pci);
244 249
245 snd_emu10k1_resume_init(emu); 250 snd_emu10k1_resume_init(emu);
246 snd_emu10k1_efx_resume(emu); 251 snd_emu10k1_efx_resume(emu);
247 snd_ac97_resume(emu->ac97); 252 snd_ac97_resume(emu->ac97);
diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c
index 8cb4fb2412db..d2a811f222c9 100644
--- a/sound/pci/ens1370.c
+++ b/sound/pci/ens1370.c
@@ -2072,9 +2072,10 @@ static int snd_ensoniq_suspend(struct pci_dev *pci, pm_message_t state)
2072 udelay(100); 2072 udelay(100);
2073 snd_ak4531_suspend(ensoniq->u.es1370.ak4531); 2073 snd_ak4531_suspend(ensoniq->u.es1370.ak4531);
2074#endif 2074#endif
2075 pci_set_power_state(pci, PCI_D3hot); 2075
2076 pci_disable_device(pci); 2076 pci_disable_device(pci);
2077 pci_save_state(pci); 2077 pci_save_state(pci);
2078 pci_set_power_state(pci, pci_choose_state(pci, state));
2078 return 0; 2079 return 0;
2079} 2080}
2080 2081
@@ -2083,9 +2084,14 @@ static int snd_ensoniq_resume(struct pci_dev *pci)
2083 struct snd_card *card = pci_get_drvdata(pci); 2084 struct snd_card *card = pci_get_drvdata(pci);
2084 struct ensoniq *ensoniq = card->private_data; 2085 struct ensoniq *ensoniq = card->private_data;
2085 2086
2086 pci_restore_state(pci);
2087 pci_enable_device(pci);
2088 pci_set_power_state(pci, PCI_D0); 2087 pci_set_power_state(pci, PCI_D0);
2088 pci_restore_state(pci);
2089 if (pci_enable_device(pci) < 0) {
2090 printk(KERN_ERR DRIVER_NAME ": pci_enable_device failed, "
2091 "disabling device\n");
2092 snd_card_disconnect(card);
2093 return -EIO;
2094 }
2089 pci_set_master(pci); 2095 pci_set_master(pci);
2090 2096
2091 snd_ensoniq_chip_init(ensoniq); 2097 snd_ensoniq_chip_init(ensoniq);
diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c
index 2da988f78ba7..1a8d36df4b5d 100644
--- a/sound/pci/es1938.c
+++ b/sound/pci/es1938.c
@@ -1481,10 +1481,14 @@ static int es1938_suspend(struct pci_dev *pci, pm_message_t state)
1481 *d = snd_es1938_reg_read(chip, *s); 1481 *d = snd_es1938_reg_read(chip, *s);
1482 1482
1483 outb(0x00, SLIO_REG(chip, IRQCONTROL)); /* disable irqs */ 1483 outb(0x00, SLIO_REG(chip, IRQCONTROL)); /* disable irqs */
1484 if (chip->irq >= 0) 1484 if (chip->irq >= 0) {
1485 synchronize_irq(chip->irq);
1485 free_irq(chip->irq, chip); 1486 free_irq(chip->irq, chip);
1487 chip->irq = -1;
1488 }
1486 pci_disable_device(pci); 1489 pci_disable_device(pci);
1487 pci_save_state(pci); 1490 pci_save_state(pci);
1491 pci_set_power_state(pci, pci_choose_state(pci, state));
1488 return 0; 1492 return 0;
1489} 1493}
1490 1494
@@ -1494,10 +1498,22 @@ static int es1938_resume(struct pci_dev *pci)
1494 struct es1938 *chip = card->private_data; 1498 struct es1938 *chip = card->private_data;
1495 unsigned char *s, *d; 1499 unsigned char *s, *d;
1496 1500
1501 pci_set_power_state(pci, PCI_D0);
1497 pci_restore_state(pci); 1502 pci_restore_state(pci);
1498 pci_enable_device(pci); 1503 if (pci_enable_device(pci) < 0) {
1499 request_irq(pci->irq, snd_es1938_interrupt, 1504 printk(KERN_ERR "es1938: pci_enable_device failed, "
1500 IRQF_DISABLED|IRQF_SHARED, "ES1938", chip); 1505 "disabling device\n");
1506 snd_card_disconnect(card);
1507 return -EIO;
1508 }
1509
1510 if (request_irq(pci->irq, snd_es1938_interrupt,
1511 IRQF_DISABLED|IRQF_SHARED, "ES1938", chip)) {
1512 printk(KERN_ERR "es1938: unable to grab IRQ %d, "
1513 "disabling device\n", pci->irq);
1514 snd_card_disconnect(card);
1515 return -EIO;
1516 }
1501 chip->irq = pci->irq; 1517 chip->irq = pci->irq;
1502 snd_es1938_chip_init(chip); 1518 snd_es1938_chip_init(chip);
1503 1519
@@ -1556,8 +1572,10 @@ static int snd_es1938_free(struct es1938 *chip)
1556 1572
1557 snd_es1938_free_gameport(chip); 1573 snd_es1938_free_gameport(chip);
1558 1574
1559 if (chip->irq >= 0) 1575 if (chip->irq >= 0) {
1576 synchronize_irq(chip->irq);
1560 free_irq(chip->irq, chip); 1577 free_irq(chip->irq, chip);
1578 }
1561 pci_release_regions(chip->pci); 1579 pci_release_regions(chip->pci);
1562 pci_disable_device(chip->pci); 1580 pci_disable_device(chip->pci);
1563 kfree(chip); 1581 kfree(chip);
@@ -1602,6 +1620,7 @@ static int __devinit snd_es1938_create(struct snd_card *card,
1602 spin_lock_init(&chip->mixer_lock); 1620 spin_lock_init(&chip->mixer_lock);
1603 chip->card = card; 1621 chip->card = card;
1604 chip->pci = pci; 1622 chip->pci = pci;
1623 chip->irq = -1;
1605 if ((err = pci_request_regions(pci, "ESS Solo-1")) < 0) { 1624 if ((err = pci_request_regions(pci, "ESS Solo-1")) < 0) {
1606 kfree(chip); 1625 kfree(chip);
1607 pci_disable_device(pci); 1626 pci_disable_device(pci);
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index b9d723c7e1db..092da53e1464 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -432,46 +432,6 @@ MODULE_PARM_DESC(joystick, "Enable joystick.");
432#define ESM_MODE_PLAY 0 432#define ESM_MODE_PLAY 0
433#define ESM_MODE_CAPTURE 1 433#define ESM_MODE_CAPTURE 1
434 434
435/* acpi states */
436enum {
437 ACPI_D0=0,
438 ACPI_D1,
439 ACPI_D2,
440 ACPI_D3
441};
442
443/* bits in the acpi masks */
444#define ACPI_12MHZ ( 1 << 15)
445#define ACPI_24MHZ ( 1 << 14)
446#define ACPI_978 ( 1 << 13)
447#define ACPI_SPDIF ( 1 << 12)
448#define ACPI_GLUE ( 1 << 11)
449#define ACPI__10 ( 1 << 10) /* reserved */
450#define ACPI_PCIINT ( 1 << 9)
451#define ACPI_HV ( 1 << 8) /* hardware volume */
452#define ACPI_GPIO ( 1 << 7)
453#define ACPI_ASSP ( 1 << 6)
454#define ACPI_SB ( 1 << 5) /* sb emul */
455#define ACPI_FM ( 1 << 4) /* fm emul */
456#define ACPI_RB ( 1 << 3) /* ringbus / aclink */
457#define ACPI_MIDI ( 1 << 2)
458#define ACPI_GP ( 1 << 1) /* game port */
459#define ACPI_WP ( 1 << 0) /* wave processor */
460
461#define ACPI_ALL (0xffff)
462#define ACPI_SLEEP (~(ACPI_SPDIF|ACPI_ASSP|ACPI_SB|ACPI_FM| \
463 ACPI_MIDI|ACPI_GP|ACPI_WP))
464#define ACPI_NONE (ACPI__10)
465
466/* these masks indicate which units we care about at
467 which states */
468static u16 acpi_state_mask[] = {
469 [ACPI_D0] = ACPI_ALL,
470 [ACPI_D1] = ACPI_SLEEP,
471 [ACPI_D2] = ACPI_SLEEP,
472 [ACPI_D3] = ACPI_NONE
473};
474
475 435
476/* APU use in the driver */ 436/* APU use in the driver */
477enum snd_enum_apu_type { 437enum snd_enum_apu_type {
@@ -2160,21 +2120,6 @@ static void snd_es1968_reset(struct es1968 *chip)
2160} 2120}
2161 2121
2162/* 2122/*
2163 * power management
2164 */
2165static void snd_es1968_set_acpi(struct es1968 *chip, int state)
2166{
2167 u16 active_mask = acpi_state_mask[state];
2168
2169 pci_set_power_state(chip->pci, state);
2170 /* make sure the units we care about are on
2171 XXX we might want to do this before state flipping? */
2172 pci_write_config_word(chip->pci, 0x54, ~ active_mask);
2173 pci_write_config_word(chip->pci, 0x56, ~ active_mask);
2174}
2175
2176
2177/*
2178 * initialize maestro chip 2123 * initialize maestro chip
2179 */ 2124 */
2180static void snd_es1968_chip_init(struct es1968 *chip) 2125static void snd_es1968_chip_init(struct es1968 *chip)
@@ -2196,9 +2141,6 @@ static void snd_es1968_chip_init(struct es1968 *chip)
2196 * IRQs. 2141 * IRQs.
2197 */ 2142 */
2198 2143
2199 /* do config work at full power */
2200 snd_es1968_set_acpi(chip, ACPI_D0);
2201
2202 /* Config Reg A */ 2144 /* Config Reg A */
2203 pci_read_config_word(pci, ESM_CONFIG_A, &w); 2145 pci_read_config_word(pci, ESM_CONFIG_A, &w);
2204 2146
@@ -2397,9 +2339,10 @@ static int es1968_suspend(struct pci_dev *pci, pm_message_t state)
2397 snd_pcm_suspend_all(chip->pcm); 2339 snd_pcm_suspend_all(chip->pcm);
2398 snd_ac97_suspend(chip->ac97); 2340 snd_ac97_suspend(chip->ac97);
2399 snd_es1968_bob_stop(chip); 2341 snd_es1968_bob_stop(chip);
2400 snd_es1968_set_acpi(chip, ACPI_D3); 2342
2401 pci_disable_device(pci); 2343 pci_disable_device(pci);
2402 pci_save_state(pci); 2344 pci_save_state(pci);
2345 pci_set_power_state(pci, pci_choose_state(pci, state));
2403 return 0; 2346 return 0;
2404} 2347}
2405 2348
@@ -2413,9 +2356,16 @@ static int es1968_resume(struct pci_dev *pci)
2413 return 0; 2356 return 0;
2414 2357
2415 /* restore all our config */ 2358 /* restore all our config */
2359 pci_set_power_state(pci, PCI_D0);
2416 pci_restore_state(pci); 2360 pci_restore_state(pci);
2417 pci_enable_device(pci); 2361 if (pci_enable_device(pci) < 0) {
2362 printk(KERN_ERR "es1968: pci_enable_device failed, "
2363 "disabling device\n");
2364 snd_card_disconnect(card);
2365 return -EIO;
2366 }
2418 pci_set_master(pci); 2367 pci_set_master(pci);
2368
2419 snd_es1968_chip_init(chip); 2369 snd_es1968_chip_init(chip);
2420 2370
2421 /* need to restore the base pointers.. */ 2371 /* need to restore the base pointers.. */
@@ -2514,7 +2464,6 @@ static int snd_es1968_free(struct es1968 *chip)
2514 if (chip->irq >= 0) 2464 if (chip->irq >= 0)
2515 free_irq(chip->irq, (void *)chip); 2465 free_irq(chip->irq, (void *)chip);
2516 snd_es1968_free_gameport(chip); 2466 snd_es1968_free_gameport(chip);
2517 snd_es1968_set_acpi(chip, ACPI_D3);
2518 chip->master_switch = NULL; 2467 chip->master_switch = NULL;
2519 chip->master_volume = NULL; 2468 chip->master_volume = NULL;
2520 pci_release_regions(chip->pci); 2469 pci_release_regions(chip->pci);
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
index 3ec7d7ee04dd..77e3d5c18302 100644
--- a/sound/pci/fm801.c
+++ b/sound/pci/fm801.c
@@ -1531,9 +1531,9 @@ static int snd_fm801_suspend(struct pci_dev *pci, pm_message_t state)
1531 chip->saved_regs[i] = inw(chip->port + saved_regs[i]); 1531 chip->saved_regs[i] = inw(chip->port + saved_regs[i]);
1532 /* FIXME: tea575x suspend */ 1532 /* FIXME: tea575x suspend */
1533 1533
1534 pci_set_power_state(pci, PCI_D3hot);
1535 pci_disable_device(pci); 1534 pci_disable_device(pci);
1536 pci_save_state(pci); 1535 pci_save_state(pci);
1536 pci_set_power_state(pci, pci_choose_state(pci, state));
1537 return 0; 1537 return 0;
1538} 1538}
1539 1539
@@ -1543,9 +1543,14 @@ static int snd_fm801_resume(struct pci_dev *pci)
1543 struct fm801 *chip = card->private_data; 1543 struct fm801 *chip = card->private_data;
1544 int i; 1544 int i;
1545 1545
1546 pci_restore_state(pci);
1547 pci_enable_device(pci);
1548 pci_set_power_state(pci, PCI_D0); 1546 pci_set_power_state(pci, PCI_D0);
1547 pci_restore_state(pci);
1548 if (pci_enable_device(pci) < 0) {
1549 printk(KERN_ERR "fm801: pci_enable_device failed, "
1550 "disabling device\n");
1551 snd_card_disconnect(card);
1552 return -EIO;
1553 }
1549 pci_set_master(pci); 1554 pci_set_master(pci);
1550 1555
1551 snd_fm801_chip_init(chip, 1); 1556 snd_fm801_chip_init(chip, 1);
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index feeed12920b4..e35cfd326df2 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -55,7 +55,7 @@ static char *model;
55static int position_fix; 55static int position_fix;
56static int probe_mask = -1; 56static int probe_mask = -1;
57static int single_cmd; 57static int single_cmd;
58static int disable_msi; 58static int enable_msi;
59 59
60module_param(index, int, 0444); 60module_param(index, int, 0444);
61MODULE_PARM_DESC(index, "Index value for Intel HD audio interface."); 61MODULE_PARM_DESC(index, "Index value for Intel HD audio interface.");
@@ -69,8 +69,8 @@ module_param(probe_mask, int, 0444);
69MODULE_PARM_DESC(probe_mask, "Bitmask to probe codecs (default = -1)."); 69MODULE_PARM_DESC(probe_mask, "Bitmask to probe codecs (default = -1).");
70module_param(single_cmd, bool, 0444); 70module_param(single_cmd, bool, 0444);
71MODULE_PARM_DESC(single_cmd, "Use single command to communicate with codecs (for debugging only)."); 71MODULE_PARM_DESC(single_cmd, "Use single command to communicate with codecs (for debugging only).");
72module_param(disable_msi, int, 0); 72module_param(enable_msi, int, 0);
73MODULE_PARM_DESC(disable_msi, "Disable Message Signaled Interrupt (MSI)"); 73MODULE_PARM_DESC(enable_msi, "Enable Message Signaled Interrupt (MSI)");
74 74
75 75
76/* just for backward compatibility */ 76/* just for backward compatibility */
@@ -86,6 +86,7 @@ MODULE_SUPPORTED_DEVICE("{{Intel, ICH6},"
86 "{ATI, SB450}," 86 "{ATI, SB450},"
87 "{ATI, SB600}," 87 "{ATI, SB600},"
88 "{ATI, RS600}," 88 "{ATI, RS600},"
89 "{ATI, RS690},"
89 "{VIA, VT8251}," 90 "{VIA, VT8251},"
90 "{VIA, VT8237A}," 91 "{VIA, VT8237A},"
91 "{SiS, SIS966}," 92 "{SiS, SIS966},"
@@ -336,6 +337,7 @@ struct azx {
336 unsigned int initialized :1; 337 unsigned int initialized :1;
337 unsigned int single_cmd :1; 338 unsigned int single_cmd :1;
338 unsigned int polling_mode :1; 339 unsigned int polling_mode :1;
340 unsigned int msi :1;
339}; 341};
340 342
341/* driver types */ 343/* driver types */
@@ -396,6 +398,7 @@ static char *driver_short_names[] __devinitdata = {
396 */ 398 */
397#define upper_32bit(addr) (sizeof(addr) > 4 ? (u32)((addr) >> 32) : (u32)0) 399#define upper_32bit(addr) (sizeof(addr) > 4 ? (u32)((addr) >> 32) : (u32)0)
398 400
401static int azx_acquire_irq(struct azx *chip, int do_disconnect);
399 402
400/* 403/*
401 * Interface for HD codec 404 * Interface for HD codec
@@ -535,6 +538,18 @@ static unsigned int azx_rirb_get_response(struct hda_codec *codec)
535 schedule_timeout_interruptible(1); 538 schedule_timeout_interruptible(1);
536 } while (time_after_eq(timeout, jiffies)); 539 } while (time_after_eq(timeout, jiffies));
537 540
541 if (chip->msi) {
542 snd_printk(KERN_WARNING "hda_intel: No response from codec, "
543 "disabling MSI...\n");
544 free_irq(chip->irq, chip);
545 chip->irq = -1;
546 pci_disable_msi(chip->pci);
547 chip->msi = 0;
548 if (azx_acquire_irq(chip, 1) < 0)
549 return -1;
550 goto again;
551 }
552
538 if (!chip->polling_mode) { 553 if (!chip->polling_mode) {
539 snd_printk(KERN_WARNING "hda_intel: azx_get_response timeout, " 554 snd_printk(KERN_WARNING "hda_intel: azx_get_response timeout, "
540 "switching to polling mode...\n"); 555 "switching to polling mode...\n");
@@ -1363,6 +1378,20 @@ static int __devinit azx_init_stream(struct azx *chip)
1363 return 0; 1378 return 0;
1364} 1379}
1365 1380
1381static int azx_acquire_irq(struct azx *chip, int do_disconnect)
1382{
1383 if (request_irq(chip->pci->irq, azx_interrupt, IRQF_DISABLED|IRQF_SHARED,
1384 "HDA Intel", chip)) {
1385 printk(KERN_ERR "hda-intel: unable to grab IRQ %d, "
1386 "disabling device\n", chip->pci->irq);
1387 if (do_disconnect)
1388 snd_card_disconnect(chip->card);
1389 return -1;
1390 }
1391 chip->irq = chip->pci->irq;
1392 return 0;
1393}
1394
1366 1395
1367#ifdef CONFIG_PM 1396#ifdef CONFIG_PM
1368/* 1397/*
@@ -1379,12 +1408,16 @@ static int azx_suspend(struct pci_dev *pci, pm_message_t state)
1379 snd_pcm_suspend_all(chip->pcm[i]); 1408 snd_pcm_suspend_all(chip->pcm[i]);
1380 snd_hda_suspend(chip->bus, state); 1409 snd_hda_suspend(chip->bus, state);
1381 azx_free_cmd_io(chip); 1410 azx_free_cmd_io(chip);
1382 if (chip->irq >= 0) 1411 if (chip->irq >= 0) {
1412 synchronize_irq(chip->irq);
1383 free_irq(chip->irq, chip); 1413 free_irq(chip->irq, chip);
1384 if (!disable_msi) 1414 chip->irq = -1;
1415 }
1416 if (chip->msi)
1385 pci_disable_msi(chip->pci); 1417 pci_disable_msi(chip->pci);
1386 pci_disable_device(pci); 1418 pci_disable_device(pci);
1387 pci_save_state(pci); 1419 pci_save_state(pci);
1420 pci_set_power_state(pci, pci_choose_state(pci, state));
1388 return 0; 1421 return 0;
1389} 1422}
1390 1423
@@ -1393,15 +1426,20 @@ static int azx_resume(struct pci_dev *pci)
1393 struct snd_card *card = pci_get_drvdata(pci); 1426 struct snd_card *card = pci_get_drvdata(pci);
1394 struct azx *chip = card->private_data; 1427 struct azx *chip = card->private_data;
1395 1428
1429 pci_set_power_state(pci, PCI_D0);
1396 pci_restore_state(pci); 1430 pci_restore_state(pci);
1397 pci_enable_device(pci); 1431 if (pci_enable_device(pci) < 0) {
1398 if (!disable_msi) 1432 printk(KERN_ERR "hda-intel: pci_enable_device failed, "
1399 pci_enable_msi(pci); 1433 "disabling device\n");
1400 /* FIXME: need proper error handling */ 1434 snd_card_disconnect(card);
1401 request_irq(pci->irq, azx_interrupt, IRQF_DISABLED|IRQF_SHARED, 1435 return -EIO;
1402 "HDA Intel", chip); 1436 }
1403 chip->irq = pci->irq;
1404 pci_set_master(pci); 1437 pci_set_master(pci);
1438 if (chip->msi)
1439 if (pci_enable_msi(pci) < 0)
1440 chip->msi = 0;
1441 if (azx_acquire_irq(chip, 1) < 0)
1442 return -EIO;
1405 azx_init_chip(chip); 1443 azx_init_chip(chip);
1406 snd_hda_resume(chip->bus); 1444 snd_hda_resume(chip->bus);
1407 snd_power_change_state(card, SNDRV_CTL_POWER_D0); 1445 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
@@ -1431,15 +1469,14 @@ static int azx_free(struct azx *chip)
1431 /* disable position buffer */ 1469 /* disable position buffer */
1432 azx_writel(chip, DPLBASE, 0); 1470 azx_writel(chip, DPLBASE, 0);
1433 azx_writel(chip, DPUBASE, 0); 1471 azx_writel(chip, DPUBASE, 0);
1434
1435 synchronize_irq(chip->irq);
1436 } 1472 }
1437 1473
1438 if (chip->irq >= 0) { 1474 if (chip->irq >= 0) {
1475 synchronize_irq(chip->irq);
1439 free_irq(chip->irq, (void*)chip); 1476 free_irq(chip->irq, (void*)chip);
1440 if (!disable_msi)
1441 pci_disable_msi(chip->pci);
1442 } 1477 }
1478 if (chip->msi)
1479 pci_disable_msi(chip->pci);
1443 if (chip->remap_addr) 1480 if (chip->remap_addr)
1444 iounmap(chip->remap_addr); 1481 iounmap(chip->remap_addr);
1445 1482
@@ -1494,6 +1531,7 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
1494 chip->pci = pci; 1531 chip->pci = pci;
1495 chip->irq = -1; 1532 chip->irq = -1;
1496 chip->driver_type = driver_type; 1533 chip->driver_type = driver_type;
1534 chip->msi = enable_msi;
1497 1535
1498 chip->position_fix = position_fix; 1536 chip->position_fix = position_fix;
1499 chip->single_cmd = single_cmd; 1537 chip->single_cmd = single_cmd;
@@ -1523,16 +1561,14 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
1523 goto errout; 1561 goto errout;
1524 } 1562 }
1525 1563
1526 if (!disable_msi) 1564 if (chip->msi)
1527 pci_enable_msi(pci); 1565 if (pci_enable_msi(pci) < 0)
1566 chip->msi = 0;
1528 1567
1529 if (request_irq(pci->irq, azx_interrupt, IRQF_DISABLED|IRQF_SHARED, 1568 if (azx_acquire_irq(chip, 0) < 0) {
1530 "HDA Intel", (void*)chip)) {
1531 snd_printk(KERN_ERR SFX "unable to grab IRQ %d\n", pci->irq);
1532 err = -EBUSY; 1569 err = -EBUSY;
1533 goto errout; 1570 goto errout;
1534 } 1571 }
1535 chip->irq = pci->irq;
1536 1572
1537 pci_set_master(pci); 1573 pci_set_master(pci);
1538 synchronize_irq(chip->irq); 1574 synchronize_irq(chip->irq);
@@ -1677,6 +1713,7 @@ static struct pci_device_id azx_ids[] = {
1677 { 0x1002, 0x437b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB450 */ 1713 { 0x1002, 0x437b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB450 */
1678 { 0x1002, 0x4383, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB600 */ 1714 { 0x1002, 0x4383, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB600 */
1679 { 0x1002, 0x793b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS600 HDMI */ 1715 { 0x1002, 0x793b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS600 HDMI */
1716 { 0x1002, 0x7919, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS690 HDMI */
1680 { 0x1106, 0x3288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_VIA }, /* VIA VT8251/VT8237A */ 1717 { 0x1106, 0x3288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_VIA }, /* VIA VT8251/VT8237A */
1681 { 0x1039, 0x7502, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_SIS }, /* SIS966 */ 1718 { 0x1039, 0x7502, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_SIS }, /* SIS966 */
1682 { 0x10b9, 0x5461, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ULI }, /* ULI M5461 */ 1719 { 0x10b9, 0x5461, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ULI }, /* ULI M5461 */
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index 511df07fa2a3..edd22dec8286 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -818,6 +818,8 @@ static struct hda_board_config ad1986a_cfg_tbl[] = {
818 .config = AD1986A_LAPTOP_EAPD }, /* ASUS A6J */ 818 .config = AD1986A_LAPTOP_EAPD }, /* ASUS A6J */
819 { .pci_subvendor = 0x1043, .pci_subdevice = 0x11f7, 819 { .pci_subvendor = 0x1043, .pci_subdevice = 0x11f7,
820 .config = AD1986A_LAPTOP_EAPD }, /* ASUS U5A */ 820 .config = AD1986A_LAPTOP_EAPD }, /* ASUS U5A */
821 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1263,
822 .config = AD1986A_LAPTOP_EAPD }, /* ASUS U5F */
821 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1297, 823 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1297,
822 .config = AD1986A_LAPTOP_EAPD }, /* ASUS Z62F */ 824 .config = AD1986A_LAPTOP_EAPD }, /* ASUS Z62F */
823 { .pci_subvendor = 0x103c, .pci_subdevice = 0x30af, 825 { .pci_subvendor = 0x103c, .pci_subdevice = 0x30af,
diff --git a/sound/pci/hda/patch_atihdmi.c b/sound/pci/hda/patch_atihdmi.c
index a27440ffd1c8..7333f275decd 100644
--- a/sound/pci/hda/patch_atihdmi.c
+++ b/sound/pci/hda/patch_atihdmi.c
@@ -161,5 +161,6 @@ static int patch_atihdmi(struct hda_codec *codec)
161 */ 161 */
162struct hda_codec_preset snd_hda_preset_atihdmi[] = { 162struct hda_codec_preset snd_hda_preset_atihdmi[] = {
163 { .id = 0x1002793c, .name = "ATI RS600 HDMI", .patch = patch_atihdmi }, 163 { .id = 0x1002793c, .name = "ATI RS600 HDMI", .patch = patch_atihdmi },
164 { .id = 0x1002791a, .name = "ATI RS690 HDMI", .patch = patch_atihdmi },
164 {} /* terminator */ 165 {} /* terminator */
165}; 166};
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 84a3eb8aacc2..0d728c6f697c 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -1799,7 +1799,7 @@ static int alc_build_pcms(struct hda_codec *codec)
1799 /* SPDIF for stream index #1 */ 1799 /* SPDIF for stream index #1 */
1800 if (spec->multiout.dig_out_nid || spec->dig_in_nid) { 1800 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1801 codec->num_pcms = 2; 1801 codec->num_pcms = 2;
1802 info++; 1802 info = spec->pcm_rec + 1;
1803 info->name = spec->stream_name_digital; 1803 info->name = spec->stream_name_digital;
1804 if (spec->multiout.dig_out_nid && 1804 if (spec->multiout.dig_out_nid &&
1805 spec->stream_digital_playback) { 1805 spec->stream_digital_playback) {
@@ -1820,7 +1820,7 @@ static int alc_build_pcms(struct hda_codec *codec)
1820 if (spec->num_adc_nids > 1 && spec->stream_analog_capture && 1820 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
1821 spec->adc_nids) { 1821 spec->adc_nids) {
1822 codec->num_pcms = 3; 1822 codec->num_pcms = 3;
1823 info++; 1823 info = spec->pcm_rec + 2;
1824 info->name = spec->stream_name_analog; 1824 info->name = spec->stream_name_analog;
1825 /* No playback stream for second PCM */ 1825 /* No playback stream for second PCM */
1826 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback; 1826 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index f4319b8d4644..9c1bce7afa86 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -1962,6 +1962,12 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
1962 .type = AC97_TUNE_HP_ONLY 1962 .type = AC97_TUNE_HP_ONLY
1963 }, 1963 },
1964 { 1964 {
1965 .subvendor = 0x10f7,
1966 .subdevice = 0x834c,
1967 .name = "Panasonic CF-R4",
1968 .type = AC97_TUNE_HP_ONLY,
1969 },
1970 {
1965 .subvendor = 0x110a, 1971 .subvendor = 0x110a,
1966 .subdevice = 0x0056, 1972 .subdevice = 0x0056,
1967 .name = "Fujitsu-Siemens Scenic", /* AD1981? */ 1973 .name = "Fujitsu-Siemens Scenic", /* AD1981? */
@@ -2476,10 +2482,14 @@ static int intel8x0_suspend(struct pci_dev *pci, pm_message_t state)
2476 if (chip->device_type == DEVICE_INTEL_ICH4) 2482 if (chip->device_type == DEVICE_INTEL_ICH4)
2477 chip->sdm_saved = igetbyte(chip, ICHREG(SDM)); 2483 chip->sdm_saved = igetbyte(chip, ICHREG(SDM));
2478 2484
2479 if (chip->irq >= 0) 2485 if (chip->irq >= 0) {
2486 synchronize_irq(chip->irq);
2480 free_irq(chip->irq, chip); 2487 free_irq(chip->irq, chip);
2488 chip->irq = -1;
2489 }
2481 pci_disable_device(pci); 2490 pci_disable_device(pci);
2482 pci_save_state(pci); 2491 pci_save_state(pci);
2492 pci_set_power_state(pci, pci_choose_state(pci, state));
2483 return 0; 2493 return 0;
2484} 2494}
2485 2495
@@ -2489,11 +2499,22 @@ static int intel8x0_resume(struct pci_dev *pci)
2489 struct intel8x0 *chip = card->private_data; 2499 struct intel8x0 *chip = card->private_data;
2490 int i; 2500 int i;
2491 2501
2502 pci_set_power_state(pci, PCI_D0);
2492 pci_restore_state(pci); 2503 pci_restore_state(pci);
2493 pci_enable_device(pci); 2504 if (pci_enable_device(pci) < 0) {
2505 printk(KERN_ERR "intel8x0: pci_enable_device failed, "
2506 "disabling device\n");
2507 snd_card_disconnect(card);
2508 return -EIO;
2509 }
2494 pci_set_master(pci); 2510 pci_set_master(pci);
2495 request_irq(pci->irq, snd_intel8x0_interrupt, IRQF_DISABLED|IRQF_SHARED, 2511 if (request_irq(pci->irq, snd_intel8x0_interrupt,
2496 card->shortname, chip); 2512 IRQF_DISABLED|IRQF_SHARED, card->shortname, chip)) {
2513 printk(KERN_ERR "intel8x0: unable to grab IRQ %d, "
2514 "disabling device\n", pci->irq);
2515 snd_card_disconnect(card);
2516 return -EIO;
2517 }
2497 chip->irq = pci->irq; 2518 chip->irq = pci->irq;
2498 synchronize_irq(chip->irq); 2519 synchronize_irq(chip->irq);
2499 snd_intel8x0_chip_init(chip, 0); 2520 snd_intel8x0_chip_init(chip, 0);
diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c
index 6703f5cb5569..bd467c501123 100644
--- a/sound/pci/intel8x0m.c
+++ b/sound/pci/intel8x0m.c
@@ -1045,10 +1045,14 @@ static int intel8x0m_suspend(struct pci_dev *pci, pm_message_t state)
1045 for (i = 0; i < chip->pcm_devs; i++) 1045 for (i = 0; i < chip->pcm_devs; i++)
1046 snd_pcm_suspend_all(chip->pcm[i]); 1046 snd_pcm_suspend_all(chip->pcm[i]);
1047 snd_ac97_suspend(chip->ac97); 1047 snd_ac97_suspend(chip->ac97);
1048 if (chip->irq >= 0) 1048 if (chip->irq >= 0) {
1049 synchronize_irq(chip->irq);
1049 free_irq(chip->irq, chip); 1050 free_irq(chip->irq, chip);
1051 chip->irq = -1;
1052 }
1050 pci_disable_device(pci); 1053 pci_disable_device(pci);
1051 pci_save_state(pci); 1054 pci_save_state(pci);
1055 pci_set_power_state(pci, pci_choose_state(pci, state));
1052 return 0; 1056 return 0;
1053} 1057}
1054 1058
@@ -1057,11 +1061,22 @@ static int intel8x0m_resume(struct pci_dev *pci)
1057 struct snd_card *card = pci_get_drvdata(pci); 1061 struct snd_card *card = pci_get_drvdata(pci);
1058 struct intel8x0m *chip = card->private_data; 1062 struct intel8x0m *chip = card->private_data;
1059 1063
1064 pci_set_power_state(pci, PCI_D0);
1060 pci_restore_state(pci); 1065 pci_restore_state(pci);
1061 pci_enable_device(pci); 1066 if (pci_enable_device(pci) < 0) {
1067 printk(KERN_ERR "intel8x0m: pci_enable_device failed, "
1068 "disabling device\n");
1069 snd_card_disconnect(card);
1070 return -EIO;
1071 }
1062 pci_set_master(pci); 1072 pci_set_master(pci);
1063 request_irq(pci->irq, snd_intel8x0_interrupt, IRQF_DISABLED|IRQF_SHARED, 1073 if (request_irq(pci->irq, snd_intel8x0_interrupt,
1064 card->shortname, chip); 1074 IRQF_DISABLED|IRQF_SHARED, card->shortname, chip)) {
1075 printk(KERN_ERR "intel8x0m: unable to grab IRQ %d, "
1076 "disabling device\n", pci->irq);
1077 snd_card_disconnect(card);
1078 return -EIO;
1079 }
1065 chip->irq = pci->irq; 1080 chip->irq = pci->irq;
1066 snd_intel8x0_chip_init(chip, 0); 1081 snd_intel8x0_chip_init(chip, 0);
1067 snd_ac97_resume(chip->ac97); 1082 snd_ac97_resume(chip->ac97);
diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c
index 05605f474a72..8cab342bbaaf 100644
--- a/sound/pci/maestro3.c
+++ b/sound/pci/maestro3.c
@@ -2589,12 +2589,9 @@ static int m3_suspend(struct pci_dev *pci, pm_message_t state)
2589 chip->suspend_mem[index++] = 2589 chip->suspend_mem[index++] =
2590 snd_m3_assp_read(chip, MEMTYPE_INTERNAL_DATA, i); 2590 snd_m3_assp_read(chip, MEMTYPE_INTERNAL_DATA, i);
2591 2591
2592 /* power down apci registers */
2593 snd_m3_outw(chip, 0xffff, 0x54);
2594 snd_m3_outw(chip, 0xffff, 0x56);
2595
2596 pci_disable_device(pci); 2592 pci_disable_device(pci);
2597 pci_save_state(pci); 2593 pci_save_state(pci);
2594 pci_set_power_state(pci, pci_choose_state(pci, state));
2598 return 0; 2595 return 0;
2599} 2596}
2600 2597
@@ -2607,8 +2604,14 @@ static int m3_resume(struct pci_dev *pci)
2607 if (chip->suspend_mem == NULL) 2604 if (chip->suspend_mem == NULL)
2608 return 0; 2605 return 0;
2609 2606
2607 pci_set_power_state(pci, PCI_D0);
2610 pci_restore_state(pci); 2608 pci_restore_state(pci);
2611 pci_enable_device(pci); 2609 if (pci_enable_device(pci) < 0) {
2610 printk(KERN_ERR "maestor3: pci_enable_device failed, "
2611 "disabling device\n");
2612 snd_card_disconnect(card);
2613 return -EIO;
2614 }
2612 pci_set_master(pci); 2615 pci_set_master(pci);
2613 2616
2614 /* first lets just bring everything back. .*/ 2617 /* first lets just bring everything back. .*/
diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c
index b1bbdb9e3b7b..945d21bf187e 100644
--- a/sound/pci/nm256/nm256.c
+++ b/sound/pci/nm256/nm256.c
@@ -1390,6 +1390,7 @@ static int nm256_suspend(struct pci_dev *pci, pm_message_t state)
1390 chip->coeffs_current = 0; 1390 chip->coeffs_current = 0;
1391 pci_disable_device(pci); 1391 pci_disable_device(pci);
1392 pci_save_state(pci); 1392 pci_save_state(pci);
1393 pci_set_power_state(pci, pci_choose_state(pci, state));
1393 return 0; 1394 return 0;
1394} 1395}
1395 1396
@@ -1401,8 +1402,17 @@ static int nm256_resume(struct pci_dev *pci)
1401 1402
1402 /* Perform a full reset on the hardware */ 1403 /* Perform a full reset on the hardware */
1403 chip->in_resume = 1; 1404 chip->in_resume = 1;
1405
1406 pci_set_power_state(pci, PCI_D0);
1404 pci_restore_state(pci); 1407 pci_restore_state(pci);
1405 pci_enable_device(pci); 1408 if (pci_enable_device(pci) < 0) {
1409 printk(KERN_ERR "nm256: pci_enable_device failed, "
1410 "disabling device\n");
1411 snd_card_disconnect(card);
1412 return -EIO;
1413 }
1414 pci_set_master(pci);
1415
1406 snd_nm256_init_chip(chip); 1416 snd_nm256_init_chip(chip);
1407 1417
1408 /* restore ac97 */ 1418 /* restore ac97 */
diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c
index ec4899147e1d..56e0c01123e7 100644
--- a/sound/pci/riptide/riptide.c
+++ b/sound/pci/riptide/riptide.c
@@ -1178,9 +1178,9 @@ static int riptide_suspend(struct pci_dev *pci, pm_message_t state)
1178 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 1178 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
1179 snd_pcm_suspend_all(chip->pcm); 1179 snd_pcm_suspend_all(chip->pcm);
1180 snd_ac97_suspend(chip->ac97); 1180 snd_ac97_suspend(chip->ac97);
1181 pci_set_power_state(pci, PCI_D3hot);
1182 pci_disable_device(pci); 1181 pci_disable_device(pci);
1183 pci_save_state(pci); 1182 pci_save_state(pci);
1183 pci_set_power_state(pci, pci_choose_state(pci, state));
1184 return 0; 1184 return 0;
1185} 1185}
1186 1186
@@ -1189,9 +1189,14 @@ static int riptide_resume(struct pci_dev *pci)
1189 struct snd_card *card = pci_get_drvdata(pci); 1189 struct snd_card *card = pci_get_drvdata(pci);
1190 struct snd_riptide *chip = card->private_data; 1190 struct snd_riptide *chip = card->private_data;
1191 1191
1192 pci_restore_state(pci);
1193 pci_enable_device(pci);
1194 pci_set_power_state(pci, PCI_D0); 1192 pci_set_power_state(pci, PCI_D0);
1193 pci_restore_state(pci);
1194 if (pci_enable_device(pci) < 0) {
1195 printk(KERN_ERR "riptide: pci_enable_device failed, "
1196 "disabling device\n");
1197 snd_card_disconnect(card);
1198 return -EIO;
1199 }
1195 pci_set_master(pci); 1200 pci_set_master(pci);
1196 snd_riptide_initialize(chip); 1201 snd_riptide_initialize(chip);
1197 snd_ac97_resume(chip->ac97); 1202 snd_ac97_resume(chip->ac97);
diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c
index 0d478871808d..1fbc4321122f 100644
--- a/sound/pci/trident/trident_main.c
+++ b/sound/pci/trident/trident_main.c
@@ -3966,15 +3966,9 @@ int snd_trident_suspend(struct pci_dev *pci, pm_message_t state)
3966 snd_ac97_suspend(trident->ac97); 3966 snd_ac97_suspend(trident->ac97);
3967 snd_ac97_suspend(trident->ac97_sec); 3967 snd_ac97_suspend(trident->ac97_sec);
3968 3968
3969 switch (trident->device) {
3970 case TRIDENT_DEVICE_ID_DX:
3971 case TRIDENT_DEVICE_ID_NX:
3972 break; /* TODO */
3973 case TRIDENT_DEVICE_ID_SI7018:
3974 break;
3975 }
3976 pci_disable_device(pci); 3969 pci_disable_device(pci);
3977 pci_save_state(pci); 3970 pci_save_state(pci);
3971 pci_set_power_state(pci, pci_choose_state(pci, state));
3978 return 0; 3972 return 0;
3979} 3973}
3980 3974
@@ -3983,9 +3977,15 @@ int snd_trident_resume(struct pci_dev *pci)
3983 struct snd_card *card = pci_get_drvdata(pci); 3977 struct snd_card *card = pci_get_drvdata(pci);
3984 struct snd_trident *trident = card->private_data; 3978 struct snd_trident *trident = card->private_data;
3985 3979
3980 pci_set_power_state(pci, PCI_D0);
3986 pci_restore_state(pci); 3981 pci_restore_state(pci);
3987 pci_enable_device(pci); 3982 if (pci_enable_device(pci) < 0) {
3988 pci_set_master(pci); /* to be sure */ 3983 printk(KERN_ERR "trident: pci_enable_device failed, "
3984 "disabling device\n");
3985 snd_card_disconnect(card);
3986 return -EIO;
3987 }
3988 pci_set_master(pci);
3989 3989
3990 switch (trident->device) { 3990 switch (trident->device) {
3991 case TRIDENT_DEVICE_ID_DX: 3991 case TRIDENT_DEVICE_ID_DX:
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index e6990e0bbf23..92b0736c0fdb 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -2185,9 +2185,9 @@ static int snd_via82xx_suspend(struct pci_dev *pci, pm_message_t state)
2185 chip->capture_src_saved[1] = inb(chip->port + VIA_REG_CAPTURE_CHANNEL + 0x10); 2185 chip->capture_src_saved[1] = inb(chip->port + VIA_REG_CAPTURE_CHANNEL + 0x10);
2186 } 2186 }
2187 2187
2188 pci_set_power_state(pci, PCI_D3hot);
2189 pci_disable_device(pci); 2188 pci_disable_device(pci);
2190 pci_save_state(pci); 2189 pci_save_state(pci);
2190 pci_set_power_state(pci, pci_choose_state(pci, state));
2191 return 0; 2191 return 0;
2192} 2192}
2193 2193
@@ -2197,9 +2197,15 @@ static int snd_via82xx_resume(struct pci_dev *pci)
2197 struct via82xx *chip = card->private_data; 2197 struct via82xx *chip = card->private_data;
2198 int i; 2198 int i;
2199 2199
2200 pci_restore_state(pci);
2201 pci_enable_device(pci);
2202 pci_set_power_state(pci, PCI_D0); 2200 pci_set_power_state(pci, PCI_D0);
2201 pci_restore_state(pci);
2202 if (pci_enable_device(pci) < 0) {
2203 printk(KERN_ERR "via82xx: pci_enable_device failed, "
2204 "disabling device\n");
2205 snd_card_disconnect(card);
2206 return -EIO;
2207 }
2208 pci_set_master(pci);
2203 2209
2204 snd_via82xx_chip_init(chip); 2210 snd_via82xx_chip_init(chip);
2205 2211
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c
index 5ab1cf3d434b..feb27c966256 100644
--- a/sound/pci/via82xx_modem.c
+++ b/sound/pci/via82xx_modem.c
@@ -1032,9 +1032,10 @@ static int snd_via82xx_suspend(struct pci_dev *pci, pm_message_t state)
1032 snd_via82xx_channel_reset(chip, &chip->devs[i]); 1032 snd_via82xx_channel_reset(chip, &chip->devs[i]);
1033 synchronize_irq(chip->irq); 1033 synchronize_irq(chip->irq);
1034 snd_ac97_suspend(chip->ac97); 1034 snd_ac97_suspend(chip->ac97);
1035 pci_set_power_state(pci, PCI_D3hot); 1035
1036 pci_disable_device(pci); 1036 pci_disable_device(pci);
1037 pci_save_state(pci); 1037 pci_save_state(pci);
1038 pci_set_power_state(pci, pci_choose_state(pci, state));
1038 return 0; 1039 return 0;
1039} 1040}
1040 1041
@@ -1044,9 +1045,14 @@ static int snd_via82xx_resume(struct pci_dev *pci)
1044 struct via82xx_modem *chip = card->private_data; 1045 struct via82xx_modem *chip = card->private_data;
1045 int i; 1046 int i;
1046 1047
1047 pci_restore_state(pci);
1048 pci_enable_device(pci);
1049 pci_set_power_state(pci, PCI_D0); 1048 pci_set_power_state(pci, PCI_D0);
1049 pci_restore_state(pci);
1050 if (pci_enable_device(pci) < 0) {
1051 printk(KERN_ERR "via82xx-modem: pci_enable_device failed, "
1052 "disabling device\n");
1053 snd_card_disconnect(card);
1054 return -EIO;
1055 }
1050 pci_set_master(pci); 1056 pci_set_master(pci);
1051 1057
1052 snd_via82xx_chip_init(chip); 1058 snd_via82xx_chip_init(chip);
diff --git a/sound/pci/vx222/vx222.c b/sound/pci/vx222/vx222.c
index e7cd8acab59a..af49e8aabf55 100644
--- a/sound/pci/vx222/vx222.c
+++ b/sound/pci/vx222/vx222.c
@@ -266,9 +266,9 @@ static int snd_vx222_suspend(struct pci_dev *pci, pm_message_t state)
266 int err; 266 int err;
267 267
268 err = snd_vx_suspend(&vx->core, state); 268 err = snd_vx_suspend(&vx->core, state);
269 pci_set_power_state(pci, PCI_D3hot);
270 pci_disable_device(pci); 269 pci_disable_device(pci);
271 pci_save_state(pci); 270 pci_save_state(pci);
271 pci_set_power_state(pci, pci_choose_state(pci, state));
272 return err; 272 return err;
273} 273}
274 274
@@ -277,9 +277,14 @@ static int snd_vx222_resume(struct pci_dev *pci)
277 struct snd_card *card = pci_get_drvdata(pci); 277 struct snd_card *card = pci_get_drvdata(pci);
278 struct snd_vx222 *vx = card->private_data; 278 struct snd_vx222 *vx = card->private_data;
279 279
280 pci_restore_state(pci);
281 pci_enable_device(pci);
282 pci_set_power_state(pci, PCI_D0); 280 pci_set_power_state(pci, PCI_D0);
281 pci_restore_state(pci);
282 if (pci_enable_device(pci) < 0) {
283 printk(KERN_ERR "vx222: pci_enable_device failed, "
284 "disabling device\n");
285 snd_card_disconnect(card);
286 return -EIO;
287 }
283 pci_set_master(pci); 288 pci_set_master(pci);
284 return snd_vx_resume(&vx->core); 289 return snd_vx_resume(&vx->core);
285} 290}
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
index ebc6da89edf3..a40c1085fd20 100644
--- a/sound/pci/ymfpci/ymfpci_main.c
+++ b/sound/pci/ymfpci/ymfpci_main.c
@@ -2218,6 +2218,7 @@ int snd_ymfpci_suspend(struct pci_dev *pci, pm_message_t state)
2218 snd_ymfpci_disable_dsp(chip); 2218 snd_ymfpci_disable_dsp(chip);
2219 pci_disable_device(pci); 2219 pci_disable_device(pci);
2220 pci_save_state(pci); 2220 pci_save_state(pci);
2221 pci_set_power_state(pci, pci_choose_state(pci, state));
2221 return 0; 2222 return 0;
2222} 2223}
2223 2224
@@ -2227,8 +2228,14 @@ int snd_ymfpci_resume(struct pci_dev *pci)
2227 struct snd_ymfpci *chip = card->private_data; 2228 struct snd_ymfpci *chip = card->private_data;
2228 unsigned int i; 2229 unsigned int i;
2229 2230
2231 pci_set_power_state(pci, PCI_D0);
2230 pci_restore_state(pci); 2232 pci_restore_state(pci);
2231 pci_enable_device(pci); 2233 if (pci_enable_device(pci) < 0) {
2234 printk(KERN_ERR "ymfpci: pci_enable_device failed, "
2235 "disabling device\n");
2236 snd_card_disconnect(card);
2237 return -EIO;
2238 }
2232 pci_set_master(pci); 2239 pci_set_master(pci);
2233 snd_ymfpci_aclink_reset(pci); 2240 snd_ymfpci_aclink_reset(pci);
2234 snd_ymfpci_codec_ready(chip, 0); 2241 snd_ymfpci_codec_ready(chip, 0);